Make WordPress Core

Ticket #41445: 41445.3.diff

File 41445.3.diff, 1.6 KB (added by adamsilverstein, 3 years ago)
  • src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    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 { 
    15251525                        return false;
    15261526                }
    15271527
     1528                // Accounts for attachments with an inherit status on trashed and deleted parents.
     1529                $post_status = get_post_status( $post );
     1530
    15281531                // 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 ) ) {
    15301533                        return true;
    15311534                }
    15321535
    1533                 $post_status_obj = get_post_status_object( $post->post_status );
     1536                $post_status_obj = get_post_status_object( $post_status );
    15341537                if ( $post_status_obj && $post_status_obj->public ) {
    15351538                        return true;
    15361539                }
    15371540
    15381541                // 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 ) {
    15401543                        $parent = get_post( $post->post_parent );
    15411544                        if ( $parent ) {
    15421545                                return $this->check_read_permission( $parent );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    15471550                 * If there isn't a parent, but the status is set to inherit, assume
    15481551                 * it's published (as per get_post_status()).
    15491552                 */
    1550                 if ( 'inherit' === $post->post_status ) {
     1553                if ( 'inherit' === $post_status ) {
    15511554                        return true;
    15521555                }
    15531556