Skip to content

Commit

Permalink
WP_Debug_Data: Extract wp-dropins data into separate method.
Browse files Browse the repository at this point in the history
This is the seventh part 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 seventh of twelve groups, the `wp-dropins` 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 WordPress/wordpress-develop#7418
Discussed in https://core.trac.wordpress.org/ticket/61648

Props apermo.
See #61648.

Built from https://develop.svn.wordpress.org/trunk@59100


git-svn-id: http://core.svn.wordpress.org/trunk@58496 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
dmsnell committed Sep 27, 2024
1 parent ed65417 commit c73731e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 27 deletions.
62 changes: 36 additions & 26 deletions wp-admin/includes/class-wp-debug-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static function debug_data() {
$info = array(
'wp-core' => array(),
'wp-paths-sizes' => array(),
'wp-dropins' => array(),
'wp-dropins' => self::get_wp_dropins(),
'wp-active-theme' => array(),
'wp-parent-theme' => array(),
'wp-themes-inactive' => array(),
Expand Down Expand Up @@ -172,17 +172,6 @@ public static function debug_data() {
);
}

$info['wp-dropins'] = array(
'label' => __( 'Drop-ins' ),
'show_count' => true,
'description' => sprintf(
/* translators: %s: wp-content directory name. */
__( 'Drop-ins are single files, found in the %s directory, that replace or enhance WordPress features in ways that are not possible for traditional plugins.' ),
'<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>'
),
'fields' => array(),
);

$info['wp-active-theme'] = array(
'label' => __( 'Active Theme' ),
'fields' => array(),
Expand Down Expand Up @@ -336,20 +325,6 @@ public static function debug_data() {
);
}

// Get a list of all drop-in replacements.
$dropins = get_dropins();

// Get dropins descriptions.
$dropin_descriptions = _get_dropins();

foreach ( $dropins as $dropin_key => $dropin ) {
$info['wp-dropins']['fields'][ sanitize_text_field( $dropin_key ) ] = array(
'label' => $dropin_key,
'value' => $dropin_descriptions[ $dropin_key ][0],
'debug' => 'true',
);
}

// List all available plugins.
$plugins = get_plugins();
$plugin_updates = get_plugin_updates();
Expand Down Expand Up @@ -840,6 +815,41 @@ public static function debug_data() {
return $info;
}

/**
* Gets the WordPress drop-in section of the debug data.
*
* @since 6.7.0
*
* @return array
*/
public static function get_wp_dropins(): array {
// Get a list of all drop-in replacements.
$dropins = get_dropins();

// Get drop-ins descriptions.
$dropin_descriptions = _get_dropins();

$fields = array();
foreach ( $dropins as $dropin_key => $dropin ) {
$fields[ sanitize_text_field( $dropin_key ) ] = array(
'label' => $dropin_key,
'value' => $dropin_descriptions[ $dropin_key ][0],
'debug' => 'true',
);
}

return array(
'label' => __( 'Drop-ins' ),
'show_count' => true,
'description' => sprintf(
/* translators: %s: wp-content directory name. */
__( 'Drop-ins are single files, found in the %s directory, that replace or enhance WordPress features in ways that are not possible for traditional plugins.' ),
'<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>'
),
'fields' => $fields,
);
}

/**
* Gets the WordPress server section of the debug data.
*
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-alpha-59099';
$wp_version = '6.7-alpha-59100';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit c73731e

Please sign in to comment.