Ticket #11455: 11455-wp_delete_attachment.3.diff
| File 11455-wp_delete_attachment.3.diff, 1.3 KB (added by nacin, 4 years ago) |
|---|
-
post.php
1268 1268 * @param int $postid Post ID. 1269 1269 * @return mixed False on failure 1270 1270 */ 1271 function wp_trash_post( $post_id = 0) {1272 if ( EMPTY_TRASH_DAYS == 0)1273 return wp_delete_post( $post_id);1271 function wp_trash_post( $post_id = 0 ) { 1272 if ( !EMPTY_TRASH_DAYS ) 1273 return wp_delete_post( $post_id ); 1274 1274 1275 if ( !$post = wp_get_single_post( $post_id, ARRAY_A) )1275 if ( !$post = wp_get_single_post( $post_id, ARRAY_A ) ) 1276 1276 return $post; 1277 1277 1278 1278 if ( $post['post_status'] == 'trash' ) 1279 1279 return false; 1280 1280 1281 if ( $post['post_type'] == 'attachment' && !MEDIA_TRASH ) 1282 return wp_delete_attachment( $post_id, true ); 1283 1281 1284 do_action('trash_post', $post_id); 1282 1285 1283 add_post_meta( $post_id,'_wp_trash_meta_status', $post['post_status']);1284 add_post_meta( $post_id,'_wp_trash_meta_time', time());1286 add_post_meta( $post_id,'_wp_trash_meta_status', $post['post_status'] ); 1287 add_post_meta( $post_id,'_wp_trash_meta_time', time() ); 1285 1288 1286 1289 $post['post_status'] = 'trash'; 1287 wp_insert_post( $post);1290 wp_insert_post( $post ); 1288 1291 1289 wp_trash_post_comments( $post_id);1292 wp_trash_post_comments( $post_id ); 1290 1293 1291 do_action( 'trashed_post', $post_id);1294 do_action( 'trashed_post', $post_id ); 1292 1295 1293 1296 return $post; 1294 1297 }