Skip to content

Commit

Permalink
Format php.
Browse files Browse the repository at this point in the history
  • Loading branch information
jffng committed Sep 18, 2023
1 parent 355f9fd commit 8067f83
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -820,13 +820,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];
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -920,7 +920,7 @@ public function test_sanitize_invalid_typography_settings(){
),
),
),
'src' => 'https://example.com/font.ttf',
'src' => 'https://example.com/font.ttf',
),
),
)
Expand All @@ -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.' );
}
Expand Down

0 comments on commit 8067f83

Please sign in to comment.