-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Font Library: add a setting to customize the conditional download of font assets from a font collection #58030
base: trunk
Are you sure you want to change the base?
Conversation
…arent (#57867) Co-authored-by: Sarah Norris <1645628+mikachan@users.noreply.github.com>
…ised API (#57844) * Add batchInstallFontFaces function and related plumbing. * Fix resolver name. * Add embedding and rebuild theme.json settings for fontFamily. * Handle responses directly, add to collection before activating. Remove unused test. * Remove getIntersectingFontFaces. * Check for existing font family before installing. * Reference src, not uploadedFile key. Co-authored-by: Matias Benedetto <matias.benedetto@gmail.com> * Check for existing font family using GET /font-families?slug=. * Filter already installed font faces (determined by matching fontWeight AND fontStyle) --------- Co-authored-by: Matias Benedetto <matias.benedetto@gmail.com> Co-authored-by: Jason Crist <jcrist@pbking.com>
* Add batchInstallFontFaces function and related plumbing. * Fix resolver name. * Add embedding and rebuild theme.json settings for fontFamily. * Handle responses directly, add to collection before activating. Remove unused test. * Remove getIntersectingFontFaces. * Check for existing font family before installing. * Reference src, not uploadedFile key. Co-authored-by: Matias Benedetto <matias.benedetto@gmail.com> * Check for existing font family using GET /font-families?slug=. * Filter already installed font faces (determined by matching fontWeight AND fontStyle) * moved response processing into the resolver for fetchGetFontFamilyBySlug * Moved response processing for font family installation to the resolver * Refactored font face installation process to handle errors more cleanly * Cleanup error handling for font library view * Add i18n function to error messages * Add TODO comment for uninstall notice --------- Co-authored-by: Jeff Ong <jonger4@gmail.com> Co-authored-by: Matias Benedetto <matias.benedetto@gmail.com> Co-authored-by: Sarah Norris <sarah@sekai.co.uk>
* Fix delete endpoint * Update fetchUninstallFontFamily to match new format * Update uninstallFont * Add uninstall notice back in * Tidy up comments * Re-word uninstall notices * Add spacing to error message * Refactored how font family values were processed so they would retain their id, which is now used to delete a font family without fetching data via slug * Rename uninstallFont to uninstallFontFamily * Throw uninstall errors rather than returning them --------- Co-authored-by: Jason Crist <jcrist@pbking.com>
…odal/local-fonts.js Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
* Wrap error messages in sprintf * Use await rather than then * Add variables for API URLs * Update packages/edit-site/src/components/global-styles/font-library-modal/resolvers.js Co-authored-by: Jeff Ong <jonger4@gmail.com> --------- Co-authored-by: Jeff Ong <jonger4@gmail.com>
* google fonts collection data provisional url * rename controller methods * fix get_items parameters * fix endpoint return * rafactor font collection class * fix tests for the refactored class * refactor font collections rest controller * update font collection tests * update the frontend to use the new endpoint data schema * format php * adding linter line ignore rul * replacing throwing an exception by calling doing_it_wrong * add translation marks Co-authored-by: Jeff Ong <jonger4@gmail.com> * user ternary operator * correct translation formatting and comments * renaming function * renaming tests * improve url matching Co-authored-by: Grant Kinney <creativecoder@users.noreply.github.com> * return error without rest_ensure_response * fix contradictory if condition --------- Co-authored-by: Jeff Ong <jonger4@gmail.com> Co-authored-by: Grant Kinney <creativecoder@users.noreply.github.com>
Size Change: +49 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works as expected for me
- Without filtering the setting, font assets are downloaded when installed.
- When filtering block editor settings and setting
fontLibraryDownloadAssets
to false, the font files are not downloaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests well for me as well:
- Font assets are downloaded by default, without filtering ✅
- Using the filter to turn
fontLibraryDownloadAssets
to false, the font files are not downloaded ✅
* @property {boolean} richEditingEnabled Whether rich editing is enabled or not | ||
* @property {boolean} codeEditingEnabled Whether code editing is enabled or not | ||
* @property {boolean} fontLibraryEnabled Whether the font library is enabled or not. | ||
* @property {boolean} fontLibraryDownloadAssets Whether the font library is enabled or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description should be changed, still have some copy pasta here.
* @property {boolean} richEditingEnabled Whether rich editing is enabled or not | ||
* @property {boolean} codeEditingEnabled Whether code editing is enabled or not | ||
* @property {boolean} fontLibraryEnabled Whether the font library is enabled or not. | ||
* @property {boolean} fontLibraryDownloadAssets Whether the font library is enabled or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @property {boolean} fontLibraryDownloadAssets Whether the font library is enabled or not. | |
* @property {boolean} fontLibraryUploadAssets Whether the font library will upload font assets or not. |
5d160f2
to
1320d20
Compare
What?
Adds a setting to customize the conditional download of font assets from a font collection.
This is a simpler approach of #57989
Why?
To allow extenders to customize if WordPress Font Library will download the assets when installing font faces from a font collection.
How?
Adds the
fontLibraryDownloadAssets
editor setting that can be customized with PHP using a filter (See testing instructions).It adds
true
as the default value for this setting.Testing Instructions
Check that the font library continues to work as expected. By default, the assets from the font families/faces installed from a font collection featuring external links for the font face assets should be downloaded to the fonts folder (
wp-content/fonts
by default). So if you install font families from the Google Fonts collection, you should have the corresponding font assets downloaded in your fonts folder (wp-content/fonts
).Use this PHP filter to disable the download of the font assets of the font families installed. With this filter, when installing font faces from a font collection (like the default Google Fonts collection) the font asset won't be downloaded to the fonts folder (
wp-content/fonts
), instead of that, the fonts will continue being served from the link provided in the font face definition.