WP_REST_Request::get_param()publicWP 4.4.0

Retrieves a parameter from the request.

Method of the class: WP_REST_Request{}

No Hooks.

Return

Mixed|null. Value if set, null otherwise.

Usage

$WP_REST_Request = new WP_REST_Request();
$WP_REST_Request->get_param( $key );
$key(string) (required)
Parameter name.

Changelog

Since 4.4.0 Introduced.

WP_REST_Request::get_param() code WP 6.6.2

public function get_param( $key ) {
	$order = $this->get_parameter_order();

	foreach ( $order as $type ) {
		// Determine if we have the parameter for this type.
		if ( isset( $this->params[ $type ][ $key ] ) ) {
			return $this->params[ $type ][ $key ];
		}
	}

	return null;
}