Languages:
English •
日本語
(Add your language)
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
Source File
has_filter() is located in wp-includes/plugin.php
.
Related
Filter Functions: