Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
58047b4
Initial plan
Copilot Jan 19, 2026
7bc9ba0
Add font library commands (collection, family, face)
Copilot Jan 19, 2026
83b0161
Fix Behat syntax in font-collection feature file
Copilot Jan 19, 2026
bfdbe14
Remove redundant version checks from command methods
Copilot Jan 19, 2026
2e49453
Refactor: Extract helper method and version check callback
Copilot Jan 19, 2026
7fe7f7a
Fix error message formatting for consistency
Copilot Jan 19, 2026
0850b36
Add `is-registered`
swissspidy Jan 19, 2026
9a2bfbb
Changes before error encountered
Copilot Jan 19, 2026
3d38b64
Add font library advanced commands (list-families, list-categories, i…
Copilot Jan 19, 2026
dae3d93
Add Behat tests for new font library commands
Copilot Jan 19, 2026
71c790c
Fix incorrect line endings
swissspidy Jan 19, 2026
18282ba
Some manual fixes
swissspidy Jan 19, 2026
d84384c
Address code review feedback: fix field names and array safety
Copilot Jan 19, 2026
2604149
Merge branch 'main' into copilot/add-font-library-commands
swissspidy Jan 22, 2026
2e97f1a
Tweak tests
swissspidy Jan 23, 2026
d0516dd
Merge branch 'main' into copilot/add-font-library-commands
swissspidy Feb 15, 2026
273e156
Merge branch 'main' into copilot/add-font-library-commands
swissspidy Feb 23, 2026
c537a7f
Merge branch 'main' into copilot/add-font-library-commands
swissspidy Mar 2, 2026
021f0f8
PHPStan fix
swissspidy Mar 2, 2026
f0b9178
Remove font family/face CRUD commands, keep install commands only
Copilot Mar 10, 2026
58fe6d5
Merge branch 'main' into copilot/add-font-library-commands
swissspidy Mar 10, 2026
7a88c0c
Formatting fixes
swissspidy Mar 10, 2026
f6cb7e7
Fix code review issues: field names, types, docblocks, error messages
Copilot Mar 10, 2026
437a438
Update src/Font_Face_Command.php
swissspidy Mar 10, 2026
f9ee5a2
Extract format_categories helper to remove duplicated formatting logic
Copilot Mar 10, 2026
80b8598
Fix Behat test to include categories column in font collection list
Copilot Mar 10, 2026
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
21 changes: 21 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@
"comment unspam",
"comment untrash",
"comment update",
"font",
"font collection",
"font collection get",
"font collection is-registered",
"font collection list",
"font collection list-categories",
"font collection list-families",
"font face",
"font face create",
"font face delete",
"font face get",
"font face install",
"font face list",
"font face update",
"font family",
"font family create",
"font family delete",
"font family get",
"font family install",
"font family list",
"font family update",
"menu",
"menu create",
"menu delete",
Expand Down
16 changes: 16 additions & 0 deletions entity-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,19 @@
},
)
);

if ( class_exists( 'WP_CLI\Dispatcher\CommandNamespace' ) ) {
WP_CLI::add_command( 'font', 'Font_Namespace' );
}

$wpcli_entity_font_version_check = array(
'before_invoke' => function () {
if ( Utils\wp_version_compare( '6.5', '<' ) ) {
WP_CLI::error( 'Requires WordPress 6.5 or greater.' );
}
},
);

WP_CLI::add_command( 'font collection', 'Font_Collection_Command', $wpcli_entity_font_version_check );
WP_CLI::add_command( 'font family', 'Font_Family_Command', $wpcli_entity_font_version_check );
WP_CLI::add_command( 'font face', 'Font_Face_Command', $wpcli_entity_font_version_check );
82 changes: 82 additions & 0 deletions features/font-collection.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
Feature: Manage WordPress font collections

Background:
Given a WP install

@require-wp-6.5
Scenario: Listing font collections
When I try `wp font collection list`
Then STDOUT should be a table containing rows:
| slug | name | description |
| google-fonts | Google Fonts | Install from Google Fonts. Fonts are copied to and served from your site. |

@require-wp-6.5
Scenario: Getting a non-existent font collection
When I try `wp font collection get nonexistent-collection`
Then the return code should be 1
And STDERR should contain:
"""
doesn't exist
"""

