Skip to content
Merged
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
Next Next commit
Cover the other use of migrate
  • Loading branch information
oandregal committed Jun 5, 2024
commit bb01521bee42e2a827109e2246dbfebcc51d4b5b
12 changes: 9 additions & 3 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ public static function get_element_class_name( $element ) {
*
* @param array $theme_json A structure that follows the theme.json schema.
* @param string $origin Optional. What source of data this object represents.
* One of 'default', 'theme', or 'custom'. Default 'theme'.
* One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'.
*/
public function __construct( $theme_json = array( 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA ), $origin = 'theme' ) {
if ( ! in_array( $origin, static::VALID_ORIGINS, true ) ) {
Expand Down Expand Up @@ -3281,12 +3281,18 @@ protected static function filter_slugs( $node, $slugs ) {
* @since 6.6.0 Added support for block style variation element styles.
*
* @param array $theme_json Structure to sanitize.
* @param string $origin Optional. What source of data this object represents.
* One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'.
* @return array Sanitized structure.
*/
public static function remove_insecure_properties( $theme_json ) {
public static function remove_insecure_properties( $theme_json, $origin = 'theme' ) {
if ( ! in_array( $origin, static::VALID_ORIGINS, true ) ) {
$origin = 'theme';
}

$sanitized = array();

$theme_json = WP_Theme_JSON_Schema_Gutenberg::migrate( $theme_json );
$theme_json = WP_Theme_JSON_Schema_Gutenberg::migrate( $theme_json, $origin );

$valid_block_names = array_keys( static::get_blocks_metadata() );
$valid_element_names = array_keys( static::ELEMENTS );
Expand Down
2 changes: 1 addition & 1 deletion lib/experimental/kses.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function gutenberg_filter_global_styles_post( $data ) {
) {
unset( $decoded_data['isGlobalStylesUserThemeJSON'] );

$data_to_encode = WP_Theme_JSON_Gutenberg::remove_insecure_properties( $decoded_data );
$data_to_encode = WP_Theme_JSON_Gutenberg::remove_insecure_properties( $decoded_data, 'custom' );

$data_to_encode['isGlobalStylesUserThemeJSON'] = true;
return wp_slash( wp_json_encode( $data_to_encode ) );
Expand Down