Last active
September 10, 2015 18:14
-
-
Save devinsays/ea3b18acc2eccf02a927 to your computer and use it in GitHub Desktop.
sanitize_hex_color
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Duplicate the sanitize_hex_color function, which is generally | |
* only available to the theme customizer. | |
*/ | |
if ( !function_exists( 'sanitize_hex_color' ) ) { | |
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; | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment