Browse Source

Merge pull request #1081 from Automattic/fix/_dsgnsystm-remove-customizer-color-settings

_dsgnsystm: Removing color options and dependencies
Thomas Guillot 6 years ago
parent
commit
f2adf8500c

+ 0 - 45
_dsgnsystm/functions.php

@@ -274,51 +274,6 @@ function _dsgnsystm_editor_content_width() {
 }
 add_action( 'enqueue_block_editor_assets', '_dsgnsystm_editor_content_width' );
 
-/**
- * Enqueue supplemental block editor styles.
- */
-function _dsgnsystm_editor_customizer_styles() {
-
-	wp_enqueue_style( '_dsgnsystm-editor-customizer-styles', get_theme_file_uri( '/style-editor-customizer.css' ), false, wp_get_theme()->get( 'Version' ), 'all' );
-
-	if ( 'custom' === get_theme_mod( 'primary_color' ) ) {
-		// Include color patterns.
-		require_once get_parent_theme_file_path( '/inc/color-patterns.php' );
-		wp_add_inline_style( '_dsgnsystm-editor-customizer-styles', _dsgnsystm_custom_colors_css() );
-	}
-}
-// add_action( 'enqueue_block_editor_assets', '_dsgnsystm_editor_customizer_styles' );
-
-/**
- * Display custom color CSS in customizer and on frontend.
- */
-function _dsgnsystm_colors_css_wrap() {
-
-	// Only bother if we haven't customized the color.
-	if ( ( ! is_customize_preview() && 'default' === get_theme_mod( 'primary_color', 'default' ) ) || is_admin() ) {
-		return;
-	}
-
-	require_once get_parent_theme_file_path( '/inc/color-patterns.php' );
-
-	$primary_color = _dsgnsystm_get_default_hue();
-	if ( 'default' !== get_theme_mod( 'primary_color', 'default' ) ) {
-		$primary_color = get_theme_mod( 'primary_color_hue', $primary_color );
-	}
-	?>
-
-	<style type="text/css" id="custom-theme-colors" <?php echo is_customize_preview() ? 'data-hue="' . absint( $primary_color ) . '"' : ''; ?>>
-		<?php echo _dsgnsystm_custom_colors_css(); ?>
-	</style>
-	<?php
-}
-// add_action( 'wp_head', '_dsgnsystm_colors_css_wrap' );
-
-/**
- * Default color filters.
- */
-require get_template_directory() . '/inc/color-filters.php';
-
 /**
  * SVG Icons class.
  */

+ 0 - 78
_dsgnsystm/inc/color-filters.php

@@ -1,78 +0,0 @@
-<?php
-/**
- * _Dsgnsystm: Color Filter for overriding the colors schemes in a child theme
- *
- * @package WordPress
- * @subpackage TwentyNineteen
- * @since 1.0
- */
-
-/**
- * Define default color filters.
- */
-
-define( '_DSGNSYSTM_DEFAULT_HUE', 199 );        // H
-define( '_DSGNSYSTM_DEFAULT_SATURATION', 100 ); // S
-define( '_DSGNSYSTM_DEFAULT_LIGHTNESS', 33 );   // L
-
-define( '_DSGNSYSTM_DEFAULT_SATURATION_SELECTION', 50 );
-define( '_DSGNSYSTM_DEFAULT_LIGHTNESS_SELECTION', 90 );
-define( '_DSGNSYSTM_DEFAULT_LIGHTNESS_HOVER', 23 );
-
-/**
- * The default hue (as in hsl) used for the primary color throughout this theme
- *
- * @return number the default hue
- */
-function _dsgnsystm_get_default_hue() {
-	return apply_filters( '_dsgnsystm_default_hue', _DSGNSYSTM_DEFAULT_HUE );
-}
-
-/**
- * The default saturation (as in hsl) used for the primary color throughout this theme
- *
- * @return number the default saturation
- */
-function _dsgnsystm_get_default_saturation() {
-	return apply_filters( '_dsgnsystm_default_saturation', _DSGNSYSTM_DEFAULT_SATURATION );
-}
-
-/**
- * The default lightness (as in hsl) used for the primary color throughout this theme
- *
- * @return number the default lightness
- */
-function _dsgnsystm_get_default_lightness() {
-	return apply_filters( '_dsgnsystm_default_lightness', _DSGNSYSTM_DEFAULT_LIGHTNESS );
-}
-
-/**
- * The default saturation (as in hsl) used when selecting text throughout this theme
- *
- * @return number the default saturation selection
- */
-function _dsgnsystm_get_default_saturation_selection() {
-	return apply_filters( '_dsgnsystm_default_saturation_selection', _DSGNSYSTM_DEFAULT_SATURATION_SELECTION );
-}
-
-/**
- * The default lightness (as in hsl) used when selecting text throughout this theme
- *
- * @return number the default lightness selection
- */
-function _dsgnsystm_get_default_lightness_selection() {
-	return apply_filters( '_dsgnsystm_default_lightness_selection', _DSGNSYSTM_DEFAULT_LIGHTNESS_SELECTION );
-}
-
-/**
- * The default lightness hover (as in hsl) used when hovering over links throughout this theme
- *
- * @return number the default lightness hover
- */
-function _dsgnsystm_get_default_lightness_hover() {
-	return apply_filters( '_dsgnsystm_default_lightness_hover', _DSGNSYSTM_DEFAULT_LIGHTNESS_HOVER );
-}
-
-function _dsgnsystm_has_custom_default_hue() {
-	return _dsgnsystm_get_default_hue() !== _DSGNSYSTM_DEFAULT_HUE;
-}

