浏览代码

Alves: Connect editor color palette to color annotations.

Allan Cole 5 年之前
父节点
当前提交
a638e0382c
共有 1 个文件被更改,包括 19 次插入18 次删除
  1. 19 18
      alves/functions.php

+ 19 - 18
alves/functions.php

@@ -53,40 +53,41 @@ if ( ! function_exists( 'alves_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(
 			'editor-color-palette',
 			array(
 				array(
 					'name'  => __( 'Primary', 'alves' ),
 					'slug'  => 'primary',
-					'color' => '#3E7D98',
+					'color' => ! isset($primary) ? '#3E7D98' : $primary,
 				),
 				array(
 					'name'  => __( 'Secondary', 'alves' ),
 					'slug'  => 'secondary',
-					'color' => '#9B6A36',
+					'color' => ! isset($secondary) ? '#9B6A36' : $secondary,
 				),
 				array(
-					'name'  => __( 'Dark Gray', 'alves' ),
-					'slug'  => 'foreground-dark',
-					'color' => '#253136',
-				),
-				array(
-					'name'  => __( 'Gray', 'alves' ),
+					'name'  => __( 'Foreground', 'alves' ),
 					'slug'  => 'foreground',
-					'color' => '#394d55',
+					'color' => ! isset($foreground) ? '#394d55' : $foreground,
 				),
 				array(
-					'name'  => __( 'Light Gray', 'alves' ),
-					'slug'  => 'foreground-light',
-					'color' => '#4d6974',
+					'name'  => __( 'Background', 'alves' ),
+					'slug'  => 'background',
+					'color' => ! isset($background) ? '#ffffff' : $background,
 				),
-				array(
-                    'name'  => __( 'White', 'alves' ),
-                    'slug'  => 'background',
-                    'color' => '#ffffff',
-                ),
 			)
 		);
 	}