wp/wp-includes/class-wp-rewrite.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
  1285 		$robots_rewrite = ( empty( $home_path['path'] ) || '/' === $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array();
  1285 		$robots_rewrite = ( empty( $home_path['path'] ) || '/' === $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array();
  1286 
  1286 
  1287 		// favicon.ico -- only if installed at the root.
  1287 		// favicon.ico -- only if installed at the root.
  1288 		$favicon_rewrite = ( empty( $home_path['path'] ) || '/' === $home_path['path'] ) ? array( 'favicon\.ico$' => $this->index . '?favicon=1' ) : array();
  1288 		$favicon_rewrite = ( empty( $home_path['path'] ) || '/' === $home_path['path'] ) ? array( 'favicon\.ico$' => $this->index . '?favicon=1' ) : array();
  1289 
  1289 
       
  1290 		// sitemap.xml -- only if installed at the root.
       
  1291 		$sitemap_rewrite = ( empty( $home_path['path'] ) || '/' === $home_path['path'] ) ? array( 'sitemap\.xml' => $this->index . '??sitemap=index' ) : array();
       
  1292 
  1290 		// Old feed and service files.
  1293 		// Old feed and service files.
  1291 		$deprecated_files = array(
  1294 		$deprecated_files = array(
  1292 			'.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index . '?feed=old',
  1295 			'.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index . '?feed=old',
  1293 			'.*wp-app\.php(/.*)?$' => $this->index . '?error=403',
  1296 			'.*wp-app\.php(/.*)?$' => $this->index . '?error=403',
  1294 		);
  1297 		);
  1447 			$this->extra_rules_top = array_merge( $this->extra_rules_top, $rules );
  1450 			$this->extra_rules_top = array_merge( $this->extra_rules_top, $rules );
  1448 		}
  1451 		}
  1449 
  1452 
  1450 		// Put them together.
  1453 		// Put them together.
  1451 		if ( $this->use_verbose_page_rules ) {
  1454 		if ( $this->use_verbose_page_rules ) {
  1452 			$this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $favicon_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules );
  1455 			$this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $favicon_rewrite, $sitemap_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules );
  1453 		} else {
  1456 		} else {
  1454 			$this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $favicon_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules );
  1457 			$this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $favicon_rewrite, $sitemap_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules );
  1455 		}
  1458 		}
  1456 
  1459 
  1457 		/**
  1460 		/**
  1458 		 * Fires after the rewrite rules are generated.
  1461 		 * Fires after the rewrite rules are generated.
  1459 		 *
  1462 		 *
  1496 		return $this->rules;
  1499 		return $this->rules;
  1497 	}
  1500 	}
  1498 
  1501 
  1499 	/**
  1502 	/**
  1500 	 * Refreshes the rewrite rules, saving the fresh value to the database.
  1503 	 * 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.
  1504 	 *
       
  1505 	 * If the {@see 'wp_loaded'} action has not occurred yet, will postpone saving to the database.
  1502 	 *
  1506 	 *
  1503 	 * @since 6.4.0
  1507 	 * @since 6.4.0
  1504 	 */
  1508 	 */
  1505 	private function refresh_rewrite_rules() {
  1509 	private function refresh_rewrite_rules() {
  1506 		$this->rules   = '';
  1510 		$this->rules   = '';
  1508 
  1512 
  1509 		$this->rewrite_rules();
  1513 		$this->rewrite_rules();
  1510 
  1514 
  1511 		if ( ! did_action( 'wp_loaded' ) ) {
  1515 		if ( ! did_action( 'wp_loaded' ) ) {
  1512 			/*
  1516 			/*
  1513 			 * Is not safe to save the results right now, as the rules may be partial.
  1517 			 * It 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.
  1518 			 * Need to give all rules the chance to register.
  1515 			 */
  1519 			 */
  1516 			add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
  1520 			add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
  1517 		} else {
  1521 		} else {
  1518 			update_option( 'rewrite_rules', $this->rules );
  1522 			update_option( 'rewrite_rules', $this->rules );