LLMS_REST_Sections_Controller::prepare_collection_query_args( WP_REST_Request $request )
Format query arguments to retrieve a collection of objects.
Parameters Parameters
- $request
-
(WP_REST_Request) (Required) Full details about the request.
Return Return
(array|WP_Error)
Source Source
File: libraries/lifterlms-rest/includes/server/class-llms-rest-sections-controller.php
* * @param WP_REST_Request $request Full details about the request. * @return array|WP_Error */ protected function prepare_collection_query_args( $request ) { $query_args = parent::prepare_collection_query_args( $request ); if ( is_wp_error( $query_args ) ) { return $query_args; } // Orderby 'order' requires a meta query. if ( isset( $query_args['orderby'] ) && 'order' === $query_args['orderby'] ) { $query_args = array_merge( $query_args, array( 'meta_key' => '_llms_order', 'orderby' => 'meta_value_num', ) ); } if ( isset( $this->parent_id ) ) { $parent_id = $this->parent_id; } elseif ( ! empty( $request['parent'] ) && $request['parent'] > 1 ) { $parent_id = $request['parent']; } // Filter by parent. if ( ! empty( $parent_id ) ) { $query_args = array_merge( $query_args, array( 'meta_query' => array( array( 'key' => '_llms_parent_course', 'value' => $parent_id, 'compare' => '=', ), ), ) );
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.0-beta.7 | |
1.0.0-beta.18 | Correctly return errors. |
1.0.0-beta.12 | Introduced. |