add_action( string $hook_name, callable $callback, int $priority = 10, int $accepted_args = 1 )
Adds a callback function to an action hook.
Description
Actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Plugins can specify that one or more of its PHP functions are executed at these points, using the Action API.
Parameters
- $hook_name
-
(Required) The name of the action to add the callback to.
- $callback
-
(Required) The callback to be run when the action is called.
- $priority
-
(Optional) Used to specify the order in which the functions associated with a particular action are executed.<br> Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
Default value: 10
- $accepted_args
-
(Optional) The number of arguments the function accepts.
Default value: 1
Return
(true) Always returns true.
Source
File: wp-includes/plugin.php
function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
return add_filter($tag, $function_to_add, $priority, $accepted_args);
}
Related
Uses
Uses | Description |
---|---|
wp-includes/plugin.php: add_filter() |
Adds a callback function to a filter hook. |
Used By
Used By | Description |
---|---|
wp-admin/includes/class-wp-site-health.php: WP_Site_Health::__construct() |
WP_Site_Health constructor. |
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::__construct() | |
wp-includes/classicpress/class-cp-customization-frontend.php: CP_Customization_Frontend::__construct() | |
wp-includes/classicpress/class-cp-customization.php: CP_Customization::__construct() | |
wp-includes/classicpress/class-cp-customization.php: CP_Customization::add_id_init() |
Add ID column to Post / Page Tables |
wp-includes/class-wp-recovery-mode.php: WP_Recovery_Mode::initialize() |
Initialize recovery mode for the current request. |
wp-includes/sitemaps/class-wp-sitemaps.php: WP_Sitemaps::init() |
Initiates all sitemap functionality. |
wp-includes/ms-site.php: wp_is_site_initialized() |
Checks whether a site is initialized. |
wp-login.php: login_header() |
Output the login page header. |
wp-includes/customize/class-wp-customize-site-icon-control.php: WP_Customize_Site_Icon_Control::__construct() |
Constructor. |
wp-includes/customize/class-wp-customize-nav-menu-item-setting.php: WP_Customize_Nav_Menu_Item_Setting::__construct() |
Constructor. |
wp-includes/customize/class-wp-customize-selective-refresh.php: WP_Customize_Selective_Refresh::__construct() |
Plugin bootstrap for Partial Refresh functionality. |
wp-includes/customize/class-wp-customize-selective-refresh.php: WP_Customize_Selective_Refresh::init_preview() |
Initializes the Customizer preview. |
wp-includes/customize/class-wp-customize-selective-refresh.php: WP_Customize_Selective_Refresh::enqueue_preview_scripts() |
Enqueues preview scripts. |
wp-includes/customize/class-wp-customize-header-image-control.php: WP_Customize_Header_Image_Control::prepare_control() | |
wp-includes/general-template.php: add_thickbox() |
Enqueues the default ThickBox js and css. |
wp-includes/widgets/class-wp-widget-text.php: WP_Widget_Text::_register_one() |
Add hooks for enqueueing assets when registering all widget instances of this widget class. |
wp-includes/widgets/class-wp-widget-recent-comments.php: WP_Widget_Recent_Comments::__construct() |
Sets up a new Recent Comments widget instance. |
wp-includes/widgets/class-wp-widget-custom-html.php: WP_Widget_Custom_HTML::_register_one() |
Add hooks for enqueueing assets when registering all widget instances of this widget class. |
wp-includes/widgets/class-wp-widget-media.php: WP_Widget_Media::_register_one() |
Add hooks while registering all widget instances of this widget class. |
wp-includes/class-wp-post-type.php: WP_Post_Type::register_meta_boxes() |
Registers the post type meta box if a custom callback was specified. |
wp-includes/class-wp-post-type.php: WP_Post_Type::add_hooks() |
Adds the future post hook action for the post type. |
wp-includes/class-wp-customize-widgets.php: WP_Customize_Widgets::selective_refresh_init() |
Adds hooks for selective refresh. |
wp-includes/class-wp-customize-widgets.php: WP_Customize_Widgets::__construct() |
Initial loader. |
wp-includes/class-wp-customize-widgets.php: WP_Customize_Widgets::schedule_customize_register() |
Ensures widgets are available for all types of previews. |
wp-includes/class-wp-customize-widgets.php: WP_Customize_Widgets::customize_preview_init() |
Adds hooks for the Customizer preview. |
wp-includes/class-wp-widget-factory.php: WP_Widget_Factory::__construct() |
PHP5 constructor. |
wp-includes/media-template.php: wp_print_media_templates() |
Prints the templates used in the media manager. |
wp-includes/nav-menu.php: _wp_delete_customize_changeset_dependent_auto_drafts() |
Deletes auto-draft posts associated with the supplied changeset. |
wp-includes/comment.php: wp_set_comment_status() |
Sets the status of a comment. |
wp-includes/admin-bar.php: wp_admin_bar_customize_menu() |
Adds the “Customize” link to the Toolbar. |
wp-includes/class-wp-embed.php: WP_Embed::__construct() |
Constructor |
wp-includes/cron.php: wp_cron() |
Registers _wp_cron() to run on the {@see ‘wp_loaded’} action. |
wp-includes/class-wp-admin-bar.php: WP_Admin_Bar::initialize() |
Initializes the admin bar. |
wp-includes/class-wp-admin-bar.php: WP_Admin_Bar::add_menus() |
Adds menus to the admin bar. |
wp-includes/theme.php: _custom_header_background_just_in_time() |
Registers the internal custom header and background routines. |
wp-includes/plugin.php: register_activation_hook() |
Set the activation hook for a plugin. |
wp-includes/plugin.php: register_deactivation_hook() |
Sets the deactivation hook for a plugin. |
wp-includes/rewrite.php: add_feed() |
Adds a new feed type like /atom1/. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::__construct() |
Constructor. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::setup_theme() |
Starts preview and customize theme. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::import_theme_starter_content() |
Imports theme starter content into the customized state. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::customize_preview_init() |
Prints JavaScript settings. |
wp-includes/class-wp-rewrite.php: WP_Rewrite::wp_rewrite_rules() |
Retrieves the rewrite rules. |
wp-includes/class-wp-rewrite.php: WP_Rewrite::flush_rules() |
Removes rewrite rules and then recreate rewrite rules. |
wp-includes/rest-api.php: rest_api_default_filters() |
Registers the default REST API filters. |
wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::customize_preview_init() |
Adds hooks for the Customizer preview. |
wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::__construct() |
Constructor. |
wp-includes/class-wp-roles.php: WP_Roles::get_roles_data() |
Gets the available roles data. |
wp-includes/class-wp-editor.php: _WP_Editors::editor_settings() | |
wp-includes/class-wp-editor.php: _WP_Editors::enqueue_default_editor() |
Enqueue all editor scripts. |
wp-includes/class-wp-scripts.php: WP_Scripts::__construct() |
Constructor. |
wp-includes/class-wp-customize-setting.php: WP_Customize_Setting::aggregate_multidimensional() |
Set up the setting for aggregated multidimensional values. |
wp-includes/class-wp-customize-setting.php: WP_Customize_Setting::preview() |
Add filters to supply the setting’s value when accessed. |
wp-includes/functions.php: wp_auth_check_load() |
Loads the auth check for monitoring whether the user is still logged in. |
wp-includes/functions.php: wp_maybe_load_widgets() |
Determines if Widgets library should be loaded. |
wp-admin/includes/class-custom-background.php: Custom_Background::__construct() |
Constructor – Registers administration header callback. |
wp-admin/includes/class-custom-background.php: Custom_Background::init() |
Sets up the hooks for the Custom Background admin page. |
wp-admin/includes/class-custom-image-header.php: Custom_Image_Header::__construct() |
Constructor – Register administration header callback. |
wp-admin/includes/class-custom-image-header.php: Custom_Image_Header::init() |
Set up the hooks for the Custom Header admin page. |
wp-admin/includes/class-wp-site-icon.php: WP_Site_Icon::__construct() |
Registers actions and filters. |
wp-admin/includes/class-wp-privacy-policy-content.php: WP_Privacy_Policy_Content::text_change_check() |
Quick check if any privacy info has changed. |
wp-admin/includes/class-wp-list-table.php: WP_List_Table::__construct() |
Constructor. |
wp-admin/includes/class-theme-upgrader.php: Theme_Upgrader::install() |
Install a theme package. |
wp-admin/includes/class-theme-upgrader.php: Theme_Upgrader::upgrade() |
Upgrade a theme. |
wp-admin/includes/class-wp-internal-pointers.php: WP_Internal_Pointers::enqueue_scripts() |
Initializes the new feature pointers. |
wp-admin/includes/plugin.php: add_menu_page() |
Adds a top-level menu page. |
wp-admin/includes/plugin.php: add_submenu_page() |
Adds a submenu page. |
wp-admin/includes/plugin.php: uninstall_plugin() |
Uninstalls a single plugin. |
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::prepare_items() | |
wp-admin/includes/update.php: wp_plugin_update_rows() |
Adds a callback to display update information for plugins with updates available. |
wp-admin/includes/update.php: wp_theme_update_rows() |
Adds a callback to display update information for themes with updates available. |
wp-admin/includes/class-plugin-upgrader.php: Plugin_Upgrader::upgrade() |
Upgrade a plugin. |
wp-admin/includes/class-plugin-upgrader.php: Plugin_Upgrader::install() |
Install a plugin package. |
Changelog
Version | Description |
---|---|
1.2.0 | Introduced. |