extension-command icon indicating copy to clipboard operation
extension-command copied to clipboard

Add type field to distinguish block themes from classic themes

Open Copilot opened this issue 3 months ago • 1 comments

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 type field to $obj_fields in Theme_Command
  • [x] Modify get_all_themes() method to detect and add theme type (block/classic)
  • [x] Update get() method to include type in theme variables
  • [x] Add type to $theme_vars array so it displays by default
  • [x] Add tests for the new type field 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

  1. Theme_Command.php: Added 'type' to $obj_fields array, $theme_vars array, and updated get() method to detect theme type
  2. ParseThemeNameInput.php: Added type detection in get_all_themes() method
  3. theme.feature: Added two test scenarios - one for block themes (@require-wp-5.9) and one for classic themes, and fixed table spacing
  4. Documentation: Updated docblock for theme list command 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.

Copilot avatar Nov 11 '25 08:11 Copilot

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!

codecov[bot] avatar Nov 11 '25 11:11 codecov[bot]