Skip to content

Commit 7c8d6d3

Browse files
Copilotswissspidy
andauthored
Add --site-path filter to wp site list to avoid conflict with global --path (#595)
* Initial plan * Fix wp site list path filter conflict by adding --site-path parameter Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> * Restore path in site_cols for WP_CLI_STRICT_ARGS_MODE compatibility Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> Co-authored-by: Pascal Birchler <pascalb@google.com>
1 parent f5c9a15 commit 7c8d6d3

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

features/site.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ Feature: Manage sites in a multisite installation
9898
{SCHEME}://example.com/first/
9999
"""
100100

101+
When I run `wp site list --field=url --site-path=/first/`
102+
Then STDOUT should be:
103+
"""
104+
{SCHEME}://example.com/first/
105+
"""
106+
101107
Scenario: Filter site list by user
102108
Given a WP multisite install
103109

src/Site_Command.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,13 +962,18 @@ private function get_network( $network_id ) {
962962
* [--<field>=<value>]
963963
* : Filter by one or more fields (see "Available Fields" section). However,
964964
* 'url' isn't an available filter, as it comes from 'home' in wp_options.
965+
* Note: '--path' conflicts with the global parameter of the same name; use
966+
* '--site-path' to filter by path instead.
965967
*
966968
* [--site__in=<value>]
967969
* : Only list the sites with these blog_id values (comma-separated).
968970
*
969971
* [--site_user=<value>]
970972
* : Only list the sites with this user.
971973
*
974+
* [--site-path=<path>]
975+
* : Filter by path. Avoids conflict with the global `--path` parameter.
976+
*
972977
* [--field=<field>]
973978
* : Prints the value of a single field for each site.
974979
*
@@ -1045,6 +1050,10 @@ public function list_( $args, $assoc_args ) {
10451050
}
10461051
}
10471052

1053+
if ( isset( $assoc_args['site-path'] ) ) {
1054+
$where['path'] = $assoc_args['site-path'];
1055+
}
1056+
10481057
if ( isset( $assoc_args['site__in'] ) ) {
10491058
$where['blog_id'] = explode( ',', $assoc_args['site__in'] );
10501059
$append = 'ORDER BY FIELD( blog_id, ' . implode( ',', array_map( 'intval', $where['blog_id'] ) ) . ' )';

0 commit comments

Comments
 (0)