WordPress.org

Make WordPress Core

Changeset 14595


Ignore:
Timestamp:
05/13/10 15:09:43 (4 years ago)
Author:
ryan
Message:

Attempt canonical redirect only for public post types. Props solarissmoke. see #13125

File:
1 edited

Legend:

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

    r14404 r14595  
    8484 
    8585        // 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']); 
     86        $id = max( get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id') ); 
     87        if ( $id && $redirect_post = get_post($id) ) { 
     88            $post_type_obj = get_post_type_object($redirect_post->post_type); 
     89            if ( $post_type_obj->public ) { 
     90                $redirect_url = get_permalink($redirect_post); 
     91                $redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id'), $redirect['query']); 
     92            } 
     93        } 
    8994 
    9095        if ( ! $redirect_url ) 
Note: See TracChangeset for help on using the changeset viewer.