Passed
Push — add/multiplan ( 1aa344...57784a )
by Virginia
03:47 queued 10s
created
templates/content-archive-workout.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
 			<?php } ?>
23 23
 			<a href="<?php echo esc_url( get_permalink() ); ?>">
24 24
 			<?php
25
-			$featured_image = get_the_post_thumbnail();
26
-			if ( ! empty( $featured_image ) && '' !== $featured_image ) {
27
-				the_post_thumbnail( 'lsx-thumbnail-square', array(
28
-					'class' => 'aligncenter',
29
-				) );
30
-			} else {
31
-				?>
25
+               $featured_image = get_the_post_thumbnail();
26
+               if ( ! empty( $featured_image ) && '' !== $featured_image ) {
27
+                    the_post_thumbnail( 'lsx-thumbnail-square', array(
28
+                         'class' => 'aligncenter',
29
+                    ) );
30
+               } else {
31
+                    ?>
32 32
 				<img loading="lazy" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
33 33
 				<?php
34
-			}
35
-			?>
34
+               }
35
+               ?>
36 36
 			</a>
37 37
 		</div>
38 38
 		<div class="content-box workout-content-box white-bg">
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 				<?php the_title( '<h3 class="workout-title">', '</h3>' ); ?>
41 41
 			</a>
42 42
 			<?php
43
-			if ( ! has_excerpt() ) {
44
-				$content = wp_trim_words( get_the_content(), 20 );
45
-				$content = '<p>' . $content . '</p>';
46
-			} else {
47
-				$content = apply_filters( 'the_excerpt', get_the_excerpt() );
48
-			}
49
-			echo wp_kses_post( $content );
50
-			?>
43
+               if ( ! has_excerpt() ) {
44
+                    $content = wp_trim_words( get_the_content(), 20 );
45
+                    $content = '<p>' . $content . '</p>';
46
+               } else {
47
+                    $content = apply_filters( 'the_excerpt', get_the_excerpt() );
48
+               }
49
+               echo wp_kses_post( $content );
50
+               ?>
51 51
 			<a href="<?php echo esc_url( get_permalink() ); ?>" class="btn border-btn"><?php esc_html_e( 'See workout', 'lsx-health-plan' ); ?></a>
52 52
 		</div>
53 53
 		<?php lsx_entry_bottom(); ?>
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @package lsx-health-plan
6 6
  */
7 7
 
8
-$featured = get_post_meta( get_the_ID(), 'workout_featured_workout', true );
8
+$featured = get_post_meta(get_the_ID(), 'workout_featured_workout', true);
9 9
 ?>
10 10
 
11 11
 <?php lsx_entry_before(); ?>
@@ -17,38 +17,38 @@  discard block
 block discarded – undo
17 17
 		<?php lsx_hp_exercise_plan_meta(); ?>
18 18
 
19 19
 		<div class="workout-feature-img">
20
-			<?php if ( $featured ) { ?>
21
-				<span class="featured-workout"><?php lsx_get_svg_icon( 'icon-featured.svg' ); ?></span>
20
+			<?php if ($featured) { ?>
21
+				<span class="featured-workout"><?php lsx_get_svg_icon('icon-featured.svg'); ?></span>
22 22
 			<?php } ?>
23
-			<a href="<?php echo esc_url( get_permalink() ); ?>">
23
+			<a href="<?php echo esc_url(get_permalink()); ?>">
24 24
 			<?php
25 25
 			$featured_image = get_the_post_thumbnail();
26
-			if ( ! empty( $featured_image ) && '' !== $featured_image ) {
27
-				the_post_thumbnail( 'lsx-thumbnail-square', array(
26
+			if ( ! empty($featured_image) && '' !== $featured_image) {
27
+				the_post_thumbnail('lsx-thumbnail-square', array(
28 28
 					'class' => 'aligncenter',
29
-				) );
29
+				));
30 30
 			} else {
31 31
 				?>
32
-				<img loading="lazy" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
32
+				<img loading="lazy" src="<?php echo esc_attr(plugin_dir_url(__FILE__) . '../assets/images/placeholder.jpg'); ?>">
33 33
 				<?php
34 34
 			}
35 35
 			?>
36 36
 			</a>
37 37
 		</div>
38 38
 		<div class="content-box workout-content-box white-bg">
39
-			<a href="<?php echo esc_url( get_permalink() ); ?>">
40
-				<?php the_title( '<h3 class="workout-title">', '</h3>' ); ?>
39
+			<a href="<?php echo esc_url(get_permalink()); ?>">
40
+				<?php the_title('<h3 class="workout-title">', '</h3>'); ?>
41 41
 			</a>
42 42
 			<?php
43
-			if ( ! has_excerpt() ) {
44
-				$content = wp_trim_words( get_the_content(), 20 );
43
+			if ( ! has_excerpt()) {
44
+				$content = wp_trim_words(get_the_content(), 20);
45 45
 				$content = '<p>' . $content . '</p>';
46 46
 			} else {
47
-				$content = apply_filters( 'the_excerpt', get_the_excerpt() );
47
+				$content = apply_filters('the_excerpt', get_the_excerpt());
48 48
 			}
49
-			echo wp_kses_post( $content );
49
+			echo wp_kses_post($content);
50 50
 			?>
51
-			<a href="<?php echo esc_url( get_permalink() ); ?>" class="btn border-btn"><?php esc_html_e( 'See workout', 'lsx-health-plan' ); ?></a>
51
+			<a href="<?php echo esc_url(get_permalink()); ?>" class="btn border-btn"><?php esc_html_e('See workout', 'lsx-health-plan'); ?></a>
52 52
 		</div>
53 53
 		<?php lsx_entry_bottom(); ?>
54 54
 	</article>
Please login to merge, or discard this patch.
templates/partials/workout-grid.php 2 patches
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 global $group_name,$shortcode_args;
9 9
 $groups = get_post_meta( get_the_ID(), $group_name, true );
10 10
 if ( is_singular( 'workout' ) ) {
11
-	$groups = get_post_meta( get_queried_object_id(), $group_name, true );
11
+     $groups = get_post_meta( get_queried_object_id(), $group_name, true );
12 12
 }
13 13
 
14 14
 $link_setting          = \lsx_health_plan\functions\get_option( 'workout_tab_link', 'single' );
@@ -18,167 +18,167 @@  discard block
 block discarded – undo
18 18
 
19 19
 // Check for shortcode overrides.
20 20
 if ( null !== $shortcode_args ) {
21
-	if ( isset( $shortcode_args['link'] ) ) {
22
-		$link_setting = $shortcode_args['link'];
23
-	}
24
-	if ( isset( $shortcode_args['description'] ) ) {
25
-		$content_setting = $shortcode_args['description'];
26
-	}
27
-	if ( isset( $shortcode_args['columns'] ) ) {
28
-		$column_setting = $shortcode_args['columns'];
29
-		$column_setting = \lsx_health_plan\functions\column_class( $column_setting );
30
-	}
31
-	if ( isset( $shortcode_args['modal_content'] ) ) {
32
-		$modal_content_setting = $shortcode_args['modal_content'];
33
-	}
21
+     if ( isset( $shortcode_args['link'] ) ) {
22
+          $link_setting = $shortcode_args['link'];
23
+     }
24
+     if ( isset( $shortcode_args['description'] ) ) {
25
+          $content_setting = $shortcode_args['description'];
26
+     }
27
+     if ( isset( $shortcode_args['columns'] ) ) {
28
+          $column_setting = $shortcode_args['columns'];
29
+          $column_setting = \lsx_health_plan\functions\column_class( $column_setting );
30
+     }
31
+     if ( isset( $shortcode_args['modal_content'] ) ) {
32
+          $modal_content_setting = $shortcode_args['modal_content'];
33
+     }
34 34
 }
35 35
 
36 36
 $modal_args = array(
37
-	'modal_content' => $modal_content_setting,
37
+     'modal_content' => $modal_content_setting,
38 38
 );
39 39
 
40 40
 $counter = 1;
41 41
 
42 42
 if ( ! empty( $groups ) ) {
43
-	?>
43
+     ?>
44 44
 	<div class="set-grid">
45 45
 		<div class="workout-grid row">
46 46
 			<?php
47
-			foreach ( $groups as $group ) {
48
-				$connected_exercise = false;
49
-				if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) {
50
-					$connected_exercise = true;
51
-				}
52
-
53
-				if ( ! $connected_exercise ) {
54
-					$group['connected_exercises'] = '';
55
-				}
56
-
57
-				if ( ( $connected_exercise ) || ( ( ! $connected_exercise ) && '' !== $group['alt_title'] && isset( $group['alt_title'] ) ) ) {
58
-
59
-					$alt_title = '';
60
-					if ( isset( $group['alt_title'] ) && '' !== $group['alt_title'] ) {
61
-						$alt_title = '<span class="alt-title">' . esc_html( $group['alt_title'] ) . '</span>';
62
-					}
63
-
64
-					$alt_description = '';
65
-					if ( isset( $group['alt_description'] ) && '' !== $group['alt_description'] ) {
66
-						$alt_description = '<span class="alt-description">' . esc_html( $group['alt_description'] ) . '</span>';
67
-					}
68
-
69
-					$alt_image = '';
70
-					if ( isset( $group['exercise_alt_thumbnail'] ) && '' !== $group['exercise_alt_thumbnail'] ) {
71
-						$alt_image = $group['exercise_alt_thumbnail'];
72
-					}
73
-
74
-					$reps = '';
75
-					if ( isset( $group['reps'] ) && '' !== $group['reps'] ) {
76
-						$reps = '<span class="reps">' . esc_html( $group['reps'] ) . '</span>';
77
-					}
78
-					$class_excerpt = 'no-excerpt';
79
-					if ( 'excerpt' === $content_setting ) {
80
-						$class_excerpt = 'has-excerpt';
81
-					}
82
-					// Setup our link and content.
83
-					switch ( $link_setting ) {
84
-						case 'single':
85
-							$link_html  = '<a href="' . get_permalink( $group['connected_exercises'] ) . '">';
86
-							$link_close = '</a>';
87
-							break;
88
-
89
-						case 'modal':
90
-							if ( ( '' !== $alt_title ) || ( '' !== $alt_description ) || ( '' !== $alt_image ) ) {
91
-								$link_html  = '<a class="alt-modal" data-toggle="modal" href="#workout-alt-exercise-modal-' . $group['connected_exercises'] . '">';
92
-								$link_close = '</a>';
93
-								// We call the button to register the alt modal, but we do not output it.
94
-								lsx_health_plan_workout_exercise_alt_button( $group['connected_exercises'], $group, false, $modal_args, $alt_title, $alt_description, $alt_image );
95
-							} else {
96
-								$link_html  = '<a data-toggle="modal" href="#workout-exercise-modal-' . $group['connected_exercises'] . '">';
97
-								$link_close = '</a>';
98
-								// We call the button to register the modal, but we do not output it.
99
-								lsx_health_plan_workout_exercise_button( $group['connected_exercises'], $group, false, $modal_args );
100
-							}
101
-
102
-							break;
103
-
104
-						case 'none':
105
-						default:
106
-							$link_html  = '';
107
-							$link_close = '';
108
-							break;
109
-					}
110
-					?>
47
+               foreach ( $groups as $group ) {
48
+                    $connected_exercise = false;
49
+                    if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) {
50
+                         $connected_exercise = true;
51
+                    }
52
+
53
+                    if ( ! $connected_exercise ) {
54
+                         $group['connected_exercises'] = '';
55
+                    }
56
+
57
+                    if ( ( $connected_exercise ) || ( ( ! $connected_exercise ) && '' !== $group['alt_title'] && isset( $group['alt_title'] ) ) ) {
58
+
59
+                         $alt_title = '';
60
+                         if ( isset( $group['alt_title'] ) && '' !== $group['alt_title'] ) {
61
+                              $alt_title = '<span class="alt-title">' . esc_html( $group['alt_title'] ) . '</span>';
62
+                         }
63
+
64
+                         $alt_description = '';
65
+                         if ( isset( $group['alt_description'] ) && '' !== $group['alt_description'] ) {
66
+                              $alt_description = '<span class="alt-description">' . esc_html( $group['alt_description'] ) . '</span>';
67
+                         }
68
+
69
+                         $alt_image = '';
70
+                         if ( isset( $group['exercise_alt_thumbnail'] ) && '' !== $group['exercise_alt_thumbnail'] ) {
71
+                              $alt_image = $group['exercise_alt_thumbnail'];
72
+                         }
73
+
74
+                         $reps = '';
75
+                         if ( isset( $group['reps'] ) && '' !== $group['reps'] ) {
76
+                              $reps = '<span class="reps">' . esc_html( $group['reps'] ) . '</span>';
77
+                         }
78
+                         $class_excerpt = 'no-excerpt';
79
+                         if ( 'excerpt' === $content_setting ) {
80
+                              $class_excerpt = 'has-excerpt';
81
+                         }
82
+                         // Setup our link and content.
83
+                         switch ( $link_setting ) {
84
+                              case 'single':
85
+                                   $link_html  = '<a href="' . get_permalink( $group['connected_exercises'] ) . '">';
86
+                                   $link_close = '</a>';
87
+                                   break;
88
+
89
+                              case 'modal':
90
+                                   if ( ( '' !== $alt_title ) || ( '' !== $alt_description ) || ( '' !== $alt_image ) ) {
91
+                                        $link_html  = '<a class="alt-modal" data-toggle="modal" href="#workout-alt-exercise-modal-' . $group['connected_exercises'] . '">';
92
+                                        $link_close = '</a>';
93
+                                        // We call the button to register the alt modal, but we do not output it.
94
+                                        lsx_health_plan_workout_exercise_alt_button( $group['connected_exercises'], $group, false, $modal_args, $alt_title, $alt_description, $alt_image );
95
+                                   } else {
96
+                                        $link_html  = '<a data-toggle="modal" href="#workout-exercise-modal-' . $group['connected_exercises'] . '">';
97
+                                        $link_close = '</a>';
98
+                                        // We call the button to register the modal, but we do not output it.
99
+                                        lsx_health_plan_workout_exercise_button( $group['connected_exercises'], $group, false, $modal_args );
100
+                                   }
101
+
102
+                                   break;
103
+
104
+                              case 'none':
105
+                              default:
106
+                                   $link_html  = '';
107
+                                   $link_close = '';
108
+                                   break;
109
+                         }
110
+                         ?>
111 111
 					<div class="col-xs-12 col-sm-6 col-md-<?php echo esc_attr( $column_setting ); ?>">
112 112
 						<article class="lsx-slot box-shadow">
113 113
 							<div class="exercise-feature-img">
114 114
 								<span class="exercise-counter"><?php echo esc_html( $counter ); ?>.</span>
115 115
 								<?php echo wp_kses_post( $link_html ); ?>
116 116
 									<?php
117
-									$thumbnail_args = array(
118
-										'class' => 'aligncenter',
119
-									);
120
-									$featured_image = get_the_post_thumbnail( $group['connected_exercises'], 'medium', $thumbnail_args );
121
-									if ( $alt_image ) {
122
-										$featured_image = '<img alt="thumbnail" loading="lazy" class="aligncenter wp-post-image" src="' . $alt_image . '">';
123
-									}
124
-									if ( ! empty( $featured_image ) && '' !== $featured_image ) {
125
-										echo wp_kses_post( $featured_image );
126
-									} else {
127
-										?>
117
+                                             $thumbnail_args = array(
118
+                                                  'class' => 'aligncenter',
119
+                                             );
120
+                                             $featured_image = get_the_post_thumbnail( $group['connected_exercises'], 'medium', $thumbnail_args );
121
+                                             if ( $alt_image ) {
122
+                                                  $featured_image = '<img alt="thumbnail" loading="lazy" class="aligncenter wp-post-image" src="' . $alt_image . '">';
123
+                                             }
124
+                                             if ( ! empty( $featured_image ) && '' !== $featured_image ) {
125
+                                                  echo wp_kses_post( $featured_image );
126
+                                             } else {
127
+                                                  ?>
128 128
 										<img loading="lazy" src="<?php echo esc_attr( plugin_dir_url( __DIR__ ) . '../assets/images/placeholder.jpg' ); ?>">
129 129
 										<?php
130
-									}
131
-									?>
130
+                                             }
131
+                                             ?>
132 132
 								<?php echo wp_kses_post( $link_close ); ?>
133 133
 							</div>
134 134
 							<div class="content-box exercise-content-box white-bg">
135 135
 								<h3 class="content-box-title <?php echo esc_html( $class_excerpt ); ?>">
136 136
 									<?php echo wp_kses_post( $link_html ); ?>
137 137
 											<?php
138
-											$exercise_title = lsx_health_plan_exercise_title( '', '', false, $group['connected_exercises'] );
139
-											if ( '' !== $alt_title ) {
140
-												$exercise_title = $alt_title;
141
-											}
142
-											echo wp_kses_post( $exercise_title );
143
-											?>
138
+                                                       $exercise_title = lsx_health_plan_exercise_title( '', '', false, $group['connected_exercises'] );
139
+                                                       if ( '' !== $alt_title ) {
140
+                                                            $exercise_title = $alt_title;
141
+                                                       }
142
+                                                       echo wp_kses_post( $exercise_title );
143
+                                                       ?>
144 144
 										</a>
145 145
 									<?php echo wp_kses_post( $link_close ); ?>
146 146
 								</h3>
147 147
 								<?php
148
-								if ( '' !== $content_setting ) {
149
-									?>
148
+                                        if ( '' !== $content_setting ) {
149
+                                             ?>
150 150
 									<p class="lsx-exercises-excerpt">
151 151
 										<?php
152
-										if ( 'excerpt' === $content_setting ) {
153
-											$excerpt = \lsx_health_plan\functions\hp_excerpt( $group['connected_exercises'] );
154
-
155
-											if ( '' !== $alt_description ) {
156
-												$excerpt = $alt_description;
157
-											}
158
-											echo wp_kses_post( $excerpt );
159
-										}
160
-										if ( 'full' === $content_setting ) {
161
-											echo wp_kses_post( get_the_content( null, null, $group['connected_exercises'] ) );
162
-										}
163
-										?>
152
+                                                  if ( 'excerpt' === $content_setting ) {
153
+                                                       $excerpt = \lsx_health_plan\functions\hp_excerpt( $group['connected_exercises'] );
154
+
155
+                                                       if ( '' !== $alt_description ) {
156
+                                                            $excerpt = $alt_description;
157
+                                                       }
158
+                                                       echo wp_kses_post( $excerpt );
159
+                                                  }
160
+                                                  if ( 'full' === $content_setting ) {
161
+                                                       echo wp_kses_post( get_the_content( null, null, $group['connected_exercises'] ) );
162
+                                                  }
163
+                                                  ?>
164 164
 									</p>
165 165
 									<?php
166
-								}
167
-								?>
166
+                                        }
167
+                                        ?>
168 168
 								<?php
169
-								$repsclass = '';
170
-								if ( '' !== $reps ) {
171
-									$repsclass = 'have-reps';
172
-								}
173
-								?>
169
+                                        $repsclass = '';
170
+                                        if ( '' !== $reps ) {
171
+                                             $repsclass = 'have-reps';
172
+                                        }
173
+                                        ?>
174 174
 								<div class="reps-container <?php echo esc_html( $repsclass ); ?>">
175 175
 									<?php
176
-									if ( '' !== $reps ) {
177
-									?>
176
+                                             if ( '' !== $reps ) {
177
+                                             ?>
178 178
 										<?php echo wp_kses_post( $reps ); ?>
179 179
 									<?php
180
-									}
181
-									?>
180
+                                             }
181
+                                             ?>
182 182
 									<?php if ( ( '' !== $link_html ) && ( $connected_exercise ) ) { ?>
183 183
 										<?php echo wp_kses_post( str_replace( '<a', '<a class="btn-simple" ', $link_html ) ); ?>
184 184
 										<?php echo wp_kses_post( $link_close ); ?>
@@ -188,10 +188,10 @@  discard block
 block discarded – undo
188 188
 						</article>
189 189
 					</div>
190 190
 					<?php
191
-					$counter ++;
192
-				}
193
-			}
194
-			?>
191
+                         $counter ++;
192
+                    }
193
+               }
194
+               ?>
195 195
 		</div>
196 196
 	</div>
197 197
 	<?php
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -5,30 +5,30 @@  discard block
 block discarded – undo
5 5
  * @package lsx-health-plan
6 6
  */
7 7
 
8
-global $group_name,$shortcode_args;
9
-$groups = get_post_meta( get_the_ID(), $group_name, true );
10
-if ( is_singular( 'workout' ) ) {
11
-	$groups = get_post_meta( get_queried_object_id(), $group_name, true );
8
+global $group_name, $shortcode_args;
9
+$groups = get_post_meta(get_the_ID(), $group_name, true);
10
+if (is_singular('workout')) {
11
+	$groups = get_post_meta(get_queried_object_id(), $group_name, true);
12 12
 }
13 13
 
14
-$link_setting          = \lsx_health_plan\functions\get_option( 'workout_tab_link', 'single' );
15
-$modal_content_setting = \lsx_health_plan\functions\get_option( 'workout_tab_modal_content', 'excerpt' );
16
-$content_setting       = \lsx_health_plan\functions\get_option( 'workout_tab_content', '' );
17
-$column_setting        = \lsx_health_plan\functions\get_option( 'workout_tab_columns', '4' );
14
+$link_setting          = \lsx_health_plan\functions\get_option('workout_tab_link', 'single');
15
+$modal_content_setting = \lsx_health_plan\functions\get_option('workout_tab_modal_content', 'excerpt');
16
+$content_setting       = \lsx_health_plan\functions\get_option('workout_tab_content', '');
17
+$column_setting        = \lsx_health_plan\functions\get_option('workout_tab_columns', '4');
18 18
 
19 19
 // Check for shortcode overrides.
20
-if ( null !== $shortcode_args ) {
21
-	if ( isset( $shortcode_args['link'] ) ) {
20
+if (null !== $shortcode_args) {
21
+	if (isset($shortcode_args['link'])) {
22 22
 		$link_setting = $shortcode_args['link'];
23 23
 	}
24
-	if ( isset( $shortcode_args['description'] ) ) {
24
+	if (isset($shortcode_args['description'])) {
25 25
 		$content_setting = $shortcode_args['description'];
26 26
 	}
27
-	if ( isset( $shortcode_args['columns'] ) ) {
27
+	if (isset($shortcode_args['columns'])) {
28 28
 		$column_setting = $shortcode_args['columns'];
29
-		$column_setting = \lsx_health_plan\functions\column_class( $column_setting );
29
+		$column_setting = \lsx_health_plan\functions\column_class($column_setting);
30 30
 	}
31
-	if ( isset( $shortcode_args['modal_content'] ) ) {
31
+	if (isset($shortcode_args['modal_content'])) {
32 32
 		$modal_content_setting = $shortcode_args['modal_content'];
33 33
 	}
34 34
 }
@@ -39,64 +39,64 @@  discard block
 block discarded – undo
39 39
 
40 40
 $counter = 1;
41 41
 
42
-if ( ! empty( $groups ) ) {
42
+if ( ! empty($groups)) {
43 43
 	?>
44 44
 	<div class="set-grid">
45 45
 		<div class="workout-grid row">
46 46
 			<?php
47
-			foreach ( $groups as $group ) {
47
+			foreach ($groups as $group) {
48 48
 				$connected_exercise = false;
49
-				if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) {
49
+				if (isset($group['connected_exercises']) && '' !== $group['connected_exercises']) {
50 50
 					$connected_exercise = true;
51 51
 				}
52 52
 
53
-				if ( ! $connected_exercise ) {
53
+				if ( ! $connected_exercise) {
54 54
 					$group['connected_exercises'] = '';
55 55
 				}
56 56
 
57
-				if ( ( $connected_exercise ) || ( ( ! $connected_exercise ) && '' !== $group['alt_title'] && isset( $group['alt_title'] ) ) ) {
57
+				if (($connected_exercise) || (( ! $connected_exercise) && '' !== $group['alt_title'] && isset($group['alt_title']))) {
58 58
 
59 59
 					$alt_title = '';
60
-					if ( isset( $group['alt_title'] ) && '' !== $group['alt_title'] ) {
61
-						$alt_title = '<span class="alt-title">' . esc_html( $group['alt_title'] ) . '</span>';
60
+					if (isset($group['alt_title']) && '' !== $group['alt_title']) {
61
+						$alt_title = '<span class="alt-title">' . esc_html($group['alt_title']) . '</span>';
62 62
 					}
63 63
 
64 64
 					$alt_description = '';
65
-					if ( isset( $group['alt_description'] ) && '' !== $group['alt_description'] ) {
66
-						$alt_description = '<span class="alt-description">' . esc_html( $group['alt_description'] ) . '</span>';
65
+					if (isset($group['alt_description']) && '' !== $group['alt_description']) {
66
+						$alt_description = '<span class="alt-description">' . esc_html($group['alt_description']) . '</span>';
67 67
 					}
68 68
 
69 69
 					$alt_image = '';
70
-					if ( isset( $group['exercise_alt_thumbnail'] ) && '' !== $group['exercise_alt_thumbnail'] ) {
70
+					if (isset($group['exercise_alt_thumbnail']) && '' !== $group['exercise_alt_thumbnail']) {
71 71
 						$alt_image = $group['exercise_alt_thumbnail'];
72 72
 					}
73 73
 
74 74
 					$reps = '';
75
-					if ( isset( $group['reps'] ) && '' !== $group['reps'] ) {
76
-						$reps = '<span class="reps">' . esc_html( $group['reps'] ) . '</span>';
75
+					if (isset($group['reps']) && '' !== $group['reps']) {
76
+						$reps = '<span class="reps">' . esc_html($group['reps']) . '</span>';
77 77
 					}
78 78
 					$class_excerpt = 'no-excerpt';
79
-					if ( 'excerpt' === $content_setting ) {
79
+					if ('excerpt' === $content_setting) {
80 80
 						$class_excerpt = 'has-excerpt';
81 81
 					}
82 82
 					// Setup our link and content.
83
-					switch ( $link_setting ) {
83
+					switch ($link_setting) {
84 84
 						case 'single':
85
-							$link_html  = '<a href="' . get_permalink( $group['connected_exercises'] ) . '">';
85
+							$link_html  = '<a href="' . get_permalink($group['connected_exercises']) . '">';
86 86
 							$link_close = '</a>';
87 87
 							break;
88 88
 
89 89
 						case 'modal':
90
-							if ( ( '' !== $alt_title ) || ( '' !== $alt_description ) || ( '' !== $alt_image ) ) {
90
+							if (('' !== $alt_title) || ('' !== $alt_description) || ('' !== $alt_image)) {
91 91
 								$link_html  = '<a class="alt-modal" data-toggle="modal" href="#workout-alt-exercise-modal-' . $group['connected_exercises'] . '">';
92 92
 								$link_close = '</a>';
93 93
 								// We call the button to register the alt modal, but we do not output it.
94
-								lsx_health_plan_workout_exercise_alt_button( $group['connected_exercises'], $group, false, $modal_args, $alt_title, $alt_description, $alt_image );
94
+								lsx_health_plan_workout_exercise_alt_button($group['connected_exercises'], $group, false, $modal_args, $alt_title, $alt_description, $alt_image);
95 95
 							} else {
96 96
 								$link_html  = '<a data-toggle="modal" href="#workout-exercise-modal-' . $group['connected_exercises'] . '">';
97 97
 								$link_close = '</a>';
98 98
 								// We call the button to register the modal, but we do not output it.
99
-								lsx_health_plan_workout_exercise_button( $group['connected_exercises'], $group, false, $modal_args );
99
+								lsx_health_plan_workout_exercise_button($group['connected_exercises'], $group, false, $modal_args);
100 100
 							}
101 101
 
102 102
 							break;
@@ -108,57 +108,57 @@  discard block
 block discarded – undo
108 108
 							break;
109 109
 					}
110 110
 					?>
111
-					<div class="col-xs-12 col-sm-6 col-md-<?php echo esc_attr( $column_setting ); ?>">
111
+					<div class="col-xs-12 col-sm-6 col-md-<?php echo esc_attr($column_setting); ?>">
112 112
 						<article class="lsx-slot box-shadow">
113 113
 							<div class="exercise-feature-img">
114
-								<span class="exercise-counter"><?php echo esc_html( $counter ); ?>.</span>
115
-								<?php echo wp_kses_post( $link_html ); ?>
114
+								<span class="exercise-counter"><?php echo esc_html($counter); ?>.</span>
115
+								<?php echo wp_kses_post($link_html); ?>
116 116
 									<?php
117 117
 									$thumbnail_args = array(
118 118
 										'class' => 'aligncenter',
119 119
 									);
120
-									$featured_image = get_the_post_thumbnail( $group['connected_exercises'], 'medium', $thumbnail_args );
121
-									if ( $alt_image ) {
120
+									$featured_image = get_the_post_thumbnail($group['connected_exercises'], 'medium', $thumbnail_args);
121
+									if ($alt_image) {
122 122
 										$featured_image = '<img alt="thumbnail" loading="lazy" class="aligncenter wp-post-image" src="' . $alt_image . '">';
123 123
 									}
124
-									if ( ! empty( $featured_image ) && '' !== $featured_image ) {
125
-										echo wp_kses_post( $featured_image );
124
+									if ( ! empty($featured_image) && '' !== $featured_image) {
125
+										echo wp_kses_post($featured_image);
126 126
 									} else {
127 127
 										?>
128
-										<img loading="lazy" src="<?php echo esc_attr( plugin_dir_url( __DIR__ ) . '../assets/images/placeholder.jpg' ); ?>">
128
+										<img loading="lazy" src="<?php echo esc_attr(plugin_dir_url(__DIR__) . '../assets/images/placeholder.jpg'); ?>">
129 129
 										<?php
130 130
 									}
131 131
 									?>
132
-								<?php echo wp_kses_post( $link_close ); ?>
132
+								<?php echo wp_kses_post($link_close); ?>
133 133
 							</div>
134 134
 							<div class="content-box exercise-content-box white-bg">
135
-								<h3 class="content-box-title <?php echo esc_html( $class_excerpt ); ?>">
136
-									<?php echo wp_kses_post( $link_html ); ?>
135
+								<h3 class="content-box-title <?php echo esc_html($class_excerpt); ?>">
136
+									<?php echo wp_kses_post($link_html); ?>
137 137
 											<?php
138
-											$exercise_title = lsx_health_plan_exercise_title( '', '', false, $group['connected_exercises'] );
139
-											if ( '' !== $alt_title ) {
138
+											$exercise_title = lsx_health_plan_exercise_title('', '', false, $group['connected_exercises']);
139
+											if ('' !== $alt_title) {
140 140
 												$exercise_title = $alt_title;
141 141
 											}
142
-											echo wp_kses_post( $exercise_title );
142
+											echo wp_kses_post($exercise_title);
143 143
 											?>
144 144
 										</a>
145
-									<?php echo wp_kses_post( $link_close ); ?>
145
+									<?php echo wp_kses_post($link_close); ?>
146 146
 								</h3>
147 147
 								<?php
148
-								if ( '' !== $content_setting ) {
148
+								if ('' !== $content_setting) {
149 149
 									?>
150 150
 									<p class="lsx-exercises-excerpt">
151 151
 										<?php
152
-										if ( 'excerpt' === $content_setting ) {
153
-											$excerpt = \lsx_health_plan\functions\hp_excerpt( $group['connected_exercises'] );
152
+										if ('excerpt' === $content_setting) {
153
+											$excerpt = \lsx_health_plan\functions\hp_excerpt($group['connected_exercises']);
154 154
 
155
-											if ( '' !== $alt_description ) {
155
+											if ('' !== $alt_description) {
156 156
 												$excerpt = $alt_description;
157 157
 											}
158
-											echo wp_kses_post( $excerpt );
158
+											echo wp_kses_post($excerpt);
159 159
 										}
160
-										if ( 'full' === $content_setting ) {
161
-											echo wp_kses_post( get_the_content( null, null, $group['connected_exercises'] ) );
160
+										if ('full' === $content_setting) {
161
+											echo wp_kses_post(get_the_content(null, null, $group['connected_exercises']));
162 162
 										}
163 163
 										?>
164 164
 									</p>
@@ -167,28 +167,28 @@  discard block
 block discarded – undo
167 167
 								?>
168 168
 								<?php
169 169
 								$repsclass = '';
170
-								if ( '' !== $reps ) {
170
+								if ('' !== $reps) {
171 171
 									$repsclass = 'have-reps';
172 172
 								}
173 173
 								?>
174
-								<div class="reps-container <?php echo esc_html( $repsclass ); ?>">
174
+								<div class="reps-container <?php echo esc_html($repsclass); ?>">
175 175
 									<?php
176
-									if ( '' !== $reps ) {
176
+									if ('' !== $reps) {
177 177
 									?>
178
-										<?php echo wp_kses_post( $reps ); ?>
178
+										<?php echo wp_kses_post($reps); ?>
179 179
 									<?php
180 180
 									}
181 181
 									?>
182
-									<?php if ( ( '' !== $link_html ) && ( $connected_exercise ) ) { ?>
183
-										<?php echo wp_kses_post( str_replace( '<a', '<a class="btn-simple" ', $link_html ) ); ?>
184
-										<?php echo wp_kses_post( $link_close ); ?>
182
+									<?php if (('' !== $link_html) && ($connected_exercise)) { ?>
183
+										<?php echo wp_kses_post(str_replace('<a', '<a class="btn-simple" ', $link_html)); ?>
184
+										<?php echo wp_kses_post($link_close); ?>
185 185
 									<?php } ?>
186 186
 								</div>
187 187
 							</div>
188 188
 						</article>
189 189
 					</div>
190 190
 					<?php
191
-					$counter ++;
191
+					$counter++;
192 192
 				}
193 193
 			}
194 194
 			?>
Please login to merge, or discard this patch.
includes/template-tags.php 2 patches
Indentation   +622 added lines, -622 removed lines patch added patch discarded remove patch
@@ -11,25 +11,25 @@  discard block
 block discarded – undo
11 11
 * @return void
12 12
 */
13 13
 function lsx_health_plan_warmup_box() {
14
-	?>
14
+     ?>
15 15
 	<div class="col-md-4" >
16 16
 		<div class="lsx-health-plan-box">
17 17
 			<h3 class="title warm-up-title title-lined"><?php esc_html_e( 'Your Warm-up', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'warm.svg' ); ?></h3>
18 18
 			<div class="spacer"></div>
19 19
 			<?php
20
-			$intro_text = \lsx_health_plan\functions\get_option( 'warmup_intro', false );
21
-			if ( false !== $intro_text ) {
22
-				?>
20
+               $intro_text = \lsx_health_plan\functions\get_option( 'warmup_intro', false );
21
+               if ( false !== $intro_text ) {
22
+                    ?>
23 23
 				<div class="excerpt">
24 24
 					<p><?php echo wp_kses_post( $intro_text ); ?></p>
25 25
 				</div>
26 26
 				<?php
27
-			}
28
-			$warm_up = \lsx_health_plan\functions\get_option( 'endpoint_warm_up', false );
29
-			if ( false === $warm_up ) {
30
-				$warm_up = 'warm-up';
31
-			}
32
-			?>
27
+               }
28
+               $warm_up = \lsx_health_plan\functions\get_option( 'endpoint_warm_up', false );
29
+               if ( false === $warm_up ) {
30
+                    $warm_up = 'warm-up';
31
+               }
32
+               ?>
33 33
 			<a href="<?php the_permalink(); ?><?php echo esc_attr( $warm_up ); ?>/" class="btn"><?php esc_html_e( 'Start your warm-up', 'lsx-health-plan' ); ?></a>
34 34
 		</div>
35 35
 	</div>
@@ -42,28 +42,28 @@  discard block
 block discarded – undo
42 42
 * @return void
43 43
 */
44 44
 function lsx_health_plan_workout_box() {
45
-	if ( ! post_type_exists( 'workout' ) ) {
46
-		return;
47
-	}
48
-	?>
45
+     if ( ! post_type_exists( 'workout' ) ) {
46
+          return;
47
+     }
48
+     ?>
49 49
 	<div class="col-md-4" >
50 50
 		<div class="lsx-health-plan-box">
51 51
 			<h3 class="title work-out-title title-lined"><?php esc_html_e( 'Your Workout', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'work.svg' ); ?></h3>
52 52
 			<div class="spacer"></div>
53 53
 			<?php
54
-			$intro_text = \lsx_health_plan\functions\get_option( 'workout_intro', false );
55
-			if ( false !== $intro_text ) {
56
-				?>
54
+               $intro_text = \lsx_health_plan\functions\get_option( 'workout_intro', false );
55
+               if ( false !== $intro_text ) {
56
+                    ?>
57 57
 				<div class="excerpt">
58 58
 					<p><?php echo wp_kses_post( $intro_text ); ?></p>
59 59
 				</div>
60 60
 				<?php
61
-			}
62
-			$workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', false );
63
-			if ( false === $workout ) {
64
-				$workout = 'workout';
65
-			}
66
-			?>
61
+               }
62
+               $workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', false );
63
+               if ( false === $workout ) {
64
+                    $workout = 'workout';
65
+               }
66
+               ?>
67 67
 			<a href="<?php the_permalink(); ?><?php echo esc_attr( $workout ); ?>/" class="btn"><?php esc_html_e( 'Start your workout', 'lsx-health-plan' ); ?></a>
68 68
 		</div>
69 69
 	</div>
@@ -76,28 +76,28 @@  discard block
 block discarded – undo
76 76
 * @return void
77 77
 */
78 78
 function lsx_health_plan_meal_box() {
79
-	if ( ! post_type_exists( 'meal' ) ) {
80
-		return;
81
-	}
82
-	?>
79
+     if ( ! post_type_exists( 'meal' ) ) {
80
+          return;
81
+     }
82
+     ?>
83 83
 	<div class="col-md-4" >
84 84
 		<div class="lsx-health-plan-box">
85 85
 			<h3 class="title meal-plan-title title-lined"><?php esc_html_e( 'Your Meal Plan', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'meal.svg' ); ?></h3>
86 86
 			<div class="spacer"></div>
87 87
 			<?php
88
-			$intro_text = \lsx_health_plan\functions\get_option( 'meal_plan_intro', false );
89
-			if ( false !== $intro_text ) {
90
-				?>
88
+               $intro_text = \lsx_health_plan\functions\get_option( 'meal_plan_intro', false );
89
+               if ( false !== $intro_text ) {
90
+                    ?>
91 91
 				<div class="excerpt">
92 92
 					<p><?php echo wp_kses_post( $intro_text ); ?></p>
93 93
 				</div>
94 94
 				<?php
95
-			}
96
-			$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false );
97
-			if ( false === $meal ) {
98
-				$meal = 'meal';
99
-			}
100
-			?>
95
+               }
96
+               $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false );
97
+               if ( false === $meal ) {
98
+                    $meal = 'meal';
99
+               }
100
+               ?>
101 101
 			<a href="<?php the_permalink(); ?><?php echo esc_attr( $meal ); ?>/" class="btn"><?php esc_html_e( 'View your meal plan', 'lsx-health-plan' ); ?></a>
102 102
 		</div>
103 103
 	</div>
@@ -110,28 +110,28 @@  discard block
 block discarded – undo
110 110
 * @return void
111 111
 */
112 112
 function lsx_health_plan_recipe_box() {
113
-	if ( ! post_type_exists( 'recipe' ) ) {
114
-		return;
115
-	}
116
-	?>
113
+     if ( ! post_type_exists( 'recipe' ) ) {
114
+          return;
115
+     }
116
+     ?>
117 117
 	<div class="col-md-4" >
118 118
 		<div class="lsx-health-plan-box">
119 119
 			<h3 class="title recipes-title title-lined"><?php esc_html_e( 'Recipes', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'recipes.svg' ); ?></h3>
120 120
 			<div class="spacer"></div>
121 121
 			<?php
122
-			$intro_text = \lsx_health_plan\functions\get_option( 'recipes_intro', false );
123
-			if ( false !== $intro_text ) {
124
-				?>
122
+               $intro_text = \lsx_health_plan\functions\get_option( 'recipes_intro', false );
123
+               if ( false !== $intro_text ) {
124
+                    ?>
125 125
 				<div class="excerpt">
126 126
 					<p><?php echo wp_kses_post( $intro_text ); ?></p>
127 127
 				</div>
128 128
 				<?php
129
-			}
130
-			$recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false );
131
-			if ( false === $recipes ) {
132
-				$recipes = 'recipes';
133
-			}
134
-			?>
129
+               }
130
+               $recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false );
131
+               if ( false === $recipes ) {
132
+                    $recipes = 'recipes';
133
+               }
134
+               ?>
135 135
 			<a href="<?php the_permalink(); ?><?php echo esc_attr( $recipes ); ?>/" class="btn"><?php esc_html_e( 'View all recipes', 'lsx-health-plan' ); ?></a>
136 136
 		</div>
137 137
 	</div>
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 * @return void
145 145
 */
146 146
 function lsx_health_plan_downloads_box() {
147
-	global $current_user;
148
-	?>
147
+     global $current_user;
148
+     ?>
149 149
 	<div class="col-md-4 day-download-box" >
150 150
 		<div class="lsx-health-plan-box">
151 151
 			<h3 class="title downloads-title title-lined"><?php esc_html_e( 'Downloads', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'download.svg' ); ?></h3>
@@ -153,13 +153,13 @@  discard block
 block discarded – undo
153 153
 			<div class="download-list">
154 154
 				<ul>
155 155
 					<?php
156
-					$downloads = \lsx_health_plan\functions\get_downloads();
157
-					if ( ! empty( $downloads ) ) {
158
-						foreach ( $downloads as $download ) {
159
-							echo wp_kses_post( '<li><a href=""><i class="fa fa-file-pdf"></i>' . do_shortcode( '[download id="' . $download . '"]' ) . '</a></li>' );
160
-						}
161
-					}
162
-					?>
156
+                         $downloads = \lsx_health_plan\functions\get_downloads();
157
+                         if ( ! empty( $downloads ) ) {
158
+                              foreach ( $downloads as $download ) {
159
+                                   echo wp_kses_post( '<li><a href=""><i class="fa fa-file-pdf"></i>' . do_shortcode( '[download id="' . $download . '"]' ) . '</a></li>' );
160
+                              }
161
+                         }
162
+                         ?>
163 163
 				</ul>
164 164
 			</div>
165 165
 		</div>
@@ -174,15 +174,15 @@  discard block
 block discarded – undo
174 174
  * @return void
175 175
  */
176 176
 function lsx_health_plan_nav_class( $tab = '' ) {
177
-	$nav_classes = array();
178
-	if ( function_exists( 'is_wc_endpoint_url' ) && 'edit-account' === $tab && is_wc_endpoint_url( 'edit-account' ) ) {
179
-		$nav_classes[] = 'active';
180
-	} elseif ( lsx_health_plan_is_current_tab( $tab ) ) {
181
-		$nav_classes[] = 'active';
182
-	}
183
-	if ( ! empty( $nav_classes ) ) {
184
-		echo wp_kses_post( implode( ' ', $nav_classes ) );
185
-	}
177
+     $nav_classes = array();
178
+     if ( function_exists( 'is_wc_endpoint_url' ) && 'edit-account' === $tab && is_wc_endpoint_url( 'edit-account' ) ) {
179
+          $nav_classes[] = 'active';
180
+     } elseif ( lsx_health_plan_is_current_tab( $tab ) ) {
181
+          $nav_classes[] = 'active';
182
+     }
183
+     if ( ! empty( $nav_classes ) ) {
184
+          echo wp_kses_post( implode( ' ', $nav_classes ) );
185
+     }
186 186
 }
187 187
 
188 188
 /**
@@ -191,22 +191,22 @@  discard block
 block discarded – undo
191 191
  * @return void
192 192
  */
193 193
 function lsx_health_plan_my_profile_tabs() {
194
-	?>
194
+     ?>
195 195
 	<div id="account-nav">
196 196
 		<ul class="nav nav-pills">
197 197
 			<li class="
198 198
 			<?php
199
-			if ( ( function_exists( 'is_wc_endpoint_url' ) && ! is_wc_endpoint_url( 'edit-account' ) ) || ! function_exists( 'is_wc_endpoint_url' ) ) {
200
-				echo esc_attr( 'active' );
201
-			}
202
-			?>
199
+               if ( ( function_exists( 'is_wc_endpoint_url' ) && ! is_wc_endpoint_url( 'edit-account' ) ) || ! function_exists( 'is_wc_endpoint_url' ) ) {
200
+                    echo esc_attr( 'active' );
201
+               }
202
+               ?>
203 203
 			"><a class="my-plan-tab" href="<?php the_permalink(); ?>"><?php esc_html_e( 'My Plans', 'lsx-health-plan' ); ?></a></li>
204 204
 			<li class="
205 205
 			<?php
206
-			if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'edit-account' ) ) {
207
-				echo esc_attr( 'active' );
208
-			}
209
-			?>
206
+               if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'edit-account' ) ) {
207
+                    echo esc_attr( 'active' );
208
+               }
209
+               ?>
210 210
 			"><a class="account-details-tab" href="<?php the_permalink(); ?>edit-account/"><?php esc_html_e( 'Account Details', 'lsx-health-plan' ); ?></a></li>
211 211
 			<li class=""><a class="logout-tab" href="<?php echo esc_url( wp_logout_url( get_permalink() ) ); ?>"><?php esc_html_e( 'Logout', 'lsx-health-plan' ); ?></a></li>
212 212
 		</ul>
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
  * @return void
221 221
  */
222 222
 function lsx_health_plan_my_profile_box() {
223
-	?>
223
+     ?>
224 224
 	<div class="lsx-health-plan my-profile-block wp-block-cover alignfull">
225 225
 		<div class="wp-block-cover__inner-container">
226 226
 			<h2><?php esc_html_e( 'My Dashboard', 'lsx-health-plan' ); ?></h2>
@@ -228,86 +228,86 @@  discard block
 block discarded – undo
228 228
 				<div class="profile-navigation">
229 229
 					<div class="profile-photo">
230 230
 					<?php
231
-						global $current_user;
232
-						get_current_user();
233
-						echo get_avatar( $current_user->ID, 240 );
234
-						?>
231
+                              global $current_user;
232
+                              get_current_user();
233
+                              echo get_avatar( $current_user->ID, 240 );
234
+                              ?>
235 235
 					</div>
236 236
 				</div>
237 237
 				<div class="profile-details">
238 238
 					<h1 class="title-lined has-text-color"><?php echo esc_html( $current_user->display_name ); ?></h1>
239 239
 					<?php
240
-					$disable_stats = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
241
-					if ( 'on' !== $disable_stats ) {
240
+                         $disable_stats = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
241
+                         if ( 'on' !== $disable_stats ) {
242 242
 
243
-						$is_weight_disabled  = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false );
244
-						$is_height_disabled  = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false );
245
-						$is_waist_disabled   = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false );
246
-						$is_bmi_disabled = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false );
243
+                              $is_weight_disabled  = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false );
244
+                              $is_height_disabled  = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false );
245
+                              $is_waist_disabled   = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false );
246
+                              $is_bmi_disabled = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false );
247 247
 
248
-						$weight = get_user_meta( get_current_user_id(), 'weight', true );
249
-						$waist = get_user_meta( get_current_user_id(), 'waist', true );
250
-						$height = get_user_meta( get_current_user_id(), 'height', true );
248
+                              $weight = get_user_meta( get_current_user_id(), 'weight', true );
249
+                              $waist = get_user_meta( get_current_user_id(), 'waist', true );
250
+                              $height = get_user_meta( get_current_user_id(), 'height', true );
251 251
 
252
-						$height_m = $height / 100;
252
+                              $height_m = $height / 100;
253 253
 
254
-						if ( 1 < $weight && 1 < $height_m ) {
255
-							$bmi = $weight / ( $height_m * $height_m );
256
-							$bmi = number_format( $bmi, 1 );
257
-						} else {
258
-							$bmi = __( 'Add more data', 'lsx-health-plan' );
259
-						}
254
+                              if ( 1 < $weight && 1 < $height_m ) {
255
+                                   $bmi = $weight / ( $height_m * $height_m );
256
+                                   $bmi = number_format( $bmi, 1 );
257
+                              } else {
258
+                                   $bmi = __( 'Add more data', 'lsx-health-plan' );
259
+                              }
260 260
 
261
-						?>
261
+                              ?>
262 262
 
263 263
 						<div>
264 264
 							<?php if ( 'on' !== $is_weight_disabled ) { ?>
265 265
 								<span><strong><?php esc_html_e( 'Weight:', 'lsx-health-plan' ); ?></strong>
266 266
 								<?php
267
-								if ( '' !== $weight ) {
268
-									echo wp_kses_post( $weight . ' kg' );
269
-								} else {
270
-									echo '/';
271
-								}
272
-								?>
267
+                                        if ( '' !== $weight ) {
268
+                                             echo wp_kses_post( $weight . ' kg' );
269
+                                        } else {
270
+                                             echo '/';
271
+                                        }
272
+                                        ?>
273 273
 								</span>
274 274
 							<?php }
275
-							if ( 'on' !== $is_waist_disabled ) {
276
-								?>
275
+                                   if ( 'on' !== $is_waist_disabled ) {
276
+                                        ?>
277 277
 								<span><strong><?php esc_html_e( 'Waist:', 'lsx-health-plan' ); ?></strong>
278 278
 								<?php
279
-								if ( '' !== $waist ) {
280
-									echo wp_kses_post( $waist . ' cm' );
281
-								} else {
282
-									echo '/';
283
-								}
284
-								?>
279
+                                        if ( '' !== $waist ) {
280
+                                             echo wp_kses_post( $waist . ' cm' );
281
+                                        } else {
282
+                                             echo '/';
283
+                                        }
284
+                                        ?>
285 285
 								</span>
286 286
 							<?php }
287
-							if ( 'on' !== $is_bmi_disabled ) {
288
-								?>
287
+                                   if ( 'on' !== $is_bmi_disabled ) {
288
+                                        ?>
289 289
 								<span><strong><?php esc_html_e( 'BMI:', 'lsx-health-plan' ); ?></strong>
290 290
 								<?php
291
-								if ( '' !== $bmi ) {
292
-									echo wp_kses_post( $bmi );
293
-								} else {
294
-									echo '/';
295
-								}
296
-								?>
291
+                                        if ( '' !== $bmi ) {
292
+                                             echo wp_kses_post( $bmi );
293
+                                        } else {
294
+                                             echo '/';
295
+                                        }
296
+                                        ?>
297 297
 								</span>
298 298
 							<?php } ?>
299 299
 						</div>
300 300
 					<?php
301
-					}
302
-					?>
301
+                         }
302
+                         ?>
303 303
 					<div class="edit-profile">
304 304
 						<?php
305
-						if ( function_exists( 'wc_get_page_id' ) ) {
306
-							$url_id = wc_get_page_id( 'myaccount' );
307
-						} else {
308
-							$url_id = '';
309
-						}
310
-						?>
305
+                              if ( function_exists( 'wc_get_page_id' ) ) {
306
+                                   $url_id = wc_get_page_id( 'myaccount' );
307
+                              } else {
308
+                                   $url_id = '';
309
+                              }
310
+                              ?>
311 311
 						<a href="<?php echo esc_url( get_permalink( $url_id ) ); ?>edit-account/"><?php esc_html_e( 'Edit', 'lsx-health-plan' ); ?></a>
312 312
 					</div>
313 313
 				</div>
@@ -323,102 +323,102 @@  discard block
 block discarded – undo
323 323
  * @return void
324 324
  */
325 325
 function lsx_health_plan_all_plans_block() {
326
-	global $post, $product;
327
-
328
-	$args = array(
329
-		'orderby'        => 'menu_order',
330
-		'order'          => 'ASC',
331
-		'post_type'      => 'plan',
332
-		'nopagin'        => true,
333
-		'post_parent'    => 0,
334
-	);
335
-
336
-	$product_ids = \lsx_health_plan\functions\woocommerce\get_membership_products();
337
-	if ( ! empty( $product_ids ) ) {
338
-		$args['meta_query'] = array(
339
-			'relation' => 'OR',
340
-			array(
341
-				'key'     => '_plan_product_id',
342
-				'value'   => $product_ids,
343
-				'compare' => 'IN',
344
-			),
345
-			array(
346
-				'key'     => '_plan_product_id',
347
-				'compare' => 'NOT EXISTS',
348
-			),
349
-		);
350
-	}
351
-
352
-	$the_query = new WP_Query( $args );
353
-	?>
326
+     global $post, $product;
327
+
328
+     $args = array(
329
+          'orderby'        => 'menu_order',
330
+          'order'          => 'ASC',
331
+          'post_type'      => 'plan',
332
+          'nopagin'        => true,
333
+          'post_parent'    => 0,
334
+     );
335
+
336
+     $product_ids = \lsx_health_plan\functions\woocommerce\get_membership_products();
337
+     if ( ! empty( $product_ids ) ) {
338
+          $args['meta_query'] = array(
339
+               'relation' => 'OR',
340
+               array(
341
+                    'key'     => '_plan_product_id',
342
+                    'value'   => $product_ids,
343
+                    'compare' => 'IN',
344
+               ),
345
+               array(
346
+                    'key'     => '_plan_product_id',
347
+                    'compare' => 'NOT EXISTS',
348
+               ),
349
+          );
350
+     }
351
+
352
+     $the_query = new WP_Query( $args );
353
+     ?>
354 354
 	<div class="all-plans-block plan-grid block-all-plans-block">
355 355
 		<div class="row">
356 356
 			<?php
357
-			if ( $the_query->have_posts() ) :
358
-				while ( $the_query->have_posts() ) :
359
-					$the_query->the_post();
360
-					lsx_entry_before();
361
-					$completed_class = '';
362
-					$linked_product  = false;
363
-					$restricted      = false;
364
-					$product         = null;
365
-					if ( \lsx_health_plan\functions\woocommerce\plan_has_products() ) {
366
-						$products       = \lsx_health_plan\functions\woocommerce\get_plan_products();
367
-						$linked_product = wc_get_product( $products[0] );
368
-						$product        = $linked_product;
369
-					}
370
-					if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) {
371
-						$restricted = wc_memberships_is_post_content_restricted( get_the_ID() ) && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() );
372
-					}
373
-
374
-					if ( lsx_health_plan_is_plan_complete() ) {
375
-						$completed_class = 'completed';
376
-					}
377
-					?>
357
+               if ( $the_query->have_posts() ) :
358
+                    while ( $the_query->have_posts() ) :
359
+                         $the_query->the_post();
360
+                         lsx_entry_before();
361
+                         $completed_class = '';
362
+                         $linked_product  = false;
363
+                         $restricted      = false;
364
+                         $product         = null;
365
+                         if ( \lsx_health_plan\functions\woocommerce\plan_has_products() ) {
366
+                              $products       = \lsx_health_plan\functions\woocommerce\get_plan_products();
367
+                              $linked_product = wc_get_product( $products[0] );
368
+                              $product        = $linked_product;
369
+                         }
370
+                         if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) {
371
+                              $restricted = wc_memberships_is_post_content_restricted( get_the_ID() ) && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() );
372
+                         }
373
+
374
+                         if ( lsx_health_plan_is_plan_complete() ) {
375
+                              $completed_class = 'completed';
376
+                         }
377
+                         ?>
378 378
 					<div class="col-xs-12 col-sm-6 col-md-4">
379 379
 						<article class="lsx-slot lsx-hp-shadow">
380 380
 							<div class="plan-feature-img">
381 381
 								<a href="<?php echo esc_url( get_permalink() ); ?>">
382 382
 								<?php
383
-								$featured_image = get_the_post_thumbnail();
384
-								if ( ! empty( $featured_image ) && '' !== $featured_image ) {
385
-									the_post_thumbnail( 'lsx-thumbnail', array(
386
-										'class' => 'aligncenter',
387
-									) );
388
-								} else {
389
-									?>
383
+                                        $featured_image = get_the_post_thumbnail();
384
+                                        if ( ! empty( $featured_image ) && '' !== $featured_image ) {
385
+                                             the_post_thumbnail( 'lsx-thumbnail', array(
386
+                                                  'class' => 'aligncenter',
387
+                                             ) );
388
+                                        } else {
389
+                                             ?>
390 390
 									<img loading="lazy"  class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
391 391
 									<?php
392
-								}
393
-								?>
392
+                                        }
393
+                                        ?>
394 394
 								</a>
395 395
 							</div>
396 396
 							<div class="content-box plan-content-box">
397 397
 								<h3 class="plan id-<?php the_ID(); ?> <?php echo esc_attr( $completed_class ); ?>"><a href="<?php echo esc_url( get_permalink() ); ?>"><?php the_title(); ?></a></h3>
398 398
 								<?php
399
-									echo wp_kses_post( \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) );
400
-								?>
399
+                                             echo wp_kses_post( \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) );
400
+                                        ?>
401 401
 								<?php
402
-								if ( false !== $linked_product && false !== $restricted ) {
403
-									echo wp_kses_post( $linked_product->get_price_html() );
404
-								}
405
-								?>
402
+                                        if ( false !== $linked_product && false !== $restricted ) {
403
+                                             echo wp_kses_post( $linked_product->get_price_html() );
404
+                                        }
405
+                                        ?>
406 406
 								<div class="excerpt">
407 407
 									<?php
408
-									if ( ! has_excerpt() ) {
409
-										$content = wp_trim_words( get_the_content(), 20 );
410
-										$content = '<p>' . $content . '</pre>';
411
-									} else {
412
-										$content = apply_filters( 'the_excerpt', get_the_excerpt() );
413
-									}
414
-									echo wp_kses_post( $content );
415
-									?>
408
+                                             if ( ! has_excerpt() ) {
409
+                                                  $content = wp_trim_words( get_the_content(), 20 );
410
+                                                  $content = '<p>' . $content . '</pre>';
411
+                                             } else {
412
+                                                  $content = apply_filters( 'the_excerpt', get_the_excerpt() );
413
+                                             }
414
+                                             echo wp_kses_post( $content );
415
+                                             ?>
416 416
 								</div>
417 417
 								<?php
418
-								if ( false === $restricted ) {
419
-									echo wp_kses_post( '<span class="progress"><progress class="bar" value="' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '" max="100"> ' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '% </progress><span>' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '%</span></span>' );
420
-								}
421
-								?>
418
+                                        if ( false === $restricted ) {
419
+                                             echo wp_kses_post( '<span class="progress"><progress class="bar" value="' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '" max="100"> ' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '% </progress><span>' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '%</span></span>' );
420
+                                        }
421
+                                        ?>
422 422
 							</div>
423 423
 						</article>
424 424
 					</div>
@@ -437,36 +437,36 @@  discard block
 block discarded – undo
437 437
  * @return void
438 438
  */
439 439
 function lsx_health_plan_day_plan_block( $args = array() ) {
440
-	$defaults = array(
441
-		'plan' => '',
442
-	);
443
-	$args     = wp_parse_args( $args, $defaults );
444
-
445
-	if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
446
-		$sections = \lsx_health_plan\functions\plan\get_sections( $args['plan'] );
447
-		?>
440
+     $defaults = array(
441
+          'plan' => '',
442
+     );
443
+     $args     = wp_parse_args( $args, $defaults );
444
+
445
+     if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
446
+          $sections = \lsx_health_plan\functions\plan\get_sections( $args['plan'] );
447
+          ?>
448 448
 		<div class="daily-plan-block day-grid">
449 449
 			<?php
450
-			foreach ( $sections as $section_key => $section_values ) {
451
-				$defaults    = array(
452
-					'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
453
-				);
454
-				$section_args = wp_parse_args( $section_values, $defaults );
455
-
456
-				$completed_class = '';
457
-				if ( lsx_health_plan_is_day_complete() ) {
458
-					$completed_class = 'completed';
459
-				}
460
-				?>
450
+               foreach ( $sections as $section_key => $section_values ) {
451
+                    $defaults    = array(
452
+                         'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
453
+                    );
454
+                    $section_args = wp_parse_args( $section_values, $defaults );
455
+
456
+                    $completed_class = '';
457
+                    if ( lsx_health_plan_is_day_complete() ) {
458
+                         $completed_class = 'completed';
459
+                    }
460
+                    ?>
461 461
 				<a href="<?php echo esc_attr( \lsx_health_plan\functions\plan\get_permalink( $args['plan'], $section_args['title'] ) ); ?>" class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>">
462 462
 					<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
463 463
 				</a>
464 464
 				<?php
465
-			}
466
-			?>
465
+               }
466
+               ?>
467 467
 		</div>
468 468
 		<?php
469
-	}
469
+     }
470 470
 }
471 471
 
472 472
 /**
@@ -476,44 +476,44 @@  discard block
 block discarded – undo
476 476
  * @return void
477 477
  */
478 478
 function lsx_health_plan_week_plan_block( $args = array() ) {
479
-	$defaults = array(
480
-		'show_downloads' => false,
481
-		'plan'           => '',
482
-	);
483
-	$args     = wp_parse_args( $args, $defaults );
484
-
485
-	if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
486
-		$groups = \lsx_health_plan\functions\plan\get_sections( $args['plan'], true );
487
-
488
-		if ( ! empty( $groups ) ) {
489
-			$counter    = 1;
490
-			$group_open = false;
491
-
492
-			foreach ( $groups as $group_key => $sections ) {
493
-				$collapse_class = '';
494
-				$group_title    = \lsx_health_plan\functions\plan\get_group_title( $sections );
495
-
496
-				// Determine if the current week is complete.
497
-				$day_ids = wp_list_pluck( $sections, 'title' );
498
-				if ( false === $group_open ) {
499
-					if ( 1 === $counter && ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
500
-						$collapse_class = 'in';
501
-						$group_open   = true;
502
-					} elseif ( ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
503
-						$collapse_class = 'in';
504
-						$group_open   = true;
505
-					}
506
-				}
507
-
508
-				// Determine if there are any weekly downloads.
509
-				$week_downloads_view = '';
510
-				/*if ( isset( $args['show_downloads'] ) && false !== $args['show_downloads'] ) {
479
+     $defaults = array(
480
+          'show_downloads' => false,
481
+          'plan'           => '',
482
+     );
483
+     $args     = wp_parse_args( $args, $defaults );
484
+
485
+     if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
486
+          $groups = \lsx_health_plan\functions\plan\get_sections( $args['plan'], true );
487
+
488
+          if ( ! empty( $groups ) ) {
489
+               $counter    = 1;
490
+               $group_open = false;
491
+
492
+               foreach ( $groups as $group_key => $sections ) {
493
+                    $collapse_class = '';
494
+                    $group_title    = \lsx_health_plan\functions\plan\get_group_title( $sections );
495
+
496
+                    // Determine if the current week is complete.
497
+                    $day_ids = wp_list_pluck( $sections, 'title' );
498
+                    if ( false === $group_open ) {
499
+                         if ( 1 === $counter && ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
500
+                              $collapse_class = 'in';
501
+                              $group_open   = true;
502
+                         } elseif ( ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
503
+                              $collapse_class = 'in';
504
+                              $group_open   = true;
505
+                         }
506
+                    }
507
+
508
+                    // Determine if there are any weekly downloads.
509
+                    $week_downloads_view = '';
510
+                    /*if ( isset( $args['show_downloads'] ) && false !== $args['show_downloads'] ) {
511 511
 					$weekly_downloads = \lsx_health_plan\functions\get_weekly_downloads( $group_key );
512 512
 					if ( ! empty( $weekly_downloads ) ) {
513 513
 						$week_downloads_view = 'week-downloads-view-on';
514 514
 					}
515 515
 				}*/
516
-				?>
516
+                    ?>
517 517
 				<div class="daily-plan-block week-grid">
518 518
 					<a href="#group-<?php echo esc_attr( $group_key ); ?>" data-toggle="collapse" class="week-title"><?php echo esc_attr( $group_title ); ?></a>
519 519
 					<div id="group-<?php echo esc_attr( $group_key ); ?>" class="week-row collapse <?php echo esc_attr( $collapse_class ); ?>">
@@ -527,38 +527,38 @@  discard block
 block discarded – undo
527 527
 								<div class="week-meals-recipes-box-inner">
528 528
 								<?php
529 529
 
530
-								foreach ( $sections as $section_key => $section_values ) {
530
+                                        foreach ( $sections as $section_key => $section_values ) {
531 531
 
532
-									$defaults    = array(
533
-										'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
534
-									);
535
-									$section_args = wp_parse_args( $section_values, $defaults );
532
+                                             $defaults    = array(
533
+                                                  'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
534
+                                             );
535
+                                             $section_args = wp_parse_args( $section_values, $defaults );
536 536
 
537
-									$completed_class = '';
538
-									if ( lsx_health_plan_is_day_complete( $args['plan'], $section_args['title'] ) ) {
539
-										$completed_class = 'completed';
540
-									}
541
-									?>
537
+                                             $completed_class = '';
538
+                                             if ( lsx_health_plan_is_day_complete( $args['plan'], $section_args['title'] ) ) {
539
+                                                  $completed_class = 'completed';
540
+                                             }
541
+                                             ?>
542 542
 									<a href="<?php echo esc_attr( \lsx_health_plan\functions\plan\get_permalink( $args['plan'], $section_args['title'] ) ); ?>" class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>">
543 543
 										<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
544 544
 									</a>
545 545
 									<?php
546
-								}
547
-								?>
546
+                                        }
547
+                                        ?>
548 548
 								</div>
549 549
 							</div>
550 550
 							<?php
551
-							if ( ! empty( $week_downloads_view ) ) {
552
-								//lsx_health_plan_weekly_downloads( $weekly_downloads );
553
-							}
554
-							?>
551
+                                   if ( ! empty( $week_downloads_view ) ) {
552
+                                        //lsx_health_plan_weekly_downloads( $weekly_downloads );
553
+                                   }
554
+                                   ?>
555 555
 						</div>
556 556
 					</div>
557 557
 				</div>
558 558
 				<?php
559
-			}
560
-		}
561
-	}
559
+               }
560
+          }
561
+     }
562 562
 }
563 563
 
564 564
 /**
@@ -568,22 +568,22 @@  discard block
 block discarded – undo
568 568
  * @return void
569 569
  */
570 570
 function lsx_health_plan_weekly_downloads( $weekly_downloads = array() ) {
571
-	if ( ! empty( $weekly_downloads ) ) {
572
-		?>
571
+     if ( ! empty( $weekly_downloads ) ) {
572
+          ?>
573 573
 		<div class="week-download-box">
574 574
 			<h3 class="title"><?php lsx_get_svg_icon( 'download.svg' ); ?><?php echo esc_html_e( 'Downloads', 'lsx-health-plan' ); ?></h3>
575 575
 			<ul class="week-download-box-list">
576 576
 				<?php
577
-				foreach ( $weekly_downloads as $weekly_download ) {
578
-					?>
577
+                    foreach ( $weekly_downloads as $weekly_download ) {
578
+                         ?>
579 579
 					<li><?php echo wp_kses_post( do_shortcode( '[download id="' . $weekly_download . '"]' ) ); ?></li>
580 580
 					<?php
581
-				}
582
-				?>
581
+                    }
582
+                    ?>
583 583
 			</ul>
584 584
 		</div>
585 585
 		<?php
586
-	}
586
+     }
587 587
 }
588 588
 
589 589
 /**
@@ -592,9 +592,9 @@  discard block
 block discarded – undo
592 592
  * @return void
593 593
  */
594 594
 function lsx_health_plan_items( $args = array() ) {
595
-	global $shortcode_args;
596
-	$shortcode_args = $args;
597
-	include LSX_HEALTH_PLAN_PATH . '/templates/partials/shortcode-loop.php';
595
+     global $shortcode_args;
596
+     $shortcode_args = $args;
597
+     include LSX_HEALTH_PLAN_PATH . '/templates/partials/shortcode-loop.php';
598 598
 }
599 599
 
600 600
 /**
@@ -603,10 +603,10 @@  discard block
 block discarded – undo
603 603
  * @return void
604 604
  */
605 605
 function lsx_health_plan_featured_video_block() {
606
-	if ( ! post_type_exists( 'video' ) ) {
607
-		return;
608
-	}
609
-	include LSX_HEALTH_PLAN_PATH . '/templates/featured-videos.php';
606
+     if ( ! post_type_exists( 'video' ) ) {
607
+          return;
608
+     }
609
+     include LSX_HEALTH_PLAN_PATH . '/templates/featured-videos.php';
610 610
 }
611 611
 
612 612
 /**
@@ -615,10 +615,10 @@  discard block
 block discarded – undo
615 615
  * @return void
616 616
  */
617 617
 function lsx_health_plan_featured_recipes_block() {
618
-	if ( ! post_type_exists( 'recipe' ) ) {
619
-		return;
620
-	}
621
-	include LSX_HEALTH_PLAN_PATH . '/templates/featured-recipes.php';
618
+     if ( ! post_type_exists( 'recipe' ) ) {
619
+          return;
620
+     }
621
+     include LSX_HEALTH_PLAN_PATH . '/templates/featured-recipes.php';
622 622
 }
623 623
 
624 624
 /**
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
  * @return void
628 628
  */
629 629
 function lsx_health_plan_featured_tips_block() {
630
-	include LSX_HEALTH_PLAN_PATH . '/templates/featured-tips.php';
630
+     include LSX_HEALTH_PLAN_PATH . '/templates/featured-tips.php';
631 631
 }
632 632
 
633 633
 /**
@@ -637,11 +637,11 @@  discard block
 block discarded – undo
637 637
  * @return void
638 638
  */
639 639
 function lsx_health_plan_day_button() {
640
-	if ( lsx_health_plan_is_day_complete() ) {
641
-		lsx_health_plan_unlock_button();
642
-	} else {
643
-		lsx_health_plan_complete_button();
644
-	}
640
+     if ( lsx_health_plan_is_day_complete() ) {
641
+          lsx_health_plan_unlock_button();
642
+     } else {
643
+          lsx_health_plan_complete_button();
644
+     }
645 645
 }
646 646
 
647 647
 /**
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
  * @return void
651 651
  */
652 652
 function lsx_health_plan_complete_button() {
653
-	?>
653
+     ?>
654 654
 	<div class="single-plan-inner-buttons">
655 655
 		<form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn">
656 656
 			<?php wp_nonce_field( 'complete', 'lsx-health-plan-actions' ); ?>
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
  * @return void
669 669
  */
670 670
 function lsx_health_plan_unlock_button() {
671
-	?>
671
+     ?>
672 672
 	<div class="single-plan-inner-buttons">
673 673
 		<form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn">
674 674
 			<?php wp_nonce_field( 'unlock', 'lsx-health-plan-actions' ); ?>
@@ -687,10 +687,10 @@  discard block
 block discarded – undo
687 687
  * @return void
688 688
  */
689 689
 function lsx_health_plan_single_nav() {
690
-	$tab_template_path = apply_filters( 'lsx_health_plan_single_nav_path', LSX_HEALTH_PLAN_PATH . '/templates/single-plan-tabs.php' );
691
-	if ( '' !== $tab_template_path ) {
692
-		require $tab_template_path;
693
-	}
690
+     $tab_template_path = apply_filters( 'lsx_health_plan_single_nav_path', LSX_HEALTH_PLAN_PATH . '/templates/single-plan-tabs.php' );
691
+     if ( '' !== $tab_template_path ) {
692
+          require $tab_template_path;
693
+     }
694 694
 }
695 695
 
696 696
 /**
@@ -700,32 +700,32 @@  discard block
 block discarded – undo
700 700
  * @return void
701 701
  */
702 702
 function lsx_health_plan_single_tabs() {
703
-	$endpoint = get_query_var( 'endpoint' );
704
-	switch ( $endpoint ) {
705
-		case 'meal':
706
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-meal.php';
707
-			break;
708
-
709
-		case 'recipes':
710
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-recipes.php';
711
-			break;
712
-
713
-		case 'workout':
714
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-workout.php';
715
-			break;
716
-
717
-		case 'warm-up':
718
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-warm-up.php';
719
-			break;
720
-
721
-		default:
722
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-plan.php';
723
-			break;
724
-	}
725
-	$tab_template_path = apply_filters( 'lsx_health_plan_single_tab_path', $tab_template_path );
726
-	if ( '' !== $tab_template_path ) {
727
-		include $tab_template_path;
728
-	}
703
+     $endpoint = get_query_var( 'endpoint' );
704
+     switch ( $endpoint ) {
705
+          case 'meal':
706
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-meal.php';
707
+               break;
708
+
709
+          case 'recipes':
710
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-recipes.php';
711
+               break;
712
+
713
+          case 'workout':
714
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-workout.php';
715
+               break;
716
+
717
+          case 'warm-up':
718
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-warm-up.php';
719
+               break;
720
+
721
+          default:
722
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-plan.php';
723
+               break;
724
+     }
725
+     $tab_template_path = apply_filters( 'lsx_health_plan_single_tab_path', $tab_template_path );
726
+     if ( '' !== $tab_template_path ) {
727
+          include $tab_template_path;
728
+     }
729 729
 }
730 730
 
731 731
 /**
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
  * @return void
735 735
  */
736 736
 function lsx_health_plan_recipe_data() {
737
-	include LSX_HEALTH_PLAN_PATH . '/templates/table-recipe-data.php';
737
+     include LSX_HEALTH_PLAN_PATH . '/templates/table-recipe-data.php';
738 738
 }
739 739
 
740 740
 /**
@@ -743,11 +743,11 @@  discard block
 block discarded – undo
743 743
  * @return recipe_type
744 744
  */
745 745
 function lsx_health_plan_recipe_type() {
746
-	$term_obj_list = get_the_terms( get_the_ID(), 'recipe-type' );
747
-	$recipe_type   = $term_obj_list[0]->name;
748
-	if ( ! empty( $recipe_type ) ) {
749
-		return $recipe_type;
750
-	}
746
+     $term_obj_list = get_the_terms( get_the_ID(), 'recipe-type' );
747
+     $recipe_type   = $term_obj_list[0]->name;
748
+     if ( ! empty( $recipe_type ) ) {
749
+          return $recipe_type;
750
+     }
751 751
 }
752 752
 
753 753
 /**
@@ -758,35 +758,35 @@  discard block
 block discarded – undo
758 758
  * @return void
759 759
  */
760 760
 function lsx_health_plan_workout_video_play_button( $m, $group, $echo = true ) {
761
-	$workout_video = '';
762
-	$giphy         = '';
763
-	$youtube       = '';
764
-	if ( isset( $group['connected_videos'] ) && '' !== $group['connected_videos'] ) {
765
-		$workout_video = esc_html( $group['connected_videos'] );
766
-		$giphy         = get_post_meta( $workout_video, 'video_giphy_source', true );
767
-		$youtube       = esc_url( get_post_meta( $workout_video, 'video_youtube_source', 1 ) );
768
-		$content       = get_post_field( 'post_content', $workout_video );
769
-		$play_button   = '<button data-toggle="modal" data-target="#workout-video-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>';
770
-
771
-		$modal_body = '';
772
-		if ( ! empty( $giphy ) ) {
773
-			$giphy      = \lsx_health_plan\functions\get_video_url( $giphy );
774
-			$modal_body = $giphy; // WPCS: XSS OK.
775
-		} elseif ( ! empty( $youtube ) ) {
776
-			$modal_body = wp_oembed_get( $youtube, array( // WPCS: XSS OK.
777
-				'width' => 480,
778
-			) );
779
-		}
780
-		$modal_body .= '<h5 class="modal-title title-lined">' . $group['name'] . '</h5>';
781
-		$modal_body .= $content;
782
-		\lsx_health_plan\functions\register_modal( 'workout-video-modal-' . $m, '', $modal_body );
783
-
784
-		if ( true === $echo ) {
785
-			echo wp_kses_post( $play_button );
786
-		} else {
787
-			return $play_button;
788
-		}
789
-	}
761
+     $workout_video = '';
762
+     $giphy         = '';
763
+     $youtube       = '';
764
+     if ( isset( $group['connected_videos'] ) && '' !== $group['connected_videos'] ) {
765
+          $workout_video = esc_html( $group['connected_videos'] );
766
+          $giphy         = get_post_meta( $workout_video, 'video_giphy_source', true );
767
+          $youtube       = esc_url( get_post_meta( $workout_video, 'video_youtube_source', 1 ) );
768
+          $content       = get_post_field( 'post_content', $workout_video );
769
+          $play_button   = '<button data-toggle="modal" data-target="#workout-video-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>';
770
+
771
+          $modal_body = '';
772
+          if ( ! empty( $giphy ) ) {
773
+               $giphy      = \lsx_health_plan\functions\get_video_url( $giphy );
774
+               $modal_body = $giphy; // WPCS: XSS OK.
775
+          } elseif ( ! empty( $youtube ) ) {
776
+               $modal_body = wp_oembed_get( $youtube, array( // WPCS: XSS OK.
777
+                    'width' => 480,
778
+               ) );
779
+          }
780
+          $modal_body .= '<h5 class="modal-title title-lined">' . $group['name'] . '</h5>';
781
+          $modal_body .= $content;
782
+          \lsx_health_plan\functions\register_modal( 'workout-video-modal-' . $m, '', $modal_body );
783
+
784
+          if ( true === $echo ) {
785
+               echo wp_kses_post( $play_button );
786
+          } else {
787
+               return $play_button;
788
+          }
789
+     }
790 790
 }
791 791
 
792 792
 /**
@@ -795,21 +795,21 @@  discard block
 block discarded – undo
795 795
  * @return void
796 796
  */
797 797
 function lsx_health_plan_recipe_archive_description() {
798
-	$description = '';
799
-	if ( is_post_type_archive( 'recipe' ) ) {
800
-		$description = \lsx_health_plan\functions\get_option( 'recipe_archive_description', '' );
801
-	} elseif ( is_post_type_archive( 'exercise' ) ) {
802
-		$description = \lsx_health_plan\functions\get_option( 'exercise_archive_description', '' );
803
-	} elseif ( is_tax() ) {
804
-		$description = get_the_archive_description();
805
-	}
806
-	if ( '' !== $description ) {
807
-		?>
798
+     $description = '';
799
+     if ( is_post_type_archive( 'recipe' ) ) {
800
+          $description = \lsx_health_plan\functions\get_option( 'recipe_archive_description', '' );
801
+     } elseif ( is_post_type_archive( 'exercise' ) ) {
802
+          $description = \lsx_health_plan\functions\get_option( 'exercise_archive_description', '' );
803
+     } elseif ( is_tax() ) {
804
+          $description = get_the_archive_description();
805
+     }
806
+     if ( '' !== $description ) {
807
+          ?>
808 808
 		<div class="lsx-hp-archive-description row">
809 809
 			<div class="col-xs-12 description-wrapper"><?php echo wp_kses_post( $description ); ?></div>
810 810
 		</div>
811 811
 		<?php
812
-	}
812
+     }
813 813
 }
814 814
 
815 815
 /**
@@ -818,24 +818,24 @@  discard block
 block discarded – undo
818 818
  * @return void
819 819
  */
820 820
 function lsx_health_plan_main_content() {
821
-	// Getting translated endpoint.
822
-	$plan = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' );
823
-
824
-	$connected_members = get_post_meta( get_the_ID(), ( $plan . '_connected_team_member' ), true );
825
-	$small_description = get_post_meta( get_the_ID(), ( $plan . '_short_description' ), true );
826
-
827
-	$content_plan = '';
828
-	if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
829
-		$content_plan .= '<div class="set-box set content-box entry-content">';
830
-		$content_plan .= '<div class="the-content">';
831
-		$content_plan .= lsx_hp_member_connected( $connected_members, $plan );
832
-		$content_plan .= '<span>' . $small_description . '</span>';
833
-		$content_plan .= '</div>';
834
-		$content_plan .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
835
-		$content_plan .= '</div>';
836
-	}
837
-
838
-	return $content_plan;
821
+     // Getting translated endpoint.
822
+     $plan = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' );
823
+
824
+     $connected_members = get_post_meta( get_the_ID(), ( $plan . '_connected_team_member' ), true );
825
+     $small_description = get_post_meta( get_the_ID(), ( $plan . '_short_description' ), true );
826
+
827
+     $content_plan = '';
828
+     if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
829
+          $content_plan .= '<div class="set-box set content-box entry-content">';
830
+          $content_plan .= '<div class="the-content">';
831
+          $content_plan .= lsx_hp_member_connected( $connected_members, $plan );
832
+          $content_plan .= '<span>' . $small_description . '</span>';
833
+          $content_plan .= '</div>';
834
+          $content_plan .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
835
+          $content_plan .= '</div>';
836
+     }
837
+
838
+     return $content_plan;
839 839
 }
840 840
 
841 841
 /**
@@ -844,23 +844,23 @@  discard block
 block discarded – undo
844 844
  * @return void
845 845
  */
846 846
 function lsx_health_plan_workout_main_content() {
847
-	// Getting translated endpoint.
848
-	$workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
849
-
850
-	$connected_members = get_post_meta( get_the_ID(), ( $workout . '_connected_team_member' ), true );
851
-	$small_description = get_post_meta( get_the_ID(), ( $workout . '_short_description' ), true );
852
-
853
-	$content = '';
854
-	if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
855
-		$content .= '<div class="set-box set content-box entry-content">';
856
-		$content .= '<div class="the-content">';
857
-		$content .= lsx_hp_member_connected( $connected_members, $workout );
858
-		$content .= '<span>' . $small_description . '</span>';
859
-		$content .= '</div>';
860
-		$content .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
861
-		$content .= '</div>';
862
-	}
863
-	return $content;
847
+     // Getting translated endpoint.
848
+     $workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
849
+
850
+     $connected_members = get_post_meta( get_the_ID(), ( $workout . '_connected_team_member' ), true );
851
+     $small_description = get_post_meta( get_the_ID(), ( $workout . '_short_description' ), true );
852
+
853
+     $content = '';
854
+     if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
855
+          $content .= '<div class="set-box set content-box entry-content">';
856
+          $content .= '<div class="the-content">';
857
+          $content .= lsx_hp_member_connected( $connected_members, $workout );
858
+          $content .= '<span>' . $small_description . '</span>';
859
+          $content .= '</div>';
860
+          $content .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
861
+          $content .= '</div>';
862
+     }
863
+     return $content;
864 864
 }
865 865
 
866 866
 /**
@@ -869,23 +869,23 @@  discard block
 block discarded – undo
869 869
  * @return void
870 870
  */
871 871
 function lsx_health_plan_meal_main_content() {
872
-	// Getting translated endpoint.
873
-	$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
874
-
875
-	$connected_members = get_post_meta( get_the_ID(), ( $meal . '_connected_team_member' ), true );
876
-	$small_description = get_post_meta( get_the_ID(), ( $meal . '_short_description' ), true );
877
-
878
-	$content_meal = '';
879
-	if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
880
-		$content_meal .= '<div class="set-box set content-box entry-content">';
881
-		$content_meal .= '<div class="the-content">';
882
-		$content_meal .= lsx_hp_member_connected( $connected_members, $meal );
883
-		$content_meal .= '<span>' . $small_description . '</span>';
884
-		$content_meal .= '</div>';
885
-		$content_meal .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
886
-		$content_meal .= '</div>';
887
-	}
888
-	return $content_meal;
872
+     // Getting translated endpoint.
873
+     $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
874
+
875
+     $connected_members = get_post_meta( get_the_ID(), ( $meal . '_connected_team_member' ), true );
876
+     $small_description = get_post_meta( get_the_ID(), ( $meal . '_short_description' ), true );
877
+
878
+     $content_meal = '';
879
+     if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
880
+          $content_meal .= '<div class="set-box set content-box entry-content">';
881
+          $content_meal .= '<div class="the-content">';
882
+          $content_meal .= lsx_hp_member_connected( $connected_members, $meal );
883
+          $content_meal .= '<span>' . $small_description . '</span>';
884
+          $content_meal .= '</div>';
885
+          $content_meal .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
886
+          $content_meal .= '</div>';
887
+     }
888
+     return $content_meal;
889 889
 }
890 890
 
891 891
 
@@ -896,36 +896,36 @@  discard block
 block discarded – undo
896 896
  * @return void
897 897
  */
898 898
 function lsx_health_plan_workout_tab_content( $index = 1 ) {
899
-	global $group_name,$shortcode_args;
900
-	$group_name = 'workout_section_' . $index;
901
-	if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
902
-		$layout = strtolower( \lsx_health_plan\functions\get_option( 'workout_tab_layout', 'table' ) );
903
-
904
-		// Check for shortcode overrides.
905
-		if ( null !== $shortcode_args && isset( $shortcode_args['layout'] ) ) {
906
-			$layout = $shortcode_args['layout'];
907
-		}
908
-	} else {
909
-		$layout = 'table';
910
-	}
911
-
912
-	switch ( $layout ) {
913
-		case 'list':
914
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-list.php';
915
-			break;
916
-
917
-		case 'grid':
918
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-grid.php';
919
-			break;
920
-
921
-		case 'table':
922
-			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-table.php';
923
-			break;
924
-	}
925
-	$tab_template_path = apply_filters( 'lsx_health_plan_workout_tab_content_path', $tab_template_path );
926
-	if ( '' !== $tab_template_path ) {
927
-		include $tab_template_path;
928
-	}
899
+     global $group_name,$shortcode_args;
900
+     $group_name = 'workout_section_' . $index;
901
+     if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
902
+          $layout = strtolower( \lsx_health_plan\functions\get_option( 'workout_tab_layout', 'table' ) );
903
+
904
+          // Check for shortcode overrides.
905
+          if ( null !== $shortcode_args && isset( $shortcode_args['layout'] ) ) {
906
+               $layout = $shortcode_args['layout'];
907
+          }
908
+     } else {
909
+          $layout = 'table';
910
+     }
911
+
912
+     switch ( $layout ) {
913
+          case 'list':
914
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-list.php';
915
+               break;
916
+
917
+          case 'grid':
918
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-grid.php';
919
+               break;
920
+
921
+          case 'table':
922
+               $tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-table.php';
923
+               break;
924
+     }
925
+     $tab_template_path = apply_filters( 'lsx_health_plan_workout_tab_content_path', $tab_template_path );
926
+     if ( '' !== $tab_template_path ) {
927
+          include $tab_template_path;
928
+     }
929 929
 }
930 930
 
931 931
 /**
@@ -934,28 +934,28 @@  discard block
 block discarded – undo
934 934
  * @return void
935 935
  */
936 936
 function lsx_health_plan_workout_sets() {
937
-	if ( is_singular( 'workout' ) ) {
938
-		global $connected_workouts;
939
-		$connected_workouts = array( get_the_ID() );
940
-	}
941
-	if ( is_singular( 'plan' ) ) {
942
-
943
-		global $connected_workouts;
944
-
945
-		$section_key  = get_query_var( 'section' );
946
-		if ( '' !== $section && \lsx_health_plan\functions\plan\has_sections() ) {
947
-			$section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key );
948
-			if ( isset( $section_info['connected_workouts'] ) && '' !== $section_info['connected_workouts'] ) {
949
-
950
-				$connected_workouts = \lsx_health_plan\functions\prep_array( $section_info['connected_workouts'] );
951
-			}
952
-		}
953
-	}
954
-	$template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
955
-	$template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
956
-	if ( '' !== $template_path && ! empty( $template_path ) ) {
957
-		include $template_path;
958
-	}
937
+     if ( is_singular( 'workout' ) ) {
938
+          global $connected_workouts;
939
+          $connected_workouts = array( get_the_ID() );
940
+     }
941
+     if ( is_singular( 'plan' ) ) {
942
+
943
+          global $connected_workouts;
944
+
945
+          $section_key  = get_query_var( 'section' );
946
+          if ( '' !== $section && \lsx_health_plan\functions\plan\has_sections() ) {
947
+               $section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key );
948
+               if ( isset( $section_info['connected_workouts'] ) && '' !== $section_info['connected_workouts'] ) {
949
+
950
+                    $connected_workouts = \lsx_health_plan\functions\prep_array( $section_info['connected_workouts'] );
951
+               }
952
+          }
953
+     }
954
+     $template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
955
+     $template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
956
+     if ( '' !== $template_path && ! empty( $template_path ) ) {
957
+          include $template_path;
958
+     }
959 959
 }
960 960
 
961 961
 /**
@@ -965,48 +965,48 @@  discard block
 block discarded – undo
965 965
  * @return void
966 966
  */
967 967
 function lsx_hp_meal_plan_recipes( $args = array() ) {
968
-	$defaults = array(
969
-		'meal_id'   => false,
970
-		'meal_time' => '',
971
-		'modal'     => true,
972
-	);
973
-	$args     = wp_parse_args( $args, $defaults );
974
-	// Looking for recipes.
975
-	$connected_recipes = get_post_meta( $args['meal_id'], $args['meal_time'] . '_recipes', true );
976
-	if ( ! empty( $connected_recipes ) ) {
977
-		$query_args    = array(
978
-			'orderby'   => 'date',
979
-			'order'     => 'DESC',
980
-			'post_type' => 'recipe',
981
-			'post__in'  => $connected_recipes,
982
-		);
983
-		$recipes = new WP_Query( $query_args );
984
-		?>
968
+     $defaults = array(
969
+          'meal_id'   => false,
970
+          'meal_time' => '',
971
+          'modal'     => true,
972
+     );
973
+     $args     = wp_parse_args( $args, $defaults );
974
+     // Looking for recipes.
975
+     $connected_recipes = get_post_meta( $args['meal_id'], $args['meal_time'] . '_recipes', true );
976
+     if ( ! empty( $connected_recipes ) ) {
977
+          $query_args    = array(
978
+               'orderby'   => 'date',
979
+               'order'     => 'DESC',
980
+               'post_type' => 'recipe',
981
+               'post__in'  => $connected_recipes,
982
+          );
983
+          $recipes = new WP_Query( $query_args );
984
+          ?>
985 985
 		<div class="recipes">
986 986
 			<div class="row eating-row">
987 987
 			<?php
988
-			if ( $recipes->have_posts() ) {
989
-				while ( $recipes->have_posts() ) {
990
-					$recipes->the_post();
991
-					if ( false !== $args['modal'] ) {
992
-						\lsx_health_plan\functions\recipes\register_recipe_modal();
993
-					}
994
-					?>
988
+               if ( $recipes->have_posts() ) {
989
+                    while ( $recipes->have_posts() ) {
990
+                         $recipes->the_post();
991
+                         if ( false !== $args['modal'] ) {
992
+                              \lsx_health_plan\functions\recipes\register_recipe_modal();
993
+                         }
994
+                         ?>
995 995
 					<div class="recipe-column">
996 996
 						<a data-toggle="modal" data-target="#recipe-modal-<?php echo esc_attr( get_the_ID() ); ?>" href="#recipe-modal-<?php echo esc_attr( get_the_ID() ); ?>" class="recipe-box box-shadow">
997 997
 							<div class="recipe-feature-img">
998 998
 								<?php
999
-								$featured_image = get_the_post_thumbnail();
1000
-								if ( ! empty( $featured_image ) && '' !== $featured_image ) {
1001
-									the_post_thumbnail( 'lsx-thumbnail-square', array(
1002
-										'class' => 'aligncenter',
1003
-									) );
1004
-								} else {
1005
-									?>
999
+                                        $featured_image = get_the_post_thumbnail();
1000
+                                        if ( ! empty( $featured_image ) && '' !== $featured_image ) {
1001
+                                             the_post_thumbnail( 'lsx-thumbnail-square', array(
1002
+                                                  'class' => 'aligncenter',
1003
+                                             ) );
1004
+                                        } else {
1005
+                                             ?>
1006 1006
 									<img loading="lazy" src="<?php echo esc_attr( plugin_dir_url( __DIR__ ) . 'assets/images/placeholder.jpg' ); ?>">
1007 1007
 									<?php
1008
-								}
1009
-								?>
1008
+                                        }
1009
+                                        ?>
1010 1010
 							</div>
1011 1011
 							<div class="recipe-content">
1012 1012
 								<h3 class="recipe-title"><?php the_title(); ?></h3>
@@ -1015,41 +1015,41 @@  discard block
 block discarded – undo
1015 1015
 						</a>
1016 1016
 					</div>
1017 1017
 				<?php
1018
-				}
1019
-			}
1020
-			wp_reset_postdata();
1021
-			?>
1018
+                    }
1019
+               }
1020
+               wp_reset_postdata();
1021
+               ?>
1022 1022
 			</div>
1023 1023
 		</div>
1024 1024
 		<?php
1025 1025
 
1026
-	}
1026
+     }
1027 1027
 }
1028 1028
 
1029 1029
 /**
1030 1030
  * Output the connected.
1031 1031
  */
1032 1032
 function lsx_hp_recipe_plan_meta( $args = array() ) {
1033
-	$defaults = array();
1034
-	$top_level_plans = array();
1035
-	// Get meals this exercise is connected to.
1036
-	$plans = get_post_meta( get_the_ID(), 'connected_plans', true );
1037
-	if ( ! empty( $plans ) ) {
1038
-		$plan       = end( $plans );
1039
-		$has_parent = wp_get_post_parent_id( $plan );
1040
-		if ( 0 === $has_parent ) {
1041
-			$top_level_plans[] = $plan;
1042
-		} elseif ( false !== $top_level_plans ) {
1043
-			$top_level_plans[] = $has_parent;
1044
-		}
1045
-	}
1046
-	if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
1047
-		$top_level_plans = array_unique( $top_level_plans );
1048
-		$top_level_plan  = end( $top_level_plans );
1049
-		?>
1033
+     $defaults = array();
1034
+     $top_level_plans = array();
1035
+     // Get meals this exercise is connected to.
1036
+     $plans = get_post_meta( get_the_ID(), 'connected_plans', true );
1037
+     if ( ! empty( $plans ) ) {
1038
+          $plan       = end( $plans );
1039
+          $has_parent = wp_get_post_parent_id( $plan );
1040
+          if ( 0 === $has_parent ) {
1041
+               $top_level_plans[] = $plan;
1042
+          } elseif ( false !== $top_level_plans ) {
1043
+               $top_level_plans[] = $has_parent;
1044
+          }
1045
+     }
1046
+     if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
1047
+          $top_level_plans = array_unique( $top_level_plans );
1048
+          $top_level_plan  = end( $top_level_plans );
1049
+          ?>
1050 1050
 			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1051 1051
 		<?php
1052
-	}
1052
+     }
1053 1053
 }
1054 1054
 
1055 1055
 /**
@@ -1057,42 +1057,42 @@  discard block
 block discarded – undo
1057 1057
  */
1058 1058
 function lsx_hp_exercise_plan_meta() {
1059 1059
 
1060
-	$top_level_plans = array();
1061
-
1062
-	// Get workouts this exercise is connected to.
1063
-	$workouts = get_post_meta( get_the_ID(), 'connected_workouts', true );
1064
-
1065
-	if ( '' !== $workouts && ! is_array( $workouts ) ) {
1066
-		$workouts = array( $workouts );
1067
-	}
1068
-	if ( ! empty( $workouts ) ) {
1069
-		foreach ( $workouts as $workout ) {
1070
-			// Get the plans this workout is connected to.
1071
-			$plans = get_post_meta( $workout, 'connected_plans', true );
1072
-
1073
-			if ( '' !== $plans && ! is_array( $plans ) ) {
1074
-				$plans = array( $plans );
1075
-			}
1076
-			if ( ! empty( $plans ) ) {
1077
-				foreach ( $plans as $plan ) {
1078
-					$has_parent = wp_get_post_parent_id( $plan );
1079
-					if ( 0 === $has_parent ) {
1080
-						$top_level_plans = $plan;
1081
-					} else {
1082
-						$top_level_plans = $has_parent;
1083
-					}
1084
-				}
1085
-			}
1086
-		}
1087
-	}
1088
-
1089
-	if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
1090
-		$top_level_plans = array_unique( $top_level_plans );
1091
-		$top_level_plan  = end( $top_level_plans );
1092
-		?>
1060
+     $top_level_plans = array();
1061
+
1062
+     // Get workouts this exercise is connected to.
1063
+     $workouts = get_post_meta( get_the_ID(), 'connected_workouts', true );
1064
+
1065
+     if ( '' !== $workouts && ! is_array( $workouts ) ) {
1066
+          $workouts = array( $workouts );
1067
+     }
1068
+     if ( ! empty( $workouts ) ) {
1069
+          foreach ( $workouts as $workout ) {
1070
+               // Get the plans this workout is connected to.
1071
+               $plans = get_post_meta( $workout, 'connected_plans', true );
1072
+
1073
+               if ( '' !== $plans && ! is_array( $plans ) ) {
1074
+                    $plans = array( $plans );
1075
+               }
1076
+               if ( ! empty( $plans ) ) {
1077
+                    foreach ( $plans as $plan ) {
1078
+                         $has_parent = wp_get_post_parent_id( $plan );
1079
+                         if ( 0 === $has_parent ) {
1080
+                              $top_level_plans = $plan;
1081
+                         } else {
1082
+                              $top_level_plans = $has_parent;
1083
+                         }
1084
+                    }
1085
+               }
1086
+          }
1087
+     }
1088
+
1089
+     if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
1090
+          $top_level_plans = array_unique( $top_level_plans );
1091
+          $top_level_plan  = end( $top_level_plans );
1092
+          ?>
1093 1093
 			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1094 1094
 		<?php
1095
-	}
1095
+     }
1096 1096
 }
1097 1097
 
1098 1098
 /**
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
  * @return void
1103 1103
  */
1104 1104
 function lsx_hp_single_related( $related_content, $post_type_text ) {
1105
-	?>
1105
+     ?>
1106 1106
 	<section id="lsx-hp-related">
1107 1107
 		<div class="row lsx-related-posts lsx-related-posts-title">
1108 1108
 			<div class="col-xs-12">
@@ -1113,13 +1113,13 @@  discard block
 block discarded – undo
1113 1113
 			<div class="col-xs-12">
1114 1114
 				<div class="lsx-related-posts-wrapper">
1115 1115
 					<?php
1116
-					foreach ( $related_content as $article ) {
1117
-						$post_title      = get_the_title( $article );
1118
-						$post_categories = wp_get_post_categories( $article );
1119
-						$post_link       = get_permalink( $article );
1116
+                         foreach ( $related_content as $article ) {
1117
+                              $post_title      = get_the_title( $article );
1118
+                              $post_categories = wp_get_post_categories( $article );
1119
+                              $post_link       = get_permalink( $article );
1120 1120
 
1121
-						$cats = array();
1122
-						?>
1121
+                              $cats = array();
1122
+                              ?>
1123 1123
 						<article id="post-<?php echo esc_html( $article ); ?>" class="lsx-slot post">
1124 1124
 							<div class="entry-layout lsx-hp-shadow">
1125 1125
 								<div class="entry-layout-content">
@@ -1127,25 +1127,25 @@  discard block
 block discarded – undo
1127 1127
 										<div class="entry-image">
1128 1128
 											<a href="<?php echo esc_url( $post_link ); ?>" class="thumbnail">
1129 1129
 											<?php
1130
-											$featured_image = get_the_post_thumbnail( $article, 'lsx-thumbnail-wide' );
1131
-											if ( ! empty( $featured_image ) && '' !== $featured_image ) {
1132
-												echo wp_kses_post( $featured_image );
1133
-											} else {
1134
-												?>
1130
+                                                       $featured_image = get_the_post_thumbnail( $article, 'lsx-thumbnail-wide' );
1131
+                                                       if ( ! empty( $featured_image ) && '' !== $featured_image ) {
1132
+                                                            echo wp_kses_post( $featured_image );
1133
+                                                       } else {
1134
+                                                            ?>
1135 1135
 												<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
1136 1136
 												<?php
1137
-											}
1138
-											?>
1137
+                                                       }
1138
+                                                       ?>
1139 1139
 											</a>
1140 1140
 										</div>
1141 1141
 										<div class="entry-meta">
1142 1142
 										<?php
1143
-										foreach ( $post_categories as $c ) {
1144
-											$cat = get_category( $c );
1145
-											/* Translators: %s: category name */
1146
-											$cats[] = '<a href="' . esc_url( get_category_link( $cat->term_id ) ) . '" title="' . sprintf( esc_html__( 'Posts in %s', 'lsx-blog-customizer' ), $cat->name ) . '">' . $cat->name . '</a>';
1147
-										}
1148
-										if ( ! empty( $cats ) ) { ?>
1143
+                                                  foreach ( $post_categories as $c ) {
1144
+                                                       $cat = get_category( $c );
1145
+                                                       /* Translators: %s: category name */
1146
+                                                       $cats[] = '<a href="' . esc_url( get_category_link( $cat->term_id ) ) . '" title="' . sprintf( esc_html__( 'Posts in %s', 'lsx-blog-customizer' ), $cat->name ) . '">' . $cat->name . '</a>';
1147
+                                                  }
1148
+                                                  if ( ! empty( $cats ) ) { ?>
1149 1149
 											<div class="post-categories"><span></span><?php echo wp_kses_post( implode( ', ', $cats ) ); ?></div>
1150 1150
 										<?php } ?>
1151 1151
 										</div>
@@ -1174,32 +1174,32 @@  discard block
 block discarded – undo
1174 1174
  * @return void
1175 1175
  */
1176 1176
 function lsx_hp_member_connected( $connected_members, $post_type ) {
1177
-	if ( ! empty( $connected_members ) ) {
1178
-		$content = '<div id="hp-connected-members" class="hp-connected-members connected-' . $post_type . '">';
1179
-		foreach ( $connected_members as $member ) {
1180
-			$post_link   = get_permalink( $member );
1181
-			$member_name = get_the_title( $member );
1182
-			$member_name = '<span class="lsx-team-name">' . $member_name . '</span>';
1183
-
1184
-			$member_link = '<a href="' . $post_link . '" >' . $member_name . '</a>';
1185
-
1186
-			$roles = '';
1187
-			$terms = get_the_terms( $member, 'team_role' );
1188
-
1189
-			if ( $terms && ! is_wp_error( $terms ) ) {
1190
-				$roles = array();
1191
-
1192
-				foreach ( $terms as $term ) {
1193
-					$roles[] = $term->name;
1194
-				}
1195
-
1196
-				$roles = join( ', ', $roles );
1197
-			}
1198
-			$member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : '';
1199
-
1200
-			$content .= '<p>' . $member_roles . ': ' . $member_link . '</p>';
1201
-		}
1202
-		$content .= '</div>';
1203
-		return $content;
1204
-	}
1177
+     if ( ! empty( $connected_members ) ) {
1178
+          $content = '<div id="hp-connected-members" class="hp-connected-members connected-' . $post_type . '">';
1179
+          foreach ( $connected_members as $member ) {
1180
+               $post_link   = get_permalink( $member );
1181
+               $member_name = get_the_title( $member );
1182
+               $member_name = '<span class="lsx-team-name">' . $member_name . '</span>';
1183
+
1184
+               $member_link = '<a href="' . $post_link . '" >' . $member_name . '</a>';
1185
+
1186
+               $roles = '';
1187
+               $terms = get_the_terms( $member, 'team_role' );
1188
+
1189
+               if ( $terms && ! is_wp_error( $terms ) ) {
1190
+                    $roles = array();
1191
+
1192
+                    foreach ( $terms as $term ) {
1193
+                         $roles[] = $term->name;
1194
+                    }
1195
+
1196
+                    $roles = join( ', ', $roles );
1197
+               }
1198
+               $member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : '';
1199
+
1200
+               $content .= '<p>' . $member_roles . ': ' . $member_link . '</p>';
1201
+          }
1202
+          $content .= '</div>';
1203
+          return $content;
1204
+     }
1205 1205
 }
Please login to merge, or discard this patch.
Spacing   +286 added lines, -286 removed lines patch added patch discarded remove patch
@@ -14,23 +14,23 @@  discard block
 block discarded – undo
14 14
 	?>
15 15
 	<div class="col-md-4" >
16 16
 		<div class="lsx-health-plan-box">
17
-			<h3 class="title warm-up-title title-lined"><?php esc_html_e( 'Your Warm-up', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'warm.svg' ); ?></h3>
17
+			<h3 class="title warm-up-title title-lined"><?php esc_html_e('Your Warm-up', 'lsx-health-plan'); ?><?php lsx_get_svg_icon('warm.svg'); ?></h3>
18 18
 			<div class="spacer"></div>
19 19
 			<?php
20
-			$intro_text = \lsx_health_plan\functions\get_option( 'warmup_intro', false );
21
-			if ( false !== $intro_text ) {
20
+			$intro_text = \lsx_health_plan\functions\get_option('warmup_intro', false);
21
+			if (false !== $intro_text) {
22 22
 				?>
23 23
 				<div class="excerpt">
24
-					<p><?php echo wp_kses_post( $intro_text ); ?></p>
24
+					<p><?php echo wp_kses_post($intro_text); ?></p>
25 25
 				</div>
26 26
 				<?php
27 27
 			}
28
-			$warm_up = \lsx_health_plan\functions\get_option( 'endpoint_warm_up', false );
29
-			if ( false === $warm_up ) {
28
+			$warm_up = \lsx_health_plan\functions\get_option('endpoint_warm_up', false);
29
+			if (false === $warm_up) {
30 30
 				$warm_up = 'warm-up';
31 31
 			}
32 32
 			?>
33
-			<a href="<?php the_permalink(); ?><?php echo esc_attr( $warm_up ); ?>/" class="btn"><?php esc_html_e( 'Start your warm-up', 'lsx-health-plan' ); ?></a>
33
+			<a href="<?php the_permalink(); ?><?php echo esc_attr($warm_up); ?>/" class="btn"><?php esc_html_e('Start your warm-up', 'lsx-health-plan'); ?></a>
34 34
 		</div>
35 35
 	</div>
36 36
 <?php
@@ -42,29 +42,29 @@  discard block
 block discarded – undo
42 42
 * @return void
43 43
 */
44 44
 function lsx_health_plan_workout_box() {
45
-	if ( ! post_type_exists( 'workout' ) ) {
45
+	if ( ! post_type_exists('workout')) {
46 46
 		return;
47 47
 	}
48 48
 	?>
49 49
 	<div class="col-md-4" >
50 50
 		<div class="lsx-health-plan-box">
51
-			<h3 class="title work-out-title title-lined"><?php esc_html_e( 'Your Workout', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'work.svg' ); ?></h3>
51
+			<h3 class="title work-out-title title-lined"><?php esc_html_e('Your Workout', 'lsx-health-plan'); ?><?php lsx_get_svg_icon('work.svg'); ?></h3>
52 52
 			<div class="spacer"></div>
53 53
 			<?php
54
-			$intro_text = \lsx_health_plan\functions\get_option( 'workout_intro', false );
55
-			if ( false !== $intro_text ) {
54
+			$intro_text = \lsx_health_plan\functions\get_option('workout_intro', false);
55
+			if (false !== $intro_text) {
56 56
 				?>
57 57
 				<div class="excerpt">
58
-					<p><?php echo wp_kses_post( $intro_text ); ?></p>
58
+					<p><?php echo wp_kses_post($intro_text); ?></p>
59 59
 				</div>
60 60
 				<?php
61 61
 			}
62
-			$workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', false );
63
-			if ( false === $workout ) {
62
+			$workout = \lsx_health_plan\functions\get_option('endpoint_workout', false);
63
+			if (false === $workout) {
64 64
 				$workout = 'workout';
65 65
 			}
66 66
 			?>
67
-			<a href="<?php the_permalink(); ?><?php echo esc_attr( $workout ); ?>/" class="btn"><?php esc_html_e( 'Start your workout', 'lsx-health-plan' ); ?></a>
67
+			<a href="<?php the_permalink(); ?><?php echo esc_attr($workout); ?>/" class="btn"><?php esc_html_e('Start your workout', 'lsx-health-plan'); ?></a>
68 68
 		</div>
69 69
 	</div>
70 70
 <?php
@@ -76,29 +76,29 @@  discard block
 block discarded – undo
76 76
 * @return void
77 77
 */
78 78
 function lsx_health_plan_meal_box() {
79
-	if ( ! post_type_exists( 'meal' ) ) {
79
+	if ( ! post_type_exists('meal')) {
80 80
 		return;
81 81
 	}
82 82
 	?>
83 83
 	<div class="col-md-4" >
84 84
 		<div class="lsx-health-plan-box">
85
-			<h3 class="title meal-plan-title title-lined"><?php esc_html_e( 'Your Meal Plan', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'meal.svg' ); ?></h3>
85
+			<h3 class="title meal-plan-title title-lined"><?php esc_html_e('Your Meal Plan', 'lsx-health-plan'); ?><?php lsx_get_svg_icon('meal.svg'); ?></h3>
86 86
 			<div class="spacer"></div>
87 87
 			<?php
88
-			$intro_text = \lsx_health_plan\functions\get_option( 'meal_plan_intro', false );
89
-			if ( false !== $intro_text ) {
88
+			$intro_text = \lsx_health_plan\functions\get_option('meal_plan_intro', false);
89
+			if (false !== $intro_text) {
90 90
 				?>
91 91
 				<div class="excerpt">
92
-					<p><?php echo wp_kses_post( $intro_text ); ?></p>
92
+					<p><?php echo wp_kses_post($intro_text); ?></p>
93 93
 				</div>
94 94
 				<?php
95 95
 			}
96
-			$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false );
97
-			if ( false === $meal ) {
96
+			$meal = \lsx_health_plan\functions\get_option('endpoint_meal', false);
97
+			if (false === $meal) {
98 98
 				$meal = 'meal';
99 99
 			}
100 100
 			?>
101
-			<a href="<?php the_permalink(); ?><?php echo esc_attr( $meal ); ?>/" class="btn"><?php esc_html_e( 'View your meal plan', 'lsx-health-plan' ); ?></a>
101
+			<a href="<?php the_permalink(); ?><?php echo esc_attr($meal); ?>/" class="btn"><?php esc_html_e('View your meal plan', 'lsx-health-plan'); ?></a>
102 102
 		</div>
103 103
 	</div>
104 104
 <?php
@@ -110,29 +110,29 @@  discard block
 block discarded – undo
110 110
 * @return void
111 111
 */
112 112
 function lsx_health_plan_recipe_box() {
113
-	if ( ! post_type_exists( 'recipe' ) ) {
113
+	if ( ! post_type_exists('recipe')) {
114 114
 		return;
115 115
 	}
116 116
 	?>
117 117
 	<div class="col-md-4" >
118 118
 		<div class="lsx-health-plan-box">
119
-			<h3 class="title recipes-title title-lined"><?php esc_html_e( 'Recipes', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'recipes.svg' ); ?></h3>
119
+			<h3 class="title recipes-title title-lined"><?php esc_html_e('Recipes', 'lsx-health-plan'); ?><?php lsx_get_svg_icon('recipes.svg'); ?></h3>
120 120
 			<div class="spacer"></div>
121 121
 			<?php
122
-			$intro_text = \lsx_health_plan\functions\get_option( 'recipes_intro', false );
123
-			if ( false !== $intro_text ) {
122
+			$intro_text = \lsx_health_plan\functions\get_option('recipes_intro', false);
123
+			if (false !== $intro_text) {
124 124
 				?>
125 125
 				<div class="excerpt">
126
-					<p><?php echo wp_kses_post( $intro_text ); ?></p>
126
+					<p><?php echo wp_kses_post($intro_text); ?></p>
127 127
 				</div>
128 128
 				<?php
129 129
 			}
130
-			$recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false );
131
-			if ( false === $recipes ) {
130
+			$recipes = \lsx_health_plan\functions\get_option('endpoint_recipe', false);
131
+			if (false === $recipes) {
132 132
 				$recipes = 'recipes';
133 133
 			}
134 134
 			?>
135
-			<a href="<?php the_permalink(); ?><?php echo esc_attr( $recipes ); ?>/" class="btn"><?php esc_html_e( 'View all recipes', 'lsx-health-plan' ); ?></a>
135
+			<a href="<?php the_permalink(); ?><?php echo esc_attr($recipes); ?>/" class="btn"><?php esc_html_e('View all recipes', 'lsx-health-plan'); ?></a>
136 136
 		</div>
137 137
 	</div>
138 138
 <?php
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
 	?>
149 149
 	<div class="col-md-4 day-download-box" >
150 150
 		<div class="lsx-health-plan-box">
151
-			<h3 class="title downloads-title title-lined"><?php esc_html_e( 'Downloads', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'download.svg' ); ?></h3>
151
+			<h3 class="title downloads-title title-lined"><?php esc_html_e('Downloads', 'lsx-health-plan'); ?><?php lsx_get_svg_icon('download.svg'); ?></h3>
152 152
 			<div class="spacer"></div>
153 153
 			<div class="download-list">
154 154
 				<ul>
155 155
 					<?php
156 156
 					$downloads = \lsx_health_plan\functions\get_downloads();
157
-					if ( ! empty( $downloads ) ) {
158
-						foreach ( $downloads as $download ) {
159
-							echo wp_kses_post( '<li><a href=""><i class="fa fa-file-pdf"></i>' . do_shortcode( '[download id="' . $download . '"]' ) . '</a></li>' );
157
+					if ( ! empty($downloads)) {
158
+						foreach ($downloads as $download) {
159
+							echo wp_kses_post('<li><a href=""><i class="fa fa-file-pdf"></i>' . do_shortcode('[download id="' . $download . '"]') . '</a></li>');
160 160
 						}
161 161
 					}
162 162
 					?>
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
  * @param string $tab
174 174
  * @return void
175 175
  */
176
-function lsx_health_plan_nav_class( $tab = '' ) {
176
+function lsx_health_plan_nav_class($tab = '') {
177 177
 	$nav_classes = array();
178
-	if ( function_exists( 'is_wc_endpoint_url' ) && 'edit-account' === $tab && is_wc_endpoint_url( 'edit-account' ) ) {
178
+	if (function_exists('is_wc_endpoint_url') && 'edit-account' === $tab && is_wc_endpoint_url('edit-account')) {
179 179
 		$nav_classes[] = 'active';
180
-	} elseif ( lsx_health_plan_is_current_tab( $tab ) ) {
180
+	} elseif (lsx_health_plan_is_current_tab($tab)) {
181 181
 		$nav_classes[] = 'active';
182 182
 	}
183
-	if ( ! empty( $nav_classes ) ) {
184
-		echo wp_kses_post( implode( ' ', $nav_classes ) );
183
+	if ( ! empty($nav_classes)) {
184
+		echo wp_kses_post(implode(' ', $nav_classes));
185 185
 	}
186 186
 }
187 187
 
@@ -196,19 +196,19 @@  discard block
 block discarded – undo
196 196
 		<ul class="nav nav-pills">
197 197
 			<li class="
198 198
 			<?php
199
-			if ( ( function_exists( 'is_wc_endpoint_url' ) && ! is_wc_endpoint_url( 'edit-account' ) ) || ! function_exists( 'is_wc_endpoint_url' ) ) {
200
-				echo esc_attr( 'active' );
199
+			if ((function_exists('is_wc_endpoint_url') && ! is_wc_endpoint_url('edit-account')) || ! function_exists('is_wc_endpoint_url')) {
200
+				echo esc_attr('active');
201 201
 			}
202 202
 			?>
203
-			"><a class="my-plan-tab" href="<?php the_permalink(); ?>"><?php esc_html_e( 'My Plans', 'lsx-health-plan' ); ?></a></li>
203
+			"><a class="my-plan-tab" href="<?php the_permalink(); ?>"><?php esc_html_e('My Plans', 'lsx-health-plan'); ?></a></li>
204 204
 			<li class="
205 205
 			<?php
206
-			if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'edit-account' ) ) {
207
-				echo esc_attr( 'active' );
206
+			if (function_exists('is_wc_endpoint_url') && is_wc_endpoint_url('edit-account')) {
207
+				echo esc_attr('active');
208 208
 			}
209 209
 			?>
210
-			"><a class="account-details-tab" href="<?php the_permalink(); ?>edit-account/"><?php esc_html_e( 'Account Details', 'lsx-health-plan' ); ?></a></li>
211
-			<li class=""><a class="logout-tab" href="<?php echo esc_url( wp_logout_url( get_permalink() ) ); ?>"><?php esc_html_e( 'Logout', 'lsx-health-plan' ); ?></a></li>
210
+			"><a class="account-details-tab" href="<?php the_permalink(); ?>edit-account/"><?php esc_html_e('Account Details', 'lsx-health-plan'); ?></a></li>
211
+			<li class=""><a class="logout-tab" href="<?php echo esc_url(wp_logout_url(get_permalink())); ?>"><?php esc_html_e('Logout', 'lsx-health-plan'); ?></a></li>
212 212
 		</ul>
213 213
 	</div>
214 214
 	<?php
@@ -223,73 +223,73 @@  discard block
 block discarded – undo
223 223
 	?>
224 224
 	<div class="lsx-health-plan my-profile-block wp-block-cover alignfull">
225 225
 		<div class="wp-block-cover__inner-container">
226
-			<h2><?php esc_html_e( 'My Dashboard', 'lsx-health-plan' ); ?></h2>
226
+			<h2><?php esc_html_e('My Dashboard', 'lsx-health-plan'); ?></h2>
227 227
 			<section id="dashboard-card">
228 228
 				<div class="profile-navigation">
229 229
 					<div class="profile-photo">
230 230
 					<?php
231 231
 						global $current_user;
232 232
 						get_current_user();
233
-						echo get_avatar( $current_user->ID, 240 );
233
+						echo get_avatar($current_user->ID, 240);
234 234
 						?>
235 235
 					</div>
236 236
 				</div>
237 237
 				<div class="profile-details">
238
-					<h1 class="title-lined has-text-color"><?php echo esc_html( $current_user->display_name ); ?></h1>
238
+					<h1 class="title-lined has-text-color"><?php echo esc_html($current_user->display_name); ?></h1>
239 239
 					<?php
240
-					$disable_stats = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
241
-					if ( 'on' !== $disable_stats ) {
240
+					$disable_stats = \lsx_health_plan\functions\get_option('disable_all_stats', false);
241
+					if ('on' !== $disable_stats) {
242 242
 
243
-						$is_weight_disabled  = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false );
244
-						$is_height_disabled  = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false );
245
-						$is_waist_disabled   = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false );
246
-						$is_bmi_disabled = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false );
243
+						$is_weight_disabled  = \lsx_health_plan\functions\get_option('disable_weight_checkbox', false);
244
+						$is_height_disabled  = \lsx_health_plan\functions\get_option('disable_height_checkbox', false);
245
+						$is_waist_disabled   = \lsx_health_plan\functions\get_option('disable_waist_checkbox', false);
246
+						$is_bmi_disabled = \lsx_health_plan\functions\get_option('disable_bmi_checkbox', false);
247 247
 
248
-						$weight = get_user_meta( get_current_user_id(), 'weight', true );
249
-						$waist = get_user_meta( get_current_user_id(), 'waist', true );
250
-						$height = get_user_meta( get_current_user_id(), 'height', true );
248
+						$weight = get_user_meta(get_current_user_id(), 'weight', true);
249
+						$waist = get_user_meta(get_current_user_id(), 'waist', true);
250
+						$height = get_user_meta(get_current_user_id(), 'height', true);
251 251
 
252 252
 						$height_m = $height / 100;
253 253
 
254
-						if ( 1 < $weight && 1 < $height_m ) {
255
-							$bmi = $weight / ( $height_m * $height_m );
256
-							$bmi = number_format( $bmi, 1 );
254
+						if (1 < $weight && 1 < $height_m) {
255
+							$bmi = $weight / ($height_m * $height_m);
256
+							$bmi = number_format($bmi, 1);
257 257
 						} else {
258
-							$bmi = __( 'Add more data', 'lsx-health-plan' );
258
+							$bmi = __('Add more data', 'lsx-health-plan');
259 259
 						}
260 260
 
261 261
 						?>
262 262
 
263 263
 						<div>
264
-							<?php if ( 'on' !== $is_weight_disabled ) { ?>
265
-								<span><strong><?php esc_html_e( 'Weight:', 'lsx-health-plan' ); ?></strong>
264
+							<?php if ('on' !== $is_weight_disabled) { ?>
265
+								<span><strong><?php esc_html_e('Weight:', 'lsx-health-plan'); ?></strong>
266 266
 								<?php
267
-								if ( '' !== $weight ) {
268
-									echo wp_kses_post( $weight . ' kg' );
267
+								if ('' !== $weight) {
268
+									echo wp_kses_post($weight . ' kg');
269 269
 								} else {
270 270
 									echo '/';
271 271
 								}
272 272
 								?>
273 273
 								</span>
274 274
 							<?php }
275
-							if ( 'on' !== $is_waist_disabled ) {
275
+							if ('on' !== $is_waist_disabled) {
276 276
 								?>
277
-								<span><strong><?php esc_html_e( 'Waist:', 'lsx-health-plan' ); ?></strong>
277
+								<span><strong><?php esc_html_e('Waist:', 'lsx-health-plan'); ?></strong>
278 278
 								<?php
279
-								if ( '' !== $waist ) {
280
-									echo wp_kses_post( $waist . ' cm' );
279
+								if ('' !== $waist) {
280
+									echo wp_kses_post($waist . ' cm');
281 281
 								} else {
282 282
 									echo '/';
283 283
 								}
284 284
 								?>
285 285
 								</span>
286 286
 							<?php }
287
-							if ( 'on' !== $is_bmi_disabled ) {
287
+							if ('on' !== $is_bmi_disabled) {
288 288
 								?>
289
-								<span><strong><?php esc_html_e( 'BMI:', 'lsx-health-plan' ); ?></strong>
289
+								<span><strong><?php esc_html_e('BMI:', 'lsx-health-plan'); ?></strong>
290 290
 								<?php
291
-								if ( '' !== $bmi ) {
292
-									echo wp_kses_post( $bmi );
291
+								if ('' !== $bmi) {
292
+									echo wp_kses_post($bmi);
293 293
 								} else {
294 294
 									echo '/';
295 295
 								}
@@ -302,13 +302,13 @@  discard block
 block discarded – undo
302 302
 					?>
303 303
 					<div class="edit-profile">
304 304
 						<?php
305
-						if ( function_exists( 'wc_get_page_id' ) ) {
306
-							$url_id = wc_get_page_id( 'myaccount' );
305
+						if (function_exists('wc_get_page_id')) {
306
+							$url_id = wc_get_page_id('myaccount');
307 307
 						} else {
308 308
 							$url_id = '';
309 309
 						}
310 310
 						?>
311
-						<a href="<?php echo esc_url( get_permalink( $url_id ) ); ?>edit-account/"><?php esc_html_e( 'Edit', 'lsx-health-plan' ); ?></a>
311
+						<a href="<?php echo esc_url(get_permalink($url_id)); ?>edit-account/"><?php esc_html_e('Edit', 'lsx-health-plan'); ?></a>
312 312
 					</div>
313 313
 				</div>
314 314
 			</section>
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	);
335 335
 
336 336
 	$product_ids = \lsx_health_plan\functions\woocommerce\get_membership_products();
337
-	if ( ! empty( $product_ids ) ) {
337
+	if ( ! empty($product_ids)) {
338 338
 		$args['meta_query'] = array(
339 339
 			'relation' => 'OR',
340 340
 			array(
@@ -349,74 +349,74 @@  discard block
 block discarded – undo
349 349
 		);
350 350
 	}
351 351
 
352
-	$the_query = new WP_Query( $args );
352
+	$the_query = new WP_Query($args);
353 353
 	?>
354 354
 	<div class="all-plans-block plan-grid block-all-plans-block">
355 355
 		<div class="row">
356 356
 			<?php
357
-			if ( $the_query->have_posts() ) :
358
-				while ( $the_query->have_posts() ) :
357
+			if ($the_query->have_posts()) :
358
+				while ($the_query->have_posts()) :
359 359
 					$the_query->the_post();
360 360
 					lsx_entry_before();
361 361
 					$completed_class = '';
362 362
 					$linked_product  = false;
363 363
 					$restricted      = false;
364 364
 					$product         = null;
365
-					if ( \lsx_health_plan\functions\woocommerce\plan_has_products() ) {
365
+					if (\lsx_health_plan\functions\woocommerce\plan_has_products()) {
366 366
 						$products       = \lsx_health_plan\functions\woocommerce\get_plan_products();
367
-						$linked_product = wc_get_product( $products[0] );
367
+						$linked_product = wc_get_product($products[0]);
368 368
 						$product        = $linked_product;
369 369
 					}
370
-					if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) {
371
-						$restricted = wc_memberships_is_post_content_restricted( get_the_ID() ) && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() );
370
+					if (function_exists('wc_memberships_is_post_content_restricted')) {
371
+						$restricted = wc_memberships_is_post_content_restricted(get_the_ID()) && ! current_user_can('wc_memberships_view_restricted_post_content', get_the_ID());
372 372
 					}
373 373
 
374
-					if ( lsx_health_plan_is_plan_complete() ) {
374
+					if (lsx_health_plan_is_plan_complete()) {
375 375
 						$completed_class = 'completed';
376 376
 					}
377 377
 					?>
378 378
 					<div class="col-xs-12 col-sm-6 col-md-4">
379 379
 						<article class="lsx-slot lsx-hp-shadow">
380 380
 							<div class="plan-feature-img">
381
-								<a href="<?php echo esc_url( get_permalink() ); ?>">
381
+								<a href="<?php echo esc_url(get_permalink()); ?>">
382 382
 								<?php
383 383
 								$featured_image = get_the_post_thumbnail();
384
-								if ( ! empty( $featured_image ) && '' !== $featured_image ) {
385
-									the_post_thumbnail( 'lsx-thumbnail', array(
384
+								if ( ! empty($featured_image) && '' !== $featured_image) {
385
+									the_post_thumbnail('lsx-thumbnail', array(
386 386
 										'class' => 'aligncenter',
387
-									) );
387
+									));
388 388
 								} else {
389 389
 									?>
390
-									<img loading="lazy"  class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
390
+									<img loading="lazy"  class="placeholder" src="<?php echo esc_attr(plugin_dir_url(__FILE__) . '../assets/images/placeholder.jpg'); ?>">
391 391
 									<?php
392 392
 								}
393 393
 								?>
394 394
 								</a>
395 395
 							</div>
396 396
 							<div class="content-box plan-content-box">
397
-								<h3 class="plan id-<?php the_ID(); ?> <?php echo esc_attr( $completed_class ); ?>"><a href="<?php echo esc_url( get_permalink() ); ?>"><?php the_title(); ?></a></h3>
397
+								<h3 class="plan id-<?php the_ID(); ?> <?php echo esc_attr($completed_class); ?>"><a href="<?php echo esc_url(get_permalink()); ?>"><?php the_title(); ?></a></h3>
398 398
 								<?php
399
-									echo wp_kses_post( \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) );
399
+									echo wp_kses_post(\lsx_health_plan\functions\hp_get_plan_type_meta($post));
400 400
 								?>
401 401
 								<?php
402
-								if ( false !== $linked_product && false !== $restricted ) {
403
-									echo wp_kses_post( $linked_product->get_price_html() );
402
+								if (false !== $linked_product && false !== $restricted) {
403
+									echo wp_kses_post($linked_product->get_price_html());
404 404
 								}
405 405
 								?>
406 406
 								<div class="excerpt">
407 407
 									<?php
408
-									if ( ! has_excerpt() ) {
409
-										$content = wp_trim_words( get_the_content(), 20 );
408
+									if ( ! has_excerpt()) {
409
+										$content = wp_trim_words(get_the_content(), 20);
410 410
 										$content = '<p>' . $content . '</pre>';
411 411
 									} else {
412
-										$content = apply_filters( 'the_excerpt', get_the_excerpt() );
412
+										$content = apply_filters('the_excerpt', get_the_excerpt());
413 413
 									}
414
-									echo wp_kses_post( $content );
414
+									echo wp_kses_post($content);
415 415
 									?>
416 416
 								</div>
417 417
 								<?php
418
-								if ( false === $restricted ) {
419
-									echo wp_kses_post( '<span class="progress"><progress class="bar" value="' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '" max="100"> ' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '% </progress><span>' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '%</span></span>' );
418
+								if (false === $restricted) {
419
+									echo wp_kses_post('<span class="progress"><progress class="bar" value="' . \lsx_health_plan\functions\get_progress(get_the_ID()) . '" max="100"> ' . \lsx_health_plan\functions\get_progress(get_the_ID()) . '% </progress><span>' . \lsx_health_plan\functions\get_progress(get_the_ID()) . '%</span></span>');
420 420
 								}
421 421
 								?>
422 422
 							</div>
@@ -436,30 +436,30 @@  discard block
 block discarded – undo
436 436
  *
437 437
  * @return void
438 438
  */
439
-function lsx_health_plan_day_plan_block( $args = array() ) {
439
+function lsx_health_plan_day_plan_block($args = array()) {
440 440
 	$defaults = array(
441 441
 		'plan' => '',
442 442
 	);
443
-	$args     = wp_parse_args( $args, $defaults );
443
+	$args     = wp_parse_args($args, $defaults);
444 444
 
445
-	if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
446
-		$sections = \lsx_health_plan\functions\plan\get_sections( $args['plan'] );
445
+	if (isset($args['plan']) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections($args['plan'])) {
446
+		$sections = \lsx_health_plan\functions\plan\get_sections($args['plan']);
447 447
 		?>
448 448
 		<div class="daily-plan-block day-grid">
449 449
 			<?php
450
-			foreach ( $sections as $section_key => $section_values ) {
451
-				$defaults    = array(
452
-					'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
450
+			foreach ($sections as $section_key => $section_values) {
451
+				$defaults = array(
452
+					'title' => __('Day', 'lsx-health-plan') . ' ' . ($section_key + 1),
453 453
 				);
454
-				$section_args = wp_parse_args( $section_values, $defaults );
454
+				$section_args = wp_parse_args($section_values, $defaults);
455 455
 
456 456
 				$completed_class = '';
457
-				if ( lsx_health_plan_is_day_complete() ) {
457
+				if (lsx_health_plan_is_day_complete()) {
458 458
 					$completed_class = 'completed';
459 459
 				}
460 460
 				?>
461
-				<a href="<?php echo esc_attr( \lsx_health_plan\functions\plan\get_permalink( $args['plan'], $section_args['title'] ) ); ?>" class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>">
462
-					<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
461
+				<a href="<?php echo esc_attr(\lsx_health_plan\functions\plan\get_permalink($args['plan'], $section_args['title'])); ?>" class="day id-<?php echo esc_attr($section_key + 1); ?> <?php echo esc_attr($completed_class); ?>">
462
+					<div class="plan-content"><?php echo esc_attr($section_args['title']); ?></div>
463 463
 				</a>
464 464
 				<?php
465 465
 			}
@@ -475,31 +475,31 @@  discard block
 block discarded – undo
475 475
  * @param  array $args An array of arguments.
476 476
  * @return void
477 477
  */
478
-function lsx_health_plan_week_plan_block( $args = array() ) {
478
+function lsx_health_plan_week_plan_block($args = array()) {
479 479
 	$defaults = array(
480 480
 		'show_downloads' => false,
481 481
 		'plan'           => '',
482 482
 	);
483
-	$args     = wp_parse_args( $args, $defaults );
483
+	$args = wp_parse_args($args, $defaults);
484 484
 
485
-	if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
486
-		$groups = \lsx_health_plan\functions\plan\get_sections( $args['plan'], true );
485
+	if (isset($args['plan']) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections($args['plan'])) {
486
+		$groups = \lsx_health_plan\functions\plan\get_sections($args['plan'], true);
487 487
 
488
-		if ( ! empty( $groups ) ) {
488
+		if ( ! empty($groups)) {
489 489
 			$counter    = 1;
490 490
 			$group_open = false;
491 491
 
492
-			foreach ( $groups as $group_key => $sections ) {
492
+			foreach ($groups as $group_key => $sections) {
493 493
 				$collapse_class = '';
494
-				$group_title    = \lsx_health_plan\functions\plan\get_group_title( $sections );
494
+				$group_title    = \lsx_health_plan\functions\plan\get_group_title($sections);
495 495
 
496 496
 				// Determine if the current week is complete.
497
-				$day_ids = wp_list_pluck( $sections, 'title' );
498
-				if ( false === $group_open ) {
499
-					if ( 1 === $counter && ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
497
+				$day_ids = wp_list_pluck($sections, 'title');
498
+				if (false === $group_open) {
499
+					if (1 === $counter && ! \lsx_health_plan\functions\is_week_complete(false, $day_ids, $group_title)) {
500 500
 						$collapse_class = 'in';
501 501
 						$group_open   = true;
502
-					} elseif ( ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
502
+					} elseif ( ! \lsx_health_plan\functions\is_week_complete(false, $day_ids, $group_title)) {
503 503
 						$collapse_class = 'in';
504 504
 						$group_open   = true;
505 505
 					}
@@ -515,32 +515,32 @@  discard block
 block discarded – undo
515 515
 				}*/
516 516
 				?>
517 517
 				<div class="daily-plan-block week-grid">
518
-					<a href="#group-<?php echo esc_attr( $group_key ); ?>" data-toggle="collapse" class="week-title"><?php echo esc_attr( $group_title ); ?></a>
519
-					<div id="group-<?php echo esc_attr( $group_key ); ?>" class="week-row collapse <?php echo esc_attr( $collapse_class ); ?>">
520
-						<div class="week-row-inner <?php echo esc_html( $week_downloads_view ); ?>">
518
+					<a href="#group-<?php echo esc_attr($group_key); ?>" data-toggle="collapse" class="week-title"><?php echo esc_attr($group_title); ?></a>
519
+					<div id="group-<?php echo esc_attr($group_key); ?>" class="week-row collapse <?php echo esc_attr($collapse_class); ?>">
520
+						<div class="week-row-inner <?php echo esc_html($week_downloads_view); ?>">
521 521
 							<div class="week-meals-recipes-box">
522 522
 
523
-								<?php if ( ! empty( $week_downloads_view ) ) { ?>
524
-									<h3 class="title"><?php lsx_get_svg_icon( 'daily-plan.svg' ); ?><?php echo esc_html_e( 'Daily Plan', 'lsx-health-plan' ); ?></h3>
523
+								<?php if ( ! empty($week_downloads_view)) { ?>
524
+									<h3 class="title"><?php lsx_get_svg_icon('daily-plan.svg'); ?><?php echo esc_html_e('Daily Plan', 'lsx-health-plan'); ?></h3>
525 525
 								<?php } ?>
526 526
 
527 527
 								<div class="week-meals-recipes-box-inner">
528 528
 								<?php
529 529
 
530
-								foreach ( $sections as $section_key => $section_values ) {
530
+								foreach ($sections as $section_key => $section_values) {
531 531
 
532
-									$defaults    = array(
533
-										'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
532
+									$defaults = array(
533
+										'title' => __('Day', 'lsx-health-plan') . ' ' . ($section_key + 1),
534 534
 									);
535
-									$section_args = wp_parse_args( $section_values, $defaults );
535
+									$section_args = wp_parse_args($section_values, $defaults);
536 536
 
537 537
 									$completed_class = '';
538
-									if ( lsx_health_plan_is_day_complete( $args['plan'], $section_args['title'] ) ) {
538
+									if (lsx_health_plan_is_day_complete($args['plan'], $section_args['title'])) {
539 539
 										$completed_class = 'completed';
540 540
 									}
541 541
 									?>
542
-									<a href="<?php echo esc_attr( \lsx_health_plan\functions\plan\get_permalink( $args['plan'], $section_args['title'] ) ); ?>" class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>">
543
-										<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
542
+									<a href="<?php echo esc_attr(\lsx_health_plan\functions\plan\get_permalink($args['plan'], $section_args['title'])); ?>" class="day id-<?php echo esc_attr($section_key + 1); ?> <?php echo esc_attr($completed_class); ?>">
543
+										<div class="plan-content"><?php echo esc_attr($section_args['title']); ?></div>
544 544
 									</a>
545 545
 									<?php
546 546
 								}
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 								</div>
549 549
 							</div>
550 550
 							<?php
551
-							if ( ! empty( $week_downloads_view ) ) {
551
+							if ( ! empty($week_downloads_view)) {
552 552
 								//lsx_health_plan_weekly_downloads( $weekly_downloads );
553 553
 							}
554 554
 							?>
@@ -567,16 +567,16 @@  discard block
 block discarded – undo
567 567
  * @param array $weekly_downloads An array of the download ids.
568 568
  * @return void
569 569
  */
570
-function lsx_health_plan_weekly_downloads( $weekly_downloads = array() ) {
571
-	if ( ! empty( $weekly_downloads ) ) {
570
+function lsx_health_plan_weekly_downloads($weekly_downloads = array()) {
571
+	if ( ! empty($weekly_downloads)) {
572 572
 		?>
573 573
 		<div class="week-download-box">
574
-			<h3 class="title"><?php lsx_get_svg_icon( 'download.svg' ); ?><?php echo esc_html_e( 'Downloads', 'lsx-health-plan' ); ?></h3>
574
+			<h3 class="title"><?php lsx_get_svg_icon('download.svg'); ?><?php echo esc_html_e('Downloads', 'lsx-health-plan'); ?></h3>
575 575
 			<ul class="week-download-box-list">
576 576
 				<?php
577
-				foreach ( $weekly_downloads as $weekly_download ) {
577
+				foreach ($weekly_downloads as $weekly_download) {
578 578
 					?>
579
-					<li><?php echo wp_kses_post( do_shortcode( '[download id="' . $weekly_download . '"]' ) ); ?></li>
579
+					<li><?php echo wp_kses_post(do_shortcode('[download id="' . $weekly_download . '"]')); ?></li>
580 580
 					<?php
581 581
 				}
582 582
 				?>
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
  *
592 592
  * @return void
593 593
  */
594
-function lsx_health_plan_items( $args = array() ) {
594
+function lsx_health_plan_items($args = array()) {
595 595
 	global $shortcode_args;
596 596
 	$shortcode_args = $args;
597 597
 	include LSX_HEALTH_PLAN_PATH . '/templates/partials/shortcode-loop.php';
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
  * @return void
604 604
  */
605 605
 function lsx_health_plan_featured_video_block() {
606
-	if ( ! post_type_exists( 'video' ) ) {
606
+	if ( ! post_type_exists('video')) {
607 607
 		return;
608 608
 	}
609 609
 	include LSX_HEALTH_PLAN_PATH . '/templates/featured-videos.php';
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
  * @return void
616 616
  */
617 617
 function lsx_health_plan_featured_recipes_block() {
618
-	if ( ! post_type_exists( 'recipe' ) ) {
618
+	if ( ! post_type_exists('recipe')) {
619 619
 		return;
620 620
 	}
621 621
 	include LSX_HEALTH_PLAN_PATH . '/templates/featured-recipes.php';
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
  * @return void
638 638
  */
639 639
 function lsx_health_plan_day_button() {
640
-	if ( lsx_health_plan_is_day_complete() ) {
640
+	if (lsx_health_plan_is_day_complete()) {
641 641
 		lsx_health_plan_unlock_button();
642 642
 	} else {
643 643
 		lsx_health_plan_complete_button();
@@ -653,9 +653,9 @@  discard block
 block discarded – undo
653 653
 	?>
654 654
 	<div class="single-plan-inner-buttons">
655 655
 		<form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn">
656
-			<?php wp_nonce_field( 'complete', 'lsx-health-plan-actions' ); ?>
657
-			<input type="hidden" name="lsx-health-plan-id" value="<?php echo esc_attr( \lsx_health_plan\functions\plan\generate_section_id() ); ?>" />
658
-			<button class="btn cta-btn" type="submit"><?php esc_html_e( 'Complete Day', 'lsx-health-plan' ); ?></button>
656
+			<?php wp_nonce_field('complete', 'lsx-health-plan-actions'); ?>
657
+			<input type="hidden" name="lsx-health-plan-id" value="<?php echo esc_attr(\lsx_health_plan\functions\plan\generate_section_id()); ?>" />
658
+			<button class="btn cta-btn" type="submit"><?php esc_html_e('Complete Day', 'lsx-health-plan'); ?></button>
659 659
 		</form>
660 660
 		<?php lsx_health_plan_back_to_plan_button(); ?>
661 661
 	</div>
@@ -671,9 +671,9 @@  discard block
 block discarded – undo
671 671
 	?>
672 672
 	<div class="single-plan-inner-buttons">
673 673
 		<form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn">
674
-			<?php wp_nonce_field( 'unlock', 'lsx-health-plan-actions' ); ?>
675
-			<input type="hidden" name="lsx-health-plan-id" value="<?php echo esc_attr( \lsx_health_plan\functions\plan\generate_section_id() ); ?>" />
676
-			<button class="btn secondary-btn" type="submit"><?php esc_html_e( 'Im not done!', 'lsx-health-plan' ); ?></button>
674
+			<?php wp_nonce_field('unlock', 'lsx-health-plan-actions'); ?>
675
+			<input type="hidden" name="lsx-health-plan-id" value="<?php echo esc_attr(\lsx_health_plan\functions\plan\generate_section_id()); ?>" />
676
+			<button class="btn secondary-btn" type="submit"><?php esc_html_e('Im not done!', 'lsx-health-plan'); ?></button>
677 677
 		</form>
678 678
 		<?php lsx_health_plan_back_to_plan_button(); ?>
679 679
 	</div>
@@ -687,8 +687,8 @@  discard block
 block discarded – undo
687 687
  * @return void
688 688
  */
689 689
 function lsx_health_plan_single_nav() {
690
-	$tab_template_path = apply_filters( 'lsx_health_plan_single_nav_path', LSX_HEALTH_PLAN_PATH . '/templates/single-plan-tabs.php' );
691
-	if ( '' !== $tab_template_path ) {
690
+	$tab_template_path = apply_filters('lsx_health_plan_single_nav_path', LSX_HEALTH_PLAN_PATH . '/templates/single-plan-tabs.php');
691
+	if ('' !== $tab_template_path) {
692 692
 		require $tab_template_path;
693 693
 	}
694 694
 }
@@ -700,8 +700,8 @@  discard block
 block discarded – undo
700 700
  * @return void
701 701
  */
702 702
 function lsx_health_plan_single_tabs() {
703
-	$endpoint = get_query_var( 'endpoint' );
704
-	switch ( $endpoint ) {
703
+	$endpoint = get_query_var('endpoint');
704
+	switch ($endpoint) {
705 705
 		case 'meal':
706 706
 			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-meal.php';
707 707
 			break;
@@ -722,8 +722,8 @@  discard block
 block discarded – undo
722 722
 			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-plan.php';
723 723
 			break;
724 724
 	}
725
-	$tab_template_path = apply_filters( 'lsx_health_plan_single_tab_path', $tab_template_path );
726
-	if ( '' !== $tab_template_path ) {
725
+	$tab_template_path = apply_filters('lsx_health_plan_single_tab_path', $tab_template_path);
726
+	if ('' !== $tab_template_path) {
727 727
 		include $tab_template_path;
728 728
 	}
729 729
 }
@@ -743,9 +743,9 @@  discard block
 block discarded – undo
743 743
  * @return recipe_type
744 744
  */
745 745
 function lsx_health_plan_recipe_type() {
746
-	$term_obj_list = get_the_terms( get_the_ID(), 'recipe-type' );
746
+	$term_obj_list = get_the_terms(get_the_ID(), 'recipe-type');
747 747
 	$recipe_type   = $term_obj_list[0]->name;
748
-	if ( ! empty( $recipe_type ) ) {
748
+	if ( ! empty($recipe_type)) {
749 749
 		return $recipe_type;
750 750
 	}
751 751
 }
@@ -757,32 +757,32 @@  discard block
 block discarded – undo
757 757
  * @param array $group
758 758
  * @return void
759 759
  */
760
-function lsx_health_plan_workout_video_play_button( $m, $group, $echo = true ) {
760
+function lsx_health_plan_workout_video_play_button($m, $group, $echo = true) {
761 761
 	$workout_video = '';
762 762
 	$giphy         = '';
763 763
 	$youtube       = '';
764
-	if ( isset( $group['connected_videos'] ) && '' !== $group['connected_videos'] ) {
765
-		$workout_video = esc_html( $group['connected_videos'] );
766
-		$giphy         = get_post_meta( $workout_video, 'video_giphy_source', true );
767
-		$youtube       = esc_url( get_post_meta( $workout_video, 'video_youtube_source', 1 ) );
768
-		$content       = get_post_field( 'post_content', $workout_video );
764
+	if (isset($group['connected_videos']) && '' !== $group['connected_videos']) {
765
+		$workout_video = esc_html($group['connected_videos']);
766
+		$giphy         = get_post_meta($workout_video, 'video_giphy_source', true);
767
+		$youtube       = esc_url(get_post_meta($workout_video, 'video_youtube_source', 1));
768
+		$content       = get_post_field('post_content', $workout_video);
769 769
 		$play_button   = '<button data-toggle="modal" data-target="#workout-video-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>';
770 770
 
771 771
 		$modal_body = '';
772
-		if ( ! empty( $giphy ) ) {
773
-			$giphy      = \lsx_health_plan\functions\get_video_url( $giphy );
772
+		if ( ! empty($giphy)) {
773
+			$giphy      = \lsx_health_plan\functions\get_video_url($giphy);
774 774
 			$modal_body = $giphy; // WPCS: XSS OK.
775
-		} elseif ( ! empty( $youtube ) ) {
776
-			$modal_body = wp_oembed_get( $youtube, array( // WPCS: XSS OK.
775
+		} elseif ( ! empty($youtube)) {
776
+			$modal_body = wp_oembed_get($youtube, array( // WPCS: XSS OK.
777 777
 				'width' => 480,
778
-			) );
778
+			));
779 779
 		}
780 780
 		$modal_body .= '<h5 class="modal-title title-lined">' . $group['name'] . '</h5>';
781 781
 		$modal_body .= $content;
782
-		\lsx_health_plan\functions\register_modal( 'workout-video-modal-' . $m, '', $modal_body );
782
+		\lsx_health_plan\functions\register_modal('workout-video-modal-' . $m, '', $modal_body);
783 783
 
784
-		if ( true === $echo ) {
785
-			echo wp_kses_post( $play_button );
784
+		if (true === $echo) {
785
+			echo wp_kses_post($play_button);
786 786
 		} else {
787 787
 			return $play_button;
788 788
 		}
@@ -796,17 +796,17 @@  discard block
 block discarded – undo
796 796
  */
797 797
 function lsx_health_plan_recipe_archive_description() {
798 798
 	$description = '';
799
-	if ( is_post_type_archive( 'recipe' ) ) {
800
-		$description = \lsx_health_plan\functions\get_option( 'recipe_archive_description', '' );
801
-	} elseif ( is_post_type_archive( 'exercise' ) ) {
802
-		$description = \lsx_health_plan\functions\get_option( 'exercise_archive_description', '' );
803
-	} elseif ( is_tax() ) {
799
+	if (is_post_type_archive('recipe')) {
800
+		$description = \lsx_health_plan\functions\get_option('recipe_archive_description', '');
801
+	} elseif (is_post_type_archive('exercise')) {
802
+		$description = \lsx_health_plan\functions\get_option('exercise_archive_description', '');
803
+	} elseif (is_tax()) {
804 804
 		$description = get_the_archive_description();
805 805
 	}
806
-	if ( '' !== $description ) {
806
+	if ('' !== $description) {
807 807
 		?>
808 808
 		<div class="lsx-hp-archive-description row">
809
-			<div class="col-xs-12 description-wrapper"><?php echo wp_kses_post( $description ); ?></div>
809
+			<div class="col-xs-12 description-wrapper"><?php echo wp_kses_post($description); ?></div>
810 810
 		</div>
811 811
 		<?php
812 812
 	}
@@ -819,19 +819,19 @@  discard block
 block discarded – undo
819 819
  */
820 820
 function lsx_health_plan_main_content() {
821 821
 	// Getting translated endpoint.
822
-	$plan = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' );
822
+	$plan = \lsx_health_plan\functions\get_option('endpoint_plan', 'plan');
823 823
 
824
-	$connected_members = get_post_meta( get_the_ID(), ( $plan . '_connected_team_member' ), true );
825
-	$small_description = get_post_meta( get_the_ID(), ( $plan . '_short_description' ), true );
824
+	$connected_members = get_post_meta(get_the_ID(), ($plan . '_connected_team_member'), true);
825
+	$small_description = get_post_meta(get_the_ID(), ($plan . '_short_description'), true);
826 826
 
827 827
 	$content_plan = '';
828
-	if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
828
+	if ($small_description || $connected_members || lsx_health_plan_has_tips()) {
829 829
 		$content_plan .= '<div class="set-box set content-box entry-content">';
830 830
 		$content_plan .= '<div class="the-content">';
831
-		$content_plan .= lsx_hp_member_connected( $connected_members, $plan );
831
+		$content_plan .= lsx_hp_member_connected($connected_members, $plan);
832 832
 		$content_plan .= '<span>' . $small_description . '</span>';
833 833
 		$content_plan .= '</div>';
834
-		$content_plan .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
834
+		$content_plan .= do_shortcode('[lsx_health_plan_featured_tips_block]');
835 835
 		$content_plan .= '</div>';
836 836
 	}
837 837
 
@@ -845,19 +845,19 @@  discard block
 block discarded – undo
845 845
  */
846 846
 function lsx_health_plan_workout_main_content() {
847 847
 	// Getting translated endpoint.
848
-	$workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
848
+	$workout = \lsx_health_plan\functions\get_option('endpoint_workout', 'workout');
849 849
 
850
-	$connected_members = get_post_meta( get_the_ID(), ( $workout . '_connected_team_member' ), true );
851
-	$small_description = get_post_meta( get_the_ID(), ( $workout . '_short_description' ), true );
850
+	$connected_members = get_post_meta(get_the_ID(), ($workout . '_connected_team_member'), true);
851
+	$small_description = get_post_meta(get_the_ID(), ($workout . '_short_description'), true);
852 852
 
853 853
 	$content = '';
854
-	if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
854
+	if ($small_description || $connected_members || lsx_health_plan_has_tips()) {
855 855
 		$content .= '<div class="set-box set content-box entry-content">';
856 856
 		$content .= '<div class="the-content">';
857
-		$content .= lsx_hp_member_connected( $connected_members, $workout );
857
+		$content .= lsx_hp_member_connected($connected_members, $workout);
858 858
 		$content .= '<span>' . $small_description . '</span>';
859 859
 		$content .= '</div>';
860
-		$content .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
860
+		$content .= do_shortcode('[lsx_health_plan_featured_tips_block]');
861 861
 		$content .= '</div>';
862 862
 	}
863 863
 	return $content;
@@ -870,19 +870,19 @@  discard block
 block discarded – undo
870 870
  */
871 871
 function lsx_health_plan_meal_main_content() {
872 872
 	// Getting translated endpoint.
873
-	$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
873
+	$meal = \lsx_health_plan\functions\get_option('endpoint_meal', 'meal');
874 874
 
875
-	$connected_members = get_post_meta( get_the_ID(), ( $meal . '_connected_team_member' ), true );
876
-	$small_description = get_post_meta( get_the_ID(), ( $meal . '_short_description' ), true );
875
+	$connected_members = get_post_meta(get_the_ID(), ($meal . '_connected_team_member'), true);
876
+	$small_description = get_post_meta(get_the_ID(), ($meal . '_short_description'), true);
877 877
 
878 878
 	$content_meal = '';
879
-	if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
879
+	if ($small_description || $connected_members || lsx_health_plan_has_tips()) {
880 880
 		$content_meal .= '<div class="set-box set content-box entry-content">';
881 881
 		$content_meal .= '<div class="the-content">';
882
-		$content_meal .= lsx_hp_member_connected( $connected_members, $meal );
882
+		$content_meal .= lsx_hp_member_connected($connected_members, $meal);
883 883
 		$content_meal .= '<span>' . $small_description . '</span>';
884 884
 		$content_meal .= '</div>';
885
-		$content_meal .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
885
+		$content_meal .= do_shortcode('[lsx_health_plan_featured_tips_block]');
886 886
 		$content_meal .= '</div>';
887 887
 	}
888 888
 	return $content_meal;
@@ -895,21 +895,21 @@  discard block
 block discarded – undo
895 895
  * @param  string $index
896 896
  * @return void
897 897
  */
898
-function lsx_health_plan_workout_tab_content( $index = 1 ) {
899
-	global $group_name,$shortcode_args;
898
+function lsx_health_plan_workout_tab_content($index = 1) {
899
+	global $group_name, $shortcode_args;
900 900
 	$group_name = 'workout_section_' . $index;
901
-	if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
902
-		$layout = strtolower( \lsx_health_plan\functions\get_option( 'workout_tab_layout', 'table' ) );
901
+	if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) {
902
+		$layout = strtolower(\lsx_health_plan\functions\get_option('workout_tab_layout', 'table'));
903 903
 
904 904
 		// Check for shortcode overrides.
905
-		if ( null !== $shortcode_args && isset( $shortcode_args['layout'] ) ) {
905
+		if (null !== $shortcode_args && isset($shortcode_args['layout'])) {
906 906
 			$layout = $shortcode_args['layout'];
907 907
 		}
908 908
 	} else {
909 909
 		$layout = 'table';
910 910
 	}
911 911
 
912
-	switch ( $layout ) {
912
+	switch ($layout) {
913 913
 		case 'list':
914 914
 			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-list.php';
915 915
 			break;
@@ -922,8 +922,8 @@  discard block
 block discarded – undo
922 922
 			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-table.php';
923 923
 			break;
924 924
 	}
925
-	$tab_template_path = apply_filters( 'lsx_health_plan_workout_tab_content_path', $tab_template_path );
926
-	if ( '' !== $tab_template_path ) {
925
+	$tab_template_path = apply_filters('lsx_health_plan_workout_tab_content_path', $tab_template_path);
926
+	if ('' !== $tab_template_path) {
927 927
 		include $tab_template_path;
928 928
 	}
929 929
 }
@@ -934,26 +934,26 @@  discard block
 block discarded – undo
934 934
  * @return void
935 935
  */
936 936
 function lsx_health_plan_workout_sets() {
937
-	if ( is_singular( 'workout' ) ) {
937
+	if (is_singular('workout')) {
938 938
 		global $connected_workouts;
939
-		$connected_workouts = array( get_the_ID() );
939
+		$connected_workouts = array(get_the_ID());
940 940
 	}
941
-	if ( is_singular( 'plan' ) ) {
941
+	if (is_singular('plan')) {
942 942
 
943 943
 		global $connected_workouts;
944 944
 
945
-		$section_key  = get_query_var( 'section' );
946
-		if ( '' !== $section && \lsx_health_plan\functions\plan\has_sections() ) {
947
-			$section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key );
948
-			if ( isset( $section_info['connected_workouts'] ) && '' !== $section_info['connected_workouts'] ) {
945
+		$section_key = get_query_var('section');
946
+		if ('' !== $section && \lsx_health_plan\functions\plan\has_sections()) {
947
+			$section_info = \lsx_health_plan\functions\plan\get_section_info($section_key);
948
+			if (isset($section_info['connected_workouts']) && '' !== $section_info['connected_workouts']) {
949 949
 
950
-				$connected_workouts = \lsx_health_plan\functions\prep_array( $section_info['connected_workouts'] );
950
+				$connected_workouts = \lsx_health_plan\functions\prep_array($section_info['connected_workouts']);
951 951
 			}
952 952
 		}
953 953
 	}
954 954
 	$template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
955
-	$template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
956
-	if ( '' !== $template_path && ! empty( $template_path ) ) {
955
+	$template_path = apply_filters('lsx_health_plan_workout_set_template_path', $template_path);
956
+	if ('' !== $template_path && ! empty($template_path)) {
957 957
 		include $template_path;
958 958
 	}
959 959
 }
@@ -964,46 +964,46 @@  discard block
 block discarded – undo
964 964
  * @param array $args
965 965
  * @return void
966 966
  */
967
-function lsx_hp_meal_plan_recipes( $args = array() ) {
967
+function lsx_hp_meal_plan_recipes($args = array()) {
968 968
 	$defaults = array(
969 969
 		'meal_id'   => false,
970 970
 		'meal_time' => '',
971 971
 		'modal'     => true,
972 972
 	);
973
-	$args     = wp_parse_args( $args, $defaults );
973
+	$args = wp_parse_args($args, $defaults);
974 974
 	// Looking for recipes.
975
-	$connected_recipes = get_post_meta( $args['meal_id'], $args['meal_time'] . '_recipes', true );
976
-	if ( ! empty( $connected_recipes ) ) {
977
-		$query_args    = array(
975
+	$connected_recipes = get_post_meta($args['meal_id'], $args['meal_time'] . '_recipes', true);
976
+	if ( ! empty($connected_recipes)) {
977
+		$query_args = array(
978 978
 			'orderby'   => 'date',
979 979
 			'order'     => 'DESC',
980 980
 			'post_type' => 'recipe',
981 981
 			'post__in'  => $connected_recipes,
982 982
 		);
983
-		$recipes = new WP_Query( $query_args );
983
+		$recipes = new WP_Query($query_args);
984 984
 		?>
985 985
 		<div class="recipes">
986 986
 			<div class="row eating-row">
987 987
 			<?php
988
-			if ( $recipes->have_posts() ) {
989
-				while ( $recipes->have_posts() ) {
988
+			if ($recipes->have_posts()) {
989
+				while ($recipes->have_posts()) {
990 990
 					$recipes->the_post();
991
-					if ( false !== $args['modal'] ) {
991
+					if (false !== $args['modal']) {
992 992
 						\lsx_health_plan\functions\recipes\register_recipe_modal();
993 993
 					}
994 994
 					?>
995 995
 					<div class="recipe-column">
996
-						<a data-toggle="modal" data-target="#recipe-modal-<?php echo esc_attr( get_the_ID() ); ?>" href="#recipe-modal-<?php echo esc_attr( get_the_ID() ); ?>" class="recipe-box box-shadow">
996
+						<a data-toggle="modal" data-target="#recipe-modal-<?php echo esc_attr(get_the_ID()); ?>" href="#recipe-modal-<?php echo esc_attr(get_the_ID()); ?>" class="recipe-box box-shadow">
997 997
 							<div class="recipe-feature-img">
998 998
 								<?php
999 999
 								$featured_image = get_the_post_thumbnail();
1000
-								if ( ! empty( $featured_image ) && '' !== $featured_image ) {
1001
-									the_post_thumbnail( 'lsx-thumbnail-square', array(
1000
+								if ( ! empty($featured_image) && '' !== $featured_image) {
1001
+									the_post_thumbnail('lsx-thumbnail-square', array(
1002 1002
 										'class' => 'aligncenter',
1003
-									) );
1003
+									));
1004 1004
 								} else {
1005 1005
 									?>
1006
-									<img loading="lazy" src="<?php echo esc_attr( plugin_dir_url( __DIR__ ) . 'assets/images/placeholder.jpg' ); ?>">
1006
+									<img loading="lazy" src="<?php echo esc_attr(plugin_dir_url(__DIR__) . 'assets/images/placeholder.jpg'); ?>">
1007 1007
 									<?php
1008 1008
 								}
1009 1009
 								?>
@@ -1029,25 +1029,25 @@  discard block
 block discarded – undo
1029 1029
 /**
1030 1030
  * Output the connected.
1031 1031
  */
1032
-function lsx_hp_recipe_plan_meta( $args = array() ) {
1032
+function lsx_hp_recipe_plan_meta($args = array()) {
1033 1033
 	$defaults = array();
1034 1034
 	$top_level_plans = array();
1035 1035
 	// Get meals this exercise is connected to.
1036
-	$plans = get_post_meta( get_the_ID(), 'connected_plans', true );
1037
-	if ( ! empty( $plans ) ) {
1038
-		$plan       = end( $plans );
1039
-		$has_parent = wp_get_post_parent_id( $plan );
1040
-		if ( 0 === $has_parent ) {
1036
+	$plans = get_post_meta(get_the_ID(), 'connected_plans', true);
1037
+	if ( ! empty($plans)) {
1038
+		$plan       = end($plans);
1039
+		$has_parent = wp_get_post_parent_id($plan);
1040
+		if (0 === $has_parent) {
1041 1041
 			$top_level_plans[] = $plan;
1042
-		} elseif ( false !== $top_level_plans ) {
1042
+		} elseif (false !== $top_level_plans) {
1043 1043
 			$top_level_plans[] = $has_parent;
1044 1044
 		}
1045 1045
 	}
1046
-	if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
1047
-		$top_level_plans = array_unique( $top_level_plans );
1048
-		$top_level_plan  = end( $top_level_plans );
1046
+	if ( ! empty($top_level_plans) && ('' !== $top_level_plans)) {
1047
+		$top_level_plans = array_unique($top_level_plans);
1048
+		$top_level_plan  = end($top_level_plans);
1049 1049
 		?>
1050
-			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1050
+			<span class="recipe-type recipe-parent"><?php echo esc_html(get_the_title($top_level_plan)); ?></span>
1051 1051
 		<?php
1052 1052
 	}
1053 1053
 }
@@ -1060,23 +1060,23 @@  discard block
 block discarded – undo
1060 1060
 	$top_level_plans = array();
1061 1061
 
1062 1062
 	// Get workouts this exercise is connected to.
1063
-	$workouts = get_post_meta( get_the_ID(), 'connected_workouts', true );
1063
+	$workouts = get_post_meta(get_the_ID(), 'connected_workouts', true);
1064 1064
 
1065
-	if ( '' !== $workouts && ! is_array( $workouts ) ) {
1066
-		$workouts = array( $workouts );
1065
+	if ('' !== $workouts && ! is_array($workouts)) {
1066
+		$workouts = array($workouts);
1067 1067
 	}
1068
-	if ( ! empty( $workouts ) ) {
1069
-		foreach ( $workouts as $workout ) {
1068
+	if ( ! empty($workouts)) {
1069
+		foreach ($workouts as $workout) {
1070 1070
 			// Get the plans this workout is connected to.
1071
-			$plans = get_post_meta( $workout, 'connected_plans', true );
1071
+			$plans = get_post_meta($workout, 'connected_plans', true);
1072 1072
 
1073
-			if ( '' !== $plans && ! is_array( $plans ) ) {
1074
-				$plans = array( $plans );
1073
+			if ('' !== $plans && ! is_array($plans)) {
1074
+				$plans = array($plans);
1075 1075
 			}
1076
-			if ( ! empty( $plans ) ) {
1077
-				foreach ( $plans as $plan ) {
1078
-					$has_parent = wp_get_post_parent_id( $plan );
1079
-					if ( 0 === $has_parent ) {
1076
+			if ( ! empty($plans)) {
1077
+				foreach ($plans as $plan) {
1078
+					$has_parent = wp_get_post_parent_id($plan);
1079
+					if (0 === $has_parent) {
1080 1080
 						$top_level_plans = $plan;
1081 1081
 					} else {
1082 1082
 						$top_level_plans = $has_parent;
@@ -1086,11 +1086,11 @@  discard block
 block discarded – undo
1086 1086
 		}
1087 1087
 	}
1088 1088
 
1089
-	if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
1090
-		$top_level_plans = array_unique( $top_level_plans );
1091
-		$top_level_plan  = end( $top_level_plans );
1089
+	if ( ! empty($top_level_plans) && ('' !== $top_level_plans)) {
1090
+		$top_level_plans = array_unique($top_level_plans);
1091
+		$top_level_plan  = end($top_level_plans);
1092 1092
 		?>
1093
-			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1093
+			<span class="recipe-type recipe-parent"><?php echo esc_html(get_the_title($top_level_plan)); ?></span>
1094 1094
 		<?php
1095 1095
 	}
1096 1096
 }
@@ -1101,38 +1101,38 @@  discard block
 block discarded – undo
1101 1101
  * @param [type] $related_content
1102 1102
  * @return void
1103 1103
  */
1104
-function lsx_hp_single_related( $related_content, $post_type_text ) {
1104
+function lsx_hp_single_related($related_content, $post_type_text) {
1105 1105
 	?>
1106 1106
 	<section id="lsx-hp-related">
1107 1107
 		<div class="row lsx-related-posts lsx-related-posts-title">
1108 1108
 			<div class="col-xs-12">
1109
-				<h2 class="lsx-related-posts-headline"><?php echo esc_html( $post_type_text ); ?></h2>
1109
+				<h2 class="lsx-related-posts-headline"><?php echo esc_html($post_type_text); ?></h2>
1110 1110
 			</div>
1111 1111
 		</div>
1112 1112
 		<div class="row lsx-related-posts lsx-related-posts-content">
1113 1113
 			<div class="col-xs-12">
1114 1114
 				<div class="lsx-related-posts-wrapper">
1115 1115
 					<?php
1116
-					foreach ( $related_content as $article ) {
1117
-						$post_title      = get_the_title( $article );
1118
-						$post_categories = wp_get_post_categories( $article );
1119
-						$post_link       = get_permalink( $article );
1116
+					foreach ($related_content as $article) {
1117
+						$post_title      = get_the_title($article);
1118
+						$post_categories = wp_get_post_categories($article);
1119
+						$post_link       = get_permalink($article);
1120 1120
 
1121 1121
 						$cats = array();
1122 1122
 						?>
1123
-						<article id="post-<?php echo esc_html( $article ); ?>" class="lsx-slot post">
1123
+						<article id="post-<?php echo esc_html($article); ?>" class="lsx-slot post">
1124 1124
 							<div class="entry-layout lsx-hp-shadow">
1125 1125
 								<div class="entry-layout-content">
1126 1126
 									<header class="entry-header">
1127 1127
 										<div class="entry-image">
1128
-											<a href="<?php echo esc_url( $post_link ); ?>" class="thumbnail">
1128
+											<a href="<?php echo esc_url($post_link); ?>" class="thumbnail">
1129 1129
 											<?php
1130
-											$featured_image = get_the_post_thumbnail( $article, 'lsx-thumbnail-wide' );
1131
-											if ( ! empty( $featured_image ) && '' !== $featured_image ) {
1132
-												echo wp_kses_post( $featured_image );
1130
+											$featured_image = get_the_post_thumbnail($article, 'lsx-thumbnail-wide');
1131
+											if ( ! empty($featured_image) && '' !== $featured_image) {
1132
+												echo wp_kses_post($featured_image);
1133 1133
 											} else {
1134 1134
 												?>
1135
-												<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
1135
+												<img loading="lazy" class="placeholder" src="<?php echo esc_attr(plugin_dir_url(__FILE__) . '../assets/images/placeholder.jpg'); ?>">
1136 1136
 												<?php
1137 1137
 											}
1138 1138
 											?>
@@ -1140,18 +1140,18 @@  discard block
 block discarded – undo
1140 1140
 										</div>
1141 1141
 										<div class="entry-meta">
1142 1142
 										<?php
1143
-										foreach ( $post_categories as $c ) {
1144
-											$cat = get_category( $c );
1143
+										foreach ($post_categories as $c) {
1144
+											$cat = get_category($c);
1145 1145
 											/* Translators: %s: category name */
1146
-											$cats[] = '<a href="' . esc_url( get_category_link( $cat->term_id ) ) . '" title="' . sprintf( esc_html__( 'Posts in %s', 'lsx-blog-customizer' ), $cat->name ) . '">' . $cat->name . '</a>';
1146
+											$cats[] = '<a href="' . esc_url(get_category_link($cat->term_id)) . '" title="' . sprintf(esc_html__('Posts in %s', 'lsx-blog-customizer'), $cat->name) . '">' . $cat->name . '</a>';
1147 1147
 										}
1148
-										if ( ! empty( $cats ) ) { ?>
1149
-											<div class="post-categories"><span></span><?php echo wp_kses_post( implode( ', ', $cats ) ); ?></div>
1148
+										if ( ! empty($cats)) { ?>
1149
+											<div class="post-categories"><span></span><?php echo wp_kses_post(implode(', ', $cats)); ?></div>
1150 1150
 										<?php } ?>
1151 1151
 										</div>
1152 1152
 										<h2 class="entry-title">
1153
-											<a href="<?php echo esc_url( $post_link ); ?>">
1154
-												<?php echo esc_html( $post_title ); ?>
1153
+											<a href="<?php echo esc_url($post_link); ?>">
1154
+												<?php echo esc_html($post_title); ?>
1155 1155
 											</a>
1156 1156
 										</h2>
1157 1157
 									</header>
@@ -1173,27 +1173,27 @@  discard block
 block discarded – undo
1173 1173
  * @param [type] $connected_members
1174 1174
  * @return void
1175 1175
  */
1176
-function lsx_hp_member_connected( $connected_members, $post_type ) {
1177
-	if ( ! empty( $connected_members ) ) {
1176
+function lsx_hp_member_connected($connected_members, $post_type) {
1177
+	if ( ! empty($connected_members)) {
1178 1178
 		$content = '<div id="hp-connected-members" class="hp-connected-members connected-' . $post_type . '">';
1179
-		foreach ( $connected_members as $member ) {
1180
-			$post_link   = get_permalink( $member );
1181
-			$member_name = get_the_title( $member );
1179
+		foreach ($connected_members as $member) {
1180
+			$post_link   = get_permalink($member);
1181
+			$member_name = get_the_title($member);
1182 1182
 			$member_name = '<span class="lsx-team-name">' . $member_name . '</span>';
1183 1183
 
1184 1184
 			$member_link = '<a href="' . $post_link . '" >' . $member_name . '</a>';
1185 1185
 
1186 1186
 			$roles = '';
1187
-			$terms = get_the_terms( $member, 'team_role' );
1187
+			$terms = get_the_terms($member, 'team_role');
1188 1188
 
1189
-			if ( $terms && ! is_wp_error( $terms ) ) {
1189
+			if ($terms && ! is_wp_error($terms)) {
1190 1190
 				$roles = array();
1191 1191
 
1192
-				foreach ( $terms as $term ) {
1192
+				foreach ($terms as $term) {
1193 1193
 					$roles[] = $term->name;
1194 1194
 				}
1195 1195
 
1196
-				$roles = join( ', ', $roles );
1196
+				$roles = join(', ', $roles);
1197 1197
 			}
1198 1198
 			$member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : '';
1199 1199
 
Please login to merge, or discard this patch.
classes/post-types/class-workout.php 2 patches
Indentation   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -10,375 +10,375 @@
 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;
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 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';
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 30
 
31
-	/**
32
-	 * Contructor
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, 'recipe_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 );
31
+     /**
32
+      * Contructor
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, 'recipe_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
-		// Template Redirects.
44
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
45
-	}
43
+          // Template Redirects.
44
+          add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
45
+     }
46 46
 
47
-	/**
48
-	 * Return an instance of this class.
49
-	 *
50
-	 * @since 1.0.0
51
-	 *
52
-	 * @return    object \lsx_health_plan\classes\Workout()    A single instance of this class.
53
-	 */
54
-	public static function get_instance() {
55
-		// If the single instance hasn't been set, set it now.
56
-		if ( null === self::$instance ) {
57
-			self::$instance = new self();
58
-		}
59
-		return self::$instance;
60
-	}
61
-	/**
62
-	 * Register the post type.
63
-	 */
64
-	public function register_post_type() {
65
-		$labels = array(
66
-			'name'               => esc_html__( 'Workouts', 'lsx-health-plan' ),
67
-			'singular_name'      => esc_html__( 'Workout', 'lsx-health-plan' ),
68
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
69
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
70
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
71
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
72
-			'all_items'          => esc_html__( 'All Workouts', 'lsx-health-plan' ),
73
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
74
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
75
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
76
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
77
-			'parent_item_colon'  => '',
78
-			'menu_name'          => esc_html__( 'Workouts', 'lsx-health-plan' ),
79
-		);
80
-		$args = array(
81
-			'labels'             => $labels,
82
-			'public'             => true,
83
-			'publicly_queryable' => true,
84
-			'show_ui'            => true,
85
-			'show_in_menu'       => true,
86
-			'show_in_rest'       => true,
87
-			'menu_icon'          => 'dashicons-universal-access',
88
-			'query_var'          => true,
89
-			'rewrite'            => array(
90
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ),
91
-			),
92
-			'capability_type'    => 'page',
93
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workouts' ),
94
-			'hierarchical'       => true,
95
-			'menu_position'      => null,
96
-			'supports'           => array(
97
-				'title',
98
-				'thumbnail',
99
-				'editor',
100
-				'excerpt',
101
-				'page-attributes',
102
-				'custom-fields',
103
-			),
104
-		);
105
-		register_post_type( 'workout', $args );
106
-	}
47
+     /**
48
+      * Return an instance of this class.
49
+      *
50
+      * @since 1.0.0
51
+      *
52
+      * @return    object \lsx_health_plan\classes\Workout()    A single instance of this class.
53
+      */
54
+     public static function get_instance() {
55
+          // If the single instance hasn't been set, set it now.
56
+          if ( null === self::$instance ) {
57
+               self::$instance = new self();
58
+          }
59
+          return self::$instance;
60
+     }
61
+     /**
62
+      * Register the post type.
63
+      */
64
+     public function register_post_type() {
65
+          $labels = array(
66
+               'name'               => esc_html__( 'Workouts', 'lsx-health-plan' ),
67
+               'singular_name'      => esc_html__( 'Workout', 'lsx-health-plan' ),
68
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
69
+               'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
70
+               'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
71
+               'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
72
+               'all_items'          => esc_html__( 'All Workouts', 'lsx-health-plan' ),
73
+               'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
74
+               'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
75
+               'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
76
+               'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
77
+               'parent_item_colon'  => '',
78
+               'menu_name'          => esc_html__( 'Workouts', 'lsx-health-plan' ),
79
+          );
80
+          $args = array(
81
+               'labels'             => $labels,
82
+               'public'             => true,
83
+               'publicly_queryable' => true,
84
+               'show_ui'            => true,
85
+               'show_in_menu'       => true,
86
+               'show_in_rest'       => true,
87
+               'menu_icon'          => 'dashicons-universal-access',
88
+               'query_var'          => true,
89
+               'rewrite'            => array(
90
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ),
91
+               ),
92
+               'capability_type'    => 'page',
93
+               'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workouts' ),
94
+               'hierarchical'       => true,
95
+               'menu_position'      => null,
96
+               'supports'           => array(
97
+                    'title',
98
+                    'thumbnail',
99
+                    'editor',
100
+                    'excerpt',
101
+                    'page-attributes',
102
+                    'custom-fields',
103
+               ),
104
+          );
105
+          register_post_type( 'workout', $args );
106
+     }
107 107
 
108
-	/**
109
-	 * Register the Type taxonomy.
110
-	 */
111
-	public function recipe_type_taxonomy_setup() {
112
-		$labels = array(
113
-			'name'              => esc_html_x( 'Workout Type', 'taxonomy general name', 'lsx-health-plan' ),
114
-			'singular_name'     => esc_html_x( 'Workout Type', 'taxonomy singular name', 'lsx-health-plan' ),
115
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
116
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
117
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
118
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
119
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
120
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
121
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
122
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
123
-			'menu_name'         => esc_html__( 'Workout Types', 'lsx-health-plan' ),
124
-		);
108
+     /**
109
+      * Register the Type taxonomy.
110
+      */
111
+     public function recipe_type_taxonomy_setup() {
112
+          $labels = array(
113
+               'name'              => esc_html_x( 'Workout Type', 'taxonomy general name', 'lsx-health-plan' ),
114
+               'singular_name'     => esc_html_x( 'Workout Type', 'taxonomy singular name', 'lsx-health-plan' ),
115
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
116
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
117
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
118
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
119
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
120
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
121
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
122
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
123
+               'menu_name'         => esc_html__( 'Workout Types', 'lsx-health-plan' ),
124
+          );
125 125
 
126
-		$args = array(
127
-			'hierarchical'      => true,
128
-			'labels'            => $labels,
129
-			'show_ui'           => true,
130
-			'show_admin_column' => true,
131
-			'query_var'         => true,
132
-			'rewrite'           => array(
133
-				'slug' => 'workout-type',
134
-			),
135
-		);
126
+          $args = array(
127
+               'hierarchical'      => true,
128
+               'labels'            => $labels,
129
+               'show_ui'           => true,
130
+               'show_admin_column' => true,
131
+               'query_var'         => true,
132
+               'rewrite'           => array(
133
+                    'slug' => 'workout-type',
134
+               ),
135
+          );
136 136
 
137
-		register_taxonomy( 'workout-type', array( 'workout' ), $args );
138
-	}
137
+          register_taxonomy( 'workout-type', array( 'workout' ), $args );
138
+     }
139 139
 
140
-	/**
141
-	 * Adds the post type to the different arrays.
142
-	 *
143
-	 * @param array $post_types
144
-	 * @return array
145
-	 */
146
-	public function enable_post_type( $post_types = array() ) {
147
-		$post_types[] = $this->slug;
148
-		return $post_types;
149
-	}
140
+     /**
141
+      * Adds the post type to the different arrays.
142
+      *
143
+      * @param array $post_types
144
+      * @return array
145
+      */
146
+     public function enable_post_type( $post_types = array() ) {
147
+          $post_types[] = $this->slug;
148
+          return $post_types;
149
+     }
150 150
 
151
-	/**
152
-	 * Enables the Bi Directional relationships
153
-	 *
154
-	 * @param array $connections
155
-	 * @return void
156
-	 */
157
-	public function enable_connections( $connections = array() ) {
158
-		$connections['workout']['connected_plans'] = 'connected_workouts';
159
-		$connections['plan']['connected_workouts'] = 'connected_plans';
151
+     /**
152
+      * Enables the Bi Directional relationships
153
+      *
154
+      * @param array $connections
155
+      * @return void
156
+      */
157
+     public function enable_connections( $connections = array() ) {
158
+          $connections['workout']['connected_plans'] = 'connected_workouts';
159
+          $connections['plan']['connected_workouts'] = 'connected_plans';
160 160
 
161
-		$connections['workout']['connected_videos'] = 'connected_workouts';
162
-		$connections['video']['connected_workouts'] = 'connected_videos';
161
+          $connections['workout']['connected_videos'] = 'connected_workouts';
162
+          $connections['video']['connected_workouts'] = 'connected_videos';
163 163
 
164
-		$connections['workout']['connected_posts'] = 'connected_workouts';
165
-		$connections['post']['connected_workouts'] = 'connected_posts';
166
-		return $connections;
167
-	}
164
+          $connections['workout']['connected_posts'] = 'connected_workouts';
165
+          $connections['post']['connected_workouts'] = 'connected_posts';
166
+          return $connections;
167
+     }
168 168
 
169
-	/**
170
-	 * Remove the "Archives:" from the post type workouts.
171
-	 *
172
-	 * @param string $title the term title.
173
-	 * @return string
174
-	 */
175
-	public function get_the_archive_title( $title ) {
176
-		if ( is_post_type_archive( 'workout' ) ) {
177
-			$title = __( 'Workouts', 'lsx-health-plan' );
178
-		}
179
-		return $title;
180
-	}
169
+     /**
170
+      * Remove the "Archives:" from the post type workouts.
171
+      *
172
+      * @param string $title the term title.
173
+      * @return string
174
+      */
175
+     public function get_the_archive_title( $title ) {
176
+          if ( is_post_type_archive( 'workout' ) ) {
177
+               $title = __( 'Workouts', 'lsx-health-plan' );
178
+          }
179
+          return $title;
180
+     }
181 181
 
182
-	/**
183
-	 * Define the metabox and field configurations.
184
-	 */
185
-	public function featured_metabox() {
186
-		$cmb = new_cmb2_box(
187
-			array(
188
-				'id'           => $this->slug . '_featured_metabox_workout',
189
-				'title'        => __( 'Featured Workout', 'lsx-health-plan' ),
190
-				'object_types' => array( $this->slug ), // Post type
191
-				'context'      => 'side',
192
-				'priority'     => 'high',
193
-				'show_names'   => true,
194
-			)
195
-		);
196
-		$cmb->add_field(
197
-			array(
198
-				'name'       => __( 'Featured Workout', 'lsx-health-plan' ),
199
-				'desc'       => __( 'Enable a featured workout' ),
200
-				'id'         => $this->slug . '_featured_workout',
201
-				'type'       => 'checkbox',
202
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
203
-			)
204
-		);
205
-	}
182
+     /**
183
+      * Define the metabox and field configurations.
184
+      */
185
+     public function featured_metabox() {
186
+          $cmb = new_cmb2_box(
187
+               array(
188
+                    'id'           => $this->slug . '_featured_metabox_workout',
189
+                    'title'        => __( 'Featured Workout', 'lsx-health-plan' ),
190
+                    'object_types' => array( $this->slug ), // Post type
191
+                    'context'      => 'side',
192
+                    'priority'     => 'high',
193
+                    'show_names'   => true,
194
+               )
195
+          );
196
+          $cmb->add_field(
197
+               array(
198
+                    'name'       => __( 'Featured Workout', 'lsx-health-plan' ),
199
+                    'desc'       => __( 'Enable a featured workout' ),
200
+                    'id'         => $this->slug . '_featured_workout',
201
+                    'type'       => 'checkbox',
202
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
203
+               )
204
+          );
205
+     }
206 206
 
207
-	/**
208
-	 * Define the metabox and field configurations.
209
-	 */
210
-	public function details_metaboxes() {
207
+     /**
208
+      * Define the metabox and field configurations.
209
+      */
210
+     public function details_metaboxes() {
211 211
 
212
-		$cmb = new_cmb2_box( array(
213
-			'id'           => $this->slug . '_details_metabox',
214
-			'title'        => __( 'Workout Details', 'lsx-health-plan' ),
215
-			'object_types' => array( $this->slug ), // Post type
216
-			'context'      => 'normal',
217
-			'priority'     => 'high',
218
-			'show_names'   => true,
219
-		) );
212
+          $cmb = new_cmb2_box( array(
213
+               'id'           => $this->slug . '_details_metabox',
214
+               'title'        => __( 'Workout Details', 'lsx-health-plan' ),
215
+               'object_types' => array( $this->slug ), // Post type
216
+               'context'      => 'normal',
217
+               'priority'     => 'high',
218
+               'show_names'   => true,
219
+          ) );
220 220
 
221
-		$cmb->add_field( array(
222
-			'name' => __( 'Workout Short Description', 'lsx-health-plan' ),
223
-			'id'   => $this->slug . '_short_description',
224
-			'type' => 'textarea_small',
225
-			'desc' => __( 'Add a small description for this workout (optional)', 'lsx-health-plan' ),
226
-		) );
221
+          $cmb->add_field( array(
222
+               'name' => __( 'Workout Short Description', 'lsx-health-plan' ),
223
+               'id'   => $this->slug . '_short_description',
224
+               'type' => 'textarea_small',
225
+               'desc' => __( 'Add a small description for this workout (optional)', 'lsx-health-plan' ),
226
+          ) );
227 227
 
228
-		$workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 );
229
-		if ( false !== $workout_sections && null !== $workout_sections ) {
230
-			$i = 1;
231
-			while ( $i <= $workout_sections ) {
228
+          $workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 );
229
+          if ( false !== $workout_sections && null !== $workout_sections ) {
230
+               $i = 1;
231
+               while ( $i <= $workout_sections ) {
232 232
 
233
-				$cmb_group = new_cmb2_box( array(
234
-					'id'           => $this->slug . '_section_' . $i . '_metabox',
235
-					'title'        => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i,
236
-					'object_types' => array( $this->slug ),
237
-				) );
233
+                    $cmb_group = new_cmb2_box( array(
234
+                         'id'           => $this->slug . '_section_' . $i . '_metabox',
235
+                         'title'        => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i,
236
+                         'object_types' => array( $this->slug ),
237
+                    ) );
238 238
 
239
-				$cmb_group->add_field( array(
240
-					'name'       => __( 'Title', 'lsx-health-plan' ),
241
-					'id'         => $this->slug . '_section_' . $i . '_title',
242
-					'type'       => 'text',
243
-					'show_on_cb' => 'cmb2_hide_if_no_cats',
244
-				) );
239
+                    $cmb_group->add_field( array(
240
+                         'name'       => __( 'Title', 'lsx-health-plan' ),
241
+                         'id'         => $this->slug . '_section_' . $i . '_title',
242
+                         'type'       => 'text',
243
+                         'show_on_cb' => 'cmb2_hide_if_no_cats',
244
+                    ) );
245 245
 
246
-				$cmb_group->add_field(
247
-					array(
248
-						'name'       => __( 'Description', 'lsx-health-plan' ),
249
-						'id'         => $this->slug . '_section_' . $i . '_description',
250
-						'type'       => 'wysiwyg',
251
-						'show_on_cb' => 'cmb2_hide_if_no_cats',
252
-						'options'    => array(
253
-							'textarea_rows' => 5,
254
-						),
255
-					)
256
-				);
246
+                    $cmb_group->add_field(
247
+                         array(
248
+                              'name'       => __( 'Description', 'lsx-health-plan' ),
249
+                              'id'         => $this->slug . '_section_' . $i . '_description',
250
+                              'type'       => 'wysiwyg',
251
+                              'show_on_cb' => 'cmb2_hide_if_no_cats',
252
+                              'options'    => array(
253
+                                   'textarea_rows' => 5,
254
+                              ),
255
+                         )
256
+                    );
257 257
 
258
-				/**
259
-				 * Repeatable Field Groups
260
-				 */
261
-				// $group_field_id is the field id string, so in this case: $prefix . 'demo'
262
-				$group_field_id = $cmb_group->add_field(
263
-					array(
264
-						'id'      => $this->slug . '_section_' . $i,
265
-						'type'    => 'group',
266
-						'options' => array(
267
-							'group_title'   => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number
268
-							'add_button'    => esc_html__( 'Add New', 'lsx-health-plan' ),
269
-							'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ),
270
-							'sortable'      => true,
271
-							'closed'        => true, // true to have the groups closed by default
272
-						),
273
-					)
274
-				);
258
+                    /**
259
+                     * Repeatable Field Groups
260
+                     */
261
+                    // $group_field_id is the field id string, so in this case: $prefix . 'demo'
262
+                    $group_field_id = $cmb_group->add_field(
263
+                         array(
264
+                              'id'      => $this->slug . '_section_' . $i,
265
+                              'type'    => 'group',
266
+                              'options' => array(
267
+                                   'group_title'   => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number
268
+                                   'add_button'    => esc_html__( 'Add New', 'lsx-health-plan' ),
269
+                                   'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ),
270
+                                   'sortable'      => true,
271
+                                   'closed'        => true, // true to have the groups closed by default
272
+                              ),
273
+                         )
274
+                    );
275 275
 
276
-				if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
277
-					$cmb_group->add_group_field(
278
-						$group_field_id,
279
-						array(
280
-							'name'       => __( 'Exercise related to this workout', 'lsx-health-plan' ),
281
-							'id'         => 'connected_exercises',
282
-							'type'       => 'post_search_ajax',
283
-							// Optional :
284
-							'limit'      => 1, // Limit selection to X items only (default 1)
285
-							'sortable'   => true,  // Allow selected items to be sortable (default false)
286
-							'query_args' => array(
287
-								'post_type'      => array( 'exercise' ),
288
-								'post_status'    => array( 'publish' ),
289
-								'posts_per_page' => -1,
290
-							),
291
-						)
292
-					);
293
-				} else {
294
-					$cmb_group->add_group_field(
295
-						$group_field_id,
296
-						array(
297
-							'name'       => __( 'Video related to this workout', 'lsx-health-plan' ),
298
-							'id'         => 'connected_videos',
299
-							'type'       => 'post_search_ajax',
300
-							// Optional :
301
-							'limit'      => 1, // Limit selection to X items only (default 1)
302
-							'sortable'   => true,  // Allow selected items to be sortable (default false)
303
-							'query_args' => array(
304
-								'post_type'      => array( 'video' ),
305
-								'post_status'    => array( 'publish' ),
306
-								'posts_per_page' => -1,
307
-							),
308
-						)
309
-					);
310
-					$cmb_group->add_group_field(
311
-						$group_field_id,
312
-						array(
313
-							'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ),
314
-							'id'   => 'name',
315
-							'type' => 'text',
316
-							// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
317
-						)
318
-					);
276
+                    if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
277
+                         $cmb_group->add_group_field(
278
+                              $group_field_id,
279
+                              array(
280
+                                   'name'       => __( 'Exercise related to this workout', 'lsx-health-plan' ),
281
+                                   'id'         => 'connected_exercises',
282
+                                   'type'       => 'post_search_ajax',
283
+                                   // Optional :
284
+                                   'limit'      => 1, // Limit selection to X items only (default 1)
285
+                                   'sortable'   => true,  // Allow selected items to be sortable (default false)
286
+                                   'query_args' => array(
287
+                                        'post_type'      => array( 'exercise' ),
288
+                                        'post_status'    => array( 'publish' ),
289
+                                        'posts_per_page' => -1,
290
+                                   ),
291
+                              )
292
+                         );
293
+                    } else {
294
+                         $cmb_group->add_group_field(
295
+                              $group_field_id,
296
+                              array(
297
+                                   'name'       => __( 'Video related to this workout', 'lsx-health-plan' ),
298
+                                   'id'         => 'connected_videos',
299
+                                   'type'       => 'post_search_ajax',
300
+                                   // Optional :
301
+                                   'limit'      => 1, // Limit selection to X items only (default 1)
302
+                                   'sortable'   => true,  // Allow selected items to be sortable (default false)
303
+                                   'query_args' => array(
304
+                                        'post_type'      => array( 'video' ),
305
+                                        'post_status'    => array( 'publish' ),
306
+                                        'posts_per_page' => -1,
307
+                                   ),
308
+                              )
309
+                         );
310
+                         $cmb_group->add_group_field(
311
+                              $group_field_id,
312
+                              array(
313
+                                   'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ),
314
+                                   'id'   => 'name',
315
+                                   'type' => 'text',
316
+                                   // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
317
+                              )
318
+                         );
319 319
 
320
-					$cmb_group->add_group_field(
321
-						$group_field_id,
322
-						array(
323
-							'name'    => __( 'Description', 'lsx-health-plan' ),
324
-							'id'      => 'description',
325
-							'type'    => 'wysiwyg',
326
-							'options' => array(
327
-								'textarea_rows' => 2,
328
-							),
329
-						)
330
-					);
331
-				}
320
+                         $cmb_group->add_group_field(
321
+                              $group_field_id,
322
+                              array(
323
+                                   'name'    => __( 'Description', 'lsx-health-plan' ),
324
+                                   'id'      => 'description',
325
+                                   'type'    => 'wysiwyg',
326
+                                   'options' => array(
327
+                                        'textarea_rows' => 2,
328
+                                   ),
329
+                              )
330
+                         );
331
+                    }
332 332
 
333
-				$cmb_group->add_group_field(
334
-					$group_field_id,
335
-					array(
336
-						'name' => esc_html__( 'Exercise title (Optional)', 'lsx-health-plan' ),
337
-						'id'   => 'alt_title',
338
-						'type' => 'text',
339
-					)
340
-				);
341
-				$cmb_group->add_group_field(
342
-					$group_field_id,
343
-					array(
344
-						'name' => esc_html__( 'Exercise Description (Optional)', 'lsx-health-plan' ),
345
-						'id'   => 'alt_description',
346
-						'type' => 'textarea_small',
347
-					)
348
-				);
349
-				$cmb_group->add_group_field(
350
-					$group_field_id,
351
-					array(
352
-						'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ),
353
-						'id'   => 'reps',
354
-						'type' => 'text',
355
-						// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
356
-					)
357
-				);
358
-				$cmb_group->add_group_field(
359
-					$group_field_id,
360
-					array(
361
-						'name'         => __( 'Exercise Image (Optional)', 'lsx-health-plan' ),
362
-						'id'           => 'exercise_alt_thumbnail',
363
-						'type'         => 'file',
364
-						'text'         => array(
365
-							'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
366
-						),
367
-						'desc'         => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ),
368
-						'query_args'   => array(
369
-							'type' => array(
370
-								'image/gif',
371
-								'image/jpeg',
372
-								'image/png',
373
-							),
374
-						),
375
-						'preview_size' => 'thumbnail',
376
-						'classes'      => 'lsx-field-col lsx-field-add-field  lsx-field-col-25',
377
-					)
378
-				);
333
+                    $cmb_group->add_group_field(
334
+                         $group_field_id,
335
+                         array(
336
+                              'name' => esc_html__( 'Exercise title (Optional)', 'lsx-health-plan' ),
337
+                              'id'   => 'alt_title',
338
+                              'type' => 'text',
339
+                         )
340
+                    );
341
+                    $cmb_group->add_group_field(
342
+                         $group_field_id,
343
+                         array(
344
+                              'name' => esc_html__( 'Exercise Description (Optional)', 'lsx-health-plan' ),
345
+                              'id'   => 'alt_description',
346
+                              'type' => 'textarea_small',
347
+                         )
348
+                    );
349
+                    $cmb_group->add_group_field(
350
+                         $group_field_id,
351
+                         array(
352
+                              'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ),
353
+                              'id'   => 'reps',
354
+                              'type' => 'text',
355
+                              // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
356
+                         )
357
+                    );
358
+                    $cmb_group->add_group_field(
359
+                         $group_field_id,
360
+                         array(
361
+                              'name'         => __( 'Exercise Image (Optional)', 'lsx-health-plan' ),
362
+                              'id'           => 'exercise_alt_thumbnail',
363
+                              'type'         => 'file',
364
+                              'text'         => array(
365
+                                   'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
366
+                              ),
367
+                              'desc'         => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ),
368
+                              'query_args'   => array(
369
+                                   'type' => array(
370
+                                        'image/gif',
371
+                                        'image/jpeg',
372
+                                        'image/png',
373
+                                   ),
374
+                              ),
375
+                              'preview_size' => 'thumbnail',
376
+                              'classes'      => 'lsx-field-col lsx-field-add-field  lsx-field-col-25',
377
+                         )
378
+                    );
379 379
 
380
-				$i++;
381
-			};
382
-		}
383
-	}
380
+                    $i++;
381
+               };
382
+          }
383
+     }
384 384
 }
Please login to merge, or discard this patch.
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -32,16 +32,16 @@  discard block
 block discarded – undo
32 32
 	 * Contructor
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, 'recipe_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, 'recipe_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_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
44
+		add_filter('lsx_health_plan_archive_template', array($this, 'enable_post_type'), 10, 1);
45 45
 	}
46 46
 
47 47
 	/**
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public static function get_instance() {
55 55
 		// If the single instance hasn't been set, set it now.
56
-		if ( null === self::$instance ) {
56
+		if (null === self::$instance) {
57 57
 			self::$instance = new self();
58 58
 		}
59 59
 		return self::$instance;
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	public function register_post_type() {
65 65
 		$labels = array(
66
-			'name'               => esc_html__( 'Workouts', 'lsx-health-plan' ),
67
-			'singular_name'      => esc_html__( 'Workout', 'lsx-health-plan' ),
68
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
69
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
70
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
71
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
72
-			'all_items'          => esc_html__( 'All Workouts', 'lsx-health-plan' ),
73
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
74
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
75
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
76
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
66
+			'name'               => esc_html__('Workouts', 'lsx-health-plan'),
67
+			'singular_name'      => esc_html__('Workout', 'lsx-health-plan'),
68
+			'add_new'            => esc_html_x('Add New', 'post type general name', 'lsx-health-plan'),
69
+			'add_new_item'       => esc_html__('Add New', 'lsx-health-plan'),
70
+			'edit_item'          => esc_html__('Edit', 'lsx-health-plan'),
71
+			'new_item'           => esc_html__('New', 'lsx-health-plan'),
72
+			'all_items'          => esc_html__('All Workouts', 'lsx-health-plan'),
73
+			'view_item'          => esc_html__('View', 'lsx-health-plan'),
74
+			'search_items'       => esc_html__('Search', 'lsx-health-plan'),
75
+			'not_found'          => esc_html__('None found', 'lsx-health-plan'),
76
+			'not_found_in_trash' => esc_html__('None found in Trash', 'lsx-health-plan'),
77 77
 			'parent_item_colon'  => '',
78
-			'menu_name'          => esc_html__( 'Workouts', 'lsx-health-plan' ),
78
+			'menu_name'          => esc_html__('Workouts', 'lsx-health-plan'),
79 79
 		);
80 80
 		$args = array(
81 81
 			'labels'             => $labels,
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 			'menu_icon'          => 'dashicons-universal-access',
88 88
 			'query_var'          => true,
89 89
 			'rewrite'            => array(
90
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ),
90
+				'slug' => \lsx_health_plan\functions\get_option('endpoint_workout', 'workout'),
91 91
 			),
92 92
 			'capability_type'    => 'page',
93
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workouts' ),
93
+			'has_archive'        => \lsx_health_plan\functions\get_option('endpoint_workout_archive', 'workouts'),
94 94
 			'hierarchical'       => true,
95 95
 			'menu_position'      => null,
96 96
 			'supports'           => array(
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 				'custom-fields',
103 103
 			),
104 104
 		);
105
-		register_post_type( 'workout', $args );
105
+		register_post_type('workout', $args);
106 106
 	}
107 107
 
108 108
 	/**
@@ -110,17 +110,17 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function recipe_type_taxonomy_setup() {
112 112
 		$labels = array(
113
-			'name'              => esc_html_x( 'Workout Type', 'taxonomy general name', 'lsx-health-plan' ),
114
-			'singular_name'     => esc_html_x( 'Workout Type', 'taxonomy singular name', 'lsx-health-plan' ),
115
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
116
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
117
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
118
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
119
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
120
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
121
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
122
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
123
-			'menu_name'         => esc_html__( 'Workout Types', 'lsx-health-plan' ),
113
+			'name'              => esc_html_x('Workout Type', 'taxonomy general name', 'lsx-health-plan'),
114
+			'singular_name'     => esc_html_x('Workout Type', 'taxonomy singular name', 'lsx-health-plan'),
115
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
116
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
117
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
118
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
119
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
120
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
121
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
122
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
123
+			'menu_name'         => esc_html__('Workout Types', 'lsx-health-plan'),
124 124
 		);
125 125
 
126 126
 		$args = array(
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 			),
135 135
 		);
136 136
 
137
-		register_taxonomy( 'workout-type', array( 'workout' ), $args );
137
+		register_taxonomy('workout-type', array('workout'), $args);
138 138
 	}
139 139
 
140 140
 	/**
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * @param array $post_types
144 144
 	 * @return array
145 145
 	 */
146
-	public function enable_post_type( $post_types = array() ) {
146
+	public function enable_post_type($post_types = array()) {
147 147
 		$post_types[] = $this->slug;
148 148
 		return $post_types;
149 149
 	}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 * @param array $connections
155 155
 	 * @return void
156 156
 	 */
157
-	public function enable_connections( $connections = array() ) {
157
+	public function enable_connections($connections = array()) {
158 158
 		$connections['workout']['connected_plans'] = 'connected_workouts';
159 159
 		$connections['plan']['connected_workouts'] = 'connected_plans';
160 160
 
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 	 * @param string $title the term title.
173 173
 	 * @return string
174 174
 	 */
175
-	public function get_the_archive_title( $title ) {
176
-		if ( is_post_type_archive( 'workout' ) ) {
177
-			$title = __( 'Workouts', 'lsx-health-plan' );
175
+	public function get_the_archive_title($title) {
176
+		if (is_post_type_archive('workout')) {
177
+			$title = __('Workouts', 'lsx-health-plan');
178 178
 		}
179 179
 		return $title;
180 180
 	}
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 		$cmb = new_cmb2_box(
187 187
 			array(
188 188
 				'id'           => $this->slug . '_featured_metabox_workout',
189
-				'title'        => __( 'Featured Workout', 'lsx-health-plan' ),
190
-				'object_types' => array( $this->slug ), // Post type
189
+				'title'        => __('Featured Workout', 'lsx-health-plan'),
190
+				'object_types' => array($this->slug), // Post type
191 191
 				'context'      => 'side',
192 192
 				'priority'     => 'high',
193 193
 				'show_names'   => true,
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 		);
196 196
 		$cmb->add_field(
197 197
 			array(
198
-				'name'       => __( 'Featured Workout', 'lsx-health-plan' ),
199
-				'desc'       => __( 'Enable a featured workout' ),
198
+				'name'       => __('Featured Workout', 'lsx-health-plan'),
199
+				'desc'       => __('Enable a featured workout'),
200 200
 				'id'         => $this->slug . '_featured_workout',
201 201
 				'type'       => 'checkbox',
202 202
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -209,43 +209,43 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	public function details_metaboxes() {
211 211
 
212
-		$cmb = new_cmb2_box( array(
212
+		$cmb = new_cmb2_box(array(
213 213
 			'id'           => $this->slug . '_details_metabox',
214
-			'title'        => __( 'Workout Details', 'lsx-health-plan' ),
215
-			'object_types' => array( $this->slug ), // Post type
214
+			'title'        => __('Workout Details', 'lsx-health-plan'),
215
+			'object_types' => array($this->slug), // Post type
216 216
 			'context'      => 'normal',
217 217
 			'priority'     => 'high',
218 218
 			'show_names'   => true,
219
-		) );
219
+		));
220 220
 
221
-		$cmb->add_field( array(
222
-			'name' => __( 'Workout Short Description', 'lsx-health-plan' ),
221
+		$cmb->add_field(array(
222
+			'name' => __('Workout Short Description', 'lsx-health-plan'),
223 223
 			'id'   => $this->slug . '_short_description',
224 224
 			'type' => 'textarea_small',
225
-			'desc' => __( 'Add a small description for this workout (optional)', 'lsx-health-plan' ),
226
-		) );
225
+			'desc' => __('Add a small description for this workout (optional)', 'lsx-health-plan'),
226
+		));
227 227
 
228
-		$workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 );
229
-		if ( false !== $workout_sections && null !== $workout_sections ) {
228
+		$workout_sections = apply_filters('lsx_health_plan_workout_sections_amount', 6);
229
+		if (false !== $workout_sections && null !== $workout_sections) {
230 230
 			$i = 1;
231
-			while ( $i <= $workout_sections ) {
231
+			while ($i <= $workout_sections) {
232 232
 
233
-				$cmb_group = new_cmb2_box( array(
233
+				$cmb_group = new_cmb2_box(array(
234 234
 					'id'           => $this->slug . '_section_' . $i . '_metabox',
235
-					'title'        => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i,
236
-					'object_types' => array( $this->slug ),
237
-				) );
235
+					'title'        => esc_html__('Exercise Group ', 'lsx-health-plan') . $i,
236
+					'object_types' => array($this->slug),
237
+				));
238 238
 
239
-				$cmb_group->add_field( array(
240
-					'name'       => __( 'Title', 'lsx-health-plan' ),
239
+				$cmb_group->add_field(array(
240
+					'name'       => __('Title', 'lsx-health-plan'),
241 241
 					'id'         => $this->slug . '_section_' . $i . '_title',
242 242
 					'type'       => 'text',
243 243
 					'show_on_cb' => 'cmb2_hide_if_no_cats',
244
-				) );
244
+				));
245 245
 
246 246
 				$cmb_group->add_field(
247 247
 					array(
248
-						'name'       => __( 'Description', 'lsx-health-plan' ),
248
+						'name'       => __('Description', 'lsx-health-plan'),
249 249
 						'id'         => $this->slug . '_section_' . $i . '_description',
250 250
 						'type'       => 'wysiwyg',
251 251
 						'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -264,28 +264,28 @@  discard block
 block discarded – undo
264 264
 						'id'      => $this->slug . '_section_' . $i,
265 265
 						'type'    => 'group',
266 266
 						'options' => array(
267
-							'group_title'   => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number
268
-							'add_button'    => esc_html__( 'Add New', 'lsx-health-plan' ),
269
-							'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ),
267
+							'group_title'   => esc_html__('Exercise {#}', 'lsx-health-plan'), // {#} gets replaced by row number
268
+							'add_button'    => esc_html__('Add New', 'lsx-health-plan'),
269
+							'remove_button' => esc_html__('Delete', 'lsx-health-plan'),
270 270
 							'sortable'      => true,
271 271
 							'closed'        => true, // true to have the groups closed by default
272 272
 						),
273 273
 					)
274 274
 				);
275 275
 
276
-				if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
276
+				if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) {
277 277
 					$cmb_group->add_group_field(
278 278
 						$group_field_id,
279 279
 						array(
280
-							'name'       => __( 'Exercise related to this workout', 'lsx-health-plan' ),
280
+							'name'       => __('Exercise related to this workout', 'lsx-health-plan'),
281 281
 							'id'         => 'connected_exercises',
282 282
 							'type'       => 'post_search_ajax',
283 283
 							// Optional :
284 284
 							'limit'      => 1, // Limit selection to X items only (default 1)
285
-							'sortable'   => true,  // Allow selected items to be sortable (default false)
285
+							'sortable'   => true, // Allow selected items to be sortable (default false)
286 286
 							'query_args' => array(
287
-								'post_type'      => array( 'exercise' ),
288
-								'post_status'    => array( 'publish' ),
287
+								'post_type'      => array('exercise'),
288
+								'post_status'    => array('publish'),
289 289
 								'posts_per_page' => -1,
290 290
 							),
291 291
 						)
@@ -294,15 +294,15 @@  discard block
 block discarded – undo
294 294
 					$cmb_group->add_group_field(
295 295
 						$group_field_id,
296 296
 						array(
297
-							'name'       => __( 'Video related to this workout', 'lsx-health-plan' ),
297
+							'name'       => __('Video related to this workout', 'lsx-health-plan'),
298 298
 							'id'         => 'connected_videos',
299 299
 							'type'       => 'post_search_ajax',
300 300
 							// Optional :
301 301
 							'limit'      => 1, // Limit selection to X items only (default 1)
302
-							'sortable'   => true,  // Allow selected items to be sortable (default false)
302
+							'sortable'   => true, // Allow selected items to be sortable (default false)
303 303
 							'query_args' => array(
304
-								'post_type'      => array( 'video' ),
305
-								'post_status'    => array( 'publish' ),
304
+								'post_type'      => array('video'),
305
+								'post_status'    => array('publish'),
306 306
 								'posts_per_page' => -1,
307 307
 							),
308 308
 						)
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 					$cmb_group->add_group_field(
311 311
 						$group_field_id,
312 312
 						array(
313
-							'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ),
313
+							'name' => esc_html__('Workout Name', 'lsx-health-plan'),
314 314
 							'id'   => 'name',
315 315
 							'type' => 'text',
316 316
 							// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 					$cmb_group->add_group_field(
321 321
 						$group_field_id,
322 322
 						array(
323
-							'name'    => __( 'Description', 'lsx-health-plan' ),
323
+							'name'    => __('Description', 'lsx-health-plan'),
324 324
 							'id'      => 'description',
325 325
 							'type'    => 'wysiwyg',
326 326
 							'options' => array(
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 				$cmb_group->add_group_field(
334 334
 					$group_field_id,
335 335
 					array(
336
-						'name' => esc_html__( 'Exercise title (Optional)', 'lsx-health-plan' ),
336
+						'name' => esc_html__('Exercise title (Optional)', 'lsx-health-plan'),
337 337
 						'id'   => 'alt_title',
338 338
 						'type' => 'text',
339 339
 					)
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 				$cmb_group->add_group_field(
342 342
 					$group_field_id,
343 343
 					array(
344
-						'name' => esc_html__( 'Exercise Description (Optional)', 'lsx-health-plan' ),
344
+						'name' => esc_html__('Exercise Description (Optional)', 'lsx-health-plan'),
345 345
 						'id'   => 'alt_description',
346 346
 						'type' => 'textarea_small',
347 347
 					)
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 				$cmb_group->add_group_field(
350 350
 					$group_field_id,
351 351
 					array(
352
-						'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ),
352
+						'name' => esc_html__('Reps / Time / Distance', 'lsx-health-plan'),
353 353
 						'id'   => 'reps',
354 354
 						'type' => 'text',
355 355
 						// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
@@ -358,13 +358,13 @@  discard block
 block discarded – undo
358 358
 				$cmb_group->add_group_field(
359 359
 					$group_field_id,
360 360
 					array(
361
-						'name'         => __( 'Exercise Image (Optional)', 'lsx-health-plan' ),
361
+						'name'         => __('Exercise Image (Optional)', 'lsx-health-plan'),
362 362
 						'id'           => 'exercise_alt_thumbnail',
363 363
 						'type'         => 'file',
364 364
 						'text'         => array(
365
-							'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
365
+							'add_upload_file_text' => __('Add File', 'lsx-health-plan'),
366 366
 						),
367
-						'desc'         => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ),
367
+						'desc'         => __('Upload an image 300px x 300px in size.', 'lsx-health-plan'),
368 368
 						'query_args'   => array(
369 369
 							'type' => array(
370 370
 								'image/gif',
Please login to merge, or discard this patch.
classes/integrations/woocommerce/class-account.php 2 patches
Indentation   +514 added lines, -514 removed lines patch added patch discarded remove patch
@@ -8,326 +8,326 @@  discard block
 block discarded – undo
8 8
  */
9 9
 class Account {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\integrations\woocommerce\Account()
17
-	 */
18
-	protected static $instance = null;
19
-
20
-	/**
21
-	 * Contructor
22
-	 */
23
-	public function __construct() {
24
-		add_action( 'init', array( $this, 'init' ), 20, 1 );
25
-
26
-		// Redirect to the Edit Account Template.
27
-		add_filter( 'template_include', array( $this, 'account_endpoint_redirect' ), 99 );
28
-
29
-		add_action( 'woocommerce_edit_account_form', array( $this, 'print_user_frontend_fields' ), 10 );
30
-
31
-		add_filter( 'lsx_hp_profile_fields', array( $this, 'add_post_data_to_account_fields' ), 10, 1 );
32
-		add_action( 'show_user_profile', array( $this, 'print_user_admin_fields' ), 30 );
33
-
34
-		add_action( 'personal_options_update', array( $this, 'save_account_fields' ) );
35
-		add_action( 'edit_user_profile_update', array( $this, 'save_account_fields' ) );
36
-
37
-		add_action( 'woocommerce_save_account_details', array( $this, 'save_account_fields' ) );
38
-		add_filter( 'woocommerce_save_account_details_errors', array( $this, 'validate_user_frontend_fields' ), 10 );
39
-
40
-		// Profile Fields.
41
-		add_filter( 'woocommerce_form_field_text', array( $this, 'lsx_profile_photo_field_filter' ), 10, 4 );
42
-		add_action( 'woocommerce_after_edit_account_form', array( $this, 'action_woocommerce_after_edit_account_form' ), 10, 0 );
43
-	}
44
-
45
-	/**
46
-	 * Return an instance of this class.
47
-	 *
48
-	 * @since 1.0.0
49
-	 *
50
-	 * @return    object \lsx_health_plan\classes\integration\woocommerce\Account()    A single instance of this class.
51
-	 */
52
-	public static function get_instance() {
53
-		// If the single instance hasn't been set, set it now.
54
-		if ( null === self::$instance ) {
55
-			self::$instance = new self();
56
-		}
57
-		return self::$instance;
58
-	}
59
-
60
-	/**
61
-	 * Runs on init
62
-	 *
63
-	 * @return void
64
-	 */
65
-	public function init() {
66
-		remove_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' );
67
-	}
68
-
69
-	/**
70
-	 * Redirects to the my account template.
71
-	 *
72
-	 * @param string $template
73
-	 * @return string
74
-	 */
75
-	public function account_endpoint_redirect( $template ) {
76
-		if ( function_exists( 'is_account_page' ) && is_account_page() ) {
77
-			if ( empty( locate_template( array( 'page-template-my-plan.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php' ) ) {
78
-				$template = LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php';
79
-			}
80
-		}
81
-		return $template;
82
-	}
83
-
84
-	/**
85
-	 * Add post values to account fields if set.
86
-	 *
87
-	 * @param array $fields
88
-	 *
89
-	 * @return array
90
-	 */
91
-	public function add_post_data_to_account_fields( $fields ) {
92
-		if ( empty( $_POST ) && wp_verify_nonce( sanitize_key( $_POST ) ) ) {
93
-			return $fields;
94
-		}
95
-
96
-		foreach ( $fields as $key => $field_args ) {
97
-			if ( isset( $_POST[ $key ] ) && empty( $_POST[ $key ] ) && wp_verify_nonce( sanitize_key( $_POST[ $key ] ) ) ) {
98
-				$fields[ $key ]['value'] = '';
99
-				continue;
100
-			}
101
-
102
-			if ( isset( $_POST[ $key ] ) ) {
103
-				$fields[ $key ]['value'] = sanitize_key( $_POST[ $key ] );
104
-			}
105
-		}
106
-
107
-		return $fields;
108
-	}
109
-
110
-	/**
111
-	 * Add fields to registration form and account area.
112
-	 */
113
-	public function print_user_frontend_fields() {
114
-		$fields            = $this->get_account_fields();
115
-		$is_user_logged_in = is_user_logged_in();
116
-
117
-		$all_disabled = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
118
-		if ( 'on' !== $all_disabled ) {
119
-			echo wp_kses_post( '<h2 class="title-lined my-stats-title">' . __( 'My Stats', 'lsx-health-plan' ) . '</h2><p><strong>' . __( 'My physical info', 'lsx-health-plan' ) . '</strong></p>' );
120
-			echo wp_kses_post( '<div class="my-stats-wrap"><div class="my-stats">' );
121
-			foreach ( $fields as $key => $field_args ) {
122
-				$value = null;
123
-				if ( ! $this->is_field_visible( $field_args ) ) {
124
-					continue;
125
-				}
126
-				if ( $is_user_logged_in ) {
127
-					$user_id = $this->get_edit_user_id();
128
-					$value   = $this->get_userdata( $user_id, $key );
129
-				}
130
-				$value = ( isset( $field_args['value'] ) && '' !== $field_args['value'] ) ? $field_args['value'] : $value;
131
-				woocommerce_form_field( $key, $field_args, $value );
132
-			}
133
-			$is_bmi_disabled = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false );
134
-			if ( 'on' !== $is_bmi_disabled ) {
135
-				echo wp_kses_post( '<p class="form-row calculate-bmi"><label>BMI</label><button class="btn border-btn">' . __( 'Calculate', 'lsx-health-plan' ) . '<i class="fa fa-calculator" aria-hidden="true"></i></button></p>' );
136
-				echo wp_kses_post( '</div>' );
137
-				echo wp_kses_post( '<div class="description"><p class="bmi-title"><strong>' . __( 'Your BMI score', 'lsx-health-plan' ) . '</strong></p>' );
138
-				echo wp_kses_post( '<p>' . __( "BMI is a measurement of a person's leanness or corpulence based on their height and weight, and is intended to quantify tissue mass. It is widely used as a general indicator of whether a person has a healthy body weight for their height.", 'lsx-health-plan' ) . '</p></div></div>' );
139
-			}
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @since 1.0.0
15
+      *
16
+      * @var      object \lsx_health_plan\classes\integrations\woocommerce\Account()
17
+      */
18
+     protected static $instance = null;
19
+
20
+     /**
21
+      * Contructor
22
+      */
23
+     public function __construct() {
24
+          add_action( 'init', array( $this, 'init' ), 20, 1 );
25
+
26
+          // Redirect to the Edit Account Template.
27
+          add_filter( 'template_include', array( $this, 'account_endpoint_redirect' ), 99 );
28
+
29
+          add_action( 'woocommerce_edit_account_form', array( $this, 'print_user_frontend_fields' ), 10 );
30
+
31
+          add_filter( 'lsx_hp_profile_fields', array( $this, 'add_post_data_to_account_fields' ), 10, 1 );
32
+          add_action( 'show_user_profile', array( $this, 'print_user_admin_fields' ), 30 );
33
+
34
+          add_action( 'personal_options_update', array( $this, 'save_account_fields' ) );
35
+          add_action( 'edit_user_profile_update', array( $this, 'save_account_fields' ) );
36
+
37
+          add_action( 'woocommerce_save_account_details', array( $this, 'save_account_fields' ) );
38
+          add_filter( 'woocommerce_save_account_details_errors', array( $this, 'validate_user_frontend_fields' ), 10 );
39
+
40
+          // Profile Fields.
41
+          add_filter( 'woocommerce_form_field_text', array( $this, 'lsx_profile_photo_field_filter' ), 10, 4 );
42
+          add_action( 'woocommerce_after_edit_account_form', array( $this, 'action_woocommerce_after_edit_account_form' ), 10, 0 );
43
+     }
44
+
45
+     /**
46
+      * Return an instance of this class.
47
+      *
48
+      * @since 1.0.0
49
+      *
50
+      * @return    object \lsx_health_plan\classes\integration\woocommerce\Account()    A single instance of this class.
51
+      */
52
+     public static function get_instance() {
53
+          // If the single instance hasn't been set, set it now.
54
+          if ( null === self::$instance ) {
55
+               self::$instance = new self();
56
+          }
57
+          return self::$instance;
58
+     }
59
+
60
+     /**
61
+      * Runs on init
62
+      *
63
+      * @return void
64
+      */
65
+     public function init() {
66
+          remove_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' );
67
+     }
68
+
69
+     /**
70
+      * Redirects to the my account template.
71
+      *
72
+      * @param string $template
73
+      * @return string
74
+      */
75
+     public function account_endpoint_redirect( $template ) {
76
+          if ( function_exists( 'is_account_page' ) && is_account_page() ) {
77
+               if ( empty( locate_template( array( 'page-template-my-plan.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php' ) ) {
78
+                    $template = LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php';
79
+               }
80
+          }
81
+          return $template;
82
+     }
83
+
84
+     /**
85
+      * Add post values to account fields if set.
86
+      *
87
+      * @param array $fields
88
+      *
89
+      * @return array
90
+      */
91
+     public function add_post_data_to_account_fields( $fields ) {
92
+          if ( empty( $_POST ) && wp_verify_nonce( sanitize_key( $_POST ) ) ) {
93
+               return $fields;
94
+          }
95
+
96
+          foreach ( $fields as $key => $field_args ) {
97
+               if ( isset( $_POST[ $key ] ) && empty( $_POST[ $key ] ) && wp_verify_nonce( sanitize_key( $_POST[ $key ] ) ) ) {
98
+                    $fields[ $key ]['value'] = '';
99
+                    continue;
100
+               }
101
+
102
+               if ( isset( $_POST[ $key ] ) ) {
103
+                    $fields[ $key ]['value'] = sanitize_key( $_POST[ $key ] );
104
+               }
105
+          }
106
+
107
+          return $fields;
108
+     }
109
+
110
+     /**
111
+      * Add fields to registration form and account area.
112
+      */
113
+     public function print_user_frontend_fields() {
114
+          $fields            = $this->get_account_fields();
115
+          $is_user_logged_in = is_user_logged_in();
116
+
117
+          $all_disabled = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
118
+          if ( 'on' !== $all_disabled ) {
119
+               echo wp_kses_post( '<h2 class="title-lined my-stats-title">' . __( 'My Stats', 'lsx-health-plan' ) . '</h2><p><strong>' . __( 'My physical info', 'lsx-health-plan' ) . '</strong></p>' );
120
+               echo wp_kses_post( '<div class="my-stats-wrap"><div class="my-stats">' );
121
+               foreach ( $fields as $key => $field_args ) {
122
+                    $value = null;
123
+                    if ( ! $this->is_field_visible( $field_args ) ) {
124
+                         continue;
125
+                    }
126
+                    if ( $is_user_logged_in ) {
127
+                         $user_id = $this->get_edit_user_id();
128
+                         $value   = $this->get_userdata( $user_id, $key );
129
+                    }
130
+                    $value = ( isset( $field_args['value'] ) && '' !== $field_args['value'] ) ? $field_args['value'] : $value;
131
+                    woocommerce_form_field( $key, $field_args, $value );
132
+               }
133
+               $is_bmi_disabled = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false );
134
+               if ( 'on' !== $is_bmi_disabled ) {
135
+                    echo wp_kses_post( '<p class="form-row calculate-bmi"><label>BMI</label><button class="btn border-btn">' . __( 'Calculate', 'lsx-health-plan' ) . '<i class="fa fa-calculator" aria-hidden="true"></i></button></p>' );
136
+                    echo wp_kses_post( '</div>' );
137
+                    echo wp_kses_post( '<div class="description"><p class="bmi-title"><strong>' . __( 'Your BMI score', 'lsx-health-plan' ) . '</strong></p>' );
138
+                    echo wp_kses_post( '<p>' . __( "BMI is a measurement of a person's leanness or corpulence based on their height and weight, and is intended to quantify tissue mass. It is widely used as a general indicator of whether a person has a healthy body weight for their height.", 'lsx-health-plan' ) . '</p></div></div>' );
139
+               }
140 140
 			
141
-		}
142
-	}
143
-
144
-	/**
145
-	 * Get user data.
146
-	 *
147
-	 * @param $user_id
148
-	 * @param $key
149
-	 *
150
-	 * @return mixed|string
151
-	 */
152
-	public function get_userdata( $user_id, $key ) {
153
-		if ( ! $this->is_userdata( $key ) ) {
154
-			return get_user_meta( $user_id, $key, true );
155
-		}
156
-
157
-		$userdata = get_userdata( $user_id );
158
-
159
-		if ( ! $userdata || ! isset( $userdata->{$key} ) ) {
160
-			return '';
161
-		}
162
-
163
-		return $userdata->{$key};
164
-	}
165
-
166
-	/**
167
-	 * Get currently editing user ID (frontend account/edit profile/edit other user).
168
-	 *
169
-	 * @return int
170
-	 */
171
-	public function get_edit_user_id() {
172
-		return ( isset( $_GET['user_id'] ) && wp_verify_nonce( sanitize_key( $_GET['user_id'] ) ) ) ? (int) $_GET['user_id'] : get_current_user_id();
173
-	}
174
-
175
-
176
-	/**
177
-	 * Save registration fields.
178
-	 *
179
-	 * @param int $customer_id
180
-	 */
181
-	public function save_account_fields( $customer_id ) {
182
-		$nonce_value = wc_get_var( $_REQUEST['save-account-details-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine.
183
-		if ( ! wp_verify_nonce( $nonce_value, 'save_account_details' ) ) {
184
-			return;
185
-		}
186
-
187
-		$fields         = $this->get_account_fields();
188
-		$sanitized_data = array();
189
-		foreach ( $fields as $key => $field_args ) {
190
-			if ( ! $this->is_field_visible( $field_args ) ) {
191
-				continue;
192
-			}
193
-
194
-			$sanitize = isset( $field_args['sanitize'] ) ? $field_args['sanitize'] : 'wc_clean';
195
-			$value    = ( isset( $_POST[ $key ] ) ) ? call_user_func( $sanitize, $_POST[ $key ] ) : '';
196
-			if ( $this->is_userdata( $key ) ) {
197
-
198
-				$sanitized_data[ $key ] = $value;
199
-				continue;
200
-			}
201
-
202
-			if ( 'profile_photo' === $key ) {
203
-				// This handles the image uploads.
204
-				require_once ABSPATH . 'wp-admin/includes/image.php';
205
-				require_once ABSPATH . 'wp-admin/includes/file.php';
206
-				require_once ABSPATH . 'wp-admin/includes/media.php';
207
-
208
-				$id = media_handle_upload( $key, 0, '' );
209
-				if ( ! is_wp_error( $id ) ) {
210
-					update_term_meta( $customer_id, $key . '_id', $id );
211
-					update_term_meta( $customer_id, $key, $id );
212
-				}
213
-			} else {
214
-				delete_user_meta( $customer_id, $key );
215
-				update_user_meta( $customer_id, $key, $value );
216
-			}
217
-		}
218
-
219
-		if ( ! empty( $sanitized_data ) ) {
220
-			$sanitized_data['ID'] = $customer_id;
221
-			wp_update_user( $sanitized_data );
222
-		}
223
-	}
224
-
225
-
226
-	/**
227
-	 * Is this field core user data.
228
-	 *
229
-	 * @param $key
230
-	 *
231
-	 * @return bool
232
-	 */
233
-	public function is_userdata( $key ) {
234
-		$userdata = array(
235
-			'user_pass',
236
-			'user_login',
237
-			'user_nicename',
238
-			'user_url',
239
-			'user_email',
240
-			'display_name',
241
-			'nickname',
242
-			'first_name',
243
-			'last_name',
244
-			'description',
245
-			'rich_editing',
246
-			'user_registered',
247
-			'role',
248
-			'jabber',
249
-			'aim',
250
-			'yim',
251
-			'show_admin_bar_front',
252
-		);
253
-
254
-		return in_array( $key, $userdata, true );
255
-	}
256
-
257
-	/**
258
-	 * Is field visible.
259
-	 *
260
-	 * @param $field_args
261
-	 *
262
-	 * @return bool
263
-	 */
264
-	public function is_field_visible( $field_args ) {
265
-		$visible = true;
266
-		$action  = filter_input( INPUT_POST, 'action' );
267
-
268
-		if ( is_admin() && ! empty( $field_args['hide_in_admin'] ) ) {
269
-			$visible = false;
270
-		} elseif ( ( is_account_page() || 'save_account_details' === $action ) && is_user_logged_in() && ! empty( $field_args['hide_in_account'] ) ) {
271
-			$visible = false;
272
-		} elseif ( ( is_account_page() || 'save_account_details' === $action ) && ! is_user_logged_in() && ! empty( $field_args['hide_in_registration'] ) ) {
273
-			$visible = false;
274
-		} elseif ( is_checkout() && ! empty( $field_args['hide_in_checkout'] ) ) {
275
-			$visible = false;
276
-		}
277
-
278
-		// Disable the fitness fields if needed.
279
-		$weight_key  = __( 'Weight:' );
280
-		$waist_key   = __( 'Waist:' );
281
-		$fitness_key = __( 'BMI Score:' );
282
-		if ( $weight_key === $field_args['label'] || $waist_key === $field_args['label'] || $fitness_key === $field_args['label'] ) {
283
-
284
-			// Check if all stats are disabled.
285
-			$all_disabled = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
286
-
287
-			$option_key = '';
288
-			switch ( $field_args['label'] ) {
289
-				case $weight_key:
290
-					$option_key = 'disable_weight_checkbox';
291
-					break;
292
-
293
-				case $weight_key:
294
-					$option_key = 'disable_height_checkbox';
295
-					break;
141
+          }
142
+     }
143
+
144
+     /**
145
+      * Get user data.
146
+      *
147
+      * @param $user_id
148
+      * @param $key
149
+      *
150
+      * @return mixed|string
151
+      */
152
+     public function get_userdata( $user_id, $key ) {
153
+          if ( ! $this->is_userdata( $key ) ) {
154
+               return get_user_meta( $user_id, $key, true );
155
+          }
156
+
157
+          $userdata = get_userdata( $user_id );
158
+
159
+          if ( ! $userdata || ! isset( $userdata->{$key} ) ) {
160
+               return '';
161
+          }
162
+
163
+          return $userdata->{$key};
164
+     }
165
+
166
+     /**
167
+      * Get currently editing user ID (frontend account/edit profile/edit other user).
168
+      *
169
+      * @return int
170
+      */
171
+     public function get_edit_user_id() {
172
+          return ( isset( $_GET['user_id'] ) && wp_verify_nonce( sanitize_key( $_GET['user_id'] ) ) ) ? (int) $_GET['user_id'] : get_current_user_id();
173
+     }
174
+
175
+
176
+     /**
177
+      * Save registration fields.
178
+      *
179
+      * @param int $customer_id
180
+      */
181
+     public function save_account_fields( $customer_id ) {
182
+          $nonce_value = wc_get_var( $_REQUEST['save-account-details-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine.
183
+          if ( ! wp_verify_nonce( $nonce_value, 'save_account_details' ) ) {
184
+               return;
185
+          }
186
+
187
+          $fields         = $this->get_account_fields();
188
+          $sanitized_data = array();
189
+          foreach ( $fields as $key => $field_args ) {
190
+               if ( ! $this->is_field_visible( $field_args ) ) {
191
+                    continue;
192
+               }
193
+
194
+               $sanitize = isset( $field_args['sanitize'] ) ? $field_args['sanitize'] : 'wc_clean';
195
+               $value    = ( isset( $_POST[ $key ] ) ) ? call_user_func( $sanitize, $_POST[ $key ] ) : '';
196
+               if ( $this->is_userdata( $key ) ) {
197
+
198
+                    $sanitized_data[ $key ] = $value;
199
+                    continue;
200
+               }
201
+
202
+               if ( 'profile_photo' === $key ) {
203
+                    // This handles the image uploads.
204
+                    require_once ABSPATH . 'wp-admin/includes/image.php';
205
+                    require_once ABSPATH . 'wp-admin/includes/file.php';
206
+                    require_once ABSPATH . 'wp-admin/includes/media.php';
207
+
208
+                    $id = media_handle_upload( $key, 0, '' );
209
+                    if ( ! is_wp_error( $id ) ) {
210
+                         update_term_meta( $customer_id, $key . '_id', $id );
211
+                         update_term_meta( $customer_id, $key, $id );
212
+                    }
213
+               } else {
214
+                    delete_user_meta( $customer_id, $key );
215
+                    update_user_meta( $customer_id, $key, $value );
216
+               }
217
+          }
218
+
219
+          if ( ! empty( $sanitized_data ) ) {
220
+               $sanitized_data['ID'] = $customer_id;
221
+               wp_update_user( $sanitized_data );
222
+          }
223
+     }
224
+
225
+
226
+     /**
227
+      * Is this field core user data.
228
+      *
229
+      * @param $key
230
+      *
231
+      * @return bool
232
+      */
233
+     public function is_userdata( $key ) {
234
+          $userdata = array(
235
+               'user_pass',
236
+               'user_login',
237
+               'user_nicename',
238
+               'user_url',
239
+               'user_email',
240
+               'display_name',
241
+               'nickname',
242
+               'first_name',
243
+               'last_name',
244
+               'description',
245
+               'rich_editing',
246
+               'user_registered',
247
+               'role',
248
+               'jabber',
249
+               'aim',
250
+               'yim',
251
+               'show_admin_bar_front',
252
+          );
253
+
254
+          return in_array( $key, $userdata, true );
255
+     }
256
+
257
+     /**
258
+      * Is field visible.
259
+      *
260
+      * @param $field_args
261
+      *
262
+      * @return bool
263
+      */
264
+     public function is_field_visible( $field_args ) {
265
+          $visible = true;
266
+          $action  = filter_input( INPUT_POST, 'action' );
267
+
268
+          if ( is_admin() && ! empty( $field_args['hide_in_admin'] ) ) {
269
+               $visible = false;
270
+          } elseif ( ( is_account_page() || 'save_account_details' === $action ) && is_user_logged_in() && ! empty( $field_args['hide_in_account'] ) ) {
271
+               $visible = false;
272
+          } elseif ( ( is_account_page() || 'save_account_details' === $action ) && ! is_user_logged_in() && ! empty( $field_args['hide_in_registration'] ) ) {
273
+               $visible = false;
274
+          } elseif ( is_checkout() && ! empty( $field_args['hide_in_checkout'] ) ) {
275
+               $visible = false;
276
+          }
277
+
278
+          // Disable the fitness fields if needed.
279
+          $weight_key  = __( 'Weight:' );
280
+          $waist_key   = __( 'Waist:' );
281
+          $fitness_key = __( 'BMI Score:' );
282
+          if ( $weight_key === $field_args['label'] || $waist_key === $field_args['label'] || $fitness_key === $field_args['label'] ) {
283
+
284
+               // Check if all stats are disabled.
285
+               $all_disabled = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
286
+
287
+               $option_key = '';
288
+               switch ( $field_args['label'] ) {
289
+                    case $weight_key:
290
+                         $option_key = 'disable_weight_checkbox';
291
+                         break;
292
+
293
+                    case $weight_key:
294
+                         $option_key = 'disable_height_checkbox';
295
+                         break;
296 296
 				
297
-				case $waist_key:
298
-					$option_key = 'disable_waist_checkbox';
299
-					break;
300
-
301
-				case $fitness_key:
302
-					$option_key = 'disable_bmi_checkbox';
303
-					break;
304
-			}
305
-			$is_disabled = \lsx_health_plan\functions\get_option( $option_key, false );
306
-			if ( 'on' === $all_disabled || 'on' === $is_disabled ) {
307
-				$visible = false;
308
-			}
309
-		}
310
-		return $visible;
311
-	}
312
-
313
-	/**
314
-	 * Add fields to admin area.
315
-	 */
316
-	public function print_user_admin_fields() {
317
-		$fields = $this->get_account_fields();
318
-		?>
297
+                    case $waist_key:
298
+                         $option_key = 'disable_waist_checkbox';
299
+                         break;
300
+
301
+                    case $fitness_key:
302
+                         $option_key = 'disable_bmi_checkbox';
303
+                         break;
304
+               }
305
+               $is_disabled = \lsx_health_plan\functions\get_option( $option_key, false );
306
+               if ( 'on' === $all_disabled || 'on' === $is_disabled ) {
307
+                    $visible = false;
308
+               }
309
+          }
310
+          return $visible;
311
+     }
312
+
313
+     /**
314
+      * Add fields to admin area.
315
+      */
316
+     public function print_user_admin_fields() {
317
+          $fields = $this->get_account_fields();
318
+          ?>
319 319
 		<h2><?php esc_html_e( 'Additional Information', 'lsx-health-plan' ); ?></h2>
320 320
 		<table class="form-table" id="iconic-additional-information">
321 321
 			<tbody>
322 322
 			<?php foreach ( $fields as $key => $field_args ) { ?>
323 323
 				<?php
324
-				if ( ! $this->is_field_visible( $field_args ) ) {
325
-					continue;
326
-				}
324
+                    if ( ! $this->is_field_visible( $field_args ) ) {
325
+                         continue;
326
+                    }
327 327
 
328
-				$user_id = $this->get_edit_user_id();
329
-				$value   = get_user_meta( $user_id, $key, true );
330
-				?>
328
+                    $user_id = $this->get_edit_user_id();
329
+                    $value   = get_user_meta( $user_id, $key, true );
330
+                    ?>
331 331
 				<tr>
332 332
 					<th>
333 333
 						<label for="<?php echo esc_html( $key ); ?>"><?php echo esc_html( $field_args['label'] ); ?></label>
@@ -341,209 +341,209 @@  discard block
 block discarded – undo
341 341
 			</tbody>
342 342
 		</table>
343 343
 		<?php
344
-	}
345
-
346
-	/**
347
-	 * Validate fields on frontend.
348
-	 *
349
-	 * @param WP_Error $errors
350
-	 *
351
-	 * @return WP_Error
352
-	 */
353
-	public function validate_user_frontend_fields( $errors ) {
354
-		$fields = $this->get_account_fields();
355
-
356
-		foreach ( $fields as $key => $field_args ) {
357
-			if ( empty( $field_args['required'] ) ) {
358
-				continue;
359
-			}
360
-
361
-			/*if ( ! isset( $_POST['register'] ) && wp_verify_nonce( sanitize_key( $_POST['register'] ) ) && ! empty( $field_args['hide_in_account'] ) ) {
344
+     }
345
+
346
+     /**
347
+      * Validate fields on frontend.
348
+      *
349
+      * @param WP_Error $errors
350
+      *
351
+      * @return WP_Error
352
+      */
353
+     public function validate_user_frontend_fields( $errors ) {
354
+          $fields = $this->get_account_fields();
355
+
356
+          foreach ( $fields as $key => $field_args ) {
357
+               if ( empty( $field_args['required'] ) ) {
358
+                    continue;
359
+               }
360
+
361
+               /*if ( ! isset( $_POST['register'] ) && wp_verify_nonce( sanitize_key( $_POST['register'] ) ) && ! empty( $field_args['hide_in_account'] ) ) {
362 362
 				continue;
363 363
 			}*/
364 364
 
365
-			if ( isset( $_POST['register'] ) && wp_verify_nonce( sanitize_key( $_POST['register'] ) ) && ! empty( $field_args['hide_in_registration'] ) ) {
366
-				continue;
367
-			}
368
-
369
-			if ( empty( $_POST[ $key ] ) ) {
370
-				/* translators: %s: field */
371
-				$message = sprintf( __( '%s is a required field.', 'lsx-health-plan' ), '<strong>' . $field_args['label'] . '</strong>' );
372
-				$errors->add( $key, $message );
373
-			}
374
-		}
375
-
376
-		return $errors;
377
-	}
378
-
379
-	/**
380
-	 * Changes the text into a file upload.
381
-	 * @param $field
382
-	 * @param $key
383
-	 * @param $args
384
-	 * @param $value
385
-	 *
386
-	 * @return mixed
387
-	 */
388
-	public function lsx_profile_photo_field_filter( $field, $key, $args, $value ) {
389
-		if ( 'profile_photo' === $args['id'] ) {
390
-
391
-			if ( $args['required'] ) {
392
-				$args['class'][] = 'validate-required';
393
-				$required        = ' <abbr class="required" title="' . esc_attr__( 'required', 'lsx-health-plan' ) . '">*</abbr>';
394
-			} else {
395
-				$required = '';
396
-			}
397
-
398
-			if ( is_string( $args['label_class'] ) ) {
399
-				$args['label_class'] = array( $args['label_class'] );
400
-			}
401
-
402
-			if ( is_null( $value ) ) {
403
-				$value = $args['default'];
404
-			}
405
-
406
-			// Custom attribute handling.
407
-			$custom_attributes         = array();
408
-			$args['custom_attributes'] = array_filter( (array) $args['custom_attributes'], 'strlen' );
409
-
410
-			if ( $args['maxlength'] ) {
411
-				$args['custom_attributes']['maxlength'] = absint( $args['maxlength'] );
412
-			}
413
-
414
-			if ( ! empty( $args['autocomplete'] ) ) {
415
-				$args['custom_attributes']['autocomplete'] = $args['autocomplete'];
416
-			}
417
-
418
-			if ( true === $args['autofocus'] ) {
419
-				$args['custom_attributes']['autofocus'] = 'autofocus';
420
-			}
421
-
422
-			if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
423
-				foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) {
424
-					$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
425
-				}
426
-			}
427
-
428
-			if ( ! empty( $args['validate'] ) ) {
429
-				foreach ( $args['validate'] as $validate ) {
430
-					$args['class'][] = 'validate-' . $validate;
431
-				}
432
-			}
433
-
434
-			$field_html      = '';
435
-			$field           = '';
436
-			$label_id        = $args['id'];
437
-			$sort            = $args['priority'] ? $args['priority'] : '';
438
-			$field_container = '<p class="form-row %1$s" id="%2$s" data-priority="' . esc_attr( $sort ) . '">%3$s</p>';
439
-			$args['class'][] = 'validate-required';
440
-			$required        = ' <abbr class="required" title="' . esc_attr__( 'required', 'lsx-health-plan' ) . '">*</abbr>';
441
-
442
-			$field .= '<input accept="image/*" type="file" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '"  value="" ' . implode( ' ', $custom_attributes ) . ' />';
443
-
444
-			if ( '' !== $value && $value !== $args['default'] ) {
445
-				$field .= '<input type="text" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '_id" id="' . esc_attr( $args['id'] ) . '_id" placeholder="' . esc_attr( $args['placeholder'] ) . '_id"  value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
446
-			}
447
-
448
-			$field .= '<input type="hidden" name="MAX_FILE_SIZE" value="500000" />';
449
-
450
-			if ( $args['label'] && 'checkbox' !== $args['type'] ) {
451
-				$field_html .= '<label for="' . esc_attr( $label_id ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) . '">' . $args['label'] . $required . '</label>';
452
-			}
453
-
454
-			$field_html .= $field;
455
-
456
-			if ( $args['description'] ) {
457
-				$field_html .= '<span class="description">' . esc_html( $args['description'] ) . '</span>';
458
-			}
459
-
460
-			$container_class = esc_attr( implode( ' ', $args['class'] ) );
461
-			$container_id    = esc_attr( $args['id'] ) . '_field';
462
-			$field           = sprintf( $field_container, $container_class, $container_id, $field_html );
463
-		}
464
-		return $field;
465
-	}
466
-
467
-
468
-	public function action_woocommerce_after_edit_account_form() {
469
-		echo do_shortcode( '[avatar_upload /]' );
470
-	}
471
-
472
-	/**
473
-	 * Get additional account fields.
474
-	 *
475
-	 * @return array
476
-	 */
477
-	public function get_account_fields() {
478
-		$account_fields = apply_filters( 'lsx_hp_profile_fields', array(
479
-			'age'  => array(
480
-				'type'                 => 'text',
481
-				'label'                => __( 'Age:', 'lsx-health-plan' ),
482
-				'placeholder'          => __( '#', 'lsx-health-plan' ),
483
-				'hide_in_account'      => false,
484
-				'hide_in_admin'        => false,
485
-				'hide_in_checkout'     => false,
486
-				'hide_in_registration' => false,
487
-				'required'             => false,
488
-			),
489
-			'weight'  => array(
490
-				'type'                 => 'text',
491
-				'label'                => __( 'Weight:', 'lsx-health-plan' ),
492
-				'placeholder'          => __( 'kg', 'lsx-health-plan' ),
493
-				'hide_in_account'      => false,
494
-				'hide_in_admin'        => false,
495
-				'hide_in_checkout'     => false,
496
-				'hide_in_registration' => false,
497
-				'required'             => false,
498
-			),
499
-			'gender'   => array(
500
-				'type'                 => 'select',
501
-				'label'                => __( 'Gender:', 'lsx-health-plan' ),
502
-				'placeholder'          => __( 'm/f', 'lsx-health-plan' ),
503
-				'hide_in_account'      => false,
504
-				'hide_in_admin'        => false,
505
-				'hide_in_checkout'     => false,
506
-				'hide_in_registration' => false,
507
-				'required'             => false,
508
-				'options'     => array(
509
-					'male'   => __( 'Male', 'lsx-health-plan' ),
510
-					'female' => __( 'Female', 'lsx-health-plan' ),
511
-				),
512
-			),
513
-			'waist'   => array(
514
-				'type'                 => 'text',
515
-				'label'                => __( 'Waist:', 'lsx-health-plan' ),
516
-				'placeholder'          => __( 'cm', 'lsx-health-plan' ),
517
-				'hide_in_account'      => false,
518
-				'hide_in_admin'        => false,
519
-				'hide_in_checkout'     => false,
520
-				'hide_in_registration' => false,
521
-				'required'             => false,
522
-			),
523
-			'height'     => array(
524
-				'type'                 => 'text',
525
-				'label'                => __( 'Height:', 'lsx-health-plan' ),
526
-				'placeholder'          => __( 'cm', 'lsx-health-plan' ),
527
-				'hide_in_account'      => false,
528
-				'hide_in_admin'        => false,
529
-				'hide_in_checkout'     => false,
530
-				'hide_in_registration' => false,
531
-				'required'             => false,
532
-			),
533
-		) );
534
-
535
-		$is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false );
536
-		if ( 'on' === $is_weight_disabled ) {
537
-			$account_fields['weight']['required'] = false;
538
-		}
539
-		$is_height_disabled = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false );
540
-		if ( 'on' === $is_height_disabled ) {
541
-			$account_fields['height']['required'] = false;
542
-		}
543
-		$is_waist_disabled = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false );
544
-		if ( 'on' === $is_waist_disabled ) {
545
-			$account_fields['waist']['required'] = false;
546
-		}
547
-		return $account_fields;
548
-	}
365
+               if ( isset( $_POST['register'] ) && wp_verify_nonce( sanitize_key( $_POST['register'] ) ) && ! empty( $field_args['hide_in_registration'] ) ) {
366
+                    continue;
367
+               }
368
+
369
+               if ( empty( $_POST[ $key ] ) ) {
370
+                    /* translators: %s: field */
371
+                    $message = sprintf( __( '%s is a required field.', 'lsx-health-plan' ), '<strong>' . $field_args['label'] . '</strong>' );
372
+                    $errors->add( $key, $message );
373
+               }
374
+          }
375
+
376
+          return $errors;
377
+     }
378
+
379
+     /**
380
+      * Changes the text into a file upload.
381
+      * @param $field
382
+      * @param $key
383
+      * @param $args
384
+      * @param $value
385
+      *
386
+      * @return mixed
387
+      */
388
+     public function lsx_profile_photo_field_filter( $field, $key, $args, $value ) {
389
+          if ( 'profile_photo' === $args['id'] ) {
390
+
391
+               if ( $args['required'] ) {
392
+                    $args['class'][] = 'validate-required';
393
+                    $required        = ' <abbr class="required" title="' . esc_attr__( 'required', 'lsx-health-plan' ) . '">*</abbr>';
394
+               } else {
395
+                    $required = '';
396
+               }
397
+
398
+               if ( is_string( $args['label_class'] ) ) {
399
+                    $args['label_class'] = array( $args['label_class'] );
400
+               }
401
+
402
+               if ( is_null( $value ) ) {
403
+                    $value = $args['default'];
404
+               }
405
+
406
+               // Custom attribute handling.
407
+               $custom_attributes         = array();
408
+               $args['custom_attributes'] = array_filter( (array) $args['custom_attributes'], 'strlen' );
409
+
410
+               if ( $args['maxlength'] ) {
411
+                    $args['custom_attributes']['maxlength'] = absint( $args['maxlength'] );
412
+               }
413
+
414
+               if ( ! empty( $args['autocomplete'] ) ) {
415
+                    $args['custom_attributes']['autocomplete'] = $args['autocomplete'];
416
+               }
417
+
418
+               if ( true === $args['autofocus'] ) {
419
+                    $args['custom_attributes']['autofocus'] = 'autofocus';
420
+               }
421
+
422
+               if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
423
+                    foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) {
424
+                         $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
425
+                    }
426
+               }
427
+
428
+               if ( ! empty( $args['validate'] ) ) {
429
+                    foreach ( $args['validate'] as $validate ) {
430
+                         $args['class'][] = 'validate-' . $validate;
431
+                    }
432
+               }
433
+
434
+               $field_html      = '';
435
+               $field           = '';
436
+               $label_id        = $args['id'];
437
+               $sort            = $args['priority'] ? $args['priority'] : '';
438
+               $field_container = '<p class="form-row %1$s" id="%2$s" data-priority="' . esc_attr( $sort ) . '">%3$s</p>';
439
+               $args['class'][] = 'validate-required';
440
+               $required        = ' <abbr class="required" title="' . esc_attr__( 'required', 'lsx-health-plan' ) . '">*</abbr>';
441
+
442
+               $field .= '<input accept="image/*" type="file" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '"  value="" ' . implode( ' ', $custom_attributes ) . ' />';
443
+
444
+               if ( '' !== $value && $value !== $args['default'] ) {
445
+                    $field .= '<input type="text" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '_id" id="' . esc_attr( $args['id'] ) . '_id" placeholder="' . esc_attr( $args['placeholder'] ) . '_id"  value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
446
+               }
447
+
448
+               $field .= '<input type="hidden" name="MAX_FILE_SIZE" value="500000" />';
449
+
450
+               if ( $args['label'] && 'checkbox' !== $args['type'] ) {
451
+                    $field_html .= '<label for="' . esc_attr( $label_id ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) . '">' . $args['label'] . $required . '</label>';
452
+               }
453
+
454
+               $field_html .= $field;
455
+
456
+               if ( $args['description'] ) {
457
+                    $field_html .= '<span class="description">' . esc_html( $args['description'] ) . '</span>';
458
+               }
459
+
460
+               $container_class = esc_attr( implode( ' ', $args['class'] ) );
461
+               $container_id    = esc_attr( $args['id'] ) . '_field';
462
+               $field           = sprintf( $field_container, $container_class, $container_id, $field_html );
463
+          }
464
+          return $field;
465
+     }
466
+
467
+
468
+     public function action_woocommerce_after_edit_account_form() {
469
+          echo do_shortcode( '[avatar_upload /]' );
470
+     }
471
+
472
+     /**
473
+      * Get additional account fields.
474
+      *
475
+      * @return array
476
+      */
477
+     public function get_account_fields() {
478
+          $account_fields = apply_filters( 'lsx_hp_profile_fields', array(
479
+               'age'  => array(
480
+                    'type'                 => 'text',
481
+                    'label'                => __( 'Age:', 'lsx-health-plan' ),
482
+                    'placeholder'          => __( '#', 'lsx-health-plan' ),
483
+                    'hide_in_account'      => false,
484
+                    'hide_in_admin'        => false,
485
+                    'hide_in_checkout'     => false,
486
+                    'hide_in_registration' => false,
487
+                    'required'             => false,
488
+               ),
489
+               'weight'  => array(
490
+                    'type'                 => 'text',
491
+                    'label'                => __( 'Weight:', 'lsx-health-plan' ),
492
+                    'placeholder'          => __( 'kg', 'lsx-health-plan' ),
493
+                    'hide_in_account'      => false,
494
+                    'hide_in_admin'        => false,
495
+                    'hide_in_checkout'     => false,
496
+                    'hide_in_registration' => false,
497
+                    'required'             => false,
498
+               ),
499
+               'gender'   => array(
500
+                    'type'                 => 'select',
501
+                    'label'                => __( 'Gender:', 'lsx-health-plan' ),
502
+                    'placeholder'          => __( 'm/f', 'lsx-health-plan' ),
503
+                    'hide_in_account'      => false,
504
+                    'hide_in_admin'        => false,
505
+                    'hide_in_checkout'     => false,
506
+                    'hide_in_registration' => false,
507
+                    'required'             => false,
508
+                    'options'     => array(
509
+                         'male'   => __( 'Male', 'lsx-health-plan' ),
510
+                         'female' => __( 'Female', 'lsx-health-plan' ),
511
+                    ),
512
+               ),
513
+               'waist'   => array(
514
+                    'type'                 => 'text',
515
+                    'label'                => __( 'Waist:', 'lsx-health-plan' ),
516
+                    'placeholder'          => __( 'cm', 'lsx-health-plan' ),
517
+                    'hide_in_account'      => false,
518
+                    'hide_in_admin'        => false,
519
+                    'hide_in_checkout'     => false,
520
+                    'hide_in_registration' => false,
521
+                    'required'             => false,
522
+               ),
523
+               'height'     => array(
524
+                    'type'                 => 'text',
525
+                    'label'                => __( 'Height:', 'lsx-health-plan' ),
526
+                    'placeholder'          => __( 'cm', 'lsx-health-plan' ),
527
+                    'hide_in_account'      => false,
528
+                    'hide_in_admin'        => false,
529
+                    'hide_in_checkout'     => false,
530
+                    'hide_in_registration' => false,
531
+                    'required'             => false,
532
+               ),
533
+          ) );
534
+
535
+          $is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false );
536
+          if ( 'on' === $is_weight_disabled ) {
537
+               $account_fields['weight']['required'] = false;
538
+          }
539
+          $is_height_disabled = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false );
540
+          if ( 'on' === $is_height_disabled ) {
541
+               $account_fields['height']['required'] = false;
542
+          }
543
+          $is_waist_disabled = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false );
544
+          if ( 'on' === $is_waist_disabled ) {
545
+               $account_fields['waist']['required'] = false;
546
+          }
547
+          return $account_fields;
548
+     }
549 549
 }
Please login to merge, or discard this patch.
Spacing   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -21,25 +21,25 @@  discard block
 block discarded – undo
21 21
 	 * Contructor
22 22
 	 */
23 23
 	public function __construct() {
24
-		add_action( 'init', array( $this, 'init' ), 20, 1 );
24
+		add_action('init', array($this, 'init'), 20, 1);
25 25
 
26 26
 		// Redirect to the Edit Account Template.
27
-		add_filter( 'template_include', array( $this, 'account_endpoint_redirect' ), 99 );
27
+		add_filter('template_include', array($this, 'account_endpoint_redirect'), 99);
28 28
 
29
-		add_action( 'woocommerce_edit_account_form', array( $this, 'print_user_frontend_fields' ), 10 );
29
+		add_action('woocommerce_edit_account_form', array($this, 'print_user_frontend_fields'), 10);
30 30
 
31
-		add_filter( 'lsx_hp_profile_fields', array( $this, 'add_post_data_to_account_fields' ), 10, 1 );
32
-		add_action( 'show_user_profile', array( $this, 'print_user_admin_fields' ), 30 );
31
+		add_filter('lsx_hp_profile_fields', array($this, 'add_post_data_to_account_fields'), 10, 1);
32
+		add_action('show_user_profile', array($this, 'print_user_admin_fields'), 30);
33 33
 
34
-		add_action( 'personal_options_update', array( $this, 'save_account_fields' ) );
35
-		add_action( 'edit_user_profile_update', array( $this, 'save_account_fields' ) );
34
+		add_action('personal_options_update', array($this, 'save_account_fields'));
35
+		add_action('edit_user_profile_update', array($this, 'save_account_fields'));
36 36
 
37
-		add_action( 'woocommerce_save_account_details', array( $this, 'save_account_fields' ) );
38
-		add_filter( 'woocommerce_save_account_details_errors', array( $this, 'validate_user_frontend_fields' ), 10 );
37
+		add_action('woocommerce_save_account_details', array($this, 'save_account_fields'));
38
+		add_filter('woocommerce_save_account_details_errors', array($this, 'validate_user_frontend_fields'), 10);
39 39
 
40 40
 		// Profile Fields.
41
-		add_filter( 'woocommerce_form_field_text', array( $this, 'lsx_profile_photo_field_filter' ), 10, 4 );
42
-		add_action( 'woocommerce_after_edit_account_form', array( $this, 'action_woocommerce_after_edit_account_form' ), 10, 0 );
41
+		add_filter('woocommerce_form_field_text', array($this, 'lsx_profile_photo_field_filter'), 10, 4);
42
+		add_action('woocommerce_after_edit_account_form', array($this, 'action_woocommerce_after_edit_account_form'), 10, 0);
43 43
 	}
44 44
 
45 45
 	/**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public static function get_instance() {
53 53
 		// If the single instance hasn't been set, set it now.
54
-		if ( null === self::$instance ) {
54
+		if (null === self::$instance) {
55 55
 			self::$instance = new self();
56 56
 		}
57 57
 		return self::$instance;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @return void
64 64
 	 */
65 65
 	public function init() {
66
-		remove_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' );
66
+		remove_action('woocommerce_account_navigation', 'woocommerce_account_navigation');
67 67
 	}
68 68
 
69 69
 	/**
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 	 * @param string $template
73 73
 	 * @return string
74 74
 	 */
75
-	public function account_endpoint_redirect( $template ) {
76
-		if ( function_exists( 'is_account_page' ) && is_account_page() ) {
77
-			if ( empty( locate_template( array( 'page-template-my-plan.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php' ) ) {
75
+	public function account_endpoint_redirect($template) {
76
+		if (function_exists('is_account_page') && is_account_page()) {
77
+			if (empty(locate_template(array('page-template-my-plan.php'))) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php')) {
78 78
 				$template = LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php';
79 79
 			}
80 80
 		}
@@ -88,19 +88,19 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return array
90 90
 	 */
91
-	public function add_post_data_to_account_fields( $fields ) {
92
-		if ( empty( $_POST ) && wp_verify_nonce( sanitize_key( $_POST ) ) ) {
91
+	public function add_post_data_to_account_fields($fields) {
92
+		if (empty($_POST) && wp_verify_nonce(sanitize_key($_POST))) {
93 93
 			return $fields;
94 94
 		}
95 95
 
96
-		foreach ( $fields as $key => $field_args ) {
97
-			if ( isset( $_POST[ $key ] ) && empty( $_POST[ $key ] ) && wp_verify_nonce( sanitize_key( $_POST[ $key ] ) ) ) {
98
-				$fields[ $key ]['value'] = '';
96
+		foreach ($fields as $key => $field_args) {
97
+			if (isset($_POST[$key]) && empty($_POST[$key]) && wp_verify_nonce(sanitize_key($_POST[$key]))) {
98
+				$fields[$key]['value'] = '';
99 99
 				continue;
100 100
 			}
101 101
 
102
-			if ( isset( $_POST[ $key ] ) ) {
103
-				$fields[ $key ]['value'] = sanitize_key( $_POST[ $key ] );
102
+			if (isset($_POST[$key])) {
103
+				$fields[$key]['value'] = sanitize_key($_POST[$key]);
104 104
 			}
105 105
 		}
106 106
 
@@ -114,28 +114,28 @@  discard block
 block discarded – undo
114 114
 		$fields            = $this->get_account_fields();
115 115
 		$is_user_logged_in = is_user_logged_in();
116 116
 
117
-		$all_disabled = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
118
-		if ( 'on' !== $all_disabled ) {
119
-			echo wp_kses_post( '<h2 class="title-lined my-stats-title">' . __( 'My Stats', 'lsx-health-plan' ) . '</h2><p><strong>' . __( 'My physical info', 'lsx-health-plan' ) . '</strong></p>' );
120
-			echo wp_kses_post( '<div class="my-stats-wrap"><div class="my-stats">' );
121
-			foreach ( $fields as $key => $field_args ) {
117
+		$all_disabled = \lsx_health_plan\functions\get_option('disable_all_stats', false);
118
+		if ('on' !== $all_disabled) {
119
+			echo wp_kses_post('<h2 class="title-lined my-stats-title">' . __('My Stats', 'lsx-health-plan') . '</h2><p><strong>' . __('My physical info', 'lsx-health-plan') . '</strong></p>');
120
+			echo wp_kses_post('<div class="my-stats-wrap"><div class="my-stats">');
121
+			foreach ($fields as $key => $field_args) {
122 122
 				$value = null;
123
-				if ( ! $this->is_field_visible( $field_args ) ) {
123
+				if ( ! $this->is_field_visible($field_args)) {
124 124
 					continue;
125 125
 				}
126
-				if ( $is_user_logged_in ) {
126
+				if ($is_user_logged_in) {
127 127
 					$user_id = $this->get_edit_user_id();
128
-					$value   = $this->get_userdata( $user_id, $key );
128
+					$value   = $this->get_userdata($user_id, $key);
129 129
 				}
130
-				$value = ( isset( $field_args['value'] ) && '' !== $field_args['value'] ) ? $field_args['value'] : $value;
131
-				woocommerce_form_field( $key, $field_args, $value );
130
+				$value = (isset($field_args['value']) && '' !== $field_args['value']) ? $field_args['value'] : $value;
131
+				woocommerce_form_field($key, $field_args, $value);
132 132
 			}
133
-			$is_bmi_disabled = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false );
134
-			if ( 'on' !== $is_bmi_disabled ) {
135
-				echo wp_kses_post( '<p class="form-row calculate-bmi"><label>BMI</label><button class="btn border-btn">' . __( 'Calculate', 'lsx-health-plan' ) . '<i class="fa fa-calculator" aria-hidden="true"></i></button></p>' );
136
-				echo wp_kses_post( '</div>' );
137
-				echo wp_kses_post( '<div class="description"><p class="bmi-title"><strong>' . __( 'Your BMI score', 'lsx-health-plan' ) . '</strong></p>' );
138
-				echo wp_kses_post( '<p>' . __( "BMI is a measurement of a person's leanness or corpulence based on their height and weight, and is intended to quantify tissue mass. It is widely used as a general indicator of whether a person has a healthy body weight for their height.", 'lsx-health-plan' ) . '</p></div></div>' );
133
+			$is_bmi_disabled = \lsx_health_plan\functions\get_option('disable_bmi_checkbox', false);
134
+			if ('on' !== $is_bmi_disabled) {
135
+				echo wp_kses_post('<p class="form-row calculate-bmi"><label>BMI</label><button class="btn border-btn">' . __('Calculate', 'lsx-health-plan') . '<i class="fa fa-calculator" aria-hidden="true"></i></button></p>');
136
+				echo wp_kses_post('</div>');
137
+				echo wp_kses_post('<div class="description"><p class="bmi-title"><strong>' . __('Your BMI score', 'lsx-health-plan') . '</strong></p>');
138
+				echo wp_kses_post('<p>' . __("BMI is a measurement of a person's leanness or corpulence based on their height and weight, and is intended to quantify tissue mass. It is widely used as a general indicator of whether a person has a healthy body weight for their height.", 'lsx-health-plan') . '</p></div></div>');
139 139
 			}
140 140
 			
141 141
 		}
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @return mixed|string
151 151
 	 */
152
-	public function get_userdata( $user_id, $key ) {
153
-		if ( ! $this->is_userdata( $key ) ) {
154
-			return get_user_meta( $user_id, $key, true );
152
+	public function get_userdata($user_id, $key) {
153
+		if ( ! $this->is_userdata($key)) {
154
+			return get_user_meta($user_id, $key, true);
155 155
 		}
156 156
 
157
-		$userdata = get_userdata( $user_id );
157
+		$userdata = get_userdata($user_id);
158 158
 
159
-		if ( ! $userdata || ! isset( $userdata->{$key} ) ) {
159
+		if ( ! $userdata || ! isset($userdata->{$key} )) {
160 160
 			return '';
161 161
 		}
162 162
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 * @return int
170 170
 	 */
171 171
 	public function get_edit_user_id() {
172
-		return ( isset( $_GET['user_id'] ) && wp_verify_nonce( sanitize_key( $_GET['user_id'] ) ) ) ? (int) $_GET['user_id'] : get_current_user_id();
172
+		return (isset($_GET['user_id']) && wp_verify_nonce(sanitize_key($_GET['user_id']))) ? (int) $_GET['user_id'] : get_current_user_id();
173 173
 	}
174 174
 
175 175
 
@@ -178,47 +178,47 @@  discard block
 block discarded – undo
178 178
 	 *
179 179
 	 * @param int $customer_id
180 180
 	 */
181
-	public function save_account_fields( $customer_id ) {
182
-		$nonce_value = wc_get_var( $_REQUEST['save-account-details-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine.
183
-		if ( ! wp_verify_nonce( $nonce_value, 'save_account_details' ) ) {
181
+	public function save_account_fields($customer_id) {
182
+		$nonce_value = wc_get_var($_REQUEST['save-account-details-nonce'], wc_get_var($_REQUEST['_wpnonce'], '')); // @codingStandardsIgnoreLine.
183
+		if ( ! wp_verify_nonce($nonce_value, 'save_account_details')) {
184 184
 			return;
185 185
 		}
186 186
 
187 187
 		$fields         = $this->get_account_fields();
188 188
 		$sanitized_data = array();
189
-		foreach ( $fields as $key => $field_args ) {
190
-			if ( ! $this->is_field_visible( $field_args ) ) {
189
+		foreach ($fields as $key => $field_args) {
190
+			if ( ! $this->is_field_visible($field_args)) {
191 191
 				continue;
192 192
 			}
193 193
 
194
-			$sanitize = isset( $field_args['sanitize'] ) ? $field_args['sanitize'] : 'wc_clean';
195
-			$value    = ( isset( $_POST[ $key ] ) ) ? call_user_func( $sanitize, $_POST[ $key ] ) : '';
196
-			if ( $this->is_userdata( $key ) ) {
194
+			$sanitize = isset($field_args['sanitize']) ? $field_args['sanitize'] : 'wc_clean';
195
+			$value    = (isset($_POST[$key])) ? call_user_func($sanitize, $_POST[$key]) : '';
196
+			if ($this->is_userdata($key)) {
197 197
 
198
-				$sanitized_data[ $key ] = $value;
198
+				$sanitized_data[$key] = $value;
199 199
 				continue;
200 200
 			}
201 201
 
202
-			if ( 'profile_photo' === $key ) {
202
+			if ('profile_photo' === $key) {
203 203
 				// This handles the image uploads.
204 204
 				require_once ABSPATH . 'wp-admin/includes/image.php';
205 205
 				require_once ABSPATH . 'wp-admin/includes/file.php';
206 206
 				require_once ABSPATH . 'wp-admin/includes/media.php';
207 207
 
208
-				$id = media_handle_upload( $key, 0, '' );
209
-				if ( ! is_wp_error( $id ) ) {
210
-					update_term_meta( $customer_id, $key . '_id', $id );
211
-					update_term_meta( $customer_id, $key, $id );
208
+				$id = media_handle_upload($key, 0, '');
209
+				if ( ! is_wp_error($id)) {
210
+					update_term_meta($customer_id, $key . '_id', $id);
211
+					update_term_meta($customer_id, $key, $id);
212 212
 				}
213 213
 			} else {
214
-				delete_user_meta( $customer_id, $key );
215
-				update_user_meta( $customer_id, $key, $value );
214
+				delete_user_meta($customer_id, $key);
215
+				update_user_meta($customer_id, $key, $value);
216 216
 			}
217 217
 		}
218 218
 
219
-		if ( ! empty( $sanitized_data ) ) {
219
+		if ( ! empty($sanitized_data)) {
220 220
 			$sanitized_data['ID'] = $customer_id;
221
-			wp_update_user( $sanitized_data );
221
+			wp_update_user($sanitized_data);
222 222
 		}
223 223
 	}
224 224
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 *
231 231
 	 * @return bool
232 232
 	 */
233
-	public function is_userdata( $key ) {
233
+	public function is_userdata($key) {
234 234
 		$userdata = array(
235 235
 			'user_pass',
236 236
 			'user_login',
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 			'show_admin_bar_front',
252 252
 		);
253 253
 
254
-		return in_array( $key, $userdata, true );
254
+		return in_array($key, $userdata, true);
255 255
 	}
256 256
 
257 257
 	/**
@@ -261,31 +261,31 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @return bool
263 263
 	 */
264
-	public function is_field_visible( $field_args ) {
264
+	public function is_field_visible($field_args) {
265 265
 		$visible = true;
266
-		$action  = filter_input( INPUT_POST, 'action' );
266
+		$action  = filter_input(INPUT_POST, 'action');
267 267
 
268
-		if ( is_admin() && ! empty( $field_args['hide_in_admin'] ) ) {
268
+		if (is_admin() && ! empty($field_args['hide_in_admin'])) {
269 269
 			$visible = false;
270
-		} elseif ( ( is_account_page() || 'save_account_details' === $action ) && is_user_logged_in() && ! empty( $field_args['hide_in_account'] ) ) {
270
+		} elseif ((is_account_page() || 'save_account_details' === $action) && is_user_logged_in() && ! empty($field_args['hide_in_account'])) {
271 271
 			$visible = false;
272
-		} elseif ( ( is_account_page() || 'save_account_details' === $action ) && ! is_user_logged_in() && ! empty( $field_args['hide_in_registration'] ) ) {
272
+		} elseif ((is_account_page() || 'save_account_details' === $action) && ! is_user_logged_in() && ! empty($field_args['hide_in_registration'])) {
273 273
 			$visible = false;
274
-		} elseif ( is_checkout() && ! empty( $field_args['hide_in_checkout'] ) ) {
274
+		} elseif (is_checkout() && ! empty($field_args['hide_in_checkout'])) {
275 275
 			$visible = false;
276 276
 		}
277 277
 
278 278
 		// Disable the fitness fields if needed.
279
-		$weight_key  = __( 'Weight:' );
280
-		$waist_key   = __( 'Waist:' );
281
-		$fitness_key = __( 'BMI Score:' );
282
-		if ( $weight_key === $field_args['label'] || $waist_key === $field_args['label'] || $fitness_key === $field_args['label'] ) {
279
+		$weight_key  = __('Weight:');
280
+		$waist_key   = __('Waist:');
281
+		$fitness_key = __('BMI Score:');
282
+		if ($weight_key === $field_args['label'] || $waist_key === $field_args['label'] || $fitness_key === $field_args['label']) {
283 283
 
284 284
 			// Check if all stats are disabled.
285
-			$all_disabled = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
285
+			$all_disabled = \lsx_health_plan\functions\get_option('disable_all_stats', false);
286 286
 
287 287
 			$option_key = '';
288
-			switch ( $field_args['label'] ) {
288
+			switch ($field_args['label']) {
289 289
 				case $weight_key:
290 290
 					$option_key = 'disable_weight_checkbox';
291 291
 					break;
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 					$option_key = 'disable_bmi_checkbox';
303 303
 					break;
304 304
 			}
305
-			$is_disabled = \lsx_health_plan\functions\get_option( $option_key, false );
306
-			if ( 'on' === $all_disabled || 'on' === $is_disabled ) {
305
+			$is_disabled = \lsx_health_plan\functions\get_option($option_key, false);
306
+			if ('on' === $all_disabled || 'on' === $is_disabled) {
307 307
 				$visible = false;
308 308
 			}
309 309
 		}
@@ -316,25 +316,25 @@  discard block
 block discarded – undo
316 316
 	public function print_user_admin_fields() {
317 317
 		$fields = $this->get_account_fields();
318 318
 		?>
319
-		<h2><?php esc_html_e( 'Additional Information', 'lsx-health-plan' ); ?></h2>
319
+		<h2><?php esc_html_e('Additional Information', 'lsx-health-plan'); ?></h2>
320 320
 		<table class="form-table" id="iconic-additional-information">
321 321
 			<tbody>
322
-			<?php foreach ( $fields as $key => $field_args ) { ?>
322
+			<?php foreach ($fields as $key => $field_args) { ?>
323 323
 				<?php
324
-				if ( ! $this->is_field_visible( $field_args ) ) {
324
+				if ( ! $this->is_field_visible($field_args)) {
325 325
 					continue;
326 326
 				}
327 327
 
328 328
 				$user_id = $this->get_edit_user_id();
329
-				$value   = get_user_meta( $user_id, $key, true );
329
+				$value   = get_user_meta($user_id, $key, true);
330 330
 				?>
331 331
 				<tr>
332 332
 					<th>
333
-						<label for="<?php echo esc_html( $key ); ?>"><?php echo esc_html( $field_args['label'] ); ?></label>
333
+						<label for="<?php echo esc_html($key); ?>"><?php echo esc_html($field_args['label']); ?></label>
334 334
 					</th>
335 335
 					<td>
336 336
 						<?php $field_args['label'] = false; ?>
337
-						<?php woocommerce_form_field( $key, $field_args, $value ); ?>
337
+						<?php woocommerce_form_field($key, $field_args, $value); ?>
338 338
 					</td>
339 339
 				</tr>
340 340
 			<?php } ?>
@@ -350,11 +350,11 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @return WP_Error
352 352
 	 */
353
-	public function validate_user_frontend_fields( $errors ) {
353
+	public function validate_user_frontend_fields($errors) {
354 354
 		$fields = $this->get_account_fields();
355 355
 
356
-		foreach ( $fields as $key => $field_args ) {
357
-			if ( empty( $field_args['required'] ) ) {
356
+		foreach ($fields as $key => $field_args) {
357
+			if (empty($field_args['required'])) {
358 358
 				continue;
359 359
 			}
360 360
 
@@ -362,14 +362,14 @@  discard block
 block discarded – undo
362 362
 				continue;
363 363
 			}*/
364 364
 
365
-			if ( isset( $_POST['register'] ) && wp_verify_nonce( sanitize_key( $_POST['register'] ) ) && ! empty( $field_args['hide_in_registration'] ) ) {
365
+			if (isset($_POST['register']) && wp_verify_nonce(sanitize_key($_POST['register'])) && ! empty($field_args['hide_in_registration'])) {
366 366
 				continue;
367 367
 			}
368 368
 
369
-			if ( empty( $_POST[ $key ] ) ) {
369
+			if (empty($_POST[$key])) {
370 370
 				/* translators: %s: field */
371
-				$message = sprintf( __( '%s is a required field.', 'lsx-health-plan' ), '<strong>' . $field_args['label'] . '</strong>' );
372
-				$errors->add( $key, $message );
371
+				$message = sprintf(__('%s is a required field.', 'lsx-health-plan'), '<strong>' . $field_args['label'] . '</strong>');
372
+				$errors->add($key, $message);
373 373
 			}
374 374
 		}
375 375
 
@@ -385,48 +385,48 @@  discard block
 block discarded – undo
385 385
 	 *
386 386
 	 * @return mixed
387 387
 	 */
388
-	public function lsx_profile_photo_field_filter( $field, $key, $args, $value ) {
389
-		if ( 'profile_photo' === $args['id'] ) {
388
+	public function lsx_profile_photo_field_filter($field, $key, $args, $value) {
389
+		if ('profile_photo' === $args['id']) {
390 390
 
391
-			if ( $args['required'] ) {
391
+			if ($args['required']) {
392 392
 				$args['class'][] = 'validate-required';
393
-				$required        = ' <abbr class="required" title="' . esc_attr__( 'required', 'lsx-health-plan' ) . '">*</abbr>';
393
+				$required        = ' <abbr class="required" title="' . esc_attr__('required', 'lsx-health-plan') . '">*</abbr>';
394 394
 			} else {
395 395
 				$required = '';
396 396
 			}
397 397
 
398
-			if ( is_string( $args['label_class'] ) ) {
399
-				$args['label_class'] = array( $args['label_class'] );
398
+			if (is_string($args['label_class'])) {
399
+				$args['label_class'] = array($args['label_class']);
400 400
 			}
401 401
 
402
-			if ( is_null( $value ) ) {
402
+			if (is_null($value)) {
403 403
 				$value = $args['default'];
404 404
 			}
405 405
 
406 406
 			// Custom attribute handling.
407 407
 			$custom_attributes         = array();
408
-			$args['custom_attributes'] = array_filter( (array) $args['custom_attributes'], 'strlen' );
408
+			$args['custom_attributes'] = array_filter((array) $args['custom_attributes'], 'strlen');
409 409
 
410
-			if ( $args['maxlength'] ) {
411
-				$args['custom_attributes']['maxlength'] = absint( $args['maxlength'] );
410
+			if ($args['maxlength']) {
411
+				$args['custom_attributes']['maxlength'] = absint($args['maxlength']);
412 412
 			}
413 413
 
414
-			if ( ! empty( $args['autocomplete'] ) ) {
414
+			if ( ! empty($args['autocomplete'])) {
415 415
 				$args['custom_attributes']['autocomplete'] = $args['autocomplete'];
416 416
 			}
417 417
 
418
-			if ( true === $args['autofocus'] ) {
418
+			if (true === $args['autofocus']) {
419 419
 				$args['custom_attributes']['autofocus'] = 'autofocus';
420 420
 			}
421 421
 
422
-			if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
423
-				foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) {
424
-					$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
422
+			if ( ! empty($args['custom_attributes']) && is_array($args['custom_attributes'])) {
423
+				foreach ($args['custom_attributes'] as $attribute => $attribute_value) {
424
+					$custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
425 425
 				}
426 426
 			}
427 427
 
428
-			if ( ! empty( $args['validate'] ) ) {
429
-				foreach ( $args['validate'] as $validate ) {
428
+			if ( ! empty($args['validate'])) {
429
+				foreach ($args['validate'] as $validate) {
430 430
 					$args['class'][] = 'validate-' . $validate;
431 431
 				}
432 432
 			}
@@ -435,38 +435,38 @@  discard block
 block discarded – undo
435 435
 			$field           = '';
436 436
 			$label_id        = $args['id'];
437 437
 			$sort            = $args['priority'] ? $args['priority'] : '';
438
-			$field_container = '<p class="form-row %1$s" id="%2$s" data-priority="' . esc_attr( $sort ) . '">%3$s</p>';
438
+			$field_container = '<p class="form-row %1$s" id="%2$s" data-priority="' . esc_attr($sort) . '">%3$s</p>';
439 439
 			$args['class'][] = 'validate-required';
440
-			$required        = ' <abbr class="required" title="' . esc_attr__( 'required', 'lsx-health-plan' ) . '">*</abbr>';
440
+			$required        = ' <abbr class="required" title="' . esc_attr__('required', 'lsx-health-plan') . '">*</abbr>';
441 441
 
442
-			$field .= '<input accept="image/*" type="file" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '"  value="" ' . implode( ' ', $custom_attributes ) . ' />';
442
+			$field .= '<input accept="image/*" type="file" class="input-text ' . esc_attr(implode(' ', $args['input_class'])) . '" name="' . esc_attr($key) . '" id="' . esc_attr($args['id']) . '" placeholder="' . esc_attr($args['placeholder']) . '"  value="" ' . implode(' ', $custom_attributes) . ' />';
443 443
 
444
-			if ( '' !== $value && $value !== $args['default'] ) {
445
-				$field .= '<input type="text" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '_id" id="' . esc_attr( $args['id'] ) . '_id" placeholder="' . esc_attr( $args['placeholder'] ) . '_id"  value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
444
+			if ('' !== $value && $value !== $args['default']) {
445
+				$field .= '<input type="text" class="input-text ' . esc_attr(implode(' ', $args['input_class'])) . '" name="' . esc_attr($key) . '_id" id="' . esc_attr($args['id']) . '_id" placeholder="' . esc_attr($args['placeholder']) . '_id"  value="' . esc_attr($value) . '" ' . implode(' ', $custom_attributes) . ' />';
446 446
 			}
447 447
 
448 448
 			$field .= '<input type="hidden" name="MAX_FILE_SIZE" value="500000" />';
449 449
 
450
-			if ( $args['label'] && 'checkbox' !== $args['type'] ) {
451
-				$field_html .= '<label for="' . esc_attr( $label_id ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) . '">' . $args['label'] . $required . '</label>';
450
+			if ($args['label'] && 'checkbox' !== $args['type']) {
451
+				$field_html .= '<label for="' . esc_attr($label_id) . '" class="' . esc_attr(implode(' ', $args['label_class'])) . '">' . $args['label'] . $required . '</label>';
452 452
 			}
453 453
 
454 454
 			$field_html .= $field;
455 455
 
456
-			if ( $args['description'] ) {
457
-				$field_html .= '<span class="description">' . esc_html( $args['description'] ) . '</span>';
456
+			if ($args['description']) {
457
+				$field_html .= '<span class="description">' . esc_html($args['description']) . '</span>';
458 458
 			}
459 459
 
460
-			$container_class = esc_attr( implode( ' ', $args['class'] ) );
461
-			$container_id    = esc_attr( $args['id'] ) . '_field';
462
-			$field           = sprintf( $field_container, $container_class, $container_id, $field_html );
460
+			$container_class = esc_attr(implode(' ', $args['class']));
461
+			$container_id    = esc_attr($args['id']) . '_field';
462
+			$field           = sprintf($field_container, $container_class, $container_id, $field_html);
463 463
 		}
464 464
 		return $field;
465 465
 	}
466 466
 
467 467
 
468 468
 	public function action_woocommerce_after_edit_account_form() {
469
-		echo do_shortcode( '[avatar_upload /]' );
469
+		echo do_shortcode('[avatar_upload /]');
470 470
 	}
471 471
 
472 472
 	/**
@@ -475,11 +475,11 @@  discard block
 block discarded – undo
475 475
 	 * @return array
476 476
 	 */
477 477
 	public function get_account_fields() {
478
-		$account_fields = apply_filters( 'lsx_hp_profile_fields', array(
478
+		$account_fields = apply_filters('lsx_hp_profile_fields', array(
479 479
 			'age'  => array(
480 480
 				'type'                 => 'text',
481
-				'label'                => __( 'Age:', 'lsx-health-plan' ),
482
-				'placeholder'          => __( '#', 'lsx-health-plan' ),
481
+				'label'                => __('Age:', 'lsx-health-plan'),
482
+				'placeholder'          => __('#', 'lsx-health-plan'),
483 483
 				'hide_in_account'      => false,
484 484
 				'hide_in_admin'        => false,
485 485
 				'hide_in_checkout'     => false,
@@ -488,8 +488,8 @@  discard block
 block discarded – undo
488 488
 			),
489 489
 			'weight'  => array(
490 490
 				'type'                 => 'text',
491
-				'label'                => __( 'Weight:', 'lsx-health-plan' ),
492
-				'placeholder'          => __( 'kg', 'lsx-health-plan' ),
491
+				'label'                => __('Weight:', 'lsx-health-plan'),
492
+				'placeholder'          => __('kg', 'lsx-health-plan'),
493 493
 				'hide_in_account'      => false,
494 494
 				'hide_in_admin'        => false,
495 495
 				'hide_in_checkout'     => false,
@@ -498,22 +498,22 @@  discard block
 block discarded – undo
498 498
 			),
499 499
 			'gender'   => array(
500 500
 				'type'                 => 'select',
501
-				'label'                => __( 'Gender:', 'lsx-health-plan' ),
502
-				'placeholder'          => __( 'm/f', 'lsx-health-plan' ),
501
+				'label'                => __('Gender:', 'lsx-health-plan'),
502
+				'placeholder'          => __('m/f', 'lsx-health-plan'),
503 503
 				'hide_in_account'      => false,
504 504
 				'hide_in_admin'        => false,
505 505
 				'hide_in_checkout'     => false,
506 506
 				'hide_in_registration' => false,
507 507
 				'required'             => false,
508 508
 				'options'     => array(
509
-					'male'   => __( 'Male', 'lsx-health-plan' ),
510
-					'female' => __( 'Female', 'lsx-health-plan' ),
509
+					'male'   => __('Male', 'lsx-health-plan'),
510
+					'female' => __('Female', 'lsx-health-plan'),
511 511
 				),
512 512
 			),
513 513
 			'waist'   => array(
514 514
 				'type'                 => 'text',
515
-				'label'                => __( 'Waist:', 'lsx-health-plan' ),
516
-				'placeholder'          => __( 'cm', 'lsx-health-plan' ),
515
+				'label'                => __('Waist:', 'lsx-health-plan'),
516
+				'placeholder'          => __('cm', 'lsx-health-plan'),
517 517
 				'hide_in_account'      => false,
518 518
 				'hide_in_admin'        => false,
519 519
 				'hide_in_checkout'     => false,
@@ -522,26 +522,26 @@  discard block
 block discarded – undo
522 522
 			),
523 523
 			'height'     => array(
524 524
 				'type'                 => 'text',
525
-				'label'                => __( 'Height:', 'lsx-health-plan' ),
526
-				'placeholder'          => __( 'cm', 'lsx-health-plan' ),
525
+				'label'                => __('Height:', 'lsx-health-plan'),
526
+				'placeholder'          => __('cm', 'lsx-health-plan'),
527 527
 				'hide_in_account'      => false,
528 528
 				'hide_in_admin'        => false,
529 529
 				'hide_in_checkout'     => false,
530 530
 				'hide_in_registration' => false,
531 531
 				'required'             => false,
532 532
 			),
533
-		) );
533
+		));
534 534
 
535
-		$is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false );
536
-		if ( 'on' === $is_weight_disabled ) {
535
+		$is_weight_disabled = \lsx_health_plan\functions\get_option('disable_weight_checkbox', false);
536
+		if ('on' === $is_weight_disabled) {
537 537
 			$account_fields['weight']['required'] = false;
538 538
 		}
539
-		$is_height_disabled = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false );
540
-		if ( 'on' === $is_height_disabled ) {
539
+		$is_height_disabled = \lsx_health_plan\functions\get_option('disable_height_checkbox', false);
540
+		if ('on' === $is_height_disabled) {
541 541
 			$account_fields['height']['required'] = false;
542 542
 		}
543
-		$is_waist_disabled = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false );
544
-		if ( 'on' === $is_waist_disabled ) {
543
+		$is_waist_disabled = \lsx_health_plan\functions\get_option('disable_waist_checkbox', false);
544
+		if ('on' === $is_waist_disabled) {
545 545
 			$account_fields['waist']['required'] = false;
546 546
 		}
547 547
 		return $account_fields;
Please login to merge, or discard this patch.
classes/admin/class-settings.php 2 patches
Indentation   +693 added lines, -693 removed lines patch added patch discarded remove patch
@@ -12,697 +12,697 @@
 block discarded – undo
12 12
  */
13 13
 class Settings {
14 14
 
15
-	/**
16
-	 * Holds class instance
17
-	 *
18
-	 * @since 1.0.0
19
-	 *
20
-	 * @var      object \lsx_health_plan\classes\admin\Settings()
21
-	 */
22
-	protected static $instance = null;
23
-
24
-	/**
25
-	 * Option key, and option page slug
26
-	 *
27
-	 * @var string
28
-	 */
29
-	protected $screen_id = 'lsx_health_plan_settings';
30
-
31
-	/**
32
-	 * An array of the post types for the Global Downloads field.
33
-	 *
34
-	 * @var array
35
-	 */
36
-	public $download_types = array();
37
-
38
-	/**
39
-	 * An array of the post types for the Global Defaults field.
40
-	 *
41
-	 * @var array
42
-	 */
43
-	public $default_types = array();
44
-
45
-	/**
46
-	 * An array of the endpoints for the Endpoint Translation field.
47
-	 *
48
-	 * @var array
49
-	 */
50
-	public $endpoints = array();
51
-
52
-	/**
53
-	 * Constructor
54
-	 */
55
-	public function __construct() {
56
-		$this->load_classes();
57
-		add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) );
58
-		add_action( 'lsx_hp_settings_page', array( $this, 'generate_tabs' ), 1, 1 );
59
-
60
-		add_action( 'lsx_hp_settings_page_general_top', array( $this, 'general_settings' ), 1, 1 );
61
-		add_action( 'lsx_hp_settings_page', array( $this, 'global_defaults' ), 3, 1 );
62
-		add_action( 'lsx_hp_settings_page', array( $this, 'global_downloads' ), 5, 1 );
63
-		add_action( 'lsx_hp_settings_page', array( $this, 'stat_disable' ), 6, 1 );
64
-		add_action( 'lsx_hp_settings_page', array( $this, 'endpoint_translations' ), 7, 1 );
65
-		add_action( 'lsx_hp_settings_page', array( $this, 'exercise_translations' ), 7, 1 );
66
-		add_action( 'lsx_hp_settings_page', array( $this, 'post_type_toggles' ), 9, 1 );
67
-	}
68
-
69
-	/**
70
-	 * Return an instance of this class.
71
-	 *
72
-	 * @since 1.0.0
73
-	 *
74
-	 * @return    object \lsx_health_plan\classes\admin\Settings()    A single instance of this class.
75
-	 */
76
-	public static function get_instance() {
77
-		// If the single instance hasn't been set, set it now.
78
-		if ( null === self::$instance ) {
79
-			self::$instance = new self();
80
-		}
81
-		return self::$instance;
82
-	}
83
-
84
-	/**
85
-	 * Loads the variable classes and the static classes.
86
-	 */
87
-	private function load_classes() {
88
-
89
-		$this->post_types = array(
90
-			'plan',
91
-			'workout',
92
-			'exercise',
93
-			//'meal',
94
-			'recipe',
95
-			//'tip',
96
-		);
97
-
98
-		foreach ( $this->post_types as $post_type ) {
99
-			$this->$post_type = require_once LSX_HEALTH_PLAN_PATH . 'classes/admin/settings/class-' . $post_type . '.php';
100
-		}
101
-	}
102
-
103
-	/**
104
-	 * Sets the variables needed for the fields.
105
-	 *
106
-	 * @return void
107
-	 */
108
-	public function set_vars() {
109
-
110
-		$this->default_types  = array(
111
-			'page' => array(
112
-				'title'       => __( 'Warm Up', 'lsx-health-plan' ),
113
-				'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ),
114
-				'limit'       => 1,
115
-				'id'          => 'plan_warmup',
116
-			),
117
-		);
118
-		$this->download_types = array(
119
-			'page' => array(
120
-				'title'       => __( 'Warm Up', 'lsx-health-plan' ),
121
-				'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ),
122
-				'limit'       => 1,
123
-			),
124
-		);
125
-		$this->endpoints      = array(
126
-			'endpoint_warm_up' => array(
127
-				'title'       => __( 'Warm Up Endpoint', 'lsx-health-plan' ),
128
-				'default'     => 'warm-up',
129
-			),
130
-		);
131
-
132
-		if ( post_type_exists( 'meal' ) ) {
133
-			$this->download_types['meal']     = array(
134
-				'title'       => __( 'Meal Plan', 'lsx-health-plan' ),
135
-				'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ),
136
-			);
137
-			$this->default_types['meal']      = array(
138
-				'title'       => __( 'Meal Plan', 'lsx-health-plan' ),
139
-				'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ),
140
-				'id'          => 'connected_meals',
141
-			);
142
-			$this->endpoints['endpoint_meal'] = array(
143
-				'title'       => __( 'Meal Endpoint', 'lsx-health-plan' ),
144
-				'default'     => 'meal',
145
-				'description' => __( 'Define the tab slug which shows on the single plan page.', 'lsx-health-plan' ),
146
-			);
147
-			$this->endpoints['endpoint_meal_archive'] = array(
148
-				'title'   => __( 'Meals Archive Endpoint', 'lsx-health-plan' ),
149
-				'default' => 'meals',
150
-			);
151
-			$this->endpoints['meal_single_slug'] = array(
152
-				'title'   => __( 'Single Meal Slug', 'lsx-health-plan' ),
153
-				'default' => 'meal',
154
-			);
155
-		}
156
-		if ( post_type_exists( 'recipe' ) ) {
157
-			$this->download_types['recipe'] = array(
158
-				'title'       => __( 'Recipe', 'lsx-health-plan' ),
159
-				'description' => __( 'Set a default recipe.', 'lsx-health-plan' ),
160
-			);
161
-			$this->default_types['recipe'] = array(
162
-				'title'       => __( 'Recipe', 'lsx-health-plan' ),
163
-				'description' => __( 'Set a default recipe.', 'lsx-health-plan' ),
164
-				'id'          => 'connected_recipes',
165
-			);
166
-			$this->endpoints['endpoint_recipe'] = array(
167
-				'title'   => __( 'Recipes Endpoint', 'lsx-health-plan' ),
168
-				'default' => 'recipe',
169
-			);
170
-		}
171
-		if ( post_type_exists( 'workout' ) ) {
172
-			$this->download_types['workout'] = array(
173
-				'title'       => __( 'Workout', 'lsx-health-plan' ),
174
-				'description' => __( 'Set a default workout routine PDF.', 'lsx-health-plan' ),
175
-			);
176
-			$this->default_types['workout'] = array(
177
-				'title'       => __( 'Workout', 'lsx-health-plan' ),
178
-				'description' => __( 'Set a default workout routine.', 'lsx-health-plan' ),
179
-				'id'          => 'connected_workouts',
180
-			);
181
-			$this->endpoints['endpoint_workout_archive'] = array(
182
-				'title'   => __( 'Workouts Archive Endpoint', 'lsx-health-plan' ),
183
-				'default' => '',
184
-			);
185
-			$this->endpoints['endpoint_workout'] = array(
186
-				'title'   => __( 'Single Workout Endpoint', 'lsx-health-plan' ),
187
-				'default' => 'workout',
188
-			);
189
-		}
190
-
191
-		$this->endpoints['login_slug'] = array(
192
-			'title'   => __( 'Login Slug', 'lsx-health-plan' ),
193
-			'default' => 'login',
194
-		);
195
-		$this->endpoints['my_plan_slug'] = array(
196
-			'title'   => __( 'My Plan Slug', 'lsx-health-plan' ),
197
-			'default' => 'my-plan',
198
-		);
199
-		$this->endpoints['plan_single_slug'] = array(
200
-			'title'   => __( 'Single Plan Slug', 'lsx-health-plan' ),
201
-			'default' => 'plan',
202
-		);
203
-		$this->endpoints['endpoint_plan_archive'] = array(
204
-			'title'   => __( 'Plans Archive Endpoint', 'lsx-health-plan' ),
205
-			'default' => 'plans',
206
-		);
207
-
208
-		if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
209
-			$this->endpoints['exercise'] = array(
210
-				'exercise_single' => array(
211
-					'title'   => __( 'Single Exercise Slug', 'lsx-health-plan' ),
212
-					'default' => 'exercise',
213
-				),
214
-				'exercise_archive' => array(
215
-					'title'   => __( 'Archive Exercise Slug', 'lsx-health-plan' ),
216
-					'default' => 'exercises',
217
-				),
218
-				'exercise_type' => array(
219
-					'title'   => __( 'Exercise Type Slug', 'lsx-health-plan' ),
220
-					'default' => 'exercise-type',
221
-				),
222
-				'exercise_equipment' => array(
223
-					'title'   => __( 'Equipment Slug', 'lsx-health-plan' ),
224
-					'default' => 'equipment',
225
-				),
226
-				'exercise_musclegroup' => array(
227
-					'title'   => __( 'Muscle Group Slug', 'lsx-health-plan' ),
228
-					'default' => 'muscle-group',
229
-				),
230
-			);
231
-		}
232
-	}
233
-
234
-	/**
235
-	 * Hook in and register a submenu options page for the Page post-type menu.
236
-	 */
237
-	public function register_settings_page() {
238
-		$this->set_vars();
239
-		$cmb = new_cmb2_box(
240
-			array(
241
-				'id'           => $this->screen_id,
242
-				'title'        => esc_html__( 'Settings', 'lsx-health-plan' ),
243
-				'object_types' => array( 'options-page' ),
244
-				'option_key'   => 'lsx_health_plan_options', // The option key and admin menu page slug.
245
-				'parent_slug'  => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu.
246
-				'capability'   => 'manage_options', // Cap required to view options-page.
247
-			)
248
-		);
249
-		do_action( 'lsx_hp_settings_page', $cmb );
250
-	}
251
-
252
-	/**
253
-	 * Registers the general settings.
254
-	 *
255
-	 * @param object $cmb new_cmb2_box().
256
-	 * @return void
257
-	 */
258
-	public function general_settings( $cmb ) {
259
-		$cmb->add_field(
260
-			array(
261
-				'name'       => __( 'Membership Product', 'lsx-health-plan' ),
262
-				'id'         => 'membership_product',
263
-				'type'       => 'post_search_ajax',
264
-				'limit'      => 1,
265
-				'sortable'   => false,
266
-				'query_args' => array(
267
-					'post_type'      => array( 'product' ),
268
-					'post_status'    => array( 'publish' ),
269
-					'posts_per_page' => -1,
270
-				),
271
-			)
272
-		);
273
-
274
-		$cmb->add_field(
275
-			array(
276
-				'name'    => __( 'Your Warm-up Intro', 'lsx-health-plan' ),
277
-				'id'      => 'warmup_intro',
278
-				'type'    => 'textarea_small',
279
-				'value'   => '',
280
-				'default' => __( "Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan' ),
281
-			)
282
-		);
283
-		if ( post_type_exists( 'workout' ) ) {
284
-			$cmb->add_field(
285
-				array(
286
-					'name'    => __( 'Your Workout Intro', 'lsx-health-plan' ),
287
-					'id'      => 'workout_intro',
288
-					'type'    => 'textarea_small',
289
-					'value'   => '',
290
-					'default' => __( "Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan' ),
291
-				)
292
-			);
293
-		}
294
-		if ( post_type_exists( 'meal' ) ) {
295
-			$cmb->add_field(
296
-				array(
297
-					'name'    => __( 'Your Meal Plan Intro', 'lsx-health-plan' ),
298
-					'id'      => 'meal_plan_intro',
299
-					'type'    => 'textarea_small',
300
-					'value'   => '',
301
-					'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ),
302
-				)
303
-			);
304
-		}
305
-		if ( post_type_exists( 'recipe' ) ) {
306
-			$cmb->add_field(
307
-				array(
308
-					'name'    => __( 'Recipes Intro', 'lsx-health-plan' ),
309
-					'id'      => 'recipes_intro',
310
-					'type'    => 'textarea_small',
311
-					'value'   => '',
312
-					'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan' ),
313
-				)
314
-			);
315
-		}
316
-	}
317
-
318
-	/**
319
-	 * Registers the global default settings.
320
-	 *
321
-	 * @param object $cmb new_cmb2_box().
322
-	 * @return void
323
-	 */
324
-	public function global_defaults( $cmb ) {
325
-		$cmb->add_field(
326
-			array(
327
-				'id'      => 'global_defaults_title',
328
-				'type'    => 'title',
329
-				'name'    => __( 'Global Defaults', 'lsx-health-plan' ),
330
-				'default' => __( 'Global Defaults', 'lsx-health-plan' ),
331
-				'description' => __( 'If you have not connected a specific post to your day plan, set a default option below.', 'lsx-health-plan' ),
332
-			)
333
-		);
334
-
335
-		foreach ( $this->default_types as $type => $default_type ) {
336
-			$limit    = 5;
337
-			$sortable = false;
338
-			if ( isset( $default_type['limit'] ) ) {
339
-				$limit    = $default_type['limit'];
340
-				$sortable = true;
341
-			}
342
-
343
-			if ( 'page' === $type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
344
-				$type = array( 'page', 'workout' );
345
-			}
346
-
347
-			$cmb->add_field(
348
-				array(
349
-					'name'       => $default_type['title'],
350
-					'desc'       => $default_type['description'],
351
-					'id'         => $default_type['id'],
352
-					'type'       => 'post_search_ajax',
353
-					'limit'      => $limit,
354
-					'sortable'   => $sortable,
355
-					'query_args' => array(
356
-						'post_type'      => $type,
357
-						'post_status'    => array( 'publish' ),
358
-						'posts_per_page' => -1,
359
-					),
360
-				)
361
-			);
362
-		}
363
-
364
-		$cmb->add_field(
365
-			array(
366
-				'id'   => 'settings_global_defaults_closing',
367
-				'type' => 'tab_closing',
368
-			)
369
-		);
370
-	}
371
-
372
-	/**
373
-	 * Registers the global dowloads settings
374
-	 *
375
-	 * @param object $cmb new_cmb2_box().
376
-	 * @return void
377
-	 */
378
-	public function global_downloads( $cmb ) {
379
-		$cmb->add_field(
380
-			array(
381
-				'id'      => 'global_downloads_title',
382
-				'type'    => 'title',
383
-				'name'    => __( 'Global Downloads', 'lsx-health-plan' ),
384
-				'default' => __( 'Global Downloads', 'lsx-health-plan' ),
385
-			)
386
-		);
387
-
388
-		foreach ( $this->download_types as $type => $download_type ) {
389
-			$limit    = 5;
390
-			$sortable = false;
391
-			if ( isset( $download_type['limit'] ) ) {
392
-				$limit    = $download_type['limit'];
393
-				$sortable = true;
394
-			}
395
-
396
-			$cmb->add_field(
397
-				array(
398
-					'name'       => $download_type['title'],
399
-					'id'         => 'download_' . $type,
400
-					'type'       => 'post_search_ajax',
401
-					'limit'      => $limit,
402
-					'sortable'   => $sortable,
403
-					'query_args' => array(
404
-						'post_type'      => array( 'dlm_download' ),
405
-						'post_status'    => array( 'publish' ),
406
-						'posts_per_page' => -1,
407
-					),
408
-				)
409
-			);
410
-		}
411
-		$cmb->add_field(
412
-			array(
413
-				'id'   => 'settings_global_downloads_closing',
414
-				'type' => 'tab_closing',
415
-			)
416
-		);
417
-	}
418
-
419
-	/**
420
-	 * Registers the endpoint translation settings.
421
-	 *
422
-	 * @param object $cmb new_cmb2_box().
423
-	 * @return void
424
-	 */
425
-	public function endpoint_translations( $cmb ) {
426
-		$cmb->add_field(
427
-			array(
428
-				'id'          => 'endpoints_title',
429
-				'type'        => 'title',
430
-				'name'        => __( 'Set Endpoint Translations', 'lsx-health-plan' ),
431
-				'default'     => __( 'Set Endpoint Translations', 'lsx-health-plan' ),
432
-				'description' => __( 'Endpoint is a web address (URL) at which the user can gain access to it. You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ),
433
-			)
434
-		);
435
-		foreach ( $this->endpoints as $slug => $endpoint_vars ) {
436
-			if ( 'exercise' === $slug ) {
437
-				continue;
438
-			}
439
-
440
-			$cmb->add_field(
441
-				array(
442
-					'name'    => $endpoint_vars['title'],
443
-					'id'      => $slug,
444
-					'type'    => 'input',
445
-					'value'   => '',
446
-					'default' => $endpoint_vars['default'],
447
-				)
448
-			);
449
-		}
450
-		$cmb->add_field(
451
-			array(
452
-				'id'   => 'settings_endpoints_closing',
453
-				'type' => 'tab_closing',
454
-			)
455
-		);
456
-	}
457
-
458
-	/**
459
-	 * Registers the endpoint translation settings.
460
-	 *
461
-	 * @param object $cmb new_cmb2_box().
462
-	 * @return void
463
-	 */
464
-	public function exercise_translations( $cmb ) {
465
-		if ( isset( $this->endpoints['exercise'] ) && '' !== $this->endpoints['exercise'] && ! empty( $this->endpoints['exercise'] ) ) {
466
-			$cmb->add_field(
467
-				array(
468
-					'id'          => 'exercise_endpoints_title',
469
-					'type'        => 'title',
470
-					'name'        => __( 'Set Exercise Translations', 'lsx-health-plan' ),
471
-					'default'     => __( 'Set Exercise Translations', 'lsx-health-plan' ),
472
-					'description' => __( 'You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ),
473
-				)
474
-			);
475
-
476
-			foreach ( $this->endpoints['exercise'] as $slug => $endpoint_vars ) {
477
-				$cmb->add_field(
478
-					array(
479
-						'name'    => $endpoint_vars['title'],
480
-						'id'      => 'endpoint_' . $slug,
481
-						'type'    => 'input',
482
-						'value'   => '',
483
-						'default' => $endpoint_vars['default'],
484
-					)
485
-				);
486
-			}
487
-			$cmb->add_field(
488
-				array(
489
-					'id'   => 'settings_exercise_closing',
490
-					'type' => 'tab_closing',
491
-				)
492
-			);
493
-		}
494
-	}
495
-
496
-	/**
497
-	 * Registers the post type toggle settings
498
-	 *
499
-	 * @param object $cmb new_cmb2_box().
500
-	 * @return void
501
-	 */
502
-	public function post_type_toggles( $cmb ) {
503
-		$post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) );
504
-
505
-		$cmb->add_field(
506
-			array(
507
-				'id'          => 'post_type_toggles_title',
508
-				'type'        => 'title',
509
-				'name'        => __( 'Disable Post Types', 'lsx-health-plan' ),
510
-				'default'     => __( 'Disable Post Types', 'lsx-health-plan' ),
511
-				'description' => __( 'Disable post types if you are wanting a minimal site.', 'lsx-health-plan' ),
512
-			)
513
-		);
514
-
515
-		foreach ( $post_types as $post_type ) {
516
-			if ( 'plan' === $post_type || 'exercise' === $post_type || ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) ) {
517
-				continue;
518
-			}
519
-
520
-			$cmb->add_field(
521
-				array(
522
-					'name'    => ucwords( $post_type ),
523
-					'id'      => $post_type . '_disabled',
524
-					'type'    => 'checkbox',
525
-					'value'   => 1,
526
-					'default' => 0,
527
-				)
528
-			);
529
-		}
530
-
531
-		$cmb->add_field(
532
-			array(
533
-				'id'   => 'settings_post_type_toggles_closing',
534
-				'type' => 'tab_closing',
535
-			)
536
-		);
537
-
538
-		$cmb->add_field(
539
-			array(
540
-				'id'          => 'post_type_toggles_enable_title',
541
-				'type'        => 'title',
542
-				'name'        => __( 'Enable Post Types', 'lsx-health-plan' ),
543
-				'default'     => __( 'Enable Post Types', 'lsx-health-plan' ),
544
-				'description' => __( 'Enable new functionality like the "exercise" post type.', 'lsx-health-plan' ),
545
-			)
546
-		);
547
-		$cmb->add_field(
548
-			array(
549
-				'name'        => __( 'Exercises', 'lsx-health-plan' ),
550
-				'id'          => 'exercise_enabled',
551
-				'type'        => 'checkbox',
552
-				'value'       => 1,
553
-				'default'     => 0,
554
-				'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ),
555
-			)
556
-		);
557
-		$cmb->add_field(
558
-			array(
559
-				'id'   => 'settings_post_type_toggles_enable_closing',
560
-				'type' => 'tab_closing',
561
-			)
562
-		);
563
-	}
564
-	/**
565
-	 * Registers the Profile Stat Toggle settings
566
-	 *
567
-	 * @param object $cmb new_cmb2_box().
568
-	 * @return void
569
-	 */
570
-
571
-	public function stat_disable( $cmb ) {
572
-		$cmb->add_field(
573
-			array(
574
-				'id'      => 'stat_disable_title',
575
-				'type'    => 'title',
576
-				'name'    => __( 'Disable Profile Stats', 'lsx-health-plan' ),
577
-				'default' => __( 'Disable Profile Stats', 'lsx-health-plan' ),
578
-			)
579
-		);
580
-		$cmb->add_field(
581
-			array(
582
-				'name'    => __( 'Disable All Stats', 'lsx-health-plan' ),
583
-				'desc'    => 'Disable All Stats',
584
-				'id'      => 'disable_all_stats',
585
-				'type'    => 'checkbox',
586
-				'value'   => 1,
587
-				'default' => 0,
588
-			)
589
-		);
590
-		$cmb->add_field(
591
-			array(
592
-				'name'    => __( 'Disable Weight', 'lsx-health-plan' ),
593
-				'id'      => 'disable_weight_checkbox',
594
-				'type'    => 'checkbox',
595
-				'value'   => 1,
596
-				'default' => 0,
597
-			)
598
-		);
599
-		$cmb->add_field(
600
-			array(
601
-				'name'    => __( 'Disable Height', 'lsx-health-plan' ),
602
-				'id'      => 'disable_height_checkbox',
603
-				'type'    => 'checkbox',
604
-				'value'   => 1,
605
-				'default' => 0,
606
-			)
607
-		);
608
-		$cmb->add_field(
609
-			array(
610
-				'name'    => __( 'Disable Waist', 'lsx-health-plan' ),
611
-				'id'      => 'disable_waist_checkbox',
612
-				'type'    => 'checkbox',
613
-				'value'   => 1,
614
-				'default' => 0,
615
-			)
616
-		);
617
-		$cmb->add_field(
618
-			array(
619
-				'name'    => __( 'Disable BMI', 'lsx-health-plan' ),
620
-				'id'      => 'disable_bmi_checkbox',
621
-				'type'    => 'checkbox',
622
-				'value'   => 1,
623
-				'default' => 0,
624
-			)
625
-		);
626
-		$cmb->add_field(
627
-			array(
628
-				'id'   => 'settings_stat_disable_closing',
629
-				'type' => 'tab_closing',
630
-			)
631
-		);
632
-	}
633
-
634
-	/**
635
-	 * Enable Business Directory Search settings only if LSX Search plugin is enabled.
636
-	 *
637
-	 * @param object $cmb The CMB2() class.
638
-	 * @param string $section either engine,archive or single.
639
-	 * @return void
640
-	 */
641
-	public function generate_tabs( $cmb ) {
642
-		$tabs = $this->get_settings_tabs();
643
-
644
-		foreach ( $tabs as $tab_key => $tab ) {
645
-			$cmb->add_field(
646
-				array(
647
-					'id'          => 'settings_' . $tab_key . '_title',
648
-					'type'        => 'title',
649
-					'name'        => $tab['title'],
650
-					'default'     => $tab['title'],
651
-					'description' => $tab['desc'],
652
-				)
653
-			);
654
-			do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb );
655
-
656
-			do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb );
657
-
658
-			do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb );
659
-
660
-			$cmb->add_field(
661
-				array(
662
-					'id'   => 'settings_' . $tab_key . '_closing',
663
-					'type' => 'tab_closing',
664
-				)
665
-			);
666
-		}
667
-	}
668
-
669
-
670
-	/**
671
-	 * Returns the tabs and their descriptions.
672
-	 *
673
-	 * @return array
674
-	 */
675
-	public function get_settings_tabs() {
676
-		$tabs = array(
677
-			'general' => array(
678
-				'title' => __( 'General', 'lsx-health-plan' ),
679
-				'desc'  => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ),
680
-			),
681
-		);
682
-
683
-		foreach ( $this->post_types as $post_type ) {
684
-			switch ( $post_type ) {
685
-				default:
686
-					//if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) {
687
-						$temp_post_type = get_post_type_object( $post_type );
688
-						if ( ! is_wp_error( $temp_post_type ) ) {
689
-							$page_url    = get_post_type_archive_link( $temp_post_type->name );
690
-							$description = sprintf(
691
-								/* translators: %s: The subscription info */
692
-								__( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ),
693
-								$page_url,
694
-								$temp_post_type->label
695
-							);
696
-
697
-							$tabs[ $post_type ] = array(
698
-								'title' => $temp_post_type->label,
699
-								'desc'  => $description,
700
-							);
701
-						}
702
-					//}
703
-					break;
704
-			}
705
-		}
706
-		return $tabs;
707
-	}
15
+     /**
16
+      * Holds class instance
17
+      *
18
+      * @since 1.0.0
19
+      *
20
+      * @var      object \lsx_health_plan\classes\admin\Settings()
21
+      */
22
+     protected static $instance = null;
23
+
24
+     /**
25
+      * Option key, and option page slug
26
+      *
27
+      * @var string
28
+      */
29
+     protected $screen_id = 'lsx_health_plan_settings';
30
+
31
+     /**
32
+      * An array of the post types for the Global Downloads field.
33
+      *
34
+      * @var array
35
+      */
36
+     public $download_types = array();
37
+
38
+     /**
39
+      * An array of the post types for the Global Defaults field.
40
+      *
41
+      * @var array
42
+      */
43
+     public $default_types = array();
44
+
45
+     /**
46
+      * An array of the endpoints for the Endpoint Translation field.
47
+      *
48
+      * @var array
49
+      */
50
+     public $endpoints = array();
51
+
52
+     /**
53
+      * Constructor
54
+      */
55
+     public function __construct() {
56
+          $this->load_classes();
57
+          add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) );
58
+          add_action( 'lsx_hp_settings_page', array( $this, 'generate_tabs' ), 1, 1 );
59
+
60
+          add_action( 'lsx_hp_settings_page_general_top', array( $this, 'general_settings' ), 1, 1 );
61
+          add_action( 'lsx_hp_settings_page', array( $this, 'global_defaults' ), 3, 1 );
62
+          add_action( 'lsx_hp_settings_page', array( $this, 'global_downloads' ), 5, 1 );
63
+          add_action( 'lsx_hp_settings_page', array( $this, 'stat_disable' ), 6, 1 );
64
+          add_action( 'lsx_hp_settings_page', array( $this, 'endpoint_translations' ), 7, 1 );
65
+          add_action( 'lsx_hp_settings_page', array( $this, 'exercise_translations' ), 7, 1 );
66
+          add_action( 'lsx_hp_settings_page', array( $this, 'post_type_toggles' ), 9, 1 );
67
+     }
68
+
69
+     /**
70
+      * Return an instance of this class.
71
+      *
72
+      * @since 1.0.0
73
+      *
74
+      * @return    object \lsx_health_plan\classes\admin\Settings()    A single instance of this class.
75
+      */
76
+     public static function get_instance() {
77
+          // If the single instance hasn't been set, set it now.
78
+          if ( null === self::$instance ) {
79
+               self::$instance = new self();
80
+          }
81
+          return self::$instance;
82
+     }
83
+
84
+     /**
85
+      * Loads the variable classes and the static classes.
86
+      */
87
+     private function load_classes() {
88
+
89
+          $this->post_types = array(
90
+               'plan',
91
+               'workout',
92
+               'exercise',
93
+               //'meal',
94
+               'recipe',
95
+               //'tip',
96
+          );
97
+
98
+          foreach ( $this->post_types as $post_type ) {
99
+               $this->$post_type = require_once LSX_HEALTH_PLAN_PATH . 'classes/admin/settings/class-' . $post_type . '.php';
100
+          }
101
+     }
102
+
103
+     /**
104
+      * Sets the variables needed for the fields.
105
+      *
106
+      * @return void
107
+      */
108
+     public function set_vars() {
109
+
110
+          $this->default_types  = array(
111
+               'page' => array(
112
+                    'title'       => __( 'Warm Up', 'lsx-health-plan' ),
113
+                    'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ),
114
+                    'limit'       => 1,
115
+                    'id'          => 'plan_warmup',
116
+               ),
117
+          );
118
+          $this->download_types = array(
119
+               'page' => array(
120
+                    'title'       => __( 'Warm Up', 'lsx-health-plan' ),
121
+                    'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ),
122
+                    'limit'       => 1,
123
+               ),
124
+          );
125
+          $this->endpoints      = array(
126
+               'endpoint_warm_up' => array(
127
+                    'title'       => __( 'Warm Up Endpoint', 'lsx-health-plan' ),
128
+                    'default'     => 'warm-up',
129
+               ),
130
+          );
131
+
132
+          if ( post_type_exists( 'meal' ) ) {
133
+               $this->download_types['meal']     = array(
134
+                    'title'       => __( 'Meal Plan', 'lsx-health-plan' ),
135
+                    'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ),
136
+               );
137
+               $this->default_types['meal']      = array(
138
+                    'title'       => __( 'Meal Plan', 'lsx-health-plan' ),
139
+                    'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ),
140
+                    'id'          => 'connected_meals',
141
+               );
142
+               $this->endpoints['endpoint_meal'] = array(
143
+                    'title'       => __( 'Meal Endpoint', 'lsx-health-plan' ),
144
+                    'default'     => 'meal',
145
+                    'description' => __( 'Define the tab slug which shows on the single plan page.', 'lsx-health-plan' ),
146
+               );
147
+               $this->endpoints['endpoint_meal_archive'] = array(
148
+                    'title'   => __( 'Meals Archive Endpoint', 'lsx-health-plan' ),
149
+                    'default' => 'meals',
150
+               );
151
+               $this->endpoints['meal_single_slug'] = array(
152
+                    'title'   => __( 'Single Meal Slug', 'lsx-health-plan' ),
153
+                    'default' => 'meal',
154
+               );
155
+          }
156
+          if ( post_type_exists( 'recipe' ) ) {
157
+               $this->download_types['recipe'] = array(
158
+                    'title'       => __( 'Recipe', 'lsx-health-plan' ),
159
+                    'description' => __( 'Set a default recipe.', 'lsx-health-plan' ),
160
+               );
161
+               $this->default_types['recipe'] = array(
162
+                    'title'       => __( 'Recipe', 'lsx-health-plan' ),
163
+                    'description' => __( 'Set a default recipe.', 'lsx-health-plan' ),
164
+                    'id'          => 'connected_recipes',
165
+               );
166
+               $this->endpoints['endpoint_recipe'] = array(
167
+                    'title'   => __( 'Recipes Endpoint', 'lsx-health-plan' ),
168
+                    'default' => 'recipe',
169
+               );
170
+          }
171
+          if ( post_type_exists( 'workout' ) ) {
172
+               $this->download_types['workout'] = array(
173
+                    'title'       => __( 'Workout', 'lsx-health-plan' ),
174
+                    'description' => __( 'Set a default workout routine PDF.', 'lsx-health-plan' ),
175
+               );
176
+               $this->default_types['workout'] = array(
177
+                    'title'       => __( 'Workout', 'lsx-health-plan' ),
178
+                    'description' => __( 'Set a default workout routine.', 'lsx-health-plan' ),
179
+                    'id'          => 'connected_workouts',
180
+               );
181
+               $this->endpoints['endpoint_workout_archive'] = array(
182
+                    'title'   => __( 'Workouts Archive Endpoint', 'lsx-health-plan' ),
183
+                    'default' => '',
184
+               );
185
+               $this->endpoints['endpoint_workout'] = array(
186
+                    'title'   => __( 'Single Workout Endpoint', 'lsx-health-plan' ),
187
+                    'default' => 'workout',
188
+               );
189
+          }
190
+
191
+          $this->endpoints['login_slug'] = array(
192
+               'title'   => __( 'Login Slug', 'lsx-health-plan' ),
193
+               'default' => 'login',
194
+          );
195
+          $this->endpoints['my_plan_slug'] = array(
196
+               'title'   => __( 'My Plan Slug', 'lsx-health-plan' ),
197
+               'default' => 'my-plan',
198
+          );
199
+          $this->endpoints['plan_single_slug'] = array(
200
+               'title'   => __( 'Single Plan Slug', 'lsx-health-plan' ),
201
+               'default' => 'plan',
202
+          );
203
+          $this->endpoints['endpoint_plan_archive'] = array(
204
+               'title'   => __( 'Plans Archive Endpoint', 'lsx-health-plan' ),
205
+               'default' => 'plans',
206
+          );
207
+
208
+          if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
209
+               $this->endpoints['exercise'] = array(
210
+                    'exercise_single' => array(
211
+                         'title'   => __( 'Single Exercise Slug', 'lsx-health-plan' ),
212
+                         'default' => 'exercise',
213
+                    ),
214
+                    'exercise_archive' => array(
215
+                         'title'   => __( 'Archive Exercise Slug', 'lsx-health-plan' ),
216
+                         'default' => 'exercises',
217
+                    ),
218
+                    'exercise_type' => array(
219
+                         'title'   => __( 'Exercise Type Slug', 'lsx-health-plan' ),
220
+                         'default' => 'exercise-type',
221
+                    ),
222
+                    'exercise_equipment' => array(
223
+                         'title'   => __( 'Equipment Slug', 'lsx-health-plan' ),
224
+                         'default' => 'equipment',
225
+                    ),
226
+                    'exercise_musclegroup' => array(
227
+                         'title'   => __( 'Muscle Group Slug', 'lsx-health-plan' ),
228
+                         'default' => 'muscle-group',
229
+                    ),
230
+               );
231
+          }
232
+     }
233
+
234
+     /**
235
+      * Hook in and register a submenu options page for the Page post-type menu.
236
+      */
237
+     public function register_settings_page() {
238
+          $this->set_vars();
239
+          $cmb = new_cmb2_box(
240
+               array(
241
+                    'id'           => $this->screen_id,
242
+                    'title'        => esc_html__( 'Settings', 'lsx-health-plan' ),
243
+                    'object_types' => array( 'options-page' ),
244
+                    'option_key'   => 'lsx_health_plan_options', // The option key and admin menu page slug.
245
+                    'parent_slug'  => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu.
246
+                    'capability'   => 'manage_options', // Cap required to view options-page.
247
+               )
248
+          );
249
+          do_action( 'lsx_hp_settings_page', $cmb );
250
+     }
251
+
252
+     /**
253
+      * Registers the general settings.
254
+      *
255
+      * @param object $cmb new_cmb2_box().
256
+      * @return void
257
+      */
258
+     public function general_settings( $cmb ) {
259
+          $cmb->add_field(
260
+               array(
261
+                    'name'       => __( 'Membership Product', 'lsx-health-plan' ),
262
+                    'id'         => 'membership_product',
263
+                    'type'       => 'post_search_ajax',
264
+                    'limit'      => 1,
265
+                    'sortable'   => false,
266
+                    'query_args' => array(
267
+                         'post_type'      => array( 'product' ),
268
+                         'post_status'    => array( 'publish' ),
269
+                         'posts_per_page' => -1,
270
+                    ),
271
+               )
272
+          );
273
+
274
+          $cmb->add_field(
275
+               array(
276
+                    'name'    => __( 'Your Warm-up Intro', 'lsx-health-plan' ),
277
+                    'id'      => 'warmup_intro',
278
+                    'type'    => 'textarea_small',
279
+                    'value'   => '',
280
+                    'default' => __( "Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan' ),
281
+               )
282
+          );
283
+          if ( post_type_exists( 'workout' ) ) {
284
+               $cmb->add_field(
285
+                    array(
286
+                         'name'    => __( 'Your Workout Intro', 'lsx-health-plan' ),
287
+                         'id'      => 'workout_intro',
288
+                         'type'    => 'textarea_small',
289
+                         'value'   => '',
290
+                         'default' => __( "Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan' ),
291
+                    )
292
+               );
293
+          }
294
+          if ( post_type_exists( 'meal' ) ) {
295
+               $cmb->add_field(
296
+                    array(
297
+                         'name'    => __( 'Your Meal Plan Intro', 'lsx-health-plan' ),
298
+                         'id'      => 'meal_plan_intro',
299
+                         'type'    => 'textarea_small',
300
+                         'value'   => '',
301
+                         'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ),
302
+                    )
303
+               );
304
+          }
305
+          if ( post_type_exists( 'recipe' ) ) {
306
+               $cmb->add_field(
307
+                    array(
308
+                         'name'    => __( 'Recipes Intro', 'lsx-health-plan' ),
309
+                         'id'      => 'recipes_intro',
310
+                         'type'    => 'textarea_small',
311
+                         'value'   => '',
312
+                         'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan' ),
313
+                    )
314
+               );
315
+          }
316
+     }
317
+
318
+     /**
319
+      * Registers the global default settings.
320
+      *
321
+      * @param object $cmb new_cmb2_box().
322
+      * @return void
323
+      */
324
+     public function global_defaults( $cmb ) {
325
+          $cmb->add_field(
326
+               array(
327
+                    'id'      => 'global_defaults_title',
328
+                    'type'    => 'title',
329
+                    'name'    => __( 'Global Defaults', 'lsx-health-plan' ),
330
+                    'default' => __( 'Global Defaults', 'lsx-health-plan' ),
331
+                    'description' => __( 'If you have not connected a specific post to your day plan, set a default option below.', 'lsx-health-plan' ),
332
+               )
333
+          );
334
+
335
+          foreach ( $this->default_types as $type => $default_type ) {
336
+               $limit    = 5;
337
+               $sortable = false;
338
+               if ( isset( $default_type['limit'] ) ) {
339
+                    $limit    = $default_type['limit'];
340
+                    $sortable = true;
341
+               }
342
+
343
+               if ( 'page' === $type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
344
+                    $type = array( 'page', 'workout' );
345
+               }
346
+
347
+               $cmb->add_field(
348
+                    array(
349
+                         'name'       => $default_type['title'],
350
+                         'desc'       => $default_type['description'],
351
+                         'id'         => $default_type['id'],
352
+                         'type'       => 'post_search_ajax',
353
+                         'limit'      => $limit,
354
+                         'sortable'   => $sortable,
355
+                         'query_args' => array(
356
+                              'post_type'      => $type,
357
+                              'post_status'    => array( 'publish' ),
358
+                              'posts_per_page' => -1,
359
+                         ),
360
+                    )
361
+               );
362
+          }
363
+
364
+          $cmb->add_field(
365
+               array(
366
+                    'id'   => 'settings_global_defaults_closing',
367
+                    'type' => 'tab_closing',
368
+               )
369
+          );
370
+     }
371
+
372
+     /**
373
+      * Registers the global dowloads settings
374
+      *
375
+      * @param object $cmb new_cmb2_box().
376
+      * @return void
377
+      */
378
+     public function global_downloads( $cmb ) {
379
+          $cmb->add_field(
380
+               array(
381
+                    'id'      => 'global_downloads_title',
382
+                    'type'    => 'title',
383
+                    'name'    => __( 'Global Downloads', 'lsx-health-plan' ),
384
+                    'default' => __( 'Global Downloads', 'lsx-health-plan' ),
385
+               )
386
+          );
387
+
388
+          foreach ( $this->download_types as $type => $download_type ) {
389
+               $limit    = 5;
390
+               $sortable = false;
391
+               if ( isset( $download_type['limit'] ) ) {
392
+                    $limit    = $download_type['limit'];
393
+                    $sortable = true;
394
+               }
395
+
396
+               $cmb->add_field(
397
+                    array(
398
+                         'name'       => $download_type['title'],
399
+                         'id'         => 'download_' . $type,
400
+                         'type'       => 'post_search_ajax',
401
+                         'limit'      => $limit,
402
+                         'sortable'   => $sortable,
403
+                         'query_args' => array(
404
+                              'post_type'      => array( 'dlm_download' ),
405
+                              'post_status'    => array( 'publish' ),
406
+                              'posts_per_page' => -1,
407
+                         ),
408
+                    )
409
+               );
410
+          }
411
+          $cmb->add_field(
412
+               array(
413
+                    'id'   => 'settings_global_downloads_closing',
414
+                    'type' => 'tab_closing',
415
+               )
416
+          );
417
+     }
418
+
419
+     /**
420
+      * Registers the endpoint translation settings.
421
+      *
422
+      * @param object $cmb new_cmb2_box().
423
+      * @return void
424
+      */
425
+     public function endpoint_translations( $cmb ) {
426
+          $cmb->add_field(
427
+               array(
428
+                    'id'          => 'endpoints_title',
429
+                    'type'        => 'title',
430
+                    'name'        => __( 'Set Endpoint Translations', 'lsx-health-plan' ),
431
+                    'default'     => __( 'Set Endpoint Translations', 'lsx-health-plan' ),
432
+                    'description' => __( 'Endpoint is a web address (URL) at which the user can gain access to it. You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ),
433
+               )
434
+          );
435
+          foreach ( $this->endpoints as $slug => $endpoint_vars ) {
436
+               if ( 'exercise' === $slug ) {
437
+                    continue;
438
+               }
439
+
440
+               $cmb->add_field(
441
+                    array(
442
+                         'name'    => $endpoint_vars['title'],
443
+                         'id'      => $slug,
444
+                         'type'    => 'input',
445
+                         'value'   => '',
446
+                         'default' => $endpoint_vars['default'],
447
+                    )
448
+               );
449
+          }
450
+          $cmb->add_field(
451
+               array(
452
+                    'id'   => 'settings_endpoints_closing',
453
+                    'type' => 'tab_closing',
454
+               )
455
+          );
456
+     }
457
+
458
+     /**
459
+      * Registers the endpoint translation settings.
460
+      *
461
+      * @param object $cmb new_cmb2_box().
462
+      * @return void
463
+      */
464
+     public function exercise_translations( $cmb ) {
465
+          if ( isset( $this->endpoints['exercise'] ) && '' !== $this->endpoints['exercise'] && ! empty( $this->endpoints['exercise'] ) ) {
466
+               $cmb->add_field(
467
+                    array(
468
+                         'id'          => 'exercise_endpoints_title',
469
+                         'type'        => 'title',
470
+                         'name'        => __( 'Set Exercise Translations', 'lsx-health-plan' ),
471
+                         'default'     => __( 'Set Exercise Translations', 'lsx-health-plan' ),
472
+                         'description' => __( 'You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ),
473
+                    )
474
+               );
475
+
476
+               foreach ( $this->endpoints['exercise'] as $slug => $endpoint_vars ) {
477
+                    $cmb->add_field(
478
+                         array(
479
+                              'name'    => $endpoint_vars['title'],
480
+                              'id'      => 'endpoint_' . $slug,
481
+                              'type'    => 'input',
482
+                              'value'   => '',
483
+                              'default' => $endpoint_vars['default'],
484
+                         )
485
+                    );
486
+               }
487
+               $cmb->add_field(
488
+                    array(
489
+                         'id'   => 'settings_exercise_closing',
490
+                         'type' => 'tab_closing',
491
+                    )
492
+               );
493
+          }
494
+     }
495
+
496
+     /**
497
+      * Registers the post type toggle settings
498
+      *
499
+      * @param object $cmb new_cmb2_box().
500
+      * @return void
501
+      */
502
+     public function post_type_toggles( $cmb ) {
503
+          $post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) );
504
+
505
+          $cmb->add_field(
506
+               array(
507
+                    'id'          => 'post_type_toggles_title',
508
+                    'type'        => 'title',
509
+                    'name'        => __( 'Disable Post Types', 'lsx-health-plan' ),
510
+                    'default'     => __( 'Disable Post Types', 'lsx-health-plan' ),
511
+                    'description' => __( 'Disable post types if you are wanting a minimal site.', 'lsx-health-plan' ),
512
+               )
513
+          );
514
+
515
+          foreach ( $post_types as $post_type ) {
516
+               if ( 'plan' === $post_type || 'exercise' === $post_type || ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) ) {
517
+                    continue;
518
+               }
519
+
520
+               $cmb->add_field(
521
+                    array(
522
+                         'name'    => ucwords( $post_type ),
523
+                         'id'      => $post_type . '_disabled',
524
+                         'type'    => 'checkbox',
525
+                         'value'   => 1,
526
+                         'default' => 0,
527
+                    )
528
+               );
529
+          }
530
+
531
+          $cmb->add_field(
532
+               array(
533
+                    'id'   => 'settings_post_type_toggles_closing',
534
+                    'type' => 'tab_closing',
535
+               )
536
+          );
537
+
538
+          $cmb->add_field(
539
+               array(
540
+                    'id'          => 'post_type_toggles_enable_title',
541
+                    'type'        => 'title',
542
+                    'name'        => __( 'Enable Post Types', 'lsx-health-plan' ),
543
+                    'default'     => __( 'Enable Post Types', 'lsx-health-plan' ),
544
+                    'description' => __( 'Enable new functionality like the "exercise" post type.', 'lsx-health-plan' ),
545
+               )
546
+          );
547
+          $cmb->add_field(
548
+               array(
549
+                    'name'        => __( 'Exercises', 'lsx-health-plan' ),
550
+                    'id'          => 'exercise_enabled',
551
+                    'type'        => 'checkbox',
552
+                    'value'       => 1,
553
+                    'default'     => 0,
554
+                    'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ),
555
+               )
556
+          );
557
+          $cmb->add_field(
558
+               array(
559
+                    'id'   => 'settings_post_type_toggles_enable_closing',
560
+                    'type' => 'tab_closing',
561
+               )
562
+          );
563
+     }
564
+     /**
565
+      * Registers the Profile Stat Toggle settings
566
+      *
567
+      * @param object $cmb new_cmb2_box().
568
+      * @return void
569
+      */
570
+
571
+     public function stat_disable( $cmb ) {
572
+          $cmb->add_field(
573
+               array(
574
+                    'id'      => 'stat_disable_title',
575
+                    'type'    => 'title',
576
+                    'name'    => __( 'Disable Profile Stats', 'lsx-health-plan' ),
577
+                    'default' => __( 'Disable Profile Stats', 'lsx-health-plan' ),
578
+               )
579
+          );
580
+          $cmb->add_field(
581
+               array(
582
+                    'name'    => __( 'Disable All Stats', 'lsx-health-plan' ),
583
+                    'desc'    => 'Disable All Stats',
584
+                    'id'      => 'disable_all_stats',
585
+                    'type'    => 'checkbox',
586
+                    'value'   => 1,
587
+                    'default' => 0,
588
+               )
589
+          );
590
+          $cmb->add_field(
591
+               array(
592
+                    'name'    => __( 'Disable Weight', 'lsx-health-plan' ),
593
+                    'id'      => 'disable_weight_checkbox',
594
+                    'type'    => 'checkbox',
595
+                    'value'   => 1,
596
+                    'default' => 0,
597
+               )
598
+          );
599
+          $cmb->add_field(
600
+               array(
601
+                    'name'    => __( 'Disable Height', 'lsx-health-plan' ),
602
+                    'id'      => 'disable_height_checkbox',
603
+                    'type'    => 'checkbox',
604
+                    'value'   => 1,
605
+                    'default' => 0,
606
+               )
607
+          );
608
+          $cmb->add_field(
609
+               array(
610
+                    'name'    => __( 'Disable Waist', 'lsx-health-plan' ),
611
+                    'id'      => 'disable_waist_checkbox',
612
+                    'type'    => 'checkbox',
613
+                    'value'   => 1,
614
+                    'default' => 0,
615
+               )
616
+          );
617
+          $cmb->add_field(
618
+               array(
619
+                    'name'    => __( 'Disable BMI', 'lsx-health-plan' ),
620
+                    'id'      => 'disable_bmi_checkbox',
621
+                    'type'    => 'checkbox',
622
+                    'value'   => 1,
623
+                    'default' => 0,
624
+               )
625
+          );
626
+          $cmb->add_field(
627
+               array(
628
+                    'id'   => 'settings_stat_disable_closing',
629
+                    'type' => 'tab_closing',
630
+               )
631
+          );
632
+     }
633
+
634
+     /**
635
+      * Enable Business Directory Search settings only if LSX Search plugin is enabled.
636
+      *
637
+      * @param object $cmb The CMB2() class.
638
+      * @param string $section either engine,archive or single.
639
+      * @return void
640
+      */
641
+     public function generate_tabs( $cmb ) {
642
+          $tabs = $this->get_settings_tabs();
643
+
644
+          foreach ( $tabs as $tab_key => $tab ) {
645
+               $cmb->add_field(
646
+                    array(
647
+                         'id'          => 'settings_' . $tab_key . '_title',
648
+                         'type'        => 'title',
649
+                         'name'        => $tab['title'],
650
+                         'default'     => $tab['title'],
651
+                         'description' => $tab['desc'],
652
+                    )
653
+               );
654
+               do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb );
655
+
656
+               do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb );
657
+
658
+               do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb );
659
+
660
+               $cmb->add_field(
661
+                    array(
662
+                         'id'   => 'settings_' . $tab_key . '_closing',
663
+                         'type' => 'tab_closing',
664
+                    )
665
+               );
666
+          }
667
+     }
668
+
669
+
670
+     /**
671
+      * Returns the tabs and their descriptions.
672
+      *
673
+      * @return array
674
+      */
675
+     public function get_settings_tabs() {
676
+          $tabs = array(
677
+               'general' => array(
678
+                    'title' => __( 'General', 'lsx-health-plan' ),
679
+                    'desc'  => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ),
680
+               ),
681
+          );
682
+
683
+          foreach ( $this->post_types as $post_type ) {
684
+               switch ( $post_type ) {
685
+                    default:
686
+                         //if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) {
687
+                              $temp_post_type = get_post_type_object( $post_type );
688
+                              if ( ! is_wp_error( $temp_post_type ) ) {
689
+                                   $page_url    = get_post_type_archive_link( $temp_post_type->name );
690
+                                   $description = sprintf(
691
+                                        /* translators: %s: The subscription info */
692
+                                        __( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ),
693
+                                        $page_url,
694
+                                        $temp_post_type->label
695
+                                   );
696
+
697
+                                   $tabs[ $post_type ] = array(
698
+                                        'title' => $temp_post_type->label,
699
+                                        'desc'  => $description,
700
+                                   );
701
+                              }
702
+                         //}
703
+                         break;
704
+               }
705
+          }
706
+          return $tabs;
707
+     }
708 708
 }
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function __construct() {
56 56
 		$this->load_classes();
57
-		add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) );
58
-		add_action( 'lsx_hp_settings_page', array( $this, 'generate_tabs' ), 1, 1 );
59
-
60
-		add_action( 'lsx_hp_settings_page_general_top', array( $this, 'general_settings' ), 1, 1 );
61
-		add_action( 'lsx_hp_settings_page', array( $this, 'global_defaults' ), 3, 1 );
62
-		add_action( 'lsx_hp_settings_page', array( $this, 'global_downloads' ), 5, 1 );
63
-		add_action( 'lsx_hp_settings_page', array( $this, 'stat_disable' ), 6, 1 );
64
-		add_action( 'lsx_hp_settings_page', array( $this, 'endpoint_translations' ), 7, 1 );
65
-		add_action( 'lsx_hp_settings_page', array( $this, 'exercise_translations' ), 7, 1 );
66
-		add_action( 'lsx_hp_settings_page', array( $this, 'post_type_toggles' ), 9, 1 );
57
+		add_action('cmb2_admin_init', array($this, 'register_settings_page'));
58
+		add_action('lsx_hp_settings_page', array($this, 'generate_tabs'), 1, 1);
59
+
60
+		add_action('lsx_hp_settings_page_general_top', array($this, 'general_settings'), 1, 1);
61
+		add_action('lsx_hp_settings_page', array($this, 'global_defaults'), 3, 1);
62
+		add_action('lsx_hp_settings_page', array($this, 'global_downloads'), 5, 1);
63
+		add_action('lsx_hp_settings_page', array($this, 'stat_disable'), 6, 1);
64
+		add_action('lsx_hp_settings_page', array($this, 'endpoint_translations'), 7, 1);
65
+		add_action('lsx_hp_settings_page', array($this, 'exercise_translations'), 7, 1);
66
+		add_action('lsx_hp_settings_page', array($this, 'post_type_toggles'), 9, 1);
67 67
 	}
68 68
 
69 69
 	/**
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public static function get_instance() {
77 77
 		// If the single instance hasn't been set, set it now.
78
-		if ( null === self::$instance ) {
78
+		if (null === self::$instance) {
79 79
 			self::$instance = new self();
80 80
 		}
81 81
 		return self::$instance;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 			//'tip',
96 96
 		);
97 97
 
98
-		foreach ( $this->post_types as $post_type ) {
98
+		foreach ($this->post_types as $post_type) {
99 99
 			$this->$post_type = require_once LSX_HEALTH_PLAN_PATH . 'classes/admin/settings/class-' . $post_type . '.php';
100 100
 		}
101 101
 	}
@@ -107,124 +107,124 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function set_vars() {
109 109
 
110
-		$this->default_types  = array(
110
+		$this->default_types = array(
111 111
 			'page' => array(
112
-				'title'       => __( 'Warm Up', 'lsx-health-plan' ),
113
-				'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ),
112
+				'title'       => __('Warm Up', 'lsx-health-plan'),
113
+				'description' => __('Set a default warm up routine.', 'lsx-health-plan'),
114 114
 				'limit'       => 1,
115 115
 				'id'          => 'plan_warmup',
116 116
 			),
117 117
 		);
118 118
 		$this->download_types = array(
119 119
 			'page' => array(
120
-				'title'       => __( 'Warm Up', 'lsx-health-plan' ),
121
-				'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ),
120
+				'title'       => __('Warm Up', 'lsx-health-plan'),
121
+				'description' => __('Set a default warm up routine.', 'lsx-health-plan'),
122 122
 				'limit'       => 1,
123 123
 			),
124 124
 		);
125
-		$this->endpoints      = array(
125
+		$this->endpoints = array(
126 126
 			'endpoint_warm_up' => array(
127
-				'title'       => __( 'Warm Up Endpoint', 'lsx-health-plan' ),
127
+				'title'       => __('Warm Up Endpoint', 'lsx-health-plan'),
128 128
 				'default'     => 'warm-up',
129 129
 			),
130 130
 		);
131 131
 
132
-		if ( post_type_exists( 'meal' ) ) {
133
-			$this->download_types['meal']     = array(
134
-				'title'       => __( 'Meal Plan', 'lsx-health-plan' ),
135
-				'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ),
132
+		if (post_type_exists('meal')) {
133
+			$this->download_types['meal'] = array(
134
+				'title'       => __('Meal Plan', 'lsx-health-plan'),
135
+				'description' => __('Set a default meal plan.', 'lsx-health-plan'),
136 136
 			);
137
-			$this->default_types['meal']      = array(
138
-				'title'       => __( 'Meal Plan', 'lsx-health-plan' ),
139
-				'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ),
137
+			$this->default_types['meal'] = array(
138
+				'title'       => __('Meal Plan', 'lsx-health-plan'),
139
+				'description' => __('Set a default meal plan.', 'lsx-health-plan'),
140 140
 				'id'          => 'connected_meals',
141 141
 			);
142 142
 			$this->endpoints['endpoint_meal'] = array(
143
-				'title'       => __( 'Meal Endpoint', 'lsx-health-plan' ),
143
+				'title'       => __('Meal Endpoint', 'lsx-health-plan'),
144 144
 				'default'     => 'meal',
145
-				'description' => __( 'Define the tab slug which shows on the single plan page.', 'lsx-health-plan' ),
145
+				'description' => __('Define the tab slug which shows on the single plan page.', 'lsx-health-plan'),
146 146
 			);
147 147
 			$this->endpoints['endpoint_meal_archive'] = array(
148
-				'title'   => __( 'Meals Archive Endpoint', 'lsx-health-plan' ),
148
+				'title'   => __('Meals Archive Endpoint', 'lsx-health-plan'),
149 149
 				'default' => 'meals',
150 150
 			);
151 151
 			$this->endpoints['meal_single_slug'] = array(
152
-				'title'   => __( 'Single Meal Slug', 'lsx-health-plan' ),
152
+				'title'   => __('Single Meal Slug', 'lsx-health-plan'),
153 153
 				'default' => 'meal',
154 154
 			);
155 155
 		}
156
-		if ( post_type_exists( 'recipe' ) ) {
156
+		if (post_type_exists('recipe')) {
157 157
 			$this->download_types['recipe'] = array(
158
-				'title'       => __( 'Recipe', 'lsx-health-plan' ),
159
-				'description' => __( 'Set a default recipe.', 'lsx-health-plan' ),
158
+				'title'       => __('Recipe', 'lsx-health-plan'),
159
+				'description' => __('Set a default recipe.', 'lsx-health-plan'),
160 160
 			);
161 161
 			$this->default_types['recipe'] = array(
162
-				'title'       => __( 'Recipe', 'lsx-health-plan' ),
163
-				'description' => __( 'Set a default recipe.', 'lsx-health-plan' ),
162
+				'title'       => __('Recipe', 'lsx-health-plan'),
163
+				'description' => __('Set a default recipe.', 'lsx-health-plan'),
164 164
 				'id'          => 'connected_recipes',
165 165
 			);
166 166
 			$this->endpoints['endpoint_recipe'] = array(
167
-				'title'   => __( 'Recipes Endpoint', 'lsx-health-plan' ),
167
+				'title'   => __('Recipes Endpoint', 'lsx-health-plan'),
168 168
 				'default' => 'recipe',
169 169
 			);
170 170
 		}
171
-		if ( post_type_exists( 'workout' ) ) {
171
+		if (post_type_exists('workout')) {
172 172
 			$this->download_types['workout'] = array(
173
-				'title'       => __( 'Workout', 'lsx-health-plan' ),
174
-				'description' => __( 'Set a default workout routine PDF.', 'lsx-health-plan' ),
173
+				'title'       => __('Workout', 'lsx-health-plan'),
174
+				'description' => __('Set a default workout routine PDF.', 'lsx-health-plan'),
175 175
 			);
176 176
 			$this->default_types['workout'] = array(
177
-				'title'       => __( 'Workout', 'lsx-health-plan' ),
178
-				'description' => __( 'Set a default workout routine.', 'lsx-health-plan' ),
177
+				'title'       => __('Workout', 'lsx-health-plan'),
178
+				'description' => __('Set a default workout routine.', 'lsx-health-plan'),
179 179
 				'id'          => 'connected_workouts',
180 180
 			);
181 181
 			$this->endpoints['endpoint_workout_archive'] = array(
182
-				'title'   => __( 'Workouts Archive Endpoint', 'lsx-health-plan' ),
182
+				'title'   => __('Workouts Archive Endpoint', 'lsx-health-plan'),
183 183
 				'default' => '',
184 184
 			);
185 185
 			$this->endpoints['endpoint_workout'] = array(
186
-				'title'   => __( 'Single Workout Endpoint', 'lsx-health-plan' ),
186
+				'title'   => __('Single Workout Endpoint', 'lsx-health-plan'),
187 187
 				'default' => 'workout',
188 188
 			);
189 189
 		}
190 190
 
191 191
 		$this->endpoints['login_slug'] = array(
192
-			'title'   => __( 'Login Slug', 'lsx-health-plan' ),
192
+			'title'   => __('Login Slug', 'lsx-health-plan'),
193 193
 			'default' => 'login',
194 194
 		);
195 195
 		$this->endpoints['my_plan_slug'] = array(
196
-			'title'   => __( 'My Plan Slug', 'lsx-health-plan' ),
196
+			'title'   => __('My Plan Slug', 'lsx-health-plan'),
197 197
 			'default' => 'my-plan',
198 198
 		);
199 199
 		$this->endpoints['plan_single_slug'] = array(
200
-			'title'   => __( 'Single Plan Slug', 'lsx-health-plan' ),
200
+			'title'   => __('Single Plan Slug', 'lsx-health-plan'),
201 201
 			'default' => 'plan',
202 202
 		);
203 203
 		$this->endpoints['endpoint_plan_archive'] = array(
204
-			'title'   => __( 'Plans Archive Endpoint', 'lsx-health-plan' ),
204
+			'title'   => __('Plans Archive Endpoint', 'lsx-health-plan'),
205 205
 			'default' => 'plans',
206 206
 		);
207 207
 
208
-		if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
208
+		if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) {
209 209
 			$this->endpoints['exercise'] = array(
210 210
 				'exercise_single' => array(
211
-					'title'   => __( 'Single Exercise Slug', 'lsx-health-plan' ),
211
+					'title'   => __('Single Exercise Slug', 'lsx-health-plan'),
212 212
 					'default' => 'exercise',
213 213
 				),
214 214
 				'exercise_archive' => array(
215
-					'title'   => __( 'Archive Exercise Slug', 'lsx-health-plan' ),
215
+					'title'   => __('Archive Exercise Slug', 'lsx-health-plan'),
216 216
 					'default' => 'exercises',
217 217
 				),
218 218
 				'exercise_type' => array(
219
-					'title'   => __( 'Exercise Type Slug', 'lsx-health-plan' ),
219
+					'title'   => __('Exercise Type Slug', 'lsx-health-plan'),
220 220
 					'default' => 'exercise-type',
221 221
 				),
222 222
 				'exercise_equipment' => array(
223
-					'title'   => __( 'Equipment Slug', 'lsx-health-plan' ),
223
+					'title'   => __('Equipment Slug', 'lsx-health-plan'),
224 224
 					'default' => 'equipment',
225 225
 				),
226 226
 				'exercise_musclegroup' => array(
227
-					'title'   => __( 'Muscle Group Slug', 'lsx-health-plan' ),
227
+					'title'   => __('Muscle Group Slug', 'lsx-health-plan'),
228 228
 					'default' => 'muscle-group',
229 229
 				),
230 230
 			);
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
 		$cmb = new_cmb2_box(
240 240
 			array(
241 241
 				'id'           => $this->screen_id,
242
-				'title'        => esc_html__( 'Settings', 'lsx-health-plan' ),
243
-				'object_types' => array( 'options-page' ),
242
+				'title'        => esc_html__('Settings', 'lsx-health-plan'),
243
+				'object_types' => array('options-page'),
244 244
 				'option_key'   => 'lsx_health_plan_options', // The option key and admin menu page slug.
245 245
 				'parent_slug'  => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu.
246 246
 				'capability'   => 'manage_options', // Cap required to view options-page.
247 247
 			)
248 248
 		);
249
-		do_action( 'lsx_hp_settings_page', $cmb );
249
+		do_action('lsx_hp_settings_page', $cmb);
250 250
 	}
251 251
 
252 252
 	/**
@@ -255,17 +255,17 @@  discard block
 block discarded – undo
255 255
 	 * @param object $cmb new_cmb2_box().
256 256
 	 * @return void
257 257
 	 */
258
-	public function general_settings( $cmb ) {
258
+	public function general_settings($cmb) {
259 259
 		$cmb->add_field(
260 260
 			array(
261
-				'name'       => __( 'Membership Product', 'lsx-health-plan' ),
261
+				'name'       => __('Membership Product', 'lsx-health-plan'),
262 262
 				'id'         => 'membership_product',
263 263
 				'type'       => 'post_search_ajax',
264 264
 				'limit'      => 1,
265 265
 				'sortable'   => false,
266 266
 				'query_args' => array(
267
-					'post_type'      => array( 'product' ),
268
-					'post_status'    => array( 'publish' ),
267
+					'post_type'      => array('product'),
268
+					'post_status'    => array('publish'),
269 269
 					'posts_per_page' => -1,
270 270
 				),
271 271
 			)
@@ -273,43 +273,43 @@  discard block
 block discarded – undo
273 273
 
274 274
 		$cmb->add_field(
275 275
 			array(
276
-				'name'    => __( 'Your Warm-up Intro', 'lsx-health-plan' ),
276
+				'name'    => __('Your Warm-up Intro', 'lsx-health-plan'),
277 277
 				'id'      => 'warmup_intro',
278 278
 				'type'    => 'textarea_small',
279 279
 				'value'   => '',
280
-				'default' => __( "Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan' ),
280
+				'default' => __("Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan'),
281 281
 			)
282 282
 		);
283
-		if ( post_type_exists( 'workout' ) ) {
283
+		if (post_type_exists('workout')) {
284 284
 			$cmb->add_field(
285 285
 				array(
286
-					'name'    => __( 'Your Workout Intro', 'lsx-health-plan' ),
286
+					'name'    => __('Your Workout Intro', 'lsx-health-plan'),
287 287
 					'id'      => 'workout_intro',
288 288
 					'type'    => 'textarea_small',
289 289
 					'value'   => '',
290
-					'default' => __( "Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan' ),
290
+					'default' => __("Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan'),
291 291
 				)
292 292
 			);
293 293
 		}
294
-		if ( post_type_exists( 'meal' ) ) {
294
+		if (post_type_exists('meal')) {
295 295
 			$cmb->add_field(
296 296
 				array(
297
-					'name'    => __( 'Your Meal Plan Intro', 'lsx-health-plan' ),
297
+					'name'    => __('Your Meal Plan Intro', 'lsx-health-plan'),
298 298
 					'id'      => 'meal_plan_intro',
299 299
 					'type'    => 'textarea_small',
300 300
 					'value'   => '',
301
-					'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ),
301
+					'default' => __('Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan'),
302 302
 				)
303 303
 			);
304 304
 		}
305
-		if ( post_type_exists( 'recipe' ) ) {
305
+		if (post_type_exists('recipe')) {
306 306
 			$cmb->add_field(
307 307
 				array(
308
-					'name'    => __( 'Recipes Intro', 'lsx-health-plan' ),
308
+					'name'    => __('Recipes Intro', 'lsx-health-plan'),
309 309
 					'id'      => 'recipes_intro',
310 310
 					'type'    => 'textarea_small',
311 311
 					'value'   => '',
312
-					'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan' ),
312
+					'default' => __("Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan'),
313 313
 				)
314 314
 			);
315 315
 		}
@@ -321,27 +321,27 @@  discard block
 block discarded – undo
321 321
 	 * @param object $cmb new_cmb2_box().
322 322
 	 * @return void
323 323
 	 */
324
-	public function global_defaults( $cmb ) {
324
+	public function global_defaults($cmb) {
325 325
 		$cmb->add_field(
326 326
 			array(
327 327
 				'id'      => 'global_defaults_title',
328 328
 				'type'    => 'title',
329
-				'name'    => __( 'Global Defaults', 'lsx-health-plan' ),
330
-				'default' => __( 'Global Defaults', 'lsx-health-plan' ),
331
-				'description' => __( 'If you have not connected a specific post to your day plan, set a default option below.', 'lsx-health-plan' ),
329
+				'name'    => __('Global Defaults', 'lsx-health-plan'),
330
+				'default' => __('Global Defaults', 'lsx-health-plan'),
331
+				'description' => __('If you have not connected a specific post to your day plan, set a default option below.', 'lsx-health-plan'),
332 332
 			)
333 333
 		);
334 334
 
335
-		foreach ( $this->default_types as $type => $default_type ) {
335
+		foreach ($this->default_types as $type => $default_type) {
336 336
 			$limit    = 5;
337 337
 			$sortable = false;
338
-			if ( isset( $default_type['limit'] ) ) {
338
+			if (isset($default_type['limit'])) {
339 339
 				$limit    = $default_type['limit'];
340 340
 				$sortable = true;
341 341
 			}
342 342
 
343
-			if ( 'page' === $type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
344
-				$type = array( 'page', 'workout' );
343
+			if ('page' === $type && false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) {
344
+				$type = array('page', 'workout');
345 345
 			}
346 346
 
347 347
 			$cmb->add_field(
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 					'sortable'   => $sortable,
355 355
 					'query_args' => array(
356 356
 						'post_type'      => $type,
357
-						'post_status'    => array( 'publish' ),
357
+						'post_status'    => array('publish'),
358 358
 						'posts_per_page' => -1,
359 359
 					),
360 360
 				)
@@ -375,20 +375,20 @@  discard block
 block discarded – undo
375 375
 	 * @param object $cmb new_cmb2_box().
376 376
 	 * @return void
377 377
 	 */
378
-	public function global_downloads( $cmb ) {
378
+	public function global_downloads($cmb) {
379 379
 		$cmb->add_field(
380 380
 			array(
381 381
 				'id'      => 'global_downloads_title',
382 382
 				'type'    => 'title',
383
-				'name'    => __( 'Global Downloads', 'lsx-health-plan' ),
384
-				'default' => __( 'Global Downloads', 'lsx-health-plan' ),
383
+				'name'    => __('Global Downloads', 'lsx-health-plan'),
384
+				'default' => __('Global Downloads', 'lsx-health-plan'),
385 385
 			)
386 386
 		);
387 387
 
388
-		foreach ( $this->download_types as $type => $download_type ) {
388
+		foreach ($this->download_types as $type => $download_type) {
389 389
 			$limit    = 5;
390 390
 			$sortable = false;
391
-			if ( isset( $download_type['limit'] ) ) {
391
+			if (isset($download_type['limit'])) {
392 392
 				$limit    = $download_type['limit'];
393 393
 				$sortable = true;
394 394
 			}
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
 					'limit'      => $limit,
402 402
 					'sortable'   => $sortable,
403 403
 					'query_args' => array(
404
-						'post_type'      => array( 'dlm_download' ),
405
-						'post_status'    => array( 'publish' ),
404
+						'post_type'      => array('dlm_download'),
405
+						'post_status'    => array('publish'),
406 406
 						'posts_per_page' => -1,
407 407
 					),
408 408
 				)
@@ -422,18 +422,18 @@  discard block
 block discarded – undo
422 422
 	 * @param object $cmb new_cmb2_box().
423 423
 	 * @return void
424 424
 	 */
425
-	public function endpoint_translations( $cmb ) {
425
+	public function endpoint_translations($cmb) {
426 426
 		$cmb->add_field(
427 427
 			array(
428 428
 				'id'          => 'endpoints_title',
429 429
 				'type'        => 'title',
430
-				'name'        => __( 'Set Endpoint Translations', 'lsx-health-plan' ),
431
-				'default'     => __( 'Set Endpoint Translations', 'lsx-health-plan' ),
432
-				'description' => __( 'Endpoint is a web address (URL) at which the user can gain access to it. You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ),
430
+				'name'        => __('Set Endpoint Translations', 'lsx-health-plan'),
431
+				'default'     => __('Set Endpoint Translations', 'lsx-health-plan'),
432
+				'description' => __('Endpoint is a web address (URL) at which the user can gain access to it. You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan'),
433 433
 			)
434 434
 		);
435
-		foreach ( $this->endpoints as $slug => $endpoint_vars ) {
436
-			if ( 'exercise' === $slug ) {
435
+		foreach ($this->endpoints as $slug => $endpoint_vars) {
436
+			if ('exercise' === $slug) {
437 437
 				continue;
438 438
 			}
439 439
 
@@ -461,19 +461,19 @@  discard block
 block discarded – undo
461 461
 	 * @param object $cmb new_cmb2_box().
462 462
 	 * @return void
463 463
 	 */
464
-	public function exercise_translations( $cmb ) {
465
-		if ( isset( $this->endpoints['exercise'] ) && '' !== $this->endpoints['exercise'] && ! empty( $this->endpoints['exercise'] ) ) {
464
+	public function exercise_translations($cmb) {
465
+		if (isset($this->endpoints['exercise']) && '' !== $this->endpoints['exercise'] && ! empty($this->endpoints['exercise'])) {
466 466
 			$cmb->add_field(
467 467
 				array(
468 468
 					'id'          => 'exercise_endpoints_title',
469 469
 					'type'        => 'title',
470
-					'name'        => __( 'Set Exercise Translations', 'lsx-health-plan' ),
471
-					'default'     => __( 'Set Exercise Translations', 'lsx-health-plan' ),
472
-					'description' => __( 'You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ),
470
+					'name'        => __('Set Exercise Translations', 'lsx-health-plan'),
471
+					'default'     => __('Set Exercise Translations', 'lsx-health-plan'),
472
+					'description' => __('You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan'),
473 473
 				)
474 474
 			);
475 475
 
476
-			foreach ( $this->endpoints['exercise'] as $slug => $endpoint_vars ) {
476
+			foreach ($this->endpoints['exercise'] as $slug => $endpoint_vars) {
477 477
 				$cmb->add_field(
478 478
 					array(
479 479
 						'name'    => $endpoint_vars['title'],
@@ -499,27 +499,27 @@  discard block
 block discarded – undo
499 499
 	 * @param object $cmb new_cmb2_box().
500 500
 	 * @return void
501 501
 	 */
502
-	public function post_type_toggles( $cmb ) {
503
-		$post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) );
502
+	public function post_type_toggles($cmb) {
503
+		$post_types = apply_filters('lsx_health_plan_post_types', isset($this->post_types));
504 504
 
505 505
 		$cmb->add_field(
506 506
 			array(
507 507
 				'id'          => 'post_type_toggles_title',
508 508
 				'type'        => 'title',
509
-				'name'        => __( 'Disable Post Types', 'lsx-health-plan' ),
510
-				'default'     => __( 'Disable Post Types', 'lsx-health-plan' ),
511
-				'description' => __( 'Disable post types if you are wanting a minimal site.', 'lsx-health-plan' ),
509
+				'name'        => __('Disable Post Types', 'lsx-health-plan'),
510
+				'default'     => __('Disable Post Types', 'lsx-health-plan'),
511
+				'description' => __('Disable post types if you are wanting a minimal site.', 'lsx-health-plan'),
512 512
 			)
513 513
 		);
514 514
 
515
-		foreach ( $post_types as $post_type ) {
516
-			if ( 'plan' === $post_type || 'exercise' === $post_type || ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) ) {
515
+		foreach ($post_types as $post_type) {
516
+			if ('plan' === $post_type || 'exercise' === $post_type || ('video' === $post_type && false !== \lsx_health_plan\functions\get_option('exercise_enabled', false))) {
517 517
 				continue;
518 518
 			}
519 519
 
520 520
 			$cmb->add_field(
521 521
 				array(
522
-					'name'    => ucwords( $post_type ),
522
+					'name'    => ucwords($post_type),
523 523
 					'id'      => $post_type . '_disabled',
524 524
 					'type'    => 'checkbox',
525 525
 					'value'   => 1,
@@ -539,19 +539,19 @@  discard block
 block discarded – undo
539 539
 			array(
540 540
 				'id'          => 'post_type_toggles_enable_title',
541 541
 				'type'        => 'title',
542
-				'name'        => __( 'Enable Post Types', 'lsx-health-plan' ),
543
-				'default'     => __( 'Enable Post Types', 'lsx-health-plan' ),
544
-				'description' => __( 'Enable new functionality like the "exercise" post type.', 'lsx-health-plan' ),
542
+				'name'        => __('Enable Post Types', 'lsx-health-plan'),
543
+				'default'     => __('Enable Post Types', 'lsx-health-plan'),
544
+				'description' => __('Enable new functionality like the "exercise" post type.', 'lsx-health-plan'),
545 545
 			)
546 546
 		);
547 547
 		$cmb->add_field(
548 548
 			array(
549
-				'name'        => __( 'Exercises', 'lsx-health-plan' ),
549
+				'name'        => __('Exercises', 'lsx-health-plan'),
550 550
 				'id'          => 'exercise_enabled',
551 551
 				'type'        => 'checkbox',
552 552
 				'value'       => 1,
553 553
 				'default'     => 0,
554
-				'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ),
554
+				'description' => __('Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan'),
555 555
 			)
556 556
 		);
557 557
 		$cmb->add_field(
@@ -568,18 +568,18 @@  discard block
 block discarded – undo
568 568
 	 * @return void
569 569
 	 */
570 570
 
571
-	public function stat_disable( $cmb ) {
571
+	public function stat_disable($cmb) {
572 572
 		$cmb->add_field(
573 573
 			array(
574 574
 				'id'      => 'stat_disable_title',
575 575
 				'type'    => 'title',
576
-				'name'    => __( 'Disable Profile Stats', 'lsx-health-plan' ),
577
-				'default' => __( 'Disable Profile Stats', 'lsx-health-plan' ),
576
+				'name'    => __('Disable Profile Stats', 'lsx-health-plan'),
577
+				'default' => __('Disable Profile Stats', 'lsx-health-plan'),
578 578
 			)
579 579
 		);
580 580
 		$cmb->add_field(
581 581
 			array(
582
-				'name'    => __( 'Disable All Stats', 'lsx-health-plan' ),
582
+				'name'    => __('Disable All Stats', 'lsx-health-plan'),
583 583
 				'desc'    => 'Disable All Stats',
584 584
 				'id'      => 'disable_all_stats',
585 585
 				'type'    => 'checkbox',
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 		);
590 590
 		$cmb->add_field(
591 591
 			array(
592
-				'name'    => __( 'Disable Weight', 'lsx-health-plan' ),
592
+				'name'    => __('Disable Weight', 'lsx-health-plan'),
593 593
 				'id'      => 'disable_weight_checkbox',
594 594
 				'type'    => 'checkbox',
595 595
 				'value'   => 1,
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 		);
599 599
 		$cmb->add_field(
600 600
 			array(
601
-				'name'    => __( 'Disable Height', 'lsx-health-plan' ),
601
+				'name'    => __('Disable Height', 'lsx-health-plan'),
602 602
 				'id'      => 'disable_height_checkbox',
603 603
 				'type'    => 'checkbox',
604 604
 				'value'   => 1,
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 		);
608 608
 		$cmb->add_field(
609 609
 			array(
610
-				'name'    => __( 'Disable Waist', 'lsx-health-plan' ),
610
+				'name'    => __('Disable Waist', 'lsx-health-plan'),
611 611
 				'id'      => 'disable_waist_checkbox',
612 612
 				'type'    => 'checkbox',
613 613
 				'value'   => 1,
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		);
617 617
 		$cmb->add_field(
618 618
 			array(
619
-				'name'    => __( 'Disable BMI', 'lsx-health-plan' ),
619
+				'name'    => __('Disable BMI', 'lsx-health-plan'),
620 620
 				'id'      => 'disable_bmi_checkbox',
621 621
 				'type'    => 'checkbox',
622 622
 				'value'   => 1,
@@ -638,10 +638,10 @@  discard block
 block discarded – undo
638 638
 	 * @param string $section either engine,archive or single.
639 639
 	 * @return void
640 640
 	 */
641
-	public function generate_tabs( $cmb ) {
641
+	public function generate_tabs($cmb) {
642 642
 		$tabs = $this->get_settings_tabs();
643 643
 
644
-		foreach ( $tabs as $tab_key => $tab ) {
644
+		foreach ($tabs as $tab_key => $tab) {
645 645
 			$cmb->add_field(
646 646
 				array(
647 647
 					'id'          => 'settings_' . $tab_key . '_title',
@@ -651,11 +651,11 @@  discard block
 block discarded – undo
651 651
 					'description' => $tab['desc'],
652 652
 				)
653 653
 			);
654
-			do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb );
654
+			do_action('lsx_hp_settings_page_' . $tab_key . '_top', $cmb);
655 655
 
656
-			do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb );
656
+			do_action('lsx_hp_settings_page_' . $tab_key . '_middle', $cmb);
657 657
 
658
-			do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb );
658
+			do_action('lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb);
659 659
 
660 660
 			$cmb->add_field(
661 661
 				array(
@@ -675,26 +675,26 @@  discard block
 block discarded – undo
675 675
 	public function get_settings_tabs() {
676 676
 		$tabs = array(
677 677
 			'general' => array(
678
-				'title' => __( 'General', 'lsx-health-plan' ),
679
-				'desc'  => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ),
678
+				'title' => __('General', 'lsx-health-plan'),
679
+				'desc'  => __('Control the sitewide settings for the LSX HP site.', 'lsx-health-plan'),
680 680
 			),
681 681
 		);
682 682
 
683
-		foreach ( $this->post_types as $post_type ) {
684
-			switch ( $post_type ) {
683
+		foreach ($this->post_types as $post_type) {
684
+			switch ($post_type) {
685 685
 				default:
686 686
 					//if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) {
687
-						$temp_post_type = get_post_type_object( $post_type );
688
-						if ( ! is_wp_error( $temp_post_type ) ) {
689
-							$page_url    = get_post_type_archive_link( $temp_post_type->name );
687
+						$temp_post_type = get_post_type_object($post_type);
688
+						if ( ! is_wp_error($temp_post_type)) {
689
+							$page_url    = get_post_type_archive_link($temp_post_type->name);
690 690
 							$description = sprintf(
691 691
 								/* translators: %s: The subscription info */
692
-								__( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ),
692
+								__('Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search'),
693 693
 								$page_url,
694 694
 								$temp_post_type->label
695 695
 							);
696 696
 
697
-							$tabs[ $post_type ] = array(
697
+							$tabs[$post_type] = array(
698 698
 								'title' => $temp_post_type->label,
699 699
 								'desc'  => $description,
700 700
 							);
Please login to merge, or discard this patch.