WP_Theme::is_allowed() WordPress Method

The WP_Theme::is_allowed() method is used to check whether a theme is allowed to be active on a site. This is determined by the site's administrator.

WP_Theme::is_allowed( string $check = 'both', int $blog_id = null ) #

Determines whether the theme is allowed (multisite only).


Parameters

$check

(string)(Optional) Whether to check only the 'network'-wide settings, the 'site' settings, or 'both'. Defaults to 'both'.

Default value: 'both'

$blog_id

(int)(Optional) Ignored if only network-wide settings are checked. Defaults to current site.

Default value: null


Top ↑

Return

(bool) Whether the theme is allowed for the network. Returns true in single-site.


Top ↑

Source

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

	public function is_allowed( $check = 'both', $blog_id = null ) {
		if ( ! is_multisite() ) {
			return true;
		}

		if ( 'both' === $check || 'network' === $check ) {
			$allowed = self::get_allowed_on_network();
			if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) {
				return true;
			}
		}

		if ( 'both' === $check || 'site' === $check ) {
			$allowed = self::get_allowed_on_site( $blog_id );
			if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) {
				return true;
			}
		}

		return false;
	}


Top ↑

Changelog

Changelog
VersionDescription
3.4.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.