WP_REST_Abilities_V1_Run_Controller::get_input_from_requestprivateWP 6.9.0

Extracts input parameters from the request.

Method of the class: WP_REST_Abilities_V1_Run_Controller{}

No Hooks.

Returns

Mixed|null. The input parameters.

Usage

// private - for code of main (parent) class only
$result = $this->get_input_from_request( $request );
$request(WP_REST_Request) (required)
The request object.

Changelog

Since 6.9.0 Introduced.

WP_REST_Abilities_V1_Run_Controller::get_input_from_request() code WP 6.9

private function get_input_from_request( $request ) {
	if ( in_array( $request->get_method(), array( 'GET', 'DELETE' ), true ) ) {
		// For GET and DELETE requests, look for 'input' query parameter.
		$query_params = $request->get_query_params();
		return $query_params['input'] ?? null;
	}

	// For POST requests, look for 'input' in JSON body.
	$json_params = $request->get_json_params();
	return $json_params['input'] ?? null;
}