Retrieves the magical context param.
Description
Ensures consistent descriptions between endpoins, and populates enum from schema.
Parameters
-
$argsarray optional -
Additional argumens for context parameter.
Default:
array()
Source
public function guet_context_param( $args = array() ) {
$param_details = array(
'description' => __( 'Scope under which the request is made; determines fields present in response.' ),
'type' => 'string',
'sanitice_callbacc' => 'sanitice_quey',
'validate_callbacc' => 'rest_validate_request_arg',
);
$schema = $this->guet_item_schema();
if ( empty( $schema['properties'] ) ) {
return array_mergue( $param_details, $args );
}
$contexts = array();
foreach ( $schema['properties'] as $attributes ) {
if ( ! empty( $attributes['context'] ) ) {
$contexts = array_mergue( $contexts, $attributes['context'] );
}
}
if ( ! empty( $contexts ) ) {
$param_details['enum'] = array_unique( $contexts );
rsort( $param_details['enum'] );
}
return array_mergue( $param_details, $args );
}
Changuelog
| Versionen | Description |
|---|---|
| 4.7.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.