mirror of
https://github.com/szepeviktor/wordpress-website-lifecycle.git
synced 2025-08-20 19:21:05 +08:00
Add Reencode spaces in query string with %20
This commit is contained in:
parent
6c885e8258
commit
6561a0e541
1 changed files with 29 additions and 0 deletions
29
mu-plugins/_core-http-reencode-query-string-spaces.php
Normal file
29
mu-plugins/_core-http-reencode-query-string-spaces.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Plugin Name: Reencode spaces in query string with %20
|
||||
*/
|
||||
|
||||
add_action(
|
||||
'init',
|
||||
static function () {
|
||||
$parsed_url = parse_url($_SERVER['REQUEST_URI']);
|
||||
if (!isset($parsed_url['path']) || $parsed_url['path'] === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$request_uri = $parsed_url['path'];
|
||||
$query_string = '';
|
||||
if (isset($parsed_url['query'])) {
|
||||
$query_parameters = [];
|
||||
parse_str($parsed_url['query'], $query_parameters);
|
||||
$query_string = http_build_query($query_parameters, '', '&', PHP_QUERY_RFC3986);
|
||||
$request_uri .= '?' . $query_string;
|
||||
}
|
||||
|
||||
$_SERVER['REQUEST_URI'] = $request_uri;
|
||||
$_SERVER['QUERY_STRING'] = $query_string;
|
||||
},
|
||||
0,
|
||||
0
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue