HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/local/wp/vendor/wp-cli/doctor-command/src/Check/Plugin_Active_Count.php
<?php

namespace WP_CLI\Doctor\Check;

use WP_CLI;

/**
 * Warns when there are greater than %threshold_count% plugins activated.
 */
class Plugin_Active_Count extends Plugin {

	/**
	 * Threshold as a total number of plugins.
	 *
	 * @var integer
	 */
	protected $threshold_count = 80;

	public function run() {
		$active = 0;
		foreach ( self::get_plugins() as $plugin ) {
			if ( 'active' === $plugin['status'] || 'active-network' === $plugin['status'] ) {
				++$active;
			}
		}

		$threshold = (int) $this->threshold_count;
		if ( $active > $threshold ) {
			$this->set_status( 'warning' );
			$this->set_message( "Number of active plugins ({$active}) exceeds threshold ({$threshold})." );
		} else {
			$this->set_status( 'success' );
			$this->set_message( "Number of active plugins ({$active}) is less than threshold ({$threshold})." );
		}
	}
}