From 269bd96f65a8341748bee41a39b44ed01396a139 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 20 Jun 2014 19:14:15 +0000 Subject: [PATCH] Posts in the Trash should not drag attachment pages down with them. Props ericlewis. Fixes #14639. Built from https://develop.svn.wordpress.org/trunk@28791 git-svn-id: http://core.svn.wordpress.org/trunk@28604 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 31b70967c6..ee456747e4 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -836,8 +836,15 @@ function get_post_status($ID = '') { return 'publish'; // Inherit status from the parent - if ( $post->post_parent && ( $post->ID != $post->post_parent ) ) - return get_post_status($post->post_parent); + if ( $post->post_parent && ( $post->ID != $post->post_parent ) ) { + $parent_post_status = get_post_status( $post->post_parent ); + if ( 'trash' == $parent_post_status ) { + return get_post_meta( $post->post_parent, '_wp_trash_meta_status', true ); + } else { + return $parent_post_status; + } + } + } return $post->post_status; @@ -3243,7 +3250,7 @@ function wp_insert_post( $postarr, $wp_error = false ) { if ( ! $update && '' == $current_guid ) { $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where ); } - + if ( 'attachment' === $postarr['post_type'] ) { if ( ! empty( $postarr['file'] ) ) { update_attached_file( $post_ID, $postarr['file'] );