diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index d414416624..0f3834ae5b 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -2236,64 +2236,3 @@ final class WP_Customize_Manager { return get_custom_logo(); } } - -/** - * Sanitizes a hex color. - * - * Returns either '', a 3 or 6 digit hex color (with #), or nothing. - * For sanitizing values without a #, see sanitize_hex_color_no_hash(). - * - * @since 3.4.0 - * - * @param string $color - * @return string|void - */ -function sanitize_hex_color( $color ) { - if ( '' === $color ) - return ''; - - // 3 or 6 hex digits, or the empty string. - if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) - return $color; -} - -/** - * Sanitizes a hex color without a hash. Use sanitize_hex_color() when possible. - * - * Saving hex colors without a hash puts the burden of adding the hash on the - * UI, which makes it difficult to use or upgrade to other color types such as - * rgba, hsl, rgb, and html color names. - * - * Returns either '', a 3 or 6 digit hex color (without a #), or null. - * - * @since 3.4.0 - * - * @param string $color - * @return string|null - */ -function sanitize_hex_color_no_hash( $color ) { - $color = ltrim( $color, '#' ); - - if ( '' === $color ) - return ''; - - return sanitize_hex_color( '#' . $color ) ? $color : null; -} - -/** - * Ensures that any hex color is properly hashed. - * Otherwise, returns value untouched. - * - * This method should only be necessary if using sanitize_hex_color_no_hash(). - * - * @since 3.4.0 - * - * @param string $color - * @return string - */ -function maybe_hash_hex_color( $color ) { - if ( $unhashed = sanitize_hex_color_no_hash( $color ) ) - return '#' . $unhashed; - - return $color; -} diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 97a290ade3..f58e435fc1 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -4803,3 +4803,68 @@ function url_shorten( $url, $length = 35 ) { } return $short_url; } + +/** + * Sanitizes a hex color. + * + * Returns either '', a 3 or 6 digit hex color (with #), or nothing. + * For sanitizing values without a #, see sanitize_hex_color_no_hash(). + * + * @since 3.4.0 + * + * @param string $color + * @return string|void + */ +function sanitize_hex_color( $color ) { + if ( '' === $color ) { + return ''; + } + + // 3 or 6 hex digits, or the empty string. + if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) { + return $color; + } +} + +/** + * Sanitizes a hex color without a hash. Use sanitize_hex_color() when possible. + * + * Saving hex colors without a hash puts the burden of adding the hash on the + * UI, which makes it difficult to use or upgrade to other color types such as + * rgba, hsl, rgb, and html color names. + * + * Returns either '', a 3 or 6 digit hex color (without a #), or null. + * + * @since 3.4.0 + * + * @param string $color + * @return string|null + */ +function sanitize_hex_color_no_hash( $color ) { + $color = ltrim( $color, '#' ); + + if ( '' === $color ) { + return ''; + } + + return sanitize_hex_color( '#' . $color ) ? $color : null; +} + +/** + * Ensures that any hex color is properly hashed. + * Otherwise, returns value untouched. + * + * This method should only be necessary if using sanitize_hex_color_no_hash(). + * + * @since 3.4.0 + * + * @param string $color + * @return string + */ +function maybe_hash_hex_color( $color ) { + if ( $unhashed = sanitize_hex_color_no_hash( $color ) ) { + return '#' . $unhashed; + } + + return $color; +} diff --git a/wp-includes/version.php b/wp-includes/version.php index 90d8739988..f41ccd05dd 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-alpha-37282'; +$wp_version = '4.6-alpha-37283'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.