WordPress: Function Reference/remove filter:修订间差异
来自站长百科
无编辑摘要 |
无编辑摘要 |
||
第1行: | 第1行: | ||
== 描述== | == 描述== | ||
这个函数移除了附加在某个filter hook上的函数。这种方法可以用来移除附加在某个filter hook上的默认函数,同时可以将这些默认函数替换为另一个函数。也看看[[WordPress:Function Reference/remove action|remove_action()]], [[WordPress:Function Reference/add filter|add_filter()]] 和 [[WordPress:Function Reference/add action|add_action()]]。 | 这个函数移除了附加在某个filter hook上的函数。这种方法可以用来移除附加在某个filter hook上的默认函数,同时可以将这些默认函数替换为另一个函数。也看看[[WordPress:Function Reference/remove action|remove_action()]], [[WordPress:Function Reference/add filter|add_filter()]] 和 [[WordPress:Function Reference/add action|add_action()]]。 | ||
'''''重点:'''要移除hook,添加hook时,<tt>$function_to_remove</tt>和<tt>$priority</tt>参数必须匹配。这也同样适用于filters和actions。移除操作失败,不会给通知。 | '''''重点:'''要移除hook,添加hook时,<tt>$function_to_remove</tt>和<tt>$priority</tt>参数必须匹配。这也同样适用于filters和actions。移除操作失败,不会给通知。 | ||
== 例子 == | == 例子 == | ||
这个函数与[[WordPress:Function Reference/remove action|remove_action()]]函数是相同的。 | 这个函数与[[WordPress:Function Reference/remove action|remove_action()]]函数是相同的。 | ||
<?php remove_filter($tag, $function_to_remove, $priority, $accepted_args); ?> | <?php remove_filter($tag, $function_to_remove, $priority, $accepted_args); ?> | ||
== 参数 == | == 参数 == | ||
{{Parameter|$tag|string|函数将要被移除的action hook is hooked。}} | {{Parameter|$tag|string|函数将要被移除的action hook 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日 (六) 15:38的最新版本
描述[ ]
这个函数移除了附加在某个filter hook上的函数。这种方法可以用来移除附加在某个filter hook上的默认函数,同时可以将这些默认函数替换为另一个函数。也看看remove_action(), add_filter() 和 add_action()。
重点:要移除hook,添加hook时,$function_to_remove和$priority参数必须匹配。这也同样适用于filters和actions。移除操作失败,不会给通知。
例子[ ]
这个函数与remove_action()函数是相同的。 <?php remove_filter($tag, $function_to_remove, $priority, $accepted_args); ?>
参数[ ]
返回[ ]
(boolean) 函数是否被移除。
- True
- 函数被成功地移除了。
- False
- 函数没有被移除。