Ticket #49711: 49711.2.patch
File 49711.2.patch, 6.7 KB (added by , 3 years ago) |
---|
-
wp-content/themes/twentytwenty/functions.php
diff --git wp-content/themes/twentytwenty/functions.php wp-content/themes/twentytwenty/functions.php index ce1e2a6..2b5c9fb 100644
function twentytwenty_theme_support() { 132 132 // Add theme support for selective refresh for widgets. 133 133 add_theme_support( 'customize-selective-refresh-widgets' ); 134 134 135 // Hex to RGB Function needed for gradient colors 136 function hex2rgb( $colour ) { 137 if ( $colour[0] == '#' ) { 138 $colour = substr( $colour, 1 ); 139 } 140 if ( strlen( $colour ) == 6 ) { 141 list( $r, $g, $b ) = array( $colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5] ); 142 } elseif ( strlen( $colour ) == 3 ) { 143 list( $r, $g, $b ) = array( $colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2] ); 144 } else { 145 return false; 146 } 147 $r = hexdec( $r ); 148 $g = hexdec( $g ); 149 $b = hexdec( $b ); 150 151 return array( 'red' => $r, 'green' => $g, 'blue' => $b ); 152 } 153 //Convert the HEX gradient colors to RGB 154 $primaryRGB = hex2rgb(sanitize_hex_color(twentytwenty_get_color_for_area( 'content', 'text' ))); 155 $secondaryRGB = hex2rgb(sanitize_hex_color(twentytwenty_get_color_for_area( 'content', 'secondary' ))); 156 $accentRGB = hex2rgb(sanitize_hex_color(twentytwenty_get_color_for_area( 'content', 'accent' ))); 157 $subtleBackgroundRGB = hex2rgb(sanitize_hex_color(twentytwenty_get_color_for_area( 'content', 'borders' ))); 158 159 $backgroundRGB = get_theme_mod( 'background_color' ); 160 if ( ! $backgroundRGB ) { 161 $background_color_arr = get_theme_support( 'custom-background' ); 162 $backgroundRGB = $background_color_arr[0]['default-color']; 163 } 164 $backgroundRGB = hex2rgb(sanitize_hex_color_no_hash($backgroundRGB)); 165 166 // Add theme support for block gradient colours. 167 add_theme_support( 168 'editor-gradient-presets', 169 array( 170 array( 171 'name' => __( 'primary to accent', 'twentytwenty' ), 172 'gradient' => 'linear-gradient(135deg, rgba('.$primaryRGB['red'].','.$primaryRGB['green'].','.$primaryRGB['blue'].', 1) 0%, rgba('.$accentRGB['red'].','.$accentRGB['green'].','.$accentRGB['blue'].', 1) 100%)', 173 'slug' => 'primary-to-accent' 174 ), 175 array( 176 'name' => __( 'accent to primary', 'twentytwenty' ), 177 'gradient' => 'linear-gradient(135deg, rgba('.$accentRGB['red'].','.$accentRGB['green'].','.$accentRGB['blue'].', 1) 0%, rgba('.$primaryRGB['red'].','.$primaryRGB['green'].','.$primaryRGB['blue'].', 1) 100%)', 178 'slug' => 'accent-to-primary', 179 ), 180 array( 181 'name' => __( 'background to accent to primary', 'twentytwenty' ), 182 'gradient' => 'linear-gradient(135deg, rgba('.$backgroundRGB['red'].','.$backgroundRGB['green'].','.$backgroundRGB['blue'].', 1) 0%, rgba('.$accentRGB['red'].','.$accentRGB['green'].','.$accentRGB['blue'].', 1) 50%, rgba('.$primaryRGB['red'].','.$primaryRGB['green'].','.$primaryRGB['blue'].', 1) 100%)', 183 'slug' => 'background-to-accent-to-primary', 184 ), 185 array( 186 'name' => __( 'primary to secondary', 'twentytwenty' ), 187 'gradient' => 'linear-gradient(135deg, rgba('.$primaryRGB['red'].','.$primaryRGB['green'].','.$primaryRGB['blue'].', 1) 0%, rgba('.$secondaryRGB['red'].','.$secondaryRGB['green'].','.$secondaryRGB['blue'].', 1) 100%)', 188 'slug' => 'primary-to-secondary', 189 ), 190 array( 191 'name' => __( 'secondary to subtle background', 'twentytwenty' ), 192 'gradient' => 'linear-gradient(135deg, rgba('.$secondaryRGB['red'].','.$secondaryRGB['green'].','.$secondaryRGB['blue'].', 1) 0%, rgba('.$subtleBackgroundRGB['red'].','.$subtleBackgroundRGB['green'].','.$subtleBackgroundRGB['blue'].', 1) 100%)', 193 'slug' => 'secondary-to-subtle-background', 194 ) 195 ) 196 ); 197 135 198 /* 136 199 * Adds `async` and `defer` support for scripts registered or enqueued 137 200 * by the theme. -
wp-content/themes/twentytwenty/inc/custom-css.php
diff --git wp-content/themes/twentytwenty/inc/custom-css.php wp-content/themes/twentytwenty/inc/custom-css.php index a1c560d..4797fde 100644
if ( ! function_exists( 'twentytwenty_get_customizer_css' ) ) { 76 76 $background = sanitize_hex_color_no_hash( get_theme_mod( 'background_color' ) ); 77 77 $background_default = 'f5efe0'; 78 78 79 // RGB colors for gradients. 80 $primaryRGB = hex2rgb(!empty($body) ? $body : $body_default); 81 $secondaryRGB = hex2rgb(!empty($secondary) ? $secondary : $secondary_default); 82 $accentRGB = hex2rgb(!empty($accent) ? $accent : $accent_default); 83 $subtleBackgroundRGB = hex2rgb(!empty($borders) ? $borders : $borders_default); 84 $backgroundRGB = hex2rgb(!empty($background) ? $background : $background_default); 85 79 86 ob_start(); 80 87 81 88 /** … … if ( ! function_exists( 'twentytwenty_get_customizer_css' ) ) { 116 123 twentytwenty_generate_css( '.cover-header .entry-header *', 'color', $cover ); 117 124 } 118 125 126 //Add Gradient colors for blocks 127 twentytwenty_generate_css( '.has-primary-to-accent-gradient-background', 'background', 'linear-gradient(135deg, rgba('.$primaryRGB['red'].','.$primaryRGB['green'].','.$primaryRGB['blue'].', 1) 0%, rgba('.$accentRGB['red'].','.$accentRGB['green'].','.$accentRGB['blue'].', 1) 100%)' ); 128 twentytwenty_generate_css( '.has-accent-to-primary-gradient-background', 'background', 'linear-gradient(135deg, rgba('.$accentRGB['red'].','.$accentRGB['green'].','.$accentRGB['blue'].', 1) 0%, rgba('.$primaryRGB['red'].','.$primaryRGB['green'].','.$primaryRGB['blue'].', 1) 100%)' ); 129 twentytwenty_generate_css( '.has-background-to-accent-to-primary-gradient-background', 'background', 'linear-gradient(135deg, rgba('.$backgroundRGB['red'].','.$backgroundRGB['green'].','.$backgroundRGB['blue'].', 1) 0%, rgba('.$accentRGB['red'].','.$accentRGB['green'].','.$accentRGB['blue'].', 1) 50%, rgba('.$primaryRGB['red'].','.$primaryRGB['green'].','.$primaryRGB['blue'].', 1) 100%)' ); 130 twentytwenty_generate_css( '.has-primary-to-secondary-gradient-background', 'background', 'linear-gradient(135deg, rgba('.$primaryRGB['red'].','.$primaryRGB['green'].','.$primaryRGB['blue'].', 1) 0%, rgba('.$secondaryRGB['red'].','.$secondaryRGB['green'].','.$secondaryRGB['blue'].', 1) 100%)' ); 131 twentytwenty_generate_css( '.has-secondary-to-subtle-background-gradient-background', 'background', 'linear-gradient(135deg, rgba('.$secondaryRGB['red'].','.$secondaryRGB['green'].','.$secondaryRGB['blue'].', 1) 0%, rgba('.$subtleBackgroundRGB['red'].','.$subtleBackgroundRGB['green'].','.$subtleBackgroundRGB['blue'].', 1) 100%)' ); 132 119 133 // Block Editor Styles. 120 134 } elseif ( 'block-editor' === $type ) { 121 135