| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
Font Utils class. Provides utility functions for working with font families.
| File Size: | 262 lines (9 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
WP_Font_Utils:: (6 methods):
maybe_add_quotes()
sanitize_font_family()
get_font_face_slug()
sanitize_from_schema()
apply_sanitizer()
get_allowed_font_mime_types()
Class: WP_Font_Utils - X-Ref
A class of utilities for working with the Font Library.| maybe_add_quotes( $item ) X-Ref |
| Adds surrounding quotes to font family names that contain special characters. It follows the recommendations from the CSS Fonts Module Level 4. param: string $item A font family name. return: string The font family name with surrounding quotes, if necessary. |
| sanitize_font_family( $font_family ) X-Ref |
| Sanitizes and formats font family names. - Applies `sanitize_text_field`. - Adds surrounding quotes to names containing any characters that are not alphabetic or dashes. It follows the recommendations from the CSS Fonts Module Level 4. param: string $font_family Font family name(s), comma-separated. return: string Sanitized and formatted font family name(s). |
| get_font_face_slug( $settings ) X-Ref |
| Generates a slug from font face properties, e.g. `open sans;normal;400;100%;U+0-10FFFF` Used for comparison with other font faces in the same family, to prevent duplicates that would both match according the CSS font matching spec. Uses only simple case-insensitive matching for fontFamily and unicodeRange, so does not handle overlapping font-family lists or unicode ranges. param: array $settings { return: string Font face slug. |
| sanitize_from_schema( $tree, $schema ) X-Ref |
| No description |
| apply_sanitizer( $value, $sanitizer ) X-Ref |
| Applies a sanitizer function to a value. param: mixed $value The value to sanitize. param: callable $sanitizer The sanitizer function to apply. return: mixed The sanitized value. |
| get_allowed_font_mime_types() X-Ref |
| Returns the expected mime-type values for font files, depending on PHP version. This is needed because the mime types detected for WOFF and WOFF2 files vary by PHP version, so checking the PHP version is necessary until a list of valid mime-types for each file extension can be provided to the 'upload_mimes' filter. TrueType fonts can be detected as either font/ttf or font/sfnt depending on the libmagic version, and both are accepted by wp_check_filetype_and_ext(). The canonical font/ttf is returned for them on all PHP versions. return: string[] A collection of mime types keyed by file extension. |
| Generated : Wed Nov 11 08:20:02 2026 | Cross-referenced by PHPXref |