Passed
Push — master ( ba36ac...40f1a9 )
by Virginia
09:22
created
templates/taxonomy-workout-type.php 3 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 <?php lsx_content_wrap_before(); ?>
11 11
 
12 12
 <?php
13
-	$page_id  = get_the_ID();
14
-	$redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id;
13
+     $page_id  = get_the_ID();
14
+     $redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id;
15 15
 ?>
16 16
 
17 17
 	<div id="primary" class="content-area <?php echo esc_attr( lsx_main_class() ); ?>">
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 
21 21
 		<!-- Begining restricted content -->
22 22
 		<?php
23
-		if ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) {
24
-			?>
23
+          if ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) {
24
+               ?>
25 25
 			<main id="main" role="main">
26 26
 
27 27
 				<?php lsx_content_top(); ?>
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 					<div class="row">
31 31
 						<?php if ( have_posts() ) : ?>
32 32
 							<?php
33
-							while ( have_posts() ) :
34
-								the_post();
35
-								?>
33
+                                   while ( have_posts() ) :
34
+                                        the_post();
35
+                                        ?>
36 36
 
37 37
 								<?php include LSX_HEALTH_PLAN_PATH . '/templates/content-archive-workout.php'; ?>
38 38
 
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 			</main><!-- #main -->
52 52
 
53 53
 			<?php
54
-		} else {
55
-			wp_redirect( $redirect );
56
-			exit;
57
-		}
58
-		?>
54
+          } else {
55
+               wp_redirect( $redirect );
56
+               exit;
57
+          }
58
+          ?>
59 59
 
60 60
 <?php lsx_content_after(); ?>
61 61
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 	$redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id;
15 15
 ?>
16 16
 
17
-	<div id="primary" class="content-area <?php echo esc_attr( lsx_main_class() ); ?>">
17
+	<div id="primary" class="content-area <?php echo esc_attr(lsx_main_class()); ?>">
18 18
 
19 19
 		<?php lsx_content_before(); ?>
20 20
 
21 21
 		<!-- Begining restricted content -->
22 22
 		<?php
23
-		if ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) {
23
+		if (current_user_can('wc_memberships_view_restricted_post_content', $post_id)) {
24 24
 			?>
25 25
 			<main id="main" role="main">
26 26
 
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
 				<div class="post-wrapper archive-plan">
30 30
 					<div class="row">
31
-						<?php if ( have_posts() ) : ?>
31
+						<?php if (have_posts()) : ?>
32 32
 							<?php
33
-							while ( have_posts() ) :
33
+							while (have_posts()) :
34 34
 								the_post();
35 35
 								?>
36 36
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
 						<?php else : ?>
42 42
 
43
-							<?php get_template_part( 'partials/content', 'none' ); ?>
43
+							<?php get_template_part('partials/content', 'none'); ?>
44 44
 
45 45
 						<?php endif; ?>
46 46
 					</div>
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
 			<?php
54 54
 		} else {
55
-			wp_redirect( $redirect );
55
+			wp_redirect($redirect);
56 56
 			exit;
57 57
 		}
58 58
 		?>
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,9 +38,12 @@
 block discarded – undo
38 38
 
39 39
 							<?php endwhile; ?>
40 40
 
41
-						<?php else : ?>
41
+						<?php else {
42
+     : ?>
42 43
 
43
-							<?php get_template_part( 'partials/content', 'none' ); ?>
44
+							<?php get_template_part( 'partials/content', 'none' );
45
+}
46
+?>
44 47
 
45 48
 						<?php endif; ?>
46 49
 					</div>
Please login to merge, or discard this patch.
templates/taxonomy-meal-type.php 3 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 <?php lsx_content_wrap_before(); ?>
11 11
 
12 12
 <?php
13
-	$page_id  = get_the_ID();
14
-	$redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id;
13
+     $page_id  = get_the_ID();
14
+     $redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id;
15 15
 ?>
16 16
 
17 17
 	<div id="primary" class="content-area <?php echo esc_attr( lsx_main_class() ); ?>">
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 
21 21
 		<!-- Begining restricted content -->
22 22
 		<?php
23
-		if ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) {
24
-			?>
23
+          if ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) {
24
+               ?>
25 25
 			<main id="main" role="main">
26 26
 
27 27
 				<?php lsx_content_top(); ?>
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 					<div class="row">
31 31
 						<?php if ( have_posts() ) : ?>
32 32
 							<?php
33
-							while ( have_posts() ) :
34
-								the_post();
35
-								?>
33
+                                   while ( have_posts() ) :
34
+                                        the_post();
35
+                                        ?>
36 36
 
37 37
 								<?php include LSX_HEALTH_PLAN_PATH . '/templates/content-archive-meal.php'; ?>
38 38
 
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 			</main><!-- #main -->
52 52
 
53 53
 			<?php
54
-		} else {
55
-			wp_redirect( $redirect );
56
-			exit;
57
-		}
58
-		?>
54
+          } else {
55
+               wp_redirect( $redirect );
56
+               exit;
57
+          }
58
+          ?>
59 59
 
60 60
 <?php lsx_content_after(); ?>
61 61
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 	$redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id;
15 15
 ?>
16 16
 
17
-	<div id="primary" class="content-area <?php echo esc_attr( lsx_main_class() ); ?>">
17
+	<div id="primary" class="content-area <?php echo esc_attr(lsx_main_class()); ?>">
18 18
 
19 19
 		<?php lsx_content_before(); ?>
20 20
 
21 21
 		<!-- Begining restricted content -->
22 22
 		<?php
23
-		if ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) {
23
+		if (current_user_can('wc_memberships_view_restricted_post_content', $post_id)) {
24 24
 			?>
25 25
 			<main id="main" role="main">
26 26
 
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
 				<div class="post-wrapper archive-plan">
30 30
 					<div class="row">
31
-						<?php if ( have_posts() ) : ?>
31
+						<?php if (have_posts()) : ?>
32 32
 							<?php
33
-							while ( have_posts() ) :
33
+							while (have_posts()) :
34 34
 								the_post();
35 35
 								?>
36 36
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
 						<?php else : ?>
42 42
 
43
-							<?php get_template_part( 'partials/content', 'none' ); ?>
43
+							<?php get_template_part('partials/content', 'none'); ?>
44 44
 
45 45
 						<?php endif; ?>
46 46
 					</div>
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
 			<?php
54 54
 		} else {
55
-			wp_redirect( $redirect );
55
+			wp_redirect($redirect);
56 56
 			exit;
57 57
 		}
58 58
 		?>
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,9 +38,12 @@
 block discarded – undo
38 38
 
39 39
 							<?php endwhile; ?>
40 40
 
41
-						<?php else : ?>
41
+						<?php else {
42
+     : ?>
42 43
 
43
-							<?php get_template_part( 'partials/content', 'none' ); ?>
44
+							<?php get_template_part( 'partials/content', 'none' );
45
+}
46
+?>
44 47
 
45 48
 						<?php endif; ?>
46 49
 					</div>
Please login to merge, or discard this patch.
includes/template-tags.php 2 patches
Indentation   +631 added lines, -631 removed lines patch added patch discarded remove patch
@@ -11,29 +11,29 @@  discard block
 block discarded – undo
11 11
 * @return void
12 12
 */
13 13
 function lsx_health_plan_workout_box() {
14
-	if ( ! post_type_exists( 'workout' ) ) {
15
-		return;
16
-	}
17
-	$intro_text = \lsx_health_plan\functions\get_option( 'workout_intro', false );
18
-	?>
14
+     if ( ! post_type_exists( 'workout' ) ) {
15
+          return;
16
+     }
17
+     $intro_text = \lsx_health_plan\functions\get_option( 'workout_intro', false );
18
+     ?>
19 19
 	<div class="workout-instructions">
20 20
 		<div class="row">
21 21
 			<div class="col-md-12">
22 22
 			<?php
23
-			if ( false !== $intro_text ) {
24
-				?>
23
+               if ( false !== $intro_text ) {
24
+                    ?>
25 25
 				<div class="excerpt">
26 26
 					<p><?php echo wp_kses_post( wpautop( $intro_text ) ); ?></p>
27 27
 				</div>
28 28
 				<?php
29
-			} else {
30
-				?>
29
+               } else {
30
+                    ?>
31 31
 				<div class="content-intro">
32 32
 					<h3><?php esc_html_e( "Don't forget your warm up!", 'lsx-health-plan' ); ?></h3>
33 33
 					<p><?php esc_html_e( 'Be sure to do the warm-up before every workout session.', 'lsx-health-plan' ); ?></p>
34 34
 				</div>
35 35
 				<?php
36
-			} ?>
36
+               } ?>
37 37
 			</div>
38 38
 		</div>
39 39
 	</div>
@@ -46,28 +46,28 @@  discard block
 block discarded – undo
46 46
 * @return void
47 47
 */
48 48
 function lsx_health_plan_meal_box() {
49
-	if ( ! post_type_exists( 'meal' ) ) {
50
-		return;
51
-	}
52
-	?>
49
+     if ( ! post_type_exists( 'meal' ) ) {
50
+          return;
51
+     }
52
+     ?>
53 53
 	<div class="col-md-4" >
54 54
 		<div class="lsx-health-plan-box">
55 55
 			<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>
56 56
 			<div class="spacer"></div>
57 57
 			<?php
58
-			$intro_text = \lsx_health_plan\functions\get_option( 'meal_plan_intro', false );
59
-			if ( false !== $intro_text ) {
60
-				?>
58
+               $intro_text = \lsx_health_plan\functions\get_option( 'meal_plan_intro', false );
59
+               if ( false !== $intro_text ) {
60
+                    ?>
61 61
 				<div class="excerpt">
62 62
 					<p><?php echo wp_kses_post( $intro_text ); ?></p>
63 63
 				</div>
64 64
 				<?php
65
-			}
66
-			$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false );
67
-			if ( false === $meal ) {
68
-				$meal = 'meal';
69
-			}
70
-			?>
65
+               }
66
+               $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false );
67
+               if ( false === $meal ) {
68
+                    $meal = 'meal';
69
+               }
70
+               ?>
71 71
 			<a href="<?php the_permalink(); ?><?php echo esc_attr( $meal ); ?>/" class="btn"><?php esc_html_e( 'View your meal plan', 'lsx-health-plan' ); ?></a>
72 72
 		</div>
73 73
 	</div>
@@ -80,28 +80,28 @@  discard block
 block discarded – undo
80 80
 * @return void
81 81
 */
82 82
 function lsx_health_plan_recipe_box() {
83
-	if ( ! post_type_exists( 'recipe' ) ) {
84
-		return;
85
-	}
86
-	?>
83
+     if ( ! post_type_exists( 'recipe' ) ) {
84
+          return;
85
+     }
86
+     ?>
87 87
 	<div class="col-md-4" >
88 88
 		<div class="lsx-health-plan-box">
89 89
 			<h3 class="title recipes-title title-lined"><?php esc_html_e( 'Recipes', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'recipes.svg' ); ?></h3>
90 90
 			<div class="spacer"></div>
91 91
 			<?php
92
-			$intro_text = \lsx_health_plan\functions\get_option( 'recipes_intro', false );
93
-			if ( false !== $intro_text ) {
94
-				?>
92
+               $intro_text = \lsx_health_plan\functions\get_option( 'recipes_intro', false );
93
+               if ( false !== $intro_text ) {
94
+                    ?>
95 95
 				<div class="excerpt">
96 96
 					<p><?php echo wp_kses_post( $intro_text ); ?></p>
97 97
 				</div>
98 98
 				<?php
99
-			}
100
-			$recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false );
101
-			if ( false === $recipes ) {
102
-				$recipes = 'recipes';
103
-			}
104
-			?>
99
+               }
100
+               $recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false );
101
+               if ( false === $recipes ) {
102
+                    $recipes = 'recipes';
103
+               }
104
+               ?>
105 105
 			<a href="<?php the_permalink(); ?><?php echo esc_attr( $recipes ); ?>/" class="btn"><?php esc_html_e( 'View all recipes', 'lsx-health-plan' ); ?></a>
106 106
 		</div>
107 107
 	</div>
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 * @return void
115 115
 */
116 116
 function lsx_health_plan_downloads_box() {
117
-	global $current_user;
118
-	?>
117
+     global $current_user;
118
+     ?>
119 119
 	<div class="col-md-4 day-download-box" >
120 120
 		<div class="lsx-health-plan-box">
121 121
 			<h3 class="title downloads-title title-lined"><?php esc_html_e( 'Downloads', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'download.svg' ); ?></h3>
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
 			<div class="download-list">
124 124
 				<ul>
125 125
 					<?php
126
-					$downloads = \lsx_health_plan\functions\get_downloads();
127
-					if ( ! empty( $downloads ) ) {
128
-						foreach ( $downloads as $download ) {
129
-							echo wp_kses_post( '<li><a href=""><i class="fa fa-file-pdf"></i>' . do_shortcode( '[download id="' . $download . '"]' ) . '</a></li>' );
130
-						}
131
-					}
132
-					?>
126
+                         $downloads = \lsx_health_plan\functions\get_downloads();
127
+                         if ( ! empty( $downloads ) ) {
128
+                              foreach ( $downloads as $download ) {
129
+                                   echo wp_kses_post( '<li><a href=""><i class="fa fa-file-pdf"></i>' . do_shortcode( '[download id="' . $download . '"]' ) . '</a></li>' );
130
+                              }
131
+                         }
132
+                         ?>
133 133
 				</ul>
134 134
 			</div>
135 135
 		</div>
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
  * @return void
145 145
  */
146 146
 function lsx_health_plan_nav_class( $tab = '' ) {
147
-	$nav_classes = array();
148
-	if ( function_exists( 'is_wc_endpoint_url' ) && 'edit-account' === $tab && is_wc_endpoint_url( 'edit-account' ) ) {
149
-		$nav_classes[] = 'active';
150
-	} elseif ( lsx_health_plan_is_current_tab( $tab ) ) {
151
-		$nav_classes[] = 'active';
152
-	}
153
-	if ( ! empty( $nav_classes ) ) {
154
-		echo wp_kses_post( implode( ' ', $nav_classes ) );
155
-	}
147
+     $nav_classes = array();
148
+     if ( function_exists( 'is_wc_endpoint_url' ) && 'edit-account' === $tab && is_wc_endpoint_url( 'edit-account' ) ) {
149
+          $nav_classes[] = 'active';
150
+     } elseif ( lsx_health_plan_is_current_tab( $tab ) ) {
151
+          $nav_classes[] = 'active';
152
+     }
153
+     if ( ! empty( $nav_classes ) ) {
154
+          echo wp_kses_post( implode( ' ', $nav_classes ) );
155
+     }
156 156
 }
157 157
 
158 158
 /**
@@ -161,29 +161,29 @@  discard block
 block discarded – undo
161 161
  * @return void
162 162
  */
163 163
 function lsx_health_plan_my_profile_tabs() {
164
-	?>
164
+     ?>
165 165
 	<div id="account-nav">
166 166
 		<ul class="nav nav-pills">
167 167
 			<li class="
168 168
 			<?php
169
-			if ( ( function_exists( 'is_wc_endpoint_url' ) && ! is_wc_endpoint_url( 'edit-account' ) ) || ! function_exists( 'is_wc_endpoint_url' ) ) {
170
-				echo esc_attr( 'active' );
171
-			}
172
-			?>
169
+               if ( ( function_exists( 'is_wc_endpoint_url' ) && ! is_wc_endpoint_url( 'edit-account' ) ) || ! function_exists( 'is_wc_endpoint_url' ) ) {
170
+                    echo esc_attr( 'active' );
171
+               }
172
+               ?>
173 173
 			"><a class="my-plan-tab" href="<?php the_permalink(); ?>"><?php esc_html_e( 'My Plans', 'lsx-health-plan' ); ?></a></li>
174 174
 			<?php
175
-			if ( function_exists( 'WC' ) ) {
176
-				?>
175
+               if ( function_exists( 'WC' ) ) {
176
+                    ?>
177 177
 				<li class="
178 178
 				<?php
179
-				if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'edit-account' ) ) {
180
-					echo esc_attr( 'active' );
181
-				}
182
-				?>
179
+                    if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'edit-account' ) ) {
180
+                         echo esc_attr( 'active' );
181
+                    }
182
+                    ?>
183 183
 				"><a class="account-details-tab" href="<?php the_permalink(); ?>edit-account/"><?php esc_html_e( 'Account Details', 'lsx-health-plan' ); ?></a></li>
184 184
 				<?php
185
-			}
186
-			?>
185
+               }
186
+               ?>
187 187
 			<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>
188 188
 		</ul>
189 189
 	</div>
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
  * @return void
197 197
  */
198 198
 function lsx_health_plan_my_profile_box() {
199
-	?>
199
+     ?>
200 200
 	<div class="lsx-health-plan my-profile-block wp-block-cover alignfull">
201 201
 		<div class="wp-block-cover__inner-container">
202 202
 			<h2><?php esc_html_e( 'My Dashboard', 'lsx-health-plan' ); ?></h2>
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
 						<div class="profile-navigation">
207 207
 							<div class="profile-photo">
208 208
 							<?php
209
-								global $current_user;
210
-								if ( function_exists( 'WC' ) ) {
211
-									get_current_user();
212
-								}
213
-								if ( class_exists( 'WP_User_Avatar_Setup' ) ) {
214
-									echo get_avatar( $current_user->ID, 240 );
215
-								}
216
-								?>
209
+                                        global $current_user;
210
+                                        if ( function_exists( 'WC' ) ) {
211
+                                             get_current_user();
212
+                                        }
213
+                                        if ( class_exists( 'WP_User_Avatar_Setup' ) ) {
214
+                                             echo get_avatar( $current_user->ID, 240 );
215
+                                        }
216
+                                        ?>
217 217
 							</div>
218 218
 						</div>
219 219
 					<?php } ?>
@@ -221,88 +221,88 @@  discard block
 block discarded – undo
221 221
 						<div class="profile-details">
222 222
 							<h1 class="title-lined has-text-color"><?php echo esc_html( $current_user->display_name ); ?></h1>
223 223
 							<?php
224
-							$disable_stats = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
225
-							if ( 'on' !== $disable_stats && function_exists( 'WC' ) ) {
224
+                                   $disable_stats = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
225
+                                   if ( 'on' !== $disable_stats && function_exists( 'WC' ) ) {
226 226
 
227
-								$is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false );
228
-								$is_height_disabled = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false );
229
-								$is_waist_disabled  = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false );
230
-								$is_bmi_disabled    = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false );
227
+                                        $is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false );
228
+                                        $is_height_disabled = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false );
229
+                                        $is_waist_disabled  = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false );
230
+                                        $is_bmi_disabled    = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false );
231 231
 
232
-								$weight = get_user_meta( get_current_user_id(), 'weight', true );
233
-								$waist  = get_user_meta( get_current_user_id(), 'waist', true );
234
-								$height = get_user_meta( get_current_user_id(), 'height', true );
232
+                                        $weight = get_user_meta( get_current_user_id(), 'weight', true );
233
+                                        $waist  = get_user_meta( get_current_user_id(), 'waist', true );
234
+                                        $height = get_user_meta( get_current_user_id(), 'height', true );
235 235
 
236
-								$height_m = 0;
237
-								if ( is_numeric( $height ) ) {
238
-									$height_m = $height / 100;
239
-								}
236
+                                        $height_m = 0;
237
+                                        if ( is_numeric( $height ) ) {
238
+                                             $height_m = $height / 100;
239
+                                        }
240 240
 
241
-								if ( 1 < $weight && 1 < $height_m ) {
242
-									$bmi = $weight / ( $height_m * $height_m );
243
-									$bmi = number_format( $bmi, 1 );
244
-								} else {
245
-									$bmi = __( 'Add more data', 'lsx-health-plan' );
246
-								}
241
+                                        if ( 1 < $weight && 1 < $height_m ) {
242
+                                             $bmi = $weight / ( $height_m * $height_m );
243
+                                             $bmi = number_format( $bmi, 1 );
244
+                                        } else {
245
+                                             $bmi = __( 'Add more data', 'lsx-health-plan' );
246
+                                        }
247 247
 
248
-								?>
248
+                                        ?>
249 249
 
250 250
 								<div>
251 251
 									<?php if ( 'on' !== $is_weight_disabled ) { ?>
252 252
 										<span><strong><?php esc_html_e( 'Weight:', 'lsx-health-plan' ); ?></strong>
253 253
 										<?php
254
-										if ( '' !== $weight ) {
255
-											echo wp_kses_post( $weight . ' kg' );
256
-										} else {
257
-											echo '/';
258
-										}
259
-										?>
254
+                                                  if ( '' !== $weight ) {
255
+                                                       echo wp_kses_post( $weight . ' kg' );
256
+                                                  } else {
257
+                                                       echo '/';
258
+                                                  }
259
+                                                  ?>
260 260
 										</span>
261 261
 									<?php }
262
-									if ( 'on' !== $is_waist_disabled ) {
263
-										?>
262
+                                             if ( 'on' !== $is_waist_disabled ) {
263
+                                                  ?>
264 264
 										<span><strong><?php esc_html_e( 'Waist:', 'lsx-health-plan' ); ?></strong>
265 265
 										<?php
266
-										if ( '' !== $waist ) {
267
-											echo wp_kses_post( $waist . ' cm' );
268
-										} else {
269
-											echo '/';
270
-										}
271
-										?>
266
+                                                  if ( '' !== $waist ) {
267
+                                                       echo wp_kses_post( $waist . ' cm' );
268
+                                                  } else {
269
+                                                       echo '/';
270
+                                                  }
271
+                                                  ?>
272 272
 										</span>
273 273
 									<?php }
274
-									if ( 'on' !== $is_bmi_disabled ) {
275
-										?>
274
+                                             if ( 'on' !== $is_bmi_disabled ) {
275
+                                                  ?>
276 276
 										<span><strong><?php esc_html_e( 'BMI:', 'lsx-health-plan' ); ?></strong>
277 277
 										<?php
278
-										if ( '' !== $bmi ) {
279
-											echo wp_kses_post( $bmi );
280
-										} else {
281
-											echo '/';
282
-										}
283
-										?>
278
+                                                  if ( '' !== $bmi ) {
279
+                                                       echo wp_kses_post( $bmi );
280
+                                                  } else {
281
+                                                       echo '/';
282
+                                                  }
283
+                                                  ?>
284 284
 										</span>
285 285
 									<?php } ?>
286 286
 								</div>
287 287
 							<?php
288
-							}
288
+                                   }
289 289
 
290
-							// Only display the edit account link if woocommerce is active.
291
-							if ( function_exists( 'WC' ) ) {
292
-								?>
290
+                                   // Only display the edit account link if woocommerce is active.
291
+                                   if ( function_exists( 'WC' ) ) {
292
+                                        ?>
293 293
 								<div class="edit-profile">
294 294
 									<?php
295
-									if ( function_exists( 'wc_get_page_id' ) ) {
296
-										$url_id = wc_get_page_id( 'myaccount' );
297
-									} else {
298
-										$url_id = '';
299
-									}
300
-									?>
295
+                                             if ( function_exists( 'wc_get_page_id' ) ) {
296
+                                                  $url_id = wc_get_page_id( 'myaccount' );
297
+                                             } else {
298
+                                                  $url_id = '';
299
+                                             }
300
+                                             ?>
301 301
 									<a href="<?php echo esc_url( get_permalink( $url_id ) ); ?>edit-account/"><?php esc_html_e( 'Edit', 'lsx-health-plan' ); ?></a>
302 302
 								</div>
303 303
 								<?php
304
-							}
305
-							?>
304
+                                   }
305
+                                   ?>
306 306
 						</div>
307 307
 					<?php } ?>
308 308
 				</section>
@@ -318,65 +318,65 @@  discard block
 block discarded – undo
318 318
  * @return void
319 319
  */
320 320
 function lsx_health_plan_all_plans_block() {
321
-	global $post, $product;
322
-
323
-	$args = array(
324
-		'orderby'        => 'menu_order',
325
-		'order'          => 'ASC',
326
-		'post_type'      => 'plan',
327
-		'nopagin'        => true,
328
-		'post_parent'    => 0,
329
-	);
330
-
331
-	if ( function_exists( '\lsx_health_plan\functions\woocommerce\get_membership_products' ) ) {
332
-		$product_ids = \lsx_health_plan\functions\woocommerce\get_membership_products();
333
-		if ( ! empty( $product_ids ) ) {
334
-			$args['meta_query'] = array(
335
-				'relation' => 'OR',
336
-				array(
337
-					'key'     => '_plan_product_id',
338
-					'value'   => $product_ids,
339
-					'compare' => 'IN',
340
-				),
341
-				array(
342
-					'key'     => '_plan_product_id',
343
-					'compare' => 'NOT EXISTS',
344
-				),
345
-			);
346
-		}
347
-	}
348
-
349
-	$the_query = new WP_Query( $args );
350
-	?>
321
+     global $post, $product;
322
+
323
+     $args = array(
324
+          'orderby'        => 'menu_order',
325
+          'order'          => 'ASC',
326
+          'post_type'      => 'plan',
327
+          'nopagin'        => true,
328
+          'post_parent'    => 0,
329
+     );
330
+
331
+     if ( function_exists( '\lsx_health_plan\functions\woocommerce\get_membership_products' ) ) {
332
+          $product_ids = \lsx_health_plan\functions\woocommerce\get_membership_products();
333
+          if ( ! empty( $product_ids ) ) {
334
+               $args['meta_query'] = array(
335
+                    'relation' => 'OR',
336
+                    array(
337
+                         'key'     => '_plan_product_id',
338
+                         'value'   => $product_ids,
339
+                         'compare' => 'IN',
340
+                    ),
341
+                    array(
342
+                         'key'     => '_plan_product_id',
343
+                         'compare' => 'NOT EXISTS',
344
+                    ),
345
+               );
346
+          }
347
+     }
348
+
349
+     $the_query = new WP_Query( $args );
350
+     ?>
351 351
 	<div class="all-plans-block plan-grid block-all-plans-block">
352 352
 		<div class="row">
353 353
 			<?php
354
-			if ( $the_query->have_posts() ) :
355
-				while ( $the_query->have_posts() ) :
356
-					$the_query->the_post();
357
-					lsx_entry_before();
358
-					$completed_class = '';
359
-					$linked_product  = false;
360
-					$restricted      = false;
361
-					$product         = null;
362
-					if ( function_exists( 'lsx_health_plan\functions\woocommerce\plan_has_products' ) && \lsx_health_plan\functions\woocommerce\plan_has_products() ) {
363
-						$products       = \lsx_health_plan\functions\woocommerce\get_plan_products();
364
-						$linked_product = wc_get_product( $products[0] );
365
-						$product        = $linked_product;
366
-					}
367
-					if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) {
368
-						$restricted = wc_memberships_is_post_content_restricted( get_the_ID() ) && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() );
369
-					}
370
-
371
-					if ( lsx_health_plan_is_plan_complete() ) {
372
-						$completed_class = 'completed';
373
-					}
374
-					$round_progress     = '';
375
-					$completed_progress = '100';
376
-					if ( false === $restricted ) {
377
-						$round_progress = round( \lsx_health_plan\functions\get_progress( get_the_ID() ), 0 );
378
-					}
379
-					?>
354
+               if ( $the_query->have_posts() ) :
355
+                    while ( $the_query->have_posts() ) :
356
+                         $the_query->the_post();
357
+                         lsx_entry_before();
358
+                         $completed_class = '';
359
+                         $linked_product  = false;
360
+                         $restricted      = false;
361
+                         $product         = null;
362
+                         if ( function_exists( 'lsx_health_plan\functions\woocommerce\plan_has_products' ) && \lsx_health_plan\functions\woocommerce\plan_has_products() ) {
363
+                              $products       = \lsx_health_plan\functions\woocommerce\get_plan_products();
364
+                              $linked_product = wc_get_product( $products[0] );
365
+                              $product        = $linked_product;
366
+                         }
367
+                         if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) {
368
+                              $restricted = wc_memberships_is_post_content_restricted( get_the_ID() ) && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() );
369
+                         }
370
+
371
+                         if ( lsx_health_plan_is_plan_complete() ) {
372
+                              $completed_class = 'completed';
373
+                         }
374
+                         $round_progress     = '';
375
+                         $completed_progress = '100';
376
+                         if ( false === $restricted ) {
377
+                              $round_progress = round( \lsx_health_plan\functions\get_progress( get_the_ID() ), 0 );
378
+                         }
379
+                         ?>
380 380
 					<div class="col-xs-12 col-sm-6 col-md-4">
381 381
 						<article class="lsx-slot lsx-hp-shadow <?php echo esc_html( 'progress-') . $round_progress; ?>">
382 382
 							<div class="plan-feature-img">
@@ -385,45 +385,45 @@  discard block
 block discarded – undo
385 385
 								<?php } ?>
386 386
 								<a href="<?php echo esc_url( get_permalink() ); ?>">
387 387
 								<?php
388
-								$featured_image = get_the_post_thumbnail();
389
-								if ( ! empty( $featured_image ) && '' !== $featured_image ) {
390
-									the_post_thumbnail( 'lsx-thumbnail', array(
391
-										'class' => 'aligncenter',
392
-									) );
393
-								} else {
394
-									?>
388
+                                        $featured_image = get_the_post_thumbnail();
389
+                                        if ( ! empty( $featured_image ) && '' !== $featured_image ) {
390
+                                             the_post_thumbnail( 'lsx-thumbnail', array(
391
+                                                  'class' => 'aligncenter',
392
+                                             ) );
393
+                                        } else {
394
+                                             ?>
395 395
 									<img loading="lazy"  class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
396 396
 									<?php
397
-								}
398
-								?>
397
+                                        }
398
+                                        ?>
399 399
 								</a>
400 400
 							</div>
401 401
 							<div class="content-box plan-content-box">
402 402
 								<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>
403 403
 								<?php
404
-									echo wp_kses_post( \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) );
405
-								?>
404
+                                             echo wp_kses_post( \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) );
405
+                                        ?>
406 406
 								<?php
407
-								if ( false !== $linked_product && false !== $restricted ) {
408
-									echo wp_kses_post( $linked_product->get_price_html() );
409
-								}
410
-								?>
407
+                                        if ( false !== $linked_product && false !== $restricted ) {
408
+                                             echo wp_kses_post( $linked_product->get_price_html() );
409
+                                        }
410
+                                        ?>
411 411
 								<div class="excerpt">
412 412
 									<?php
413
-									if ( ! has_excerpt() ) {
414
-										$content = wp_trim_words( get_the_content(), 20 );
415
-										$content = '<p>' . $content . '</pre>';
416
-									} else {
417
-										$content = apply_filters( 'the_excerpt', get_the_excerpt() );
418
-									}
419
-									echo wp_kses_post( $content );
420
-									?>
413
+                                             if ( ! has_excerpt() ) {
414
+                                                  $content = wp_trim_words( get_the_content(), 20 );
415
+                                                  $content = '<p>' . $content . '</pre>';
416
+                                             } else {
417
+                                                  $content = apply_filters( 'the_excerpt', get_the_excerpt() );
418
+                                             }
419
+                                             echo wp_kses_post( $content );
420
+                                             ?>
421 421
 								</div>
422 422
 								<?php
423
-								if ( false === $restricted ) {
424
-									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>' . $round_progress . '%</span></span>' );
425
-								}
426
-								?>
423
+                                        if ( false === $restricted ) {
424
+                                             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>' . $round_progress . '%</span></span>' );
425
+                                        }
426
+                                        ?>
427 427
 							</div>
428 428
 						</article>
429 429
 					</div>
@@ -442,36 +442,36 @@  discard block
 block discarded – undo
442 442
  * @return void
443 443
  */
444 444
 function lsx_health_plan_day_plan_block( $args = array() ) {
445
-	$defaults = array(
446
-		'plan' => '',
447
-	);
448
-	$args     = wp_parse_args( $args, $defaults );
449
-
450
-	if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
451
-		$sections = \lsx_health_plan\functions\plan\get_sections();
452
-		?>
445
+     $defaults = array(
446
+          'plan' => '',
447
+     );
448
+     $args     = wp_parse_args( $args, $defaults );
449
+
450
+     if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
451
+          $sections = \lsx_health_plan\functions\plan\get_sections();
452
+          ?>
453 453
 		<div class="daily-plan-block day-grid">
454 454
 			<?php
455
-			foreach ( $sections as $section_key => $section_values ) {
456
-				$defaults    = array(
457
-					'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
458
-				);
459
-				$section_args = wp_parse_args( $section_values, $defaults );
460
-
461
-				$completed_class = '';
462
-				if ( lsx_health_plan_is_day_complete() ) {
463
-					$completed_class = 'completed';
464
-				}
465
-				?>
455
+               foreach ( $sections as $section_key => $section_values ) {
456
+                    $defaults    = array(
457
+                         'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
458
+                    );
459
+                    $section_args = wp_parse_args( $section_values, $defaults );
460
+
461
+                    $completed_class = '';
462
+                    if ( lsx_health_plan_is_day_complete() ) {
463
+                         $completed_class = 'completed';
464
+                    }
465
+                    ?>
466 466
 				<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 ); ?>">
467 467
 					<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
468 468
 				</a>
469 469
 				<?php
470
-			}
471
-			?>
470
+               }
471
+               ?>
472 472
 		</div>
473 473
 		<?php
474
-	}
474
+     }
475 475
 }
476 476
 
477 477
 /**
@@ -481,44 +481,44 @@  discard block
 block discarded – undo
481 481
  * @return void
482 482
  */
483 483
 function lsx_health_plan_week_plan_block( $args = array() ) {
484
-	$defaults = array(
485
-		'show_downloads' => false,
486
-		'plan'           => '',
487
-	);
488
-	$args     = wp_parse_args( $args, $defaults );
489
-
490
-	if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
491
-		$groups = \lsx_health_plan\functions\plan\get_sections( true );
492
-
493
-		if ( ! empty( $groups ) ) {
494
-			$counter    = 1;
495
-			$group_open = false;
496
-
497
-			foreach ( $groups as $group_key => $sections ) {
498
-				$collapse_class = '';
499
-				$group_title    = \lsx_health_plan\functions\plan\get_group_title( $sections );
500
-
501
-				// Determine if the current week is complete.
502
-				$day_ids = wp_list_pluck( $sections, 'title' );
503
-				if ( false === $group_open ) {
504
-					if ( 1 === $counter && ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
505
-						$collapse_class = 'in';
506
-						$group_open   = true;
507
-					} elseif ( ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
508
-						$collapse_class = 'in';
509
-						$group_open   = true;
510
-					}
511
-				}
512
-
513
-				// Determine if there are any weekly downloads.
514
-				$week_downloads_view = '';
515
-				if ( isset( $args['show_downloads'] ) && false !== $args['show_downloads'] ) {
516
-					$weekly_downloads = \lsx_health_plan\functions\get_weekly_downloads( $group_key );
517
-					if ( ! empty( $weekly_downloads ) ) {
518
-						$week_downloads_view = 'week-downloads-view-on';
519
-					}
520
-				}
521
-				?>
484
+     $defaults = array(
485
+          'show_downloads' => false,
486
+          'plan'           => '',
487
+     );
488
+     $args     = wp_parse_args( $args, $defaults );
489
+
490
+     if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
491
+          $groups = \lsx_health_plan\functions\plan\get_sections( true );
492
+
493
+          if ( ! empty( $groups ) ) {
494
+               $counter    = 1;
495
+               $group_open = false;
496
+
497
+               foreach ( $groups as $group_key => $sections ) {
498
+                    $collapse_class = '';
499
+                    $group_title    = \lsx_health_plan\functions\plan\get_group_title( $sections );
500
+
501
+                    // Determine if the current week is complete.
502
+                    $day_ids = wp_list_pluck( $sections, 'title' );
503
+                    if ( false === $group_open ) {
504
+                         if ( 1 === $counter && ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
505
+                              $collapse_class = 'in';
506
+                              $group_open   = true;
507
+                         } elseif ( ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
508
+                              $collapse_class = 'in';
509
+                              $group_open   = true;
510
+                         }
511
+                    }
512
+
513
+                    // Determine if there are any weekly downloads.
514
+                    $week_downloads_view = '';
515
+                    if ( isset( $args['show_downloads'] ) && false !== $args['show_downloads'] ) {
516
+                         $weekly_downloads = \lsx_health_plan\functions\get_weekly_downloads( $group_key );
517
+                         if ( ! empty( $weekly_downloads ) ) {
518
+                              $week_downloads_view = 'week-downloads-view-on';
519
+                         }
520
+                    }
521
+                    ?>
522 522
 				<div class="daily-plan-block week-grid">
523 523
 					<a href="#group-<?php echo esc_attr( $group_key ); ?>" data-toggle="collapse" class="week-title"><?php echo esc_attr( $group_title ); ?></a>
524 524
 					<div id="group-<?php echo esc_attr( $group_key ); ?>" class="week-row collapse <?php echo esc_attr( $collapse_class ); ?>">
@@ -532,46 +532,46 @@  discard block
 block discarded – undo
532 532
 								<div class="week-meals-recipes-box-inner">
533 533
 								<?php
534 534
 
535
-								foreach ( $sections as $section_key => $section_values ) {
535
+                                        foreach ( $sections as $section_key => $section_values ) {
536 536
 
537
-									$defaults    = array(
538
-										'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
539
-									);
540
-									$section_args = wp_parse_args( $section_values, $defaults );
537
+                                             $defaults    = array(
538
+                                                  'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
539
+                                             );
540
+                                             $section_args = wp_parse_args( $section_values, $defaults );
541 541
 
542
-									$completed_class = '';
543
-									if ( lsx_health_plan_is_day_complete( $args['plan'], $section_args['title'] ) ) {
544
-										$completed_class = 'completed';
545
-									}
546
-									if ( $section_args['rest_day_enabled'] && ! $section_args['connected_meals'] ) {
547
-										?>
542
+                                             $completed_class = '';
543
+                                             if ( lsx_health_plan_is_day_complete( $args['plan'], $section_args['title'] ) ) {
544
+                                                  $completed_class = 'completed';
545
+                                             }
546
+                                             if ( $section_args['rest_day_enabled'] && ! $section_args['connected_meals'] ) {
547
+                                                  ?>
548 548
 										<span class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>">
549 549
 											<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
550 550
 										</span>
551 551
 										<?php
552
-									} else {
553
-										?>
552
+                                             } else {
553
+                                                  ?>
554 554
 										<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 ); ?>">
555 555
 											<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
556 556
 										</a>
557 557
 										<?php
558
-									}
559
-								}
560
-								?>
558
+                                             }
559
+                                        }
560
+                                        ?>
561 561
 								</div>
562 562
 							</div>
563 563
 							<?php
564
-							if ( ! empty( $week_downloads_view ) ) {
565
-								lsx_health_plan_weekly_downloads( $weekly_downloads );
566
-							}
567
-							?>
564
+                                   if ( ! empty( $week_downloads_view ) ) {
565
+                                        lsx_health_plan_weekly_downloads( $weekly_downloads );
566
+                                   }
567
+                                   ?>
568 568
 						</div>
569 569
 					</div>
570 570
 				</div>
571 571
 				<?php
572
-			}
573
-		}
574
-	}
572
+               }
573
+          }
574
+     }
575 575
 }
576 576
 
577 577
 /**
@@ -581,22 +581,22 @@  discard block
 block discarded – undo
581 581
  * @return void
582 582
  */
583 583
 function lsx_health_plan_weekly_downloads( $weekly_downloads = array() ) {
584
-	if ( ! empty( $weekly_downloads ) ) {
585
-		?>
584
+     if ( ! empty( $weekly_downloads ) ) {
585
+          ?>
586 586
 		<div class="week-download-box">
587 587
 			<h3 class="title"><?php lsx_get_svg_icon( 'download.svg' ); ?><?php echo esc_html_e( 'Downloads', 'lsx-health-plan' ); ?></h3>
588 588
 			<ul class="week-download-box-list">
589 589
 				<?php
590
-				foreach ( $weekly_downloads as $weekly_download ) {
591
-					?>
590
+                    foreach ( $weekly_downloads as $weekly_download ) {
591
+                         ?>
592 592
 					<li><?php echo wp_kses_post( do_shortcode( '[download id="' . $weekly_download . '"]' ) ); ?></li>
593 593
 					<?php
594
-				}
595
-				?>
594
+                    }
595
+                    ?>
596 596
 			</ul>
597 597
 		</div>
598 598
 		<?php
599
-	}
599
+     }
600 600
 }
601 601
 
602 602
 /**
@@ -605,9 +605,9 @@  discard block
 block discarded – undo
605 605
  * @return void
606 606
  */
607 607
 function lsx_health_plan_items( $args = array() ) {
608
-	global $shortcode_args;
609
-	$shortcode_args = $args;
610
-	include LSX_HEALTH_PLAN_PATH . '/templates/partials/shortcode-loop.php';
608
+     global $shortcode_args;
609
+     $shortcode_args = $args;
610
+     include LSX_HEALTH_PLAN_PATH . '/templates/partials/shortcode-loop.php';
611 611
 }
612 612
 
613 613
 /**
@@ -616,10 +616,10 @@  discard block
 block discarded – undo
616 616
  * @return void
617 617
  */
618 618
 function lsx_health_plan_featured_video_block() {
619
-	if ( ! post_type_exists( 'video' ) ) {
620
-		return;
621
-	}
622
-	include LSX_HEALTH_PLAN_PATH . '/templates/featured-videos.php';
619
+     if ( ! post_type_exists( 'video' ) ) {
620
+          return;
621
+     }
622
+     include LSX_HEALTH_PLAN_PATH . '/templates/featured-videos.php';
623 623
 }
624 624
 
625 625
 /**
@@ -628,10 +628,10 @@  discard block
 block discarded – undo
628 628
  * @return void
629 629
  */
630 630
 function lsx_health_plan_featured_recipes_block() {
631
-	if ( ! post_type_exists( 'recipe' ) ) {
632
-		return;
633
-	}
634
-	include LSX_HEALTH_PLAN_PATH . '/templates/featured-recipes.php';
631
+     if ( ! post_type_exists( 'recipe' ) ) {
632
+          return;
633
+     }
634
+     include LSX_HEALTH_PLAN_PATH . '/templates/featured-recipes.php';
635 635
 }
636 636
 
637 637
 /**
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
  * @return void
641 641
  */
642 642
 function lsx_health_plan_featured_tips_block() {
643
-	include LSX_HEALTH_PLAN_PATH . '/templates/featured-tips.php';
643
+     include LSX_HEALTH_PLAN_PATH . '/templates/featured-tips.php';
644 644
 }
645 645
 
646 646
 /**
@@ -650,11 +650,11 @@  discard block
 block discarded – undo
650 650
  * @return void
651 651
  */
652 652
 function lsx_health_plan_day_button() {
653
-	if ( lsx_health_plan_is_day_complete() ) {
654
-		lsx_health_plan_unlock_button();
655
-	} else {
656
-		lsx_health_plan_complete_button();
657
-	}
653
+     if ( lsx_health_plan_is_day_complete() ) {
654
+          lsx_health_plan_unlock_button();
655
+     } else {
656
+          lsx_health_plan_complete_button();
657
+     }
658 658
 }
659 659
 
660 660
 /**
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
  * @return void
664 664
  */
665 665
 function lsx_health_plan_complete_button() {
666
-	?>
666
+     ?>
667 667
 	<div class="single-plan-inner-buttons">
668 668
 		<form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn">
669 669
 			<?php wp_nonce_field( 'complete', 'lsx-health-plan-actions' ); ?>
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
  * @return void
682 682
  */
683 683
 function lsx_health_plan_unlock_button() {
684
-	?>
684
+     ?>
685 685
 	<div class="single-plan-inner-buttons">
686 686
 		<form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn">
687 687
 			<?php wp_nonce_field( 'unlock', 'lsx-health-plan-actions' ); ?>
@@ -700,10 +700,10 @@  discard block
 block discarded – undo
700 700
  * @return void
701 701
  */
702 702
 function lsx_health_plan_single_nav() {
703
-	$tab_template_path = apply_filters( 'lsx_health_plan_single_nav_path', LSX_HEALTH_PLAN_PATH . '/templates/single-plan-tabs.php' );
704
-	if ( '' !== $tab_template_path ) {
705
-		require $tab_template_path;
706
-	}
703
+     $tab_template_path = apply_filters( 'lsx_health_plan_single_nav_path', LSX_HEALTH_PLAN_PATH . '/templates/single-plan-tabs.php' );
704
+     if ( '' !== $tab_template_path ) {
705
+          require $tab_template_path;
706
+     }
707 707
 }
708 708
 
709 709
 /**
@@ -713,32 +713,32 @@  discard block
 block discarded – undo
713 713
  * @return void
714 714
  */
715 715
 function lsx_health_plan_single_tabs() {
716
-	$endpoint = get_query_var( 'endpoint' );
717
-	switch ( $endpoint ) {
718
-		case 'meal':
719
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-meal.php';
720
-			break;
721
-
722
-		case 'recipes':
723
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-recipes.php';
724
-			break;
725
-
726
-		case 'workout':
727
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-workout.php';
728
-			break;
729
-
730
-		case 'warm-up':
731
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-warm-up.php';
732
-			break;
733
-
734
-		default:
735
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-plan.php';
736
-			break;
737
-	}
738
-	$tab_template_path = apply_filters( 'lsx_health_plan_single_tab_path', $tab_template_path );
739
-	if ( '' !== $tab_template_path ) {
740
-		include $tab_template_path;
741
-	}
716
+     $endpoint = get_query_var( 'endpoint' );
717
+     switch ( $endpoint ) {
718
+          case 'meal':
719
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-meal.php';
720
+               break;
721
+
722
+          case 'recipes':
723
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-recipes.php';
724
+               break;
725
+
726
+          case 'workout':
727
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-workout.php';
728
+               break;
729
+
730
+          case 'warm-up':
731
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-warm-up.php';
732
+               break;
733
+
734
+          default:
735
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-plan.php';
736
+               break;
737
+     }
738
+     $tab_template_path = apply_filters( 'lsx_health_plan_single_tab_path', $tab_template_path );
739
+     if ( '' !== $tab_template_path ) {
740
+          include $tab_template_path;
741
+     }
742 742
 }
743 743
 
744 744
 /**
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
  * @return void
748 748
  */
749 749
 function lsx_health_plan_recipe_data() {
750
-	include LSX_HEALTH_PLAN_PATH . '/templates/table-recipe-data.php';
750
+     include LSX_HEALTH_PLAN_PATH . '/templates/table-recipe-data.php';
751 751
 }
752 752
 
753 753
 /**
@@ -756,11 +756,11 @@  discard block
 block discarded – undo
756 756
  * @return recipe_type
757 757
  */
758 758
 function lsx_health_plan_recipe_type() {
759
-	$term_obj_list = get_the_terms( get_the_ID(), 'recipe-type' );
760
-	$recipe_type   = $term_obj_list[0]->name;
761
-	if ( ! empty( $recipe_type ) ) {
762
-		return $recipe_type;
763
-	}
759
+     $term_obj_list = get_the_terms( get_the_ID(), 'recipe-type' );
760
+     $recipe_type   = $term_obj_list[0]->name;
761
+     if ( ! empty( $recipe_type ) ) {
762
+          return $recipe_type;
763
+     }
764 764
 }
765 765
 
766 766
 /**
@@ -771,35 +771,35 @@  discard block
 block discarded – undo
771 771
  * @return void
772 772
  */
773 773
 function lsx_health_plan_workout_video_play_button( $m, $group, $echo = true ) {
774
-	$workout_video = '';
775
-	$giphy         = '';
776
-	$youtube       = '';
777
-	if ( isset( $group['connected_videos'] ) && '' !== $group['connected_videos'] ) {
778
-		$workout_video = esc_html( $group['connected_videos'] );
779
-		$giphy         = get_post_meta( $workout_video, 'video_giphy_source', true );
780
-		$youtube       = esc_url( get_post_meta( $workout_video, 'video_youtube_source', 1 ) );
781
-		$content       = get_post_field( 'post_content', $workout_video );
782
-		$play_button   = '<button data-toggle="modal" data-target="#workout-video-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>';
783
-
784
-		$modal_body = '';
785
-		if ( ! empty( $giphy ) ) {
786
-			$giphy      = \lsx_health_plan\functions\get_video_url( $giphy );
787
-			$modal_body = $giphy; // WPCS: XSS OK.
788
-		} elseif ( ! empty( $youtube ) ) {
789
-			$modal_body = wp_oembed_get( $youtube, array( // WPCS: XSS OK.
790
-				'width' => 480,
791
-			) );
792
-		}
793
-		$modal_body .= '<h5 class="modal-title title-lined">' . $group['name'] . '</h5>';
794
-		$modal_body .= $content;
795
-		\lsx_health_plan\functions\register_modal( 'workout-video-modal-' . $m, '', $modal_body );
796
-
797
-		if ( true === $echo ) {
798
-			echo wp_kses_post( $play_button );
799
-		} else {
800
-			return $play_button;
801
-		}
802
-	}
774
+     $workout_video = '';
775
+     $giphy         = '';
776
+     $youtube       = '';
777
+     if ( isset( $group['connected_videos'] ) && '' !== $group['connected_videos'] ) {
778
+          $workout_video = esc_html( $group['connected_videos'] );
779
+          $giphy         = get_post_meta( $workout_video, 'video_giphy_source', true );
780
+          $youtube       = esc_url( get_post_meta( $workout_video, 'video_youtube_source', 1 ) );
781
+          $content       = get_post_field( 'post_content', $workout_video );
782
+          $play_button   = '<button data-toggle="modal" data-target="#workout-video-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>';
783
+
784
+          $modal_body = '';
785
+          if ( ! empty( $giphy ) ) {
786
+               $giphy      = \lsx_health_plan\functions\get_video_url( $giphy );
787
+               $modal_body = $giphy; // WPCS: XSS OK.
788
+          } elseif ( ! empty( $youtube ) ) {
789
+               $modal_body = wp_oembed_get( $youtube, array( // WPCS: XSS OK.
790
+                    'width' => 480,
791
+               ) );
792
+          }
793
+          $modal_body .= '<h5 class="modal-title title-lined">' . $group['name'] . '</h5>';
794
+          $modal_body .= $content;
795
+          \lsx_health_plan\functions\register_modal( 'workout-video-modal-' . $m, '', $modal_body );
796
+
797
+          if ( true === $echo ) {
798
+               echo wp_kses_post( $play_button );
799
+          } else {
800
+               return $play_button;
801
+          }
802
+     }
803 803
 }
804 804
 
805 805
 /**
@@ -808,21 +808,21 @@  discard block
 block discarded – undo
808 808
  * @return void
809 809
  */
810 810
 function lsx_health_plan_recipe_archive_description() {
811
-	$description = '';
812
-	if ( is_post_type_archive( 'recipe' ) ) {
813
-		$description = \lsx_health_plan\functions\get_option( 'recipe_archive_description', '' );
814
-	} elseif ( is_post_type_archive( 'exercise' ) ) {
815
-		$description = \lsx_health_plan\functions\get_option( 'exercise_archive_description', '' );
816
-	} elseif ( is_tax() ) {
817
-		$description = get_the_archive_description();
818
-	}
819
-	if ( '' !== $description ) {
820
-		?>
811
+     $description = '';
812
+     if ( is_post_type_archive( 'recipe' ) ) {
813
+          $description = \lsx_health_plan\functions\get_option( 'recipe_archive_description', '' );
814
+     } elseif ( is_post_type_archive( 'exercise' ) ) {
815
+          $description = \lsx_health_plan\functions\get_option( 'exercise_archive_description', '' );
816
+     } elseif ( is_tax() ) {
817
+          $description = get_the_archive_description();
818
+     }
819
+     if ( '' !== $description ) {
820
+          ?>
821 821
 		<div class="lsx-hp-archive-description row">
822 822
 			<div class="col-xs-12 description-wrapper"><?php echo wp_kses_post( wpautop( $description ) ); ?></div>
823 823
 		</div>
824 824
 		<?php
825
-	}
825
+     }
826 826
 }
827 827
 
828 828
 /**
@@ -831,23 +831,23 @@  discard block
 block discarded – undo
831 831
  * @return void
832 832
  */
833 833
 function lsx_health_plan_workout_main_content() {
834
-	// Getting translated endpoint.
835
-	$workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
836
-
837
-	$connected_members = get_post_meta( get_the_ID(), ( $workout . '_connected_team_member' ), true );
838
-	$small_description = get_post_meta( get_the_ID(), ( $workout . '_short_description' ), true );
839
-
840
-	$content = '';
841
-	if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
842
-		$content .= '<div class="short-desc set-box set content-box entry-content">';
843
-		$content .= '<div class="the-content">';
844
-		$content .= lsx_hp_member_connected( $connected_members, $workout );
845
-		$content .= '<span>' . $small_description . '</span>';
846
-		$content .= '</div>';
847
-		$content .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
848
-		$content .= '</div>';
849
-	}
850
-	return $content;
834
+     // Getting translated endpoint.
835
+     $workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
836
+
837
+     $connected_members = get_post_meta( get_the_ID(), ( $workout . '_connected_team_member' ), true );
838
+     $small_description = get_post_meta( get_the_ID(), ( $workout . '_short_description' ), true );
839
+
840
+     $content = '';
841
+     if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
842
+          $content .= '<div class="short-desc set-box set content-box entry-content">';
843
+          $content .= '<div class="the-content">';
844
+          $content .= lsx_hp_member_connected( $connected_members, $workout );
845
+          $content .= '<span>' . $small_description . '</span>';
846
+          $content .= '</div>';
847
+          $content .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
848
+          $content .= '</div>';
849
+     }
850
+     return $content;
851 851
 }
852 852
 
853 853
 /**
@@ -856,23 +856,23 @@  discard block
 block discarded – undo
856 856
  * @return void
857 857
  */
858 858
 function lsx_health_plan_meal_main_content() {
859
-	// Getting translated endpoint.
860
-	$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
861
-
862
-	$connected_members = get_post_meta( get_the_ID(), ( $meal . '_connected_team_member' ), true );
863
-	$small_description = get_post_meta( get_the_ID(), ( $meal . '_short_description' ), true );
864
-
865
-	$content_meal = '';
866
-	if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
867
-		$content_meal .= '<div class="set-box set content-box entry-content">';
868
-		$content_meal .= '<div class="the-content">';
869
-		$content_meal .= lsx_hp_member_connected( $connected_members, $meal );
870
-		$content_meal .= '<span>' . $small_description . '</span>';
871
-		$content_meal .= '</div>';
872
-		$content_meal .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
873
-		$content_meal .= '</div>';
874
-	}
875
-	return $content_meal;
859
+     // Getting translated endpoint.
860
+     $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
861
+
862
+     $connected_members = get_post_meta( get_the_ID(), ( $meal . '_connected_team_member' ), true );
863
+     $small_description = get_post_meta( get_the_ID(), ( $meal . '_short_description' ), true );
864
+
865
+     $content_meal = '';
866
+     if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
867
+          $content_meal .= '<div class="set-box set content-box entry-content">';
868
+          $content_meal .= '<div class="the-content">';
869
+          $content_meal .= lsx_hp_member_connected( $connected_members, $meal );
870
+          $content_meal .= '<span>' . $small_description . '</span>';
871
+          $content_meal .= '</div>';
872
+          $content_meal .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
873
+          $content_meal .= '</div>';
874
+     }
875
+     return $content_meal;
876 876
 }
877 877
 
878 878
 
@@ -883,36 +883,36 @@  discard block
 block discarded – undo
883 883
  * @return void
884 884
  */
885 885
 function lsx_health_plan_workout_tab_content( $index = 1 ) {
886
-	global $group_name,$shortcode_args;
887
-	$group_name = 'workout_section_' . $index;
888
-	if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
889
-		$layout = strtolower( \lsx_health_plan\functions\get_option( 'workout_tab_layout', 'table' ) );
890
-
891
-		// Check for shortcode overrides.
892
-		if ( null !== $shortcode_args && isset( $shortcode_args['layout'] ) ) {
893
-			$layout = $shortcode_args['layout'];
894
-		}
895
-	} else {
896
-		$layout = 'table';
897
-	}
898
-
899
-	switch ( $layout ) {
900
-		case 'list':
901
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-list.php';
902
-			break;
903
-
904
-		case 'grid':
905
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-grid.php';
906
-			break;
907
-
908
-		case 'table':
909
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-table.php';
910
-			break;
911
-	}
912
-	$tab_template_path = apply_filters( 'lsx_health_plan_workout_tab_content_path', $tab_template_path );
913
-	if ( '' !== $tab_template_path ) {
914
-		include $tab_template_path;
915
-	}
886
+     global $group_name,$shortcode_args;
887
+     $group_name = 'workout_section_' . $index;
888
+     if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
889
+          $layout = strtolower( \lsx_health_plan\functions\get_option( 'workout_tab_layout', 'table' ) );
890
+
891
+          // Check for shortcode overrides.
892
+          if ( null !== $shortcode_args && isset( $shortcode_args['layout'] ) ) {
893
+               $layout = $shortcode_args['layout'];
894
+          }
895
+     } else {
896
+          $layout = 'table';
897
+     }
898
+
899
+     switch ( $layout ) {
900
+          case 'list':
901
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-list.php';
902
+               break;
903
+
904
+          case 'grid':
905
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-grid.php';
906
+               break;
907
+
908
+          case 'table':
909
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-table.php';
910
+               break;
911
+     }
912
+     $tab_template_path = apply_filters( 'lsx_health_plan_workout_tab_content_path', $tab_template_path );
913
+     if ( '' !== $tab_template_path ) {
914
+          include $tab_template_path;
915
+     }
916 916
 }
917 917
 
918 918
 /**
@@ -921,28 +921,28 @@  discard block
 block discarded – undo
921 921
  * @return void
922 922
  */
923 923
 function lsx_health_plan_workout_sets() {
924
-	if ( is_singular( 'workout' ) ) {
925
-		global $connected_workouts;
926
-		$connected_workouts = array( get_the_ID() );
927
-	}
928
-	if ( is_singular( 'plan' ) ) {
929
-
930
-		global $connected_workouts;
931
-
932
-		$section_key  = get_query_var( 'section' );
933
-		if ( '' !== $section && \lsx_health_plan\functions\plan\has_sections() ) {
934
-			$section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key );
935
-			if ( isset( $section_info['connected_workouts'] ) && '' !== $section_info['connected_workouts'] ) {
936
-
937
-				$connected_workouts = \lsx_health_plan\functions\prep_array( $section_info['connected_workouts'] );
938
-			}
939
-		}
940
-	}
941
-	$template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
942
-	$template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
943
-	if ( '' !== $template_path && ! empty( $template_path ) ) {
944
-		include $template_path;
945
-	}
924
+     if ( is_singular( 'workout' ) ) {
925
+          global $connected_workouts;
926
+          $connected_workouts = array( get_the_ID() );
927
+     }
928
+     if ( is_singular( 'plan' ) ) {
929
+
930
+          global $connected_workouts;
931
+
932
+          $section_key  = get_query_var( 'section' );
933
+          if ( '' !== $section && \lsx_health_plan\functions\plan\has_sections() ) {
934
+               $section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key );
935
+               if ( isset( $section_info['connected_workouts'] ) && '' !== $section_info['connected_workouts'] ) {
936
+
937
+                    $connected_workouts = \lsx_health_plan\functions\prep_array( $section_info['connected_workouts'] );
938
+               }
939
+          }
940
+     }
941
+     $template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
942
+     $template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
943
+     if ( '' !== $template_path && ! empty( $template_path ) ) {
944
+          include $template_path;
945
+     }
946 946
 }
947 947
 
948 948
 /**
@@ -953,11 +953,11 @@  discard block
 block discarded – undo
953 953
  */
954 954
 function lsx_health_plan_warmup_sets( $connected_workouts ) {
955 955
 	
956
-	$template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
957
-	$template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
958
-	if ( '' !== $template_path && ! empty( $template_path ) ) {
959
-		include $template_path;
960
-	}
956
+     $template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
957
+     $template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
958
+     if ( '' !== $template_path && ! empty( $template_path ) ) {
959
+          include $template_path;
960
+     }
961 961
 }
962 962
 
963 963
 /**
@@ -967,48 +967,48 @@  discard block
 block discarded – undo
967 967
  * @return void
968 968
  */
969 969
 function lsx_hp_meal_plan_recipes( $args = array() ) {
970
-	$defaults = array(
971
-		'meal_id'   => false,
972
-		'meal_time' => '',
973
-		'modal'     => true,
974
-	);
975
-	$args     = wp_parse_args( $args, $defaults );
976
-	// Looking for recipes.
977
-	$connected_recipes = get_post_meta( $args['meal_id'], $args['meal_time'] . '_recipes', true );
978
-	if ( ! empty( $connected_recipes ) ) {
979
-		$query_args    = array(
980
-			'orderby'   => 'date',
981
-			'order'     => 'DESC',
982
-			'post_type' => 'recipe',
983
-			'post__in'  => $connected_recipes,
984
-		);
985
-		$recipes = new WP_Query( $query_args );
986
-		?>
970
+     $defaults = array(
971
+          'meal_id'   => false,
972
+          'meal_time' => '',
973
+          'modal'     => true,
974
+     );
975
+     $args     = wp_parse_args( $args, $defaults );
976
+     // Looking for recipes.
977
+     $connected_recipes = get_post_meta( $args['meal_id'], $args['meal_time'] . '_recipes', true );
978
+     if ( ! empty( $connected_recipes ) ) {
979
+          $query_args    = array(
980
+               'orderby'   => 'date',
981
+               'order'     => 'DESC',
982
+               'post_type' => 'recipe',
983
+               'post__in'  => $connected_recipes,
984
+          );
985
+          $recipes = new WP_Query( $query_args );
986
+          ?>
987 987
 		<div class="recipes">
988 988
 			<div class="row eating-row">
989 989
 			<?php
990
-			if ( $recipes->have_posts() ) {
991
-				while ( $recipes->have_posts() ) {
992
-					$recipes->the_post();
993
-					if ( false !== $args['modal'] ) {
994
-						\lsx_health_plan\functions\recipes\register_recipe_modal();
995
-					}
996
-					?>
990
+               if ( $recipes->have_posts() ) {
991
+                    while ( $recipes->have_posts() ) {
992
+                         $recipes->the_post();
993
+                         if ( false !== $args['modal'] ) {
994
+                              \lsx_health_plan\functions\recipes\register_recipe_modal();
995
+                         }
996
+                         ?>
997 997
 					<div class="recipe-column">
998 998
 						<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">
999 999
 							<div class="recipe-feature-img">
1000 1000
 								<?php
1001
-								$featured_image = get_the_post_thumbnail();
1002
-								if ( ! empty( $featured_image ) && '' !== $featured_image ) {
1003
-									the_post_thumbnail( 'lsx-thumbnail-square', array(
1004
-										'class' => 'aligncenter',
1005
-									) );
1006
-								} else {
1007
-									?>
1001
+                                        $featured_image = get_the_post_thumbnail();
1002
+                                        if ( ! empty( $featured_image ) && '' !== $featured_image ) {
1003
+                                             the_post_thumbnail( 'lsx-thumbnail-square', array(
1004
+                                                  'class' => 'aligncenter',
1005
+                                             ) );
1006
+                                        } else {
1007
+                                             ?>
1008 1008
 									<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __DIR__ ) . 'assets/images/placeholder.jpg' ); ?>">
1009 1009
 									<?php
1010
-								}
1011
-								?>
1010
+                                        }
1011
+                                        ?>
1012 1012
 							</div>
1013 1013
 							<div class="recipe-content">
1014 1014
 								<h3 class="recipe-title"><?php the_title(); ?></h3>
@@ -1017,41 +1017,41 @@  discard block
 block discarded – undo
1017 1017
 						</a>
1018 1018
 					</div>
1019 1019
 				<?php
1020
-				}
1021
-			}
1022
-			wp_reset_postdata();
1023
-			?>
1020
+                    }
1021
+               }
1022
+               wp_reset_postdata();
1023
+               ?>
1024 1024
 			</div>
1025 1025
 		</div>
1026 1026
 		<?php
1027 1027
 
1028
-	}
1028
+     }
1029 1029
 }
1030 1030
 
1031 1031
 /**
1032 1032
  * Output the connected.
1033 1033
  */
1034 1034
 function lsx_hp_recipe_plan_meta( $args = array() ) {
1035
-	$defaults = array();
1036
-	$top_level_plans = array();
1037
-	// Get meals this exercise is connected to.
1038
-	$plans = get_post_meta( get_the_ID(), 'connected_plans', true );
1039
-	if ( ! empty( $plans ) ) {
1040
-		$plan       = end( $plans );
1041
-		$has_parent = wp_get_post_parent_id( $plan );
1042
-		if ( 0 === $has_parent ) {
1043
-			$top_level_plans[] = $plan;
1044
-		} elseif ( false !== $top_level_plans ) {
1045
-			$top_level_plans[] = $has_parent;
1046
-		}
1047
-	}
1048
-	if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
1049
-		$top_level_plans = array_unique( $top_level_plans );
1050
-		$top_level_plan  = end( $top_level_plans );
1051
-		?>
1035
+     $defaults = array();
1036
+     $top_level_plans = array();
1037
+     // Get meals this exercise is connected to.
1038
+     $plans = get_post_meta( get_the_ID(), 'connected_plans', true );
1039
+     if ( ! empty( $plans ) ) {
1040
+          $plan       = end( $plans );
1041
+          $has_parent = wp_get_post_parent_id( $plan );
1042
+          if ( 0 === $has_parent ) {
1043
+               $top_level_plans[] = $plan;
1044
+          } elseif ( false !== $top_level_plans ) {
1045
+               $top_level_plans[] = $has_parent;
1046
+          }
1047
+     }
1048
+     if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
1049
+          $top_level_plans = array_unique( $top_level_plans );
1050
+          $top_level_plan  = end( $top_level_plans );
1051
+          ?>
1052 1052
 			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1053 1053
 		<?php
1054
-	}
1054
+     }
1055 1055
 }
1056 1056
 
1057 1057
 /**
@@ -1059,42 +1059,42 @@  discard block
 block discarded – undo
1059 1059
  */
1060 1060
 function lsx_hp_exercise_plan_meta() {
1061 1061
 
1062
-	$top_level_plans = array();
1063
-
1064
-	// Get workouts this exercise is connected to.
1065
-	$workouts = get_post_meta( get_the_ID(), 'connected_workouts', true );
1066
-
1067
-	if ( '' !== $workouts && ! is_array( $workouts ) ) {
1068
-		$workouts = array( $workouts );
1069
-	}
1070
-	if ( ! empty( $workouts ) ) {
1071
-		foreach ( $workouts as $workout ) {
1072
-			// Get the plans this workout is connected to.
1073
-			$plans = get_post_meta( $workout, 'connected_plans', true );
1074
-
1075
-			if ( '' !== $plans && ! is_array( $plans ) ) {
1076
-				$plans = array( $plans );
1077
-			}
1078
-			if ( ! empty( $plans ) ) {
1079
-				foreach ( $plans as $plan ) {
1080
-					$has_parent = wp_get_post_parent_id( $plan );
1081
-					if ( 0 === $has_parent ) {
1082
-						$top_level_plans = $plan;
1083
-					} else {
1084
-						$top_level_plans = $has_parent;
1085
-					}
1086
-				}
1087
-			}
1088
-		}
1089
-	}
1090
-
1091
-	if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
1092
-		$top_level_plans = array_unique( $top_level_plans );
1093
-		$top_level_plan  = end( $top_level_plans );
1094
-		?>
1062
+     $top_level_plans = array();
1063
+
1064
+     // Get workouts this exercise is connected to.
1065
+     $workouts = get_post_meta( get_the_ID(), 'connected_workouts', true );
1066
+
1067
+     if ( '' !== $workouts && ! is_array( $workouts ) ) {
1068
+          $workouts = array( $workouts );
1069
+     }
1070
+     if ( ! empty( $workouts ) ) {
1071
+          foreach ( $workouts as $workout ) {
1072
+               // Get the plans this workout is connected to.
1073
+               $plans = get_post_meta( $workout, 'connected_plans', true );
1074
+
1075
+               if ( '' !== $plans && ! is_array( $plans ) ) {
1076
+                    $plans = array( $plans );
1077
+               }
1078
+               if ( ! empty( $plans ) ) {
1079
+                    foreach ( $plans as $plan ) {
1080
+                         $has_parent = wp_get_post_parent_id( $plan );
1081
+                         if ( 0 === $has_parent ) {
1082
+                              $top_level_plans = $plan;
1083
+                         } else {
1084
+                              $top_level_plans = $has_parent;
1085
+                         }
1086
+                    }
1087
+               }
1088
+          }
1089
+     }
1090
+
1091
+     if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
1092
+          $top_level_plans = array_unique( $top_level_plans );
1093
+          $top_level_plan  = end( $top_level_plans );
1094
+          ?>
1095 1095
 			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1096 1096
 		<?php
1097
-	}
1097
+     }
1098 1098
 }
1099 1099
 
1100 1100
 /**
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
  * @return void
1105 1105
  */
1106 1106
 function lsx_hp_single_related( $related_content, $post_type_text ) {
1107
-	?>
1107
+     ?>
1108 1108
 	<section id="lsx-hp-related">
1109 1109
 		<div class="row lsx-related-posts lsx-related-posts-title">
1110 1110
 			<div class="col-xs-12">
@@ -1115,14 +1115,14 @@  discard block
 block discarded – undo
1115 1115
 			<div class="col-xs-12">
1116 1116
 				<div class="lsx-related-posts-wrapper">
1117 1117
 					<?php
1118
-					$i = 0;
1119
-					foreach ( $related_content as $article ) {
1120
-						$post_title      = get_the_title( $article );
1121
-						$post_categories = wp_get_post_categories( $article );
1122
-						$post_link       = get_permalink( $article );
1123
-
1124
-						$cats = array();
1125
-						?>
1118
+                         $i = 0;
1119
+                         foreach ( $related_content as $article ) {
1120
+                              $post_title      = get_the_title( $article );
1121
+                              $post_categories = wp_get_post_categories( $article );
1122
+                              $post_link       = get_permalink( $article );
1123
+
1124
+                              $cats = array();
1125
+                              ?>
1126 1126
 						<article id="post-<?php echo esc_html( $article ); ?>" class="lsx-slot post">
1127 1127
 							<div class="entry-layout lsx-hp-shadow">
1128 1128
 								<div class="entry-layout-content">
@@ -1130,25 +1130,25 @@  discard block
 block discarded – undo
1130 1130
 										<div class="entry-image">
1131 1131
 											<a href="<?php echo esc_url( $post_link ); ?>" class="thumbnail">
1132 1132
 											<?php
1133
-											$featured_image = get_the_post_thumbnail( $article, 'lsx-thumbnail-wide' );
1134
-											if ( ! empty( $featured_image ) && '' !== $featured_image ) {
1135
-												echo wp_kses_post( $featured_image );
1136
-											} else {
1137
-												?>
1133
+                                                       $featured_image = get_the_post_thumbnail( $article, 'lsx-thumbnail-wide' );
1134
+                                                       if ( ! empty( $featured_image ) && '' !== $featured_image ) {
1135
+                                                            echo wp_kses_post( $featured_image );
1136
+                                                       } else {
1137
+                                                            ?>
1138 1138
 												<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
1139 1139
 												<?php
1140
-											}
1141
-											?>
1140
+                                                       }
1141
+                                                       ?>
1142 1142
 											</a>
1143 1143
 										</div>
1144 1144
 										<div class="entry-meta">
1145 1145
 										<?php
1146
-										foreach ( $post_categories as $c ) {
1147
-											$cat = get_category( $c );
1148
-											/* Translators: %s: category name */
1149
-											$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>';
1150
-										}
1151
-										if ( ! empty( $cats ) ) { ?>
1146
+                                                  foreach ( $post_categories as $c ) {
1147
+                                                       $cat = get_category( $c );
1148
+                                                       /* Translators: %s: category name */
1149
+                                                       $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>';
1150
+                                                  }
1151
+                                                  if ( ! empty( $cats ) ) { ?>
1152 1152
 											<div class="post-categories"><span></span><?php echo wp_kses_post( implode( ', ', $cats ) ); ?></div>
1153 1153
 										<?php } ?>
1154 1154
 										</div>
@@ -1163,8 +1163,8 @@  discard block
 block discarded – undo
1163 1163
 						</article>
1164 1164
 
1165 1165
 					<?php
1166
-					if (++$i === 3) break;
1167
-					} ?>
1166
+                         if (++$i === 3) break;
1167
+                         } ?>
1168 1168
 				</div>
1169 1169
 			</div>
1170 1170
 		</div>
@@ -1179,32 +1179,32 @@  discard block
 block discarded – undo
1179 1179
  * @return void
1180 1180
  */
1181 1181
 function lsx_hp_member_connected( $connected_members, $post_type ) {
1182
-	if ( ! empty( $connected_members ) ) {
1183
-		$content = '<div id="hp-connected-members" class="hp-connected-members connected-' . $post_type . '">';
1184
-		foreach ( $connected_members as $member ) {
1185
-			$post_link   = get_permalink( $member );
1186
-			$member_name = get_the_title( $member );
1187
-			$member_name = '<span class="lsx-team-name">' . $member_name . '</span>';
1188
-
1189
-			$member_link = '<a href="' . $post_link . '" >' . $member_name . '</a>';
1190
-
1191
-			$roles = '';
1192
-			$terms = get_the_terms( $member, 'team_role' );
1193
-
1194
-			if ( $terms && ! is_wp_error( $terms ) ) {
1195
-				$roles = array();
1196
-
1197
-				foreach ( $terms as $term ) {
1198
-					$roles[] = $term->name;
1199
-				}
1200
-
1201
-				$roles = join( ', ', $roles );
1202
-			}
1203
-			$member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : '';
1204
-
1205
-			$content .= '<p>' . $member_roles . ': ' . $member_link . '</p>';
1206
-		}
1207
-		$content .= '</div>';
1208
-		return $content;
1209
-	}
1182
+     if ( ! empty( $connected_members ) ) {
1183
+          $content = '<div id="hp-connected-members" class="hp-connected-members connected-' . $post_type . '">';
1184
+          foreach ( $connected_members as $member ) {
1185
+               $post_link   = get_permalink( $member );
1186
+               $member_name = get_the_title( $member );
1187
+               $member_name = '<span class="lsx-team-name">' . $member_name . '</span>';
1188
+
1189
+               $member_link = '<a href="' . $post_link . '" >' . $member_name . '</a>';
1190
+
1191
+               $roles = '';
1192
+               $terms = get_the_terms( $member, 'team_role' );
1193
+
1194
+               if ( $terms && ! is_wp_error( $terms ) ) {
1195
+                    $roles = array();
1196
+
1197
+                    foreach ( $terms as $term ) {
1198
+                         $roles[] = $term->name;
1199
+                    }
1200
+
1201
+                    $roles = join( ', ', $roles );
1202
+               }
1203
+               $member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : '';
1204
+
1205
+               $content .= '<p>' . $member_roles . ': ' . $member_link . '</p>';
1206
+          }
1207
+          $content .= '</div>';
1208
+          return $content;
1209
+     }
1210 1210
 }
Please login to merge, or discard this patch.
Spacing   +294 added lines, -294 removed lines patch added patch discarded remove patch
@@ -11,26 +11,26 @@  discard block
 block discarded – undo
11 11
 * @return void
12 12
 */
13 13
 function lsx_health_plan_workout_box() {
14
-	if ( ! post_type_exists( 'workout' ) ) {
14
+	if ( ! post_type_exists('workout')) {
15 15
 		return;
16 16
 	}
17
-	$intro_text = \lsx_health_plan\functions\get_option( 'workout_intro', false );
17
+	$intro_text = \lsx_health_plan\functions\get_option('workout_intro', false);
18 18
 	?>
19 19
 	<div class="workout-instructions">
20 20
 		<div class="row">
21 21
 			<div class="col-md-12">
22 22
 			<?php
23
-			if ( false !== $intro_text ) {
23
+			if (false !== $intro_text) {
24 24
 				?>
25 25
 				<div class="excerpt">
26
-					<p><?php echo wp_kses_post( wpautop( $intro_text ) ); ?></p>
26
+					<p><?php echo wp_kses_post(wpautop($intro_text)); ?></p>
27 27
 				</div>
28 28
 				<?php
29 29
 			} else {
30 30
 				?>
31 31
 				<div class="content-intro">
32
-					<h3><?php esc_html_e( "Don't forget your warm up!", 'lsx-health-plan' ); ?></h3>
33
-					<p><?php esc_html_e( 'Be sure to do the warm-up before every workout session.', 'lsx-health-plan' ); ?></p>
32
+					<h3><?php esc_html_e("Don't forget your warm up!", 'lsx-health-plan'); ?></h3>
33
+					<p><?php esc_html_e('Be sure to do the warm-up before every workout session.', 'lsx-health-plan'); ?></p>
34 34
 				</div>
35 35
 				<?php
36 36
 			} ?>
@@ -46,29 +46,29 @@  discard block
 block discarded – undo
46 46
 * @return void
47 47
 */
48 48
 function lsx_health_plan_meal_box() {
49
-	if ( ! post_type_exists( 'meal' ) ) {
49
+	if ( ! post_type_exists('meal')) {
50 50
 		return;
51 51
 	}
52 52
 	?>
53 53
 	<div class="col-md-4" >
54 54
 		<div class="lsx-health-plan-box">
55
-			<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>
55
+			<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>
56 56
 			<div class="spacer"></div>
57 57
 			<?php
58
-			$intro_text = \lsx_health_plan\functions\get_option( 'meal_plan_intro', false );
59
-			if ( false !== $intro_text ) {
58
+			$intro_text = \lsx_health_plan\functions\get_option('meal_plan_intro', false);
59
+			if (false !== $intro_text) {
60 60
 				?>
61 61
 				<div class="excerpt">
62
-					<p><?php echo wp_kses_post( $intro_text ); ?></p>
62
+					<p><?php echo wp_kses_post($intro_text); ?></p>
63 63
 				</div>
64 64
 				<?php
65 65
 			}
66
-			$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false );
67
-			if ( false === $meal ) {
66
+			$meal = \lsx_health_plan\functions\get_option('endpoint_meal', false);
67
+			if (false === $meal) {
68 68
 				$meal = 'meal';
69 69
 			}
70 70
 			?>
71
-			<a href="<?php the_permalink(); ?><?php echo esc_attr( $meal ); ?>/" class="btn"><?php esc_html_e( 'View your meal plan', 'lsx-health-plan' ); ?></a>
71
+			<a href="<?php the_permalink(); ?><?php echo esc_attr($meal); ?>/" class="btn"><?php esc_html_e('View your meal plan', 'lsx-health-plan'); ?></a>
72 72
 		</div>
73 73
 	</div>
74 74
 <?php
@@ -80,29 +80,29 @@  discard block
 block discarded – undo
80 80
 * @return void
81 81
 */
82 82
 function lsx_health_plan_recipe_box() {
83
-	if ( ! post_type_exists( 'recipe' ) ) {
83
+	if ( ! post_type_exists('recipe')) {
84 84
 		return;
85 85
 	}
86 86
 	?>
87 87
 	<div class="col-md-4" >
88 88
 		<div class="lsx-health-plan-box">
89
-			<h3 class="title recipes-title title-lined"><?php esc_html_e( 'Recipes', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'recipes.svg' ); ?></h3>
89
+			<h3 class="title recipes-title title-lined"><?php esc_html_e('Recipes', 'lsx-health-plan'); ?><?php lsx_get_svg_icon('recipes.svg'); ?></h3>
90 90
 			<div class="spacer"></div>
91 91
 			<?php
92
-			$intro_text = \lsx_health_plan\functions\get_option( 'recipes_intro', false );
93
-			if ( false !== $intro_text ) {
92
+			$intro_text = \lsx_health_plan\functions\get_option('recipes_intro', false);
93
+			if (false !== $intro_text) {
94 94
 				?>
95 95
 				<div class="excerpt">
96
-					<p><?php echo wp_kses_post( $intro_text ); ?></p>
96
+					<p><?php echo wp_kses_post($intro_text); ?></p>
97 97
 				</div>
98 98
 				<?php
99 99
 			}
100
-			$recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false );
101
-			if ( false === $recipes ) {
100
+			$recipes = \lsx_health_plan\functions\get_option('endpoint_recipe', false);
101
+			if (false === $recipes) {
102 102
 				$recipes = 'recipes';
103 103
 			}
104 104
 			?>
105
-			<a href="<?php the_permalink(); ?><?php echo esc_attr( $recipes ); ?>/" class="btn"><?php esc_html_e( 'View all recipes', 'lsx-health-plan' ); ?></a>
105
+			<a href="<?php the_permalink(); ?><?php echo esc_attr($recipes); ?>/" class="btn"><?php esc_html_e('View all recipes', 'lsx-health-plan'); ?></a>
106 106
 		</div>
107 107
 	</div>
108 108
 <?php
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 	?>
119 119
 	<div class="col-md-4 day-download-box" >
120 120
 		<div class="lsx-health-plan-box">
121
-			<h3 class="title downloads-title title-lined"><?php esc_html_e( 'Downloads', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'download.svg' ); ?></h3>
121
+			<h3 class="title downloads-title title-lined"><?php esc_html_e('Downloads', 'lsx-health-plan'); ?><?php lsx_get_svg_icon('download.svg'); ?></h3>
122 122
 			<div class="spacer"></div>
123 123
 			<div class="download-list">
124 124
 				<ul>
125 125
 					<?php
126 126
 					$downloads = \lsx_health_plan\functions\get_downloads();
127
-					if ( ! empty( $downloads ) ) {
128
-						foreach ( $downloads as $download ) {
129
-							echo wp_kses_post( '<li><a href=""><i class="fa fa-file-pdf"></i>' . do_shortcode( '[download id="' . $download . '"]' ) . '</a></li>' );
127
+					if ( ! empty($downloads)) {
128
+						foreach ($downloads as $download) {
129
+							echo wp_kses_post('<li><a href=""><i class="fa fa-file-pdf"></i>' . do_shortcode('[download id="' . $download . '"]') . '</a></li>');
130 130
 						}
131 131
 					}
132 132
 					?>
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
  * @param string $tab
144 144
  * @return void
145 145
  */
146
-function lsx_health_plan_nav_class( $tab = '' ) {
146
+function lsx_health_plan_nav_class($tab = '') {
147 147
 	$nav_classes = array();
148
-	if ( function_exists( 'is_wc_endpoint_url' ) && 'edit-account' === $tab && is_wc_endpoint_url( 'edit-account' ) ) {
148
+	if (function_exists('is_wc_endpoint_url') && 'edit-account' === $tab && is_wc_endpoint_url('edit-account')) {
149 149
 		$nav_classes[] = 'active';
150
-	} elseif ( lsx_health_plan_is_current_tab( $tab ) ) {
150
+	} elseif (lsx_health_plan_is_current_tab($tab)) {
151 151
 		$nav_classes[] = 'active';
152 152
 	}
153
-	if ( ! empty( $nav_classes ) ) {
154
-		echo wp_kses_post( implode( ' ', $nav_classes ) );
153
+	if ( ! empty($nav_classes)) {
154
+		echo wp_kses_post(implode(' ', $nav_classes));
155 155
 	}
156 156
 }
157 157
 
@@ -166,25 +166,25 @@  discard block
 block discarded – undo
166 166
 		<ul class="nav nav-pills">
167 167
 			<li class="
168 168
 			<?php
169
-			if ( ( function_exists( 'is_wc_endpoint_url' ) && ! is_wc_endpoint_url( 'edit-account' ) ) || ! function_exists( 'is_wc_endpoint_url' ) ) {
170
-				echo esc_attr( 'active' );
169
+			if ((function_exists('is_wc_endpoint_url') && ! is_wc_endpoint_url('edit-account')) || ! function_exists('is_wc_endpoint_url')) {
170
+				echo esc_attr('active');
171 171
 			}
172 172
 			?>
173
-			"><a class="my-plan-tab" href="<?php the_permalink(); ?>"><?php esc_html_e( 'My Plans', 'lsx-health-plan' ); ?></a></li>
173
+			"><a class="my-plan-tab" href="<?php the_permalink(); ?>"><?php esc_html_e('My Plans', 'lsx-health-plan'); ?></a></li>
174 174
 			<?php
175
-			if ( function_exists( 'WC' ) ) {
175
+			if (function_exists('WC')) {
176 176
 				?>
177 177
 				<li class="
178 178
 				<?php
179
-				if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'edit-account' ) ) {
180
-					echo esc_attr( 'active' );
179
+				if (function_exists('is_wc_endpoint_url') && is_wc_endpoint_url('edit-account')) {
180
+					echo esc_attr('active');
181 181
 				}
182 182
 				?>
183
-				"><a class="account-details-tab" href="<?php the_permalink(); ?>edit-account/"><?php esc_html_e( 'Account Details', 'lsx-health-plan' ); ?></a></li>
183
+				"><a class="account-details-tab" href="<?php the_permalink(); ?>edit-account/"><?php esc_html_e('Account Details', 'lsx-health-plan'); ?></a></li>
184 184
 				<?php
185 185
 			}
186 186
 			?>
187
-			<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>
187
+			<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>
188 188
 		</ul>
189 189
 	</div>
190 190
 	<?php
@@ -199,84 +199,84 @@  discard block
 block discarded – undo
199 199
 	?>
200 200
 	<div class="lsx-health-plan my-profile-block wp-block-cover alignfull">
201 201
 		<div class="wp-block-cover__inner-container">
202
-			<h2><?php esc_html_e( 'My Dashboard', 'lsx-health-plan' ); ?></h2>
203
-			<?php if ( function_exists( 'WC' ) || class_exists( 'WP_User_Avatar_Setup' ) ) { ?>
202
+			<h2><?php esc_html_e('My Dashboard', 'lsx-health-plan'); ?></h2>
203
+			<?php if (function_exists('WC') || class_exists('WP_User_Avatar_Setup')) { ?>
204 204
 				<section id="dashboard-card">
205
-					<?php if ( function_exists( 'WC' ) || class_exists( 'WP_User_Avatar_Setup' ) ) { ?>
205
+					<?php if (function_exists('WC') || class_exists('WP_User_Avatar_Setup')) { ?>
206 206
 						<div class="profile-navigation">
207 207
 							<div class="profile-photo">
208 208
 							<?php
209 209
 								global $current_user;
210
-								if ( function_exists( 'WC' ) ) {
210
+								if (function_exists('WC')) {
211 211
 									get_current_user();
212 212
 								}
213
-								if ( class_exists( 'WP_User_Avatar_Setup' ) ) {
214
-									echo get_avatar( $current_user->ID, 240 );
213
+								if (class_exists('WP_User_Avatar_Setup')) {
214
+									echo get_avatar($current_user->ID, 240);
215 215
 								}
216 216
 								?>
217 217
 							</div>
218 218
 						</div>
219 219
 					<?php } ?>
220
-					<?php if ( function_exists( 'WC' ) ) { ?>
220
+					<?php if (function_exists('WC')) { ?>
221 221
 						<div class="profile-details">
222
-							<h1 class="title-lined has-text-color"><?php echo esc_html( $current_user->display_name ); ?></h1>
222
+							<h1 class="title-lined has-text-color"><?php echo esc_html($current_user->display_name); ?></h1>
223 223
 							<?php
224
-							$disable_stats = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
225
-							if ( 'on' !== $disable_stats && function_exists( 'WC' ) ) {
224
+							$disable_stats = \lsx_health_plan\functions\get_option('disable_all_stats', false);
225
+							if ('on' !== $disable_stats && function_exists('WC')) {
226 226
 
227
-								$is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false );
228
-								$is_height_disabled = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false );
229
-								$is_waist_disabled  = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false );
230
-								$is_bmi_disabled    = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false );
227
+								$is_weight_disabled = \lsx_health_plan\functions\get_option('disable_weight_checkbox', false);
228
+								$is_height_disabled = \lsx_health_plan\functions\get_option('disable_height_checkbox', false);
229
+								$is_waist_disabled  = \lsx_health_plan\functions\get_option('disable_waist_checkbox', false);
230
+								$is_bmi_disabled    = \lsx_health_plan\functions\get_option('disable_bmi_checkbox', false);
231 231
 
232
-								$weight = get_user_meta( get_current_user_id(), 'weight', true );
233
-								$waist  = get_user_meta( get_current_user_id(), 'waist', true );
234
-								$height = get_user_meta( get_current_user_id(), 'height', true );
232
+								$weight = get_user_meta(get_current_user_id(), 'weight', true);
233
+								$waist  = get_user_meta(get_current_user_id(), 'waist', true);
234
+								$height = get_user_meta(get_current_user_id(), 'height', true);
235 235
 
236 236
 								$height_m = 0;
237
-								if ( is_numeric( $height ) ) {
237
+								if (is_numeric($height)) {
238 238
 									$height_m = $height / 100;
239 239
 								}
240 240
 
241
-								if ( 1 < $weight && 1 < $height_m ) {
242
-									$bmi = $weight / ( $height_m * $height_m );
243
-									$bmi = number_format( $bmi, 1 );
241
+								if (1 < $weight && 1 < $height_m) {
242
+									$bmi = $weight / ($height_m * $height_m);
243
+									$bmi = number_format($bmi, 1);
244 244
 								} else {
245
-									$bmi = __( 'Add more data', 'lsx-health-plan' );
245
+									$bmi = __('Add more data', 'lsx-health-plan');
246 246
 								}
247 247
 
248 248
 								?>
249 249
 
250 250
 								<div>
251
-									<?php if ( 'on' !== $is_weight_disabled ) { ?>
252
-										<span><strong><?php esc_html_e( 'Weight:', 'lsx-health-plan' ); ?></strong>
251
+									<?php if ('on' !== $is_weight_disabled) { ?>
252
+										<span><strong><?php esc_html_e('Weight:', 'lsx-health-plan'); ?></strong>
253 253
 										<?php
254
-										if ( '' !== $weight ) {
255
-											echo wp_kses_post( $weight . ' kg' );
254
+										if ('' !== $weight) {
255
+											echo wp_kses_post($weight . ' kg');
256 256
 										} else {
257 257
 											echo '/';
258 258
 										}
259 259
 										?>
260 260
 										</span>
261 261
 									<?php }
262
-									if ( 'on' !== $is_waist_disabled ) {
262
+									if ('on' !== $is_waist_disabled) {
263 263
 										?>
264
-										<span><strong><?php esc_html_e( 'Waist:', 'lsx-health-plan' ); ?></strong>
264
+										<span><strong><?php esc_html_e('Waist:', 'lsx-health-plan'); ?></strong>
265 265
 										<?php
266
-										if ( '' !== $waist ) {
267
-											echo wp_kses_post( $waist . ' cm' );
266
+										if ('' !== $waist) {
267
+											echo wp_kses_post($waist . ' cm');
268 268
 										} else {
269 269
 											echo '/';
270 270
 										}
271 271
 										?>
272 272
 										</span>
273 273
 									<?php }
274
-									if ( 'on' !== $is_bmi_disabled ) {
274
+									if ('on' !== $is_bmi_disabled) {
275 275
 										?>
276
-										<span><strong><?php esc_html_e( 'BMI:', 'lsx-health-plan' ); ?></strong>
276
+										<span><strong><?php esc_html_e('BMI:', 'lsx-health-plan'); ?></strong>
277 277
 										<?php
278
-										if ( '' !== $bmi ) {
279
-											echo wp_kses_post( $bmi );
278
+										if ('' !== $bmi) {
279
+											echo wp_kses_post($bmi);
280 280
 										} else {
281 281
 											echo '/';
282 282
 										}
@@ -288,17 +288,17 @@  discard block
 block discarded – undo
288 288
 							}
289 289
 
290 290
 							// Only display the edit account link if woocommerce is active.
291
-							if ( function_exists( 'WC' ) ) {
291
+							if (function_exists('WC')) {
292 292
 								?>
293 293
 								<div class="edit-profile">
294 294
 									<?php
295
-									if ( function_exists( 'wc_get_page_id' ) ) {
296
-										$url_id = wc_get_page_id( 'myaccount' );
295
+									if (function_exists('wc_get_page_id')) {
296
+										$url_id = wc_get_page_id('myaccount');
297 297
 									} else {
298 298
 										$url_id = '';
299 299
 									}
300 300
 									?>
301
-									<a href="<?php echo esc_url( get_permalink( $url_id ) ); ?>edit-account/"><?php esc_html_e( 'Edit', 'lsx-health-plan' ); ?></a>
301
+									<a href="<?php echo esc_url(get_permalink($url_id)); ?>edit-account/"><?php esc_html_e('Edit', 'lsx-health-plan'); ?></a>
302 302
 								</div>
303 303
 								<?php
304 304
 							}
@@ -328,9 +328,9 @@  discard block
 block discarded – undo
328 328
 		'post_parent'    => 0,
329 329
 	);
330 330
 
331
-	if ( function_exists( '\lsx_health_plan\functions\woocommerce\get_membership_products' ) ) {
331
+	if (function_exists('\lsx_health_plan\functions\woocommerce\get_membership_products')) {
332 332
 		$product_ids = \lsx_health_plan\functions\woocommerce\get_membership_products();
333
-		if ( ! empty( $product_ids ) ) {
333
+		if ( ! empty($product_ids)) {
334 334
 			$args['meta_query'] = array(
335 335
 				'relation' => 'OR',
336 336
 				array(
@@ -346,82 +346,82 @@  discard block
 block discarded – undo
346 346
 		}
347 347
 	}
348 348
 
349
-	$the_query = new WP_Query( $args );
349
+	$the_query = new WP_Query($args);
350 350
 	?>
351 351
 	<div class="all-plans-block plan-grid block-all-plans-block">
352 352
 		<div class="row">
353 353
 			<?php
354
-			if ( $the_query->have_posts() ) :
355
-				while ( $the_query->have_posts() ) :
354
+			if ($the_query->have_posts()) :
355
+				while ($the_query->have_posts()) :
356 356
 					$the_query->the_post();
357 357
 					lsx_entry_before();
358 358
 					$completed_class = '';
359 359
 					$linked_product  = false;
360 360
 					$restricted      = false;
361 361
 					$product         = null;
362
-					if ( function_exists( 'lsx_health_plan\functions\woocommerce\plan_has_products' ) && \lsx_health_plan\functions\woocommerce\plan_has_products() ) {
362
+					if (function_exists('lsx_health_plan\functions\woocommerce\plan_has_products') && \lsx_health_plan\functions\woocommerce\plan_has_products()) {
363 363
 						$products       = \lsx_health_plan\functions\woocommerce\get_plan_products();
364
-						$linked_product = wc_get_product( $products[0] );
364
+						$linked_product = wc_get_product($products[0]);
365 365
 						$product        = $linked_product;
366 366
 					}
367
-					if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) {
368
-						$restricted = wc_memberships_is_post_content_restricted( get_the_ID() ) && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() );
367
+					if (function_exists('wc_memberships_is_post_content_restricted')) {
368
+						$restricted = wc_memberships_is_post_content_restricted(get_the_ID()) && ! current_user_can('wc_memberships_view_restricted_post_content', get_the_ID());
369 369
 					}
370 370
 
371
-					if ( lsx_health_plan_is_plan_complete() ) {
371
+					if (lsx_health_plan_is_plan_complete()) {
372 372
 						$completed_class = 'completed';
373 373
 					}
374 374
 					$round_progress     = '';
375 375
 					$completed_progress = '100';
376
-					if ( false === $restricted ) {
377
-						$round_progress = round( \lsx_health_plan\functions\get_progress( get_the_ID() ), 0 );
376
+					if (false === $restricted) {
377
+						$round_progress = round(\lsx_health_plan\functions\get_progress(get_the_ID()), 0);
378 378
 					}
379 379
 					?>
380 380
 					<div class="col-xs-12 col-sm-6 col-md-4">
381
-						<article class="lsx-slot lsx-hp-shadow <?php echo esc_html( 'progress-') . $round_progress; ?>">
381
+						<article class="lsx-slot lsx-hp-shadow <?php echo esc_html('progress-') . $round_progress; ?>">
382 382
 							<div class="plan-feature-img">
383
-								<?php if ( (int)$completed_progress === (int)$round_progress ) { ?>
384
-									<span class="featured-plan"><?php lsx_get_svg_icon( 'icon-completed.svg' ); ?></span>
383
+								<?php if ((int) $completed_progress === (int) $round_progress) { ?>
384
+									<span class="featured-plan"><?php lsx_get_svg_icon('icon-completed.svg'); ?></span>
385 385
 								<?php } ?>
386
-								<a href="<?php echo esc_url( get_permalink() ); ?>">
386
+								<a href="<?php echo esc_url(get_permalink()); ?>">
387 387
 								<?php
388 388
 								$featured_image = get_the_post_thumbnail();
389
-								if ( ! empty( $featured_image ) && '' !== $featured_image ) {
390
-									the_post_thumbnail( 'lsx-thumbnail', array(
389
+								if ( ! empty($featured_image) && '' !== $featured_image) {
390
+									the_post_thumbnail('lsx-thumbnail', array(
391 391
 										'class' => 'aligncenter',
392
-									) );
392
+									));
393 393
 								} else {
394 394
 									?>
395
-									<img loading="lazy"  class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
395
+									<img loading="lazy"  class="placeholder" src="<?php echo esc_attr(plugin_dir_url(__FILE__) . '../assets/images/placeholder.jpg'); ?>">
396 396
 									<?php
397 397
 								}
398 398
 								?>
399 399
 								</a>
400 400
 							</div>
401 401
 							<div class="content-box plan-content-box">
402
-								<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>
402
+								<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>
403 403
 								<?php
404
-									echo wp_kses_post( \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) );
404
+									echo wp_kses_post(\lsx_health_plan\functions\hp_get_plan_type_meta($post));
405 405
 								?>
406 406
 								<?php
407
-								if ( false !== $linked_product && false !== $restricted ) {
408
-									echo wp_kses_post( $linked_product->get_price_html() );
407
+								if (false !== $linked_product && false !== $restricted) {
408
+									echo wp_kses_post($linked_product->get_price_html());
409 409
 								}
410 410
 								?>
411 411
 								<div class="excerpt">
412 412
 									<?php
413
-									if ( ! has_excerpt() ) {
414
-										$content = wp_trim_words( get_the_content(), 20 );
413
+									if ( ! has_excerpt()) {
414
+										$content = wp_trim_words(get_the_content(), 20);
415 415
 										$content = '<p>' . $content . '</pre>';
416 416
 									} else {
417
-										$content = apply_filters( 'the_excerpt', get_the_excerpt() );
417
+										$content = apply_filters('the_excerpt', get_the_excerpt());
418 418
 									}
419
-									echo wp_kses_post( $content );
419
+									echo wp_kses_post($content);
420 420
 									?>
421 421
 								</div>
422 422
 								<?php
423
-								if ( false === $restricted ) {
424
-									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>' . $round_progress . '%</span></span>' );
423
+								if (false === $restricted) {
424
+									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>' . $round_progress . '%</span></span>');
425 425
 								}
426 426
 								?>
427 427
 							</div>
@@ -441,30 +441,30 @@  discard block
 block discarded – undo
441 441
  *
442 442
  * @return void
443 443
  */
444
-function lsx_health_plan_day_plan_block( $args = array() ) {
444
+function lsx_health_plan_day_plan_block($args = array()) {
445 445
 	$defaults = array(
446 446
 		'plan' => '',
447 447
 	);
448
-	$args     = wp_parse_args( $args, $defaults );
448
+	$args     = wp_parse_args($args, $defaults);
449 449
 
450
-	if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
450
+	if (isset($args['plan']) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections($args['plan'])) {
451 451
 		$sections = \lsx_health_plan\functions\plan\get_sections();
452 452
 		?>
453 453
 		<div class="daily-plan-block day-grid">
454 454
 			<?php
455
-			foreach ( $sections as $section_key => $section_values ) {
456
-				$defaults    = array(
457
-					'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
455
+			foreach ($sections as $section_key => $section_values) {
456
+				$defaults = array(
457
+					'title' => __('Day', 'lsx-health-plan') . ' ' . ($section_key + 1),
458 458
 				);
459
-				$section_args = wp_parse_args( $section_values, $defaults );
459
+				$section_args = wp_parse_args($section_values, $defaults);
460 460
 
461 461
 				$completed_class = '';
462
-				if ( lsx_health_plan_is_day_complete() ) {
462
+				if (lsx_health_plan_is_day_complete()) {
463 463
 					$completed_class = 'completed';
464 464
 				}
465 465
 				?>
466
-				<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 ); ?>">
467
-					<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
466
+				<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); ?>">
467
+					<div class="plan-content"><?php echo esc_attr($section_args['title']); ?></div>
468 468
 				</a>
469 469
 				<?php
470 470
 			}
@@ -480,31 +480,31 @@  discard block
 block discarded – undo
480 480
  * @param  array $args An array of arguments.
481 481
  * @return void
482 482
  */
483
-function lsx_health_plan_week_plan_block( $args = array() ) {
483
+function lsx_health_plan_week_plan_block($args = array()) {
484 484
 	$defaults = array(
485 485
 		'show_downloads' => false,
486 486
 		'plan'           => '',
487 487
 	);
488
-	$args     = wp_parse_args( $args, $defaults );
488
+	$args = wp_parse_args($args, $defaults);
489 489
 
490
-	if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
491
-		$groups = \lsx_health_plan\functions\plan\get_sections( true );
490
+	if (isset($args['plan']) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections($args['plan'])) {
491
+		$groups = \lsx_health_plan\functions\plan\get_sections(true);
492 492
 
493
-		if ( ! empty( $groups ) ) {
493
+		if ( ! empty($groups)) {
494 494
 			$counter    = 1;
495 495
 			$group_open = false;
496 496
 
497
-			foreach ( $groups as $group_key => $sections ) {
497
+			foreach ($groups as $group_key => $sections) {
498 498
 				$collapse_class = '';
499
-				$group_title    = \lsx_health_plan\functions\plan\get_group_title( $sections );
499
+				$group_title    = \lsx_health_plan\functions\plan\get_group_title($sections);
500 500
 
501 501
 				// Determine if the current week is complete.
502
-				$day_ids = wp_list_pluck( $sections, 'title' );
503
-				if ( false === $group_open ) {
504
-					if ( 1 === $counter && ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
502
+				$day_ids = wp_list_pluck($sections, 'title');
503
+				if (false === $group_open) {
504
+					if (1 === $counter && ! \lsx_health_plan\functions\is_week_complete(false, $day_ids, $group_title)) {
505 505
 						$collapse_class = 'in';
506 506
 						$group_open   = true;
507
-					} elseif ( ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
507
+					} elseif ( ! \lsx_health_plan\functions\is_week_complete(false, $day_ids, $group_title)) {
508 508
 						$collapse_class = 'in';
509 509
 						$group_open   = true;
510 510
 					}
@@ -512,47 +512,47 @@  discard block
 block discarded – undo
512 512
 
513 513
 				// Determine if there are any weekly downloads.
514 514
 				$week_downloads_view = '';
515
-				if ( isset( $args['show_downloads'] ) && false !== $args['show_downloads'] ) {
516
-					$weekly_downloads = \lsx_health_plan\functions\get_weekly_downloads( $group_key );
517
-					if ( ! empty( $weekly_downloads ) ) {
515
+				if (isset($args['show_downloads']) && false !== $args['show_downloads']) {
516
+					$weekly_downloads = \lsx_health_plan\functions\get_weekly_downloads($group_key);
517
+					if ( ! empty($weekly_downloads)) {
518 518
 						$week_downloads_view = 'week-downloads-view-on';
519 519
 					}
520 520
 				}
521 521
 				?>
522 522
 				<div class="daily-plan-block week-grid">
523
-					<a href="#group-<?php echo esc_attr( $group_key ); ?>" data-toggle="collapse" class="week-title"><?php echo esc_attr( $group_title ); ?></a>
524
-					<div id="group-<?php echo esc_attr( $group_key ); ?>" class="week-row collapse <?php echo esc_attr( $collapse_class ); ?>">
525
-						<div class="week-row-inner <?php echo esc_html( $week_downloads_view ); ?>">
523
+					<a href="#group-<?php echo esc_attr($group_key); ?>" data-toggle="collapse" class="week-title"><?php echo esc_attr($group_title); ?></a>
524
+					<div id="group-<?php echo esc_attr($group_key); ?>" class="week-row collapse <?php echo esc_attr($collapse_class); ?>">
525
+						<div class="week-row-inner <?php echo esc_html($week_downloads_view); ?>">
526 526
 							<div class="week-meals-recipes-box">
527 527
 
528
-								<?php if ( ! empty( $week_downloads_view ) ) { ?>
529
-									<h3 class="title"><?php lsx_get_svg_icon( 'daily-plan.svg' ); ?><?php echo esc_html_e( 'Plan', 'lsx-health-plan' ); ?></h3>
528
+								<?php if ( ! empty($week_downloads_view)) { ?>
529
+									<h3 class="title"><?php lsx_get_svg_icon('daily-plan.svg'); ?><?php echo esc_html_e('Plan', 'lsx-health-plan'); ?></h3>
530 530
 								<?php } ?>
531 531
 
532 532
 								<div class="week-meals-recipes-box-inner">
533 533
 								<?php
534 534
 
535
-								foreach ( $sections as $section_key => $section_values ) {
535
+								foreach ($sections as $section_key => $section_values) {
536 536
 
537
-									$defaults    = array(
538
-										'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
537
+									$defaults = array(
538
+										'title' => __('Day', 'lsx-health-plan') . ' ' . ($section_key + 1),
539 539
 									);
540
-									$section_args = wp_parse_args( $section_values, $defaults );
540
+									$section_args = wp_parse_args($section_values, $defaults);
541 541
 
542 542
 									$completed_class = '';
543
-									if ( lsx_health_plan_is_day_complete( $args['plan'], $section_args['title'] ) ) {
543
+									if (lsx_health_plan_is_day_complete($args['plan'], $section_args['title'])) {
544 544
 										$completed_class = 'completed';
545 545
 									}
546
-									if ( $section_args['rest_day_enabled'] && ! $section_args['connected_meals'] ) {
546
+									if ($section_args['rest_day_enabled'] && ! $section_args['connected_meals']) {
547 547
 										?>
548
-										<span class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>">
549
-											<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
548
+										<span class="day id-<?php echo esc_attr($section_key + 1); ?> <?php echo esc_attr($completed_class); ?>">
549
+											<div class="plan-content"><?php echo esc_attr($section_args['title']); ?></div>
550 550
 										</span>
551 551
 										<?php
552 552
 									} else {
553 553
 										?>
554
-										<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 ); ?>">
555
-											<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
554
+										<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); ?>">
555
+											<div class="plan-content"><?php echo esc_attr($section_args['title']); ?></div>
556 556
 										</a>
557 557
 										<?php
558 558
 									}
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 								</div>
562 562
 							</div>
563 563
 							<?php
564
-							if ( ! empty( $week_downloads_view ) ) {
565
-								lsx_health_plan_weekly_downloads( $weekly_downloads );
564
+							if ( ! empty($week_downloads_view)) {
565
+								lsx_health_plan_weekly_downloads($weekly_downloads);
566 566
 							}
567 567
 							?>
568 568
 						</div>
@@ -580,16 +580,16 @@  discard block
 block discarded – undo
580 580
  * @param array $weekly_downloads An array of the download ids.
581 581
  * @return void
582 582
  */
583
-function lsx_health_plan_weekly_downloads( $weekly_downloads = array() ) {
584
-	if ( ! empty( $weekly_downloads ) ) {
583
+function lsx_health_plan_weekly_downloads($weekly_downloads = array()) {
584
+	if ( ! empty($weekly_downloads)) {
585 585
 		?>
586 586
 		<div class="week-download-box">
587
-			<h3 class="title"><?php lsx_get_svg_icon( 'download.svg' ); ?><?php echo esc_html_e( 'Downloads', 'lsx-health-plan' ); ?></h3>
587
+			<h3 class="title"><?php lsx_get_svg_icon('download.svg'); ?><?php echo esc_html_e('Downloads', 'lsx-health-plan'); ?></h3>
588 588
 			<ul class="week-download-box-list">
589 589
 				<?php
590
-				foreach ( $weekly_downloads as $weekly_download ) {
590
+				foreach ($weekly_downloads as $weekly_download) {
591 591
 					?>
592
-					<li><?php echo wp_kses_post( do_shortcode( '[download id="' . $weekly_download . '"]' ) ); ?></li>
592
+					<li><?php echo wp_kses_post(do_shortcode('[download id="' . $weekly_download . '"]')); ?></li>
593 593
 					<?php
594 594
 				}
595 595
 				?>
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
  *
605 605
  * @return void
606 606
  */
607
-function lsx_health_plan_items( $args = array() ) {
607
+function lsx_health_plan_items($args = array()) {
608 608
 	global $shortcode_args;
609 609
 	$shortcode_args = $args;
610 610
 	include LSX_HEALTH_PLAN_PATH . '/templates/partials/shortcode-loop.php';
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
  * @return void
617 617
  */
618 618
 function lsx_health_plan_featured_video_block() {
619
-	if ( ! post_type_exists( 'video' ) ) {
619
+	if ( ! post_type_exists('video')) {
620 620
 		return;
621 621
 	}
622 622
 	include LSX_HEALTH_PLAN_PATH . '/templates/featured-videos.php';
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
  * @return void
629 629
  */
630 630
 function lsx_health_plan_featured_recipes_block() {
631
-	if ( ! post_type_exists( 'recipe' ) ) {
631
+	if ( ! post_type_exists('recipe')) {
632 632
 		return;
633 633
 	}
634 634
 	include LSX_HEALTH_PLAN_PATH . '/templates/featured-recipes.php';
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
  * @return void
651 651
  */
652 652
 function lsx_health_plan_day_button() {
653
-	if ( lsx_health_plan_is_day_complete() ) {
653
+	if (lsx_health_plan_is_day_complete()) {
654 654
 		lsx_health_plan_unlock_button();
655 655
 	} else {
656 656
 		lsx_health_plan_complete_button();
@@ -666,9 +666,9 @@  discard block
 block discarded – undo
666 666
 	?>
667 667
 	<div class="single-plan-inner-buttons">
668 668
 		<form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn">
669
-			<?php wp_nonce_field( 'complete', 'lsx-health-plan-actions' ); ?>
670
-			<input type="hidden" name="lsx-health-plan-id" value="<?php echo esc_attr( \lsx_health_plan\functions\plan\generate_section_id() ); ?>" />
671
-			<button class="btn cta-btn" type="submit"><?php esc_html_e( 'Complete Day', 'lsx-health-plan' ); ?></button>
669
+			<?php wp_nonce_field('complete', 'lsx-health-plan-actions'); ?>
670
+			<input type="hidden" name="lsx-health-plan-id" value="<?php echo esc_attr(\lsx_health_plan\functions\plan\generate_section_id()); ?>" />
671
+			<button class="btn cta-btn" type="submit"><?php esc_html_e('Complete Day', 'lsx-health-plan'); ?></button>
672 672
 		</form>
673 673
 		<?php lsx_health_plan_back_to_plan_button(); ?>
674 674
 	</div>
@@ -684,9 +684,9 @@  discard block
 block discarded – undo
684 684
 	?>
685 685
 	<div class="single-plan-inner-buttons">
686 686
 		<form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn">
687
-			<?php wp_nonce_field( 'unlock', 'lsx-health-plan-actions' ); ?>
688
-			<input type="hidden" name="lsx-health-plan-id" value="<?php echo esc_attr( \lsx_health_plan\functions\plan\generate_section_id() ); ?>" />
689
-			<button class="btn secondary-btn" type="submit"><?php esc_html_e( 'Im not done!', 'lsx-health-plan' ); ?></button>
687
+			<?php wp_nonce_field('unlock', 'lsx-health-plan-actions'); ?>
688
+			<input type="hidden" name="lsx-health-plan-id" value="<?php echo esc_attr(\lsx_health_plan\functions\plan\generate_section_id()); ?>" />
689
+			<button class="btn secondary-btn" type="submit"><?php esc_html_e('Im not done!', 'lsx-health-plan'); ?></button>
690 690
 		</form>
691 691
 		<?php lsx_health_plan_back_to_plan_button(); ?>
692 692
 	</div>
@@ -700,8 +700,8 @@  discard block
 block discarded – undo
700 700
  * @return void
701 701
  */
702 702
 function lsx_health_plan_single_nav() {
703
-	$tab_template_path = apply_filters( 'lsx_health_plan_single_nav_path', LSX_HEALTH_PLAN_PATH . '/templates/single-plan-tabs.php' );
704
-	if ( '' !== $tab_template_path ) {
703
+	$tab_template_path = apply_filters('lsx_health_plan_single_nav_path', LSX_HEALTH_PLAN_PATH . '/templates/single-plan-tabs.php');
704
+	if ('' !== $tab_template_path) {
705 705
 		require $tab_template_path;
706 706
 	}
707 707
 }
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
  * @return void
714 714
  */
715 715
 function lsx_health_plan_single_tabs() {
716
-	$endpoint = get_query_var( 'endpoint' );
717
-	switch ( $endpoint ) {
716
+	$endpoint = get_query_var('endpoint');
717
+	switch ($endpoint) {
718 718
 		case 'meal':
719 719
 			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-meal.php';
720 720
 			break;
@@ -735,8 +735,8 @@  discard block
 block discarded – undo
735 735
 			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-plan.php';
736 736
 			break;
737 737
 	}
738
-	$tab_template_path = apply_filters( 'lsx_health_plan_single_tab_path', $tab_template_path );
739
-	if ( '' !== $tab_template_path ) {
738
+	$tab_template_path = apply_filters('lsx_health_plan_single_tab_path', $tab_template_path);
739
+	if ('' !== $tab_template_path) {
740 740
 		include $tab_template_path;
741 741
 	}
742 742
 }
@@ -756,9 +756,9 @@  discard block
 block discarded – undo
756 756
  * @return recipe_type
757 757
  */
758 758
 function lsx_health_plan_recipe_type() {
759
-	$term_obj_list = get_the_terms( get_the_ID(), 'recipe-type' );
759
+	$term_obj_list = get_the_terms(get_the_ID(), 'recipe-type');
760 760
 	$recipe_type   = $term_obj_list[0]->name;
761
-	if ( ! empty( $recipe_type ) ) {
761
+	if ( ! empty($recipe_type)) {
762 762
 		return $recipe_type;
763 763
 	}
764 764
 }
@@ -770,32 +770,32 @@  discard block
 block discarded – undo
770 770
  * @param array $group
771 771
  * @return void
772 772
  */
773
-function lsx_health_plan_workout_video_play_button( $m, $group, $echo = true ) {
773
+function lsx_health_plan_workout_video_play_button($m, $group, $echo = true) {
774 774
 	$workout_video = '';
775 775
 	$giphy         = '';
776 776
 	$youtube       = '';
777
-	if ( isset( $group['connected_videos'] ) && '' !== $group['connected_videos'] ) {
778
-		$workout_video = esc_html( $group['connected_videos'] );
779
-		$giphy         = get_post_meta( $workout_video, 'video_giphy_source', true );
780
-		$youtube       = esc_url( get_post_meta( $workout_video, 'video_youtube_source', 1 ) );
781
-		$content       = get_post_field( 'post_content', $workout_video );
777
+	if (isset($group['connected_videos']) && '' !== $group['connected_videos']) {
778
+		$workout_video = esc_html($group['connected_videos']);
779
+		$giphy         = get_post_meta($workout_video, 'video_giphy_source', true);
780
+		$youtube       = esc_url(get_post_meta($workout_video, 'video_youtube_source', 1));
781
+		$content       = get_post_field('post_content', $workout_video);
782 782
 		$play_button   = '<button data-toggle="modal" data-target="#workout-video-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>';
783 783
 
784 784
 		$modal_body = '';
785
-		if ( ! empty( $giphy ) ) {
786
-			$giphy      = \lsx_health_plan\functions\get_video_url( $giphy );
785
+		if ( ! empty($giphy)) {
786
+			$giphy      = \lsx_health_plan\functions\get_video_url($giphy);
787 787
 			$modal_body = $giphy; // WPCS: XSS OK.
788
-		} elseif ( ! empty( $youtube ) ) {
789
-			$modal_body = wp_oembed_get( $youtube, array( // WPCS: XSS OK.
788
+		} elseif ( ! empty($youtube)) {
789
+			$modal_body = wp_oembed_get($youtube, array( // WPCS: XSS OK.
790 790
 				'width' => 480,
791
-			) );
791
+			));
792 792
 		}
793 793
 		$modal_body .= '<h5 class="modal-title title-lined">' . $group['name'] . '</h5>';
794 794
 		$modal_body .= $content;
795
-		\lsx_health_plan\functions\register_modal( 'workout-video-modal-' . $m, '', $modal_body );
795
+		\lsx_health_plan\functions\register_modal('workout-video-modal-' . $m, '', $modal_body);
796 796
 
797
-		if ( true === $echo ) {
798
-			echo wp_kses_post( $play_button );
797
+		if (true === $echo) {
798
+			echo wp_kses_post($play_button);
799 799
 		} else {
800 800
 			return $play_button;
801 801
 		}
@@ -809,17 +809,17 @@  discard block
 block discarded – undo
809 809
  */
810 810
 function lsx_health_plan_recipe_archive_description() {
811 811
 	$description = '';
812
-	if ( is_post_type_archive( 'recipe' ) ) {
813
-		$description = \lsx_health_plan\functions\get_option( 'recipe_archive_description', '' );
814
-	} elseif ( is_post_type_archive( 'exercise' ) ) {
815
-		$description = \lsx_health_plan\functions\get_option( 'exercise_archive_description', '' );
816
-	} elseif ( is_tax() ) {
812
+	if (is_post_type_archive('recipe')) {
813
+		$description = \lsx_health_plan\functions\get_option('recipe_archive_description', '');
814
+	} elseif (is_post_type_archive('exercise')) {
815
+		$description = \lsx_health_plan\functions\get_option('exercise_archive_description', '');
816
+	} elseif (is_tax()) {
817 817
 		$description = get_the_archive_description();
818 818
 	}
819
-	if ( '' !== $description ) {
819
+	if ('' !== $description) {
820 820
 		?>
821 821
 		<div class="lsx-hp-archive-description row">
822
-			<div class="col-xs-12 description-wrapper"><?php echo wp_kses_post( wpautop( $description ) ); ?></div>
822
+			<div class="col-xs-12 description-wrapper"><?php echo wp_kses_post(wpautop($description)); ?></div>
823 823
 		</div>
824 824
 		<?php
825 825
 	}
@@ -832,19 +832,19 @@  discard block
 block discarded – undo
832 832
  */
833 833
 function lsx_health_plan_workout_main_content() {
834 834
 	// Getting translated endpoint.
835
-	$workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
835
+	$workout = \lsx_health_plan\functions\get_option('endpoint_workout', 'workout');
836 836
 
837
-	$connected_members = get_post_meta( get_the_ID(), ( $workout . '_connected_team_member' ), true );
838
-	$small_description = get_post_meta( get_the_ID(), ( $workout . '_short_description' ), true );
837
+	$connected_members = get_post_meta(get_the_ID(), ($workout . '_connected_team_member'), true);
838
+	$small_description = get_post_meta(get_the_ID(), ($workout . '_short_description'), true);
839 839
 
840 840
 	$content = '';
841
-	if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
841
+	if ($small_description || $connected_members || lsx_health_plan_has_tips()) {
842 842
 		$content .= '<div class="short-desc set-box set content-box entry-content">';
843 843
 		$content .= '<div class="the-content">';
844
-		$content .= lsx_hp_member_connected( $connected_members, $workout );
844
+		$content .= lsx_hp_member_connected($connected_members, $workout);
845 845
 		$content .= '<span>' . $small_description . '</span>';
846 846
 		$content .= '</div>';
847
-		$content .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
847
+		$content .= do_shortcode('[lsx_health_plan_featured_tips_block]');
848 848
 		$content .= '</div>';
849 849
 	}
850 850
 	return $content;
@@ -857,19 +857,19 @@  discard block
 block discarded – undo
857 857
  */
858 858
 function lsx_health_plan_meal_main_content() {
859 859
 	// Getting translated endpoint.
860
-	$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
860
+	$meal = \lsx_health_plan\functions\get_option('endpoint_meal', 'meal');
861 861
 
862
-	$connected_members = get_post_meta( get_the_ID(), ( $meal . '_connected_team_member' ), true );
863
-	$small_description = get_post_meta( get_the_ID(), ( $meal . '_short_description' ), true );
862
+	$connected_members = get_post_meta(get_the_ID(), ($meal . '_connected_team_member'), true);
863
+	$small_description = get_post_meta(get_the_ID(), ($meal . '_short_description'), true);
864 864
 
865 865
 	$content_meal = '';
866
-	if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
866
+	if ($small_description || $connected_members || lsx_health_plan_has_tips()) {
867 867
 		$content_meal .= '<div class="set-box set content-box entry-content">';
868 868
 		$content_meal .= '<div class="the-content">';
869
-		$content_meal .= lsx_hp_member_connected( $connected_members, $meal );
869
+		$content_meal .= lsx_hp_member_connected($connected_members, $meal);
870 870
 		$content_meal .= '<span>' . $small_description . '</span>';
871 871
 		$content_meal .= '</div>';
872
-		$content_meal .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
872
+		$content_meal .= do_shortcode('[lsx_health_plan_featured_tips_block]');
873 873
 		$content_meal .= '</div>';
874 874
 	}
875 875
 	return $content_meal;
@@ -882,21 +882,21 @@  discard block
 block discarded – undo
882 882
  * @param  string $index
883 883
  * @return void
884 884
  */
885
-function lsx_health_plan_workout_tab_content( $index = 1 ) {
886
-	global $group_name,$shortcode_args;
885
+function lsx_health_plan_workout_tab_content($index = 1) {
886
+	global $group_name, $shortcode_args;
887 887
 	$group_name = 'workout_section_' . $index;
888
-	if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
889
-		$layout = strtolower( \lsx_health_plan\functions\get_option( 'workout_tab_layout', 'table' ) );
888
+	if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) {
889
+		$layout = strtolower(\lsx_health_plan\functions\get_option('workout_tab_layout', 'table'));
890 890
 
891 891
 		// Check for shortcode overrides.
892
-		if ( null !== $shortcode_args && isset( $shortcode_args['layout'] ) ) {
892
+		if (null !== $shortcode_args && isset($shortcode_args['layout'])) {
893 893
 			$layout = $shortcode_args['layout'];
894 894
 		}
895 895
 	} else {
896 896
 		$layout = 'table';
897 897
 	}
898 898
 
899
-	switch ( $layout ) {
899
+	switch ($layout) {
900 900
 		case 'list':
901 901
 			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-list.php';
902 902
 			break;
@@ -909,8 +909,8 @@  discard block
 block discarded – undo
909 909
 			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-table.php';
910 910
 			break;
911 911
 	}
912
-	$tab_template_path = apply_filters( 'lsx_health_plan_workout_tab_content_path', $tab_template_path );
913
-	if ( '' !== $tab_template_path ) {
912
+	$tab_template_path = apply_filters('lsx_health_plan_workout_tab_content_path', $tab_template_path);
913
+	if ('' !== $tab_template_path) {
914 914
 		include $tab_template_path;
915 915
 	}
916 916
 }
@@ -921,26 +921,26 @@  discard block
 block discarded – undo
921 921
  * @return void
922 922
  */
923 923
 function lsx_health_plan_workout_sets() {
924
-	if ( is_singular( 'workout' ) ) {
924
+	if (is_singular('workout')) {
925 925
 		global $connected_workouts;
926
-		$connected_workouts = array( get_the_ID() );
926
+		$connected_workouts = array(get_the_ID());
927 927
 	}
928
-	if ( is_singular( 'plan' ) ) {
928
+	if (is_singular('plan')) {
929 929
 
930 930
 		global $connected_workouts;
931 931
 
932
-		$section_key  = get_query_var( 'section' );
933
-		if ( '' !== $section && \lsx_health_plan\functions\plan\has_sections() ) {
934
-			$section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key );
935
-			if ( isset( $section_info['connected_workouts'] ) && '' !== $section_info['connected_workouts'] ) {
932
+		$section_key = get_query_var('section');
933
+		if ('' !== $section && \lsx_health_plan\functions\plan\has_sections()) {
934
+			$section_info = \lsx_health_plan\functions\plan\get_section_info($section_key);
935
+			if (isset($section_info['connected_workouts']) && '' !== $section_info['connected_workouts']) {
936 936
 
937
-				$connected_workouts = \lsx_health_plan\functions\prep_array( $section_info['connected_workouts'] );
937
+				$connected_workouts = \lsx_health_plan\functions\prep_array($section_info['connected_workouts']);
938 938
 			}
939 939
 		}
940 940
 	}
941 941
 	$template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
942
-	$template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
943
-	if ( '' !== $template_path && ! empty( $template_path ) ) {
942
+	$template_path = apply_filters('lsx_health_plan_workout_set_template_path', $template_path);
943
+	if ('' !== $template_path && ! empty($template_path)) {
944 944
 		include $template_path;
945 945
 	}
946 946
 }
@@ -951,11 +951,11 @@  discard block
 block discarded – undo
951 951
  * @param [type] $connected_workouts
952 952
  * @return void
953 953
  */
954
-function lsx_health_plan_warmup_sets( $connected_workouts ) {
954
+function lsx_health_plan_warmup_sets($connected_workouts) {
955 955
 	
956 956
 	$template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
957
-	$template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
958
-	if ( '' !== $template_path && ! empty( $template_path ) ) {
957
+	$template_path = apply_filters('lsx_health_plan_workout_set_template_path', $template_path);
958
+	if ('' !== $template_path && ! empty($template_path)) {
959 959
 		include $template_path;
960 960
 	}
961 961
 }
@@ -966,46 +966,46 @@  discard block
 block discarded – undo
966 966
  * @param array $args
967 967
  * @return void
968 968
  */
969
-function lsx_hp_meal_plan_recipes( $args = array() ) {
969
+function lsx_hp_meal_plan_recipes($args = array()) {
970 970
 	$defaults = array(
971 971
 		'meal_id'   => false,
972 972
 		'meal_time' => '',
973 973
 		'modal'     => true,
974 974
 	);
975
-	$args     = wp_parse_args( $args, $defaults );
975
+	$args = wp_parse_args($args, $defaults);
976 976
 	// Looking for recipes.
977
-	$connected_recipes = get_post_meta( $args['meal_id'], $args['meal_time'] . '_recipes', true );
978
-	if ( ! empty( $connected_recipes ) ) {
979
-		$query_args    = array(
977
+	$connected_recipes = get_post_meta($args['meal_id'], $args['meal_time'] . '_recipes', true);
978
+	if ( ! empty($connected_recipes)) {
979
+		$query_args = array(
980 980
 			'orderby'   => 'date',
981 981
 			'order'     => 'DESC',
982 982
 			'post_type' => 'recipe',
983 983
 			'post__in'  => $connected_recipes,
984 984
 		);
985
-		$recipes = new WP_Query( $query_args );
985
+		$recipes = new WP_Query($query_args);
986 986
 		?>
987 987
 		<div class="recipes">
988 988
 			<div class="row eating-row">
989 989
 			<?php
990
-			if ( $recipes->have_posts() ) {
991
-				while ( $recipes->have_posts() ) {
990
+			if ($recipes->have_posts()) {
991
+				while ($recipes->have_posts()) {
992 992
 					$recipes->the_post();
993
-					if ( false !== $args['modal'] ) {
993
+					if (false !== $args['modal']) {
994 994
 						\lsx_health_plan\functions\recipes\register_recipe_modal();
995 995
 					}
996 996
 					?>
997 997
 					<div class="recipe-column">
998
-						<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">
998
+						<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">
999 999
 							<div class="recipe-feature-img">
1000 1000
 								<?php
1001 1001
 								$featured_image = get_the_post_thumbnail();
1002
-								if ( ! empty( $featured_image ) && '' !== $featured_image ) {
1003
-									the_post_thumbnail( 'lsx-thumbnail-square', array(
1002
+								if ( ! empty($featured_image) && '' !== $featured_image) {
1003
+									the_post_thumbnail('lsx-thumbnail-square', array(
1004 1004
 										'class' => 'aligncenter',
1005
-									) );
1005
+									));
1006 1006
 								} else {
1007 1007
 									?>
1008
-									<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __DIR__ ) . 'assets/images/placeholder.jpg' ); ?>">
1008
+									<img loading="lazy" class="placeholder" src="<?php echo esc_attr(plugin_dir_url(__DIR__) . 'assets/images/placeholder.jpg'); ?>">
1009 1009
 									<?php
1010 1010
 								}
1011 1011
 								?>
@@ -1031,25 +1031,25 @@  discard block
 block discarded – undo
1031 1031
 /**
1032 1032
  * Output the connected.
1033 1033
  */
1034
-function lsx_hp_recipe_plan_meta( $args = array() ) {
1034
+function lsx_hp_recipe_plan_meta($args = array()) {
1035 1035
 	$defaults = array();
1036 1036
 	$top_level_plans = array();
1037 1037
 	// Get meals this exercise is connected to.
1038
-	$plans = get_post_meta( get_the_ID(), 'connected_plans', true );
1039
-	if ( ! empty( $plans ) ) {
1040
-		$plan       = end( $plans );
1041
-		$has_parent = wp_get_post_parent_id( $plan );
1042
-		if ( 0 === $has_parent ) {
1038
+	$plans = get_post_meta(get_the_ID(), 'connected_plans', true);
1039
+	if ( ! empty($plans)) {
1040
+		$plan       = end($plans);
1041
+		$has_parent = wp_get_post_parent_id($plan);
1042
+		if (0 === $has_parent) {
1043 1043
 			$top_level_plans[] = $plan;
1044
-		} elseif ( false !== $top_level_plans ) {
1044
+		} elseif (false !== $top_level_plans) {
1045 1045
 			$top_level_plans[] = $has_parent;
1046 1046
 		}
1047 1047
 	}
1048
-	if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
1049
-		$top_level_plans = array_unique( $top_level_plans );
1050
-		$top_level_plan  = end( $top_level_plans );
1048
+	if ( ! empty($top_level_plans) && ('' !== $top_level_plans)) {
1049
+		$top_level_plans = array_unique($top_level_plans);
1050
+		$top_level_plan  = end($top_level_plans);
1051 1051
 		?>
1052
-			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1052
+			<span class="recipe-type recipe-parent"><?php echo esc_html(get_the_title($top_level_plan)); ?></span>
1053 1053
 		<?php
1054 1054
 	}
1055 1055
 }
@@ -1062,23 +1062,23 @@  discard block
 block discarded – undo
1062 1062
 	$top_level_plans = array();
1063 1063
 
1064 1064
 	// Get workouts this exercise is connected to.
1065
-	$workouts = get_post_meta( get_the_ID(), 'connected_workouts', true );
1065
+	$workouts = get_post_meta(get_the_ID(), 'connected_workouts', true);
1066 1066
 
1067
-	if ( '' !== $workouts && ! is_array( $workouts ) ) {
1068
-		$workouts = array( $workouts );
1067
+	if ('' !== $workouts && ! is_array($workouts)) {
1068
+		$workouts = array($workouts);
1069 1069
 	}
1070
-	if ( ! empty( $workouts ) ) {
1071
-		foreach ( $workouts as $workout ) {
1070
+	if ( ! empty($workouts)) {
1071
+		foreach ($workouts as $workout) {
1072 1072
 			// Get the plans this workout is connected to.
1073
-			$plans = get_post_meta( $workout, 'connected_plans', true );
1073
+			$plans = get_post_meta($workout, 'connected_plans', true);
1074 1074
 
1075
-			if ( '' !== $plans && ! is_array( $plans ) ) {
1076
-				$plans = array( $plans );
1075
+			if ('' !== $plans && ! is_array($plans)) {
1076
+				$plans = array($plans);
1077 1077
 			}
1078
-			if ( ! empty( $plans ) ) {
1079
-				foreach ( $plans as $plan ) {
1080
-					$has_parent = wp_get_post_parent_id( $plan );
1081
-					if ( 0 === $has_parent ) {
1078
+			if ( ! empty($plans)) {
1079
+				foreach ($plans as $plan) {
1080
+					$has_parent = wp_get_post_parent_id($plan);
1081
+					if (0 === $has_parent) {
1082 1082
 						$top_level_plans = $plan;
1083 1083
 					} else {
1084 1084
 						$top_level_plans = $has_parent;
@@ -1088,11 +1088,11 @@  discard block
 block discarded – undo
1088 1088
 		}
1089 1089
 	}
1090 1090
 
1091
-	if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
1092
-		$top_level_plans = array_unique( $top_level_plans );
1093
-		$top_level_plan  = end( $top_level_plans );
1091
+	if ( ! empty($top_level_plans) && ('' !== $top_level_plans)) {
1092
+		$top_level_plans = array_unique($top_level_plans);
1093
+		$top_level_plan  = end($top_level_plans);
1094 1094
 		?>
1095
-			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1095
+			<span class="recipe-type recipe-parent"><?php echo esc_html(get_the_title($top_level_plan)); ?></span>
1096 1096
 		<?php
1097 1097
 	}
1098 1098
 }
@@ -1103,12 +1103,12 @@  discard block
 block discarded – undo
1103 1103
  * @param [type] $related_content
1104 1104
  * @return void
1105 1105
  */
1106
-function lsx_hp_single_related( $related_content, $post_type_text ) {
1106
+function lsx_hp_single_related($related_content, $post_type_text) {
1107 1107
 	?>
1108 1108
 	<section id="lsx-hp-related">
1109 1109
 		<div class="row lsx-related-posts lsx-related-posts-title">
1110 1110
 			<div class="col-xs-12">
1111
-				<h2 class="lsx-related-posts-headline"><?php echo esc_html( $post_type_text ); ?></h2>
1111
+				<h2 class="lsx-related-posts-headline"><?php echo esc_html($post_type_text); ?></h2>
1112 1112
 			</div>
1113 1113
 		</div>
1114 1114
 		<div class="row lsx-related-posts lsx-related-posts-content">
@@ -1116,26 +1116,26 @@  discard block
 block discarded – undo
1116 1116
 				<div class="lsx-related-posts-wrapper">
1117 1117
 					<?php
1118 1118
 					$i = 0;
1119
-					foreach ( $related_content as $article ) {
1120
-						$post_title      = get_the_title( $article );
1121
-						$post_categories = wp_get_post_categories( $article );
1122
-						$post_link       = get_permalink( $article );
1119
+					foreach ($related_content as $article) {
1120
+						$post_title      = get_the_title($article);
1121
+						$post_categories = wp_get_post_categories($article);
1122
+						$post_link       = get_permalink($article);
1123 1123
 
1124 1124
 						$cats = array();
1125 1125
 						?>
1126
-						<article id="post-<?php echo esc_html( $article ); ?>" class="lsx-slot post">
1126
+						<article id="post-<?php echo esc_html($article); ?>" class="lsx-slot post">
1127 1127
 							<div class="entry-layout lsx-hp-shadow">
1128 1128
 								<div class="entry-layout-content">
1129 1129
 									<header class="entry-header">
1130 1130
 										<div class="entry-image">
1131
-											<a href="<?php echo esc_url( $post_link ); ?>" class="thumbnail">
1131
+											<a href="<?php echo esc_url($post_link); ?>" class="thumbnail">
1132 1132
 											<?php
1133
-											$featured_image = get_the_post_thumbnail( $article, 'lsx-thumbnail-wide' );
1134
-											if ( ! empty( $featured_image ) && '' !== $featured_image ) {
1135
-												echo wp_kses_post( $featured_image );
1133
+											$featured_image = get_the_post_thumbnail($article, 'lsx-thumbnail-wide');
1134
+											if ( ! empty($featured_image) && '' !== $featured_image) {
1135
+												echo wp_kses_post($featured_image);
1136 1136
 											} else {
1137 1137
 												?>
1138
-												<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
1138
+												<img loading="lazy" class="placeholder" src="<?php echo esc_attr(plugin_dir_url(__FILE__) . '../assets/images/placeholder.jpg'); ?>">
1139 1139
 												<?php
1140 1140
 											}
1141 1141
 											?>
@@ -1143,18 +1143,18 @@  discard block
 block discarded – undo
1143 1143
 										</div>
1144 1144
 										<div class="entry-meta">
1145 1145
 										<?php
1146
-										foreach ( $post_categories as $c ) {
1147
-											$cat = get_category( $c );
1146
+										foreach ($post_categories as $c) {
1147
+											$cat = get_category($c);
1148 1148
 											/* Translators: %s: category name */
1149
-											$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>';
1149
+											$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>';
1150 1150
 										}
1151
-										if ( ! empty( $cats ) ) { ?>
1152
-											<div class="post-categories"><span></span><?php echo wp_kses_post( implode( ', ', $cats ) ); ?></div>
1151
+										if ( ! empty($cats)) { ?>
1152
+											<div class="post-categories"><span></span><?php echo wp_kses_post(implode(', ', $cats)); ?></div>
1153 1153
 										<?php } ?>
1154 1154
 										</div>
1155 1155
 										<h2 class="entry-title">
1156
-											<a href="<?php echo esc_url( $post_link ); ?>">
1157
-												<?php echo esc_html( $post_title ); ?>
1156
+											<a href="<?php echo esc_url($post_link); ?>">
1157
+												<?php echo esc_html($post_title); ?>
1158 1158
 											</a>
1159 1159
 										</h2>
1160 1160
 									</header>
@@ -1178,27 +1178,27 @@  discard block
 block discarded – undo
1178 1178
  * @param [type] $connected_members
1179 1179
  * @return void
1180 1180
  */
1181
-function lsx_hp_member_connected( $connected_members, $post_type ) {
1182
-	if ( ! empty( $connected_members ) ) {
1181
+function lsx_hp_member_connected($connected_members, $post_type) {
1182
+	if ( ! empty($connected_members)) {
1183 1183
 		$content = '<div id="hp-connected-members" class="hp-connected-members connected-' . $post_type . '">';
1184
-		foreach ( $connected_members as $member ) {
1185
-			$post_link   = get_permalink( $member );
1186
-			$member_name = get_the_title( $member );
1184
+		foreach ($connected_members as $member) {
1185
+			$post_link   = get_permalink($member);
1186
+			$member_name = get_the_title($member);
1187 1187
 			$member_name = '<span class="lsx-team-name">' . $member_name . '</span>';
1188 1188
 
1189 1189
 			$member_link = '<a href="' . $post_link . '" >' . $member_name . '</a>';
1190 1190
 
1191 1191
 			$roles = '';
1192
-			$terms = get_the_terms( $member, 'team_role' );
1192
+			$terms = get_the_terms($member, 'team_role');
1193 1193
 
1194
-			if ( $terms && ! is_wp_error( $terms ) ) {
1194
+			if ($terms && ! is_wp_error($terms)) {
1195 1195
 				$roles = array();
1196 1196
 
1197
-				foreach ( $terms as $term ) {
1197
+				foreach ($terms as $term) {
1198 1198
 					$roles[] = $term->name;
1199 1199
 				}
1200 1200
 
1201
-				$roles = join( ', ', $roles );
1201
+				$roles = join(', ', $roles);
1202 1202
 			}
1203 1203
 			$member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : '';
1204 1204
 
Please login to merge, or discard this patch.
classes/post-types/class-meal.php 2 patches
Indentation   +444 added lines, -444 removed lines patch added patch discarded remove patch
@@ -8,477 +8,477 @@
 block discarded – undo
8 8
  */
9 9
 class Meal {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\Meal()
17
-	 */
18
-	protected static $instance = null;
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @since 1.0.0
15
+      *
16
+      * @var      object \lsx_health_plan\classes\Meal()
17
+      */
18
+     protected static $instance = null;
19 19
 
20
-	/**
21
-	 * Holds post_type slug used as an index
22
-	 *
23
-	 * @since 1.0.0
24
-	 *
25
-	 * @var      string
26
-	 */
27
-	public $slug = 'meal';
20
+     /**
21
+      * Holds post_type slug used as an index
22
+      *
23
+      * @since 1.0.0
24
+      *
25
+      * @var      string
26
+      */
27
+     public $slug = 'meal';
28 28
 
29
-	/**
30
-	 * Constructor
31
-	 */
32
-	public function __construct() {
33
-		add_action( 'init', array( $this, 'register_post_type' ) );
34
-		add_action( 'init', array( $this, 'taxonomy_setup' ) );
29
+     /**
30
+      * Constructor
31
+      */
32
+     public function __construct() {
33
+          add_action( 'init', array( $this, 'register_post_type' ) );
34
+          add_action( 'init', array( $this, 'taxonomy_setup' ) );
35 35
 		
36
-		add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
37
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
38
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
36
+          add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
37
+          add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
38
+          add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
39 39
 
40
-		// Template Redirects.
41
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
42
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
40
+          // Template Redirects.
41
+          add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
42
+          add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
43 43
 
44
-		add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
45
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
44
+          add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
45
+          add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
46 46
 
47
-		//Breadcrumbs
48
-		add_filter( 'wpseo_breadcrumb_links', array( $this, 'meal_breadcrumb_filter' ), 30, 1 );
49
-		add_filter( 'woocommerce_get_breadcrumb', array( $this, 'meal_breadcrumb_filter' ), 30, 1 );
50
-	}
47
+          //Breadcrumbs
48
+          add_filter( 'wpseo_breadcrumb_links', array( $this, 'meal_breadcrumb_filter' ), 30, 1 );
49
+          add_filter( 'woocommerce_get_breadcrumb', array( $this, 'meal_breadcrumb_filter' ), 30, 1 );
50
+     }
51 51
 
52
-	/**
53
-	 * Return an instance of this class.
54
-	 *
55
-	 * @since 1.0.0
56
-	 *
57
-	 * @return    object \lsx_health_plan\classes\Day()    A single instance of this class.
58
-	 */
59
-	public static function get_instance() {
60
-		// If the single instance hasn't been set, set it now.
61
-		if ( null === self::$instance ) {
62
-			self::$instance = new self();
63
-		}
64
-		return self::$instance;
65
-	}
66
-	/**
67
-	 * Register the post type.
68
-	 */
69
-	public function register_post_type() {
70
-		$labels = array(
71
-			'name'               => esc_html__( 'Meals', 'lsx-health-plan' ),
72
-			'singular_name'      => esc_html__( 'Meal', 'lsx-health-plan' ),
73
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
74
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
75
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
76
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
77
-			'all_items'          => esc_html__( 'All Meals', 'lsx-health-plan' ),
78
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
79
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
80
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
81
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
82
-			'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
83
-			'menu_name'          => esc_html__( 'Meals', 'lsx-health-plan' ),
84
-		);
85
-		$args   = array(
86
-			'labels'             => $labels,
87
-			'public'             => true,
88
-			'publicly_queryable' => true,
89
-			'show_ui'            => true,
90
-			'show_in_menu'       => true,
91
-			'show_in_rest'       => true,
92
-			'menu_icon'          => 'dashicons-carrot',
93
-			'query_var'          => true,
94
-			'rewrite'            => array(
95
-				'slug' => \lsx_health_plan\functions\get_option( 'meal_single_slug', 'meal' ),
96
-			),
97
-			'capability_type'    => 'page',
98
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meals' ),
99
-			'hierarchical'       => true,
100
-			'menu_position'      => null,
101
-			'supports'           => array(
102
-				'title',
103
-				'editor',
104
-				'thumbnail',
105
-				'page-attributes',
106
-				'custom-fields',
107
-			),
108
-		);
109
-		register_post_type( 'meal', $args );
110
-	}
52
+     /**
53
+      * Return an instance of this class.
54
+      *
55
+      * @since 1.0.0
56
+      *
57
+      * @return    object \lsx_health_plan\classes\Day()    A single instance of this class.
58
+      */
59
+     public static function get_instance() {
60
+          // If the single instance hasn't been set, set it now.
61
+          if ( null === self::$instance ) {
62
+               self::$instance = new self();
63
+          }
64
+          return self::$instance;
65
+     }
66
+     /**
67
+      * Register the post type.
68
+      */
69
+     public function register_post_type() {
70
+          $labels = array(
71
+               'name'               => esc_html__( 'Meals', 'lsx-health-plan' ),
72
+               'singular_name'      => esc_html__( 'Meal', 'lsx-health-plan' ),
73
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
74
+               'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
75
+               'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
76
+               'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
77
+               'all_items'          => esc_html__( 'All Meals', 'lsx-health-plan' ),
78
+               'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
79
+               'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
80
+               'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
81
+               'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
82
+               'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
83
+               'menu_name'          => esc_html__( 'Meals', 'lsx-health-plan' ),
84
+          );
85
+          $args   = array(
86
+               'labels'             => $labels,
87
+               'public'             => true,
88
+               'publicly_queryable' => true,
89
+               'show_ui'            => true,
90
+               'show_in_menu'       => true,
91
+               'show_in_rest'       => true,
92
+               'menu_icon'          => 'dashicons-carrot',
93
+               'query_var'          => true,
94
+               'rewrite'            => array(
95
+                    'slug' => \lsx_health_plan\functions\get_option( 'meal_single_slug', 'meal' ),
96
+               ),
97
+               'capability_type'    => 'page',
98
+               'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meals' ),
99
+               'hierarchical'       => true,
100
+               'menu_position'      => null,
101
+               'supports'           => array(
102
+                    'title',
103
+                    'editor',
104
+                    'thumbnail',
105
+                    'page-attributes',
106
+                    'custom-fields',
107
+               ),
108
+          );
109
+          register_post_type( 'meal', $args );
110
+     }
111 111
 
112
-	/**
113
-	 * Register the Meal Type taxonomy.
114
-	 */
115
-	public function taxonomy_setup() {
116
-		$labels = array(
117
-			'name'              => esc_html_x( 'Meal Type', 'taxonomy general name', 'lsx-health-plan' ),
118
-			'singular_name'     => esc_html_x( 'Meal Types', 'taxonomy singular name', 'lsx-health-plan' ),
119
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
120
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
121
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
122
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
123
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
124
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
125
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
126
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
127
-			'menu_name'         => esc_html__( 'Meal Types', 'lsx-health-plan' ),
128
-		);
129
-		$args   = array(
130
-			'hierarchical'      => true,
131
-			'labels'            => $labels,
132
-			'show_ui'           => true,
133
-			'show_in_menu'      => 'edit.php?post_type=meal',
134
-			'show_admin_column' => true,
135
-			'query_var'         => true,
136
-			'rewrite'           => array(
137
-				'slug' => 'meal-type',
138
-			),
139
-		);
140
-		register_taxonomy( 'meal-type', array( $this->slug ), $args );
141
-	}
112
+     /**
113
+      * Register the Meal Type taxonomy.
114
+      */
115
+     public function taxonomy_setup() {
116
+          $labels = array(
117
+               'name'              => esc_html_x( 'Meal Type', 'taxonomy general name', 'lsx-health-plan' ),
118
+               'singular_name'     => esc_html_x( 'Meal Types', 'taxonomy singular name', 'lsx-health-plan' ),
119
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
120
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
121
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
122
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
123
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
124
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
125
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
126
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
127
+               'menu_name'         => esc_html__( 'Meal Types', 'lsx-health-plan' ),
128
+          );
129
+          $args   = array(
130
+               'hierarchical'      => true,
131
+               'labels'            => $labels,
132
+               'show_ui'           => true,
133
+               'show_in_menu'      => 'edit.php?post_type=meal',
134
+               'show_admin_column' => true,
135
+               'query_var'         => true,
136
+               'rewrite'           => array(
137
+                    'slug' => 'meal-type',
138
+               ),
139
+          );
140
+          register_taxonomy( 'meal-type', array( $this->slug ), $args );
141
+     }
142 142
 
143
-	/**
144
-	 * Adds the post type to the different arrays.
145
-	 *
146
-	 * @param array $post_types
147
-	 * @return array
148
-	 */
149
-	public function enable_post_type( $post_types = array() ) {
150
-		$post_types[] = $this->slug;
151
-		return $post_types;
152
-	}
143
+     /**
144
+      * Adds the post type to the different arrays.
145
+      *
146
+      * @param array $post_types
147
+      * @return array
148
+      */
149
+     public function enable_post_type( $post_types = array() ) {
150
+          $post_types[] = $this->slug;
151
+          return $post_types;
152
+     }
153 153
 
154
-	/**
155
-	 * Enables the Bi Directional relationships
156
-	 *
157
-	 * @param array $connections
158
-	 * @return void
159
-	 */
160
-	public function enable_connections( $connections = array() ) {
161
-		$connections['meal']['connected_plans'] = 'connected_meals';
162
-		$connections['plan']['connected_meals'] = 'connected_plans';
163
-		return $connections;
164
-	}
154
+     /**
155
+      * Enables the Bi Directional relationships
156
+      *
157
+      * @param array $connections
158
+      * @return void
159
+      */
160
+     public function enable_connections( $connections = array() ) {
161
+          $connections['meal']['connected_plans'] = 'connected_meals';
162
+          $connections['plan']['connected_meals'] = 'connected_plans';
163
+          return $connections;
164
+     }
165 165
 
166
-	/**
167
-	 * Remove the "Archives:" from the post type meal.
168
-	 *
169
-	 * @param string $title the term title.
170
-	 * @return string
171
-	 */
172
-	public function get_the_archive_title( $title ) {
173
-		if ( is_post_type_archive( 'meal' ) ) {
174
-			$title = __( 'Meals', 'lsx-health-plan' );
175
-		}
176
-		return $title;
177
-	}
166
+     /**
167
+      * Remove the "Archives:" from the post type meal.
168
+      *
169
+      * @param string $title the term title.
170
+      * @return string
171
+      */
172
+     public function get_the_archive_title( $title ) {
173
+          if ( is_post_type_archive( 'meal' ) ) {
174
+               $title = __( 'Meals', 'lsx-health-plan' );
175
+          }
176
+          return $title;
177
+     }
178 178
 
179
-	/**
180
-	 * Define the metabox and field configurations.
181
-	 */
182
-	public function featured_metabox() {
183
-		$cmb = new_cmb2_box(
184
-			array(
185
-				'id'           => $this->slug . '_featured_metabox_meal',
186
-				'title'        => __( 'Featured Meal', 'lsx-health-plan' ),
187
-				'object_types' => array( $this->slug ), // Post type
188
-				'context'      => 'side',
189
-				'priority'     => 'high',
190
-				'show_names'   => true,
191
-			)
192
-		);
193
-		$cmb->add_field(
194
-			array(
195
-				'name'       => __( 'Featured Meal', 'lsx-health-plan' ),
196
-				'desc'       => __( 'Enable a featured meal' ),
197
-				'id'         => $this->slug . '_featured_meal',
198
-				'type'       => 'checkbox',
199
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
200
-			)
201
-		);
202
-	}
179
+     /**
180
+      * Define the metabox and field configurations.
181
+      */
182
+     public function featured_metabox() {
183
+          $cmb = new_cmb2_box(
184
+               array(
185
+                    'id'           => $this->slug . '_featured_metabox_meal',
186
+                    'title'        => __( 'Featured Meal', 'lsx-health-plan' ),
187
+                    'object_types' => array( $this->slug ), // Post type
188
+                    'context'      => 'side',
189
+                    'priority'     => 'high',
190
+                    'show_names'   => true,
191
+               )
192
+          );
193
+          $cmb->add_field(
194
+               array(
195
+                    'name'       => __( 'Featured Meal', 'lsx-health-plan' ),
196
+                    'desc'       => __( 'Enable a featured meal' ),
197
+                    'id'         => $this->slug . '_featured_meal',
198
+                    'type'       => 'checkbox',
199
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
200
+               )
201
+          );
202
+     }
203 203
 
204
-	/**
205
-	 * Define the metabox and field configurations.
206
-	 */
207
-	public function details_metaboxes() {
208
-		$cmb = new_cmb2_box( array(
209
-			'id'           => $this->slug . '_shopping_list_metabox',
210
-			'title'        => __( 'Shopping List', 'lsx-health-plan' ),
211
-			'object_types' => array( $this->slug ), // Post type
212
-			'context'      => 'normal',
213
-			'priority'     => 'high',
214
-			'show_names'   => true,
215
-		) );
216
-		$cmb->add_field( array(
217
-			'name'       => __( 'Shopping List', 'lsx-health-plan' ),
218
-			'desc'       => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ),
219
-			'id'         => $this->slug . '_shopping_list',
220
-			'type'       => 'post_search_ajax',
221
-			// Optional :
222
-			'limit'      => 1,  // Limit selection to X items only (default 1)
223
-			'sortable'   => true, // Allow selected items to be sortable (default false)
224
-			'query_args' => array(
225
-				'post_type'      => array( 'page' ),
226
-				'post_status'    => array( 'publish' ),
227
-				'posts_per_page' => -1,
228
-			),
229
-		) );
230
-		$cmb = new_cmb2_box( array(
231
-			'id'           => $this->slug . '_details_metabox',
232
-			'title'        => __( 'Meal Details', 'lsx-health-plan' ),
233
-			'object_types' => array( $this->slug ), // Post type
234
-			'context'      => 'normal',
235
-			'priority'     => 'high',
236
-			'show_names'   => true,
237
-		) );
204
+     /**
205
+      * Define the metabox and field configurations.
206
+      */
207
+     public function details_metaboxes() {
208
+          $cmb = new_cmb2_box( array(
209
+               'id'           => $this->slug . '_shopping_list_metabox',
210
+               'title'        => __( 'Shopping List', 'lsx-health-plan' ),
211
+               'object_types' => array( $this->slug ), // Post type
212
+               'context'      => 'normal',
213
+               'priority'     => 'high',
214
+               'show_names'   => true,
215
+          ) );
216
+          $cmb->add_field( array(
217
+               'name'       => __( 'Shopping List', 'lsx-health-plan' ),
218
+               'desc'       => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ),
219
+               'id'         => $this->slug . '_shopping_list',
220
+               'type'       => 'post_search_ajax',
221
+               // Optional :
222
+               'limit'      => 1,  // Limit selection to X items only (default 1)
223
+               'sortable'   => true, // Allow selected items to be sortable (default false)
224
+               'query_args' => array(
225
+                    'post_type'      => array( 'page' ),
226
+                    'post_status'    => array( 'publish' ),
227
+                    'posts_per_page' => -1,
228
+               ),
229
+          ) );
230
+          $cmb = new_cmb2_box( array(
231
+               'id'           => $this->slug . '_details_metabox',
232
+               'title'        => __( 'Meal Details', 'lsx-health-plan' ),
233
+               'object_types' => array( $this->slug ), // Post type
234
+               'context'      => 'normal',
235
+               'priority'     => 'high',
236
+               'show_names'   => true,
237
+          ) );
238 238
 
239
-		$cmb->add_field( array(
240
-			'name' => __( 'Meal Short Description', 'lsx-health-plan' ),
241
-			'id'   => $this->slug . '_short_description',
242
-			'type' => 'textarea_small',
243
-			'desc' => __( 'Add a small description for this meal (optional)', 'lsx-health-plan' ),
244
-		) );
239
+          $cmb->add_field( array(
240
+               'name' => __( 'Meal Short Description', 'lsx-health-plan' ),
241
+               'id'   => $this->slug . '_short_description',
242
+               'type' => 'textarea_small',
243
+               'desc' => __( 'Add a small description for this meal (optional)', 'lsx-health-plan' ),
244
+          ) );
245 245
 
246
-		$cmb->add_field( array(
247
-			'name'       => __( 'Pre Breakfast Snack', 'lsx-health-plan' ),
248
-			'id'         => $this->slug . '_pre_breakfast_snack',
249
-			'type'       => 'wysiwyg',
250
-			'show_on_cb' => 'cmb2_hide_if_no_cats',
251
-			'options'    => array(
252
-				'textarea_rows' => 5,
253
-			),
254
-		) );
255
-		$cmb->add_field( array(
256
-			'name'       => __( 'Breakfast', 'lsx-health-plan' ),
257
-			'id'         => $this->slug . '_breakfast',
258
-			'type'       => 'wysiwyg',
259
-			'show_on_cb' => 'cmb2_hide_if_no_cats',
260
-			'options'    => array(
261
-				'textarea_rows' => 5,
262
-			),
263
-		) );
246
+          $cmb->add_field( array(
247
+               'name'       => __( 'Pre Breakfast Snack', 'lsx-health-plan' ),
248
+               'id'         => $this->slug . '_pre_breakfast_snack',
249
+               'type'       => 'wysiwyg',
250
+               'show_on_cb' => 'cmb2_hide_if_no_cats',
251
+               'options'    => array(
252
+                    'textarea_rows' => 5,
253
+               ),
254
+          ) );
255
+          $cmb->add_field( array(
256
+               'name'       => __( 'Breakfast', 'lsx-health-plan' ),
257
+               'id'         => $this->slug . '_breakfast',
258
+               'type'       => 'wysiwyg',
259
+               'show_on_cb' => 'cmb2_hide_if_no_cats',
260
+               'options'    => array(
261
+                    'textarea_rows' => 5,
262
+               ),
263
+          ) );
264 264
 
265
-		$cmb->add_field(
266
-			array(
267
-				'name'       => __( 'Post Breakfast Snack', 'lsx-health-plan' ),
268
-				'id'         => $this->slug . '_breakfast_snack',
269
-				'type'       => 'wysiwyg',
270
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
271
-				'options'    => array(
272
-					'textarea_rows' => 5,
273
-				),
274
-			)
275
-		);
265
+          $cmb->add_field(
266
+               array(
267
+                    'name'       => __( 'Post Breakfast Snack', 'lsx-health-plan' ),
268
+                    'id'         => $this->slug . '_breakfast_snack',
269
+                    'type'       => 'wysiwyg',
270
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
271
+                    'options'    => array(
272
+                         'textarea_rows' => 5,
273
+                    ),
274
+               )
275
+          );
276 276
 
277
-		if ( post_type_exists( 'recipe' ) ) {
278
-			$cmb->add_field(
279
-				array(
280
-					'name'       => __( 'Breakfast Recipes', 'lsx-health-plan' ),
281
-					'desc'       => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ),
282
-					'id'         => 'breakfast_recipes',
283
-					'type'       => 'post_search_ajax',
284
-					// Optional :
285
-					'limit'      => 15,  // Limit selection to X items only (default 1)
286
-					'sortable'   => true, // Allow selected items to be sortable (default false)
287
-					'query_args' => array(
288
-						'post_type'      => array( 'recipe' ),
289
-						'post_status'    => array( 'publish' ),
290
-						'posts_per_page' => -1,
291
-					),
292
-				)
293
-			);
294
-		}
277
+          if ( post_type_exists( 'recipe' ) ) {
278
+               $cmb->add_field(
279
+                    array(
280
+                         'name'       => __( 'Breakfast Recipes', 'lsx-health-plan' ),
281
+                         'desc'       => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ),
282
+                         'id'         => 'breakfast_recipes',
283
+                         'type'       => 'post_search_ajax',
284
+                         // Optional :
285
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
286
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
287
+                         'query_args' => array(
288
+                              'post_type'      => array( 'recipe' ),
289
+                              'post_status'    => array( 'publish' ),
290
+                              'posts_per_page' => -1,
291
+                         ),
292
+                    )
293
+               );
294
+          }
295 295
 
296
-		$cmb->add_field(
297
-			array(
298
-				'name'       => __( 'Pre Lunch Snack', 'lsx-health-plan' ),
299
-				'id'         => $this->slug . '_pre_lunch_snack',
300
-				'type'       => 'wysiwyg',
301
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
302
-				'options'    => array(
303
-					'textarea_rows' => 5,
304
-				),
305
-			)
306
-		);
307
-		$cmb->add_field(
308
-			array(
309
-				'name'       => __( 'Lunch', 'lsx-health-plan' ),
310
-				'id'         => $this->slug . '_lunch',
311
-				'type'       => 'wysiwyg',
312
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
313
-				'options'    => array(
314
-					'textarea_rows' => 5,
315
-				),
316
-			)
317
-		);
318
-		$cmb->add_field(
319
-			array(
320
-				'name'       => __( 'Post Lunch Snack', 'lsx-health-plan' ),
321
-				'id'         => $this->slug . '_lunch_snack',
322
-				'type'       => 'wysiwyg',
323
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
324
-				'options'    => array(
325
-					'textarea_rows' => 5,
326
-				),
327
-			)
328
-		);
296
+          $cmb->add_field(
297
+               array(
298
+                    'name'       => __( 'Pre Lunch Snack', 'lsx-health-plan' ),
299
+                    'id'         => $this->slug . '_pre_lunch_snack',
300
+                    'type'       => 'wysiwyg',
301
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
302
+                    'options'    => array(
303
+                         'textarea_rows' => 5,
304
+                    ),
305
+               )
306
+          );
307
+          $cmb->add_field(
308
+               array(
309
+                    'name'       => __( 'Lunch', 'lsx-health-plan' ),
310
+                    'id'         => $this->slug . '_lunch',
311
+                    'type'       => 'wysiwyg',
312
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
313
+                    'options'    => array(
314
+                         'textarea_rows' => 5,
315
+                    ),
316
+               )
317
+          );
318
+          $cmb->add_field(
319
+               array(
320
+                    'name'       => __( 'Post Lunch Snack', 'lsx-health-plan' ),
321
+                    'id'         => $this->slug . '_lunch_snack',
322
+                    'type'       => 'wysiwyg',
323
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
324
+                    'options'    => array(
325
+                         'textarea_rows' => 5,
326
+                    ),
327
+               )
328
+          );
329 329
 
330
-		if ( post_type_exists( 'recipe' ) ) {
331
-			$cmb->add_field(
332
-				array(
333
-					'name'       => __( 'Lunch Recipes', 'lsx-health-plan' ),
334
-					'desc'       => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ),
335
-					'id'         => 'lunch_recipes',
336
-					'type'       => 'post_search_ajax',
337
-					// Optional :
338
-					'limit'      => 15,  // Limit selection to X items only (default 1)
339
-					'sortable'   => true, // Allow selected items to be sortable (default false)
340
-					'query_args' => array(
341
-						'post_type'      => array( 'recipe' ),
342
-						'post_status'    => array( 'publish' ),
343
-						'posts_per_page' => -1,
344
-					),
345
-				)
346
-			);
347
-		}
330
+          if ( post_type_exists( 'recipe' ) ) {
331
+               $cmb->add_field(
332
+                    array(
333
+                         'name'       => __( 'Lunch Recipes', 'lsx-health-plan' ),
334
+                         'desc'       => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ),
335
+                         'id'         => 'lunch_recipes',
336
+                         'type'       => 'post_search_ajax',
337
+                         // Optional :
338
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
339
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
340
+                         'query_args' => array(
341
+                              'post_type'      => array( 'recipe' ),
342
+                              'post_status'    => array( 'publish' ),
343
+                              'posts_per_page' => -1,
344
+                         ),
345
+                    )
346
+               );
347
+          }
348 348
 
349
-		$cmb->add_field(
350
-			array(
351
-				'name'       => __( 'Pre Dinner Snack', 'lsx-health-plan' ),
352
-				'id'         => $this->slug . '_pre_dinner_snack',
353
-				'type'       => 'wysiwyg',
354
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
355
-				'options'    => array(
356
-					'textarea_rows' => 5,
357
-				),
358
-			)
359
-		);
360
-		$cmb->add_field(
361
-			array(
362
-				'name'       => __( 'Dinner', 'lsx-health-plan' ),
363
-				'id'         => $this->slug . '_dinner',
364
-				'type'       => 'wysiwyg',
365
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
366
-				'options'    => array(
367
-					'textarea_rows' => 5,
368
-				),
369
-			)
370
-		);
371
-		$cmb->add_field(
372
-			array(
373
-				'name'       => __( 'Post Dinner Snack', 'lsx-health-plan' ),
374
-				'id'         => $this->slug . '_dinner_snack',
375
-				'type'       => 'wysiwyg',
376
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
377
-				'options'    => array(
378
-					'textarea_rows' => 5,
379
-				),
380
-			)
381
-		);
349
+          $cmb->add_field(
350
+               array(
351
+                    'name'       => __( 'Pre Dinner Snack', 'lsx-health-plan' ),
352
+                    'id'         => $this->slug . '_pre_dinner_snack',
353
+                    'type'       => 'wysiwyg',
354
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
355
+                    'options'    => array(
356
+                         'textarea_rows' => 5,
357
+                    ),
358
+               )
359
+          );
360
+          $cmb->add_field(
361
+               array(
362
+                    'name'       => __( 'Dinner', 'lsx-health-plan' ),
363
+                    'id'         => $this->slug . '_dinner',
364
+                    'type'       => 'wysiwyg',
365
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
366
+                    'options'    => array(
367
+                         'textarea_rows' => 5,
368
+                    ),
369
+               )
370
+          );
371
+          $cmb->add_field(
372
+               array(
373
+                    'name'       => __( 'Post Dinner Snack', 'lsx-health-plan' ),
374
+                    'id'         => $this->slug . '_dinner_snack',
375
+                    'type'       => 'wysiwyg',
376
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
377
+                    'options'    => array(
378
+                         'textarea_rows' => 5,
379
+                    ),
380
+               )
381
+          );
382 382
 
383
-		if ( post_type_exists( 'recipe' ) ) {
384
-			$cmb->add_field(
385
-				array(
386
-					'name'       => __( 'Dinner Recipes', 'lsx-health-plan' ),
387
-					'desc'       => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ),
388
-					'id'         => 'dinner_recipes',
389
-					'type'       => 'post_search_ajax',
390
-					// Optional :
391
-					'limit'      => 15,  // Limit selection to X items only (default 1)
392
-					'sortable'   => true, // Allow selected items to be sortable (default false)
393
-					'query_args' => array(
394
-						'post_type'      => array( 'recipe' ),
395
-						'post_status'    => array( 'publish' ),
396
-						'posts_per_page' => -1,
397
-					),
398
-				)
399
-			);
400
-		}
401
-	}
402
-	/**
403
-	 * Set the post type archive to show the parent plans only.
404
-	 *
405
-	 * @param object $wp_query
406
-	 * @return array
407
-	 */
408
-	public function set_parent_only( $wp_query ) {
409
-		if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'meal' ) || $wp_query->is_tax( array( 'meal-type' ) ) ) ) {
410
-			$wp_query->set( 'post_parent', '0' );
411
-		}
412
-	}
383
+          if ( post_type_exists( 'recipe' ) ) {
384
+               $cmb->add_field(
385
+                    array(
386
+                         'name'       => __( 'Dinner Recipes', 'lsx-health-plan' ),
387
+                         'desc'       => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ),
388
+                         'id'         => 'dinner_recipes',
389
+                         'type'       => 'post_search_ajax',
390
+                         // Optional :
391
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
392
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
393
+                         'query_args' => array(
394
+                              'post_type'      => array( 'recipe' ),
395
+                              'post_status'    => array( 'publish' ),
396
+                              'posts_per_page' => -1,
397
+                         ),
398
+                    )
399
+               );
400
+          }
401
+     }
402
+     /**
403
+      * Set the post type archive to show the parent plans only.
404
+      *
405
+      * @param object $wp_query
406
+      * @return array
407
+      */
408
+     public function set_parent_only( $wp_query ) {
409
+          if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'meal' ) || $wp_query->is_tax( array( 'meal-type' ) ) ) ) {
410
+               $wp_query->set( 'post_parent', '0' );
411
+          }
412
+     }
413 413
 
414 414
 
415
-	/**
416
-	 * Holds the array for the single meal breadcrumbs.
417
-	 *
418
-	 * @var array $crumbs
419
-	 * @return array
420
-	 */
421
-	public function meal_breadcrumb_filter( $crumbs ) {
422
-		$meal  = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
423
-		$meals = \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meal' );
415
+     /**
416
+      * Holds the array for the single meal breadcrumbs.
417
+      *
418
+      * @var array $crumbs
419
+      * @return array
420
+      */
421
+     public function meal_breadcrumb_filter( $crumbs ) {
422
+          $meal  = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
423
+          $meals = \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meal' );
424 424
 
425
-		if ( is_singular( 'meal' ) ) {	
426
-			$meal_name     = get_the_title();
427
-			$url           = get_post_type_archive_link( $meal );
428
-			$term_obj_list = get_the_terms( get_the_ID(), 'meal-type' );
429
-			$meal_type     = $term_obj_list[0]->name;
430
-			if ( empty( $meal_type ) ) {
431
-				$meal_type = __( 'Meal', 'lsx-health-plan' );
432
-			}
433
-			$meal_type_url = get_term_link( $term_obj_list[0]->term_id );
425
+          if ( is_singular( 'meal' ) ) {	
426
+               $meal_name     = get_the_title();
427
+               $url           = get_post_type_archive_link( $meal );
428
+               $term_obj_list = get_the_terms( get_the_ID(), 'meal-type' );
429
+               $meal_type     = $term_obj_list[0]->name;
430
+               if ( empty( $meal_type ) ) {
431
+                    $meal_type = __( 'Meal', 'lsx-health-plan' );
432
+               }
433
+               $meal_type_url = get_term_link( $term_obj_list[0]->term_id );
434 434
 
435
-			$new_crumbs    = array();
436
-			$new_crumbs[0] = $crumbs[0];
435
+               $new_crumbs    = array();
436
+               $new_crumbs[0] = $crumbs[0];
437 437
 
438
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
439
-				$new_crumbs[1] = array(
440
-					0 => $meals,
441
-					1 => $url,
442
-				);
443
-				$new_crumbs[2] = array(
444
-					0 => $meal_type,
445
-					1 => $meal_type_url,
446
-				);
447
-				$new_crumbs[3] = array(
448
-					0 => $meal_name,
449
-				);
450
-			} else {
451
-				$new_crumbs[1] = array(
452
-					'text' => $meals,
453
-					'url'  => $url,
454
-				);
455
-				$new_crumbs[2] = array(
456
-					'text' => $meal_type,
457
-					'url'  => $meal_type_url,
458
-				);
459
-				$new_crumbs[3] = array(
460
-					'text' => $meal_name,
461
-				);
462
-			}
463
-			$crumbs = $new_crumbs;
438
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
439
+                    $new_crumbs[1] = array(
440
+                         0 => $meals,
441
+                         1 => $url,
442
+                    );
443
+                    $new_crumbs[2] = array(
444
+                         0 => $meal_type,
445
+                         1 => $meal_type_url,
446
+                    );
447
+                    $new_crumbs[3] = array(
448
+                         0 => $meal_name,
449
+                    );
450
+               } else {
451
+                    $new_crumbs[1] = array(
452
+                         'text' => $meals,
453
+                         'url'  => $url,
454
+                    );
455
+                    $new_crumbs[2] = array(
456
+                         'text' => $meal_type,
457
+                         'url'  => $meal_type_url,
458
+                    );
459
+                    $new_crumbs[3] = array(
460
+                         'text' => $meal_name,
461
+                    );
462
+               }
463
+               $crumbs = $new_crumbs;
464 464
 
465
-		}
466
-		if ( is_post_type_archive( 'meal' ) ) {
465
+          }
466
+          if ( is_post_type_archive( 'meal' ) ) {
467 467
 
468
-			$new_crumbs    = array();
469
-			$new_crumbs[0] = $crumbs[0];
468
+               $new_crumbs    = array();
469
+               $new_crumbs[0] = $crumbs[0];
470 470
 
471
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
472
-				$new_crumbs[1] = array(
473
-					0 => $meals,
474
-				);
475
-			} else {
476
-				$new_crumbs[1] = array(
477
-					'text' => $meals,
478
-				);
479
-			}
480
-			$crumbs = $new_crumbs;
481
-		}
482
-		return $crumbs;
483
-	}
471
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
472
+                    $new_crumbs[1] = array(
473
+                         0 => $meals,
474
+                    );
475
+               } else {
476
+                    $new_crumbs[1] = array(
477
+                         'text' => $meals,
478
+                    );
479
+               }
480
+               $crumbs = $new_crumbs;
481
+          }
482
+          return $crumbs;
483
+     }
484 484
 }
Please login to merge, or discard this patch.
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -30,23 +30,23 @@  discard block
 block discarded – undo
30 30
 	 * Constructor
31 31
 	 */
32 32
 	public function __construct() {
33
-		add_action( 'init', array( $this, 'register_post_type' ) );
34
-		add_action( 'init', array( $this, 'taxonomy_setup' ) );
33
+		add_action('init', array($this, 'register_post_type'));
34
+		add_action('init', array($this, 'taxonomy_setup'));
35 35
 		
36
-		add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
37
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
38
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
36
+		add_filter('lsx_health_plan_connections', array($this, 'enable_connections'), 10, 1);
37
+		add_action('cmb2_admin_init', array($this, 'featured_metabox'), 5);
38
+		add_action('cmb2_admin_init', array($this, 'details_metaboxes'));
39 39
 
40 40
 		// Template Redirects.
41
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
42
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
41
+		add_filter('lsx_health_plan_single_template', array($this, 'enable_post_type'), 10, 1);
42
+		add_filter('lsx_health_plan_archive_template', array($this, 'enable_post_type'), 10, 1);
43 43
 
44
-		add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
45
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
44
+		add_action('pre_get_posts', array($this, 'set_parent_only'), 10, 1);
45
+		add_filter('get_the_archive_title', array($this, 'get_the_archive_title'), 100);
46 46
 
47 47
 		//Breadcrumbs
48
-		add_filter( 'wpseo_breadcrumb_links', array( $this, 'meal_breadcrumb_filter' ), 30, 1 );
49
-		add_filter( 'woocommerce_get_breadcrumb', array( $this, 'meal_breadcrumb_filter' ), 30, 1 );
48
+		add_filter('wpseo_breadcrumb_links', array($this, 'meal_breadcrumb_filter'), 30, 1);
49
+		add_filter('woocommerce_get_breadcrumb', array($this, 'meal_breadcrumb_filter'), 30, 1);
50 50
 	}
51 51
 
52 52
 	/**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public static function get_instance() {
60 60
 		// If the single instance hasn't been set, set it now.
61
-		if ( null === self::$instance ) {
61
+		if (null === self::$instance) {
62 62
 			self::$instance = new self();
63 63
 		}
64 64
 		return self::$instance;
@@ -68,21 +68,21 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function register_post_type() {
70 70
 		$labels = array(
71
-			'name'               => esc_html__( 'Meals', 'lsx-health-plan' ),
72
-			'singular_name'      => esc_html__( 'Meal', 'lsx-health-plan' ),
73
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
74
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
75
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
76
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
77
-			'all_items'          => esc_html__( 'All Meals', 'lsx-health-plan' ),
78
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
79
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
80
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
81
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
82
-			'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
83
-			'menu_name'          => esc_html__( 'Meals', 'lsx-health-plan' ),
71
+			'name'               => esc_html__('Meals', 'lsx-health-plan'),
72
+			'singular_name'      => esc_html__('Meal', 'lsx-health-plan'),
73
+			'add_new'            => esc_html_x('Add New', 'post type general name', 'lsx-health-plan'),
74
+			'add_new_item'       => esc_html__('Add New', 'lsx-health-plan'),
75
+			'edit_item'          => esc_html__('Edit', 'lsx-health-plan'),
76
+			'new_item'           => esc_html__('New', 'lsx-health-plan'),
77
+			'all_items'          => esc_html__('All Meals', 'lsx-health-plan'),
78
+			'view_item'          => esc_html__('View', 'lsx-health-plan'),
79
+			'search_items'       => esc_html__('Search', 'lsx-health-plan'),
80
+			'not_found'          => esc_html__('None found', 'lsx-health-plan'),
81
+			'not_found_in_trash' => esc_html__('None found in Trash', 'lsx-health-plan'),
82
+			'parent_item_colon'  => esc_html__('Parent:', 'lsx-health-plan'),
83
+			'menu_name'          => esc_html__('Meals', 'lsx-health-plan'),
84 84
 		);
85
-		$args   = array(
85
+		$args = array(
86 86
 			'labels'             => $labels,
87 87
 			'public'             => true,
88 88
 			'publicly_queryable' => true,
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 			'menu_icon'          => 'dashicons-carrot',
93 93
 			'query_var'          => true,
94 94
 			'rewrite'            => array(
95
-				'slug' => \lsx_health_plan\functions\get_option( 'meal_single_slug', 'meal' ),
95
+				'slug' => \lsx_health_plan\functions\get_option('meal_single_slug', 'meal'),
96 96
 			),
97 97
 			'capability_type'    => 'page',
98
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meals' ),
98
+			'has_archive'        => \lsx_health_plan\functions\get_option('endpoint_meal_archive', 'meals'),
99 99
 			'hierarchical'       => true,
100 100
 			'menu_position'      => null,
101 101
 			'supports'           => array(
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 				'custom-fields',
107 107
 			),
108 108
 		);
109
-		register_post_type( 'meal', $args );
109
+		register_post_type('meal', $args);
110 110
 	}
111 111
 
112 112
 	/**
@@ -114,19 +114,19 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function taxonomy_setup() {
116 116
 		$labels = array(
117
-			'name'              => esc_html_x( 'Meal Type', 'taxonomy general name', 'lsx-health-plan' ),
118
-			'singular_name'     => esc_html_x( 'Meal Types', 'taxonomy singular name', 'lsx-health-plan' ),
119
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
120
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
121
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
122
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
123
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
124
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
125
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
126
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
127
-			'menu_name'         => esc_html__( 'Meal Types', 'lsx-health-plan' ),
117
+			'name'              => esc_html_x('Meal Type', 'taxonomy general name', 'lsx-health-plan'),
118
+			'singular_name'     => esc_html_x('Meal Types', 'taxonomy singular name', 'lsx-health-plan'),
119
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
120
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
121
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
122
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
123
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
124
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
125
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
126
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
127
+			'menu_name'         => esc_html__('Meal Types', 'lsx-health-plan'),
128 128
 		);
129
-		$args   = array(
129
+		$args = array(
130 130
 			'hierarchical'      => true,
131 131
 			'labels'            => $labels,
132 132
 			'show_ui'           => true,
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 				'slug' => 'meal-type',
138 138
 			),
139 139
 		);
140
-		register_taxonomy( 'meal-type', array( $this->slug ), $args );
140
+		register_taxonomy('meal-type', array($this->slug), $args);
141 141
 	}
142 142
 
143 143
 	/**
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @param array $post_types
147 147
 	 * @return array
148 148
 	 */
149
-	public function enable_post_type( $post_types = array() ) {
149
+	public function enable_post_type($post_types = array()) {
150 150
 		$post_types[] = $this->slug;
151 151
 		return $post_types;
152 152
 	}
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @param array $connections
158 158
 	 * @return void
159 159
 	 */
160
-	public function enable_connections( $connections = array() ) {
160
+	public function enable_connections($connections = array()) {
161 161
 		$connections['meal']['connected_plans'] = 'connected_meals';
162 162
 		$connections['plan']['connected_meals'] = 'connected_plans';
163 163
 		return $connections;
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 	 * @param string $title the term title.
170 170
 	 * @return string
171 171
 	 */
172
-	public function get_the_archive_title( $title ) {
173
-		if ( is_post_type_archive( 'meal' ) ) {
174
-			$title = __( 'Meals', 'lsx-health-plan' );
172
+	public function get_the_archive_title($title) {
173
+		if (is_post_type_archive('meal')) {
174
+			$title = __('Meals', 'lsx-health-plan');
175 175
 		}
176 176
 		return $title;
177 177
 	}
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 		$cmb = new_cmb2_box(
184 184
 			array(
185 185
 				'id'           => $this->slug . '_featured_metabox_meal',
186
-				'title'        => __( 'Featured Meal', 'lsx-health-plan' ),
187
-				'object_types' => array( $this->slug ), // Post type
186
+				'title'        => __('Featured Meal', 'lsx-health-plan'),
187
+				'object_types' => array($this->slug), // Post type
188 188
 				'context'      => 'side',
189 189
 				'priority'     => 'high',
190 190
 				'show_names'   => true,
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 		);
193 193
 		$cmb->add_field(
194 194
 			array(
195
-				'name'       => __( 'Featured Meal', 'lsx-health-plan' ),
196
-				'desc'       => __( 'Enable a featured meal' ),
195
+				'name'       => __('Featured Meal', 'lsx-health-plan'),
196
+				'desc'       => __('Enable a featured meal'),
197 197
 				'id'         => $this->slug . '_featured_meal',
198 198
 				'type'       => 'checkbox',
199 199
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -205,66 +205,66 @@  discard block
 block discarded – undo
205 205
 	 * Define the metabox and field configurations.
206 206
 	 */
207 207
 	public function details_metaboxes() {
208
-		$cmb = new_cmb2_box( array(
208
+		$cmb = new_cmb2_box(array(
209 209
 			'id'           => $this->slug . '_shopping_list_metabox',
210
-			'title'        => __( 'Shopping List', 'lsx-health-plan' ),
211
-			'object_types' => array( $this->slug ), // Post type
210
+			'title'        => __('Shopping List', 'lsx-health-plan'),
211
+			'object_types' => array($this->slug), // Post type
212 212
 			'context'      => 'normal',
213 213
 			'priority'     => 'high',
214 214
 			'show_names'   => true,
215
-		) );
216
-		$cmb->add_field( array(
217
-			'name'       => __( 'Shopping List', 'lsx-health-plan' ),
218
-			'desc'       => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ),
215
+		));
216
+		$cmb->add_field(array(
217
+			'name'       => __('Shopping List', 'lsx-health-plan'),
218
+			'desc'       => __('Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.'),
219 219
 			'id'         => $this->slug . '_shopping_list',
220 220
 			'type'       => 'post_search_ajax',
221 221
 			// Optional :
222
-			'limit'      => 1,  // Limit selection to X items only (default 1)
222
+			'limit'      => 1, // Limit selection to X items only (default 1)
223 223
 			'sortable'   => true, // Allow selected items to be sortable (default false)
224 224
 			'query_args' => array(
225
-				'post_type'      => array( 'page' ),
226
-				'post_status'    => array( 'publish' ),
225
+				'post_type'      => array('page'),
226
+				'post_status'    => array('publish'),
227 227
 				'posts_per_page' => -1,
228 228
 			),
229
-		) );
230
-		$cmb = new_cmb2_box( array(
229
+		));
230
+		$cmb = new_cmb2_box(array(
231 231
 			'id'           => $this->slug . '_details_metabox',
232
-			'title'        => __( 'Meal Details', 'lsx-health-plan' ),
233
-			'object_types' => array( $this->slug ), // Post type
232
+			'title'        => __('Meal Details', 'lsx-health-plan'),
233
+			'object_types' => array($this->slug), // Post type
234 234
 			'context'      => 'normal',
235 235
 			'priority'     => 'high',
236 236
 			'show_names'   => true,
237
-		) );
237
+		));
238 238
 
239
-		$cmb->add_field( array(
240
-			'name' => __( 'Meal Short Description', 'lsx-health-plan' ),
239
+		$cmb->add_field(array(
240
+			'name' => __('Meal Short Description', 'lsx-health-plan'),
241 241
 			'id'   => $this->slug . '_short_description',
242 242
 			'type' => 'textarea_small',
243
-			'desc' => __( 'Add a small description for this meal (optional)', 'lsx-health-plan' ),
244
-		) );
243
+			'desc' => __('Add a small description for this meal (optional)', 'lsx-health-plan'),
244
+		));
245 245
 
246
-		$cmb->add_field( array(
247
-			'name'       => __( 'Pre Breakfast Snack', 'lsx-health-plan' ),
246
+		$cmb->add_field(array(
247
+			'name'       => __('Pre Breakfast Snack', 'lsx-health-plan'),
248 248
 			'id'         => $this->slug . '_pre_breakfast_snack',
249 249
 			'type'       => 'wysiwyg',
250 250
 			'show_on_cb' => 'cmb2_hide_if_no_cats',
251 251
 			'options'    => array(
252 252
 				'textarea_rows' => 5,
253 253
 			),
254
-		) );
255
-		$cmb->add_field( array(
256
-			'name'       => __( 'Breakfast', 'lsx-health-plan' ),
254
+		));
255
+		$cmb->add_field(array(
256
+			'name'       => __('Breakfast', 'lsx-health-plan'),
257 257
 			'id'         => $this->slug . '_breakfast',
258 258
 			'type'       => 'wysiwyg',
259 259
 			'show_on_cb' => 'cmb2_hide_if_no_cats',
260 260
 			'options'    => array(
261 261
 				'textarea_rows' => 5,
262 262
 			),
263
-		) );
263
+		));
264 264
 
265 265
 		$cmb->add_field(
266 266
 			array(
267
-				'name'       => __( 'Post Breakfast Snack', 'lsx-health-plan' ),
267
+				'name'       => __('Post Breakfast Snack', 'lsx-health-plan'),
268 268
 				'id'         => $this->slug . '_breakfast_snack',
269 269
 				'type'       => 'wysiwyg',
270 270
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -274,19 +274,19 @@  discard block
 block discarded – undo
274 274
 			)
275 275
 		);
276 276
 
277
-		if ( post_type_exists( 'recipe' ) ) {
277
+		if (post_type_exists('recipe')) {
278 278
 			$cmb->add_field(
279 279
 				array(
280
-					'name'       => __( 'Breakfast Recipes', 'lsx-health-plan' ),
281
-					'desc'       => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ),
280
+					'name'       => __('Breakfast Recipes', 'lsx-health-plan'),
281
+					'desc'       => __('Connect additional recipes options for breakfast.', 'lsx-health-plan'),
282 282
 					'id'         => 'breakfast_recipes',
283 283
 					'type'       => 'post_search_ajax',
284 284
 					// Optional :
285
-					'limit'      => 15,  // Limit selection to X items only (default 1)
285
+					'limit'      => 15, // Limit selection to X items only (default 1)
286 286
 					'sortable'   => true, // Allow selected items to be sortable (default false)
287 287
 					'query_args' => array(
288
-						'post_type'      => array( 'recipe' ),
289
-						'post_status'    => array( 'publish' ),
288
+						'post_type'      => array('recipe'),
289
+						'post_status'    => array('publish'),
290 290
 						'posts_per_page' => -1,
291 291
 					),
292 292
 				)
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
 		$cmb->add_field(
297 297
 			array(
298
-				'name'       => __( 'Pre Lunch Snack', 'lsx-health-plan' ),
298
+				'name'       => __('Pre Lunch Snack', 'lsx-health-plan'),
299 299
 				'id'         => $this->slug . '_pre_lunch_snack',
300 300
 				'type'       => 'wysiwyg',
301 301
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		);
307 307
 		$cmb->add_field(
308 308
 			array(
309
-				'name'       => __( 'Lunch', 'lsx-health-plan' ),
309
+				'name'       => __('Lunch', 'lsx-health-plan'),
310 310
 				'id'         => $this->slug . '_lunch',
311 311
 				'type'       => 'wysiwyg',
312 312
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		);
318 318
 		$cmb->add_field(
319 319
 			array(
320
-				'name'       => __( 'Post Lunch Snack', 'lsx-health-plan' ),
320
+				'name'       => __('Post Lunch Snack', 'lsx-health-plan'),
321 321
 				'id'         => $this->slug . '_lunch_snack',
322 322
 				'type'       => 'wysiwyg',
323 323
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -327,19 +327,19 @@  discard block
 block discarded – undo
327 327
 			)
328 328
 		);
329 329
 
330
-		if ( post_type_exists( 'recipe' ) ) {
330
+		if (post_type_exists('recipe')) {
331 331
 			$cmb->add_field(
332 332
 				array(
333
-					'name'       => __( 'Lunch Recipes', 'lsx-health-plan' ),
334
-					'desc'       => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ),
333
+					'name'       => __('Lunch Recipes', 'lsx-health-plan'),
334
+					'desc'       => __('Connect additional recipes options for lunch.', 'lsx-health-plan'),
335 335
 					'id'         => 'lunch_recipes',
336 336
 					'type'       => 'post_search_ajax',
337 337
 					// Optional :
338
-					'limit'      => 15,  // Limit selection to X items only (default 1)
338
+					'limit'      => 15, // Limit selection to X items only (default 1)
339 339
 					'sortable'   => true, // Allow selected items to be sortable (default false)
340 340
 					'query_args' => array(
341
-						'post_type'      => array( 'recipe' ),
342
-						'post_status'    => array( 'publish' ),
341
+						'post_type'      => array('recipe'),
342
+						'post_status'    => array('publish'),
343 343
 						'posts_per_page' => -1,
344 344
 					),
345 345
 				)
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 
349 349
 		$cmb->add_field(
350 350
 			array(
351
-				'name'       => __( 'Pre Dinner Snack', 'lsx-health-plan' ),
351
+				'name'       => __('Pre Dinner Snack', 'lsx-health-plan'),
352 352
 				'id'         => $this->slug . '_pre_dinner_snack',
353 353
 				'type'       => 'wysiwyg',
354 354
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 		);
360 360
 		$cmb->add_field(
361 361
 			array(
362
-				'name'       => __( 'Dinner', 'lsx-health-plan' ),
362
+				'name'       => __('Dinner', 'lsx-health-plan'),
363 363
 				'id'         => $this->slug . '_dinner',
364 364
 				'type'       => 'wysiwyg',
365 365
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 		);
371 371
 		$cmb->add_field(
372 372
 			array(
373
-				'name'       => __( 'Post Dinner Snack', 'lsx-health-plan' ),
373
+				'name'       => __('Post Dinner Snack', 'lsx-health-plan'),
374 374
 				'id'         => $this->slug . '_dinner_snack',
375 375
 				'type'       => 'wysiwyg',
376 376
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -380,19 +380,19 @@  discard block
 block discarded – undo
380 380
 			)
381 381
 		);
382 382
 
383
-		if ( post_type_exists( 'recipe' ) ) {
383
+		if (post_type_exists('recipe')) {
384 384
 			$cmb->add_field(
385 385
 				array(
386
-					'name'       => __( 'Dinner Recipes', 'lsx-health-plan' ),
387
-					'desc'       => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ),
386
+					'name'       => __('Dinner Recipes', 'lsx-health-plan'),
387
+					'desc'       => __('Connect additional recipes options for dinner.', 'lsx-health-plan'),
388 388
 					'id'         => 'dinner_recipes',
389 389
 					'type'       => 'post_search_ajax',
390 390
 					// Optional :
391
-					'limit'      => 15,  // Limit selection to X items only (default 1)
391
+					'limit'      => 15, // Limit selection to X items only (default 1)
392 392
 					'sortable'   => true, // Allow selected items to be sortable (default false)
393 393
 					'query_args' => array(
394
-						'post_type'      => array( 'recipe' ),
395
-						'post_status'    => array( 'publish' ),
394
+						'post_type'      => array('recipe'),
395
+						'post_status'    => array('publish'),
396 396
 						'posts_per_page' => -1,
397 397
 					),
398 398
 				)
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
 	 * @param object $wp_query
406 406
 	 * @return array
407 407
 	 */
408
-	public function set_parent_only( $wp_query ) {
409
-		if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'meal' ) || $wp_query->is_tax( array( 'meal-type' ) ) ) ) {
410
-			$wp_query->set( 'post_parent', '0' );
408
+	public function set_parent_only($wp_query) {
409
+		if ( ! is_admin() && $wp_query->is_main_query() && ($wp_query->is_post_type_archive('meal') || $wp_query->is_tax(array('meal-type')))) {
410
+			$wp_query->set('post_parent', '0');
411 411
 		}
412 412
 	}
413 413
 
@@ -418,24 +418,24 @@  discard block
 block discarded – undo
418 418
 	 * @var array $crumbs
419 419
 	 * @return array
420 420
 	 */
421
-	public function meal_breadcrumb_filter( $crumbs ) {
422
-		$meal  = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
423
-		$meals = \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meal' );
421
+	public function meal_breadcrumb_filter($crumbs) {
422
+		$meal  = \lsx_health_plan\functions\get_option('endpoint_meal', 'meal');
423
+		$meals = \lsx_health_plan\functions\get_option('endpoint_meal_archive', 'meal');
424 424
 
425
-		if ( is_singular( 'meal' ) ) {	
425
+		if (is_singular('meal')) {	
426 426
 			$meal_name     = get_the_title();
427
-			$url           = get_post_type_archive_link( $meal );
428
-			$term_obj_list = get_the_terms( get_the_ID(), 'meal-type' );
427
+			$url           = get_post_type_archive_link($meal);
428
+			$term_obj_list = get_the_terms(get_the_ID(), 'meal-type');
429 429
 			$meal_type     = $term_obj_list[0]->name;
430
-			if ( empty( $meal_type ) ) {
431
-				$meal_type = __( 'Meal', 'lsx-health-plan' );
430
+			if (empty($meal_type)) {
431
+				$meal_type = __('Meal', 'lsx-health-plan');
432 432
 			}
433
-			$meal_type_url = get_term_link( $term_obj_list[0]->term_id );
433
+			$meal_type_url = get_term_link($term_obj_list[0]->term_id);
434 434
 
435 435
 			$new_crumbs    = array();
436 436
 			$new_crumbs[0] = $crumbs[0];
437 437
 
438
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
438
+			if (function_exists('woocommerce_breadcrumb')) {
439 439
 				$new_crumbs[1] = array(
440 440
 					0 => $meals,
441 441
 					1 => $url,
@@ -463,12 +463,12 @@  discard block
 block discarded – undo
463 463
 			$crumbs = $new_crumbs;
464 464
 
465 465
 		}
466
-		if ( is_post_type_archive( 'meal' ) ) {
466
+		if (is_post_type_archive('meal')) {
467 467
 
468 468
 			$new_crumbs    = array();
469 469
 			$new_crumbs[0] = $crumbs[0];
470 470
 
471
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
471
+			if (function_exists('woocommerce_breadcrumb')) {
472 472
 				$new_crumbs[1] = array(
473 473
 					0 => $meals,
474 474
 				);
Please login to merge, or discard this patch.
classes/post-types/class-exercise.php 2 patches
Indentation   +478 added lines, -478 removed lines patch added patch discarded remove patch
@@ -8,483 +8,483 @@
 block discarded – undo
8 8
  */
9 9
 class Exercise {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\Exercise()
17
-	 */
18
-	protected static $instance = null;
19
-
20
-	/**
21
-	 * Holds post_type slug used as an index
22
-	 *
23
-	 * @since 1.0.0
24
-	 *
25
-	 * @var      string
26
-	 */
27
-	public $slug = 'exercise';
28
-
29
-	/**
30
-	 * Constructor
31
-	 */
32
-	public function __construct() {
33
-
34
-		if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
35
-			// Post Type and Taxonomies.
36
-			add_action( 'init', array( $this, 'register_post_type' ) );
37
-			add_action( 'init', array( $this, 'exercise_type_taxonomy_setup' ) );
38
-			add_action( 'init', array( $this, 'equipment_taxonomy_setup' ) );
39
-			add_action( 'init', array( $this, 'muscle_group_taxonomy_setup' ) );
40
-			add_action( 'admin_menu', array( $this, 'register_menus' ) );
41
-
42
-			// Custom Fields.
43
-			add_action( 'cmb2_admin_init', array( $this, 'exercise_details' ), 8 );
44
-			add_action( 'cmb2_admin_init', array( $this, 'gallery_metabox' ), 9 );
45
-			add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
46
-
47
-			// Template Redirects.
48
-			add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
49
-			add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
50
-
51
-			//Breadcrumbs
52
-			add_filter( 'wpseo_breadcrumb_links', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 );
53
-			add_filter( 'woocommerce_get_breadcrumb', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 );
54
-
55
-		}
56
-
57
-	}
58
-
59
-
60
-	/**
61
-	 * Return an instance of this class.
62
-	 *
63
-	 * @since 1.0.0
64
-	 *
65
-	 * @return    object \lsx_health_plan\classes\Exercise()    A single instance of this class.
66
-	 */
67
-	public static function get_instance() {
68
-		// If the single instance hasn't been set, set it now.
69
-		if ( null === self::$instance ) {
70
-			self::$instance = new self();
71
-		}
72
-		return self::$instance;
73
-	}
74
-	/**
75
-	 * Register the post type.
76
-	 */
77
-	public function register_post_type() {
78
-		$labels = array(
79
-			'name'               => esc_html__( 'Exercises', 'lsx-health-plan' ),
80
-			'singular_name'      => esc_html__( 'Exercise', 'lsx-health-plan' ),
81
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
82
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
83
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
84
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
85
-			'all_items'          => esc_html__( 'All Exercises', 'lsx-health-plan' ),
86
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
87
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
88
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
89
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
90
-			'parent_item_colon'  => '',
91
-			'menu_name'          => esc_html__( 'Exercises', 'lsx-health-plan' ),
92
-		);
93
-		$args   = array(
94
-			'labels'             => $labels,
95
-			'public'             => true,
96
-			'publicly_queryable' => true,
97
-			'show_ui'            => true,
98
-			'show_in_menu'       => 'edit.php?post_type=workout-pseudo',
99
-			'show_in_rest'       => true,
100
-			'menu_icon'          => 'dashicons-universal-access',
101
-			'query_var'          => true,
102
-			'rewrite'            => array(
103
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ),
104
-			),
105
-			'capability_type'    => 'page',
106
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercises' ),
107
-			'hierarchical'       => false,
108
-			'menu_position'      => null,
109
-			'supports'           => array(
110
-				'title',
111
-				'thumbnail',
112
-				'editor',
113
-				'excerpt',
114
-				'custom-fields',
115
-			),
116
-		);
117
-		register_post_type( 'exercise', $args );
118
-	}
119
-
120
-	/**
121
-	 * Register the Exercise taxonomy.
122
-	 *
123
-	 * @return void
124
-	 */
125
-	public function exercise_type_taxonomy_setup() {
126
-		$labels = array(
127
-			'name'              => esc_html_x( 'Exercise Type', 'taxonomy general name', 'lsx-health-plan' ),
128
-			'singular_name'     => esc_html_x( 'Exercise Type', 'taxonomy singular name', 'lsx-health-plan' ),
129
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
130
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
131
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
132
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
133
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
134
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
135
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
136
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
137
-			'menu_name'         => esc_html__( 'Exercise Types', 'lsx-health-plan' ),
138
-		);
139
-
140
-		$args = array(
141
-			'hierarchical'      => true,
142
-			'labels'            => $labels,
143
-			'show_ui'           => true,
144
-			'show_admin_column' => true,
145
-			'query_var'         => true,
146
-			'rewrite'           => array(
147
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_type', 'exercise-type' ),
148
-			),
149
-			'show_in_rest'      => true,
150
-		);
151
-
152
-		register_taxonomy( 'exercise-type', array( 'exercise' ), $args );
153
-	}
154
-
155
-	/**
156
-	 * Register the Exercise taxonomy.
157
-	 *
158
-	 * @return void
159
-	 */
160
-	public function equipment_taxonomy_setup() {
161
-		$labels = array(
162
-			'name'              => esc_html_x( 'Equipment', 'taxonomy general name', 'lsx-health-plan' ),
163
-			'singular_name'     => esc_html_x( 'Equipment', 'taxonomy singular name', 'lsx-health-plan' ),
164
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
165
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
166
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
167
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
168
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
169
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
170
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
171
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
172
-			'menu_name'         => esc_html__( 'Equipment', 'lsx-health-plan' ),
173
-		);
174
-
175
-		$args = array(
176
-			'hierarchical'      => true,
177
-			'labels'            => $labels,
178
-			'show_ui'           => true,
179
-			'show_admin_column' => true,
180
-			'query_var'         => true,
181
-			'rewrite'           => array(
182
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_equipment', 'equipment' ),
183
-			),
184
-			'show_in_rest'      => true,
185
-		);
186
-
187
-		register_taxonomy( 'equipment', array( 'exercise' ), $args );
188
-	}
189
-
190
-	/**
191
-	 * Register the Muscle Group taxonomy.
192
-	 *
193
-	 * @return void
194
-	 */
195
-	public function muscle_group_taxonomy_setup() {
196
-		$labels = array(
197
-			'name'              => esc_html_x( 'Muscle Groups', 'taxonomy general name', 'lsx-health-plan' ),
198
-			'singular_name'     => esc_html_x( 'Muscle Group', 'taxonomy singular name', 'lsx-health-plan' ),
199
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
200
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
201
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
202
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
203
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
204
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
205
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
206
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
207
-			'menu_name'         => esc_html__( 'Muscle Groups', 'lsx-health-plan' ),
208
-		);
209
-
210
-		$args = array(
211
-			'hierarchical'      => true,
212
-			'labels'            => $labels,
213
-			'show_ui'           => true,
214
-			'show_admin_column' => true,
215
-			'query_var'         => true,
216
-			'rewrite'           => array(
217
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_musclegroup', 'muscle-group' ),
218
-			),
219
-			'show_in_rest'      => true,
220
-		);
221
-
222
-		register_taxonomy( 'muscle-group', array( 'exercise' ), $args );
223
-	}
224
-
225
-	/**
226
-	 * Registers the Recipes under the Meals Post type menu.
227
-	 *
228
-	 * @return void
229
-	 */
230
-	public function register_menus() {
231
-		add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercises', 'lsx-health-plan' ), esc_html__( 'Exercises', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=exercise' );
232
-		add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercise Types', 'lsx-health-plan' ), esc_html__( 'Exercise Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=exercise-type&post_type=exercise' );
233
-		add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Equipment', 'lsx-health-plan' ), esc_html__( 'Equipment', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=equipment&post_type=exercise' );
234
-		add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Muscle Groups', 'lsx-health-plan' ), esc_html__( 'Muscle Groups', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=muscle-group&post_type=exercise' );
235
-	}
236
-
237
-	/**
238
-	 * Adds the post type to the different arrays.
239
-	 *
240
-	 * @param array $post_types
241
-	 * @return array
242
-	 */
243
-	public function enable_post_type( $post_types = array() ) {
244
-		$post_types[] = $this->slug;
245
-		return $post_types;
246
-	}
247
-
248
-	/**
249
-	 * Enables the Bi Directional relationships
250
-	 *
251
-	 * @param array $connections
252
-	 * @return void
253
-	 */
254
-	public function enable_connections( $connections = array() ) {
255
-		$connections['exercise']['connected_workouts'] = 'connected_exercises';
256
-		$connections['workout']['connected_exercises'] = 'connected_workouts';
257
-		return $connections;
258
-	}
259
-
260
-	/**
261
-	 * Define the metabox and field configurations.
262
-	 */
263
-	public function gallery_metabox() {
264
-		$cmb = new_cmb2_box(
265
-			array(
266
-				'id'           => $this->slug . '_gallery_details_metabox',
267
-				'title'        => __( 'Exercise Gallery', 'lsx-health-plan' ),
268
-				'object_types' => array( $this->slug ),
269
-				'context'      => 'normal',
270
-				'priority'     => 'low',
271
-				'show_names'   => true,
272
-			)
273
-		);
274
-
275
-		$cmb->add_field(
276
-			array(
277
-				'name'    => __( 'Layout', 'lsx-health-plan' ),
278
-				'id'      => $this->slug . '_gallery_layout',
279
-				'type'    => 'radio',
280
-				'options' => array(
281
-					'slider' => __( 'Slider', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
282
-					'grid'   => __( 'Grid', 'lsx-health-plan' ),
283
-				),
284
-				'default' => 'grid',
285
-			)
286
-		);
287
-
288
-		$cmb->add_field(
289
-			array(
290
-				'name'    => __( 'Grid Columns', 'lsx-health-plan' ),
291
-				'id'      => $this->slug . '_gallery_columns',
292
-				'type'    => 'select',
293
-				'options' => array(
294
-					'3' => __( '2 Columns', 'lsx-health-plan' ),
295
-					'4' => __( '3 Columns', 'lsx-health-plan' ),
296
-				),
297
-				'default' => '1',
298
-			)
299
-		);
300
-
301
-		// Repeatable group.
302
-		$gallery_group = $cmb->add_field(
303
-			array(
304
-				'id'      => $this->slug . '_gallery',
305
-				'type'    => 'group',
306
-				'options' => array(
307
-					'group_title'   => __( 'Gallery', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
308
-					'add_button'    => __( 'Add Item', 'lsx-health-plan' ),
309
-					'remove_button' => __( 'Remove Item', 'lsx-health-plan' ),
310
-					'sortable'      => true,
311
-				),
312
-				'desc'    => __( 'Upload only one image, video or gif per gallery group, each group will only display 1 item.', 'lsx-health-plan' ),
313
-				'classes' => 'lsx-admin-row',
314
-			)
315
-		);
316
-
317
-		// Title.
318
-		$cmb->add_group_field(
319
-			$gallery_group,
320
-			array(
321
-				'name'       => __( 'Image', 'lsx-health-plan' ),
322
-				'id'         => $this->slug . '_gallery_image',
323
-				'type'       => 'file',
324
-				'text'       => array(
325
-					'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
326
-				),
327
-				'desc'       => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ),
328
-				'query_args' => array(
329
-					'type' => array(
330
-						'image/gif',
331
-						'image/jpeg',
332
-						'image/png',
333
-					),
334
-				),
335
-				'preview_size' => 'lsx-thumbnail-wide',
336
-				'classes' => 'lsx-field-col lsx-field-col-80',
337
-			)
338
-		);
339
-
340
-		// Title.
341
-		$cmb->add_group_field(
342
-			$gallery_group,
343
-			array(
344
-				'name'    => __( 'oEmbed', 'lsx-health-plan' ),
345
-				'id'      => $this->slug . '_gallery_embed',
346
-				'type'    => 'text',
347
-				'desc'    => __( 'Drop in the embed url for your video from YouTube, Vimeo or DailyMotion, e.g: "https://www.youtube.com/watch?v=9xwazD5SyVg". A full list of supports formats can be found at <a href="https://make.wordpress.org/support/user-manual/content/media/adding-media-to-your-pages-and-posts/embedding-media-from-other-sites/">WordPress</a>', 'lsx-health-plan' ),
348
-				'classes' => 'test-apply-form lsx-field-col lsx-field-col-50',
349
-			)
350
-		);
351
-
352
-		$cmb->add_group_field(
353
-			$gallery_group,
354
-			array(
355
-				'name'    => __( 'External Media', 'lsx-health-plan' ),
356
-				'id'      => $this->slug . '_gallery_external',
357
-				'type'    => 'textarea_code',
358
-				'desc'    => __( 'Drop in the iFrame embed code from Giphy in this field, i.e: &lt;iframe src="https://giphy.com/embed/3o7527Rn1HxXWqgxuo" width="480" height="270" frameborder="0" class="giphy-embed" allowfullscreen&gt;&lt;/iframe&gt;', 'lsx-health-plan' ),
359
-				'classes' => 'lsx-field-col lsx-field-col-50',
360
-			)
361
-		);
362
-	}
363
-
364
-	/**
365
-	 * Registers the general settings for the exercise.
366
-	 *
367
-	 * @return void
368
-	 */
369
-	public function exercise_details() {
370
-		$cmb = new_cmb2_box(
371
-			array(
372
-				'id'           => $this->slug . '_general_details_metabox',
373
-				'title'        => __( 'Details', 'lsx-health-plan' ),
374
-				'object_types' => array( $this->slug ),
375
-				'context'      => 'normal',
376
-				'priority'     => 'high',
377
-				'show_names'   => true,
378
-			)
379
-		);
380
-
381
-		$cmb->add_field(
382
-			array(
383
-				'name'    => __( 'Side', 'lsx-health-plan' ),
384
-				'id'      => $this->slug . '_side',
385
-				'type'    => 'select',
386
-				'options' => array(
387
-					''      => __( 'Select', 'lsx-health-plan' ),
388
-					'left'  => __( 'Left', 'lsx-health-plan' ),
389
-					'right' => __( 'Right', 'lsx-health-plan' ),
390
-				),
391
-				'desc'    => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ),
392
-			)
393
-		);
394
-	}
395
-
396
-	/**
397
-	 * Holds the array for the single exercise breadcrumbs.
398
-	 *
399
-	 * @var array $crumbs
400
-	 * @return array
401
-	 */
402
-	public function exercise_breadcrumb_filter( $crumbs ) {
403
-		$exercise  = \lsx_health_plan\functions\get_option( 'endpoint_exercise', 'exercise' );
404
-		$exercises = \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercise' );
405
-		$url       = get_post_type_archive_link( $exercise );
406
-
407
-		if ( is_singular( 'exercise' ) ) {
408
-			$exercise_name     = get_the_title();	
409
-			$term_obj_list     = get_the_terms( get_the_ID(), 'exercise-type' );
410
-			$exercise_type     = $term_obj_list[0]->name;
411
-			$exercise_type_url = get_term_link( $term_obj_list[0]->term_id );
412
-
413
-			$new_crumbs    = array();
414
-			$new_crumbs[0] = $crumbs[0];
415
-
416
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
417
-				$new_crumbs[1] = array(
418
-					0 => $exercises,
419
-					1 => $url,
420
-				);
421
-				$new_crumbs[2] = array(
422
-					0 => $exercise_type,
423
-					1 => $exercise_type_url,
424
-				);
425
-				$new_crumbs[3] = array(
426
-					0 => $exercise_name,
427
-				);
428
-			} else {
429
-				$new_crumbs[1] = array(
430
-					'text' => $exercises,
431
-					'url'  => $url,
432
-				);
433
-				$new_crumbs[2] = array(
434
-					'text' => $exercise_type,
435
-					'url'  => $exercise_type_url,
436
-				);
437
-				$new_crumbs[3] = array(
438
-					'text' => $exercise_name,
439
-				);
440
-			}
441
-			$crumbs = $new_crumbs;
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @since 1.0.0
15
+      *
16
+      * @var      object \lsx_health_plan\classes\Exercise()
17
+      */
18
+     protected static $instance = null;
19
+
20
+     /**
21
+      * Holds post_type slug used as an index
22
+      *
23
+      * @since 1.0.0
24
+      *
25
+      * @var      string
26
+      */
27
+     public $slug = 'exercise';
28
+
29
+     /**
30
+      * Constructor
31
+      */
32
+     public function __construct() {
33
+
34
+          if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
35
+               // Post Type and Taxonomies.
36
+               add_action( 'init', array( $this, 'register_post_type' ) );
37
+               add_action( 'init', array( $this, 'exercise_type_taxonomy_setup' ) );
38
+               add_action( 'init', array( $this, 'equipment_taxonomy_setup' ) );
39
+               add_action( 'init', array( $this, 'muscle_group_taxonomy_setup' ) );
40
+               add_action( 'admin_menu', array( $this, 'register_menus' ) );
41
+
42
+               // Custom Fields.
43
+               add_action( 'cmb2_admin_init', array( $this, 'exercise_details' ), 8 );
44
+               add_action( 'cmb2_admin_init', array( $this, 'gallery_metabox' ), 9 );
45
+               add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
46
+
47
+               // Template Redirects.
48
+               add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
49
+               add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
50
+
51
+               //Breadcrumbs
52
+               add_filter( 'wpseo_breadcrumb_links', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 );
53
+               add_filter( 'woocommerce_get_breadcrumb', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 );
54
+
55
+          }
56
+
57
+     }
58
+
59
+
60
+     /**
61
+      * Return an instance of this class.
62
+      *
63
+      * @since 1.0.0
64
+      *
65
+      * @return    object \lsx_health_plan\classes\Exercise()    A single instance of this class.
66
+      */
67
+     public static function get_instance() {
68
+          // If the single instance hasn't been set, set it now.
69
+          if ( null === self::$instance ) {
70
+               self::$instance = new self();
71
+          }
72
+          return self::$instance;
73
+     }
74
+     /**
75
+      * Register the post type.
76
+      */
77
+     public function register_post_type() {
78
+          $labels = array(
79
+               'name'               => esc_html__( 'Exercises', 'lsx-health-plan' ),
80
+               'singular_name'      => esc_html__( 'Exercise', 'lsx-health-plan' ),
81
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
82
+               'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
83
+               'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
84
+               'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
85
+               'all_items'          => esc_html__( 'All Exercises', 'lsx-health-plan' ),
86
+               'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
87
+               'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
88
+               'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
89
+               'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
90
+               'parent_item_colon'  => '',
91
+               'menu_name'          => esc_html__( 'Exercises', 'lsx-health-plan' ),
92
+          );
93
+          $args   = array(
94
+               'labels'             => $labels,
95
+               'public'             => true,
96
+               'publicly_queryable' => true,
97
+               'show_ui'            => true,
98
+               'show_in_menu'       => 'edit.php?post_type=workout-pseudo',
99
+               'show_in_rest'       => true,
100
+               'menu_icon'          => 'dashicons-universal-access',
101
+               'query_var'          => true,
102
+               'rewrite'            => array(
103
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ),
104
+               ),
105
+               'capability_type'    => 'page',
106
+               'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercises' ),
107
+               'hierarchical'       => false,
108
+               'menu_position'      => null,
109
+               'supports'           => array(
110
+                    'title',
111
+                    'thumbnail',
112
+                    'editor',
113
+                    'excerpt',
114
+                    'custom-fields',
115
+               ),
116
+          );
117
+          register_post_type( 'exercise', $args );
118
+     }
119
+
120
+     /**
121
+      * Register the Exercise taxonomy.
122
+      *
123
+      * @return void
124
+      */
125
+     public function exercise_type_taxonomy_setup() {
126
+          $labels = array(
127
+               'name'              => esc_html_x( 'Exercise Type', 'taxonomy general name', 'lsx-health-plan' ),
128
+               'singular_name'     => esc_html_x( 'Exercise Type', 'taxonomy singular name', 'lsx-health-plan' ),
129
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
130
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
131
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
132
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
133
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
134
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
135
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
136
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
137
+               'menu_name'         => esc_html__( 'Exercise Types', 'lsx-health-plan' ),
138
+          );
139
+
140
+          $args = array(
141
+               'hierarchical'      => true,
142
+               'labels'            => $labels,
143
+               'show_ui'           => true,
144
+               'show_admin_column' => true,
145
+               'query_var'         => true,
146
+               'rewrite'           => array(
147
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_type', 'exercise-type' ),
148
+               ),
149
+               'show_in_rest'      => true,
150
+          );
151
+
152
+          register_taxonomy( 'exercise-type', array( 'exercise' ), $args );
153
+     }
154
+
155
+     /**
156
+      * Register the Exercise taxonomy.
157
+      *
158
+      * @return void
159
+      */
160
+     public function equipment_taxonomy_setup() {
161
+          $labels = array(
162
+               'name'              => esc_html_x( 'Equipment', 'taxonomy general name', 'lsx-health-plan' ),
163
+               'singular_name'     => esc_html_x( 'Equipment', 'taxonomy singular name', 'lsx-health-plan' ),
164
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
165
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
166
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
167
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
168
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
169
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
170
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
171
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
172
+               'menu_name'         => esc_html__( 'Equipment', 'lsx-health-plan' ),
173
+          );
174
+
175
+          $args = array(
176
+               'hierarchical'      => true,
177
+               'labels'            => $labels,
178
+               'show_ui'           => true,
179
+               'show_admin_column' => true,
180
+               'query_var'         => true,
181
+               'rewrite'           => array(
182
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_equipment', 'equipment' ),
183
+               ),
184
+               'show_in_rest'      => true,
185
+          );
186
+
187
+          register_taxonomy( 'equipment', array( 'exercise' ), $args );
188
+     }
189
+
190
+     /**
191
+      * Register the Muscle Group taxonomy.
192
+      *
193
+      * @return void
194
+      */
195
+     public function muscle_group_taxonomy_setup() {
196
+          $labels = array(
197
+               'name'              => esc_html_x( 'Muscle Groups', 'taxonomy general name', 'lsx-health-plan' ),
198
+               'singular_name'     => esc_html_x( 'Muscle Group', 'taxonomy singular name', 'lsx-health-plan' ),
199
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
200
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
201
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
202
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
203
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
204
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
205
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
206
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
207
+               'menu_name'         => esc_html__( 'Muscle Groups', 'lsx-health-plan' ),
208
+          );
209
+
210
+          $args = array(
211
+               'hierarchical'      => true,
212
+               'labels'            => $labels,
213
+               'show_ui'           => true,
214
+               'show_admin_column' => true,
215
+               'query_var'         => true,
216
+               'rewrite'           => array(
217
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_musclegroup', 'muscle-group' ),
218
+               ),
219
+               'show_in_rest'      => true,
220
+          );
221
+
222
+          register_taxonomy( 'muscle-group', array( 'exercise' ), $args );
223
+     }
224
+
225
+     /**
226
+      * Registers the Recipes under the Meals Post type menu.
227
+      *
228
+      * @return void
229
+      */
230
+     public function register_menus() {
231
+          add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercises', 'lsx-health-plan' ), esc_html__( 'Exercises', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=exercise' );
232
+          add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercise Types', 'lsx-health-plan' ), esc_html__( 'Exercise Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=exercise-type&post_type=exercise' );
233
+          add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Equipment', 'lsx-health-plan' ), esc_html__( 'Equipment', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=equipment&post_type=exercise' );
234
+          add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Muscle Groups', 'lsx-health-plan' ), esc_html__( 'Muscle Groups', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=muscle-group&post_type=exercise' );
235
+     }
236
+
237
+     /**
238
+      * Adds the post type to the different arrays.
239
+      *
240
+      * @param array $post_types
241
+      * @return array
242
+      */
243
+     public function enable_post_type( $post_types = array() ) {
244
+          $post_types[] = $this->slug;
245
+          return $post_types;
246
+     }
247
+
248
+     /**
249
+      * Enables the Bi Directional relationships
250
+      *
251
+      * @param array $connections
252
+      * @return void
253
+      */
254
+     public function enable_connections( $connections = array() ) {
255
+          $connections['exercise']['connected_workouts'] = 'connected_exercises';
256
+          $connections['workout']['connected_exercises'] = 'connected_workouts';
257
+          return $connections;
258
+     }
259
+
260
+     /**
261
+      * Define the metabox and field configurations.
262
+      */
263
+     public function gallery_metabox() {
264
+          $cmb = new_cmb2_box(
265
+               array(
266
+                    'id'           => $this->slug . '_gallery_details_metabox',
267
+                    'title'        => __( 'Exercise Gallery', 'lsx-health-plan' ),
268
+                    'object_types' => array( $this->slug ),
269
+                    'context'      => 'normal',
270
+                    'priority'     => 'low',
271
+                    'show_names'   => true,
272
+               )
273
+          );
274
+
275
+          $cmb->add_field(
276
+               array(
277
+                    'name'    => __( 'Layout', 'lsx-health-plan' ),
278
+                    'id'      => $this->slug . '_gallery_layout',
279
+                    'type'    => 'radio',
280
+                    'options' => array(
281
+                         'slider' => __( 'Slider', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
282
+                         'grid'   => __( 'Grid', 'lsx-health-plan' ),
283
+                    ),
284
+                    'default' => 'grid',
285
+               )
286
+          );
287
+
288
+          $cmb->add_field(
289
+               array(
290
+                    'name'    => __( 'Grid Columns', 'lsx-health-plan' ),
291
+                    'id'      => $this->slug . '_gallery_columns',
292
+                    'type'    => 'select',
293
+                    'options' => array(
294
+                         '3' => __( '2 Columns', 'lsx-health-plan' ),
295
+                         '4' => __( '3 Columns', 'lsx-health-plan' ),
296
+                    ),
297
+                    'default' => '1',
298
+               )
299
+          );
300
+
301
+          // Repeatable group.
302
+          $gallery_group = $cmb->add_field(
303
+               array(
304
+                    'id'      => $this->slug . '_gallery',
305
+                    'type'    => 'group',
306
+                    'options' => array(
307
+                         'group_title'   => __( 'Gallery', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
308
+                         'add_button'    => __( 'Add Item', 'lsx-health-plan' ),
309
+                         'remove_button' => __( 'Remove Item', 'lsx-health-plan' ),
310
+                         'sortable'      => true,
311
+                    ),
312
+                    'desc'    => __( 'Upload only one image, video or gif per gallery group, each group will only display 1 item.', 'lsx-health-plan' ),
313
+                    'classes' => 'lsx-admin-row',
314
+               )
315
+          );
316
+
317
+          // Title.
318
+          $cmb->add_group_field(
319
+               $gallery_group,
320
+               array(
321
+                    'name'       => __( 'Image', 'lsx-health-plan' ),
322
+                    'id'         => $this->slug . '_gallery_image',
323
+                    'type'       => 'file',
324
+                    'text'       => array(
325
+                         'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
326
+                    ),
327
+                    'desc'       => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ),
328
+                    'query_args' => array(
329
+                         'type' => array(
330
+                              'image/gif',
331
+                              'image/jpeg',
332
+                              'image/png',
333
+                         ),
334
+                    ),
335
+                    'preview_size' => 'lsx-thumbnail-wide',
336
+                    'classes' => 'lsx-field-col lsx-field-col-80',
337
+               )
338
+          );
339
+
340
+          // Title.
341
+          $cmb->add_group_field(
342
+               $gallery_group,
343
+               array(
344
+                    'name'    => __( 'oEmbed', 'lsx-health-plan' ),
345
+                    'id'      => $this->slug . '_gallery_embed',
346
+                    'type'    => 'text',
347
+                    'desc'    => __( 'Drop in the embed url for your video from YouTube, Vimeo or DailyMotion, e.g: "https://www.youtube.com/watch?v=9xwazD5SyVg". A full list of supports formats can be found at <a href="https://make.wordpress.org/support/user-manual/content/media/adding-media-to-your-pages-and-posts/embedding-media-from-other-sites/">WordPress</a>', 'lsx-health-plan' ),
348
+                    'classes' => 'test-apply-form lsx-field-col lsx-field-col-50',
349
+               )
350
+          );
351
+
352
+          $cmb->add_group_field(
353
+               $gallery_group,
354
+               array(
355
+                    'name'    => __( 'External Media', 'lsx-health-plan' ),
356
+                    'id'      => $this->slug . '_gallery_external',
357
+                    'type'    => 'textarea_code',
358
+                    'desc'    => __( 'Drop in the iFrame embed code from Giphy in this field, i.e: &lt;iframe src="https://giphy.com/embed/3o7527Rn1HxXWqgxuo" width="480" height="270" frameborder="0" class="giphy-embed" allowfullscreen&gt;&lt;/iframe&gt;', 'lsx-health-plan' ),
359
+                    'classes' => 'lsx-field-col lsx-field-col-50',
360
+               )
361
+          );
362
+     }
363
+
364
+     /**
365
+      * Registers the general settings for the exercise.
366
+      *
367
+      * @return void
368
+      */
369
+     public function exercise_details() {
370
+          $cmb = new_cmb2_box(
371
+               array(
372
+                    'id'           => $this->slug . '_general_details_metabox',
373
+                    'title'        => __( 'Details', 'lsx-health-plan' ),
374
+                    'object_types' => array( $this->slug ),
375
+                    'context'      => 'normal',
376
+                    'priority'     => 'high',
377
+                    'show_names'   => true,
378
+               )
379
+          );
380
+
381
+          $cmb->add_field(
382
+               array(
383
+                    'name'    => __( 'Side', 'lsx-health-plan' ),
384
+                    'id'      => $this->slug . '_side',
385
+                    'type'    => 'select',
386
+                    'options' => array(
387
+                         ''      => __( 'Select', 'lsx-health-plan' ),
388
+                         'left'  => __( 'Left', 'lsx-health-plan' ),
389
+                         'right' => __( 'Right', 'lsx-health-plan' ),
390
+                    ),
391
+                    'desc'    => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ),
392
+               )
393
+          );
394
+     }
395
+
396
+     /**
397
+      * Holds the array for the single exercise breadcrumbs.
398
+      *
399
+      * @var array $crumbs
400
+      * @return array
401
+      */
402
+     public function exercise_breadcrumb_filter( $crumbs ) {
403
+          $exercise  = \lsx_health_plan\functions\get_option( 'endpoint_exercise', 'exercise' );
404
+          $exercises = \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercise' );
405
+          $url       = get_post_type_archive_link( $exercise );
406
+
407
+          if ( is_singular( 'exercise' ) ) {
408
+               $exercise_name     = get_the_title();	
409
+               $term_obj_list     = get_the_terms( get_the_ID(), 'exercise-type' );
410
+               $exercise_type     = $term_obj_list[0]->name;
411
+               $exercise_type_url = get_term_link( $term_obj_list[0]->term_id );
412
+
413
+               $new_crumbs    = array();
414
+               $new_crumbs[0] = $crumbs[0];
415
+
416
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
417
+                    $new_crumbs[1] = array(
418
+                         0 => $exercises,
419
+                         1 => $url,
420
+                    );
421
+                    $new_crumbs[2] = array(
422
+                         0 => $exercise_type,
423
+                         1 => $exercise_type_url,
424
+                    );
425
+                    $new_crumbs[3] = array(
426
+                         0 => $exercise_name,
427
+                    );
428
+               } else {
429
+                    $new_crumbs[1] = array(
430
+                         'text' => $exercises,
431
+                         'url'  => $url,
432
+                    );
433
+                    $new_crumbs[2] = array(
434
+                         'text' => $exercise_type,
435
+                         'url'  => $exercise_type_url,
436
+                    );
437
+                    $new_crumbs[3] = array(
438
+                         'text' => $exercise_name,
439
+                    );
440
+               }
441
+               $crumbs = $new_crumbs;
442 442
 		
443
-		}
444
-		if ( is_tax( 'exercise-type' ) || is_tax( 'muscle-group' ) || is_tax( 'equipment' ) ) {
445
-			$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
446
-
447
-			$single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name;
448
-
449
-			$new_crumbs    = array();
450
-			$new_crumbs[0] = $crumbs[0];
451
-
452
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
453
-				$new_crumbs[1] = array(
454
-					0 => $exercises,
455
-					1 => $url,
456
-				);
457
-				$new_crumbs[2] = array(
458
-					0 => $single_term_title,
459
-				);
460
-			} else {
461
-				$new_crumbs[1] = array(
462
-					'text' => $exercises,
463
-					'url'  => $url,
464
-				);
465
-				$new_crumbs[2] = array(
466
-					'text' => $single_term_title,
467
-				);
468
-			}
469
-			$crumbs = $new_crumbs;
470
-
471
-		}
472
-		if ( is_post_type_archive( 'exercise' ) ) {
473
-
474
-			$new_crumbs    = array();
475
-			$new_crumbs[0] = $crumbs[0];
476
-
477
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
478
-				$new_crumbs[1] = array(
479
-					0 => $exercises,
480
-				);
481
-			} else {
482
-				$new_crumbs[1] = array(
483
-					'text' => $exercises,
484
-				);
485
-			}
486
-			$crumbs = $new_crumbs;
487
-		}
488
-		return $crumbs;
489
-	}
443
+          }
444
+          if ( is_tax( 'exercise-type' ) || is_tax( 'muscle-group' ) || is_tax( 'equipment' ) ) {
445
+               $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
446
+
447
+               $single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name;
448
+
449
+               $new_crumbs    = array();
450
+               $new_crumbs[0] = $crumbs[0];
451
+
452
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
453
+                    $new_crumbs[1] = array(
454
+                         0 => $exercises,
455
+                         1 => $url,
456
+                    );
457
+                    $new_crumbs[2] = array(
458
+                         0 => $single_term_title,
459
+                    );
460
+               } else {
461
+                    $new_crumbs[1] = array(
462
+                         'text' => $exercises,
463
+                         'url'  => $url,
464
+                    );
465
+                    $new_crumbs[2] = array(
466
+                         'text' => $single_term_title,
467
+                    );
468
+               }
469
+               $crumbs = $new_crumbs;
470
+
471
+          }
472
+          if ( is_post_type_archive( 'exercise' ) ) {
473
+
474
+               $new_crumbs    = array();
475
+               $new_crumbs[0] = $crumbs[0];
476
+
477
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
478
+                    $new_crumbs[1] = array(
479
+                         0 => $exercises,
480
+                    );
481
+               } else {
482
+                    $new_crumbs[1] = array(
483
+                         'text' => $exercises,
484
+                    );
485
+               }
486
+               $crumbs = $new_crumbs;
487
+          }
488
+          return $crumbs;
489
+     }
490 490
 }
Please login to merge, or discard this patch.
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -31,26 +31,26 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	public function __construct() {
33 33
 
34
-		if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
34
+		if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) {
35 35
 			// Post Type and Taxonomies.
36
-			add_action( 'init', array( $this, 'register_post_type' ) );
37
-			add_action( 'init', array( $this, 'exercise_type_taxonomy_setup' ) );
38
-			add_action( 'init', array( $this, 'equipment_taxonomy_setup' ) );
39
-			add_action( 'init', array( $this, 'muscle_group_taxonomy_setup' ) );
40
-			add_action( 'admin_menu', array( $this, 'register_menus' ) );
36
+			add_action('init', array($this, 'register_post_type'));
37
+			add_action('init', array($this, 'exercise_type_taxonomy_setup'));
38
+			add_action('init', array($this, 'equipment_taxonomy_setup'));
39
+			add_action('init', array($this, 'muscle_group_taxonomy_setup'));
40
+			add_action('admin_menu', array($this, 'register_menus'));
41 41
 
42 42
 			// Custom Fields.
43
-			add_action( 'cmb2_admin_init', array( $this, 'exercise_details' ), 8 );
44
-			add_action( 'cmb2_admin_init', array( $this, 'gallery_metabox' ), 9 );
45
-			add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
43
+			add_action('cmb2_admin_init', array($this, 'exercise_details'), 8);
44
+			add_action('cmb2_admin_init', array($this, 'gallery_metabox'), 9);
45
+			add_filter('lsx_health_plan_connections', array($this, 'enable_connections'), 10, 1);
46 46
 
47 47
 			// Template Redirects.
48
-			add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
49
-			add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
48
+			add_filter('lsx_health_plan_archive_template', array($this, 'enable_post_type'), 10, 1);
49
+			add_filter('lsx_health_plan_single_template', array($this, 'enable_post_type'), 10, 1);
50 50
 
51 51
 			//Breadcrumbs
52
-			add_filter( 'wpseo_breadcrumb_links', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 );
53
-			add_filter( 'woocommerce_get_breadcrumb', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 );
52
+			add_filter('wpseo_breadcrumb_links', array($this, 'exercise_breadcrumb_filter'), 30, 1);
53
+			add_filter('woocommerce_get_breadcrumb', array($this, 'exercise_breadcrumb_filter'), 30, 1);
54 54
 
55 55
 		}
56 56
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public static function get_instance() {
68 68
 		// If the single instance hasn't been set, set it now.
69
-		if ( null === self::$instance ) {
69
+		if (null === self::$instance) {
70 70
 			self::$instance = new self();
71 71
 		}
72 72
 		return self::$instance;
@@ -76,21 +76,21 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function register_post_type() {
78 78
 		$labels = array(
79
-			'name'               => esc_html__( 'Exercises', 'lsx-health-plan' ),
80
-			'singular_name'      => esc_html__( 'Exercise', 'lsx-health-plan' ),
81
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
82
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
83
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
84
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
85
-			'all_items'          => esc_html__( 'All Exercises', 'lsx-health-plan' ),
86
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
87
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
88
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
89
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
79
+			'name'               => esc_html__('Exercises', 'lsx-health-plan'),
80
+			'singular_name'      => esc_html__('Exercise', 'lsx-health-plan'),
81
+			'add_new'            => esc_html_x('Add New', 'post type general name', 'lsx-health-plan'),
82
+			'add_new_item'       => esc_html__('Add New', 'lsx-health-plan'),
83
+			'edit_item'          => esc_html__('Edit', 'lsx-health-plan'),
84
+			'new_item'           => esc_html__('New', 'lsx-health-plan'),
85
+			'all_items'          => esc_html__('All Exercises', 'lsx-health-plan'),
86
+			'view_item'          => esc_html__('View', 'lsx-health-plan'),
87
+			'search_items'       => esc_html__('Search', 'lsx-health-plan'),
88
+			'not_found'          => esc_html__('None found', 'lsx-health-plan'),
89
+			'not_found_in_trash' => esc_html__('None found in Trash', 'lsx-health-plan'),
90 90
 			'parent_item_colon'  => '',
91
-			'menu_name'          => esc_html__( 'Exercises', 'lsx-health-plan' ),
91
+			'menu_name'          => esc_html__('Exercises', 'lsx-health-plan'),
92 92
 		);
93
-		$args   = array(
93
+		$args = array(
94 94
 			'labels'             => $labels,
95 95
 			'public'             => true,
96 96
 			'publicly_queryable' => true,
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 			'menu_icon'          => 'dashicons-universal-access',
101 101
 			'query_var'          => true,
102 102
 			'rewrite'            => array(
103
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ),
103
+				'slug' => \lsx_health_plan\functions\get_option('endpoint_exercise_single', 'exercise'),
104 104
 			),
105 105
 			'capability_type'    => 'page',
106
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercises' ),
106
+			'has_archive'        => \lsx_health_plan\functions\get_option('endpoint_exercise_archive', 'exercises'),
107 107
 			'hierarchical'       => false,
108 108
 			'menu_position'      => null,
109 109
 			'supports'           => array(
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 				'custom-fields',
115 115
 			),
116 116
 		);
117
-		register_post_type( 'exercise', $args );
117
+		register_post_type('exercise', $args);
118 118
 	}
119 119
 
120 120
 	/**
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
 	 */
125 125
 	public function exercise_type_taxonomy_setup() {
126 126
 		$labels = array(
127
-			'name'              => esc_html_x( 'Exercise Type', 'taxonomy general name', 'lsx-health-plan' ),
128
-			'singular_name'     => esc_html_x( 'Exercise Type', 'taxonomy singular name', 'lsx-health-plan' ),
129
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
130
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
131
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
132
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
133
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
134
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
135
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
136
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
137
-			'menu_name'         => esc_html__( 'Exercise Types', 'lsx-health-plan' ),
127
+			'name'              => esc_html_x('Exercise Type', 'taxonomy general name', 'lsx-health-plan'),
128
+			'singular_name'     => esc_html_x('Exercise Type', 'taxonomy singular name', 'lsx-health-plan'),
129
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
130
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
131
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
132
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
133
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
134
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
135
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
136
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
137
+			'menu_name'         => esc_html__('Exercise Types', 'lsx-health-plan'),
138 138
 		);
139 139
 
140 140
 		$args = array(
@@ -144,12 +144,12 @@  discard block
 block discarded – undo
144 144
 			'show_admin_column' => true,
145 145
 			'query_var'         => true,
146 146
 			'rewrite'           => array(
147
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_type', 'exercise-type' ),
147
+				'slug' => \lsx_health_plan\functions\get_option('endpoint_exercise_type', 'exercise-type'),
148 148
 			),
149 149
 			'show_in_rest'      => true,
150 150
 		);
151 151
 
152
-		register_taxonomy( 'exercise-type', array( 'exercise' ), $args );
152
+		register_taxonomy('exercise-type', array('exercise'), $args);
153 153
 	}
154 154
 
155 155
 	/**
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function equipment_taxonomy_setup() {
161 161
 		$labels = array(
162
-			'name'              => esc_html_x( 'Equipment', 'taxonomy general name', 'lsx-health-plan' ),
163
-			'singular_name'     => esc_html_x( 'Equipment', 'taxonomy singular name', 'lsx-health-plan' ),
164
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
165
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
166
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
167
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
168
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
169
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
170
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
171
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
172
-			'menu_name'         => esc_html__( 'Equipment', 'lsx-health-plan' ),
162
+			'name'              => esc_html_x('Equipment', 'taxonomy general name', 'lsx-health-plan'),
163
+			'singular_name'     => esc_html_x('Equipment', 'taxonomy singular name', 'lsx-health-plan'),
164
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
165
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
166
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
167
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
168
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
169
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
170
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
171
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
172
+			'menu_name'         => esc_html__('Equipment', 'lsx-health-plan'),
173 173
 		);
174 174
 
175 175
 		$args = array(
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
 			'show_admin_column' => true,
180 180
 			'query_var'         => true,
181 181
 			'rewrite'           => array(
182
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_equipment', 'equipment' ),
182
+				'slug' => \lsx_health_plan\functions\get_option('endpoint_exercise_equipment', 'equipment'),
183 183
 			),
184 184
 			'show_in_rest'      => true,
185 185
 		);
186 186
 
187
-		register_taxonomy( 'equipment', array( 'exercise' ), $args );
187
+		register_taxonomy('equipment', array('exercise'), $args);
188 188
 	}
189 189
 
190 190
 	/**
@@ -194,17 +194,17 @@  discard block
 block discarded – undo
194 194
 	 */
195 195
 	public function muscle_group_taxonomy_setup() {
196 196
 		$labels = array(
197
-			'name'              => esc_html_x( 'Muscle Groups', 'taxonomy general name', 'lsx-health-plan' ),
198
-			'singular_name'     => esc_html_x( 'Muscle Group', 'taxonomy singular name', 'lsx-health-plan' ),
199
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
200
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
201
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
202
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
203
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
204
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
205
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
206
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
207
-			'menu_name'         => esc_html__( 'Muscle Groups', 'lsx-health-plan' ),
197
+			'name'              => esc_html_x('Muscle Groups', 'taxonomy general name', 'lsx-health-plan'),
198
+			'singular_name'     => esc_html_x('Muscle Group', 'taxonomy singular name', 'lsx-health-plan'),
199
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
200
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
201
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
202
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
203
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
204
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
205
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
206
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
207
+			'menu_name'         => esc_html__('Muscle Groups', 'lsx-health-plan'),
208 208
 		);
209 209
 
210 210
 		$args = array(
@@ -214,12 +214,12 @@  discard block
 block discarded – undo
214 214
 			'show_admin_column' => true,
215 215
 			'query_var'         => true,
216 216
 			'rewrite'           => array(
217
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_musclegroup', 'muscle-group' ),
217
+				'slug' => \lsx_health_plan\functions\get_option('endpoint_exercise_musclegroup', 'muscle-group'),
218 218
 			),
219 219
 			'show_in_rest'      => true,
220 220
 		);
221 221
 
222
-		register_taxonomy( 'muscle-group', array( 'exercise' ), $args );
222
+		register_taxonomy('muscle-group', array('exercise'), $args);
223 223
 	}
224 224
 
225 225
 	/**
@@ -228,10 +228,10 @@  discard block
 block discarded – undo
228 228
 	 * @return void
229 229
 	 */
230 230
 	public function register_menus() {
231
-		add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercises', 'lsx-health-plan' ), esc_html__( 'Exercises', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=exercise' );
232
-		add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercise Types', 'lsx-health-plan' ), esc_html__( 'Exercise Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=exercise-type&post_type=exercise' );
233
-		add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Equipment', 'lsx-health-plan' ), esc_html__( 'Equipment', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=equipment&post_type=exercise' );
234
-		add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Muscle Groups', 'lsx-health-plan' ), esc_html__( 'Muscle Groups', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=muscle-group&post_type=exercise' );
231
+		add_submenu_page('edit.php?post_type=workout', esc_html__('Exercises', 'lsx-health-plan'), esc_html__('Exercises', 'lsx-health-plan'), 'edit_posts', 'edit.php?post_type=exercise');
232
+		add_submenu_page('edit.php?post_type=workout', esc_html__('Exercise Types', 'lsx-health-plan'), esc_html__('Exercise Types', 'lsx-health-plan'), 'edit_posts', 'edit-tags.php?taxonomy=exercise-type&post_type=exercise');
233
+		add_submenu_page('edit.php?post_type=workout', esc_html__('Equipment', 'lsx-health-plan'), esc_html__('Equipment', 'lsx-health-plan'), 'edit_posts', 'edit-tags.php?taxonomy=equipment&post_type=exercise');
234
+		add_submenu_page('edit.php?post_type=workout', esc_html__('Muscle Groups', 'lsx-health-plan'), esc_html__('Muscle Groups', 'lsx-health-plan'), 'edit_posts', 'edit-tags.php?taxonomy=muscle-group&post_type=exercise');
235 235
 	}
236 236
 
237 237
 	/**
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 * @param array $post_types
241 241
 	 * @return array
242 242
 	 */
243
-	public function enable_post_type( $post_types = array() ) {
243
+	public function enable_post_type($post_types = array()) {
244 244
 		$post_types[] = $this->slug;
245 245
 		return $post_types;
246 246
 	}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * @param array $connections
252 252
 	 * @return void
253 253
 	 */
254
-	public function enable_connections( $connections = array() ) {
254
+	public function enable_connections($connections = array()) {
255 255
 		$connections['exercise']['connected_workouts'] = 'connected_exercises';
256 256
 		$connections['workout']['connected_exercises'] = 'connected_workouts';
257 257
 		return $connections;
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 		$cmb = new_cmb2_box(
265 265
 			array(
266 266
 				'id'           => $this->slug . '_gallery_details_metabox',
267
-				'title'        => __( 'Exercise Gallery', 'lsx-health-plan' ),
268
-				'object_types' => array( $this->slug ),
267
+				'title'        => __('Exercise Gallery', 'lsx-health-plan'),
268
+				'object_types' => array($this->slug),
269 269
 				'context'      => 'normal',
270 270
 				'priority'     => 'low',
271 271
 				'show_names'   => true,
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 
275 275
 		$cmb->add_field(
276 276
 			array(
277
-				'name'    => __( 'Layout', 'lsx-health-plan' ),
277
+				'name'    => __('Layout', 'lsx-health-plan'),
278 278
 				'id'      => $this->slug . '_gallery_layout',
279 279
 				'type'    => 'radio',
280 280
 				'options' => array(
281
-					'slider' => __( 'Slider', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
282
-					'grid'   => __( 'Grid', 'lsx-health-plan' ),
281
+					'slider' => __('Slider', 'lsx-health-plan') . ' {#}', // {#} gets replaced by row number
282
+					'grid'   => __('Grid', 'lsx-health-plan'),
283 283
 				),
284 284
 				'default' => 'grid',
285 285
 			)
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
 
288 288
 		$cmb->add_field(
289 289
 			array(
290
-				'name'    => __( 'Grid Columns', 'lsx-health-plan' ),
290
+				'name'    => __('Grid Columns', 'lsx-health-plan'),
291 291
 				'id'      => $this->slug . '_gallery_columns',
292 292
 				'type'    => 'select',
293 293
 				'options' => array(
294
-					'3' => __( '2 Columns', 'lsx-health-plan' ),
295
-					'4' => __( '3 Columns', 'lsx-health-plan' ),
294
+					'3' => __('2 Columns', 'lsx-health-plan'),
295
+					'4' => __('3 Columns', 'lsx-health-plan'),
296 296
 				),
297 297
 				'default' => '1',
298 298
 			)
@@ -304,12 +304,12 @@  discard block
 block discarded – undo
304 304
 				'id'      => $this->slug . '_gallery',
305 305
 				'type'    => 'group',
306 306
 				'options' => array(
307
-					'group_title'   => __( 'Gallery', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
308
-					'add_button'    => __( 'Add Item', 'lsx-health-plan' ),
309
-					'remove_button' => __( 'Remove Item', 'lsx-health-plan' ),
307
+					'group_title'   => __('Gallery', 'lsx-health-plan') . ' {#}', // {#} gets replaced by row number
308
+					'add_button'    => __('Add Item', 'lsx-health-plan'),
309
+					'remove_button' => __('Remove Item', 'lsx-health-plan'),
310 310
 					'sortable'      => true,
311 311
 				),
312
-				'desc'    => __( 'Upload only one image, video or gif per gallery group, each group will only display 1 item.', 'lsx-health-plan' ),
312
+				'desc'    => __('Upload only one image, video or gif per gallery group, each group will only display 1 item.', 'lsx-health-plan'),
313 313
 				'classes' => 'lsx-admin-row',
314 314
 			)
315 315
 		);
@@ -318,13 +318,13 @@  discard block
 block discarded – undo
318 318
 		$cmb->add_group_field(
319 319
 			$gallery_group,
320 320
 			array(
321
-				'name'       => __( 'Image', 'lsx-health-plan' ),
321
+				'name'       => __('Image', 'lsx-health-plan'),
322 322
 				'id'         => $this->slug . '_gallery_image',
323 323
 				'type'       => 'file',
324 324
 				'text'       => array(
325
-					'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
325
+					'add_upload_file_text' => __('Add File', 'lsx-health-plan'),
326 326
 				),
327
-				'desc'       => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ),
327
+				'desc'       => __('Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan'),
328 328
 				'query_args' => array(
329 329
 					'type' => array(
330 330
 						'image/gif',
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
 		$cmb->add_group_field(
342 342
 			$gallery_group,
343 343
 			array(
344
-				'name'    => __( 'oEmbed', 'lsx-health-plan' ),
344
+				'name'    => __('oEmbed', 'lsx-health-plan'),
345 345
 				'id'      => $this->slug . '_gallery_embed',
346 346
 				'type'    => 'text',
347
-				'desc'    => __( 'Drop in the embed url for your video from YouTube, Vimeo or DailyMotion, e.g: "https://www.youtube.com/watch?v=9xwazD5SyVg". A full list of supports formats can be found at <a href="https://make.wordpress.org/support/user-manual/content/media/adding-media-to-your-pages-and-posts/embedding-media-from-other-sites/">WordPress</a>', 'lsx-health-plan' ),
347
+				'desc'    => __('Drop in the embed url for your video from YouTube, Vimeo or DailyMotion, e.g: "https://www.youtube.com/watch?v=9xwazD5SyVg". A full list of supports formats can be found at <a href="https://make.wordpress.org/support/user-manual/content/media/adding-media-to-your-pages-and-posts/embedding-media-from-other-sites/">WordPress</a>', 'lsx-health-plan'),
348 348
 				'classes' => 'test-apply-form lsx-field-col lsx-field-col-50',
349 349
 			)
350 350
 		);
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 		$cmb->add_group_field(
353 353
 			$gallery_group,
354 354
 			array(
355
-				'name'    => __( 'External Media', 'lsx-health-plan' ),
355
+				'name'    => __('External Media', 'lsx-health-plan'),
356 356
 				'id'      => $this->slug . '_gallery_external',
357 357
 				'type'    => 'textarea_code',
358
-				'desc'    => __( 'Drop in the iFrame embed code from Giphy in this field, i.e: &lt;iframe src="https://giphy.com/embed/3o7527Rn1HxXWqgxuo" width="480" height="270" frameborder="0" class="giphy-embed" allowfullscreen&gt;&lt;/iframe&gt;', 'lsx-health-plan' ),
358
+				'desc'    => __('Drop in the iFrame embed code from Giphy in this field, i.e: &lt;iframe src="https://giphy.com/embed/3o7527Rn1HxXWqgxuo" width="480" height="270" frameborder="0" class="giphy-embed" allowfullscreen&gt;&lt;/iframe&gt;', 'lsx-health-plan'),
359 359
 				'classes' => 'lsx-field-col lsx-field-col-50',
360 360
 			)
361 361
 		);
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 		$cmb = new_cmb2_box(
371 371
 			array(
372 372
 				'id'           => $this->slug . '_general_details_metabox',
373
-				'title'        => __( 'Details', 'lsx-health-plan' ),
374
-				'object_types' => array( $this->slug ),
373
+				'title'        => __('Details', 'lsx-health-plan'),
374
+				'object_types' => array($this->slug),
375 375
 				'context'      => 'normal',
376 376
 				'priority'     => 'high',
377 377
 				'show_names'   => true,
@@ -380,15 +380,15 @@  discard block
 block discarded – undo
380 380
 
381 381
 		$cmb->add_field(
382 382
 			array(
383
-				'name'    => __( 'Side', 'lsx-health-plan' ),
383
+				'name'    => __('Side', 'lsx-health-plan'),
384 384
 				'id'      => $this->slug . '_side',
385 385
 				'type'    => 'select',
386 386
 				'options' => array(
387
-					''      => __( 'Select', 'lsx-health-plan' ),
388
-					'left'  => __( 'Left', 'lsx-health-plan' ),
389
-					'right' => __( 'Right', 'lsx-health-plan' ),
387
+					''      => __('Select', 'lsx-health-plan'),
388
+					'left'  => __('Left', 'lsx-health-plan'),
389
+					'right' => __('Right', 'lsx-health-plan'),
390 390
 				),
391
-				'desc'    => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ),
391
+				'desc'    => __('Select which side this exercise uses. ', 'lsx-health-plan'),
392 392
 			)
393 393
 		);
394 394
 	}
@@ -399,21 +399,21 @@  discard block
 block discarded – undo
399 399
 	 * @var array $crumbs
400 400
 	 * @return array
401 401
 	 */
402
-	public function exercise_breadcrumb_filter( $crumbs ) {
403
-		$exercise  = \lsx_health_plan\functions\get_option( 'endpoint_exercise', 'exercise' );
404
-		$exercises = \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercise' );
405
-		$url       = get_post_type_archive_link( $exercise );
402
+	public function exercise_breadcrumb_filter($crumbs) {
403
+		$exercise  = \lsx_health_plan\functions\get_option('endpoint_exercise', 'exercise');
404
+		$exercises = \lsx_health_plan\functions\get_option('endpoint_exercise_archive', 'exercise');
405
+		$url       = get_post_type_archive_link($exercise);
406 406
 
407
-		if ( is_singular( 'exercise' ) ) {
407
+		if (is_singular('exercise')) {
408 408
 			$exercise_name     = get_the_title();	
409
-			$term_obj_list     = get_the_terms( get_the_ID(), 'exercise-type' );
409
+			$term_obj_list     = get_the_terms(get_the_ID(), 'exercise-type');
410 410
 			$exercise_type     = $term_obj_list[0]->name;
411
-			$exercise_type_url = get_term_link( $term_obj_list[0]->term_id );
411
+			$exercise_type_url = get_term_link($term_obj_list[0]->term_id);
412 412
 
413 413
 			$new_crumbs    = array();
414 414
 			$new_crumbs[0] = $crumbs[0];
415 415
 
416
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
416
+			if (function_exists('woocommerce_breadcrumb')) {
417 417
 				$new_crumbs[1] = array(
418 418
 					0 => $exercises,
419 419
 					1 => $url,
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 			$crumbs = $new_crumbs;
442 442
 		
443 443
 		}
444
-		if ( is_tax( 'exercise-type' ) || is_tax( 'muscle-group' ) || is_tax( 'equipment' ) ) {
445
-			$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
444
+		if (is_tax('exercise-type') || is_tax('muscle-group') || is_tax('equipment')) {
445
+			$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); 
446 446
 
447
-			$single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name;
447
+			$single_term_title = str_replace('-', ' ', $term->taxonomy) . ': ' . $term->name;
448 448
 
449 449
 			$new_crumbs    = array();
450 450
 			$new_crumbs[0] = $crumbs[0];
451 451
 
452
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
452
+			if (function_exists('woocommerce_breadcrumb')) {
453 453
 				$new_crumbs[1] = array(
454 454
 					0 => $exercises,
455 455
 					1 => $url,
@@ -469,12 +469,12 @@  discard block
 block discarded – undo
469 469
 			$crumbs = $new_crumbs;
470 470
 
471 471
 		}
472
-		if ( is_post_type_archive( 'exercise' ) ) {
472
+		if (is_post_type_archive('exercise')) {
473 473
 
474 474
 			$new_crumbs    = array();
475 475
 			$new_crumbs[0] = $crumbs[0];
476 476
 
477
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
477
+			if (function_exists('woocommerce_breadcrumb')) {
478 478
 				$new_crumbs[1] = array(
479 479
 					0 => $exercises,
480 480
 				);
Please login to merge, or discard this patch.
classes/post-types/class-workout.php 2 patches
Indentation   +457 added lines, -457 removed lines patch added patch discarded remove patch
@@ -10,461 +10,461 @@
 block discarded – undo
10 10
  */
11 11
 class Workout {
12 12
 
13
-	/**
14
-	 * Holds class instance
15
-	 *
16
-	 * @since 1.0.0
17
-	 *
18
-	 * @var      object \lsx_health_plan\classes\Workout()
19
-	 */
20
-	protected static $instance = null;
21
-
22
-	/**
23
-	 * Holds post_type slug used as an index
24
-	 *
25
-	 * @since 1.0.0
26
-	 *
27
-	 * @var      string
28
-	 */
29
-	public $slug = 'workout';
30
-
31
-	/**
32
-	 * Constructor
33
-	 */
34
-	public function __construct() {
35
-		add_action( 'init', array( $this, 'register_post_type' ) );
36
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
37
-		add_action( 'init', array( $this, 'workout_type_taxonomy_setup' ) );
38
-		add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
39
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
40
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
41
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
42
-
43
-		// Template Redirects.
44
-		add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
45
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
46
-
47
-		//Breadcrumbs
48
-		add_filter( 'wpseo_breadcrumb_links', array( $this, 'workout_breadcrumb_filter' ), 30, 1 );
49
-		add_filter( 'woocommerce_get_breadcrumb', array( $this, 'workout_breadcrumb_filter' ), 30, 1 );
50
-	}
51
-
52
-	/**
53
-	 * Return an instance of this class.
54
-	 *
55
-	 * @since 1.0.0
56
-	 *
57
-	 * @return    object \lsx_health_plan\classes\Workout()    A single instance of this class.
58
-	 */
59
-	public static function get_instance() {
60
-		// If the single instance hasn't been set, set it now.
61
-		if ( null === self::$instance ) {
62
-			self::$instance = new self();
63
-		}
64
-		return self::$instance;
65
-	}
66
-	/**
67
-	 * Register the post type.
68
-	 */
69
-	public function register_post_type() {
70
-		$labels = array(
71
-			'name'               => esc_html__( 'Workouts', 'lsx-health-plan' ),
72
-			'singular_name'      => esc_html__( 'Workout', 'lsx-health-plan' ),
73
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
74
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
75
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
76
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
77
-			'all_items'          => esc_html__( 'All Workouts', 'lsx-health-plan' ),
78
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
79
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
80
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
81
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
82
-			'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
83
-			'menu_name'          => esc_html__( 'Workouts', 'lsx-health-plan' ),
84
-		);
85
-		$args = array(
86
-			'labels'             => $labels,
87
-			'public'             => true,
88
-			'publicly_queryable' => true,
89
-			'show_ui'            => true,
90
-			'show_in_menu'       => true,
91
-			'show_in_rest'       => true,
92
-			'menu_icon'          => 'dashicons-universal-access',
93
-			'query_var'          => true,
94
-			'rewrite'            => array(
95
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ),
96
-			),
97
-			'capability_type'    => 'page',
98
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workouts' ),
99
-			'hierarchical'       => true,
100
-			'menu_position'      => null,
101
-			'supports'           => array(
102
-				'title',
103
-				'thumbnail',
104
-				'editor',
105
-				'excerpt',
106
-				'page-attributes',
107
-				'custom-fields',
108
-			),
109
-		);
110
-		register_post_type( 'workout', $args );
111
-	}
112
-
113
-	/**
114
-	 * Register the Type taxonomy.
115
-	 */
116
-	public function workout_type_taxonomy_setup() {
117
-		$labels = array(
118
-			'name'              => esc_html_x( 'Workout Type', 'taxonomy general name', 'lsx-health-plan' ),
119
-			'singular_name'     => esc_html_x( 'Workout Type', 'taxonomy singular name', 'lsx-health-plan' ),
120
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
121
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
122
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
123
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
124
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
125
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
126
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
127
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
128
-			'menu_name'         => esc_html__( 'Workout Types', 'lsx-health-plan' ),
129
-		);
130
-
131
-		$args = array(
132
-			'hierarchical'      => true,
133
-			'labels'            => $labels,
134
-			'show_ui'           => true,
135
-			'show_admin_column' => true,
136
-			'query_var'         => true,
137
-			'rewrite'           => array(
138
-				'slug' => 'workout-type',
139
-			),
140
-		);
141
-
142
-		register_taxonomy( 'workout-type', array( 'workout' ), $args );
143
-	}
144
-
145
-	/**
146
-	 * Adds the post type to the different arrays.
147
-	 *
148
-	 * @param array $post_types
149
-	 * @return array
150
-	 */
151
-	public function enable_post_type( $post_types = array() ) {
152
-		$post_types[] = $this->slug;
153
-		return $post_types;
154
-	}
155
-
156
-	/**
157
-	 * Enables the Bi Directional relationships
158
-	 *
159
-	 * @param array $connections
160
-	 * @return void
161
-	 */
162
-	public function enable_connections( $connections = array() ) {
163
-		$connections['workout']['connected_plans'] = 'connected_workouts';
164
-		$connections['plan']['connected_workouts'] = 'connected_plans';
165
-
166
-		$connections['workout']['connected_videos'] = 'connected_workouts';
167
-		$connections['video']['connected_workouts'] = 'connected_videos';
168
-
169
-		$connections['workout']['connected_posts'] = 'connected_workouts';
170
-		$connections['post']['connected_workouts'] = 'connected_posts';
171
-		return $connections;
172
-	}
173
-
174
-	/**
175
-	 * Remove the "Archives:" from the post type workouts.
176
-	 *
177
-	 * @param string $title the term title.
178
-	 * @return string
179
-	 */
180
-	public function get_the_archive_title( $title ) {
181
-		if ( is_post_type_archive( 'workout' ) ) {
182
-			$title = __( 'Workouts', 'lsx-health-plan' );
183
-		}
184
-		return $title;
185
-	}
186
-
187
-	/**
188
-	 * Define the metabox and field configurations.
189
-	 */
190
-	public function featured_metabox() {
191
-		$cmb = new_cmb2_box(
192
-			array(
193
-				'id'           => $this->slug . '_featured_metabox_workout',
194
-				'title'        => __( 'Featured Workout', 'lsx-health-plan' ),
195
-				'object_types' => array( $this->slug ), // Post type
196
-				'context'      => 'side',
197
-				'priority'     => 'high',
198
-				'show_names'   => true,
199
-			)
200
-		);
201
-		$cmb->add_field(
202
-			array(
203
-				'name'       => __( 'Featured Workout', 'lsx-health-plan' ),
204
-				'desc'       => __( 'Enable a featured workout' ),
205
-				'id'         => $this->slug . '_featured_workout',
206
-				'type'       => 'checkbox',
207
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
208
-			)
209
-		);
210
-	}
211
-
212
-	/**
213
-	 * Define the metabox and field configurations.
214
-	 */
215
-	public function details_metaboxes() {
216
-
217
-		$cmb = new_cmb2_box( array(
218
-			'id'           => $this->slug . '_details_metabox',
219
-			'title'        => __( 'Workout Details', 'lsx-health-plan' ),
220
-			'object_types' => array( $this->slug ), // Post type
221
-			'context'      => 'normal',
222
-			'priority'     => 'high',
223
-			'show_names'   => true,
224
-		) );
225
-
226
-		$cmb->add_field( array(
227
-			'name' => __( 'Workout Short Description', 'lsx-health-plan' ),
228
-			'id'   => $this->slug . '_short_description',
229
-			'type' => 'textarea_small',
230
-			'desc' => __( 'Add a small description for this workout (optional)', 'lsx-health-plan' ),
231
-		) );
232
-
233
-		$workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 );
234
-		if ( false !== $workout_sections && null !== $workout_sections ) {
235
-			$i = 1;
236
-			while ( $i <= $workout_sections ) {
237
-
238
-				$cmb_group = new_cmb2_box( array(
239
-					'id'           => $this->slug . '_section_' . $i . '_metabox',
240
-					'title'        => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i,
241
-					'object_types' => array( $this->slug ),
242
-				) );
243
-
244
-				$cmb_group->add_field( array(
245
-					'name'       => __( 'Title', 'lsx-health-plan' ),
246
-					'id'         => $this->slug . '_section_' . $i . '_title',
247
-					'type'       => 'text',
248
-					'show_on_cb' => 'cmb2_hide_if_no_cats',
249
-				) );
250
-
251
-				$cmb_group->add_field(
252
-					array(
253
-						'name'       => __( 'Description', 'lsx-health-plan' ),
254
-						'id'         => $this->slug . '_section_' . $i . '_description',
255
-						'type'       => 'wysiwyg',
256
-						'show_on_cb' => 'cmb2_hide_if_no_cats',
257
-						'options'    => array(
258
-							'textarea_rows' => 5,
259
-						),
260
-					)
261
-				);
262
-
263
-				/**
264
-				 * Repeatable Field Groups
265
-				 */
266
-				// $group_field_id is the field id string, so in this case: $prefix . 'demo'
267
-				$group_field_id = $cmb_group->add_field(
268
-					array(
269
-						'id'      => $this->slug . '_section_' . $i,
270
-						'type'    => 'group',
271
-						'options' => array(
272
-							'group_title'   => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number
273
-							'add_button'    => esc_html__( 'Add New', 'lsx-health-plan' ),
274
-							'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ),
275
-							'sortable'      => true,
276
-							'closed'        => true, // true to have the groups closed by default
277
-						),
278
-					)
279
-				);
280
-
281
-				if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
282
-					$cmb_group->add_group_field(
283
-						$group_field_id,
284
-						array(
285
-							'name'       => __( 'Exercise related to this workout', 'lsx-health-plan' ),
286
-							'id'         => 'connected_exercises',
287
-							'type'       => 'post_search_ajax',
288
-							// Optional :
289
-							'limit'      => 1, // Limit selection to X items only (default 1)
290
-							'sortable'   => true,  // Allow selected items to be sortable (default false)
291
-							'query_args' => array(
292
-								'post_type'      => array( 'exercise' ),
293
-								'post_status'    => array( 'publish' ),
294
-								'posts_per_page' => -1,
295
-							),
296
-						)
297
-					);
298
-				} else {
299
-					$cmb_group->add_group_field(
300
-						$group_field_id,
301
-						array(
302
-							'name'       => __( 'Video related to this workout', 'lsx-health-plan' ),
303
-							'id'         => 'connected_videos',
304
-							'type'       => 'post_search_ajax',
305
-							// Optional :
306
-							'limit'      => 1, // Limit selection to X items only (default 1)
307
-							'sortable'   => true,  // Allow selected items to be sortable (default false)
308
-							'query_args' => array(
309
-								'post_type'      => array( 'video' ),
310
-								'post_status'    => array( 'publish' ),
311
-								'posts_per_page' => -1,
312
-							),
313
-						)
314
-					);
315
-					$cmb_group->add_group_field(
316
-						$group_field_id,
317
-						array(
318
-							'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ),
319
-							'id'   => 'name',
320
-							'type' => 'text',
321
-							// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
322
-						)
323
-					);
324
-
325
-					$cmb_group->add_group_field(
326
-						$group_field_id,
327
-						array(
328
-							'name'    => __( 'Description', 'lsx-health-plan' ),
329
-							'id'      => 'description',
330
-							'type'    => 'wysiwyg',
331
-							'options' => array(
332
-								'textarea_rows' => 2,
333
-							),
334
-						)
335
-					);
336
-				}
337
-
338
-				$cmb_group->add_group_field(
339
-					$group_field_id,
340
-					array(
341
-						'name' => esc_html__( 'Exercise title (Optional)', 'lsx-health-plan' ),
342
-						'id'   => 'alt_title',
343
-						'type' => 'text',
344
-					)
345
-				);
346
-				$cmb_group->add_group_field(
347
-					$group_field_id,
348
-					array(
349
-						'name' => esc_html__( 'Exercise Description (Optional)', 'lsx-health-plan' ),
350
-						'id'   => 'alt_description',
351
-						'type' => 'textarea_small',
352
-					)
353
-				);
354
-				$cmb_group->add_group_field(
355
-					$group_field_id,
356
-					array(
357
-						'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ),
358
-						'id'   => 'reps',
359
-						'type' => 'text',
360
-						// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
361
-					)
362
-				);
363
-				$cmb_group->add_group_field(
364
-					$group_field_id,
365
-					array(
366
-						'name'         => __( 'Exercise Image (Optional)', 'lsx-health-plan' ),
367
-						'id'           => 'exercise_alt_thumbnail',
368
-						'type'         => 'file',
369
-						'text'         => array(
370
-							'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
371
-						),
372
-						'desc'         => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ),
373
-						'query_args'   => array(
374
-							'type' => array(
375
-								'image/gif',
376
-								'image/jpeg',
377
-								'image/png',
378
-							),
379
-						),
380
-						'preview_size' => 'thumbnail',
381
-						'classes'      => 'lsx-field-col lsx-field-add-field  lsx-field-col-25',
382
-					)
383
-				);
384
-
385
-				$i++;
386
-			};
387
-		}
388
-	}
389
-	/**
390
-	 * Set the post type archive to show the parent plans only.
391
-	 *
392
-	 * @param object $wp_query
393
-	 * @return array
394
-	 */
395
-	public function set_parent_only( $wp_query ) {
396
-		if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'workout' ) || $wp_query->is_tax( array( 'workout-type' ) ) ) ) {
397
-			$wp_query->set( 'post_parent', '0' );
398
-		}
399
-	}
400
-
401
-	/**
402
-	 * Holds the array for the single workout breadcrumbs.
403
-	 *
404
-	 * @var array $crumbs
405
-	 * @return array
406
-	 */
407
-	public function workout_breadcrumb_filter( $crumbs ) {
408
-		$workout  = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
409
-		$workouts = \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workout' );
410
-
411
-		if ( is_singular( 'workout' ) ) {	
412
-			$workout_name  = get_the_title();
413
-			$url           = get_post_type_archive_link( $workout );
414
-			$term_obj_list = get_the_terms( get_the_ID(), 'workout-type' );
415
-			$workout_type  = $term_obj_list[0]->name;
416
-			if ( empty( $workout_type ) ) {
417
-				$workout_type = __( 'Workout', 'lsx-health-plan' );
418
-			}
419
-			$workout_type_url = get_term_link( $term_obj_list[0]->term_id );
420
-
421
-			$new_crumbs    = array();
422
-			$new_crumbs[0] = $crumbs[0];
423
-
424
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
425
-				$new_crumbs[1] = array(
426
-					0 => $workouts,
427
-					1 => $url,
428
-				);
429
-				$new_crumbs[2] = array(
430
-					0 => $workout_type,
431
-					1 => $workout_type_url,
432
-				);
433
-				$new_crumbs[3] = array(
434
-					0 => $workout_name,
435
-				);
436
-			} else {
437
-				$new_crumbs[1] = array(
438
-					'text' => $workouts,
439
-					'url'  => $url,
440
-				);
441
-				$new_crumbs[2] = array(
442
-					'text' => $workout_type,
443
-					'url'  => $workout_type_url,
444
-				);
445
-				$new_crumbs[3] = array(
446
-					'text' => $workout_name,
447
-				);
448
-			}
449
-			$crumbs = $new_crumbs;
450
-
451
-		}
452
-		if ( is_post_type_archive( 'workout' ) ) {
453
-
454
-			$new_crumbs    = array();
455
-			$new_crumbs[0] = $crumbs[0];
456
-
457
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
458
-				$new_crumbs[1] = array(
459
-					0 => $workouts,
460
-				);
461
-			} else {
462
-				$new_crumbs[1] = array(
463
-					'text' => $workouts,
464
-				);
465
-			}
466
-			$crumbs = $new_crumbs;
467
-		}
468
-		return $crumbs;
469
-	}
13
+     /**
14
+      * Holds class instance
15
+      *
16
+      * @since 1.0.0
17
+      *
18
+      * @var      object \lsx_health_plan\classes\Workout()
19
+      */
20
+     protected static $instance = null;
21
+
22
+     /**
23
+      * Holds post_type slug used as an index
24
+      *
25
+      * @since 1.0.0
26
+      *
27
+      * @var      string
28
+      */
29
+     public $slug = 'workout';
30
+
31
+     /**
32
+      * Constructor
33
+      */
34
+     public function __construct() {
35
+          add_action( 'init', array( $this, 'register_post_type' ) );
36
+          add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
37
+          add_action( 'init', array( $this, 'workout_type_taxonomy_setup' ) );
38
+          add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
39
+          add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
40
+          add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
41
+          add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
42
+
43
+          // Template Redirects.
44
+          add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
45
+          add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
46
+
47
+          //Breadcrumbs
48
+          add_filter( 'wpseo_breadcrumb_links', array( $this, 'workout_breadcrumb_filter' ), 30, 1 );
49
+          add_filter( 'woocommerce_get_breadcrumb', array( $this, 'workout_breadcrumb_filter' ), 30, 1 );
50
+     }
51
+
52
+     /**
53
+      * Return an instance of this class.
54
+      *
55
+      * @since 1.0.0
56
+      *
57
+      * @return    object \lsx_health_plan\classes\Workout()    A single instance of this class.
58
+      */
59
+     public static function get_instance() {
60
+          // If the single instance hasn't been set, set it now.
61
+          if ( null === self::$instance ) {
62
+               self::$instance = new self();
63
+          }
64
+          return self::$instance;
65
+     }
66
+     /**
67
+      * Register the post type.
68
+      */
69
+     public function register_post_type() {
70
+          $labels = array(
71
+               'name'               => esc_html__( 'Workouts', 'lsx-health-plan' ),
72
+               'singular_name'      => esc_html__( 'Workout', 'lsx-health-plan' ),
73
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
74
+               'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
75
+               'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
76
+               'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
77
+               'all_items'          => esc_html__( 'All Workouts', 'lsx-health-plan' ),
78
+               'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
79
+               'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
80
+               'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
81
+               'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
82
+               'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
83
+               'menu_name'          => esc_html__( 'Workouts', 'lsx-health-plan' ),
84
+          );
85
+          $args = array(
86
+               'labels'             => $labels,
87
+               'public'             => true,
88
+               'publicly_queryable' => true,
89
+               'show_ui'            => true,
90
+               'show_in_menu'       => true,
91
+               'show_in_rest'       => true,
92
+               'menu_icon'          => 'dashicons-universal-access',
93
+               'query_var'          => true,
94
+               'rewrite'            => array(
95
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ),
96
+               ),
97
+               'capability_type'    => 'page',
98
+               'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workouts' ),
99
+               'hierarchical'       => true,
100
+               'menu_position'      => null,
101
+               'supports'           => array(
102
+                    'title',
103
+                    'thumbnail',
104
+                    'editor',
105
+                    'excerpt',
106
+                    'page-attributes',
107
+                    'custom-fields',
108
+               ),
109
+          );
110
+          register_post_type( 'workout', $args );
111
+     }
112
+
113
+     /**
114
+      * Register the Type taxonomy.
115
+      */
116
+     public function workout_type_taxonomy_setup() {
117
+          $labels = array(
118
+               'name'              => esc_html_x( 'Workout Type', 'taxonomy general name', 'lsx-health-plan' ),
119
+               'singular_name'     => esc_html_x( 'Workout Type', 'taxonomy singular name', 'lsx-health-plan' ),
120
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
121
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
122
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
123
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
124
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
125
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
126
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
127
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
128
+               'menu_name'         => esc_html__( 'Workout Types', 'lsx-health-plan' ),
129
+          );
130
+
131
+          $args = array(
132
+               'hierarchical'      => true,
133
+               'labels'            => $labels,
134
+               'show_ui'           => true,
135
+               'show_admin_column' => true,
136
+               'query_var'         => true,
137
+               'rewrite'           => array(
138
+                    'slug' => 'workout-type',
139
+               ),
140
+          );
141
+
142
+          register_taxonomy( 'workout-type', array( 'workout' ), $args );
143
+     }
144
+
145
+     /**
146
+      * Adds the post type to the different arrays.
147
+      *
148
+      * @param array $post_types
149
+      * @return array
150
+      */
151
+     public function enable_post_type( $post_types = array() ) {
152
+          $post_types[] = $this->slug;
153
+          return $post_types;
154
+     }
155
+
156
+     /**
157
+      * Enables the Bi Directional relationships
158
+      *
159
+      * @param array $connections
160
+      * @return void
161
+      */
162
+     public function enable_connections( $connections = array() ) {
163
+          $connections['workout']['connected_plans'] = 'connected_workouts';
164
+          $connections['plan']['connected_workouts'] = 'connected_plans';
165
+
166
+          $connections['workout']['connected_videos'] = 'connected_workouts';
167
+          $connections['video']['connected_workouts'] = 'connected_videos';
168
+
169
+          $connections['workout']['connected_posts'] = 'connected_workouts';
170
+          $connections['post']['connected_workouts'] = 'connected_posts';
171
+          return $connections;
172
+     }
173
+
174
+     /**
175
+      * Remove the "Archives:" from the post type workouts.
176
+      *
177
+      * @param string $title the term title.
178
+      * @return string
179
+      */
180
+     public function get_the_archive_title( $title ) {
181
+          if ( is_post_type_archive( 'workout' ) ) {
182
+               $title = __( 'Workouts', 'lsx-health-plan' );
183
+          }
184
+          return $title;
185
+     }
186
+
187
+     /**
188
+      * Define the metabox and field configurations.
189
+      */
190
+     public function featured_metabox() {
191
+          $cmb = new_cmb2_box(
192
+               array(
193
+                    'id'           => $this->slug . '_featured_metabox_workout',
194
+                    'title'        => __( 'Featured Workout', 'lsx-health-plan' ),
195
+                    'object_types' => array( $this->slug ), // Post type
196
+                    'context'      => 'side',
197
+                    'priority'     => 'high',
198
+                    'show_names'   => true,
199
+               )
200
+          );
201
+          $cmb->add_field(
202
+               array(
203
+                    'name'       => __( 'Featured Workout', 'lsx-health-plan' ),
204
+                    'desc'       => __( 'Enable a featured workout' ),
205
+                    'id'         => $this->slug . '_featured_workout',
206
+                    'type'       => 'checkbox',
207
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
208
+               )
209
+          );
210
+     }
211
+
212
+     /**
213
+      * Define the metabox and field configurations.
214
+      */
215
+     public function details_metaboxes() {
216
+
217
+          $cmb = new_cmb2_box( array(
218
+               'id'           => $this->slug . '_details_metabox',
219
+               'title'        => __( 'Workout Details', 'lsx-health-plan' ),
220
+               'object_types' => array( $this->slug ), // Post type
221
+               'context'      => 'normal',
222
+               'priority'     => 'high',
223
+               'show_names'   => true,
224
+          ) );
225
+
226
+          $cmb->add_field( array(
227
+               'name' => __( 'Workout Short Description', 'lsx-health-plan' ),
228
+               'id'   => $this->slug . '_short_description',
229
+               'type' => 'textarea_small',
230
+               'desc' => __( 'Add a small description for this workout (optional)', 'lsx-health-plan' ),
231
+          ) );
232
+
233
+          $workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 );
234
+          if ( false !== $workout_sections && null !== $workout_sections ) {
235
+               $i = 1;
236
+               while ( $i <= $workout_sections ) {
237
+
238
+                    $cmb_group = new_cmb2_box( array(
239
+                         'id'           => $this->slug . '_section_' . $i . '_metabox',
240
+                         'title'        => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i,
241
+                         'object_types' => array( $this->slug ),
242
+                    ) );
243
+
244
+                    $cmb_group->add_field( array(
245
+                         'name'       => __( 'Title', 'lsx-health-plan' ),
246
+                         'id'         => $this->slug . '_section_' . $i . '_title',
247
+                         'type'       => 'text',
248
+                         'show_on_cb' => 'cmb2_hide_if_no_cats',
249
+                    ) );
250
+
251
+                    $cmb_group->add_field(
252
+                         array(
253
+                              'name'       => __( 'Description', 'lsx-health-plan' ),
254
+                              'id'         => $this->slug . '_section_' . $i . '_description',
255
+                              'type'       => 'wysiwyg',
256
+                              'show_on_cb' => 'cmb2_hide_if_no_cats',
257
+                              'options'    => array(
258
+                                   'textarea_rows' => 5,
259
+                              ),
260
+                         )
261
+                    );
262
+
263
+                    /**
264
+                     * Repeatable Field Groups
265
+                     */
266
+                    // $group_field_id is the field id string, so in this case: $prefix . 'demo'
267
+                    $group_field_id = $cmb_group->add_field(
268
+                         array(
269
+                              'id'      => $this->slug . '_section_' . $i,
270
+                              'type'    => 'group',
271
+                              'options' => array(
272
+                                   'group_title'   => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number
273
+                                   'add_button'    => esc_html__( 'Add New', 'lsx-health-plan' ),
274
+                                   'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ),
275
+                                   'sortable'      => true,
276
+                                   'closed'        => true, // true to have the groups closed by default
277
+                              ),
278
+                         )
279
+                    );
280
+
281
+                    if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
282
+                         $cmb_group->add_group_field(
283
+                              $group_field_id,
284
+                              array(
285
+                                   'name'       => __( 'Exercise related to this workout', 'lsx-health-plan' ),
286
+                                   'id'         => 'connected_exercises',
287
+                                   'type'       => 'post_search_ajax',
288
+                                   // Optional :
289
+                                   'limit'      => 1, // Limit selection to X items only (default 1)
290
+                                   'sortable'   => true,  // Allow selected items to be sortable (default false)
291
+                                   'query_args' => array(
292
+                                        'post_type'      => array( 'exercise' ),
293
+                                        'post_status'    => array( 'publish' ),
294
+                                        'posts_per_page' => -1,
295
+                                   ),
296
+                              )
297
+                         );
298
+                    } else {
299
+                         $cmb_group->add_group_field(
300
+                              $group_field_id,
301
+                              array(
302
+                                   'name'       => __( 'Video related to this workout', 'lsx-health-plan' ),
303
+                                   'id'         => 'connected_videos',
304
+                                   'type'       => 'post_search_ajax',
305
+                                   // Optional :
306
+                                   'limit'      => 1, // Limit selection to X items only (default 1)
307
+                                   'sortable'   => true,  // Allow selected items to be sortable (default false)
308
+                                   'query_args' => array(
309
+                                        'post_type'      => array( 'video' ),
310
+                                        'post_status'    => array( 'publish' ),
311
+                                        'posts_per_page' => -1,
312
+                                   ),
313
+                              )
314
+                         );
315
+                         $cmb_group->add_group_field(
316
+                              $group_field_id,
317
+                              array(
318
+                                   'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ),
319
+                                   'id'   => 'name',
320
+                                   'type' => 'text',
321
+                                   // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
322
+                              )
323
+                         );
324
+
325
+                         $cmb_group->add_group_field(
326
+                              $group_field_id,
327
+                              array(
328
+                                   'name'    => __( 'Description', 'lsx-health-plan' ),
329
+                                   'id'      => 'description',
330
+                                   'type'    => 'wysiwyg',
331
+                                   'options' => array(
332
+                                        'textarea_rows' => 2,
333
+                                   ),
334
+                              )
335
+                         );
336
+                    }
337
+
338
+                    $cmb_group->add_group_field(
339
+                         $group_field_id,
340
+                         array(
341
+                              'name' => esc_html__( 'Exercise title (Optional)', 'lsx-health-plan' ),
342
+                              'id'   => 'alt_title',
343
+                              'type' => 'text',
344
+                         )
345
+                    );
346
+                    $cmb_group->add_group_field(
347
+                         $group_field_id,
348
+                         array(
349
+                              'name' => esc_html__( 'Exercise Description (Optional)', 'lsx-health-plan' ),
350
+                              'id'   => 'alt_description',
351
+                              'type' => 'textarea_small',
352
+                         )
353
+                    );
354
+                    $cmb_group->add_group_field(
355
+                         $group_field_id,
356
+                         array(
357
+                              'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ),
358
+                              'id'   => 'reps',
359
+                              'type' => 'text',
360
+                              // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
361
+                         )
362
+                    );
363
+                    $cmb_group->add_group_field(
364
+                         $group_field_id,
365
+                         array(
366
+                              'name'         => __( 'Exercise Image (Optional)', 'lsx-health-plan' ),
367
+                              'id'           => 'exercise_alt_thumbnail',
368
+                              'type'         => 'file',
369
+                              'text'         => array(
370
+                                   'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
371
+                              ),
372
+                              'desc'         => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ),
373
+                              'query_args'   => array(
374
+                                   'type' => array(
375
+                                        'image/gif',
376
+                                        'image/jpeg',
377
+                                        'image/png',
378
+                                   ),
379
+                              ),
380
+                              'preview_size' => 'thumbnail',
381
+                              'classes'      => 'lsx-field-col lsx-field-add-field  lsx-field-col-25',
382
+                         )
383
+                    );
384
+
385
+                    $i++;
386
+               };
387
+          }
388
+     }
389
+     /**
390
+      * Set the post type archive to show the parent plans only.
391
+      *
392
+      * @param object $wp_query
393
+      * @return array
394
+      */
395
+     public function set_parent_only( $wp_query ) {
396
+          if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'workout' ) || $wp_query->is_tax( array( 'workout-type' ) ) ) ) {
397
+               $wp_query->set( 'post_parent', '0' );
398
+          }
399
+     }
400
+
401
+     /**
402
+      * Holds the array for the single workout breadcrumbs.
403
+      *
404
+      * @var array $crumbs
405
+      * @return array
406
+      */
407
+     public function workout_breadcrumb_filter( $crumbs ) {
408
+          $workout  = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
409
+          $workouts = \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workout' );
410
+
411
+          if ( is_singular( 'workout' ) ) {	
412
+               $workout_name  = get_the_title();
413
+               $url           = get_post_type_archive_link( $workout );
414
+               $term_obj_list = get_the_terms( get_the_ID(), 'workout-type' );
415
+               $workout_type  = $term_obj_list[0]->name;
416
+               if ( empty( $workout_type ) ) {
417
+                    $workout_type = __( 'Workout', 'lsx-health-plan' );
418
+               }
419
+               $workout_type_url = get_term_link( $term_obj_list[0]->term_id );
420
+
421
+               $new_crumbs    = array();
422
+               $new_crumbs[0] = $crumbs[0];
423
+
424
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
425
+                    $new_crumbs[1] = array(
426
+                         0 => $workouts,
427
+                         1 => $url,
428
+                    );
429
+                    $new_crumbs[2] = array(
430
+                         0 => $workout_type,
431
+                         1 => $workout_type_url,
432
+                    );
433
+                    $new_crumbs[3] = array(
434
+                         0 => $workout_name,
435
+                    );
436
+               } else {
437
+                    $new_crumbs[1] = array(
438
+                         'text' => $workouts,
439
+                         'url'  => $url,
440
+                    );
441
+                    $new_crumbs[2] = array(
442
+                         'text' => $workout_type,
443
+                         'url'  => $workout_type_url,
444
+                    );
445
+                    $new_crumbs[3] = array(
446
+                         'text' => $workout_name,
447
+                    );
448
+               }
449
+               $crumbs = $new_crumbs;
450
+
451
+          }
452
+          if ( is_post_type_archive( 'workout' ) ) {
453
+
454
+               $new_crumbs    = array();
455
+               $new_crumbs[0] = $crumbs[0];
456
+
457
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
458
+                    $new_crumbs[1] = array(
459
+                         0 => $workouts,
460
+                    );
461
+               } else {
462
+                    $new_crumbs[1] = array(
463
+                         'text' => $workouts,
464
+                    );
465
+               }
466
+               $crumbs = $new_crumbs;
467
+          }
468
+          return $crumbs;
469
+     }
470 470
 }
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -32,21 +32,21 @@  discard block
 block discarded – undo
32 32
 	 * Constructor
33 33
 	 */
34 34
 	public function __construct() {
35
-		add_action( 'init', array( $this, 'register_post_type' ) );
36
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
37
-		add_action( 'init', array( $this, 'workout_type_taxonomy_setup' ) );
38
-		add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
39
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
40
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
41
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
35
+		add_action('init', array($this, 'register_post_type'));
36
+		add_filter('lsx_health_plan_single_template', array($this, 'enable_post_type'), 10, 1);
37
+		add_action('init', array($this, 'workout_type_taxonomy_setup'));
38
+		add_filter('lsx_health_plan_connections', array($this, 'enable_connections'), 10, 1);
39
+		add_action('cmb2_admin_init', array($this, 'featured_metabox'), 5);
40
+		add_action('cmb2_admin_init', array($this, 'details_metaboxes'));
41
+		add_filter('get_the_archive_title', array($this, 'get_the_archive_title'), 100);
42 42
 
43 43
 		// Template Redirects.
44
-		add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
45
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
44
+		add_action('pre_get_posts', array($this, 'set_parent_only'), 10, 1);
45
+		add_filter('lsx_health_plan_archive_template', array($this, 'enable_post_type'), 10, 1);
46 46
 
47 47
 		//Breadcrumbs
48
-		add_filter( 'wpseo_breadcrumb_links', array( $this, 'workout_breadcrumb_filter' ), 30, 1 );
49
-		add_filter( 'woocommerce_get_breadcrumb', array( $this, 'workout_breadcrumb_filter' ), 30, 1 );
48
+		add_filter('wpseo_breadcrumb_links', array($this, 'workout_breadcrumb_filter'), 30, 1);
49
+		add_filter('woocommerce_get_breadcrumb', array($this, 'workout_breadcrumb_filter'), 30, 1);
50 50
 	}
51 51
 
52 52
 	/**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public static function get_instance() {
60 60
 		// If the single instance hasn't been set, set it now.
61
-		if ( null === self::$instance ) {
61
+		if (null === self::$instance) {
62 62
 			self::$instance = new self();
63 63
 		}
64 64
 		return self::$instance;
@@ -68,19 +68,19 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function register_post_type() {
70 70
 		$labels = array(
71
-			'name'               => esc_html__( 'Workouts', 'lsx-health-plan' ),
72
-			'singular_name'      => esc_html__( 'Workout', 'lsx-health-plan' ),
73
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
74
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
75
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
76
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
77
-			'all_items'          => esc_html__( 'All Workouts', 'lsx-health-plan' ),
78
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
79
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
80
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
81
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
82
-			'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
83
-			'menu_name'          => esc_html__( 'Workouts', 'lsx-health-plan' ),
71
+			'name'               => esc_html__('Workouts', 'lsx-health-plan'),
72
+			'singular_name'      => esc_html__('Workout', 'lsx-health-plan'),
73
+			'add_new'            => esc_html_x('Add New', 'post type general name', 'lsx-health-plan'),
74
+			'add_new_item'       => esc_html__('Add New', 'lsx-health-plan'),
75
+			'edit_item'          => esc_html__('Edit', 'lsx-health-plan'),
76
+			'new_item'           => esc_html__('New', 'lsx-health-plan'),
77
+			'all_items'          => esc_html__('All Workouts', 'lsx-health-plan'),
78
+			'view_item'          => esc_html__('View', 'lsx-health-plan'),
79
+			'search_items'       => esc_html__('Search', 'lsx-health-plan'),
80
+			'not_found'          => esc_html__('None found', 'lsx-health-plan'),
81
+			'not_found_in_trash' => esc_html__('None found in Trash', 'lsx-health-plan'),
82
+			'parent_item_colon'  => esc_html__('Parent:', 'lsx-health-plan'),
83
+			'menu_name'          => esc_html__('Workouts', 'lsx-health-plan'),
84 84
 		);
85 85
 		$args = array(
86 86
 			'labels'             => $labels,
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 			'menu_icon'          => 'dashicons-universal-access',
93 93
 			'query_var'          => true,
94 94
 			'rewrite'            => array(
95
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ),
95
+				'slug' => \lsx_health_plan\functions\get_option('endpoint_workout', 'workout'),
96 96
 			),
97 97
 			'capability_type'    => 'page',
98
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workouts' ),
98
+			'has_archive'        => \lsx_health_plan\functions\get_option('endpoint_workout_archive', 'workouts'),
99 99
 			'hierarchical'       => true,
100 100
 			'menu_position'      => null,
101 101
 			'supports'           => array(
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 				'custom-fields',
108 108
 			),
109 109
 		);
110
-		register_post_type( 'workout', $args );
110
+		register_post_type('workout', $args);
111 111
 	}
112 112
 
113 113
 	/**
@@ -115,17 +115,17 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 	public function workout_type_taxonomy_setup() {
117 117
 		$labels = array(
118
-			'name'              => esc_html_x( 'Workout Type', 'taxonomy general name', 'lsx-health-plan' ),
119
-			'singular_name'     => esc_html_x( 'Workout Type', 'taxonomy singular name', 'lsx-health-plan' ),
120
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
121
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
122
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
123
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
124
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
125
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
126
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
127
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
128
-			'menu_name'         => esc_html__( 'Workout Types', 'lsx-health-plan' ),
118
+			'name'              => esc_html_x('Workout Type', 'taxonomy general name', 'lsx-health-plan'),
119
+			'singular_name'     => esc_html_x('Workout Type', 'taxonomy singular name', 'lsx-health-plan'),
120
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
121
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
122
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
123
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
124
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
125
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
126
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
127
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
128
+			'menu_name'         => esc_html__('Workout Types', 'lsx-health-plan'),
129 129
 		);
130 130
 
131 131
 		$args = array(
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 			),
140 140
 		);
141 141
 
142
-		register_taxonomy( 'workout-type', array( 'workout' ), $args );
142
+		register_taxonomy('workout-type', array('workout'), $args);
143 143
 	}
144 144
 
145 145
 	/**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @param array $post_types
149 149
 	 * @return array
150 150
 	 */
151
-	public function enable_post_type( $post_types = array() ) {
151
+	public function enable_post_type($post_types = array()) {
152 152
 		$post_types[] = $this->slug;
153 153
 		return $post_types;
154 154
 	}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * @param array $connections
160 160
 	 * @return void
161 161
 	 */
162
-	public function enable_connections( $connections = array() ) {
162
+	public function enable_connections($connections = array()) {
163 163
 		$connections['workout']['connected_plans'] = 'connected_workouts';
164 164
 		$connections['plan']['connected_workouts'] = 'connected_plans';
165 165
 
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 	 * @param string $title the term title.
178 178
 	 * @return string
179 179
 	 */
180
-	public function get_the_archive_title( $title ) {
181
-		if ( is_post_type_archive( 'workout' ) ) {
182
-			$title = __( 'Workouts', 'lsx-health-plan' );
180
+	public function get_the_archive_title($title) {
181
+		if (is_post_type_archive('workout')) {
182
+			$title = __('Workouts', 'lsx-health-plan');
183 183
 		}
184 184
 		return $title;
185 185
 	}
@@ -191,8 +191,8 @@  discard block
 block discarded – undo
191 191
 		$cmb = new_cmb2_box(
192 192
 			array(
193 193
 				'id'           => $this->slug . '_featured_metabox_workout',
194
-				'title'        => __( 'Featured Workout', 'lsx-health-plan' ),
195
-				'object_types' => array( $this->slug ), // Post type
194
+				'title'        => __('Featured Workout', 'lsx-health-plan'),
195
+				'object_types' => array($this->slug), // Post type
196 196
 				'context'      => 'side',
197 197
 				'priority'     => 'high',
198 198
 				'show_names'   => true,
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 		);
201 201
 		$cmb->add_field(
202 202
 			array(
203
-				'name'       => __( 'Featured Workout', 'lsx-health-plan' ),
204
-				'desc'       => __( 'Enable a featured workout' ),
203
+				'name'       => __('Featured Workout', 'lsx-health-plan'),
204
+				'desc'       => __('Enable a featured workout'),
205 205
 				'id'         => $this->slug . '_featured_workout',
206 206
 				'type'       => 'checkbox',
207 207
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -214,43 +214,43 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	public function details_metaboxes() {
216 216
 
217
-		$cmb = new_cmb2_box( array(
217
+		$cmb = new_cmb2_box(array(
218 218
 			'id'           => $this->slug . '_details_metabox',
219
-			'title'        => __( 'Workout Details', 'lsx-health-plan' ),
220
-			'object_types' => array( $this->slug ), // Post type
219
+			'title'        => __('Workout Details', 'lsx-health-plan'),
220
+			'object_types' => array($this->slug), // Post type
221 221
 			'context'      => 'normal',
222 222
 			'priority'     => 'high',
223 223
 			'show_names'   => true,
224
-		) );
224
+		));
225 225
 
226
-		$cmb->add_field( array(
227
-			'name' => __( 'Workout Short Description', 'lsx-health-plan' ),
226
+		$cmb->add_field(array(
227
+			'name' => __('Workout Short Description', 'lsx-health-plan'),
228 228
 			'id'   => $this->slug . '_short_description',
229 229
 			'type' => 'textarea_small',
230
-			'desc' => __( 'Add a small description for this workout (optional)', 'lsx-health-plan' ),
231
-		) );
230
+			'desc' => __('Add a small description for this workout (optional)', 'lsx-health-plan'),
231
+		));
232 232
 
233
-		$workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 );
234
-		if ( false !== $workout_sections && null !== $workout_sections ) {
233
+		$workout_sections = apply_filters('lsx_health_plan_workout_sections_amount', 6);
234
+		if (false !== $workout_sections && null !== $workout_sections) {
235 235
 			$i = 1;
236
-			while ( $i <= $workout_sections ) {
236
+			while ($i <= $workout_sections) {
237 237
 
238
-				$cmb_group = new_cmb2_box( array(
238
+				$cmb_group = new_cmb2_box(array(
239 239
 					'id'           => $this->slug . '_section_' . $i . '_metabox',
240
-					'title'        => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i,
241
-					'object_types' => array( $this->slug ),
242
-				) );
240
+					'title'        => esc_html__('Exercise Group ', 'lsx-health-plan') . $i,
241
+					'object_types' => array($this->slug),
242
+				));
243 243
 
244
-				$cmb_group->add_field( array(
245
-					'name'       => __( 'Title', 'lsx-health-plan' ),
244
+				$cmb_group->add_field(array(
245
+					'name'       => __('Title', 'lsx-health-plan'),
246 246
 					'id'         => $this->slug . '_section_' . $i . '_title',
247 247
 					'type'       => 'text',
248 248
 					'show_on_cb' => 'cmb2_hide_if_no_cats',
249
-				) );
249
+				));
250 250
 
251 251
 				$cmb_group->add_field(
252 252
 					array(
253
-						'name'       => __( 'Description', 'lsx-health-plan' ),
253
+						'name'       => __('Description', 'lsx-health-plan'),
254 254
 						'id'         => $this->slug . '_section_' . $i . '_description',
255 255
 						'type'       => 'wysiwyg',
256 256
 						'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -269,28 +269,28 @@  discard block
 block discarded – undo
269 269
 						'id'      => $this->slug . '_section_' . $i,
270 270
 						'type'    => 'group',
271 271
 						'options' => array(
272
-							'group_title'   => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number
273
-							'add_button'    => esc_html__( 'Add New', 'lsx-health-plan' ),
274
-							'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ),
272
+							'group_title'   => esc_html__('Exercise {#}', 'lsx-health-plan'), // {#} gets replaced by row number
273
+							'add_button'    => esc_html__('Add New', 'lsx-health-plan'),
274
+							'remove_button' => esc_html__('Delete', 'lsx-health-plan'),
275 275
 							'sortable'      => true,
276 276
 							'closed'        => true, // true to have the groups closed by default
277 277
 						),
278 278
 					)
279 279
 				);
280 280
 
281
-				if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
281
+				if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) {
282 282
 					$cmb_group->add_group_field(
283 283
 						$group_field_id,
284 284
 						array(
285
-							'name'       => __( 'Exercise related to this workout', 'lsx-health-plan' ),
285
+							'name'       => __('Exercise related to this workout', 'lsx-health-plan'),
286 286
 							'id'         => 'connected_exercises',
287 287
 							'type'       => 'post_search_ajax',
288 288
 							// Optional :
289 289
 							'limit'      => 1, // Limit selection to X items only (default 1)
290
-							'sortable'   => true,  // Allow selected items to be sortable (default false)
290
+							'sortable'   => true, // Allow selected items to be sortable (default false)
291 291
 							'query_args' => array(
292
-								'post_type'      => array( 'exercise' ),
293
-								'post_status'    => array( 'publish' ),
292
+								'post_type'      => array('exercise'),
293
+								'post_status'    => array('publish'),
294 294
 								'posts_per_page' => -1,
295 295
 							),
296 296
 						)
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 					$cmb_group->add_group_field(
300 300
 						$group_field_id,
301 301
 						array(
302
-							'name'       => __( 'Video related to this workout', 'lsx-health-plan' ),
302
+							'name'       => __('Video related to this workout', 'lsx-health-plan'),
303 303
 							'id'         => 'connected_videos',
304 304
 							'type'       => 'post_search_ajax',
305 305
 							// Optional :
306 306
 							'limit'      => 1, // Limit selection to X items only (default 1)
307
-							'sortable'   => true,  // Allow selected items to be sortable (default false)
307
+							'sortable'   => true, // Allow selected items to be sortable (default false)
308 308
 							'query_args' => array(
309
-								'post_type'      => array( 'video' ),
310
-								'post_status'    => array( 'publish' ),
309
+								'post_type'      => array('video'),
310
+								'post_status'    => array('publish'),
311 311
 								'posts_per_page' => -1,
312 312
 							),
313 313
 						)
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 					$cmb_group->add_group_field(
316 316
 						$group_field_id,
317 317
 						array(
318
-							'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ),
318
+							'name' => esc_html__('Workout Name', 'lsx-health-plan'),
319 319
 							'id'   => 'name',
320 320
 							'type' => 'text',
321 321
 							// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 					$cmb_group->add_group_field(
326 326
 						$group_field_id,
327 327
 						array(
328
-							'name'    => __( 'Description', 'lsx-health-plan' ),
328
+							'name'    => __('Description', 'lsx-health-plan'),
329 329
 							'id'      => 'description',
330 330
 							'type'    => 'wysiwyg',
331 331
 							'options' => array(
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 				$cmb_group->add_group_field(
339 339
 					$group_field_id,
340 340
 					array(
341
-						'name' => esc_html__( 'Exercise title (Optional)', 'lsx-health-plan' ),
341
+						'name' => esc_html__('Exercise title (Optional)', 'lsx-health-plan'),
342 342
 						'id'   => 'alt_title',
343 343
 						'type' => 'text',
344 344
 					)
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 				$cmb_group->add_group_field(
347 347
 					$group_field_id,
348 348
 					array(
349
-						'name' => esc_html__( 'Exercise Description (Optional)', 'lsx-health-plan' ),
349
+						'name' => esc_html__('Exercise Description (Optional)', 'lsx-health-plan'),
350 350
 						'id'   => 'alt_description',
351 351
 						'type' => 'textarea_small',
352 352
 					)
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 				$cmb_group->add_group_field(
355 355
 					$group_field_id,
356 356
 					array(
357
-						'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ),
357
+						'name' => esc_html__('Reps / Time / Distance', 'lsx-health-plan'),
358 358
 						'id'   => 'reps',
359 359
 						'type' => 'text',
360 360
 						// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
@@ -363,13 +363,13 @@  discard block
 block discarded – undo
363 363
 				$cmb_group->add_group_field(
364 364
 					$group_field_id,
365 365
 					array(
366
-						'name'         => __( 'Exercise Image (Optional)', 'lsx-health-plan' ),
366
+						'name'         => __('Exercise Image (Optional)', 'lsx-health-plan'),
367 367
 						'id'           => 'exercise_alt_thumbnail',
368 368
 						'type'         => 'file',
369 369
 						'text'         => array(
370
-							'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
370
+							'add_upload_file_text' => __('Add File', 'lsx-health-plan'),
371 371
 						),
372
-						'desc'         => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ),
372
+						'desc'         => __('Upload an image 300px x 300px in size.', 'lsx-health-plan'),
373 373
 						'query_args'   => array(
374 374
 							'type' => array(
375 375
 								'image/gif',
@@ -392,9 +392,9 @@  discard block
 block discarded – undo
392 392
 	 * @param object $wp_query
393 393
 	 * @return array
394 394
 	 */
395
-	public function set_parent_only( $wp_query ) {
396
-		if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'workout' ) || $wp_query->is_tax( array( 'workout-type' ) ) ) ) {
397
-			$wp_query->set( 'post_parent', '0' );
395
+	public function set_parent_only($wp_query) {
396
+		if ( ! is_admin() && $wp_query->is_main_query() && ($wp_query->is_post_type_archive('workout') || $wp_query->is_tax(array('workout-type')))) {
397
+			$wp_query->set('post_parent', '0');
398 398
 		}
399 399
 	}
400 400
 
@@ -404,24 +404,24 @@  discard block
 block discarded – undo
404 404
 	 * @var array $crumbs
405 405
 	 * @return array
406 406
 	 */
407
-	public function workout_breadcrumb_filter( $crumbs ) {
408
-		$workout  = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
409
-		$workouts = \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workout' );
407
+	public function workout_breadcrumb_filter($crumbs) {
408
+		$workout  = \lsx_health_plan\functions\get_option('endpoint_workout', 'workout');
409
+		$workouts = \lsx_health_plan\functions\get_option('endpoint_workout_archive', 'workout');
410 410
 
411
-		if ( is_singular( 'workout' ) ) {	
411
+		if (is_singular('workout')) {	
412 412
 			$workout_name  = get_the_title();
413
-			$url           = get_post_type_archive_link( $workout );
414
-			$term_obj_list = get_the_terms( get_the_ID(), 'workout-type' );
413
+			$url           = get_post_type_archive_link($workout);
414
+			$term_obj_list = get_the_terms(get_the_ID(), 'workout-type');
415 415
 			$workout_type  = $term_obj_list[0]->name;
416
-			if ( empty( $workout_type ) ) {
417
-				$workout_type = __( 'Workout', 'lsx-health-plan' );
416
+			if (empty($workout_type)) {
417
+				$workout_type = __('Workout', 'lsx-health-plan');
418 418
 			}
419
-			$workout_type_url = get_term_link( $term_obj_list[0]->term_id );
419
+			$workout_type_url = get_term_link($term_obj_list[0]->term_id);
420 420
 
421 421
 			$new_crumbs    = array();
422 422
 			$new_crumbs[0] = $crumbs[0];
423 423
 
424
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
424
+			if (function_exists('woocommerce_breadcrumb')) {
425 425
 				$new_crumbs[1] = array(
426 426
 					0 => $workouts,
427 427
 					1 => $url,
@@ -449,12 +449,12 @@  discard block
 block discarded – undo
449 449
 			$crumbs = $new_crumbs;
450 450
 
451 451
 		}
452
-		if ( is_post_type_archive( 'workout' ) ) {
452
+		if (is_post_type_archive('workout')) {
453 453
 
454 454
 			$new_crumbs    = array();
455 455
 			$new_crumbs[0] = $crumbs[0];
456 456
 
457
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
457
+			if (function_exists('woocommerce_breadcrumb')) {
458 458
 				$new_crumbs[1] = array(
459 459
 					0 => $workouts,
460 460
 				);
Please login to merge, or discard this patch.
classes/post-types/class-recipe.php 2 patches
Indentation   +491 added lines, -491 removed lines patch added patch discarded remove patch
@@ -8,251 +8,251 @@  discard block
 block discarded – undo
8 8
  */
9 9
 class Recipe {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\Recipe()
17
-	 */
18
-	protected static $instance = null;
19
-
20
-	/**
21
-	 * Holds post_type slug used as an index
22
-	 *
23
-	 * @since 1.0.0
24
-	 *
25
-	 * @var      string
26
-	 */
27
-	public $slug = 'recipe';
28
-
29
-	/**
30
-	 * Holds post_type labels
31
-	 *
32
-	 * @since 1.0.0
33
-	 *
34
-	 * @var      string
35
-	 */
36
-	public $labels = array();
37
-
38
-	/**
39
-	 * Constructor
40
-	 */
41
-	public function __construct() {
42
-		add_action( 'init', array( $this, 'register_post_type' ) );
43
-		add_action( 'init', array( $this, 'taxonomy_setup' ) );
44
-		add_action( 'admin_menu', array( $this, 'register_menus' ) );
45
-
46
-		// Frontend Actions and Filters.
47
-		add_action( 'wp_head', array( $this, 'remove_archive_original_header' ), 99 );
48
-		add_action( 'lsx_content_wrap_before', array( $this, 'hp_lsx_archive_header' ) );
49
-
50
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
51
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
52
-		add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
53
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
54
-		add_filter( 'lsx_display_global_header_description', array( $this, 'disable_global_header_description' ), 100 );
55
-
56
-		//Breadcrumbs
57
-		add_filter( 'wpseo_breadcrumb_links', array( $this, 'recipes_breadcrumb_filter' ), 30, 1 );
58
-		add_filter( 'woocommerce_get_breadcrumb', array( $this, 'recipes_breadcrumb_filter' ), 30, 1 );
59
-
60
-		// Backend Actions and Filters.
61
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ) );
62
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
63
-	}
64
-
65
-	/**
66
-	 * Return an instance of this class.
67
-	 *
68
-	 * @since 1.0.0
69
-	 *
70
-	 * @return    object \lsx_health_plan\classes\Recipe()    A single instance of this class.
71
-	 */
72
-	public static function get_instance() {
73
-
74
-		// If the single instance hasn't been set, set it now.
75
-		if ( null === self::$instance ) {
76
-			self::$instance = new self();
77
-		}
78
-
79
-		return self::$instance;
80
-
81
-	}
82
-
83
-	/**
84
-	 * Register the post type.
85
-	 */
86
-	public function register_post_type() {
87
-		$this->labels = array(
88
-			'name'               => esc_html__( 'Recipes', 'lsx-health-plan' ),
89
-			'singular_name'      => esc_html__( 'Recipe', 'lsx-health-plan' ),
90
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
91
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
92
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
93
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
94
-			'all_items'          => esc_html__( 'All Recipes', 'lsx-health-plan' ),
95
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
96
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
97
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
98
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
99
-			'parent_item_colon'  => '',
100
-			'menu_name'          => esc_html__( 'Recipes', 'lsx-health-plan' ),
101
-		);
102
-		$args         = array(
103
-			'labels'             => $this->labels,
104
-			'public'             => true,
105
-			'publicly_queryable' => true,
106
-			'show_ui'            => true,
107
-			'show_in_menu'       => 'edit.php?post_type=meal-pseudo',
108
-			'show_in_rest'       => true,
109
-			'menu_icon'          => 'dashicons-editor-ul',
110
-			'query_var'          => true,
111
-			'rewrite'            => array(
112
-				'slug' => 'recipe',
113
-			),
114
-			'capability_type'    => 'post',
115
-			'has_archive'        => 'recipes',
116
-			'hierarchical'       => false,
117
-			'menu_position'      => null,
118
-			'supports'           => array(
119
-				'title',
120
-				'editor',
121
-				'thumbnail',
122
-				'custom-fields',
123
-			),
124
-		);
125
-		register_post_type( 'recipe', $args );
126
-	}
127
-
128
-	/**
129
-	 * Registers the Recipes under the Meals Post type menu.
130
-	 *
131
-	 * @return void
132
-	 */
133
-	public function register_menus() {
134
-		add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Recipes', 'lsx-health-plan' ), esc_html__( 'Recipes', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=recipe' );
135
-		add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Recipe Types', 'lsx-health-plan' ), esc_html__( 'Recipe Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=recipe-type&post_type=recipe' );
136
-		add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Cuisines', 'lsx-health-plan' ), esc_html__( 'Cuisines', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=recipe-cuisine&post_type=recipe' );
137
-	}
138
-
139
-	/**
140
-	 * Register the Cuisine taxonomy.
141
-	 */
142
-	public function taxonomy_setup() {
143
-		$labels = array(
144
-			'name'              => esc_html_x( 'Cuisine', 'taxonomy general name', 'lsx-health-plan' ),
145
-			'singular_name'     => esc_html_x( 'Cuisines', 'taxonomy singular name', 'lsx-health-plan' ),
146
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
147
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
148
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
149
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
150
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
151
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
152
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
153
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
154
-			'menu_name'         => esc_html__( 'Cuisines', 'lsx-health-plan' ),
155
-		);
156
-		$args   = array(
157
-			'hierarchical'      => true,
158
-			'labels'            => $labels,
159
-			'show_ui'           => true,
160
-			'show_admin_column' => true,
161
-			'show_in_menu'      => 'edit.php?post_type=meal',
162
-			'query_var'         => true,
163
-			'rewrite'           => array(
164
-				'slug' => 'recipe-cuisine',
165
-			),
166
-		);
167
-		register_taxonomy( 'recipe-cuisine', array( $this->slug ), $args );
168
-
169
-		$labels = array(
170
-			'name'              => esc_html_x( 'Recipe Type', 'taxonomy general name', 'lsx-health-plan' ),
171
-			'singular_name'     => esc_html_x( 'Recipe Types', 'taxonomy singular name', 'lsx-health-plan' ),
172
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
173
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
174
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
175
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
176
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
177
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
178
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
179
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
180
-			'menu_name'         => esc_html__( 'Types', 'lsx-health-plan' ),
181
-		);
182
-		$args   = array(
183
-			'hierarchical'      => true,
184
-			'labels'            => $labels,
185
-			'show_ui'           => true,
186
-			'show_in_menu'      => 'edit.php?post_type=meal',
187
-			'show_admin_column' => true,
188
-			'query_var'         => true,
189
-			'rewrite'           => array(
190
-				'slug' => 'recipe-type',
191
-			),
192
-		);
193
-		register_taxonomy( 'recipe-type', array( $this->slug ), $args );
194
-	}
195
-
196
-	/**
197
-	 * Adds the post type to the different arrays.
198
-	 *
199
-	 * @param array $post_types
200
-	 * @return array
201
-	 */
202
-	public function enable_post_type( $post_types = array() ) {
203
-		$post_types[] = $this->slug;
204
-		return $post_types;
205
-	}
206
-
207
-	/**
208
-	 * Enables the Bi Directional relationships
209
-	 *
210
-	 * @param array $connections
211
-	 * @return void
212
-	 */
213
-	public function enable_connections( $connections = array() ) {
214
-		$connections['recipe']['connected_plans'] = 'connected_recipes';
215
-		$connections['plan']['connected_recipes'] = 'connected_plans';
216
-		return $connections;
217
-	}
218
-
219
-	/**
220
-	 * Remove the "Archives:" from the post type recipes.
221
-	 *
222
-	 * @param string $title the term title.
223
-	 * @return string
224
-	 */
225
-	public function get_the_archive_title( $title ) {
226
-		if ( is_post_type_archive( 'recipe' ) ) {
227
-			$title = __( 'Recipes', 'lsx-health-plan' );
228
-		}
229
-		if ( is_post_type_archive( 'exercise' ) ) {
230
-			$title = __( 'Exercises', 'lsx-health-plan' );
231
-		}
232
-		if ( is_tax( 'recipe-type' ) ) {
233
-			$queried_object = get_queried_object();
234
-			if ( isset( $queried_object->name ) ) {
235
-				$title = $queried_object->name . ' ' . __( 'Recipes', 'lsx-health-plan' );
236
-			}
237
-		}
238
-		return $title;
239
-	}
240
-
241
-	public function remove_archive_original_header() {
242
-		if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) {
243
-			remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
244
-		}
245
-		if ( is_singular( 'recipe' ) || is_singular( 'exercise' ) ) {
246
-			remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
247
-		}
248
-		if ( ! is_post_type_archive() ) {
249
-			add_action( 'lsx_content_wrap_before', 'lsx_health_plan_recipe_archive_description', 11 );
250
-		}
251
-	}
252
-
253
-	public function hp_lsx_archive_header() {
254
-		if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) {
255
-		?>
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @since 1.0.0
15
+      *
16
+      * @var      object \lsx_health_plan\classes\Recipe()
17
+      */
18
+     protected static $instance = null;
19
+
20
+     /**
21
+      * Holds post_type slug used as an index
22
+      *
23
+      * @since 1.0.0
24
+      *
25
+      * @var      string
26
+      */
27
+     public $slug = 'recipe';
28
+
29
+     /**
30
+      * Holds post_type labels
31
+      *
32
+      * @since 1.0.0
33
+      *
34
+      * @var      string
35
+      */
36
+     public $labels = array();
37
+
38
+     /**
39
+      * Constructor
40
+      */
41
+     public function __construct() {
42
+          add_action( 'init', array( $this, 'register_post_type' ) );
43
+          add_action( 'init', array( $this, 'taxonomy_setup' ) );
44
+          add_action( 'admin_menu', array( $this, 'register_menus' ) );
45
+
46
+          // Frontend Actions and Filters.
47
+          add_action( 'wp_head', array( $this, 'remove_archive_original_header' ), 99 );
48
+          add_action( 'lsx_content_wrap_before', array( $this, 'hp_lsx_archive_header' ) );
49
+
50
+          add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
51
+          add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
52
+          add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
53
+          add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
54
+          add_filter( 'lsx_display_global_header_description', array( $this, 'disable_global_header_description' ), 100 );
55
+
56
+          //Breadcrumbs
57
+          add_filter( 'wpseo_breadcrumb_links', array( $this, 'recipes_breadcrumb_filter' ), 30, 1 );
58
+          add_filter( 'woocommerce_get_breadcrumb', array( $this, 'recipes_breadcrumb_filter' ), 30, 1 );
59
+
60
+          // Backend Actions and Filters.
61
+          add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ) );
62
+          add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
63
+     }
64
+
65
+     /**
66
+      * Return an instance of this class.
67
+      *
68
+      * @since 1.0.0
69
+      *
70
+      * @return    object \lsx_health_plan\classes\Recipe()    A single instance of this class.
71
+      */
72
+     public static function get_instance() {
73
+
74
+          // If the single instance hasn't been set, set it now.
75
+          if ( null === self::$instance ) {
76
+               self::$instance = new self();
77
+          }
78
+
79
+          return self::$instance;
80
+
81
+     }
82
+
83
+     /**
84
+      * Register the post type.
85
+      */
86
+     public function register_post_type() {
87
+          $this->labels = array(
88
+               'name'               => esc_html__( 'Recipes', 'lsx-health-plan' ),
89
+               'singular_name'      => esc_html__( 'Recipe', 'lsx-health-plan' ),
90
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
91
+               'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
92
+               'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
93
+               'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
94
+               'all_items'          => esc_html__( 'All Recipes', 'lsx-health-plan' ),
95
+               'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
96
+               'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
97
+               'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
98
+               'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
99
+               'parent_item_colon'  => '',
100
+               'menu_name'          => esc_html__( 'Recipes', 'lsx-health-plan' ),
101
+          );
102
+          $args         = array(
103
+               'labels'             => $this->labels,
104
+               'public'             => true,
105
+               'publicly_queryable' => true,
106
+               'show_ui'            => true,
107
+               'show_in_menu'       => 'edit.php?post_type=meal-pseudo',
108
+               'show_in_rest'       => true,
109
+               'menu_icon'          => 'dashicons-editor-ul',
110
+               'query_var'          => true,
111
+               'rewrite'            => array(
112
+                    'slug' => 'recipe',
113
+               ),
114
+               'capability_type'    => 'post',
115
+               'has_archive'        => 'recipes',
116
+               'hierarchical'       => false,
117
+               'menu_position'      => null,
118
+               'supports'           => array(
119
+                    'title',
120
+                    'editor',
121
+                    'thumbnail',
122
+                    'custom-fields',
123
+               ),
124
+          );
125
+          register_post_type( 'recipe', $args );
126
+     }
127
+
128
+     /**
129
+      * Registers the Recipes under the Meals Post type menu.
130
+      *
131
+      * @return void
132
+      */
133
+     public function register_menus() {
134
+          add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Recipes', 'lsx-health-plan' ), esc_html__( 'Recipes', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=recipe' );
135
+          add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Recipe Types', 'lsx-health-plan' ), esc_html__( 'Recipe Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=recipe-type&post_type=recipe' );
136
+          add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Cuisines', 'lsx-health-plan' ), esc_html__( 'Cuisines', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=recipe-cuisine&post_type=recipe' );
137
+     }
138
+
139
+     /**
140
+      * Register the Cuisine taxonomy.
141
+      */
142
+     public function taxonomy_setup() {
143
+          $labels = array(
144
+               'name'              => esc_html_x( 'Cuisine', 'taxonomy general name', 'lsx-health-plan' ),
145
+               'singular_name'     => esc_html_x( 'Cuisines', 'taxonomy singular name', 'lsx-health-plan' ),
146
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
147
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
148
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
149
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
150
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
151
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
152
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
153
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
154
+               'menu_name'         => esc_html__( 'Cuisines', 'lsx-health-plan' ),
155
+          );
156
+          $args   = array(
157
+               'hierarchical'      => true,
158
+               'labels'            => $labels,
159
+               'show_ui'           => true,
160
+               'show_admin_column' => true,
161
+               'show_in_menu'      => 'edit.php?post_type=meal',
162
+               'query_var'         => true,
163
+               'rewrite'           => array(
164
+                    'slug' => 'recipe-cuisine',
165
+               ),
166
+          );
167
+          register_taxonomy( 'recipe-cuisine', array( $this->slug ), $args );
168
+
169
+          $labels = array(
170
+               'name'              => esc_html_x( 'Recipe Type', 'taxonomy general name', 'lsx-health-plan' ),
171
+               'singular_name'     => esc_html_x( 'Recipe Types', 'taxonomy singular name', 'lsx-health-plan' ),
172
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
173
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
174
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
175
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
176
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
177
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
178
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
179
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
180
+               'menu_name'         => esc_html__( 'Types', 'lsx-health-plan' ),
181
+          );
182
+          $args   = array(
183
+               'hierarchical'      => true,
184
+               'labels'            => $labels,
185
+               'show_ui'           => true,
186
+               'show_in_menu'      => 'edit.php?post_type=meal',
187
+               'show_admin_column' => true,
188
+               'query_var'         => true,
189
+               'rewrite'           => array(
190
+                    'slug' => 'recipe-type',
191
+               ),
192
+          );
193
+          register_taxonomy( 'recipe-type', array( $this->slug ), $args );
194
+     }
195
+
196
+     /**
197
+      * Adds the post type to the different arrays.
198
+      *
199
+      * @param array $post_types
200
+      * @return array
201
+      */
202
+     public function enable_post_type( $post_types = array() ) {
203
+          $post_types[] = $this->slug;
204
+          return $post_types;
205
+     }
206
+
207
+     /**
208
+      * Enables the Bi Directional relationships
209
+      *
210
+      * @param array $connections
211
+      * @return void
212
+      */
213
+     public function enable_connections( $connections = array() ) {
214
+          $connections['recipe']['connected_plans'] = 'connected_recipes';
215
+          $connections['plan']['connected_recipes'] = 'connected_plans';
216
+          return $connections;
217
+     }
218
+
219
+     /**
220
+      * Remove the "Archives:" from the post type recipes.
221
+      *
222
+      * @param string $title the term title.
223
+      * @return string
224
+      */
225
+     public function get_the_archive_title( $title ) {
226
+          if ( is_post_type_archive( 'recipe' ) ) {
227
+               $title = __( 'Recipes', 'lsx-health-plan' );
228
+          }
229
+          if ( is_post_type_archive( 'exercise' ) ) {
230
+               $title = __( 'Exercises', 'lsx-health-plan' );
231
+          }
232
+          if ( is_tax( 'recipe-type' ) ) {
233
+               $queried_object = get_queried_object();
234
+               if ( isset( $queried_object->name ) ) {
235
+                    $title = $queried_object->name . ' ' . __( 'Recipes', 'lsx-health-plan' );
236
+               }
237
+          }
238
+          return $title;
239
+     }
240
+
241
+     public function remove_archive_original_header() {
242
+          if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) {
243
+               remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
244
+          }
245
+          if ( is_singular( 'recipe' ) || is_singular( 'exercise' ) ) {
246
+               remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
247
+          }
248
+          if ( ! is_post_type_archive() ) {
249
+               add_action( 'lsx_content_wrap_before', 'lsx_health_plan_recipe_archive_description', 11 );
250
+          }
251
+     }
252
+
253
+     public function hp_lsx_archive_header() {
254
+          if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) {
255
+          ?>
256 256
 			<div class="archive-header-wrapper banner-archive">
257 257
 				<?php lsx_global_header_inner_bottom(); ?>
258 258
 				<header class="archive-header">
@@ -265,253 +265,253 @@  discard block
 block discarded – undo
265 265
 					</h1>
266 266
 
267 267
 					<?php
268
-					lsx_health_plan_recipe_archive_description();
269
-					?>
268
+                         lsx_health_plan_recipe_archive_description();
269
+                         ?>
270 270
 				</header>
271 271
 			</div>
272 272
 		<?php
273
-		}
274
-	}
275
-
276
-	/**
277
-	 * Disables the global header description
278
-	 *
279
-	 * @param boolean $disable
280
-	 * @return boolean
281
-	 */
282
-	public function disable_global_header_description( $disable ) {
283
-		if ( is_tax( 'recipe-type' ) ) {
284
-			$disable = true;
285
-		}
286
-		return $disable;
287
-	}
288
-
289
-	/**
290
-	 * Holds the array for the breadcrumbs.
291
-	 *
292
-	 * @var array $crumbs
293
-	 * @return array
294
-	 */
295
-	public function recipes_breadcrumb_filter( $crumbs ) {
296
-		$recipe  = \lsx_health_plan\functions\get_option( 'endpoint_recipe', 'recipe' );
297
-		$recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe_archive', 'recipes' );
298
-		$url     = get_post_type_archive_link( 'recipe' );
299
-
300
-		if ( is_singular( 'recipe' ) ) {
301
-			$recipe_name     = get_the_title();
302
-			$term_obj_list   = get_the_terms( get_the_ID(), 'recipe-type' );
303
-			$recipe_type     = $term_obj_list[0]->name;
304
-			$recipe_type_url = get_term_link( $term_obj_list[0]->term_id );
305
-
306
-			$new_crumbs    = array();
307
-			$new_crumbs[0] = $crumbs[0];
308
-
309
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
310
-				$new_crumbs[1] = array(
311
-					0 => $recipes,
312
-					1 => $url,
313
-				);
314
-				$new_crumbs[2] = array(
315
-					0 => $recipe_type,
316
-					1 => $recipe_type_url,
317
-				);
318
-				$new_crumbs[3] = array(
319
-					0 => $recipe_name,
320
-				);
321
-			} else {
322
-				$new_crumbs[1] = array(
323
-					'text' => $recipes,
324
-					'url'  => $url,
325
-				);
326
-				$new_crumbs[2] = array(
327
-					'text' => $recipe_type,
328
-					'url'  => $recipe_type_url,
329
-				);
330
-				$new_crumbs[3] = array(
331
-					'text' => $recipe_name,
332
-				);
333
-			}
334
-			$crumbs = $new_crumbs;
335
-		}
336
-		if ( is_tax( 'recipe-type' ) || is_tax( 'recipe-cuisine' ) ) {
337
-			$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
338
-
339
-			$single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name;
340
-
341
-			$new_crumbs    = array();
342
-			$new_crumbs[0] = $crumbs[0];
343
-
344
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
345
-				$new_crumbs[1] = array(
346
-					0 => $recipes,
347
-					1 => $url,
348
-				);
349
-				$new_crumbs[2] = array(
350
-					0 => $single_term_title,
351
-				);
352
-			} else {
353
-				$new_crumbs[1] = array(
354
-					'text' => $recipes,
355
-					'url'  => $url,
356
-				);
357
-				$new_crumbs[2] = array(
358
-					'text' => $single_term_title,
359
-				);
360
-			}
361
-			$crumbs = $new_crumbs;
362
-		}
363
-		if ( is_post_type_archive( 'recipe' ) ) {
364
-
365
-			$new_crumbs    = array();
366
-			$new_crumbs[0] = $crumbs[0];
367
-
368
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
369
-				$new_crumbs[1] = array(
370
-					0 => $recipes,
371
-				);
372
-			} else {
373
-				$new_crumbs[1] = array(
374
-					'text' => $recipes,
375
-				);
376
-			}
377
-			$crumbs = $new_crumbs;
378
-		}
379
-		return $crumbs;
380
-	}
381
-
382
-	/**
383
-	 * Define the metabox and field configurations.
384
-	 */
385
-	public function featured_metabox() {
386
-		$cmb = new_cmb2_box(
387
-			array(
388
-				'id'           => $this->slug . '_featured_metabox',
389
-				'title'        => __( 'Featured', 'lsx-health-plan' ),
390
-				'object_types' => array( $this->slug ),
391
-				'context'      => 'side',
392
-				'priority'     => 'high',
393
-				'show_names'   => true,
394
-			)
395
-		);
396
-		$cmb->add_field(
397
-			array(
398
-				'name'       => __( 'Featured', 'lsx-health-plan' ),
399
-				'desc'       => __( 'Enable the checkbox to feature this recipe, featured recipes display in any page that has the recipe shortcode: [lsx_health_plan_featured_recipes_block]', 'lsx-health-plan' ),
400
-				'id'         => $this->slug . '_featured',
401
-				'type'       => 'checkbox',
402
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
403
-			)
404
-		);
405
-	}
406
-
407
-	/**
408
-	 * Define the metabox and field configurations.
409
-	 */
410
-	public function details_metaboxes() {
411
-		$cmb = new_cmb2_box(
412
-			array(
413
-				'id'           => $this->slug . '_details_metabox',
414
-				'title'        => __( 'Cooking Info', 'lsx-health-plan' ),
415
-				'object_types' => array( $this->slug ), // Post type
416
-				'context'      => 'normal',
417
-				'priority'     => 'high',
418
-				'show_names'   => true,
419
-			)
420
-		);
421
-		$cmb->add_field(
422
-			array(
423
-				'name'       => __( 'Prep Time', 'lsx-health-plan' ),
424
-				'id'         => $this->slug . '_prep_time',
425
-				'desc'       => __( 'Add the preparation time for the entire meal i.e: 25 mins', 'lsx-health-plan' ),
426
-				'type'       => 'text',
427
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
428
-			)
429
-		);
430
-		$cmb->add_field(
431
-			array(
432
-				'name'       => __( 'Cooking Time', 'lsx-health-plan' ),
433
-				'id'         => $this->slug . '_cooking_time',
434
-				'desc'       => __( 'Add the cooking time i.e: 15 mins', 'lsx-health-plan' ),
435
-				'type'       => 'text',
436
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
437
-			)
438
-		);
439
-		$cmb->add_field(
440
-			array(
441
-				'name'       => __( 'Serves', 'lsx-health-plan' ),
442
-				'id'         => $this->slug . '_serves',
443
-				'desc'       => __( 'Add the recommended serving size i.e: 6', 'lsx-health-plan' ),
444
-				'type'       => 'text',
445
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
446
-				'attributes' => array(
447
-					'type'    => 'number',
448
-					'pattern' => '\d*',
449
-				),
450
-			)
451
-		);
452
-		$cmb->add_field(
453
-			array(
454
-				'name'       => __( 'Portion', 'lsx-health-plan' ),
455
-				'desc'       => __( 'Add the recommended portion size i.e: 200mg', 'lsx-health-plan' ),
456
-				'id'         => $this->slug . '_portion',
457
-				'type'       => 'text',
458
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
459
-			)
460
-		);
461
-		$cmb = new_cmb2_box(
462
-			array(
463
-				'id'           => $this->slug . '_nutritional_metabox',
464
-				'title'        => __( 'Nutritional Info', 'lsx-health-plan' ),
465
-				'object_types' => array( $this->slug ), // Post type
466
-				'context'      => 'normal',
467
-				'priority'     => 'high',
468
-				'show_names'   => true,
469
-			)
470
-		);
471
-		$cmb->add_field(
472
-			array(
473
-				'name'       => __( 'Energy', 'lsx-health-plan' ),
474
-				'id'         => $this->slug . '_energy',
475
-				'desc'       => __( 'Add the energy amount for the entire meal i.e: 700 kj', 'lsx-health-plan' ),
476
-				'type'       => 'text',
477
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
478
-			)
479
-		);
480
-		$cmb->add_field(
481
-			array(
482
-				'name'       => __( 'Protein', 'lsx-health-plan' ),
483
-				'id'         => $this->slug . '_protein',
484
-				'desc'       => __( 'Add the protein amount for the entire meal i.e: 50 g', 'lsx-health-plan' ),
485
-				'type'       => 'text',
486
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
487
-			)
488
-		);
489
-		$cmb->add_field(
490
-			array(
491
-				'name'       => __( 'Carbohydrates', 'lsx-health-plan' ),
492
-				'id'         => $this->slug . '_carbohydrates',
493
-				'desc'       => __( 'Add the carbohydrates amount for the entire meal i.e: 5 g', 'lsx-health-plan' ),
494
-				'type'       => 'text',
495
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
496
-			)
497
-		);
498
-		$cmb->add_field(
499
-			array(
500
-				'name'       => __( 'Fibre', 'lsx-health-plan' ),
501
-				'id'         => $this->slug . '_fibre',
502
-				'desc'       => __( 'Add the fibre amount for the entire meal i.e: 5 g', 'lsx-health-plan' ),
503
-				'type'       => 'text',
504
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
505
-			)
506
-		);
507
-		$cmb->add_field(
508
-			array(
509
-				'name'       => __( 'Fat', 'lsx-health-plan' ),
510
-				'id'         => $this->slug . '_fat',
511
-				'desc'       => __( 'Add the fat amount for the entire meal i.e: 20 g', 'lsx-health-plan' ),
512
-				'type'       => 'text',
513
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
514
-			)
515
-		);
516
-	}
273
+          }
274
+     }
275
+
276
+     /**
277
+      * Disables the global header description
278
+      *
279
+      * @param boolean $disable
280
+      * @return boolean
281
+      */
282
+     public function disable_global_header_description( $disable ) {
283
+          if ( is_tax( 'recipe-type' ) ) {
284
+               $disable = true;
285
+          }
286
+          return $disable;
287
+     }
288
+
289
+     /**
290
+      * Holds the array for the breadcrumbs.
291
+      *
292
+      * @var array $crumbs
293
+      * @return array
294
+      */
295
+     public function recipes_breadcrumb_filter( $crumbs ) {
296
+          $recipe  = \lsx_health_plan\functions\get_option( 'endpoint_recipe', 'recipe' );
297
+          $recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe_archive', 'recipes' );
298
+          $url     = get_post_type_archive_link( 'recipe' );
299
+
300
+          if ( is_singular( 'recipe' ) ) {
301
+               $recipe_name     = get_the_title();
302
+               $term_obj_list   = get_the_terms( get_the_ID(), 'recipe-type' );
303
+               $recipe_type     = $term_obj_list[0]->name;
304
+               $recipe_type_url = get_term_link( $term_obj_list[0]->term_id );
305
+
306
+               $new_crumbs    = array();
307
+               $new_crumbs[0] = $crumbs[0];
308
+
309
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
310
+                    $new_crumbs[1] = array(
311
+                         0 => $recipes,
312
+                         1 => $url,
313
+                    );
314
+                    $new_crumbs[2] = array(
315
+                         0 => $recipe_type,
316
+                         1 => $recipe_type_url,
317
+                    );
318
+                    $new_crumbs[3] = array(
319
+                         0 => $recipe_name,
320
+                    );
321
+               } else {
322
+                    $new_crumbs[1] = array(
323
+                         'text' => $recipes,
324
+                         'url'  => $url,
325
+                    );
326
+                    $new_crumbs[2] = array(
327
+                         'text' => $recipe_type,
328
+                         'url'  => $recipe_type_url,
329
+                    );
330
+                    $new_crumbs[3] = array(
331
+                         'text' => $recipe_name,
332
+                    );
333
+               }
334
+               $crumbs = $new_crumbs;
335
+          }
336
+          if ( is_tax( 'recipe-type' ) || is_tax( 'recipe-cuisine' ) ) {
337
+               $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
338
+
339
+               $single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name;
340
+
341
+               $new_crumbs    = array();
342
+               $new_crumbs[0] = $crumbs[0];
343
+
344
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
345
+                    $new_crumbs[1] = array(
346
+                         0 => $recipes,
347
+                         1 => $url,
348
+                    );
349
+                    $new_crumbs[2] = array(
350
+                         0 => $single_term_title,
351
+                    );
352
+               } else {
353
+                    $new_crumbs[1] = array(
354
+                         'text' => $recipes,
355
+                         'url'  => $url,
356
+                    );
357
+                    $new_crumbs[2] = array(
358
+                         'text' => $single_term_title,
359
+                    );
360
+               }
361
+               $crumbs = $new_crumbs;
362
+          }
363
+          if ( is_post_type_archive( 'recipe' ) ) {
364
+
365
+               $new_crumbs    = array();
366
+               $new_crumbs[0] = $crumbs[0];
367
+
368
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
369
+                    $new_crumbs[1] = array(
370
+                         0 => $recipes,
371
+                    );
372
+               } else {
373
+                    $new_crumbs[1] = array(
374
+                         'text' => $recipes,
375
+                    );
376
+               }
377
+               $crumbs = $new_crumbs;
378
+          }
379
+          return $crumbs;
380
+     }
381
+
382
+     /**
383
+      * Define the metabox and field configurations.
384
+      */
385
+     public function featured_metabox() {
386
+          $cmb = new_cmb2_box(
387
+               array(
388
+                    'id'           => $this->slug . '_featured_metabox',
389
+                    'title'        => __( 'Featured', 'lsx-health-plan' ),
390
+                    'object_types' => array( $this->slug ),
391
+                    'context'      => 'side',
392
+                    'priority'     => 'high',
393
+                    'show_names'   => true,
394
+               )
395
+          );
396
+          $cmb->add_field(
397
+               array(
398
+                    'name'       => __( 'Featured', 'lsx-health-plan' ),
399
+                    'desc'       => __( 'Enable the checkbox to feature this recipe, featured recipes display in any page that has the recipe shortcode: [lsx_health_plan_featured_recipes_block]', 'lsx-health-plan' ),
400
+                    'id'         => $this->slug . '_featured',
401
+                    'type'       => 'checkbox',
402
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
403
+               )
404
+          );
405
+     }
406
+
407
+     /**
408
+      * Define the metabox and field configurations.
409
+      */
410
+     public function details_metaboxes() {
411
+          $cmb = new_cmb2_box(
412
+               array(
413
+                    'id'           => $this->slug . '_details_metabox',
414
+                    'title'        => __( 'Cooking Info', 'lsx-health-plan' ),
415
+                    'object_types' => array( $this->slug ), // Post type
416
+                    'context'      => 'normal',
417
+                    'priority'     => 'high',
418
+                    'show_names'   => true,
419
+               )
420
+          );
421
+          $cmb->add_field(
422
+               array(
423
+                    'name'       => __( 'Prep Time', 'lsx-health-plan' ),
424
+                    'id'         => $this->slug . '_prep_time',
425
+                    'desc'       => __( 'Add the preparation time for the entire meal i.e: 25 mins', 'lsx-health-plan' ),
426
+                    'type'       => 'text',
427
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
428
+               )
429
+          );
430
+          $cmb->add_field(
431
+               array(
432
+                    'name'       => __( 'Cooking Time', 'lsx-health-plan' ),
433
+                    'id'         => $this->slug . '_cooking_time',
434
+                    'desc'       => __( 'Add the cooking time i.e: 15 mins', 'lsx-health-plan' ),
435
+                    'type'       => 'text',
436
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
437
+               )
438
+          );
439
+          $cmb->add_field(
440
+               array(
441
+                    'name'       => __( 'Serves', 'lsx-health-plan' ),
442
+                    'id'         => $this->slug . '_serves',
443
+                    'desc'       => __( 'Add the recommended serving size i.e: 6', 'lsx-health-plan' ),
444
+                    'type'       => 'text',
445
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
446
+                    'attributes' => array(
447
+                         'type'    => 'number',
448
+                         'pattern' => '\d*',
449
+                    ),
450
+               )
451
+          );
452
+          $cmb->add_field(
453
+               array(
454
+                    'name'       => __( 'Portion', 'lsx-health-plan' ),
455
+                    'desc'       => __( 'Add the recommended portion size i.e: 200mg', 'lsx-health-plan' ),
456
+                    'id'         => $this->slug . '_portion',
457
+                    'type'       => 'text',
458
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
459
+               )
460
+          );
461
+          $cmb = new_cmb2_box(
462
+               array(
463
+                    'id'           => $this->slug . '_nutritional_metabox',
464
+                    'title'        => __( 'Nutritional Info', 'lsx-health-plan' ),
465
+                    'object_types' => array( $this->slug ), // Post type
466
+                    'context'      => 'normal',
467
+                    'priority'     => 'high',
468
+                    'show_names'   => true,
469
+               )
470
+          );
471
+          $cmb->add_field(
472
+               array(
473
+                    'name'       => __( 'Energy', 'lsx-health-plan' ),
474
+                    'id'         => $this->slug . '_energy',
475
+                    'desc'       => __( 'Add the energy amount for the entire meal i.e: 700 kj', 'lsx-health-plan' ),
476
+                    'type'       => 'text',
477
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
478
+               )
479
+          );
480
+          $cmb->add_field(
481
+               array(
482
+                    'name'       => __( 'Protein', 'lsx-health-plan' ),
483
+                    'id'         => $this->slug . '_protein',
484
+                    'desc'       => __( 'Add the protein amount for the entire meal i.e: 50 g', 'lsx-health-plan' ),
485
+                    'type'       => 'text',
486
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
487
+               )
488
+          );
489
+          $cmb->add_field(
490
+               array(
491
+                    'name'       => __( 'Carbohydrates', 'lsx-health-plan' ),
492
+                    'id'         => $this->slug . '_carbohydrates',
493
+                    'desc'       => __( 'Add the carbohydrates amount for the entire meal i.e: 5 g', 'lsx-health-plan' ),
494
+                    'type'       => 'text',
495
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
496
+               )
497
+          );
498
+          $cmb->add_field(
499
+               array(
500
+                    'name'       => __( 'Fibre', 'lsx-health-plan' ),
501
+                    'id'         => $this->slug . '_fibre',
502
+                    'desc'       => __( 'Add the fibre amount for the entire meal i.e: 5 g', 'lsx-health-plan' ),
503
+                    'type'       => 'text',
504
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
505
+               )
506
+          );
507
+          $cmb->add_field(
508
+               array(
509
+                    'name'       => __( 'Fat', 'lsx-health-plan' ),
510
+                    'id'         => $this->slug . '_fat',
511
+                    'desc'       => __( 'Add the fat amount for the entire meal i.e: 20 g', 'lsx-health-plan' ),
512
+                    'type'       => 'text',
513
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
514
+               )
515
+          );
516
+     }
517 517
 }
Please login to merge, or discard this patch.
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -39,27 +39,27 @@  discard block
 block discarded – undo
39 39
 	 * Constructor
40 40
 	 */
41 41
 	public function __construct() {
42
-		add_action( 'init', array( $this, 'register_post_type' ) );
43
-		add_action( 'init', array( $this, 'taxonomy_setup' ) );
44
-		add_action( 'admin_menu', array( $this, 'register_menus' ) );
42
+		add_action('init', array($this, 'register_post_type'));
43
+		add_action('init', array($this, 'taxonomy_setup'));
44
+		add_action('admin_menu', array($this, 'register_menus'));
45 45
 
46 46
 		// Frontend Actions and Filters.
47
-		add_action( 'wp_head', array( $this, 'remove_archive_original_header' ), 99 );
48
-		add_action( 'lsx_content_wrap_before', array( $this, 'hp_lsx_archive_header' ) );
47
+		add_action('wp_head', array($this, 'remove_archive_original_header'), 99);
48
+		add_action('lsx_content_wrap_before', array($this, 'hp_lsx_archive_header'));
49 49
 
50
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
51
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
52
-		add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
53
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
54
-		add_filter( 'lsx_display_global_header_description', array( $this, 'disable_global_header_description' ), 100 );
50
+		add_filter('lsx_health_plan_archive_template', array($this, 'enable_post_type'), 10, 1);
51
+		add_filter('lsx_health_plan_single_template', array($this, 'enable_post_type'), 10, 1);
52
+		add_filter('lsx_health_plan_connections', array($this, 'enable_connections'), 10, 1);
53
+		add_filter('get_the_archive_title', array($this, 'get_the_archive_title'), 100);
54
+		add_filter('lsx_display_global_header_description', array($this, 'disable_global_header_description'), 100);
55 55
 
56 56
 		//Breadcrumbs
57
-		add_filter( 'wpseo_breadcrumb_links', array( $this, 'recipes_breadcrumb_filter' ), 30, 1 );
58
-		add_filter( 'woocommerce_get_breadcrumb', array( $this, 'recipes_breadcrumb_filter' ), 30, 1 );
57
+		add_filter('wpseo_breadcrumb_links', array($this, 'recipes_breadcrumb_filter'), 30, 1);
58
+		add_filter('woocommerce_get_breadcrumb', array($this, 'recipes_breadcrumb_filter'), 30, 1);
59 59
 
60 60
 		// Backend Actions and Filters.
61
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ) );
62
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
61
+		add_action('cmb2_admin_init', array($this, 'featured_metabox'));
62
+		add_action('cmb2_admin_init', array($this, 'details_metaboxes'));
63 63
 	}
64 64
 
65 65
 	/**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	public static function get_instance() {
73 73
 
74 74
 		// If the single instance hasn't been set, set it now.
75
-		if ( null === self::$instance ) {
75
+		if (null === self::$instance) {
76 76
 			self::$instance = new self();
77 77
 		}
78 78
 
@@ -85,21 +85,21 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public function register_post_type() {
87 87
 		$this->labels = array(
88
-			'name'               => esc_html__( 'Recipes', 'lsx-health-plan' ),
89
-			'singular_name'      => esc_html__( 'Recipe', 'lsx-health-plan' ),
90
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
91
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
92
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
93
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
94
-			'all_items'          => esc_html__( 'All Recipes', 'lsx-health-plan' ),
95
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
96
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
97
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
98
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
88
+			'name'               => esc_html__('Recipes', 'lsx-health-plan'),
89
+			'singular_name'      => esc_html__('Recipe', 'lsx-health-plan'),
90
+			'add_new'            => esc_html_x('Add New', 'post type general name', 'lsx-health-plan'),
91
+			'add_new_item'       => esc_html__('Add New', 'lsx-health-plan'),
92
+			'edit_item'          => esc_html__('Edit', 'lsx-health-plan'),
93
+			'new_item'           => esc_html__('New', 'lsx-health-plan'),
94
+			'all_items'          => esc_html__('All Recipes', 'lsx-health-plan'),
95
+			'view_item'          => esc_html__('View', 'lsx-health-plan'),
96
+			'search_items'       => esc_html__('Search', 'lsx-health-plan'),
97
+			'not_found'          => esc_html__('None found', 'lsx-health-plan'),
98
+			'not_found_in_trash' => esc_html__('None found in Trash', 'lsx-health-plan'),
99 99
 			'parent_item_colon'  => '',
100
-			'menu_name'          => esc_html__( 'Recipes', 'lsx-health-plan' ),
100
+			'menu_name'          => esc_html__('Recipes', 'lsx-health-plan'),
101 101
 		);
102
-		$args         = array(
102
+		$args = array(
103 103
 			'labels'             => $this->labels,
104 104
 			'public'             => true,
105 105
 			'publicly_queryable' => true,
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 				'custom-fields',
123 123
 			),
124 124
 		);
125
-		register_post_type( 'recipe', $args );
125
+		register_post_type('recipe', $args);
126 126
 	}
127 127
 
128 128
 	/**
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 	 * @return void
132 132
 	 */
133 133
 	public function register_menus() {
134
-		add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Recipes', 'lsx-health-plan' ), esc_html__( 'Recipes', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=recipe' );
135
-		add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Recipe Types', 'lsx-health-plan' ), esc_html__( 'Recipe Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=recipe-type&post_type=recipe' );
136
-		add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Cuisines', 'lsx-health-plan' ), esc_html__( 'Cuisines', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=recipe-cuisine&post_type=recipe' );
134
+		add_submenu_page('edit.php?post_type=meal', esc_html__('Recipes', 'lsx-health-plan'), esc_html__('Recipes', 'lsx-health-plan'), 'edit_posts', 'edit.php?post_type=recipe');
135
+		add_submenu_page('edit.php?post_type=meal', esc_html__('Recipe Types', 'lsx-health-plan'), esc_html__('Recipe Types', 'lsx-health-plan'), 'edit_posts', 'edit-tags.php?taxonomy=recipe-type&post_type=recipe');
136
+		add_submenu_page('edit.php?post_type=meal', esc_html__('Cuisines', 'lsx-health-plan'), esc_html__('Cuisines', 'lsx-health-plan'), 'edit_posts', 'edit-tags.php?taxonomy=recipe-cuisine&post_type=recipe');
137 137
 	}
138 138
 
139 139
 	/**
@@ -141,19 +141,19 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function taxonomy_setup() {
143 143
 		$labels = array(
144
-			'name'              => esc_html_x( 'Cuisine', 'taxonomy general name', 'lsx-health-plan' ),
145
-			'singular_name'     => esc_html_x( 'Cuisines', 'taxonomy singular name', 'lsx-health-plan' ),
146
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
147
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
148
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
149
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
150
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
151
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
152
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
153
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
154
-			'menu_name'         => esc_html__( 'Cuisines', 'lsx-health-plan' ),
144
+			'name'              => esc_html_x('Cuisine', 'taxonomy general name', 'lsx-health-plan'),
145
+			'singular_name'     => esc_html_x('Cuisines', 'taxonomy singular name', 'lsx-health-plan'),
146
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
147
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
148
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
149
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
150
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
151
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
152
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
153
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
154
+			'menu_name'         => esc_html__('Cuisines', 'lsx-health-plan'),
155 155
 		);
156
-		$args   = array(
156
+		$args = array(
157 157
 			'hierarchical'      => true,
158 158
 			'labels'            => $labels,
159 159
 			'show_ui'           => true,
@@ -164,22 +164,22 @@  discard block
 block discarded – undo
164 164
 				'slug' => 'recipe-cuisine',
165 165
 			),
166 166
 		);
167
-		register_taxonomy( 'recipe-cuisine', array( $this->slug ), $args );
167
+		register_taxonomy('recipe-cuisine', array($this->slug), $args);
168 168
 
169 169
 		$labels = array(
170
-			'name'              => esc_html_x( 'Recipe Type', 'taxonomy general name', 'lsx-health-plan' ),
171
-			'singular_name'     => esc_html_x( 'Recipe Types', 'taxonomy singular name', 'lsx-health-plan' ),
172
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
173
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
174
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
175
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
176
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
177
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
178
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
179
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
180
-			'menu_name'         => esc_html__( 'Types', 'lsx-health-plan' ),
170
+			'name'              => esc_html_x('Recipe Type', 'taxonomy general name', 'lsx-health-plan'),
171
+			'singular_name'     => esc_html_x('Recipe Types', 'taxonomy singular name', 'lsx-health-plan'),
172
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
173
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
174
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
175
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
176
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
177
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
178
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
179
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
180
+			'menu_name'         => esc_html__('Types', 'lsx-health-plan'),
181 181
 		);
182
-		$args   = array(
182
+		$args = array(
183 183
 			'hierarchical'      => true,
184 184
 			'labels'            => $labels,
185 185
 			'show_ui'           => true,
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 				'slug' => 'recipe-type',
191 191
 			),
192 192
 		);
193
-		register_taxonomy( 'recipe-type', array( $this->slug ), $args );
193
+		register_taxonomy('recipe-type', array($this->slug), $args);
194 194
 	}
195 195
 
196 196
 	/**
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 * @param array $post_types
200 200
 	 * @return array
201 201
 	 */
202
-	public function enable_post_type( $post_types = array() ) {
202
+	public function enable_post_type($post_types = array()) {
203 203
 		$post_types[] = $this->slug;
204 204
 		return $post_types;
205 205
 	}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @param array $connections
211 211
 	 * @return void
212 212
 	 */
213
-	public function enable_connections( $connections = array() ) {
213
+	public function enable_connections($connections = array()) {
214 214
 		$connections['recipe']['connected_plans'] = 'connected_recipes';
215 215
 		$connections['plan']['connected_recipes'] = 'connected_plans';
216 216
 		return $connections;
@@ -222,45 +222,45 @@  discard block
 block discarded – undo
222 222
 	 * @param string $title the term title.
223 223
 	 * @return string
224 224
 	 */
225
-	public function get_the_archive_title( $title ) {
226
-		if ( is_post_type_archive( 'recipe' ) ) {
227
-			$title = __( 'Recipes', 'lsx-health-plan' );
225
+	public function get_the_archive_title($title) {
226
+		if (is_post_type_archive('recipe')) {
227
+			$title = __('Recipes', 'lsx-health-plan');
228 228
 		}
229
-		if ( is_post_type_archive( 'exercise' ) ) {
230
-			$title = __( 'Exercises', 'lsx-health-plan' );
229
+		if (is_post_type_archive('exercise')) {
230
+			$title = __('Exercises', 'lsx-health-plan');
231 231
 		}
232
-		if ( is_tax( 'recipe-type' ) ) {
232
+		if (is_tax('recipe-type')) {
233 233
 			$queried_object = get_queried_object();
234
-			if ( isset( $queried_object->name ) ) {
235
-				$title = $queried_object->name . ' ' . __( 'Recipes', 'lsx-health-plan' );
234
+			if (isset($queried_object->name)) {
235
+				$title = $queried_object->name . ' ' . __('Recipes', 'lsx-health-plan');
236 236
 			}
237 237
 		}
238 238
 		return $title;
239 239
 	}
240 240
 
241 241
 	public function remove_archive_original_header() {
242
-		if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) {
243
-			remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
242
+		if (is_post_type_archive('recipe') || is_post_type_archive('exercise')) {
243
+			remove_action('lsx_content_wrap_before', 'lsx_global_header');
244 244
 		}
245
-		if ( is_singular( 'recipe' ) || is_singular( 'exercise' ) ) {
246
-			remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
245
+		if (is_singular('recipe') || is_singular('exercise')) {
246
+			remove_action('lsx_content_wrap_before', 'lsx_global_header');
247 247
 		}
248
-		if ( ! is_post_type_archive() ) {
249
-			add_action( 'lsx_content_wrap_before', 'lsx_health_plan_recipe_archive_description', 11 );
248
+		if ( ! is_post_type_archive()) {
249
+			add_action('lsx_content_wrap_before', 'lsx_health_plan_recipe_archive_description', 11);
250 250
 		}
251 251
 	}
252 252
 
253 253
 	public function hp_lsx_archive_header() {
254
-		if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) {
254
+		if (is_post_type_archive('recipe') || is_post_type_archive('exercise')) {
255 255
 		?>
256 256
 			<div class="archive-header-wrapper banner-archive">
257 257
 				<?php lsx_global_header_inner_bottom(); ?>
258 258
 				<header class="archive-header">
259 259
 					<h1 class="archive-title">
260
-						<?php if ( has_post_format() && ! is_category() && ! is_tag() && ! is_date() && ! is_tax( 'post_format' ) ) { ?>
261
-							<?php the_archive_title( esc_html__( 'Type:', 'lsx' ) ); ?>
260
+						<?php if (has_post_format() && ! is_category() && ! is_tag() && ! is_date() && ! is_tax('post_format')) { ?>
261
+							<?php the_archive_title(esc_html__('Type:', 'lsx')); ?>
262 262
 						<?php } else { ?>
263
-							<?php echo wp_kses_post( apply_filters( 'lsx_global_header_title', get_the_archive_title() ) ); ?>
263
+							<?php echo wp_kses_post(apply_filters('lsx_global_header_title', get_the_archive_title())); ?>
264 264
 						<?php } ?>
265 265
 					</h1>
266 266
 
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 	 * @param boolean $disable
280 280
 	 * @return boolean
281 281
 	 */
282
-	public function disable_global_header_description( $disable ) {
283
-		if ( is_tax( 'recipe-type' ) ) {
282
+	public function disable_global_header_description($disable) {
283
+		if (is_tax('recipe-type')) {
284 284
 			$disable = true;
285 285
 		}
286 286
 		return $disable;
@@ -292,21 +292,21 @@  discard block
 block discarded – undo
292 292
 	 * @var array $crumbs
293 293
 	 * @return array
294 294
 	 */
295
-	public function recipes_breadcrumb_filter( $crumbs ) {
296
-		$recipe  = \lsx_health_plan\functions\get_option( 'endpoint_recipe', 'recipe' );
297
-		$recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe_archive', 'recipes' );
298
-		$url     = get_post_type_archive_link( 'recipe' );
295
+	public function recipes_breadcrumb_filter($crumbs) {
296
+		$recipe  = \lsx_health_plan\functions\get_option('endpoint_recipe', 'recipe');
297
+		$recipes = \lsx_health_plan\functions\get_option('endpoint_recipe_archive', 'recipes');
298
+		$url     = get_post_type_archive_link('recipe');
299 299
 
300
-		if ( is_singular( 'recipe' ) ) {
300
+		if (is_singular('recipe')) {
301 301
 			$recipe_name     = get_the_title();
302
-			$term_obj_list   = get_the_terms( get_the_ID(), 'recipe-type' );
302
+			$term_obj_list   = get_the_terms(get_the_ID(), 'recipe-type');
303 303
 			$recipe_type     = $term_obj_list[0]->name;
304
-			$recipe_type_url = get_term_link( $term_obj_list[0]->term_id );
304
+			$recipe_type_url = get_term_link($term_obj_list[0]->term_id);
305 305
 
306 306
 			$new_crumbs    = array();
307 307
 			$new_crumbs[0] = $crumbs[0];
308 308
 
309
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
309
+			if (function_exists('woocommerce_breadcrumb')) {
310 310
 				$new_crumbs[1] = array(
311 311
 					0 => $recipes,
312 312
 					1 => $url,
@@ -333,15 +333,15 @@  discard block
 block discarded – undo
333 333
 			}
334 334
 			$crumbs = $new_crumbs;
335 335
 		}
336
-		if ( is_tax( 'recipe-type' ) || is_tax( 'recipe-cuisine' ) ) {
337
-			$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
336
+		if (is_tax('recipe-type') || is_tax('recipe-cuisine')) {
337
+			$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); 
338 338
 
339
-			$single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name;
339
+			$single_term_title = str_replace('-', ' ', $term->taxonomy) . ': ' . $term->name;
340 340
 
341 341
 			$new_crumbs    = array();
342 342
 			$new_crumbs[0] = $crumbs[0];
343 343
 
344
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
344
+			if (function_exists('woocommerce_breadcrumb')) {
345 345
 				$new_crumbs[1] = array(
346 346
 					0 => $recipes,
347 347
 					1 => $url,
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
 			}
361 361
 			$crumbs = $new_crumbs;
362 362
 		}
363
-		if ( is_post_type_archive( 'recipe' ) ) {
363
+		if (is_post_type_archive('recipe')) {
364 364
 
365 365
 			$new_crumbs    = array();
366 366
 			$new_crumbs[0] = $crumbs[0];
367 367
 
368
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
368
+			if (function_exists('woocommerce_breadcrumb')) {
369 369
 				$new_crumbs[1] = array(
370 370
 					0 => $recipes,
371 371
 				);
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
 		$cmb = new_cmb2_box(
387 387
 			array(
388 388
 				'id'           => $this->slug . '_featured_metabox',
389
-				'title'        => __( 'Featured', 'lsx-health-plan' ),
390
-				'object_types' => array( $this->slug ),
389
+				'title'        => __('Featured', 'lsx-health-plan'),
390
+				'object_types' => array($this->slug),
391 391
 				'context'      => 'side',
392 392
 				'priority'     => 'high',
393 393
 				'show_names'   => true,
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 		);
396 396
 		$cmb->add_field(
397 397
 			array(
398
-				'name'       => __( 'Featured', 'lsx-health-plan' ),
399
-				'desc'       => __( 'Enable the checkbox to feature this recipe, featured recipes display in any page that has the recipe shortcode: [lsx_health_plan_featured_recipes_block]', 'lsx-health-plan' ),
398
+				'name'       => __('Featured', 'lsx-health-plan'),
399
+				'desc'       => __('Enable the checkbox to feature this recipe, featured recipes display in any page that has the recipe shortcode: [lsx_health_plan_featured_recipes_block]', 'lsx-health-plan'),
400 400
 				'id'         => $this->slug . '_featured',
401 401
 				'type'       => 'checkbox',
402 402
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
 		$cmb = new_cmb2_box(
412 412
 			array(
413 413
 				'id'           => $this->slug . '_details_metabox',
414
-				'title'        => __( 'Cooking Info', 'lsx-health-plan' ),
415
-				'object_types' => array( $this->slug ), // Post type
414
+				'title'        => __('Cooking Info', 'lsx-health-plan'),
415
+				'object_types' => array($this->slug), // Post type
416 416
 				'context'      => 'normal',
417 417
 				'priority'     => 'high',
418 418
 				'show_names'   => true,
@@ -420,27 +420,27 @@  discard block
 block discarded – undo
420 420
 		);
421 421
 		$cmb->add_field(
422 422
 			array(
423
-				'name'       => __( 'Prep Time', 'lsx-health-plan' ),
423
+				'name'       => __('Prep Time', 'lsx-health-plan'),
424 424
 				'id'         => $this->slug . '_prep_time',
425
-				'desc'       => __( 'Add the preparation time for the entire meal i.e: 25 mins', 'lsx-health-plan' ),
425
+				'desc'       => __('Add the preparation time for the entire meal i.e: 25 mins', 'lsx-health-plan'),
426 426
 				'type'       => 'text',
427 427
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
428 428
 			)
429 429
 		);
430 430
 		$cmb->add_field(
431 431
 			array(
432
-				'name'       => __( 'Cooking Time', 'lsx-health-plan' ),
432
+				'name'       => __('Cooking Time', 'lsx-health-plan'),
433 433
 				'id'         => $this->slug . '_cooking_time',
434
-				'desc'       => __( 'Add the cooking time i.e: 15 mins', 'lsx-health-plan' ),
434
+				'desc'       => __('Add the cooking time i.e: 15 mins', 'lsx-health-plan'),
435 435
 				'type'       => 'text',
436 436
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
437 437
 			)
438 438
 		);
439 439
 		$cmb->add_field(
440 440
 			array(
441
-				'name'       => __( 'Serves', 'lsx-health-plan' ),
441
+				'name'       => __('Serves', 'lsx-health-plan'),
442 442
 				'id'         => $this->slug . '_serves',
443
-				'desc'       => __( 'Add the recommended serving size i.e: 6', 'lsx-health-plan' ),
443
+				'desc'       => __('Add the recommended serving size i.e: 6', 'lsx-health-plan'),
444 444
 				'type'       => 'text',
445 445
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
446 446
 				'attributes' => array(
@@ -451,8 +451,8 @@  discard block
 block discarded – undo
451 451
 		);
452 452
 		$cmb->add_field(
453 453
 			array(
454
-				'name'       => __( 'Portion', 'lsx-health-plan' ),
455
-				'desc'       => __( 'Add the recommended portion size i.e: 200mg', 'lsx-health-plan' ),
454
+				'name'       => __('Portion', 'lsx-health-plan'),
455
+				'desc'       => __('Add the recommended portion size i.e: 200mg', 'lsx-health-plan'),
456 456
 				'id'         => $this->slug . '_portion',
457 457
 				'type'       => 'text',
458 458
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -461,8 +461,8 @@  discard block
 block discarded – undo
461 461
 		$cmb = new_cmb2_box(
462 462
 			array(
463 463
 				'id'           => $this->slug . '_nutritional_metabox',
464
-				'title'        => __( 'Nutritional Info', 'lsx-health-plan' ),
465
-				'object_types' => array( $this->slug ), // Post type
464
+				'title'        => __('Nutritional Info', 'lsx-health-plan'),
465
+				'object_types' => array($this->slug), // Post type
466 466
 				'context'      => 'normal',
467 467
 				'priority'     => 'high',
468 468
 				'show_names'   => true,
@@ -470,45 +470,45 @@  discard block
 block discarded – undo
470 470
 		);
471 471
 		$cmb->add_field(
472 472
 			array(
473
-				'name'       => __( 'Energy', 'lsx-health-plan' ),
473
+				'name'       => __('Energy', 'lsx-health-plan'),
474 474
 				'id'         => $this->slug . '_energy',
475
-				'desc'       => __( 'Add the energy amount for the entire meal i.e: 700 kj', 'lsx-health-plan' ),
475
+				'desc'       => __('Add the energy amount for the entire meal i.e: 700 kj', 'lsx-health-plan'),
476 476
 				'type'       => 'text',
477 477
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
478 478
 			)
479 479
 		);
480 480
 		$cmb->add_field(
481 481
 			array(
482
-				'name'       => __( 'Protein', 'lsx-health-plan' ),
482
+				'name'       => __('Protein', 'lsx-health-plan'),
483 483
 				'id'         => $this->slug . '_protein',
484
-				'desc'       => __( 'Add the protein amount for the entire meal i.e: 50 g', 'lsx-health-plan' ),
484
+				'desc'       => __('Add the protein amount for the entire meal i.e: 50 g', 'lsx-health-plan'),
485 485
 				'type'       => 'text',
486 486
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
487 487
 			)
488 488
 		);
489 489
 		$cmb->add_field(
490 490
 			array(
491
-				'name'       => __( 'Carbohydrates', 'lsx-health-plan' ),
491
+				'name'       => __('Carbohydrates', 'lsx-health-plan'),
492 492
 				'id'         => $this->slug . '_carbohydrates',
493
-				'desc'       => __( 'Add the carbohydrates amount for the entire meal i.e: 5 g', 'lsx-health-plan' ),
493
+				'desc'       => __('Add the carbohydrates amount for the entire meal i.e: 5 g', 'lsx-health-plan'),
494 494
 				'type'       => 'text',
495 495
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
496 496
 			)
497 497
 		);
498 498
 		$cmb->add_field(
499 499
 			array(
500
-				'name'       => __( 'Fibre', 'lsx-health-plan' ),
500
+				'name'       => __('Fibre', 'lsx-health-plan'),
501 501
 				'id'         => $this->slug . '_fibre',
502
-				'desc'       => __( 'Add the fibre amount for the entire meal i.e: 5 g', 'lsx-health-plan' ),
502
+				'desc'       => __('Add the fibre amount for the entire meal i.e: 5 g', 'lsx-health-plan'),
503 503
 				'type'       => 'text',
504 504
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
505 505
 			)
506 506
 		);
507 507
 		$cmb->add_field(
508 508
 			array(
509
-				'name'       => __( 'Fat', 'lsx-health-plan' ),
509
+				'name'       => __('Fat', 'lsx-health-plan'),
510 510
 				'id'         => $this->slug . '_fat',
511
-				'desc'       => __( 'Add the fat amount for the entire meal i.e: 20 g', 'lsx-health-plan' ),
511
+				'desc'       => __('Add the fat amount for the entire meal i.e: 20 g', 'lsx-health-plan'),
512 512
 				'type'       => 'text',
513 513
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
514 514
 			)
Please login to merge, or discard this patch.
classes/post-types/class-plan.php 2 patches
Indentation   +572 added lines, -572 removed lines patch added patch discarded remove patch
@@ -10,208 +10,208 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class Plan {
12 12
 
13
-	/**
14
-	 * Holds class instance
15
-	 *
16
-	 * @since 1.0.0
17
-	 *
18
-	 * @var      object \lsx_health_plan\classes\Plan()
19
-	 */
20
-	protected static $instance = null;
21
-
22
-	/**
23
-	 * Holds post_type slug used as an index
24
-	 *
25
-	 * @since 1.0.0
26
-	 *
27
-	 * @var      string
28
-	 */
29
-	public $slug = 'plan';
30
-
31
-	/**
32
-	 * Constructor
33
-	 */
34
-	public function __construct() {
35
-
36
-		add_action( 'init', array( $this, 'register_post_type' ) );
37
-		add_action( 'init', array( $this, 'plan_type_taxonomy_setup' ) );
38
-		add_action( 'init', array( $this, 'week_taxonomy_setup' ) );
39
-
40
-		// Icons for the plan types.
41
-		add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 );
42
-		add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 );
43
-		$prefix_taxonomy = 'plan-type';
44
-		add_action( sprintf( '%s_edit_form_fields', $prefix_taxonomy ), array( $this, 'add_thumbnail_form_field' ), 3, 1 );
45
-
46
-		// Register the Metaboxes.
47
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
48
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ), 5 );
49
-		add_action( 'cmb2_admin_init', array( $this, 'plan_connections' ), 5 );
50
-		add_action( 'cmb2_admin_init', array( $this, 'sections_metabox_loop' ), 1 );
51
-
52
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
53
-		//add_filter( 'lsx_global_header_title', array( $this, 'hp_recipe_header_title' ), 200, 1 );
54
-
55
-		// Template Redirects.
56
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
57
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
58
-
59
-		// Plan Archive Actions.
60
-		add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
61
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
62
-		add_action( 'lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1 );
63
-		add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1 );
64
-		add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_filters_disabled', 10, 1 );
65
-
66
-		//Breadcrumbs
67
-		add_filter( 'wpseo_breadcrumb_links', array( $this, 'plan_breadcrumb_filter' ), 30, 1 );
68
-		add_filter( 'woocommerce_get_breadcrumb', array( $this, 'plan_breadcrumb_filter' ), 30, 1 );
13
+     /**
14
+      * Holds class instance
15
+      *
16
+      * @since 1.0.0
17
+      *
18
+      * @var      object \lsx_health_plan\classes\Plan()
19
+      */
20
+     protected static $instance = null;
21
+
22
+     /**
23
+      * Holds post_type slug used as an index
24
+      *
25
+      * @since 1.0.0
26
+      *
27
+      * @var      string
28
+      */
29
+     public $slug = 'plan';
30
+
31
+     /**
32
+      * Constructor
33
+      */
34
+     public function __construct() {
35
+
36
+          add_action( 'init', array( $this, 'register_post_type' ) );
37
+          add_action( 'init', array( $this, 'plan_type_taxonomy_setup' ) );
38
+          add_action( 'init', array( $this, 'week_taxonomy_setup' ) );
39
+
40
+          // Icons for the plan types.
41
+          add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 );
42
+          add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 );
43
+          $prefix_taxonomy = 'plan-type';
44
+          add_action( sprintf( '%s_edit_form_fields', $prefix_taxonomy ), array( $this, 'add_thumbnail_form_field' ), 3, 1 );
45
+
46
+          // Register the Metaboxes.
47
+          add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
48
+          add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ), 5 );
49
+          add_action( 'cmb2_admin_init', array( $this, 'plan_connections' ), 5 );
50
+          add_action( 'cmb2_admin_init', array( $this, 'sections_metabox_loop' ), 1 );
51
+
52
+          add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
53
+          //add_filter( 'lsx_global_header_title', array( $this, 'hp_recipe_header_title' ), 200, 1 );
54
+
55
+          // Template Redirects.
56
+          add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
57
+          add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
58
+
59
+          // Plan Archive Actions.
60
+          add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
61
+          add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
62
+          add_action( 'lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1 );
63
+          add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1 );
64
+          add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_filters_disabled', 10, 1 );
65
+
66
+          //Breadcrumbs
67
+          add_filter( 'wpseo_breadcrumb_links', array( $this, 'plan_breadcrumb_filter' ), 30, 1 );
68
+          add_filter( 'woocommerce_get_breadcrumb', array( $this, 'plan_breadcrumb_filter' ), 30, 1 );
69 69
 		
70
-	}
71
-
72
-	/**
73
-	 * Return an instance of this class.
74
-	 *
75
-	 * @since 1.0.0
76
-	 *
77
-	 * @return    object \lsx_health_plan\classes\Meal_Plan()    A single instance of this class.
78
-	 */
79
-	public static function get_instance() {
80
-		// If the single instance hasn't been set, set it now.
81
-		if ( null === self::$instance ) {
82
-			self::$instance = new self();
83
-		}
84
-		return self::$instance;
85
-	}
86
-	/**
87
-	 * Register the post type.
88
-	 */
89
-	public function register_post_type() {
90
-		$labels = array(
91
-			'name'               => esc_html__( 'Plans', 'lsx-health-plan' ),
92
-			'singular_name'      => esc_html__( 'Plan', 'lsx-health-plan' ),
93
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
94
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
95
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
96
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
97
-			'all_items'          => esc_html__( 'All Plans', 'lsx-health-plan' ),
98
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
99
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
100
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
101
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
102
-			'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
103
-			'menu_name'          => esc_html__( 'Plans', 'lsx-health-plan' ),
104
-		);
105
-		$args   = array(
106
-			'labels'             => $labels,
107
-			'public'             => true,
108
-			'publicly_queryable' => true,
109
-			'show_ui'            => true,
110
-			'show_in_menu'       => true,
111
-			'show_in_rest'       => true,
112
-			'menu_icon'          => 'dashicons-welcome-write-blog',
113
-			'query_var'          => true,
114
-			'rewrite'            => array(
115
-				'slug' => \lsx_health_plan\functions\get_option( 'plan_single_slug', 'plan' ),
116
-			),
117
-			'capability_type'    => 'page',
118
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plans' ),
119
-			'hierarchical'       => false,
120
-			'menu_position'      => null,
121
-			'supports'           => array(
122
-				'title',
123
-				'editor',
124
-				'thumbnail',
125
-				'page-attributes',
126
-				'custom-fields',
127
-			),
128
-		);
129
-		register_post_type( 'plan', $args );
130
-	}
131
-
132
-	/**
133
-	 * Register the Type taxonomy.
134
-	 */
135
-	public function plan_type_taxonomy_setup() {
136
-		$labels = array(
137
-			'name'              => esc_html_x( 'Plan Type', 'taxonomy general name', 'lsx-health-plan' ),
138
-			'singular_name'     => esc_html_x( 'Plan Type', 'taxonomy singular name', 'lsx-health-plan' ),
139
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
140
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
141
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
142
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
143
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
144
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
145
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
146
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
147
-			'menu_name'         => esc_html__( 'Plan Types', 'lsx-health-plan' ),
148
-		);
149
-
150
-		$args = array(
151
-			'hierarchical'      => true,
152
-			'labels'            => $labels,
153
-			'show_ui'           => true,
154
-			'show_admin_column' => true,
155
-			'query_var'         => true,
156
-			'rewrite'           => array(
157
-				'slug' => 'plan-type',
158
-			),
159
-		);
160
-
161
-		register_taxonomy( 'plan-type', array( 'plan' ), $args );
162
-	}
163
-
164
-	/**
165
-	 * Register the Week taxonomy.
166
-	 */
167
-	public function week_taxonomy_setup() {
168
-		$labels = array(
169
-			'name'              => esc_html_x( 'Week', 'taxonomy general name', 'lsx-health-plan' ),
170
-			'singular_name'     => esc_html_x( 'Week', 'taxonomy singular name', 'lsx-health-plan' ),
171
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
172
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
173
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
174
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
175
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
176
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
177
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
178
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
179
-			'menu_name'         => esc_html__( 'Weeks', 'lsx-health-plan' ),
180
-		);
181
-
182
-		$args = array(
183
-			'hierarchical'      => true,
184
-			'labels'            => $labels,
185
-			'show_ui'           => true,
186
-			'show_admin_column' => true,
187
-			'query_var'         => true,
188
-			'show_in_rest'      => true,
189
-			'rewrite'           => array(
190
-				'slug' => 'week',
191
-			),
192
-		);
193
-
194
-		register_taxonomy( 'week', array( 'plan' ), $args );
195
-	}
196
-
197
-	/**
198
-	 * Output the form field for this metadata when adding a new term
199
-	 *
200
-	 * @since 0.1.0
201
-	 */
202
-	public function add_thumbnail_form_field( $term = false ) {
203
-		if ( is_object( $term ) ) {
204
-			$value         = get_term_meta( $term->term_id, 'thumbnail', true );
205
-			$image_preview = wp_get_attachment_image_src( $value, 'thumbnail' );
206
-
207
-			if ( is_array( $image_preview ) ) {
208
-				$image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url( $image_preview[0] ) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />';
209
-			}
210
-		} else {
211
-			$image_preview = false;
212
-			$value         = false;
213
-		}
214
-		?>
70
+     }
71
+
72
+     /**
73
+      * Return an instance of this class.
74
+      *
75
+      * @since 1.0.0
76
+      *
77
+      * @return    object \lsx_health_plan\classes\Meal_Plan()    A single instance of this class.
78
+      */
79
+     public static function get_instance() {
80
+          // If the single instance hasn't been set, set it now.
81
+          if ( null === self::$instance ) {
82
+               self::$instance = new self();
83
+          }
84
+          return self::$instance;
85
+     }
86
+     /**
87
+      * Register the post type.
88
+      */
89
+     public function register_post_type() {
90
+          $labels = array(
91
+               'name'               => esc_html__( 'Plans', 'lsx-health-plan' ),
92
+               'singular_name'      => esc_html__( 'Plan', 'lsx-health-plan' ),
93
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
94
+               'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
95
+               'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
96
+               'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
97
+               'all_items'          => esc_html__( 'All Plans', 'lsx-health-plan' ),
98
+               'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
99
+               'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
100
+               'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
101
+               'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
102
+               'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
103
+               'menu_name'          => esc_html__( 'Plans', 'lsx-health-plan' ),
104
+          );
105
+          $args   = array(
106
+               'labels'             => $labels,
107
+               'public'             => true,
108
+               'publicly_queryable' => true,
109
+               'show_ui'            => true,
110
+               'show_in_menu'       => true,
111
+               'show_in_rest'       => true,
112
+               'menu_icon'          => 'dashicons-welcome-write-blog',
113
+               'query_var'          => true,
114
+               'rewrite'            => array(
115
+                    'slug' => \lsx_health_plan\functions\get_option( 'plan_single_slug', 'plan' ),
116
+               ),
117
+               'capability_type'    => 'page',
118
+               'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plans' ),
119
+               'hierarchical'       => false,
120
+               'menu_position'      => null,
121
+               'supports'           => array(
122
+                    'title',
123
+                    'editor',
124
+                    'thumbnail',
125
+                    'page-attributes',
126
+                    'custom-fields',
127
+               ),
128
+          );
129
+          register_post_type( 'plan', $args );
130
+     }
131
+
132
+     /**
133
+      * Register the Type taxonomy.
134
+      */
135
+     public function plan_type_taxonomy_setup() {
136
+          $labels = array(
137
+               'name'              => esc_html_x( 'Plan Type', 'taxonomy general name', 'lsx-health-plan' ),
138
+               'singular_name'     => esc_html_x( 'Plan Type', 'taxonomy singular name', 'lsx-health-plan' ),
139
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
140
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
141
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
142
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
143
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
144
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
145
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
146
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
147
+               'menu_name'         => esc_html__( 'Plan Types', 'lsx-health-plan' ),
148
+          );
149
+
150
+          $args = array(
151
+               'hierarchical'      => true,
152
+               'labels'            => $labels,
153
+               'show_ui'           => true,
154
+               'show_admin_column' => true,
155
+               'query_var'         => true,
156
+               'rewrite'           => array(
157
+                    'slug' => 'plan-type',
158
+               ),
159
+          );
160
+
161
+          register_taxonomy( 'plan-type', array( 'plan' ), $args );
162
+     }
163
+
164
+     /**
165
+      * Register the Week taxonomy.
166
+      */
167
+     public function week_taxonomy_setup() {
168
+          $labels = array(
169
+               'name'              => esc_html_x( 'Week', 'taxonomy general name', 'lsx-health-plan' ),
170
+               'singular_name'     => esc_html_x( 'Week', 'taxonomy singular name', 'lsx-health-plan' ),
171
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
172
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
173
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
174
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
175
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
176
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
177
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
178
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
179
+               'menu_name'         => esc_html__( 'Weeks', 'lsx-health-plan' ),
180
+          );
181
+
182
+          $args = array(
183
+               'hierarchical'      => true,
184
+               'labels'            => $labels,
185
+               'show_ui'           => true,
186
+               'show_admin_column' => true,
187
+               'query_var'         => true,
188
+               'show_in_rest'      => true,
189
+               'rewrite'           => array(
190
+                    'slug' => 'week',
191
+               ),
192
+          );
193
+
194
+          register_taxonomy( 'week', array( 'plan' ), $args );
195
+     }
196
+
197
+     /**
198
+      * Output the form field for this metadata when adding a new term
199
+      *
200
+      * @since 0.1.0
201
+      */
202
+     public function add_thumbnail_form_field( $term = false ) {
203
+          if ( is_object( $term ) ) {
204
+               $value         = get_term_meta( $term->term_id, 'thumbnail', true );
205
+               $image_preview = wp_get_attachment_image_src( $value, 'thumbnail' );
206
+
207
+               if ( is_array( $image_preview ) ) {
208
+                    $image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url( $image_preview[0] ) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />';
209
+               }
210
+          } else {
211
+               $image_preview = false;
212
+               $value         = false;
213
+          }
214
+          ?>
215 215
 		<tr class="form-field form-required term-thumbnail-wrap">
216 216
 			<th scope="row"><label for="thumbnail"><?php esc_html_e( 'Icon Image', 'lsx-health-plan' ); ?></label></th>
217 217
 			<td>
@@ -225,379 +225,379 @@  discard block
 block discarded – undo
225 225
 			</td>
226 226
 		</tr>
227 227
 		<?php
228
-	}
229
-
230
-	/**
231
-	 * Saves the Taxonomy term icon image
232
-	 *
233
-	 * @since 0.1.0
234
-	 *
235
-	 * @param  int    $term_id
236
-	 * @param  string $taxonomy
237
-	 */
238
-	public function save_meta( $term_id = 0, $taxonomy = '' ) {
239
-		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
240
-			return;
241
-		}
242
-
243
-		if ( ! isset( $_POST['thumbnail'] ) ) {
244
-			return;
245
-		}
246
-
247
-		if ( check_admin_referer( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ) ) {
248
-			if ( ! isset( $_POST['thumbnail'] ) ) {
249
-				return;
250
-			}
251
-
252
-			$thumbnail_meta = sanitize_text_field( $_POST['thumbnail'] );
253
-			$thumbnail_meta = ! empty( $thumbnail_meta ) ? $thumbnail_meta : '';
254
-
255
-			if ( empty( $thumbnail_meta ) ) {
256
-				delete_term_meta( $term_id, 'thumbnail' );
257
-			} else {
258
-				update_term_meta( $term_id, 'thumbnail', $thumbnail_meta );
259
-			}
260
-		}
261
-	}
262
-
263
-	/**
264
-	 * Define the metabox and field configurations.
265
-	 */
266
-	public function details_metaboxes() {
267
-		$cmb = new_cmb2_box( array(
268
-			'id'           => $this->slug . '_details_metabox',
269
-			'title'        => __( 'Details', 'lsx-health-plan' ),
270
-			'object_types' => array( $this->slug ), // Post type
271
-			'context'      => 'normal',
272
-			'priority'     => 'high',
273
-			'show_names'   => true,
274
-		) );
275
-
276
-		$cmb->add_field( array(
277
-			'name' => __( 'Plan Short Description', 'lsx-health-plan' ),
278
-			'id'   => $this->slug . '_short_description',
279
-			'type' => 'textarea_small',
280
-			'desc' => __( 'Add a small description for this plan (optional)', 'lsx-health-plan' ),
281
-		) );
282
-
283
-		$warmup_type = 'page';
284
-		if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
285
-			$warmup_type = array( 'page', 'workout' );
286
-		}
287
-		$cmb->add_field( array(
288
-			'name'       => __( 'Warmup', 'lsx-health-plan' ),
289
-			'desc'       => __( 'Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan' ),
290
-			'id'         => $this->slug . '_warmup',
291
-			'type'       => 'post_search_ajax',
292
-			// Optional :
293
-			'limit'      => 3,  // Limit selection to X items only (default 1)
294
-			'sortable'   => true, // Allow selected items to be sortable (default false)
295
-			'query_args' => array(
296
-				'post_type'      => $warmup_type,
297
-				'post_status'    => array( 'publish' ),
298
-				'posts_per_page' => -1,
299
-			),
300
-		) );
301
-	}
302
-
303
-	/**
304
-	 * Adds the post type to the different arrays.
305
-	 *
306
-	 * @param array $post_types
307
-	 * @return array
308
-	 */
309
-	public function enable_post_type( $post_types = array() ) {
310
-		$post_types[] = $this->slug;
311
-		return $post_types;
312
-	}
313
-
314
-	/**
315
-	 * Registers the workout connections on the plan post type.
316
-	 *
317
-	 * @return void
318
-	 */
319
-	public function plan_connections() {
320
-		$cmb = new_cmb2_box(
321
-			array(
322
-				'id'           => $this->slug . '_connections_metabox',
323
-				'title'        => __( 'Plans', 'lsx-health-plan' ),
324
-				'object_types' => array( 'workout', 'meal', 'tip', 'recipe' ),
325
-				'context'      => 'normal',
326
-				'priority'     => 'high',
327
-				'show_names'   => true,
328
-			)
329
-		);
330
-		$cmb->add_field(
331
-			array(
332
-				'name'       => __( 'Plan', 'lsx-health-plan' ),
333
-				'id'         => 'connected_plans',
334
-				'desc'       => __( 'Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan' ),
335
-				'type'       => 'post_search_ajax',
336
-				'limit'      => 15,
337
-				'sortable'   => true,
338
-				'query_args' => array(
339
-					'post_type'      => array( 'plan' ),
340
-					'post_status'    => array( 'publish' ),
341
-					'posts_per_page' => -1,
342
-				),
343
-			)
344
-		);
345
-	}
346
-
347
-	/**
348
-	 * Remove the "Archives:" from the post type.
349
-	 *
350
-	 * @param string $title the term title.
351
-	 * @return string
352
-	 */
353
-	public function get_the_archive_title( $title ) {
354
-		if ( is_post_type_archive( 'plan' ) ) {
355
-			$title = __( 'Our health plans', 'lsx-health-plan' );
356
-		}
357
-		return $title;
358
-	}
359
-
360
-	/**
361
-	 * Set the post type archive to show the parent plans only.
362
-	 *
363
-	 * @param object $wp_query
364
-	 * @return array
365
-	 */
366
-	public function set_parent_only( $wp_query ) {
367
-		if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'plan' ) || $wp_query->is_tax( 'plan-type' ) ) ) {
368
-			$wp_query->set( 'post_parent', '0' );
369
-		}
370
-	}
371
-
372
-	/**
373
-	 * Define the metabox and field configurations.
374
-	 */
375
-	public function featured_metabox() {
376
-		$cmb = new_cmb2_box(
377
-			array(
378
-				'id'           => $this->slug . '_featured_metabox_plan',
379
-				'title'        => __( 'Featured Plan', 'lsx-health-plan' ),
380
-				'object_types' => array( $this->slug ), // Post type
381
-				'context'      => 'side',
382
-				'priority'     => 'high',
383
-				'show_names'   => true,
384
-			)
385
-		);
386
-		$cmb->add_field(
387
-			array(
388
-				'name'       => __( 'Featured Plan', 'lsx-health-plan' ),
389
-				'desc'       => __( 'Enable a featured plan' ),
390
-				'id'         => $this->slug . '_featured_plan',
391
-				'type'       => 'checkbox',
392
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
393
-			)
394
-		);
395
-	}
396
-
397
-	/**
398
-	 * Define the metabox and field configurations.
399
-	 */
400
-	public function sections_metabox_loop() {
401
-		$cmb = new_cmb2_box(
402
-			array(
403
-				'id'           => $this->slug . '_sections_metabox',
404
-				'title'        => __( 'Sections', 'lsx-health-plan' ),
405
-				'object_types' => array( $this->slug ), // Post type.
406
-				'context'      => 'normal',
407
-				'priority'     => 'low',
408
-				'show_names'   => true,
409
-			)
410
-		);
411
-
412
-		/*
228
+     }
229
+
230
+     /**
231
+      * Saves the Taxonomy term icon image
232
+      *
233
+      * @since 0.1.0
234
+      *
235
+      * @param  int    $term_id
236
+      * @param  string $taxonomy
237
+      */
238
+     public function save_meta( $term_id = 0, $taxonomy = '' ) {
239
+          if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
240
+               return;
241
+          }
242
+
243
+          if ( ! isset( $_POST['thumbnail'] ) ) {
244
+               return;
245
+          }
246
+
247
+          if ( check_admin_referer( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ) ) {
248
+               if ( ! isset( $_POST['thumbnail'] ) ) {
249
+                    return;
250
+               }
251
+
252
+               $thumbnail_meta = sanitize_text_field( $_POST['thumbnail'] );
253
+               $thumbnail_meta = ! empty( $thumbnail_meta ) ? $thumbnail_meta : '';
254
+
255
+               if ( empty( $thumbnail_meta ) ) {
256
+                    delete_term_meta( $term_id, 'thumbnail' );
257
+               } else {
258
+                    update_term_meta( $term_id, 'thumbnail', $thumbnail_meta );
259
+               }
260
+          }
261
+     }
262
+
263
+     /**
264
+      * Define the metabox and field configurations.
265
+      */
266
+     public function details_metaboxes() {
267
+          $cmb = new_cmb2_box( array(
268
+               'id'           => $this->slug . '_details_metabox',
269
+               'title'        => __( 'Details', 'lsx-health-plan' ),
270
+               'object_types' => array( $this->slug ), // Post type
271
+               'context'      => 'normal',
272
+               'priority'     => 'high',
273
+               'show_names'   => true,
274
+          ) );
275
+
276
+          $cmb->add_field( array(
277
+               'name' => __( 'Plan Short Description', 'lsx-health-plan' ),
278
+               'id'   => $this->slug . '_short_description',
279
+               'type' => 'textarea_small',
280
+               'desc' => __( 'Add a small description for this plan (optional)', 'lsx-health-plan' ),
281
+          ) );
282
+
283
+          $warmup_type = 'page';
284
+          if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
285
+               $warmup_type = array( 'page', 'workout' );
286
+          }
287
+          $cmb->add_field( array(
288
+               'name'       => __( 'Warmup', 'lsx-health-plan' ),
289
+               'desc'       => __( 'Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan' ),
290
+               'id'         => $this->slug . '_warmup',
291
+               'type'       => 'post_search_ajax',
292
+               // Optional :
293
+               'limit'      => 3,  // Limit selection to X items only (default 1)
294
+               'sortable'   => true, // Allow selected items to be sortable (default false)
295
+               'query_args' => array(
296
+                    'post_type'      => $warmup_type,
297
+                    'post_status'    => array( 'publish' ),
298
+                    'posts_per_page' => -1,
299
+               ),
300
+          ) );
301
+     }
302
+
303
+     /**
304
+      * Adds the post type to the different arrays.
305
+      *
306
+      * @param array $post_types
307
+      * @return array
308
+      */
309
+     public function enable_post_type( $post_types = array() ) {
310
+          $post_types[] = $this->slug;
311
+          return $post_types;
312
+     }
313
+
314
+     /**
315
+      * Registers the workout connections on the plan post type.
316
+      *
317
+      * @return void
318
+      */
319
+     public function plan_connections() {
320
+          $cmb = new_cmb2_box(
321
+               array(
322
+                    'id'           => $this->slug . '_connections_metabox',
323
+                    'title'        => __( 'Plans', 'lsx-health-plan' ),
324
+                    'object_types' => array( 'workout', 'meal', 'tip', 'recipe' ),
325
+                    'context'      => 'normal',
326
+                    'priority'     => 'high',
327
+                    'show_names'   => true,
328
+               )
329
+          );
330
+          $cmb->add_field(
331
+               array(
332
+                    'name'       => __( 'Plan', 'lsx-health-plan' ),
333
+                    'id'         => 'connected_plans',
334
+                    'desc'       => __( 'Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan' ),
335
+                    'type'       => 'post_search_ajax',
336
+                    'limit'      => 15,
337
+                    'sortable'   => true,
338
+                    'query_args' => array(
339
+                         'post_type'      => array( 'plan' ),
340
+                         'post_status'    => array( 'publish' ),
341
+                         'posts_per_page' => -1,
342
+                    ),
343
+               )
344
+          );
345
+     }
346
+
347
+     /**
348
+      * Remove the "Archives:" from the post type.
349
+      *
350
+      * @param string $title the term title.
351
+      * @return string
352
+      */
353
+     public function get_the_archive_title( $title ) {
354
+          if ( is_post_type_archive( 'plan' ) ) {
355
+               $title = __( 'Our health plans', 'lsx-health-plan' );
356
+          }
357
+          return $title;
358
+     }
359
+
360
+     /**
361
+      * Set the post type archive to show the parent plans only.
362
+      *
363
+      * @param object $wp_query
364
+      * @return array
365
+      */
366
+     public function set_parent_only( $wp_query ) {
367
+          if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'plan' ) || $wp_query->is_tax( 'plan-type' ) ) ) {
368
+               $wp_query->set( 'post_parent', '0' );
369
+          }
370
+     }
371
+
372
+     /**
373
+      * Define the metabox and field configurations.
374
+      */
375
+     public function featured_metabox() {
376
+          $cmb = new_cmb2_box(
377
+               array(
378
+                    'id'           => $this->slug . '_featured_metabox_plan',
379
+                    'title'        => __( 'Featured Plan', 'lsx-health-plan' ),
380
+                    'object_types' => array( $this->slug ), // Post type
381
+                    'context'      => 'side',
382
+                    'priority'     => 'high',
383
+                    'show_names'   => true,
384
+               )
385
+          );
386
+          $cmb->add_field(
387
+               array(
388
+                    'name'       => __( 'Featured Plan', 'lsx-health-plan' ),
389
+                    'desc'       => __( 'Enable a featured plan' ),
390
+                    'id'         => $this->slug . '_featured_plan',
391
+                    'type'       => 'checkbox',
392
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
393
+               )
394
+          );
395
+     }
396
+
397
+     /**
398
+      * Define the metabox and field configurations.
399
+      */
400
+     public function sections_metabox_loop() {
401
+          $cmb = new_cmb2_box(
402
+               array(
403
+                    'id'           => $this->slug . '_sections_metabox',
404
+                    'title'        => __( 'Sections', 'lsx-health-plan' ),
405
+                    'object_types' => array( $this->slug ), // Post type.
406
+                    'context'      => 'normal',
407
+                    'priority'     => 'low',
408
+                    'show_names'   => true,
409
+               )
410
+          );
411
+
412
+          /*
413 413
 		This is where the repeatable group is defined, each field has the same ID as the legacy field.
414 414
 		There is a function which runs and adds to looped fields to individual fields for WP Query compatability.
415 415
 		*/
416
-		$group = $cmb->add_field(
417
-			array(
418
-				'id'      => $this->slug . '_sections',
419
-				'type'    => 'group',
420
-				'options' => array(
421
-					'group_title'   => __( 'Section', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
422
-					'add_button'    => __( 'Add section', 'lsx-health-plan' ),
423
-					'remove_button' => __( 'Remove section', 'lsx-health-plan' ),
424
-					'sortable'      => true,
425
-					'closed'        => true, // true to have the groups closed by default
426
-				),
427
-				'classes' => 'lsx-admin-row',
416
+          $group = $cmb->add_field(
417
+               array(
418
+                    'id'      => $this->slug . '_sections',
419
+                    'type'    => 'group',
420
+                    'options' => array(
421
+                         'group_title'   => __( 'Section', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
422
+                         'add_button'    => __( 'Add section', 'lsx-health-plan' ),
423
+                         'remove_button' => __( 'Remove section', 'lsx-health-plan' ),
424
+                         'sortable'      => true,
425
+                         'closed'        => true, // true to have the groups closed by default
426
+                    ),
427
+                    'classes' => 'lsx-admin-row',
428 428
 				
429
-			)
430
-		);
431
-
432
-		$cmb->add_group_field(
433
-			$group,
434
-			array(
435
-				'name'       => __( 'Title', 'lsx-health-plan' ),
436
-				'id'         => 'title',
437
-				'type'       => 'text',
438
-				'desc'       => __( 'e.g Day 1 / Week 1', 'lsx-health-plan' ),
439
-				'classes'    => 'lsx-field-col  lsx-field-col-50',
440
-			)
441
-		);
442
-
443
-		$cmb->add_group_field(
444
-			$group,
445
-			array(
446
-				'name'       => __( 'Group', 'lsx-health-plan' ),
447
-				'id'         => 'group',
448
-				'type'       => 'text',
449
-				'desc'       => __( 'e.g Week 1 / January', 'lsx-health-plan' ),
450
-				'classes'    => 'lsx-field-col  lsx-field-col-50',
451
-			)
452
-		);
453
-
454
-		$cmb->add_group_field(
455
-			$group,
456
-			array(
457
-				'name' => __( 'Overview', 'lsx-health-plan' ),
458
-				'id'   => 'description',
459
-				'type' => 'wysiwyg',
460
-			)
461
-		);
462
-
463
-		if ( post_type_exists( 'workout' ) ) {
464
-			$cmb->add_group_field(
465
-				$group,
466
-				array(
467
-					'name'       => __( 'Workouts', 'lsx-health-plan' ),
468
-					'id'         => 'connected_workouts',
469
-					'desc'       => __( 'Connect the workout(s) that apply to this section.', 'lsx-health-plan' ),
470
-					'type'       => 'post_search_ajax',
471
-					'limit'      => 15,
472
-					'sortable'   => true,
473
-					'query_args' => array(
474
-						'post_type'      => array( 'workout' ),
475
-						'post_status'    => array( 'publish' ),
476
-						'posts_per_page' => -1,
477
-					),
478
-					'classes'    => 'lsx-field-col lsx-field-add-field lsx-field-col-50',
479
-				)
480
-			);
481
-			$cmb->add_group_field(
482
-				$group,
483
-				array(
484
-					'name'        => __( 'Rest day', 'lsx-health-plan' ),
485
-					'id'          => 'rest_day_enabled',
486
-					'type'        => 'checkbox',
487
-					'value'       => 1,
488
-					'default'     => 0,
489
-					'description' => __( 'Enabling the rest day will add an item called "Rest" with no links.', 'lsx-health-plan' ),
490
-					'classes'     => 'lsx-field-col lsx-field-add-field lsx-field-col-50',
491
-				)
492
-			);
493
-		}
494
-
495
-		if ( post_type_exists( 'meal' ) ) {
496
-			$cmb->add_group_field(
497
-				$group,
498
-				array(
499
-					'name'       => __( 'Meals', 'lsx-health-plan' ),
500
-					'desc'       => __( 'Connect the meal(s) that apply to this section.', 'lsx-health-plan' ),
501
-					'id'         => 'connected_meals',
502
-					'type'       => 'post_search_ajax',
503
-					// Optional :
504
-					'limit'      => 15, // Limit selection to X items only (default 1)
505
-					'sortable'   => true, // Allow selected items to be sortable (default false)
506
-					'query_args' => array(
507
-						'post_type'      => array( 'meal' ),
508
-						'post_status'    => array( 'publish' ),
509
-						'posts_per_page' => -1,
510
-					),
511
-					'classes'    => 'lsx-field-col lsx-field-add-field  lsx-field-col-50',
512
-				)
513
-			);
514
-		}
515
-		if ( post_type_exists( 'tip' ) ) {
516
-			$cmb->add_group_field(
517
-				$group,
518
-				array(
519
-					'name'       => __( 'Tips', 'lsx-health-plan' ),
520
-					'id'         => 'connected_tips',
521
-					'desc'       => __( 'Connect the tip(s) that apply to this section.', 'lsx-health-plan' ),
522
-					'type'       => 'post_search_ajax',
523
-					// Optional :
524
-					'limit'      => 15,  // Limit selection to X items only (default 1)
525
-					'sortable'   => true,  // Allow selected items to be sortable (default false)
526
-					'query_args' => array(
527
-						'post_type'      => array( 'tip' ),
528
-						'post_status'    => array( 'publish' ),
529
-						'posts_per_page' => -1,
530
-					),
531
-					'classes'    => 'lsx-field-col lsx-field-add-field  lsx-field-col-50',
532
-				)
533
-			);
534
-		}
535
-	}
536
-
537
-	/**
538
-	 * Holds the array for the single plan breadcrumbs.
539
-	 *
540
-	 * @var array $crumbs
541
-	 * @return array
542
-	 */
543
-	public function plan_breadcrumb_filter( $crumbs ) {
544
-		$plan  = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' );
545
-		$plans = \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plan' );
546
-
547
-		if ( is_singular( 'plan' ) ) {	
548
-			$plan_name     = get_the_title();
549
-			$url           = get_post_type_archive_link( $plan );
550
-			$term_obj_list = get_the_terms( get_the_ID(), 'plan-type' );
551
-			$plan_type     = $term_obj_list[0]->name;
552
-			$plan_type_url = get_term_link( $term_obj_list[0]->term_id );
553
-
554
-			$new_crumbs    = array();
555
-			$new_crumbs[0] = $crumbs[0];
556
-
557
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
558
-				$new_crumbs[1] = array(
559
-					0 => $plans,
560
-					1 => $url,
561
-				);
562
-				$new_crumbs[2] = array(
563
-					0 => $plan_type,
564
-					1 => $plan_type_url,
565
-				);
566
-				$new_crumbs[3] = array(
567
-					0 => $plan_name,
568
-				);
569
-			} else {
570
-				$new_crumbs[1] = array(
571
-					'text' => $plans,
572
-					'url'  => $url,
573
-				);
574
-				$new_crumbs[2] = array(
575
-					'text' => $plan_type,
576
-					'url'  => $plan_type_url,
577
-				);
578
-				$new_crumbs[3] = array(
579
-					'text' => $plan_name,
580
-				);
581
-			}
582
-			$crumbs = $new_crumbs;
583
-
584
-		}
585
-		if ( is_post_type_archive( 'plan' ) ) {
586
-
587
-			$new_crumbs    = array();
588
-			$new_crumbs[0] = $crumbs[0];
589
-
590
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
591
-				$new_crumbs[1] = array(
592
-					0 => $plans,
593
-				);
594
-			} else {
595
-				$new_crumbs[1] = array(
596
-					'text' => $plans,
597
-				);
598
-			}
599
-			$crumbs = $new_crumbs;
600
-		}
601
-		return $crumbs;
602
-	}
429
+               )
430
+          );
431
+
432
+          $cmb->add_group_field(
433
+               $group,
434
+               array(
435
+                    'name'       => __( 'Title', 'lsx-health-plan' ),
436
+                    'id'         => 'title',
437
+                    'type'       => 'text',
438
+                    'desc'       => __( 'e.g Day 1 / Week 1', 'lsx-health-plan' ),
439
+                    'classes'    => 'lsx-field-col  lsx-field-col-50',
440
+               )
441
+          );
442
+
443
+          $cmb->add_group_field(
444
+               $group,
445
+               array(
446
+                    'name'       => __( 'Group', 'lsx-health-plan' ),
447
+                    'id'         => 'group',
448
+                    'type'       => 'text',
449
+                    'desc'       => __( 'e.g Week 1 / January', 'lsx-health-plan' ),
450
+                    'classes'    => 'lsx-field-col  lsx-field-col-50',
451
+               )
452
+          );
453
+
454
+          $cmb->add_group_field(
455
+               $group,
456
+               array(
457
+                    'name' => __( 'Overview', 'lsx-health-plan' ),
458
+                    'id'   => 'description',
459
+                    'type' => 'wysiwyg',
460
+               )
461
+          );
462
+
463
+          if ( post_type_exists( 'workout' ) ) {
464
+               $cmb->add_group_field(
465
+                    $group,
466
+                    array(
467
+                         'name'       => __( 'Workouts', 'lsx-health-plan' ),
468
+                         'id'         => 'connected_workouts',
469
+                         'desc'       => __( 'Connect the workout(s) that apply to this section.', 'lsx-health-plan' ),
470
+                         'type'       => 'post_search_ajax',
471
+                         'limit'      => 15,
472
+                         'sortable'   => true,
473
+                         'query_args' => array(
474
+                              'post_type'      => array( 'workout' ),
475
+                              'post_status'    => array( 'publish' ),
476
+                              'posts_per_page' => -1,
477
+                         ),
478
+                         'classes'    => 'lsx-field-col lsx-field-add-field lsx-field-col-50',
479
+                    )
480
+               );
481
+               $cmb->add_group_field(
482
+                    $group,
483
+                    array(
484
+                         'name'        => __( 'Rest day', 'lsx-health-plan' ),
485
+                         'id'          => 'rest_day_enabled',
486
+                         'type'        => 'checkbox',
487
+                         'value'       => 1,
488
+                         'default'     => 0,
489
+                         'description' => __( 'Enabling the rest day will add an item called "Rest" with no links.', 'lsx-health-plan' ),
490
+                         'classes'     => 'lsx-field-col lsx-field-add-field lsx-field-col-50',
491
+                    )
492
+               );
493
+          }
494
+
495
+          if ( post_type_exists( 'meal' ) ) {
496
+               $cmb->add_group_field(
497
+                    $group,
498
+                    array(
499
+                         'name'       => __( 'Meals', 'lsx-health-plan' ),
500
+                         'desc'       => __( 'Connect the meal(s) that apply to this section.', 'lsx-health-plan' ),
501
+                         'id'         => 'connected_meals',
502
+                         'type'       => 'post_search_ajax',
503
+                         // Optional :
504
+                         'limit'      => 15, // Limit selection to X items only (default 1)
505
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
506
+                         'query_args' => array(
507
+                              'post_type'      => array( 'meal' ),
508
+                              'post_status'    => array( 'publish' ),
509
+                              'posts_per_page' => -1,
510
+                         ),
511
+                         'classes'    => 'lsx-field-col lsx-field-add-field  lsx-field-col-50',
512
+                    )
513
+               );
514
+          }
515
+          if ( post_type_exists( 'tip' ) ) {
516
+               $cmb->add_group_field(
517
+                    $group,
518
+                    array(
519
+                         'name'       => __( 'Tips', 'lsx-health-plan' ),
520
+                         'id'         => 'connected_tips',
521
+                         'desc'       => __( 'Connect the tip(s) that apply to this section.', 'lsx-health-plan' ),
522
+                         'type'       => 'post_search_ajax',
523
+                         // Optional :
524
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
525
+                         'sortable'   => true,  // Allow selected items to be sortable (default false)
526
+                         'query_args' => array(
527
+                              'post_type'      => array( 'tip' ),
528
+                              'post_status'    => array( 'publish' ),
529
+                              'posts_per_page' => -1,
530
+                         ),
531
+                         'classes'    => 'lsx-field-col lsx-field-add-field  lsx-field-col-50',
532
+                    )
533
+               );
534
+          }
535
+     }
536
+
537
+     /**
538
+      * Holds the array for the single plan breadcrumbs.
539
+      *
540
+      * @var array $crumbs
541
+      * @return array
542
+      */
543
+     public function plan_breadcrumb_filter( $crumbs ) {
544
+          $plan  = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' );
545
+          $plans = \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plan' );
546
+
547
+          if ( is_singular( 'plan' ) ) {	
548
+               $plan_name     = get_the_title();
549
+               $url           = get_post_type_archive_link( $plan );
550
+               $term_obj_list = get_the_terms( get_the_ID(), 'plan-type' );
551
+               $plan_type     = $term_obj_list[0]->name;
552
+               $plan_type_url = get_term_link( $term_obj_list[0]->term_id );
553
+
554
+               $new_crumbs    = array();
555
+               $new_crumbs[0] = $crumbs[0];
556
+
557
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
558
+                    $new_crumbs[1] = array(
559
+                         0 => $plans,
560
+                         1 => $url,
561
+                    );
562
+                    $new_crumbs[2] = array(
563
+                         0 => $plan_type,
564
+                         1 => $plan_type_url,
565
+                    );
566
+                    $new_crumbs[3] = array(
567
+                         0 => $plan_name,
568
+                    );
569
+               } else {
570
+                    $new_crumbs[1] = array(
571
+                         'text' => $plans,
572
+                         'url'  => $url,
573
+                    );
574
+                    $new_crumbs[2] = array(
575
+                         'text' => $plan_type,
576
+                         'url'  => $plan_type_url,
577
+                    );
578
+                    $new_crumbs[3] = array(
579
+                         'text' => $plan_name,
580
+                    );
581
+               }
582
+               $crumbs = $new_crumbs;
583
+
584
+          }
585
+          if ( is_post_type_archive( 'plan' ) ) {
586
+
587
+               $new_crumbs    = array();
588
+               $new_crumbs[0] = $crumbs[0];
589
+
590
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
591
+                    $new_crumbs[1] = array(
592
+                         0 => $plans,
593
+                    );
594
+               } else {
595
+                    $new_crumbs[1] = array(
596
+                         'text' => $plans,
597
+                    );
598
+               }
599
+               $crumbs = $new_crumbs;
600
+          }
601
+          return $crumbs;
602
+     }
603 603
 }
Please login to merge, or discard this patch.
Spacing   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -33,39 +33,39 @@  discard block
 block discarded – undo
33 33
 	 */
34 34
 	public function __construct() {
35 35
 
36
-		add_action( 'init', array( $this, 'register_post_type' ) );
37
-		add_action( 'init', array( $this, 'plan_type_taxonomy_setup' ) );
38
-		add_action( 'init', array( $this, 'week_taxonomy_setup' ) );
36
+		add_action('init', array($this, 'register_post_type'));
37
+		add_action('init', array($this, 'plan_type_taxonomy_setup'));
38
+		add_action('init', array($this, 'week_taxonomy_setup'));
39 39
 
40 40
 		// Icons for the plan types.
41
-		add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 );
42
-		add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 );
41
+		add_action('create_term', array($this, 'save_meta'), 10, 2);
42
+		add_action('edit_term', array($this, 'save_meta'), 10, 2);
43 43
 		$prefix_taxonomy = 'plan-type';
44
-		add_action( sprintf( '%s_edit_form_fields', $prefix_taxonomy ), array( $this, 'add_thumbnail_form_field' ), 3, 1 );
44
+		add_action(sprintf('%s_edit_form_fields', $prefix_taxonomy), array($this, 'add_thumbnail_form_field'), 3, 1);
45 45
 
46 46
 		// Register the Metaboxes.
47
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
48
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ), 5 );
49
-		add_action( 'cmb2_admin_init', array( $this, 'plan_connections' ), 5 );
50
-		add_action( 'cmb2_admin_init', array( $this, 'sections_metabox_loop' ), 1 );
47
+		add_action('cmb2_admin_init', array($this, 'featured_metabox'), 5);
48
+		add_action('cmb2_admin_init', array($this, 'details_metaboxes'), 5);
49
+		add_action('cmb2_admin_init', array($this, 'plan_connections'), 5);
50
+		add_action('cmb2_admin_init', array($this, 'sections_metabox_loop'), 1);
51 51
 
52
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
52
+		add_filter('get_the_archive_title', array($this, 'get_the_archive_title'), 100);
53 53
 		//add_filter( 'lsx_global_header_title', array( $this, 'hp_recipe_header_title' ), 200, 1 );
54 54
 
55 55
 		// Template Redirects.
56
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
57
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
56
+		add_filter('lsx_health_plan_archive_template', array($this, 'enable_post_type'), 10, 1);
57
+		add_filter('lsx_health_plan_single_template', array($this, 'enable_post_type'), 10, 1);
58 58
 
59 59
 		// Plan Archive Actions.
60
-		add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
61
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
62
-		add_action( 'lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1 );
63
-		add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1 );
64
-		add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_filters_disabled', 10, 1 );
60
+		add_action('pre_get_posts', array($this, 'set_parent_only'), 10, 1);
61
+		add_filter('get_the_archive_title', array($this, 'get_the_archive_title'), 100);
62
+		add_action('lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1);
63
+		add_filter('lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1);
64
+		add_filter('lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_filters_disabled', 10, 1);
65 65
 
66 66
 		//Breadcrumbs
67
-		add_filter( 'wpseo_breadcrumb_links', array( $this, 'plan_breadcrumb_filter' ), 30, 1 );
68
-		add_filter( 'woocommerce_get_breadcrumb', array( $this, 'plan_breadcrumb_filter' ), 30, 1 );
67
+		add_filter('wpseo_breadcrumb_links', array($this, 'plan_breadcrumb_filter'), 30, 1);
68
+		add_filter('woocommerce_get_breadcrumb', array($this, 'plan_breadcrumb_filter'), 30, 1);
69 69
 		
70 70
 	}
71 71
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public static function get_instance() {
80 80
 		// If the single instance hasn't been set, set it now.
81
-		if ( null === self::$instance ) {
81
+		if (null === self::$instance) {
82 82
 			self::$instance = new self();
83 83
 		}
84 84
 		return self::$instance;
@@ -88,21 +88,21 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function register_post_type() {
90 90
 		$labels = array(
91
-			'name'               => esc_html__( 'Plans', 'lsx-health-plan' ),
92
-			'singular_name'      => esc_html__( 'Plan', 'lsx-health-plan' ),
93
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
94
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
95
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
96
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
97
-			'all_items'          => esc_html__( 'All Plans', 'lsx-health-plan' ),
98
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
99
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
100
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
101
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
102
-			'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
103
-			'menu_name'          => esc_html__( 'Plans', 'lsx-health-plan' ),
91
+			'name'               => esc_html__('Plans', 'lsx-health-plan'),
92
+			'singular_name'      => esc_html__('Plan', 'lsx-health-plan'),
93
+			'add_new'            => esc_html_x('Add New', 'post type general name', 'lsx-health-plan'),
94
+			'add_new_item'       => esc_html__('Add New', 'lsx-health-plan'),
95
+			'edit_item'          => esc_html__('Edit', 'lsx-health-plan'),
96
+			'new_item'           => esc_html__('New', 'lsx-health-plan'),
97
+			'all_items'          => esc_html__('All Plans', 'lsx-health-plan'),
98
+			'view_item'          => esc_html__('View', 'lsx-health-plan'),
99
+			'search_items'       => esc_html__('Search', 'lsx-health-plan'),
100
+			'not_found'          => esc_html__('None found', 'lsx-health-plan'),
101
+			'not_found_in_trash' => esc_html__('None found in Trash', 'lsx-health-plan'),
102
+			'parent_item_colon'  => esc_html__('Parent:', 'lsx-health-plan'),
103
+			'menu_name'          => esc_html__('Plans', 'lsx-health-plan'),
104 104
 		);
105
-		$args   = array(
105
+		$args = array(
106 106
 			'labels'             => $labels,
107 107
 			'public'             => true,
108 108
 			'publicly_queryable' => true,
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 			'menu_icon'          => 'dashicons-welcome-write-blog',
113 113
 			'query_var'          => true,
114 114
 			'rewrite'            => array(
115
-				'slug' => \lsx_health_plan\functions\get_option( 'plan_single_slug', 'plan' ),
115
+				'slug' => \lsx_health_plan\functions\get_option('plan_single_slug', 'plan'),
116 116
 			),
117 117
 			'capability_type'    => 'page',
118
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plans' ),
118
+			'has_archive'        => \lsx_health_plan\functions\get_option('endpoint_plan_archive', 'plans'),
119 119
 			'hierarchical'       => false,
120 120
 			'menu_position'      => null,
121 121
 			'supports'           => array(
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 				'custom-fields',
127 127
 			),
128 128
 		);
129
-		register_post_type( 'plan', $args );
129
+		register_post_type('plan', $args);
130 130
 	}
131 131
 
132 132
 	/**
@@ -134,17 +134,17 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public function plan_type_taxonomy_setup() {
136 136
 		$labels = array(
137
-			'name'              => esc_html_x( 'Plan Type', 'taxonomy general name', 'lsx-health-plan' ),
138
-			'singular_name'     => esc_html_x( 'Plan Type', 'taxonomy singular name', 'lsx-health-plan' ),
139
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
140
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
141
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
142
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
143
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
144
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
145
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
146
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
147
-			'menu_name'         => esc_html__( 'Plan Types', 'lsx-health-plan' ),
137
+			'name'              => esc_html_x('Plan Type', 'taxonomy general name', 'lsx-health-plan'),
138
+			'singular_name'     => esc_html_x('Plan Type', 'taxonomy singular name', 'lsx-health-plan'),
139
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
140
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
141
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
142
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
143
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
144
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
145
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
146
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
147
+			'menu_name'         => esc_html__('Plan Types', 'lsx-health-plan'),
148 148
 		);
149 149
 
150 150
 		$args = array(
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			),
159 159
 		);
160 160
 
161
-		register_taxonomy( 'plan-type', array( 'plan' ), $args );
161
+		register_taxonomy('plan-type', array('plan'), $args);
162 162
 	}
163 163
 
164 164
 	/**
@@ -166,17 +166,17 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	public function week_taxonomy_setup() {
168 168
 		$labels = array(
169
-			'name'              => esc_html_x( 'Week', 'taxonomy general name', 'lsx-health-plan' ),
170
-			'singular_name'     => esc_html_x( 'Week', 'taxonomy singular name', 'lsx-health-plan' ),
171
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
172
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
173
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
174
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
175
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
176
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
177
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
178
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
179
-			'menu_name'         => esc_html__( 'Weeks', 'lsx-health-plan' ),
169
+			'name'              => esc_html_x('Week', 'taxonomy general name', 'lsx-health-plan'),
170
+			'singular_name'     => esc_html_x('Week', 'taxonomy singular name', 'lsx-health-plan'),
171
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
172
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
173
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
174
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
175
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
176
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
177
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
178
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
179
+			'menu_name'         => esc_html__('Weeks', 'lsx-health-plan'),
180 180
 		);
181 181
 
182 182
 		$args = array(
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 			),
192 192
 		);
193 193
 
194
-		register_taxonomy( 'week', array( 'plan' ), $args );
194
+		register_taxonomy('week', array('plan'), $args);
195 195
 	}
196 196
 
197 197
 	/**
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @since 0.1.0
201 201
 	 */
202
-	public function add_thumbnail_form_field( $term = false ) {
203
-		if ( is_object( $term ) ) {
204
-			$value         = get_term_meta( $term->term_id, 'thumbnail', true );
205
-			$image_preview = wp_get_attachment_image_src( $value, 'thumbnail' );
202
+	public function add_thumbnail_form_field($term = false) {
203
+		if (is_object($term)) {
204
+			$value         = get_term_meta($term->term_id, 'thumbnail', true);
205
+			$image_preview = wp_get_attachment_image_src($value, 'thumbnail');
206 206
 
207
-			if ( is_array( $image_preview ) ) {
208
-				$image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url( $image_preview[0] ) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />';
207
+			if (is_array($image_preview)) {
208
+				$image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url($image_preview[0]) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />';
209 209
 			}
210 210
 		} else {
211 211
 			$image_preview = false;
@@ -213,15 +213,15 @@  discard block
 block discarded – undo
213 213
 		}
214 214
 		?>
215 215
 		<tr class="form-field form-required term-thumbnail-wrap">
216
-			<th scope="row"><label for="thumbnail"><?php esc_html_e( 'Icon Image', 'lsx-health-plan' ); ?></label></th>
216
+			<th scope="row"><label for="thumbnail"><?php esc_html_e('Icon Image', 'lsx-health-plan'); ?></label></th>
217 217
 			<td>
218
-				<input class="input_image_id" type="hidden" name="thumbnail" value="<?php echo wp_kses_post( $value ); ?>">
218
+				<input class="input_image_id" type="hidden" name="thumbnail" value="<?php echo wp_kses_post($value); ?>">
219 219
 				<div class="thumbnail-preview">
220
-					<?php echo wp_kses_post( $image_preview ); ?>
220
+					<?php echo wp_kses_post($image_preview); ?>
221 221
 				</div>
222
-				<a style="<?php if ( '' !== $value && false !== $value ) { ?>display:none;<?php } ?>" class="button-secondary lsx-thumbnail-image-add"><?php esc_html_e( 'Choose Image', 'lsx-health-plan' ); ?></a>
223
-				<a style="<?php if ( '' === $value || false === $value ) { ?>display:none;<?php } ?>" class="button-secondary lsx-thumbnail-image-remove"><?php esc_html_e( 'Remove Image', 'lsx-health-plan' ); ?></a>
224
-				<?php wp_nonce_field( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ); ?>
222
+				<a style="<?php if ('' !== $value && false !== $value) { ?>display:none;<?php } ?>" class="button-secondary lsx-thumbnail-image-add"><?php esc_html_e('Choose Image', 'lsx-health-plan'); ?></a>
223
+				<a style="<?php if ('' === $value || false === $value) { ?>display:none;<?php } ?>" class="button-secondary lsx-thumbnail-image-remove"><?php esc_html_e('Remove Image', 'lsx-health-plan'); ?></a>
224
+				<?php wp_nonce_field('lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce'); ?>
225 225
 			</td>
226 226
 		</tr>
227 227
 		<?php
@@ -235,27 +235,27 @@  discard block
 block discarded – undo
235 235
 	 * @param  int    $term_id
236 236
 	 * @param  string $taxonomy
237 237
 	 */
238
-	public function save_meta( $term_id = 0, $taxonomy = '' ) {
239
-		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
238
+	public function save_meta($term_id = 0, $taxonomy = '') {
239
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
240 240
 			return;
241 241
 		}
242 242
 
243
-		if ( ! isset( $_POST['thumbnail'] ) ) {
243
+		if ( ! isset($_POST['thumbnail'])) {
244 244
 			return;
245 245
 		}
246 246
 
247
-		if ( check_admin_referer( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ) ) {
248
-			if ( ! isset( $_POST['thumbnail'] ) ) {
247
+		if (check_admin_referer('lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce')) {
248
+			if ( ! isset($_POST['thumbnail'])) {
249 249
 				return;
250 250
 			}
251 251
 
252
-			$thumbnail_meta = sanitize_text_field( $_POST['thumbnail'] );
253
-			$thumbnail_meta = ! empty( $thumbnail_meta ) ? $thumbnail_meta : '';
252
+			$thumbnail_meta = sanitize_text_field($_POST['thumbnail']);
253
+			$thumbnail_meta = ! empty($thumbnail_meta) ? $thumbnail_meta : '';
254 254
 
255
-			if ( empty( $thumbnail_meta ) ) {
256
-				delete_term_meta( $term_id, 'thumbnail' );
255
+			if (empty($thumbnail_meta)) {
256
+				delete_term_meta($term_id, 'thumbnail');
257 257
 			} else {
258
-				update_term_meta( $term_id, 'thumbnail', $thumbnail_meta );
258
+				update_term_meta($term_id, 'thumbnail', $thumbnail_meta);
259 259
 			}
260 260
 		}
261 261
 	}
@@ -264,40 +264,40 @@  discard block
 block discarded – undo
264 264
 	 * Define the metabox and field configurations.
265 265
 	 */
266 266
 	public function details_metaboxes() {
267
-		$cmb = new_cmb2_box( array(
267
+		$cmb = new_cmb2_box(array(
268 268
 			'id'           => $this->slug . '_details_metabox',
269
-			'title'        => __( 'Details', 'lsx-health-plan' ),
270
-			'object_types' => array( $this->slug ), // Post type
269
+			'title'        => __('Details', 'lsx-health-plan'),
270
+			'object_types' => array($this->slug), // Post type
271 271
 			'context'      => 'normal',
272 272
 			'priority'     => 'high',
273 273
 			'show_names'   => true,
274
-		) );
274
+		));
275 275
 
276
-		$cmb->add_field( array(
277
-			'name' => __( 'Plan Short Description', 'lsx-health-plan' ),
276
+		$cmb->add_field(array(
277
+			'name' => __('Plan Short Description', 'lsx-health-plan'),
278 278
 			'id'   => $this->slug . '_short_description',
279 279
 			'type' => 'textarea_small',
280
-			'desc' => __( 'Add a small description for this plan (optional)', 'lsx-health-plan' ),
281
-		) );
280
+			'desc' => __('Add a small description for this plan (optional)', 'lsx-health-plan'),
281
+		));
282 282
 
283 283
 		$warmup_type = 'page';
284
-		if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
285
-			$warmup_type = array( 'page', 'workout' );
284
+		if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) {
285
+			$warmup_type = array('page', 'workout');
286 286
 		}
287
-		$cmb->add_field( array(
288
-			'name'       => __( 'Warmup', 'lsx-health-plan' ),
289
-			'desc'       => __( 'Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan' ),
287
+		$cmb->add_field(array(
288
+			'name'       => __('Warmup', 'lsx-health-plan'),
289
+			'desc'       => __('Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan'),
290 290
 			'id'         => $this->slug . '_warmup',
291 291
 			'type'       => 'post_search_ajax',
292 292
 			// Optional :
293
-			'limit'      => 3,  // Limit selection to X items only (default 1)
293
+			'limit'      => 3, // Limit selection to X items only (default 1)
294 294
 			'sortable'   => true, // Allow selected items to be sortable (default false)
295 295
 			'query_args' => array(
296 296
 				'post_type'      => $warmup_type,
297
-				'post_status'    => array( 'publish' ),
297
+				'post_status'    => array('publish'),
298 298
 				'posts_per_page' => -1,
299 299
 			),
300
-		) );
300
+		));
301 301
 	}
302 302
 
303 303
 	/**
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * @param array $post_types
307 307
 	 * @return array
308 308
 	 */
309
-	public function enable_post_type( $post_types = array() ) {
309
+	public function enable_post_type($post_types = array()) {
310 310
 		$post_types[] = $this->slug;
311 311
 		return $post_types;
312 312
 	}
@@ -320,8 +320,8 @@  discard block
 block discarded – undo
320 320
 		$cmb = new_cmb2_box(
321 321
 			array(
322 322
 				'id'           => $this->slug . '_connections_metabox',
323
-				'title'        => __( 'Plans', 'lsx-health-plan' ),
324
-				'object_types' => array( 'workout', 'meal', 'tip', 'recipe' ),
323
+				'title'        => __('Plans', 'lsx-health-plan'),
324
+				'object_types' => array('workout', 'meal', 'tip', 'recipe'),
325 325
 				'context'      => 'normal',
326 326
 				'priority'     => 'high',
327 327
 				'show_names'   => true,
@@ -329,15 +329,15 @@  discard block
 block discarded – undo
329 329
 		);
330 330
 		$cmb->add_field(
331 331
 			array(
332
-				'name'       => __( 'Plan', 'lsx-health-plan' ),
332
+				'name'       => __('Plan', 'lsx-health-plan'),
333 333
 				'id'         => 'connected_plans',
334
-				'desc'       => __( 'Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan' ),
334
+				'desc'       => __('Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan'),
335 335
 				'type'       => 'post_search_ajax',
336 336
 				'limit'      => 15,
337 337
 				'sortable'   => true,
338 338
 				'query_args' => array(
339
-					'post_type'      => array( 'plan' ),
340
-					'post_status'    => array( 'publish' ),
339
+					'post_type'      => array('plan'),
340
+					'post_status'    => array('publish'),
341 341
 					'posts_per_page' => -1,
342 342
 				),
343 343
 			)
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
 	 * @param string $title the term title.
351 351
 	 * @return string
352 352
 	 */
353
-	public function get_the_archive_title( $title ) {
354
-		if ( is_post_type_archive( 'plan' ) ) {
355
-			$title = __( 'Our health plans', 'lsx-health-plan' );
353
+	public function get_the_archive_title($title) {
354
+		if (is_post_type_archive('plan')) {
355
+			$title = __('Our health plans', 'lsx-health-plan');
356 356
 		}
357 357
 		return $title;
358 358
 	}
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
 	 * @param object $wp_query
364 364
 	 * @return array
365 365
 	 */
366
-	public function set_parent_only( $wp_query ) {
367
-		if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'plan' ) || $wp_query->is_tax( 'plan-type' ) ) ) {
368
-			$wp_query->set( 'post_parent', '0' );
366
+	public function set_parent_only($wp_query) {
367
+		if ( ! is_admin() && $wp_query->is_main_query() && ($wp_query->is_post_type_archive('plan') || $wp_query->is_tax('plan-type'))) {
368
+			$wp_query->set('post_parent', '0');
369 369
 		}
370 370
 	}
371 371
 
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 		$cmb = new_cmb2_box(
377 377
 			array(
378 378
 				'id'           => $this->slug . '_featured_metabox_plan',
379
-				'title'        => __( 'Featured Plan', 'lsx-health-plan' ),
380
-				'object_types' => array( $this->slug ), // Post type
379
+				'title'        => __('Featured Plan', 'lsx-health-plan'),
380
+				'object_types' => array($this->slug), // Post type
381 381
 				'context'      => 'side',
382 382
 				'priority'     => 'high',
383 383
 				'show_names'   => true,
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
 		);
386 386
 		$cmb->add_field(
387 387
 			array(
388
-				'name'       => __( 'Featured Plan', 'lsx-health-plan' ),
389
-				'desc'       => __( 'Enable a featured plan' ),
388
+				'name'       => __('Featured Plan', 'lsx-health-plan'),
389
+				'desc'       => __('Enable a featured plan'),
390 390
 				'id'         => $this->slug . '_featured_plan',
391 391
 				'type'       => 'checkbox',
392 392
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
 		$cmb = new_cmb2_box(
402 402
 			array(
403 403
 				'id'           => $this->slug . '_sections_metabox',
404
-				'title'        => __( 'Sections', 'lsx-health-plan' ),
405
-				'object_types' => array( $this->slug ), // Post type.
404
+				'title'        => __('Sections', 'lsx-health-plan'),
405
+				'object_types' => array($this->slug), // Post type.
406 406
 				'context'      => 'normal',
407 407
 				'priority'     => 'low',
408 408
 				'show_names'   => true,
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 				'id'      => $this->slug . '_sections',
419 419
 				'type'    => 'group',
420 420
 				'options' => array(
421
-					'group_title'   => __( 'Section', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
422
-					'add_button'    => __( 'Add section', 'lsx-health-plan' ),
423
-					'remove_button' => __( 'Remove section', 'lsx-health-plan' ),
421
+					'group_title'   => __('Section', 'lsx-health-plan') . ' {#}', // {#} gets replaced by row number
422
+					'add_button'    => __('Add section', 'lsx-health-plan'),
423
+					'remove_button' => __('Remove section', 'lsx-health-plan'),
424 424
 					'sortable'      => true,
425 425
 					'closed'        => true, // true to have the groups closed by default
426 426
 				),
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
 		$cmb->add_group_field(
433 433
 			$group,
434 434
 			array(
435
-				'name'       => __( 'Title', 'lsx-health-plan' ),
435
+				'name'       => __('Title', 'lsx-health-plan'),
436 436
 				'id'         => 'title',
437 437
 				'type'       => 'text',
438
-				'desc'       => __( 'e.g Day 1 / Week 1', 'lsx-health-plan' ),
438
+				'desc'       => __('e.g Day 1 / Week 1', 'lsx-health-plan'),
439 439
 				'classes'    => 'lsx-field-col  lsx-field-col-50',
440 440
 			)
441 441
 		);
@@ -443,10 +443,10 @@  discard block
 block discarded – undo
443 443
 		$cmb->add_group_field(
444 444
 			$group,
445 445
 			array(
446
-				'name'       => __( 'Group', 'lsx-health-plan' ),
446
+				'name'       => __('Group', 'lsx-health-plan'),
447 447
 				'id'         => 'group',
448 448
 				'type'       => 'text',
449
-				'desc'       => __( 'e.g Week 1 / January', 'lsx-health-plan' ),
449
+				'desc'       => __('e.g Week 1 / January', 'lsx-health-plan'),
450 450
 				'classes'    => 'lsx-field-col  lsx-field-col-50',
451 451
 			)
452 452
 		);
@@ -454,25 +454,25 @@  discard block
 block discarded – undo
454 454
 		$cmb->add_group_field(
455 455
 			$group,
456 456
 			array(
457
-				'name' => __( 'Overview', 'lsx-health-plan' ),
457
+				'name' => __('Overview', 'lsx-health-plan'),
458 458
 				'id'   => 'description',
459 459
 				'type' => 'wysiwyg',
460 460
 			)
461 461
 		);
462 462
 
463
-		if ( post_type_exists( 'workout' ) ) {
463
+		if (post_type_exists('workout')) {
464 464
 			$cmb->add_group_field(
465 465
 				$group,
466 466
 				array(
467
-					'name'       => __( 'Workouts', 'lsx-health-plan' ),
467
+					'name'       => __('Workouts', 'lsx-health-plan'),
468 468
 					'id'         => 'connected_workouts',
469
-					'desc'       => __( 'Connect the workout(s) that apply to this section.', 'lsx-health-plan' ),
469
+					'desc'       => __('Connect the workout(s) that apply to this section.', 'lsx-health-plan'),
470 470
 					'type'       => 'post_search_ajax',
471 471
 					'limit'      => 15,
472 472
 					'sortable'   => true,
473 473
 					'query_args' => array(
474
-						'post_type'      => array( 'workout' ),
475
-						'post_status'    => array( 'publish' ),
474
+						'post_type'      => array('workout'),
475
+						'post_status'    => array('publish'),
476 476
 						'posts_per_page' => -1,
477 477
 					),
478 478
 					'classes'    => 'lsx-field-col lsx-field-add-field lsx-field-col-50',
@@ -481,51 +481,51 @@  discard block
 block discarded – undo
481 481
 			$cmb->add_group_field(
482 482
 				$group,
483 483
 				array(
484
-					'name'        => __( 'Rest day', 'lsx-health-plan' ),
484
+					'name'        => __('Rest day', 'lsx-health-plan'),
485 485
 					'id'          => 'rest_day_enabled',
486 486
 					'type'        => 'checkbox',
487 487
 					'value'       => 1,
488 488
 					'default'     => 0,
489
-					'description' => __( 'Enabling the rest day will add an item called "Rest" with no links.', 'lsx-health-plan' ),
489
+					'description' => __('Enabling the rest day will add an item called "Rest" with no links.', 'lsx-health-plan'),
490 490
 					'classes'     => 'lsx-field-col lsx-field-add-field lsx-field-col-50',
491 491
 				)
492 492
 			);
493 493
 		}
494 494
 
495
-		if ( post_type_exists( 'meal' ) ) {
495
+		if (post_type_exists('meal')) {
496 496
 			$cmb->add_group_field(
497 497
 				$group,
498 498
 				array(
499
-					'name'       => __( 'Meals', 'lsx-health-plan' ),
500
-					'desc'       => __( 'Connect the meal(s) that apply to this section.', 'lsx-health-plan' ),
499
+					'name'       => __('Meals', 'lsx-health-plan'),
500
+					'desc'       => __('Connect the meal(s) that apply to this section.', 'lsx-health-plan'),
501 501
 					'id'         => 'connected_meals',
502 502
 					'type'       => 'post_search_ajax',
503 503
 					// Optional :
504 504
 					'limit'      => 15, // Limit selection to X items only (default 1)
505 505
 					'sortable'   => true, // Allow selected items to be sortable (default false)
506 506
 					'query_args' => array(
507
-						'post_type'      => array( 'meal' ),
508
-						'post_status'    => array( 'publish' ),
507
+						'post_type'      => array('meal'),
508
+						'post_status'    => array('publish'),
509 509
 						'posts_per_page' => -1,
510 510
 					),
511 511
 					'classes'    => 'lsx-field-col lsx-field-add-field  lsx-field-col-50',
512 512
 				)
513 513
 			);
514 514
 		}
515
-		if ( post_type_exists( 'tip' ) ) {
515
+		if (post_type_exists('tip')) {
516 516
 			$cmb->add_group_field(
517 517
 				$group,
518 518
 				array(
519
-					'name'       => __( 'Tips', 'lsx-health-plan' ),
519
+					'name'       => __('Tips', 'lsx-health-plan'),
520 520
 					'id'         => 'connected_tips',
521
-					'desc'       => __( 'Connect the tip(s) that apply to this section.', 'lsx-health-plan' ),
521
+					'desc'       => __('Connect the tip(s) that apply to this section.', 'lsx-health-plan'),
522 522
 					'type'       => 'post_search_ajax',
523 523
 					// Optional :
524
-					'limit'      => 15,  // Limit selection to X items only (default 1)
525
-					'sortable'   => true,  // Allow selected items to be sortable (default false)
524
+					'limit'      => 15, // Limit selection to X items only (default 1)
525
+					'sortable'   => true, // Allow selected items to be sortable (default false)
526 526
 					'query_args' => array(
527
-						'post_type'      => array( 'tip' ),
528
-						'post_status'    => array( 'publish' ),
527
+						'post_type'      => array('tip'),
528
+						'post_status'    => array('publish'),
529 529
 						'posts_per_page' => -1,
530 530
 					),
531 531
 					'classes'    => 'lsx-field-col lsx-field-add-field  lsx-field-col-50',
@@ -540,21 +540,21 @@  discard block
 block discarded – undo
540 540
 	 * @var array $crumbs
541 541
 	 * @return array
542 542
 	 */
543
-	public function plan_breadcrumb_filter( $crumbs ) {
544
-		$plan  = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' );
545
-		$plans = \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plan' );
543
+	public function plan_breadcrumb_filter($crumbs) {
544
+		$plan  = \lsx_health_plan\functions\get_option('endpoint_plan', 'plan');
545
+		$plans = \lsx_health_plan\functions\get_option('endpoint_plan_archive', 'plan');
546 546
 
547
-		if ( is_singular( 'plan' ) ) {	
547
+		if (is_singular('plan')) {	
548 548
 			$plan_name     = get_the_title();
549
-			$url           = get_post_type_archive_link( $plan );
550
-			$term_obj_list = get_the_terms( get_the_ID(), 'plan-type' );
549
+			$url           = get_post_type_archive_link($plan);
550
+			$term_obj_list = get_the_terms(get_the_ID(), 'plan-type');
551 551
 			$plan_type     = $term_obj_list[0]->name;
552
-			$plan_type_url = get_term_link( $term_obj_list[0]->term_id );
552
+			$plan_type_url = get_term_link($term_obj_list[0]->term_id);
553 553
 
554 554
 			$new_crumbs    = array();
555 555
 			$new_crumbs[0] = $crumbs[0];
556 556
 
557
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
557
+			if (function_exists('woocommerce_breadcrumb')) {
558 558
 				$new_crumbs[1] = array(
559 559
 					0 => $plans,
560 560
 					1 => $url,
@@ -582,12 +582,12 @@  discard block
 block discarded – undo
582 582
 			$crumbs = $new_crumbs;
583 583
 
584 584
 		}
585
-		if ( is_post_type_archive( 'plan' ) ) {
585
+		if (is_post_type_archive('plan')) {
586 586
 
587 587
 			$new_crumbs    = array();
588 588
 			$new_crumbs[0] = $crumbs[0];
589 589
 
590
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
590
+			if (function_exists('woocommerce_breadcrumb')) {
591 591
 				$new_crumbs[1] = array(
592 592
 					0 => $plans,
593 593
 				);
Please login to merge, or discard this patch.