Skip to content

Commit 38243be

Browse files
committed
WP_Debug_Data: Extract wp-mu-plugins data into separate method.
This is the part five in a larger modularization of the data in `WP_Debug_Data`. Previously this was a single massive method drawing in debug data from various groups of related data, where the groups were independent from each other. This patch separates the fifth of twelve groups, the `wp-mu-plugins` info, into a separate method focused on that data. This work precedes changes to make the `WP_Debug_Data` class more extensible for better use by plugin and theme code. Developed in https://github.com/wordpress/wordpress-develop/7305 Discussed in https://core.trac.wordpress.org/ticket/61648 Props apermo, dmsnell. See #61648. git-svn-id: https://develop.svn.wordpress.org/trunk@59011 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 55352ab commit 38243be

File tree

1 file changed

+52
-42
lines changed

1 file changed

+52
-42
lines changed

src/wp-admin/includes/class-wp-debug-data.php

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static function debug_data() {
8181
'wp-active-theme' => array(),
8282
'wp-parent-theme' => array(),
8383
'wp-themes-inactive' => array(),
84-
'wp-mu-plugins' => array(),
84+
'wp-mu-plugins' => self::get_wp_mu_plugins(),
8585
'wp-plugins-active' => array(),
8686
'wp-plugins-inactive' => array(),
8787
'wp-media' => array(),
@@ -199,12 +199,6 @@ public static function debug_data() {
199199
'fields' => array(),
200200
);
201201

202-
$info['wp-mu-plugins'] = array(
203-
'label' => __( 'Must Use Plugins' ),
204-
'show_count' => true,
205-
'fields' => array(),
206-
);
207-
208202
$info['wp-plugins-active'] = array(
209203
'label' => __( 'Active Plugins' ),
210204
'show_count' => true,
@@ -540,41 +534,6 @@ public static function debug_data() {
540534
'debug' => $gs_debug,
541535
);
542536

543-
// List must use plugins if there are any.
544-
$mu_plugins = get_mu_plugins();
545-
546-
foreach ( $mu_plugins as $plugin_path => $plugin ) {
547-
$plugin_version = $plugin['Version'];
548-
$plugin_author = $plugin['Author'];
549-
550-
$plugin_version_string = __( 'No version or author information is available.' );
551-
$plugin_version_string_debug = 'author: (undefined), version: (undefined)';
552-
553-
if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
554-
/* translators: 1: Plugin version number. 2: Plugin author name. */
555-
$plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
556-
$plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
557-
} else {
558-
if ( ! empty( $plugin_author ) ) {
559-
/* translators: %s: Plugin author name. */
560-
$plugin_version_string = sprintf( __( 'By %s' ), $plugin_author );
561-
$plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
562-
}
563-
564-
if ( ! empty( $plugin_version ) ) {
565-
/* translators: %s: Plugin version number. */
566-
$plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version );
567-
$plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
568-
}
569-
}
570-
571-
$info['wp-mu-plugins']['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
572-
'label' => $plugin['Name'],
573-
'value' => $plugin_version_string,
574-
'debug' => $plugin_version_string_debug,
575-
);
576-
}
577-
578537
// List all available plugins.
579538
$plugins = get_plugins();
580539
$plugin_updates = get_plugin_updates();
@@ -1257,6 +1216,57 @@ public static function get_wp_server(): array {
12571216
);
12581217
}
12591218

1219+
/**
1220+
* Gets the WordPress plugins section of the debug data.
1221+
*
1222+
* @since 6.7.0
1223+
*
1224+
* @return array
1225+
*/
1226+
public static function get_wp_mu_plugins(): array {
1227+
// List must use plugins if there are any.
1228+
$mu_plugins = get_mu_plugins();
1229+
$fields = array();
1230+
1231+
foreach ( $mu_plugins as $plugin_path => $plugin ) {
1232+
$plugin_version = $plugin['Version'];
1233+
$plugin_author = $plugin['Author'];
1234+
1235+
$plugin_version_string = __( 'No version or author information is available.' );
1236+
$plugin_version_string_debug = 'author: (undefined), version: (undefined)';
1237+
1238+
if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
1239+
/* translators: 1: Plugin version number. 2: Plugin author name. */
1240+
$plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
1241+
$plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
1242+
} else {
1243+
if ( ! empty( $plugin_author ) ) {
1244+
/* translators: %s: Plugin author name. */
1245+
$plugin_version_string = sprintf( __( 'By %s' ), $plugin_author );
1246+
$plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
1247+
}
1248+
1249+
if ( ! empty( $plugin_version ) ) {
1250+
/* translators: %s: Plugin version number. */
1251+
$plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version );
1252+
$plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
1253+
}
1254+
}
1255+
1256+
$fields[ sanitize_text_field( $plugin['Name'] ) ] = array(
1257+
'label' => $plugin['Name'],
1258+
'value' => $plugin_version_string,
1259+
'debug' => $plugin_version_string_debug,
1260+
);
1261+
}
1262+
1263+
return array(
1264+
'label' => __( 'Must Use Plugins' ),
1265+
'show_count' => true,
1266+
'fields' => $fields,
1267+
);
1268+
}
1269+
12601270
/**
12611271
* Gets the WordPress constants section of the debug data.
12621272
*

0 commit comments

Comments
 (0)