sanitize_hex_color_no_hash()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
sanitize_hex_color_no_hash( string $color ): string|null
Описание
Сохранение шестнадцатеричных цветов без решётки перекладывает обязанность добавлять её на интерфейс, что затрудняет использование или переход к другим типам цвета, таким как rgba, hsl, rgb и названия цветов HTML.
Возвращает либо '', либо трёх- или шестизначный шестнадцатеричный цвет (без #), либо null.
Оригинал (английский)
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.
Параметры
$color
string
обязательный
Возвращаемое значение
string|null
Исходный код
wp-includes/formatting.php:6266
function sanitize_hex_color_no_hash( $color ) {
$color = ltrim( $color, '#' );
if ( '' === $color ) {
return '';
}
return sanitize_hex_color( '#' . $color ) ? $color : null;
}
История изменений
| Версия | Описание |
|---|---|
| 3.4.0 | Introduced. |

