Explorar o código

Balasana: Add color options for foreground-dark/light.
- Fix hidden editor color selectors

Allan Cole %!s(int64=5) %!d(string=hai) anos
pai
achega
4506673196
Modificáronse 1 ficheiros con 30 adicións e 8 borrados
  1. 30 8
      balasana/functions.php

+ 30 - 8
balasana/functions.php

@@ -58,11 +58,13 @@ if ( ! function_exists( 'balasana_setup' ) ) :
 		 *
 		 * - if the customizer color is empty, use the default
 		 */
-		$colors_array = get_theme_mod( 'colors_manager' ); // color annotations array()
-		$primary      = ! empty( $colors_array ) ? $colors_array['colors']['link'] : '#19744C'; // $config-global--color-primary-default;
-		$secondary    = ! empty( $colors_array ) ? $colors_array['colors']['fg1'] : '#BC2213';  // $config-global--color-secondary-default;
-		$foreground   = ! empty( $colors_array ) ? $colors_array['colors']['txt'] : '#303030';  // $config-global--color-foreground-default;
-		$background   = ! empty( $colors_array ) ? $colors_array['colors']['bg'] : '#FFFFFF';   // $config-global--color-background-default;
+		$colors_array     = get_theme_mod( 'colors_manager' ); // color annotations array()
+		$primary          = ! empty( $colors_array ) ? $colors_array['colors']['link'] : '#19744C'; // $config-global--color-primary-default;
+		$secondary        = ! empty( $colors_array ) ? $colors_array['colors']['fg1'] : '#BC2213';  // $config-global--color-secondary-default;
+		$background       = ! empty( $colors_array ) ? $colors_array['colors']['bg'] : '#FFFFFF';   // $config-global--color-background-default;
+		$foreground       = ! empty( $colors_array ) ? $colors_array['colors']['txt'] : '#303030';  // $config-global--color-foreground-default;
+		$foreground_light = ( ! empty( $colors_array ) && $colors_array['colors']['txt'] != '#303030' ) ? $colors_array['colors']['txt'] : '#505050';  // $config-global--color-foreground-light-default;
+		$foreground_dark  = ( ! empty( $colors_array ) && $colors_array['colors']['txt'] != '#303030' ) ? $colors_array['colors']['txt'] : '#101010';  // $config-global--color-foreground-dark-default;
 
 		// Editor color palette.
 		add_theme_support(
@@ -78,15 +80,25 @@ if ( ! function_exists( 'balasana_setup' ) ) :
 					'slug'  => 'secondary',
 					'color' => $secondary,
 				),
+				array(
+					'name'  => __( 'Background', 'balasana' ),
+					'slug'  => 'background',
+					'color' => $background,
+				),
 				array(
 					'name'  => __( 'Foreground', 'balasana' ),
 					'slug'  => 'foreground',
 					'color' => $foreground,
 				),
 				array(
-					'name'  => __( 'Background', 'balasana' ),
-					'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,
 				),
 			)
 		);
@@ -184,5 +196,15 @@ function balasana_editor_styles() {
 
 	// Enqueue Google fonts in the editor
 	wp_enqueue_style( 'balasana-editor-fonts', balasana_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'] != '#394d55' ) { // $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', 'balasana_editor_styles' );