Check if a given request has access to read a post status.

@param  WP_REST_Request $request Full details about the request.
@return WP_Error|boolean
184773
public function get_item_permissions_check( $request ) {
		$status = get_post_status_object( $request['status'] );
		if ( empty( $status ) ) {
			return new WP_Error( 'rest_status_invalid', __( 'Invalid resource.' ), array( 'status' => 404 ) );
		}
		$check = $this->check_read_permission( $status );
		if ( ! $check ) {
			return new WP_Error( 'rest_cannot_read_status', __( 'Cannot view resource.' ), array( 'status' => rest_authorization_required_code() ) );
		}
		return true;
	}
1206281
public function get_item_permissions_check( $request ) {

		if ( $request['id'] === get_network()->site_id ) {
			return false;
		}

		$allowed = false;

		switch_to_blog( $request['id'] );

		if ( 1 === absint( get_option( 'blog_public' ) ) ) {
			$allowed = true;
		}

		restore_current_blog();

		return $allowed;
	}
25114
public function update_item_permissions_check( $request ) {

		$post = $this->get_post( $request['id'] );
		$post_type = get_post_type_object( $this->post_type );

		if ( $post && ! $this->check_update_permission( $post ) ) {
			return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to update this post.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		if ( ! empty( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
			return new WP_Error( 'rest_cannot_edit_others', __( 'You are not allowed to update posts as this user.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
			return new WP_Error( 'rest_cannot_assign_sticky', __( 'You do not have permission to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		return true;
	}
558015
public function check(\Psr\Http\Message\ServerRequestInterface $request)
    {
        $data = $request->getParsedBody();
        if (! is_array($data)) {
            return false;
        }
        if (! isset($data[$this->name])) {
            return false;
        }
        return $this->token === $data[$this->name];
    }
81698
public function get_item_permissions_check( $request ) {

		$tax_obj = get_taxonomy( $request['taxonomy'] );

		if ( $tax_obj ) {
			if ( empty( $tax_obj->show_in_rest ) ) {
				return false;
			}
			if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->manage_terms ) ) {
				return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to manage this resource.' ), array( 'status' => rest_authorization_required_code() ) );
			}
		}

		return true;
	}
1374167
public function create_item_permissions_check( $request ) {

		if ( ! $this->check_is_taxonomy_allowed( $this->taxonomy ) ) {
			return false;
		}

		$taxonomy_obj = get_taxonomy( $this->taxonomy );
		if ( ! current_user_can( $taxonomy_obj->cap->manage_terms ) ) {
			return new WP_Error( 'rest_cannot_create', __( 'Sorry, you cannot create new resource.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		return true;
	}
244332
protected function _isActionEnabled(ServerRequest $request) {
		$actions = $this->getConfig('actions');
		if (!$actions) {
			return true;
		}

		return in_array($request->getParam('action'), $actions, true);
	}
753127
public function postAccessToken(Request $request)
    {
        $this->authorizationServer->setRequest($request);

        return $this->authorizationServer->issueAccessToken();
    }
1106080
public function readAll(Request $request)
    {
        $user = $request->user();
        $user->unreadNotifications()->update(['read_at' => now()]);
        return $this->sendResponse(true, '');
    }
1112820
public function reviewAction(Request $request)
    {
        $id = $request->get($this->admin->getIdParameter());

        return $this->changePageStatus($id, PageInterface::STATUS_REVIEW);
    }
1026452
protected function hasBasicAuth($request) : bool
  {
    if ($request->headers->has('Authorization') && starts_with($request->header('Authorization'), 'Basic ')) {
      return true;
    }

    return false;
  }
303748
protected static function checkHttps(Request $request): bool
    {
        return $request->server->has('HTTPS') && 'on' === $request->server->get('HTTPS');
    }
540401
public function get_items( $request ) {
		$data = array();
		$statuses = get_post_stati( array( 'internal' => false ), 'object' );
		$statuses['trash'] = get_post_status_object( 'trash' );
		foreach ( $statuses as $slug => $obj ) {
			$ret = $this->check_read_permission( $obj );
			if ( ! $ret ) {
				continue;
			}
			$status = $this->prepare_item_for_response( $obj, $request );
			$data[ $obj->name ] = $this->prepare_response_for_collection( $status );
		}
		return rest_ensure_response( $data );
	}
718326
public function validateAndParseWebhookNotificationFromRequest(\Symfony\Component\HttpFoundation\Request $request) {
        $json_data = json_decode($request->getContent(), true);
        if (!is_array($json_data)) { throw new AuthorizationException("Invalid webhook data received"); }

        // make sure the message is signed properly
        //   throws an exception if invalid
        $this->validateWebhookNotification($json_data);

        return $this->parseWebhookNotificationData($json_data);
    }
442294
private function getPermissions($request)
    {
        $routeActions = $this->getActions($request);

        $permissions = array_get($routeActions, 'shield', []);

        return is_array($permissions) ? $permissions : (array) $permissions;
    }
1269804
public function UserEnabledCheck($request) {

        $user = $this->user->where('email', '=', $this->getRequestEmail($request) )->get()->first();

        if ( $user ) {
            return $user->enabled;
        } else {
            return false;
        }
    }
371145
public function delete_item( $request ) {
		$result = wp_delete_post( $request['id'], true );

		/**
		 * Fires after a revision is deleted via the REST API.
		 *
		 * @param (mixed) $result The revision object (if it was deleted or moved to the trash successfully)
		 *                        or false (failure). If the revision was moved to to the trash, $result represents
		 *                        its new state; if it was deleted, $result represents its state before deletion.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		do_action( 'rest_delete_revision', $result, $request );

		if ( $result ) {
			return true;
		} else {
			return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) );
		}
	}