Make WordPress Core

Changeset 31104


Ignore:
Timestamp:
01/08/2015 09:59:57 PM (10 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rewrite.php

    r31090 r31104  
    20372037     */
    20382038    public function flush_rules($hard = true) {
     2039        // Prevent this action from running before everyone has registered their rewrites
     2040        if ( ! did_action( 'wp_loaded' ) ) {
     2041            add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
     2042            return;
     2043        }
     2044
    20392045        delete_option('rewrite_rules');
    20402046        $this->wp_rewrite_rules();
Note: See TracChangeset for help on using the changeset viewer.