@@ -447,24 +447,39 @@ public function get( $args, $assoc_args ) {
447447	 *     Success: Deleted post 1294. 
448448	 */ 
449449	public  function  delete ( $ args$ assoc_args
450- 		$ defaultsarray (
451- 			'force '  => false ,
452- 		);
450+ 		$ defaults'force '  => false  ];
453451		$ assoc_argsarray_merge ( $ defaults$ assoc_args
454452
455- 		parent ::_delete ( $ args$ assoc_argsfunction  ( $ post_id$ assoc_args
456- 			$ statusget_post_status ( $ post_id
457- 			$ post_typeget_post_type ( $ post_id
458- 			$ rwp_delete_post ( $ post_id$ assoc_args'force ' ] );
453+ 		parent ::_delete ( $ args$ assoc_args$ this 'delete_callback '  ] );
454+ 	}
455+ 
456+ 	/** 
457+ 	 * Callback used to delete a post. 
458+ 	 * 
459+ 	 * @param $post_id 
460+ 	 * @param $assoc_args 
461+ 	 * @return array 
462+ 	 */ 
463+ 	protected  function  delete_callback ( $ post_id$ assoc_args
464+ 		$ statusget_post_status ( $ post_id
465+ 		$ post_typeget_post_type ( $ post_id
466+ 
467+ 		if  ( ! $ assoc_args'force ' ]
468+ 			&& ( $ post_type'post '  && $ post_type'page '  ) ) {
469+ 			return  [
470+ 				'error ' ,
471+ 				"Posts of type ' {$ post_type' do not support being sent to trash. \n" 
472+ 				. 'Please use the --force flag to skip trash and delete them permanently. ' ,
473+ 			];
474+ 		}
475+ 
476+ 		if  ( ! wp_delete_post ( $ post_id$ assoc_args'force ' ] ) ) {
477+ 			return  [ 'error ' , "Failed deleting post  {$ post_id. "  ];
478+ 		}
459479
460- 			if  ( $ r
461- 				$ action$ assoc_args'force ' ] || 'trash '  === $ status'revision '  === $ post_type'Deleted '  : 'Trashed ' ;
480+ 		$ action$ assoc_args'force ' ] || 'trash '  === $ status'revision '  === $ post_type'Deleted '  : 'Trashed ' ;
462481
463- 				return  array ( 'success ' , "$ action post  $ post_id. "  );
464- 			} else  {
465- 				return  array ( 'error ' , "Failed deleting post  $ post_id. "  );
466- 			}
467- 		} );
482+ 		return  [ 'success ' , "{$ action post  {$ post_id. "  ];
468483	}
469484
470485	/** 
0 commit comments