How to list the Hooks and order of execution in current loading page?

I need to know the list of hooks that are called in the current page . How to identify the priority assigned to the action and filters in the action . If i want to remove the default action on word-press . It cause any error ? May i overwrite the default action that to be execute?

add_filter( $tag, $function_to_add, $priority, $accepted_args ); 

in this case i change the priority as 50 . i don’t get any changes compare with 10 or Default. if This Priority value is for order of execution means i need to change the values as bigger or smaller?.

Related posts

2 comments

  1. Paste this into your functions.php

    //LIST ALL HOOKS
    
    function dump_hook( $tag, $hook ) {
        ksort($hook);
    
        echo "<pre>>>>>>t$tag<br>";
    
        foreach( $hook as $priority => $functions ) {
    
        echo $priority;
    
        foreach( $functions as $function )
            if( $function['function'] != 'list_hook_details' ) {
    
            echo "t";
    
            if( is_string( $function['function'] ) )
                echo $function['function'];
    
            elseif( is_string( $function['function'][0] ) )
                 echo $function['function'][0] . ' -> ' . $function['function'][1];
    
            elseif( is_object( $function['function'][0] ) )
                echo "(object) " . get_class( $function['function'][0] ) . ' -> ' . $function['function'][1];
    
            else
                print_r($function);
    
            echo ' (' . $function['accepted_args'] . ') <br>';
            }
        }
    
        echo '</pre>';
    }
    
    function list_hooks( $filter = false ){
        global $wp_filter;
    
        $hooks = $wp_filter;
        ksort( $hooks );
    
        foreach( $hooks as $tag => $hook )
            if ( false === $filter || false !== strpos( $tag, $filter ) )
                dump_hook($tag, $hook);
    }
    

    Write this on index.php or single.php or any other page to see the filters applied to a particular function along with priority.

    <?php  list_hooks(); ?>
    

    This method even show your own create filters.

Comments are closed.