Skip to content

Commit dd15200

Browse files
authored
Merge branch 'main' into copilot/add-wp-cli-menu-item-get-command
2 parents 7789f3e + e982b14 commit dd15200

17 files changed

+907
-20
lines changed

.github/workflows/code-quality.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
branches:
77
- main
88
- master
9+
schedule:
10+
- cron: '17 2 * * *' # Run every day on a seemly random time.
911

1012
jobs:
1113
code-quality:

README.md

Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ wp comment create [--<field>=<value>] [--porcelain]
150150

151151
# Create a note (WordPress 6.9+).
152152
$ wp comment create --comment_post_ID=15 --comment_content="This block needs revision" --comment_author="editor" --comment_type="note"
153-
Success: Created comment 933.
 *
153+
Success: Created comment 933.
154154

155155

156156

@@ -2947,6 +2947,116 @@ wp post meta update <id> <key> [<value>] [--format=<format>]
29472947

29482948

29492949

2950+
### wp post revision
2951+
2952+
Manages post revisions.
2953+
2954+
~~~
2955+
wp post revision
2956+
~~~
2957+
2958+
**EXAMPLES**
2959+
2960+
# Restore a post revision
2961+
$ wp post revision restore 123
2962+
Success: Restored revision 123.
2963+
2964+
# Show diff between two revisions
2965+
$ wp post revision diff 123 456
2966+
2967+
2968+
2969+
2970+
2971+
### wp post revision diff
2972+
2973+
Shows the difference between two revisions.
2974+
2975+
~~~
2976+
wp post revision diff <from> [<to>] [--field=<field>]
2977+
~~~
2978+
2979+
**OPTIONS**
2980+
2981+
<from>
2982+
The 'from' revision ID or post ID.
2983+
2984+
[<to>]
2985+
The 'to' revision ID or post ID. If not provided, compares with the current post.
2986+
2987+
[--field=<field>]
2988+
Compare specific field(s). Default: post_content
2989+
2990+
**EXAMPLES**
2991+
2992+
# Show diff between two revisions
2993+
$ wp post revision diff 123 456
2994+
2995+
# Show diff between a revision and the current post
2996+
$ wp post revision diff 123
2997+
2998+
2999+
3000+
### wp post revision prune
3001+
3002+
Deletes old post revisions.
3003+
3004+
~~~
3005+
wp post revision prune [<post-id>...] [--latest=<limit>] [--earliest=<limit>] [--yes]
3006+
~~~
3007+
3008+
**OPTIONS**
3009+
3010+
[<post-id>...]
3011+
One or more post IDs to prune revisions for. If not provided, prunes revisions for all posts.
3012+
3013+
[--latest=<limit>]
3014+
Keep only the latest N revisions per post. Older revisions will be deleted.
3015+
3016+
[--earliest=<limit>]
3017+
Keep only the earliest N revisions per post. Newer revisions will be deleted.
3018+
3019+
[--yes]
3020+
Skip confirmation prompt.
3021+
3022+
**EXAMPLES**
3023+
3024+
# Delete all but the latest 5 revisions for post 123
3025+
$ wp post revision prune 123 --latest=5
3026+
Success: Deleted 3 revisions for post 123.
3027+
3028+
# Delete all but the latest 5 revisions for all posts
3029+
$ wp post revision prune --latest=5
3030+
Success: Deleted 150 revisions across 30 posts.
3031+
3032+
# Delete all but the earliest 2 revisions for posts 123 and 456
3033+
$ wp post revision prune 123 456 --earliest=2
3034+
Success: Deleted 5 revisions for post 123.
3035+
Success: Deleted 3 revisions for post 456.
3036+
3037+
3038+
3039+
### wp post revision restore
3040+
3041+
Restores a post revision.
3042+
3043+
~~~
3044+
wp post revision restore <revision_id>
3045+
~~~
3046+
3047+
**OPTIONS**
3048+
3049+
<revision_id>
3050+
The revision ID to restore.
3051+
3052+
**EXAMPLES**
3053+
3054+
# Restore a post revision
3055+
$ wp post revision restore 123
3056+
Success: Restored revision 123.
3057+
3058+
3059+
29503060
### wp post term
29513061

29523062
Adds, updates, removes, and lists post terms.
@@ -5612,6 +5722,7 @@ These fields will be displayed by default for each term:
56125722

56135723
These fields are optionally available:
56145724

5725+
* term_group
56155726
* url
56165727

56175728
**EXAMPLES**

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@
115115
"post meta patch",
116116
"post meta pluck",
117117
"post meta update",
118+
"post revision",
119+
"post revision diff",
120+
"post revision prune",
121+
"post revision restore",
118122
"post term",
119123
"post term add",
120124
"post term list",

entity-command.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
)
4747
);
4848
WP_CLI::add_command( 'post meta', 'Post_Meta_Command' );
49+
WP_CLI::add_command( 'post revision', 'Post_Revision_Command' );
4950
WP_CLI::add_command( 'post term', 'Post_Term_Command' );
5051
WP_CLI::add_command( 'post-type', 'Post_Type_Command' );
5152
WP_CLI::add_command( 'site', 'Site_Command' );
@@ -54,11 +55,15 @@
5455
'Site_Meta_Command',
5556
array(
5657
'before_invoke' => function () {
58+
/**
59+
* @var \wpdb $wpdb
60+
*/
61+
global $wpdb;
5762
if ( ! is_multisite() ) {
5863
WP_CLI::error( 'This is not a multisite installation.' );
5964
}
6065
if ( ! function_exists( 'is_site_meta_supported' ) || ! is_site_meta_supported() ) {
61-
WP_CLI::error( sprintf( 'The %s table is not installed. Please run the network database upgrade.', $GLOBALS['wpdb']->blogmeta ) );
66+
WP_CLI::error( sprintf( 'The %s table is not installed. Please run the network database upgrade.', $wpdb->blogmeta ) );
6267
}
6368
},
6469
)

features/post-block.feature

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,15 @@ Feature: Manage blocks in post content
127127
Then save STDOUT as {POST_ID}
128128

129129
When I run `wp post block render {POST_ID}`
130+
# In WordPress 7.0+ paragraph blocks are rendered with a class name.
131+
# See https://github.com/WordPress/gutenberg/pull/71207.
130132
Then STDOUT should contain:
131133
"""
132-
<p>Hello World</p>
134+
<p
135+
"""
136+
And STDOUT should contain:
137+
"""
138+
>Hello World</p>
133139
"""
134140
And STDOUT should contain:
135141
"""
@@ -143,7 +149,11 @@ Feature: Manage blocks in post content
143149
When I run `wp post block render {POST_ID} --block=core/paragraph`
144150
Then STDOUT should contain:
145151
"""
146-
<p>Hello World</p>
152+
<p
153+
"""
154+
And STDOUT should contain:
155+
"""
156+
>Hello World</p>
147157
"""
148158
And STDOUT should not contain:
149159
"""
@@ -773,9 +783,15 @@ Feature: Manage blocks in post content
773783
Then save STDOUT as {POST_ID}
774784

775785
When I run `wp post block export {POST_ID} --format=html`
786+
# In WordPress 7.0+ paragraph blocks are rendered with a class name.
787+
# See https://github.com/WordPress/gutenberg/pull/71207.
776788
Then STDOUT should contain:
777789
"""
778-
<p>Hello World</p>
790+
<p
791+
"""
792+
And STDOUT should contain:
793+
"""
794+
>Hello World</p>
779795
"""
780796

781797
@require-wp-5.0

0 commit comments

Comments
 (0)