Skip to content

Commit 7b4f13c

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/wp-cli-issue-5286-n50evd-silent-noop
# Conflicts: # features/post.feature
2 parents e325a80 + d58d4fe commit 7b4f13c

14 files changed

Lines changed: 1614 additions & 11 deletions

‎README.md‎

Lines changed: 137 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3150,7 +3150,7 @@ wp post get <id> [--field=<field>] [--fields=<fields>] [--format=<format>]
31503150
Gets a list of posts.
31513151

31523152
~~~
3153-
wp post list [--<field>=<value>] [--p=<id>|ID] [--title=<title>|post_title] [--name=<slug>|post_name] [--author=<author>|post_author] [--author_name=<author_name>] [--post_type=<post_type>] [--post_status=<post_status>] [--post_parent=<post_parent>] [--post_mime_type=<post_mime_type>] [--menu_order=<menu_order>] [--comment_status=<comment_status>] [--ping_status=<ping_status>] [--comment_count=<comment_count>] [--s=<string>] [--year=<year>] [--monthnum=<monthnum>] [--day=<day>] [--m=<yearmonth>] [--w=<week>] [--field=<field>] [--fields=<fields>] [--format=<format>]
3153+
wp post list [--<field>=<value>] [--p=<id>|ID] [--title=<title>|post_title] [--name=<slug>|post_name] [--author=<author>|post_author] [--author_name=<author_name>] [--cat=<cat>] [--category_name=<category_name>] [--tag=<tag>] [--post_type=<post_type>] [--post_status=<post_status>] [--post_parent=<post_parent>] [--post_mime_type=<post_mime_type>] [--menu_order=<menu_order>] [--comment_status=<comment_status>] [--ping_status=<ping_status>] [--comment_count=<comment_count>] [--s=<string>] [--year=<year>] [--monthnum=<monthnum>] [--day=<day>] [--hour=<hour>] [--minute=<minute>] [--second=<second>] [--m=<yearmonth>] [--w=<week>] [--meta_key=<meta_key>] [--meta_value=<meta_value>] [--orderby=<orderby>] [--order=<order>] [--post__in=<ids>] [--post__not_in=<ids>] [--post_name__in=<slugs>] [--post_parent__in=<ids>] [--post_parent__not_in=<ids>] [--author__in=<ids>] [--author__not_in=<ids>] [--category__in=<ids>] [--category__and=<ids>] [--category__not_in=<ids>] [--tag_id=<tag_id>] [--tag__in=<ids>] [--tag__and=<ids>] [--tag__not_in=<ids>] [--tag_slug__in=<slugs>] [--tag_slug__and=<slugs>] [--page_id=<page_id>] [--pagename=<pagename>] [--attachment_id=<attachment_id>] [--date_query=<json>] [--meta_query=<json>] [--tax_query=<json>] [--meta_compare=<meta_compare>] [--sentence=<sentence>] [--exact=<exact>] [--search_columns=<columns>] [--perm=<perm>] [--posts_per_page=<number>] [--paged=<paged>] [--offset=<offset>] [--nopaging=<nopaging>] [--field=<field>] [--fields=<fields>] [--format=<format>]
31543154
~~~
31553155

