If I have lots of custom methods what
is the best approach to handling this?
Instead of filtering xmlrpc_methods
, you could extend the wp_xmlrpc_server
class and set your class as default with the filter wp_xmlrpc_server_class
.
// Webeo_XMLRPC.php
include_once(ABSPATH . WPINC . '/class-IXR.php');
include_once(ABSPATH . WPINC . '/class-wp-xmlrpc-server.php');
class Webeo_XMLRPC extends wp_xmlrpc_server {
public function __construct() {
parent::__construct();
$methods = array(
'webeo.getPost' => 'this:webeo_getPost',
'webeo.getPosts' => 'this:webeo_getPosts'
);
$this->methods = array_merge($this->methods, $methods);
}
public static function webeo_getName() {
return __CLASS__;
}
public function sayHello($args) {
return 'Hello Commander!';
}
public function webeo_getPost($args) {
// do the magic
}
public function webeo_getPosts($args) {
// do the magic
}
}
add_filter('wp_xmlrpc_server_class', array('Webeo_XMLRPC', 'webeo_getName'));