Skip to content

Commit 5517499

Browse files
authored
Merge pull request #233 from wp-cli/232-supports-get-post-type
Include 'supports' field when fetching a single post type
2 parents 459fba6 + 43e9399 commit 5517499

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3029,6 +3029,22 @@ wp post-type get <post-type> [--field=<field>] [--fields=<fields>] [--format=<fo
30293029
- yaml
30303030
---
30313031

3032+
**AVAILABLE FIELDS**
3033+
3034+
These fields will be displayed by default for each post type:
3035+
3036+
* name
3037+
* label
3038+
* description
3039+
* hierarchical
3040+
* public
3041+
* capability_type
3042+
* labels
3043+
* cap
3044+
* supports
3045+
3046+
There are no optionally available fields.
3047+
30323048
**EXAMPLES**
30333049

30343050
# Get details about the 'page' post type.
@@ -3070,7 +3086,7 @@ wp post-type list [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--f
30703086

30713087
**AVAILABLE FIELDS**
30723088

3073-
These fields will be displayed by default for each term:
3089+
These fields will be displayed by default for each post type:
30743090

30753091
* name
30763092
* label

features/post-type.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ Feature: Manage WordPress post types
2323
| Field | Value |
2424
| name | page |
2525
| label | Pages |
26+
And STDOUT should contain:
27+
"""
28+
supports
29+
"""
30+
And STDOUT should contain:
31+
"""
32+
"title":true
33+
"""

src/Post_Type_Command.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Post_Type_Command extends WP_CLI_Command {
6262
*
6363
* ## AVAILABLE FIELDS
6464
*
65-
* These fields will be displayed by default for each term:
65+
* These fields will be displayed by default for each post type:
6666
*
6767
* * name
6868
* * label
@@ -130,6 +130,22 @@ public function list_( $args, $assoc_args ) {
130130
* - yaml
131131
* ---
132132
*
133+
* ## AVAILABLE FIELDS
134+
*
135+
* These fields will be displayed by default for each post type:
136+
*
137+
* * name
138+
* * label
139+
* * description
140+
* * hierarchical
141+
* * public
142+
* * capability_type
143+
* * labels
144+
* * cap
145+
* * supports
146+
*
147+
* There are no optionally available fields.
148+
*
133149
* ## EXAMPLES
134150
*
135151
* # Get details about the 'page' post type.
@@ -146,7 +162,8 @@ public function get( $args, $assoc_args ) {
146162
if ( empty( $assoc_args['fields'] ) ) {
147163
$default_fields = array_merge( $this->fields, array(
148164
'labels',
149-
'cap'
165+
'cap',
166+
'supports',
150167
) );
151168

152169
$assoc_args['fields'] = $default_fields;
@@ -161,6 +178,7 @@ public function get( $args, $assoc_args ) {
161178
'capability_type' => $post_type->capability_type,
162179
'labels' => $post_type->labels,
163180
'cap' => $post_type->cap,
181+
'supports' => get_all_post_type_supports( $post_type->name ),
164182
);
165183

166184
$formatter = $this->get_formatter( $assoc_args );

0 commit comments

Comments
 (0)