On this page
WP_Theme::is_allowed( string $check = 'both', int $blog_id = null ): bool
Determines whether the theme is allowed (multisite only).
Parameters
$checkstring Optional-
Whether to check only the
'network'-wide settings, the'site'settings, or'both'. Defaults to'both'.Default:
'both' $blog_idint Optional-
Ignored if only network-wide settings are checked. Defaults to current site.
Default:
null
Return
bool Whether the theme is allowed for the network. Returns true in single-site.
Source
File: wp-includes/class-wp-theme.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Theme::get_allowed_on_network() wp-includes/class-wp-theme.php | Returns array of stylesheet names of themes allowed on the network. |
| WP_Theme::get_allowed_on_site() wp-includes/class-wp-theme.php | Returns array of stylesheet names of themes allowed on the site. |
| WP_Theme::get_stylesheet() wp-includes/class-wp-theme.php | Returns the directory name of the theme’s “stylesheet” files, inside the theme root. |
| is_multisite() wp-includes/load.php | If Multisite is enabled. |
Changelog
| Version | Description |
|---|---|
| 3.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme/is_allowed