Does flush_rewrite_rules() remove all rules added by other plugins as well as mine?

This is why you need to add rewrite rules on the init action on every request, as well as on plugin activation.

When your plugin deactivation hook is run, other plugin init hooks have already run, so their rules exist in the global variable that stores them for the life of each request.

Flushing rewrite rules empties the option that stores the rules long-term, and then repopulates it with whatever is in that global variable.

Leave a Comment