WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/23/2016 09:53:44 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

Remove the unit tests which are no longer supported.
This also removes the is_feed() code to avoid confusion - only pages & embeds will be redirected.

Merges [36280] and [36281] to trunk.

Props dd32.
See #21602, #35344.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/query.php

    r36989 r37075  
    48864886 * @global WP_Query   $wp_query   Global WP_Query instance.
    48874887 * @global wpdb       $wpdb       WordPress database abstraction object.
    4888  * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
    48894888 */
    48904889function wp_old_slug_redirect() {
    4891     global $wp_query, $wp_rewrite;
    4892 
    4893     if ( get_queried_object() ) {
    4894         return;
    4895     }
    4896 
    4897     if ( '' !== $wp_query->query_vars['name'] ) :
     4890    global $wp_query;
     4891
     4892    if ( is_404() && '' !== $wp_query->query_vars['name'] ) :
    48984893        global $wpdb;
    48994894
     
    49374932        $link = get_permalink( $id );
    49384933
    4939         if ( is_feed() ) {
    4940             $link = user_trailingslashit( trailingslashit( $link ) . 'feed' );
    4941         } elseif ( isset( $GLOBALS['wp_query']->query_vars['paged'] ) && $GLOBALS['wp_query']->query_vars['paged'] > 1 ) {
     4934        if ( isset( $GLOBALS['wp_query']->query_vars['paged'] ) && $GLOBALS['wp_query']->query_vars['paged'] > 1 ) {
    49424935            $link = user_trailingslashit( trailingslashit( $link ) . 'page/' . $GLOBALS['wp_query']->query_vars['paged'] );
    49434936        } elseif( is_embed() ) {
    49444937            $link = user_trailingslashit( trailingslashit( $link ) . 'embed' );
    4945         } elseif ( is_404() ) {
    4946             // Add rewrite endpoints if necessary.
    4947             foreach ( $wp_rewrite->endpoints as $endpoint ) {
    4948                 if ( $endpoint[2] && false !== get_query_var( $endpoint[2], false ) ) {
    4949                     $link = user_trailingslashit( trailingslashit( $link ) . $endpoint[1] );
    4950                 }
    4951             }
    49524938        }
    49534939
Note: See TracChangeset for help on using the changeset viewer.