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. Built from https://develop.svn.wordpress.org/trunk@59011 git-svn-id: http://core.svn.wordpress.org/trunk@58407 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3c03500cea
commit
ee69ec404e
|
@ -81,7 +81,7 @@ class WP_Debug_Data {
|
|||
'wp-active-theme' => array(),
|
||||
'wp-parent-theme' => array(),
|
||||
'wp-themes-inactive' => array(),
|
||||
'wp-mu-plugins' => array(),
|
||||
'wp-mu-plugins' => self::get_wp_mu_plugins(),
|
||||
'wp-plugins-active' => array(),
|
||||
'wp-plugins-inactive' => array(),
|
||||
'wp-media' => array(),
|
||||
|
@ -199,12 +199,6 @@ class WP_Debug_Data {
|
|||
'fields' => array(),
|
||||
);
|
||||
|
||||
$info['wp-mu-plugins'] = array(
|
||||
'label' => __( 'Must Use Plugins' ),
|
||||
'show_count' => true,
|
||||
'fields' => array(),
|
||||
);
|
||||
|
||||
$info['wp-plugins-active'] = array(
|
||||
'label' => __( 'Active Plugins' ),
|
||||
'show_count' => true,
|
||||
|
@ -540,41 +534,6 @@ class WP_Debug_Data {
|
|||
'debug' => $gs_debug,
|
||||
);
|
||||
|
||||
// List must use plugins if there are any.
|
||||
$mu_plugins = get_mu_plugins();
|
||||
|
||||
foreach ( $mu_plugins as $plugin_path => $plugin ) {
|
||||
$plugin_version = $plugin['Version'];
|
||||
$plugin_author = $plugin['Author'];
|
||||
|
||||
$plugin_version_string = __( 'No version or author information is available.' );
|
||||
$plugin_version_string_debug = 'author: (undefined), version: (undefined)';
|
||||
|
||||
if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
|
||||
/* translators: 1: Plugin version number. 2: Plugin author name. */
|
||||
$plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
|
||||
$plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
|
||||
} else {
|
||||
if ( ! empty( $plugin_author ) ) {
|
||||
/* translators: %s: Plugin author name. */
|
||||
$plugin_version_string = sprintf( __( 'By %s' ), $plugin_author );
|
||||
$plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
|
||||
}
|
||||
|
||||
if ( ! empty( $plugin_version ) ) {
|
||||
/* translators: %s: Plugin version number. */
|
||||
$plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version );
|
||||
$plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
|
||||
}
|
||||
}
|
||||
|
||||
$info['wp-mu-plugins']['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
|
||||
'label' => $plugin['Name'],
|
||||
'value' => $plugin_version_string,
|
||||
'debug' => $plugin_version_string_debug,
|
||||
);
|
||||
}
|
||||
|
||||
// List all available plugins.
|
||||
$plugins = get_plugins();
|
||||
$plugin_updates = get_plugin_updates();
|
||||
|
@ -1257,6 +1216,57 @@ class WP_Debug_Data {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the WordPress plugins section of the debug data.
|
||||
*
|
||||
* @since 6.7.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_wp_mu_plugins(): array {
|
||||
// List must use plugins if there are any.
|
||||
$mu_plugins = get_mu_plugins();
|
||||
$fields = array();
|
||||
|
||||
foreach ( $mu_plugins as $plugin_path => $plugin ) {
|
||||
$plugin_version = $plugin['Version'];
|
||||
$plugin_author = $plugin['Author'];
|
||||
|
||||
$plugin_version_string = __( 'No version or author information is available.' );
|
||||
$plugin_version_string_debug = 'author: (undefined), version: (undefined)';
|
||||
|
||||
if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
|
||||
/* translators: 1: Plugin version number. 2: Plugin author name. */
|
||||
$plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
|
||||
$plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
|
||||
} else {
|
||||
if ( ! empty( $plugin_author ) ) {
|
||||
/* translators: %s: Plugin author name. */
|
||||
$plugin_version_string = sprintf( __( 'By %s' ), $plugin_author );
|
||||
$plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
|
||||
}
|
||||
|
||||
if ( ! empty( $plugin_version ) ) {
|
||||
/* translators: %s: Plugin version number. */
|
||||
$plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version );
|
||||
$plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
|
||||
}
|
||||
}
|
||||
|
||||
$fields[ sanitize_text_field( $plugin['Name'] ) ] = array(
|
||||
'label' => $plugin['Name'],
|
||||
'value' => $plugin_version_string,
|
||||
'debug' => $plugin_version_string_debug,
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'label' => __( 'Must Use Plugins' ),
|
||||
'show_count' => true,
|
||||
'fields' => $fields,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the WordPress constants section of the debug data.
|
||||
*
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.7-alpha-59010';
|
||||
$wp_version = '6.7-alpha-59011';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue