/**
* Flag for whether the themes cache bucket should be persistently cached.
*
- * Default is false. Can be set with the wp_cache_themes_persistently filter.
+ * Default is false. Can be set with the {@see 'wp_cache_themes_persistently'} filter.
*
* @static
* @access private
* translated data. We are doing so now as it is safe to do. However, as
* Name and Title could have been used as the key for get_themes(), both remain
* untranslated for back compatibility. This means that ['Name'] is not ideal,
- * and care should be taken to use $theme->display('Name') to get a properly
+ * and care should be taken to use `$theme::display( 'Name' )` to get a properly
* translated header.
*
* @param mixed $offset
switch ( $offset ) {
case 'Name' :
case 'Title' :
- // See note above about using translated data. get() is not ideal.
- // It is only for backwards compatibility. Use display().
+ /*
+ * See note above about using translated data. get() is not ideal.
+ * It is only for backward compatibility. Use display().
+ */
return $this->get('Name');
case 'Author' :
return $this->display( 'Author');
private function markup_header( $header, $value, $translate ) {
switch ( $header ) {
case 'Name' :
- if ( empty( $value ) )
- $value = $this->get_stylesheet();
+ if ( empty( $value ) ) {
+ $value = esc_html( $this->get_stylesheet() );
+ }
break;
case 'Description' :
$value = wptexturize( $value );
$this->name_translated = translate( $value, $this->get('TextDomain' ) );
return $this->name_translated;
case 'Tags' :
- if ( empty( $value ) || ! function_exists( 'get_theme_feature_list' ) )
+ if ( empty( $value ) || ! function_exists( 'get_theme_feature_list' ) ) {
return $value;
+ }
static $tags_list;
if ( ! isset( $tags_list ) ) {
- $tags_list = array();
+ $tags_list = array(
+ // As of 4.6, deprecated tags which are only used to provide translation for older themes.
+ 'black' => __( 'Black' ), 'blue' => __( 'Blue' ), 'brown' => __( 'Brown' ),
+ 'gray' => __( 'Gray' ), 'green' => __( 'Green' ), 'orange' => __( 'Orange' ),
+ 'pink' => __( 'Pink' ), 'purple' => __( 'Purple' ), 'red' => __( 'Red' ),
+ 'silver' => __( 'Silver' ), 'tan' => __( 'Tan' ), 'white' => __( 'White' ),
+ 'yellow' => __( 'Yellow' ), 'dark' => __( 'Dark' ), 'light' => __( 'Light' ),
+ 'fixed-layout' => __( 'Fixed Layout' ), 'fluid-layout' => __( 'Fluid Layout' ),
+ 'responsive-layout' => __( 'Responsive Layout' ), 'blavatar' => __( 'Blavatar' ),
+ 'photoblogging' => __( 'Photoblogging' ), 'seasonal' => __( 'Seasonal' ),
+ );
+
$feature_list = get_theme_feature_list( false ); // No API
- foreach ( $feature_list as $tags )
+ foreach ( $feature_list as $tags ) {
$tags_list += $tags;
+ }
}
foreach ( $value as &$tag ) {
*
* This is typically the absolute URL to wp-content/themes. This forms the basis
* for all other URLs returned by WP_Theme, so we pass it to the public function
- * get_theme_root_uri() and allow it to run the theme_root_uri filter.
+ * get_theme_root_uri() and allow it to run the {@see 'theme_root_uri'} filter.
*
* @since 3.4.0
* @access public
$page_templates += $this->parent()->get_page_templates( $post );
/**
- * Filter list of page templates for a theme.
+ * Filters list of page templates for a theme.
*
* @since 3.9.0
* @since 4.4.0 Converted to allow complete control over the `$page_templates` array.
*/
public static function get_allowed( $blog_id = null ) {
/**
- * Filter the array of themes allowed on the network.
+ * Filters the array of themes allowed on the network.
*
* Site is provided as context so that a list of network allowed themes can
* be filtered further.
}
/**
- * Filter the array of themes allowed on the network.
+ * Filters the array of themes allowed on the network.
*
* @since MU
*
if ( isset( $allowed_themes[ $blog_id ] ) ) {
/**
- * Filter the array of themes allowed on the site.
+ * Filters the array of themes allowed on the site.
*
* @since 4.5.0
*
return (array) apply_filters( 'site_allowed_themes', $allowed_themes[ $blog_id ], $blog_id );
}
+ /**
+ * Enables a theme for all sites on the current network.
+ *
+ * @since 4.6.0
+ * @access public
+ * @static
+ *
+ * @param string|array $stylesheets Stylesheet name or array of stylesheet names.
+ */
+ 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 );
+ }
+
+ /**
+ * Disables a theme for all sites on the current network.
+ *
+ * @since 4.6.0
+ * @access public
+ * @static
+ *
+ * @param string|array $stylesheets Stylesheet name or array of stylesheet names.
+ */
+ public static function network_disable_theme( $stylesheets ) {
+ if ( ! is_multisite() ) {
+ return;
+ }
+
+ if ( ! is_array( $stylesheets ) ) {
+ $stylesheets = array( $stylesheets );
+ }
+
+ $allowed_themes = get_site_option( 'allowedthemes' );
+ foreach ( $stylesheets as $stylesheet ) {
+ if ( isset( $allowed_themes[ $stylesheet ] ) ) {
+ unset( $allowed_themes[ $stylesheet ] );
+ }
+ }
+
+ update_site_option( 'allowedthemes', $allowed_themes );
+ }
+
/**
* Sorts themes by name.
*