WordPress: Function Reference/remove action:修订间差异
来自站长百科
无编辑摘要 |
无编辑摘要 |
||
第1行: | 第1行: | ||
== 描述== | == 描述== | ||
这个函数移除了附加到某个action hook上的函数。这种方法也可以用来移除复交到某个action hook上的默认函数而且将替换为其它的函数。也看看[[WordPress:Function Reference/remove filter|remove_filter()]], [[WordPress:Function Reference/add action|add_action()]] 和 [[WordPress:Function Reference/add filter|add_filter()]]。 | 这个函数移除了附加到某个action hook上的函数。这种方法也可以用来移除复交到某个action hook上的默认函数而且将替换为其它的函数。也看看[[WordPress:Function Reference/remove filter|remove_filter()]], [[WordPress:Function Reference/add action|add_action()]] 和 [[WordPress:Function Reference/add filter|add_filter()]]。 | ||
'''''重点:'''要移除hook,<tt>$function_to_remove</tt> 和<tt>$priority</tt>参数在添加hook的时候,必须匹配。这一点同样适用于filters和actions。移除失败,不会给通知。'' | '''''重点:'''要移除hook,<tt>$function_to_remove</tt> 和<tt>$priority</tt>参数在添加hook的时候,必须匹配。这一点同样适用于filters和actions。移除失败,不会给通知。'' | ||
== 例子 == | == 例子 == | ||
这个函数与[[WordPress:Function Reference/remove filter|remove_filter()]]函数相同。 | 这个函数与[[WordPress:Function Reference/remove filter|remove_filter()]]函数相同。 | ||
<?php remove_action($tag, $function_to_remove, $priority, $accepted_args); ?> | <?php remove_action($tag, $function_to_remove, $priority, $accepted_args); ?> | ||
== 参数 == | == 参数 == | ||
{{Parameter|$tag|string|The action hook to which the function to be removed is hooked.}} | {{Parameter|$tag|string|The action hook to which the function to be removed is hooked.}} | ||
{{Parameter|$function_to_remove|string|应该移除的函数名称。}} | {{Parameter|$function_to_remove|string|应该移除的函数名称。}} | ||
{{Parameter|$priority|int|函数的优先级。 (如函数最初hooked时定义的那样)。|optional|10}} | {{Parameter|$priority|int|函数的优先级。 (如函数最初hooked时定义的那样)。|optional|10}} | ||
{{Parameter|$accepted_args|int|函数接受的参数的数目。|optional|1}} | {{Parameter|$accepted_args|int|函数接受的参数的数目。|optional|1}} | ||
== 返回 == | == 返回 == | ||
(''boolean'') 函数是否被移除。 | (''boolean'') 函数是否被移除。 | ||
; <tt>True</tt> : 函数成功地移除了。 | ; <tt>True</tt> : 函数成功地移除了。 | ||
; <tt>False</tt> : 函数不能够移除。 | ; <tt>False</tt> : 函数不能够移除。 |
2008年7月26日 (六) 16:53的最新版本
描述[ ]
这个函数移除了附加到某个action hook上的函数。这种方法也可以用来移除复交到某个action hook上的默认函数而且将替换为其它的函数。也看看remove_filter(), add_action() 和 add_filter()。
重点:要移除hook,$function_to_remove 和$priority参数在添加hook的时候,必须匹配。这一点同样适用于filters和actions。移除失败,不会给通知。
例子[ ]
这个函数与remove_filter()函数相同。
<?php remove_action($tag, $function_to_remove, $priority, $accepted_args); ?>
参数[ ]
返回[ ]
(boolean) 函数是否被移除。
- True
- 函数成功地移除了。
- False
- 函数不能够移除。