+ 0 - 108
_dsgnsystm/inc/color-patterns.php

@@ -1,108 +0,0 @@
-<?php
-/**
- * _Dsgnsystm: Color Patterns
- *
- * @package WordPress
- * @subpackage TwentyNineteen
- * @since 1.0
- */
-
-/**
- * Generate the CSS for the current primary color.
- */
-function _dsgnsystm_custom_colors_css() {
-
-	$primary_color = _dsgnsystm_get_default_hue();
-	if ( 'default' !== get_theme_mod( 'primary_color', 'default' ) ) {
-		$primary_color = absint( get_theme_mod( 'primary_color_hue', $primary_color ) );
-	}
-
-	/**
-	 * Filter _Dsgnsystm default saturation level.
-	 *
-	 * @since _Dsgnsystm 1.0
-	 *
-	 * @param int $saturation Color saturation level.
-	 */
-	$saturation = _dsgnsystm_get_default_saturation();
-	$saturation = absint( $saturation ) . '%';
-
-	/**
-	 * Filter _Dsgnsystm default selection saturation level.
-	 *
-	 * @since _Dsgnsystm 1.0
-	 *
-	 * @param int $saturation_selection Selection color saturation level.
-	 */
-	$saturation_selection = _dsgnsystm_get_default_saturation_selection();
-	$saturation_selection = absint( $saturation_selection ) . '%';
-
-	/**
-	 * Filter _Dsgnsystm default lightness level.
-	 *
-	 * @since _Dsgnsystm 1.0
-	 *
-	 * @param int $lightness Color lightness level.
-	 */
-	$lightness = _dsgnsystm_get_default_lightness();
-	$lightness = absint( $lightness ) . '%';
-
-	/**
-	 * Filter _Dsgnsystm default hover lightness level.
-	 *
-	 * @since _Dsgnsystm 1.0
-	 *
-	 * @param int $lightness_hover Hover color lightness level.
-	 */
-	$lightness_hover = _dsgnsystm_get_default_lightness_hover();
-	$lightness_hover = absint( $lightness_hover ) . '%';
-
-	/**
-	 * Filter _Dsgnsystm default selection lightness level.
-	 *
-	 * @since _Dsgnsystm 1.0
-	 *
-	 * @param int $lightness_selection Selection color lightness level.
-	 */
-	$lightness_selection = _dsgnsystm_get_default_lightness_selection();
-	$lightness_selection = absint( $lightness_selection ) . '%';
-
-	$theme_css = '
-		/*
-		 * Reset color variables:
-		 */
-		:root {
-			--global--color-primary: hsl( ' . $primary_color . ', ' . $saturation . ', ' . $lightness . ' );
-			--global--color-primary-hover: hsl( ' . $primary_color . ', ' . $saturation . ', ' . $lightness_hover . ' );
-			--global--color-secondary: var(--global--color-primary);
-			--global--color-secondary-hover: var(--global--color-primary-hover);
-			--global--color-text-selection: hsl( ' . $primary_color . ', ' . $saturation_selection . ', ' . $lightness_selection . ' );
-		}';
-
-	$editor_css = '
-		/*
-		 * Reset color variables:
-		 */
-		:root {
-			--global--color-primary: hsl( ' . $primary_color . ', ' . $saturation . ', ' . $lightness . ' );
-			--global--color-primary-hover: hsl( ' . $primary_color . ', ' . $saturation . ', ' . $lightness_hover . ' );
-			--global--color-secondary: var(--global--color-primary);
-			--global--color-secondary-hover: var(--global--color-primary-hover);
-			--global--color-text-selection: hsl( ' . $primary_color . ', ' . $saturation_selection . ', ' . $lightness_selection . ' );
-		}';
-
-	if ( function_exists( 'register_block_type' ) && is_admin() ) {
-		$theme_css = $editor_css;
-	}
-
-	/**
-	 * Filters _Dsgnsystm custom colors CSS.
-	 *
-	 * @since _Dsgnsystm 1.0
-	 *
-	 * @param string $css           Base theme colors CSS.
-	 * @param int    $primary_color The user's selected color hue.
-	 * @param string $saturation    Filtered theme color saturation level.
-	 */
-	return apply_filters( '_dsgnsystm_custom_colors_css', $theme_css, $primary_color, $saturation );
-}

