Make WordPress Core

Changeset 45680


Ignore:
Timestamp:
07/26/2019 03:48:32 AM (7 years ago)
Author:
SergeyBiryukov
Message:

Site Health: Show parent theme in its own accordion on Site Health Info screen; rename "Other Themes" to "Inactive Themes".

Props garrett-eclipse, mukesh27, Clorith, xkon, msaggiorato.
Fixes #46925.

File:
1 edited

Legend:

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

    r45399 r45680  
    129129        );
    130130
    131         $info['wp-themes'] = array(
    132             'label'      => __( 'Other Themes' ),
     131        $info['wp-parent-theme'] = array(
     132            'label'  => __( 'Parent Theme' ),
     133            'fields' => array(),
     134        );
     135
     136        $info['wp-themes-inactive'] = array(
     137            'label'      => __( 'Inactive Themes' ),
    133138            'show_count' => true,
    134139            'fields'     => array(),
     
    874879        $active_theme_author_uri = $active_theme->offsetGet( 'Author URI' );
    875880
     881        if ( $active_theme->parent_theme ) {
     882            $active_theme_parent_theme = sprintf(
     883                // translators: 1: Theme name. 2: Theme slug.
     884                __( '%1$s (%2$s)' ),
     885                $active_theme->parent_theme,
     886                $active_theme->template
     887            );
     888            $active_theme_parent_theme_debug = sprintf(
     889                '%s (%s)',
     890                $active_theme->parent_theme,
     891                $active_theme->template
     892            );
     893        } else {
     894            $active_theme_parent_theme       = __( 'None' );
     895            $active_theme_parent_theme_debug = 'none';
     896        }
     897
    876898        $info['wp-active-theme']['fields'] = array(
    877899            'name'           => array(
    878900                'label' => __( 'Name' ),
    879901                // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
    880                 'value' => $active_theme->Name,
     902                'value' => sprintf(
     903                    // translators: 1: Theme name. 2: Theme slug.
     904                    __( '%1$s (%2$s)' ),
     905                    // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
     906                    $active_theme->Name,
     907                    $active_theme->stylesheet
     908                ),
    881909            ),
    882910            'version'        => array(
     
    897925            'parent_theme'   => array(
    898926                'label' => __( 'Parent theme' ),
    899                 'value' => ( $active_theme->parent_theme ? $active_theme->parent_theme : __( 'None' ) ),
    900                 'debug' => ( $active_theme->parent_theme ? $active_theme->parent_theme : 'none' ),
     927                'value' => $active_theme_parent_theme,
     928                'debug' => $active_theme_parent_theme_debug,
    901929            ),
    902930            'theme_features' => array(
     
    906934            'theme_path'     => array(
    907935                'label' => __( 'Theme directory location' ),
    908                 'value' => get_template_directory(),
     936                'value' => get_stylesheet_directory(),
    909937            ),
    910938        );
     939
     940        $parent_theme = $active_theme->parent();
     941
     942        if ( $parent_theme ) {
     943            // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
     944            $parent_theme_version       = $parent_theme->Version;
     945            $parent_theme_version_debug = $parent_theme_version;
     946
     947            if ( array_key_exists( $parent_theme->stylesheet, $theme_updates ) ) {
     948                $parent_theme_update_new_version = $theme_updates[ $parent_theme->stylesheet ]->update['new_version'];
     949
     950                // translators: %s: Latest theme version number.
     951                $parent_theme_version       .= ' ' . sprintf( __( '(Latest version: %s)' ), $parent_theme_update_new_version );
     952                $parent_theme_version_debug .= sprintf( ' (latest version: %s)', $parent_theme_update_new_version );
     953            }
     954
     955            $parent_theme_author_uri = $parent_theme->offsetGet( 'Author URI' );
     956
     957            $info['wp-parent-theme']['fields'] = array(
     958                'name'           => array(
     959                    'label' => __( 'Name' ),
     960                    // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
     961                    'value' => sprintf(
     962                        // translators: 1: Theme name. 2: Theme slug.
     963                        __( '%1$s (%2$s)' ),
     964                        // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
     965                        $parent_theme->Name,
     966                        $parent_theme->stylesheet
     967                    ),
     968                ),
     969                'version'        => array(
     970                    'label' => __( 'Version' ),
     971                    'value' => $parent_theme_version,
     972                    'debug' => $parent_theme_version_debug,
     973                ),
     974                'author'         => array(
     975                    'label' => __( 'Author' ),
     976                    // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
     977                    'value' => wp_kses( $parent_theme->Author, array() ),
     978                ),
     979                'author_website' => array(
     980                    'label' => __( 'Author website' ),
     981                    'value' => ( $parent_theme_author_uri ? $parent_theme_author_uri : __( 'Undefined' ) ),
     982                    'debug' => ( $parent_theme_author_uri ? $parent_theme_author_uri : '(undefined)' ),
     983                ),
     984                'theme_path'     => array(
     985                    'label' => __( 'Theme directory location' ),
     986                    'value' => get_template_directory(),
     987                ),
     988            );
     989        }
    911990
    912991        // Populate a list of all themes available in the install.
     
    914993
    915994        foreach ( $all_themes as $theme_slug => $theme ) {
    916             // Ignore the currently active theme from the list of all themes.
     995            // Exclude the currently active theme from the list of all themes.
    917996            if ( $active_theme->stylesheet === $theme_slug ) {
    918997                continue;
    919998            }
     999
     1000            // Exclude the currently active parent theme from the list of all themes.
     1001            if ( ! empty( $parent_theme ) && $parent_theme->stylesheet === $theme_slug ) {
     1002                continue;
     1003            }
     1004
    9201005            // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
    9211006            $theme_version = $theme->Version;
     
    9541039
    9551040            // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
    956             $info['wp-themes']['fields'][ sanitize_text_field( $theme->Name ) ] = array(
     1041            $info['wp-themes-inactive']['fields'][ sanitize_text_field( $theme->Name ) ] = array(
    9571042                'label' => sprintf(
    9581043                    // translators: 1: Theme name. 2: Theme slug.
Note: See TracChangeset for help on using the changeset viewer.