当前浏览:首页 / WordPress函数 / remove_all_filters()

remove_all_filters( string $hook_name, int|false $priority = false ): true

从过滤器钩子中删除所有回调函数

allmore...

filter 过滤

removemore...


参数

$hook_namestring必填
要从中删除回调的过滤器。
$priorityint|false可选
从中删除它们的优先级编号

默认:false


返回

true 始终返回true。



源码

查看源码 官方文档


更新日志

版本描述
2.7.0开始引入

使用示例

  • 示例1

    例子:

    remove_all_filters( 'the_content' );

    这个示例将删除the_content函数中的所有钩子,用于任何插件或主题。
    但是,如果您只想以特定的优先级删除一组特定的钩子,则可以使用优先级,10是大多数过滤器的默认值:

    remove_all_filters( 'wp_delete_file', 10 );

    由于类派生过滤器很难删除,如果它们使用非默认优先级(以15为例),您可以改为这样做:

    remove_all_filters( 'wp_delete_file', 15 );
  • 示例2

    例子:

    remove_all_filters('the_content', 'plugin_filters');

    此示例将删除the_content函数中的所有插件挂钩。