Download the PHP package humanmade/hm-rewrite without Composer
On this page you can find all versions of the php package humanmade/hm-rewrite. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download humanmade/hm-rewrite
More information about humanmade/hm-rewrite
Files in humanmade/hm-rewrite
Package hm-rewrite
Short Description HM_Rewrite is a wrapper for the WordPress WP Rewrite system. http://hmn.md/wordpress-rewrite-rules-hm-core-style/
License GPL-2.0-or-later
Informations about the package hm-rewrite
hm-rewrite
HM_Rewrite
and HM_Rewrite_Rule
are wrappers for the WordPress rewrite / wp_query system.
The goal of HM_Rewrite and associated fuctions / classes is to make it very easy to add new routing points with new pages (as in dynamic pages, post_type_archive
etc). It basically wraps a few tasks into a nice API. Everything (almost) you need for setting up a new routing page can be done all at once, relying heavily on PHP Closures. It essentially wraps adding to the rewrite_rules
, adding your template file to template_redirect
, wp_title
hook, body_class
hook, parse_query
hook etc. Also also provides some callbacks for conveniance. Each rewrite rule is an instance of HM_Rewrite_Rule
. Here you add the regex / wp_query
vars and any other options for the "page". For example a callback function to parse_request
to add additional query vars, or a callback * body_class
. There is also a wrapper function for all of this in one call hm_add_rewrite_rule()
. hm_add_rewrite_rule()
is generally the recommended interface, you can interact with the underlying objects for more advanced stuff (and also tacking onto other rewrite rules)Simple use case example:
A more advanced example using more callbacks:
Contribution guidelines
see https://github.com/humanmade/hm-rewrite/blob/master/CONTRIBUTING.md