Skip to content

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

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/allow-delete-site-with-url
Draft

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

Conversation

Copy link
Contributor

Copilot AI commented Feb 4, 2026

Multisite installations with custom domains couldn't easily delete sites by URL - only by ID or slug, which required manual lookup in automated workflows.

Implementation

Adds wp site get <site> command that accepts both site IDs and full URLs:

URL detection and lookup

  • Parses URLs via wp_parse_url() to extract domain and path
  • Queries wp_blogs table by domain and path for URL-based lookups
  • Falls back to existing fetcher for numeric IDs

Output formatting

  • Returns site details via WP_CLI\Formatter with standard format options
  • Default fields: blog_id, url, last_updated, registered
  • Optional fields: site_id, domain, path, public, archived, mature, spam, deleted, lang_id
  • Supports --field parameter for single field extraction

Command registration

  • Added to composer.json commands list

Usage

# Get site ID from URL
$ wp site get http://example.com/subdir/ --field=blog_id
2

# Delete site by URL
$ wp site delete $(wp site get http://example.com/subdir/ --field=blog_id) --yes
Success: The site at 'http://example.com/subdir/' was deleted.

Follows the pattern established by wp user get and wp post get for consistency with existing commands.

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:

  • 2b53fd.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 signup h bobuser --field=active (dns block)
  • 417b4e.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 install-network k/entity-commandfeatures/site.feature --subdomains=0 deactivate vendor/bin/wp sh vend�� site etwork /entity-command/vendor/wp-cli/wp-cli/bin/wp -cli/bin/wp create rgo/bin/sh /entity-command/vendor/wp-cli/wp-cli/bin/wp (dns block)
  • 6750df.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 install-network vendor/bin/sh --subdomains=0 /tmp/wp-cli-test/home/REDACTED/work/entity-command/entity-command/vendor/wp-cli/wp-cli�� mposer/vendor/bisite sh vend�� l &amp;&amp; debian-sa1 foo option mposer/vendor/bin/sh option_name --format=json sh sh (dns block)
  • 75a777.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 features/site-create.feature /usr/local/.ghcup/bin/mysql src/User_Applicawhich list /entity-command/vendor/bin/sh ode /ent�� ith-url dirname (dns block)
  • de6696.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 _Command.php cal/bin/bash site.*url foreSuiteTested.--version cal/bin/grep grep -l site.*url ./src/Network_Namespace.php mposer/vendor/bin/git site.*url n_Command.php /usr/bin/grep grep (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 ep grep ehat�� function url vendor/wp-cli/wp-cli/bundle/rmccue/requests/src/Exception/Http/Status431.php /home/REDACTED/.local/bin/grep site url\|site_ush siteCommand.php /home/REDACTED/.cocore grep (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 rep grep -l site.*url _Command.php nfig/composer/vefeatures/site.feature site.*url foreSuiteTested.--version nfig/composer/vendor/bin/grep grep (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 cal/bin/sh sh vend�� 8375422c2c24.700--tags=~@less-than-wp-6.6&amp;&amp;~@less-than-wp-5.1&amp;&amp;~@less-than-wp-6.8&amp;&amp;~@less-than-psh install-network ndor/bin/sh --subdomains=0 1 /usr/local/.ghcup/bin/sh sh (dns block)
  • wp-cli.org
    • Triggering command: /usr/bin/curl curl -sSL REDACTED sh -cli�� /entity-command/vendor/wp-cli/wpbobuser ( &#34;bobuser&#34;, &#34;bobuser@example.com&#34; ); vendor/bin/wp --fields=signup_sh --format=csv p/bin/sh sh /ent�� user signup vendor/bin/sh --fields=signup_sh active --per_page=1 sh (dns block)

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

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 88.88889% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Site_Command.php 88.88% 4 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
Copy link

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

This PR implements a wp site get command for WordPress multisite installations, enabling users to retrieve site information by either site ID or URL. This solves the problem of needing to manually look up site IDs when working with custom domains in automated workflows.

Changes:

  • Added wp site get command that accepts site IDs or full URLs as input
  • Implemented URL parsing and database lookup for URL-based site retrieval
  • Added comprehensive test scenarios covering ID lookup, URL lookup, subdirectory sites, and error cases

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Site_Command.php Implements the new get() method with URL detection, database querying, and formatted output following the pattern of existing entity get commands
features/site.feature Adds 5 test scenarios covering site retrieval by ID, URL, subdirectory URLs, integration with site delete, and error handling for non-existent sites
composer.json Registers the "site get" command in the commands list

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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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