Ticket #48515: 48515.2.diff
File 48515.2.diff, 2.8 KB (added by , 4 years ago) |
---|
-
wp-includes/class-wp-theme.php
diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php index 2697aaf521..96f67dbc72 100644
a b final class WP_Theme implements ArrayAccess { 35 35 'Tags' => 'Tags', 36 36 'TextDomain' => 'Text Domain', 37 37 'DomainPath' => 'Domain Path', 38 'Requires' => 'Requires at least', 39 'RequiresPHP' => 'Requires PHP', 38 40 ); 39 41 40 42 /** … … final class WP_Theme implements ArrayAccess { 267 269 ); 268 270 return; 269 271 } else { 270 $this->headers = get_file_data( $this->theme_root . '/' . $theme_file, self::$file_headers, 'theme' ); 272 $this->headers = $this->get_theme_headers( $theme_dir, $theme_file ); 273 271 274 // Default themes always trump their pretenders. 272 275 // Properly identify default themes that are inside a directory within wp-content/themes. 273 276 $default_theme_slug = array_search( $this->headers['Name'], self::$default_themes ); … … final class WP_Theme implements ArrayAccess { 850 853 $value = array_filter( array_map( 'trim', explode( ',', strip_tags( $value ) ) ) ); 851 854 break; 852 855 case 'Version': 856 case 'Requires': 857 case 'RequiresPHP': 853 858 $value = strip_tags( $value ); 854 859 break; 855 860 } … … final class WP_Theme implements ArrayAccess { 1110 1115 return $this->theme_root_uri; 1111 1116 } 1112 1117 1118 /** 1119 * Get headers from theme's style.css and readme.txt files. 1120 * 1121 * Uses `get_file_data()` to get and combine the theme headers 1122 * from the theme's style.css and readme.txt files. 1123 * 1124 * Precedence order: readme.txt > style.css 1125 * 1126 * @since 5.x.x 1127 * 1128 * @param string $theme_dir Directory of the theme within the theme_root. 1129 * @param string $theme_file Main theme file. 1130 * 1131 * @return array Theme headers. 1132 */ 1133 public function get_theme_headers( $theme_dir, $theme_file ) { 1134 $theme_headers = get_file_data( $this->theme_root . '/' . $theme_file, self::$file_headers, 'theme' ); 1135 1136 $readme = $this->theme_root . '/'. $theme_dir . '/readme.txt'; 1137 if ( file_exists( $readme ) ) { 1138 $readme_headers = get_file_data( $readme, self::$file_headers, 'theme' ); 1139 1140 // Precedence to headers in readme.txt over style.css file. 1141 foreach ( $theme_headers as $header => $value ) { 1142 if ( ! empty( $readme_headers[ $header ] ) ) { 1143 $theme_headers[ $header ] = $readme_headers[ $header ]; 1144 } 1145 } 1146 } 1147 1148 // Many themes incorrectly use `Requires at least: WordPress x.x`, including default themes. 1149 // It should only be the version number, `Requires at least: x.x`. 1150 if ( false !== strpos( $theme_headers['Requires'], 'WordPress' ) ) { 1151 $theme_headers['Requires'] = trim( str_replace( 'WordPress', '', $theme_headers['Requires'] ) ); 1152 } 1153 1154 return $theme_headers; 1155 } 1156 1113 1157 /** 1114 1158 * Returns the main screenshot file for the theme. 1115 1159 *