Changeset 58354
- Timestamp:
- 06/06/2024 08:00:08 AM (6 months ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json-resolver.php
r58339 r58354 526 526 $decoded_data['isGlobalStylesUserThemeJSON'] 527 527 ) { 528 unset( $decoded_data['isGlobalStylesUserThemeJSON'] ); 528 529 $config = $decoded_data; 529 530 } … … 531 532 532 533 /** This filter is documented in wp-includes/class-wp-theme-json-resolver.php */ 533 $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) ); 534 $config = $theme_json->get_data(); 535 536 // Needs to be set for schema migrations of user data. 537 $config['isGlobalStylesUserThemeJSON'] = true; 538 539 static::$user = new WP_Theme_JSON( $config, 'custom' ); 534 $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) ); 535 static::$user = $theme_json->get_theme_json(); 540 536 541 537 return static::$user; -
trunk/src/wp-includes/class-wp-theme-json-schema.php
r58339 r58354 36 36 * 37 37 * @since 5.9.0 38 * @since 6.6.0 Migrate up to v3 .38 * @since 6.6.0 Migrate up to v3 and add $origin parameter. 39 39 * 40 40 * @param array $theme_json The structure to migrate. 41 * 41 * @param string $origin Optional. What source of data this object represents. 42 * One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'. 42 43 * @return array The structure in the last version. 43 44 */ 44 public static function migrate( $theme_json ) {45 public static function migrate( $theme_json, $origin = 'theme' ) { 45 46 if ( ! isset( $theme_json['version'] ) ) { 46 47 $theme_json = array( … … 55 56 // Deliberate fall through. Once migrated to v2, also migrate to v3. 56 57 case 2: 57 $theme_json = self::migrate_v2_to_v3( $theme_json );58 $theme_json = self::migrate_v2_to_v3( $theme_json, $origin ); 58 59 } 59 60 … … 101 102 * @since 6.6.0 102 103 * 103 * @param array $old Data to migrate. 104 * 104 * @param array $old Data to migrate. 105 * @param string $origin What source of data this object represents. 106 * One of 'blocks', 'default', 'theme', or 'custom'. 105 107 * @return array Data with defaultFontSizes set to false. 106 108 */ 107 private static function migrate_v2_to_v3( $old ) {109 private static function migrate_v2_to_v3( $old, $origin ) { 108 110 // Copy everything. 109 111 $new = $old; … … 116 118 * as they should take on the value of the theme origin. 117 119 */ 118 if ( 119 isset( $new['isGlobalStylesUserThemeJSON'] ) && 120 true === $new['isGlobalStylesUserThemeJSON'] 121 ) { 120 if ( 'custom' === $origin ) { 122 121 return $new; 123 122 } -
trunk/src/wp-includes/class-wp-theme-json.php
r58339 r58354 748 748 * @param array $theme_json A structure that follows the theme.json schema. 749 749 * @param string $origin Optional. What source of data this object represents. 750 * One of ' default', 'theme', or 'custom'. Default 'theme'.750 * One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'. 751 751 */ 752 752 public function __construct( $theme_json = array( 'version' => WP_Theme_JSON::LATEST_SCHEMA ), $origin = 'theme' ) { … … 755 755 } 756 756 757 $this->theme_json = WP_Theme_JSON_Schema::migrate( $theme_json );757 $this->theme_json = WP_Theme_JSON_Schema::migrate( $theme_json, $origin ); 758 758 $valid_block_names = array_keys( static::get_blocks_metadata() ); 759 759 $valid_element_names = array_keys( static::ELEMENTS ); … … 3243 3243 * @since 5.9.0 3244 3244 * @since 6.3.2 Preserves global styles block variations when securing styles. 3245 * @since 6.6.0 Updated to allow variation element styles .3245 * @since 6.6.0 Updated to allow variation element styles and $origin parameter. 3246 3246 * 3247 3247 * @param array $theme_json Structure to sanitize. 3248 * @param string $origin Optional. What source of data this object represents. 3249 * One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'. 3248 3250 * @return array Sanitized structure. 3249 3251 */ 3250 public static function remove_insecure_properties( $theme_json ) { 3252 public static function remove_insecure_properties( $theme_json, $origin = 'theme' ) { 3253 if ( ! in_array( $origin, static::VALID_ORIGINS, true ) ) { 3254 $origin = 'theme'; 3255 } 3256 3251 3257 $sanitized = array(); 3252 3258 3253 $theme_json = WP_Theme_JSON_Schema::migrate( $theme_json );3259 $theme_json = WP_Theme_JSON_Schema::migrate( $theme_json, $origin ); 3254 3260 3255 3261 $valid_block_names = array_keys( static::get_blocks_metadata() ); -
trunk/src/wp-includes/kses.php
r58294 r58354 2147 2147 unset( $decoded_data['isGlobalStylesUserThemeJSON'] ); 2148 2148 2149 $data_to_encode = WP_Theme_JSON::remove_insecure_properties( $decoded_data );2149 $data_to_encode = WP_Theme_JSON::remove_insecure_properties( $decoded_data, 'custom' ); 2150 2150 2151 2151 $data_to_encode['isGlobalStylesUserThemeJSON'] = true;
Note: See TracChangeset
for help on using the changeset viewer.