Skip to content

Commit eb56981

Browse files
Copilotswissspidy
andcommitted
Skip --force requirement for already trashed posts
Co-authored-by: swissspidy <[email protected]>
1 parent e2c5c12 commit eb56981

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

features/post.feature

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@ Feature: Manage WordPress posts
5757
When I try the previous command again
5858
Then the return code should be 1
5959

60+
Scenario: Deleting already trashed custom post type posts
61+
When I run `wp post create --post_title='Test CPT post' --post_type='book' --porcelain`
62+
Then STDOUT should be a number
63+
And save STDOUT as {BOOK_POST_ID}
64+
65+
When I run `wp post update {BOOK_POST_ID} --post_status='trash'`
66+
Then STDOUT should be:
67+
"""
68+
Success: Updated post {BOOK_POST_ID}.
69+
"""
70+
71+
When I run `wp post delete {BOOK_POST_ID}`
72+
Then STDOUT should be:
73+
"""
74+
Success: Deleted post {BOOK_POST_ID}.
75+
"""
76+
6077
Scenario: Updating an invalid post should exit with an error
6178
Given a WP install
6279

src/Post_Command.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ protected function delete_callback( $post_id, $assoc_args ) {
497497
$post_type = get_post_type( $post_id );
498498

499499
if ( ! $assoc_args['force']
500+
&& 'trash' !== $status
500501
&& ( 'post' !== $post_type && 'page' !== $post_type ) ) {
501502
return [
502503
'error',

0 commit comments

Comments
 (0)