post_type ); return $post_type && current_user_can( $post_type->cap->edit_posts ); } protected function private_type_error() { return new WP_Error( 'rest_forbidden', esc_html__( 'Sorry, you are not allowed to view these items.', 'academy' ), array( 'status' => rest_authorization_required_code() ) ); } public function get_items_permissions_check( $request ) { if ( ! $this->can_read_private_type() ) { return $this->private_type_error(); } return parent::get_items_permissions_check( $request ); } public function get_item_permissions_check( $request ) { if ( ! $this->can_read_private_type() ) { return $this->private_type_error(); } return parent::get_item_permissions_check( $request ); } }