Ticket #45928: 45928.5.diff
File 45928.5.diff, 10.1 KB (added by , 4 years ago) |
---|
-
src/wp-content/themes/twentynineteen/functions.php
diff --git a/src/wp-content/themes/twentynineteen/functions.php b/src/wp-content/themes/twentynineteen/functions.php index 901aa29990..8c941807c4 100644
a b if ( ! function_exists( 'twentynineteen_setup' ) ) : 138 138 ) 139 139 ); 140 140 141 $default_hue = twentynineteen_get_default_hue(); 142 $saturation = apply_filters( 'twentynineteen_custom_colors_saturation', 100 ); 143 $lightness = apply_filters( 'twentynineteen_custom_colors_lightness', 33 ); 144 $lightness_hover = apply_filters( 'twentynineteen_custom_colors_lightness_hover', 23 ); 145 141 146 // Editor color palette. 142 147 add_theme_support( 143 148 'editor-color-palette', … … if ( ! function_exists( 'twentynineteen_setup' ) ) : 145 150 array( 146 151 'name' => 'default' === get_theme_mod( 'primary_color' ) ? __( 'Blue', 'twentynineteen' ) : null, 147 152 'slug' => 'primary', 148 'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? 199 : get_theme_mod( 'primary_color_hue', 199 ), 100, 33),153 'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? $default_hue : get_theme_mod( 'primary_color_hue', $default_hue ), $saturation, $lightness ), 149 154 ), 150 155 array( 151 156 'name' => 'default' === get_theme_mod( 'primary_color' ) ? __( 'Dark Blue', 'twentynineteen' ) : null, 152 157 'slug' => 'secondary', 153 'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? 199 : get_theme_mod( 'primary_color_hue', 199 ), 100, 23 ),158 'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? $default_hue : get_theme_mod( 'primary_color_hue', $default_hue ), $saturation, 23 ), 154 159 ), 155 160 array( 156 161 'name' => __( 'Dark Gray', 'twentynineteen' ), … … function twentynineteen_colors_css_wrap() { 279 284 280 285 require_once get_parent_theme_file_path( '/inc/color-patterns.php' ); 281 286 282 $primary_color = 199;287 $primary_color = twentynineteen_get_default_hue(); 283 288 if ( 'default' !== get_theme_mod( 'primary_color', 'default' ) ) { 284 $primary_color = get_theme_mod( 'primary_color_hue', 199);289 $primary_color = get_theme_mod( 'primary_color_hue', $primary_color ); 285 290 } 286 291 ?> 287 292 … … function twentynineteen_colors_css_wrap() { 292 297 } 293 298 add_action( 'wp_head', 'twentynineteen_colors_css_wrap' ); 294 299 300 /** 301 * Default color filters. 302 */ 303 require get_template_directory() . '/inc/color-filters.php'; 304 295 305 /** 296 306 * SVG Icons class. 297 307 */ -
new file src/wp-content/themes/twentynineteen/inc/color-filters.php
diff --git a/src/wp-content/themes/twentynineteen/inc/color-filters.php b/src/wp-content/themes/twentynineteen/inc/color-filters.php new file mode 100644 index 0000000000..e83479c870
- + 1 <?php 2 /** 3 * Twenty Nineteen: Color Filter for overriding the colors schemes in a child theme 4 * 5 * @package WordPress 6 * @subpackage TwentyNineteen 7 * @since 1.0 8 */ 9 10 /** 11 * Define default color filters. 12 */ 13 14 define( 'TWENTYNINETEEN_DEFAULT_HUE', 199 ); // H 15 define( 'TWENTYNINETEEN_DEFAULT_SATURATION', 100 ); // S 16 define( 'TWENTYNINETEEN_DEFAULT_LIGHTNESS', 33 ); // L 17 18 define( 'TWENTYNINETEEN_DEFAULT_SATURATION_SELECTION', 50 ); 19 define( 'TWENTYNINETEEN_DEFAULT_LIGHTNESS_SELECTION', 90 ); 20 define( 'TWENTYNINETEEN_DEFAULT_LIGHTNESS_HOVER', 23 ); 21 22 /** 23 * The default hue (as in hsl) used for the primary color throughout this theme 24 * 25 * @return number the default hue 26 */ 27 function twentynineteen_get_default_hue() { 28 return apply_filters( 'twentynineteen_default_hue', TWENTYNINETEEN_DEFAULT_HUE ); 29 } 30 31 /** 32 * The default saturation (as in hsl) used for the primary color throughout this theme 33 * 34 * @return number the default saturation 35 */ 36 function twentynineteen_get_default_saturation() { 37 return apply_filters( 'twentynineteen_default_saturation', TWENTYNINETEEN_DEFAULT_SATURATION ); 38 } 39 40 /** 41 * The default lightness (as in hsl) used for the primary color throughout this theme 42 * 43 * @return number the default lightness 44 */ 45 function twentynineteen_get_default_lightness() { 46 return apply_filters( 'twentynineteen_default_lightness', TWENTYNINETEEN_DEFAULT_LIGHTNESS ); 47 } 48 49 /** 50 * The default saturation (as in hsl) used when selecting text throughout this theme 51 * 52 * @return number the default saturation selection 53 */ 54 function twentynineteen_get_default_saturation_selection() { 55 return apply_filters( 'twentynineteen_default_saturation_selection', TWENTYNINETEEN_DEFAULT_SATURATION_SELECTION ); 56 } 57 58 /** 59 * The default lightness (as in hsl) used when selecting text throughout this theme 60 * 61 * @return number the default lightness selection 62 */ 63 function twentynineteen_get_default_lightness_selection() { 64 return apply_filters( 'twentynineteen_default_lightness_selection', TWENTYNINETEEN_DEFAULT_LIGHTNESS_SELECTION ); 65 } 66 67 /** 68 * The default lightness hover (as in hsl) used when hovering over links throughout this theme 69 * 70 * @return number the default lightness hover 71 */ 72 function twentynineteen_get_default_lightness_hover() { 73 return apply_filters( 'twentynineteen_default_lightness_hover', TWENTYNINETEEN_DEFAULT_LIGHTNESS_HOVER ); 74 } 75 76 function twentynineteen_has_custom_default_hue() { 77 return twentynineteen_get_default_hue() !== TWENTYNINETEEN_DEFAULT_HUE; 78 } -
src/wp-content/themes/twentynineteen/inc/color-patterns.php
diff --git a/src/wp-content/themes/twentynineteen/inc/color-patterns.php b/src/wp-content/themes/twentynineteen/inc/color-patterns.php index c16c1d6a49..4813c09d50 100644
a b 12 12 */ 13 13 function twentynineteen_custom_colors_css() { 14 14 15 $primary_color = 199;15 $primary_color = twentynineteen_get_default_hue(); 16 16 if ( 'default' !== get_theme_mod( 'primary_color', 'default' ) ) { 17 $primary_color = absint( get_theme_mod( 'primary_color_hue', 199) );17 $primary_color = absint( get_theme_mod( 'primary_color_hue', $primary_color ) ); 18 18 } 19 19 20 20 /** … … function twentynineteen_custom_colors_css() { 24 24 * 25 25 * @param int $saturation Color saturation level. 26 26 */ 27 $saturation = apply_filters( 'twentynineteen_custom_colors_saturation', 100);27 $saturation = twentynineteen_get_default_saturation(); 28 28 $saturation = absint( $saturation ) . '%'; 29 29 30 30 /** … … function twentynineteen_custom_colors_css() { 34 34 * 35 35 * @param int $saturation_selection Selection color saturation level. 36 36 */ 37 $saturation_selection = absint( apply_filters( 'twentynineteen_custom_colors_saturation_selection', 50 ));38 $saturation_selection = $saturation_selection. '%';37 $saturation_selection = twentynineteen_get_default_saturation_selection(); 38 $saturation_selection = absint( $saturation_selection ) . '%'; 39 39 40 40 /** 41 41 * Filter Twenty Nineteen default lightness level. … … function twentynineteen_custom_colors_css() { 44 44 * 45 45 * @param int $lightness Color lightness level. 46 46 */ 47 $lightness = apply_filters( 'twentynineteen_custom_colors_lightness', 33);47 $lightness = twentynineteen_get_default_lightness(); 48 48 $lightness = absint( $lightness ) . '%'; 49 49 50 50 /** … … function twentynineteen_custom_colors_css() { 54 54 * 55 55 * @param int $lightness_hover Hover color lightness level. 56 56 */ 57 $lightness_hover = apply_filters( 'twentynineteen_custom_colors_lightness_hover', 23);57 $lightness_hover = twentynineteen_get_default_lightness_hover(); 58 58 $lightness_hover = absint( $lightness_hover ) . '%'; 59 59 60 60 /** … … function twentynineteen_custom_colors_css() { 64 64 * 65 65 * @param int $lightness_selection Selection color lightness level. 66 66 */ 67 $lightness_selection = apply_filters( 'twentynineteen_custom_colors_lightness_selection', 90);67 $lightness_selection = twentynineteen_get_default_lightness_selection(); 68 68 $lightness_selection = absint( $lightness_selection ) . '%'; 69 69 70 70 $theme_css = ' -
src/wp-content/themes/twentynineteen/inc/customizer.php
diff --git a/src/wp-content/themes/twentynineteen/inc/customizer.php b/src/wp-content/themes/twentynineteen/inc/customizer.php index b0a784e930..c979e441c9 100644
a b function twentynineteen_customize_register( $wp_customize ) { 64 64 $wp_customize->add_setting( 65 65 'primary_color_hue', 66 66 array( 67 'default' => 199,67 'default' => twentynineteen_get_default_hue(), 68 68 'transport' => 'postMessage', 69 69 'sanitize_callback' => 'absint', 70 70 ) … … function twentynineteen_customize_partial_blogdescription() { 125 125 * Bind JS handlers to instantly live-preview changes. 126 126 */ 127 127 function twentynineteen_customize_preview_js() { 128 wp_enqueue_script( 'twentynineteen-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20181214', true ); 128 wp_enqueue_script( 'twentynineteen-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20181214', true );wp_localize_script( 129 'twentynineteen-customize-preview', 130 '_TwentyNineteenPreviewData', 131 array( 132 'default_hue' => twentynineteen_get_default_hue(), 133 ) 134 ); 129 135 } 130 136 add_action( 'customize_preview_init', 'twentynineteen_customize_preview_js' ); 131 137 -
src/wp-content/themes/twentynineteen/js/customize-preview.js
diff --git a/src/wp-content/themes/twentynineteen/js/customize-preview.js b/src/wp-content/themes/twentynineteen/js/customize-preview.js index 91b91f3e0c..429105d0a6 100644
a b 1 /* global _TwentyNineteenPreviewData */ 1 2 /** 2 3 * File customize-preview.js. 3 4 * … … 17 18 css = style.html(), 18 19 color; 19 20 20 if ( 'custom' === to ){21 if ( 'custom' === to ) { 21 22 // If a custom primary color is selected, use the currently set primary_color_hue 22 23 color = wp.customize.get().primary_color_hue; 23 24 } else { 24 25 // If the "default" option is selected, get the default primary_color_hue 25 color = 199;26 color = _TwentyNineteenPreviewData.default_hue; 26 27 } 27 28 28 29 // Equivalent to css.replaceAll, with hue followed by comma to prevent values with units from being changed.