Index: wp-includes/formatting.php
===================================================================
--- wp-includes/formatting.php	(revision 19099)
+++ wp-includes/formatting.php	(working copy)
@@ -2432,6 +2432,48 @@
 }
 
 /**
+ * Escape a color represented in hexadecimal notation for use in css.
+ *
+ * @param string $color RGB color represented in hexadecimal notation.
+ * @return string The value of $color if it is a color represented in hexadecimal notation prepended with the hash (#) character; The string 'transparent' otherwise.
+ *
+ * @since 3.4
+ */
+function esc_color_hex( $color ) {
+	$color = esc_color_hex_raw( $color );
+	if ( 'transparent' != $color )
+		$color = '#' . $color;
+	return $color;
+}
+
+/**
+ * Escape a color represented in hexadecimal notation for database saves.
+ *
+ * @param string $color RGB color represented in hexadecimal notation.
+ * @return string The value of $color if it is a color represented in hexadecimal notation; The string 'transparent' otherwise.
+ *
+ * @since 3.4
+ */
+function esc_color_hex_raw( $color ) {
+	$default = 'transparent';
+	$color = trim( $color );
+
+	if ( 0 === strpos( $color, '#' ) )
+		$color = substr( $color, 1 );
+
+	if ( 0 === strpos( $color, '%23' ) )
+		$color = substr( $color, 3 );
+
+	if ( ! ctype_xdigit( $color ) )
+		return $default;
+
+	if ( ! in_array( strlen( $color ), array( 3, 6 ) ) )
+		return $default;
+
+	return strtolower( $color );
+}
+
+/**
  * Escape a HTML tag name.
  *
  * @since 2.5.0
