Skip to content

Commit 941e7e3

Browse files
authored
Merge pull request #100 from montu1996/fix-97
Introduce wp theme mod list
2 parents be1f2b7 + 8211e8b commit 941e7e3

3 files changed

Lines changed: 93 additions & 1 deletion

File tree

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
"theme path",
6464
"theme search",
6565
"theme status",
66-
"theme update"
66+
"theme update",
67+
"theme mod list"
6768
]
6869
}
6970
}

features/theme-mod-list.feature

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Feature: Manage WordPress theme mods list
2+
3+
Background:
4+
Given a WP install
5+
And I run `wp theme mod set key_a value_a`
6+
And I run `wp theme mod set key_b value_b`
7+
8+
Scenario: Getting theme mods
9+
When I run `wp theme mod list`
10+
Then STDOUT should be a table containing rows:
11+
| key | value |
12+
13+
When I run `wp theme mod list --field=key`
14+
Then STDOUT should be:
15+
"""
16+
key_a
17+
key_b
18+
"""
19+
20+
When I run `wp theme mod list --field=value`
21+
Then STDOUT should be:
22+
"""
23+
value_a
24+
value_b
25+
"""
26+
27+
When I run `wp theme mod list --format=json`
28+
Then STDOUT should be:
29+
"""
30+
[{"key":"key_a","value":"value_a"},{"key":"key_b","value":"value_b"}]
31+
"""
32+
33+
When I run `wp theme mod list --format=csv`
34+
Then STDOUT should be:
35+
"""
36+
key,value
37+
key_a,value_a
38+
key_b,value_b
39+
"""
40+
41+
When I run `wp theme mod list --format=yaml`
42+
Then STDOUT should be:
43+
"""
44+
---
45+
-
46+
key: key_a
47+
value: value_a
48+
-
49+
key: key_b
50+
value: value_b
51+
"""

src/Theme_Mod_Command.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,46 @@ public function get( $args = array(), $assoc_args = array() ) {
121121

122122
}
123123

124+
/**
125+
* Gets a list of theme mods.
126+
*
127+
* ## OPTIONS
128+
*
129+
* [--field=<field>]
130+
* : Returns the value of a single field.
131+
*
132+
* [--format=<format>]
133+
* : Render output in a particular format.
134+
* ---
135+
* default: table
136+
* options:
137+
* - table
138+
* - json
139+
* - csv
140+
* - yaml
141+
* ---
142+
*
143+
* ## EXAMPLES
144+
*
145+
* # Gets a list of theme mods.
146+
* $ wp theme mod list
147+
* +------------------+---------+
148+
* | key | value |
149+
* +------------------+---------+
150+
* | background_color | dd3333 |
151+
* | link_color | #dd9933 |
152+
* | main_text_color | #8224e3 |
153+
* +------------------+---------+
154+
*
155+
* @subcommand list
156+
*/
157+
public function list_( $args = array(), $assoc_args = array() ) {
158+
159+
$assoc_args['all'] = 1;
160+
161+
$this->get( $args, $assoc_args );
162+
}
163+
124164
/**
125165
* Removes one or more theme mods.
126166
*

0 commit comments

Comments
 (0)