Skip to content

Implement wp site get command to enable site operations by URL#571

Open
Copilot wants to merge 7 commits intomainfrom
copilot/allow-delete-site-with-url
Open

Implement wp site get command to enable site operations by URL#571
Copilot wants to merge 7 commits intomainfrom
copilot/allow-delete-site-with-url

Conversation

Copy link
Contributor

Copilot AI commented Feb 4, 2026

  • Understand existing codebase and site command structure
  • Implement wp site get command that accepts site ID or URL
  • Add support for fetching site by URL (domain/path lookup)
  • Add proper field formatting with WP_CLI\Formatter
  • Create Behat tests for the new command
  • Test the command with various scenarios (ID, URL, field output)
  • Update documentation with usage examples
  • Run code quality checks (lint, phpcs, phpstan)
  • Verify all site.feature tests pass
  • Address code review feedback (refactor field casting, improve test reliability)
  • Use WordPress's cached get_blog_id_from_url() function for URL lookups
Original prompt

This section details on the original issue you should resolve

<issue_title>site delete: allow deleting a site with the --url option</issue_title>
<issue_description>## Feature Request

Describe your use case and the problem you are facing

Currently the blog ID or slug must be specified when using the command. In cases where a custom domain is used, however, the --slug option fails and it is tedious to look up the assigned site ID in an automated use case.

Describe the solution you'd like

Allow site deletion by only specifying the --url option. For example: wp site delete --url="http://example.com".
</issue_description>

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

@swissspidy We could implement `wp site get ` instead, then one could pair `wp site delete` with `wp site get http://example.com --field=id`. This would be more in line with all the other commands.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@github-actions github-actions bot added command:network-meta-delete Related to 'network meta delete' command command:network-meta-get Related to 'network meta get' command command:network Related to 'network' command labels Feb 4, 2026
@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

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

Files with missing lines Patch % Lines
src/Site_Command.php 0.00% 31 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI and others added 4 commits February 4, 2026 16:34
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
… reliability

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add option to delete site using --url Implement wp site get command to enable site operations by URL Feb 4, 2026
Copilot AI requested a review from swissspidy February 4, 2026 16:56
@swissspidy swissspidy requested a review from Copilot February 4, 2026 19:07

This comment was marked as resolved.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@swissspidy swissspidy marked this pull request as ready for review February 5, 2026 06:28
@swissspidy swissspidy requested a review from a team as a code owner February 5, 2026 06:28
$site = null;

// Check if the argument is a URL (contains :// or starts with www.)
if ( false !== strpos( $site_arg, '://' ) || 0 === strpos( $site_arg, 'www.' ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

@copilot can we use get_blog_id_from_url here? it's cached. signature: function get_blog_id_from_url( $domain, $path = '/' ): int (returns 0 if no blog found, otherwise the ID of the matching blog.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Refactored to use get_blog_id_from_url() instead of the direct database query. This provides better performance through caching and uses the standard WordPress API. (e91a6e5)

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

Copilot AI commented Feb 5, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • ace4d8.example.com
    • Triggering command: /usr/bin/php /usr/bin/php /home/REDACTED/work/entity-command/entity-command/vendor/wp-cli/wp-cli/bin/../php/boot-fs.php core install-network --title=WP CLI Network --subdomains=1 (dns block)
  • example.com
    • Triggering command: /usr/bin/php /usr/bin/php /home/REDACTED/work/entity-command/entity-command/vendor/wp-cli/wp-cli/bin/../php/boot-fs.php core install --url=REDACTED --title=WP CLI Site --admin_user=admin --admin_email=admin@example.com --admin_password=password1 --skip-email (dns block)
    • Triggering command: /usr/bin/php /usr/bin/php /home/REDACTED/work/entity-command/entity-command/vendor/wp-cli/wp-cli/bin/../php/boot-fs.php core install --url=REDACTED --title=WP CLI Site --admin_user=admin --admin_email=admin@example.com --admin_password=password1 --skip-email de/node/bin/sh sh -cli�� /entity-command/vendor/wp-cli/wp/tmp/wp-cli-test-core-download-cache/wp-activate.php list vendor/bin/wp site deactivate (dns block)
    • Triggering command: /usr/bin/php /usr/bin/php /home/REDACTED/work/entity-command/entity-command/vendor/wp-cli/wp-cli/bin/../php/boot-fs.php core install --url=REDACTED --title=WP CLI Site --admin_user=admin --admin_email=admin@example.com --admin_password=password1 --skip-email k/entity-commandfeatures/site.feature:785 sh -cli�� 42241&#39; create de/node/bin/sh &#39;/* &#39;/tmp/wp-climysql sh tnet/tools/sh sh (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

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

Labels

command:network Related to 'network' command command:network-meta-delete Related to 'network meta delete' command command:network-meta-get Related to 'network meta get' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

site delete: allow deleting a site with the --url option

2 participants