WordPress.org

Make WordPress Core

Changeset 14355


Ignore:
Timestamp:
05/03/2010 12:37:11 AM (11 years ago)
Author:
dd32
Message:

Serve a canonical redirection for ?p=, ?page_id=, ?attachment_id= url's for incorrect post_types (ie. ?p=<page_id> will redirect to that page url). Fixes #13125

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/canonical.php

    r14162 r14355  
    8282    // These tests give us a WP-generated permalink
    8383    if ( is_404() ) {
    84         $redirect_url = redirect_guess_404_permalink();
     84
     85        // Redirect ?page_id, ?p=, ?attachment_id= to their respective url's
     86        $id = max( get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id'));
     87        if ( $id && $redirect_url = get_permalink($id) )
     88            $redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id'), $redirect['query']);
     89   
     90        if ( ! $redirect_url )
     91            $redirect_url = redirect_guess_404_permalink();
     92
    8593    } elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {
    8694        // rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
Note: See TracChangeset for help on using the changeset viewer.