Web fonts array passed to wp_register_webfonts()
changed:
Original API: each variation identifies its font-family.
wp_register_webfonts(
array(
array(
'provider' => 'local',
'font-family' => 'Source Serif Pro',
'font-weight' => '200 900',
'font-style' => 'normal',
'src' => get_theme_file_uri( 'assets/fonts/source-serif-pro/SourceSerif4Variable-Roman.ttf.woff2' ),
),
array(
'provider' => 'local',
'font-family' => 'Source Serif Pro',
'font-weight' => '200 900',
'font-style' => 'italic',
'src' => get_theme_file_uri( 'assets/fonts/source-serif-pro/SourceSerif4Variable-Italic.ttf.woff2' ),
),
)
);
New API: variations are grouped to their font-family.
wp_register_webfonts(
array(
'Source Serif Pro' => array(
array(
'provider' => 'local',
'font-weight' => '200 900',
'font-style' => 'normal',
'src' => get_theme_file_uri( 'assets/fonts/source-serif-pro/SourceSerif4Variable-Roman.ttf.woff2' ),
),
array(
'provider' => 'local',
'font-weight' => '200 900',
'font-style' => 'italic',
'src' => get_theme_file_uri( 'assets/fonts/source-serif-pro/SourceSerif4Variable-Italic.ttf.woff2' ),
),
),
)
);
Functionality | Original | New |
---|---|---|
Get enqueued web fonts | WP_Webfonts::get_registered_webfonts() | WP_Webfonts::get_registered() |
Get all web fonts | WP_Webfonts::get_all_webfonts() | WP_Webfonts::get_registered() |
Register web font | WP_Webfonts::register_webfont() | WP_Webfonts::add_variation() |