-
Notifications
You must be signed in to change notification settings - Fork 6
[CMSP-695] Filter WP font_dir
#29
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
Conversation
we're loading after pantheon-updates because that's where the get_current_wordpress_version helper is defined
this allows us to test things that are in gutenberg but haven't been merged into core yet
check wp version and then maybe pull font library out of gutenberg
we don't need a filter if users can just filter it themselves.
this means that if a customer adds the filter with the default priority, it will override our modification.
With enough decisions at play here, will flip this to draft for now.
I considered for a minute if we need a means to support this for users using newest versions of g'berg on Core versions <6.4 but I think that can be documented with alternative means instead, if at all. |
so we don't ever end up with accidental naming clashes
it's not actually unused
pwtyler
left a comment
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.
- Lots of repetition could be cleaned up
- fonts.php I think could be simplified but maybe I'm wrong
Co-authored-by: Phil Tyler <phil.tyler@pantheon.io>
because function no longer exists
we don't need it since these are shellchecked at the source
|
Tests are passing on the |
This PR adds our own handling for the WP Font Library.
This is designed to filter the
font_dir(added in WP 6.5 / Gutenberg 17.6.0) to use an alternate path by default that, on Pantheon, is a writeable filesystem (meaning they can install fonts on production without having to commit them to the codebase). This behavior can be overridden by filtering thepantheon_modify_fonts_dirvalue.Note that this is blocked by WordPress/gutenberg#58696. Behaviorally speaking, while the tests pass and the font directory is filtered appropriately, testing manually returns an invalid JSON response error (see Loom).That doesn't mean that we can't merge this PR (we might decide we don't want to, or default thepantheon_modify_fonts_dirtofalseuntil WordPress/gutenberg#58696 is fixed). Aversion_comparedetermines whether to even load the namespace handling our WP Font Library modifications, so anyone using < WP 6.5 will remain unaffected even if we merge this and do a release anyway.An approach to add our own filter to define the font directory was considered and decided against, since the user could just use the core
font_dirfilter. Instead, I made our filter fire earlier (priority9) so a defaultfont_dirfilter will override our filter.We're storing the value of
wp_get_upload_dirinto a global ($_pantheon_upload_dir) so we do not create an infinite loop caused by filtering inside of a filter (font_dirandupload_dir), see WordPress/gutenberg#58696 (comment).TODO: Documentation for the new filter (and the WP filter) and descriptions of the behavior on Pantheon's environment. This will be done in a PR against the docs repo separately.