Skip to content

Commit

Permalink
Refactor to continue if values are not arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
mikachan committed Nov 8, 2023
1 parent ffabdfa commit e50f0a5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/experimental/fonts-api/class-wp-fonts-resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,17 @@ private static function get_settings() {
$settings = static::set_tyopgraphy_settings_array_structure( $settings );
}

// Merge the variation settings with the global settings.
if ( is_array( $settings['typography']['fontFamilies']['theme'] ) && is_array( $variation['settings']['typography']['fontFamilies']['theme'] ) ) {
$settings['typography']['fontFamilies']['theme'] = array_merge(
$settings['typography']['fontFamilies']['theme'],
$variation['settings']['typography']['fontFamilies']['theme']
);
// Skip if typography.fontFamilies.theme from the global settings and the variation are not arrays.
if ( ! is_array( $settings['typography']['fontFamilies']['theme'] ) && ! is_array( $variation['settings']['typography']['fontFamilies']['theme'] ) ) {
continue;
}

// Merge the variation settings with the global settings.
$settings['typography']['fontFamilies']['theme'] = array_merge(
$settings['typography']['fontFamilies']['theme'],
$variation['settings']['typography']['fontFamilies']['theme']
);

// Make sure there are no duplicates.
$settings['typography']['fontFamilies'] = array_unique( $settings['typography']['fontFamilies'] );
}
Expand Down

0 comments on commit e50f0a5

Please sign in to comment.