[wp-hackers] Best practice way for a plugin to use WP_Rewrite

Dion Hulse (dd32) wordpress at dd32.id.au
Tue Nov 10 08:41:32 UTC 2009


On Tue, 10 Nov 2009 18:02:57 +1100, Matt Jacob <matt at mattjacob.com> wrote:
> And that leaves me with this: what is the best practice method for
> ensuring that my rewrite rules are present at every page load? Is
> there one, or are there just varying degrees of bad methods? Would it
> be feasible to add a "permalink_structure_saved" hook in a future
> release?

Simply add
add_filter('rewrite_rules_array', array($this, 'InsertRewriteRules'));
to your class's 'init' action function

You only call the flush on YOUR activations, but anytime the rules are  
flushed by anything, then your filter is hooked ready to fire.

Just hooking it by itself causes no negative effects.
-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


More information about the wp-hackers mailing list