Making WordPress.org


Ignore:
Timestamp:
09/04/2025 06:01:37 AM (2 months ago)
Author:
dd32
Message:

Theme Directory: Resolve some Undefined warnings / unset offsets in the Theme Preview/Review endpoint.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/rest-api/class-theme-preview.php

    r14523 r14524  
    151151        $version         = $params['version'] ?? false;
    152152        $theme_package   = new WPORG_Themes_Repo_Package( $theme_data->slug, $version );
    153         $parent_package  = $theme_data->template ? new WPORG_Themes_Repo_Package( $theme_data->template ) : false;
    154153        $theme_blueprint = $theme_package->preview_blueprint;
     154        $parent_package  = false;
     155        if ( isset( $theme_data->template ) && $theme_data->template !== $theme_data->slug ) {
     156            $parent_package = new WPORG_Themes_Repo_Package( $theme_data->template );
     157        }
    155158
    156159        // Base blueprint.
     
    214217                'options' => [
    215218                    'blogname'        => $theme_data->name . ( $version ? " $version" : '' ),
    216                     'blogdescription' => preg_replace( '![.].+$!',  '.', $theme_data->sections['description'] ), // First sentence only.
     219                    'blogdescription' => preg_replace( '![.].+$!',  '.', $theme_data->sections['description'] ?? '' ), // First sentence only.
    217220                ]
    218221            ],
     
    230233            // Note: The following use `url` to allow setting the caption to the proper theme name.
    231234            // Install parent theme.
    232             empty( $theme_data->template ) ? false : [
     235            ! $parent_package ? false : [
    233236                'step'         => 'installTheme',
    234237                'themeData' => [
     
    259262        $theme_steps = array_filter(
    260263            $theme_steps,
    261             static function( $step ) use( $invalid_steps ) {
     264            static function( $step ) {
    262265                // Don't install assets from URLs.
    263266                if (
Note: See TracChangeset for help on using the changeset viewer.