public function enable( $args, $assoc_args ) {
		if ( ! is_multisite() ) {
			WP_CLI::error( 'This is not a multisite installation.' );
		}

		$theme = $this->fetcher->get_check( $args[0] );
		$name  = $theme->get( 'Name' );

		# If the --network flag is set, we'll be calling the (get|update)_site_option functions
		$_site = ! empty( $assoc_args['network'] ) ? '_site' : '';

		# Add the current theme to the allowed themes option or site option
		$allowed_themes = call_user_func( "get{$_site}_option", 'allowedthemes' );
		if ( empty( $allowed_themes ) ) {
			$allowed_themes = array();
		}
		$allowed_themes[ $theme->get_stylesheet() ] = true;
		call_user_func( "update{$_site}_option", 'allowedthemes', $allowed_themes );

		if ( ! empty( $assoc_args['network'] ) ) {
			WP_CLI::success( "Network enabled the '$name' theme." );
		} else {
			WP_CLI::success( "Enabled the '$name' theme." );
		}

		# If the --activate flag is set, activate the theme for the current site
		if ( ! empty( $assoc_args['activate'] ) ) {
			$this->activate( $args );
		}
	}
public function enable( $args, $assoc_args ) {
		if ( ! is_multisite() ) {
			WP_CLI::error( 'This is not a multisite installation.' );
		}

		$theme = $this->fetcher->get_check( $args[0] );
		$name  = $theme->get( 'Name' );

		# If the --network flag is set, we'll be calling the (get|update)_site_option functions
		$_site = ! empty( $assoc_args['network'] ) ? '_site' : '';

		# Add the current theme to the allowed themes option or site option
		$allowed_themes = call_user_func( "get{$_site}_option", 'allowedthemes' );
		if ( empty( $allowed_themes ) ) {
			$allowed_themes = array();
		}
		$allowed_themes[ $theme->get_stylesheet() ] = true;
		call_user_func( "update{$_site}_option", 'allowedthemes', $allowed_themes );

		if ( ! empty( $assoc_args['network'] ) ) {
			WP_CLI::success( "Network enabled the '$name' theme." );
		} else {
			WP_CLI::success( "Enabled the '$name' theme." );
		}

		# If the --activate flag is set, activate the theme for the current site
		if ( ! empty( $assoc_args['activate'] ) ) {
			$this->activate( $args );
		}
	}
public function enable ( $ args , $ assoc_args ) { if ( ! is_multisite ( ) ) { WP_CLI :: error ( 'This is not a multisite installation.' ) ; } $ theme = $ this -> fetcher -> get_check ( $ args [ 0 ] ) ; $ name = $ theme -> get ( 'Name' ) ; # If the --network flag is set, we'll be calling the (get|update)_site_option functions $ _site = ! empty ( $ assoc_args [ 'network' ] ) ? '_site' : '' ; # Add the current theme to the allowed themes option or site option $ allowed_themes = call_user_func ( "get{$_site}_option" , 'allowedthemes' ) ; if ( empty ( $ allowed_themes ) ) { $ allowed_themes = array ( ) ; } $ allowed_themes [ $ theme -> get_stylesheet ( ) ] = true ; call_user_func ( "update{$_site}_option" , 'allowedthemes' , $ allowed_themes ) ; if ( ! empty ( $ assoc_args [ 'network' ] ) ) { WP_CLI :: success ( "Network enabled the '$name' theme." ) ; } else { WP_CLI :: success ( "Enabled the '$name' theme." ) ; } # If the --activate flag is set, activate the theme for the current site if ( ! empty ( $ assoc_args [ 'activate' ] ) ) { $ this -> activate ( $ args ) ; } }
Enables a theme on a WordPress multisite install.

Permits theme to be activated from the dashboard of a site on a WordPress
multisite install.

## OPTIONS

<theme>
: The theme to enable.

[--network]
: If set, the theme is enabled for the entire network

[--activate]
: If set, the theme is activated for the current site. Note that
the "network" flag has no influence on this.

## EXAMPLES

# Enable theme
$ wp theme enable twentysixteen
Success: Enabled the 'Twenty Sixteen' theme.

# Network enable theme
$ wp theme enable twentysixteen --network
Success: Network enabled the 'Twenty Sixteen' theme.

# Network enable and activate theme for current site
$ wp theme enable twentysixteen --activate
Success: Enabled the 'Twenty Sixteen' theme.
Success: Switched to 'Twenty Sixteen' theme.
Enables a theme on a WordPress multisite install .