remove_action()删除一个动作的回调方法

目录

描述

译文

该函数移除一个附属于指定动作hook的函数。该方法可用来移除附属于特定动作hook的默认函数,并可能用其它函数取而代之。参见remove_action(), add_filter()和add_action()。

重要:添加hook时的$function_to_remove 和$priority参数要能够相匹配,这样才可以移除hook。该原则也适用于过滤器和动作。移除失败时不进行警告提示。

原文

This function is an alias to remove_filter().

This function removes a function attached to a specified action hook. This method can be used to remove default functions attached to a specific action hook and possibly replace them with a substitute. See also remove_filter(), add_action() and add_filter().

Important: To remove a hook, the $function_to_remove and $priority arguments must match when the hook was added. This goes for both filters and actions. No warning will be given on removal failure.

remove_action() 描述

用法

<?php remove_action$tag$function_to_remove$priority ); ?>

remove_action() 用法

参数

$tag

(string) (必填) The action hook to which the function to be removed is hooked.

默认值: None

$function_to_remove

(callable) (必填) The name of the function which should be removed.

默认值: None

$priority

(int) (可选) The priority of the function (as defined when the function was originally hooked).

默认值: 10

remove_action() 参数

历史

添加于 版本: 1.2.0

remove_action() 历史

源文件

remove_action() 函数的代码位于 wp-includes/plugin.php.

remove_action() 源文件

相关