Skip to content

Add wp widget patch command for nested option updates#72

Merged
swissspidy merged 8 commits intomainfrom
copilot/patch-widget-options
Mar 16, 2026
Merged

Add wp widget patch command for nested option updates#72
swissspidy merged 8 commits intomainfrom
copilot/patch-widget-options

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 14, 2026

  • Add patch method to Widget_Command class in src/Widget_Command.php
    • Add use WP_CLI\Traverser\RecursiveDataStructureTraverser; import
    • Implement patch method following Option_Command pattern from entity-command
  • Register widget patch in composer.json extra.commands
  • Add Behat acceptance tests in features/widget.feature
    • Remove failing echo 'null' | wp widget patch update ... --format=json test case
  • Run linting (composer lint) — ✅ passed
  • Run code style checks (composer phpcs) — ✅ passed
  • Run static analysis (composer phpstan) — ✅ passed
Original prompt

This section details on the original issue you should resolve

<issue_title>Patch widget options</issue_title>
<issue_description>The options for a widget are stored as a serialised array. There's no way of patching a field in a widget's options using wp widget update.

Possible syntax:

wp widget patch <widget-id> <field> <key-path>... [<value>]

Example usage:

wp widget patch archives-3 options title "My Site Archives"</issue_description>

Comments on the Issue (you are @copilot in this section)

@schlessera For consistency, we should use the same syntax as we do with the other patch commands: ``` wp widget patch ... [] ``` where `` is one of `insert`, `update`, `delete`.

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@github-actions github-actions bot added command:widget-update Related to 'widget update' command scope:documentation Related to documentation scope:testing Related to testing labels Mar 14, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 14, 2026

Codecov Report

❌ Patch coverage is 87.87879% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Widget_Command.php 87.87% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add patch options for widget fields Add wp widget patch command for nested option updates Mar 14, 2026
Copilot AI requested a review from swissspidy March 14, 2026 22:36
@swissspidy swissspidy marked this pull request as ready for review March 15, 2026 08:24
@swissspidy swissspidy requested a review from a team as a code owner March 15, 2026 08:24
Copilot AI review requested due to automatic review settings March 15, 2026 08:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new wp widget patch subcommand to support “patch-style” edits (insert/update/delete) of nested widget option values, aligning widget management with other WP‑CLI patch patterns.

Changes:

  • Introduces Widget_Command::patch() using RecursiveDataStructureTraverser to insert/update/delete nested option keys.
  • Adds Behat coverage for basic patch update/insert/delete flows and error cases.
  • Registers widget patch in the package’s bundled command list.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/Widget_Command.php Adds the patch subcommand implementation and wires it into widget option persistence.
features/widget.feature Adds a Behat scenario covering basic widget patch behavior and error handling.
composer.json Exposes widget patch as a bundled command.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

swissspidy and others added 2 commits March 15, 2026 22:51
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

Copilot AI requested a review from swissspidy March 16, 2026 12:04
@swissspidy swissspidy merged commit 8048b0c into main Mar 16, 2026
59 of 60 checks passed
@swissspidy swissspidy deleted the copilot/patch-widget-options branch March 16, 2026 14:42
@swissspidy swissspidy added this to the 2.2.1 milestone Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:widget-update Related to 'widget update' command scope:documentation Related to documentation scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Patch widget options

3 participants