Make WordPress Core

Ticket #45424: 45424.6.patch

File 45424.6.patch, 3.3 KB (added by allancole, 6 years ago)

Properly set primary color hue theme option. Props richtabor. More info: https://github.com/WordPress/twentynineteen/pull/683

  • src/wp-content/themes/twentynineteen/inc/color-patterns.php

     
    1212 */
    1313function twentynineteen_custom_colors_css() {
    1414
    15         if ( 'default' === get_theme_mod( 'primary_color', 'default' ) ) {
    16                 $primary_color = 199;
    17         } else {
     15        $primary_color = 199;
     16        if ( 'default' !== get_theme_mod( 'primary_color', 'default' ) ) {
    1817                $primary_color = absint( get_theme_mod( 'primary_color_hue', 199 ) );
    1918        }
    2019
     
    2524         *
    2625         * @param int $saturation Color saturation level.
    2726         */
     27        $saturation = apply_filters( 'twentynineteen_custom_colors_saturation', 100 );
     28        $saturation = absint( $saturation ) . '%';
    2829
    29         $saturation           = absint( apply_filters( 'twentynineteen_custom_colors_saturation', 100 ) );
    30         $saturation           = $saturation . '%';
    31 
     30        /**
     31         * Filter Twenty Nineteen default selection saturation level.
     32         *
     33         * @since Twenty Nineteen 1.0
     34         *
     35         * @param int $saturation_selection Selection color saturation level.
     36         */
    3237        $saturation_selection = absint( apply_filters( 'twentynineteen_custom_colors_saturation_selection', 50 ) );
    3338        $saturation_selection = $saturation_selection . '%';
    3439
    35         $lightness            = absint( apply_filters( 'twentynineteen_custom_colors_lightness', 33 ) );
    36         $lightness            = $lightness . '%';
     40        /**
     41         * Filter Twenty Nineteen default lightness level.
     42         *
     43         * @since Twenty Nineteen 1.0
     44         *
     45         * @param int $lightness Color lightness level.
     46         */
     47        $lightness = apply_filters( 'twentynineteen_custom_colors_lightness', 33 );
     48        $lightness = absint( $lightness ) . '%';
    3749
    38         $lightness_hover      = absint( apply_filters( 'twentynineteen_custom_colors_lightness_hover', 23 ) );
    39         $lightness_hover      = $lightness_hover . '%';
     50        /**
     51         * Filter Twenty Nineteen default hover lightness level.
     52         *
     53         * @since Twenty Nineteen 1.0
     54         *
     55         * @param int $lightness_hover Hover color lightness level.
     56         */
     57        $lightness_hover = apply_filters( 'twentynineteen_custom_colors_lightness_hover', 23 );
     58        $lightness_hover = absint( $lightness_hover ) . '%';
    4059
    41         $lightness_selection  = absint( apply_filters( 'twentynineteen_custom_colors_lightness_selection', 90 ) );
    42         $lightness_selection  = $lightness_selection . '%';
     60        /**
     61         * Filter Twenty Nineteen default selection lightness level.
     62         *
     63         * @since Twenty Nineteen 1.0
     64         *
     65         * @param int $lightness_selection Selection color lightness level.
     66         */
     67        $lightness_selection = apply_filters( 'twentynineteen_custom_colors_lightness_selection', 90 );
     68        $lightness_selection = absint( $lightness_selection ) . '%';
    4369
    4470        $theme_css = '
    4571                /*
     
    233259                        color: inherit;
    234260                }
    235261                ';
    236         $css = '';
     262
    237263        if ( function_exists( 'register_block_type' ) && is_admin() ) {
    238                 $css .= $editor_css;
    239         } else if ( ! is_admin() ) {
    240                 $css = $theme_css;
     264                $theme_css = $editor_css;
    241265        }
    242266
    243267        /**
     
    249273         * @param int    $primary_color The user's selected color hue.
    250274         * @param string $saturation    Filtered theme color saturation level.
    251275         */
    252         return apply_filters( 'twentynineteen_custom_colors_css', $css, $primary_color, $saturation );
     276        return apply_filters( 'twentynineteen_custom_colors_css', $theme_css, $primary_color, $saturation );
    253277}