Changes from branches/3.4/wp-includes/canonical.php at r21115 to trunk/wp-includes/canonical.php at r20688
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/canonical.php
r21115 r20688 101 101 102 102 if ( ! $redirect_url ) { 103 if ( $redirect_url = redirect_guess_404_permalink( ) ) {103 if ( $redirect_url = redirect_guess_404_permalink( $requested_url ) ) { 104 104 $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url ); 105 105 } … … 462 462 463 463 /** 464 * Attempts to guess the correct URL based on query vars 464 * Attempts to guess the correct URL from the current URL (that produced a 404) or 465 * the current query variables. 465 466 * 466 467 * @since 2.3.0 467 468 * @uses $wpdb 468 469 * 470 * @param string $current_url Optional. The URL that has 404'd. 469 471 * @return bool|string The correct URL if one is found. False on failure. 470 472 */ 471 function redirect_guess_404_permalink( ) {473 function redirect_guess_404_permalink( $current_url = '' ) { 472 474 global $wpdb, $wp_rewrite; 475 476 if ( ! empty( $current_url ) ) 477 $parsed_url = @parse_url( $current_url ); 478 479 // Attempt to redirect bare category slugs if the permalink structure starts 480 // with the %category% tag. 481 if ( isset( $parsed_url['path'] ) 482 && preg_match( '#^[^%]+%category%#', $wp_rewrite->permalink_structure ) 483 && $cat = get_category_by_path( $parsed_url['path'] ) 484 ) { 485 if ( ! is_wp_error( $cat ) ) 486 return get_term_link( $cat ); 487 } 473 488 474 489 if ( get_query_var('name') ) {
Note: See TracChangeset
for help on using the changeset viewer.