WP_Font_Utils::maybe_add_quotes
Adds surrounding quotes to font family names that contain special characters.
It follows the recommendations from the CSS Fonts Module Level 4.
Метод класса: WP_Font_Utils{}
Хуков нет.
Возвращает
Строку. The font family name with surrounding quotes, if necessary.
Использование
$result = WP_Font_Utils::maybe_add_quotes( $item );
- $item(строка) (обязательный)
- A font family name.
Список изменений
| С версии 6.5.0 | Введена. |
Код WP_Font_Utils::maybe_add_quotes() WP Font Utils::maybe add quotes WP 6.9.1
private static function maybe_add_quotes( $item ) {
// Matches strings that are not exclusively alphabetic characters or hyphens, and do not exactly follow the pattern generic(alphabetic characters or hyphens).
$regex = '/^(?!generic\([a-zA-Z\-]+\)$)(?!^[a-zA-Z\-]+$).+/';
$item = trim( $item );
if ( preg_match( $regex, $item ) ) {
$item = trim( $item, "\"'" );
return '"' . $item . '"';
}
return $item;
}