WP_Hook::has_filters() WordPress Method

The WP_Hook::has_filters() method is used to check if any filters have been registered for a given hook. This is useful for checking if a particular hook has any registered callbacks before running the hook. If no callbacks are registered, then there is no need to run the hook.

WP_Hook::has_filters() #

Checks if any callbacks have been registered for this hook.


Return

(bool) True if callbacks have been registered for the current hook, otherwise false.


Top ↑

Source

File: wp-includes/class-wp-hook.php

	public function has_filters() {
		foreach ( $this->callbacks as $callbacks ) {
			if ( $callbacks ) {
				return true;
			}
		}

		return false;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.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.