How Many Plugins?

Over in a comment thread on the Tavern, Adam mentioned that he’d like to have a plugin count in the Right Now box on the Dashboard. As it happens, I once wrote a plugin for a client that added some information to the Right Now box, so it was easy to alter it to print the number of plugins:

Plugin Name: How Many Plugins
Plugin URI:
Description: Counts the number of active plugins you have and prints a link in the Right Now box
Author: Stephanie Leary
Version: 0.1
Author URI:

function scl_get_plugin_count() {
	$all_plugins = apply_filters( 'all_plugins', get_plugins() );
	foreach ( (array) $all_plugins as $plugin_file => $plugin_data) {
		if ( is_plugin_active($plugin_file) ) {
			$active_plugins[ $plugin_file ] = $plugin_data;
	$total_active_plugins = count($active_plugins);
	echo '<p class="plugins-right-now">You have <a href="plugins.php">'.$total_active_plugins.' active plugins</a>.';

add_action('activity_box_end', 'scl_get_plugin_count');

Save this as a PHP file in your wp-content/plugins directory (I just called it count-plugins.php) and activate it.

Of course, if you have a lot of plugins, I suppose this might slow down your Dashboard a little.

ETA: There’s a much shorter solution in the comments!

This is an excerpt from Content Strategy for WordPress.My latest books are Content Strategy for WordPress (2015) and WordPress for Web Developers (2013). Sign up to be notified when I have a new book for you.


  1. says

    I was coming here to suggest the same thing as Ozh. get_plugins() reads the entire directory of plugins, verifies files and plugin headers, and the like. It’s slow, and you probably don’t want to slow your dashboard down that much. Calling get_option(‘active_plugins’) is a cheap and easy way for the same result.

  2. says

    In addition to what @Ohz said, if you want to make it WP network friendly

    $count = count( get_option( ‘active_plugins’ ) );
    if( is_multisite() )
    $count += count( get_site_option( ‘active_sitewide_plugins’, array() ) );

    echo $count;

Leave a Reply

Your email address will not be published. Required fields are marked *