doing_filter( null|string $filter = null )
Retrieve the name of a filter currently being processed.
描述
The function current_filter() only returns the most recent filter or action being executed. did_action() returns true once the action is initially processed.
This function allows detection for any filter currently being executed (despite not being the most recent filter to fire, in the case of hooks called from hook callbacks) to be verified.
参数
- $filter
-
(null|string)
(Optional)
Filter to check. Defaults to null, which checks if any filter is currently being run.Default value: null
返回值
(bool) Whether the filter is currently in the stack.
源代码
File: wp-includes/plugin.php
function doing_filter( $filter = null ) {
global $wp_current_filter;
if ( null === $filter ) {
return ! empty( $wp_current_filter );
}
return in_array( $filter, $wp_current_filter );
}
更新日志
Version | 描述 |
---|---|
3.9.0 | Introduced. |
相关函数
Used By
-
wp-includes/plugin.php:
doing_action()
User Contributed Notes
-
Skip to note content
You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
Contributed by
Codex
To check if any filter is being applied you could write something like this:
if (doing_filter() ) { // Do Something Here }
你可能对这些文章感兴趣:
- wordpress函数edit_user()用法示例
- wordpress函数email_exists()用法示例
- wordpress函数endElement()用法示例
- wordpress函数edit_term_link()用法示例
- wordpress函数edit_post_link()用法示例
- wordpress函数edit_tag_link()用法示例
- wordpress函数edit_link()用法示例
- wordpress函数edit_post()用法示例
- wordpress函数edit_comment_link()用法示例
- wordpress函数edit_form_image_editor()用法示例
- wordpress函数edit_bookmark_link()用法示例
- wordpress函数edit_comment()用法示例
- wordpress函数drop_index()用法示例
- wordpress函数dynamic_sidebar()用法示例
如有疑问,请前往问答中心反馈!
反馈