Skip to content

Commit 1f79395

Browse files
author
JasWSInc
committed
Bug fix; $_GET should be passed through when requested by config.
1 parent ba599f5 commit 1f79395

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

wp-redirects/wp-redirects.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,19 @@ public static function redirect_redirects()
150150
if(!($is_singular_redirect = is_singular('redirect')))
151151
return; // Nothing to do in this case.
152152

153-
$to = (string)get_post_meta(get_the_ID(), 'wp_redirect_to', TRUE);
153+
$redirect_id = get_the_ID(); // Pull this one time only.
154+
155+
$to = (string)get_post_meta($redirect_id, 'wp_redirect_to', TRUE);
154156
$to = preg_replace_callback('/%%\\\$([^\[]+?)(.+?)%%/i', 'wp_redirects::_url_e_gprcs_value', $to);
155157
$to = preg_replace('/%%(.+?)%%/i', '', $to); // Ditch any remaining replacement codes.
156158

157159
$to = // Cleanup any double slashes left over by replacement codes.
158160
wp_redirects::trim(preg_replace('/(?<!\:)\/+/', '/', $to), 0, '?&=#');
159161

160-
$status = (is_numeric($status = get_post_meta(get_the_ID(), 'wp_redirect_status', TRUE))) ? (integer)$status : 301;
162+
if($to && !empty($_GET) && get_post_meta($redirect_id, 'wp_redirect_to_w_query_vars', TRUE))
163+
$to = add_query_arg(urlencode_deep(wp_redirects::trim_strip_deep($_GET)), $to);
164+
165+
$status = (is_numeric($status = get_post_meta($redirect_id, 'wp_redirect_status', TRUE))) ? (integer)$status : 301;
161166

162167
if($to && $status) // Redirection URL w/ a possible custom status code.
163168
wp_redirect($to, $status).exit(); // It's a good day in Eureka :-)
@@ -200,12 +205,12 @@ public static function redirect_uri_patterns()
200205
$_to = preg_replace_callback('/%%\\\$([^\[]+?)(.+?)%%/i', 'wp_redirects::_url_e_gprcs_value', $_to);
201206
$_to = preg_replace('/%%(.+?)%%/i', '', $_to); // Ditch any remaining replacement codes.
202207

203-
if(!empty($_GET) && get_post_meta($_pattern->post_id, 'wp_redirect_to_w_query_vars', TRUE))
204-
$_to = add_query_arg(urlencode_deep(wp_redirects::trim_strip_deep($_GET)), $_to);
205-
206208
$_to = // Cleanup any double slashes left over by replacement codes.
207209
wp_redirects::trim(preg_replace('/(?<!\:)\/+/', '/', $_to), 0, '?&=#');
208210

211+
if($_to && !empty($_GET) && get_post_meta($_pattern->post_id, 'wp_redirect_to_w_query_vars', TRUE))
212+
$_to = add_query_arg(urlencode_deep(wp_redirects::trim_strip_deep($_GET)), $_to);
213+
209214
$_status = (is_numeric($_status = get_post_meta($_pattern->post_id, 'wp_redirect_status', TRUE))) ? (integer)$_status : 301;
210215

211216
wp_redirect($_to, $_status).exit(); // Redirection URL w/ a possible custom status code.

0 commit comments

Comments
 (0)