admin管理员组

文章数量:1313735

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.

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.

Share Improve this question asked Nov 27, 2020 at 15:19 Greg VivGreg Viv 1232 bronze badges 2
  • 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 Commented 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 Commented Nov 27, 2020 at 16:47
Add a comment  | 

1 Answer 1

Reset to default 3

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

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

本文标签: filtersHow to make applyFilters function return false via functionsphp