自WP 5.1以来,存档相同结果的一种更安全的方法是使用http\\u request\\u reject\\u unsafe\\u URL过滤:
function performize_turn_off_reject_unsafe_urls($ret,$url)
{
//here you can use regex or anything you want to check the url
if($url===\'https://urltowhitelist\')
$ret = false;
return $args;
}
add_filter( \'http_request_reject_unsafe_urls\', \'performize_turn_off_reject_unsafe_urls\',10,2 );
此外,http\\u request\\u args使用2个参数,因此如果要使用http\\u request\\u args,可以通过以下方式执行:
function turn_off_reject_unsafe_urls($args,$url) {
if($url===\'https://urltowhitelist\')
$args[\'reject_unsafe_urls\'] = false;
return $args;
}
add_filter( \'http_request_args\', \'turn_off_reject_unsafe_urls\',10,2);