has_filter

Definition:
function has_filter($tag, $function_to_check = false) {}

Check if any filter has been registered for a hook.

Parameters

  • string $tag: The name of the filter hook.
  • callback $function_to_check: optional. If specified, return the priority of that function on this hook or false if not attached.

Return values

returns:Optionally returns the priority on that hook for the specified function.

Source code

function has_filter($tag, $function_to_check = false) {

	global $wp_filter;



	$has = !empty($wp_filter[$tag]);

	if ( false === $function_to_check || false == $has )

		return $has;



	if ( !$idx = _wp_filter_build_unique_id($tag, $function_to_check, false) )

		return false;



	foreach ( (array) array_keys($wp_filter[$tag]) as $priority ) {

		if ( isset($wp_filter[$tag][$priority][$idx]) )

			return $priority;

	}



	return false;

}

1931

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: