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 delete_item( $request ) { $object = $this->get_object( $request['id'], false ); // We don't return 404s for items that are not found. if ( ! is_wp_error( $object ) ) { // If there was an error deleting the object return the error. If the error is that the object doesn't exist return 204 below! $del = $this->delete_object( $object, $request ); if ( is_wp_error( $del ) ) { return $del; } } $response = rest_ensure_response( null ); $response->set_status( 204 ); return $response; } /** * Retrieves the query params for the objects collection. * * @since 1.0.0-beta.1 * @since 1.0.0-beta.12 Added `search_columns` collection param for searchable resources. * * @return array Collection parameters. */ 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', );
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. |