LLMS_REST_Enrollments_Controller::prepare_links( object $enrollment, WP_REST_Request $request )
Prepare enrollments links for the request.
Parameters Parameters
- $enrollment
-
(object) (Required) Enrollment object data.
- $request
-
(WP_REST_Request) (Required) Request object.
Return Return
(array) Links for the given object.
Source Source
File: libraries/lifterlms-rest/includes/server/class-llms-rest-enrollments-controller.php
/** * Filters the enrollment data for a response. * * @since 1.0.0-beta.10 * * @param array $data Array of enrollment properties prepared for response. * @param stdClass $enrollment Enrollment object. * @param WP_REST_Request $request Full details about the request. */ return apply_filters( 'llms_rest_prepare_enrollment_object_response', $data, $enrollment, $request ); } /** * Prepare enrollments links for the request. * * @since 1.0.0-beta.1 * @since 1.0.0-beta.14 Added $request parameter. * * @param object $enrollment Enrollment object data. * @param WP_REST_Request $request Request object. * @return array Links for the given object. */ public function prepare_links( $enrollment, $request ) { $links = array( 'self' => array( 'href' => rest_url( sprintf( '/%s/%s/%d/%s/%d', 'llms/v1', 'students', $enrollment->student_id, 'enrollments', $enrollment->post_id ) ), ), 'collection' => array( 'href' => rest_url( sprintf( '/%s/%s/%d/%s', 'llms/v1', 'students', $enrollment->student_id, 'enrollments' ) ), ), 'student' => array( 'href' => rest_url( sprintf( '/%s/%s/%d', 'llms/v1', 'students', $enrollment->student_id ) ), ), ); switch ( get_post_type( $enrollment->post_id ) ) : case 'course': $links['post'] = array( 'type' => 'course', 'href' => rest_url( sprintf( '/%s/%s/%d', 'llms/v1', 'courses', $enrollment->post_id ) ), );
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.0-beta.14 | Added $request parameter. |
1.0.0-beta.1 | Introduced. |