If WP_Rewrite::flush_rules() is called on 'init' or earlier, wait until 'wp_loaded' before actually flushing the rules, to make sure all the rules registered on 'init' are included.

props joostdevalk.
see #30501.
Built from https://develop.svn.wordpress.org/trunk@31104


git-svn-id: http://core.svn.wordpress.org/trunk@31085 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2015-01-08 22:00:23 +00:00
parent 6e29458407
commit 91297b7a30
2 changed files with 7 additions and 1 deletions

View File

@ -2036,6 +2036,12 @@ class WP_Rewrite {
* @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard).
*/
public function flush_rules($hard = true) {
// Prevent this action from running before everyone has registered their rewrites
if ( ! did_action( 'wp_loaded' ) ) {
add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
return;
}
delete_option('rewrite_rules');
$this->wp_rewrite_rules();
/**

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-alpha-31103';
$wp_version = '4.2-alpha-31104';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.