Changeset 56779
- Timestamp:
- 10/04/2023 07:08:55 PM (18 months ago)
- Location:
- branches/6.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.3
- Property svn:mergeinfo changed
/trunk merged: 56502,56778
- Property svn:mergeinfo changed
-
branches/6.3/src/wp-includes/class-wp-theme-json.php
r56181 r56779 2850 2850 * 2851 2851 * @since 5.9.0 2852 * @since 6.3.2 Preserves global styles block variations when securing styles. 2852 2853 * 2853 2854 * @param array $theme_json Structure to sanitize. … … 2910 2911 if ( ! empty( $output ) ) { 2911 2912 _wp_array_set( $sanitized, $metadata['path'], $output ); 2913 } 2914 2915 if ( isset( $metadata['variations'] ) ) { 2916 foreach ( $metadata['variations'] as $variation ) { 2917 $variation_input = _wp_array_get( $theme_json, $variation['path'], array() ); 2918 if ( empty( $variation_input ) ) { 2919 continue; 2920 } 2921 2922 $variation_output = static::remove_insecure_styles( $variation_input ); 2923 if ( ! empty( $variation_output ) ) { 2924 _wp_array_set( $sanitized, $variation['path'], $variation_output ); 2925 } 2926 } 2912 2927 } 2913 2928 } -
branches/6.3/tests/phpunit/tests/theme/wpThemeJson.php
r56101 r56779 3870 3870 } 3871 3871 3872 public function test_block_style_variations() { 3873 wp_set_current_user( static::$administrator_id ); 3874 3875 $expected = array( 3876 'version' => WP_Theme_JSON::LATEST_SCHEMA, 3877 'styles' => array( 3878 'blocks' => array( 3879 'core/button' => array( 3880 'color' => array( 3881 'background' => 'blue', 3882 ), 3883 'variations' => array( 3884 'outline' => array( 3885 'color' => array( 3886 'background' => 'purple', 3887 ), 3888 ), 3889 ), 3890 ), 3891 ), 3892 ), 3893 ); 3894 3895 $actual = WP_Theme_JSON::remove_insecure_properties( $expected ); 3896 3897 $this->assertSameSetsWithIndex( $expected, $actual ); 3898 } 3899 3900 public function test_block_style_variations_with_invalid_properties() { 3901 wp_set_current_user( static::$administrator_id ); 3902 3903 $partially_invalid_variation = array( 3904 'version' => WP_Theme_JSON::LATEST_SCHEMA, 3905 'styles' => array( 3906 'blocks' => array( 3907 'core/button' => array( 3908 'color' => array( 3909 'background' => 'blue', 3910 ), 3911 'variations' => array( 3912 'outline' => array( 3913 'color' => array( 3914 'background' => 'purple', 3915 ), 3916 'invalid' => array( 3917 'value' => 'should be stripped', 3918 ), 3919 ), 3920 ), 3921 ), 3922 ), 3923 ), 3924 ); 3925 3926 $expected = array( 3927 'version' => WP_Theme_JSON::LATEST_SCHEMA, 3928 'styles' => array( 3929 'blocks' => array( 3930 'core/button' => array( 3931 'color' => array( 3932 'background' => 'blue', 3933 ), 3934 'variations' => array( 3935 'outline' => array( 3936 'color' => array( 3937 'background' => 'purple', 3938 ), 3939 ), 3940 ), 3941 ), 3942 ), 3943 ), 3944 ); 3945 3946 $actual = WP_Theme_JSON::remove_insecure_properties( $partially_invalid_variation ); 3947 3948 $this->assertSameSetsWithIndex( $expected, $actual ); 3949 } 3950 3872 3951 /** 3873 3952 * @ticket 56611
Note: See TracChangeset
for help on using the changeset viewer.