Apologies, I didn’t look into the issue in detail. I simply switched the plugin on and saw that XML-RPC was still reachable. I only got as far as the “XML-RPC server accepts POST requests only” message, while I think the xmlrpc_enabled
filter is checked further down the line.
There are indeed plenty of ways to block XML-RPC, and there’s no reason why your plugin should have to limit itself to just one of them. Here’s some code (go ahead and use it for free) for blocking that file with WordPress’ .htaccess, using activation hooks to make sure it’s applied with the plugin.
add_filter('mod_rewrite_rules', 'noxmlrpc_mod_rewrite_rules');
function noxmlrpc_mod_rewrite_rules($rules) {
$insert = "RewriteRule xmlrpc\.php$ - [F,L]";
$rules = preg_replace('!RewriteRule!', "$insert\n\nRewriteRule", $rules, 1);
return $rules;
}
register_activation_hook(__FILE__, 'noxmlrpc_htaccess_activate');
function noxmlrpc_htaccess_activate() {
flush_rewrite_rules(true);
}
register_deactivation_hook(__FILE__, 'noxmlrpc_htaccess_deactivate');
function noxmlrpc_htaccess_deactivate() {
remove_filter('mod_rewrite_rules', 'noxmlrpc_mod_rewrite_rules');
flush_rewrite_rules(true);
}