Skip to content

Commit 273e156

Browse files
authored
Merge branch 'main' into copilot/add-font-library-commands
2 parents d0516dd + 7aea0fd commit 273e156

File tree

6 files changed

+668
-0
lines changed

6 files changed

+668
-0
lines changed

README.md

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,79 @@ wp menu item delete <db-id>...
11301130

11311131

11321132

1133+
### wp menu item get
1134+
1135+
Gets details about a menu item.
1136+
1137+
~~~
1138+
wp menu item get <db-id> [--field=<field>] [--fields=<fields>] [--format=<format>]
1139+
~~~
1140+
1141+
**OPTIONS**
1142+
1143+
<db-id>
1144+
Database ID for the menu item.
1145+
1146+
[--field=<field>]
1147+
Instead of returning the whole menu item, returns the value of a single field.
1148+
1149+
[--fields=<fields>]
1150+
Limit the output to specific fields. Defaults to db_id, type, title, link, position.
1151+
1152+
[--format=<format>]
1153+
Render output in a particular format.
1154+
---
1155+
default: table
1156+
options:
1157+
- table
1158+
- csv
1159+
- json
1160+
- yaml
1161+
---
1162+
1163+
**AVAILABLE FIELDS**
1164+
1165+
These fields are available:
1166+
1167+
* db_id
1168+
* type
1169+
* title
1170+
* link
1171+
* position
1172+
* menu_item_parent
1173+
* object_id
1174+
* object
1175+
* type_label
1176+
* target
1177+
* attr_title
1178+
* description
1179+
* classes
1180+
* xfn
1181+
1182+
**EXAMPLES**
1183+
1184+
# Get details about a menu item with ID 45
1185+
$ wp menu item get 45
1186+
+-------------+----------------------------------+
1187+
| Field | Value |
1188+
+-------------+----------------------------------+
1189+
| db_id | 45 |
1190+
| type | custom |
1191+
| title | WordPress |
1192+
| link | https://wordpress.org |
1193+
| position | 1 |
1194+
+-------------+----------------------------------+
1195+
1196+
# Get a specific field from a menu item
1197+
$ wp menu item get 45 --field=title
1198+
WordPress
1199+
1200+
# Get menu item data in JSON format
1201+
$ wp menu item get 45 --format=json
1202+
{"db_id":45,"type":"custom","title":"WordPress","link":"https://wordpress.org","position":1}
1203+
1204+
1205+
11331206
### wp menu item list
11341207

11351208
Gets a list of items associated with a menu.
@@ -2947,6 +3020,116 @@ wp post meta update <id> <key> [<value>] [--format=<format>]
29473020

29483021

29493022

3023+
### wp post revision
3024+
3025+
Manages post revisions.
3026+
3027+
~~~
3028+
wp post revision
3029+
~~~
3030+
3031+
**EXAMPLES**
3032+
3033+
# Restore a post revision
3034+
$ wp post revision restore 123
3035+
Success: Restored revision 123.
3036+
3037+
# Show diff between two revisions
3038+
$ wp post revision diff 123 456
3039+
3040+
3041+
3042+
3043+
3044+
### wp post revision diff
3045+
3046+
Shows the difference between two revisions.
3047+
3048+
~~~
3049+
wp post revision diff <from> [<to>] [--field=<field>]
3050+
~~~
3051+
3052+
**OPTIONS**
3053+
3054+
<from>
3055+
The 'from' revision ID or post ID.
3056+
3057+
[<to>]
3058+
The 'to' revision ID or post ID. If not provided, compares with the current post.
3059+
3060+
[--field=<field>]
3061+
Compare specific field(s). Default: post_content
3062+
3063+
**EXAMPLES**
3064+
3065+
# Show diff between two revisions
3066+
$ wp post revision diff 123 456
3067+
3068+
# Show diff between a revision and the current post
3069+
$ wp post revision diff 123
3070+
3071+
3072+
3073+
### wp post revision prune
3074+
3075+
Deletes old post revisions.
3076+
3077+
~~~
3078+
wp post revision prune [<post-id>...] [--latest=<limit>] [--earliest=<limit>] [--yes]
3079+
~~~
3080+
3081+
**OPTIONS**
3082+
3083+
[<post-id>...]
3084+
One or more post IDs to prune revisions for. If not provided, prunes revisions for all posts.
3085+
3086+
[--latest=<limit>]
3087+
Keep only the latest N revisions per post. Older revisions will be deleted.
3088+
3089+
[--earliest=<limit>]
3090+
Keep only the earliest N revisions per post. Newer revisions will be deleted.
3091+
3092+
[--yes]
3093+
Skip confirmation prompt.
3094+
3095+
**EXAMPLES**
3096+
3097+
# Delete all but the latest 5 revisions for post 123
3098+
$ wp post revision prune 123 --latest=5
3099+
Success: Deleted 3 revisions for post 123.
3100+
3101+
# Delete all but the latest 5 revisions for all posts
3102+
$ wp post revision prune --latest=5
3103+
Success: Deleted 150 revisions across 30 posts.
3104+
3105+
# Delete all but the earliest 2 revisions for posts 123 and 456
3106+
$ wp post revision prune 123 456 --earliest=2
3107+
Success: Deleted 5 revisions for post 123.
3108+
Success: Deleted 3 revisions for post 456.
3109+
3110+
3111+
3112+
### wp post revision restore
3113+
3114+
Restores a post revision.
3115+
3116+
~~~
3117+
wp post revision restore <revision_id>
3118+
~~~
3119+
3120+
**OPTIONS**
3121+
3122+
<revision_id>
3123+
The revision ID to restore.
3124+
3125+
**EXAMPLES**
3126+
3127+
# Restore a post revision
3128+
$ wp post revision restore 123
3129+
Success: Restored revision 123.
3130+
3131+
3132+
29503133
### wp post term
29513134

