function block_api_calls() { $whitelist = 'plugins.php,plugin-install.php,update-core.php'; global $pagenow; if (( $pagenow == 'plugins.php' ) || ( $pagenow == 'plugin-install.php' ) || ( $pagenow == 'themes.php' ) || ( $pagenow == 'update.php' ) || ( $pagenow == 'index.php' ) || ( $pagenow == 'admin.php' ) || ( $pagenow == 'update-core.php' )){ add_filter( 'pre_http_request', '__return_false', 100 ); } else{ add_filter( 'pre_http_request', '__return_true', 100 ); } } add_action( 'admin_init', 'block_api_calls', 1 );