So far as I know, the XML RPC class is not instantiated unless needed, which is when the request is to /xmlrpc.php
.
You would instantiate the class the same way the Core does:
include_once(ABSPATH . 'wp-admin/includes/admin.php');
include_once(ABSPATH . WPINC . '/class-IXR.php');
include_once(ABSPATH . WPINC . '/class-wp-xmlrpc-server.php');
/**
* Posts submitted via the XML-RPC interface get that title
* @name post_default_title
* @var string
*/
$post_default_title = "";
/**
* Filter the class used for handling XML-RPC requests.
*
* @since 3.1.0
* @param string The name of the XML-RPC server class.
*/
$wp_xmlrpc_server_class = apply_filters( 'wp_xmlrpc_server_class', 'wp_xmlrpc_server' );
$wp_xmlrpc_server = new $wp_xmlrpc_server_class;
You have two options for doing that:
- Create a method inside your class to instantiate the XML RPC class,
and save the instance to a class variable. - Instantiate outside of the class and pass the instance to your
class. This is something called “dependency injection“, which has both pros and cons.