-
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 face permissions #58957
Font face permissions #58957
Conversation
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/compat/wordpress-6.5/fonts/fonts.php |
Size Change: +110 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
Flaky tests detected in d1933ab. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7925920273
|
34c6fe4
to
5b7e83b
Compare
packages/edit-site/src/components/global-styles/font-library-modal/index.js
Show resolved
Hide resolved
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Hi @peterwilsoncc 👋 , thanks for working on this.
I tested this PR following the instructions, and it works as described. If understood correctly from your comment defining |
It doesn‘t matter where the fonts folder is located. The capability check prevents adding fonts if file mods are disallowed. |
There's some nuance to how fonts work that seems important to consider here:
So I think that permission to create a wp_font_face post should stay separate from uploading a font file. If Perhaps we could hand this by
Additionally, there's a discussion in this issue about how to signal when to upload a font file to the site (the current behavior with the Google Fonts library) vs using the remotely hosted font file. I'll add a comment there, I think that |
a0b3648
to
efa3238
Compare
packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js
Outdated
Show resolved
Hide resolved
@creativecoder I'm going to have to thinkg about this, I only became aware of the permissions discussion a couple of days ago so still getting my head aound the workings of the controller. |
efa3238
to
d1933ab
Compare
/** | ||
* Filters the user capabilities to grant the font family capabilities as necessary. | ||
* | ||
* Files must be modifiable to grant these capabilities and the user must als |
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.
* Files must be modifiable to grant these capabilities and the user must als | |
* Files must be modifiable to grant these capabilities and the user must also |
* have the `edit_theme_options` capability. | ||
* | ||
* These are created as faux primitive capabilities to allow for the use | ||
* if the delete_post meta capability. |
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.
* if the delete_post meta capability. | |
* of the delete_post meta capability. |
Thanks for all the work on this PR. We will need to merge this PR prior to Beta 3 and I'm starting to become concerned that it's now getting very close. I think we should add some tests, including some Playwright e2e tests to validate that the Upload/Delete options are / aren't available based on certain conditions. @creativecoder @matiasbenedetto are you able to support with this? For my part I'm going to manually test the PR and will be around to assist wherever I can. |
@getdave I'm working on a new PR today, combining the approach here with #59104, based on @peterwilsoncc 's feedback. Here's what I'm planning:
|
Closing this in favour of #59294 which includes a combination of this PR and Grant's original PR. |
What?
Modifies the font face permissions to ensure the file system is writable for the installation and deletion of fonts.
The font library's JavaScript is modified to use these permission to determine whether to allow:
See #55280
Why?
Currently the
DISALLOW_FILE_MODS
constant is not checked as part of the font faces API allowing users to upload fonts when the fonts should not be disabled.As this constant is used to indicate an immutable file system, the constant needs to be considered to allow for a good user experience uploading fonts. See WordPress/wporg-main-2022#388, #55063
How?
install_font_faces
,delete_font_faces
.[core data store].canUser( 'create', 'font-families' );
to determine if a user can upload, removes the UI if not[core data store].canUser( 'delete', 'font-families' );
to determine if a user can delete, removes the UI if notNote
Please test running this branch on WordPress 6.4.
The file the changes have been made in are not loaded on the current version of WordPress trunk.
Testing Instructions
define( 'DISALLOW_FILE_MODS', true );
to your wp-config file.Testing Instructions for Keyboard
Screenshots or screencast