public function check_read_permission( $post ) {
		$post_type = get_post_type_object( $post->post_type );
		if ( ! $this->check_is_post_type_allowed( $post_type ) ) {
			return false;
		}

		// Can we read the post?
		if ( 'publish' === $post->post_status || current_user_can( $post_type->cap->read_post, $post->ID ) ) {
			return true;
		}

		$post_status_obj = get_post_status_object( $post->post_status );
		if ( $post_status_obj && $post_status_obj->public ) {
			return true;
		}

		// Can we read the parent if we're inheriting?
		if ( 'inherit' === $post->post_status && $post->post_parent > 0 ) {
			$parent = $this->get_post( $post->post_parent );
			return $this->check_read_permission( $parent );
		}

		// If we don't have a parent, but the status is set to inherit, assume
		// it's published (as per get_post_status()).
		if ( 'inherit' === $post->post_status ) {
			return true;
		}

		return false;
	}
public function check_read_permission( $post ) {
		$post_type = get_post_type_object( $post->post_type );
		if ( ! $this->check_is_post_type_allowed( $post_type ) ) {
			return false;
		}

		// Can we read the post?
		if ( 'publish' === $post->post_status || current_user_can( $post_type->cap->read_post, $post->ID ) ) {
			return true;
		}

		$post_status_obj = get_post_status_object( $post->post_status );
		if ( $post_status_obj && $post_status_obj->public ) {
			return true;
		}

		// Can we read the parent if we're inheriting?
		if ( 'inherit' === $post->post_status && $post->post_parent > 0 ) {
			$parent = $this->get_post( $post->post_parent );
			return $this->check_read_permission( $parent );
		}

		// If we don't have a parent, but the status is set to inherit, assume
		// it's published (as per get_post_status()).
		if ( 'inherit' === $post->post_status ) {
			return true;
		}

		return false;
	}
public function check_read_permission ( $ post ) { $ post_type = get_post_type_object ( $ post -> post_type ) ; if ( ! $ this -> check_is_post_type_allowed ( $ post_type ) ) { return false ; } // Can we read the post? if ( 'publish' === $ post -> post_status || current_user_can ( $ post_type -> cap -> read_post , $ post -> ID ) ) { return true ; } $ post_status_obj = get_post_status_object ( $ post -> post_status ) ; if ( $ post_status_obj && $ post_status_obj -> public ) { return true ; } // Can we read the parent if we're inheriting? if ( 'inherit' === $ post -> post_status && $ post -> post_parent > 0 ) { $ parent = $ this -> get_post ( $ post -> post_parent ) ; return $ this -> check_read_permission ( $ parent ) ; } // If we don't have a parent, but the status is set to inherit, assume // it's published (as per get_post_status()). if ( 'inherit' === $ post -> post_status ) { return true ; } return false ; }
Check if we can read a post.

Correctly handles posts with the inherit status.

@param object $post Post object.
@return boolean Can we read it?
Check if we can read a post .