From 1f22ce0b295f84b08a60adbd137f256795cd5f32 Mon Sep 17 00:00:00 2001 From: Jeff Ong Date: Fri, 4 Aug 2023 15:03:49 -0400 Subject: [PATCH] Format php. --- lib/class-wp-theme-json-gutenberg.php | 12 ++++++------ phpunit/class-wp-theme-json-test.php | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index d796fb238cb82b..ad1415bf39f7ee 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -811,13 +811,13 @@ protected static function sanitize( $input, $valid_block_names, $valid_element_n $schema['settings']['blocks'] = $schema_settings_blocks; // For settings.typography.fontFamilies, make the $schema have all indexes present in the $input. - if ( isset( $input['settings']['typography']['fontFamilies'] )){ - foreach( $input['settings']['typography']['fontFamilies'] as $font_family_key => $value ){ - $schema['settings']['typography']['fontFamilies'][$font_family_key] = static::VALID_SETTINGS['typography']['fontFamilies'][0]; + if ( isset( $input['settings']['typography']['fontFamilies'] ) ) { + foreach ( $input['settings']['typography']['fontFamilies'] as $font_family_key => $value ) { + $schema['settings']['typography']['fontFamilies'][ $font_family_key ] = static::VALID_SETTINGS['typography']['fontFamilies'][0]; // Do the same for fontFace. - if ( isset( $input['settings']['typography']['fontFamilies'][$font_family_key]['fontFace']) ){ - foreach( $input['settings']['typography']['fontFamilies'][$font_family_key]['fontFace'] as $font_face_key => $value2 ){ - $schema['settings']['typography']['fontFamilies'][$font_family_key]['fontFace'][$font_face_key] = static::VALID_SETTINGS['typography']['fontFamilies'][0]['fontFace'][0]; + if ( isset( $input['settings']['typography']['fontFamilies'][ $font_family_key ]['fontFace'] ) ) { + foreach ( $input['settings']['typography']['fontFamilies'][ $font_family_key ]['fontFace'] as $font_face_key => $value2 ) { + $schema['settings']['typography']['fontFamilies'][ $font_family_key ]['fontFace'][ $font_face_key ] = static::VALID_SETTINGS['typography']['fontFamilies'][0]['fontFace'][0]; } } } diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index 7059169c00df4f..631e04337b5cb0 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -896,7 +896,7 @@ public function test_remove_invalid_element_pseudo_selectors() { $this->assertEqualSetsWithIndex( $expected, $actual ); } - public function test_sanitize_invalid_typography_settings(){ + public function test_sanitize_invalid_typography_settings() { $theme_json = new WP_Theme_JSON_Gutenberg( array( 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA, @@ -907,7 +907,7 @@ public function test_sanitize_invalid_typography_settings(){ array( 'name' => 'Piazzolla', 'slug' => 'piazzolla', - 'badKey' => 'I am invalid', + 'badKey' => 'I am invalid', 'fontFamily' => 'Piazzolla', 'fontFace' => array( array( @@ -920,7 +920,7 @@ public function test_sanitize_invalid_typography_settings(){ ), ), ), - 'src' => 'https://example.com/font.ttf', + 'src' => 'https://example.com/font.ttf', ), ), ) @@ -946,8 +946,8 @@ public function test_sanitize_invalid_typography_settings(){ 'slug' => 'piazzolla', ), ), - ) - ) + ), + ), ); $this->assertSameSetsWithIndex( $expected, $sanitized_theme_json, 'Sanitized theme.json settings do not match.' ); }