mirror of
https://gh.wpcy.net/https://github.com/szepeviktor/wordpress-website-lifecycle.git
synced 2026-04-24 05:09:10 +08:00
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Plugin Name: Log not WordPress friendly URL query strings
|
|
* Plugin URI: https://github.com/szepeviktor/wordpress-website-lifecycle
|
|
*/
|
|
|
|
add_action(
|
|
'parse_request',
|
|
static function () {
|
|
if (empty($_SERVER['QUERY_STRING'])) {
|
|
return;
|
|
}
|
|
|
|
if (strpos($_SERVER['QUERY_STRING'], '+') !== false) {
|
|
error_log(sprintf(
|
|
'Non-WordPress query string: plus_encoded_whitespace ("%s")',
|
|
$_SERVER['QUERY_STRING']
|
|
));
|
|
return;
|
|
}
|
|
|
|
if (strpos($_SERVER['QUERY_STRING'], '*') !== false) {
|
|
error_log(sprintf(
|
|
'Non-WordPress query string: not_encoded_asterisk ("%s")',
|
|
$_SERVER['QUERY_STRING']
|
|
));
|
|
return;
|
|
}
|
|
|
|
if (preg_match('/%[[:xdigit:]]?[a-f]/', $_SERVER['QUERY_STRING']) === 1) {
|
|
error_log(sprintf(
|
|
'Non-WordPress query string: lower_case_hexadecimal_digit ("%s")',
|
|
$_SERVER['QUERY_STRING']
|
|
));
|
|
return;
|
|
}
|
|
},
|
|
0,
|
|
0
|
|
);
|