|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* LSX Health Plan Template Tags. |
|
4
|
|
|
* |
|
5
|
|
|
* @package lsx-health-plan |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Outputs the warmup box on the single plan page. |
|
10
|
|
|
* |
|
11
|
|
|
* @return void |
|
12
|
|
|
*/ |
|
13
|
|
|
function lsx_health_plan_warmup_box() { |
|
14
|
|
|
?> |
|
15
|
|
|
<div class="col-md-4" > |
|
16
|
|
|
<div class="lsx-health-plan-box"> |
|
17
|
|
|
<h3 class="title warm-up-title title-lined"><?php esc_html_e( 'Your Warm-up', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'warm.svg' ); ?></h3> |
|
18
|
|
|
<div class="spacer"></div> |
|
19
|
|
|
<?php |
|
20
|
|
|
$intro_text = \lsx_health_plan\functions\get_option( 'warmup_intro', false ); |
|
21
|
|
|
if ( false !== $intro_text ) { |
|
22
|
|
|
?> |
|
23
|
|
|
<div class="excerpt"> |
|
24
|
|
|
<p><?php echo wp_kses_post( $intro_text ); ?></p> |
|
|
|
|
|
|
25
|
|
|
</div> |
|
26
|
|
|
<?php |
|
27
|
|
|
} |
|
28
|
|
|
$warm_up = \lsx_health_plan\functions\get_option( 'endpoint_warm_up', false ); |
|
29
|
|
|
if ( false === $warm_up ) { |
|
30
|
|
|
$warm_up = 'warm-up'; |
|
31
|
|
|
} |
|
32
|
|
|
?> |
|
33
|
|
|
<a href="<?php the_permalink(); ?><?php echo esc_attr( $warm_up ); ?>/" class="btn"><?php esc_html_e( 'Start your warm-up', 'lsx-health-plan' ); ?></a> |
|
34
|
|
|
</div> |
|
35
|
|
|
</div> |
|
36
|
|
|
<?php |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Outputs the workout box on the single plan page. |
|
41
|
|
|
* |
|
42
|
|
|
* @return void |
|
43
|
|
|
*/ |
|
44
|
|
|
function lsx_health_plan_workout_box() { |
|
45
|
|
|
if ( ! post_type_exists( 'workout' ) ) { |
|
46
|
|
|
return; |
|
47
|
|
|
} |
|
48
|
|
|
?> |
|
49
|
|
|
<div class="col-md-4" > |
|
50
|
|
|
<div class="lsx-health-plan-box"> |
|
51
|
|
|
<h3 class="title work-out-title title-lined"><?php esc_html_e( 'Your Workout', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'work.svg' ); ?></h3> |
|
52
|
|
|
<div class="spacer"></div> |
|
53
|
|
|
<?php |
|
54
|
|
|
$intro_text = \lsx_health_plan\functions\get_option( 'workout_intro', false ); |
|
55
|
|
|
if ( false !== $intro_text ) { |
|
56
|
|
|
?> |
|
57
|
|
|
<div class="excerpt"> |
|
58
|
|
|
<p><?php echo wp_kses_post( $intro_text ); ?></p> |
|
|
|
|
|
|
59
|
|
|
</div> |
|
60
|
|
|
<?php |
|
61
|
|
|
} |
|
62
|
|
|
$workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', false ); |
|
63
|
|
|
if ( false === $workout ) { |
|
64
|
|
|
$workout = 'workout'; |
|
65
|
|
|
} |
|
66
|
|
|
?> |
|
67
|
|
|
<a href="<?php the_permalink(); ?><?php echo esc_attr( $workout ); ?>/" class="btn"><?php esc_html_e( 'Start your workout', 'lsx-health-plan' ); ?></a> |
|
68
|
|
|
</div> |
|
69
|
|
|
</div> |
|
70
|
|
|
<?php |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Outputs the meal plan box on the single plan page. |
|
75
|
|
|
* |
|
76
|
|
|
* @return void |
|
77
|
|
|
*/ |
|
78
|
|
|
function lsx_health_plan_meal_box() { |
|
79
|
|
|
if ( ! post_type_exists( 'meal' ) ) { |
|
80
|
|
|
return; |
|
81
|
|
|
} |
|
82
|
|
|
?> |
|
83
|
|
|
<div class="col-md-4" > |
|
84
|
|
|
<div class="lsx-health-plan-box"> |
|
85
|
|
|
<h3 class="title meal-plan-title title-lined"><?php esc_html_e( 'Your Meal Plan', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'meal.svg' ); ?></h3> |
|
86
|
|
|
<div class="spacer"></div> |
|
87
|
|
|
<?php |
|
88
|
|
|
$intro_text = \lsx_health_plan\functions\get_option( 'meal_plan_intro', false ); |
|
89
|
|
|
if ( false !== $intro_text ) { |
|
90
|
|
|
?> |
|
91
|
|
|
<div class="excerpt"> |
|
92
|
|
|
<p><?php echo wp_kses_post( $intro_text ); ?></p> |
|
|
|
|
|
|
93
|
|
|
</div> |
|
94
|
|
|
<?php |
|
95
|
|
|
} |
|
96
|
|
|
$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false ); |
|
97
|
|
|
if ( false === $meal ) { |
|
98
|
|
|
$meal = 'meal'; |
|
99
|
|
|
} |
|
100
|
|
|
?> |
|
101
|
|
|
<a href="<?php the_permalink(); ?><?php echo esc_attr( $meal ); ?>/" class="btn"><?php esc_html_e( 'View your meal plan', 'lsx-health-plan' ); ?></a> |
|
102
|
|
|
</div> |
|
103
|
|
|
</div> |
|
104
|
|
|
<?php |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Outputs the recipe box on the single plan page. |
|
109
|
|
|
* |
|
110
|
|
|
* @return void |
|
111
|
|
|
*/ |
|
112
|
|
|
function lsx_health_plan_recipe_box() { |
|
113
|
|
|
if ( ! post_type_exists( 'recipe' ) ) { |
|
114
|
|
|
return; |
|
115
|
|
|
} |
|
116
|
|
|
?> |
|
117
|
|
|
<div class="col-md-4" > |
|
118
|
|
|
<div class="lsx-health-plan-box"> |
|
119
|
|
|
<h3 class="title recipes-title title-lined"><?php esc_html_e( 'Recipes', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'recipes.svg' ); ?></h3> |
|
120
|
|
|
<div class="spacer"></div> |
|
121
|
|
|
<?php |
|
122
|
|
|
$intro_text = \lsx_health_plan\functions\get_option( 'recipes_intro', false ); |
|
123
|
|
|
if ( false !== $intro_text ) { |
|
124
|
|
|
?> |
|
125
|
|
|
<div class="excerpt"> |
|
126
|
|
|
<p><?php echo wp_kses_post( $intro_text ); ?></p> |
|
|
|
|
|
|
127
|
|
|
</div> |
|
128
|
|
|
<?php |
|
129
|
|
|
} |
|
130
|
|
|
$recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false ); |
|
131
|
|
|
if ( false === $recipes ) { |
|
132
|
|
|
$recipes = 'recipes'; |
|
133
|
|
|
} |
|
134
|
|
|
?> |
|
135
|
|
|
<a href="<?php the_permalink(); ?><?php echo esc_attr( $recipes ); ?>/" class="btn"><?php esc_html_e( 'View all recipes', 'lsx-health-plan' ); ?></a> |
|
136
|
|
|
</div> |
|
137
|
|
|
</div> |
|
138
|
|
|
<?php |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* Outputs the downloads box on the single plan page. |
|
143
|
|
|
* |
|
144
|
|
|
* @return void |
|
145
|
|
|
*/ |
|
146
|
|
|
function lsx_health_plan_downloads_box() { |
|
147
|
|
|
global $current_user; |
|
148
|
|
|
?> |
|
149
|
|
|
<div class="col-md-4 day-download-box" > |
|
150
|
|
|
<div class="lsx-health-plan-box"> |
|
151
|
|
|
<h3 class="title downloads-title title-lined"><?php esc_html_e( 'Downloads', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'download.svg' ); ?></h3> |
|
152
|
|
|
<div class="spacer"></div> |
|
153
|
|
|
<div class="download-list"> |
|
154
|
|
|
<ul> |
|
155
|
|
|
<?php |
|
156
|
|
|
$downloads = \lsx_health_plan\functions\get_downloads(); |
|
157
|
|
|
if ( ! empty( $downloads ) ) { |
|
158
|
|
|
foreach ( $downloads as $download ) { |
|
|
|
|
|
|
159
|
|
|
echo wp_kses_post( '<li><a href=""><i class="fa fa-file-pdf"></i>' . do_shortcode( '[download id="' . $download . '"]' ) . '</a></li>' ); |
|
160
|
|
|
} |
|
161
|
|
|
} |
|
162
|
|
|
?> |
|
163
|
|
|
</ul> |
|
164
|
|
|
</div> |
|
165
|
|
|
</div> |
|
166
|
|
|
</div> |
|
167
|
|
|
<?php |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* outputs the dynamic classes for the nav tabs. |
|
172
|
|
|
* |
|
173
|
|
|
* @param string $tab |
|
174
|
|
|
* @return void |
|
175
|
|
|
*/ |
|
176
|
|
|
function lsx_health_plan_nav_class( $tab = '' ) { |
|
177
|
|
|
$nav_classes = array(); |
|
178
|
|
|
if ( function_exists( 'is_wc_endpoint_url' ) && 'edit-account' === $tab && is_wc_endpoint_url( 'edit-account' ) ) { |
|
179
|
|
|
$nav_classes[] = 'active'; |
|
180
|
|
|
} elseif ( lsx_health_plan_is_current_tab( $tab ) ) { |
|
181
|
|
|
$nav_classes[] = 'active'; |
|
182
|
|
|
} |
|
183
|
|
|
if ( ! empty( $nav_classes ) ) { |
|
184
|
|
|
echo wp_kses_post( implode( ' ', $nav_classes ) ); |
|
185
|
|
|
} |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* Outputs the my profile tabs |
|
190
|
|
|
* |
|
191
|
|
|
* @return void |
|
192
|
|
|
*/ |
|
193
|
|
|
function lsx_health_plan_my_profile_tabs() { |
|
194
|
|
|
?> |
|
195
|
|
|
<div id="account-nav"> |
|
196
|
|
|
<ul class="nav nav-pills"> |
|
197
|
|
|
<li class=" |
|
198
|
|
|
<?php |
|
199
|
|
|
if ( ( function_exists( 'is_wc_endpoint_url' ) && ! is_wc_endpoint_url( 'edit-account' ) ) || ! function_exists( 'is_wc_endpoint_url' ) ) { |
|
200
|
|
|
echo esc_attr( 'active' ); |
|
201
|
|
|
} |
|
202
|
|
|
?> |
|
203
|
|
|
"><a class="my-plan-tab" href="<?php the_permalink(); ?>"><?php esc_html_e( 'My Plans', 'lsx-health-plan' ); ?></a></li> |
|
204
|
|
|
<li class=" |
|
205
|
|
|
<?php |
|
206
|
|
|
if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'edit-account' ) ) { |
|
207
|
|
|
echo esc_attr( 'active' ); |
|
208
|
|
|
} |
|
209
|
|
|
?> |
|
210
|
|
|
"><a class="account-details-tab" href="<?php the_permalink(); ?>edit-account/"><?php esc_html_e( 'Account Details', 'lsx-health-plan' ); ?></a></li> |
|
211
|
|
|
<li class=""><a class="logout-tab" href="<?php echo esc_url( wp_logout_url( get_permalink() ) ); ?>"><?php esc_html_e( 'Logout', 'lsx-health-plan' ); ?></a></li> |
|
|
|
|
|
|
212
|
|
|
</ul> |
|
213
|
|
|
</div> |
|
214
|
|
|
<?php |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* Outputs the my profile box |
|
219
|
|
|
* |
|
220
|
|
|
* @return void |
|
221
|
|
|
*/ |
|
222
|
|
|
function lsx_health_plan_my_profile_box() { |
|
223
|
|
|
?> |
|
224
|
|
|
<div class="lsx-health-plan my-profile-block wp-block-cover alignfull"> |
|
225
|
|
|
<div class="wp-block-cover__inner-container"> |
|
226
|
|
|
<h2><?php esc_html_e( 'My Dashboard', 'lsx-health-plan' ); ?></h2> |
|
227
|
|
|
<section id="dashboard-card"> |
|
228
|
|
|
<div class="profile-navigation"> |
|
229
|
|
|
<div class="profile-photo"> |
|
230
|
|
|
<?php |
|
231
|
|
|
global $current_user; |
|
232
|
|
|
get_current_user(); |
|
233
|
|
|
echo get_avatar( $current_user->ID, 240 ); |
|
|
|
|
|
|
234
|
|
|
?> |
|
235
|
|
|
</div> |
|
236
|
|
|
</div> |
|
237
|
|
|
<div class="profile-details"> |
|
238
|
|
|
<h1 class="title-lined has-text-color"><?php echo esc_html( $current_user->display_name ); ?></h1> |
|
239
|
|
|
<?php |
|
240
|
|
|
$disable_stats = \lsx_health_plan\functions\get_option( 'disable_all_stats', false ); |
|
241
|
|
|
if ( 'on' !== $disable_stats ) { |
|
242
|
|
|
|
|
243
|
|
|
$is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false ); |
|
244
|
|
|
$is_height_disabled = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false ); |
|
245
|
|
|
$is_waist_disabled = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false ); |
|
246
|
|
|
$is_bmi_disabled = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false ); |
|
247
|
|
|
|
|
248
|
|
|
$weight = get_user_meta( get_current_user_id(), 'weight', true ); |
|
249
|
|
|
$waist = get_user_meta( get_current_user_id(), 'waist', true ); |
|
250
|
|
|
$height = get_user_meta( get_current_user_id(), 'height', true ); |
|
251
|
|
|
|
|
252
|
|
|
$height_m = $height / 100; |
|
253
|
|
|
|
|
254
|
|
|
if ( 1 < $weight && 1 < $height_m ) { |
|
255
|
|
|
$bmi = $weight / ( $height_m * $height_m ); |
|
256
|
|
|
$bmi = number_format( $bmi, 1 ); |
|
257
|
|
|
} else { |
|
258
|
|
|
$bmi = __( 'Add more data', 'lsx-health-plan' ); |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
?> |
|
262
|
|
|
|
|
263
|
|
|
<div> |
|
264
|
|
|
<?php if ( 'on' !== $is_weight_disabled ) { ?> |
|
265
|
|
|
<span><strong><?php esc_html_e( 'Weight:', 'lsx-health-plan' ); ?></strong> |
|
266
|
|
|
<?php |
|
267
|
|
|
if ( '' !== $weight ) { |
|
268
|
|
|
echo wp_kses_post( $weight . ' kg' ); |
|
269
|
|
|
} else { |
|
270
|
|
|
echo '/'; |
|
271
|
|
|
} |
|
272
|
|
|
?> |
|
273
|
|
|
</span> |
|
274
|
|
|
<?php } |
|
275
|
|
|
if ( 'on' !== $is_waist_disabled ) { |
|
276
|
|
|
?> |
|
277
|
|
|
<span><strong><?php esc_html_e( 'Waist:', 'lsx-health-plan' ); ?></strong> |
|
278
|
|
|
<?php |
|
279
|
|
|
if ( '' !== $waist ) { |
|
280
|
|
|
echo wp_kses_post( $waist . ' cm' ); |
|
281
|
|
|
} else { |
|
282
|
|
|
echo '/'; |
|
283
|
|
|
} |
|
284
|
|
|
?> |
|
285
|
|
|
</span> |
|
286
|
|
|
<?php } |
|
287
|
|
|
if ( 'on' !== $is_bmi_disabled ) { |
|
288
|
|
|
?> |
|
289
|
|
|
<span><strong><?php esc_html_e( 'BMI:', 'lsx-health-plan' ); ?></strong> |
|
290
|
|
|
<?php |
|
291
|
|
|
if ( '' !== $bmi ) { |
|
292
|
|
|
echo wp_kses_post( $bmi ); |
|
293
|
|
|
} else { |
|
294
|
|
|
echo '/'; |
|
295
|
|
|
} |
|
296
|
|
|
?> |
|
297
|
|
|
</span> |
|
298
|
|
|
<?php } ?> |
|
299
|
|
|
</div> |
|
300
|
|
|
<?php |
|
301
|
|
|
} |
|
302
|
|
|
?> |
|
303
|
|
|
<div class="edit-profile"> |
|
304
|
|
|
<?php |
|
305
|
|
|
if ( function_exists( 'wc_get_page_id' ) ) { |
|
306
|
|
|
$url_id = wc_get_page_id( 'myaccount' ); |
|
307
|
|
|
} else { |
|
308
|
|
|
$url_id = ''; |
|
309
|
|
|
} |
|
310
|
|
|
?> |
|
311
|
|
|
<a href="<?php echo esc_url( get_permalink( $url_id ) ); ?>edit-account/"><?php esc_html_e( 'Edit', 'lsx-health-plan' ); ?></a> |
|
|
|
|
|
|
312
|
|
|
</div> |
|
313
|
|
|
</div> |
|
314
|
|
|
</section> |
|
315
|
|
|
</div> |
|
316
|
|
|
</div> |
|
317
|
|
|
<?php |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
/** |
|
321
|
|
|
* Outputs the my profile list of plans box |
|
322
|
|
|
* |
|
323
|
|
|
* @return void |
|
324
|
|
|
*/ |
|
325
|
|
|
function lsx_health_plan_all_plans_block() { |
|
326
|
|
|
global $post, $product; |
|
327
|
|
|
|
|
328
|
|
|
$args = array( |
|
329
|
|
|
'orderby' => 'menu_order', |
|
330
|
|
|
'order' => 'ASC', |
|
331
|
|
|
'post_type' => 'plan', |
|
332
|
|
|
'nopagin' => true, |
|
333
|
|
|
'post_parent' => 0, |
|
334
|
|
|
); |
|
335
|
|
|
|
|
336
|
|
|
$product_ids = \lsx_health_plan\functions\woocommerce\get_membership_products(); |
|
337
|
|
|
if ( ! empty( $product_ids ) ) { |
|
338
|
|
|
$args['meta_query'] = array( |
|
339
|
|
|
'relation' => 'OR', |
|
340
|
|
|
array( |
|
341
|
|
|
'key' => '_plan_product_id', |
|
342
|
|
|
'value' => $product_ids, |
|
343
|
|
|
'compare' => 'IN', |
|
344
|
|
|
), |
|
345
|
|
|
array( |
|
346
|
|
|
'key' => '_plan_product_id', |
|
347
|
|
|
'compare' => 'NOT EXISTS', |
|
348
|
|
|
), |
|
349
|
|
|
); |
|
350
|
|
|
} |
|
351
|
|
|
|
|
352
|
|
|
$the_query = new WP_Query( $args ); |
|
353
|
|
|
?> |
|
354
|
|
|
<div class="all-plans-block plan-grid block-all-plans-block"> |
|
355
|
|
|
<div class="row"> |
|
356
|
|
|
<?php |
|
357
|
|
|
if ( $the_query->have_posts() ) : |
|
358
|
|
|
while ( $the_query->have_posts() ) : |
|
359
|
|
|
$the_query->the_post(); |
|
360
|
|
|
lsx_entry_before(); |
|
|
|
|
|
|
361
|
|
|
$completed_class = ''; |
|
362
|
|
|
$linked_product = false; |
|
363
|
|
|
$restricted = false; |
|
364
|
|
|
$product = null; |
|
365
|
|
|
if ( \lsx_health_plan\functions\woocommerce\plan_has_products() ) { |
|
366
|
|
|
$products = \lsx_health_plan\functions\woocommerce\get_plan_products(); |
|
367
|
|
|
$linked_product = wc_get_product( $products[0] ); |
|
|
|
|
|
|
368
|
|
|
$product = $linked_product; |
|
369
|
|
|
} |
|
370
|
|
|
if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) { |
|
371
|
|
|
$restricted = wc_memberships_is_post_content_restricted( get_the_ID() ) && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() ); |
|
372
|
|
|
} |
|
373
|
|
|
|
|
374
|
|
|
if ( lsx_health_plan_is_plan_complete() ) { |
|
375
|
|
|
$completed_class = 'completed'; |
|
376
|
|
|
} |
|
377
|
|
|
?> |
|
378
|
|
|
<div class="col-xs-12 col-sm-6 col-md-4"> |
|
379
|
|
|
<article class="lsx-slot lsx-hp-shadow"> |
|
380
|
|
|
<div class="plan-feature-img"> |
|
381
|
|
|
<a href="<?php echo esc_url( get_permalink() ); ?>"> |
|
|
|
|
|
|
382
|
|
|
<?php |
|
383
|
|
|
$featured_image = get_the_post_thumbnail(); |
|
384
|
|
|
if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
385
|
|
|
the_post_thumbnail( 'lsx-thumbnail', array( |
|
386
|
|
|
'class' => 'aligncenter', |
|
387
|
|
|
) ); |
|
388
|
|
|
} else { |
|
389
|
|
|
?> |
|
390
|
|
|
<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>"> |
|
391
|
|
|
<?php |
|
392
|
|
|
} |
|
393
|
|
|
?> |
|
394
|
|
|
</a> |
|
395
|
|
|
</div> |
|
396
|
|
|
<div class="content-box plan-content-box"> |
|
397
|
|
|
<h3 class="plan id-<?php the_ID(); ?> <?php echo esc_attr( $completed_class ); ?>"><a href="<?php echo esc_url( get_permalink() ); ?>"><?php the_title(); ?></a></h3> |
|
398
|
|
|
<?php |
|
399
|
|
|
echo wp_kses_post( \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) ); |
|
|
|
|
|
|
400
|
|
|
?> |
|
401
|
|
|
<?php |
|
402
|
|
|
if ( false !== $linked_product && false !== $restricted ) { |
|
403
|
|
|
echo wp_kses_post( $linked_product->get_price_html() ); |
|
404
|
|
|
} |
|
405
|
|
|
?> |
|
406
|
|
|
<div class="excerpt"> |
|
407
|
|
|
<?php |
|
408
|
|
|
if ( ! has_excerpt() ) { |
|
409
|
|
|
$content = wp_trim_words( get_the_content(), 20 ); |
|
410
|
|
|
$content = '<p>' . $content . '</pre>'; |
|
411
|
|
|
} else { |
|
412
|
|
|
$content = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
413
|
|
|
} |
|
414
|
|
|
echo wp_kses_post( $content ); |
|
415
|
|
|
?> |
|
416
|
|
|
</div> |
|
417
|
|
|
<?php |
|
418
|
|
|
if ( false === $restricted ) { |
|
419
|
|
|
echo wp_kses_post( '<span class="progress"><progress class="bar" value="' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '" max="100"> ' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '% </progress><span>' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '%</span></span>' ); |
|
|
|
|
|
|
420
|
|
|
} |
|
421
|
|
|
?> |
|
422
|
|
|
</div> |
|
423
|
|
|
</article> |
|
424
|
|
|
</div> |
|
425
|
|
|
<?php endwhile; ?> |
|
426
|
|
|
<?php endif; ?> |
|
427
|
|
|
</div> |
|
428
|
|
|
<?php wp_reset_postdata(); ?> |
|
429
|
|
|
</div> |
|
430
|
|
|
|
|
431
|
|
|
<?php |
|
432
|
|
|
} |
|
433
|
|
|
|
|
434
|
|
|
/** |
|
435
|
|
|
* Outputs the my profile day view box |
|
436
|
|
|
* |
|
437
|
|
|
* @return void |
|
438
|
|
|
*/ |
|
439
|
|
|
function lsx_health_plan_day_plan_block( $args = array() ) { |
|
440
|
|
|
$defaults = array( |
|
441
|
|
|
'plan' => '', |
|
442
|
|
|
); |
|
443
|
|
|
$args = wp_parse_args( $args, $defaults ); |
|
444
|
|
|
|
|
445
|
|
|
if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) { |
|
446
|
|
|
$sections = \lsx_health_plan\functions\plan\get_sections( $args['plan'] ); |
|
447
|
|
|
?> |
|
448
|
|
|
<div class="daily-plan-block day-grid"> |
|
449
|
|
|
<?php |
|
450
|
|
|
foreach ( $sections as $section_key => $section_values ) { |
|
451
|
|
|
$defaults = array( |
|
452
|
|
|
'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ), |
|
453
|
|
|
); |
|
454
|
|
|
$section_args = wp_parse_args( $section_values, $defaults ); |
|
455
|
|
|
|
|
456
|
|
|
$completed_class = ''; |
|
457
|
|
|
if ( lsx_health_plan_is_day_complete() ) { |
|
458
|
|
|
$completed_class = 'completed'; |
|
459
|
|
|
} |
|
460
|
|
|
?> |
|
461
|
|
|
<a href="<?php echo esc_attr( \lsx_health_plan\functions\plan\get_permalink( $args['plan'], $section_args['title'] ) ); ?>" class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>"> |
|
|
|
|
|
|
462
|
|
|
<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div> |
|
463
|
|
|
</a> |
|
464
|
|
|
<?php |
|
465
|
|
|
} |
|
466
|
|
|
?> |
|
467
|
|
|
</div> |
|
468
|
|
|
<?php |
|
469
|
|
|
} |
|
470
|
|
|
} |
|
471
|
|
|
|
|
472
|
|
|
/** |
|
473
|
|
|
* Outputs the my profile week view box |
|
474
|
|
|
* |
|
475
|
|
|
* @param array $args An array of arguments. |
|
476
|
|
|
* @return void |
|
477
|
|
|
*/ |
|
478
|
|
|
function lsx_health_plan_week_plan_block( $args = array() ) { |
|
479
|
|
|
$defaults = array( |
|
480
|
|
|
'show_downloads' => false, |
|
481
|
|
|
'plan' => '', |
|
482
|
|
|
); |
|
483
|
|
|
$args = wp_parse_args( $args, $defaults ); |
|
484
|
|
|
|
|
485
|
|
|
if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) { |
|
486
|
|
|
$groups = \lsx_health_plan\functions\plan\get_sections( $args['plan'], true ); |
|
487
|
|
|
|
|
488
|
|
|
if ( ! empty( $groups ) ) { |
|
489
|
|
|
$counter = 1; |
|
490
|
|
|
$group_open = false; |
|
491
|
|
|
|
|
492
|
|
|
foreach ( $groups as $group_key => $sections ) { |
|
493
|
|
|
$collapse_class = ''; |
|
494
|
|
|
$group_title = \lsx_health_plan\functions\plan\get_group_title( $sections ); |
|
495
|
|
|
|
|
496
|
|
|
// Determine if the current week is complete. |
|
497
|
|
|
$day_ids = wp_list_pluck( $sections, 'title' ); |
|
498
|
|
|
if ( false === $group_open ) { |
|
499
|
|
|
if ( 1 === $counter && ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) { |
|
500
|
|
|
$collapse_class = 'in'; |
|
501
|
|
|
$group_open = true; |
|
502
|
|
|
} elseif ( ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) { |
|
503
|
|
|
$collapse_class = 'in'; |
|
504
|
|
|
$group_open = true; |
|
505
|
|
|
} |
|
506
|
|
|
} |
|
507
|
|
|
|
|
508
|
|
|
// Determine if there are any weekly downloads. |
|
509
|
|
|
$week_downloads_view = ''; |
|
510
|
|
|
/*if ( isset( $args['show_downloads'] ) && false !== $args['show_downloads'] ) { |
|
511
|
|
|
$weekly_downloads = \lsx_health_plan\functions\get_weekly_downloads( $group_key ); |
|
512
|
|
|
if ( ! empty( $weekly_downloads ) ) { |
|
513
|
|
|
$week_downloads_view = 'week-downloads-view-on'; |
|
514
|
|
|
} |
|
515
|
|
|
}*/ |
|
516
|
|
|
?> |
|
517
|
|
|
<div class="daily-plan-block week-grid"> |
|
518
|
|
|
<a href="#group-<?php echo esc_attr( $group_key ); ?>" data-toggle="collapse" class="week-title"><?php echo esc_attr( $group_title ); ?></a> |
|
|
|
|
|
|
519
|
|
|
<div id="group-<?php echo esc_attr( $group_key ); ?>" class="week-row collapse <?php echo esc_attr( $collapse_class ); ?>"> |
|
520
|
|
|
<div class="week-row-inner <?php echo esc_html( $week_downloads_view ); ?>"> |
|
521
|
|
|
<div class="week-meals-recipes-box"> |
|
522
|
|
|
|
|
523
|
|
|
<?php if ( ! empty( $week_downloads_view ) ) { ?> |
|
524
|
|
|
<h3 class="title"><?php lsx_get_svg_icon( 'daily-plan.svg' ); ?><?php echo esc_html_e( 'Daily Plan', 'lsx-health-plan' ); ?></h3> |
|
525
|
|
|
<?php } ?> |
|
526
|
|
|
|
|
527
|
|
|
<div class="week-meals-recipes-box-inner"> |
|
528
|
|
|
<?php |
|
529
|
|
|
|
|
530
|
|
|
foreach ( $sections as $section_key => $section_values ) { |
|
531
|
|
|
|
|
532
|
|
|
$defaults = array( |
|
533
|
|
|
'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ), |
|
534
|
|
|
); |
|
535
|
|
|
$section_args = wp_parse_args( $section_values, $defaults ); |
|
536
|
|
|
|
|
537
|
|
|
$completed_class = ''; |
|
538
|
|
|
if ( lsx_health_plan_is_day_complete( $args['plan'], $section_args['title'] ) ) { |
|
539
|
|
|
$completed_class = 'completed'; |
|
540
|
|
|
} |
|
541
|
|
|
?> |
|
542
|
|
|
<a href="<?php echo esc_attr( \lsx_health_plan\functions\plan\get_permalink( $args['plan'], $section_args['title'] ) ); ?>" class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>"> |
|
543
|
|
|
<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div> |
|
544
|
|
|
</a> |
|
545
|
|
|
<?php |
|
546
|
|
|
} |
|
547
|
|
|
?> |
|
548
|
|
|
</div> |
|
549
|
|
|
</div> |
|
550
|
|
|
<?php |
|
551
|
|
|
if ( ! empty( $week_downloads_view ) ) { |
|
552
|
|
|
//lsx_health_plan_weekly_downloads( $weekly_downloads ); |
|
553
|
|
|
} |
|
554
|
|
|
?> |
|
555
|
|
|
</div> |
|
556
|
|
|
</div> |
|
557
|
|
|
</div> |
|
558
|
|
|
<?php |
|
559
|
|
|
} |
|
560
|
|
|
} |
|
561
|
|
|
} |
|
562
|
|
|
} |
|
563
|
|
|
|
|
564
|
|
|
/** |
|
565
|
|
|
* Outputs the weekly downloads box. |
|
566
|
|
|
* |
|
567
|
|
|
* @param array $weekly_downloads An array of the download ids. |
|
568
|
|
|
* @return void |
|
569
|
|
|
*/ |
|
570
|
|
|
function lsx_health_plan_weekly_downloads( $weekly_downloads = array() ) { |
|
571
|
|
|
if ( ! empty( $weekly_downloads ) ) { |
|
572
|
|
|
?> |
|
573
|
|
|
<div class="week-download-box"> |
|
574
|
|
|
<h3 class="title"><?php lsx_get_svg_icon( 'download.svg' ); ?><?php echo esc_html_e( 'Downloads', 'lsx-health-plan' ); ?></h3> |
|
575
|
|
|
<ul class="week-download-box-list"> |
|
576
|
|
|
<?php |
|
577
|
|
|
foreach ( $weekly_downloads as $weekly_download ) { |
|
578
|
|
|
?> |
|
579
|
|
|
<li><?php echo wp_kses_post( do_shortcode( '[download id="' . $weekly_download . '"]' ) ); ?></li> |
|
580
|
|
|
<?php |
|
581
|
|
|
} |
|
582
|
|
|
?> |
|
583
|
|
|
</ul> |
|
584
|
|
|
</div> |
|
585
|
|
|
<?php |
|
586
|
|
|
} |
|
587
|
|
|
} |
|
588
|
|
|
|
|
589
|
|
|
/** |
|
590
|
|
|
* Outputs the featured items of any type shortcode (intended for exercises) |
|
591
|
|
|
* |
|
592
|
|
|
* @return void |
|
593
|
|
|
*/ |
|
594
|
|
|
function lsx_health_plan_items( $args = array() ) { |
|
595
|
|
|
global $shortcode_args; |
|
596
|
|
|
$shortcode_args = $args; |
|
597
|
|
|
include LSX_HEALTH_PLAN_PATH . '/templates/partials/shortcode-loop.php'; |
|
598
|
|
|
} |
|
599
|
|
|
|
|
600
|
|
|
/** |
|
601
|
|
|
* Outputs the featured video shortcode |
|
602
|
|
|
* |
|
603
|
|
|
* @return void |
|
604
|
|
|
*/ |
|
605
|
|
|
function lsx_health_plan_featured_video_block() { |
|
606
|
|
|
if ( ! post_type_exists( 'video' ) ) { |
|
607
|
|
|
return; |
|
608
|
|
|
} |
|
609
|
|
|
include LSX_HEALTH_PLAN_PATH . '/templates/featured-videos.php'; |
|
610
|
|
|
} |
|
611
|
|
|
|
|
612
|
|
|
/** |
|
613
|
|
|
* Outputs the featured recipes shortcode |
|
614
|
|
|
* |
|
615
|
|
|
* @return void |
|
616
|
|
|
*/ |
|
617
|
|
|
function lsx_health_plan_featured_recipes_block() { |
|
618
|
|
|
if ( ! post_type_exists( 'recipe' ) ) { |
|
619
|
|
|
return; |
|
620
|
|
|
} |
|
621
|
|
|
include LSX_HEALTH_PLAN_PATH . '/templates/featured-recipes.php'; |
|
622
|
|
|
} |
|
623
|
|
|
|
|
624
|
|
|
/** |
|
625
|
|
|
* Outputs the featured tips shortcode |
|
626
|
|
|
* |
|
627
|
|
|
* @return void |
|
628
|
|
|
*/ |
|
629
|
|
|
function lsx_health_plan_featured_tips_block() { |
|
630
|
|
|
include LSX_HEALTH_PLAN_PATH . '/templates/featured-tips.php'; |
|
631
|
|
|
} |
|
632
|
|
|
|
|
633
|
|
|
/** |
|
634
|
|
|
* Outputs the Health Plan Buttons |
|
635
|
|
|
* |
|
636
|
|
|
* @param string $button |
|
637
|
|
|
* @return void |
|
638
|
|
|
*/ |
|
639
|
|
|
function lsx_health_plan_day_button() { |
|
640
|
|
|
if ( lsx_health_plan_is_day_complete() ) { |
|
641
|
|
|
lsx_health_plan_unlock_button(); |
|
642
|
|
|
} else { |
|
643
|
|
|
lsx_health_plan_complete_button(); |
|
644
|
|
|
} |
|
645
|
|
|
} |
|
646
|
|
|
|
|
647
|
|
|
/** |
|
648
|
|
|
* Outputs the health plan complete button. |
|
649
|
|
|
* |
|
650
|
|
|
* @return void |
|
651
|
|
|
*/ |
|
652
|
|
|
function lsx_health_plan_complete_button() { |
|
653
|
|
|
?> |
|
654
|
|
|
<div class="single-plan-inner-buttons"> |
|
655
|
|
|
<form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn"> |
|
656
|
|
|
<?php wp_nonce_field( 'complete', 'lsx-health-plan-actions' ); ?> |
|
657
|
|
|
<input type="hidden" name="lsx-health-plan-id" value="<?php echo esc_attr( \lsx_health_plan\functions\plan\generate_section_id() ); ?>" /> |
|
658
|
|
|
<button class="btn cta-btn" type="submit"><?php esc_html_e( 'Complete Day', 'lsx-health-plan' ); ?></button> |
|
659
|
|
|
</form> |
|
660
|
|
|
<?php lsx_health_plan_back_to_plan_button(); ?> |
|
661
|
|
|
</div> |
|
662
|
|
|
<?php |
|
663
|
|
|
} |
|
664
|
|
|
|
|
665
|
|
|
/** |
|
666
|
|
|
* Outputs the health plan unlock button. |
|
667
|
|
|
* |
|
668
|
|
|
* @return void |
|
669
|
|
|
*/ |
|
670
|
|
|
function lsx_health_plan_unlock_button() { |
|
671
|
|
|
?> |
|
672
|
|
|
<div class="single-plan-inner-buttons"> |
|
673
|
|
|
<form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn"> |
|
674
|
|
|
<?php wp_nonce_field( 'unlock', 'lsx-health-plan-actions' ); ?> |
|
675
|
|
|
<input type="hidden" name="lsx-health-plan-id" value="<?php echo esc_attr( \lsx_health_plan\functions\plan\generate_section_id() ); ?>" /> |
|
676
|
|
|
<button class="btn secondary-btn" type="submit"><?php esc_html_e( 'Im not done!', 'lsx-health-plan' ); ?></button> |
|
677
|
|
|
</form> |
|
678
|
|
|
<?php lsx_health_plan_back_to_plan_button(); ?> |
|
679
|
|
|
</div> |
|
680
|
|
|
<?php |
|
681
|
|
|
} |
|
682
|
|
|
|
|
683
|
|
|
/** |
|
684
|
|
|
* Outputs the Single Plan Endpoint Tabs |
|
685
|
|
|
* |
|
686
|
|
|
* @param string $button |
|
687
|
|
|
* @return void |
|
688
|
|
|
*/ |
|
689
|
|
|
function lsx_health_plan_single_nav() { |
|
690
|
|
|
$tab_template_path = apply_filters( 'lsx_health_plan_single_nav_path', LSX_HEALTH_PLAN_PATH . '/templates/single-plan-tabs.php' ); |
|
691
|
|
|
if ( '' !== $tab_template_path ) { |
|
692
|
|
|
require $tab_template_path; |
|
693
|
|
|
} |
|
694
|
|
|
} |
|
695
|
|
|
|
|
696
|
|
|
/** |
|
697
|
|
|
* Outputs the Single Plan Tab based on the endpoint |
|
698
|
|
|
* |
|
699
|
|
|
* @param string $button |
|
700
|
|
|
* @return void |
|
701
|
|
|
*/ |
|
702
|
|
|
function lsx_health_plan_single_tabs() { |
|
703
|
|
|
$endpoint = get_query_var( 'endpoint' ); |
|
704
|
|
|
switch ( $endpoint ) { |
|
705
|
|
|
case 'meal': |
|
706
|
|
|
$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-meal.php'; |
|
707
|
|
|
break; |
|
708
|
|
|
|
|
709
|
|
|
case 'recipes': |
|
710
|
|
|
$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-recipes.php'; |
|
711
|
|
|
break; |
|
712
|
|
|
|
|
713
|
|
|
case 'workout': |
|
714
|
|
|
$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-workout.php'; |
|
715
|
|
|
break; |
|
716
|
|
|
|
|
717
|
|
|
case 'warm-up': |
|
718
|
|
|
$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-warm-up.php'; |
|
719
|
|
|
break; |
|
720
|
|
|
|
|
721
|
|
|
default: |
|
722
|
|
|
$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-plan.php'; |
|
723
|
|
|
break; |
|
724
|
|
|
} |
|
725
|
|
|
$tab_template_path = apply_filters( 'lsx_health_plan_single_tab_path', $tab_template_path ); |
|
726
|
|
|
if ( '' !== $tab_template_path ) { |
|
727
|
|
|
include $tab_template_path; |
|
728
|
|
|
} |
|
729
|
|
|
} |
|
730
|
|
|
|
|
731
|
|
|
/** |
|
732
|
|
|
* Outputs the recipe info on a table. |
|
733
|
|
|
* |
|
734
|
|
|
* @return void |
|
735
|
|
|
*/ |
|
736
|
|
|
function lsx_health_plan_recipe_data() { |
|
737
|
|
|
include LSX_HEALTH_PLAN_PATH . '/templates/table-recipe-data.php'; |
|
738
|
|
|
} |
|
739
|
|
|
|
|
740
|
|
|
/** |
|
741
|
|
|
* Outputs the recipe type. |
|
742
|
|
|
* |
|
743
|
|
|
* @return recipe_type |
|
|
|
|
|
|
744
|
|
|
*/ |
|
745
|
|
|
function lsx_health_plan_recipe_type() { |
|
746
|
|
|
$term_obj_list = get_the_terms( get_the_ID(), 'recipe-type' ); |
|
|
|
|
|
|
747
|
|
|
$recipe_type = $term_obj_list[0]->name; |
|
748
|
|
|
if ( ! empty( $recipe_type ) ) { |
|
749
|
|
|
return $recipe_type; |
|
750
|
|
|
} |
|
751
|
|
|
} |
|
752
|
|
|
|
|
753
|
|
|
/** |
|
754
|
|
|
* Outputs the modal button and registers the video modal to show. |
|
755
|
|
|
* |
|
756
|
|
|
* @param int $m |
|
757
|
|
|
* @param array $group |
|
758
|
|
|
* @return void |
|
759
|
|
|
*/ |
|
760
|
|
|
function lsx_health_plan_workout_video_play_button( $m, $group, $echo = true ) { |
|
761
|
|
|
$workout_video = ''; |
|
762
|
|
|
$giphy = ''; |
|
763
|
|
|
$youtube = ''; |
|
764
|
|
|
if ( isset( $group['connected_videos'] ) && '' !== $group['connected_videos'] ) { |
|
765
|
|
|
$workout_video = esc_html( $group['connected_videos'] ); |
|
766
|
|
|
$giphy = get_post_meta( $workout_video, 'video_giphy_source', true ); |
|
|
|
|
|
|
767
|
|
|
$youtube = esc_url( get_post_meta( $workout_video, 'video_youtube_source', 1 ) ); |
|
768
|
|
|
$content = get_post_field( 'post_content', $workout_video ); |
|
|
|
|
|
|
769
|
|
|
$play_button = '<button data-toggle="modal" data-target="#workout-video-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>'; |
|
770
|
|
|
|
|
771
|
|
|
$modal_body = ''; |
|
772
|
|
|
if ( ! empty( $giphy ) ) { |
|
773
|
|
|
$giphy = \lsx_health_plan\functions\get_video_url( $giphy ); |
|
774
|
|
|
$modal_body = $giphy; // WPCS: XSS OK. |
|
775
|
|
|
} elseif ( ! empty( $youtube ) ) { |
|
776
|
|
|
$modal_body = wp_oembed_get( $youtube, array( // WPCS: XSS OK. |
|
777
|
|
|
'width' => 480, |
|
778
|
|
|
) ); |
|
779
|
|
|
} |
|
780
|
|
|
$modal_body .= '<h5 class="modal-title title-lined">' . $group['name'] . '</h5>'; |
|
781
|
|
|
$modal_body .= $content; |
|
782
|
|
|
\lsx_health_plan\functions\register_modal( 'workout-video-modal-' . $m, '', $modal_body ); |
|
783
|
|
|
|
|
784
|
|
|
if ( true === $echo ) { |
|
785
|
|
|
echo wp_kses_post( $play_button ); |
|
786
|
|
|
} else { |
|
787
|
|
|
return $play_button; |
|
788
|
|
|
} |
|
789
|
|
|
} |
|
790
|
|
|
} |
|
791
|
|
|
|
|
792
|
|
|
/** |
|
793
|
|
|
* Outputs the recipe description if it is included. |
|
794
|
|
|
* |
|
795
|
|
|
* @return void |
|
796
|
|
|
*/ |
|
797
|
|
|
function lsx_health_plan_recipe_archive_description() { |
|
798
|
|
|
$description = ''; |
|
799
|
|
|
if ( is_post_type_archive( 'recipe' ) ) { |
|
800
|
|
|
$description = \lsx_health_plan\functions\get_option( 'recipe_archive_description', '' ); |
|
801
|
|
|
} elseif ( is_post_type_archive( 'exercise' ) ) { |
|
802
|
|
|
$description = \lsx_health_plan\functions\get_option( 'exercise_archive_description', '' ); |
|
803
|
|
|
} elseif ( is_tax() ) { |
|
804
|
|
|
$description = get_the_archive_description(); |
|
805
|
|
|
} |
|
806
|
|
|
if ( '' !== $description ) { |
|
807
|
|
|
?> |
|
808
|
|
|
<div class="lsx-hp-archive-description row"> |
|
809
|
|
|
<div class="col-xs-12 description-wrapper"><?php echo wp_kses_post( $description ); ?></div> |
|
810
|
|
|
</div> |
|
811
|
|
|
<?php |
|
812
|
|
|
} |
|
813
|
|
|
} |
|
814
|
|
|
|
|
815
|
|
|
/** |
|
816
|
|
|
* Outputs the Single Plan main content. |
|
817
|
|
|
* |
|
818
|
|
|
* @return void |
|
819
|
|
|
*/ |
|
820
|
|
|
function lsx_health_plan_main_content() { |
|
821
|
|
|
// Getting translated endpoint. |
|
822
|
|
|
$plan = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ); |
|
823
|
|
|
|
|
824
|
|
|
$connected_members = get_post_meta( get_the_ID(), ( $plan . '_connected_team_member' ), true ); |
|
|
|
|
|
|
825
|
|
|
$small_description = get_post_meta( get_the_ID(), ( $plan . '_short_description' ), true ); |
|
826
|
|
|
|
|
827
|
|
|
$content_plan = ''; |
|
828
|
|
|
if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) { |
|
829
|
|
|
$content_plan .= '<div class="set-box set content-box entry-content">'; |
|
830
|
|
|
$content_plan .= '<div class="the-content">'; |
|
831
|
|
|
$content_plan .= lsx_hp_member_connected( $connected_members, $plan ); |
|
832
|
|
|
$content_plan .= '<span>' . $small_description . '</span>'; |
|
833
|
|
|
$content_plan .= '</div>'; |
|
834
|
|
|
$content_plan .= do_shortcode( '[lsx_health_plan_featured_tips_block]' ); |
|
835
|
|
|
$content_plan .= '</div>'; |
|
836
|
|
|
} |
|
837
|
|
|
|
|
838
|
|
|
return $content_plan; |
|
839
|
|
|
} |
|
840
|
|
|
|
|
841
|
|
|
/** |
|
842
|
|
|
* Outputs the Single Plan Workout main content. |
|
843
|
|
|
* |
|
844
|
|
|
* @return void |
|
845
|
|
|
*/ |
|
846
|
|
|
function lsx_health_plan_workout_main_content() { |
|
847
|
|
|
// Getting translated endpoint. |
|
848
|
|
|
$workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ); |
|
849
|
|
|
|
|
850
|
|
|
$connected_members = get_post_meta( get_the_ID(), ( $workout . '_connected_team_member' ), true ); |
|
|
|
|
|
|
851
|
|
|
$small_description = get_post_meta( get_the_ID(), ( $workout . '_short_description' ), true ); |
|
852
|
|
|
|
|
853
|
|
|
$content = ''; |
|
854
|
|
|
if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) { |
|
855
|
|
|
$content .= '<div class="set-box set content-box entry-content">'; |
|
856
|
|
|
$content .= '<div class="the-content">'; |
|
857
|
|
|
$content .= lsx_hp_member_connected( $connected_members, $workout ); |
|
858
|
|
|
$content .= '<span>' . $small_description . '</span>'; |
|
859
|
|
|
$content .= '</div>'; |
|
860
|
|
|
$content .= do_shortcode( '[lsx_health_plan_featured_tips_block]' ); |
|
861
|
|
|
$content .= '</div>'; |
|
862
|
|
|
} |
|
863
|
|
|
return $content; |
|
864
|
|
|
} |
|
865
|
|
|
|
|
866
|
|
|
/** |
|
867
|
|
|
* Outputs the Single Plan Workout main content. |
|
868
|
|
|
* |
|
869
|
|
|
* @return void |
|
870
|
|
|
*/ |
|
871
|
|
|
function lsx_health_plan_meal_main_content() { |
|
872
|
|
|
// Getting translated endpoint. |
|
873
|
|
|
$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' ); |
|
874
|
|
|
|
|
875
|
|
|
$connected_members = get_post_meta( get_the_ID(), ( $meal . '_connected_team_member' ), true ); |
|
|
|
|
|
|
876
|
|
|
$small_description = get_post_meta( get_the_ID(), ( $meal . '_short_description' ), true ); |
|
877
|
|
|
|
|
878
|
|
|
$content_meal = ''; |
|
879
|
|
|
if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) { |
|
880
|
|
|
$content_meal .= '<div class="set-box set content-box entry-content">'; |
|
881
|
|
|
$content_meal .= '<div class="the-content">'; |
|
882
|
|
|
$content_meal .= lsx_hp_member_connected( $connected_members, $meal ); |
|
883
|
|
|
$content_meal .= '<span>' . $small_description . '</span>'; |
|
884
|
|
|
$content_meal .= '</div>'; |
|
885
|
|
|
$content_meal .= do_shortcode( '[lsx_health_plan_featured_tips_block]' ); |
|
886
|
|
|
$content_meal .= '</div>'; |
|
887
|
|
|
} |
|
888
|
|
|
return $content_meal; |
|
889
|
|
|
} |
|
890
|
|
|
|
|
891
|
|
|
|
|
892
|
|
|
/** |
|
893
|
|
|
* Outputs the Single Plan Workout Tab based on the layout selected. |
|
894
|
|
|
* |
|
895
|
|
|
* @param string $index |
|
896
|
|
|
* @return void |
|
897
|
|
|
*/ |
|
898
|
|
|
function lsx_health_plan_workout_tab_content( $index = 1 ) { |
|
899
|
|
|
global $group_name,$shortcode_args; |
|
900
|
|
|
$group_name = 'workout_section_' . $index; |
|
901
|
|
|
if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
902
|
|
|
$layout = strtolower( \lsx_health_plan\functions\get_option( 'workout_tab_layout', 'table' ) ); |
|
|
|
|
|
|
903
|
|
|
|
|
904
|
|
|
// Check for shortcode overrides. |
|
905
|
|
|
if ( null !== $shortcode_args && isset( $shortcode_args['layout'] ) ) { |
|
906
|
|
|
$layout = $shortcode_args['layout']; |
|
907
|
|
|
} |
|
908
|
|
|
} else { |
|
909
|
|
|
$layout = 'table'; |
|
910
|
|
|
} |
|
911
|
|
|
|
|
912
|
|
|
switch ( $layout ) { |
|
913
|
|
|
case 'list': |
|
914
|
|
|
$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-list.php'; |
|
915
|
|
|
break; |
|
916
|
|
|
|
|
917
|
|
|
case 'grid': |
|
918
|
|
|
$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-grid.php'; |
|
919
|
|
|
break; |
|
920
|
|
|
|
|
921
|
|
|
case 'table': |
|
922
|
|
|
$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-table.php'; |
|
923
|
|
|
break; |
|
924
|
|
|
} |
|
925
|
|
|
$tab_template_path = apply_filters( 'lsx_health_plan_workout_tab_content_path', $tab_template_path ); |
|
926
|
|
|
if ( '' !== $tab_template_path ) { |
|
927
|
|
|
include $tab_template_path; |
|
928
|
|
|
} |
|
929
|
|
|
} |
|
930
|
|
|
|
|
931
|
|
|
/** |
|
932
|
|
|
* This will detect and include the Workout sets loop. |
|
933
|
|
|
* |
|
934
|
|
|
* @return void |
|
935
|
|
|
*/ |
|
936
|
|
|
function lsx_health_plan_workout_sets() { |
|
937
|
|
|
if ( is_singular( 'workout' ) ) { |
|
938
|
|
|
global $connected_workouts; |
|
939
|
|
|
$connected_workouts = array( get_the_ID() ); |
|
940
|
|
|
} |
|
941
|
|
|
if ( is_singular( 'plan' ) ) { |
|
942
|
|
|
|
|
943
|
|
|
global $connected_workouts; |
|
944
|
|
|
|
|
945
|
|
|
$section_key = get_query_var( 'section' ); |
|
946
|
|
|
if ( '' !== $section && \lsx_health_plan\functions\plan\has_sections() ) { |
|
947
|
|
|
$section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key ); |
|
948
|
|
|
if ( isset( $section_info['connected_workouts'] ) && '' !== $section_info['connected_workouts'] ) { |
|
949
|
|
|
|
|
950
|
|
|
$connected_workouts = \lsx_health_plan\functions\prep_array( $section_info['connected_workouts'] ); |
|
951
|
|
|
} |
|
952
|
|
|
} |
|
953
|
|
|
} |
|
954
|
|
|
$template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php'; |
|
955
|
|
|
$template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path ); |
|
956
|
|
|
if ( '' !== $template_path && ! empty( $template_path ) ) { |
|
957
|
|
|
include $template_path; |
|
958
|
|
|
} |
|
959
|
|
|
} |
|
960
|
|
|
|
|
961
|
|
|
/** |
|
962
|
|
|
* Outputs the recipes connected to the meal plan. |
|
963
|
|
|
* |
|
964
|
|
|
* @param array $args |
|
965
|
|
|
* @return void |
|
966
|
|
|
*/ |
|
967
|
|
|
function lsx_hp_meal_plan_recipes( $args = array() ) { |
|
968
|
|
|
$defaults = array( |
|
969
|
|
|
'meal_id' => false, |
|
970
|
|
|
'meal_time' => '', |
|
971
|
|
|
'modal' => true, |
|
972
|
|
|
); |
|
973
|
|
|
$args = wp_parse_args( $args, $defaults ); |
|
974
|
|
|
// Looking for recipes. |
|
975
|
|
|
$connected_recipes = get_post_meta( $args['meal_id'], $args['meal_time'] . '_recipes', true ); |
|
976
|
|
|
if ( ! empty( $connected_recipes ) ) { |
|
977
|
|
|
$query_args = array( |
|
978
|
|
|
'orderby' => 'date', |
|
979
|
|
|
'order' => 'DESC', |
|
980
|
|
|
'post_type' => 'recipe', |
|
981
|
|
|
'post__in' => $connected_recipes, |
|
982
|
|
|
); |
|
983
|
|
|
$recipes = new WP_Query( $query_args ); |
|
984
|
|
|
?> |
|
985
|
|
|
<div class="recipes"> |
|
986
|
|
|
<div class="row eating-row"> |
|
987
|
|
|
<?php |
|
988
|
|
|
if ( $recipes->have_posts() ) { |
|
989
|
|
|
while ( $recipes->have_posts() ) { |
|
990
|
|
|
$recipes->the_post(); |
|
991
|
|
|
if ( false !== $args['modal'] ) { |
|
992
|
|
|
\lsx_health_plan\functions\recipes\register_recipe_modal(); |
|
993
|
|
|
} |
|
994
|
|
|
?> |
|
995
|
|
|
<div class="recipe-column"> |
|
996
|
|
|
<a data-toggle="modal" data-target="#recipe-modal-<?php echo esc_attr( get_the_ID() ); ?>" href="#recipe-modal-<?php echo esc_attr( get_the_ID() ); ?>" class="recipe-box box-shadow"> |
|
|
|
|
|
|
997
|
|
|
<div class="recipe-feature-img"> |
|
998
|
|
|
<?php |
|
999
|
|
|
$featured_image = get_the_post_thumbnail(); |
|
1000
|
|
|
if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
1001
|
|
|
the_post_thumbnail( 'lsx-thumbnail-square', array( |
|
1002
|
|
|
'class' => 'aligncenter', |
|
1003
|
|
|
) ); |
|
1004
|
|
|
} else { |
|
1005
|
|
|
?> |
|
1006
|
|
|
<img loading="lazy" src="<?php echo esc_attr( plugin_dir_url( __DIR__ ) . 'assets/images/placeholder.jpg' ); ?>"> |
|
1007
|
|
|
<?php |
|
1008
|
|
|
} |
|
1009
|
|
|
?> |
|
1010
|
|
|
</div> |
|
1011
|
|
|
<div class="recipe-content"> |
|
1012
|
|
|
<h3 class="recipe-title"><?php the_title(); ?></h3> |
|
1013
|
|
|
<?php lsx_health_plan_recipe_data(); ?> |
|
1014
|
|
|
</div> |
|
1015
|
|
|
</a> |
|
1016
|
|
|
</div> |
|
1017
|
|
|
<?php |
|
1018
|
|
|
} |
|
1019
|
|
|
} |
|
1020
|
|
|
wp_reset_postdata(); |
|
1021
|
|
|
?> |
|
1022
|
|
|
</div> |
|
1023
|
|
|
</div> |
|
1024
|
|
|
<?php |
|
1025
|
|
|
|
|
1026
|
|
|
} |
|
1027
|
|
|
} |
|
1028
|
|
|
|
|
1029
|
|
|
/** |
|
1030
|
|
|
* Output the connected. |
|
1031
|
|
|
*/ |
|
1032
|
|
|
function lsx_hp_recipe_plan_meta( $args = array() ) { |
|
1033
|
|
|
$defaults = array(); |
|
1034
|
|
|
$top_level_plans = array(); |
|
1035
|
|
|
// Get meals this exercise is connected to. |
|
1036
|
|
|
$plans = get_post_meta( get_the_ID(), 'connected_plans', true ); |
|
|
|
|
|
|
1037
|
|
|
if ( ! empty( $plans ) ) { |
|
1038
|
|
|
$plan = end( $plans ); |
|
|
|
|
|
|
1039
|
|
|
$has_parent = wp_get_post_parent_id( $plan ); |
|
1040
|
|
|
if ( 0 === $has_parent ) { |
|
1041
|
|
|
$top_level_plans[] = $plan; |
|
1042
|
|
|
} elseif ( false !== $top_level_plans ) { |
|
|
|
|
|
|
1043
|
|
|
$top_level_plans[] = $has_parent; |
|
1044
|
|
|
} |
|
1045
|
|
|
} |
|
1046
|
|
|
if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) { |
|
1047
|
|
|
$top_level_plans = array_unique( $top_level_plans ); |
|
1048
|
|
|
$top_level_plan = end( $top_level_plans ); |
|
1049
|
|
|
?> |
|
1050
|
|
|
<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span> |
|
1051
|
|
|
<?php |
|
1052
|
|
|
} |
|
1053
|
|
|
} |
|
1054
|
|
|
|
|
1055
|
|
|
/** |
|
1056
|
|
|
* Output the connected. |
|
1057
|
|
|
*/ |
|
1058
|
|
|
function lsx_hp_exercise_plan_meta() { |
|
1059
|
|
|
|
|
1060
|
|
|
$top_level_plans = array(); |
|
1061
|
|
|
|
|
1062
|
|
|
// Get workouts this exercise is connected to. |
|
1063
|
|
|
$workouts = get_post_meta( get_the_ID(), 'connected_workouts', true ); |
|
|
|
|
|
|
1064
|
|
|
|
|
1065
|
|
|
if ( '' !== $workouts && ! is_array( $workouts ) ) { |
|
1066
|
|
|
$workouts = array( $workouts ); |
|
1067
|
|
|
} |
|
1068
|
|
|
if ( ! empty( $workouts ) ) { |
|
1069
|
|
|
foreach ( $workouts as $workout ) { |
|
1070
|
|
|
// Get the plans this workout is connected to. |
|
1071
|
|
|
$plans = get_post_meta( $workout, 'connected_plans', true ); |
|
1072
|
|
|
|
|
1073
|
|
|
if ( '' !== $plans && ! is_array( $plans ) ) { |
|
1074
|
|
|
$plans = array( $plans ); |
|
1075
|
|
|
} |
|
1076
|
|
|
if ( ! empty( $plans ) ) { |
|
1077
|
|
|
foreach ( $plans as $plan ) { |
|
1078
|
|
|
$has_parent = wp_get_post_parent_id( $plan ); |
|
1079
|
|
|
if ( 0 === $has_parent ) { |
|
1080
|
|
|
$top_level_plans = $plan; |
|
1081
|
|
|
} else { |
|
1082
|
|
|
$top_level_plans = $has_parent; |
|
1083
|
|
|
} |
|
1084
|
|
|
} |
|
1085
|
|
|
} |
|
1086
|
|
|
} |
|
1087
|
|
|
} |
|
1088
|
|
|
|
|
1089
|
|
|
if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) { |
|
1090
|
|
|
$top_level_plans = array_unique( $top_level_plans ); |
|
1091
|
|
|
$top_level_plan = end( $top_level_plans ); |
|
1092
|
|
|
?> |
|
1093
|
|
|
<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span> |
|
1094
|
|
|
<?php |
|
1095
|
|
|
} |
|
1096
|
|
|
} |
|
1097
|
|
|
|
|
1098
|
|
|
/** |
|
1099
|
|
|
* Template for related content box for all singles. |
|
1100
|
|
|
* |
|
1101
|
|
|
* @param [type] $related_content |
|
|
|
|
|
|
1102
|
|
|
* @return void |
|
1103
|
|
|
*/ |
|
1104
|
|
|
function lsx_hp_single_related( $related_content, $post_type_text ) { |
|
1105
|
|
|
?> |
|
1106
|
|
|
<section id="lsx-hp-related"> |
|
1107
|
|
|
<div class="row lsx-related-posts lsx-related-posts-title"> |
|
1108
|
|
|
<div class="col-xs-12"> |
|
1109
|
|
|
<h2 class="lsx-related-posts-headline"><?php echo esc_html( $post_type_text ); ?></h2> |
|
1110
|
|
|
</div> |
|
1111
|
|
|
</div> |
|
1112
|
|
|
<div class="row lsx-related-posts lsx-related-posts-content"> |
|
1113
|
|
|
<div class="col-xs-12"> |
|
1114
|
|
|
<div class="lsx-related-posts-wrapper"> |
|
1115
|
|
|
<?php |
|
1116
|
|
|
foreach ( $related_content as $article ) { |
|
1117
|
|
|
$post_title = get_the_title( $article ); |
|
1118
|
|
|
$post_categories = wp_get_post_categories( $article ); |
|
1119
|
|
|
$post_link = get_permalink( $article ); |
|
1120
|
|
|
|
|
1121
|
|
|
$cats = array(); |
|
1122
|
|
|
?> |
|
1123
|
|
|
<article id="post-<?php echo esc_html( $article ); ?>" class="lsx-slot post"> |
|
1124
|
|
|
<div class="entry-layout lsx-hp-shadow"> |
|
1125
|
|
|
<div class="entry-layout-content"> |
|
1126
|
|
|
<header class="entry-header"> |
|
1127
|
|
|
<div class="entry-image"> |
|
1128
|
|
|
<a href="<?php echo esc_url( $post_link ); ?>" class="thumbnail"> |
|
|
|
|
|
|
1129
|
|
|
<?php |
|
1130
|
|
|
$featured_image = get_the_post_thumbnail( $article, 'lsx-thumbnail-wide' ); |
|
1131
|
|
|
if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
1132
|
|
|
echo wp_kses_post( $featured_image ); |
|
1133
|
|
|
} else { |
|
1134
|
|
|
?> |
|
1135
|
|
|
<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>"> |
|
1136
|
|
|
<?php |
|
1137
|
|
|
} |
|
1138
|
|
|
?> |
|
1139
|
|
|
</a> |
|
1140
|
|
|
</div> |
|
1141
|
|
|
<div class="entry-meta"> |
|
1142
|
|
|
<?php |
|
1143
|
|
|
foreach ( $post_categories as $c ) { |
|
1144
|
|
|
$cat = get_category( $c ); |
|
1145
|
|
|
/* Translators: %s: category name */ |
|
1146
|
|
|
$cats[] = '<a href="' . esc_url( get_category_link( $cat->term_id ) ) . '" title="' . sprintf( esc_html__( 'Posts in %s', 'lsx-blog-customizer' ), $cat->name ) . '">' . $cat->name . '</a>'; |
|
|
|
|
|
|
1147
|
|
|
} |
|
1148
|
|
|
if ( ! empty( $cats ) ) { ?> |
|
1149
|
|
|
<div class="post-categories"><span></span><?php echo wp_kses_post( implode( ', ', $cats ) ); ?></div> |
|
1150
|
|
|
<?php } ?> |
|
1151
|
|
|
</div> |
|
1152
|
|
|
<h2 class="entry-title"> |
|
1153
|
|
|
<a href="<?php echo esc_url( $post_link ); ?>"> |
|
1154
|
|
|
<?php echo esc_html( $post_title ); ?> |
|
1155
|
|
|
</a> |
|
1156
|
|
|
</h2> |
|
1157
|
|
|
</header> |
|
1158
|
|
|
</div> |
|
1159
|
|
|
</div> |
|
1160
|
|
|
</article> |
|
1161
|
|
|
|
|
1162
|
|
|
<?php } ?> |
|
1163
|
|
|
</div> |
|
1164
|
|
|
</div> |
|
1165
|
|
|
</div> |
|
1166
|
|
|
</section> |
|
1167
|
|
|
<?php |
|
1168
|
|
|
} |
|
1169
|
|
|
|
|
1170
|
|
|
/** |
|
1171
|
|
|
* Template for connected members. |
|
1172
|
|
|
* |
|
1173
|
|
|
* @param [type] $connected_members |
|
|
|
|
|
|
1174
|
|
|
* @return void |
|
1175
|
|
|
*/ |
|
1176
|
|
|
function lsx_hp_member_connected( $connected_members, $post_type ) { |
|
1177
|
|
|
if ( ! empty( $connected_members ) ) { |
|
1178
|
|
|
$content = '<div id="hp-connected-members" class="hp-connected-members connected-' . $post_type . '">'; |
|
1179
|
|
|
foreach ( $connected_members as $member ) { |
|
1180
|
|
|
$post_link = get_permalink( $member ); |
|
1181
|
|
|
$member_name = get_the_title( $member ); |
|
1182
|
|
|
$member_name = '<span class="lsx-team-name">' . $member_name . '</span>'; |
|
1183
|
|
|
|
|
1184
|
|
|
$member_link = '<a href="' . $post_link . '" >' . $member_name . '</a>'; |
|
|
|
|
|
|
1185
|
|
|
|
|
1186
|
|
|
$roles = ''; |
|
1187
|
|
|
$terms = get_the_terms( $member, 'team_role' ); |
|
1188
|
|
|
|
|
1189
|
|
|
if ( $terms && ! is_wp_error( $terms ) ) { |
|
1190
|
|
|
$roles = array(); |
|
1191
|
|
|
|
|
1192
|
|
|
foreach ( $terms as $term ) { |
|
1193
|
|
|
$roles[] = $term->name; |
|
1194
|
|
|
} |
|
1195
|
|
|
|
|
1196
|
|
|
$roles = join( ', ', $roles ); |
|
1197
|
|
|
} |
|
1198
|
|
|
$member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : ''; |
|
1199
|
|
|
|
|
1200
|
|
|
$content .= '<p>' . $member_roles . ': ' . $member_link . '</p>'; |
|
1201
|
|
|
} |
|
1202
|
|
|
$content .= '</div>'; |
|
1203
|
|
|
return $content; |
|
1204
|
|
|
} |
|
1205
|
|
|
} |
|
1206
|
|
|
|