[wp-testers] permalink hooks...

Peter Westwood peter.westwood at ftwr.co.uk
Thu Dec 20 23:21:40 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Dan Milward wrote:
> Say we have a page that is generated automatically by our plugin and
> the URL is site.com/product_page/
>
> Now lets imagine the user turns permalinks off and
> site.com/product_page/ suddenly becomes site.com/?p=16
>
> Currently there is no hook for us to detect permalink changes so we
> can not change the URL in the plugin settings to match things
> accordingly.
>
> At present if a user changes their permalinks they have to refresh
> the page URLs manually by clicking a link in the WP e-Commerce
> settings or their site will break (they will get a 404 error).
>
> It would make much more sense if this whole process was automated by
> a hook that detected permalink changes.
>
ok.

Looking at the current trunk code.

When permalinks are changed a call is made to
$wp_rewrite->set_permalink_structure
If the structure has changed this the new structure is saved in the
options with the following call:
update_option('permalink_structure', $permalink_structure);

update_option has hooks in it that allow you to do something when it
is called in this case.

do_action( "update_option_{$option_name}", $oldvalue, $_newvalue );

This gives you the old and new value.

Hope this helps.

westi

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
iD8DBQFHavkEVPRdzag0AcURAl3NAJ9w/zKY/uQrJ1ACqOYMKDfTfEoCyQCaArY4
nbiJqx2ibxil1qsuVUg3E9g=
=5MxG
-----END PGP SIGNATURE-----



More information about the wp-testers mailing list