瀏覽代碼

Brompton: Add foreground color variant to editor palette.

Allan Cole 5 年之前
父節點
當前提交
f9fd2cc588
共有 1 個文件被更改,包括 27 次插入5 次删除
  1. 27 5
      brompton/functions.php

+ 27 - 5
brompton/functions.php

@@ -70,8 +70,10 @@ if ( ! function_exists( 'brompton_setup' ) ) :
 		$colors_array = get_theme_mod( 'colors_manager' ); // color annotations array()
 		$colors_array = get_theme_mod( 'colors_manager' ); // color annotations array()
 		$primary      = ! empty( $colors_array ) ? $colors_array['colors']['link'] : '#C04239'; // $config-global--color-primary-default;
 		$primary      = ! empty( $colors_array ) ? $colors_array['colors']['link'] : '#C04239'; // $config-global--color-primary-default;
 		$secondary    = ! empty( $colors_array ) ? $colors_array['colors']['fg1'] : '#FFFFFF';  // $config-global--color-secondary-default;
 		$secondary    = ! empty( $colors_array ) ? $colors_array['colors']['fg1'] : '#FFFFFF';  // $config-global--color-secondary-default;
-		$foreground   = ! empty( $colors_array ) ? $colors_array['colors']['txt'] : '#505050';  // $config-global--color-foreground-default;
 		$background   = ! empty( $colors_array ) ? $colors_array['colors']['bg'] : '#E8E4DD';   // $config-global--color-background-default;
 		$background   = ! empty( $colors_array ) ? $colors_array['colors']['bg'] : '#E8E4DD';   // $config-global--color-background-default;
+		$foreground   = ! empty( $colors_array ) ? $colors_array['colors']['txt'] : '#505050';  // $config-global--color-foreground-default;
+		$foreground_light = ( ! empty( $colors_array ) && $colors_array['colors']['txt'] != '#505050' ) ? $colors_array['colors']['txt'] : '#666666';  // $config-global--color-foreground-light-default;
+		$foreground_dark  = ( ! empty( $colors_array ) && $colors_array['colors']['txt'] != '#505050' ) ? $colors_array['colors']['txt'] : '#474747';  // $config-global--color-foreground-dark-default;
 
 
 		// Editor color palette.
 		// Editor color palette.
 		add_theme_support(
 		add_theme_support(
@@ -88,14 +90,24 @@ if ( ! function_exists( 'brompton_setup' ) ) :
 					'color' => $secondary,
 					'color' => $secondary,
 				),
 				),
 				array(
 				array(
-					'name'  => __( 'Foreground', 'brompton' ),
+					'name'  => __( 'Background', 'barnsbury' ),
+					'slug'  => 'background',
+					'color' => $background,
+				),
+				array(
+					'name'  => __( 'Foreground', 'barnsbury' ),
 					'slug'  => 'foreground',
 					'slug'  => 'foreground',
 					'color' => $foreground,
 					'color' => $foreground,
 				),
 				),
 				array(
 				array(
-					'name'  => __( 'Background', 'brompton' ),
-					'slug'  => 'background',
-					'color' => $background,
+					'name'  => __( 'Foreground Light', 'balasana' ),
+					'slug'  => 'foreground-light',
+					'color' => $foreground_light,
+				),
+				array(
+					'name'  => __( 'Foreground Dark', 'balasana' ),
+					'slug'  => 'foreground-dark',
+					'color' => $foreground_dark,
 				),
 				),
 			)
 			)
 		);
 		);
@@ -188,5 +200,15 @@ function brompton_editor_styles() {
 
 
 	// Enqueue Google fonts in the editor, if necessary
 	// Enqueue Google fonts in the editor, if necessary
 	wp_enqueue_style( 'brompton-editor-fonts', brompton_fonts_url(), array(), null );
 	wp_enqueue_style( 'brompton-editor-fonts', brompton_fonts_url(), array(), null );
+
+	// Hide duplicate palette colors
+	$colors_array = get_theme_mod('colors_manager', array( 'colors' => true )); // color annotations array()
+	if ( ! empty( $colors_array ) && $colors_array['colors']['txt'] != '#505050' ) { // $config-global--color-foreground-light-default;
+		$inline_palette_css = '.components-circular-option-picker__option-wrapper:nth-child(5),
+			.components-circular-option-picker__option-wrapper:nth-child(6) {
+				display: none;
+			}';
+		wp_add_inline_style( 'wp-edit-blocks', $inline_palette_css );
+	}
 }
 }
 add_action( 'enqueue_block_editor_assets', 'brompton_editor_styles' );
 add_action( 'enqueue_block_editor_assets', 'brompton_editor_styles' );