Skip to content

Instantly share code, notes, and snippets.

@vishalkakadiya
Last active December 28, 2020 12:16
Show Gist options
  • Save vishalkakadiya/ac70e878ece40ce9be7cfd9e916dad66 to your computer and use it in GitHub Desktop.
Save vishalkakadiya/ac70e878ece40ce9be7cfd9e916dad66 to your computer and use it in GitHub Desktop.
Get list of function names which is hooked available on particular hook.
<?php
/**
* Change `the_content` thing in below function with your hook in filter
* - You can change $wp_filter to $wp_actions to get details of action hooks.
*
* NOTE: THIS IS FOR ONLY DEBUG PURPOSE NOT SEND THIS CODE TO PRODUCTION.
*/
function vk_list_hooks() {
global $wp_filter;
$functions = [];
foreach ( $wp_filter['the_content']->callbacks as $callbacks ) {
foreach ( $callbacks as $callback ) {
if ( isset( $callback['function'] ) && ! empty( $callback['function'] ) ) {
$callback_function = $callback['function'];
if ( is_string( $callback_function ) ) {
$functions[] = $callback_function;
}
}
}
}
echo '$functions: <pre>';
print_r( $functions );
echo '</pre>';
die;
}
add_action( 'wp', 'vk_list_hooks', 999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment