@@ -506,7 +506,9 @@ protected function delete_callback( $post_id, $assoc_args ) {
506506 $ status = get_post_status ( $ post_id );
507507 $ post_type = get_post_type ( $ post_id );
508508
509- if ( $ assoc_args ['force ' ] || 'trash ' === $ status || 'revision ' === $ post_type ) {
509+ $ force_delete = $ assoc_args ['force ' ] || 'trash ' === $ status || 'revision ' === $ post_type ;
510+
511+ if ( $ force_delete || ! EMPTY_TRASH_DAYS ) {
510512 if ( ! wp_delete_post ( $ post_id , true ) ) {
511513 return [ 'error ' , "Failed deleting post {$ post_id }. " ];
512514 }
@@ -517,19 +519,10 @@ protected function delete_callback( $post_id, $assoc_args ) {
517519 // Use wp_trash_post() directly because wp_delete_post() only auto-trashes
518520 // 'post' and 'page' types, permanently deleting all other post types even
519521 // when $force_delete is false. wp_trash_post() works for all post types.
520- if ( EMPTY_TRASH_DAYS && wp_trash_post ( $ post_id ) ) {
522+ if ( wp_trash_post ( $ post_id ) ) {
521523 return [ 'success ' , "Trashed post {$ post_id }. " ];
522524 }
523525
524- // Trash is disabled via EMPTY_TRASH_DAYS, or wp_trash_post() failed.
525- if ( ! EMPTY_TRASH_DAYS ) {
526- if ( ! wp_delete_post ( $ post_id , true ) ) {
527- return [ 'error ' , "Failed deleting post {$ post_id }. " ];
528- }
529-
530- return [ 'success ' , "Deleted post {$ post_id }. " ];
531- }
532-
533526 return [ 'error ' , "Failed trashing post {$ post_id }. " ];
534527 }
535528
0 commit comments