[wp-trac] [WordPress Trac] #29118: Registering rewrite rules is hard, so let's introduce remove_rewrite_rule.

WordPress Trac noreply at wordpress.org
Tue Aug 5 15:22:58 UTC 2014


#29118: Registering rewrite rules is hard, so let's introduce remove_rewrite_rule.
---------------------------+------------------------------
 Reporter:  ericlewis      |       Owner:
     Type:  enhancement    |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Rewrite Rules  |     Version:
 Severity:  normal         |  Resolution:
 Keywords:  has-patch      |     Focuses:
---------------------------+------------------------------
Changes (by ericlewis):

 * keywords:   => has-patch


Comment:

 In 29118.diff, introduce `remove_rewrite_rule()`, which is a facade for
 the `remove_rule()` method on the `WP_Rewrite` class.

 This allows for a more intuitive API, and comprehensible boilerplate for
 plugin developers:

 {{{
 #!php
 function add_some_rewrite_rules() {
         add_rewrite_rule( ... );
 }
 add_action( 'init', 'add_some_rewrite_rules' );

 function remove_some_rewrite_rules() {
         remove_rewrite_rule( ... );
 }

 register_activation_hook( __FILE__, function() {
         add_some_rewrite_rules();
         flush_rewrite_rules();
 } );

 register_deactivation_hook( __FILE__, function() {
         remove_some_rewrite_rules();
         flush_rewrite_rules();
 } );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29118#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list