Skip to content

Commit

Permalink
Merge pull request #444 from shawnhooper/441-delete-site-by-slug
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy authored Nov 16, 2023
2 parents 684d4d1 + 342167f commit 3f7c916
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
23 changes: 23 additions & 0 deletions features/site.feature
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,29 @@ Feature: Manage sites in a multisite installation
When I try the previous command again
Then the return code should be 1

When I run `wp site create --slug=42`
Then STDOUT should contain:
"""
Success: Site 3 created: http
"""
And STDOUT should contain:
"""
://example.com/42/
"""

When I run `wp site delete --slug=42 --yes`
Then STDOUT should contain:
"""
://example.com/42/' was deleted.
"""

When I try the previous command again
Then STDERR should contain:
"""
Site with slug '42' does not exist.
"""
And the return code should be 1

Scenario: Get site info
Given a WP multisite install

Expand Down
6 changes: 5 additions & 1 deletion src/Site_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,11 @@ public function delete( $args, $assoc_args ) {
}

if ( isset( $assoc_args['slug'] ) ) {
$blog = get_blog_details( trim( $assoc_args['slug'], '/' ) );
$blog_id = get_id_from_blogname( $assoc_args['slug'] );
if ( null === $blog_id ) {
WP_CLI::error( "Site with slug '{$assoc_args['slug']}' does not exist." );
}
$blog = get_blog_details( $blog_id );
} else {
if ( empty( $args ) ) {
WP_CLI::error( 'Need to specify a blog id.' );
Expand Down

0 comments on commit 3f7c916

Please sign in to comment.