Canonical / Query: Restore the `is_404()` check in `wp_old_slug_redirect()` which was removed in [34659].

This reverts part of [34659] due to excessive canonical problems it's caused in 4.4.x.

Fixes #35344, #21602 for the 4.4 branch.

Built from https://develop.svn.wordpress.org/branches/4.4@36280


git-svn-id: http://core.svn.wordpress.org/branches/4.4@36247 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2016-01-13 08:20:28 +00:00
parent 75aa06ea84
commit 26c5f0137f
1 changed files with 2 additions and 14 deletions

View File

@ -4981,16 +4981,11 @@ class WP_Query {
*
* @global WP_Query $wp_query Global WP_Query instance.
* @global wpdb $wpdb WordPress database abstraction object.
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
*/
function wp_old_slug_redirect() {
global $wp_query, $wp_rewrite;
global $wp_query;
if ( get_queried_object() ) {
return;
}
if ( '' !== $wp_query->query_vars['name'] ) :
if ( is_404() && '' !== $wp_query->query_vars['name'] ) :
global $wpdb;
// Guess the current post_type based on the query vars.
@ -5038,13 +5033,6 @@ function wp_old_slug_redirect() {
$link = user_trailingslashit( trailingslashit( $link ) . 'page/' . $GLOBALS['wp_query']->query_vars['paged'] );
} elseif( is_embed() ) {
$link = user_trailingslashit( trailingslashit( $link ) . 'embed' );
} elseif ( is_404() ) {
// Add rewrite endpoints if necessary.
foreach ( $wp_rewrite->endpoints as $endpoint ) {
if ( $endpoint[2] && false !== get_query_var( $endpoint[2], false ) ) {
$link = user_trailingslashit( trailingslashit( $link ) . $endpoint[1] );
}
}
}
/**