Skip to content

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.

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 0% with 409 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Font_Family_Command.php 0.00% 162 Missing ⚠️
src/Font_Face_Command.php 0.00% 142 Missing ⚠️
src/Font_Collection_Command.php 0.00% 105 Missing ⚠️

📢 Thoughts on this report? Let us know!

@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.

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.

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.

*
* @package wp-cli
*/
class Font_Family_Command extends WP_CLI_Command {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This class shares a lot of duplicated logic with Font_Face_Command for CRUD operations (list_, get, create, update, delete) since both operate on custom post types.

Consider creating a common abstract base class (e.g., Font_Post_Type_Command) that both Font_Family_Command and Font_Face_Command can extend. This base class could contain the shared logic for these operations, using abstract methods or properties to handle the parts that differ (like post_type, entity_name, and the fields to display).

This would significantly reduce code duplication and improve maintainability.

This comment was marked as resolved.

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

2 participants