WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/has filter

Description

Check if any filter has been registered for a hook.

Usage

 <?php has_filter$tag$function_to_check ); ?> 

Parameters

$tag
(string) (required) The name of the filter hook.
Default: None
$function_to_check
(callback) (optional) If specified, return the priority of that function on this hook. If the specified function is not attached to this hook, returns false.
Default: False

Return

int | boolean 
If no function is specified: returns true if any function is registered for this hook, or false otherwise. If a function is specified (as the second parameter): returns an integer for the priority of the hook if the function is registered, or false otherwise.

Examples

<?php
if ( ! has_filter'the_content''example_alter_the_content' ) )
    
add_filter'the_content''prefix_alter_the_content' );
?>

Notes

  • Uses: global array $wp_filter that stores all of the filters

Change Log

  • Since: 2.5.0

Source File

has_filter() is located in wp-includes/plugin.php.

Related

Filter Functions:

See also index of Function Reference and index of Template Tags.