Ticket #45928: 45928.2.patch
File 45928.2.patch, 9.4 KB (added by , 6 years ago) |
---|
-
src/wp-content/themes/twentynineteen/functions.php
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 ); 141 145 // Editor color palette. 142 146 add_theme_support( 143 147 'editor-color-palette', … … 145 149 array( 146 150 'name' => __( 'Primary', 'twentynineteen' ), 147 151 'slug' => 'primary', 148 'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? 199 : get_theme_mod( 'primary_color_hue', 199 ), 100, 33),152 'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? $default_hue : get_theme_mod( 'primary_color_hue', $default_hue ), $saturation, $lightness ), 149 153 ), 150 154 array( 151 155 'name' => __( 'Secondary', 'twentynineteen' ), 152 156 'slug' => 'secondary', 153 'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? 199 : get_theme_mod( 'primary_color_hue', 199 ), 100, 23 ),157 'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? $default_hue : get_theme_mod( 'primary_color_hue', $default_hue ), $saturation, 23 ), 154 158 ), 155 159 array( 156 160 'name' => __( 'Dark Gray', 'twentynineteen' ), … … 272 276 */ 273 277 function twentynineteen_colors_css_wrap() { 274 278 275 // Only include custom colors in customizer or frontend.276 if ( ( ! is_customize_preview() && 'default' === get_theme_mod( 'primary_color', 'default' ) ) || is_admin() ) {279 // Only bother if we haven't customized the color. 280 if ( 'default' === get_theme_mod( 'primary_color', 'default' ) && ! twentynineteen_has_custom_default_hue() ) { 277 281 return; 278 282 } 279 283 280 284 require_once get_parent_theme_file_path( '/inc/color-patterns.php' ); 281 285 282 $primary_color = 199;286 $primary_color = twentynineteen_get_default_hue(); 283 287 if ( 'default' !== get_theme_mod( 'primary_color', 'default' ) ) { 284 $primary_color = get_theme_mod( 'primary_color_hue', 199);288 $primary_color = get_theme_mod( 'primary_color_hue', $primary_color ); 285 289 } 286 290 ?> 287 291 … … 293 297 add_action( 'wp_head', 'twentynineteen_colors_css_wrap' ); 294 298 295 299 /** 300 * Default color filters. 301 */ 302 require get_template_directory() . '/inc/color-filters.php'; 303 304 /** 296 305 * SVG Icons class. 297 306 */ 298 307 require get_template_directory() . '/classes/class-twentynineteen-svg-icons.php'; -
src/wp-content/themes/twentynineteen/inc/color-filters.php
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
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 /** … … 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 /** … … 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. … … 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 /** … … 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 /** … … 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
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 ) … … 126 126 */ 127 127 function twentynineteen_customize_preview_js() { 128 128 wp_enqueue_script( 'twentynineteen-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20181231', true ); 129 wp_localize_script( 'twentynineteen-customize-preview', '_TwentyNineteenPreviewData', array( 130 'default_hue' => twentynineteen_get_default_hue() 131 )); 129 132 } 130 133 add_action( 'customize_preview_init', 'twentynineteen_customize_preview_js' ); 131 134 -
src/wp-content/themes/twentynineteen/js/customize-preview.js
22 22 color = wp.customize.get().primary_color_hue; 23 23 } else { 24 24 // If the "default" option is selected, get the default primary_color_hue 25 color = 199;25 color = _TwentyNineteenPreviewData.default_hue; 26 26 } 27 27 28 28 // Equivalent to css.replaceAll, with hue followed by comma to prevent values with units from being changed.