When shifting WP_Rewrite::flush_rules()
to a later action if it was called too early, make sure to do a hard flush if requested.
props Denis-de-Bernardy, mordauk for initial patch. fixes #30501. git-svn-id: https://develop.svn.wordpress.org/trunk@31964 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2418711c47
commit
e4a9e49b6d
@ -2044,13 +2044,21 @@ class WP_Rewrite {
|
|||||||
* @access public
|
* @access public
|
||||||
* @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard).
|
* @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) {
|
public function flush_rules( $hard = true ) {
|
||||||
|
static $do_hard_later;
|
||||||
|
|
||||||
// Prevent this action from running before everyone has registered their rewrites
|
// Prevent this action from running before everyone has registered their rewrites
|
||||||
if ( ! did_action( 'wp_loaded' ) ) {
|
if ( ! did_action( 'wp_loaded' ) ) {
|
||||||
add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
|
add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
|
||||||
|
$do_hard_later = ( isset( $do_hard_later ) ) ? $do_hard_later || $hard : $hard;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( isset( $do_hard_later ) ) {
|
||||||
|
$hard = $do_hard_later;
|
||||||
|
unset( $do_hard_later );
|
||||||
|
}
|
||||||
|
|
||||||
delete_option('rewrite_rules');
|
delete_option('rewrite_rules');
|
||||||
$this->wp_rewrite_rules();
|
$this->wp_rewrite_rules();
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user