Is it possible to extend Wordpress XMLRPC interface from a plugin?

こ雲淡風輕ζ 提交于 2019-12-06 14:17:54

In short, yes. You can add a function as either a plug-in or in your theme's functions.php file that handles XMLRPC calls. You'll 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 your method call to the built-in XMLRPC method handler. When someone makes a request to http://yoursite.com/xmlrpc.php with 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 reporting with my plug-ins. When one of my plug-ins malfunctions on a client's website, it reports the malfunction by posting data to http://www.mywordpressinstallation.com/xmlrpc.php. On my site, I have a plug-in that stores this information in a database so I can review it later and fix bugs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!