did_action( string $tag )
Retrieve the number of times an action is fired.
描述
参数
- $tag
-
(string)
(Required)
The name of the action hook.
返回值
(int) The number of times action hook $tag is fired.
源代码
File: wp-includes/plugin.php
function did_action($tag) {
global $wp_actions;
if ( ! isset( $wp_actions[ $tag ] ) )
return 0;
return $wp_actions[$tag];
}
更新日志
Version | 描述 |
---|---|
2.1.0 | Introduced. |
相关函数
Used By
-
wp-includes/class-wp-editor.php:
_WP_Editors::enqueue_default_editor() -
wp-includes/class-wp-customize-manager.php:
WP_Customize_Manager::_publish_changeset_values() -
wp-includes/class-wp-customize-manager.php:
WP_Customize_Manager::import_theme_starter_content() -
wp-includes/theme.php:
_wp_customize_publish_changeset() -
wp-includes/class-wp-site.php:
WP_Site::__get() -
wp-includes/class-wp-site.php:
WP_Site::__isset() -
wp-includes/theme.php:
add_theme_support() -
wp-includes/theme.php:
_remove_theme_support() -
wp-includes/general-template.php:
wp_admin_css() -
wp-includes/load.php:
wp_load_translations_early() -
wp-includes/functions.php:
_default_wp_die_handler() -
wp-includes/taxonomy.php:
create_initial_taxonomies() -
wp-includes/media.php:
wp_enqueue_media() -
wp-includes/embed.php:
wp_oembed_add_provider() -
wp-includes/embed.php:
wp_oembed_remove_provider() -
wp-includes/media.php:
wp_video_shortcode() -
wp-includes/media.php:
wp_audio_shortcode() -
wp-includes/class-wp-rewrite.php:
WP_Rewrite::wp_rewrite_rules() -
wp-includes/class-wp-rewrite.php:
WP_Rewrite::flush_rules() -
wp-includes/ms-blogs.php:
switch_to_blog() -
wp-includes/ms-blogs.php:
restore_current_blog() -
wp-includes/wp-db.php:
wpdb::check_connection() -
wp-includes/wp-db.php:
wpdb::select() -
wp-includes/widgets.php:
wp_register_sidebar_widget() -
wp-includes/widgets.php:
wp_register_widget_control() -
wp-includes/widgets.php:
_register_widget_form_callback() -
wp-includes/class-wp-customize-widgets.php:
WP_Customize_Widgets::call_widget_update() -
wp-includes/script-loader.php:
print_head_scripts() -
wp-includes/script-loader.php:
wp_print_head_scripts() -
wp-includes/script-loader.php:
script_concat_settings() -
wp-includes/script-loader.php:
wp_default_scripts()
Show 26 more used by
Hide more used by
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
Example
Using did_action() function to make sure custom meta field is only added during the first run since it can run multiple times.
function my_sticky_option() { global $post; // if the post is a custom post type and only during the first execution of the action quick_edit_custom_box if ( $post->post_type == 'custom_post_type' && did_action( 'quick_edit_custom_box' ) === 1 ) { ?> <fieldset class="inline-edit-col-right"> <div class="inline-edit-col"> <label class="alignleft"> <input type="checkbox" name="sticky" value="sticky" /> <span class="checkbox-title"> <?php _e( 'Featured (sticky)', 'textdomain_string' ); ?> </span> </label> </div> </fieldset> <?php } // endif; } // add the sticky option to the quick edit area add_action( 'quick_edit_custom_box', 'my_sticky_option' );
你可能对这些文章感兴趣:
- wordpress函数gd_edit_image_support()用法示例
- wordpress函数funky_javascript_callback()用法示例
- wordpress函数funky_javascript_fix()用法示例
- wordpress函数gallery_shortcode()用法示例
- wordpress函数format_to_post()用法示例
- wordpress函数form_option()用法示例
- wordpress函数format_to_edit()用法示例
- wordpress函数force_ssl_login()用法示例
- wordpress函数format_code_lang()用法示例
- wordpress函数format_for_editor()用法示例
- wordpress函数force_ssl_content()用法示例
- wordpress函数flush_rewrite_rules()用法示例
- wordpress函数force_balance_tags()用法示例
- wordpress函数force_ssl_admin()用法示例
如有疑问,请前往问答中心反馈!
反馈