Skip to content

Add wp icon and wp icon collection commands - #648

Merged
swissspidy merged 1 commit into
mainfrom
claude/svg-icons-collections-support-eb9e9u
Aug 26, 2026
Merged

Add wp icon and wp icon collection commands#648
swissspidy merged 1 commit into
mainfrom
claude/svg-icons-collections-support-eb9e9u

Conversation

@swissspidy

@swissspidy swissspidy commented Aug 26, 2026

Copy link
Copy Markdown
Member

Add new WP-CLI commands to manage WordPress SVG icons and icon collections, which were introduced in WordPress 7.0 and 7.1.

Summary

This adds comprehensive command-line support for the WordPress Icons API through two new command groups: wp icon and wp icon collection. These commands allow users to list, inspect, and render registered SVG icons and their collections.

Key Changes

  • Icon_Command.php: New command class with four subcommands:

    • wp icon list - List registered icons with filtering by collection and search term
    • wp icon get - Display detailed information about a specific icon
    • wp icon is-registered - Check if an icon is registered (useful in scripts)
    • wp icon render - Render an icon's SVG markup with customizable size, CSS classes, and accessible labels
  • Icon_Collection_Command.php: New command class with three subcommands:

    • wp icon collection list - List all registered icon collections with icon counts
    • wp icon collection get - Display details about a specific collection
    • wp icon collection is-registered - Check if a collection is registered
  • Feature tests: Comprehensive Behat test coverage for both command groups, including:

    • Basic listing and filtering operations
    • Icon and collection retrieval
    • Icon rendering with various options
    • Plugin-registered icons and collections
    • Version compatibility checks (WordPress 7.1+ required)
  • Configuration updates:

    • Register commands in entity-command.php with version check (WordPress 7.1+)
    • Add command names to composer.json for documentation generation
    • Update phpstan.neon.dist to suppress compatibility warnings for the new Icons API
    • Update phpcs.xml.dist to exclude new command files from certain checks

Implementation Details

  • Commands gracefully fail on WordPress versions < 7.1 with a clear error message
  • Icon rendering applies the same sizing and accessibility attributes as WordPress's front-end rendering
  • Search functionality matches both icon names and labels
  • Icon counts are dynamically calculated per collection
  • All output supports multiple formats (table, JSON, CSV, YAML, etc.)

https://claude.ai/code/session_01Gg5xvmNbnSSpXzmGmWu1xh

Summary by CodeRabbit

  • New Features

    • Added WP-CLI commands for listing, retrieving, and checking registered icons and icon collections.
    • Added SVG icon rendering with configurable size, CSS class, and accessibility label.
    • Added collection and icon filtering, detailed metadata, icon counts, and multiple output formats.
    • Added clear validation and error messages for unavailable collections, icons, invalid options, and unsupported WordPress versions.
  • Tests

    • Added comprehensive acceptance coverage for icon and icon collection commands, including WordPress 7.1 compatibility.

WordPress 7.1 introduced an Icons API where SVG icons are registered in
code with `wp_register_icon()` and grouped into collections registered
with `wp_register_icon_collection()`. Like font collections, they are
registry-based and only exist for the duration of a request, so the new
commands read and render them rather than creating or deleting them.

`wp icon list` supports filtering by collection and searching names and
labels, `wp icon get` exposes the registered SVG markup and the file an
icon is loaded from, and `wp icon render` applies the same sizing and
accessibility attributes that WordPress applies on the front end, so the
markup can be piped straight into a template.

Both commands abort on WordPress < 7.1 via `before_invoke`. The Icons
API is not covered by the WordPress stubs yet, so the PHPStan entries
for the unknown symbols use `reportUnmatched` to avoid becoming errors
themselves once the stubs catch up.

Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gg5xvmNbnSSpXzmGmWu1xh
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 99ce1254-4a5e-46ba-9015-7a3da1e09316

📥 Commits

Reviewing files that changed from the base of the PR and between acd3beb and e104bde.

