钩子文档

xmlrpc_enabled

💡 云策文档标注

概述

xmlrpc_enabled 过滤器用于控制需要认证的 XML-RPC 方法是否启用,而非完全禁用 XML-RPC。它替代了 3.5 版本中的 enable_xmlrpc UI 选项,以实现功能对等。

关键要点

  • 过滤器仅影响需要认证的 XML-RPC 方法(如发布功能),不影响无需认证的 pingbacks 或自定义端点。
  • 默认值为 true,表示启用;可通过 add_filter('xmlrpc_enabled', '__return_false') 禁用。
  • 如需更细粒度控制所有 XML-RPC 方法和请求,应使用 'xmlrpc_methods' 和 'xmlrpc_element_limit' 钩子。

代码示例

add_filter( 'xmlrpc_enabled', '__return_false' );

注意事项

文档中提到的 xmlrpc_element_limit 钩子链接可能已失效,需注意检查更新。


📄 原文内容

Filters whether XML-RPC methods requiring authentication are enabled.

Description

Contrary to the way it’s named, this filter does not control whether XML-RPC is fully enabled, rather, it only controls whether XML-RPC methods requiring authentication – such as for publishing purposes – are enabled.

Further, the filter does not control whether pingbacks or other custom endpoints that don’t require authentication are enabled. This behavior is expected, and due to how parity was matched with the enable_xmlrpc UI option the filter replaced when it was introduced in 3.5.

To disable XML-RPC methods that require authentication, use:

add_filter( 'xmlrpc_enabled', '__return_false' );

For more granular control over all XML-RPC methods and requests, see the ‘xmlrpc_methods’ and ‘xmlrpc_element_limit’ hooks.

Parameters

$is_enabledbool
Whether XML-RPC is enabled. Default true.

Source

$this->is_enabled = apply_filters( 'xmlrpc_enabled', $is_enabled );

Changelog

Version Description
3.5.0 Introduced.

User Contributed Notes