^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 5年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云1核2g仅需102元/年,今日10点开抢

wordpress函数did_action()用法示例

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

  1. 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' );
    

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