WP_Theme::network_disable_theme() WordPress Method

The WP_Theme::network_disable_theme() function allows you to disable a theme for all sites on a network. This function takes a theme object as its only parameter.

WP_Theme::network_disable_theme( string|string[] $stylesheets ) #

Disables a theme for all sites on the current network.


Parameters

$stylesheets

(string|string[])(Required)Stylesheet name or array of stylesheet names.


Top ↑

Source

File: wp-includes/class-wp-theme.php

	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 );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.