# Show Which Functions Run on a Hook

> Lets administrators add ?wpide_hook=the_content (or any hook name) to a URL and see the callbacks attached to that hook with their priorities and source files, printed at the bottom of the page.

- Type: PHP
- Runs: Run everywhere
- Category: [Developer](https://wpide.com/library/category/developer/)
- Tags: debugging, hooks, actions, filters
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/dev-hook-inspector/

## Code

```php
add_action( 'shutdown', function () {
    global $wp_filter;

    if ( empty( $_GET['wpide_hook'] ) || ! current_user_can( 'manage_options' ) || wp_doing_ajax() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) { // phpcs:ignore WordPress.Security.NonceVerification
        return;
    }

    $hook = sanitize_text_field( wp_unslash( $_GET['wpide_hook'] ) ); // phpcs:ignore WordPress.Security.NonceVerification

    echo '<div id="wpide-hook-inspector" style="position:relative;z-index:99999;margin:20px;padding:16px;background:#fff;border:2px solid #2271b1;font:13px/1.5 monospace;color:#1e1e1e;">';
    echo '<strong>Callbacks on "' . esc_html( $hook ) . '"</strong><br>';

    if ( empty( $wp_filter[ $hook ] ) ) {
        echo 'None.</div>';
        return;
    }

    foreach ( $wp_filter[ $hook ]->callbacks as $priority => $callbacks ) {
        foreach ( $callbacks as $callback ) {
            $fn    = $callback['function'];
            $label = 'closure';
            $file  = '';

            try {
                if ( is_string( $fn ) ) {
                    $label = $fn;
                    $ref   = strpos( $fn, '::' ) ? new ReflectionMethod( $fn ) : new ReflectionFunction( $fn );
                } elseif ( is_array( $fn ) ) {
                    $label = ( is_object( $fn[0] ) ? get_class( $fn[0] ) : $fn[0] ) . '::' . $fn[1];
                    $ref   = new ReflectionMethod( $fn[0], $fn[1] );
                } else {
                    $ref = new ReflectionFunction( $fn );
                }
                $file = str_replace( ABSPATH, '', (string) $ref->getFileName() ) . ':' . $ref->getStartLine();
            } catch ( ReflectionException $e ) {
                $file = '';
            }

            printf( '%1$d &nbsp; %2$s &nbsp; <span style="color:#646970;">%3$s</span><br>', (int) $priority, esc_html( $label ), esc_html( $file ) );
        }
    }

    echo '</div>';
}, 0 );
```

## Notes

Only administrators see the output. Remove the parameter to hide it again.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show Which Functions Run on a Hook" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
