Canonical redirects should only be applied for GET requests.

props c.axelsson.
fixes #27498.
Built from https://develop.svn.wordpress.org/trunk@28958


git-svn-id: http://core.svn.wordpress.org/trunk@28754 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-07-02 14:11:14 +00:00
parent 19a3159082
commit f84ef60b52
1 changed files with 6 additions and 1 deletions

View File

@ -39,6 +39,10 @@
function redirect_canonical( $requested_url = null, $do_redirect = true ) {
global $wp_rewrite, $is_IIS, $wp_query, $wpdb;
if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'GET' !== $_SERVER['REQUEST_METHOD'] ) {
return;
}
// If we're not in wp-admin and the post has been published and preview nonce
// is non-existent or invalid then no need for preview in query
if ( is_preview() && get_query_var( 'p' ) && 'publish' == get_post_status( get_query_var( 'p' ) ) ) {
@ -49,8 +53,9 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
}
}
if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || !empty($_POST) || is_preview() || is_robots() || ( $is_IIS && !iis7_supports_permalinks() ) )
if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || is_preview() || is_robots() || ( $is_IIS && !iis7_supports_permalinks() ) ) {
return;
}
if ( !$requested_url ) {
// build the URL in the address bar