WP_Theme::network_enable_theme() public WP 4.6.0
Enables a theme for all sites on the current network.
{} It's a method of the class: WP_Theme{}
No Hooks.
Return
Null. Nothing.
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. |
Code of WP_Theme::network_enable_theme() WP Theme::network enable theme WP 5.6
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 );
}