Changeset 48732
- Timestamp:
- 08/04/2020 05:37:59 PM (5 years ago)
- Location:
- branches/5.5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.5
-
branches/5.5/src/wp-admin/includes/class-wp-debug-data.php
r48697 r48732 906 906 $plugins = get_plugins(); 907 907 $plugin_updates = get_plugin_updates(); 908 $auto_updates = array(); 908 $transient = get_site_transient( 'update_plugins' ); 909 910 $auto_updates = array(); 909 911 910 912 $auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'plugin' ); … … 948 950 949 951 if ( $auto_updates_enabled ) { 950 if ( in_array( $plugin_path, $auto_updates, true ) ) { 952 if ( isset( $transient->response[ $plugin_path ] ) ) { 953 $item = $transient->response[ $plugin_path ]; 954 } elseif ( isset( $transient->no_update[ $plugin_path ] ) ) { 955 $item = $transient->no_update[ $plugin_path ]; 956 } else { 957 $item = array( 958 'id' => $plugin_path, 959 'slug' => '', 960 'plugin' => $plugin_path, 961 'new_version' => '', 962 'url' => '', 963 'package' => '', 964 'icons' => array(), 965 'banners' => array(), 966 'banners_rtl' => array(), 967 'tested' => '', 968 'requires_php' => '', 969 'compatibility' => new stdClass(), 970 ); 971 $item = (object) array_merge( $item, array_intersect_key( $plugin, $item ) ); 972 } 973 974 /** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */ 975 $auto_update_forced = apply_filters( 'auto_update_plugin', null, $item ); 976 977 if ( ! is_null( $auto_update_forced ) ) { 978 $enabled = $auto_update_forced; 979 } else { 980 $enabled = in_array( $plugin_path, $auto_updates, true ); 981 } 982 983 if ( $enabled ) { 951 984 $auto_updates_string = __( 'Auto-updates enabled' ); 952 $enabled = true;953 954 /**955 * Filters the text string of the auto-updates setting for each plugin in the Site Health debug data.956 *957 * @since 5.5.0958 *959 * @param string $auto_updates_string The string output for the auto-updates column.960 * @param string $plugin_path The path to the plugin file.961 * @param array $plugin An array of plugin data.962 * @param bool $enabled Whether auto-updates are enabled for this item.963 */964 $auto_updates_string = apply_filters( 'plugin_auto_update_debug_string', $auto_updates_string, $plugin_path, $plugin, $enabled );965 985 } else { 966 986 $auto_updates_string = __( 'Auto-updates disabled' ); 967 $enabled = false; 968 969 /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */ 970 $auto_updates_string = apply_filters( 'plugin_auto_update_debug_string', $auto_updates_string, $plugin_path, $plugin, $enabled ); 971 } 987 } 988 989 /** 990 * Filters the text string of the auto-updates setting for each plugin in the Site Health debug data. 991 * 992 * @since 5.5.0 993 * 994 * @param string $auto_updates_string The string output for the auto-updates column. 995 * @param string $plugin_path The path to the plugin file. 996 * @param array $plugin An array of plugin data. 997 * @param bool $enabled Whether auto-updates are enabled for this item. 998 */ 999 $auto_updates_string = apply_filters( 'plugin_auto_update_debug_string', $auto_updates_string, $plugin_path, $plugin, $enabled ); 972 1000 973 1001 $plugin_version_string .= ' | ' . $auto_updates_string; … … 994 1022 $active_theme = wp_get_theme(); 995 1023 $theme_updates = get_theme_updates(); 1024 $transient = get_site_transient( 'update_themes' ); 996 1025 997 1026 $active_theme_version = $active_theme->version; … … 1071 1100 1072 1101 if ( $auto_updates_enabled ) { 1073 if ( in_array( $active_theme->stylesheet, $auto_updates, true ) ) { 1102 if ( isset( $transient->response[ $active_theme->stylesheet ] ) ) { 1103 $item = $transient->response[ $active_theme->stylesheet ]; 1104 } elseif ( isset( $transient->no_update[ $active_theme->stylesheet ] ) ) { 1105 $item = $transient->no_update[ $active_theme->stylesheet ]; 1106 } else { 1107 $item = (object) array( 1108 'theme' => $active_theme->stylesheet, 1109 'new_version' => $active_theme->version, 1110 'url' => '', 1111 'package' => '', 1112 'requires' => '', 1113 'requires_php' => '', 1114 ); 1115 } 1116 1117 /** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */ 1118 $auto_update_forced = apply_filters( 'auto_update_theme', null, $item ); 1119 1120 if ( ! is_null( $auto_update_forced ) ) { 1121 $enabled = $auto_update_forced; 1122 } else { 1123 $enabled = in_array( $active_theme->stylesheet, $auto_updates, true ); 1124 } 1125 1126 if ( $enabled ) { 1074 1127 $auto_updates_string = __( 'Enabled' ); 1075 $enabled = true; 1128 } else { 1129 $auto_updates_string = __( 'Disabled' ); 1130 } 1131 1132 /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */ 1133 $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $active_theme, $enabled ); 1134 1135 $info['wp-active-theme']['fields']['auto_update'] = array( 1136 'label' => __( 'Auto-updates' ), 1137 'value' => $auto_updates_string, 1138 'debug' => $auto_updates_string, 1139 ); 1140 } 1141 1142 $parent_theme = $active_theme->parent(); 1143 1144 if ( $parent_theme ) { 1145 $parent_theme_version = $parent_theme->version; 1146 $parent_theme_version_debug = $parent_theme_version; 1147 1148 if ( array_key_exists( $parent_theme->stylesheet, $theme_updates ) ) { 1149 $parent_theme_update_new_version = $theme_updates[ $parent_theme->stylesheet ]->update['new_version']; 1150 1151 /* translators: %s: Latest theme version number. */ 1152 $parent_theme_version .= ' ' . sprintf( __( '(Latest version: %s)' ), $parent_theme_update_new_version ); 1153 $parent_theme_version_debug .= sprintf( ' (latest version: %s)', $parent_theme_update_new_version ); 1154 } 1155 1156 $parent_theme_author_uri = $parent_theme->display( 'AuthorURI' ); 1157 1158 $info['wp-parent-theme']['fields'] = array( 1159 'name' => array( 1160 'label' => __( 'Name' ), 1161 'value' => sprintf( 1162 /* translators: 1: Theme name. 2: Theme slug. */ 1163 __( '%1$s (%2$s)' ), 1164 $parent_theme->name, 1165 $parent_theme->stylesheet 1166 ), 1167 ), 1168 'version' => array( 1169 'label' => __( 'Version' ), 1170 'value' => $parent_theme_version, 1171 'debug' => $parent_theme_version_debug, 1172 ), 1173 'author' => array( 1174 'label' => __( 'Author' ), 1175 'value' => wp_kses( $parent_theme->author, array() ), 1176 ), 1177 'author_website' => array( 1178 'label' => __( 'Author website' ), 1179 'value' => ( $parent_theme_author_uri ? $parent_theme_author_uri : __( 'Undefined' ) ), 1180 'debug' => ( $parent_theme_author_uri ? $parent_theme_author_uri : '(undefined)' ), 1181 ), 1182 'theme_path' => array( 1183 'label' => __( 'Theme directory location' ), 1184 'value' => get_template_directory(), 1185 ), 1186 ); 1187 1188 if ( $auto_updates_enabled ) { 1189 if ( isset( $transient->response[ $parent_theme->stylesheet ] ) ) { 1190 $item = $transient->response[ $parent_theme->stylesheet ]; 1191 } elseif ( isset( $transient->no_update[ $parent_theme->stylesheet ] ) ) { 1192 $item = $transient->no_update[ $parent_theme->stylesheet ]; 1193 } else { 1194 $item = (object) array( 1195 'theme' => $parent_theme->stylesheet, 1196 'new_version' => $parent_theme->version, 1197 'url' => '', 1198 'package' => '', 1199 'requires' => '', 1200 'requires_php' => '', 1201 ); 1202 } 1203 1204 /** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */ 1205 $auto_update_forced = apply_filters( 'auto_update_theme', null, $item ); 1206 1207 if ( ! is_null( $auto_update_forced ) ) { 1208 $enabled = $auto_update_forced; 1209 } else { 1210 $enabled = in_array( $parent_theme->stylesheet, $auto_updates, true ); 1211 } 1212 1213 if ( $enabled ) { 1214 $parent_theme_auto_update_string = __( 'Enabled' ); 1215 } else { 1216 $parent_theme_auto_update_string = __( 'Disabled' ); 1217 } 1218 1219 /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */ 1220 $parent_theme_auto_update_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $parent_theme, $enabled ); 1221 1222 $info['wp-parent-theme']['fields']['auto_update'] = array( 1223 'label' => __( 'Auto-update' ), 1224 'value' => $parent_theme_auto_update_string, 1225 'debug' => $parent_theme_auto_update_string, 1226 ); 1227 } 1228 } 1229 1230 // Populate a list of all themes available in the install. 1231 $all_themes = wp_get_themes(); 1232 1233 foreach ( $all_themes as $theme_slug => $theme ) { 1234 // Exclude the currently active theme from the list of all themes. 1235 if ( $active_theme->stylesheet === $theme_slug ) { 1236 continue; 1237 } 1238 1239 // Exclude the currently active parent theme from the list of all themes. 1240 if ( ! empty( $parent_theme ) && $parent_theme->stylesheet === $theme_slug ) { 1241 continue; 1242 } 1243 1244 $theme_version = $theme->version; 1245 $theme_author = $theme->author; 1246 1247 // Sanitize. 1248 $theme_author = wp_kses( $theme_author, array() ); 1249 1250 $theme_version_string = __( 'No version or author information is available.' ); 1251 $theme_version_string_debug = 'undefined'; 1252 1253 if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) { 1254 /* translators: 1: Theme version number. 2: Theme author name. */ 1255 $theme_version_string = sprintf( __( 'Version %1$s by %2$s' ), $theme_version, $theme_author ); 1256 $theme_version_string_debug = sprintf( 'version: %s, author: %s', $theme_version, $theme_author ); 1257 } else { 1258 if ( ! empty( $theme_author ) ) { 1259 /* translators: %s: Theme author name. */ 1260 $theme_version_string = sprintf( __( 'By %s' ), $theme_author ); 1261 $theme_version_string_debug = sprintf( 'author: %s, version: (undefined)', $theme_author ); 1262 } 1263 1264 if ( ! empty( $theme_version ) ) { 1265 /* translators: %s: Theme version number. */ 1266 $theme_version_string = sprintf( __( 'Version %s' ), $theme_version ); 1267 $theme_version_string_debug = sprintf( 'author: (undefined), version: %s', $theme_version ); 1268 } 1269 } 1270 1271 if ( array_key_exists( $theme_slug, $theme_updates ) ) { 1272 /* translators: %s: Latest theme version number. */ 1273 $theme_version_string .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_updates[ $theme_slug ]->update['new_version'] ); 1274 $theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] ); 1275 } 1276 1277 if ( $auto_updates_enabled ) { 1278 if ( isset( $transient->response[ $theme_slug ] ) ) { 1279 $item = $transient->response[ $theme_slug ]; 1280 } elseif ( isset( $transient->no_update[ $theme_slug ] ) ) { 1281 $item = $transient->no_update[ $theme_slug ]; 1282 } else { 1283 $item = (object) array( 1284 'theme' => $theme_slug, 1285 'new_version' => $theme->version, 1286 'url' => '', 1287 'package' => '', 1288 'requires' => '', 1289 'requires_php' => '', 1290 ); 1291 } 1292 1293 /** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */ 1294 $auto_update_forced = apply_filters( 'auto_update_theme', null, $item ); 1295 1296 if ( ! is_null( $auto_update_forced ) ) { 1297 $enabled = $auto_update_forced; 1298 } else { 1299 $enabled = in_array( $theme_slug, $auto_updates, true ); 1300 } 1301 1302 if ( $enabled ) { 1303 $auto_updates_string = __( 'Auto-updates enabled' ); 1304 } else { 1305 $auto_updates_string = __( 'Auto-updates disabled' ); 1306 } 1076 1307 1077 1308 /** … … 1084 1315 * @param bool $enabled Whether auto-updates are enabled for this item. 1085 1316 */ 1086 $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $active_theme, $enabled ); 1087 } else { 1088 $auto_updates_string = __( 'Disabled' ); 1089 $enabled = false; 1090 1091 /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */ 1092 $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $active_theme, $enabled ); 1093 } 1094 1095 $info['wp-active-theme']['fields']['auto_update'] = array( 1096 'label' => __( 'Auto-updates' ), 1097 'value' => $auto_updates_string, 1098 'debug' => $auto_updates_string, 1099 ); 1100 } 1101 1102 $parent_theme = $active_theme->parent(); 1103 1104 if ( $parent_theme ) { 1105 $parent_theme_version = $parent_theme->version; 1106 $parent_theme_version_debug = $parent_theme_version; 1107 1108 if ( array_key_exists( $parent_theme->stylesheet, $theme_updates ) ) { 1109 $parent_theme_update_new_version = $theme_updates[ $parent_theme->stylesheet ]->update['new_version']; 1110 1111 /* translators: %s: Latest theme version number. */ 1112 $parent_theme_version .= ' ' . sprintf( __( '(Latest version: %s)' ), $parent_theme_update_new_version ); 1113 $parent_theme_version_debug .= sprintf( ' (latest version: %s)', $parent_theme_update_new_version ); 1114 } 1115 1116 $parent_theme_author_uri = $parent_theme->display( 'AuthorURI' ); 1117 1118 $info['wp-parent-theme']['fields'] = array( 1119 'name' => array( 1120 'label' => __( 'Name' ), 1121 'value' => sprintf( 1122 /* translators: 1: Theme name. 2: Theme slug. */ 1123 __( '%1$s (%2$s)' ), 1124 $parent_theme->name, 1125 $parent_theme->stylesheet 1126 ), 1127 ), 1128 'version' => array( 1129 'label' => __( 'Version' ), 1130 'value' => $parent_theme_version, 1131 'debug' => $parent_theme_version_debug, 1132 ), 1133 'author' => array( 1134 'label' => __( 'Author' ), 1135 'value' => wp_kses( $parent_theme->author, array() ), 1136 ), 1137 'author_website' => array( 1138 'label' => __( 'Author website' ), 1139 'value' => ( $parent_theme_author_uri ? $parent_theme_author_uri : __( 'Undefined' ) ), 1140 'debug' => ( $parent_theme_author_uri ? $parent_theme_author_uri : '(undefined)' ), 1141 ), 1142 'theme_path' => array( 1143 'label' => __( 'Theme directory location' ), 1144 'value' => get_template_directory(), 1145 ), 1146 ); 1147 if ( $auto_updates_enabled ) { 1148 if ( in_array( $parent_theme->stylesheet, $auto_updates, true ) ) { 1149 $parent_theme_auto_update_string = __( 'Enabled' ); 1150 } else { 1151 $parent_theme_auto_update_string = __( 'Disabled' ); 1152 } 1153 1154 $info['wp-parent-theme']['fields']['auto_update'] = array( 1155 'label' => __( 'Auto-update' ), 1156 'value' => $parent_theme_auto_update_string, 1157 'debug' => $parent_theme_auto_update_string, 1158 ); 1159 } 1160 } 1161 1162 // Populate a list of all themes available in the install. 1163 $all_themes = wp_get_themes(); 1164 1165 foreach ( $all_themes as $theme_slug => $theme ) { 1166 // Exclude the currently active theme from the list of all themes. 1167 if ( $active_theme->stylesheet === $theme_slug ) { 1168 continue; 1169 } 1170 1171 // Exclude the currently active parent theme from the list of all themes. 1172 if ( ! empty( $parent_theme ) && $parent_theme->stylesheet === $theme_slug ) { 1173 continue; 1174 } 1175 1176 $theme_version = $theme->version; 1177 $theme_author = $theme->author; 1178 1179 // Sanitize. 1180 $theme_author = wp_kses( $theme_author, array() ); 1181 1182 $theme_version_string = __( 'No version or author information is available.' ); 1183 $theme_version_string_debug = 'undefined'; 1184 1185 if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) { 1186 /* translators: 1: Theme version number. 2: Theme author name. */ 1187 $theme_version_string = sprintf( __( 'Version %1$s by %2$s' ), $theme_version, $theme_author ); 1188 $theme_version_string_debug = sprintf( 'version: %s, author: %s', $theme_version, $theme_author ); 1189 } else { 1190 if ( ! empty( $theme_author ) ) { 1191 /* translators: %s: Theme author name. */ 1192 $theme_version_string = sprintf( __( 'By %s' ), $theme_author ); 1193 $theme_version_string_debug = sprintf( 'author: %s, version: (undefined)', $theme_author ); 1194 } 1195 1196 if ( ! empty( $theme_version ) ) { 1197 /* translators: %s: Theme version number. */ 1198 $theme_version_string = sprintf( __( 'Version %s' ), $theme_version ); 1199 $theme_version_string_debug = sprintf( 'author: (undefined), version: %s', $theme_version ); 1200 } 1201 } 1202 1203 if ( array_key_exists( $theme_slug, $theme_updates ) ) { 1204 /* translators: %s: Latest theme version number. */ 1205 $theme_version_string .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_updates[ $theme_slug ]->update['new_version'] ); 1206 $theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] ); 1207 } 1208 1209 if ( $auto_updates_enabled ) { 1210 if ( in_array( $theme_slug, $auto_updates, true ) ) { 1211 $auto_updates_string = __( 'Auto-updates enabled' ); 1212 $enabled = true; 1213 1214 /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */ 1215 $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled ); 1216 } else { 1217 $auto_updates_string = __( 'Auto-updates disabled' ); 1218 $enabled = false; 1219 1220 /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */ 1221 $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled ); 1222 } 1317 $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled ); 1223 1318 1224 1319 $theme_version_string .= ' | ' . $auto_updates_string;
Note: See TracChangeset
for help on using the changeset viewer.