1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?php
/**
* Access plan schema definition
*
* This schema contains all properties of the access plan that are not inherited from the parent schema.
*
* @package LifterLMS/Classes
*
* @since 1.0.0-beta.18
* @version 1.0.0-beta.18
*
* @see LLMS_REST_Access_Plans_Controller::get_item_schema()
*/
defined( 'ABSPATH' ) || exit;
return array(
'price' => array(
'description' => __( 'Access plan price.', 'lifterlms' ),
'type' => 'number',
'required' => true,
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'validate_callback' => 'llms_rest_validate_positive_float_w_zero',
),
),
'access_expiration' => array(
'description' => __( 'Access expiration type. `lifetime` provides access until cancelled or until a recurring payment fails. `limited-period` provides access for a limited period as specified by `access_length` and `access_period` `limited-date` provides access until the date specified by access_expires_date`.', 'lifterlms' ),
'type' => 'string',
'default' => 'lifetime',
'enum' => array(
'lifetime',
'limited-period',
'limited-date',
),
'context' => array( 'view', 'edit' ),
),
'access_expires' => array(
'description' => __( 'Date when access expires. Only applicable when `access_expiration` is `limited-date`. `Format: Y-m-d H:i:s`.', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'access_length' => array(
'description' => __( 'Determine the length of access from time of purchase. Only applicable when `access_expiration` is `limited-period`.', 'lifterlms' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
'default' => 1,
'arg_options' => array(
'validate_callback' => 'llms_rest_validate_strictly_positive_int',
'sanitize_callback' => 'absint',
),
),
'access_period' => array(
'description' => __( 'Determine the length of access from time of purchase. Only applicable when `access_expiration` is `limited-period`', 'lifterlms' ),
'type' => 'string',
'default' => 'year',
'enum' => array_keys( llms_get_access_plan_period_options() ),
'context' => array( 'view', 'edit' ),
),
'availability_restrictions' => array(
'description' => __( 'Restrict usage of this access plan to students enrolled in at least one of the specified memberships.', 'lifterlms' ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'validate_callback' => static function ( $val ) {
return llms_rest_validate_memberships( $val, true ); // Allow empty to unset.
},
),
),
'enroll_text' => array(
'description' => __( 'Text of the "Purchase" button', 'lifterlms' ),
'type' => 'string',
'default' => __( 'Buy Now', 'lifterlms' ),
'context' => array( 'view', 'edit' ),
),
'frequency' => array(
'description' => __( 'Billing frequency [0-6]. `0` denotes a one-time payment. `>= 1` denotes a recurring plan.', 'lifterlms' ),
'type' => 'integer',
'default' => 0,
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'validate_callback' => static function ( $val ) {
return in_array( $val, range( 0, 6 ), true ) ? true : new WP_Error(
'rest_invalid_param',
__( 'Must be an integer in the range 0-6', 'lifterlms' )
);
},
'sanitize_callback' => 'absint',
),
),
'length' => array(
'description' => __( 'For recurring plans only. Determines the number of intervals a plan should run for. `0` denotes the plan should run until cancelled.', 'lifterlms' ),
'type' => 'integer',
'default' => 0,
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'sanitize_callback' => 'absint',
),
),
'period' => array(
'description' => __( 'For recurring plans only. Determines the interval of recurring payments.', 'lifterlms' ),
'type' => 'string',
'default' => 'year',
'enum' => array_keys( llms_get_access_plan_period_options() ),
'context' => array( 'view', 'edit' ),
),
'post_id' => array(
'description' => __( 'Determines the course or membership which can be accessed through the plan.', 'lifterlms' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
'required' => true,
'arg_options' => array(
'validate_callback' => static function ( $val ) {
return llms_rest_validate_products( $val ) ? true : new WP_Error(
'rest_invalid_param',
__( 'Must be a valid course or membership ID', 'lifterlms' )
);
},
'sanitize_callback' => 'absint',
),
),
'redirect_forced' => array(
'description' => __( "Use this plans's redirect settings when purchasing a Membership this plan is restricted to. Applicable only when `availability_restrictions` exist for the plan", 'lifterlms' ),
'type' => 'boolean',
'default' => false,
'context' => array( 'view', 'edit' ),
),
'redirect_page' => array(
'description' => __( 'WordPress page ID to use for checkout success redirection. Applicable only when `redirect_type` is page.', 'lifterlms' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'validate_callback' => 'llms_rest_validate_strictly_positive_int',
'sanitize_callback' => 'absint',
),
),
'redirect_type' => array(
'description' => __( "Determines the redirection behavior of the user's browser upon successful checkout or registration through the plan. `self`: Redirect to the permalink of the specified `post_id`. `page`: Redirect to the permalink of the WordPress page specified by `redirect_page_id`. `url`: Redirect to the URL specified by `redirect_url`.", 'lifterlms' ),
'type' => 'string',
'default' => 'self',
'enum' => array(
'self',
'page',
'url',
),
'context' => array( 'view', 'edit' ),
),
'redirect_url' => array(
'description' => __( 'URL to use for checkout success redirection. Applicable only when `redirect_type` is `url`.', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'format' => 'uri',
'arg_options' => array(
'sanitize_callback' => 'esc_url_raw',
),
),
'sale_date_end' => array(
'description' => __( 'Used to automatically end a scheduled sale. If empty, the plan remains on sale indefinitely. Only applies when `sale_enabled` is `true`. Format: `Y-m-d H:i:s`.', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'sale_date_start' => array(
'description' => __( 'Used to automatically start a scheduled sale. If empty, the plan is on sale immediately. Only applies when `sale_enabled` is `true`. Format: `Y-m-d H:i:s`.', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'sale_enabled' => array(
'description' => __( 'Mark the plan as "On Sale" allowing for temporary price adjustments.', 'lifterlms' ),
'type' => 'boolean',
'default' => false,
'context' => array( 'view', 'edit' ),
),
'sale_price' => array(
'description' => __( 'Sale price. Only applies when `sale_enabled` is `true`.', 'lifterlms' ),
'type' => 'number',
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'validate_callback' => 'llms_rest_validate_positive_float_w_zero',
),
),
'sku' => array(
'description' => __( 'External identifier', 'lifterlms' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'trial_enabled' => array(
'description' => __( 'Enable a trial period for a recurring access plan.', 'lifterlms' ),
'type' => 'boolean',
'default' => false,
'context' => array( 'view', 'edit' ),
),
'trial_length' => array(
'description' => __( 'Determines the length of trial access. Only applies when `trial_enabled` is `true`.', 'lifterlms' ),
'type' => 'integer',
'default' => 1,
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'validate_callback' => 'llms_rest_validate_strictly_positive_int',
'sanitize_callback' => 'absint',
),
),
'trial_period' => array(
'description' => __( 'Determines the length of trial access. Only applies when `trial_enabled` is `true`.', 'lifterlms' ),
'type' => 'string',
'default' => 'week',
'enum' => array(
'year',
'month',
'week',
'day',
),
'context' => array( 'view', 'edit' ),
),
'trial_price' => array(
'description' => __( 'Determines the price of the trial period. Only applies when `trial_enabled` is `true`.', 'lifterlms' ),
'type' => 'number',
'default' => 0,
'context' => array( 'view', 'edit' ),
'arg_options' => array(
'validate_callback' => 'llms_rest_validate_positive_float_w_zero',
),
),
'visibility' => array(
'description' => __( 'Access plan visibility.', 'lifterlms' ),
'type' => 'string',
'default' => 'visible',
'enum' => array_keys( llms_get_access_plan_visibility_options() ),
'context' => array( 'view', 'edit' ),
),
);