Explorar o código

Change how 'old custom theme colors' are cleaned out to be more specific (#5754)

Jason Crist %!s(int64=3) %!d(string=hai) anos
pai
achega
6ab7080e27
Modificáronse 1 ficheiros con 12 adicións e 1 borrados
  1. 12 1
      blockbase/inc/customizer/wp-customize-colors.php

+ 12 - 1
blockbase/inc/customizer/wp-customize-colors.php

@@ -152,7 +152,18 @@ class GlobalStylesColorCustomizer {
 		$new_settings['color']['palette']['theme'] = $this->user_color_palette;
 		// We used to set the values in 'custom' but moved to 'theme' to mirror GS functionality.
 		// This ensures that new saves don't store the customizations in both places.
-		unset($new_settings['color']['palette']['custom']);
+		if($new_settings['color']['palette']['custom']) {
+			foreach ( $new_settings['color']['palette']['theme'] as $theme_color ) {
+				foreach ( $new_settings['color']['palette']['custom'] as $key => $custom_color ) {
+					if( $theme_color['slug'] === $custom_color['slug'] ) {
+						unset( $new_settings['color']['palette']['custom'][$key] );
+					}
+				}
+			}
+			if ( ! $new_settings['color']['palette']['custom'] ) {
+				unset ( $new_settings['color']['palette']['custom'] );
+			}
+		}
 
 		// Add the updated global styles to the update request
 		$update_request = new WP_REST_Request( 'PUT', '/wp/v2/global-styles/' );