diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
index 30cb8f69fa..6865de74a4 100644
|
|
class WP_REST_Posts_Controller extends WP_REST_Controller { |
1525 | 1525 | return false; |
1526 | 1526 | } |
1527 | 1527 | |
| 1528 | // Accounts for attachments with an inherit status on trashed and deleted parents. |
| 1529 | $post_status = get_post_status( $post ); |
| 1530 | |
1528 | 1531 | // Is the post readable? |
1529 | | if ( 'publish' === $post->post_status || current_user_can( 'read_post', $post->ID ) ) { |
| 1532 | if ( 'publish' === $post_status || current_user_can( 'read_post', $post->ID ) ) { |
1530 | 1533 | return true; |
1531 | 1534 | } |
1532 | 1535 | |
1533 | | $post_status_obj = get_post_status_object( $post->post_status ); |
| 1536 | $post_status_obj = get_post_status_object( $post_status ); |
1534 | 1537 | if ( $post_status_obj && $post_status_obj->public ) { |
1535 | 1538 | return true; |
1536 | 1539 | } |
1537 | 1540 | |
1538 | 1541 | // Can we read the parent if we're inheriting? |
1539 | | if ( 'inherit' === $post->post_status && $post->post_parent > 0 ) { |
| 1542 | if ( 'inherit' === $post_status && $post->post_parent > 0 ) { |
1540 | 1543 | $parent = get_post( $post->post_parent ); |
1541 | 1544 | if ( $parent ) { |
1542 | 1545 | return $this->check_read_permission( $parent ); |
… |
… |
class WP_REST_Posts_Controller extends WP_REST_Controller { |
1547 | 1550 | * If there isn't a parent, but the status is set to inherit, assume |
1548 | 1551 | * it's published (as per get_post_status()). |
1549 | 1552 | */ |
1550 | | if ( 'inherit' === $post->post_status ) { |
| 1553 | if ( 'inherit' === $post_status ) { |
1551 | 1554 | return true; |
1552 | 1555 | } |
1553 | 1556 | |