Changeset 34659 for trunk/src/wp-includes/query.php
- Timestamp:
- 09/28/2015 06:56:54 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/query.php
r34502 r34659 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 if ( is_404() && '' != $wp_query->query_vars['name'] ) : 4733 global $wp_query, $wp_rewrite; 4734 4735 if ( '' !== $wp_query->query_vars['name'] ) : 4734 4736 global $wpdb; 4735 4737 … … 4768 4770 return; 4769 4771 4770 $link = get_permalink($id); 4771 4772 if ( !$link ) 4772 $link = get_permalink( $id ); 4773 4774 if ( is_feed() ) { 4775 $link = user_trailingslashit( trailingslashit( $link ) . 'feed' ); 4776 } elseif ( isset( $GLOBALS['wp_query']->query_vars['paged'] ) && $GLOBALS['wp_query']->query_vars['paged'] > 1 ) { 4777 $link = user_trailingslashit( trailingslashit( $link ) . 'page/' . $GLOBALS['wp_query']->query_vars['paged'] ); 4778 } elseif ( is_404() ) { 4779 // Add rewrite endpoints if necessary. 4780 foreach ( $wp_rewrite->endpoints as $endpoint ) { 4781 if ( $endpoint[2] && false !== get_query_var( $endpoint[2], false ) ) { 4782 $link = user_trailingslashit( trailingslashit( $link ) . $endpoint[1] ); 4783 } 4784 } 4785 } 4786 4787 /** 4788 * Filter the old slug redirect URL. 4789 * 4790 * @since 4.4.0 4791 * 4792 * @param string $link The redirect URL. 4793 */ 4794 $link = apply_filters( 'old_slug_redirect_url', $link ); 4795 4796 if ( ! $link ) { 4773 4797 return; 4798 } 4774 4799 4775 4800 wp_redirect( $link, 301 ); // Permanent redirect
Note: See TracChangeset
for help on using the changeset viewer.