Skip to content

Commit

Permalink
Improve warning message for install and activate multiple themes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber committed Apr 26, 2024
1 parent afdbff3 commit d906790
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 ) ) );

Check failure on line 492 in src/Theme_Command.php

View workflow job for this annotation

GitHub Actions / code-quality / PHPCS

String "Only this single theme will be activated: %s" does not require double quotes; use single quotes instead
reset( $args );
}

$theme_root = get_theme_root();
Expand Down

0 comments on commit d906790

Please sign in to comment.