Make WordPress Core


Ignore:
Timestamp:
02/17/2022 01:46:27 PM (3 years ago)
Author:
jorgefilipecosta
Message:

Global Styles: Fix PHP warning in WP_REST_Global_Styles_Controller if no styles exist.

There is a PHP warning in WP_REST_Global_Styles_Controller because we are assuming that every theme.json has styles property, which is not always the case.

Props ntsekouras.
Fixes #54900.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php

    r52399 r52750  
    564564
    565565        if ( rest_is_field_included( 'styles', $fields ) ) {
    566             $data['styles'] = $theme->get_raw_data()['styles'];
     566            $raw_data = $theme->get_raw_data();
     567            if ( isset( $raw_data['styles'] ) ) {
     568                $data['styles'] = $raw_data['styles'];
     569            }
    567570        }
    568571
Note: See TracChangeset for help on using the changeset viewer.