Skip to content

Add type field to distinguish block themes from classic themes - #477

Merged
swissspidy merged 10 commits into
mainfrom
copilot/add-theme-type-field
Jan 20, 2026
Merged

swissspidy merged 10 commits into
mainfrom
copilot/add-theme-type-field

Conversation

Copilot AI commented Nov 11, 2025 •

Copy link
Copy Markdown
Contributor

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

  • Add type field to $obj_fields in Theme_Command
  • Modify get_all_themes() method to detect and add theme type (block/classic)
  • Update get() method to include type in theme variables
  • Add type to $theme_vars array so it displays by default
  • Add tests for the new type field in theme.feature
  • Update documentation for theme list command
  • Fix table spacing in test assertions
  • Run security checks (no issues found)
  • 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 AI and others added 2 commits November 11, 2025 09:04
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add theme type distinction for wp theme commands Add type field to distinguish block themes from classic themes Nov 11, 2025
Copilot AI requested a review from swissspidy November 11, 2025 09:09
@swissspidy swissspidy added command:theme-get Related to 'theme get' command command:theme-list Related to 'theme list' command labels Nov 11, 2025
@swissspidy swissspidy added this to the 2.2.1 milestone Nov 11, 2025
@codecov

codecov Bot commented Nov 11, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ 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 ⚠️
src/WP_CLI/ParseThemeNameInput.php 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy
swissspidy marked this pull request as ready for review November 11, 2025 13:04
@swissspidy
swissspidy requested a review from a team as a code owner November 11, 2025 13:04

This comment was marked as resolved.

swissspidy and others added 2 commits December 19, 2025 10:41
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy swissspidy linked an issue Dec 22, 2025 that may be closed by this pull request
@swissspidy
swissspidy merged commit 19c1410 into main Jan 20, 2026
69 of 83 checks passed
@swissspidy
swissspidy deleted the copilot/add-theme-type-field branch January 20, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:theme-get Related to 'theme get' command command:theme-list Related to 'theme list' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Distinguish block themes vs classic themes

3 participants