Skip to content

Commit

Permalink
Merge pull request #115 from GeoJunkie/fix/bad-plugin-slugs-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera authored Sep 11, 2022
2 parents f6babbd + ff9a338 commit 80713ba
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
10 changes: 10 additions & 0 deletions features/language-plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ Feature: Manage translation files for a WordPress install
| en_US | English (United States) | active |
| en_GB | English (UK) | uninstalled |

When I try `wp language plugin list not-a-plugin --format=json`
Then STDOUT should be:
"""
[]
"""
And STDERR should contain:
"""
Warning: Plugin 'not-a-plugin' not found.
"""

When I try `wp language plugin is-installed hello-dolly en_GB`
Then the return code should be 1
And STDERR should be empty
Expand Down
10 changes: 10 additions & 0 deletions features/language-theme.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ Feature: Manage translation files for a WordPress install
| en_US | English (United States) | active |
| en_GB | English (UK) | uninstalled |

When I try `wp language theme list not-a-theme --format=json`
Then STDOUT should be:
"""
[]
"""
And STDERR should contain:
"""
Warning: Theme 'not-a-theme' not found.
"""

When I try `wp language theme is-installed twentyten en_GB`
Then the return code should be 1
And STDERR should be empty
Expand Down
6 changes: 6 additions & 0 deletions src/Plugin_Language_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,14 @@ public function list_( $args, $assoc_args ) {
$current_locale = get_locale();

$translations = array();
$plugins = new \WP_CLI\Fetchers\Plugin();

foreach ( $args as $plugin ) {
if ( ! $plugins->get( $plugin ) ) {
WP_CLI::warning( "Plugin '{$plugin}' not found." );
continue;
}

$installed_translations = $this->get_installed_languages( $plugin );
$available_translations = $this->get_all_languages( $plugin );

Expand Down
7 changes: 7 additions & 0 deletions src/Theme_Language_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,15 @@ function( $file ) {
$current_locale = get_locale();

$translations = array();
$themes = new \WP_CLI\Fetchers\Theme();

foreach ( $args as $theme ) {

if ( ! $themes->get( $theme ) ) {
WP_CLI::warning( "Theme '{$theme}' not found." );
continue;
}

$installed_translations = $this->get_installed_languages( $theme );
$available_translations = $this->get_all_languages( $theme );

Expand Down

0 comments on commit 80713ba

Please sign in to comment.