From c73731e74e67001cc89bfc33ad7a136b3d82cca5 Mon Sep 17 00:00:00 2001 From: dmsnell Date: Fri, 27 Sep 2024 05:58:18 +0000 Subject: [PATCH] WP_Debug_Data: Extract `wp-dropins` data into separate method. 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 https://github.com/wordpress/wordpress-develop/pull/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 --- wp-admin/includes/class-wp-debug-data.php | 62 +++++++++++++---------- wp-includes/version.php | 2 +- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/wp-admin/includes/class-wp-debug-data.php b/wp-admin/includes/class-wp-debug-data.php index bf3212eebc..496a6da34a 100644 --- a/wp-admin/includes/class-wp-debug-data.php +++ b/wp-admin/includes/class-wp-debug-data.php @@ -77,7 +77,7 @@ class WP_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(), @@ -172,17 +172,6 @@ class WP_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.' ), - '' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '' - ), - 'fields' => array(), - ); - $info['wp-active-theme'] = array( 'label' => __( 'Active Theme' ), 'fields' => array(), @@ -336,20 +325,6 @@ class WP_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(); @@ -840,6 +815,41 @@ class WP_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.' ), + '' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '' + ), + 'fields' => $fields, + ); + } + /** * Gets the WordPress server section of the debug data. * diff --git a/wp-includes/version.php b/wp-includes/version.php index e42218718a..9cdbe31c0e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.