[wp-trac] [WordPress Trac] #62258: Update Google Fonts collection
WordPress Trac
noreply at wordpress.org
Fri Oct 18 20:48:58 UTC 2024
#62258: Update Google Fonts collection
-------------------------------------------------+-------------------------
Reporter: mmaattiiaass | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: General | Version: trunk
Severity: normal | Resolution:
Keywords: needs-testing needs-testing-info | Focuses: css
2nd-opinion |
-------------------------------------------------+-------------------------
Changes (by dilip2615):
* keywords: => needs-testing needs-testing-info 2nd-opinion
* focuses: => css
Comment:
To update the Google Fonts collection for WordPress 6.7, fetch the latest
fonts data from the Google Fonts API. Replace the existing JSON file or
fonts data in your project with the new version. For example, if you're
updating Gutenberg, modify the font-loading mechanism to use the new data,
then test to ensure new fonts are available. Finally, clear cache and
verify functionality.
Fetch Latest Google Fonts: Use the API to get the updated fonts list:
{{{
$api_key = 'YOUR_API_KEY';
$url = "https://www.googleapis.com/webfonts/v1/webfonts?key=$api_key";
$response = wp_remote_get($url);
$body = wp_remote_retrieve_body($response);
$fonts_data = json_decode($body, true);
}}}
Replace Existing Fonts: Update your local JSON file or replace the
existing font array in your project:
{{{
file_put_contents('path/to/fonts.json', json_encode($fonts_data));
}}}
Update Frontend: Update the font loading in your theme or plugin, e.g.,
enqueue the latest fonts:
{{{
Update Frontend: Update the font loading in your theme or plugin, e.g.,
enqueue the latest fonts:
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62258#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list