Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions features/site.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions src/Site_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -962,13 +962,18 @@ private function get_network( $network_id ) {
* [--<field>=<value>]
* : 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=<value>]
* : Only list the sites with these blog_id values (comma-separated).
*
* [--site_user=<value>]
* : Only list the sites with this user.
*
* [--site-path=<path>]
* : Filter by path. Avoids conflict with the global `--path` parameter.
*
* [--field=<field>]
* : Prints the value of a single field for each site.
*
Expand Down Expand Up @@ -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'] ) ) . ' )';
Expand Down
Loading