@require-wp-6.5
Scenario: Checking whether a font collection is registered
When I try `wp font collection is-registered nonexistent-collection`
Then the return code should be 1

When I run `wp font collection is-registered google-fonts`
Then the return code should be 0

@require-wp-6.5
Scenario: Listing font families in a collection
When I run `wp font collection list-families google-fonts --format=count`
Then STDOUT should be a number

@require-wp-6.5
Scenario: Listing font families in a collection with fields
When I run `wp font collection list-families google-fonts --fields=slug,name --format=csv`
Then STDOUT should contain:
"""
slug,name
"""

@require-wp-6.5
Scenario: Filtering font families by category
When I run `wp font collection list-families google-fonts --category=sans-serif --format=count`
Then STDOUT should be a number

@require-wp-6.5
Scenario: Listing categories in a collection
When I run `wp font collection list-categories google-fonts --format=csv`
Then STDOUT should contain:
"""
slug,name
"""

@require-wp-6.5
Scenario: Getting a non-existent collection for list-families
When I try `wp font collection list-families nonexistent-collection`
Then the return code should be 1
And STDERR should contain:
"""
doesn't exist
"""

@require-wp-6.5
Scenario: Getting a non-existent collection for list-categories
When I try `wp font collection list-categories nonexistent-collection`
Then the return code should be 1
And STDERR should contain:
"""
doesn't exist
"""

@less-than-wp-6.5
Scenario: Font collection commands fail on WordPress < 6.5
Given a WP install
When I try `wp font collection list`
Then the return code should be 1
And STDERR should contain:
"""
Requires WordPress 6.5 or greater
"""
192 changes: 192 additions & 0 deletions features/font-face.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
Feature: Manage WordPress font faces

Background:
Given a WP install

@require-wp-6.5
Scenario: Creating a font face
Given I run `wp font family create --post_title="Test Family" --porcelain`
And save STDOUT as {FONT_FAMILY_ID}

When I run `wp font face create --post_parent={FONT_FAMILY_ID} --post_title="Regular" --porcelain`
Then STDOUT should be a number
And save STDOUT as {FONT_FACE_ID}

When I run `wp font face get {FONT_FACE_ID} --field=post_title`
Comment thread
swissspidy marked this conversation as resolved.
Outdated
Then STDOUT should be:
"""
Regular
"""

@require-wp-6.5
Scenario: Listing font faces
Given I run `wp font family create --post_title="Test Family" --porcelain`
And save STDOUT as {FONT_FAMILY_ID}
And I run `wp font face create --post_parent={FONT_FAMILY_ID} --post_title="Regular" --porcelain`
And save STDOUT as {FACE1}
And I run `wp font face create --post_parent={FONT_FAMILY_ID} --post_title="Bold" --porcelain`
And save STDOUT as {FACE2}

When I run `wp font face list --format=csv --fields=ID,post_title,post_parent`
Comment thread
swissspidy marked this conversation as resolved.
Outdated
Then STDOUT should contain:
"""
Regular
"""
And STDOUT should contain:
"""
Bold
"""

@require-wp-6.5
Scenario: Listing font faces by family
Given I run `wp font family create --post_title="Family One" --porcelain`
And save STDOUT as {FAMILY1}
And I run `wp font family create --post_title="Family Two" --porcelain`
And save STDOUT as {FAMILY2}
And I run `wp font face create --post_parent={FAMILY1} --post_title="F1 Regular" --porcelain`
And I run `wp font face create --post_parent={FAMILY2} --post_title="F2 Regular" --porcelain`

When I run `wp font face list --post_parent={FAMILY1} --format=csv --fields=post_title`
Comment thread
swissspidy marked this conversation as resolved.
Outdated
Then STDOUT should contain:
"""
F1 Regular
"""
And STDOUT should not contain:
"""
F2 Regular
"""

@require-wp-6.5
Scenario: Getting a font face
Given I run `wp font family create --post_title="Test Family" --porcelain`
And save STDOUT as {FONT_FAMILY_ID}
And I run `wp font face create --post_parent={FONT_FAMILY_ID} --post_title="Bold" --porcelain`
And save STDOUT as {FONT_FACE_ID}

