[wp-trac] [WordPress Trac] #42563: Flushing rewrite rules on plugin deactivation does nothing

WordPress Trac noreply at wordpress.org
Tue Dec 12 01:18:57 UTC 2017


#42563: Flushing rewrite rules on plugin deactivation does nothing
---------------------------+----------------------
 Reporter:  brainfork      |       Owner:
     Type:  defect (bug)   |      Status:  closed
 Priority:  normal         |   Milestone:
Component:  Rewrite Rules  |     Version:  4.8.3
 Severity:  normal         |  Resolution:  invalid
 Keywords:                 |     Focuses:
---------------------------+----------------------
Changes (by dd32):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 Thanks for mentioning that @ptbello - I've fixed that entry to fix that.

 The correct method here is to call `unregister_post_type()` (and/or
 `unregister_taxonomy()`) in the deactivation handler prior to calling
 `flush_rewrite_rules()`.

 For example:
 {{{
 function xxx_plugin_deactivate() {
       unregister_post_type( 'aaaaa' );
       unregister_taxonomy( 'bbbbb' );
       flush_rewrite_rules();
 }
 }}}

 I'm closing this as `invalid` as it's working as expected - if you've
 called `register_post_type()` on that pageload, calling
 `flush_rewrite_rules()` later in that page will deliberately include the
 post type rules as it doesn't have any way of detecting that it's
 happening during deactivation of a plugin that's registered a rule.

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


More information about the wp-trac mailing list