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 33 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,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 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.
jazzsequence marked this conversation as resolved.
Show resolved Hide resolved

## 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)
jazzsequence marked this conversation as resolved.
Show resolved Hide resolved
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.
7 changes: 7 additions & 0 deletions source/releasenotes/2024-03-04-pantheon-mu-plugin-1-3-3.md
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).
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Enhancements in Pantheon Advanced Page Cache v1.5.0
published_date: "2024-03-11"
categories: [wordpress]
categories: [wordpress, plugins]
jazzsequence marked this conversation as resolved.
Show resolved Hide resolved
---

Pantheon Advanced Page Cache v1.5.0 is now available on [WordPress.org](https://wordpress.org/plugins/pantheon-advanced-page-cache/) and [GitHub](https://github.com/pantheon-systems/pantheon-advanced-page-cache/releases/tag/1.5.0). This release adds a new filter to make cache purges less aggressive and provide more flexibility for developers and the sites they maintain. You can learn about the filter in the plugin's [README file](https://github.com/pantheon-systems/pantheon-advanced-page-cache?tab=readme-ov-file#ignoring-specific-post-types) which includes an example of how to use it.
Expand Down
Loading