Changeset 20395
- Timestamp:
- 04/07/2012 01:03:55 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/canonical.php
r20386 r20395 76 76 77 77 if ( $redirect_url = get_permalink($id) ) 78 $redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id', 'post_type'), $redirect['query']);78 $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url ); 79 79 } 80 80 } … … 89 89 if ( $post_type_obj->public ) { 90 90 $redirect_url = get_permalink($redirect_post); 91 $redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id', 'post_type'), $redirect['query']);91 $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url ); 92 92 } 93 93 } 94 94 95 95 if ( ! $redirect_url ) { 96 $redirect_url = redirect_guess_404_permalink( $requested_url ); 97 $redirect['query'] = remove_query_arg( array( 'post_type', 'pagename', 'name' ), $redirect['query'] ); 96 if ( $redirect_url = redirect_guess_404_permalink( $requested_url ) ) { 97 $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url ); 98 } 98 99 } 99 100 … … 420 421 421 422 /** 423 * Removes arguments from a query string if they are not present in a URL 424 * DO NOT use this in plugin code. 425 * 426 * @since 3.4 427 * @access private 428 * 429 * @return string The altered query string 430 */ 431 function _remove_qs_args_if_not_in_url( $query_string, Array $args_to_check, $url ) { 432 $parsed_url = @parse_url( $url ); 433 parse_str( $parsed_url['query'], $parsed_query ); 434 foreach ( $args_to_check as $qv ) { 435 if ( !isset( $parsed_query[$qv] ) ) 436 $query_string = remove_query_arg( $qv, $query_string ); 437 } 438 return $query_string; 439 } 440 441 /** 422 442 * Attempts to guess the correct URL from the current URL (that produced a 404) or 423 443 * the current query variables.
Note: See TracChangeset
for help on using the changeset viewer.