wp/wp-includes/class-wp-rewrite.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
   273 	 * variables listed in WP_Rewrite::$queryreplace.
   273 	 * variables listed in WP_Rewrite::$queryreplace.
   274 	 *
   274 	 *
   275 	 * Additional tags can be added with add_rewrite_tag().
   275 	 * Additional tags can be added with add_rewrite_tag().
   276 	 *
   276 	 *
   277 	 * @since 1.5.0
   277 	 * @since 1.5.0
   278 	 * @var array
   278 	 * @var string[]
   279 	 */
   279 	 */
   280 	public $rewritecode = array(
   280 	public $rewritecode = array(
   281 		'%year%',
   281 		'%year%',
   282 		'%monthnum%',
   282 		'%monthnum%',
   283 		'%day%',
   283 		'%day%',
   294 	/**
   294 	/**
   295 	 * Regular expressions to be substituted into rewrite rules in place
   295 	 * Regular expressions to be substituted into rewrite rules in place
   296 	 * of rewrite tags, see WP_Rewrite::$rewritecode.
   296 	 * of rewrite tags, see WP_Rewrite::$rewritecode.
   297 	 *
   297 	 *
   298 	 * @since 1.5.0
   298 	 * @since 1.5.0
   299 	 * @var array
   299 	 * @var string[]
   300 	 */
   300 	 */
   301 	public $rewritereplace = array(
   301 	public $rewritereplace = array(
   302 		'([0-9]{4})',
   302 		'([0-9]{4})',
   303 		'([0-9]{1,2})',
   303 		'([0-9]{1,2})',
   304 		'([0-9]{1,2})',
   304 		'([0-9]{1,2})',
   314 
   314 
   315 	/**
   315 	/**
   316 	 * Query variables that rewrite tags map to, see WP_Rewrite::$rewritecode.
   316 	 * Query variables that rewrite tags map to, see WP_Rewrite::$rewritecode.
   317 	 *
   317 	 *
   318 	 * @since 1.5.0
   318 	 * @since 1.5.0
   319 	 * @var array
   319 	 * @var string[]
   320 	 */
   320 	 */
   321 	public $queryreplace = array(
   321 	public $queryreplace = array(
   322 		'year=',
   322 		'year=',
   323 		'monthnum=',
   323 		'monthnum=',
   324 		'day=',
   324 		'day=',
   334 
   334 
   335 	/**
   335 	/**
   336 	 * Supported default feeds.
   336 	 * Supported default feeds.
   337 	 *
   337 	 *
   338 	 * @since 1.5.0
   338 	 * @since 1.5.0
   339 	 * @var array
   339 	 * @var string[]
   340 	 */
   340 	 */
   341 	public $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
   341 	public $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
   342 
   342 
   343 	/**
   343 	/**
   344 	 * Determines whether permalinks are being used.
   344 	 * Determines whether permalinks are being used.
  1171 					$match = $match . '(?:/([0-9]+))?/?$';
  1171 					$match = $match . '(?:/([0-9]+))?/?$';
  1172 					$query = $index . '?' . $query . '&page=' . $this->preg_index( $num_toks + 1 );
  1172 					$query = $index . '?' . $query . '&page=' . $this->preg_index( $num_toks + 1 );
  1173 
  1173 
  1174 					// Not matching a permalink so this is a lot simpler.
  1174 					// Not matching a permalink so this is a lot simpler.
  1175 				} else {
  1175 				} else {
  1176 					// Close the match and finalise the query.
  1176 					// Close the match and finalize the query.
  1177 					$match .= '?$';
  1177 					$match .= '?$';
  1178 					$query  = $index . '?' . $query;
  1178 					$query  = $index . '?' . $query;
  1179 				}
  1179 				}
  1180 
  1180 
  1181 				/*
  1181 				/*
  1313 		$date_rewrite = $this->generate_rewrite_rules( $this->get_date_permastruct(), EP_DATE );
  1313 		$date_rewrite = $this->generate_rewrite_rules( $this->get_date_permastruct(), EP_DATE );
  1314 
  1314 
  1315 		/**
  1315 		/**
  1316 		 * Filters rewrite rules used for date archives.
  1316 		 * Filters rewrite rules used for date archives.
  1317 		 *
  1317 		 *
  1318 		 * Likely date archives would include /yyyy/, /yyyy/mm/, and /yyyy/mm/dd/.
  1318 		 * Likely date archives would include `/yyyy/`, `/yyyy/mm/`, and `/yyyy/mm/dd/`.
  1319 		 *
  1319 		 *
  1320 		 * @since 1.5.0
  1320 		 * @since 1.5.0
  1321 		 *
  1321 		 *
  1322 		 * @param string[] $date_rewrite Array of rewrite rules for date archives, keyed by their regex pattern.
  1322 		 * @param string[] $date_rewrite Array of rewrite rules for date archives, keyed by their regex pattern.
  1323 		 */
  1323 		 */
  1328 
  1328 
  1329 		/**
  1329 		/**
  1330 		 * Filters rewrite rules used for root-level archives.
  1330 		 * Filters rewrite rules used for root-level archives.
  1331 		 *
  1331 		 *
  1332 		 * Likely root-level archives would include pagination rules for the homepage
  1332 		 * Likely root-level archives would include pagination rules for the homepage
  1333 		 * as well as site-wide post feeds (e.g. /feed/, and /feed/atom/).
  1333 		 * as well as site-wide post feeds (e.g. `/feed/`, and `/feed/atom/`).
  1334 		 *
  1334 		 *
  1335 		 * @since 1.5.0
  1335 		 * @since 1.5.0
  1336 		 *
  1336 		 *
  1337 		 * @param string[] $root_rewrite Array of root-level rewrite rules, keyed by their regex pattern.
  1337 		 * @param string[] $root_rewrite Array of root-level rewrite rules, keyed by their regex pattern.
  1338 		 */
  1338 		 */
  1342 		$comments_rewrite = $this->generate_rewrite_rules( $this->root . $this->comments_base, EP_COMMENTS, false, true, true, false );
  1342 		$comments_rewrite = $this->generate_rewrite_rules( $this->root . $this->comments_base, EP_COMMENTS, false, true, true, false );
  1343 
  1343 
  1344 		/**
  1344 		/**
  1345 		 * Filters rewrite rules used for comment feed archives.
  1345 		 * Filters rewrite rules used for comment feed archives.
  1346 		 *
  1346 		 *
  1347 		 * Likely comments feed archives include /comments/feed/, and /comments/feed/atom/.
  1347 		 * Likely comments feed archives include `/comments/feed/` and `/comments/feed/atom/`.
  1348 		 *
  1348 		 *
  1349 		 * @since 1.5.0
  1349 		 * @since 1.5.0
  1350 		 *
  1350 		 *
  1351 		 * @param string[] $comments_rewrite Array of rewrite rules for the site-wide comments feeds, keyed by their regex pattern.
  1351 		 * @param string[] $comments_rewrite Array of rewrite rules for the site-wide comments feeds, keyed by their regex pattern.
  1352 		 */
  1352 		 */
  1357 		$search_rewrite   = $this->generate_rewrite_rules( $search_structure, EP_SEARCH );
  1357 		$search_rewrite   = $this->generate_rewrite_rules( $search_structure, EP_SEARCH );
  1358 
  1358 
  1359 		/**
  1359 		/**
  1360 		 * Filters rewrite rules used for search archives.
  1360 		 * Filters rewrite rules used for search archives.
  1361 		 *
  1361 		 *
  1362 		 * Likely search-related archives include /search/search+query/ as well as
  1362 		 * Likely search-related archives include `/search/search+query/` as well as
  1363 		 * pagination and feed paths for a search.
  1363 		 * pagination and feed paths for a search.
  1364 		 *
  1364 		 *
  1365 		 * @since 1.5.0
  1365 		 * @since 1.5.0
  1366 		 *
  1366 		 *
  1367 		 * @param string[] $search_rewrite Array of rewrite rules for search queries, keyed by their regex pattern.
  1367 		 * @param string[] $search_rewrite Array of rewrite rules for search queries, keyed by their regex pattern.
  1372 		$author_rewrite = $this->generate_rewrite_rules( $this->get_author_permastruct(), EP_AUTHORS );
  1372 		$author_rewrite = $this->generate_rewrite_rules( $this->get_author_permastruct(), EP_AUTHORS );
  1373 
  1373 
  1374 		/**
  1374 		/**
  1375 		 * Filters rewrite rules used for author archives.
  1375 		 * Filters rewrite rules used for author archives.
  1376 		 *
  1376 		 *
  1377 		 * Likely author archives would include /author/author-name/, as well as
  1377 		 * Likely author archives would include `/author/author-name/`, as well as
  1378 		 * pagination and feed paths for author archives.
  1378 		 * pagination and feed paths for author archives.
  1379 		 *
  1379 		 *
  1380 		 * @since 1.5.0
  1380 		 * @since 1.5.0
  1381 		 *
  1381 		 *
  1382 		 * @param string[] $author_rewrite Array of rewrite rules for author archives, keyed by their regex pattern.
  1382 		 * @param string[] $author_rewrite Array of rewrite rules for author archives, keyed by their regex pattern.
  1409 
  1409 
  1410 			/**
  1410 			/**
  1411 			 * Filters rewrite rules used for individual permastructs.
  1411 			 * Filters rewrite rules used for individual permastructs.
  1412 			 *
  1412 			 *
  1413 			 * The dynamic portion of the hook name, `$permastructname`, refers
  1413 			 * The dynamic portion of the hook name, `$permastructname`, refers
  1414 			 * to the name of the registered permastruct, e.g. 'post_tag' (tags),
  1414 			 * to the name of the registered permastruct.
  1415 			 * 'category' (categories), etc.
  1415 			 *
       
  1416 			 * Possible hook names include:
       
  1417 			 *
       
  1418 			 *  - `category_rewrite_rules`
       
  1419 			 *  - `post_format_rewrite_rules`
       
  1420 			 *  - `post_tag_rewrite_rules`
  1416 			 *
  1421 			 *
  1417 			 * @since 3.1.0
  1422 			 * @since 3.1.0
  1418 			 *
  1423 			 *
  1419 			 * @param string[] $rules Array of rewrite rules generated for the current permastruct, keyed by their regex pattern.
  1424 			 * @param string[] $rules Array of rewrite rules generated for the current permastruct, keyed by their regex pattern.
  1420 			 */
  1425 			 */
  1446 		/**
  1451 		/**
  1447 		 * Fires after the rewrite rules are generated.
  1452 		 * Fires after the rewrite rules are generated.
  1448 		 *
  1453 		 *
  1449 		 * @since 1.5.0
  1454 		 * @since 1.5.0
  1450 		 *
  1455 		 *
  1451 		 * @param WP_Rewrite $this Current WP_Rewrite instance (passed by reference).
  1456 		 * @param WP_Rewrite $wp_rewrite Current WP_Rewrite instance (passed by reference).
  1452 		 */
  1457 		 */
  1453 		do_action_ref_array( 'generate_rewrite_rules', array( &$this ) );
  1458 		do_action_ref_array( 'generate_rewrite_rules', array( &$this ) );
  1454 
  1459 
  1455 		/**
  1460 		/**
  1456 		 * Filters the full set of generated rewrite rules.
  1461 		 * Filters the full set of generated rewrite rules.