WP_Theme::is_allowed()publicWP 3.4.0

Determines whether the theme is allowed (multisite only).

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

Хуков нет.

Возвращает

true|false. Whether the theme is allowed for the network. Returns true in single-site.

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

$WP_Theme = new WP_Theme();
$WP_Theme->is_allowed( $check, $blog_id );
$check(строка)
Whether to check only the 'network'-wide settings, the 'site' settings, or 'both'.
По умолчанию: 'both'
$blog_id(int)
Ignored if only network-wide settings are checked.
По умолчанию: current site

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

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

Код WP_Theme::is_allowed() WP 6.5.2

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