diff --git src/wp-includes/query.php src/wp-includes/query.php
index dde5b59..e370181 100644
|
|
class WP_Query { |
4725 | 4725 | * |
4726 | 4726 | * @since 2.1.0 |
4727 | 4727 | * |
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. |
4730 | 4731 | */ |
4731 | 4732 | function wp_old_slug_redirect() { |
4732 | | global $wp_query; |
| 4733 | global $wp_query, $wp_rewrite; |
| 4734 | |
4733 | 4735 | if ( is_404() && '' != $wp_query->query_vars['name'] ) : |
4734 | 4736 | global $wpdb; |
4735 | 4737 | |
… |
… |
function wp_old_slug_redirect() { |
4767 | 4769 | if ( ! $id ) |
4768 | 4770 | return; |
4769 | 4771 | |
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 ); |
4771 | 4789 | |
4772 | | if ( !$link ) |
| 4790 | if ( ! $link ) { |
4773 | 4791 | return; |
| 4792 | } |
4774 | 4793 | |
4775 | 4794 | wp_redirect( $link, 301 ); // Permanent redirect |
4776 | 4795 | exit; |