Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using this function to add a custom end point to the WordPress urls

add_rewrite_endpoint('print', EP_ALL);

When the plug-in gets deactivated, I run this function

flush_rewrite_rules();

This flush the rewrite rules, and disable the 'print' end point. Fine. But I'm thinking of other plug-ins. What if other plug-ins have registered some rewrite rules. Will they be flushed too?

If so, how can I preserve them as this will run their rewrite rules. And the same being for my plug-in. Do you have to re-register the rules everytime WordPress is called?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

What flush_rewrite_rules(); does is call $wp_rewrite->flush_rules(); (Also called when updating permalinks). All plugins rewrite rules are regenerated then, so you dont need to worry about other plugins rules being "missing".

Also is not a good idea to call this function (flush_rewrite_rule) on hooks that run each time wordpress is loaded, and is enough to call add_rewrite_endpoint or add_rewrite_rule on activation or deactivation hooks.

share|improve this answer
3  
It was my understanding that you should added the rewrite rule on each load, but only flush on activation/deactivation. –  chrisguitarguy Sep 28 '11 at 14:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.