Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@
"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 install",
"font family",
"font family install",
"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 @@ -113,3 +113,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 | categories |
| google-fonts | Google Fonts | Install from Google Fonts. Fonts are copied to and served from your site. | Sans Serif (sans-serif), Display (display), Serif (serif), Handwriting (handwriting), Monospace (monospace) |

@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
"""
68 changes: 68 additions & 0 deletions features/font-face.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Feature: Manage WordPress font faces

Background:
Given a WP install

@require-wp-6.5
Scenario: Installing a font face
Given I run `wp post create --post_type=wp_font_family --post_title="Test Family" --post_status=publish --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 post get {FONT_FACE_ID} --field=post_parent`
Then STDOUT should be:
"""
{FONT_FAMILY_ID}
"""

@require-wp-6.5
Scenario: Installing a font face with custom properties
Given I run `wp post create --post_type=wp_font_family --post_title="Test Family" --post_status=publish --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 post get {FONT_FACE_ID} --field=post_title`
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 post create --post_type=wp_font_family --post_title="Test Family" --post_status=publish --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:
"""
missing --src parameter
"""

@less-than-wp-6.5
Scenario: Font face install commands fail on WordPress < 6.5
When I try `wp font face install 1 --src=test.woff2`
Then the return code should be 1
And STDERR should contain:
"""
Requires WordPress 6.5 or greater
"""
46 changes: 46 additions & 0 deletions features/font-family.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Feature: Manage WordPress font families

Background:
Given a WP install

@require-wp-6.5
Scenario: Installing a font family from a collection
When I run `wp font family install google-fonts "roboto" --porcelain`
Then STDOUT should be a number
And save STDOUT as {FONT_FAMILY_ID}

When I run `wp post get {FONT_FAMILY_ID} --field=post_title`
Then STDOUT should contain:
"""
Roboto
"""

When I run `wp post list --post_type=wp_font_face --post_parent={FONT_FAMILY_ID} --format=count`
Then STDOUT should be a number

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

@require-wp-6.5
Scenario: Installing a non-existent font family from a collection
When I try `wp font family install google-fonts nonexistent-family`
Then the return code should be 1
And STDERR should contain:
"""
not found
"""

@less-than-wp-6.5
Scenario: Font family install commands fail on WordPress < 6.5
When I try `wp font family install google-fonts roboto`
Then the return code should be 1
And STDERR should contain:
"""
Requires WordPress 6.5 or greater
"""
2 changes: 2 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound">
<exclude-pattern>*/src/Taxonomy_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Comment(_Meta)?_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Font(_Collection|_Face|_Family)?_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Font_Namespace\.php$</exclude-pattern>
<exclude-pattern>*/src/Menu(_Item|_Location)?_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Network_Meta_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Network_Namespace\.php$</exclude-pattern>
Expand Down
Loading