Recent

RESTclassPro only

REST

Registers POST /wzkb/v1/ask.

The endpoint is public. Page caching makes nonces unreliable for anonymous visitors, so it relies on a same-origin check plus the guards in Ask_Handler instead.

Namespace: WebberZone\Knowledge_Base\Pro\AI
Since: 3.2.0
Source: includes/pro/ai/class-rest.php line 24

Methods

__construct()

Constructor.

Line: 52

public function __construct( Ask_Handler $handler );
Type Name Description
Ask_Handler $handler Ask handler.

get_url() static

Full URL of the endpoint.

Since: 3.2.0
Line: 65

static public function get_url(  ): string;

Returns: string — URL.

register_routes()

Register the route.

Since: 3.2.0
Line: 74

public function register_routes(  ): void;

Returns: void

ask()

Handle a request.

Since: 3.2.0
Line: 101

public function ask( WP_REST_Request $request ): \WP_REST_Response|\WP_Error;
Type Name Description
\WP_REST_Request $request Request.

Returns: \WP_REST_Response|\WP_Error — Response.

is_bot() static

Whether the request comes from a crawler, script or HTTP library rather than a browser.

Since: 3.2.0
Line: 146

static public function is_bot( WP_REST_Request $request ): bool;
Type Name Description
\WP_REST_Request $request Request.

Returns: bool — True if the user agent is empty or looks automated.

is_same_origin() static

Whether the request’s Origin (or, failing that, Referer) is this site.

Since: 3.2.0
Line: 172

static public function is_same_origin( WP_REST_Request $request ): bool;
Type Name Description
\WP_REST_Request $request Request.

Returns: bool — True if same origin.