Файловый менеджер - Редактировать - /var/www/html/theaffinitydental/wp-includes/blocks/spacer/fonts.tar
Назад
class-wp-font-face.php 0000755 00000024016 00000000000 0010615 0 ustar 00 <?php /** * WP_Font_Face class. * * @package WordPress * @subpackage Fonts * @since 6.4.0 */ /** * Font Face generates and prints `@font-face` styles for given fonts. * * @since 6.4.0 */ class WP_Font_Face { /** * The font-face property defaults. * * @since 6.4.0 * * @var string[] */ private $font_face_property_defaults = array( 'font-family' => '', 'font-style' => 'normal', 'font-weight' => '400', 'font-display' => 'fallback', ); /** * Valid font-face property names. * * @since 6.4.0 * * @var string[] */ private $valid_font_face_properties = array( 'ascent-override', 'descent-override', 'font-display', 'font-family', 'font-stretch', 'font-style', 'font-weight', 'font-variant', 'font-feature-settings', 'font-variation-settings', 'line-gap-override', 'size-adjust', 'src', 'unicode-range', ); /** * Valid font-display values. * * @since 6.4.0 * * @var string[] */ private $valid_font_display = array( 'auto', 'block', 'fallback', 'swap', 'optional' ); /** * Array of font-face style tag's attribute(s) * where the key is the attribute name and the * value is its value. * * @since 6.4.0 * * @var string[] */ private $style_tag_attrs = array(); /** * Creates and initializes an instance of WP_Font_Face. * * @since 6.4.0 */ public function __construct() { if ( function_exists( 'is_admin' ) && ! is_admin() && function_exists( 'current_theme_supports' ) && ! current_theme_supports( 'html5', 'style' ) ) { $this->style_tag_attrs = array( 'type' => 'text/css' ); } } /** * Generates and prints the `@font-face` styles for the given fonts. * * @since 6.4.0 * * @param array[][] $fonts Optional. The font-families and their font variations. * See {@see wp_print_font_faces()} for the supported fields. * Default empty array. */ public function generate_and_print( array $fonts ) { $fonts = $this->validate_fonts( $fonts ); // Bail out if there are no fonts are given to process. if ( empty( $fonts ) ) { return; } $css = $this->get_css( $fonts ); /* * The font-face CSS is contained within <style> tags and can only be interpreted * as CSS in the browser. Using wp_strip_all_tags() is sufficient escaping * to avoid malicious attempts to close </style> and open a <script>. */ $css = wp_strip_all_tags( $css ); // Bail out if there is no CSS to print. if ( empty( $css ) ) { return; } printf( $this->get_style_element(), $css ); } /** * Validates each of the font-face properties. * * @since 6.4.0 * * @param array $fonts The fonts to valid. * @return array Prepared font-faces organized by provider and font-family. */ private function validate_fonts( array $fonts ) { $validated_fonts = array(); foreach ( $fonts as $font_faces ) { foreach ( $font_faces as $font_face ) { $font_face = $this->validate_font_face_declarations( $font_face ); // Skip if failed validation. if ( false === $font_face ) { continue; } $validated_fonts[] = $font_face; } } return $validated_fonts; } /** * Validates each font-face declaration (property and value pairing). * * @since 6.4.0 * * @param array $font_face Font face property and value pairings to validate. * @return array|false Validated font-face on success, or false on failure. */ private function validate_font_face_declarations( array $font_face ) { $font_face = wp_parse_args( $font_face, $this->font_face_property_defaults ); // Check the font-family. if ( empty( $font_face['font-family'] ) || ! is_string( $font_face['font-family'] ) ) { // @todo replace with `wp_trigger_error()`. _doing_it_wrong( __METHOD__, __( 'Font font-family must be a non-empty string.' ), '6.4.0' ); return false; } // Make sure that local fonts have 'src' defined. if ( empty( $font_face['src'] ) || ( ! is_string( $font_face['src'] ) && ! is_array( $font_face['src'] ) ) ) { // @todo replace with `wp_trigger_error()`. _doing_it_wrong( __METHOD__, __( 'Font src must be a non-empty string or an array of strings.' ), '6.4.0' ); return false; } // Validate the 'src' property. foreach ( (array) $font_face['src'] as $src ) { if ( empty( $src ) || ! is_string( $src ) ) { // @todo replace with `wp_trigger_error()`. _doing_it_wrong( __METHOD__, __( 'Each font src must be a non-empty string.' ), '6.4.0' ); return false; } } // Check the font-weight. if ( ! is_string( $font_face['font-weight'] ) && ! is_int( $font_face['font-weight'] ) ) { // @todo replace with `wp_trigger_error()`. _doing_it_wrong( __METHOD__, __( 'Font font-weight must be a properly formatted string or integer.' ), '6.4.0' ); return false; } // Check the font-display. if ( ! in_array( $font_face['font-display'], $this->valid_font_display, true ) ) { $font_face['font-display'] = $this->font_face_property_defaults['font-display']; } // Remove invalid properties. foreach ( $font_face as $property => $value ) { if ( ! in_array( $property, $this->valid_font_face_properties, true ) ) { unset( $font_face[ $property ] ); } } return $font_face; } /** * Gets the style element for wrapping the `@font-face` CSS. * * @since 6.4.0 * * @return string The style element. */ private function get_style_element() { $attributes = $this->generate_style_element_attributes(); return "<style class='wp-fonts-local'{$attributes}>\n%s\n</style>\n"; } /** * Gets the defined <style> element's attributes. * * @since 6.4.0 * * @return string A string of attribute=value when defined, else, empty string. */ private function generate_style_element_attributes() { $attributes = ''; foreach ( $this->style_tag_attrs as $name => $value ) { $attributes .= " {$name}='{$value}'"; } return $attributes; } /** * Gets the `@font-face` CSS styles for locally-hosted font files. * * This method does the following processing tasks: * 1. Orchestrates an optimized `src` (with format) for browser support. * 2. Generates the `@font-face` for all its fonts. * * @since 6.4.0 * * @param array[] $font_faces The font-faces to generate @font-face CSS styles. * @return string The `@font-face` CSS styles. */ private function get_css( $font_faces ) { $css = ''; foreach ( $font_faces as $font_face ) { // Order the font's `src` items to optimize for browser support. $font_face = $this->order_src( $font_face ); // Build the @font-face CSS for this font. $css .= '@font-face{' . $this->build_font_face_css( $font_face ) . '}' . "\n"; } // Don't print the last newline character. return rtrim( $css, "\n" ); } /** * Orders `src` items to optimize for browser support. * * @since 6.4.0 * * @param array $font_face Font face to process. * @return array Font-face with ordered src items. */ private function order_src( array $font_face ) { if ( ! is_array( $font_face['src'] ) ) { $font_face['src'] = (array) $font_face['src']; } $src = array(); $src_ordered = array(); foreach ( $font_face['src'] as $url ) { // Add data URIs first. if ( str_starts_with( trim( $url ), 'data:' ) ) { $src_ordered[] = array( 'url' => $url, 'format' => 'data', ); continue; } $format = pathinfo( $url, PATHINFO_EXTENSION ); $src[ $format ] = $url; } // Add woff2. if ( ! empty( $src['woff2'] ) ) { $src_ordered[] = array( 'url' => $src['woff2'], 'format' => 'woff2', ); } // Add woff. if ( ! empty( $src['woff'] ) ) { $src_ordered[] = array( 'url' => $src['woff'], 'format' => 'woff', ); } // Add ttf. if ( ! empty( $src['ttf'] ) ) { $src_ordered[] = array( 'url' => $src['ttf'], 'format' => 'truetype', ); } // Add eot. if ( ! empty( $src['eot'] ) ) { $src_ordered[] = array( 'url' => $src['eot'], 'format' => 'embedded-opentype', ); } // Add otf. if ( ! empty( $src['otf'] ) ) { $src_ordered[] = array( 'url' => $src['otf'], 'format' => 'opentype', ); } $font_face['src'] = $src_ordered; return $font_face; } /** * Builds the font-family's CSS. * * @since 6.4.0 * * @param array $font_face Font face to process. * @return string This font-family's CSS. */ private function build_font_face_css( array $font_face ) { $css = ''; /* * Wrap font-family in quotes if it contains spaces * and is not already wrapped in quotes. */ if ( str_contains( $font_face['font-family'], ' ' ) && ! str_contains( $font_face['font-family'], '"' ) && ! str_contains( $font_face['font-family'], "'" ) ) { $font_face['font-family'] = '"' . $font_face['font-family'] . '"'; } foreach ( $font_face as $key => $value ) { // Compile the "src" parameter. if ( 'src' === $key ) { $value = $this->compile_src( $value ); } // If font-variation-settings is an array, convert it to a string. if ( 'font-variation-settings' === $key && is_array( $value ) ) { $value = $this->compile_variations( $value ); } if ( ! empty( $value ) ) { $css .= "$key:$value;"; } } return $css; } /** * Compiles the `src` into valid CSS. * * @since 6.4.0 * * @param array $value Value to process. * @return string The CSS. */ private function compile_src( array $value ) { $src = ''; foreach ( $value as $item ) { $src .= ( 'data' === $item['format'] ) ? ", url({$item['url']})" : ", url('{$item['url']}') format('{$item['format']}')"; } $src = ltrim( $src, ', ' ); return $src; } /** * Compiles the font variation settings. * * @since 6.4.0 * * @param array $font_variation_settings Array of font variation settings. * @return string The CSS. */ private function compile_variations( array $font_variation_settings ) { $variations = ''; foreach ( $font_variation_settings as $key => $value ) { $variations .= "$key $value"; } return $variations; } } class-wp-font-library.php 0000755 00000006653 00000000000 0011372 0 ustar 00 <?php /** * Font Library class. * * This file contains the Font Library class definition. * * @package WordPress * @subpackage Fonts * @since 6.5.0 */ /** * Font Library class. * * @since 6.5.0 */ class WP_Font_Library { /** * Font collections. * * @since 6.5.0 * @var array */ private $collections = array(); /** * Container for the main instance of the class. * * @since 6.5.0 * @var WP_Font_Library|null */ private static $instance = null; /** * Register a new font collection. * * @since 6.5.0 * * @param string $slug Font collection slug. May only contain alphanumeric characters, dashes, * and underscores. See sanitize_title(). * @param array $args Font collection data. See wp_register_font_collection() for information on accepted arguments. * @return WP_Font_Collection|WP_Error A font collection if it was registered successfully, * or WP_Error object on failure. */ public function register_font_collection( string $slug, array $args ) { $new_collection = new WP_Font_Collection( $slug, $args ); if ( $this->is_collection_registered( $new_collection->slug ) ) { $error_message = sprintf( /* translators: %s: Font collection slug. */ __( 'Font collection with slug: "%s" is already registered.' ), $new_collection->slug ); _doing_it_wrong( __METHOD__, $error_message, '6.5.0' ); return new WP_Error( 'font_collection_registration_error', $error_message ); } $this->collections[ $new_collection->slug ] = $new_collection; return $new_collection; } /** * Unregisters a previously registered font collection. * * @since 6.5.0 * * @param string $slug Font collection slug. * @return bool True if the font collection was unregistered successfully and false otherwise. */ public function unregister_font_collection( string $slug ) { if ( ! $this->is_collection_registered( $slug ) ) { _doing_it_wrong( __METHOD__, /* translators: %s: Font collection slug. */ sprintf( __( 'Font collection "%s" not found.' ), $slug ), '6.5.0' ); return false; } unset( $this->collections[ $slug ] ); return true; } /** * Checks if a font collection is registered. * * @since 6.5.0 * * @param string $slug Font collection slug. * @return bool True if the font collection is registered and false otherwise. */ private function is_collection_registered( string $slug ) { return array_key_exists( $slug, $this->collections ); } /** * Gets all the font collections available. * * @since 6.5.0 * * @return array List of font collections. */ public function get_font_collections() { return $this->collections; } /** * Gets a font collection. * * @since 6.5.0 * * @param string $slug Font collection slug. * @return WP_Font_Collection|null Font collection object, or null if the font collection doesn't exist. */ public function get_font_collection( string $slug ) { if ( $this->is_collection_registered( $slug ) ) { return $this->collections[ $slug ]; } return null; } /** * Utility method to retrieve the main instance of the class. * * The instance will be created if it does not exist yet. * * @since 6.5.0 * * @return WP_Font_Library The main instance. */ public static function get_instance() { if ( null === self::$instance ) { self::$instance = new self(); } return self::$instance; } } class-wp-font-collection.php 0000755 00000021274 00000000000 0012055 0 ustar 00 <?php /** * Font Collection class. * * This file contains the Font Collection class definition. * * @package WordPress * @subpackage Fonts * @since 6.5.0 */ /** * Font Collection class. * * @since 6.5.0 * * @see wp_register_font_collection() */ final class WP_Font_Collection { /** * The unique slug for the font collection. * * @since 6.5.0 * @var string */ public $slug; /** * Font collection data. * * @since 6.5.0 * @var array|WP_Error|null */ private $data; /** * Font collection JSON file path or URL. * * @since 6.5.0 * @var string|null */ private $src; /** * WP_Font_Collection constructor. * * @since 6.5.0 * * @param string $slug Font collection slug. May only contain alphanumeric characters, dashes, * and underscores. See sanitize_title(). * @param array $args Font collection data. See wp_register_font_collection() for information on accepted arguments. */ public function __construct( string $slug, array $args ) { $this->slug = sanitize_title( $slug ); if ( $this->slug !== $slug ) { _doing_it_wrong( __METHOD__, /* translators: %s: Font collection slug. */ sprintf( __( 'Font collection slug "%s" is not valid. Slugs must use only alphanumeric characters, dashes, and underscores.' ), $slug ), '6.5.0' ); } $required_properties = array( 'name', 'font_families' ); if ( isset( $args['font_families'] ) && is_string( $args['font_families'] ) ) { // JSON data is lazy loaded by ::get_data(). $this->src = $args['font_families']; unset( $args['font_families'] ); $required_properties = array( 'name' ); } $this->data = $this->sanitize_and_validate_data( $args, $required_properties ); } /** * Retrieves the font collection data. * * @since 6.5.0 * * @return array|WP_Error An array containing the font collection data, or a WP_Error on failure. */ public function get_data() { if ( is_wp_error( $this->data ) ) { return $this->data; } // If the collection uses JSON data, load it and cache the data/error. if ( isset( $this->src ) ) { $this->data = $this->load_from_json( $this->src ); } if ( is_wp_error( $this->data ) ) { return $this->data; } // Set defaults for optional properties. $defaults = array( 'description' => '', 'categories' => array(), ); return wp_parse_args( $this->data, $defaults ); } /** * Loads font collection data from a JSON file or URL. * * @since 6.5.0 * * @param string $file_or_url File path or URL to a JSON file containing the font collection data. * @return array|WP_Error An array containing the font collection data on success, * else an instance of WP_Error on failure. */ private function load_from_json( $file_or_url ) { $url = wp_http_validate_url( $file_or_url ); $file = file_exists( $file_or_url ) ? wp_normalize_path( realpath( $file_or_url ) ) : false; if ( ! $url && ! $file ) { // translators: %s: File path or URL to font collection JSON file. $message = __( 'Font collection JSON file is invalid or does not exist.' ); _doing_it_wrong( __METHOD__, $message, '6.5.0' ); return new WP_Error( 'font_collection_json_missing', $message ); } $data = $url ? $this->load_from_url( $url ) : $this->load_from_file( $file ); if ( is_wp_error( $data ) ) { return $data; } $data = array( 'name' => $this->data['name'], 'font_families' => $data['font_families'], ); if ( isset( $this->data['description'] ) ) { $data['description'] = $this->data['description']; } if ( isset( $this->data['categories'] ) ) { $data['categories'] = $this->data['categories']; } return $data; } /** * Loads the font collection data from a JSON file path. * * @since 6.5.0 * * @param string $file File path to a JSON file containing the font collection data. * @return array|WP_Error An array containing the font collection data on success, * else an instance of WP_Error on failure. */ private function load_from_file( $file ) { $data = wp_json_file_decode( $file, array( 'associative' => true ) ); if ( empty( $data ) ) { return new WP_Error( 'font_collection_decode_error', __( 'Error decoding the font collection JSON file contents.' ) ); } return $this->sanitize_and_validate_data( $data, array( 'font_families' ) ); } /** * Loads the font collection data from a JSON file URL. * * @since 6.5.0 * * @param string $url URL to a JSON file containing the font collection data. * @return array|WP_Error An array containing the font collection data on success, * else an instance of WP_Error on failure. */ private function load_from_url( $url ) { // Limit key to 167 characters to avoid failure in the case of a long URL. $transient_key = substr( 'wp_font_collection_url_' . $url, 0, 167 ); $data = get_site_transient( $transient_key ); if ( false === $data ) { $response = wp_safe_remote_get( $url ); if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { return new WP_Error( 'font_collection_request_error', sprintf( // translators: %s: Font collection URL. __( 'Error fetching the font collection data from "%s".' ), $url ) ); } $data = json_decode( wp_remote_retrieve_body( $response ), true ); if ( empty( $data ) ) { return new WP_Error( 'font_collection_decode_error', __( 'Error decoding the font collection data from the HTTP response JSON.' ) ); } // Make sure the data is valid before storing it in a transient. $data = $this->sanitize_and_validate_data( $data, array( 'font_families' ) ); if ( is_wp_error( $data ) ) { return $data; } set_site_transient( $transient_key, $data, DAY_IN_SECONDS ); } return $data; } /** * Sanitizes and validates the font collection data. * * @since 6.5.0 * * @param array $data Font collection data to sanitize and validate. * @param array $required_properties Required properties that must exist in the passed data. * @return array|WP_Error Sanitized data if valid, otherwise a WP_Error instance. */ private function sanitize_and_validate_data( $data, $required_properties = array() ) { $schema = self::get_sanitization_schema(); $data = WP_Font_Utils::sanitize_from_schema( $data, $schema ); foreach ( $required_properties as $property ) { if ( empty( $data[ $property ] ) ) { $message = sprintf( // translators: 1: Font collection slug, 2: Missing property name, e.g. "font_families". __( 'Font collection "%1$s" has missing or empty property: "%2$s".' ), $this->slug, $property ); _doing_it_wrong( __METHOD__, $message, '6.5.0' ); return new WP_Error( 'font_collection_missing_property', $message ); } } return $data; } /** * Retrieves the font collection sanitization schema. * * @since 6.5.0 * * @return array Font collection sanitization schema. */ private static function get_sanitization_schema() { return array( 'name' => 'sanitize_text_field', 'description' => 'sanitize_text_field', 'font_families' => array( array( 'font_family_settings' => array( 'name' => 'sanitize_text_field', 'slug' => static function ( $value ) { return _wp_to_kebab_case( sanitize_title( $value ) ); }, 'fontFamily' => 'WP_Font_Utils::sanitize_font_family', 'preview' => 'sanitize_url', 'fontFace' => array( array( 'fontFamily' => 'sanitize_text_field', 'fontStyle' => 'sanitize_text_field', 'fontWeight' => 'sanitize_text_field', 'src' => static function ( $value ) { return is_array( $value ) ? array_map( 'sanitize_text_field', $value ) : sanitize_text_field( $value ); }, 'preview' => 'sanitize_url', 'fontDisplay' => 'sanitize_text_field', 'fontStretch' => 'sanitize_text_field', 'ascentOverride' => 'sanitize_text_field', 'descentOverride' => 'sanitize_text_field', 'fontVariant' => 'sanitize_text_field', 'fontFeatureSettings' => 'sanitize_text_field', 'fontVariationSettings' => 'sanitize_text_field', 'lineGapOverride' => 'sanitize_text_field', 'sizeAdjust' => 'sanitize_text_field', 'unicodeRange' => 'sanitize_text_field', ), ), ), 'categories' => array( 'sanitize_title' ), ), ), 'categories' => array( array( 'name' => 'sanitize_text_field', 'slug' => 'sanitize_title', ), ), ); } } dashicons.eot 0000755 00000156364 00000000000 0007213 0 ustar 00 �� H� � LP ��� d a s h i c o n s R e g u l a r V e r s i o n 1 . 0 d a s h i c o n s � 0GSUB���� 8 BOS/2@�O% | Vcmap_�>� $ �glyfqd�E � �@head�f� � 6hhea7H � $hmtx��� � Plocal�A �maxpo � name�+_� � "post#2\� �, . ���� T ���_<� �6� �6���� T � � , DFLT liga �� f G f � � PfEd @� �G . �� �� �� �� �� , � � , � � <