From e2c5c1231fc56605e6410096448cb4b6b1a7ed71 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 10:43:11 +0000 Subject: [PATCH 1/2] Initial plan From eb5698119bf447000c2fe1db610b509ec3aca421 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 10:57:18 +0000 Subject: [PATCH 2/2] Skip --force requirement for already trashed posts Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/post.feature | 17 +++++++++++++++++ src/Post_Command.php | 1 + 2 files changed, 18 insertions(+) diff --git a/features/post.feature b/features/post.feature index 858668bf..1988cce5 100644 --- a/features/post.feature +++ b/features/post.feature @@ -57,6 +57,23 @@ Feature: Manage WordPress posts When I try the previous command again Then the return code should be 1 + Scenario: Deleting already trashed custom post type posts + When I run `wp post create --post_title='Test CPT post' --post_type='book' --porcelain` + Then STDOUT should be a number + And save STDOUT as {BOOK_POST_ID} + + When I run `wp post update {BOOK_POST_ID} --post_status='trash'` + Then STDOUT should be: + """ + Success: Updated post {BOOK_POST_ID}. + """ + + When I run `wp post delete {BOOK_POST_ID}` + Then STDOUT should be: + """ + Success: Deleted post {BOOK_POST_ID}. + """ + Scenario: Updating an invalid post should exit with an error Given a WP install diff --git a/src/Post_Command.php b/src/Post_Command.php index b8dd833d..05c5af1b 100644 --- a/src/Post_Command.php +++ b/src/Post_Command.php @@ -497,6 +497,7 @@ protected function delete_callback( $post_id, $assoc_args ) { $post_type = get_post_type( $post_id ); if ( ! $assoc_args['force'] + && 'trash' !== $status && ( 'post' !== $post_type && 'page' !== $post_type ) ) { return [ 'error',