# Theme Usage Report for the Network

> Adds Network Admin > Themes > Usage, listing every installed theme with the sites that use it (directly or as a parent theme), so unused themes are easy to spot.

- Type: PHP
- Runs: Admin only
- Category: [Multisite](https://wpide.com/library/category/multisite/)
- Tags: network-admin, themes, report
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/ms-theme-usage-report/

## Code

```php
if ( ! is_multisite() ) {
    return;
}

add_action( 'network_admin_menu', function () {
    add_submenu_page( 'themes.php', __( 'Theme usage' ), __( 'Usage' ), 'manage_network_themes', 'wpide-theme-usage', function () {
        if ( ! current_user_can( 'manage_network_themes' ) ) {
            return;
        }

        $usage = get_site_transient( 'wpide_theme_usage' );

        if ( false === $usage ) {
            $usage = array();
            foreach ( get_sites( array( 'number' => 0, 'fields' => 'ids', 'deleted' => 0 ) ) as $blog_id ) {
                $stylesheet = get_blog_option( $blog_id, 'stylesheet' );
                $template   = get_blog_option( $blog_id, 'template' );
                $usage[ $stylesheet ]['direct'][] = (int) $blog_id;
                if ( $template && $template !== $stylesheet ) {
                    $usage[ $template ]['parent'][] = (int) $blog_id;
                }
            }
            set_site_transient( 'wpide_theme_usage', $usage, HOUR_IN_SECONDS );
        }

        $allowed = WP_Theme::get_allowed_on_network();

        echo '<div class="wrap"><h1>' . esc_html__( 'Theme usage' ) . '</h1><table class="widefat striped"><thead><tr><th>' . esc_html__( 'Theme' ) . '</th><th>' . esc_html__( 'Network enabled' ) . '</th><th>' . esc_html__( 'Active on' ) . '</th><th>' . esc_html__( 'Parent of' ) . '</th></tr></thead><tbody>';

        foreach ( wp_get_themes() as $slug => $theme ) {
            $direct = isset( $usage[ $slug ]['direct'] ) ? count( $usage[ $slug ]['direct'] ) : 0;
            $parent = isset( $usage[ $slug ]['parent'] ) ? count( $usage[ $slug ]['parent'] ) : 0;

            printf(
                '<tr><td>%1$s</td><td>%2$s</td><td>%3$s</td><td>%4$s</td></tr>',
                esc_html( $theme->get( 'Name' ) ),
                isset( $allowed[ $slug ] ) ? '&#10003;' : '&mdash;',
                $direct || $parent ? esc_html( (string) $direct ) : '<span style="color:#b32d2e">' . esc_html__( 'Unused' ) . '</span>',
                esc_html( (string) $parent )
            );
        }

        echo '</tbody></table></div>';
    } );
} );

add_action( 'switch_theme', function () {
    delete_site_transient( 'wpide_theme_usage' );
} );
```

## Notes

Cached for an hour and refreshed whenever a site switches theme.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Theme Usage Report for the Network" 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/
