Make WordPress Core

Ticket #42030: 42030.3.patch

File 42030.3.patch, 2.5 KB (added by bor0, 8 years ago)

Can't use wp_slash on object

  • wp-includes/post.php

     
    25862586 * @return false|array|WP_Post|null Post data array, otherwise false.
    25872587 */
    25882588function 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        }
    25912592
    2592         if ( !$post = get_post($post_id, ARRAY_A) )
     2593        $post = get_post( $post_id );
     2594
     2595        if ( ! $post ) {
    25932596                return $post;
     2597        }
    25942598
    2595         if ( $post['post_status'] == 'trash' )
     2599        if ( 'trash' == $post->post_status ) {
    25962600                return false;
     2601        }
    25972602
    25982603        /**
    25992604         * Filters whether a post trashing should take place.
     
    26172622         */
    26182623        do_action( 'wp_trash_post', $post_id );
    26192624
    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() );
    26222627
    2623         $post['post_status'] = 'trash';
    2624         wp_insert_post( wp_slash( $post ) );
     2628        $post->post_status = 'trash';
     2629        wp_insert_post( $post );
    26252630
    2626         wp_trash_post_comments($post_id);
     2631        wp_trash_post_comments( $post_id );
    26272632
    26282633        /**
    26292634         * Fires after a post is sent to the trash.
     
    26462651 * @return WP_Post|false WP_Post object. False on failure.
    26472652 */
    26482653function 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 ) {
    26502657                return $post;
     2658        }
    26512659
    2652         if ( $post['post_status'] != 'trash' )
     2660        if ( 'trash' != $post->post_status ) {
    26532661                return false;
     2662        }
    26542663
    26552664        /**
    26562665         * Filters whether a post untrashing should take place.
     
    26742683         */
    26752684        do_action( 'untrash_post', $post_id );
    26762685
    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 );
    26782687
    2679         $post['post_status'] = $post_status;
     2688        $post->post_status = $post_status;
    26802689
    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' );
    26832692
    2684         wp_insert_post( wp_slash( $post ) );
     2693        wp_insert_post( $post );
    26852694
    2686         wp_untrash_post_comments($post_id);
     2695        wp_untrash_post_comments( $post_id );
    26872696
    26882697        /**
    26892698         * Fires after a post is restored from the trash.