Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to apply this filter from this question.

add_filter( 'the_content', 'pre_content_filter', 0 );

function pre_content_filter( $content ) {
    return preg_replace_callback( '|<pre.*>(.*)</pre|isU' , 'convert_pre_entities', $content );
}

function convert_pre_entities( $matches ) {
    return str_replace( $matches[1], html_entity_decode( $matches[1] ), $matches[0] );
}

But it seems there is no effect. So I want to check if the function pre_content_filter is really applied. How can I do it?

I've tried debug-bar and debug-bar-extender, but I couldn't find if I can do it.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You can use has_filter() to check for registered filers.

Example:

add_filter( 'the_content', function( $content ) 
{
    if ( has_filter( 'the_content', 'pre_content_filter' ) )
        return 'pre_content_filter() is active<br>' . $content;

    return $content;
}, -1 );
share|improve this answer
add comment

You can find out all the functions hooked into a particular "filter" and check if a particular function is in that list. Below function returns the list of all functions hooked into a specific filter hook.

function get_filters_for( $hook = '' ) {
    global $wp_filter;
    if( empty( $hook ) || !isset( $wp_filter[$hook] ) )
        return;

    return $wp_filter[$hook];
}

Call it like this and run a loop to check if the function is in this list.

get_filters_for( 'the_content' );
share|improve this answer
    
Didn't realize @toscho has already answered !! –  Subharanjan Dec 10 '13 at 11:02
    
Thanks Subharanjan! I tried to use your function in Debug Bar Console plugin by pasting function and run var_dump(get_filters_for( 'the_content' ));, but it shows nothing. Am I doing wrong? –  Tetsu Dec 10 '13 at 14:16
    
@Tetsu Just removed an extra parenthesis from the return statement. It works now.. Please check. :) awesomescreenshot.com/06e22nqdbd –  Subharanjan Dec 10 '13 at 14:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.