[wp-hackers] update_option problem

aesqe aesqe at skyphe.org
Thu May 14 13:10:49 GMT 2009


@Mike:
It's for my Decategorizer plugin, sorry I didn't explain any further 
what it was for. $wp_rewrite->flush_rules() doesn't do the trick, but it 
seems that $wp_rewrite->init() does.

@westi:
Thanks for the explanation, and also thank you very much for the addition :)


On 14.5.2009 8:39, Peter Westwood wrote:
>
> On 14 May 2009, at 00:59, aesqe wrote:
>
>> Hi all :)
>>
>> I've been trying to figure out why the following doesn't work:
>>
>> <?php
>> /*
>> Plugin Name: permalink check
>> Plugin URI: ...
>> Description: ...
>> Author: ...
>> Version: 1.0
>> Author URI: ...
>> */
>>
>> function permalinkage()
>> {
>> global $wp_rewrite;
>> echo $wp_rewrite->get_category_permastruct();
>> }
>> add_action('update_option_permalink_structure', 'permalinkage');
>> ?>
>>
>> Permalink structure gets updated, but get_category_permastruct()
>> returns previous value each time.
>>
>> Is this related to option caching, maybe?
>>
>
> No.
>
> The reason here is that your are asking for the information before it
> has been updated.
>
> The process goes as follows in WP_Rewrite:
>
> function set_permalink_structure($permalink_structure) {
> if ($permalink_structure != $this->permalink_structure) {
> update_option('permalink_structure', $permalink_structure);
> $this->init();
> }
> }
>
> The WP_Rewrite::init function is what reconfigures the rewrite engine
> with the new permalink structure and so until that has been called you
> will get the old configuration from the $wp_rewrite object.
>
> At the moment there is not a hook that I can see that will let you act
> on this option change after it has been completed.
>
>  From WordPress 2.8 you will be able to use the new
> 'permalink_structure_changed' action which I have added to
> set_permalink_structure in [11325].
>
> Cheers
>
> westi
>
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.325 / Virus Database: 270.12.27/2112 - Release Date: 05/13/09 07:04:00
>

-- 
-._______________KAWAII!_______________.-
Skyphe.org : It'll all make sense one day
http://skyphe.org .:. http://breedart.org


More information about the wp-hackers mailing list