Recent

RESTclassPro only

REST

Registers POST /bsearch/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\Better_Search\Pro\AI
Since: 4.5.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: 4.5.0
Line: 65

static public function get_url(  ): string;

Returns: string — URL.

register_routes()

Register the route.

Since: 4.5.0
Line: 74

public function register_routes(  ): void;

Returns: void

check_permission()

Public questions are allowed only from this site’s browser UI.

Since: 4.5.0
Line: 112

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

Returns: bool|\WP_Error — Whether the request is allowed.

ask()

Handle a request.

Since: 4.5.0
Line: 130

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: 4.5.0
Line: 174

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: 4.5.0
Line: 200

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.