• Resolved phongmedia

    (@phongmedia)


    Hi,
    Due to a custom comment plugin I’m using, Press Permit Core’s ‘CommentsInterceptor’ filter is a total show-stopper.

    I would like to remove this filter, although I’ve been unable to do it so far.

    This is the filter I would like to remove.
    add_filter( 'comments_clauses', array( 'CommentsInterceptor', 'flt_comments_clauses' ), 10, 2 );

    For instance, adding this line doesn’t do anything :
    remove_filter( 'comments_clauses', array( 'CommentsInterceptor', 'flt_comments_clauses' ), 11, 2 );

    Any help would be appreciated.
    Thanks

    http://ww.wp.xz.cn/plugins/press-permit-core/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Kevin Behrens

    (@kevinb)

    First, be sure the your remove_filter function uses the same priority argument as the add_filter call you’re trying to disable. In this code excerpt, you pass 11 instead of 10.

    Also, be sure that your remove_filter call is executed after the add_filter call. To do so, you can hook your remove_filter function to action ‘pp_init’.

    Thread Starter phongmedia

    (@phongmedia)

    OK, so for instance, I add this line to functions.php

    remove_filter( 'pp_init', array( 'CommentsInterceptor', 'flt_comments_clauses' ), 10 );

    Although that’s not causing the filter to be removed. What am I missing here? Thanks.

    Plugin Author Kevin Behrens

    (@kevinb)

    You have misunderstand the meaning of hooking into an action.

    When you just insert the remove_filter call into functions.php, it executes as soon as functions.php is loaded. At that time, the add_filter call you’re concerned about has not executed yet, so the removal attempt is ineffective. Instead, you should do this:

    add_action( 'pp_init', 'my_filter_removal' );
    function my_filter_removal() {
      remove_filter( 'comments_clauses', array( 'CommentsInterceptor', 'flt_comments_clauses' ), 10, 2 );
    }

    Note that I have retained all the original function arguments of the add_filter call.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Remove CommentsInterceptor Filter’ is closed to new replies.