Can I extend the Wordpress XMLRPC interface from a plugin?

Is it possible to create a plugin that, when active, adds a new function to the XMLRPC interface and processes its call?

+2
source share
1 answer

In short, yes. You can add a function as a plug-in or in a theme functions.php file that handles XMLRPC calls. You will need the following sections:

function xml_add_method( $methods ) { $methods['myClient.myMethod'] = 'my_method_callback'; return $methods; } add_filter( 'xmlrpc_methods', 'xml_add_method'); 

This function adds a method call to the built-in XMLRPC method handler. When someone accesses http://yoursite.com/xmlrpc.php using this method, all parameters will be sent to the my_method_callback() function:

 function my_method_callback( $args ) { // Do Something // Return Something } 

I use this system to handle error messages using my plugins. When one of my plug-ins is faulty on the client website, it reports a failure by posting http://www.mywordpressinstallation.com/xmlrpc.php . I have a plugin on my site that stores this information in a database, so I can view it later and fix the errors.

+6
source

Source: https://habr.com/ru/post/1308573/


All Articles