Add type field to distinguish block themes from classic themes
Adding type field to distinguish block themes vs classic themes for wp theme get and wp theme list commands.
Summary
This PR adds a new type field that indicates whether a theme is a block or classic theme. The implementation uses WP_Theme::is_block_theme() (available since WordPress 5.9) with backward compatibility checks.
Changes Made
- [x] Add
typefield to$obj_fieldsin Theme_Command - [x] Modify
get_all_themes()method to detect and add theme type (block/classic) - [x] Update
get()method to includetypein theme variables - [x] Add
typeto$theme_varsarray so it displays by default - [x] Add tests for the new
typefield in theme.feature - [x] Update documentation for theme list command
- [x] Fix table spacing in test assertions
- [x] Run security checks (no issues found)
- [x] Verify all changes are minimal and focused
Implementation Details
-
Theme_Command.php: Added 'type' to
$obj_fieldsarray,$theme_varsarray, and updatedget()method to detect theme type -
ParseThemeNameInput.php: Added type detection in
get_all_themes()method - theme.feature: Added two test scenarios - one for block themes (@require-wp-5.9) and one for classic themes, and fixed table spacing
-
Documentation: Updated docblock for
theme listcommand to include 'type' field
The implementation includes proper backward compatibility by checking if the is_block_theme() method exists before calling it, ensuring it works with older WordPress versions.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Codecov Report
:x: Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/Theme_Command.php | 0.00% | 4 Missing :warning: |
| src/WP_CLI/ParseThemeNameInput.php | 0.00% | 4 Missing :warning: |
:loudspeaker: Thoughts on this report? Let us know!