WP_REST_Request::has_param() public WP 5.3.0
Checks if a parameter exists in the request.
This allows distinguishing between an omitted parameter, and a parameter specifically set to null.
{} It's a method of the class: WP_REST_Request{}
No Hooks.
Return
true/false. True if a param exists for the given key.
Usage
$WP_REST_Request = new WP_REST_Request(); $WP_REST_Request->has_param( $key );
- $key(string) (required)
- Parameter name.
Changelog
Since 5.3.0 | Introduced. |
Code of WP_REST_Request::has_param() WP REST Request::has param WP 5.6
public function has_param( $key ) {
$order = $this->get_parameter_order();
foreach ( $order as $type ) {
if ( is_array( $this->params[ $type ] ) && array_key_exists( $key, $this->params[ $type ] ) ) {
return true;
}
}
return false;
}