Last active
April 21, 2017 14:43
-
-
Save TruongTuyen/26190800216d99cb3f512ff87bfcc4d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wptq_hooked_action_for( $hook_name = '' ){ | |
global $wp_filter; | |
if( empty( $hook_name ) || !isset( $wp_filter[$hook_name] ) || !is_object( $wp_filter[$hook_name] ) ){ | |
return; | |
} | |
$list_hooked = array(); | |
$callbacks = $wp_filter[$hook_name]->callbacks; | |
if( !empty( $callbacks ) ){ | |
foreach( $callbacks as $key=>$value ){ | |
if( is_array( $value ) && !empty( $value ) ){ | |
foreach( $value as $k=>$v ){ | |
if( array_key_exists( 'function', $v ) && !is_array( $v['function'] ) ){ | |
$list_hooked[] = array( | |
'type' => 'function', | |
'function_name' => $v['function'], | |
'accepted_args' => $v['accepted_args'], | |
'priority' => $key | |
); | |
}elseif( array_key_exists( 'function', $v ) && is_array( $v['function'] ) && is_object( $v['function'][0] ) && !empty( $v['function'][1] ) ){ | |
$list_hooked[] = array( | |
'type' => 'method', | |
'object_name' => get_class( $v['function'][0]), | |
'method_name' => $v['function'][1], | |
'accepted_args' => $v['accepted_args'], | |
'priority' => $key | |
); | |
} | |
} | |
} | |
} | |
} | |
echo "<pre>"; | |
print_r( $list_hooked ); | |
echo "</pre>"; | |
} | |
//Example | |
wptq_hooked_action_for( 'wp_head' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment