From 9adbdd4a2c103a6768adcb66abcaac3a523e0f19 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 22 Jun 2015 15:30:42 +0100 Subject: [PATCH] Tweak URL generation before redirect --- includes/class-wc-cache-helper.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-cache-helper.php b/includes/class-wc-cache-helper.php index b409055bc78..f4093248754 100644 --- a/includes/class-wc-cache-helper.php +++ b/includes/class-wc-cache-helper.php @@ -49,7 +49,16 @@ class WC_Cache_Helper { $current_hash = isset( $_GET['v'] ) ? wc_clean( $_GET['v'] ) : ''; if ( empty( $current_hash ) || $current_hash !== $location_hash ) { global $wp; - wp_safe_redirect( esc_url_raw( add_query_arg( 'v', $location_hash, remove_query_arg( array( 'v', 'pagename' ), add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ) ) ) ), 307 ); + + $redirect_url = trailingslashit( home_url( $wp->request ) ); + + if ( ! get_option( 'permalink_structure' ) ) { + $redirect_url = add_query_arg( $wp->query_string, '', $redirect_url ); + } + + $redirect_url = add_query_arg( 'v', $location_hash, remove_query_arg( 'v', $redirect_url ) ); + + wp_safe_redirect( esc_url_raw( $redirect_url ), 307 ); exit; } }