Sfoglia il codice sorgente

Rivington: Connect editor color palette to color annotations.

Allan Cole 5 anni fa
parent
commit
34e2997707
1 ha cambiato i file con 19 aggiunte e 27 eliminazioni
  1. 19 27
      rivington/functions.php

+ 19 - 27
rivington/functions.php

@@ -58,52 +58,44 @@ if ( ! function_exists( 'rivington_setup' ) ) :
 			)
 			)
 		);
 		);
 
 
-		// Add child theme editor color pallete to match Sass-map variables in `_config-child-theme-deep.scss`.
+		/*
+		 * Get customizer colors and add them to the editor color palettes
+		 *
+		 * - if the customizer color is empty, use the default
+		 */
+		$colors_array = get_theme_mod('colors_manager'); // color annotations array()
+		$background   = $colors_array['colors']['bg'];   // $config-global--color-background-default;
+		$primary      = $colors_array['colors']['link']; // $config-global--color-primary-default;
+		$foreground   = $colors_array['colors']['txt'];  // $config-global--color-foreground-default;
+		$secondary    = $colors_array['colors']['fg1'];  // $config-global--color-secondary-default;
+
+		// Editor color palette.
 		add_theme_support(
 		add_theme_support(
 			'editor-color-palette',
 			'editor-color-palette',
 			array(
 			array(
 				array(
 				array(
 					'name'  => __( 'Primary', 'rivington' ),
 					'name'  => __( 'Primary', 'rivington' ),
 					'slug'  => 'primary',
 					'slug'  => 'primary',
-					'color' => '#CAAB57',
+					'color' => ! isset($primary) ? '#CAAB57' : $primary,
 				),
 				),
 				array(
 				array(
 					'name'  => __( 'Secondary', 'rivington' ),
 					'name'  => __( 'Secondary', 'rivington' ),
 					'slug'  => 'secondary',
 					'slug'  => 'secondary',
-					'color' => '#EE4266',
+					'color' => ! isset($secondary) ? '#EE4266' : $secondary,
 				),
 				),
 				array(
 				array(
-					'name'  => __( 'Light Gray', 'rivington' ),
-					'slug'  => 'foreground-dark',
-					'color' => '#8F8F8F',
-				),
-				array(
-					'name'  => __( 'Off White', 'rivington' ),
+					'name'  => __( 'Foreground', 'rivington' ),
 					'slug'  => 'foreground',
 					'slug'  => 'foreground',
-					'color' => '#F2F2F2',
+					'color' => ! isset($foreground) ? '#F2F2F2' : $foreground,
 				),
 				),
 				array(
 				array(
-					'name'  => __( 'White', 'rivington' ),
-					'slug'  => 'foreground-light',
-					'color' => '#FFFFFF',
-				),
-				array(
-					'name'  => __( 'Dark Navy', 'rivington' ),
-					'slug'  => 'background-dark',
-					'color' => '#030713',
-				),
-				array(
-					'name'  => __( 'Navy', 'rivington' ),
+					'name'  => __( 'Background', 'rivington' ),
 					'slug'  => 'background',
 					'slug'  => 'background',
-					'color' => '#060f29',
-				),
-				array(
-					'name'  => __( 'Light Navy', 'rivington' ),
-					'slug'  => 'background-light',
-					'color' => '#0d1f55',
+					'color' => ! isset($background) ? '#060f29' : $background,
 				),
 				),
 			)
 			)
 		);
 		);
+
 		// Remove footer menu
 		// Remove footer menu
 		unregister_nav_menu( 'menu-2' );
 		unregister_nav_menu( 'menu-2' );
 	}
 	}