1559
1567
$registration_pages['.*wp-register.php$'] = $this->index . '?register=true'; // Deprecated
1569
// Post rewrite rules.
1562
1570
$post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK );
1563
$post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
1573
* Filter rewrite rules used for "post" archives.
1577
* @param array $post_rewrite The rewrite rules for posts.
1579
$post_rewrite = apply_filters( 'post_rewrite_rules', $post_rewrite );
1581
// Date rewrite rules.
1566
1582
$date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE);
1567
$date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);
1585
* Filter rewrite rules used for date archives.
1587
* Likely date archives would include /yyyy/, /yyyy/mm/, and /yyyy/mm/dd/.
1591
* @param array $date_rewrite The rewrite rules for date archives.
1593
$date_rewrite = apply_filters( 'date_rewrite_rules', $date_rewrite );
1595
// Root-level rewrite rules.
1570
1596
$root_rewrite = $this->generate_rewrite_rules($this->root . '/', EP_ROOT);
1571
$root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
1599
* Filter rewrite rules used for root-level archives.
1601
* Likely root-level archives would include pagination rules for the homepage
1602
* as well as site-wide post feeds (e.g. /feed/, and /feed/atom/).
1606
* @param array $root_rewrite The root-level rewrite rules.
1608
$root_rewrite = apply_filters( 'root_rewrite_rules', $root_rewrite );
1610
// Comments rewrite rules.
1574
1611
$comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, EP_COMMENTS, false, true, true, false);
1575
$comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
1614
* Filter rewrite rules used for comment feed archives.
1616
* Likely comments feed archives include /comments/feed/, and /comments/feed/atom/.
1620
* @param array $comments_rewrite The rewrite rules for the site-wide comments feeds.
1622
$comments_rewrite = apply_filters( 'comments_rewrite_rules', $comments_rewrite );
1624
// Search rewrite rules.
1578
1625
$search_structure = $this->get_search_permastruct();
1579
1626
$search_rewrite = $this->generate_rewrite_rules($search_structure, EP_SEARCH);
1580
$search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
1629
* Filter rewrite rules used for search archives.
1631
* Likely search-related archives include /search/search+query/ as well as
1632
* pagination and feed paths for a search.
1636
* @param array $search_rewrite The rewrite rules for search queries.
1638
$search_rewrite = apply_filters( 'search_rewrite_rules', $search_rewrite );
1640
// Author rewrite rules.
1583
1641
$author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS);
1584
$author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
1644
* Filter rewrite rules used for author archives.
1646
* Likely author archives would include /author/author-name/, as well as
1647
* pagination and feed paths for author archives.
1651
* @param array $author_rewrite The rewrite rules for author archives.
1653
$author_rewrite = apply_filters( 'author_rewrite_rules', $author_rewrite );
1655
// Pages rewrite rules.
1587
1656
$page_rewrite = $this->page_rewrite_rules();
1588
$page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
1590
// Extra permastructs
1659
* Filter rewrite rules used for "page" post type archives.
1663
* @param array $page_rewrite The rewrite rules for the "page" post type.
1665
$page_rewrite = apply_filters( 'page_rewrite_rules', $page_rewrite );
1667
// Extra permastructs.
1591
1668
foreach ( $this->extra_permastructs as $permastructname => $struct ) {
1592
1669
if ( is_array( $struct ) ) {
1593
1670
if ( count( $struct ) == 2 )
1598
1675
$rules = $this->generate_rewrite_rules( $struct );
1601
$rules = apply_filters($permastructname . '_rewrite_rules', $rules);
1602
if ( 'post_tag' == $permastructname )
1603
$rules = apply_filters('tag_rewrite_rules', $rules);
1679
* Filter rewrite rules used for individual permastructs.
1681
* The dynamic portion of the hook name, $permastructname, refers
1682
* to the name of the registered permastruct, e.g. 'post_tag' (tags),
1683
* 'category' (categories), etc.
1687
* @param array $rules The rewrite rules generated for the current permastruct.
1689
$rules = apply_filters( $permastructname . '_rewrite_rules', $rules );
1690
if ( 'post_tag' == $permastructname ) {
1693
* Filter rewrite rules used specifically for Tags.
1696
* @deprecated 3.1.0 Use 'post_tag_rewrite_rules' instead
1698
* @param array $rules The rewrite rules generated for tags.
1700
$rules = apply_filters( 'tag_rewrite_rules', $rules );
1605
1703
$this->extra_rules_top = array_merge($this->extra_rules_top, $rules);
1612
1710
$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
1614
do_action_ref_array('generate_rewrite_rules', array(&$this));
1615
$this->rules = apply_filters('rewrite_rules_array', $this->rules);
1713
* Fires after the rewrite rules are generated.
1717
* @param WP_Rewrite $this Current WP_Rewrite instance, passed by reference.
1719
do_action_ref_array( 'generate_rewrite_rules', array( &$this ) );
1722
* Filter the full set of generated rewrite rules.
1726
* @param array $this->rules The compiled array of rewrite rules.
1728
$this->rules = apply_filters( 'rewrite_rules_array', $this->rules );
1617
1730
return $this->rules;
1721
1834
$rules .= "</IfModule>\n";
1723
$rules = apply_filters('mod_rewrite_rules', $rules);
1724
$rules = apply_filters('rewrite_rules', $rules); // Deprecated
1838
* Filter the list of rewrite rules formatted for output to an .htaccess file.
1842
* @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
1844
$rules = apply_filters( 'mod_rewrite_rules', $rules );
1847
* Filter the list of rewrite rules formatted for output to an .htaccess file.
1850
* @deprecated 1.5.0 Use the mod_rewrite_rules filter instead.
1852
* @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
1854
$rules = apply_filters( 'rewrite_rules', $rules ); // Deprecated
1819
1956
* Add an endpoint, like /trackback/.
1821
* See {@link add_rewrite_endpoint()} for full documentation.
1823
* @see add_rewrite_endpoint()
1959
* @since 3.9.0 $query_var parameter added.
1825
1960
* @access public
1962
* @see add_rewrite_endpoint() for full documentation.
1826
1963
* @uses WP::add_query_var()
1828
* @param string $name Name of the endpoint.
1829
* @param int $places Endpoint mask describing the places the endpoint should be added.
1965
* @param string $name Name of the endpoint.
1966
* @param int $places Endpoint mask describing the places the endpoint should be added.
1967
* @param string $query_var Name of the corresponding query variable. Default is value of $name.
1831
function add_endpoint($name, $places) {
1969
function add_endpoint( $name, $places, $query_var = null ) {
1833
$this->endpoints[] = array ( $places, $name );
1834
$wp->add_query_var($name);
1971
if ( null === $query_var ) {
1974
$this->endpoints[] = array( $places, $name, $query_var );
1975
$wp->add_query_var( $query_var );