Halloween Sale 15% off Ends in See the plans
PHP

List All Registered Shortcodes Under Tools

Adds a Tools > Shortcodes screen listing every shortcode available on the site and the plugin, theme or function that provides it, so you know what can be used in content.

Don’t have WPIDE yet? Install it on your site

Code

add_action( 'admin_menu', function () {
    add_management_page( 'Shortcodes', 'Shortcodes', 'manage_options', 'wpide-shortcodes', function () {
        global $shortcode_tags;

        $source = function ( $callback ) {
            try {
                if ( is_string( $callback ) && false !== strpos( $callback, '::' ) ) {
                    $callback = explode( '::', $callback );
                }
                $reflection = is_array( $callback ) ? new ReflectionMethod( $callback[0], $callback[1] ) : new ReflectionFunction( $callback );
                $file       = (string) $reflection->getFileName();
            } catch ( ReflectionException $e ) {
                return '';
            }
            if ( false !== strpos( $file, WP_PLUGIN_DIR ) ) {
                return 'Plugin: ' . strtok( str_replace( WP_PLUGIN_DIR . '/', '', $file ), '/' );
            }
            if ( false !== strpos( $file, get_theme_root() ) ) {
                return 'Theme: ' . strtok( str_replace( get_theme_root() . '/', '', $file ), '/' );
            }
            return false !== strpos( $file, ABSPATH . WPINC ) ? 'WordPress' : str_replace( ABSPATH, '', $file );
        };

        $tags = $shortcode_tags;
        ksort( $tags );

        echo '<div class="wrap"><h1>Shortcodes (' . count( $tags ) . ')</h1><table class="widefat striped"><thead><tr><th>Shortcode</th><th>Provided by</th></tr></thead><tbody>';
        foreach ( $tags as $tag => $callback ) {
            printf( '<tr><td><code>[%s]</code></td><td>%s</td></tr>', esc_html( $tag ), esc_html( $source( $callback ) ) );
        }
        echo '</tbody></table></div>';
    } );
} );

Notes

Shortcodes registered only on the front end will not appear here.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.