do_action( string $hook_name, mixed $arg )
Calls the callback functions that have been added to an action hook.
Description
This function invokes all functions attached to action hook $hook_name
.
It is possible to create new action hooks by simply calling this function, specifying the name of the new hook using the $hook_name
parameter.
You can pass extra arguments to the hooks, much like you can with apply_filters()
.
Example usage:
// The action callback function.
function example_callback( $arg1, $arg2 ) {
// (maybe) do something with the args.
}
add_action( 'example_action', 'example_callback', 10, 2 );
/*
* Trigger the actions by calling the 'example_callback()' function
* that's hooked onto `example_action` above.
*
* - 'example_action' is the action hook.
* - $arg1 and $arg2 are the additional arguments passed to the callback.
do_action( 'example_action', $arg1, $arg2 );
Parameters
- $hook_name
-
(Required) The name of the action to be executed.
- $arg
-
(Optional) Additional arguments which are passed on to the functions hooked to the action. Default empty.
Source
File: wp-includes/plugin.php
function do_action($tag, $arg = '') {
global $wp_filter, $wp_actions, $wp_current_filter;
if ( ! isset($wp_actions[$tag]) )
$wp_actions[$tag] = 1;
else
++$wp_actions[$tag];
$all_args = func_get_args();
// Do 'all' actions first
if ( isset($wp_filter['all']) ) {
$wp_current_filter[] = $tag;
_wp_call_all_hook( $all_args );
}
if ( !isset($wp_filter[$tag]) ) {
if ( isset($wp_filter['all']) )
array_pop($wp_current_filter);
return;
}
if ( !isset($wp_filter['all']) )
$wp_current_filter[] = $tag;
$args = $all_args;
array_shift( $args );
if ( empty( $args ) ) {
$args = array( '' );
}
$wp_filter[ $tag ]->do_action( $args );
array_pop($wp_current_filter);
}
Related
Uses
Uses | Description |
---|---|
wp-includes/plugin.php: _wp_call_all_hook() |
Calls the ‘all’ hook, which will process the functions hooked into it. |
Used By
Used By | Description |
---|---|
wp-admin/includes/class-wp-application-passwords-list-table.php: WP_Application_Passwords_List_Table::print_js_template_row() |
Prints the JavaScript template for the new row item. |
wp-admin/includes/class-wp-application-passwords-list-table.php: WP_Application_Passwords_List_Table::column_default() |
Generates content for a single row of the table |
wp-admin/includes/class-wp-ms-sites-list-table.php: WP_MS_Sites_List_Table::extra_tablenav() |
Extra controls to be displayed between bulk actions and pagination. |
wp-admin/includes/meta-boxes.php: register_and_do_post_meta_boxes() |
Registers the default post meta boxes, and runs the |
wp-includes/classicpress/class-wp-compat.php: WP_Compat::using_block_function() |
This function have to be called from a polyfill to map themes and plugins calling those functions. |
wp-includes/sitemaps.php: wp_sitemaps_get_server() |
Retrieves the current Sitemaps server instance. |
wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php: WP_REST_Sidebars_Controller::update_item() |
Updates a sidebar. |
wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php: WP_REST_Menus_Controller::create_item() |
Creates a single term in a taxonomy. |
wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php: WP_REST_Menus_Controller::update_item() |
Updates a single term from a taxonomy. |
wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php: WP_REST_Menus_Controller::delete_item() |
Deletes a single term from a taxonomy. |
wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php: WP_REST_Menus_Controller::handle_auto_add() |
Updates the menu’s auto add from a REST request. |
wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php: WP_REST_Autosaves_Controller::create_post_autosave() |
Creates autosave for the specified post. |
wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php: WP_REST_Application_Passwords_Controller::create_item() |
Creates an application password. |
wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php: WP_REST_Application_Passwords_Controller::update_item() |
Updates an application password. |
wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php: WP_REST_Menu_Items_Controller::delete_item() |
Deletes a single menu item. |
wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php: WP_REST_Menu_Items_Controller::create_item() |
Creates a single post. |
wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php: WP_REST_Menu_Items_Controller::update_item() |
Updates a single nav menu item. |
wp-includes/object-relationships.php: cp_object_relationship_exists() |
Check if a relationship exists between two recognized objects. |
wp-includes/object-relationships.php: cp_add_object_relationship() |
Create a relationship between two recognized objects. |
wp-includes/object-relationships.php: cp_delete_object_relationship() |
Delete a relationship between two recognized objects. |
wp-includes/ms-site.php: wp_maybe_transition_site_statuses_on_update() |
Triggers actions on site status updates. |
wp-includes/ms-site.php: wp_prepare_site_data() |
Prepares site data for insertion or update in the database. |
wp-includes/ms-site.php: wp_insert_site() |
Inserts a new site into the database. |
wp-includes/ms-site.php: wp_update_site() |
Updates a site in the database. |
wp-includes/ms-site.php: wp_delete_site() |
Deletes a site from the database. |
wp-includes/general-template.php: wp_body_open() |
Fires the wp_body_open action. |
wp-signup.php: confirm_user_signup() |
Shows a message confirming that the new user has been registered and is awaiting activation. |
wp-signup.php: signup_blog() |
Shows a form for a user or visitor to sign up for a new site. |
wp-signup.php: confirm_blog_signup() |
Shows a message confirming that the new site has been registered and is awaiting activation. |
wp-signup.php: do_signup_header() |
Prints signup_header via wp_head. |
wp-signup.php: show_blog_form() |
Generates and displays the Sign-up and Create Site forms. |
wp-signup.php: show_user_form() |
Displays the fields for the new user account registration form. |
wp-signup.php: signup_another_blog() |
Shows a form for returning users to sign up for another site. |
wp-signup.php: confirm_another_blog_signup() |
Shows a message confirming that the new site has been created. |
wp-signup.php: signup_user() |
Shows a form for a visitor to sign up for a new user account. |
wp-login.php: login_header() |
Output the login page header. |
wp-login.php: login_footer() |
Outputs the footer for the login page. |
wp-includes/customize/class-wp-customize-nav-menu-item-control.php: WP_Customize_Nav_Menu_Item_Control::content_template() |
JS/Underscore template for the control UI. |
wp-includes/general-template.php: wp_enqueue_code_editor() |
Enqueues assets needed by the code editor for the given settings. |
wp-includes/general-template.php: wp_head() |
Fires the wp_head action. |
wp-includes/general-template.php: wp_footer() |
Fires the wp_footer action. |
wp-includes/general-template.php: wp_meta() |
Theme container function for the ‘wp_meta’ action. |
wp-includes/general-template.php: get_header() |
Loads header template. |
wp-includes/general-template.php: get_footer() |
Loads footer template. |
wp-includes/general-template.php: get_sidebar() |
Loads sidebar template. |
wp-includes/general-template.php: get_template_part() |
Loads a template part into a template. |
wp-includes/general-template.php: get_search_form() |
Displays search form. |
wp-includes/script-loader.php: wp_print_footer_scripts() |
Hooks to print the scripts and styles in the footer. |
wp-includes/script-loader.php: wp_enqueue_scripts() |
Wrapper for do_action( ‘wp_enqueue_scripts’ ). |
wp-includes/script-loader.php: wp_print_head_scripts() |
Prints the script queue in the HTML head on the front end. |
wp-includes/script-loader.php: print_head_scripts() |
Prints the script queue in the HTML head on admin pages. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::create_item() |
Creates a comment. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::update_item() |
Updates a comment. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::delete_item() |
Deletes a comment. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::create_item() |
Creates a single user. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::update_item() |
Updates a single user. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::delete_item() |
Deletes a single user. |
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php: WP_REST_Terms_Controller::create_item() |
Creates a single term in a taxonomy. |
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php: WP_REST_Terms_Controller::update_item() |
Updates a single term from a taxonomy. |
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php: WP_REST_Terms_Controller::delete_item() |
Deletes a single term from a taxonomy. |
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php: WP_REST_Revisions_Controller::delete_item() |
Deletes a single revision. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::create_item() |
Creates a single post. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::update_item() |
Updates a single post. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::delete_item() |
Deletes a single post. |
wp-includes/functions.wp-styles.php: wp_print_styles() |
Displays styles that are in the $handles queue. |
wp-includes/template.php: load_template() |
Requires the template file with WordPress environment. |
wp-includes/media-template.php: wp_print_media_templates() |
Prints the templates used in the media manager. |
wp-includes/nav-menu.php: wp_delete_nav_menu() |
Deletes a navigation menu. |
wp-includes/nav-menu.php: wp_update_nav_menu_object() |
Saves the properties of a menu or create a new menu with those properties. |
wp-includes/nav-menu.php: wp_update_nav_menu_item() |
Saves the properties of a menu item or create a new one. |
wp-includes/embed.php: enqueue_embed_scripts() |
Enqueues embed iframe default CSS and JS. |
wp-includes/ms-load.php: ms_load_current_site_and_network() |
Identifies the network and site of a requested domain and path and populates the corresponding network and site global objects as part of the multisite bootstrap process. |
wp-includes/capabilities.php: grant_super_admin() |
Grants Super Admin privileges. |
wp-includes/capabilities.php: revoke_super_admin() |
Revokes Super Admin privileges. |
wp-includes/functions.wp-scripts.php: wp_print_scripts() |
Prints scripts in document head that are in the $handles queue. |
wp-includes/ms-network.php: clean_network_cache() |
Removes a network from the object cache. |
wp-includes/ms-blogs.php: switch_to_blog() |
Switches the current blog. |
wp-includes/ms-blogs.php: restore_current_blog() |
Restores the current blog, after calling switch_to_blog(). |
wp-includes/ms-site.php: clean_blog_cache() |
Clean the blog cache |
wp-includes/ms-blogs.php: wpmu_update_blogs_date() |
Updates the last_updated field for the current site. |
wp-includes/meta.php: update_metadata_by_mid() |
Updates metadata by meta ID. |
wp-includes/meta.php: delete_metadata_by_mid() |
Deletes metadata by meta ID. |
wp-includes/meta.php: add_metadata() |
Adds metadata for the specified object. |
wp-includes/meta.php: update_metadata() |
Updates metadata for the specified object. If no value already exists for the specified object ID and metadata key, the metadata will be added. |
wp-includes/meta.php: delete_metadata() |
Deletes metadata for the specified object. |
wp-includes/theme.php: check_theme_switched() |
Checks if a theme has been changed and runs ‘after_switch_theme’ hook on the next WP load. |
wp-includes/theme.php: _wp_customize_publish_changeset() |
Publishes a snapshot’s changes. |
wp-includes/theme.php: switch_theme() |
Switches the theme. |
wp-includes/post-thumbnail-template.php: get_the_post_thumbnail() |
Retrieves the post thumbnail. |
wp-includes/ms-functions.php: add_existing_user_to_blog() |
Adds a user to a blog based on details from maybe_add_existing_user_to_blog(). |
wp-includes/ms-functions.php: wpmu_signup_blog() |
Records site signup information for future activation. |
wp-includes/ms-functions.php: wpmu_signup_user() |
Records user signup information for future activation. |
wp-includes/ms-functions.php: wpmu_activate_signup() |
Activates a signup. |
wp-includes/ms-functions.php: wpmu_create_user() |
Creates a user. |
wp-includes/ms-functions.php: add_user_to_blog() |
Adds a user to a blog, along with specifying the user’s role. |
wp-includes/ms-functions.php: remove_user_from_blog() |
Removes a user from a blog. |
wp-admin/includes/class-wp-media-list-table.php: WP_Media_List_Table::column_default() |
Handles output for the default column. |
wp-admin/includes/class-wp-media-list-table.php: WP_Media_List_Table::extra_tablenav() | |
wp-admin/includes/class-wp-plugins-list-table.php: WP_Plugins_List_Table::single_row() | |
wp-admin/includes/class-wp-ms-themes-list-table.php: WP_MS_Themes_List_Table::column_default() |
Handles default column output. |
wp-admin/includes/class-wp-ms-themes-list-table.php: WP_MS_Themes_List_Table::single_row() | |
wp-admin/includes/class-wp-comments-list-table.php: WP_Comments_List_Table::extra_tablenav() | |
wp-admin/includes/class-wp-comments-list-table.php: WP_Comments_List_Table::column_default() | |
wp-admin/includes/schema.php: populate_options() |
Create WordPress options and set the default values. |
wp-admin/includes/nav-menu.php: wp_nav_menu_update_menu_items() |
Saves nav menu items. |
wp-admin/includes/class-theme-upgrader.php: Theme_Upgrader::install() |
Install a theme package. |
wp-admin/includes/class-theme-upgrader.php: Theme_Upgrader::bulk_upgrade() |
Upgrade several themes at once. |
wp-admin/includes/class-wp-links-list-table.php: WP_Links_List_Table::column_default() |
Handles the default column output. |
wp-admin/includes/class-core-upgrader.php: Core_Upgrader::upgrade() |
Upgrade ClassicPress core. |
wp-admin/includes/bookmark.php: wp_delete_link() |
Deletes a specified link from the database. |
wp-admin/includes/bookmark.php: wp_insert_link() |
Inserts a link into the database, or updates an existing link. |
wp-admin/includes/class-wp-plugin-install-list-table.php: WP_Plugin_Install_List_Table::display_tablenav() | |
wp-admin/includes/meta-boxes.php: page_attributes_meta_box() |
Displays page attributes form fields. |
wp-admin/includes/meta-boxes.php: link_submit_meta_box() |
Displays link create form fields. |
wp-admin/includes/meta-boxes.php: post_submit_meta_box() |
Displays post submit form fields. |
wp-admin/includes/meta-boxes.php: attachment_submit_meta_box() |
Displays attachment submit form fields. |
wp-admin/includes/meta-boxes.php: post_comment_status_meta_box() |
Displays comments status form fields. |
wp-admin/includes/update-core.php: update_core() |
Upgrades the core of ClassicPress. |
wp-admin/includes/class-wp-privacy-requests-table.php: WP_Privacy_Requests_Table::column_default() |
Default column handler. |
wp-admin/includes/privacy-tools.php: wp_privacy_process_personal_data_erasure_page() |
Mark erasure requests as completed after processing is finished. |
wp-admin/includes/theme.php: delete_theme() |
Removes a theme. |
wp-admin/includes/plugin.php: activate_plugin() |
Attempts activation of plugin in a “sandbox” and redirects on success. |
wp-admin/includes/plugin.php: deactivate_plugins() |
Deactivates a single plugin or multiple plugins. |
wp-admin/includes/plugin.php: delete_plugins() |
Removes directory and files of a plugin for a list of plugins. |
wp-admin/includes/plugin.php: uninstall_plugin() |
Uninstalls a single plugin. |
wp-admin/includes/class-wp-ms-sites-list-table.php: WP_MS_Sites_List_Table::column_plugins() |
Handles the plugins column output. |
wp-admin/includes/class-wp-ms-sites-list-table.php: WP_MS_Sites_List_Table::column_default() |
Handles output for the default column. |
wp-admin/includes/privacy-tools.php: wp_privacy_generate_personal_data_export_file() |
Generate the personal data export file. |
wp-admin/includes/privacy-tools.php: wp_privacy_process_personal_data_export_page() |
Intercept personal data exporter page Ajax responses in order to assemble the personal data export file. |
wp-admin/includes/class-language-pack-upgrader.php: Language_Pack_Upgrader::bulk_upgrade() |
Bulk upgrade language packs. |
wp-admin/includes/class-wp-theme-install-list-table.php: WP_Theme_Install_List_Table::display() |
Displays the theme install table. |
wp-admin/includes/update.php: wp_plugin_update_row() |
Displays update information for a plugin. |
wp-admin/includes/update.php: wp_theme_update_row() |
Displays update information for a theme. |
wp-admin/includes/class-plugin-upgrader.php: Plugin_Upgrader::bulk_upgrade() |
Bulk upgrade several plugins at once. |
wp-admin/includes/class-plugin-upgrader.php: Plugin_Upgrader::install() |
Install a plugin package. |
wp-admin/includes/ms.php: confirm_delete_users() | |
wp-includes/ms-deprecated.php: update_user_status() |
Update the status of a user in the database. |
wp-admin/includes/ms.php: wpmu_delete_user() |
Deletes a user from the network and remove from all sites. |
wp-admin/install.php: display_setup_form() |
Displays installer setup form. |
wp-activate.php: do_activate_header() |
Adds an action hook specific to this page. |
Changelog
Version | Description |
---|---|
5.3.0 | Formalized the existing and already documented ...$arg parameter by adding it to the function signature. |
1.2.0 | Introduced. |