Changeset 59176
- Timestamp:
- 10/05/2024 07:21:59 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-debug-data.php
r59175 r59176 36 36 */ 37 37 public static function debug_data() { 38 global $_wp_theme_features;39 40 // Save few function calls.41 $upload_dir = wp_upload_dir();42 $is_multisite = is_multisite();43 44 38 /* 45 39 * Set up the array that holds all debug information. … … 47 41 * When iterating through the debug data, the ordering of the sections 48 42 * occurs in insertion-order of the assignments into this array. Setting 49 * up empty values here preserves that specific ordering so it doesn't43 * up empty values here preserves that specific ordering, so it doesn't 50 44 * depend on when inside this method each section is otherwise assigned. 51 45 * … … 59 53 'wp-paths-sizes' => self::get_wp_paths_sizes(), 60 54 'wp-dropins' => self::get_wp_dropins(), 61 'wp-active-theme' => array(),62 'wp-parent-theme' => array(),63 'wp-themes-inactive' => array(),55 'wp-active-theme' => self::get_wp_active_theme(), 56 'wp-parent-theme' => self::get_wp_parent_theme(), 57 'wp-themes-inactive' => self::get_wp_themes_inactive(), 64 58 'wp-mu-plugins' => self::get_wp_mu_plugins(), 65 59 'wp-plugins-active' => self::get_wp_plugins_active(), … … 83 77 } 84 78 ); 85 86 $info['wp-active-theme'] = array(87 'label' => __( 'Active Theme' ),88 'fields' => array(),89 );90 91 $info['wp-parent-theme'] = array(92 'label' => __( 'Parent Theme' ),93 'fields' => array(),94 );95 96 $info['wp-themes-inactive'] = array(97 'label' => __( 'Inactive Themes' ),98 'show_count' => true,99 'fields' => array(),100 );101 102 // Populate the section for the currently active theme.103 $theme_features = array();104 105 if ( ! empty( $_wp_theme_features ) ) {106 foreach ( $_wp_theme_features as $feature => $options ) {107 $theme_features[] = $feature;108 }109 }110 111 $active_theme = wp_get_theme();112 $theme_updates = get_theme_updates();113 $transient = get_site_transient( 'update_themes' );114 115 $active_theme_version = $active_theme->version;116 $active_theme_version_debug = $active_theme_version;117 118 $auto_updates = array();119 $auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'theme' );120 if ( $auto_updates_enabled ) {121 $auto_updates = (array) get_site_option( 'auto_update_themes', array() );122 }123 124 if ( array_key_exists( $active_theme->stylesheet, $theme_updates ) ) {125 $theme_update_new_version = $theme_updates[ $active_theme->stylesheet ]->update['new_version'];126 127 /* translators: %s: Latest theme version number. */128 $active_theme_version .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_update_new_version );129 $active_theme_version_debug .= sprintf( ' (latest version: %s)', $theme_update_new_version );130 }131 132 $active_theme_author_uri = $active_theme->display( 'AuthorURI' );133 134 if ( $active_theme->parent_theme ) {135 $active_theme_parent_theme = sprintf(136 /* translators: 1: Theme name. 2: Theme slug. */137 __( '%1$s (%2$s)' ),138 $active_theme->parent_theme,139 $active_theme->template140 );141 $active_theme_parent_theme_debug = sprintf(142 '%s (%s)',143 $active_theme->parent_theme,144 $active_theme->template145 );146 } else {147 $active_theme_parent_theme = __( 'None' );148 $active_theme_parent_theme_debug = 'none';149 }150 151 $info['wp-active-theme']['fields'] = array(152 'name' => array(153 'label' => __( 'Name' ),154 'value' => sprintf(155 /* translators: 1: Theme name. 2: Theme slug. */156 __( '%1$s (%2$s)' ),157 $active_theme->name,158 $active_theme->stylesheet159 ),160 ),161 'version' => array(162 'label' => __( 'Version' ),163 'value' => $active_theme_version,164 'debug' => $active_theme_version_debug,165 ),166 'author' => array(167 'label' => __( 'Author' ),168 'value' => wp_kses( $active_theme->author, array() ),169 ),170 'author_website' => array(171 'label' => __( 'Author website' ),172 'value' => ( $active_theme_author_uri ? $active_theme_author_uri : __( 'Undefined' ) ),173 'debug' => ( $active_theme_author_uri ? $active_theme_author_uri : '(undefined)' ),174 ),175 'parent_theme' => array(176 'label' => __( 'Parent theme' ),177 'value' => $active_theme_parent_theme,178 'debug' => $active_theme_parent_theme_debug,179 ),180 'theme_features' => array(181 'label' => __( 'Theme features' ),182 'value' => implode( ', ', $theme_features ),183 ),184 'theme_path' => array(185 'label' => __( 'Theme directory location' ),186 'value' => get_stylesheet_directory(),187 ),188 );189 190 if ( $auto_updates_enabled ) {191 if ( isset( $transient->response[ $active_theme->stylesheet ] ) ) {192 $item = $transient->response[ $active_theme->stylesheet ];193 } elseif ( isset( $transient->no_update[ $active_theme->stylesheet ] ) ) {194 $item = $transient->no_update[ $active_theme->stylesheet ];195 } else {196 $item = array(197 'theme' => $active_theme->stylesheet,198 'new_version' => $active_theme->version,199 'url' => '',200 'package' => '',201 'requires' => '',202 'requires_php' => '',203 );204 }205 206 $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );207 208 if ( ! is_null( $auto_update_forced ) ) {209 $enabled = $auto_update_forced;210 } else {211 $enabled = in_array( $active_theme->stylesheet, $auto_updates, true );212 }213 214 if ( $enabled ) {215 $auto_updates_string = __( 'Enabled' );216 } else {217 $auto_updates_string = __( 'Disabled' );218 }219 220 /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */221 $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $active_theme, $enabled );222 223 $info['wp-active-theme']['fields']['auto_update'] = array(224 'label' => __( 'Auto-updates' ),225 'value' => $auto_updates_string,226 'debug' => $auto_updates_string,227 );228 }229 230 $parent_theme = $active_theme->parent();231 232 if ( $parent_theme ) {233 $parent_theme_version = $parent_theme->version;234 $parent_theme_version_debug = $parent_theme_version;235 236 if ( array_key_exists( $parent_theme->stylesheet, $theme_updates ) ) {237 $parent_theme_update_new_version = $theme_updates[ $parent_theme->stylesheet ]->update['new_version'];238 239 /* translators: %s: Latest theme version number. */240 $parent_theme_version .= ' ' . sprintf( __( '(Latest version: %s)' ), $parent_theme_update_new_version );241 $parent_theme_version_debug .= sprintf( ' (latest version: %s)', $parent_theme_update_new_version );242 }243 244 $parent_theme_author_uri = $parent_theme->display( 'AuthorURI' );245 246 $info['wp-parent-theme']['fields'] = array(247 'name' => array(248 'label' => __( 'Name' ),249 'value' => sprintf(250 /* translators: 1: Theme name. 2: Theme slug. */251 __( '%1$s (%2$s)' ),252 $parent_theme->name,253 $parent_theme->stylesheet254 ),255 ),256 'version' => array(257 'label' => __( 'Version' ),258 'value' => $parent_theme_version,259 'debug' => $parent_theme_version_debug,260 ),261 'author' => array(262 'label' => __( 'Author' ),263 'value' => wp_kses( $parent_theme->author, array() ),264 ),265 'author_website' => array(266 'label' => __( 'Author website' ),267 'value' => ( $parent_theme_author_uri ? $parent_theme_author_uri : __( 'Undefined' ) ),268 'debug' => ( $parent_theme_author_uri ? $parent_theme_author_uri : '(undefined)' ),269 ),270 'theme_path' => array(271 'label' => __( 'Theme directory location' ),272 'value' => get_template_directory(),273 ),274 );275 276 if ( $auto_updates_enabled ) {277 if ( isset( $transient->response[ $parent_theme->stylesheet ] ) ) {278 $item = $transient->response[ $parent_theme->stylesheet ];279 } elseif ( isset( $transient->no_update[ $parent_theme->stylesheet ] ) ) {280 $item = $transient->no_update[ $parent_theme->stylesheet ];281 } else {282 $item = array(283 'theme' => $parent_theme->stylesheet,284 'new_version' => $parent_theme->version,285 'url' => '',286 'package' => '',287 'requires' => '',288 'requires_php' => '',289 );290 }291 292 $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );293 294 if ( ! is_null( $auto_update_forced ) ) {295 $enabled = $auto_update_forced;296 } else {297 $enabled = in_array( $parent_theme->stylesheet, $auto_updates, true );298 }299 300 if ( $enabled ) {301 $parent_theme_auto_update_string = __( 'Enabled' );302 } else {303 $parent_theme_auto_update_string = __( 'Disabled' );304 }305 306 /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */307 $parent_theme_auto_update_string = apply_filters( 'theme_auto_update_debug_string', $parent_theme_auto_update_string, $parent_theme, $enabled );308 309 $info['wp-parent-theme']['fields']['auto_update'] = array(310 'label' => __( 'Auto-update' ),311 'value' => $parent_theme_auto_update_string,312 'debug' => $parent_theme_auto_update_string,313 );314 }315 }316 317 // Populate a list of all themes available in the install.318 $all_themes = wp_get_themes();319 320 foreach ( $all_themes as $theme_slug => $theme ) {321 // Exclude the currently active theme from the list of all themes.322 if ( $active_theme->stylesheet === $theme_slug ) {323 continue;324 }325 326 // Exclude the currently active parent theme from the list of all themes.327 if ( ! empty( $parent_theme ) && $parent_theme->stylesheet === $theme_slug ) {328 continue;329 }330 331 $theme_version = $theme->version;332 $theme_author = $theme->author;333 334 // Sanitize.335 $theme_author = wp_kses( $theme_author, array() );336 337 $theme_version_string = __( 'No version or author information is available.' );338 $theme_version_string_debug = 'undefined';339 340 if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) {341 /* translators: 1: Theme version number. 2: Theme author name. */342 $theme_version_string = sprintf( __( 'Version %1$s by %2$s' ), $theme_version, $theme_author );343 $theme_version_string_debug = sprintf( 'version: %s, author: %s', $theme_version, $theme_author );344 } else {345 if ( ! empty( $theme_author ) ) {346 /* translators: %s: Theme author name. */347 $theme_version_string = sprintf( __( 'By %s' ), $theme_author );348 $theme_version_string_debug = sprintf( 'author: %s, version: (undefined)', $theme_author );349 }350 351 if ( ! empty( $theme_version ) ) {352 /* translators: %s: Theme version number. */353 $theme_version_string = sprintf( __( 'Version %s' ), $theme_version );354 $theme_version_string_debug = sprintf( 'author: (undefined), version: %s', $theme_version );355 }356 }357 358 if ( array_key_exists( $theme_slug, $theme_updates ) ) {359 /* translators: %s: Latest theme version number. */360 $theme_version_string .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_updates[ $theme_slug ]->update['new_version'] );361 $theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] );362 }363 364 if ( $auto_updates_enabled ) {365 if ( isset( $transient->response[ $theme_slug ] ) ) {366 $item = $transient->response[ $theme_slug ];367 } elseif ( isset( $transient->no_update[ $theme_slug ] ) ) {368 $item = $transient->no_update[ $theme_slug ];369 } else {370 $item = array(371 'theme' => $theme_slug,372 'new_version' => $theme->version,373 'url' => '',374 'package' => '',375 'requires' => '',376 'requires_php' => '',377 );378 }379 380 $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );381 382 if ( ! is_null( $auto_update_forced ) ) {383 $enabled = $auto_update_forced;384 } else {385 $enabled = in_array( $theme_slug, $auto_updates, true );386 }387 388 if ( $enabled ) {389 $auto_updates_string = __( 'Auto-updates enabled' );390 } else {391 $auto_updates_string = __( 'Auto-updates disabled' );392 }393 394 /**395 * Filters the text string of the auto-updates setting for each theme in the Site Health debug data.396 *397 * @since 5.5.0398 *399 * @param string $auto_updates_string The string output for the auto-updates column.400 * @param WP_Theme $theme An object of theme data.401 * @param bool $enabled Whether auto-updates are enabled for this item.402 */403 $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled );404 405 $theme_version_string .= ' | ' . $auto_updates_string;406 $theme_version_string_debug .= ', ' . $auto_updates_string;407 }408 409 $info['wp-themes-inactive']['fields'][ sanitize_text_field( $theme->name ) ] = array(410 'label' => sprintf(411 /* translators: 1: Theme name. 2: Theme slug. */412 __( '%1$s (%2$s)' ),413 $theme->name,414 $theme_slug415 ),416 'value' => $theme_version_string,417 'debug' => $theme_version_string_debug,418 );419 }420 79 421 80 /** … … 1352 1011 1353 1012 /** 1013 * Gets the WordPress active theme section of the debug data. 1014 * 1015 * @since 6.7.0 1016 * 1017 * @return array 1018 */ 1019 private static function get_wp_active_theme(): array { 1020 global $_wp_theme_features; 1021 1022 // Populate the section for the currently active theme. 1023 $theme_features = array(); 1024 1025 if ( ! empty( $_wp_theme_features ) ) { 1026 foreach ( $_wp_theme_features as $feature => $options ) { 1027 $theme_features[] = $feature; 1028 } 1029 } 1030 1031 $active_theme = wp_get_theme(); 1032 $theme_updates = get_theme_updates(); 1033 $transient = get_site_transient( 'update_themes' ); 1034 1035 $active_theme_version = $active_theme->version; 1036 $active_theme_version_debug = $active_theme_version; 1037 1038 $auto_updates = array(); 1039 $auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'theme' ); 1040 if ( $auto_updates_enabled ) { 1041 $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); 1042 } 1043 1044 if ( array_key_exists( $active_theme->stylesheet, $theme_updates ) ) { 1045 $theme_update_new_version = $theme_updates[ $active_theme->stylesheet ]->update['new_version']; 1046 1047 /* translators: %s: Latest theme version number. */ 1048 $active_theme_version .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_update_new_version ); 1049 $active_theme_version_debug .= sprintf( ' (latest version: %s)', $theme_update_new_version ); 1050 } 1051 1052 $active_theme_author_uri = $active_theme->display( 'AuthorURI' ); 1053 1054 if ( $active_theme->parent_theme ) { 1055 $active_theme_parent_theme = sprintf( 1056 /* translators: 1: Theme name. 2: Theme slug. */ 1057 __( '%1$s (%2$s)' ), 1058 $active_theme->parent_theme, 1059 $active_theme->template 1060 ); 1061 $active_theme_parent_theme_debug = sprintf( 1062 '%s (%s)', 1063 $active_theme->parent_theme, 1064 $active_theme->template 1065 ); 1066 } else { 1067 $active_theme_parent_theme = __( 'None' ); 1068 $active_theme_parent_theme_debug = 'none'; 1069 } 1070 1071 $fields = array( 1072 'name' => array( 1073 'label' => __( 'Name' ), 1074 'value' => sprintf( 1075 /* translators: 1: Theme name. 2: Theme slug. */ 1076 __( '%1$s (%2$s)' ), 1077 $active_theme->name, 1078 $active_theme->stylesheet 1079 ), 1080 ), 1081 'version' => array( 1082 'label' => __( 'Version' ), 1083 'value' => $active_theme_version, 1084 'debug' => $active_theme_version_debug, 1085 ), 1086 'author' => array( 1087 'label' => __( 'Author' ), 1088 'value' => wp_kses( $active_theme->author, array() ), 1089 ), 1090 'author_website' => array( 1091 'label' => __( 'Author website' ), 1092 'value' => ( $active_theme_author_uri ? $active_theme_author_uri : __( 'Undefined' ) ), 1093 'debug' => ( $active_theme_author_uri ? $active_theme_author_uri : '(undefined)' ), 1094 ), 1095 'parent_theme' => array( 1096 'label' => __( 'Parent theme' ), 1097 'value' => $active_theme_parent_theme, 1098 'debug' => $active_theme_parent_theme_debug, 1099 ), 1100 'theme_features' => array( 1101 'label' => __( 'Theme features' ), 1102 'value' => implode( ', ', $theme_features ), 1103 ), 1104 'theme_path' => array( 1105 'label' => __( 'Theme directory location' ), 1106 'value' => get_stylesheet_directory(), 1107 ), 1108 ); 1109 1110 if ( $auto_updates_enabled ) { 1111 if ( isset( $transient->response[ $active_theme->stylesheet ] ) ) { 1112 $item = $transient->response[ $active_theme->stylesheet ]; 1113 } elseif ( isset( $transient->no_update[ $active_theme->stylesheet ] ) ) { 1114 $item = $transient->no_update[ $active_theme->stylesheet ]; 1115 } else { 1116 $item = array( 1117 'theme' => $active_theme->stylesheet, 1118 'new_version' => $active_theme->version, 1119 'url' => '', 1120 'package' => '', 1121 'requires' => '', 1122 'requires_php' => '', 1123 ); 1124 } 1125 1126 $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item ); 1127 1128 if ( ! is_null( $auto_update_forced ) ) { 1129 $enabled = $auto_update_forced; 1130 } else { 1131 $enabled = in_array( $active_theme->stylesheet, $auto_updates, true ); 1132 } 1133 1134 if ( $enabled ) { 1135 $auto_updates_string = __( 'Enabled' ); 1136 } else { 1137 $auto_updates_string = __( 'Disabled' ); 1138 } 1139 1140 /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */ 1141 $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $active_theme, $enabled ); 1142 1143 $fields['auto_update'] = array( 1144 'label' => __( 'Auto-updates' ), 1145 'value' => $auto_updates_string, 1146 'debug' => $auto_updates_string, 1147 ); 1148 } 1149 1150 return array( 1151 'label' => __( 'Active Theme' ), 1152 'fields' => $fields, 1153 ); 1154 } 1155 1156 /** 1157 * Gets the WordPress parent theme section of the debug data. 1158 * 1159 * @since 6.7.0 1160 * 1161 * @return array 1162 */ 1163 private static function get_wp_parent_theme(): array { 1164 $theme_updates = get_theme_updates(); 1165 $transient = get_site_transient( 'update_themes' ); 1166 1167 $auto_updates = array(); 1168 $auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'theme' ); 1169 if ( $auto_updates_enabled ) { 1170 $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); 1171 } 1172 1173 $active_theme = wp_get_theme(); 1174 $parent_theme = $active_theme->parent(); 1175 $fields = array(); 1176 1177 if ( $parent_theme ) { 1178 $parent_theme_version = $parent_theme->version; 1179 $parent_theme_version_debug = $parent_theme_version; 1180 1181 if ( array_key_exists( $parent_theme->stylesheet, $theme_updates ) ) { 1182 $parent_theme_update_new_version = $theme_updates[ $parent_theme->stylesheet ]->update['new_version']; 1183 1184 /* translators: %s: Latest theme version number. */ 1185 $parent_theme_version .= ' ' . sprintf( __( '(Latest version: %s)' ), $parent_theme_update_new_version ); 1186 $parent_theme_version_debug .= sprintf( ' (latest version: %s)', $parent_theme_update_new_version ); 1187 } 1188 1189 $parent_theme_author_uri = $parent_theme->display( 'AuthorURI' ); 1190 1191 $fields = array( 1192 'name' => array( 1193 'label' => __( 'Name' ), 1194 'value' => sprintf( 1195 /* translators: 1: Theme name. 2: Theme slug. */ 1196 __( '%1$s (%2$s)' ), 1197 $parent_theme->name, 1198 $parent_theme->stylesheet 1199 ), 1200 ), 1201 'version' => array( 1202 'label' => __( 'Version' ), 1203 'value' => $parent_theme_version, 1204 'debug' => $parent_theme_version_debug, 1205 ), 1206 'author' => array( 1207 'label' => __( 'Author' ), 1208 'value' => wp_kses( $parent_theme->author, array() ), 1209 ), 1210 'author_website' => array( 1211 'label' => __( 'Author website' ), 1212 'value' => ( $parent_theme_author_uri ? $parent_theme_author_uri : __( 'Undefined' ) ), 1213 'debug' => ( $parent_theme_author_uri ? $parent_theme_author_uri : '(undefined)' ), 1214 ), 1215 'theme_path' => array( 1216 'label' => __( 'Theme directory location' ), 1217 'value' => get_template_directory(), 1218 ), 1219 ); 1220 1221 if ( $auto_updates_enabled ) { 1222 if ( isset( $transient->response[ $parent_theme->stylesheet ] ) ) { 1223 $item = $transient->response[ $parent_theme->stylesheet ]; 1224 } elseif ( isset( $transient->no_update[ $parent_theme->stylesheet ] ) ) { 1225 $item = $transient->no_update[ $parent_theme->stylesheet ]; 1226 } else { 1227 $item = array( 1228 'theme' => $parent_theme->stylesheet, 1229 'new_version' => $parent_theme->version, 1230 'url' => '', 1231 'package' => '', 1232 'requires' => '', 1233 'requires_php' => '', 1234 ); 1235 } 1236 1237 $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item ); 1238 1239 if ( ! is_null( $auto_update_forced ) ) { 1240 $enabled = $auto_update_forced; 1241 } else { 1242 $enabled = in_array( $parent_theme->stylesheet, $auto_updates, true ); 1243 } 1244 1245 if ( $enabled ) { 1246 $parent_theme_auto_update_string = __( 'Enabled' ); 1247 } else { 1248 $parent_theme_auto_update_string = __( 'Disabled' ); 1249 } 1250 1251 /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */ 1252 $parent_theme_auto_update_string = apply_filters( 'theme_auto_update_debug_string', $parent_theme_auto_update_string, $parent_theme, $enabled ); 1253 1254 $fields['auto_update'] = array( 1255 'label' => __( 'Auto-update' ), 1256 'value' => $parent_theme_auto_update_string, 1257 'debug' => $parent_theme_auto_update_string, 1258 ); 1259 } 1260 } 1261 1262 return array( 1263 'label' => __( 'Parent Theme' ), 1264 'fields' => $fields, 1265 ); 1266 } 1267 1268 /** 1269 * Gets the WordPress inactive themes section of the debug data. 1270 * 1271 * @since 6.7.0 1272 * 1273 * @return array 1274 */ 1275 private static function get_wp_themes_inactive(): array { 1276 $active_theme = wp_get_theme(); 1277 $parent_theme = $active_theme->parent(); 1278 $theme_updates = get_theme_updates(); 1279 1280 $auto_updates = array(); 1281 $auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'theme' ); 1282 if ( $auto_updates_enabled ) { 1283 $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); 1284 } 1285 1286 // Populate a list of all themes available in the installation. 1287 $all_themes = wp_get_themes(); 1288 $fields = array(); 1289 1290 foreach ( $all_themes as $theme_slug => $theme ) { 1291 // Exclude the currently active theme from the list of all themes. 1292 if ( $active_theme->stylesheet === $theme_slug ) { 1293 continue; 1294 } 1295 1296 // Exclude the currently active parent theme from the list of all themes. 1297 if ( ! empty( $parent_theme ) && $parent_theme->stylesheet === $theme_slug ) { 1298 continue; 1299 } 1300 1301 $theme_version = $theme->version; 1302 $theme_author = $theme->author; 1303 1304 // Sanitize. 1305 $theme_author = wp_kses( $theme_author, array() ); 1306 1307 $theme_version_string = __( 'No version or author information is available.' ); 1308 $theme_version_string_debug = 'undefined'; 1309 1310 if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) { 1311 /* translators: 1: Theme version number. 2: Theme author name. */ 1312 $theme_version_string = sprintf( __( 'Version %1$s by %2$s' ), $theme_version, $theme_author ); 1313 $theme_version_string_debug = sprintf( 'version: %s, author: %s', $theme_version, $theme_author ); 1314 } else { 1315 if ( ! empty( $theme_author ) ) { 1316 /* translators: %s: Theme author name. */ 1317 $theme_version_string = sprintf( __( 'By %s' ), $theme_author ); 1318 $theme_version_string_debug = sprintf( 'author: %s, version: (undefined)', $theme_author ); 1319 } 1320 1321 if ( ! empty( $theme_version ) ) { 1322 /* translators: %s: Theme version number. */ 1323 $theme_version_string = sprintf( __( 'Version %s' ), $theme_version ); 1324 $theme_version_string_debug = sprintf( 'author: (undefined), version: %s', $theme_version ); 1325 } 1326 } 1327 1328 if ( array_key_exists( $theme_slug, $theme_updates ) ) { 1329 /* translators: %s: Latest theme version number. */ 1330 $theme_version_string .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_updates[ $theme_slug ]->update['new_version'] ); 1331 $theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] ); 1332 } 1333 1334 if ( $auto_updates_enabled ) { 1335 if ( isset( $transient->response[ $theme_slug ] ) ) { 1336 $item = $transient->response[ $theme_slug ]; 1337 } elseif ( isset( $transient->no_update[ $theme_slug ] ) ) { 1338 $item = $transient->no_update[ $theme_slug ]; 1339 } else { 1340 $item = array( 1341 'theme' => $theme_slug, 1342 'new_version' => $theme->version, 1343 'url' => '', 1344 'package' => '', 1345 'requires' => '', 1346 'requires_php' => '', 1347 ); 1348 } 1349 1350 $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item ); 1351 1352 if ( ! is_null( $auto_update_forced ) ) { 1353 $enabled = $auto_update_forced; 1354 } else { 1355 $enabled = in_array( $theme_slug, $auto_updates, true ); 1356 } 1357 1358 if ( $enabled ) { 1359 $auto_updates_string = __( 'Auto-updates enabled' ); 1360 } else { 1361 $auto_updates_string = __( 'Auto-updates disabled' ); 1362 } 1363 1364 /** 1365 * Filters the text string of the auto-updates setting for each theme in the Site Health debug data. 1366 * 1367 * @since 5.5.0 1368 * 1369 * @param string $auto_updates_string The string output for the auto-updates column. 1370 * @param WP_Theme $theme An object of theme data. 1371 * @param bool $enabled Whether auto-updates are enabled for this item. 1372 */ 1373 $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled ); 1374 1375 $theme_version_string .= ' | ' . $auto_updates_string; 1376 $theme_version_string_debug .= ', ' . $auto_updates_string; 1377 } 1378 1379 $fields[ sanitize_text_field( $theme->name ) ] = array( 1380 'label' => sprintf( 1381 /* translators: 1: Theme name. 2: Theme slug. */ 1382 __( '%1$s (%2$s)' ), 1383 $theme->name, 1384 $theme_slug 1385 ), 1386 'value' => $theme_version_string, 1387 'debug' => $theme_version_string_debug, 1388 ); 1389 } 1390 1391 return array( 1392 'label' => __( 'Inactive Themes' ), 1393 'show_count' => true, 1394 'fields' => $fields, 1395 ); 1396 } 1397 1398 /** 1354 1399 * Gets the WordPress constants section of the debug data. 1355 1400 *
Note: See TracChangeset
for help on using the changeset viewer.