WP_Theme::network_enable_theme
Enables a theme for all sites on the current network.
Method of the class: WP_Theme{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WP_Theme::network_enable_theme( $stylesheets );
- $stylesheets(string|string[]) (required)
- Stylesheet name or array of stylesheet names.
Changelog
| Since 4.6.0 | Introduced. |
WP_Theme::network_enable_theme() WP Theme::network enable theme code WP 6.8.3
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 );
}