Skip to content

Commit

Permalink
Merge pull request #419 from wp-cli/improve-multiple-theme-install-wa…
Browse files Browse the repository at this point in the history
…rning

Improve warning message for install and activate multiple themes
  • Loading branch information
ernilambar committed Apr 26, 2024
2 parents afdbff3 + 2cebfa2 commit 5dcbb5e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
19 changes: 16 additions & 3 deletions features/theme-install.feature
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ Feature: Install WordPress themes
Scenario: Installation of multiple themes with activate
When I try `wp theme install twentytwelve twentyeleven --activate`
Then STDERR should contain:
"""
Warning: Only a single theme can be active.
"""
"""
Warning: Only this single theme will be activated: twentyeleven
"""

When I run `wp theme list --field=name`
Then STDOUT should contain:
"""
twentyeleven
twentytwelve
"""

When I run `wp theme list --field=name --status=active`
Then STDOUT should contain:
"""
twentyeleven
"""
3 changes: 2 additions & 1 deletion src/Theme_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,8 @@ protected function filter_item_list( $items, $args ) {
*/
public function install( $args, $assoc_args ) {
if ( count( $args ) > 1 && Utils\get_flag_value( $assoc_args, 'activate', false ) ) {
WP_CLI::warning( 'Only a single theme can be active.' );
WP_CLI::warning( sprintf( 'Only this single theme will be activated: %s', end( $args ) ) );
reset( $args );
}

$theme_root = get_theme_root();
Expand Down

0 comments on commit 5dcbb5e

Please sign in to comment.