From 18af1823aea2f4a6336d3e80311a714414776769 Mon Sep 17 00:00:00 2001 From: Geert De Deckere Date: Thu, 14 Jun 2012 10:14:45 +0200 Subject: [PATCH] Fix color modifications on shorthand hex colors --- woocommerce-core-functions.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/woocommerce-core-functions.php b/woocommerce-core-functions.php index fd79e3f6b39..5dab7d26501 100644 --- a/woocommerce-core-functions.php +++ b/woocommerce-core-functions.php @@ -495,7 +495,9 @@ function woocommerce_get_formatted_variation( $variation = '', $flat = false ) { if (!function_exists('woocommerce_hex_darker')) { function woocommerce_hex_darker( $color, $factor = 30 ) { $color = str_replace('#', '', $color); - + // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" + $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); + $base['R'] = hexdec($color{0}.$color{1}); $base['G'] = hexdec($color{2}.$color{3}); $base['B'] = hexdec($color{4}.$color{5}); @@ -520,7 +522,9 @@ if (!function_exists('woocommerce_hex_darker')) { if (!function_exists('woocommerce_hex_lighter')) { function woocommerce_hex_lighter( $color, $factor = 30 ) { $color = str_replace('#', '', $color); - + // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" + $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); + $base['R'] = hexdec($color{0}.$color{1}); $base['G'] = hexdec($color{2}.$color{3}); $base['B'] = hexdec($color{4}.$color{5});