WP_Theme::network_enable_theme()public staticWP 4.6.0

Enables a theme for all sites on the current network.

Method of the class: WP_Theme{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = WP_Theme::network_enable_theme( $stylesheets );
$stylesheets(string|string[]) (required)
Stylesheet name or array of stylesheet names.

Changelog

Since 4.6.0 Introduced.

WP_Theme::network_enable_theme() code WP 6.5.2

public static function network_enable_theme( $stylesheets ) {
	if ( ! is_multisite() ) {
		return;
	}

	if ( ! is_array( $stylesheets ) ) {
		$stylesheets = array( $stylesheets );
	}

	$allowed_themes = get_site_option( 'allowedthemes' );
	foreach ( $stylesheets as $stylesheet ) {
		$allowed_themes[ $stylesheet ] = true;
	}

	update_site_option( 'allowedthemes', $allowed_themes );
}