Skip to content

Commit e3d89d9

Browse files
authored
Merge pull request #162 from michaelw85/96_filter_multiple_values
2 parents 316efc6 + 007f77d commit e3d89d9

File tree

6 files changed

+43
-3
lines changed

6 files changed

+43
-3
lines changed

features/language-core.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,3 +535,16 @@ Feature: Manage translation files for a WordPress install
535535
"""
536536
en_US
537537
"""
538+
539+
@require-wp-4.0
540+
Scenario: List languages by multiple statuses
541+
Given a WP install
542+
And an empty cache
543+
And I run `wp language core install nl_NL`
544+
545+
When I run `wp language core list --fields=language,status --status=active,installed`
546+
Then STDOUT should be a table containing rows:
547+
| language | status |
548+
| en_US | active |
549+
| nl_NL | installed |
550+
And STDERR should be empty

features/language-plugin.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,3 +439,16 @@ Feature: Manage translation files for a WordPress install
439439
jetpack,invalid_lang,"not available"
440440
"""
441441
And STDERR should be empty
442+
443+
@require-wp-4.0
444+
Scenario: List languages by multiple statuses
445+
Given a WP install
446+
And an empty cache
447+
And I run `wp language plugin install akismet nl_NL`
448+
449+
When I run `wp language plugin list --all --fields=plugin,language,status --status=active,installed`
450+
Then STDOUT should be a table containing rows:
451+
| plugin | language | status |
452+
| akismet | en_US | active |
453+
| akismet | nl_NL | installed |
454+
And STDERR should be empty

features/language-theme.feature

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,17 @@ Feature: Manage translation files for a WordPress install
314314
twentysixteen,de_DE,"not installed"
315315
"""
316316
And STDERR should be empty
317+
318+
@require-wp-4.0
319+
Scenario: List languages by multiple statuses
320+
Given a WP install
321+
And an empty cache
322+
And I run `wp theme install twentyten --force`
323+
And I run `wp language theme install twentyten nl_NL`
324+
325+
When I run `wp language theme list twentyten --fields=language,status --status=active,installed`
326+
Then STDOUT should be a table containing rows:
327+
| language | status |
328+
| en_US | active |
329+
| nl_NL | installed |
330+
And STDERR should be empty

src/Core_Language_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function ( $translation ) use ( $available, $current_locale, $updates ) {
126126

127127
foreach ( $translations as $key => $translation ) {
128128
foreach ( array_keys( $translation ) as $field ) {
129-
if ( isset( $assoc_args[ $field ] ) && $assoc_args[ $field ] !== $translation[ $field ] ) {
129+
if ( isset( $assoc_args[ $field ] ) && ! in_array( $translation[ $field ], array_map( 'trim', explode( ',', $assoc_args[ $field ] ) ), true ) ) {
130130
unset( $translations[ $key ] );
131131
}
132132
}

src/Plugin_Language_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function list_( $args, $assoc_args ) {
154154

155155
// Support features like --status=active.
156156
foreach ( array_keys( $translation ) as $field ) {
157-
if ( isset( $assoc_args[ $field ] ) && $assoc_args[ $field ] !== $translation[ $field ] ) {
157+
if ( isset( $assoc_args[ $field ] ) && ! in_array( $translation[ $field ], array_map( 'trim', explode( ',', $assoc_args[ $field ] ) ), true ) ) {
158158
continue 2;
159159
}
160160
}

src/Theme_Language_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ function ( $file ) {
160160

161161
// Support features like --status=active.
162162
foreach ( array_keys( $translation ) as $field ) {
163-
if ( isset( $assoc_args[ $field ] ) && $assoc_args[ $field ] !== $translation[ $field ] ) {
163+
if ( isset( $assoc_args[ $field ] ) && ! in_array( $translation[ $field ], array_map( 'trim', explode( ',', $assoc_args[ $field ] ) ), true ) ) {
164164
continue 2;
165165
}
166166
}

0 commit comments

Comments
 (0)