LLMS_REST_Memberships_Controller::prepare_object_for_response( LLMS_Membership $membership, WP_REST_Request $request )
Prepare a single object output for response.
Parameters Parameters
- $membership
-
(LLMS_Membership) (Required) Membership object.
- $request
-
(WP_REST_Request) (Required) Full details about the request.
Return Return
(array)
Source Source
File: libraries/lifterlms-rest/includes/server/class-llms-rest-memberships-controller.php
/** * 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; } /** * Prepare a single object output for response. * * @since 1.0.0-beta.9 * * @param LLMS_Membership $membership Membership object. * @param WP_REST_Request $request Full details about the request. * @return array */ protected function prepare_object_for_response( $membership, $request ) { $data = parent::prepare_object_for_response( $membership, $request ); $context = $request->get_param( 'context' ); // Auto enroll. $data['auto_enroll'] = $membership->get_auto_enroll_courses(); // Catalog visibility. $data['catalog_visibility'] = $membership->get_product()->get_catalog_visibility(); // Categories. $data['categories'] = $membership->get_categories( array( 'fields' => 'ids', ) ); // Instructors. $instructors = $membership->get_instructors(); $instructors = empty( $instructors ) ? array() : wp_list_pluck( $instructors, 'id' ); $data['instructors'] = $instructors; // Restriction action. $data['restriction_action'] = $membership->get( 'restriction_redirect_type' ); $data['restriction_action'] = $data['restriction_action'] ? $data['restriction_action'] : 'none'; // Restriction message. $data['restriction_message'] = array( 'raw' => $membership->get( 'restriction_notice', $raw = true ), 'rendered' => do_shortcode( $membership->get( 'restriction_notice' ) ), ); // Restriction page id. if ( 'page' === $data['restriction_action'] || 'edit' === $context ) { $data['restriction_page_id'] = $membership->get( 'redirect_page_id' ); } // Restriction URL. if ( 'custom' === $data['restriction_action'] || 'edit' === $context ) { $data['restriction_url'] = $membership->get( 'redirect_custom_url' ); } // Tags. $data['tags'] = $membership->get_tags( array( 'fields' => 'ids', ) ); // Sales page type. $data['sales_page_type'] = $membership->get( 'sales_page_content_type' ); $data['sales_page_type'] = $data['sales_page_type'] ? $data['sales_page_type'] : 'none';
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.0-beta.9 | Introduced. |