diff --git a/features/site.feature b/features/site.feature index 300eb6f51..a9e098690 100644 --- a/features/site.feature +++ b/features/site.feature @@ -98,6 +98,12 @@ Feature: Manage sites in a multisite installation {SCHEME}://example.com/first/ """ + When I run `wp site list --field=url --site-path=/first/` + Then STDOUT should be: + """ + {SCHEME}://example.com/first/ + """ + Scenario: Filter site list by user Given a WP multisite install diff --git a/src/Site_Command.php b/src/Site_Command.php index 11c0d6ebf..114bf1446 100644 --- a/src/Site_Command.php +++ b/src/Site_Command.php @@ -962,6 +962,8 @@ private function get_network( $network_id ) { * [--=] * : Filter by one or more fields (see "Available Fields" section). However, * 'url' isn't an available filter, as it comes from 'home' in wp_options. + * Note: '--path' conflicts with the global parameter of the same name; use + * '--site-path' to filter by path instead. * * [--site__in=] * : Only list the sites with these blog_id values (comma-separated). @@ -969,6 +971,9 @@ private function get_network( $network_id ) { * [--site_user=] * : Only list the sites with this user. * + * [--site-path=] + * : Filter by path. Avoids conflict with the global `--path` parameter. + * * [--field=] * : Prints the value of a single field for each site. * @@ -1045,6 +1050,10 @@ public function list_( $args, $assoc_args ) { } } + if ( isset( $assoc_args['site-path'] ) ) { + $where['path'] = $assoc_args['site-path']; + } + if ( isset( $assoc_args['site__in'] ) ) { $where['blog_id'] = explode( ',', $assoc_args['site__in'] ); $append = 'ORDER BY FIELD( blog_id, ' . implode( ',', array_map( 'intval', $where['blog_id'] ) ) . ' )';