X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/784f914b1e4b1c62d6657e86397c2e83bcee4295..073c5ed6408e2f00dc1863b463fe205467628905:/wp-includes/class-wp-theme.php diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php index d98fb314..35c56503 100644 --- a/wp-includes/class-wp-theme.php +++ b/wp-includes/class-wp-theme.php @@ -170,7 +170,7 @@ final class WP_Theme implements ArrayAccess { /** * 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 @@ -437,7 +437,7 @@ final class WP_Theme implements ArrayAccess { * 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 @@ -447,8 +447,10 @@ final class WP_Theme implements ArrayAccess { 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'); @@ -718,8 +720,9 @@ final class WP_Theme implements ArrayAccess { 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 ); @@ -769,15 +772,28 @@ final class WP_Theme implements ArrayAccess { $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 ) { @@ -918,7 +934,7 @@ final class WP_Theme implements ArrayAccess { * * 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 @@ -1029,7 +1045,7 @@ final class WP_Theme implements ArrayAccess { $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. @@ -1190,7 +1206,7 @@ final class WP_Theme implements ArrayAccess { */ 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. @@ -1223,7 +1239,7 @@ final class WP_Theme implements ArrayAccess { } /** - * Filter the array of themes allowed on the network. + * Filters the array of themes allowed on the network. * * @since MU * @@ -1255,7 +1271,7 @@ final class WP_Theme implements ArrayAccess { 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 * @@ -1315,6 +1331,60 @@ final class WP_Theme implements ArrayAccess { 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. *