WP_Theme::network_disable_theme()public staticWP 4.6.0

Disables 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_disable_theme( $stylesheets );
$stylesheets(string|string[]) (required)
Stylesheet name or array of stylesheet names.

Changelog

Since 4.6.0 Introduced.

WP_Theme::network_disable_theme() code WP 6.5.2

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

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

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

	update_site_option( 'allowedthemes', $allowed_themes );
}