Skip to content

Instantly share code, notes, and snippets.

@junaidtk
Last active July 2, 2019 13:19
Show Gist options
  • Select an option

  • Save junaidtk/201c1730b76f1c3384a81272ffac2b92 to your computer and use it in GitHub Desktop.

Select an option

Save junaidtk/201c1730b76f1c3384a81272ffac2b92 to your computer and use it in GitHub Desktop.
Show all hooks in the WP page
This code will display all hooks used in a page for wordpress website.
$debug_tags = array();
add_action( 'all', function ( $tag ) {
global $debug_tags;
if ( in_array( $tag, $debug_tags ) ) {
return;
}
echo "<pre>" . $tag . "</pre>";
$debug_tags[] = $tag;
} );
function wporg_debug(){
echo '<p>' . current_action() . '</p>';
}
add_action('all', 'wporg_debug');
For checking how many times a hooks works
==========================================
function wporg_custom(){
if (did_action('save_post') !== 1) {
return;
}
// Do somthing
}
add_action('save_post', 'wporg_custom');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment