rest_parse_request_arg() WordPress Function

The rest_parse_request_arg() function is used to parse a JSON request body into an array. This function is used by the WordPress REST API to parse JSON request bodies.

rest_parse_request_arg( mixed $value, WP_REST_Request $request, string $param ) #

Parse a request argument based on details registered to the route.


Description

Runs a validation check and sanitizes the value, primarily to be used via the sanitize_callback arguments in the endpoint args registration.


Top ↑

Parameters

$value

(mixed)(Required)

$request

(WP_REST_Request)(Required)

$param

(string)(Required)


Top ↑

Return

(mixed)


Top ↑

Source

File: wp-includes/rest-api.php

function rest_parse_request_arg( $value, $request, $param ) {
	$is_valid = rest_validate_request_arg( $value, $request, $param );

	if ( is_wp_error( $is_valid ) ) {
		return $is_valid;
	}

	$value = rest_sanitize_request_arg( $value, $request, $param );

	return $value;
}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More