2

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?.

  • i asked this question before yours in stack overflow . How do you say its duplicate (Feb 25-14) . Your post date (Sep 29 '14). @tazotodua – Babu Nov 16 '15 at 10:37
  • Ok goodview i accept it . No need to remove flag on this @tazotodua – Babu Nov 18 '15 at 5:38
5

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.

|improve this answer|||||
  • i cant paste it Sudeep . Because i want this info to my plugin .sorry – Babu Feb 25 '14 at 6:56
  • @RyanBabu : Sorry, I didn't realize that you want this for some plugin. – Sudeep K Rana Feb 25 '14 at 7:03
  • That's ok it may help some time thanks for your answer – Babu Feb 25 '14 at 7:09
  • @SudeepKRana, Quickly tested your code. Must say, it is blilliant. – Pieter Goosen Feb 25 '14 at 17:38
  • Looks like the changes introduced with WP 4.7 break Sudeep's original code above. The hooks passed to ksort() are WP_Hook objects now instead of arrays. If I get a few minutes I'll post a fix. – jdm2112 Aug 2 '17 at 17:50
2

The lower priority numbers are executed first, higher numbers last

|improve this answer|||||
  • i changed the priority into 0 . but the default hook first called . add_filter('authenticate', array($this, 'myfunction'), 0, 3); – Babu Feb 25 '14 at 6:58
  • @goose Gave you an up vote here but you could expand the answer. Isn't there code you can use to display hooks on the front end on page load rather than use a plugin which isn't compatible with the latest version of WordPress? – Brad Dalton Aug 8 '14 at 7:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.