Fieldmanager_Colorpicker::sanitize_hex_color PHP Method

sanitize_hex_color() public method

Returns either '', a 3 or 6 digit hex color (with #), or nothing. This was copied from core; sanitize_hex_color() is not available outside of the customizer. {@see https://core.trac.wordpress.org/ticket/27583}.
public sanitize_hex_color ( string $color ) : string
$color string
return string
    function sanitize_hex_color($color)
    {
        $color = trim($color);
        if ('' !== $color && preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color)) {
            return $color;
        }
        return '';
    }