How to check is XML-RPC enabled in WordPress
XML-RPC is enabled by default for WP versions > 3.5 (with 'xmlrpc_enabled' hook which allow to disable it) For older versions, there is a field in the database (options table), which indicates if it is enabled or not.(This option is removed for wp > 3.5)
function is_xmlrpc_enabled() {
$returnBool = false;
$enabled = get_option('enable_xmlrpc'); //for ver<3.5
if($enabled) {
$returnBool = true;
}
else {
global $wp_version;
if (version_compare($wp_version, '3.5', '>=')) {
$returnBool = true; //its on by default for versions above 3.5
}
else {
$returnBool = false;
}
}
return $returnBool;
}
WordPress has two test methods in its XML-RPC server:
demo.sayHello – Returns a standard “Hello!” message.
demo.addTwoNumbers – Accepts an array containing two numbers and returns the sum.
function sayHello()
{
$params = array();
return $this->send_request('demo.sayHello',$params);
}
$objXMLRPClientWordPress = new XMLRPClientWordPress("http://localhost/wordpress31/xmlrpc.php" , "username" , "passowrd");
function send_request($requestname, $params)
{
$request = xmlrpc_encode_request($requestname, $params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_URL, $this->XMLRPCURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$results = curl_exec($ch);
curl_close($ch);
return $results;
}
If you get the same result it means you are able to send the request properly to your WordPress XML-RPC server and receive the request properly.