Skip to content

Commit df82078

Browse files
committed
Check if theme exists
1 parent d54ebb2 commit df82078

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

features/language-theme.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ Feature: Manage translation files for a WordPress install
1919
| en_US | English (United States) | active |
2020
| en_GB | English (UK) | uninstalled |
2121

22+
When I try `wp language theme list not-a-theme --format=json`
23+
Then STDOUT should be:
24+
"""
25+
[]
26+
"""
27+
And STDERR should contain:
28+
"""
29+
Warning: Theme 'not-a-theme' not found.
30+
"""
31+
2232
When I try `wp language theme is-installed twentyten en_GB`
2333
Then the return code should be 1
2434
And STDERR should be empty

src/Theme_Language_Command.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,15 @@ function( $file ) {
114114
$current_locale = get_locale();
115115

116116
$translations = array();
117+
$themes = new \WP_CLI\Fetchers\Theme();
117118

118119
foreach ( $args as $theme ) {
120+
121+
if ( ! $themes->get( $theme ) ) {
122+
WP_CLI::warning( "Theme '{$theme}' not found." );
123+
continue;
124+
}
125+
119126
$installed_translations = $this->get_installed_languages( $theme );
120127
$available_translations = $this->get_all_languages( $theme );
121128

0 commit comments

Comments
 (0)