LLMS_REST_Controller::get_collection_params()
Retrieves the query params for the objects collection.
Return Return
(array) Collection parameters.
Source Source
File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-controller.php
public function get_collection_params() {
$query_params = parent::get_collection_params();
$query_params['context']['default'] = 'view';
// We're not currently implementing searching for all of our controllers.
if ( empty( $this->is_searchable ) ) {
unset( $query_params['search'] );
} elseif ( ! empty( $this->search_columns_mapping ) ) {
$search_columns = array_keys( $this->search_columns_mapping );
$query_params['search_columns'] = array(
'description' => __( 'Column names to be searched. Accepts a single column or a comma separated list of columns.', 'lifterlms' ),
'type' => 'array',
'items' => array(
'type' => 'string',
'enum' => $search_columns,
),
'default' => $search_columns,
);
}
// page and per_page params are already specified in WP_Rest_Controller->get_collection_params().
$query_params['order'] = array(
'description' => __( 'Order sort attribute ascending or descending.', 'lifterlms' ),
'type' => 'string',
'default' => 'asc',
'enum' => array( 'asc', 'desc' ),
'validate_callback' => 'rest_validate_request_arg',
);
$query_params['orderby'] = array(
'description' => __( 'Sort collection by object attribute.', 'lifterlms' ),
'type' => 'string',
'default' => $this->orderby_properties[0],
'enum' => $this->orderby_properties,
'validate_callback' => 'rest_validate_request_arg',
);
$query_params['include'] = array(
'description' => __( 'Limit results to a list of ids. Accepts a single id or a comma separated list of ids.', 'lifterlms' ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'validate_callback' => 'rest_validate_request_arg',
);
$query_params['exclude'] = array(
'description' => __( 'Exclude a list of ids from results. Accepts a single id or a comma separated list of ids.', 'lifterlms' ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'validate_callback' => 'rest_validate_request_arg',
);
return $query_params;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0-beta.12 | Added search_columns collection param for searchable resources. |
| 1.0.0-beta.1 | Introduced. |