From a415c29efee45520ae252d2aa28f1083a521cd7b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 09:56:49 +0200 Subject: Adding upstream version 6.4.3+dfsg1. Signed-off-by: Daniel Baumann --- wp-includes/fonts/class-wp-font-face-resolver.php | 178 +++++++++ wp-includes/fonts/class-wp-font-face.php | 430 ++++++++++++++++++++++ wp-includes/fonts/dashicons.eot | Bin 0 -> 56564 bytes wp-includes/fonts/dashicons.svg | 1 + wp-includes/fonts/dashicons.ttf | Bin 0 -> 56392 bytes wp-includes/fonts/dashicons.woff | Bin 0 -> 26124 bytes wp-includes/fonts/dashicons.woff2 | Bin 0 -> 26132 bytes 7 files changed, 609 insertions(+) create mode 100644 wp-includes/fonts/class-wp-font-face-resolver.php create mode 100644 wp-includes/fonts/class-wp-font-face.php create mode 100644 wp-includes/fonts/dashicons.eot create mode 100644 wp-includes/fonts/dashicons.svg create mode 100644 wp-includes/fonts/dashicons.ttf create mode 100644 wp-includes/fonts/dashicons.woff create mode 100644 wp-includes/fonts/dashicons.woff2 (limited to 'wp-includes/fonts') diff --git a/wp-includes/fonts/class-wp-font-face-resolver.php b/wp-includes/fonts/class-wp-font-face-resolver.php new file mode 100644 index 0000000..125ff6a --- /dev/null +++ b/wp-includes/fonts/class-wp-font-face-resolver.php @@ -0,0 +1,178 @@ + $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; + } +} diff --git a/wp-includes/fonts/class-wp-font-face.php b/wp-includes/fonts/class-wp-font-face.php new file mode 100644 index 0000000..974e13e --- /dev/null +++ b/wp-includes/fonts/class-wp-font-face.php @@ -0,0 +1,430 @@ + '', + '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 and open a