From f84ef60b527493d4e52311b6980f2d37bd0d10d8 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 2 Jul 2014 14:11:14 +0000 Subject: [PATCH] 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 --- wp-includes/canonical.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index b9547d824b..a4a56ec445 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -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