public function activate( $args, $assoc_args = array() ) {
		$network_wide = Utils\get_flag_value( $assoc_args, 'network' );
		$all          = Utils\get_flag_value( $assoc_args, 'all', false );

		$args = $this->check_optional_args_and_all( $args, $all );
		if ( ! $args ) {
			return;
		}

		$successes = 0;
		$errors    = 0;
		$plugins   = $this->fetcher->get_many( $args );
		if ( count( $plugins ) < count( $args ) ) {
			$errors = count( $args ) - count( $plugins );
		}
		foreach ( $plugins as $plugin ) {
			$status = $this->get_status( $plugin->file );
			if ( $all && in_array( $status, [ 'active', 'active-network' ], true ) ) {
				continue;
			}
			// Network-active is the highest level of activation status
			if ( 'active-network' === $status ) {
				WP_CLI::warning( "Plugin '{$plugin->name}' is already network active." );
				continue;
			}
			// Don't reactivate active plugins, but do let them become network-active
			if ( ! $network_wide && 'active' === $status ) {
				WP_CLI::warning( "Plugin '{$plugin->name}' is already active." );
				continue;
			}

			// Plugins need to be deactivated before being network activated
			if ( $network_wide && 'active' === $status ) {
				deactivate_plugins( $plugin->file, false, false );
			}

			activate_plugin( $plugin->file, '', $network_wide );

			$this->active_output( $plugin->name, $plugin->file, $network_wide, 'activate' );
			$successes++;
		}

		if ( ! $this->chained_command ) {
			$verb = $network_wide ? 'network activate' : 'activate';
			Utils\report_batch_operation_results( 'plugin', $verb, count( $args ), $successes, $errors );
		}

	}
public function activate( $args, $assoc_args = array() ) {
		$network_wide = Utils\get_flag_value( $assoc_args, 'network' );
		$all          = Utils\get_flag_value( $assoc_args, 'all', false );

		$args = $this->check_optional_args_and_all( $args, $all );
		if ( ! $args ) {
			return;
		}

		$successes = 0;
		$errors    = 0;
		$plugins   = $this->fetcher->get_many( $args );
		if ( count( $plugins ) < count( $args ) ) {
			$errors = count( $args ) - count( $plugins );
		}
		foreach ( $plugins as $plugin ) {
			$status = $this->get_status( $plugin->file );
			if ( $all && in_array( $status, [ 'active', 'active-network' ], true ) ) {
				continue;
			}
			// Network-active is the highest level of activation status
			if ( 'active-network' === $status ) {
				WP_CLI::warning( "Plugin '{$plugin->name}' is already network active." );
				continue;
			}
			// Don't reactivate active plugins, but do let them become network-active
			if ( ! $network_wide && 'active' === $status ) {
				WP_CLI::warning( "Plugin '{$plugin->name}' is already active." );
				continue;
			}

			// Plugins need to be deactivated before being network activated
			if ( $network_wide && 'active' === $status ) {
				deactivate_plugins( $plugin->file, false, false );
			}

			activate_plugin( $plugin->file, '', $network_wide );

			$this->active_output( $plugin->name, $plugin->file, $network_wide, 'activate' );
			$successes++;
		}

		if ( ! $this->chained_command ) {
			$verb = $network_wide ? 'network activate' : 'activate';
			Utils\report_batch_operation_results( 'plugin', $verb, count( $args ), $successes, $errors );
		}

	}
public function activate ( $ args , $ assoc_args = array ( ) ) { $ network_wide = Utils \ get_flag_value ( $ assoc_args , 'network' ) ; $ all = Utils \ get_flag_value ( $ assoc_args , 'all' , false ) ; $ args = $ this -> check_optional_args_and_all ( $ args , $ all ) ; if ( ! $ args ) { return ; } $ successes = 0 ; $ errors = 0 ; $ plugins = $ this -> fetcher -> get_many ( $ args ) ; if ( count ( $ plugins ) < count ( $ args ) ) { $ errors = count ( $ args ) - count ( $ plugins ) ; } foreach ( $ plugins as $ plugin ) { $ status = $ this -> get_status ( $ plugin -> file ) ; if ( $ all && in_array ( $ status , [ 'active' , 'active-network' ] , true ) ) { continue ; } // Network-active is the highest level of activation status if ( 'active-network' === $ status ) { WP_CLI :: warning ( "Plugin '{$plugin->name}' is already network active." ) ; continue ; } // Don't reactivate active plugins, but do let them become network-active if ( ! $ network_wide && 'active' === $ status ) { WP_CLI :: warning ( "Plugin '{$plugin->name}' is already active." ) ; continue ; } // Plugins need to be deactivated before being network activated if ( $ network_wide && 'active' === $ status ) { deactivate_plugins ( $ plugin -> file , false , false ) ; } activate_plugin ( $ plugin -> file , '' , $ network_wide ) ; $ this -> active_output ( $ plugin -> name , $ plugin -> file , $ network_wide , 'activate' ) ; $ successes ++ ; } if ( ! $ this -> chained_command ) { $ verb = $ network_wide ? 'network activate' : 'activate' ; Utils \ report_batch_operation_results ( 'plugin' , $ verb , count ( $ args ) , $ successes , $ errors ) ; } }
Activates one or more plugins.

## OPTIONS

[<plugin>...]
: One or more plugins to activate.

[--all]
: If set, all plugins will be activated.

[--network]
: If set, the plugin will be activated for the entire multisite network.

## EXAMPLES

# Activate plugin
$ wp plugin activate hello
Plugin 'hello' activated.
Success: Activated 1 of 1 plugins.

# Activate plugin in entire multisite network
$ wp plugin activate hello --network
Plugin 'hello' network activated.
Success: Network activated 1 of 1 plugins.
Activates one or more plugins .