Conversation
|
@schlessera can you please review this PR? |
src/Theme_Mod_Command.php
Outdated
| * +------------------+---------+ | ||
| * | ||
| */ | ||
| public function list( $args = array(), $assoc_args = array() ) { |
There was a problem hiding this comment.
list is a protected keyword in more recent versions of PHP, so you cannot use it as a method name.
Use list_ instead, and then add the @subcommand list annotation to the docblock, similar to how it is done here: https://github.com/wp-cli/extension-command/blob/master/src/Plugin_Command.php#L1006-L1008
src/Theme_Mod_Command.php
Outdated
| $assoc_args['all'] = 1; | ||
| } | ||
| // If no format was given ,set to default 'table'. | ||
| if ( ! array_key_exists( 'format', $assoc_args ) ) { |
There was a problem hiding this comment.
Setting the default --format should be unnecessary, as the default is already provided in https://github.com/wp-cli/extension-command/pull/100/files#diff-03f3f9875c58703b8a8855ca3e5ca77eR138 and will be enforced by the system.
src/Theme_Mod_Command.php
Outdated
| } | ||
|
|
||
| /** | ||
| * Gets all theme mods. |
There was a problem hiding this comment.
Should be Gets a list of theme mods. to match similar commands.
src/Theme_Mod_Command.php
Outdated
| * | ||
| * ## OPTIONS | ||
| * | ||
| * [<mod>...] |
There was a problem hiding this comment.
This one should be removed, as the filtering is overridden by the --all flag.
| @@ -0,0 +1,38 @@ | |||
| Feature: Manage WordPress theme mods list | |||
There was a problem hiding this comment.
The tests should be written with a list of theme mods that actually contain values, otherwise the tests could just succeed by random chance.
There was a problem hiding this comment.
You can use something like this to pre-populate the list:
Background:
Given a WP install
And I run `wp theme mod set key_a value_a`
And I run `wp theme mod set key_b value_b`
schlessera
left a comment
There was a problem hiding this comment.
Only 2 small changes, and then this is good for merging...
features/theme-mod-list.feature
Outdated
| - | ||
| key: key_b | ||
| value: value_b | ||
| """ No newline at end of file |
There was a problem hiding this comment.
Code Style: Always end files with a new line to avoid text processing issues on exotic platforms.
src/Theme_Mod_Command.php
Outdated
| * @subcommand list | ||
| */ | ||
| public function list_( $args = array(), $assoc_args = array() ) { | ||
| if ( ! array_key_exists( 'all', $assoc_args ) ) { |
There was a problem hiding this comment.
Now that I think about this some more, I'd prefer to have it just always forcefully set $assoc_args['all'] to 1 here. If you check for existence of the key first, a user could do something like this, which would produce an error:
wp theme mod list --no-all
So please just remove the if ( ! array_key_exists( ... ) { } that wraps the assignment.
|
Thanks for the pull request, @montu1996 ! |
Added new command
wp theme mod list.