Ticket #20496: published-post-preview-canonical-redirect.patch
File published-post-preview-canonical-redirect.patch, 1.6 KB (added by , 12 years ago) |
---|
-
wp-includes/canonical.php
39 39 function redirect_canonical( $requested_url = null, $do_redirect = true ) { 40 40 global $wp_rewrite, $is_IIS, $wp_query, $wpdb; 41 41 42 // If we're not in wp-admin and the post has been published and preview nonce 43 // is non-existant or invalid then no need for preview in query 44 if( ! is_admin() && get_query_var('preview') == 'true' && intval( get_query_var('p') ) > 0 && get_post_status( get_query_var('p') ) == 'publish' ) { 45 if ( ! isset($_GET['preview_id']) || ! isset($_GET['preview_nonce']) || ! wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . intval($_GET['preview_id']) ) ) { 46 $wp_query->is_preview = false; 47 } 48 } 49 42 50 if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || !empty($_POST) || is_preview() || is_robots() || ( $is_IIS && !iis7_supports_permalinks() ) ) 43 51 return; 44 52 … … 68 76 if ( !isset($redirect['query']) ) 69 77 $redirect['query'] = ''; 70 78 79 // If its not a preview then remove it from URL 80 if( ! is_preview() ) { 81 $redirect['query'] = remove_query_arg( 'preview', $redirect['query'] ); 82 } 83 71 84 if ( is_feed() && ( $id = get_query_var( 'p' ) ) ) { 72 85 if ( $redirect_url = get_post_comments_feed_link( $id, get_query_var( 'feed' ) ) ) { 73 86 $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type', 'feed'), $redirect_url );