WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (6 months ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rewrite.php

    r45736 r47122  
    158158 */
    159159function add_rewrite_tag( $tag, $regex, $query = '' ) {
    160     // validate the tag's name
     160    // Validate the tag's name.
    161161    if ( strlen( $tag ) < 3 || $tag[0] != '%' || $tag[ strlen( $tag ) - 1 ] != '%' ) {
    162162        return;
     
    254254    $hook = 'do_feed_' . $feedname;
    255255
    256     // Remove default function hook
     256    // Remove default function hook.
    257257    remove_action( $hook, $hook );
    258258
     
    421421        $maybe_page = $query_vars['day'];
    422422    }
    423     // Bug found in #11694 - 'page' was returning '/4'
     423    // Bug found in #11694 - 'page' was returning '/4'.
    424424    $maybe_page = (int) trim( $maybe_page, '/' );
    425425
     
    486486    }
    487487
    488     // First, check to see if there is a 'p=N' or 'page_id=N' to match against
     488    // First, check to see if there is a 'p=N' or 'page_id=N' to match against.
    489489    if ( preg_match( '#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values ) ) {
    490490        $id = absint( $values[2] );
     
    494494    }
    495495
    496     // Get rid of the #anchor
     496    // Get rid of the #anchor.
    497497    $url_split = explode( '#', $url );
    498498    $url       = $url_split[0];
    499499
    500     // Get rid of URL ?query=string
     500    // Get rid of URL ?query=string.
    501501    $url_split = explode( '?', $url );
    502502    $url       = $url_split[0];
     
    506506    $url    = set_url_scheme( $url, $scheme );
    507507
    508     // Add 'www.' if it is absent and should be there
     508    // Add 'www.' if it is absent and should be there.
    509509    if ( false !== strpos( home_url(), '://www.' ) && false === strpos( $url, '://www.' ) ) {
    510510        $url = str_replace( '://', '://www.', $url );
    511511    }
    512512
    513     // Strip 'www.' if it is present and shouldn't be
     513    // Strip 'www.' if it is present and shouldn't be.
    514514    if ( false === strpos( home_url(), '://www.' ) ) {
    515515        $url = str_replace( '://www.', '://', $url );
     
    524524    }
    525525
    526     // Check to see if we are using rewrite rules
     526    // Check to see if we are using rewrite rules.
    527527    $rewrite = $wp_rewrite->wp_rewrite_rules();
    528528
    529     // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options
     529    // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options.
    530530    if ( empty( $rewrite ) ) {
    531531        return 0;
    532532    }
    533533
    534     // Strip 'index.php/' if we're not using path info permalinks
     534    // Strip 'index.php/' if we're not using path info permalinks.
    535535    if ( ! $wp_rewrite->using_index_permalinks() ) {
    536536        $url = str_replace( $wp_rewrite->index . '/', '', $url );
     
    538538
    539539    if ( false !== strpos( trailingslashit( $url ), home_url( '/' ) ) ) {
    540         // Chop off http://domain.com/[path]
     540        // Chop off http://domain.com/[path].
    541541        $url = str_replace( home_url(), '', $url );
    542542    } else {
    543         // Chop off /path/to/blog
     543        // Chop off /path/to/blog.
    544544        $home_path = parse_url( home_url( '/' ) );
    545545        $home_path = isset( $home_path['path'] ) ? $home_path['path'] : '';
     
    547547    }
    548548
    549     // Trim leading and lagging slashes
     549    // Trim leading and lagging slashes.
    550550    $url = trim( $url, '/' );
    551551
     
    563563    foreach ( (array) $rewrite as $match => $query ) {
    564564
    565         // If the requesting file is the anchor of the match, prepend it
    566         // to the path info.
     565        // If the requesting file is the anchor of the match,
     566        // prepend it to the path info.
    567567        if ( ! empty( $url ) && ( $url != $request ) && ( strpos( $match, $url ) === 0 ) ) {
    568568            $request_match = $url . '/' . $request;
     
    592592            $query = addslashes( WP_MatchesMapRegex::apply( $query, $matches ) );
    593593
    594             // Filter out non-public query vars
     594            // Filter out non-public query vars.
    595595            global $wp;
    596596            parse_str( $query, $query_vars );
     
    609609            $query = wp_resolve_numeric_slug_conflicts( $query );
    610610
    611             // Do the query
     611            // Do the query.
    612612            $query = new WP_Query( $query );
    613613            if ( ! empty( $query->posts ) && $query->is_singular ) {
Note: See TracChangeset for help on using the changeset viewer.