remove_all_actions() WordPress Function

The remove_all_actions() function is a powerful tool for customizing a WordPress site. It allows you to remove all of the default actions that are added by WordPress, and replace them with your own custom actions. This can be used to change the way that your site looks and behaves, or to add new features that are not available in the default WordPress installation.

remove_all_actions( string $hook_name, int|false $priority = false ) #

Removes all of the callback functions from an action hook.


Parameters

$hook_name

(string)(Required)The action to remove callbacks from.

$priority

(int|false)(Optional) The priority number to remove them from.

Default value: false


Top ↑

Return

(true) Always returns true.


Top ↑

More Information

Prior to Version 4.7

  • You can’t call this function from within the hook you would like to remove actions from. For example adding an action to wp_footer that calls remove_all_actions('wp_footer') will cause an infinite loop condition because the while loop suddenly doesn’t have a next value. In WordPress 3.8.1 you’ll get a warning message like:
    Warning: next() expects parameter 1 to be array, null given in wp-includes/plugin.php on line 431
  • You’ll just need to hook into a hook that’s called before the hook you wish to clear is called.

Since Version 4.7, these limitations have been addressed. Please refer to https://wordpress.org/support/wordpress-version/version-4-7/#for-developers


Top ↑

Source

File: wp-includes/plugin.php

function remove_all_actions( $hook_name, $priority = false ) {
	return remove_all_filters( $hook_name, $priority );
}


Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.