mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-25 18:48:57 +01:00
aaec843875
The static instance of `WP_Font_Face` is not needed. It was an unnecessary carryover from the experimental Fonts API (which was not introduced into Core). Whereas the Fonts API needed to persist its data (i.e. to maintain the registered and enqueued fonts throughout the web request), Font Face does not have data to persist. Font Face processes the fonts it receives when `WP_Font_Face::generate_and_print( $fonts )` is invoked. Thus, a singleton is not needed. Removing the static reduces the amount of the code in the function and eliminates running its tests in separate processes to ensure a different instance is always used. References: * [https://github.com/WordPress/gutenberg/pull/54228 Gutenberg PR 54228]. Follow-up to [56500]. Props hellofromTonya, costdev. Fixes #59165. Built from https://develop.svn.wordpress.org/trunk@56540 git-svn-id: http://core.svn.wordpress.org/trunk@56052 1a063a9b-81f0-0310-95a4-ce76da25c4cd
54 lines
2.3 KiB
PHP
54 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* Fonts functions.
|
|
*
|
|
* @package WordPress
|
|
* @subpackage Fonts
|
|
* @since 6.4.0
|
|
*/
|
|
|
|
/**
|
|
* Generates and prints font-face styles for given fonts or theme.json fonts.
|
|
*
|
|
* @since 6.4.0
|
|
*
|
|
* @param array[][] $fonts {
|
|
* Optional. The font-families and their font variations. Default empty array.
|
|
*
|
|
* @type string $font-family => array[] $variations {
|
|
* Optional. An associated array of font variations for this font-family.
|
|
* Each variation has the following structure.
|
|
*
|
|
* @type array $font_variation {
|
|
* @type string $font-family The font-family property.
|
|
* @type string|string[] $src The URL(s) to each resource containing the font data.
|
|
* @type string $font_style Optional. The font-style property. Default 'normal'.
|
|
* @type string $font-weight Optional. The font-weight property. Default '400'.
|
|
* @type string $font-display Optional. The font-display property. Default 'fallback'.
|
|
* @type string $ascent-override Optional. The ascent-override property.
|
|
* @type string $descent-override Optional. The descent-override property.
|
|
* @type string $font-stretch Optional. The font-stretch property.
|
|
* @type string $font-variant Optional. The font-variant property.
|
|
* @type string $font-feature-settings Optional. The font-feature-settings property.
|
|
* @type string $font-variation-settings Optional. The font-variation-settings property.
|
|
* @type string $line-gap-override Optional. The line-gap-override property.
|
|
* @type string $size-adjust Optional. The size-adjust property.
|
|
* @type string $unicode-range Optional. The unicode-range property.
|
|
* }
|
|
* }
|
|
* }
|
|
*/
|
|
function wp_print_font_faces( $fonts = array() ) {
|
|
|
|
if ( empty( $fonts ) ) {
|
|
$fonts = WP_Font_Face_Resolver::get_fonts_from_theme_json();
|
|
}
|
|
|
|
if ( empty( $fonts ) ) {
|
|
return;
|
|
}
|
|
|
|
$wp_font_face = new WP_Font_Face();
|
|
$wp_font_face->generate_and_print( $fonts );
|
|
}
|