WordPress.org

Make WordPress Core

Ticket #32991: 32991.patch

File 32991.patch, 2.9 KB (added by flixos90, 4 years ago)

wp_delete_post, wp_delete_attachment, wp_trash_post, wp_untrash_post return WP_Post

  • src/wp-includes/post.php

     
    26102610 * @param int  $postid       Optional. Post ID. Default 0.
    26112611 * @param bool $force_delete Optional. Whether to bypass trash and force deletion.
    26122612 *                           Default false.
    2613  * @return array|false|WP_Post False on failure.
     2613 * @return WP_Post|null|false False on failure.
    26142614 */
    26152615function wp_delete_post( $postid = 0, $force_delete = false ) {
    26162616        global $wpdb;
    26172617
    2618         if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
     2618        if ( !$post = get_post( $postid ) )
    26192619                return $post;
    26202620
    26212621        if ( !$force_delete && ( $post->post_type == 'post' || $post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS )
     
    27532753 *
    27542754 * @param int $post_id Optional. Post ID. Default is ID of the global $post
    27552755 *                     if EMPTY_TRASH_DAYS equals true.
    2756  * @return false|array|WP_Post|null Post data array, otherwise false.
     2756 * @return WP_Post|null|false False on failure.
    27572757 */
    27582758function wp_trash_post( $post_id = 0 ) {
    27592759        if ( !EMPTY_TRASH_DAYS )
     
    27912791         */
    27922792        do_action( 'trashed_post', $post_id );
    27932793
    2794         return $post;
     2794        return get_post( $post_id );
    27952795}
    27962796
    27972797/**
     
    28002800 * @since 2.9.0
    28012801 *
    28022802 * @param int $post_id Optional. Post ID. Default is ID of the global $post.
    2803  * @return WP_Post|false WP_Post object. False on failure.
     2803 * @return WP_Post|null|false False on failure.
    28042804 */
    28052805function wp_untrash_post( $post_id = 0 ) {
    28062806        if ( !$post = get_post($post_id, ARRAY_A) )
     
    28382838         */
    28392839        do_action( 'untrashed_post', $post_id );
    28402840
    2841         return $post;
     2841        return get_post( $post_id );
    28422842}
    28432843
    28442844/**
     
    48734873 * @param int  $post_id      Attachment ID.
    48744874 * @param bool $force_delete Optional. Whether to bypass trash and force deletion.
    48754875 *                           Default false.
    4876  * @return mixed False on failure. Post data on success.
     4876 * @return WP_Post|null|false False on failure.
    48774877 */
    48784878function wp_delete_attachment( $post_id, $force_delete = false ) {
    48794879        global $wpdb;
    48804880
    4881         if ( !$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) ) )
     4881        if ( !$post = get_post( $post_id ) )
    48824882                return $post;
    48834883
    48844884        if ( 'attachment' != $post->post_type )
  • src/wp-includes/revision.php

     
    383383 * @since 2.6.0
    384384 *
    385385 * @param int|WP_Post $revision_id Revision ID or revision object.
    386  * @return array|false|WP_Post|WP_Error|null Null or WP_Error if error, deleted post if success.
     386 * @return WP_Post|null|false False on failure.
    387387 */
    388388function wp_delete_post_revision( $revision_id ) {
    389389        if ( ! $revision = wp_get_post_revision( $revision_id ) ) {