Ticket #26095: 26095.diff
File 26095.diff, 9.1 KB (added by , 10 years ago) |
---|
-
src/wp-includes/rewrite.php
288 288 function url_to_postid($url) { 289 289 global $wp_rewrite; 290 290 291 $url = apply_filters('url_to_postid', $url); 291 /** 292 * Filter the URL that will be examined to determine a post ID. 293 * 294 * @since 2.2.0 295 * 296 * @param string $url The URL which will be searched. 297 */ 298 $url = apply_filters( 'url_to_postid', $url ); 292 299 293 300 // First, check to see if there is a 'p=N' or 'page_id=N' to match against 294 301 if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) ) { … … 1558 1565 } 1559 1566 $registration_pages['.*wp-register.php$'] = $this->index . '?register=true'; // Deprecated 1560 1567 1561 // Post 1568 // Post rewrite rules. 1562 1569 $post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK ); 1563 $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);1564 1570 1565 // Date 1571 /** 1572 * Filter rewrite rules used for "post" post type archives. 1573 * 1574 * @since 1.5.0 1575 * 1576 * @param array $post_rewrite The rewrite rules for the "post" post type. 1577 */ 1578 $post_rewrite = apply_filters( 'post_rewrite_rules', $post_rewrite ); 1579 1580 // Date rewrite rules. 1566 1581 $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE); 1567 $date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);1568 1582 1569 // Root 1583 /** 1584 * Filter rewrite rules used for date archives. 1585 * 1586 * Likely date archives would include /yyyy/, /yyyy/mm/, and /yyyy/mm/dd/. 1587 * 1588 * @since 1.5.0 1589 * 1590 * @param array $date_rewrite The rewrite rules for date archives. 1591 */ 1592 $date_rewrite = apply_filters( 'date_rewrite_rules', $date_rewrite ); 1593 1594 // Root-level rewrite rules. 1570 1595 $root_rewrite = $this->generate_rewrite_rules($this->root . '/', EP_ROOT); 1571 $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);1572 1596 1573 // Comments 1597 /** 1598 * Filter rewrite rules used for root-level archives. 1599 * 1600 * Likely root-level archives would include pagination rules for the homepage 1601 * as well as site-wide post feeds (e.g. /feed/, and /feed/atom/). 1602 * 1603 * @since 1.5.0 1604 * 1605 * @param array $root_rewrite The root-level rewrite rules. 1606 */ 1607 $root_rewrite = apply_filters( 'root_rewrite_rules', $root_rewrite ); 1608 1609 // Comments rewrite rules. 1574 1610 $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);1576 1611 1577 // Search 1612 /** 1613 * Filter rewrite rules used for comment feed archives. 1614 * 1615 * Likely comments feed archives include /comments/feed/, and /comments/feed/atom/. 1616 * 1617 * @since 1.5.0 1618 * 1619 * @param array $comments_rewrite The rewrite rules for the site-wide comments feeds. 1620 */ 1621 $comments_rewrite = apply_filters( 'comments_rewrite_rules', $comments_rewrite ); 1622 1623 // Search rewrite rules. 1578 1624 $search_structure = $this->get_search_permastruct(); 1579 1625 $search_rewrite = $this->generate_rewrite_rules($search_structure, EP_SEARCH); 1580 $search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);1581 1626 1582 // Authors 1627 /** 1628 * Filter rewrite rules used for search archives. 1629 * 1630 * Likely search-related archives include /search/search+query/ as well as 1631 * pagination and feed paths for a search. 1632 * 1633 * @since 1.5.0 1634 * 1635 * @param array $search_rewrite The rewrite rules for search queries. 1636 */ 1637 $search_rewrite = apply_filters( 'search_rewrite_rules', $search_rewrite ); 1638 1639 // Author rewrite rules. 1583 1640 $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS); 1584 $author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);1585 1641 1586 // Pages 1642 /** 1643 * Filter rewrite rules used for author archives. 1644 * 1645 * Likely author archives would inlcude /author/author-name/, as well as 1646 * pagination and feed paths for author archives. 1647 * 1648 * @since 1.5.0 1649 * 1650 * @param array $author_rewrite The rewrite rules for author archives. 1651 */ 1652 $author_rewrite = apply_filters( 'author_rewrite_rules', $author_rewrite ); 1653 1654 // Pages rewrite rules. 1587 1655 $page_rewrite = $this->page_rewrite_rules(); 1588 $page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);1589 1656 1590 // Extra permastructs 1657 /** 1658 * Filter rewrite rules used for "page" post type archives. 1659 * 1660 * @since 1.5.0 1661 * 1662 * @param array $page_rewrite The rewrite rules for the "page" post type. 1663 */ 1664 $page_rewrite = apply_filters( 'page_rewrite_rules', $page_rewrite ); 1665 1666 // Extra permastructs. 1591 1667 foreach ( $this->extra_permastructs as $permastructname => $struct ) { 1592 1668 if ( is_array( $struct ) ) { 1593 1669 if ( count( $struct ) == 2 ) … … 1598 1674 $rules = $this->generate_rewrite_rules( $struct ); 1599 1675 } 1600 1676 1601 $rules = apply_filters($permastructname . '_rewrite_rules', $rules); 1602 if ( 'post_tag' == $permastructname ) 1603 $rules = apply_filters('tag_rewrite_rules', $rules); 1677 /** 1678 * Filter rewrite rules used for individual permastructs. 1679 * 1680 * The dynamic portion of the hook name, $permastructname, refers 1681 * to the name of the registered permastruct, e.g. 'post_tag' (tags), 1682 * 'category' (categories), etc. 1683 * 1684 * @since 3.1.0 1685 * 1686 * @param array $rules The rewrite rules generated for the current permastruct. 1687 */ 1688 $rules = apply_filters( $permastructname . '_rewrite_rules', $rules ); 1689 if ( 'post_tag' == $permastructname ) { 1690 /** 1691 * Filter rewrite rules used specifically for Tags. 1692 * 1693 * @since 2.3.0 1694 * @deprecated 3.1.0 Use 'post_tag_rewrite_rules' instead 1695 * 1696 * @param array $rules The rewrite rules generated for tags. 1697 */ 1698 $rules = apply_filters( 'tag_rewrite_rules', $rules ); 1699 } 1604 1700 1605 1701 $this->extra_rules_top = array_merge($this->extra_rules_top, $rules); 1606 1702 } … … 1611 1707 else 1612 1708 $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); 1613 1709 1614 do_action_ref_array('generate_rewrite_rules', array(&$this)); 1615 $this->rules = apply_filters('rewrite_rules_array', $this->rules); 1710 /** 1711 * Fires after the rewrite rules are generated. 1712 * 1713 * @since 1.5.0 1714 * 1715 * @param WP_Rewrite $this Current WP_Rewrite instance, passed by reference. 1716 */ 1717 do_action_ref_array( 'generate_rewrite_rules', array( &$this ) ); 1616 1718 1719 /** 1720 * Filter the full set of generated rewrite rules. 1721 * 1722 * @since 1.5.0 1723 * 1724 * @param array $this->rules The compiled array of rewrite rules. 1725 */ 1726 $this->rules = apply_filters( 'rewrite_rules_array', $this->rules ); 1727 1617 1728 return $this->rules; 1618 1729 } 1619 1730 … … 1720 1831 1721 1832 $rules .= "</IfModule>\n"; 1722 1833 1723 $rules = apply_filters('mod_rewrite_rules', $rules); 1724 $rules = apply_filters('rewrite_rules', $rules); // Deprecated 1834 /** 1835 * Filter rewrite rules formatted for output to a mod_rewrite .htaccess file. 1836 * 1837 * @since 1.5.0 1838 * 1839 * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess. 1840 */ 1841 $rules = apply_filters( 'mod_rewrite_rules', $rules ); 1725 1842 1843 /** 1844 * Filter rewrite rules formatted for output to a mod_rewrite .htaccess file. 1845 * 1846 * @since 1.5.0 1847 * @deprecated 1.5.0 Use the mod_rewrite_rules filter instead. 1848 * 1849 * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess. 1850 */ 1851 $rules = apply_filters( 'rewrite_rules', $rules ); // Deprecated 1852 1726 1853 return $rules; 1727 1854 } 1728 1855 … … 1767 1894 </configuration>'; 1768 1895 } 1769 1896 1770 $rules = apply_filters('iis7_url_rewrite_rules', $rules); 1897 /** 1898 * Filter rewrite rules formatted for output to an IIS web.config file. 1899 * 1900 * @since 2.8.0 1901 * 1902 * @param string $rules Rewrite rules formatted for IIS web.config. 1903 */ 1904 $rules = apply_filters( 'iis7_url_rewrite_rules', $rules ); 1771 1905 1772 1906 return $rules; 1773 1907 } … … 1910 2044 * A "hard" flush updates .htaccess (Apache) or web.config (IIS). 1911 2045 * 1912 2046 * @since 3.7.0 1913 * @param bool $hard Defaults to true. 2047 * 2048 * @param bool $hard Whether to flush rewrite rules "hard". Default true. 1914 2049 */ 1915 if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) 2050 if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) { 1916 2051 return; 2052 } 1917 2053 if ( function_exists( 'save_mod_rewrite_rules' ) ) 1918 2054 save_mod_rewrite_rules(); 1919 2055 if ( function_exists( 'iis7_save_url_rewrite_rules' ) ) … … 1972 2108 $old_permalink_structure = $this->permalink_structure; 1973 2109 update_option('permalink_structure', $permalink_structure); 1974 2110 $this->init(); 1975 do_action('permalink_structure_changed', $old_permalink_structure, $permalink_structure); 2111 2112 /** 2113 * Fires after the permalink structure is updated. 2114 * 2115 * @since 2.8.0 2116 * 2117 * @param string $old_permalink_structure The previous permalink structure. 2118 * @param string $permalink_structure The new permalink structure. 2119 */ 2120 do_action( 'permalink_structure_changed', $old_permalink_structure, $permalink_structure ); 1976 2121 } 1977 2122 } 1978 2123