Skip to content

Introduce wp theme mod list#100

Merged
schlessera merged 8 commits intowp-cli:masterfrom
montu1996:fix-97
May 29, 2018
Merged

Introduce wp theme mod list#100
schlessera merged 8 commits intowp-cli:masterfrom
montu1996:fix-97

Conversation

@montu1996
Copy link
Copy Markdown

Added new command wp theme mod list.

@montu1996
Copy link
Copy Markdown
Author

@schlessera can you please review this PR?

* +------------------+---------+
*
*/
public function list( $args = array(), $assoc_args = array() ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

$assoc_args['all'] = 1;
}
// If no format was given ,set to default 'table'.
if ( ! array_key_exists( 'format', $assoc_args ) ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

}

/**
* Gets all theme mods.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Gets a list of theme mods. to match similar commands.

*
* ## OPTIONS
*
* [<mod>...]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be removed, as the filtering is overridden by the --all flag.

@@ -0,0 +1,38 @@
Feature: Manage WordPress theme mods list
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests should be written with a list of theme mods that actually contain values, otherwise the tests could just succeed by random chance.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schlessera Done. can you please check again? 😃

Copy link
Copy Markdown
Member

@schlessera schlessera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only 2 small changes, and then this is good for merging...

-
key: key_b
value: value_b
""" No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Style: Always end files with a new line to avoid text processing issues on exotic platforms.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.....

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* @subcommand list
*/
public function list_( $args = array(), $assoc_args = array() ) {
if ( ! array_key_exists( 'all', $assoc_args ) ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@schlessera schlessera added this to the 1.1.10 milestone May 29, 2018
@schlessera schlessera merged commit 941e7e3 into wp-cli:master May 29, 2018
@schlessera
Copy link
Copy Markdown
Member

Thanks for the pull request, @montu1996 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants