Skip to content

Conversation

@iamsohilvahora
Copy link
Contributor

Description

This PR extends the wp sidebar command with additional subcommands to make sidebar management more complete and consistent with other WP-CLI commands.

New subcommands added

  • wp sidebar get <id>
    Retrieve details for a specific registered sidebar.

  • wp sidebar exists <id>
    Check whether a sidebar exists (returns appropriate exit codes).

  • wp sidebar widgets <id>
    List widgets assigned to a given sidebar.

@iamsohilvahora iamsohilvahora requested a review from a team as a code owner January 28, 2026 08:13
@github-actions
Copy link

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

@gemini-code-assist

This comment was marked as resolved.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request extends the wp sidebar command with get, exists, and widgets subcommands, which is a great addition for more complete sidebar management. The implementation is generally solid, but I've found a recurring bug in all new subcommands where wp_register_unused_sidebar() is not called. This will lead to failures when operating on the inactive widgets sidebar. I've also suggested restoring some documentation for the list command that was removed and a minor readability improvement in the widgets command. Overall, great work on expanding the command's functionality.

@iamsohilvahora
Copy link
Contributor Author

720ded9

@swissspidy
Copy link
Member

Thanks for your PR.

Haven't looked at the code or the failing test yet, but a quick question:

How is "wp sidebar widgets" different from the already existing "wp widget list" command? We don't want to duplicate functionality.

@iamsohilvahora
Copy link
Contributor Author

@swissspidy

  • wp widget list

    • What it does:
      • Lists all available widget types on the site.
    • Think of it as:
      • “What widgets exist and can be used?”
  • wp sidebar widgets

    • What it does:
      • Shows which widgets are actually assigned to sidebars.
    • Think of it as:
      • “Which widgets are currently in use and where?”

@swissspidy
Copy link
Member

I'm afraid that's incorrect. Have you tried using & comparing the two commands?

wp widget list lists widgets associated with a sidebar (using wp_get_sidebars_widgets(). You get the widget name, ID, position, etc.

@iamsohilvahora
Copy link
Contributor Author

@swissspidy

0e6d9d1

@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Sidebar_Command.php 0.00% 14 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy
Copy link
Member

This is still lacking test coverage. If you could add Behat tests for these new commands I'll happily take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants