Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_REST_Access_Plans_Controller::allow_request_when_access_plan_limit_not_reached( WP_REST_Request $request )
Allow request when the access plan limit per product is not reached.
Parameters Parameters
- $request
-
(WP_REST_Request) (Required) Full details about the request.
Return Return
(true|WP_Error)
Source Source
File: libraries/lifterlms-rest/includes/server/class-llms-rest-access-plans-controller.php
} $product_id = isset( $request['post_id'] ) ? $request['post_id'] : $this->get_object( (int) $request['id'] )->get( 'product_id' ); $product = new LLMS_Product( $product_id ); $limit = $product->get_access_plan_limit(); $product_access_plans = $product->get_access_plans( false, false ); // Check whether we're updating an access plan, and whether this access plan was already a destination's product access plan, // otherwise we're either creating an access plan or moving the access plans from a product to a different one. $updating_product_access_plan = ! empty( $request['id'] ) && ! empty( $product_access_plans ) && in_array( $request['id'], wp_list_pluck( $product_access_plans, 'id' ), true ); if ( ! $updating_product_access_plan && count( $product_access_plans ) >= $limit ) { return llms_rest_bad_request_error( sprintf( // Translators: %1$d = access plans limit per product, %2$s access plan post type plural name, %3$s product post type singular name. __( 'Only %1$d %2$s allowed per %3$s', 'lifterlms' ), $limit, strtolower( get_post_type_object( $this->post_type )->labels->name ), strtolower( get_post_type_object( get_post_type( $product_id ) )->labels->singular_name ) ) ); } return true; } }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.0-beta.20 | |
1.0.0-beta-24 | Introduced. |