Make WordPress Core


Ignore:
Timestamp:
09/27/2024 05:56:50 AM (4 months ago)
Author:
dmsnell
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-debug-data.php

    r59060 r59100  
    7878            'wp-core'             => array(),
    7979            'wp-paths-sizes'      => array(),
    80             'wp-dropins'          => array(),
     80            'wp-dropins'          => self::get_wp_dropins(),
    8181            'wp-active-theme'     => array(),
    8282            'wp-parent-theme'     => array(),
     
    173173        }
    174174
    175         $info['wp-dropins'] = array(
    176             'label'       => __( 'Drop-ins' ),
    177             'show_count'  => true,
    178             'description' => sprintf(
    179                 /* translators: %s: wp-content directory name. */
    180                 __( '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.' ),
    181                 '<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>'
    182             ),
    183             'fields'      => array(),
    184         );
    185 
    186175        $info['wp-active-theme'] = array(
    187176            'label'  => __( 'Active Theme' ),
     
    334323                    'debug' => 'loading...',
    335324                ),
    336             );
    337         }
    338 
    339         // Get a list of all drop-in replacements.
    340         $dropins = get_dropins();
    341 
    342         // Get dropins descriptions.
    343         $dropin_descriptions = _get_dropins();
    344 
    345         foreach ( $dropins as $dropin_key => $dropin ) {
    346             $info['wp-dropins']['fields'][ sanitize_text_field( $dropin_key ) ] = array(
    347                 'label' => $dropin_key,
    348                 'value' => $dropin_descriptions[ $dropin_key ][0],
    349                 'debug' => 'true',
    350325            );
    351326        }
     
    842817
    843818    /**
     819     * Gets the WordPress drop-in section of the debug data.
     820     *
     821     * @since 6.7.0
     822     *
     823     * @return array
     824     */
     825    public static function get_wp_dropins(): array {
     826        // Get a list of all drop-in replacements.
     827        $dropins = get_dropins();
     828
     829        // Get drop-ins descriptions.
     830        $dropin_descriptions = _get_dropins();
     831
     832        $fields = array();
     833        foreach ( $dropins as $dropin_key => $dropin ) {
     834            $fields[ sanitize_text_field( $dropin_key ) ] = array(
     835                'label' => $dropin_key,
     836                'value' => $dropin_descriptions[ $dropin_key ][0],
     837                'debug' => 'true',
     838            );
     839        }
     840
     841        return array(
     842            'label'       => __( 'Drop-ins' ),
     843            'show_count'  => true,
     844            'description' => sprintf(
     845            /* translators: %s: wp-content directory name. */
     846                __( '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.' ),
     847                '<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>'
     848            ),
     849            'fields'      => $fields,
     850        );
     851    }
     852
     853    /**
    844854     * Gets the WordPress server section of the debug data.
    845855     *
Note: See TracChangeset for help on using the changeset viewer.