When I try `wp font face get {FONT_FACE_ID}`
Then the return code should be 0
And STDOUT should contain:
"""
Bold
"""

@require-wp-6.5
Scenario: Updating a font face
Given I run `wp font family create --post_title="Test Family" --porcelain`
And save STDOUT as {FONT_FAMILY_ID}
And I run `wp font face create --post_parent={FONT_FAMILY_ID} --post_title="Old Name" --porcelain`
And save STDOUT as {FONT_FACE_ID}

When I run `wp font face update {FONT_FACE_ID} --post_title="New Name"`
Then STDOUT should contain:
"""
Success: Updated font face
"""

When I run `wp font face get {FONT_FACE_ID} --field=post_title`
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The Behat test uses --field=post_title but the actual field name in the implementation is 'name'. This test will fail because the items array returned by the get method uses 'name' as the key, not 'post_title'. The test should use --field=name instead.

Copilot uses AI. Check for mistakes.
Then STDOUT should be:
"""
New Name
"""

@require-wp-6.5
Scenario: Deleting a font face
Given I run `wp font family create --post_title="Test Family" --porcelain`
And save STDOUT as {FONT_FAMILY_ID}
And I run `wp font face create --post_parent={FONT_FAMILY_ID} --post_title="Delete Me" --porcelain`
And save STDOUT as {FONT_FACE_ID}

When I run `wp font face delete {FONT_FACE_ID}`
Then STDOUT should contain:
"""
Success: Deleted font face
"""

When I try `wp font face get {FONT_FACE_ID}`
Then the return code should be 1
And STDERR should contain:
"""
doesn't exist
"""

@require-wp-6.5
Scenario: Creating a font face requires parent
When I try `wp font face create --post_title="Regular"`
Then the return code should be 1
And STDERR should contain:
"""
--post_parent parameter is required
"""

@require-wp-6.5
Scenario: Creating a font face with invalid parent
When I try `wp font face create --post_parent=999999 --post_title="Regular"`
Then the return code should be 1
And STDERR should contain:
"""
doesn't exist
"""

@require-wp-6.5
Scenario: Installing a font face
Given I run `wp font family create --post_title="Test Family" --porcelain`
And save STDOUT as {FONT_FAMILY_ID}

When I run `wp font face install {FONT_FAMILY_ID} --src="https://example.com/font.woff2" --porcelain`
Then STDOUT should be a number
And save STDOUT as {FONT_FACE_ID}

When I run `wp font face get {FONT_FACE_ID} --field=post_parent`
Comment thread
swissspidy marked this conversation as resolved.
Outdated
Then STDOUT should be:
"""
{FONT_FAMILY_ID}
"""

@require-wp-6.5
Scenario: Installing a font face with custom properties
Given I run `wp font family create --post_title="Test Family" --porcelain`
And save STDOUT as {FONT_FAMILY_ID}

When I run `wp font face install {FONT_FAMILY_ID} --src="font.woff2" --font-weight=700 --font-style=italic --porcelain`
Then STDOUT should be a number
And save STDOUT as {FONT_FACE_ID}

When I run `wp font face get {FONT_FACE_ID} --field=post_title`
Comment thread
swissspidy marked this conversation as resolved.
Outdated
Then STDOUT should contain:
"""
700
"""
And STDOUT should contain:
"""
italic
"""

@require-wp-6.5
Scenario: Installing a font face with invalid parent
When I try `wp font face install 999999 --src="font.woff2"`
Then the return code should be 1
And STDERR should contain:
"""
doesn't exist
"""

@require-wp-6.5
Scenario: Installing a font face without required src parameter
Given I run `wp font family create --post_title="Test Family" --porcelain`
And save STDOUT as {FONT_FAMILY_ID}

When I try `wp font face install {FONT_FAMILY_ID}`
Then the return code should be 1
And STDERR should contain:
"""
--src parameter is required
"""

@less-than-wp-6.5
Scenario: Font face commands fail on WordPress < 6.5
When I try `wp font face list`
Then the return code should be 1
And STDERR should contain:
"""
Requires WordPress 6.5 or greater
"""
Loading
Loading