For example:
if ( is_hooked('hook_name') ) {
throw new \Exception('You cannot hook to a protected action.');
} else {
do_action('hook_name');
}
Is there a way to define the is_hooked()
function?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communitySure, that's called has_action
, which is an alias of has_filter
. Usage:
if ( has_action('hook_name') ) {
throw new \Exception('You cannot hook to a protected action.');
} else {
do_action('hook_name');
}
These two functions access the global array $wp_filter
that stores all of the filters / actions