Skip to content

Commit

Permalink
Fix global styles override
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Sep 1, 2021
1 parent 9c0a85b commit eea9799
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,17 @@ function_exists( 'gutenberg_is_edit_site_page' ) &&
}

// Reset existing global styles.
$styles_without_existing_global_styles = array();
foreach ( $settings['styles'] as $key => $style ) {
if ( isset( $style['__unstableType'] ) && 'globalStyles' === $style['__unstableType'] ) {
unset( $settings['styles'][ $key ] );
if ( ! isset( $style['__unstableType'] ) || 'globalStyles' !== $style['__unstableType'] ) {
$styles_without_existing_global_styles[] = $style;
}
}

// Add the new ones.
$settings['styles'][] = $css_variables;
$settings['styles'][] = $block_styles;
$styles_without_existing_global_styles[] = $css_variables;
$styles_without_existing_global_styles[] = $block_styles;
$settings['styles'] = $styles_without_existing_global_styles;
}

// Copied from get_block_editor_settings() at wordpress-develop/block-editor.php.
Expand Down

0 comments on commit eea9799

Please sign in to comment.