LLMS_REST_Memberships_Controller::prepare_links( LLMS_Membership $membership, WP_REST_Request $request )
Prepare links for the request.
Parameters Parameters
- $membership
-
(LLMS_Membership) (Required) LLMS Membership.
- $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-memberships-controller.php
* * @since 1.0.0-beta.9 * * @param array $prepared_item Array of membership item properties prepared for database. * @param WP_REST_Request $request Full details about the request. * @param array $schema The item schema. */ $prepared_item = apply_filters( 'llms_rest_pre_insert_membership', $prepared_item, $request, $schema ); return $prepared_item; } /** * Prepare links for the request. * * @since 1.0.0-beta.9 * @since 1.0.0-beta.14 Added `$request` parameter. * @since 1.0.0-beta.18 Fixed access plans link. * * @param LLMS_Membership $membership LLMS Membership. * @param WP_REST_Request $request Request object. * @return array Links for the given object. */ protected function prepare_links( $membership, $request ) { $links = parent::prepare_links( $membership, $request ); unset( $links['content'] ); $id = $membership->get( 'id' ); // Access plans. $links['access_plans'] = array( 'href' => add_query_arg( 'post_id', $id, rest_url( sprintf( '%s/%s', $this->namespace, 'access-plans' ) ) ), ); // Auto enrollment courses. $auto_enroll_courses = implode( ',', $membership->get_auto_enroll_courses() ); if ( $auto_enroll_courses ) { $links['auto_enrollment_courses'] = array( 'href' => add_query_arg( 'include', $auto_enroll_courses, rest_url( sprintf( '%s/%s', $this->namespace, 'courses' ) ) ), ); } // Enrollments. $links['enrollments'] = array( 'href' => rest_url( sprintf( '/%s/%s/%d/%s', $this->namespace, $this->rest_base, $id, 'enrollments' ) ), ); // Instructors. $links['instructors'] = array( 'href' => add_query_arg( 'post', $id, rest_url( sprintf( '%s/%s', $this->namespace, 'instructors' ) ) ),
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.0-beta.9 | |
1.0.0-beta.18 | Fixed access plans link. |
1.0.0-beta.14 | Introduced. |