Last active
July 2, 2019 13:19
-
-
Save junaidtk/201c1730b76f1c3384a81272ffac2b92 to your computer and use it in GitHub Desktop.
Show all hooks in the WP page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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