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
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php
/**
* Template functions for pricing tables
*
* @package LifterLMS/Functions
*
* @since 3.23.0
* @version 3.38.0
*/
defined( 'ABSPATH' ) || exit;
/**
* Retrieve a list of CSS classes for a single access plan element
*
* @since 3.23.0
*
* @param LLMS_Access_Plan $plan Access plan object.
* @return string
*/
function llms_get_access_plan_classes( $plan ) {
$classes = array(
'llms-access-plan',
sprintf( 'llms-access-plan-%d', $plan->get( 'id' ) ),
);
if ( $plan->is_featured() ) {
$classes[] = 'featured';
}
if ( $plan->is_on_sale() ) {
$classes[] = 'on-sale';
}
return implode( ' ', apply_filters( 'llms_access_plan_classes', $classes, $plan ) );
}
if ( ! function_exists( 'llms_template_access_plan' ) ) {
/**
* Include single access plan template within the pricing table
*
* @since 3.23.0
*
* @param LLMS_Access_Plan $plan Access plan object.
* @return void
*/
function llms_template_access_plan( $plan ) {
llms_get_template(
'product/access-plan.php',
compact( 'plan' )
);
}
}
if ( ! function_exists( 'llms_template_access_plan_button' ) ) {
/**
* Include Single Access Plan Button Template
*
* @since 3.23.0
*
* @param LLMS_Access_Plan $plan Access plan object.
* @return void
*/
function llms_template_access_plan_button( $plan ) {
llms_get_template(
'product/access-plan-button.php',
compact( 'plan' )
);
}
}
if ( ! function_exists( 'llms_template_access_plan_description' ) ) {
/**
* Include Single Access Plan Description Template
*
* @since 3.23.0
*
* @param LLMS_Access_Plan $plan Access plan object.
* @return void
*/
function llms_template_access_plan_description( $plan ) {
llms_get_template(
'product/access-plan-description.php',
compact( 'plan' )
);
}
}
if ( ! function_exists( 'llms_template_access_plan_feature' ) ) {
/**
* Include Single Access Plan Featured Template
*
* @since 3.23.0
*
* @param LLMS_Access_Plan $plan Access plan object.
* @return void
*/
function llms_template_access_plan_feature( $plan ) {
llms_get_template(
'product/access-plan-feature.php',
compact( 'plan' )
);
}
}
if ( ! function_exists( 'llms_template_access_plan_pricing' ) ) {
/**
* Include Single Access Plan pricing Template
*
* @since 3.23.0
*
* @param LLMS_Access_Plan $plan Access plan object.
* @return void
*/
function llms_template_access_plan_pricing( $plan ) {
llms_get_template(
'product/access-plan-pricing.php',
compact( 'plan' )
);
}
}
if ( ! function_exists( 'llms_template_access_plan_restrictions' ) ) {
/**
* Include Single Access Plan restrictions Template
*
* @since 3.23.0
*
* @param LLMS_Access_Plan $plan Access plan object.
* @return void
*/
function llms_template_access_plan_restrictions( $plan ) {
llms_get_template(
'product/access-plan-restrictions.php',
compact( 'plan' )
);
}
}
if ( ! function_exists( 'llms_template_access_plan_title' ) ) {
/**
* Include Single Access Plan title Template
*
* @since 3.23.0
*
* @param LLMS_Access_Plan $plan Access plan object.
* @return void
*/
function llms_template_access_plan_title( $plan ) {
llms_get_template(
'product/access-plan-title.php',
compact( 'plan' )
);
}
}
if ( ! function_exists( 'llms_template_access_plan_trial' ) ) {
/**
* Include Single Access Plan trial Template
*
* @since 3.23.0
*
* @param LLMS_Access_Plan $plan Access plan object.
* @return void
*/
function llms_template_access_plan_trial( $plan ) {
llms_get_template(
'product/access-plan-trial.php',
compact( 'plan' )
);
}
}
if ( ! function_exists( 'llms_template_product_not_purchasable' ) ) {
/**
* Include template for products that aren't purchasable
*
* @since 3.38.0
*
* @param int $post_id Optional. WP Post ID of the product. Default is ID of the global $post.
* @return void
*/
function llms_template_product_not_purchasable( $post_id = null ) {
$post_id = $post_id ? $post_id : get_the_ID();
$product = new LLMS_Product( $post_id );
llms_get_template(
'product/not-purchasable.php',
compact( 'product' )
);
}
}
if ( ! function_exists( 'lifterlms_template_pricing_table' ) ) {
/**
* Include pricing table for a LifterLMS Product (course or membership)
*
* @since 3.0.0
* @since 3.38.0 Fixed spelling error in variable passed to template.
*
* @param int $post_id Optional. WP Post ID of the product. Default is ID of the global $post.
* @return void
*/
function lifterlms_template_pricing_table( $post_id = null ) {
$post_id = $post_id ? $post_id : get_the_ID();
$product = new LLMS_Product( $post_id );
/**
* Filter current user's enrollment status
*
* This filter is used to customize the output behavior of the pricing table.
* It does not modify the user's enrollment status.
*
* @since Unknown
*
* @param boolean $is_enrolled User's current enrollment status.
*/
$is_enrolled = apply_filters(
'llms_product_pricing_table_enrollment_status',
llms_is_user_enrolled( get_current_user_id(), $product->get( 'id' ) )
);
$purchasable = $product->is_purchasable();
$has_free = $product->has_free_access_plan();
$has_restrictions = $product->has_restrictions();
/**
* Fix variable spelling in a backwards compatible way
*
* If the template "product/pricing-table.php" is overwritten and relies
* on the misspelled variable, passing both versions in will ensure the
* template continues to function as expected.
*
* @link https://github.com/gocodebox/lifterlms/issues/1128
*
* @deprecated 3.38.0
*/
$purchaseable = $purchasable;
llms_get_template(
'product/pricing-table.php',
compact( 'product', 'is_enrolled', 'purchasable', 'purchaseable', 'has_free', 'has_restrictions' )
);
}
}