Ticket #42030: 42030.3.patch
| File 42030.3.patch, 2.5 KB (added by , 8 years ago) |
|---|
-
wp-includes/post.php
2586 2586 * @return false|array|WP_Post|null Post data array, otherwise false. 2587 2587 */ 2588 2588 function wp_trash_post( $post_id = 0 ) { 2589 if ( !EMPTY_TRASH_DAYS ) 2590 return wp_delete_post($post_id, true); 2589 if ( ! EMPTY_TRASH_DAYS ) { 2590 return wp_delete_post( $post_id, true ); 2591 } 2591 2592 2592 if ( !$post = get_post($post_id, ARRAY_A) ) 2593 $post = get_post( $post_id ); 2594 2595 if ( ! $post ) { 2593 2596 return $post; 2597 } 2594 2598 2595 if ( $post['post_status'] == 'trash' )2599 if ( 'trash' == $post->post_status ) { 2596 2600 return false; 2601 } 2597 2602 2598 2603 /** 2599 2604 * Filters whether a post trashing should take place. … … 2617 2622 */ 2618 2623 do_action( 'wp_trash_post', $post_id ); 2619 2624 2620 add_post_meta( $post_id,'_wp_trash_meta_status', $post['post_status']);2621 add_post_meta( $post_id,'_wp_trash_meta_time', time());2625 add_post_meta( $post_id,'_wp_trash_meta_status', $post->post_status ); 2626 add_post_meta( $post_id,'_wp_trash_meta_time', time() ); 2622 2627 2623 $post ['post_status']= 'trash';2624 wp_insert_post( wp_slash( $post ));2628 $post->post_status = 'trash'; 2629 wp_insert_post( $post ); 2625 2630 2626 wp_trash_post_comments( $post_id);2631 wp_trash_post_comments( $post_id ); 2627 2632 2628 2633 /** 2629 2634 * Fires after a post is sent to the trash. … … 2646 2651 * @return WP_Post|false WP_Post object. False on failure. 2647 2652 */ 2648 2653 function wp_untrash_post( $post_id = 0 ) { 2649 if ( !$post = get_post($post_id, ARRAY_A) ) 2654 $post = get_post( $post_id ); 2655 2656 if ( ! $post ) { 2650 2657 return $post; 2658 } 2651 2659 2652 if ( $post['post_status'] != 'trash' )2660 if ( 'trash' != $post->post_status ) { 2653 2661 return false; 2662 } 2654 2663 2655 2664 /** 2656 2665 * Filters whether a post untrashing should take place. … … 2674 2683 */ 2675 2684 do_action( 'untrash_post', $post_id ); 2676 2685 2677 $post_status = get_post_meta( $post_id, '_wp_trash_meta_status', true);2686 $post_status = get_post_meta( $post_id, '_wp_trash_meta_status', true ); 2678 2687 2679 $post ['post_status']= $post_status;2688 $post->post_status = $post_status; 2680 2689 2681 delete_post_meta( $post_id, '_wp_trash_meta_status');2682 delete_post_meta( $post_id, '_wp_trash_meta_time');2690 delete_post_meta( $post_id, '_wp_trash_meta_status' ); 2691 delete_post_meta( $post_id, '_wp_trash_meta_time' ); 2683 2692 2684 wp_insert_post( wp_slash( $post ));2693 wp_insert_post( $post ); 2685 2694 2686 wp_untrash_post_comments( $post_id);2695 wp_untrash_post_comments( $post_id ); 2687 2696 2688 2697 /** 2689 2698 * Fires after a post is restored from the trash.