Retrieves merged parameters from the request.
Description
The equivalent of get_param(), but returns all parameters for the request.
Handles merging all the available values into a single array.
Source
public function get_params() {
$order = $this->get_parameter_order();
$order = array_reverse( $order, true );
$params = array();
foreach ( $order as $type ) {
/*
* array_merge() / the "+" operator will mess up
* numeric keys, so instead do a manual foreach.
*/
foreach ( (array) $this->params[ $type ] as $key => $value ) {
$params[ $key ] = $value;
}
}
return $params;
}
Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |
Example Usage: Get an array of the merged parameters from the request
Example URL:
https://developer.wordpress.org/?first_name=John&last_name=Doe&age=15&country=Nigeria
Inside the REST API endpoint’s callback:
Output:
array (size=4)
'first_name' => string 'John' (length=4)
'last_name' => string 'Doe' (length=3)
'age' => string '15' (length=2)
'country' => string 'Nigeria' (length=7)