Make WordPress Core

Ticket #26095: 26095.diff

File 26095.diff, 9.1 KB (added by DrewAPicture, 10 years ago)

2nd pass

  • src/wp-includes/rewrite.php

     
    288288function url_to_postid($url) {
    289289        global $wp_rewrite;
    290290
    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 );
    292299
    293300        // First, check to see if there is a 'p=N' or 'page_id=N' to match against
    294301        if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) )       {
     
    15581565                }
    15591566                $registration_pages['.*wp-register.php$'] = $this->index . '?register=true'; // Deprecated
    15601567
    1561                 // Post
     1568                // Post rewrite rules.
    15621569                $post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK );
    1563                 $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
    15641570
    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.
    15661581                $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE);
    1567                 $date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);
    15681582
    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.
    15701595                $root_rewrite = $this->generate_rewrite_rules($this->root . '/', EP_ROOT);
    1571                 $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
    15721596
    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.
    15741610                $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);
    15761611
    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.
    15781624                $search_structure = $this->get_search_permastruct();
    15791625                $search_rewrite = $this->generate_rewrite_rules($search_structure, EP_SEARCH);
    1580                 $search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
    15811626
    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.
    15831640                $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS);
    1584                 $author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
    15851641
    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.
    15871655                $page_rewrite = $this->page_rewrite_rules();
    1588                 $page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
    15891656
    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.
    15911667                foreach ( $this->extra_permastructs as $permastructname => $struct ) {
    15921668                        if ( is_array( $struct ) ) {
    15931669                                if ( count( $struct ) == 2 )
     
    15981674                                $rules = $this->generate_rewrite_rules( $struct );
    15991675                        }
    16001676
    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                        }
    16041700
    16051701                        $this->extra_rules_top = array_merge($this->extra_rules_top, $rules);
    16061702                }
     
    16111707                else
    16121708                        $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);
    16131709
    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 ) );
    16161718
     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
    16171728                return $this->rules;
    16181729        }
    16191730
     
    17201831
    17211832                $rules .= "</IfModule>\n";
    17221833
    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 );
    17251842
     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
    17261853                return $rules;
    17271854        }
    17281855
     
    17671894</configuration>';
    17681895                }
    17691896
    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 );
    17711905
    17721906                return $rules;
    17731907        }
     
    19102044                 * A "hard" flush updates .htaccess (Apache) or web.config (IIS).
    19112045                 *
    19122046                 * @since 3.7.0
    1913                  * @param bool $hard Defaults to true.
     2047                 *
     2048                 * @param bool $hard Whether to flush rewrite rules "hard". Default true.
    19142049                 */
    1915                 if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) )
     2050                if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) {
    19162051                        return;
     2052                }
    19172053                if ( function_exists( 'save_mod_rewrite_rules' ) )
    19182054                        save_mod_rewrite_rules();
    19192055                if ( function_exists( 'iis7_save_url_rewrite_rules' ) )
     
    19722108                        $old_permalink_structure = $this->permalink_structure;
    19732109                        update_option('permalink_structure', $permalink_structure);
    19742110                        $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 );
    19762121                }
    19772122        }
    19782123