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
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' ) ) ), ); // Students. $links['students'] = array( 'href' => add_query_arg( 'enrolled_in', $id, rest_url( sprintf( '%s/%s', $this->namespace, 'students' ) ) ), ); /** * Filters the membership's links. * * @since 1.0.0-beta.9 * * @param array $links Links for the given membership. * @param LLMS_Membership $membership LLMS Membership object. */ $links = apply_filters( 'llms_rest_membership_links', $links, $membership ); return $links; }
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. |