Make WordPress Core

Changeset 54501


Ignore:
Timestamp:
10/11/2022 08:06:16 PM (4 years ago)
Author:
hellofromTonya
Message:

Editor: Rename new theme_json_{$context} filters.

The newly introduced filters are renamed to use the wp_theme_json_data{$context} structure:

  • theme_json_default renamed to wp_theme_json_data_default
  • theme_json_theme renamed to wp_theme_json_data_theme
  • theme_json_blocks renamed to wp_theme_json_data_blocks
  • theme_json_user renamed to wp_theme_json_data_user

The following new filter gets the wp_ prefix added:

  • theme_json_get_style_nodes renamed to wp_theme_json_get_style_nodes

Follow-up to [56467], [54183], [54118].

Props kebbet, desrosj, mukesh27, ocean90, sergeybiryukov, davidbaumwald, hellofromTonya.
Fixes #56796.

Location:
trunk
Files:
4 edited

Legend:

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

    r54493 r54501  
    181181                 * @param WP_Theme_JSON_Data Class to access and update the underlying data.
    182182                 */
    183                 $theme_json   = apply_filters( 'theme_json_default', new WP_Theme_JSON_Data( $config, 'default' ) );
     183                $theme_json   = apply_filters( 'wp_theme_json_data_default', new WP_Theme_JSON_Data( $config, 'default' ) );
    184184                $config       = $theme_json->get_data();
    185185                static::$core = new WP_Theme_JSON( $config, 'default' );
     
    257257                         * @param WP_Theme_JSON_Data Class to access and update the underlying data.
    258258                         */
    259                         $theme_json      = apply_filters( 'theme_json_theme', new WP_Theme_JSON_Data( $theme_json_data, 'theme' ) );
     259                        $theme_json      = apply_filters( 'wp_theme_json_data_theme', new WP_Theme_JSON_Data( $theme_json_data, 'theme' ) );
    260260                        $theme_json_data = $theme_json->get_data();
    261261                        static::$theme   = new WP_Theme_JSON( $theme_json_data );
     
    358358                 * @param WP_Theme_JSON_Data Class to access and update the underlying data.
    359359                 */
    360                 $theme_json = apply_filters( 'theme_json_blocks', new WP_Theme_JSON_Data( $config, 'blocks' ) );
     360                $theme_json = apply_filters( 'wp_theme_json_data_blocks', new WP_Theme_JSON_Data( $config, 'blocks' ) );
    361361                $config     = $theme_json->get_data();
    362362
     
    491491                                 * @param WP_Theme_JSON_Data Class to access and update the underlying data.
    492492                                 */
    493                                 $theme_json = apply_filters( 'theme_json_user', new WP_Theme_JSON_Data( $config, 'custom' ) );
     493                                $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) );
    494494                                $config     = $theme_json->get_data();
    495495                                return new WP_Theme_JSON( $config, 'custom' );
     
    509509
    510510                /** This filter is documented in wp-includes/class-wp-theme-json-resolver.php */
    511                 $theme_json   = apply_filters( 'theme_json_user', new WP_Theme_JSON_Data( $config, 'custom' ) );
     511                $theme_json   = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) );
    512512                $config       = $theme_json->get_data();
    513513                static::$user = new WP_Theme_JSON( $config, 'custom' );
  • trunk/src/wp-includes/class-wp-theme-json.php

    r54497 r54501  
    19121912                 * @param array $nodes Style nodes with metadata.
    19131913                 */
    1914                 return apply_filters( 'theme_json_get_style_nodes', $nodes );
     1914                return apply_filters( 'wp_theme_json_get_style_nodes', $nodes );
    19151915        }
    19161916
  • trunk/src/wp-includes/script-loader.php

    r54485 r54501  
    24302430         * This filter must be registered before calling wp_get_global_stylesheet();
    24312431         */
    2432         add_filter( 'theme_json_get_style_nodes', 'wp_filter_out_block_nodes' );
     2432        add_filter( 'wp_theme_json_get_style_nodes', 'wp_filter_out_block_nodes' );
    24332433
    24342434        $stylesheet = wp_get_global_stylesheet();
  • trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php

    r54493 r54501  
    391391                }
    392392
    393                 $expected_filter_count = did_filter( 'theme_json_default' );
     393                $expected_filter_count = did_filter( 'wp_theme_json_data_default' );
    394394                $actual                = WP_Theme_JSON_Resolver::get_core_data();
    395395                if ( $should_fire_filter ) {
     
    397397                }
    398398
    399                 $this->assertSame( $expected_filter_count, did_filter( 'theme_json_default' ), 'The filter "theme_json_default" should fire the given number of times' );
     399                $this->assertSame( $expected_filter_count, did_filter( 'wp_theme_json_data_default' ), 'The filter "theme_json_default" should fire the given number of times' );
    400400                $this->assertInstanceOf( WP_Theme_JSON::class, $actual, 'WP_Theme_JSON_Resolver::get_core_data() should return instance of WP_Theme_JSON' );
    401401                $this->assertSame( static::$property_core->getValue(), $actual, 'WP_Theme_JSON_Resolver::$core property should be the same object as returned from WP_Theme_JSON_Resolver::get_core_data()' );
Note: See TracChangeset for help on using the changeset viewer.