Ticket #21020: 21020.diff
File 21020.diff, 2.2 KB (added by , 12 years ago) |
---|
-
wp-includes/rewrite.php
1537 1537 $registration_pages['.*wp-register.php$'] = $this->index . '?register=true'; // Deprecated 1538 1538 1539 1539 // Post 1540 $post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK, false , true, false, false);1540 $post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK, false ); 1541 1541 $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite); 1542 1542 1543 1543 // Date -
wp-includes/canonical.php
100 100 } 101 101 102 102 if ( ! $redirect_url ) { 103 if ( $redirect_url = redirect_guess_404_permalink( $requested_url) ) {103 if ( $redirect_url = redirect_guess_404_permalink() ) { 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 } 106 106 } … … 461 461 } 462 462 463 463 /** 464 * Attempts to guess the correct URL from the current URL (that produced a 404) or 465 * the current query variables. 464 * Attempts to guess the correct URL based on query vars 466 465 * 467 466 * @since 2.3.0 468 467 * @uses $wpdb 469 468 * 470 * @param string $current_url Optional. The URL that has 404'd.471 469 * @return bool|string The correct URL if one is found. False on failure. 472 470 */ 473 function redirect_guess_404_permalink( $current_url = '') {471 function redirect_guess_404_permalink() { 474 472 global $wpdb, $wp_rewrite; 475 473 476 if ( ! empty( $current_url ) )477 $parsed_url = @parse_url( $current_url );478 479 // Attempt to redirect bare category slugs if the permalink structure starts480 // 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 }488 489 474 if ( get_query_var('name') ) { 490 475 $where = $wpdb->prepare("post_name LIKE %s", like_escape( get_query_var('name') ) . '%'); 491 476