31563156
Display posts based on all arguments supported by [WP_Query()](https://developer.wordpress.org/reference/classes/wp_query/).
@@ -3186,6 +3186,17 @@ Only shows post types marked as post by default.
31863186
[--author_name=<author_name>]
31873187
Filter by the 'user_nicename' of the post's author.
31883188

3189+
[--cat=<cat>]
3190+
Filter by category ID. Accepts a comma-separated list to match any of
3191+
them, and a negative ID excludes that category instead.
3192+
3193+
[--category_name=<category_name>]
3194+
Filter by category slug.
3195+
3196+
[--tag=<tag>]
3197+
Filter by tag slug. Accepts a comma-separated list to match any of them,
3198+
or a '+'-separated list to require all of them.
3199+
31893200
[--post_type=<post_type>]
31903201
Filter by post type. Defaults to 'post'. Accepts a comma-separated list,
31913202
or 'any' for every type registered without 'exclude_from_search'.
@@ -3225,12 +3236,137 @@ Only shows post types marked as post by default.
32253236
[--day=<day>]
32263237
Filter by day of the month, 1 to 31.
32273238

3239+
[--hour=<hour>]
3240+
Filter by hour, 0 to 23.
3241+
3242+
[--minute=<minute>]
3243+
Filter by minute, 0 to 59.
3244+
3245+
[--second=<second>]
3246+
Filter by second, 0 to 59.
3247+
32283248
[--m=<yearmonth>]
32293249
Filter by year and month together, e.g. 202401.
32303250

32313251
[--w=<week>]
32323252
Filter by week of the year, 0 to 53.
32333253

3254+
[--meta_key=<meta_key>]
3255+
Filter by posts having this meta key. Pair it with `--meta_value` to
3256+
filter on the value as well.
3257+
3258+
[--meta_value=<meta_value>]
3259+
Filter by this meta value. Needs `--meta_key` to say which key it
3260+
belongs to.
3261+
3262+
[--orderby=<orderby>]
3263+
Order the results by this field. Accepts what WP_Query accepts, e.g.
3264+
'date', 'title', 'ID', 'menu_order', 'rand', or 'meta_value' alongside
3265+
`--meta_key`.
3266+
3267+
[--order=<order>]
3268+
Direction to order by. Accepts 'ASC' or 'DESC'.
3269+
3270+
[--post__in=<ids>]
3271+
Only list the posts with these IDs (comma-separated).
3272+
3273+
[--post__not_in=<ids>]
3274+
Exclude the posts with these IDs (comma-separated).
3275+
3276+
[--post_name__in=<slugs>]
3277+
Only list the posts with these slugs (comma-separated). Unlike `--name`
3278+
this is not a single-post query, so it reaches drafts as well.
3279+
3280+
[--post_parent__in=<ids>]
3281+
Only list the posts whose parent is one of these IDs (comma-separated).
3282+
3283+
[--post_parent__not_in=<ids>]
3284+
Exclude the posts whose parent is one of these IDs (comma-separated).
3285+
3286+
[--author__in=<ids>]
3287+
Only list the posts by these author IDs (comma-separated).
3288+
3289+
[--author__not_in=<ids>]
3290+
Exclude the posts by these author IDs (comma-separated).
3291+
3292+
[--category__in=<ids>]
3293+
Only list the posts in these category IDs (comma-separated).
3294+
3295+
[--category__and=<ids>]
3296+
Only list the posts in all of these category IDs (comma-separated).
3297+
3298+
[--category__not_in=<ids>]
3299+
Exclude the posts in these category IDs (comma-separated).
3300+
3301+
[--tag_id=<tag_id>]
3302+
Filter by tag ID.
3303+
3304+
[--tag__in=<ids>]
3305+
Only list the posts with these tag IDs (comma-separated).
3306+
3307+
[--tag__and=<ids>]
3308+
Only list the posts with all of these tag IDs (comma-separated).
3309+
3310+
[--tag__not_in=<ids>]
3311+
Exclude the posts with these tag IDs (comma-separated).
3312+
3313+
[--tag_slug__in=<slugs>]
3314+
Only list the posts with these tag slugs (comma-separated).
3315+
3316+
[--tag_slug__and=<slugs>]
3317+
Only list the posts with all of these tag slugs (comma-separated).
3318+
3319+
[--page_id=<page_id>]
3320+
Filter by page ID. Needs `--post_type=page` to match anything.
3321+
3322+
[--pagename=<pagename>]
3323+
Filter by page slug. Needs `--post_type=page` to match anything.
3324+
3325+
[--attachment_id=<attachment_id>]
3326+
Filter by attachment ID. Needs `--post_type=attachment` to match
3327+
anything.
3328+
3329+
[--date_query=<json>]
3330+
Filter by a date query, given as JSON. See WP_Date_Query.
3331+
3332+
[--meta_query=<json>]
3333+
Filter by a meta query, given as JSON. See WP_Meta_Query.
3334+
3335+
[--tax_query=<json>]
3336+
Filter by a taxonomy query, given as JSON. See WP_Tax_Query.
3337+
3338+
[--meta_compare=<meta_compare>]
3339+
Operator to test `--meta_value` with, e.g. '=', '!=', '>' or 'LIKE'.
3340+
3341+
[--sentence=<sentence>]
3342+
Match `--s` as one phrase rather than as separate words. Accepts 1 or 0.
3343+
3344+
[--exact=<exact>]
3345+
Match `--s` against the whole column rather than part of it. Accepts 1
3346+
or 0.
3347+
3348+
[--search_columns=<columns>]
3349+
Comma-separated list of columns `--s` looks in. Accepts 'post_title',
3350+
'post_excerpt' and 'post_content'. Needs WordPress 6.2 or later.
3351+
3352+
[--perm=<perm>]
3353+
Filter by what the current user may do with the post. Accepts
3354+
'readable' or 'editable'; pair it with the global `--user` argument,
3355+
since WP-CLI is no user by default.
3356+
3357+
[--posts_per_page=<number>]
3358+
How many posts to return. Defaults to -1, meaning every post.
3359+
3360+
[--paged=<paged>]
3361+
Which page of results to return, counted in `--posts_per_page` steps.
3362+
3363+
[--offset=<offset>]
3364+
How many posts to skip. Needs `--posts_per_page` set to something other
3365+
than -1, which otherwise takes precedence.
3366+
3367+
[--nopaging=<nopaging>]
3368+
Return every post, ignoring `--posts_per_page`. Accepts 1 or 0.
3369+
32343370
[--field=<field>]
32353371
Prints the value of a single field for each post.
32363372

‎composer.json‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@
7474
"font face install",
7575
"font family",
7676
"font family install",
77+
"icon",
78+
"icon collection",
79+
"icon collection get",
80+
"icon collection is-registered",
81+
"icon collection list",
82+
"icon get",
83+
"icon is-registered",
84+
"icon list",
85+
"icon render",
7786
"menu",
7887
"menu create",
7988
"menu delete",

‎entity-command.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,14 @@
140140
WP_CLI::add_command( 'font collection', 'Font_Collection_Command', $wpcli_entity_font_version_check );
141141
WP_CLI::add_command( 'font family', 'Font_Family_Command', $wpcli_entity_font_version_check );
142142
WP_CLI::add_command( 'font face', 'Font_Face_Command', $wpcli_entity_font_version_check );
143+
144+
$wpcli_entity_icon_version_check = array(
145+
'before_invoke' => function () {
146+
if ( Utils\wp_version_compare( '7.1', '<' ) ) {
147+
WP_CLI::error( 'Requires WordPress 7.1 or greater.' );
148+
}
149+
},
150+
);
151+
152+
WP_CLI::add_command( 'icon', 'Icon_Command', $wpcli_entity_icon_version_check );
153+
WP_CLI::add_command( 'icon collection', 'Icon_Collection_Command', $wpcli_entity_icon_version_check );

‎features/icon-collection.feature‎

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
Feature: Manage WordPress icon collections
2+
3+
Background:
4+
Given a WP install
5+
6+
@require-wp-7.1
7+
Scenario: Listing icon collections
8+
When I run `wp icon collection list --fields=slug,label,description`
9+
Then STDOUT should be a table containing rows:
10+
| slug | label | description |
11+
| core | WordPress | Default icon collection. |
12+
13+
@require-wp-7.1
14+
Scenario: Listing icon collections in other formats
15+
When I run `wp icon collection list --format=ids`
16+
Then STDOUT should contain:
17+
"""
18+
core
19+
"""
20+
21+
When I run `wp icon collection list --fields=slug,label --format=json`
22+
Then STDOUT should be JSON containing:
23+
"""
24+
[{"slug":"core","label":"WordPress"}]
25+
"""
26+
27+
When I run `wp icon collection list --format=count`
28+
Then STDOUT should be a number
29+
30+
@require-wp-7.1
31+
Scenario: Getting an icon collection
32+
When I run `wp icon collection get core --fields=slug,label,description`
33+
Then STDOUT should be a table containing rows:
34+
| Field | Value |
35+
| slug | core |
36+
| label | WordPress |
37+
| description | Default icon collection. |
38+
39+
When I run `wp icon collection get core --field=label`
40+
Then STDOUT should be:
41+
"""
42+
WordPress
43+
"""
44+
45+
@require-wp-7.1
46+
Scenario: Counting the icons of a collection
47+
When I run `wp icon collection get core --field=count`
48+
Then STDOUT should be a number
49+
50+
@require-wp-7.1
51+
Scenario: Getting a non-existent icon collection
52+
When I try `wp icon collection get nonexistent-collection`
53+
Then the return code should be 1
54+
And STDERR should contain:
55+
"""
56+
doesn't exist
57+
"""
58+
59+
@require-wp-7.1
60+
Scenario: Checking whether an icon collection is registered
61+
When I try `wp icon collection is-registered nonexistent-collection`
62+
Then the return code should be 1
63+
64+
When I run `wp icon collection is-registered core`
65+
Then the return code should be 0
66+
67+
@require-wp-7.1
68+
Scenario: Listing a collection registered by a plugin
69+
Given a wp-content/mu-plugins/test-icons.php file:
70+
"""
71+
<?php
72+
// Plugin Name: Test Icons
73+
add_action(
74+
'init',
75+
function () {
76+
wp_register_icon_collection(
77+
'test-icons',
78+
array(
79+
'label' => 'Test Icons',
80+
'description' => 'A collection for testing.',
81+
)
82+
);
83+
84+
wp_register_icon(
85+
'test-icons/square',
86+
array(
87+
'label' => 'Square',
88+
'content' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 4h16v16H4z" /></svg>',
89+
)
90+
);
91+
}
92+
);
93+
"""
94+
95+
When I run `wp icon collection list --fields=slug,label,description,count`
96+
Then STDOUT should be a table containing rows:
97+
| slug | label | description | count |
98+
| test-icons | Test Icons | A collection for testing. | 1 |
99+
100+
When I run `wp icon collection is-registered test-icons`
101+
Then the return code should be 0
102+
103+
@less-than-wp-7.1
104+
Scenario: Icon collection commands fail on WordPress < 7.1
105+
When I try `wp icon collection list`
106+
Then the return code should be 1
107+
And STDERR should contain:
108+
"""
109+
Requires WordPress 7.1 or greater
110+
"""

0 commit comments

Comments
 (0)