LLMS_REST_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.


Top ↑

Return Return

(array|WP_Error)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-controller.php

			$prepared_for_total_count = $this->prepare_args_for_total_count_query( $prepared, $request );
			$count_query              = $this->get_objects_query( $prepared_for_total_count, $request );
			$count_results            = $this->get_pagination_data_from_query( $count_query, $prepared_for_total_count, $request );

			$pagination['total_results'] = $count_results['total_results'];
		}

		if ( $pagination['current_page'] > $pagination['total_pages'] && $pagination['total_results'] > 0 ) {
			return llms_rest_bad_request_error( __( 'The page number requested is larger than the number of pages available.', 'lifterlms' ) );
		}

		$objects = $this->get_objects_from_query( $query );
		$items   = $this->prepare_collection_items_for_response( $objects, $request );

		$response = rest_ensure_response( $items );
		$response = $this->add_header_pagination( $response, $pagination, $request );

		return $response;

	}

	/**


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.7
1.0.0-beta.12 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.