Index: wp-includes/formatting.php
===================================================================
--- wp-includes/formatting.php	(revision 19125)
+++ wp-includes/formatting.php	(working copy)
@@ -2433,6 +2433,42 @@
 }
 
 /**
+ * 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 sanitize_color_hex( $color ) {
+	$color = sanitize_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 sanitize_color_hex_raw( $color ) {
+	$default = 'transparent';
+	$color = trim( strtolower( urldecode( $color ) ), "# \t\n\r\0\x0B" );
+
+	if ( ! in_array( strlen( $color ), array( 3, 6 ) ) )
+		return $default;
+	
+	if ( ! preg_match( "/(([a-f0-9]){3}){1,2}$/i", $color ) )
+		return $default;
+	
+	return $color;
+}
+
+/**
  * Escape a HTML tag name.
  *
  * @since 2.5.0