+ 0 - 81
_dsgnsystm/inc/template-functions.php

@@ -255,84 +255,3 @@ function _dsgnsystm_add_mobile_parent_nav_menu_items( $sorted_menu_items, $args
 	return $amended_menu_items;
 }
 // add_filter( 'wp_nav_menu_objects', '_dsgnsystm_add_mobile_parent_nav_menu_items', 10, 2 );
-
-/**
- * Convert HSL to HEX colors
- */
-function _dsgnsystm_hsl_hex( $h, $s, $l, $to_hex = true ) {
-
-	$h /= 360;
-	$s /= 100;
-	$l /= 100;
-
-	$r = $l;
-	$g = $l;
-	$b = $l;
-	$v = ( $l <= 0.5 ) ? ( $l * ( 1.0 + $s ) ) : ( $l + $s - $l * $s );
-	if ( $v > 0 ) {
-		$m;
-		$sv;
-		$sextant;
-		$fract;
-		$vsf;
-		$mid1;
-		$mid2;
-
-		$m       = $l + $l - $v;
-		$sv      = ( $v - $m ) / $v;
-		$h      *= 6.0;
-		$sextant = floor( $h );
-		$fract   = $h - $sextant;
-		$vsf     = $v * $sv * $fract;
-		$mid1    = $m + $vsf;
-		$mid2    = $v - $vsf;
-
-		switch ( $sextant ) {
-			case 0:
-				$r = $v;
-				$g = $mid1;
-				$b = $m;
-				break;
-			case 1:
-				$r = $mid2;
-				$g = $v;
-				$b = $m;
-				break;
-			case 2:
-				$r = $m;
-				$g = $v;
-				$b = $mid1;
-				break;
-			case 3:
-				$r = $m;
-				$g = $mid2;
-				$b = $v;
-				break;
-			case 4:
-				$r = $mid1;
-				$g = $m;
-				$b = $v;
-				break;
-			case 5:
-				$r = $v;
-				$g = $m;
-				$b = $mid2;
-				break;
-		}
-	}
-	$r = round( $r * 255, 0 );
-	$g = round( $g * 255, 0 );
-	$b = round( $b * 255, 0 );
-
-	if ( $to_hex ) {
-
-		$r = ( $r < 15 ) ? '0' . dechex( $r ) : dechex( $r );
-		$g = ( $g < 15 ) ? '0' . dechex( $g ) : dechex( $g );
-		$b = ( $b < 15 ) ? '0' . dechex( $b ) : dechex( $b );
-
-		return "#$r$g$b";
-
-	}
-
-	return "rgb($r, $g, $b)";
-}