So I have a following code inside the plugin:

if( window.wp.hooks.applyFilters( 'filtername', true, $(this) ) ) {
//do something

how can I make above statement always false without editing plugin files but using functions.php instead? I'm not sure if I understand applyfilters correctly but I've tried:

function filtername() {
    return false;
add_filter( 'filtername', 'filtername', 10, 3 );

but it didn't work. What would be propper way to do it? Can someone please explain.

  • I don't know how the client side wp.hooks works, but I'd be surprised if it called into server-side filters. Do you need a client-side filter instead?
    – Rup
    Nov 27, 2020 at 15:34
  • I just realized this is javascript hook indeed. I don't know why I looked at php function to solve it.
    – Greg Viv
    Nov 27, 2020 at 16:47

1 Answer 1


JS hooks don't do server-side calls to retrieve PHP declared hooks.

wp.hooks.addFilter( 'hookName', 'namespace', () => { return false; }, 10 )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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