Changeset 56448
- Timestamp:
- 08/24/2023 03:55:27 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-rewrite.php
r56210 r56448 1491 1491 $this->rules = get_option( 'rewrite_rules' ); 1492 1492 if ( empty( $this->rules ) ) { 1493 $this->matches = 'matches'; 1494 $this->rewrite_rules(); 1495 if ( ! did_action( 'wp_loaded' ) ) { 1496 add_action( 'wp_loaded', array( $this, 'flush_rules' ) ); 1497 return $this->rules; 1498 } 1493 $this->refresh_rewrite_rules(); 1494 } 1495 1496 return $this->rules; 1497 } 1498 1499 /** 1500 * Refreshes the rewrite rules, saving the fresh value to the database. 1501 * If the `wp_loaded` action has not occurred yet, will postpone saving to the database. 1502 * 1503 * @since 6.4.0 1504 */ 1505 private function refresh_rewrite_rules() { 1506 $this->rules = ''; 1507 $this->matches = 'matches'; 1508 1509 $this->rewrite_rules(); 1510 1511 if ( ! did_action( 'wp_loaded' ) ) { 1512 /* 1513 * Is not safe to save the results right now, as the rules may be partial. 1514 * Need to give all rules the chance to register. 1515 */ 1516 add_action( 'wp_loaded', array( $this, 'flush_rules' ) ); 1517 } else { 1499 1518 update_option( 'rewrite_rules', $this->rules ); 1500 1519 } 1501 1502 return $this->rules;1503 1520 } 1504 1521 … … 1865 1882 } 1866 1883 1867 update_option( 'rewrite_rules', '' ); 1868 $this->wp_rewrite_rules(); 1884 $this->refresh_rewrite_rules(); 1869 1885 1870 1886 /**
Note: See TracChangeset
for help on using the changeset viewer.