To hook my plugin content into anywhere, suppose I offered the theme developers to create their own hooks with a prefix (pre_
) anywhere in their theme - the rest of the hook is unknown to me. So what will they do?
Suppose, in single.php
they placed a hook like:
do_action( 'pre_kauwa' );
in page.php
they placed a hook like:
do_action( 'pre_kala' );
And so on...
How can I get all those do_action()
declarations with a prefix pre_
from an active WordPress installation (active theme)
or,
from an active WordPress viewport (post, page, archive bla bla)
...so that I can make a list of hooks dynamically where my content can be hooked using add_action()
?
Testing testing...
In wp-includes/plugin.php
I found the has_filter()
function declaration. From there I took the following line for testing:
$wp_filter = $GLOBALS['wp_filter'];
$has = ! empty( $wp_filter[ $tag ] );
In my dummy theme's index.php
after the_content()
(within the loop) I placed:
do_action( 'pre_kk' );
Just after the do_action()
call I placed:
$t_test = $GLOBALS['wp_filter'];
$hk = 'pre_kk';
var_dump( $t_test[$hk] );
But it's throwing an undefined index.
add_action( 'pre_kk', 'your_function' )
to yourdo_action( 'pre_kk' )
? Because otherwise - if I'm not totally mistaken - it won't be added to$wp_filter
.