wp_hoist_late_printed_styles()wp-includes/script-loader.php |
Adds the hooks needed for CSS output to be delayed until after the content of the page has been established.
|
wp_enqueue_img_auto_sizes_contain_css_fix()wp-includes/media.php |
Enqueues a CSS rule to fix potential visual issues with images using sizes=auto.
|
wp_enqueue_emoji_styles()wp-includes/formatting.php |
Enqueues the important emoji-related styles.
|
wp_enqueue_admin_bar_bump_styles()wp-includes/admin-bar.php |
Enqueues inline bump styles to make room for the admin bar.
|
wp_enqueue_admin_bar_header_styles()wp-includes/admin-bar.php |
Enqueues inline style to hide the admin bar when printing.
|
wp_enqueue_embed_styles()wp-includes/embed.php |
Enqueues the CSS in the embed iframe header.
|
wp_enqueue_block_template_skip_link()wp-includes/theme-templates.php |
Enqueues the skip-link script & styles.
|
wp_enqueue_global_styles_custom_css()wp-includes/deprecated.php |
Enqueues the global styles custom css defined via theme.json.
|
_wp_get_iframed_editor_assets()wp-includes/block-editor.php |
Collect the block editor assets that need to be loaded into the editor’s iframe.
|
locate_block_template()wp-includes/block-template.php |
Finds a block template with equal or higher specificity than a given PHP template file.
|
wp_enqueue_global_styles()wp-includes/script-loader.php |
Enqueues the global styles defined via theme.json.
|
wp_is_site_initialized()wp-includes/ms-site.php |
Checks whether a site is initialized.
|
WP_Roles::get_roles_data()wp-includes/class-wp-roles.php |
Gets the available roles data.
|
_wp_delete_customize_changeset_dependent_auto_drafts()wp-includes/nav-menu.php |
Deletes auto-draft posts associated with the supplied changeset.
|
_wp_customize_publish_changeset()wp-includes/theme.php |
Publishes a snapshot’s changes.
|
WP_Post_Type::unregister_meta_boxes()wp-includes/class-wp-post-type.php |
Unregisters the post type meta box if a custom callback was specified.
|
WP_Post_Type::remove_hooks()wp-includes/class-wp-post-type.php |
Removes the future post hook action for the post type.
|
wp_oembed_add_discovery_links()wp-includes/embed.php |
Adds oEmbed discovery links in the head element of the website.
|
WP_Automatic_Updater::run()wp-admin/includes/class-wp-automatic-updater.php |
Kicks off the background update process, looping through all pending updates.
|
Language_Pack_Upgrader::bulk_upgrade()wp-admin/includes/class-language-pack-upgrader.php |
Upgrades several language packs at once.
|
Theme_Upgrader::install()wp-admin/includes/class-theme-upgrader.php |
Install a theme package.
|
Theme_Upgrader::upgrade()wp-admin/includes/class-theme-upgrader.php |
Upgrades a theme.
|
Plugin_Upgrader::install()wp-admin/includes/class-plugin-upgrader.php |
Install a plugin package.
|
Plugin_Upgrader::upgrade()wp-admin/includes/class-plugin-upgrader.php |
Upgrades a plugin.
|
WP_MS_Themes_List_Table::single_row()wp-admin/includes/class-wp-ms-themes-list-table.php |
|
WP_Customize_Manager::__construct()wp-includes/class-wp-customize-manager.php |
Constructor.
|
_remove_theme_support()wp-includes/theme.php |
Do not use. Removes theme support internally without knowledge of those not used by themes directly.
|
check_theme_switched()wp-includes/theme.php |
Checks if a theme has been changed and runs ‘after_switch_theme’ hook on the next WP load.
|
automatic_feed_links()wp-includes/deprecated.php |
Enable/disable automatic general feed link outputting.
|
add_feed()wp-includes/rewrite.php |
Adds a new feed type like /atom1/.
|
wp_print_media_templates()wp-includes/media-template.php |
Prints the templates used in the media manager.
|
Skip to note 7 content
Codex
This function is identical to the remove_filter() function.
remove_action() must be called inside a function and cannot be called directly in your plugin or theme.
If an action has been added from within a class, for example by a plugin, removing it will require accessing the class through a variable that holds the class instance.
add_action( 'wp_head', 'remove_my_class_action' ); function remove_my_class_action() { global $my_class; remove_action( 'wp_footer', array( $my_class, 'class_function_being_removed' ) ); }Unless the function is static in which case you could call the class and function directly.
add_action( 'wp_head', 'remove_my_class_action' ); function remove_my_class_action() { remove_action( 'wp_footer', array( 'My_Class', 'class_function_being_removed' ) ); }Notes:
Skip to note 8 content
tripflex
If you need to be able to remove an action/filter for a class object you do not have access to, you can do so with this function (which includes support for WordPress 4.7+):
/** * Make sure the function does not exist before defining it */ if( ! function_exists( 'remove_class_filter' ) ){ /** * Remove Class Filter Without Access to Class Object * * In order to use the core WordPress remove_filter() on a filter added with the callback * to a class, you either have to have access to that class object, or it has to be a call * to a static method. This method allows you to remove filters with a callback to a class * you don't have access to. * * Works with WordPress 1.2+ (4.7+ support added 9-19-2016) * Updated 2-27-2017 to use internal WordPress removal for 4.7+ (to prevent PHP warnings output) * * @param string $tag Filter to remove * @param string $class_name Class name for the filter's callback * @param string $method_name Method name for the filter's callback * @param int $priority Priority of the filter (default 10) * * @return bool Whether the function is removed. */ function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ) { global $wp_filter; // Check that filter actually exists first if ( ! isset( $wp_filter[ $tag ] ) ) { return FALSE; } /** * If filter config is an object, means we're using WordPress 4.7+ and the config is no longer * a simple array, rather it is an object that implements the ArrayAccess interface. * * To be backwards compatible, we set $callbacks equal to the correct array as a reference (so $wp_filter is updated) * * @see <a href="https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/" rel="nofollow ugc">https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/</a> */ if ( is_object( $wp_filter[ $tag ] ) && isset( $wp_filter[ $tag ]->callbacks ) ) { // Create $fob object from filter tag, to use below $fob = $wp_filter[ $tag ]; $callbacks = &$wp_filter[ $tag ]->callbacks; } else { $callbacks = &$wp_filter[ $tag ]; } // Exit if there aren't any callbacks for specified priority if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) { return FALSE; } // Loop through each filter for the specified priority, looking for our class & method foreach ( (array) $callbacks[ $priority ] as $filter_id => $filter ) { // Filter should always be an array - array( $this, 'method' ), if not goto next if ( ! isset( $filter['function'] ) || ! is_array( $filter['function'] ) ) { continue; } // If first value in array is not an object, it can't be a class if ( ! is_object( $filter['function'][0] ) ) { continue; } // Method doesn't match the one we're looking for, goto next if ( $filter['function'][1] !== $method_name ) { continue; } // Method matched, now let's check the Class if ( get_class( $filter['function'][0] ) === $class_name ) { // WordPress 4.7+ use core remove_filter() since we found the class object if ( isset( $fob ) ) { // Handles removing filter, reseting callback priority keys mid-iteration, etc. $fob->remove_filter( $tag, $filter['function'], $priority ); } else { // Use legacy removal process (pre 4.7) unset( $callbacks[ $priority ][ $filter_id ] ); // and if it was the only filter in that priority, unset that priority if ( empty( $callbacks[ $priority ] ) ) { unset( $callbacks[ $priority ] ); } // and if the only filter for that tag, set the tag to an empty array if ( empty( $callbacks ) ) { $callbacks = array(); } // Remove this filter from merged_filters, which specifies if filters have been sorted unset( $GLOBALS['merged_filters'][ $tag ] ); } return TRUE; } } return FALSE; } } /** * Make sure the function does not exist before defining it */ if( ! function_exists( 'remove_class_action') ){ /** * Remove Class Action Without Access to Class Object * * In order to use the core WordPress remove_action() on an action added with the callback * to a class, you either have to have access to that class object, or it has to be a call * to a static method. This method allows you to remove actions with a callback to a class * you don't have access to. * * Works with WordPress 1.2+ (4.7+ support added 9-19-2016) * * @param string $tag Action to remove * @param string $class_name Class name for the action's callback * @param string $method_name Method name for the action's callback * @param int $priority Priority of the action (default 10) * * @return bool Whether the function is removed. */ function remove_class_action( $tag, $class_name = '', $method_name = '', $priority = 10 ) { remove_class_filter( $tag, $class_name, $method_name, $priority ); } }https://gist.github.com/tripflex/c6518efc1753cf2392559866b4bd1a53
Skip to note 9 content
Bart Kuijper
The old codex contains this very important note that unfortunately didn’t make it into this page:
Important: To remove a hook, the
<em>$function_to_remove</em>and<em>$priority arguments</em>must match when the hook was added. This goes for both filters and actions. No warning will be given on removal failure.Skip to note 10 content
Anthony Hortin
Related:
do_action()
add_action()
Skip to note 11 content
Sushil Adhikari
/** * Different way to remove hooks declare inside class */ class MyClass { /** * The single instance of the class. * */ protected static $_instance = null; /** * Main plugins instance * * Ensures only one instance of this class * Its always good practice to user single instance of the class so we can modify hooks initialized on this class */ public static function get_instance() { if ( is_null( self::$_instance ) ) { self::$_instance = new self(); } return self::$_instance; } /** * Register hoooks */ public function __construct() { /* * @hooked add_custom_body_class 10 */ add_filter( 'body_class', array( $this, 'add_custom_body_class' ) ); /* * @hooked static static_body_class - 20 */ add_filter( 'body_class', array( 'MyClass', 'static_body_class' ), 20 ); } /** * @return array of class */ public function add_custom_body_class( $class ) { $class[ 'custom_class' ] = 'customClass'; return $class; } /** * @return array of class */ static function static_body_class( $class ) { $class[ 'static_custom_class' ] = 'staticCustomClass'; return $class; } } $my_class = MyClass::get_instance(); /** * Remove methods: add_custom_body_class attached to body class */ add_action( 'wp_head', 'themeslug_remove_hooks' ); function themeslug_remove_hooks() { /** * Always use same class object, this can be achieve by restricting multiple instance of the class */ $is_action_removed = remove_action( 'body_class', array( MyClass::get_instance(), 'add_custom_body_class' ) ); /** * Remove static method class by using class name with same priority 20 */ $is_action_removed = remove_action( 'body_class', array( 'MyClass', 'static_body_class' ), 20 ); }Skip to note 12 content
geigel
It seems (for the moment) like there is no easy way to specifically target an action for removal that relies on an anonymous function. A blanket removal will remove it if using the default priority, but it also wipes out other actions that have hooked into it. Additional discussion regarding some solutions people have been able to put together is found here: https://wordpress.stackexchange.com/questions/137688/remove-actions-filters-added-via-anonymous-functions