@@ -82,8 +82,8 @@ public static function debug_data() {
8282 'wp-parent-theme ' => array (),
8383 'wp-themes-inactive ' => array (),
8484 'wp-mu-plugins ' => self ::get_wp_mu_plugins (),
85- 'wp-plugins-active ' => array (),
86- 'wp-plugins-inactive ' => array (),
85+ 'wp-plugins-active ' => self :: get_wp_plugins_active (),
86+ 'wp-plugins-inactive ' => self :: get_wp_plugins_inactive (),
8787 'wp-media ' => self ::get_wp_media (),
8888 'wp-server ' => self ::get_wp_server (),
8989 'wp-database ' => self ::get_wp_database (),
@@ -188,18 +188,6 @@ public static function debug_data() {
188188 'fields ' => array (),
189189 );
190190
191- $ info ['wp-plugins-active ' ] = array (
192- 'label ' => __ ( 'Active Plugins ' ),
193- 'show_count ' => true ,
194- 'fields ' => array (),
195- );
196-
197- $ info ['wp-plugins-inactive ' ] = array (
198- 'label ' => __ ( 'Inactive Plugins ' ),
199- 'show_count ' => true ,
200- 'fields ' => array (),
201- );
202-
203191 // Conditionally add debug information for multisite setups.
204192 if ( is_multisite () ) {
205193 $ site_id = get_current_blog_id ();
@@ -325,112 +313,6 @@ public static function debug_data() {
325313 );
326314 }
327315
328- // List all available plugins.
329- $ plugins = get_plugins ();
330- $ plugin_updates = get_plugin_updates ();
331- $ transient = get_site_transient ( 'update_plugins ' );
332-
333- $ auto_updates = array ();
334-
335- $ auto_updates_enabled = wp_is_auto_update_enabled_for_type ( 'plugin ' );
336-
337- if ( $ auto_updates_enabled ) {
338- $ auto_updates = (array ) get_site_option ( 'auto_update_plugins ' , array () );
339- }
340-
341- foreach ( $ plugins as $ plugin_path => $ plugin ) {
342- $ plugin_part = ( is_plugin_active ( $ plugin_path ) ) ? 'wp-plugins-active ' : 'wp-plugins-inactive ' ;
343-
344- $ plugin_version = $ plugin ['Version ' ];
345- $ plugin_author = $ plugin ['Author ' ];
346-
347- $ plugin_version_string = __ ( 'No version or author information is available. ' );
348- $ plugin_version_string_debug = 'author: (undefined), version: (undefined) ' ;
349-
350- if ( ! empty ( $ plugin_version ) && ! empty ( $ plugin_author ) ) {
351- /* translators: 1: Plugin version number. 2: Plugin author name. */
352- $ plugin_version_string = sprintf ( __ ( 'Version %1$s by %2$s ' ), $ plugin_version , $ plugin_author );
353- $ plugin_version_string_debug = sprintf ( 'version: %s, author: %s ' , $ plugin_version , $ plugin_author );
354- } else {
355- if ( ! empty ( $ plugin_author ) ) {
356- /* translators: %s: Plugin author name. */
357- $ plugin_version_string = sprintf ( __ ( 'By %s ' ), $ plugin_author );
358- $ plugin_version_string_debug = sprintf ( 'author: %s, version: (undefined) ' , $ plugin_author );
359- }
360-
361- if ( ! empty ( $ plugin_version ) ) {
362- /* translators: %s: Plugin version number. */
363- $ plugin_version_string = sprintf ( __ ( 'Version %s ' ), $ plugin_version );
364- $ plugin_version_string_debug = sprintf ( 'author: (undefined), version: %s ' , $ plugin_version );
365- }
366- }
367-
368- if ( array_key_exists ( $ plugin_path , $ plugin_updates ) ) {
369- /* translators: %s: Latest plugin version number. */
370- $ plugin_version_string .= ' ' . sprintf ( __ ( '(Latest version: %s) ' ), $ plugin_updates [ $ plugin_path ]->update ->new_version );
371- $ plugin_version_string_debug .= sprintf ( ' (latest version: %s) ' , $ plugin_updates [ $ plugin_path ]->update ->new_version );
372- }
373-
374- if ( $ auto_updates_enabled ) {
375- if ( isset ( $ transient ->response [ $ plugin_path ] ) ) {
376- $ item = $ transient ->response [ $ plugin_path ];
377- } elseif ( isset ( $ transient ->no_update [ $ plugin_path ] ) ) {
378- $ item = $ transient ->no_update [ $ plugin_path ];
379- } else {
380- $ item = array (
381- 'id ' => $ plugin_path ,
382- 'slug ' => '' ,
383- 'plugin ' => $ plugin_path ,
384- 'new_version ' => '' ,
385- 'url ' => '' ,
386- 'package ' => '' ,
387- 'icons ' => array (),
388- 'banners ' => array (),
389- 'banners_rtl ' => array (),
390- 'tested ' => '' ,
391- 'requires_php ' => '' ,
392- 'compatibility ' => new stdClass (),
393- );
394- $ item = wp_parse_args ( $ plugin , $ item );
395- }
396-
397- $ auto_update_forced = wp_is_auto_update_forced_for_item ( 'plugin ' , null , (object ) $ item );
398-
399- if ( ! is_null ( $ auto_update_forced ) ) {
400- $ enabled = $ auto_update_forced ;
401- } else {
402- $ enabled = in_array ( $ plugin_path , $ auto_updates , true );
403- }
404-
405- if ( $ enabled ) {
406- $ auto_updates_string = __ ( 'Auto-updates enabled ' );
407- } else {
408- $ auto_updates_string = __ ( 'Auto-updates disabled ' );
409- }
410-
411- /**
412- * Filters the text string of the auto-updates setting for each plugin in the Site Health debug data.
413- *
414- * @since 5.5.0
415- *
416- * @param string $auto_updates_string The string output for the auto-updates column.
417- * @param string $plugin_path The path to the plugin file.
418- * @param array $plugin An array of plugin data.
419- * @param bool $enabled Whether auto-updates are enabled for this item.
420- */
421- $ auto_updates_string = apply_filters ( 'plugin_auto_update_debug_string ' , $ auto_updates_string , $ plugin_path , $ plugin , $ enabled );
422-
423- $ plugin_version_string .= ' | ' . $ auto_updates_string ;
424- $ plugin_version_string_debug .= ', ' . $ auto_updates_string ;
425- }
426-
427- $ info [ $ plugin_part ]['fields ' ][ sanitize_text_field ( $ plugin ['Name ' ] ) ] = array (
428- 'label ' => $ plugin ['Name ' ],
429- 'value ' => $ plugin_version_string ,
430- 'debug ' => $ plugin_version_string_debug ,
431- );
432- }
433-
434316 // Populate the section for the currently active theme.
435317 $ theme_features = array ();
436318
@@ -1288,6 +1170,157 @@ private static function get_wp_mu_plugins(): array {
12881170 );
12891171 }
12901172
1173+ /**
1174+ * Gets the WordPress active plugins section of the debug data.
1175+ *
1176+ * @since 6.7.0
1177+ *
1178+ * @return array
1179+ */
1180+ private static function get_wp_plugins_active (): array {
1181+ return array (
1182+ 'label ' => __ ( 'Active Plugins ' ),
1183+ 'show_count ' => true ,
1184+ 'fields ' => self ::get_wp_plugins_raw_data ()['wp-plugins-active ' ],
1185+ );
1186+ }
1187+
1188+ /**
1189+ * Gets the WordPress inactive plugins section of the debug data.
1190+ *
1191+ * @since 6.7.0
1192+ *
1193+ * @return array
1194+ */
1195+ private static function get_wp_plugins_inactive (): array {
1196+ return array (
1197+ 'label ' => __ ( 'Inactive Plugins ' ),
1198+ 'show_count ' => true ,
1199+ 'fields ' => self ::get_wp_plugins_raw_data ()['wp-plugins-inactive ' ],
1200+ );
1201+ }
1202+
1203+ /**
1204+ * Gets the raw plugin data for the WordPress active and inactive sections of the debug data.
1205+ *
1206+ * @since 6.7.0
1207+ *
1208+ * @return array
1209+ */
1210+ private static function get_wp_plugins_raw_data (): array {
1211+ // List all available plugins.
1212+ $ plugins = get_plugins ();
1213+ $ plugin_updates = get_plugin_updates ();
1214+ $ transient = get_site_transient ( 'update_plugins ' );
1215+
1216+ $ auto_updates = array ();
1217+ $ fields = array (
1218+ 'wp-plugins-active ' => array (),
1219+ 'wp-plugins-inactive ' => array (),
1220+ );
1221+
1222+ $ auto_updates_enabled = wp_is_auto_update_enabled_for_type ( 'plugin ' );
1223+
1224+ if ( $ auto_updates_enabled ) {
1225+ $ auto_updates = (array ) get_site_option ( 'auto_update_plugins ' , array () );
1226+ }
1227+
1228+ foreach ( $ plugins as $ plugin_path => $ plugin ) {
1229+ $ plugin_part = ( is_plugin_active ( $ plugin_path ) ) ? 'wp-plugins-active ' : 'wp-plugins-inactive ' ;
1230+
1231+ $ plugin_version = $ plugin ['Version ' ];
1232+ $ plugin_author = $ plugin ['Author ' ];
1233+
1234+ $ plugin_version_string = __ ( 'No version or author information is available. ' );
1235+ $ plugin_version_string_debug = 'author: (undefined), version: (undefined) ' ;
1236+
1237+ if ( ! empty ( $ plugin_version ) && ! empty ( $ plugin_author ) ) {
1238+ /* translators: 1: Plugin version number. 2: Plugin author name. */
1239+ $ plugin_version_string = sprintf ( __ ( 'Version %1$s by %2$s ' ), $ plugin_version , $ plugin_author );
1240+ $ plugin_version_string_debug = sprintf ( 'version: %s, author: %s ' , $ plugin_version , $ plugin_author );
1241+ } else {
1242+ if ( ! empty ( $ plugin_author ) ) {
1243+ /* translators: %s: Plugin author name. */
1244+ $ plugin_version_string = sprintf ( __ ( 'By %s ' ), $ plugin_author );
1245+ $ plugin_version_string_debug = sprintf ( 'author: %s, version: (undefined) ' , $ plugin_author );
1246+ }
1247+
1248+ if ( ! empty ( $ plugin_version ) ) {
1249+ /* translators: %s: Plugin version number. */
1250+ $ plugin_version_string = sprintf ( __ ( 'Version %s ' ), $ plugin_version );
1251+ $ plugin_version_string_debug = sprintf ( 'author: (undefined), version: %s ' , $ plugin_version );
1252+ }
1253+ }
1254+
1255+ if ( array_key_exists ( $ plugin_path , $ plugin_updates ) ) {
1256+ /* translators: %s: Latest plugin version number. */
1257+ $ plugin_version_string .= ' ' . sprintf ( __ ( '(Latest version: %s) ' ), $ plugin_updates [ $ plugin_path ]->update ->new_version );
1258+ $ plugin_version_string_debug .= sprintf ( ' (latest version: %s) ' , $ plugin_updates [ $ plugin_path ]->update ->new_version );
1259+ }
1260+
1261+ if ( $ auto_updates_enabled ) {
1262+ if ( isset ( $ transient ->response [ $ plugin_path ] ) ) {
1263+ $ item = $ transient ->response [ $ plugin_path ];
1264+ } elseif ( isset ( $ transient ->no_update [ $ plugin_path ] ) ) {
1265+ $ item = $ transient ->no_update [ $ plugin_path ];
1266+ } else {
1267+ $ item = array (
1268+ 'id ' => $ plugin_path ,
1269+ 'slug ' => '' ,
1270+ 'plugin ' => $ plugin_path ,
1271+ 'new_version ' => '' ,
1272+ 'url ' => '' ,
1273+ 'package ' => '' ,
1274+ 'icons ' => array (),
1275+ 'banners ' => array (),
1276+ 'banners_rtl ' => array (),
1277+ 'tested ' => '' ,
1278+ 'requires_php ' => '' ,
1279+ 'compatibility ' => new stdClass (),
1280+ );
1281+ $ item = wp_parse_args ( $ plugin , $ item );
1282+ }
1283+
1284+ $ auto_update_forced = wp_is_auto_update_forced_for_item ( 'plugin ' , null , (object ) $ item );
1285+
1286+ if ( ! is_null ( $ auto_update_forced ) ) {
1287+ $ enabled = $ auto_update_forced ;
1288+ } else {
1289+ $ enabled = in_array ( $ plugin_path , $ auto_updates , true );
1290+ }
1291+
1292+ if ( $ enabled ) {
1293+ $ auto_updates_string = __ ( 'Auto-updates enabled ' );
1294+ } else {
1295+ $ auto_updates_string = __ ( 'Auto-updates disabled ' );
1296+ }
1297+
1298+ /**
1299+ * Filters the text string of the auto-updates setting for each plugin in the Site Health debug data.
1300+ *
1301+ * @since 5.5.0
1302+ *
1303+ * @param string $auto_updates_string The string output for the auto-updates column.
1304+ * @param string $plugin_path The path to the plugin file.
1305+ * @param array $plugin An array of plugin data.
1306+ * @param bool $enabled Whether auto-updates are enabled for this item.
1307+ */
1308+ $ auto_updates_string = apply_filters ( 'plugin_auto_update_debug_string ' , $ auto_updates_string , $ plugin_path , $ plugin , $ enabled );
1309+
1310+ $ plugin_version_string .= ' | ' . $ auto_updates_string ;
1311+ $ plugin_version_string_debug .= ', ' . $ auto_updates_string ;
1312+ }
1313+
1314+ $ fields [ $ plugin_part ][ sanitize_text_field ( $ plugin ['Name ' ] ) ] = array (
1315+ 'label ' => $ plugin ['Name ' ],
1316+ 'value ' => $ plugin_version_string ,
1317+ 'debug ' => $ plugin_version_string_debug ,
1318+ );
1319+ }
1320+
1321+ return $ fields ;
1322+ }
1323+
12911324 /**
12921325 * Gets the WordPress constants section of the debug data.
12931326 *
0 commit comments