multiple functions with same filter

by Jess_Pinkman   Last Updated August 14, 2019 03:08 AM - source

I want to use the same filter hook in different locations, and I just want to make sure this is OK to do so ( preliminary test shows it works, but I am not 100% sure it is OK to do so).

So the add_filter('check_powers', .... ) is in one location only ( not that it matters)

function define_user_powers()
{
  if ( user_is_powerful() ){
    add_filter('check_powers', 'give_super_power');
  }
}

function give_super_power( $powers ){
  $powers = true;
  return $powers;
}

But the apply_filters('check_powers') is in several locations:

function kick_ass()
{
  $powers = apply_filters('check_powers', false );
  if ( $powers ) {
   do_smthng();
  }

}

function fly()
{
  $powers = apply_filters('check_powers', false );
  if ( $powers ) {
   do_smthng_else();
  }
}

All questions i have found relates to the other way around ( multiple add_filter to same hook).



Related Questions



Worpress permalink setting

Updated August 07, 2015 14:03 PM

Wordpress custom taxonomy check box to dropdown

Updated August 20, 2015 17:03 PM

How do I Make a Theme "plugin-ready"?

Updated August 01, 2019 15:08 PM

Remove action added in plugin class from theme

Updated October 09, 2018 11:08 AM