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_Deactivated.php
<?php

namespace WP_CLI\Doctor\Check;

use WP_CLI;
use WP_CLI\Doctor\Check;

/**
 * Warns when greater than %threshold_percentage%% of plugins are deactivated.
 */
class Plugin_Deactivated extends Plugin {

	/**
	 * Threshold as a percentage.
	 *
	 * @var integer
	 */
	protected $threshold_percentage = 40;

	public function run() {
		$plugins = self::get_plugins();

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

		$threshold = (int) $this->threshold_percentage;
		if ( $inactive + $active > 0 && ( $inactive / ( $inactive + $active ) ) > ( $threshold / 100 ) ) {
			$this->set_status( 'warning' );
			$this->set_message( "Greater than {$threshold} percent of plugins are deactivated." );
		} else {
			$this->set_status( 'success' );
			$this->set_message( "Less than {$threshold} percent of plugins are deactivated." );
		}
	}
}