@@ -150,14 +150,19 @@ public static function redirect_redirects()
150
150
if (!($ is_singular_redirect = is_singular ('redirect ' )))
151
151
return ; // Nothing to do in this case.
152
152
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 );
154
156
$ to = preg_replace_callback ('/%% \\\$([^\[]+?)(.+?)%%/i ' , 'wp_redirects::_url_e_gprcs_value ' , $ to );
155
157
$ to = preg_replace ('/%%(.+?)%%/i ' , '' , $ to ); // Ditch any remaining replacement codes.
156
158
157
159
$ to = // Cleanup any double slashes left over by replacement codes.
158
160
wp_redirects::trim (preg_replace ('/(?<!\:)\/+/ ' , '/ ' , $ to ), 0 , '?&=# ' );
159
161
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 ;
161
166
162
167
if ($ to && $ status ) // Redirection URL w/ a possible custom status code.
163
168
wp_redirect ($ to , $ status ).exit (); // It's a good day in Eureka :-)
@@ -200,12 +205,12 @@ public static function redirect_uri_patterns()
200
205
$ _to = preg_replace_callback ('/%% \\\$([^\[]+?)(.+?)%%/i ' , 'wp_redirects::_url_e_gprcs_value ' , $ _to );
201
206
$ _to = preg_replace ('/%%(.+?)%%/i ' , '' , $ _to ); // Ditch any remaining replacement codes.
202
207
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
-
206
208
$ _to = // Cleanup any double slashes left over by replacement codes.
207
209
wp_redirects::trim (preg_replace ('/(?<!\:)\/+/ ' , '/ ' , $ _to ), 0 , '?&=# ' );
208
210
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
+
209
214
$ _status = (is_numeric ($ _status = get_post_meta ($ _pattern ->post_id , 'wp_redirect_status ' , TRUE ))) ? (integer )$ _status : 301 ;
210
215
211
216
wp_redirect ($ _to , $ _status ).exit (); // Redirection URL w/ a possible custom status code.
0 commit comments