When you have the ability to block it via your web server\'s configuration, @Charles\' suggestions are good.
If you can only disable it using php, the xmlrpc_enabled
filter is not the right way.
Like documented here:
https://developer.wordpress.org/reference/hooks/xmlrpc_enabled/
it only disables xml rpc methods that require authentication.
Instead use the xmlrpc_methods
filter to disable all methods:
<?php
// Disable all xml-rpc endpoints
add_filter(\'xmlrpc_methods\', function () {
return [];
}, PHP_INT_MAX);
You can test if it\'s working by sending a POST request to xmlrpc.php with the following content:
<methodCall>
<methodName>system.listMethods</methodName>
</methodCall>
If the filter is working, there should only be 3 methods left:
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
<param>
<value>
<array>
<data>
<value>
<string>system.multicall</string>
</value>
<value>
<string>system.listMethods</string>
</value>
<value>
<string>system.getCapabilities</string>
</value>
</data>
</array>
</value>
</param>
</params>
</methodResponse>
you can quickly test it with curl:
curl -X POST \\
-H \'Cache-Control: no-cache\' \\
-H \'Content-Type: application/xml\' \\
-d \'<methodCall><methodName>system.listMethods</methodName></methodCall>\' \\
https://your-wordpress-site.com/xmlrpc.php