Search code examples
wordpressdashboardcode-snippets

Display list of installed plugins in Wordpress admin area


I would like to find a way of displaying a list of all my installed plugin in a neat widget on the home admin area of Wordpress.


Solution

  • Often when I'm doing performance audits on websites I like to clearly see exactly what I'm working with and having a complete list of plugins whereby I can copy and paste into an Google doc or sheet is really handy so I can go through the list and see what plugins I can remove, upgrade, and keep.

    This solution is an adaptation of a similar solution found here.

    However, that solution only displays active plugins and not a complete list. For example plugins like Easy Updates Manager wouldn't show as it's only admin-based.

    The solution below shows a complete list of all installed plugins. Regardless whether they are active or not.

    add_action('wp_dashboard_setup', 'wpse_54742_wp_dashboard_setup');
    
    function wpse_54742_wp_dashboard_setup() {
        wp_add_dashboard_widget( 'wpse_54742_active_site_plugins', __( 'Installed Plugins' ), 'wpse_54742_active_site_plugins' );
    }
    
    function wpse_54742_active_site_plugins() {
        $all_plugins = get_plugins();
        $active_plugins = get_option('active_plugins');
        echo '<ul>';
        foreach ( $active_plugins as $index => $plugin ) {
            if ( array_key_exists( $plugin, $all_plugins ) ) {
                //var_export( $all_plugins[ $plugin ] );
                echo '<h4 style="margin-bottom:15px;font-weight:400;font-size:12px">', $all_plugins[ $plugin ][ 'Name' ], ' ('. $all_plugins[ $plugin ][ 'Version' ] .')</h4>';
                
            }
        }
        echo '</ul>';
    }
    

    Unless you have a child theme installed, I wouldn't recommend adding this to your functions.php file. Instead, use a plugin like code snippets if you want to have better control over your code snippets.

    Hope this helps some of you as I feel this is pretty handy to have. Equally, if any has a more elegant solution, I'd love to hear about it.