mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 09:07:59 +01:00
Editor: Load all style variation fonts within the editors.
Loads the font family files from style variations defined within a theme for user in the site and post editors. This is to ensure the fonts are shown while editing without the need for a reload after switching styles. Props ironprogrammer, mmaattiiaass. Fixes #62231. Built from https://develop.svn.wordpress.org/trunk@59260 git-svn-id: http://core.svn.wordpress.org/trunk@58652 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a67b37192f
commit
5cdf55fda7
@ -172,3 +172,4 @@ add_filter( 'list_pages', '_wp_privacy_settings_filter_draft_page_titles', 10, 2
|
||||
|
||||
// Font management.
|
||||
add_action( 'admin_print_styles', 'wp_print_font_faces', 50 );
|
||||
add_action( 'admin_print_styles', 'wp_print_font_faces_from_style_variations', 50 );
|
||||
|
@ -366,6 +366,7 @@ function _wp_get_iframed_editor_assets() {
|
||||
ob_start();
|
||||
wp_print_styles();
|
||||
wp_print_font_faces();
|
||||
wp_print_font_faces_from_style_variations();
|
||||
$styles = ob_get_clean();
|
||||
|
||||
if ( $has_emoji_styles ) {
|
||||
|
@ -54,6 +54,22 @@ function wp_print_font_faces( $fonts = array() ) {
|
||||
$wp_font_face->generate_and_print( $fonts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates and prints font-face styles defined the the theme style variations.
|
||||
*
|
||||
* @since 6.7.0
|
||||
*
|
||||
*/
|
||||
function wp_print_font_faces_from_style_variations() {
|
||||
$fonts = WP_Font_Face_Resolver::get_fonts_from_style_variations();
|
||||
|
||||
if ( empty( $fonts ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_print_font_faces( $fonts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new font collection in the font library.
|
||||
*
|
||||
|
@ -36,6 +36,38 @@ class WP_Font_Face_Resolver {
|
||||
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.
|
||||
*
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.7-beta3-59259';
|
||||
$wp_version = '6.7-beta3-59260';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user