WP_Theme::network_enable_theme() WordPress Method
The WP_Theme::network_enable_theme() method enables a theme for the entire network. This is useful if you want to make sure that all of your sites on a network are using the same theme. It also allows you to centrally manage your themes from one location.
WP_Theme::network_enable_theme( string|string[] $stylesheets ) #
Enables a theme for all sites on the current network.
Parameters
- $stylesheets
(string|string[])(Required)Stylesheet name or array of stylesheet names.
Source
File: wp-includes/class-wp-theme.php
public static function network_enable_theme( $stylesheets ) {
if ( ! is_multisite() ) {
return;
}
if ( ! is_array( $stylesheets ) ) {
$stylesheets = array( $stylesheets );
}
$allowed_themes = get_site_option( 'allowedthemes' );
foreach ( $stylesheets as $stylesheet ) {
$allowed_themes[ $stylesheet ] = true;
}
update_site_option( 'allowedthemes', $allowed_themes );
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 4.6.0 | Introduced. |