Changeset 8843 for trunk/wp-includes/canonical.php
- Timestamp:
- 09/08/2008 01:50:08 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/canonical.php
r8742 r8843 38 38 */ 39 39 function redirect_canonical($requested_url=null, $do_redirect=true) { 40 global $wp_rewrite, $is_IIS ;40 global $wp_rewrite, $is_IIS, $wp_query, $wpdb; 41 41 42 42 if ( is_feed() || is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() || is_robots() ) … … 60 60 $redirect_url = false; 61 61 62 if ( is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p')) ) { 63 64 $vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) ); 65 66 if ( isset($vars[0]) && $vars = $vars[0] ) { 67 if ( 'revision' == $vars->post_type && $vars->post_parent > 0 ) 68 $id = $vars->post_parent; 69 70 if ( $redirect_url = get_permalink($id) ) 71 $redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id'), $redirect['query']); 72 } 73 } 74 62 75 // These tests give us a WP-generated permalink 63 76 if ( is_404() ) { … … 65 78 } elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) { 66 79 // rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101 67 if ( is_single() && isset($_GET['p']) ) {80 if ( is_single() && isset($_GET['p']) && ! $redirect_url ) { 68 81 if ( $redirect_url = get_permalink(get_query_var('p')) ) 69 82 $redirect['query'] = remove_query_arg('p', $redirect['query']); 70 } elseif ( is_page() && isset($_GET['page_id']) ) {83 } elseif ( is_page() && isset($_GET['page_id']) && ! $redirect_url ) { 71 84 if ( $redirect_url = get_permalink(get_query_var('page_id')) ) 72 85 $redirect['query'] = remove_query_arg('page_id', $redirect['query']); … … 254 267 function redirect_guess_404_permalink() { 255 268 global $wpdb; 269 256 270 if ( !get_query_var('name') ) 257 271 return false;
Note: See TracChangeset
for help on using the changeset viewer.