WP_Theme::network_enable_theme()public staticWP 4.6.0

Enables a theme for all sites on the current network.

Метод класса: WP_Theme{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = WP_Theme::network_enable_theme( $stylesheets );
$stylesheets(строка|string[]) (обязательный)
Stylesheet name or array of stylesheet names.

Список изменений

С версии 4.6.0 Введена.

Код WP_Theme::network_enable_theme() 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 );
}