Skip to content

Commit 80713ba

Browse files
authored
Merge pull request #115 from GeoJunkie/fix/bad-plugin-slugs-warning
2 parents f6babbd + ff9a338 commit 80713ba

4 files changed

Lines changed: 33 additions & 0 deletions

File tree

features/language-plugin.feature

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

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

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/Plugin_Language_Command.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,14 @@ public function list_( $args, $assoc_args ) {
109109
$current_locale = get_locale();
110110

111111
$translations = array();
112+
$plugins = new \WP_CLI\Fetchers\Plugin();
112113

113114
foreach ( $args as $plugin ) {
115+
if ( ! $plugins->get( $plugin ) ) {
116+
WP_CLI::warning( "Plugin '{$plugin}' not found." );
117+
continue;
118+
}
119+
114120
$installed_translations = $this->get_installed_languages( $plugin );
115121
$available_translations = $this->get_all_languages( $plugin );
116122

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)