Skip to content

Add font library commands for WordPress 6.5+#567

Draft
Copilot wants to merge 19 commits intomainfrom
copilot/add-font-library-commands
Draft

Add font library commands for WordPress 6.5+#567
Copilot wants to merge 19 commits intomainfrom
copilot/add-font-library-commands

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

Font Library Commands Implementation

Overview

This PR adds WP-CLI commands for managing the WordPress Font Library (introduced in WordPress 6.5), covering font collections, families, and faces.

Commands Implemented

Font Collections

  • wp font collection list - List all registered collections
  • wp font collection get <slug> - Get collection details
  • wp font collection is-registered <slug> - Check if collection is registered
  • wp font collection list-families <slug> [--category=<slug>] - List font families in a collection, optionally filtered by category
  • wp font collection list-categories <slug> - List categories in a collection

Font Families (CRUD)

  • wp font family list - List all font families
  • wp font family get <id> - Get family details
  • wp font family create --post_title=<title> - Create new family
  • wp font family update <id> - Update existing family
  • wp font family delete <id>... - Delete font families
  • wp font family install <collection> <family> - Install a font family from a collection (creates family + all font faces)

Font Faces (CRUD)

  • wp font face list - List all font faces
  • wp font face get <id> - Get face details
  • wp font face create --post_parent=<id> --post_title=<title> - Create new face
  • wp font face update <id> - Update existing face
  • wp font face delete <id>... - Delete font faces
  • wp font face install <family-id> --src=<src> [options] - Install a font face with custom parameters

Implementation Details

  • All commands require WordPress 6.5+ (enforced via shared before_invoke hook)
  • Font families and faces use custom post types (wp_font_family, wp_font_face)
  • Font collections use the WordPress Font Library API (WP_Font_Library)
  • Follows existing patterns in entity-command package
  • Comprehensive Behat tests for all commands including new additions
  • All code quality checks pass (linting, PHPCS, PHPStan, PHPUnit)

Code Review Fixes Applied

✅ Fixed incorrect description field mapping in Font_Collection_Command
✅ Added safe array access with null coalescing operators
✅ Updated documentation examples to match actual field names (name vs post_title, parent vs post_parent)
✅ Updated Behat tests to use correct field names
✅ All quality checks passing

Original prompt

This section details on the original issue you should resolve

<issue_title>Add font library commands</issue_title>
<issue_description>Introduced in WordPress 6.5, the Font Library allows users to manage fonts directly in the editor. See https://make.wordpress.org/core/2024/03/14/new-feature-font-library/

There are font collections, which contain a predefined list of font families. A font family contains one or more font faces.

We should be able to follow WP_REST_Font_Collections_Controller, WP_REST_Font_Families_Controller and WP_REST_Font_Faces_Controller for implementing CRUD functionality for these entities. If everything lives under the wp font umbrella we can do:

  • wp font collection listget (collections can't be added or deleted)
  • wp font family list|get|add|delete
  • wp font face list|get|add|delete</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits January 19, 2026 12:17
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 83.17073% with 69 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Font_Collection_Command.php 75.23% 26 Missing ⚠️
src/Font_Family_Command.php 86.41% 22 Missing ⚠️
src/Font_Face_Command.php 85.50% 20 Missing ⚠️
entity-command.php 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive set of WP-CLI commands for managing the new Font Library feature from WordPress 6.5. The implementation is well-structured, follows existing patterns, and includes thorough Behat tests. The WordPress version check is also correctly implemented. I've identified one minor bug in the font collection get command and suggested a refactoring to reduce code duplication between the Font_Family_Command and Font_Face_Command classes. Overall, this is a great addition.

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy
Copy link
Member

Considering removing the font family & font face handling for now, as these could be handled via wp post --post_type=...

@swissspidy
Copy link
Member

@copilot review the current implementation here, consult https://make.wordpress.org/core/2024/03/14/new-feature-font-library/ & linked documentation and compare it with existing wp post ... commands to see how useful the new wp font family of commands is, and if something is missing

Copy link
Contributor Author

Copilot AI commented Mar 2, 2026

@copilot review the current implementation here, consult https://make.wordpress.org/core/2024/03/14/new-feature-font-library/ & linked documentation and compare it with existing `wp ...

Review: Font Library Commands vs wp post

After comprehensive analysis comparing with wp post commands and the Font Library documentation:

✅ Keep - Unique Value

Font Collection Commands (all 5 commands)

  • Collections use WP_Font_Library API, not post types
  • No wp post equivalent exists
  • Provides font discovery/browsing before installation
  • Commands: list, get, is-registered, list-families, list-categories

Install Commands (2 commands)

  • wp font family install google-fonts inter - Automates creating 1 family + all faces (9+) in one command
  • wp font face install <id> --src=<url> --font-weight=700 - Simplifies complex JSON structure
  • High-value convenience vs manual wp post create with complex JSON

⚠️ Reconsider - Duplicates wp post

Font Family/Face CRUD (10 commands total)

  • list, get, create, update, delete for both families and faces
  • These are thin wrappers around wp_insert_post(), WP_Query, etc.
  • Already achievable via wp post --post_type=wp_font_family

Comparison:

# Current
wp font family list
wp font family create --post_title="Arial"

# Equivalent with wp post
wp post list --post_type=wp_font_family
wp post create --post_type=wp_font_family --post_title="Arial"

Code Impact:

  • Font_Collection_Command: 419 lines ✅ (all unique)
  • Font_Family_Command: ~150 unique, ~380 duplicate
  • Font_Face_Command: ~130 unique, ~390 duplicate
  • ~770 lines of duplicated code

Recommendation: Option A (Minimal)

Keep: Collection commands + Install commands (~700 lines)
Remove: Basic CRUD commands (~770 lines)
Document: Using wp post for CRUD operations

This provides maximum value with minimum duplication while leveraging existing, well-tested infrastructure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add font library commands

3 participants