Make WordPress Core

Ticket #33920: 33920.diff

File 33920.diff, 1.4 KB (added by swissspidy, 10 years ago)
  • src/wp-includes/query.php

    diff --git src/wp-includes/query.php src/wp-includes/query.php
    index dde5b59..e370181 100644
    class WP_Query { 
    47254725 *
    47264726 * @since 2.1.0
    47274727 *
    4728  * @global WP_Query $wp_query Global WP_Query instance.
    4729  * @global wpdb     $wpdb     WordPress database abstraction object.
     4728 * @global WP_Query   $wp_query   Global WP_Query instance.
     4729 * @global wpdb       $wpdb       WordPress database abstraction object.
     4730 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
    47304731 */
    47314732function wp_old_slug_redirect() {
    4732         global $wp_query;
     4733        global $wp_query, $wp_rewrite;
     4734
    47334735        if ( is_404() && '' != $wp_query->query_vars['name'] ) :
    47344736                global $wpdb;
    47354737
    function wp_old_slug_redirect() { 
    47674769                if ( ! $id )
    47684770                        return;
    47694771
    4770                 $link = get_permalink($id);
     4772                $link = get_permalink( $id );
     4773
     4774                // Add rewrite endpoints if necessary.
     4775                foreach ( $wp_rewrite->endpoints as $endpoint ) {
     4776                        if ( $endpoint[2] && false !== get_query_var( $endpoint[2], false ) ) {
     4777                                $link = user_trailingslashit( trailingslashit( $link ) . $endpoint[2] );
     4778                        }
     4779                }
     4780
     4781                /**
     4782                 * Filter the old slug redirect URL.
     4783                 *
     4784                 * @since 4.4.0
     4785                 *
     4786                 * @param string $link The redirect URL.
     4787                 */
     4788                $link = apply_filters( 'old_slug_redirect_url', $link );
    47714789
    4772                 if ( !$link )
     4790                if ( ! $link ) {
    47734791                        return;
     4792                }
    47744793
    47754794                wp_redirect( $link, 301 ); // Permanent redirect
    47764795                exit;