是否可以从插件扩展Wordpress XMLRPC接口? [英] Is it possible to extend Wordpress XMLRPC interface from a plugin?

查看:164
本文介绍了是否可以从插件扩展Wordpress XMLRPC接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能创建一个插件,当该插件处于活动状态时,该插件将向XMLRPC接口添加新的函数"并处理其调用?

Is it possible to create a plugin that, when active, would add a new "function" to the XMLRPC interface and handle its calling?

推荐答案

总之,是的.您可以将函数添加为插件,也可以在主题的用于处理XMLRPC调用的functions.php文件中添加.您将需要以下部分:

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');

此函数将您的方法调用添加到内置XMLRPC方法处理程序中.当有人使用此方法请求 http://yoursite.com/xmlrpc.php 时,所有参数将发送到my_method_callback()函数:

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
}

我使用此系统来处理我的插件的错误报告.当我的一个插件在客户的网站上发生故障时,它会通过将数据发布到 http://上来报告故障. www.mywordpressinstallation.com/xmlrpc.php .在我的网站上,我有一个插件将该信息存储在数据库中,以便以后查看并修复错误.

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.

这篇关于是否可以从插件扩展Wordpress XMLRPC接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