-
Notifications
You must be signed in to change notification settings - Fork 676
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CMSP-695] WordPress 6.5 font library documentation and behavior (#8867)
* add draft release notes for WP 6.5 font library * add a guide under WordPress Configuration that talks about the WP Font Library * rename the release note with the expected release date * remove nonfunctional links * add g'berg issue * update notes to maintain consistency * update publish date * add troubleshooting info if the FS is not writeable * some copy changes * fix image url * add new screenshots * update info about handling fonts like media files * update troubleshooting steps * add one more troubleshooting Q & A * specify in the admin * Be more clear that this only happens if you've changed the Pantheon setting Co-authored-by: Phil Tyler <[email protected]> * remove references to "restoring wp default behavior" * note how we prioritized our filter * add details to how 'active' fonts work * update copy about post type this was already noted in the considerations, so we don't need to explain it again here * simplify language Co-authored-by: Phil Tyler <[email protected]> * more simplification Co-authored-by: Phil Tyler <[email protected]> * clarify introductory paragraph * discuss (new) wp default behavior and why we're keeping our mu-plugin behavior * remove note, this is no longer an issue * update language about overriding our font_dir filter * add our G'berg issue for font handling for manual uploads * add link to more resources * remove release notes for wp 6.5 from this PR * remove link to release post (that doesn't exist) so we can publish this page sooner * add new plugin tag for PAPC release note * add a new release note for the MU plugin release * note when developing locally Co-authored-by: Phil Tyler <[email protected]> * remove unrelated release note update Co-authored-by: Phil Tyler <[email protected]> --------- Co-authored-by: Phil Tyler <[email protected]>
- Loading branch information
1 parent
34b4087
commit 89516a0
Showing
5 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
source/content/guides/wordpress-configurations/07-wordpress-font-library.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
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 introduces a new [Font Library](https://make.wordpress.org/core/2024/03/14/new-feature-font-library/) feature. The Font Library allows you to upload fonts from your computer or add any of the fonts available on Google's font library to your WordPress site. In anticipation of this, Pantheon has added a feature to our [Pantheon MU Plugin](https://github.com/pantheon-systems/pantheon-mu-plugin) to store those fonts in a writeable directory (`wp-content/uploads/fonts/`), so that you can use the feature without any issues after updating your sites to 6.5. | ||
|
||
By default, WordPress will install fonts into `wp-content/fonts/` if it is writeable. If `wp-content/fonts/` is not writeable, like on Pantheon environments, WordPress will install fonts into `wp-content/uploads/fonts/`. This can create inconsistency when developing locally if WordPress is using its default behavior because your `wp-content/fonts/` is likely to be writeable on your local environment. In this instance, fonts installed _on Pantheon_ would be stored in `wp-content/uploads/fonts` but fonts installed _locally_ would be stored in `wp-content/fonts`, which is why we have altered the behavior in the mu-plugin. | ||
|
||
## Using the `font_dir` Filter | ||
|
||
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; | ||
} ); | ||
``` | ||
|
||
The default priority for WordPress filters is `10`. We have set _our_ `font_dir` filter to priority `9` so it allows you to override our modification. | ||
|
||
## Considerations | ||
|
||
WordPress handles fonts more like **media files** than **plugins or themes**. This means that when fonts are added to one Pantheon site environment, they will not necessarily exist in your other environments (e.g. installing a font on Dev does not mean it will push to Test when you deploy). In WordPress, fonts have two parts, there is a font post type (similar to the `attachment` post type for media files) and the font files themselves. Without the font post type existing in the database, WordPress has no way of knowing that a font is installed (in the same way that WordPress has no way that a particular image exists in the `/uploads` directory if it was not uploaded via the media library). | ||
|
||
If you intend to override the Pantheon behavior, know that committing font files to your repository will not make them available automatically on your other environments. | ||
|
||
## Troubleshooting | ||
|
||
### "No font faces were installed" error message | ||
|
||
![No font faces were installed](../../../images/wordpress-configurations/07-no-font-faces-installed.png) | ||
|
||
If you have altered the `font_dir` path and are uploading to a directory that is not writeable, you may see this error message. Ensure that the directory you are using in your `font_dir` filter is writeable (e.g. in `wp-content/uploads/`). | ||
|
||
### I've cloned my database from Live and my font is installed but not "active" | ||
|
||
![Font is installed but not active](../../../images/wordpress-configurations/07-font-installed-not-active.png) | ||
|
||
If you've cloned your database and files from your live environment to Dev or Test and the font appears in your Font Library but is not "active" (it displays a message like "0/1 variants active"), you can click into the font, select the variant you want, and click update. | ||
|
||
![Update Font](../../../images/wordpress-configurations/07-font-update.png) | ||
|
||
Whether or not a font is "active" is similar to whether or not a plugin or theme is active. If a font is not active, it means the font is installed and recognized by WordPress but it cannot be used on the site until you activate it. | ||
|
||
### I've uploaded fonts to my `/fonts` directory, but they aren't showing up in the Font Library | ||
|
||
Fonts need to be installed via the Font Library in the WordPress admin. This is because fonts contain data that is stored in a post type. Simply having a font in your `/fonts` directory does not mean it will be recognized by WordPress. See [this Gutenberg issue](https://github.com/WordPress/gutenberg/issues/59102) to track this in WordPress core. | ||
|
||
## More Resources | ||
* [New Feature: Font Library](https://make.wordpress.org/core/2024/03/14/new-feature-font-library/) | ||
* [Font Library Gutenberg Tracking Ticket](https://github.com/WordPress/gutenberg/issues/55277) |
Binary file added
BIN
+49.3 KB
source/images/wordpress-configurations/07-font-installed-not-active.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: Pantheon MU Plugin v1.3.3 updates | ||
published_date: "2024-03-04" | ||
categories: [wordpress, plugins] | ||
--- | ||
|
||
WordPress 6.5 will add a new [Font Library](https://make.wordpress.org/core/2024/03/14/new-feature-font-library/) feature. The Font Library allows you to upload fonts from your computer or add any of the fonts available on Google's font library to your WordPress site. In anticipation of this, Pantheon has added a feature to our [Pantheon MU Plugin](https://github.com/pantheon-systems/pantheon-mu-plugin) to support the new Font Library feature. You can read more about the Font Library feature in our [guide to using the Font Library on Pantheon](/guides/wordpress-configurations/wordpress-font-library). |