Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'trunk' into fix/no-static
  • Loading branch information
spacedmonkey authored Nov 22, 2022
commit 81d485c61820807a4781a399888e20571dd67a16
2 changes: 1 addition & 1 deletion src/wp-admin/site-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static function( $classes ) {
}

$active_global_styles_id = $wp_theme_json_resolver->get_user_global_styles_post_id();
$active_theme = wp_get_theme()->get_stylesheet();
$active_theme = get_stylesheet();
$preload_paths = array(
array( '/wp/v2/media', 'OPTIONS' ),
'/wp/v2/types?context=view',
Expand Down
3 changes: 2 additions & 1 deletion src/wp-includes/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,8 @@ function wp_is_theme_directory_ignored( $path ) {
* @return WP_Error|string Path of the ZIP file or error on failure.
*/
function wp_generate_block_templates_export_file() {
global $wp_theme_json_resolver;
global $wp_theme_json_resolver, $wp_version;

if ( ! class_exists( 'ZipArchive' ) ) {
return new WP_Error( 'missing_zip_package', __( 'Zip Export not supported.' ) );
}
Expand Down
39 changes: 24 additions & 15 deletions src/wp-includes/class-wp-theme-json-resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,14 @@ public function get_theme_data( $deprecated = array(), $options = array() ) {
$options = wp_parse_args( $options, array( 'with_supports' => true ) );

if ( null === $this->theme || ! $this->has_same_registered_blocks( 'theme' ) ) {
$theme_json_data = $this->read_json_file( $this->get_file_path_from_theme( 'theme.json' ) );
$theme_json_data = $this->translate( $theme_json_data, wp_get_theme()->get( 'TextDomain' ) );
$theme_json_file = $this->get_file_path_from_theme( 'theme.json' );
$wp_theme = wp_get_theme();
if ( '' !== $theme_json_file ) {
$theme_json_data = $this->read_json_file( $theme_json_file );
$theme_json_data = $this->translate( $theme_json_data, $wp_theme->get( 'TextDomain' ) );
} else {
$theme_json_data = array();
}

/**
* Filters the data provided by the theme for global styles and settings.
Expand All @@ -267,20 +273,23 @@ public function get_theme_data( $deprecated = array(), $options = array() ) {
$theme_json = apply_filters( 'wp_theme_json_data_theme', new WP_Theme_JSON_Data( $theme_json_data, 'theme' ) );
$theme_json_data = $theme_json->get_data();
$this->theme = new WP_Theme_JSON( $theme_json_data );
}

if ( wp_get_theme()->parent() ) {
// Get parent theme.json.
$parent_theme_json_data = $this->read_json_file( $this->get_file_path_from_theme( 'theme.json', true ) );
$parent_theme_json_data = $this->translate( $parent_theme_json_data, wp_get_theme()->parent()->get( 'TextDomain' ) );
$parent_theme = new WP_Theme_JSON( $parent_theme_json_data );

/*
* Merge the child theme.json into the parent theme.json.
* The child theme takes precedence over the parent.
*/
$parent_theme->merge( $this->theme );
$this->theme = $parent_theme;
if ( $wp_theme->parent() ) {
// Get parent theme.json.
$parent_theme_json_file = $this->get_file_path_from_theme( 'theme.json', true );
if ( '' !== $parent_theme_json_file ) {
$parent_theme_json_data = $this->read_json_file( $parent_theme_json_file );
$parent_theme_json_data = $this->translate( $parent_theme_json_data, $wp_theme->parent()->get( 'TextDomain' ) );
$parent_theme = new WP_Theme_JSON( $parent_theme_json_data );

/*
* Merge the child theme.json into the parent theme.json.
* The child theme takes precedence over the parent.
*/
$parent_theme->merge( static::$theme );
$this->theme = $parent_theme;
}
}
}

if ( ! $options['with_supports'] ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ public function get_theme_item_permissions_check( $request ) {
*/
public function get_theme_item( $request ) {
global $wp_theme_json_resolver;
if ( wp_get_theme()->get_stylesheet() !== $request['stylesheet'] ) {

if ( get_stylesheet() !== $request['stylesheet'] ) {
// This endpoint only supports the active theme for now.
return new WP_Error(
'rest_theme_not_found',
Expand Down Expand Up @@ -640,7 +641,8 @@ public function get_theme_items_permissions_check( $request ) { // phpcs:ignore
*/
public function get_theme_items( $request ) {
global $wp_theme_json_resolver;
if ( wp_get_theme()->get_stylesheet() !== $request['stylesheet'] ) {

if ( get_stylesheet() !== $request['stylesheet'] ) {
// This endpoint only supports the active theme for now.
return new WP_Error(
'rest_theme_not_found',
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.