Make sure rewrite rules are not written until wp_loaded
has fired
If a plugin attempts to change the rewrite rules to early, other plugins may have their rules inadvertently discarded. Additionally, some function such as `url_to_post_id` cause a rewrite rule lookup that could cause this accidental flushing. This forces the flushing to only occur once `wp_loaded` has been fired. Fixes #37892. Props Chouby. git-svn-id: https://develop.svn.wordpress.org/trunk@38751 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
981ff63724
commit
bb8d792d37
@ -1475,6 +1475,10 @@ class WP_Rewrite {
|
||||
if ( empty($this->rules) ) {
|
||||
$this->matches = 'matches';
|
||||
$this->rewrite_rules();
|
||||
if ( ! did_action( 'wp_loaded' ) ) {
|
||||
add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
|
||||
return $this->rules;
|
||||
}
|
||||
update_option('rewrite_rules', $this->rules);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user