dvadf
File manager - Edit - /home/centroca/public_html/fonts.tar
Back
class-wp-font-face-resolver.php 0000644 00000013024 15252467627 0012525 0 ustar 00 <?php /** * WP_Font_Face_Resolver class. * * @package WordPress * @subpackage Fonts * @since 6.4.0 */ /** * The Font Face Resolver abstracts the processing of different data sources * (such as theme.json) for processing within the Font Face. * * This class is for internal core usage and is not supposed to be used by * extenders (plugins and/or themes). * * @access private */ class WP_Font_Face_Resolver { /** * Gets fonts defined in theme.json. * * @since 6.4.0 * * @return array Returns the font-families, each with their font-face variations. */ public static function get_fonts_from_theme_json() { $settings = wp_get_global_settings(); // Bail out early if there are no font settings. if ( empty( $settings['typography']['fontFamilies'] ) ) { return array(); } return static::parse_settings( $settings ); } /** * Gets fonts defined in style variations. * * @since 6.7.0 * * @return array Returns an array of font-families. */ public static function get_fonts_from_style_variations() { $variations = WP_Theme_JSON_Resolver::get_style_variations(); $fonts = array(); if ( empty( $variations ) ) { return $fonts; } foreach ( $variations as $variation ) { if ( ! empty( $variation['settings']['typography']['fontFamilies']['theme'] ) ) { $fonts = array_merge( $fonts, $variation['settings']['typography']['fontFamilies']['theme'] ); } } $settings = array( 'typography' => array( 'fontFamilies' => array( 'theme' => $fonts, ), ), ); return static::parse_settings( $settings ); } /** * Parse theme.json settings to extract font definitions with variations grouped by font-family. * * @since 6.4.0 * * @param array $settings Font settings to parse. * @return array Returns an array of fonts, grouped by font-family. */ private static function parse_settings( array $settings ) { $fonts = array(); foreach ( $settings['typography']['fontFamilies'] as $font_families ) { foreach ( $font_families as $definition ) { // Skip if "fontFace" is not defined, meaning there are no variations. if ( empty( $definition['fontFace'] ) ) { continue; } // Skip if "fontFamily" is not defined. if ( empty( $definition['fontFamily'] ) ) { continue; } $font_family_name = static::maybe_parse_name_from_comma_separated_list( $definition['fontFamily'] ); // Skip if no font family is defined. if ( empty( $font_family_name ) ) { continue; } $fonts[] = static::convert_font_face_properties( $definition['fontFace'], $font_family_name ); } } return $fonts; } /** * Parse font-family name from comma-separated lists. * * If the given `fontFamily` is a comma-separated lists (example: "Inter, sans-serif" ), * parse and return the fist font from the list. * * @since 6.4.0 * * @param string $font_family Font family `fontFamily' to parse. * @return string Font-family name. */ private static function maybe_parse_name_from_comma_separated_list( $font_family ) { if ( str_contains( $font_family, ',' ) ) { $font_family = explode( ',', $font_family )[0]; } return trim( $font_family, "\"'" ); } /** * Converts font-face properties from theme.json format. * * @since 6.4.0 * * @param array $font_face_definition The font-face definitions to convert. * @param string $font_family_property The value to store in the font-face font-family property. * @return array Converted font-face properties. */ private static function convert_font_face_properties( array $font_face_definition, $font_family_property ) { $converted_font_faces = array(); foreach ( $font_face_definition as $font_face ) { // Add the font-family property to the font-face. $font_face['font-family'] = $font_family_property; // Converts the "file:./" src placeholder into a theme font file URI. if ( ! empty( $font_face['src'] ) ) { $font_face['src'] = static::to_theme_file_uri( (array) $font_face['src'] ); } // Convert camelCase properties into kebab-case. $font_face = static::to_kebab_case( $font_face ); $converted_font_faces[] = $font_face; } return $converted_font_faces; } /** * Converts each 'file:./' placeholder into a URI to the font file in the theme. * * The 'file:./' is specified in the theme's `theme.json` as a placeholder to be * replaced with the URI to the font file's location in the theme. When a "src" * beings with this placeholder, it is replaced, converting the src into a URI. * * @since 6.4.0 * * @param array $src An array of font file sources to process. * @return array An array of font file src URI(s). */ private static function to_theme_file_uri( array $src ) { $placeholder = 'file:./'; foreach ( $src as $src_key => $src_url ) { // Skip if the src doesn't start with the placeholder, as there's nothing to replace. if ( ! str_starts_with( $src_url, $placeholder ) ) { continue; } $src_file = str_replace( $placeholder, '', $src_url ); $src[ $src_key ] = get_theme_file_uri( $src_file ); } return $src; } /** * Converts all first dimension keys into kebab-case. * * @since 6.4.0 * * @param array $data The array to process. * @return array Data with first dimension keys converted into kebab-case. */ private static function to_kebab_case( array $data ) { foreach ( $data as $key => $value ) { $kebab_case = _wp_to_kebab_case( $key ); $data[ $kebab_case ] = $value; if ( $kebab_case !== $key ) { unset( $data[ $key ] ); } } return $data; } } class-wp-font-utils.php 0000644 00000021270 15252467627 0011132 0 ustar 00 <?php /** * Font Utils class. * * Provides utility functions for working with font families. * * @package WordPress * @subpackage Fonts * @since 6.5.0 */ /** * A class of utilities for working with the Font Library. * * These utilities may change or be removed in the future and are intended for internal use only. * * @since 6.5.0 * @access private */ class WP_Font_Utils { /** * Adds surrounding quotes to font family names that contain special characters. * * It follows the recommendations from the CSS Fonts Module Level 4. * @link https://www.w3.org/TR/css-fonts-4/#font-family-prop * * @since 6.5.0 * * @param string $item A font family name. * @return string The font family name with surrounding quotes, if necessary. */ 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; } /** * 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. * @link https://www.w3.org/TR/css-fonts-4/#font-family-prop * * @since 6.5.0 * @access private * * @see sanitize_text_field() * * @param string $font_family Font family name(s), comma-separated. * @return string Sanitized and formatted font family name(s). */ public static function sanitize_font_family( $font_family ) { if ( ! $font_family ) { return ''; } $output = sanitize_text_field( $font_family ); $formatted_items = array(); if ( str_contains( $output, ',' ) ) { $items = explode( ',', $output ); foreach ( $items as $item ) { $formatted_item = self::maybe_add_quotes( $item ); if ( ! empty( $formatted_item ) ) { $formatted_items[] = $formatted_item; } } return implode( ', ', $formatted_items ); } return self::maybe_add_quotes( $output ); } /** * 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. * * @since 6.5.0 * @access private * * @link https://drafts.csswg.org/css-fonts/#font-style-matching * * @param array $settings { * Font face settings. * * @type string $fontFamily Font family name. * @type string $fontStyle Optional font style, defaults to 'normal'. * @type string $fontWeight Optional font weight, defaults to 400. * @type string $fontStretch Optional font stretch, defaults to '100%'. * @type string $unicodeRange Optional unicode range, defaults to 'U+0-10FFFF'. * } * @return string Font face slug. */ public static function get_font_face_slug( $settings ) { $defaults = array( 'fontFamily' => '', 'fontStyle' => 'normal', 'fontWeight' => '400', 'fontStretch' => '100%', 'unicodeRange' => 'U+0-10FFFF', ); $settings = wp_parse_args( $settings, $defaults ); if ( function_exists( 'mb_strtolower' ) ) { $font_family = mb_strtolower( $settings['fontFamily'] ); } else { $font_family = strtolower( $settings['fontFamily'] ); } $font_style = strtolower( $settings['fontStyle'] ); $font_weight = strtolower( $settings['fontWeight'] ); $font_stretch = strtolower( $settings['fontStretch'] ); $unicode_range = strtoupper( $settings['unicodeRange'] ); // Convert weight keywords to numeric strings. $font_weight = str_replace( array( 'normal', 'bold' ), array( '400', '700' ), $font_weight ); // Convert stretch keywords to numeric strings. $font_stretch_map = array( 'ultra-condensed' => '50%', 'extra-condensed' => '62.5%', 'condensed' => '75%', 'semi-condensed' => '87.5%', 'normal' => '100%', 'semi-expanded' => '112.5%', 'expanded' => '125%', 'extra-expanded' => '150%', 'ultra-expanded' => '200%', ); $font_stretch = str_replace( array_keys( $font_stretch_map ), array_values( $font_stretch_map ), $font_stretch ); $slug_elements = array( $font_family, $font_style, $font_weight, $font_stretch, $unicode_range ); $slug_elements = array_map( function ( $elem ) { // Remove quotes to normalize font-family names, and ';' to use as a separator. $elem = trim( str_replace( array( '"', "'", ';' ), '', $elem ) ); // Normalize comma separated lists by removing whitespace in between items, // but keep whitespace within items (e.g. "Open Sans" and "OpenSans" are different fonts). // CSS spec for whitespace includes: U+000A LINE FEED, U+0009 CHARACTER TABULATION, or U+0020 SPACE, // which by default are all matched by \s in PHP. return preg_replace( '/,\s+/', ',', $elem ); }, $slug_elements ); return sanitize_text_field( implode( ';', $slug_elements ) ); } /** * Sanitizes a tree of data using a schema. * * The schema structure should mirror the data tree. Each value provided in the * schema should be a callable that will be applied to sanitize the corresponding * value in the data tree. Keys that are in the data tree, but not present in the * schema, will be removed in the sanitized data. Nested arrays are traversed recursively. * * @since 6.5.0 * * @access private * * @param array $tree The data to sanitize. * @param array $schema The schema used for sanitization. * @return array The sanitized data. */ public static function sanitize_from_schema( $tree, $schema ) { if ( ! is_array( $tree ) || ! is_array( $schema ) ) { return array(); } foreach ( $tree as $key => $value ) { // Remove keys not in the schema or with null/empty values. if ( ! array_key_exists( $key, $schema ) ) { unset( $tree[ $key ] ); continue; } $is_value_array = is_array( $value ); $is_schema_array = is_array( $schema[ $key ] ) && ! is_callable( $schema[ $key ] ); if ( $is_value_array && $is_schema_array ) { if ( wp_is_numeric_array( $value ) ) { // If indexed, process each item in the array. foreach ( $value as $item_key => $item_value ) { $tree[ $key ][ $item_key ] = isset( $schema[ $key ][0] ) && is_array( $schema[ $key ][0] ) ? self::sanitize_from_schema( $item_value, $schema[ $key ][0] ) : self::apply_sanitizer( $item_value, $schema[ $key ][0] ); } } else { // If it is an associative or indexed array, process as a single object. $tree[ $key ] = self::sanitize_from_schema( $value, $schema[ $key ] ); } } elseif ( ! $is_value_array && $is_schema_array ) { // If the value is not an array but the schema is, remove the key. unset( $tree[ $key ] ); } elseif ( ! $is_schema_array ) { // If the schema is not an array, apply the sanitizer to the value. $tree[ $key ] = self::apply_sanitizer( $value, $schema[ $key ] ); } // Remove keys with null/empty values. if ( empty( $tree[ $key ] ) ) { unset( $tree[ $key ] ); } } return $tree; } /** * Applies a sanitizer function to a value. * * @since 6.5.0 * * @param mixed $value The value to sanitize. * @param callable $sanitizer The sanitizer function to apply. * @return mixed The sanitized value. */ private static function apply_sanitizer( $value, $sanitizer ) { if ( null === $sanitizer ) { return $value; } return call_user_func( $sanitizer, $value ); } /** * Returns the expected mime-type values for font files, depending on PHP version. * * This is needed because font mime types 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. * * @since 6.5.0 * * @access private * * @return string[] A collection of mime types keyed by file extension. */ public static function get_allowed_font_mime_types() { $php_7_ttf_mime_type = PHP_VERSION_ID >= 70300 ? 'application/font-sfnt' : 'application/x-font-ttf'; return array( 'otf' => 'application/vnd.ms-opentype', 'ttf' => PHP_VERSION_ID >= 70400 ? 'font/sfnt' : $php_7_ttf_mime_type, 'woff' => PHP_VERSION_ID >= 80112 ? 'font/woff' : 'application/font-woff', 'woff2' => PHP_VERSION_ID >= 80112 ? 'font/woff2' : 'application/font-woff2', ); } } dashicons.woff 0000644 00000063014 15252467627 0007426 0 ustar 00 wOFF f � FFTM D rL"�GDEF ` 3 OS/2 � @ `�i�cmap � A ��@�gasp �� glyf Y� ���l��head \� . 6��hhea ], $��hmtx ]H �@rloca ^P ���vmaxp `` Y �name `� � V/*v�post b � F��?�webf f ��V� �=�� �� �c-x�c`d``�b `b`d`dd�,` � 9 x�c`f?�8�����U�e�4ʹ���)�Ja���~����_ ��bDR��� 6� �x�ݐ�KA�璨�7�� Ł���$��4�$�"���H�hb!];[��E;��F�j���6�y$`ao�yÃ�` �ɀ;X�q��9e��!�A&�A6 �K#�S@S���L5ڠ�h_Y�V��U^�jV��վ�늩�S3u�0-s`�8�6���(��(��@i&��1}�r��U�N[�Km*���SA�n�t�CS6K]��i��9d�~N���s��(���?���_����o���qK8��8�Ξ�tv�mg]�媬ɪ\��rN��#�ĵ���L�����NV?�TX������6y�t �� xڬ� |U�8\����;[��[��t��,��7�u�=l!� K�/F�MnQAPE7D\F�"�a�F�mD&��C�qduF��s I_����N:�̛���t��[U�n����'r�GN�ݜ�I��K�W����]o�{*����������-d�c���X3������Lh�C�g�<�3G���*���_�z�� �iH(LLf+1[�`HCd�P@L9��%�Y�0 Ca>����x0ְ;g��eM+��ݺ�6�H��i�e�Œ7j�i��?�R�������e��f6���Ow��[ʳ���$-������tK^plf���eK�ʕ���ͺU#�X�!^.*5�j.��^m2�R)!:G�;���i��u���(M�B*�ƚ[��4rzm+�ݺ^[� u|"}}���1��ѐ�O$Э�IM{��6�6,�$;���|[��F�U��,�o`�=zw����TKN�4�7��Wȵ\6���^S��di$A��]�%���MÎ%�H�)(��%����l$abf����7o���eDjiill|�q"}�R�z�Uda�������� �-&�d�OнW)��MM��H�XrWk���[������?����7*����[c߰�Mr;�y3Y�n��y��45r� �G�i���b�#D�w��]vJ�&��:�U�R��/�u, ���:;t�h�+~�z�~�#�uu�©�X���n;z�p����%�<�}��N���.�+�5� ��X|T�wr �#��T^Jd?0'Q�O��:�&��;$����h�. 8��p'�?K�85��g��q!"g�]� =n#�iP����X@�_"�=Y�o��_W��<�����z� �D�s�\.��K���w�7N��n�v�ι��~8��r�K����RL�猜�.�<{,D�Y��Ӭ�M.46`5J��߯�}5����m~��9D��~Ar��xX�^�t��j�n�?/�cW����8�z%�Z0g��~AO��5?� ,����@��+�����K�1��:�#K|8��Ĉ�@8�u�1��G<�$�dC��uŽ��X����f#��@��>O�NU��[�Z�v-�n��n����b�b��Gn'��<Zn���[¥g��;UЕ�2qu����_OzuԄf���?�SA�a�� 1���F�Ǯ?��0�ɇ� �$ep�?Xa�0��R7̷l��]X�� �y�! .H-$C�(tV@߄�Oe�xjЛ�I*m\^��<��t٥��$�?l�����ݑ�\��ƍk��C�L([��l9g��)5[yV�z��5��g���#����*����,�F{��=!�ǡ�C��9 ؍&s�,��>�:�wJY�in��cw�-�=����;���'�(�`��'��g���t ��3�\�ivδ-&�gCI0/^2{!ޅײvE�By*�WΔD�D��Q�vVu0�� 5�<j��v��֗臻iOD�S�z.�+VM��j�\�2����&�\��ͤq��Q����� |)�W���j&�*�\sS�}�f9��NO� �3rh�#CN�Mt�����O��G�_%e����0PJ�9G�6�^ڿ���ֹ��A��$k_og����?�6�p2 �X�ſ\I�Me�T6�'�b�m�&