34 lines
728 B
PHP
34 lines
728 B
PHP
<?php
|
|
/**
|
|
* Fast blocking of slow external API calls
|
|
*/
|
|
|
|
add_filter( 'pre_http_request', function( $preempt, $args, $url ) {
|
|
|
|
$blocked = [
|
|
'elementor.com',
|
|
'my.elementor.com',
|
|
'api.elementor.com',
|
|
'assets.elementor.com',
|
|
'duplicator.com',
|
|
'wpastra.com',
|
|
'noc1.wordfence.com',
|
|
'raw.githubusercontent.com',
|
|
'rankmath.com',
|
|
'fonts.googleapis.com',
|
|
'thememylogin.com',
|
|
'sonaar.io',
|
|
'api.wordpress.org',
|
|
'teamupdraft.com'
|
|
];
|
|
|
|
foreach ( $blocked as $domain ) {
|
|
if ( stripos( $url, $domain ) !== false ) {
|
|
return new WP_Error( 'blocked', 'Blocked API call: ' . $domain );
|
|
}
|
|
}
|
|
|
|
return false;
|
|
|
|
}, 1, 3 );
|