我通过使用wp\\u resource\\u hints filter和preg\\u match实现了这一点:
/**
* Removes dns-prefetchs links in header
*/
public function remove_prefetchs($urls) {
foreach ($urls as $key => $url) {
if(preg_match(\'/google.com|code.jquery.com$/\', $url) === 1) {
unset( $urls[ $key ] );
}
}
return $urls;
}
add_filter( \'wp_resource_hints\', array( $this, \'remove_prefetchs\' ), 10, 2);