PHP Web Development Wordpress

Display all hooks functions added to hook

Sometime it is required to list all the functions added to a hook in WordPress, Below in the given code, add this code to functions.php of theme and hit the site on front-end it will display all the added functions add to that hook with the priority of hooked function. 

<?php
/********** Begin **************/
/**
* @param hookname : name of the hook
* Author: NaveenPal
function nis_print_added_functions_to_hook($hookname='') {
    global $wp_filter;
    if( empty($hookname) || !isset($wp_filter[$hookname]) ){
      echo 'Hook '.$hookname.' is not found!';
    }
    echo '<pre>';
    print_r($wp_filter[$hookname]);
    echo '</pre>';
} /// end of function nis_print_added_functions_to_hook

// call function
$myhookname = 'post_thumbnail_html';
nis_print_added_functions_to_hook($myhookname);
/********** End **************/

Leave a Reply

Your email address will not be published. Required fields are marked *


CAPTCHA Image
Reload Image