Make WordPress Core


Ignore:
Timestamp:
09/01/2023 02:51:55 AM (3 years ago)
Author:
isabel_brison
Message:

Editor: Preserve block style variations when securing theme.

Adds the ability to process block style variations to the remove_insecure_properties function of theme json class.

Props dsas, ramonopoly.
Fixes #59108.

File:
1 edited

Legend:

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

    r56414 r56502  
    28222822         *
    28232823         * @since 5.9.0
     2824         * @since 6.3.1 Preserves global styles block variations when securing styles.
    28242825         *
    28252826         * @param array $theme_json Structure to sanitize.
    … …  
    28792880                        if ( ! empty( $output ) ) {
    28802881                                _wp_array_set( $sanitized, $metadata['path'], $output );
     2882                        }
     2883
     2884                        if ( isset( $metadata['variations'] ) ) {
     2885                                foreach ( $metadata['variations'] as $variation ) {
     2886                                        $variation_input = _wp_array_get( $theme_json, $variation['path'], array() );
     2887                                        if ( empty( $variation_input ) ) {
     2888                                                continue;
     2889                                        }
     2890
     2891                                        $variation_output = static::remove_insecure_styles( $variation_input );
     2892                                        if ( ! empty( $variation_output ) ) {
     2893                                                _wp_array_set( $sanitized, $variation['path'], $variation_output );
     2894                                        }
     2895                                }
    28812896                        }
    28822897                }
Note: See TracChangeset for help on using the changeset viewer.