Skip to content
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

[CMSP-695] WordPress 6.5 font library documentation and behavior #8867

Merged
merged 35 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
53b2f18
add draft release notes for WP 6.5 font library
jazzsequence Feb 14, 2024
54bfb9c
add a guide under WordPress Configuration that talks about the WP Fon…
jazzsequence Feb 14, 2024
c9fd5e9
rename the release note with the expected release date
jazzsequence Feb 14, 2024
566fe6a
remove nonfunctional links
jazzsequence Feb 14, 2024
bdfd875
add g'berg issue
jazzsequence Feb 14, 2024
c553ffa
update notes to maintain consistency
jazzsequence Feb 14, 2024
57a787f
update publish date
jazzsequence Feb 14, 2024
8fd3bf2
add troubleshooting info if the FS is not writeable
jazzsequence Feb 15, 2024
9a22682
some copy changes
jazzsequence Feb 15, 2024
d4bf296
fix image url
jazzsequence Feb 15, 2024
8c6a938
add new screenshots
jazzsequence Feb 15, 2024
6bea7f4
update info about handling fonts like media files
jazzsequence Feb 15, 2024
e96cdde
update troubleshooting steps
jazzsequence Feb 15, 2024
ed2505c
add one more troubleshooting Q & A
jazzsequence Feb 15, 2024
e36ddb2
specify in the admin
jazzsequence Feb 15, 2024
c7e9a09
Be more clear that this only happens if you've changed the Pantheon s…
jazzsequence Feb 15, 2024
252e896
remove references to "restoring wp default behavior"
jazzsequence Feb 16, 2024
ad83d54
note how we prioritized our filter
jazzsequence Feb 16, 2024
0b97b88
add details to how 'active' fonts work
jazzsequence Feb 16, 2024
ad65671
update copy about post type
jazzsequence Feb 16, 2024
0785575
simplify language
jazzsequence Feb 16, 2024
8ced605
more simplification
jazzsequence Feb 16, 2024
5968b20
clarify introductory paragraph
jazzsequence Mar 19, 2024
aef5e79
discuss (new) wp default behavior and why we're keeping our mu-plugin…
jazzsequence Mar 19, 2024
db1d125
remove note, this is no longer an issue
jazzsequence Mar 19, 2024
ad0a5af
update language about overriding our font_dir filter
jazzsequence Mar 19, 2024
b48a981
add our G'berg issue for font handling for manual uploads
jazzsequence Mar 19, 2024
e356c02
add link to more resources
jazzsequence Mar 19, 2024
46922b2
remove release notes for wp 6.5 from this PR
jazzsequence Mar 19, 2024
657c4b2
remove link to release post (that doesn't exist)
jazzsequence Mar 19, 2024
1186cd9
Merge branch 'main' into cmsp-695-6.5-font-library-docs
jazzsequence Mar 19, 2024
64c1337
add new plugin tag for PAPC release note
jazzsequence Mar 19, 2024
529e57f
add a new release note for the MU plugin release
jazzsequence Mar 19, 2024
ceedeba
note when developing locally
jazzsequence Mar 19, 2024
82d259d
remove unrelated release note update
jazzsequence Mar 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: WordPress Configurations Guide
subtitle: Using the WordPress Font Library on Pantheon
description: Understand how to use the WordPress Font Library on Pantheon and how to restore the WordPress default behavior.
contenttype: [guide]
innav: [false]
categories: [config]
cms: [wordpress]
audience: [development]
product: [--]
integration: [plugins]
tags: [workflow, code]
contributors: [jazzsequence]
permalink: docs/guides/wordpress-configurations/wordpress-font-library
---

This section provides information on how to use the WordPress Font Library on Pantheon.

[WordPress 6.5 (release name)]() introduced a new [Font Library]() feature. This feature allows you to upload fonts to your WordPress site or install any of the fonts available from Google's font library. In anticipation of this, Pantheon added a feature to our [Pantheon MU Plugin](https://github.com/pantheon-systems/pantheon-mu-plugin) to store those fonts in a writeable `wp-content/uploads/fonts/` directory, so that you can use the feature without any issues after updating your sites to 6.5. This changed the default WordPress core behavior of storing fonts in `wp-content/fonts` which would require committing fonts to your site repository and deploying them from dev to test to live.

## Using the Filter

If you want to use the default WordPress behavior and store fonts in `wp-content/fonts`, you can use the following filter:

```php
add_filter( 'pantheon_modify_fonts_dir', '__return_false' );
```

Put this code somewhere in your site codebase as a plugin, in a theme `functions.php` file or in a [custom mu-plugin](https://docs.pantheon.io/guides/wordpress-configurations/wordpress-custom-code). This will restore the original behavior and commit fonts to your site repository.

You can _change the directory_ where fonts are stored by using the WordPress core filter `font_dir` like this:

```php
add_filter( 'font_dir', function( $defaults ) {
$font_dir = '/path/to/your/custom/dir';
$font_url = site_url( $font_dir );

$defaults['path'] = $font_dir;
$defaults['url'] = $font_url;
$defaults['basedir'] = $font_dir;
$defaults['baseurl'] = $font_url;

return $defaults;
} );
```

<Alert title="Note" type="info">

You cannot use the function `wp_get_upload_dir()` inside the `font_dir` filter because it will cause an infinite loop. Instead, if you want to use the `wp_get_upload_dir()` function, you can use a global variable as [we do in our mu-plugin](https://github.com/pantheon-systems/pantheon-mu-plugin/blob/main/inc/fonts.php) or [remove the filter and then re-add it](https://github.com/WordPress/wordcamp.org/pull/1245/files#diff-e441f1053cefcd468bd20fed91d1aac5e902871d7c564be909fc35590f9c3082R635-R637).

For more information, refer to [this Gutenberg issue](https://github.com/WordPress/gutenberg/issues/58696).

</Alert>

## Considerations

The distinction between the two approaches for handling fonts depends what works best for your workflow and whether you consider your fonts to be handled more like media files or more like themes and plugins.

**If you consider fonts to be more like media files**, use the default Pantheon behavior added in our `mu-plugin`. This makes it easier to _install fonts onto production sites_ but perhaps more difficult to _synchronize_ those fonts on the lower environments (test and dev).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the default Pantheon filter, do fonts move between environments with a "clone files" workflow as expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few things I need to test. That's one. I also have a couple open questions that I posted in #core-editor Slack: https://wordpress.slack.com/archives/C02QB2JS7/p1707937998405009

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I smashed that subscribe button for more jazzsequence gutenberg goodness.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's what I'm seeing:

  1. Install font on live site
  2. Pull Live db down to Dev and sync files
  3. The font appears in the font manager but is not active
  4. Clicking into the font, selecting it and clicking update activates it

So, to answer your question, it does appear that they are pulled down when you clone the DB and files (I suspect you would need to clone the DB and files in order to get them), but there is an additional step to actually use them on the lower environment you pulled down to. I will update the doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And, to be clear, I think the "active" value is similar to Plugin/Theme "activation", meaning it's there it's just not "available". It's similar, I believe, to the fact that when I cloned down my DB and files from Live to Dev, my FSE theme was active, but the specific theme style that I was using on Live was not selected on Dev.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's curious that activation status doesn't carry through db clone the way plugin activation status would.

Copy link
Contributor Author

@jazzsequence jazzsequence Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not sure what this tells me exactly, because surely these settings are stored in the database somewhere, but whatever the full site editor is doing with styles, it's doing the same thing with fonts. ¯\_(ツ)_/¯


**If you consider fonts to be more like themes and plugins**, use the WordPress default behavior and the `pantheon_modify_fonts_dir` filter. This ensures that the fonts are installed across environments, but does not necessarily mean that fonts that are _physically installed_ on your lower environments (e.g. they exist in the `wp-content/fonts` directory) are recognized by WordPress. (They may still need to be added in the WordPress admin.)

## More Resources
* [Font Library Gutenberg Tracking Ticket](https://github.com/WordPress/gutenberg/issues/55277)
jazzsequence marked this conversation as resolved.
Show resolved Hide resolved
13 changes: 13 additions & 0 deletions source/releasenotes/2024-03-26-wordpress-6.5.md
jazzsequence marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: WordPress 6.5 (release name) Release
published_date: "2024-03-26"
categories: [wordpress]
---

The latest version of WordPress, [6.5 (release name)](), became available on Pantheon as of March 26, 2024.

<h3>Highlights</h3>

* WordPress 6.5 introduces the new [Font Library](). This feature allows you to upload fonts to your WordPress site or install any of the fonts available from Google's font library.
* By default, WordPress will store these fonts into the `wp-content/fonts` directory. On Pantheon, this directory is not writeable on live sites. We have added a feature to our [Pantheon MU Plugin](https://github.com/pantheon-systems/pantheon-mu-plugin) to store those fonts in a writeable `wp-content/uploads/fonts/` directory, so that you can use the feature without any issues after updating your sites to 6.5.
* If you would like to restore the original behavior and commit fonts to your site repository, refer to our [documentation](/guides/wordpress-configurations/wordpress-font-library).
Loading