Make WordPress Core


Ignore:
Timestamp:
10/07/2022 09:38:15 AM (18 months ago)
Author:
audrasjb
Message:

Editor: Add missing blocks origin to theme.json.

This changeset updates the blocks origin name from core to blocks and adds it to the list of valid origins for theme.json.
(See the original fix in Gutenberg's PR 44363).

Why?

  • This new origin was missing from the list.
  • The core name is not reflective of what it does, as this data origin is related to block styles, whether they come with WordPress or third-party blocks.
  • The existing filter for this piece of data is called theme_json_blocks, to reflect it filters "block" data.
  • Though core origin was used in the past for default, this commit reverts it. Why? It was confusing. The goal is to use names that communicate what part of the pipeline are processing (default > blocks > theme > custom).

How?

  • Renames the string, from core to blocks.
  • Adds blocks to the list of valid origins.
  • Verifies that the $theme_json->get_stylesheet() call uses the proper $origins at all times.

Follow-up to [54162], [54251].

Props oandregal, czapla, jorgefilipecosta, scruffian, bernhard-reiter hellofromTonya.
See #56467.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json-resolver.php

    r54399 r54408  
    296296         * @param WP_Theme_JSON_Data Class to access and update the underlying data.
    297297         */
    298         $theme_json = apply_filters( 'theme_json_blocks', new WP_Theme_JSON_Data( $config, 'core' ) );
     298        $theme_json = apply_filters( 'theme_json_blocks', new WP_Theme_JSON_Data( $config, 'blocks' ) );
    299299        $config     = $theme_json->get_data();
    300300
    301         // Core here means it's the lower level part of the styles chain.
    302         // It can be a core or a third-party block.
    303         return new WP_Theme_JSON( $config, 'core' );
     301        return new WP_Theme_JSON( $config, 'blocks' );
    304302    }
    305303
Note: See TracChangeset for help on using the changeset viewer.