29523135
Adds, updates, removes, and lists post terms.
@@ -4620,6 +4803,81 @@ WP_CLI::add_hook( 'after_invoke:site empty', function(){
46204803

46214804

46224805

4806+
### wp site get
4807+
4808+
Gets details about a site in a multisite installation.
4809+
4810+
~~~
4811+
wp site get <site> [--field=<field>] [--fields=<fields>] [--format=<format>]
4812+
~~~
4813+
4814+
**OPTIONS**
4815+
4816+
<site>
4817+
Site ID or URL of the site to get. For subdirectory sites, use the full URL (e.g., http://example.com/subdir/).
4818+
4819+
[--field=<field>]
4820+
Instead of returning the whole site, returns the value of a single field.
4821+
4822+
[--fields=<fields>]
4823+
Limit the output to specific fields. Defaults to all fields.
4824+
4825+
[--format=<format>]
4826+
Render output in a particular format.
4827+
---
4828+
default: table
4829+
options:
4830+
- table
4831+
- csv
4832+
- json
4833+
- yaml
4834+
---
4835+
4836+
**AVAILABLE FIELDS**
4837+
4838+
These fields will be displayed by default for the site:
4839+
4840+
* blog_id
4841+
* url
4842+
* last_updated
4843+
* registered
4844+
4845+
These fields are optionally available:
4846+
4847+
* site_id
4848+
* domain
4849+
* path
4850+
* public
4851+
* archived
4852+
* mature
4853+
* spam
4854+
* deleted
4855+
* lang_id
4856+
4857+
**EXAMPLES**
4858+
4859+
# Get site by ID
4860+
$ wp site get 1
4861+
+---------+-------------------------+---------------------+---------------------+
4862+
| blog_id | url | last_updated | registered |
4863+
+---------+-------------------------+---------------------+---------------------+
4864+
| 1 | http://example.com/ | 2025-01-01 12:00:00 | 2025-01-01 12:00:00 |
4865+
+---------+-------------------------+---------------------+---------------------+
4866+
4867+
# Get site URL by site ID
4868+
$ wp site get 1 --field=url
4869+
http://example.com/
4870+
4871+
# Get site ID by URL
4872+
$ wp site get http://example.com/subdir/ --field=blog_id
4873+
2
4874+
4875+
# Delete a site by URL
4876+
$ wp site delete $(wp site get http://example.com/subdir/ --field=blog_id) --yes
4877+
Success: The site at 'http://example.com/subdir/' was deleted.
4878+
4879+
4880+
46234881
### wp site list
46244882

46254883
Lists all sites in a multisite installation.

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"menu item add-post",
9393
"menu item add-term",
9494
"menu item delete",
95+
"menu item get",
9596
"menu item list",
9697
"menu item update",
9798
"menu list",
@@ -174,6 +175,7 @@
174175
"site deactivate",
175176
"site delete",
176177
"site empty",
178+
"site get",
177179
"site list",
178180
"site mature",
179181
"site meta",

features/menu-item.feature

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,61 @@ Feature: Manage WordPress menu items
194194
| type | title | position | link |
195195
| custom | First | 1 | https://first.com |
196196
| custom | Third | 2 | https://third.com |
197+
198+
Scenario: Get menu item details
199+
When I run `wp menu create "Sidebar Menu"`
200+
Then STDOUT should not be empty
201+
202+
When I run `wp menu item add-custom sidebar-menu Apple https://apple.com --porcelain`
203+
Then save STDOUT as {ITEM_ID}
204+
205+
When I run `wp menu item get {ITEM_ID}`
206+
Then STDOUT should be a table containing rows:
207+
| Field | Value |
208+
| db_id | {ITEM_ID} |
209+
| type | custom |
210+
| title | Apple |
211+
| link | https://apple.com |
212+
| position | 1 |
213+
214+
When I run `wp menu item get {ITEM_ID} --format=json`
215+
Then STDOUT should be JSON containing:
216+
"""
217+
{
218+
"db_id": {ITEM_ID},
219+
"type": "custom",
220+
"title": "Apple",
221+
"link": "https://apple.com"
222+
}
223+
"""
224+
225+
When I run `wp menu item get {ITEM_ID} --field=title`
226+
Then STDOUT should be:
227+
"""
228+
Apple
229+
"""
230+
231+
When I run `wp menu item get {ITEM_ID} --fields=db_id,title,type --format=csv`
232+
Then STDOUT should be CSV containing:
233+
| Field | Value |
234+
| db_id | {ITEM_ID} |
235+
| title | Apple |
236+
| type | custom |
237+
238+
When I try `wp menu item get 99999999`
239+
Then STDERR should be:
240+
"""
241+
Error: Invalid menu item.
242+
"""
243+
And the return code should be 1
244+
245+
When I run `wp post create --post_title='Test Post' --porcelain`
246+
Then save STDOUT as {POST_ID}
247+
248+
When I try `wp menu item get {POST_ID}`
249+
Then STDERR should be:
250+
"""
251+
Error: Invalid menu item.
252+
"""
253+
And the return code should be 1
254+

0 commit comments

Comments
 (0)