📒 Files selected for processing (8)
  • composer.json
  • entity-command.php
  • features/icon-collection.feature
  • features/icon.feature
  • phpcs.xml.dist
  • phpstan.neon.dist
  • src/Icon_Collection_Command.php
  • src/Icon_Command.php

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Added WordPress 7.1-gated WP-CLI commands for listing, retrieving, checking, and rendering registered icons and icon collections. Added formatter support, SVG validation, compatibility configuration, and acceptance-test coverage.

Changes

Icon command support

Layer / File(s) Summary
Command registration and compatibility
src/Icon_Command.php, src/Icon_Collection_Command.php, entity-command.php, composer.json, phpcs.xml.dist, phpstan.neon.dist
The package registers icon and icon collection commands for WordPress 7.1 and newer. Static-analysis and coding-standard configuration covers the WordPress Icons API.
Icon collection operations
src/Icon_Collection_Command.php, features/icon-collection.feature
The collection commands list collections, retrieve collection metadata, report icon counts, check registration, normalize metadata, and support formatted output. Acceptance tests cover core, plugin-registered, missing, and unsupported collections.
Icon discovery and metadata
src/Icon_Command.php, features/icon.feature
The icon commands list and filter registered icons, retrieve metadata, check registration, and format registry values. Acceptance tests cover core icons, missing icons, collection filters, and output formats.
Icon rendering and validation
src/Icon_Command.php, features/icon.feature
The render command supports size, CSS class, accessibility label, and intrinsic sizing options. It validates icon names, sizes, and SVG output. Tests cover plugin-registered icons and WordPress version gating.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to e104b

This PR adds CLI support for managing registered SVG icons and collections; no actionable merge-blocking risk remains based on the current evidence.

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant Icon_Command
  participant IconsRegistry
  participant wp_get_icon
  CLI->>Icon_Command: render icon with size, class, and label
  Icon_Command->>IconsRegistry: retrieve registered icon
  Icon_Command->>wp_get_icon: render icon SVG
  wp_get_icon-->>Icon_Command: SVG markup
  Icon_Command-->>CLI: output rendered SVG
Loading

Suggested reviewers: brianhenryie

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: adding the wp icon and wp icon collection command groups.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 3 files. (5 skipped: 5…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 3 files. (5 skipped: 5 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/svg-icons-collections-support-eb9e9u

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added command:font Related to 'font' command command:font-collection Related to 'font collection' command labels Aug 26, 2026
@swissspidy
swissspidy marked this pull request as ready for review August 26, 2026 09:47
@swissspidy
swissspidy requested a review from a team as a code owner August 26, 2026 09:47
Copilot AI lite review requested due to automatic review settings August 26, 2026 09:47
@swissspidy swissspidy removed command:font Related to 'font' command command:font-collection Related to 'font collection' command labels Aug 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@swissspidy swissspidy added this to the 3.0.3 milestone Aug 26, 2026
@swissspidy swissspidy added command:icon Related to 'icon' command command:icon-collection Related to 'icon collection' command labels Aug 26, 2026
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.22222% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
entity-command.php 80.00% 1 Missing ⚠️
src/Icon_Collection_Command.php 97.67% 1 Missing ⚠️
src/Icon_Command.php 98.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Suppressed comments (1)

src/Icon_Command.php:306

  • In SVG, the attribute is case-sensitive and should be viewBox, not viewbox (the current example markup is invalid SVG/XML as written).
	 *     <svg aria-hidden="true" focusable="false" height="24" width="24" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24">

Comment thread src/Icon_Command.php
Comment thread phpcs.xml.dist
@swissspidy
swissspidy merged commit d58d4fe into main Aug 26, 2026
67 checks passed
@swissspidy
swissspidy deleted the claude/svg-icons-collections-support-eb9e9u branch August 26, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:icon Related to 'icon' command command:icon-collection Related to 'icon collection' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants