rest_parse_hex_color()
Parses a 3 or 6 digit hex color (with #).
Хуков нет.
Возвращает
Строку|false. Color value on success, false on failure.
Использование
rest_parse_hex_color( $color );
- $color(строка) (обязательный)
- 3 or 6 digit hex color (with #).
Список изменений
| С версии 5.4.0 | Введена. |
Код rest_parse_hex_color() rest parse hex color WP 7.0
function rest_parse_hex_color( $color ) {
$regex = '|^#([A-Fa-f0-9]{3}){1,2}$|';
if ( ! preg_match( $regex, $color, $matches ) ) {
return false;
}
return $color;
}