LLMS_REST_Courses_Controller
Description Description
Source Source
File: libraries/lifterlms-rest/includes/server/class-llms-rest-courses-controller.php
Changelog Changelog
Version | Description |
---|---|
1.0.0-beta.9 | In update_additional_object_fields() method, use WP_Error::$errors in place of WP_Error::has_errors() to support WordPress version prior to 5.1. Also made sure course's instructor is at least set as the post author. Defined instructors validate callback so to make sure instructors list is either not empty and composed by real user ids. Fixed sales_page_url not returned in edit context. Removed create_llms_post() and get_object() methods, now abstracted in LLMS_REST_Posts_Controller class. llms_rest_course_filters_removed_for_response filter hook added. Added llms_rest_course_item_schema , llms_rest_pre_insert_course , llms_rest_prepare_course_object_response , llms_rest_course_links filter hooks. |
1.0.0-beta.8 | Fixed sales_page_type not returned as none if course's sales_page_content_type property is empty. Renamed sales_page_page_type and sales_page_page_url properties, respectively to sales_page_type and sales_page_url according to the specs. Add missing quotes in enrollment/access default messages shortcodes. Call set_bulk() llms post method passing true as second parameter, so to instruct it to return a WP_Error on failure. Add missing quotes in enrollment/access default messages shortcodes. sales_page_page_id and sales_page_url always returned in edit context. |
1.0.0-beta.7 | Make access_opens_date , access_closes_date , enrollment_opens_date , enrollment_closes_date nullable. Allow prerequisite and prerequisite_track to be cleared (set to 0). Also: - if prerequisite is not a valid course the course prerequisite will be set to 0; - if prerequisite_track is not a valid course track, the course prerequisite_track will be set to 0. update_additional_object_fields() returns false if nothing to update. Properties access_opens_date , access_closes_date , enrollment_opens_date , enrollment_closes_date handling moved here from prepare_item_for_database() method to update_additional_object_fields() method so to better handle the update of the course's properties time_period and enrollment_period . Added logic to prevent trying to update "derived only" courses's properties (time_period , enrollment_period , has_prerequisite ) if their values didn't really change, otherwise we'd get a WP_Error which the consumer cannot avoid having no direct control on those properties. In update_additional_object_fields() method, use WP_Error::$errors in place of WP_Error::has_errors() to support WordPress version prior to 5.1. Overridden get_object_id() method to avoid using the deprecated LLMS_Course::get_id() which, as coded in the LLMS_REST_Controller_Stubs::get_object_id() takes precedence over get( 'id' ) . |
1.0.0-beta.14 | Update prepare_links() to accept a second parameter, WP_REST_Request . |
1.0.0-beta.1 | Introduced. |
Methods Methods
- __construct — Constructor.
- get_course_content_collection_params — Retrieves the query params for the sections objects collection.
- get_course_content_items — Get a collection of content items (sections).
- get_enrollments_collection_params — Retrieves the query params for the enrollments objects collection.
- get_filters_to_be_removed_for_response — Get action/filters to be removed before preparing the item for response.
- get_item_schema — Get the Course's schema, conforming to JSON Schema.
- get_object_id — Retrieve an ID from the object
- get_taxonomy_rest_base — Maps a taxonomy name to the relative rest base
- prepare_item_for_database — Prepares a single post for create or update.
- prepare_links — Prepare links for the request.
- prepare_object_for_response — Prepare a single object output for response.
- register_routes — Register routes.
- update_additional_object_fields — Updates a single llms course.