Changeset 47122 for trunk/src/wp-includes/rewrite.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rewrite.php
r45736 r47122 158 158 */ 159 159 function add_rewrite_tag( $tag, $regex, $query = '' ) { 160 // validate the tag's name160 // Validate the tag's name. 161 161 if ( strlen( $tag ) < 3 || $tag[0] != '%' || $tag[ strlen( $tag ) - 1 ] != '%' ) { 162 162 return; … … 254 254 $hook = 'do_feed_' . $feedname; 255 255 256 // Remove default function hook 256 // Remove default function hook. 257 257 remove_action( $hook, $hook ); 258 258 … … 421 421 $maybe_page = $query_vars['day']; 422 422 } 423 // Bug found in #11694 - 'page' was returning '/4' 423 // Bug found in #11694 - 'page' was returning '/4'. 424 424 $maybe_page = (int) trim( $maybe_page, '/' ); 425 425 … … 486 486 } 487 487 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. 489 489 if ( preg_match( '#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values ) ) { 490 490 $id = absint( $values[2] ); … … 494 494 } 495 495 496 // Get rid of the #anchor 496 // Get rid of the #anchor. 497 497 $url_split = explode( '#', $url ); 498 498 $url = $url_split[0]; 499 499 500 // Get rid of URL ?query=string 500 // Get rid of URL ?query=string. 501 501 $url_split = explode( '?', $url ); 502 502 $url = $url_split[0]; … … 506 506 $url = set_url_scheme( $url, $scheme ); 507 507 508 // Add 'www.' if it is absent and should be there 508 // Add 'www.' if it is absent and should be there. 509 509 if ( false !== strpos( home_url(), '://www.' ) && false === strpos( $url, '://www.' ) ) { 510 510 $url = str_replace( '://', '://www.', $url ); 511 511 } 512 512 513 // Strip 'www.' if it is present and shouldn't be 513 // Strip 'www.' if it is present and shouldn't be. 514 514 if ( false === strpos( home_url(), '://www.' ) ) { 515 515 $url = str_replace( '://www.', '://', $url ); … … 524 524 } 525 525 526 // Check to see if we are using rewrite rules 526 // Check to see if we are using rewrite rules. 527 527 $rewrite = $wp_rewrite->wp_rewrite_rules(); 528 528 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. 530 530 if ( empty( $rewrite ) ) { 531 531 return 0; 532 532 } 533 533 534 // Strip 'index.php/' if we're not using path info permalinks 534 // Strip 'index.php/' if we're not using path info permalinks. 535 535 if ( ! $wp_rewrite->using_index_permalinks() ) { 536 536 $url = str_replace( $wp_rewrite->index . '/', '', $url ); … … 538 538 539 539 if ( false !== strpos( trailingslashit( $url ), home_url( '/' ) ) ) { 540 // Chop off http://domain.com/[path] 540 // Chop off http://domain.com/[path]. 541 541 $url = str_replace( home_url(), '', $url ); 542 542 } else { 543 // Chop off /path/to/blog 543 // Chop off /path/to/blog. 544 544 $home_path = parse_url( home_url( '/' ) ); 545 545 $home_path = isset( $home_path['path'] ) ? $home_path['path'] : ''; … … 547 547 } 548 548 549 // Trim leading and lagging slashes 549 // Trim leading and lagging slashes. 550 550 $url = trim( $url, '/' ); 551 551 … … 563 563 foreach ( (array) $rewrite as $match => $query ) { 564 564 565 // If the requesting file is the anchor of the match, prepend it566 // to the path info.565 // If the requesting file is the anchor of the match, 566 // prepend it to the path info. 567 567 if ( ! empty( $url ) && ( $url != $request ) && ( strpos( $match, $url ) === 0 ) ) { 568 568 $request_match = $url . '/' . $request; … … 592 592 $query = addslashes( WP_MatchesMapRegex::apply( $query, $matches ) ); 593 593 594 // Filter out non-public query vars 594 // Filter out non-public query vars. 595 595 global $wp; 596 596 parse_str( $query, $query_vars ); … … 609 609 $query = wp_resolve_numeric_slug_conflicts( $query ); 610 610 611 // Do the query 611 // Do the query. 612 612 $query = new WP_Query( $query ); 613 613 if ( ! empty( $query->posts ) && $query->is_singular ) {
Note: See TracChangeset
for help on using the changeset viewer.