Passed
Push — add/multiplan ( 9f935c...4dee3f )
by Virginia
03:51
created
includes/functions/plan.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
  * @return boolean
15 15
  */
16 16
 function is_search_enabled() {
17
-	$enabled = false;
18
-	if ( function_exists( 'lsx_search' ) ) {
19
-		$search_instance = \LSX_Search::get_instance();
20
-		if ( null !== $search_instance ) {
21
-			$enabled = $search_instance->frontend->is_search_enabled();
22
-		}
23
-	}
24
-	return $enabled;
17
+     $enabled = false;
18
+     if ( function_exists( 'lsx_search' ) ) {
19
+          $search_instance = \LSX_Search::get_instance();
20
+          if ( null !== $search_instance ) {
21
+               $enabled = $search_instance->frontend->is_search_enabled();
22
+          }
23
+     }
24
+     return $enabled;
25 25
 }
26 26
 
27 27
 /**
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
  * @return boolean
32 32
  */
33 33
 function has_sections( $plan_id = 0 ) {
34
-	$sections = false;
35
-	if ( 0 === $plan_id ) {
36
-		$plan_id = get_the_ID();
37
-	}
38
-	$lsx_hp   = lsx_health_plan();
39
-	$sections = $lsx_hp->frontend->plan_query->query_sections( $plan_id );
40
-	return $sections;
34
+     $sections = false;
35
+     if ( 0 === $plan_id ) {
36
+          $plan_id = get_the_ID();
37
+     }
38
+     $lsx_hp   = lsx_health_plan();
39
+     $sections = $lsx_hp->frontend->plan_query->query_sections( $plan_id );
40
+     return $sections;
41 41
 }
42 42
 
43 43
 /**
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
  * @return array
49 49
  */
50 50
 function get_sections( $group_sections = false ) {
51
-	$lsx_hp   = lsx_health_plan();
52
-	$sections = $lsx_hp->frontend->plan_query->get_sections( $group_sections );
53
-	return $sections;
51
+     $lsx_hp   = lsx_health_plan();
52
+     $sections = $lsx_hp->frontend->plan_query->get_sections( $group_sections );
53
+     return $sections;
54 54
 }
55 55
 
56 56
 /**
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
  * @return array
61 61
  */
62 62
 function get_section_info( $section_key = '' ) {
63
-	$section_info = array();
63
+     $section_info = array();
64 64
 
65
-	$sections = get_sections();
66
-	if ( ! empty( $sections ) ) {
67
-		foreach ( $sections as $key => $values ) {
68
-			$current_key = sanitize_title( $values['title'] );
69
-			if ( $current_key === $section_key ) {
70
-				return $values;
71
-			}
72
-		}
73
-	}
74
-	return $section_info;
65
+     $sections = get_sections();
66
+     if ( ! empty( $sections ) ) {
67
+          foreach ( $sections as $key => $values ) {
68
+               $current_key = sanitize_title( $values['title'] );
69
+               if ( $current_key === $section_key ) {
70
+                    return $values;
71
+               }
72
+          }
73
+     }
74
+     return $section_info;
75 75
 }
76 76
 
77 77
 /**
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
  * @return array
82 82
  */
83 83
 function get_group_title( $sections = array() ) {
84
-	$group_title = apply_filters( 'lsx_hp_default_plan_group', __( 'Daily Plan', 'lsx-health-plan' ) );
85
-	if ( ! empty( $sections ) ) {
86
-		$first_section = reset( $sections );
87
-		if ( isset( $first_section['group'] ) && '' !== $first_section['group'] ) {
88
-			$group_title = $first_section['group'];
89
-		}
90
-	}
91
-	return $group_title;
84
+     $group_title = apply_filters( 'lsx_hp_default_plan_group', __( 'Daily Plan', 'lsx-health-plan' ) );
85
+     if ( ! empty( $sections ) ) {
86
+          $first_section = reset( $sections );
87
+          if ( isset( $first_section['group'] ) && '' !== $first_section['group'] ) {
88
+               $group_title = $first_section['group'];
89
+          }
90
+     }
91
+     return $group_title;
92 92
 }
93 93
 
94 94
 /**
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
  * @return array
100 100
  */
101 101
 function get_permalink( $plan_id = 0, $title = '' ) {
102
-	if ( 0 === $plan_id ) {
103
-		$plan_id = get_the_ID();
104
-	}
105
-	$url = \get_permalink( $plan_id );
106
-	if ( '' !== $title ) {
107
-		$url .= sanitize_title( $title ) . '/';
108
-	}
109
-	return $url;
102
+     if ( 0 === $plan_id ) {
103
+          $plan_id = get_the_ID();
104
+     }
105
+     $url = \get_permalink( $plan_id );
106
+     if ( '' !== $title ) {
107
+          $url .= sanitize_title( $title ) . '/';
108
+     }
109
+     return $url;
110 110
 }
111 111
 
112 112
 /**
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
  * @return boolean
116 116
  */
117 117
 function is_filters_disabled( $disabled = false ) {
118
-	$is_disabled = \lsx_health_plan\functions\get_option( 'plan_filters_disabled', false );
119
-	if ( false !== $is_disabled ) {
120
-		$disabled = true;
121
-	}
122
-	return $disabled;
118
+     $is_disabled = \lsx_health_plan\functions\get_option( 'plan_filters_disabled', false );
119
+     if ( false !== $is_disabled ) {
120
+          $disabled = true;
121
+     }
122
+     return $disabled;
123 123
 }
124 124
 
125 125
 /**
@@ -130,17 +130,17 @@  discard block
 block discarded – undo
130 130
  * @return string
131 131
  */
132 132
 function generate_section_id( $section_key = '' ) {
133
-	$key          = get_the_ID();
134
-	if ( '' === $section_key ) {
135
-		$section_key  = get_query_var( 'section' );
136
-	}
133
+     $key          = get_the_ID();
134
+     if ( '' === $section_key ) {
135
+          $section_key  = get_query_var( 'section' );
136
+     }
137 137
 
138
-	$section_key = sanitize_title( $section_key );
138
+     $section_key = sanitize_title( $section_key );
139 139
 	
140
-	if ( '' !== $section_key && \lsx_health_plan\functions\plan\has_sections() ) {
141
-		$group_title  = apply_filters( 'lsx_hp_default_plan_group', __( 'Daily Plan', 'lsx-health-plan' ) );
142
-		$section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key );
143
-		$key         .= '_' . sanitize_key( $group_title ) . '_' . sanitize_key( $section_info['title'] );
144
-	}
145
-	return $key;
140
+     if ( '' !== $section_key && \lsx_health_plan\functions\plan\has_sections() ) {
141
+          $group_title  = apply_filters( 'lsx_hp_default_plan_group', __( 'Daily Plan', 'lsx-health-plan' ) );
142
+          $section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key );
143
+          $key         .= '_' . sanitize_key( $group_title ) . '_' . sanitize_key( $section_info['title'] );
144
+     }
145
+     return $key;
146 146
 }
Please login to merge, or discard this patch.
includes/functions.php 1 patch
Indentation   +272 added lines, -272 removed lines patch added patch discarded remove patch
@@ -17,27 +17,27 @@  discard block
 block discarded – undo
17 17
  * @return boolean
18 18
  */
19 19
 function has_attached_post( $post_id = '', $meta_key = '', $single = true ) {
20
-	$has_post = false;
21
-	if ( '' === $post_id ) {
22
-		$post_id = get_the_ID();
23
-	}
24
-	$items = get_post_meta( $post_id, $meta_key, $single );
25
-	if ( '' !== $items && false !== $items && 0 !== $items ) {
26
-		if ( ! is_array( $items ) ) {
27
-			$items = array( $items );
28
-		}
29
-		$items = check_posts_exist( $items );
30
-		if ( ! empty( $items ) ) {
31
-			$has_post = true;
32
-		}
33
-	} else {
34
-		// Check for defaults.
35
-		$options = get_option( 'all' );
36
-		if ( isset( $options[ $meta_key ] ) && '' !== $options[ $meta_key ] && ! empty( $options[ $meta_key ] ) ) {
37
-			$has_post = true;
38
-		}
39
-	}
40
-	return $has_post;
20
+     $has_post = false;
21
+     if ( '' === $post_id ) {
22
+          $post_id = get_the_ID();
23
+     }
24
+     $items = get_post_meta( $post_id, $meta_key, $single );
25
+     if ( '' !== $items && false !== $items && 0 !== $items ) {
26
+          if ( ! is_array( $items ) ) {
27
+               $items = array( $items );
28
+          }
29
+          $items = check_posts_exist( $items );
30
+          if ( ! empty( $items ) ) {
31
+               $has_post = true;
32
+          }
33
+     } else {
34
+          // Check for defaults.
35
+          $options = get_option( 'all' );
36
+          if ( isset( $options[ $meta_key ] ) && '' !== $options[ $meta_key ] && ! empty( $options[ $meta_key ] ) ) {
37
+               $has_post = true;
38
+          }
39
+     }
40
+     return $has_post;
41 41
 }
42 42
 
43 43
 /**
@@ -48,18 +48,18 @@  discard block
 block discarded – undo
48 48
  * @return mixed           Option value
49 49
  */
50 50
 function get_option( $key = '', $default = false ) {
51
-	if ( function_exists( 'cmb2_get_option' ) ) {
52
-		return cmb2_get_option( 'lsx_health_plan_options', $key, $default );
53
-	}
54
-	// Fallback to get_option if CMB2 is not loaded yet.
55
-	$opts = \get_option( 'lsx_health_plan_options', $default );
56
-	$val  = $default;
57
-	if ( 'all' === $key ) {
58
-		$val = $opts;
59
-	} elseif ( is_array( $opts ) && array_key_exists( $key, $opts ) && false !== $opts[ $key ] ) {
60
-		$val = $opts[ $key ];
61
-	}
62
-	return $val;
51
+     if ( function_exists( 'cmb2_get_option' ) ) {
52
+          return cmb2_get_option( 'lsx_health_plan_options', $key, $default );
53
+     }
54
+     // Fallback to get_option if CMB2 is not loaded yet.
55
+     $opts = \get_option( 'lsx_health_plan_options', $default );
56
+     $val  = $default;
57
+     if ( 'all' === $key ) {
58
+          $val = $opts;
59
+     } elseif ( is_array( $opts ) && array_key_exists( $key, $opts ) && false !== $opts[ $key ] ) {
60
+          $val = $opts[ $key ];
61
+     }
62
+     return $val;
63 63
 }
64 64
 
65 65
 /**
@@ -70,54 +70,54 @@  discard block
 block discarded – undo
70 70
  * @return mixed           Option value
71 71
  */
72 72
 function get_downloads( $type = 'all', $post_id = '' ) {
73
-	$lsx_health_plan = \lsx_health_plan();
74
-	$post_types      = $lsx_health_plan->get_post_types();
75
-	if ( '' === $post_id ) {
76
-		$post_id = get_the_ID();
77
-	}
78
-	$downloads = array();
79
-	$options   = get_option( 'all' );
80
-
81
-	foreach ( $post_types as $post_type ) {
82
-		if ( 'all' === $type || in_array( $type, $post_types, true ) ) {
83
-
84
-			// Get the default downloads for this post type.
85
-			$default_downloads = array();
86
-			$new_downloads     = array();
87
-			if ( isset( $options[ 'download_' . $post_type ] ) ) {
88
-				if ( is_array( $options[ 'download_' . $post_type ] ) ) {
89
-					$default_downloads = $options[ 'download_' . $post_type ];
90
-				} else {
91
-					$default_downloads[] = $options[ 'download_' . $post_type ];
92
-				}
93
-			}
94
-
95
-			if ( 'page' === $post_type ) {
96
-				$key = 'plan_warmup';
97
-			} else {
98
-				$key = 'connected_' . $post_type . 's';
99
-			}
100
-
101
-			$connected_items = get_post_meta( $post_id, $key, true );
102
-			if ( ! empty( $connected_items ) ) {
103
-				foreach ( $connected_items as $connected_item ) {
104
-					$current_downloads = get_post_meta( $connected_item, 'connected_downloads', true );
105
-					if ( false !== $current_downloads && ! empty( $current_downloads ) ) {
106
-						$new_downloads = array_merge( $new_downloads, $current_downloads );
107
-					}
108
-				}
109
-			}
110
-
111
-			if ( ! empty( $new_downloads ) ) {
112
-				$downloads = array_merge( $downloads, $new_downloads );
113
-			} elseif ( ! empty( $default_downloads ) ) {
114
-				$downloads = array_merge( $downloads, $default_downloads );
115
-			}
116
-			$downloads = array_unique( $downloads );
117
-		}
118
-	}
119
-	$downloads = check_posts_exist( $downloads );
120
-	return $downloads;
73
+     $lsx_health_plan = \lsx_health_plan();
74
+     $post_types      = $lsx_health_plan->get_post_types();
75
+     if ( '' === $post_id ) {
76
+          $post_id = get_the_ID();
77
+     }
78
+     $downloads = array();
79
+     $options   = get_option( 'all' );
80
+
81
+     foreach ( $post_types as $post_type ) {
82
+          if ( 'all' === $type || in_array( $type, $post_types, true ) ) {
83
+
84
+               // Get the default downloads for this post type.
85
+               $default_downloads = array();
86
+               $new_downloads     = array();
87
+               if ( isset( $options[ 'download_' . $post_type ] ) ) {
88
+                    if ( is_array( $options[ 'download_' . $post_type ] ) ) {
89
+                         $default_downloads = $options[ 'download_' . $post_type ];
90
+                    } else {
91
+                         $default_downloads[] = $options[ 'download_' . $post_type ];
92
+                    }
93
+               }
94
+
95
+               if ( 'page' === $post_type ) {
96
+                    $key = 'plan_warmup';
97
+               } else {
98
+                    $key = 'connected_' . $post_type . 's';
99
+               }
100
+
101
+               $connected_items = get_post_meta( $post_id, $key, true );
102
+               if ( ! empty( $connected_items ) ) {
103
+                    foreach ( $connected_items as $connected_item ) {
104
+                         $current_downloads = get_post_meta( $connected_item, 'connected_downloads', true );
105
+                         if ( false !== $current_downloads && ! empty( $current_downloads ) ) {
106
+                              $new_downloads = array_merge( $new_downloads, $current_downloads );
107
+                         }
108
+                    }
109
+               }
110
+
111
+               if ( ! empty( $new_downloads ) ) {
112
+                    $downloads = array_merge( $downloads, $new_downloads );
113
+               } elseif ( ! empty( $default_downloads ) ) {
114
+                    $downloads = array_merge( $downloads, $default_downloads );
115
+               }
116
+               $downloads = array_unique( $downloads );
117
+          }
118
+     }
119
+     $downloads = check_posts_exist( $downloads );
120
+     return $downloads;
121 121
 }
122 122
 
123 123
 /**
@@ -127,35 +127,35 @@  discard block
 block discarded – undo
127 127
  * @return array           an array of the downloads or empty.
128 128
  */
129 129
 function get_weekly_downloads( $week = '' ) {
130
-	$downloads = array();
131
-	if ( '' !== $week ) {
132
-		$saved_downloads = get_transient( 'lsx_hp_weekly_downloads_' . $week );
133
-		if ( false !== $saved_downloads && ! empty( $saved_downloads ) ) {
134
-			$downloads = $saved_downloads;
135
-		} else {
136
-			$args = array(
137
-				'orderby'        => 'title',
138
-				'order'          => 'ASC',
139
-				'post_type'      => 'dlm_download',
140
-				'posts_per_page' => -1,
141
-				'nopagin'        => true,
142
-				'fields'         => 'ids',
143
-				'tax_query'      => array(
144
-					array(
145
-						'taxonomy' => 'dlm_download_category',
146
-						'field'    => 'slug',
147
-						'terms'    => array( $week ),
148
-					),
149
-				),
150
-			);
151
-			$download_query = new \WP_Query( $args );
152
-			if ( $download_query->have_posts() ) {
153
-				$downloads = $download_query->posts;
154
-			}
155
-		}
156
-	}
157
-	$downloads = check_posts_exist( $downloads );
158
-	return $downloads;
130
+     $downloads = array();
131
+     if ( '' !== $week ) {
132
+          $saved_downloads = get_transient( 'lsx_hp_weekly_downloads_' . $week );
133
+          if ( false !== $saved_downloads && ! empty( $saved_downloads ) ) {
134
+               $downloads = $saved_downloads;
135
+          } else {
136
+               $args = array(
137
+                    'orderby'        => 'title',
138
+                    'order'          => 'ASC',
139
+                    'post_type'      => 'dlm_download',
140
+                    'posts_per_page' => -1,
141
+                    'nopagin'        => true,
142
+                    'fields'         => 'ids',
143
+                    'tax_query'      => array(
144
+                         array(
145
+                              'taxonomy' => 'dlm_download_category',
146
+                              'field'    => 'slug',
147
+                              'terms'    => array( $week ),
148
+                         ),
149
+                    ),
150
+               );
151
+               $download_query = new \WP_Query( $args );
152
+               if ( $download_query->have_posts() ) {
153
+                    $downloads = $download_query->posts;
154
+               }
155
+          }
156
+     }
157
+     $downloads = check_posts_exist( $downloads );
158
+     return $downloads;
159 159
 }
160 160
 
161 161
 /**
@@ -165,22 +165,22 @@  discard block
 block discarded – undo
165 165
  * @return void
166 166
  */
167 167
 function check_posts_exist( $post_ids = array() ) {
168
-	$new_ids = array();
169
-	global $wpdb;
170
-	if ( is_array( $post_ids ) && ! empty( $post_ids ) ) {
171
-		$post_ids = "'" . implode( "','", $post_ids ) . "'";
172
-		$query    = "
168
+     $new_ids = array();
169
+     global $wpdb;
170
+     if ( is_array( $post_ids ) && ! empty( $post_ids ) ) {
171
+          $post_ids = "'" . implode( "','", $post_ids ) . "'";
172
+          $query    = "
173 173
 			SELECT `ID` 
174 174
 			FROM `{$wpdb->posts}`
175 175
 			WHERE `ID` IN ({$post_ids})
176 176
 			AND `post_status` != 'trash'
177 177
 		";
178
-		$results = $wpdb->get_results( $query ); // WPCS: unprepared SQL
179
-		if ( ! empty( $results ) ) {
180
-			$new_ids = wp_list_pluck( $results, 'ID' );
181
-		}
182
-	}
183
-	return $new_ids;
178
+          $results = $wpdb->get_results( $query ); // WPCS: unprepared SQL
179
+          if ( ! empty( $results ) ) {
180
+               $new_ids = wp_list_pluck( $results, 'ID' );
181
+          }
182
+     }
183
+     return $new_ids;
184 184
 }
185 185
 
186 186
 /**
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
  * @return void
193 193
  */
194 194
 function register_modal( $id = '', $title = '', $body = '' ) {
195
-	lsx_health_plan()->frontend->modals->register_modal(
196
-		array(
197
-			'title' => $title,
198
-			'body'  => $body,
199
-		),
200
-		$id
201
-	);
195
+     lsx_health_plan()->frontend->modals->register_modal(
196
+          array(
197
+               'title' => $title,
198
+               'body'  => $body,
199
+          ),
200
+          $id
201
+     );
202 202
 }
203 203
 
204 204
 /**
@@ -208,13 +208,13 @@  discard block
 block discarded – undo
208 208
  * @return void
209 209
  */
210 210
 function output_modal( $args = array() ) {
211
-	$defaults = array(
212
-		'id'    => '',
213
-		'title' => '',
214
-		'body'  => '',
215
-	);
216
-	$args     = wp_parse_args( $args, $defaults );
217
-	?>
211
+     $defaults = array(
212
+          'id'    => '',
213
+          'title' => '',
214
+          'body'  => '',
215
+     );
216
+     $args     = wp_parse_args( $args, $defaults );
217
+     ?>
218 218
 	<!-- Modal -->
219 219
 	<div class="modal fade lsx-health-plan-modal" id="<?php echo esc_html( $args['id'] ); ?>" tabindex="-1" role="dialog" aria-labelledby="<?php echo esc_html( $args['id'] ); ?>"  aria-hidden="true">
220 220
 		<div class="modal-dialog" role="document">
@@ -222,36 +222,36 @@  discard block
 block discarded – undo
222 222
 			<button type="button" class="close" data-dismiss="modal">&times;</button>			
223 223
 				<div class="modal-header">
224 224
 					<?php
225
-					if ( '' !== $args['title'] ) {
226
-						echo wp_kses_post( '<h2>' . $args['title'] . '</h2>' );
227
-					}
228
-					?>
225
+                         if ( '' !== $args['title'] ) {
226
+                              echo wp_kses_post( '<h2>' . $args['title'] . '</h2>' );
227
+                         }
228
+                         ?>
229 229
 				</div>
230 230
 				<div class="modal-body">
231 231
 				<?php
232
-				if ( '' !== $args['body'] ) {
233
-					$allowed_html = array(
234
-						'iframe' => array(
235
-							'data-src'        => array(),
236
-							'src'             => array(),
237
-							'width'           => array(),
238
-							'height'          => array(),
239
-							'frameBorder'     => array( '0' ),
240
-							'class'           => array(),
241
-							'allowFullScreen' => array(),
242
-							'style'           => array(),
243
-						),
244
-						'h5'     => array(
245
-							'class' => array(),
246
-						),
247
-					);
248
-					if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
249
-						echo wp_kses_post( $args['body'] );
250
-					} else {
251
-						echo wp_kses( $args['body'], $allowed_html );
252
-					}
253
-				}
254
-				?>
232
+                    if ( '' !== $args['body'] ) {
233
+                         $allowed_html = array(
234
+                              'iframe' => array(
235
+                                   'data-src'        => array(),
236
+                                   'src'             => array(),
237
+                                   'width'           => array(),
238
+                                   'height'          => array(),
239
+                                   'frameBorder'     => array( '0' ),
240
+                                   'class'           => array(),
241
+                                   'allowFullScreen' => array(),
242
+                                   'style'           => array(),
243
+                              ),
244
+                              'h5'     => array(
245
+                                   'class' => array(),
246
+                              ),
247
+                         );
248
+                         if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
249
+                              echo wp_kses_post( $args['body'] );
250
+                         } else {
251
+                              echo wp_kses( $args['body'], $allowed_html );
252
+                         }
253
+                    }
254
+                    ?>
255 255
 				</div>
256 256
 			</div>
257 257
 		</div>
@@ -267,18 +267,18 @@  discard block
 block discarded – undo
267 267
  * @return void
268 268
  */
269 269
 function get_video_url( $embed ) {
270
-	$url = '';
271
-	if ( false !== stripos( $embed, '<iframe' ) ) {
272
-		preg_match( '/src="([^"]+)"/', $embed, $match );
273
-		if ( is_array( $match ) && isset( $match[1] ) ) {
274
-			$url = '<iframe data-src="' . $match[1] . '" style="border: 0;" frameBorder="0" class="giphy-embed" allowFullScreen height="300" width="100%"></iframe>';
275
-		} else {
276
-			$url = $embed;
277
-		}
278
-	} else {
279
-		$url = $embed;
280
-	}
281
-	return $url;
270
+     $url = '';
271
+     if ( false !== stripos( $embed, '<iframe' ) ) {
272
+          preg_match( '/src="([^"]+)"/', $embed, $match );
273
+          if ( is_array( $match ) && isset( $match[1] ) ) {
274
+               $url = '<iframe data-src="' . $match[1] . '" style="border: 0;" frameBorder="0" class="giphy-embed" allowFullScreen height="300" width="100%"></iframe>';
275
+          } else {
276
+               $url = $embed;
277
+          }
278
+     } else {
279
+          $url = $embed;
280
+     }
281
+     return $url;
282 282
 }
283 283
 
284 284
 /**
@@ -289,18 +289,18 @@  discard block
 block discarded – undo
289 289
  * @return boolean
290 290
  */
291 291
 function is_week_complete( $term_id = false, $section_keys = array(), $group_title = '' ) {
292
-	$return = false;
293
-	if ( ! empty( $section_keys ) ) {
294
-		$group_count = count( $section_keys );
295
-		foreach ( $section_keys as &$pid ) {
296
-			$pid = 'day_' . \lsx_health_plan\functions\plan\generate_section_id( $pid ) . '_complete';
297
-		}
298
-		$days_complete = get_meta_amounts( $section_keys );
299
-		if ( (int) $group_count === (int) $days_complete ) {
300
-			$return = true;
301
-		}
302
-	}
303
-	return $return;
292
+     $return = false;
293
+     if ( ! empty( $section_keys ) ) {
294
+          $group_count = count( $section_keys );
295
+          foreach ( $section_keys as &$pid ) {
296
+               $pid = 'day_' . \lsx_health_plan\functions\plan\generate_section_id( $pid ) . '_complete';
297
+          }
298
+          $days_complete = get_meta_amounts( $section_keys );
299
+          if ( (int) $group_count === (int) $days_complete ) {
300
+               $return = true;
301
+          }
302
+     }
303
+     return $return;
304 304
 }
305 305
 
306 306
 /**
@@ -311,23 +311,23 @@  discard block
 block discarded – undo
311 311
  * @return void
312 312
  */
313 313
 function get_meta_amounts( $post_ids = array() ) {
314
-	global $wpdb;
315
-	$amount       = 0;
316
-	$current_user = wp_get_current_user();
317
-	if ( false !== $current_user && ! empty( $post_ids ) ) {
318
-		$post_ids = "'" . implode( "','", $post_ids ) . "'";
319
-		$query    = "
314
+     global $wpdb;
315
+     $amount       = 0;
316
+     $current_user = wp_get_current_user();
317
+     if ( false !== $current_user && ! empty( $post_ids ) ) {
318
+          $post_ids = "'" . implode( "','", $post_ids ) . "'";
319
+          $query    = "
320 320
 			SELECT COUNT(`meta_value`) 
321 321
 			FROM `{$wpdb->usermeta}`
322 322
 			WHERE `meta_key` IN ({$post_ids})
323 323
 			AND `user_id` = '{$current_user->ID}'
324 324
 		";
325
-		$results  = $wpdb->get_var( $query ); // WPCS: unprepared SQL
326
-		if ( ! empty( $results ) ) {
327
-			$amount = $results;
328
-		}
329
-	}
330
-	return $amount;
325
+          $results  = $wpdb->get_var( $query ); // WPCS: unprepared SQL
326
+          if ( ! empty( $results ) ) {
327
+               $amount = $results;
328
+          }
329
+     }
330
+     return $amount;
331 331
 }
332 332
 
333 333
 /**
@@ -337,39 +337,39 @@  discard block
 block discarded – undo
337 337
  * @return void
338 338
  */
339 339
 function hp_get_plan_type_meta( $post ) {
340
-	$plan_meta = '';
340
+     $plan_meta = '';
341 341
 
342
-	$term_obj_list = get_the_terms( $post->ID, 'plan-type' );
343
-	if ( false !== $term_obj_list ) {
344
-		$terms_string  = join( ' & ', wp_list_pluck( $term_obj_list, 'name' ) );
345
-		$terms_ids     = wp_list_pluck( $term_obj_list, 'term_id' );
342
+     $term_obj_list = get_the_terms( $post->ID, 'plan-type' );
343
+     if ( false !== $term_obj_list ) {
344
+          $terms_string  = join( ' & ', wp_list_pluck( $term_obj_list, 'name' ) );
345
+          $terms_ids     = wp_list_pluck( $term_obj_list, 'term_id' );
346 346
 
347
-		foreach ( $terms_ids as $terms_id ) {
348
-			$term_thumbnail_id = get_term_meta( $terms_id, 'thumbnail', true );
349
-			$img               = wp_get_attachment_image_src( $term_thumbnail_id, 'thumbnail' );
350
-			if ( ! empty( $img ) ) {
351
-				$image_url         = $img[0];
352
-				$img               = '<img loading="lazy" alt="thumbnail" style="width:24px; height: auto;" class="attachment-responsive wp-post-image lsx-responsive" src="' . esc_url( $image_url ) . '" />';
353
-			}
347
+          foreach ( $terms_ids as $terms_id ) {
348
+               $term_thumbnail_id = get_term_meta( $terms_id, 'thumbnail', true );
349
+               $img               = wp_get_attachment_image_src( $term_thumbnail_id, 'thumbnail' );
350
+               if ( ! empty( $img ) ) {
351
+                    $image_url         = $img[0];
352
+                    $img               = '<img loading="lazy" alt="thumbnail" style="width:24px; height: auto;" class="attachment-responsive wp-post-image lsx-responsive" src="' . esc_url( $image_url ) . '" />';
353
+               }
354 354
 
355
-			$plan_meta .= $img;
356
-		}
355
+               $plan_meta .= $img;
356
+          }
357 357
 
358
-		$plan_meta = '<div class="plan-meta">' . $plan_meta . '<span>' . $terms_string . '</span></div>';
359
-	}
358
+          $plan_meta = '<div class="plan-meta">' . $plan_meta . '<span>' . $terms_string . '</span></div>';
359
+     }
360 360
 
361
-	return $plan_meta;
361
+     return $plan_meta;
362 362
 }
363 363
 
364 364
 /**
365 365
  * Limit media library access
366 366
  */
367 367
 function set_only_author( $wp_query ) {
368
-	global $current_user;
369
-	if ( is_admin() && ! current_user_can( 'edit_others_posts' ) ) {
370
-		$wp_query->set( 'administrator', $current_user->ID );
371
-		add_filter( 'views_upload', 'fix_media_counts' );
372
-	}
368
+     global $current_user;
369
+     if ( is_admin() && ! current_user_can( 'edit_others_posts' ) ) {
370
+          $wp_query->set( 'administrator', $current_user->ID );
371
+          add_filter( 'views_upload', 'fix_media_counts' );
372
+     }
373 373
 }
374 374
 add_action( 'pre_get_posts', '\lsx_health_plan\functions\set_only_author' );
375 375
 
@@ -380,12 +380,12 @@  discard block
 block discarded – undo
380 380
  * @return void
381 381
  */
382 382
 function hp_excerpt( $post_id ) {
383
-	if ( ! has_excerpt( $post_id ) ) {
384
-		$content = wp_trim_words( get_post_field( 'post_content', $post_id ), 10 );
385
-	} else {
386
-		$content = get_the_excerpt( $post_id );
387
-	}
388
-	return $content;
383
+     if ( ! has_excerpt( $post_id ) ) {
384
+          $content = wp_trim_words( get_post_field( 'post_content', $post_id ), 10 );
385
+     } else {
386
+          $content = get_the_excerpt( $post_id );
387
+     }
388
+     return $content;
389 389
 }
390 390
 
391 391
 /**
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
  * @return void
396 396
  */
397 397
 function column_class( $columns = '3' ) {
398
-	$cols .= '5' === $columns ? '15' : 12 / $columns;
399
-	return $cols;
398
+     $cols .= '5' === $columns ? '15' : 12 / $columns;
399
+     return $cols;
400 400
 }
401 401
 
402 402
 /**
@@ -406,22 +406,22 @@  discard block
 block discarded – undo
406 406
  * @return void
407 407
  */
408 408
 function get_exercises_by_workout( $workout = '' ) {
409
-	$exercises = array();
410
-	$i               = 1;
411
-	$section_counter = 6;
412
-	while ( $i <= $section_counter ) {
413
-		$group_name = 'workout_section_' . $i;
414
-		$groups     = get_post_meta( $workout, $group_name, true );
415
-		if ( ! empty( $groups ) ) {
416
-			foreach ( $groups as $group ) {
417
-				if ( isset( $group['connected_exercises'] ) ) {
418
-					$exercises[] = $group['connected_exercises'];
419
-				}
420
-			}
421
-		}
422
-		$i++;
423
-	}
424
-	return $exercises;
409
+     $exercises = array();
410
+     $i               = 1;
411
+     $section_counter = 6;
412
+     while ( $i <= $section_counter ) {
413
+          $group_name = 'workout_section_' . $i;
414
+          $groups     = get_post_meta( $workout, $group_name, true );
415
+          if ( ! empty( $groups ) ) {
416
+               foreach ( $groups as $group ) {
417
+                    if ( isset( $group['connected_exercises'] ) ) {
418
+                         $exercises[] = $group['connected_exercises'];
419
+                    }
420
+               }
421
+          }
422
+          $i++;
423
+     }
424
+     return $exercises;
425 425
 }
426 426
 
427 427
 
@@ -432,20 +432,20 @@  discard block
 block discarded – undo
432 432
  * @return int
433 433
  */
434 434
 function get_progress( $plan_id = false ) {
435
-	$progress = 0;
436
-	$complete = array();
437
-	$count    = 0;
438
-	if ( false !== $plan_id &&  \lsx_health_plan\functions\plan\has_sections( $plan_id ) ) {
439
-		$sections = \lsx_health_plan\functions\plan\get_sections();
440
-		$all_count = count( $sections );
441
-		foreach ( $sections as $section_key => $section_values ) {
442
-			if ( lsx_health_plan_is_day_complete( $plan_id, $section_values['title'] ) ) {
443
-				$complete[] = true;
444
-			}
445
-		}
446
-		$progress = (int) count( $complete ) / (int) $all_count * 100;
447
-	}
448
-	return $progress;
435
+     $progress = 0;
436
+     $complete = array();
437
+     $count    = 0;
438
+     if ( false !== $plan_id &&  \lsx_health_plan\functions\plan\has_sections( $plan_id ) ) {
439
+          $sections = \lsx_health_plan\functions\plan\get_sections();
440
+          $all_count = count( $sections );
441
+          foreach ( $sections as $section_key => $section_values ) {
442
+               if ( lsx_health_plan_is_day_complete( $plan_id, $section_values['title'] ) ) {
443
+                    $complete[] = true;
444
+               }
445
+          }
446
+          $progress = (int) count( $complete ) / (int) $all_count * 100;
447
+     }
448
+     return $progress;
449 449
 }
450 450
 
451 451
 
@@ -457,18 +457,18 @@  discard block
 block discarded – undo
457 457
  */
458 458
 function hp_back_archive_link() {
459 459
 
460
-	$post_type = 'exercise';
461
-	if ( is_tax( 'recipe-cuisine' ) || is_tax( 'recipe-type' ) ) {
462
-		$post_type = 'recipe';
463
-	}
460
+     $post_type = 'exercise';
461
+     if ( is_tax( 'recipe-cuisine' ) || is_tax( 'recipe-type' ) ) {
462
+          $post_type = 'recipe';
463
+     }
464 464
 
465
-	if ( is_tax() ) {
466
-		?>
465
+     if ( is_tax() ) {
466
+          ?>
467 467
 		<div class="archive-category-title hp-archive-category-title">
468 468
 			<a class="back-to-blog" href="<?php echo ( esc_url( get_post_type_archive_link( $post_type ) ) ); ?>"><?php echo esc_html__( 'Back To ', 'lsx' ) . esc_html( $post_type ) . 's'; ?></a>
469 469
 		</div>
470 470
 		<?php
471
-	}
471
+     }
472 472
 }
473 473
 add_action( 'lsx_content_wrap_before', '\lsx_health_plan\functions\hp_back_archive_link', 20 );
474 474
 
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
  * @return array
480 480
  */
481 481
 function prep_array( $item ) {
482
-	if ( ! is_array( $item ) ) {
483
-		$item = explode( ',', $item );
484
-		if ( ! is_array( $item ) ) {
485
-			$item = array( $item );
486
-		}
487
-	}
488
-	return $item;
482
+     if ( ! is_array( $item ) ) {
483
+          $item = explode( ',', $item );
484
+          if ( ! is_array( $item ) ) {
485
+               $item = array( $item );
486
+          }
487
+     }
488
+     return $item;
489 489
 }
Please login to merge, or discard this patch.
classes/class-frontend.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -8,120 +8,120 @@
 block discarded – undo
8 8
  */
9 9
 class Frontend {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\Frontend()
17
-	 */
18
-	protected static $instance = null;
19
-
20
-	/**
21
-	 * @var object \lsx_health_plan\classes\frontend\Endpoints();
22
-	 */
23
-	public $endpoints;
24
-
25
-	/**
26
-	 * @var object \lsx_health_plan\classes\frontend\Modals();
27
-	 */
28
-	public $modals;
29
-
30
-	/**
31
-	 * @var object \lsx_health_plan\classes\frontend\Gallery();
32
-	 */
33
-	public $gallery;
34
-
35
-	/**
36
-	 * @var object \lsx_health_plan\classes\frontend\Plan_Status();
37
-	 */
38
-	public $plan_status;
39
-
40
-	/**
41
-	 * @var object \lsx_health_plan\classes\frontend\Plan_Query();
42
-	 */
43
-	public $plan_query;
44
-
45
-	/**
46
-	 * @var object \lsx_health_plan\classes\frontend\General();
47
-	 */
48
-	public $general;
49
-
50
-	/**
51
-	 * @var object \lsx_health_plan\classes\frontend\Template_Redirects();
52
-	 */
53
-	public $template_redirects;
54
-
55
-	/**
56
-	 * Constructor
57
-	 */
58
-	public function __construct() {
59
-		if ( ! is_admin() ) {
60
-			$this->load_classes();
61
-			add_action( 'template_redirect', array( $this, 'redirect' ) );
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @since 1.0.0
15
+      *
16
+      * @var      object \lsx_health_plan\classes\Frontend()
17
+      */
18
+     protected static $instance = null;
19
+
20
+     /**
21
+      * @var object \lsx_health_plan\classes\frontend\Endpoints();
22
+      */
23
+     public $endpoints;
24
+
25
+     /**
26
+      * @var object \lsx_health_plan\classes\frontend\Modals();
27
+      */
28
+     public $modals;
29
+
30
+     /**
31
+      * @var object \lsx_health_plan\classes\frontend\Gallery();
32
+      */
33
+     public $gallery;
34
+
35
+     /**
36
+      * @var object \lsx_health_plan\classes\frontend\Plan_Status();
37
+      */
38
+     public $plan_status;
39
+
40
+     /**
41
+      * @var object \lsx_health_plan\classes\frontend\Plan_Query();
42
+      */
43
+     public $plan_query;
44
+
45
+     /**
46
+      * @var object \lsx_health_plan\classes\frontend\General();
47
+      */
48
+     public $general;
49
+
50
+     /**
51
+      * @var object \lsx_health_plan\classes\frontend\Template_Redirects();
52
+      */
53
+     public $template_redirects;
54
+
55
+     /**
56
+      * Constructor
57
+      */
58
+     public function __construct() {
59
+          if ( ! is_admin() ) {
60
+               $this->load_classes();
61
+               add_action( 'template_redirect', array( $this, 'redirect' ) );
62 62
 			
63
-		}	
64
-	}
65
-
66
-	/**
67
-	 * Return an instance of this class.
68
-	 *
69
-	 * @since 1.0.0
70
-	 *
71
-	 * @return    object \lsx_health_plan\classes\Frontend()    A single instance of this class.
72
-	 */
73
-	public static function get_instance() {
74
-		// If the single instance hasn't been set, set it now.
75
-		if ( null === self::$instance ) {
76
-			self::$instance = new self();
77
-		}
78
-		return self::$instance;
79
-	}
80
-
81
-	/**
82
-	 * Loads the variable classes and the static classes.
83
-	 */
84
-	private function load_classes() {
85
-		require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-endpoints.php';
86
-		$this->endpoints = frontend\Endpoints::get_instance();
87
-
88
-		require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-modals.php';
89
-		$this->modals = Modals::get_instance();
90
-
91
-		require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-gallery.php';
92
-		$this->gallery = frontend\Gallery::get_instance();
93
-
94
-		require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-plan-status.php';
95
-		$this->plan_status = frontend\Plan_Status::get_instance();
96
-
97
-		require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-plan-query.php';
98
-		$this->plan_query = frontend\Plan_Query::get_instance();
99
-
100
-		require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-general.php';
101
-		$this->general = frontend\General::get_instance();
102
-
103
-		require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-template-redirects.php';
104
-		$this->template_redirects = frontend\Template_Redirects::get_instance();
105
-	}
106
-
107
-	/**
108
-	 * Redirect the user from the cart or checkout page if they have purchased the product already.
109
-	 *
110
-	 * @return void
111
-	 */
112
-	public function redirect() {
113
-		if ( ! is_user_logged_in() || ! function_exists( 'wc_get_page_id' ) || is_home() ) {
114
-			return;
115
-		}
116
-		if ( lsx_health_plan_user_has_purchase() && ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) ) ) {
117
-			wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) );
118
-			die;
119
-		}
120
-
121
-		$product_id = \lsx_health_plan\functions\get_option( 'membership_product', false );
122
-		if ( false !== $product_id && is_single( $product_id ) ) {
123
-			wp_redirect( home_url() );
124
-			wp_die();
125
-		}
126
-	}
63
+          }	
64
+     }
65
+
66
+     /**
67
+      * Return an instance of this class.
68
+      *
69
+      * @since 1.0.0
70
+      *
71
+      * @return    object \lsx_health_plan\classes\Frontend()    A single instance of this class.
72
+      */
73
+     public static function get_instance() {
74
+          // If the single instance hasn't been set, set it now.
75
+          if ( null === self::$instance ) {
76
+               self::$instance = new self();
77
+          }
78
+          return self::$instance;
79
+     }
80
+
81
+     /**
82
+      * Loads the variable classes and the static classes.
83
+      */
84
+     private function load_classes() {
85
+          require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-endpoints.php';
86
+          $this->endpoints = frontend\Endpoints::get_instance();
87
+
88
+          require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-modals.php';
89
+          $this->modals = Modals::get_instance();
90
+
91
+          require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-gallery.php';
92
+          $this->gallery = frontend\Gallery::get_instance();
93
+
94
+          require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-plan-status.php';
95
+          $this->plan_status = frontend\Plan_Status::get_instance();
96
+
97
+          require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-plan-query.php';
98
+          $this->plan_query = frontend\Plan_Query::get_instance();
99
+
100
+          require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-general.php';
101
+          $this->general = frontend\General::get_instance();
102
+
103
+          require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-template-redirects.php';
104
+          $this->template_redirects = frontend\Template_Redirects::get_instance();
105
+     }
106
+
107
+     /**
108
+      * Redirect the user from the cart or checkout page if they have purchased the product already.
109
+      *
110
+      * @return void
111
+      */
112
+     public function redirect() {
113
+          if ( ! is_user_logged_in() || ! function_exists( 'wc_get_page_id' ) || is_home() ) {
114
+               return;
115
+          }
116
+          if ( lsx_health_plan_user_has_purchase() && ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) ) ) {
117
+               wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) );
118
+               die;
119
+          }
120
+
121
+          $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false );
122
+          if ( false !== $product_id && is_single( $product_id ) ) {
123
+               wp_redirect( home_url() );
124
+               wp_die();
125
+          }
126
+     }
127 127
 }
Please login to merge, or discard this patch.
classes/frontend/class-endpoints.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -8,88 +8,88 @@
 block discarded – undo
8 8
  */
9 9
 class Endpoints {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\frontend\Endpoints()
17
-	 */
18
-	protected static $instance = null;
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @since 1.0.0
15
+      *
16
+      * @var      object \lsx_health_plan\classes\frontend\Endpoints()
17
+      */
18
+     protected static $instance = null;
19 19
 
20
-	/**
21
-	 * Constructor
22
-	 */
23
-	public function __construct() {
24
-		add_action( 'init', array( $this, 'setup' ) );
25
-	}
20
+     /**
21
+      * Constructor
22
+      */
23
+     public function __construct() {
24
+          add_action( 'init', array( $this, 'setup' ) );
25
+     }
26 26
 
27
-	/**
28
-	 * Return an instance of this class.
29
-	 *
30
-	 * @since 1.0.0
31
-	 *
32
-	 * @return    object \lsx_health_plan\classes\frontend\Endpoints()    A single instance of this class.
33
-	 */
34
-	public static function get_instance() {
35
-		// If the single instance hasn't been set, set it now.
36
-		if ( null === self::$instance ) {
37
-			self::$instance = new self();
38
-		}
39
-		return self::$instance;
40
-	}
27
+     /**
28
+      * Return an instance of this class.
29
+      *
30
+      * @since 1.0.0
31
+      *
32
+      * @return    object \lsx_health_plan\classes\frontend\Endpoints()    A single instance of this class.
33
+      */
34
+     public static function get_instance() {
35
+          // If the single instance hasn't been set, set it now.
36
+          if ( null === self::$instance ) {
37
+               self::$instance = new self();
38
+          }
39
+          return self::$instance;
40
+     }
41 41
 
42
-	/**
43
-	 * Runs on init
44
-	 */
45
-	public function setup() {
46
-		$this->add_rewrite_rules();
47
-	}
42
+     /**
43
+      * Runs on init
44
+      */
45
+     public function setup() {
46
+          $this->add_rewrite_rules();
47
+     }
48 48
 
49
-	/**
50
-	 * Registers the rewrites.
51
-	 */
52
-	public function add_rewrite_rules() {
53
-		// Here is where we add in the rewrite rules above the normal WP ones.
54
-		add_rewrite_tag( '%endpoint%', '([^&]+)' );
55
-		add_rewrite_tag( '%section%', '([^&]+)' );
49
+     /**
50
+      * Registers the rewrites.
51
+      */
52
+     public function add_rewrite_rules() {
53
+          // Here is where we add in the rewrite rules above the normal WP ones.
54
+          add_rewrite_tag( '%endpoint%', '([^&]+)' );
55
+          add_rewrite_tag( '%section%', '([^&]+)' );
56 56
 
57
-		// Plan Sections.
58
-		add_rewrite_rule( 'plan/([^/]+)/([^/]+)/?$', 'index.php?plan=$matches[1]&section=$matches[2]', 'top' );
57
+          // Plan Sections.
58
+          add_rewrite_rule( 'plan/([^/]+)/([^/]+)/?$', 'index.php?plan=$matches[1]&section=$matches[2]', 'top' );
59 59
 
60
-		// Warm up.
61
-		$warm_up = \lsx_health_plan\functions\get_option( 'endpoint_warm_up', false );
62
-		if ( false === $warm_up ) {
63
-			$warm_up = 'warm-up';
64
-		}
60
+          // Warm up.
61
+          $warm_up = \lsx_health_plan\functions\get_option( 'endpoint_warm_up', false );
62
+          if ( false === $warm_up ) {
63
+               $warm_up = 'warm-up';
64
+          }
65 65
 
66
-		add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $warm_up . '/?$', 'index.php?plan=$matches[1]&section=$matches[2]&endpoint=warm-up', 'top' );
66
+          add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $warm_up . '/?$', 'index.php?plan=$matches[1]&section=$matches[2]&endpoint=warm-up', 'top' );
67 67
 
68
-		// Workout.
69
-		if ( post_type_exists( 'workout' ) ) {
70
-			$workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', false );
71
-			if ( false === $workout ) {
72
-				$workout = 'workout';
73
-			}
74
-		}
75
-		add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $workout . '/?$', 'index.php?plan=$matches[1]&section=$matches[2]&endpoint=workout', 'top' );
68
+          // Workout.
69
+          if ( post_type_exists( 'workout' ) ) {
70
+               $workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', false );
71
+               if ( false === $workout ) {
72
+                    $workout = 'workout';
73
+               }
74
+          }
75
+          add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $workout . '/?$', 'index.php?plan=$matches[1]&section=$matches[2]&endpoint=workout', 'top' );
76 76
 
77
-		// Meal.
78
-		if ( post_type_exists( 'meal' ) ) {
79
-			$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false );
80
-			if ( false === $meal ) {
81
-				$meal = 'meal';
82
-			}
83
-		}
84
-		add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $meal . '/?$', 'index.php?plan=$matches[1]&section=$matches[2]&endpoint=meal', 'top' );
77
+          // Meal.
78
+          if ( post_type_exists( 'meal' ) ) {
79
+               $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false );
80
+               if ( false === $meal ) {
81
+                    $meal = 'meal';
82
+               }
83
+          }
84
+          add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $meal . '/?$', 'index.php?plan=$matches[1]&section=$matches[2]&endpoint=meal', 'top' );
85 85
 
86
-		// Recipe.
87
-		if ( post_type_exists( 'recipe' ) ) {
88
-			$recipe = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false );
89
-			if ( false === $recipe ) {
90
-				$recipe = 'recipes';
91
-			}
92
-		}
93
-		add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $recipe . '/?$', 'index.php?plan=$matches[1]&section=$matches[2]&endpoint=recipes', 'top' );
94
-	}
86
+          // Recipe.
87
+          if ( post_type_exists( 'recipe' ) ) {
88
+               $recipe = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false );
89
+               if ( false === $recipe ) {
90
+                    $recipe = 'recipes';
91
+               }
92
+          }
93
+          add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $recipe . '/?$', 'index.php?plan=$matches[1]&section=$matches[2]&endpoint=recipes', 'top' );
94
+     }
95 95
 }
Please login to merge, or discard this patch.
classes/frontend/class-plan-status.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -8,53 +8,53 @@
 block discarded – undo
8 8
  */
9 9
 class Plan_Status {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\frontend\Plan_Status()
17
-	 */
18
-	protected static $instance = null;
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @since 1.0.0
15
+      *
16
+      * @var      object \lsx_health_plan\classes\frontend\Plan_Status()
17
+      */
18
+     protected static $instance = null;
19 19
 
20
-	/**
21
-	 * Constructor
22
-	 */
23
-	public function __construct() {
24
-		add_action( 'init', array( $this, 'handle_day_action' ), 100 );
25
-	}
20
+     /**
21
+      * Constructor
22
+      */
23
+     public function __construct() {
24
+          add_action( 'init', array( $this, 'handle_day_action' ), 100 );
25
+     }
26 26
 
27
-	/**
28
-	 * Return an instance of this class.
29
-	 *
30
-	 * @since 1.0.0
31
-	 *
32
-	 * @return    object \lsx_health_plan\classes\frontend\Plan_Status()    A single instance of this class.
33
-	 */
34
-	public static function get_instance() {
35
-		// If the single instance hasn't been set, set it now.
36
-		if ( null === self::$instance ) {
37
-			self::$instance = new self();
38
-		}
39
-		return self::$instance;
40
-	}
27
+     /**
28
+      * Return an instance of this class.
29
+      *
30
+      * @since 1.0.0
31
+      *
32
+      * @return    object \lsx_health_plan\classes\frontend\Plan_Status()    A single instance of this class.
33
+      */
34
+     public static function get_instance() {
35
+          // If the single instance hasn't been set, set it now.
36
+          if ( null === self::$instance ) {
37
+               self::$instance = new self();
38
+          }
39
+          return self::$instance;
40
+     }
41 41
 
42
-	/**
43
-	 * Registers the rewrites.
44
-	 */
45
-	public function handle_day_action() {
46
-		if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'complete' ) ) {
47
-			update_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete', true );
48
-			$plan_id     = sanitize_key( $_POST['lsx-health-plan-id'] );
49
-			$plan_parent = wp_get_post_parent_id( $plan_id );
50
-			if ( 0 !== $plan_parent ) {
51
-				$plan_id = $plan_parent;
52
-			}
53
-			wp_safe_redirect( get_permalink( $plan_id ) );
54
-		}
42
+     /**
43
+      * Registers the rewrites.
44
+      */
45
+     public function handle_day_action() {
46
+          if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'complete' ) ) {
47
+               update_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete', true );
48
+               $plan_id     = sanitize_key( $_POST['lsx-health-plan-id'] );
49
+               $plan_parent = wp_get_post_parent_id( $plan_id );
50
+               if ( 0 !== $plan_parent ) {
51
+                    $plan_id = $plan_parent;
52
+               }
53
+               wp_safe_redirect( get_permalink( $plan_id ) );
54
+          }
55 55
 
56
-		if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'unlock' ) ) {
57
-			delete_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete' );
58
-		}
59
-	}
56
+          if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'unlock' ) ) {
57
+               delete_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete' );
58
+          }
59
+     }
60 60
 }
Please login to merge, or discard this patch.
classes/frontend/class-modals.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -8,68 +8,68 @@
 block discarded – undo
8 8
  */
9 9
 class Modals {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\Modals()
17
-	 */
18
-	protected static $instance = null;
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @since 1.0.0
15
+      *
16
+      * @var      object \lsx_health_plan\classes\Modals()
17
+      */
18
+     protected static $instance = null;
19 19
 
20
-	/**
21
-	 * Holds the modals to be outputted
22
-	 *
23
-	 * @var array
24
-	 */
25
-	public $modals = array();
20
+     /**
21
+      * Holds the modals to be outputted
22
+      *
23
+      * @var array
24
+      */
25
+     public $modals = array();
26 26
 
27
-	/**
28
-	 * Constructor
29
-	 */
30
-	public function __construct() {
31
-		add_action( 'wp_footer', array( $this, 'output_modals' ) );
32
-	}
27
+     /**
28
+      * Constructor
29
+      */
30
+     public function __construct() {
31
+          add_action( 'wp_footer', array( $this, 'output_modals' ) );
32
+     }
33 33
 
34
-	/**
35
-	 * Return an instance of this class.
36
-	 *
37
-	 * @since 1.0.0
38
-	 *
39
-	 * @return    object \lsx_health_plan\classes\Endpoints()    A single instance of this class.
40
-	 */
41
-	public static function get_instance() {
42
-		// If the single instance hasn't been set, set it now.
43
-		if ( null === self::$instance ) {
44
-			self::$instance = new self();
45
-		}
46
-		return self::$instance;
47
-	}
34
+     /**
35
+      * Return an instance of this class.
36
+      *
37
+      * @since 1.0.0
38
+      *
39
+      * @return    object \lsx_health_plan\classes\Endpoints()    A single instance of this class.
40
+      */
41
+     public static function get_instance() {
42
+          // If the single instance hasn't been set, set it now.
43
+          if ( null === self::$instance ) {
44
+               self::$instance = new self();
45
+          }
46
+          return self::$instance;
47
+     }
48 48
 
49
-	/**
50
-	 * Registers a modal to be outputted
51
-	 *
52
-	 * @param array $modal
53
-	 * @param string $index
54
-	 * @return void
55
-	 */
56
-	public function register_modal( $modal = array(), $index = '' ) {
57
-		if ( '' !== $index && ! empty( $modal ) ) {
58
-			$modal['id'] = $index;
59
-			$this->modals[ $index ] = $modal;
60
-		}
61
-	}
49
+     /**
50
+      * Registers a modal to be outputted
51
+      *
52
+      * @param array $modal
53
+      * @param string $index
54
+      * @return void
55
+      */
56
+     public function register_modal( $modal = array(), $index = '' ) {
57
+          if ( '' !== $index && ! empty( $modal ) ) {
58
+               $modal['id'] = $index;
59
+               $this->modals[ $index ] = $modal;
60
+          }
61
+     }
62 62
 
63
-	/**
64
-	 * Registers the rewrites.
65
-	 */
66
-	public function output_modals() {
67
-		if ( ! empty( $this->modals ) ) {
68
-			wp_enqueue_script( 'lsx-health-plan-modals', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-modals.min.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true );
63
+     /**
64
+      * Registers the rewrites.
65
+      */
66
+     public function output_modals() {
67
+          if ( ! empty( $this->modals ) ) {
68
+               wp_enqueue_script( 'lsx-health-plan-modals', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-modals.min.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true );
69 69
 
70
-			foreach ( $this->modals as $index => $modal ) {
71
-				\lsx_health_plan\functions\output_modal( $modal );
72
-			}
73
-		}
74
-	}
70
+               foreach ( $this->modals as $index => $modal ) {
71
+                    \lsx_health_plan\functions\output_modal( $modal );
72
+               }
73
+          }
74
+     }
75 75
 }
Please login to merge, or discard this patch.
classes/frontend/class-gallery.php 1 patch
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -8,264 +8,264 @@
 block discarded – undo
8 8
  */
9 9
 class Gallery {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @var object \lsx_health_plan\classes\lib\Gallery()
15
-	 */
16
-	protected static $instance = null;
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @var object \lsx_health_plan\classes\lib\Gallery()
15
+      */
16
+     protected static $instance = null;
17 17
 
18
-	/**
19
-	 * The current item ID.
20
-	 *
21
-	 * @var boolean | int
22
-	 */
23
-	public $item_id = false;
18
+     /**
19
+      * The current item ID.
20
+      *
21
+      * @var boolean | int
22
+      */
23
+     public $item_id = false;
24 24
 
25
-	/**
26
-	 * The current item post_type used in the custom field retrival..
27
-	 *
28
-	 * @var boolean | int
29
-	 */
30
-	public $post_type = false;
25
+     /**
26
+      * The current item post_type used in the custom field retrival..
27
+      *
28
+      * @var boolean | int
29
+      */
30
+     public $post_type = false;
31 31
 
32
-	/**
33
-	 * Holds the the default parameters for the gallery output.
34
-	 *
35
-	 * @var array
36
-	 */
37
-	public $defaults = array();
32
+     /**
33
+      * Holds the the default parameters for the gallery output.
34
+      *
35
+      * @var array
36
+      */
37
+     public $defaults = array();
38 38
 
39
-	/**
40
-	 * If the current post has a gallery.
41
-	 *
42
-	 * @var boolean
43
-	 */
44
-	public $has_gallery = false;
39
+     /**
40
+      * If the current post has a gallery.
41
+      *
42
+      * @var boolean
43
+      */
44
+     public $has_gallery = false;
45 45
 
46
-	/**
47
-	 * Holds the array of gallery images.
48
-	 *
49
-	 * @var array
50
-	 */
51
-	public $gallery = array();
46
+     /**
47
+      * Holds the array of gallery images.
48
+      *
49
+      * @var array
50
+      */
51
+     public $gallery = array();
52 52
 
53
-	/**
54
-	 * Holds the html for the current gallery being output.
55
-	 *
56
-	 * @var array
57
-	 */
58
-	public $html = array();
53
+     /**
54
+      * Holds the html for the current gallery being output.
55
+      *
56
+      * @var array
57
+      */
58
+     public $html = array();
59 59
 
60
-	/**
61
-	 * Holds the parameters for the current gallery being output.
62
-	 *
63
-	 * @var array
64
-	 */
65
-	public $args = array();
60
+     /**
61
+      * Holds the parameters for the current gallery being output.
62
+      *
63
+      * @var array
64
+      */
65
+     public $args = array();
66 66
 
67
-	/**
68
-	 * Constructor
69
-	 */
70
-	public function __construct() {
71
-	}
67
+     /**
68
+      * Constructor
69
+      */
70
+     public function __construct() {
71
+     }
72 72
 
73
-	/**
74
-	 * Return an instance of this class.
75
-	 *
76
-	 * @since 1.0.0
77
-	 *
78
-	 * @return    object \lsx_health_plan\classes\lib\Gallery()    A single instance of this class.
79
-	 */
80
-	public static function get_instance() {
81
-		// If the single instance hasn't been set, set it now.
82
-		if ( null === self::$instance ) {
83
-			self::$instance = new self();
84
-		}
85
-		return self::$instance;
86
-	}
73
+     /**
74
+      * Return an instance of this class.
75
+      *
76
+      * @since 1.0.0
77
+      *
78
+      * @return    object \lsx_health_plan\classes\lib\Gallery()    A single instance of this class.
79
+      */
80
+     public static function get_instance() {
81
+          // If the single instance hasn't been set, set it now.
82
+          if ( null === self::$instance ) {
83
+               self::$instance = new self();
84
+          }
85
+          return self::$instance;
86
+     }
87 87
 
88
-	/**
89
-	 * Check if the item has a gallery of images returns true or false.
90
-	 *
91
-	 * @param  string $item_id
92
-	 * @param  string $post_type
93
-	 * @return boolean
94
-	 */
95
-	public function has_gallery( $item_id = '', $post_type = '' ) {
88
+     /**
89
+      * Check if the item has a gallery of images returns true or false.
90
+      *
91
+      * @param  string $item_id
92
+      * @param  string $post_type
93
+      * @return boolean
94
+      */
95
+     public function has_gallery( $item_id = '', $post_type = '' ) {
96 96
 
97
-		if ( '' === $item_id ) {
98
-			$this->item_id = get_the_ID();
99
-		} else {
100
-			$this->item_id = $item_id;
101
-		}
102
-		$this->has_gallery = false;
103
-		if ( '' === $post_type ) {
104
-			$this->post_type = get_post_type( $this->item_id );
105
-		}
106
-		$gallery = get_post_meta( $this->item_id, $this->post_type . '_gallery', true );
97
+          if ( '' === $item_id ) {
98
+               $this->item_id = get_the_ID();
99
+          } else {
100
+               $this->item_id = $item_id;
101
+          }
102
+          $this->has_gallery = false;
103
+          if ( '' === $post_type ) {
104
+               $this->post_type = get_post_type( $this->item_id );
105
+          }
106
+          $gallery = get_post_meta( $this->item_id, $this->post_type . '_gallery', true );
107 107
 
108
-		if ( ! empty( $gallery ) && ( '' !== $gallery ) ) {
109
-			$this->gallery     = $gallery;
110
-			$this->has_gallery = true;
111
-			wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/src/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true );
112
-			wp_enqueue_script( 'lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-slider.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true );
113
-		}
114
-		return $this->has_gallery;
115
-	}
108
+          if ( ! empty( $gallery ) && ( '' !== $gallery ) ) {
109
+               $this->gallery     = $gallery;
110
+               $this->has_gallery = true;
111
+               wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/src/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true );
112
+               wp_enqueue_script( 'lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-slider.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true );
113
+          }
114
+          return $this->has_gallery;
115
+     }
116 116
 
117
-	/**
118
-	 * Returns the defaults for the gallery, after grabbing the setting from the item.
119
-	 *
120
-	 * @param  string $item_id
121
-	 * @param  string $post_type
122
-	 * @return array
123
-	 */
124
-	public function get_defaults( $item_id = '', $post_type = '' ) {
125
-		if ( '' === $item_id ) {
126
-			$item_id = $this->item_id;
127
-		}
128
-		if ( '' === $post_type ) {
129
-			$post_type = $this->post_type;
130
-		}
131
-		$this->defaults = array(
132
-			'columns'   => '3',
133
-			'layout'    => 'slider',
134
-			'interval'  => false,
135
-			'css_class' => false,
136
-		);
137
-		foreach ( $this->defaults as $key => $default ) {
138
-			$override = get_post_meta( $item_id, $this->post_type . '_gallery_' . $key, true );
139
-			if ( '' !== $override && false !== $override && ! empty( $override ) ) {
140
-				$this->defaults[ $key ] = $override;
141
-			}
142
-		}
143
-		return $this->defaults;
144
-	}
117
+     /**
118
+      * Returns the defaults for the gallery, after grabbing the setting from the item.
119
+      *
120
+      * @param  string $item_id
121
+      * @param  string $post_type
122
+      * @return array
123
+      */
124
+     public function get_defaults( $item_id = '', $post_type = '' ) {
125
+          if ( '' === $item_id ) {
126
+               $item_id = $this->item_id;
127
+          }
128
+          if ( '' === $post_type ) {
129
+               $post_type = $this->post_type;
130
+          }
131
+          $this->defaults = array(
132
+               'columns'   => '3',
133
+               'layout'    => 'slider',
134
+               'interval'  => false,
135
+               'css_class' => false,
136
+          );
137
+          foreach ( $this->defaults as $key => $default ) {
138
+               $override = get_post_meta( $item_id, $this->post_type . '_gallery_' . $key, true );
139
+               if ( '' !== $override && false !== $override && ! empty( $override ) ) {
140
+                    $this->defaults[ $key ] = $override;
141
+               }
142
+          }
143
+          return $this->defaults;
144
+     }
145 145
 
146
-	/**
147
-	 * Gets and returns the gallery html.
148
-	 *
149
-	 * @param string $item_id
150
-	 * @param string $post_type
151
-	 * @return void
152
-	 */
153
-	public function get_gallery( $item_id = '', $post_type = '', $args = array() ) {
154
-		$return     = '';
155
-		$this->html = array();
156
-		$this->args = wp_parse_args( $args, $this->get_defaults( $item_id, $post_type ) );
157
-		if ( ! empty( $this->gallery ) ) {
158
-			$this->args['count'] = 1;
159
-			if ( '' !== $post_type ) {
160
-				$this->args['post_type'] = $post_type;
161
-			} else {
162
-				$this->args['post_type'] = $this->post_type;
163
-			}
146
+     /**
147
+      * Gets and returns the gallery html.
148
+      *
149
+      * @param string $item_id
150
+      * @param string $post_type
151
+      * @return void
152
+      */
153
+     public function get_gallery( $item_id = '', $post_type = '', $args = array() ) {
154
+          $return     = '';
155
+          $this->html = array();
156
+          $this->args = wp_parse_args( $args, $this->get_defaults( $item_id, $post_type ) );
157
+          if ( ! empty( $this->gallery ) ) {
158
+               $this->args['count'] = 1;
159
+               if ( '' !== $post_type ) {
160
+                    $this->args['post_type'] = $post_type;
161
+               } else {
162
+                    $this->args['post_type'] = $this->post_type;
163
+               }
164 164
 
165
-			// output the opening boostrap row divs.
166
-			$this->before_loop();
165
+               // output the opening boostrap row divs.
166
+               $this->before_loop();
167 167
 
168
-			foreach ( $this->gallery as $key => $gallery ) {
168
+               foreach ( $this->gallery as $key => $gallery ) {
169 169
 
170
-				$this->loop_start();
170
+                    $this->loop_start();
171 171
 
172
-				if ( isset( $gallery['exercise_gallery_image_id'] ) && ! empty( $gallery['exercise_gallery_image_id'] ) ) {
173
-					$size         = apply_filters( 'lsx_hp_exercise_gallery_size', 'full' );
174
-					$thumbnail    = wp_get_attachment_image( $gallery['exercise_gallery_image_id'], $size );
175
-					$this->html[] = $thumbnail;
176
-				} elseif ( isset( $gallery['exercise_gallery_external'] ) && ! empty( $gallery['exercise_gallery_external'] ) ) {
177
-					$this->html[] = $gallery['exercise_gallery_external']; // WPCS: XSS OK.
178
-				} elseif ( isset( $gallery['exercise_gallery_embed'] ) && ! empty( $gallery['exercise_gallery_embed'] ) ) {
179
-					$embed_args = array(
180
-						'width' => '530',
181
-					);
182
-					$embed        = wp_oembed_get( $gallery['exercise_gallery_embed'], $embed_args );
183
-					$this->html[] = str_replace( 'width="530"', 'width="100%"', $embed ); // WPCS: XSS OK.
184
-				}
172
+                    if ( isset( $gallery['exercise_gallery_image_id'] ) && ! empty( $gallery['exercise_gallery_image_id'] ) ) {
173
+                         $size         = apply_filters( 'lsx_hp_exercise_gallery_size', 'full' );
174
+                         $thumbnail    = wp_get_attachment_image( $gallery['exercise_gallery_image_id'], $size );
175
+                         $this->html[] = $thumbnail;
176
+                    } elseif ( isset( $gallery['exercise_gallery_external'] ) && ! empty( $gallery['exercise_gallery_external'] ) ) {
177
+                         $this->html[] = $gallery['exercise_gallery_external']; // WPCS: XSS OK.
178
+                    } elseif ( isset( $gallery['exercise_gallery_embed'] ) && ! empty( $gallery['exercise_gallery_embed'] ) ) {
179
+                         $embed_args = array(
180
+                              'width' => '530',
181
+                         );
182
+                         $embed        = wp_oembed_get( $gallery['exercise_gallery_embed'], $embed_args );
183
+                         $this->html[] = str_replace( 'width="530"', 'width="100%"', $embed ); // WPCS: XSS OK.
184
+                    }
185 185
 
186
-				$this->loop_end();
186
+                    $this->loop_end();
187 187
 
188
-				$this->args['count']++;
189
-			}
188
+                    $this->args['count']++;
189
+               }
190 190
 
191
-			// output the closing boostrap row divs.
192
-			$this->after_loop();
193
-		}
191
+               // output the closing boostrap row divs.
192
+               $this->after_loop();
193
+          }
194 194
 
195
-		// Join the html output if its not empty.
196
-		if ( ! empty( $this->html ) ) {
197
-			$return = implode( '', $this->html );
198
-		}
199
-		return $return;
200
-	}
195
+          // Join the html output if its not empty.
196
+          if ( ! empty( $this->html ) ) {
197
+               $return = implode( '', $this->html );
198
+          }
199
+          return $return;
200
+     }
201 201
 
202
-	/**
203
-	 * Outputs the CSS class for the panels
204
-	 *
205
-	 * @param string $columns
206
-	 * @return string
207
-	 */
208
-	public function column_class() {
209
-		$cols  = 'col-xs-12 col-sm-';
210
-		$cols .= '5' === $this->args['columns'] ? '15' : 12 / $this->args['columns'];
211
-		return $cols;
212
-	}
202
+     /**
203
+      * Outputs the CSS class for the panels
204
+      *
205
+      * @param string $columns
206
+      * @return string
207
+      */
208
+     public function column_class() {
209
+          $cols  = 'col-xs-12 col-sm-';
210
+          $cols .= '5' === $this->args['columns'] ? '15' : 12 / $this->args['columns'];
211
+          return $cols;
212
+     }
213 213
 
214
-	/**
215
-	 * Runs just after the if and before the while statement in $this->output()
216
-	 */
217
-	public function before_loop() {
218
-		if ( 'slider' === $this->args['layout'] ) {
219
-			$this->carousel_id = wp_rand( 20, 20000 );
220
-			$this->html[]      = "<div class='lsx-hp-widget-items slick-slider slick-dotted slick-has-arrows {$this->args['css_class']} ' data-interval='{$this->args['interval']}' data-slick='{ \"slidesToShow\": {$this->args['columns']}, \"slidesToScroll\": {$this->args['columns']} }'>";
221
-		} else {
222
-			$this->html[] = "<div class='lsx-hp-widget-items widget-item-grid-layout'>";
223
-		}
224
-	}
214
+     /**
215
+      * Runs just after the if and before the while statement in $this->output()
216
+      */
217
+     public function before_loop() {
218
+          if ( 'slider' === $this->args['layout'] ) {
219
+               $this->carousel_id = wp_rand( 20, 20000 );
220
+               $this->html[]      = "<div class='lsx-hp-widget-items slick-slider slick-dotted slick-has-arrows {$this->args['css_class']} ' data-interval='{$this->args['interval']}' data-slick='{ \"slidesToShow\": {$this->args['columns']}, \"slidesToScroll\": {$this->args['columns']} }'>";
221
+          } else {
222
+               $this->html[] = "<div class='lsx-hp-widget-items widget-item-grid-layout'>";
223
+          }
224
+     }
225 225
 
226
-	/**
227
-	 * Runs at the very end of the loop before it runs again.
228
-	 */
229
-	public function loop_start() {
230
-		// Get the call for the active slide.
231
-		if ( 'slider' === $this->args['layout'] ) {
232
-			$this->html[] = "<div class='lsx-hp-widget-item-wrap lsx-{$this->args['post_type']}'>";
233
-		} else {
234
-			if ( 1 === $this->args['count'] ) {
235
-				$this->html[] = "<div class='row'>";
236
-			}
237
-			$this->html[] = '<div class="' . $this->column_class() . '">';
238
-		}
239
-	}
226
+     /**
227
+      * Runs at the very end of the loop before it runs again.
228
+      */
229
+     public function loop_start() {
230
+          // Get the call for the active slide.
231
+          if ( 'slider' === $this->args['layout'] ) {
232
+               $this->html[] = "<div class='lsx-hp-widget-item-wrap lsx-{$this->args['post_type']}'>";
233
+          } else {
234
+               if ( 1 === $this->args['count'] ) {
235
+                    $this->html[] = "<div class='row'>";
236
+               }
237
+               $this->html[] = '<div class="' . $this->column_class() . '">';
238
+          }
239
+     }
240 240
 
241
-	/**
242
-	 * Runs at the very end of the loop before it runs again.
243
-	 */
244
-	public function loop_end() {
245
-		if ( 'slider' !== $this->args['layout'] ) {
246
-			$this->html[] = '</div>';
247
-		}
248
-		// Close the current slide panel.
249
-		if ( 'slider' === $this->args['layout'] ) {
250
-			$this->html[] = '</div>';
251
-		} elseif ( 0 === $this->args['count'] % $this->args['columns'] || count( $this->gallery ) === $this->args['count'] ) {
252
-			$this->html[] = '</div>';
241
+     /**
242
+      * Runs at the very end of the loop before it runs again.
243
+      */
244
+     public function loop_end() {
245
+          if ( 'slider' !== $this->args['layout'] ) {
246
+               $this->html[] = '</div>';
247
+          }
248
+          // Close the current slide panel.
249
+          if ( 'slider' === $this->args['layout'] ) {
250
+               $this->html[] = '</div>';
251
+          } elseif ( 0 === $this->args['count'] % $this->args['columns'] || count( $this->gallery ) === $this->args['count'] ) {
252
+               $this->html[] = '</div>';
253 253
 
254
-			if ( $this->args['count'] < count( $this->gallery ) ) {
255
-				$this->html[] = "<div class='row'>";
256
-			}
257
-		}
258
-	}
254
+               if ( $this->args['count'] < count( $this->gallery ) ) {
255
+                    $this->html[] = "<div class='row'>";
256
+               }
257
+          }
258
+     }
259 259
 
260
-	/**
261
-	 * Runs just after the if and before the while statement in $this->output()
262
-	 */
263
-	public function after_loop() {
264
-		// Slider output Closing.
265
-		if ( 'slider' === $this->args['layout'] ) {
266
-			$this->html[] = '</div>';
267
-		} else {
268
-			$this->html[] = '</div>';
269
-		}
270
-	}
260
+     /**
261
+      * Runs just after the if and before the while statement in $this->output()
262
+      */
263
+     public function after_loop() {
264
+          // Slider output Closing.
265
+          if ( 'slider' === $this->args['layout'] ) {
266
+               $this->html[] = '</div>';
267
+          } else {
268
+               $this->html[] = '</div>';
269
+          }
270
+     }
271 271
 }
Please login to merge, or discard this patch.
classes/frontend/class-template-redirects.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -8,81 +8,81 @@
 block discarded – undo
8 8
  */
9 9
 class Template_Redirects {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\frontend\Template_Redirects()
17
-	 */
18
-	protected static $instance = null;
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @since 1.0.0
15
+      *
16
+      * @var      object \lsx_health_plan\classes\frontend\Template_Redirects()
17
+      */
18
+     protected static $instance = null;
19 19
 
20
-	/**
21
-	 * Constructor
22
-	 */
23
-	public function __construct() {
24
-		add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 );
25
-		add_filter( 'template_include', array( $this, 'single_template_include' ), 99 );
26
-		add_filter( 'template_include', array( $this, 'taxonomy_template_include' ), 99 );
27
-	}
20
+     /**
21
+      * Constructor
22
+      */
23
+     public function __construct() {
24
+          add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 );
25
+          add_filter( 'template_include', array( $this, 'single_template_include' ), 99 );
26
+          add_filter( 'template_include', array( $this, 'taxonomy_template_include' ), 99 );
27
+     }
28 28
 
29
-	/**
30
-	 * Return an instance of this class.
31
-	 *
32
-	 * @since 1.0.0
33
-	 *
34
-	 * @return    object \lsx_health_plan\classes\frontend\Template_Redirects()    A single instance of this class.
35
-	 */
36
-	public static function get_instance() {
37
-		// If the single instance hasn't been set, set it now.
38
-		if ( null === self::$instance ) {
39
-			self::$instance = new self();
40
-		}
41
-		return self::$instance;
42
-	}
29
+     /**
30
+      * Return an instance of this class.
31
+      *
32
+      * @since 1.0.0
33
+      *
34
+      * @return    object \lsx_health_plan\classes\frontend\Template_Redirects()    A single instance of this class.
35
+      */
36
+     public static function get_instance() {
37
+          // If the single instance hasn't been set, set it now.
38
+          if ( null === self::$instance ) {
39
+               self::$instance = new self();
40
+          }
41
+          return self::$instance;
42
+     }
43 43
 
44
-	/**
45
-	 * Archive template.
46
-	 */
47
-	public function archive_template_include( $template ) {
48
-		$applicable_post_types = apply_filters( 'lsx_health_plan_archive_template', array() );
49
-		if ( ! empty( $applicable_post_types ) && is_main_query() && is_post_type_archive( $applicable_post_types ) ) {
50
-			$post_type = get_post_type();
51
-			if ( empty( locate_template( array( 'archive-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php' ) ) {
52
-				$template = LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php';
53
-			}
54
-		}
55
-		return $template;
56
-	}
44
+     /**
45
+      * Archive template.
46
+      */
47
+     public function archive_template_include( $template ) {
48
+          $applicable_post_types = apply_filters( 'lsx_health_plan_archive_template', array() );
49
+          if ( ! empty( $applicable_post_types ) && is_main_query() && is_post_type_archive( $applicable_post_types ) ) {
50
+               $post_type = get_post_type();
51
+               if ( empty( locate_template( array( 'archive-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php' ) ) {
52
+                    $template = LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php';
53
+               }
54
+          }
55
+          return $template;
56
+     }
57 57
 
58
-	/**
59
-	 * Single template.
60
-	 */
61
-	public function single_template_include( $template ) {
62
-		$applicable_post_types = apply_filters( 'lsx_health_plan_single_template', array() );
63
-		if ( ! empty( $applicable_post_types ) && is_main_query() && is_singular( $applicable_post_types ) ) {
64
-			$post_type = get_post_type();
65
-			if ( empty( locate_template( array( 'single-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php' ) ) {
66
-				$template = LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php';
67
-			}
68
-		}
69
-		return $template;
70
-	}
58
+     /**
59
+      * Single template.
60
+      */
61
+     public function single_template_include( $template ) {
62
+          $applicable_post_types = apply_filters( 'lsx_health_plan_single_template', array() );
63
+          if ( ! empty( $applicable_post_types ) && is_main_query() && is_singular( $applicable_post_types ) ) {
64
+               $post_type = get_post_type();
65
+               if ( empty( locate_template( array( 'single-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php' ) ) {
66
+                    $template = LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php';
67
+               }
68
+          }
69
+          return $template;
70
+     }
71 71
 
72
-	/**
73
-	 * Redirect WordPress to the taxonomy located in the plugin
74
-	 *
75
-	 * @param     $template string
76
-	 * @return    string
77
-	 */
78
-	public function taxonomy_template_include( $template ) {
79
-		$applicable_taxonomies = apply_filters( 'lsx_health_plan_taxonomies_template', array() );
80
-		if ( is_main_query() && is_tax( $applicable_taxonomies ) ) {
81
-			$current_taxonomy = get_query_var( 'taxonomy' );
82
-			if ( '' === locate_template( array( 'taxonomy-' . $current_taxonomy . '.php' ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php' ) ) {
83
-				$template = LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php';
84
-			}
85
-		}
86
-		return $template;
87
-	}
72
+     /**
73
+      * Redirect WordPress to the taxonomy located in the plugin
74
+      *
75
+      * @param     $template string
76
+      * @return    string
77
+      */
78
+     public function taxonomy_template_include( $template ) {
79
+          $applicable_taxonomies = apply_filters( 'lsx_health_plan_taxonomies_template', array() );
80
+          if ( is_main_query() && is_tax( $applicable_taxonomies ) ) {
81
+               $current_taxonomy = get_query_var( 'taxonomy' );
82
+               if ( '' === locate_template( array( 'taxonomy-' . $current_taxonomy . '.php' ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php' ) ) {
83
+                    $template = LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php';
84
+               }
85
+          }
86
+          return $template;
87
+     }
88 88
 }
Please login to merge, or discard this patch.
classes/post-types/class-meal.php 1 patch
Indentation   +351 added lines, -351 removed lines patch added patch discarded remove patch
@@ -8,371 +8,371 @@
 block discarded – undo
8 8
  */
9 9
 class Meal {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\Meal()
17
-	 */
18
-	protected static $instance = null;
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @since 1.0.0
15
+      *
16
+      * @var      object \lsx_health_plan\classes\Meal()
17
+      */
18
+     protected static $instance = null;
19 19
 
20
-	/**
21
-	 * Holds post_type slug used as an index
22
-	 *
23
-	 * @since 1.0.0
24
-	 *
25
-	 * @var      string
26
-	 */
27
-	public $slug = 'meal';
20
+     /**
21
+      * Holds post_type slug used as an index
22
+      *
23
+      * @since 1.0.0
24
+      *
25
+      * @var      string
26
+      */
27
+     public $slug = 'meal';
28 28
 
29
-	/**
30
-	 * Constructor
31
-	 */
32
-	public function __construct() {
33
-		add_action( 'init', array( $this, 'register_post_type' ) );
34
-		add_action( 'init', array( $this, 'taxonomy_setup' ) );
35
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
36
-		add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
37
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
38
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
39
-	}
29
+     /**
30
+      * Constructor
31
+      */
32
+     public function __construct() {
33
+          add_action( 'init', array( $this, 'register_post_type' ) );
34
+          add_action( 'init', array( $this, 'taxonomy_setup' ) );
35
+          add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
36
+          add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
37
+          add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
38
+          add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
39
+     }
40 40
 
41
-	/**
42
-	 * Return an instance of this class.
43
-	 *
44
-	 * @since 1.0.0
45
-	 *
46
-	 * @return    object \lsx_health_plan\classes\Day()    A single instance of this class.
47
-	 */
48
-	public static function get_instance() {
49
-		// If the single instance hasn't been set, set it now.
50
-		if ( null === self::$instance ) {
51
-			self::$instance = new self();
52
-		}
53
-		return self::$instance;
54
-	}
55
-	/**
56
-	 * Register the post type.
57
-	 */
58
-	public function register_post_type() {
59
-		$labels = array(
60
-			'name'               => esc_html__( 'Meals', 'lsx-health-plan' ),
61
-			'singular_name'      => esc_html__( 'Meal', 'lsx-health-plan' ),
62
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
63
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
64
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
65
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
66
-			'all_items'          => esc_html__( 'All Meals', 'lsx-health-plan' ),
67
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
68
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
69
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
70
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
71
-			'parent_item_colon'  => '',
72
-			'menu_name'          => esc_html__( 'Meals', 'lsx-health-plan' ),
73
-		);
74
-		$args   = array(
75
-			'labels'             => $labels,
76
-			'public'             => true,
77
-			'publicly_queryable' => true,
78
-			'show_ui'            => true,
79
-			'show_in_menu'       => true,
80
-			'show_in_rest'       => true,
81
-			'menu_icon'          => 'dashicons-carrot',
82
-			'query_var'          => true,
83
-			'rewrite'            => array(
84
-				'slug' => \lsx_health_plan\functions\get_option( 'meal_single_slug', 'meal' ),
85
-			),
86
-			'capability_type'    => 'post',
87
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meals' ),
88
-			'hierarchical'       => true,
89
-			'menu_position'      => null,
90
-			'supports'           => array(
91
-				'title',
92
-				'editor',
93
-				'thumbnail',
94
-				'page-attributes',
95
-				'custom-fields',
96
-			),
97
-		);
98
-		register_post_type( 'meal', $args );
99
-	}
41
+     /**
42
+      * Return an instance of this class.
43
+      *
44
+      * @since 1.0.0
45
+      *
46
+      * @return    object \lsx_health_plan\classes\Day()    A single instance of this class.
47
+      */
48
+     public static function get_instance() {
49
+          // If the single instance hasn't been set, set it now.
50
+          if ( null === self::$instance ) {
51
+               self::$instance = new self();
52
+          }
53
+          return self::$instance;
54
+     }
55
+     /**
56
+      * Register the post type.
57
+      */
58
+     public function register_post_type() {
59
+          $labels = array(
60
+               'name'               => esc_html__( 'Meals', 'lsx-health-plan' ),
61
+               'singular_name'      => esc_html__( 'Meal', 'lsx-health-plan' ),
62
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
63
+               'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
64
+               'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
65
+               'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
66
+               'all_items'          => esc_html__( 'All Meals', 'lsx-health-plan' ),
67
+               'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
68
+               'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
69
+               'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
70
+               'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
71
+               'parent_item_colon'  => '',
72
+               'menu_name'          => esc_html__( 'Meals', 'lsx-health-plan' ),
73
+          );
74
+          $args   = array(
75
+               'labels'             => $labels,
76
+               'public'             => true,
77
+               'publicly_queryable' => true,
78
+               'show_ui'            => true,
79
+               'show_in_menu'       => true,
80
+               'show_in_rest'       => true,
81
+               'menu_icon'          => 'dashicons-carrot',
82
+               'query_var'          => true,
83
+               'rewrite'            => array(
84
+                    'slug' => \lsx_health_plan\functions\get_option( 'meal_single_slug', 'meal' ),
85
+               ),
86
+               'capability_type'    => 'post',
87
+               'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meals' ),
88
+               'hierarchical'       => true,
89
+               'menu_position'      => null,
90
+               'supports'           => array(
91
+                    'title',
92
+                    'editor',
93
+                    'thumbnail',
94
+                    'page-attributes',
95
+                    'custom-fields',
96
+               ),
97
+          );
98
+          register_post_type( 'meal', $args );
99
+     }
100 100
 
101
-	/**
102
-	 * Register the Week taxonomy.
103
-	 */
104
-	public function taxonomy_setup() {
105
-		$labels = array(
106
-			'name'              => esc_html_x( 'Meal Type', 'taxonomy general name', 'lsx-health-plan' ),
107
-			'singular_name'     => esc_html_x( 'Meal Types', 'taxonomy singular name', 'lsx-health-plan' ),
108
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
109
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
110
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
111
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
112
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
113
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
114
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
115
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
116
-			'menu_name'         => esc_html__( 'Meal Types', 'lsx-health-plan' ),
117
-		);
118
-		$args   = array(
119
-			'hierarchical'      => true,
120
-			'labels'            => $labels,
121
-			'show_ui'           => true,
122
-			'show_in_menu'      => 'edit.php?post_type=meal',
123
-			'show_admin_column' => true,
124
-			'query_var'         => true,
125
-			'rewrite'           => array(
126
-				'slug' => 'meal-type',
127
-			),
128
-		);
129
-		register_taxonomy( 'meal-type', array( $this->slug ), $args );
130
-	}
101
+     /**
102
+      * Register the Week taxonomy.
103
+      */
104
+     public function taxonomy_setup() {
105
+          $labels = array(
106
+               'name'              => esc_html_x( 'Meal Type', 'taxonomy general name', 'lsx-health-plan' ),
107
+               'singular_name'     => esc_html_x( 'Meal Types', 'taxonomy singular name', 'lsx-health-plan' ),
108
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
109
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
110
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
111
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
112
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
113
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
114
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
115
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
116
+               'menu_name'         => esc_html__( 'Meal Types', 'lsx-health-plan' ),
117
+          );
118
+          $args   = array(
119
+               'hierarchical'      => true,
120
+               'labels'            => $labels,
121
+               'show_ui'           => true,
122
+               'show_in_menu'      => 'edit.php?post_type=meal',
123
+               'show_admin_column' => true,
124
+               'query_var'         => true,
125
+               'rewrite'           => array(
126
+                    'slug' => 'meal-type',
127
+               ),
128
+          );
129
+          register_taxonomy( 'meal-type', array( $this->slug ), $args );
130
+     }
131 131
 
132
-	/**
133
-	 * Adds the post type to the different arrays.
134
-	 *
135
-	 * @param array $post_types
136
-	 * @return array
137
-	 */
138
-	public function enable_post_type( $post_types = array() ) {
139
-		$post_types[] = $this->slug;
140
-		return $post_types;
141
-	}
132
+     /**
133
+      * Adds the post type to the different arrays.
134
+      *
135
+      * @param array $post_types
136
+      * @return array
137
+      */
138
+     public function enable_post_type( $post_types = array() ) {
139
+          $post_types[] = $this->slug;
140
+          return $post_types;
141
+     }
142 142
 
143
-	/**
144
-	 * Enables the Bi Directional relationships
145
-	 *
146
-	 * @param array $connections
147
-	 * @return void
148
-	 */
149
-	public function enable_connections( $connections = array() ) {
150
-		$connections['meal']['connected_plans'] = 'connected_meals';
151
-		$connections['plan']['connected_meals'] = 'connected_plans';
152
-		return $connections;
153
-	}
143
+     /**
144
+      * Enables the Bi Directional relationships
145
+      *
146
+      * @param array $connections
147
+      * @return void
148
+      */
149
+     public function enable_connections( $connections = array() ) {
150
+          $connections['meal']['connected_plans'] = 'connected_meals';
151
+          $connections['plan']['connected_meals'] = 'connected_plans';
152
+          return $connections;
153
+     }
154 154
 
155
-	/**
156
-	 * Define the metabox and field configurations.
157
-	 */
158
-	public function featured_metabox() {
159
-		$cmb = new_cmb2_box(
160
-			array(
161
-				'id'           => $this->slug . '_featured_metabox_meal',
162
-				'title'        => __( 'Featured Meal', 'lsx-health-plan' ),
163
-				'object_types' => array( $this->slug ), // Post type
164
-				'context'      => 'side',
165
-				'priority'     => 'high',
166
-				'show_names'   => true,
167
-			)
168
-		);
169
-		$cmb->add_field(
170
-			array(
171
-				'name'       => __( 'Featured Meal', 'lsx-health-plan' ),
172
-				'desc'       => __( 'Enable a featured meal' ),
173
-				'id'         => $this->slug . '_featured_meal',
174
-				'type'       => 'checkbox',
175
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
176
-			)
177
-		);
178
-	}
155
+     /**
156
+      * Define the metabox and field configurations.
157
+      */
158
+     public function featured_metabox() {
159
+          $cmb = new_cmb2_box(
160
+               array(
161
+                    'id'           => $this->slug . '_featured_metabox_meal',
162
+                    'title'        => __( 'Featured Meal', 'lsx-health-plan' ),
163
+                    'object_types' => array( $this->slug ), // Post type
164
+                    'context'      => 'side',
165
+                    'priority'     => 'high',
166
+                    'show_names'   => true,
167
+               )
168
+          );
169
+          $cmb->add_field(
170
+               array(
171
+                    'name'       => __( 'Featured Meal', 'lsx-health-plan' ),
172
+                    'desc'       => __( 'Enable a featured meal' ),
173
+                    'id'         => $this->slug . '_featured_meal',
174
+                    'type'       => 'checkbox',
175
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
176
+               )
177
+          );
178
+     }
179 179
 
180
-	/**
181
-	 * Define the metabox and field configurations.
182
-	 */
183
-	public function details_metaboxes() {
184
-		$cmb = new_cmb2_box( array(
185
-			'id'           => $this->slug . '_shopping_list_metabox',
186
-			'title'        => __( 'Shopping List', 'lsx-health-plan' ),
187
-			'object_types' => array( $this->slug ), // Post type
188
-			'context'      => 'normal',
189
-			'priority'     => 'high',
190
-			'show_names'   => true,
191
-		) );
192
-		$cmb->add_field( array(
193
-			'name'       => __( 'Shopping List', 'lsx-health-plan' ),
194
-			'desc'       => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ),
195
-			'id'         => $this->slug . '_shopping_list',
196
-			'type'       => 'post_search_ajax',
197
-			// Optional :
198
-			'limit'      => 1,  // Limit selection to X items only (default 1)
199
-			'sortable'   => true, // Allow selected items to be sortable (default false)
200
-			'query_args' => array(
201
-				'post_type'      => array( 'page' ),
202
-				'post_status'    => array( 'publish' ),
203
-				'posts_per_page' => -1,
204
-			),
205
-		) );
206
-		$cmb = new_cmb2_box( array(
207
-			'id'           => $this->slug . '_details_metabox',
208
-			'title'        => __( 'Meal Details', 'lsx-health-plan' ),
209
-			'object_types' => array( $this->slug ), // Post type
210
-			'context'      => 'normal',
211
-			'priority'     => 'high',
212
-			'show_names'   => true,
213
-		) );
180
+     /**
181
+      * Define the metabox and field configurations.
182
+      */
183
+     public function details_metaboxes() {
184
+          $cmb = new_cmb2_box( array(
185
+               'id'           => $this->slug . '_shopping_list_metabox',
186
+               'title'        => __( 'Shopping List', 'lsx-health-plan' ),
187
+               'object_types' => array( $this->slug ), // Post type
188
+               'context'      => 'normal',
189
+               'priority'     => 'high',
190
+               'show_names'   => true,
191
+          ) );
192
+          $cmb->add_field( array(
193
+               'name'       => __( 'Shopping List', 'lsx-health-plan' ),
194
+               'desc'       => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ),
195
+               'id'         => $this->slug . '_shopping_list',
196
+               'type'       => 'post_search_ajax',
197
+               // Optional :
198
+               'limit'      => 1,  // Limit selection to X items only (default 1)
199
+               'sortable'   => true, // Allow selected items to be sortable (default false)
200
+               'query_args' => array(
201
+                    'post_type'      => array( 'page' ),
202
+                    'post_status'    => array( 'publish' ),
203
+                    'posts_per_page' => -1,
204
+               ),
205
+          ) );
206
+          $cmb = new_cmb2_box( array(
207
+               'id'           => $this->slug . '_details_metabox',
208
+               'title'        => __( 'Meal Details', 'lsx-health-plan' ),
209
+               'object_types' => array( $this->slug ), // Post type
210
+               'context'      => 'normal',
211
+               'priority'     => 'high',
212
+               'show_names'   => true,
213
+          ) );
214 214
 
215
-		$cmb->add_field( array(
216
-			'name' => __( 'Meal Short Description', 'lsx-health-plan' ),
217
-			'id'   => $this->slug . '_short_description',
218
-			'type' => 'textarea_small',
219
-			'desc' => __( 'Add a small description for this meal (optional)', 'lsx-health-plan' ),
220
-		) );
215
+          $cmb->add_field( array(
216
+               'name' => __( 'Meal Short Description', 'lsx-health-plan' ),
217
+               'id'   => $this->slug . '_short_description',
218
+               'type' => 'textarea_small',
219
+               'desc' => __( 'Add a small description for this meal (optional)', 'lsx-health-plan' ),
220
+          ) );
221 221
 
222
-		$cmb->add_field( array(
223
-			'name'       => __( 'Pre Breakfast Snack', 'lsx-health-plan' ),
224
-			'id'         => $this->slug . '_pre_breakfast_snack',
225
-			'type'       => 'wysiwyg',
226
-			'show_on_cb' => 'cmb2_hide_if_no_cats',
227
-			'options'    => array(
228
-				'textarea_rows' => 5,
229
-			),
230
-		) );
231
-		$cmb->add_field( array(
232
-			'name'       => __( 'Breakfast', 'lsx-health-plan' ),
233
-			'id'         => $this->slug . '_breakfast',
234
-			'type'       => 'wysiwyg',
235
-			'show_on_cb' => 'cmb2_hide_if_no_cats',
236
-			'options'    => array(
237
-				'textarea_rows' => 5,
238
-			),
239
-		) );
222
+          $cmb->add_field( array(
223
+               'name'       => __( 'Pre Breakfast Snack', 'lsx-health-plan' ),
224
+               'id'         => $this->slug . '_pre_breakfast_snack',
225
+               'type'       => 'wysiwyg',
226
+               'show_on_cb' => 'cmb2_hide_if_no_cats',
227
+               'options'    => array(
228
+                    'textarea_rows' => 5,
229
+               ),
230
+          ) );
231
+          $cmb->add_field( array(
232
+               'name'       => __( 'Breakfast', 'lsx-health-plan' ),
233
+               'id'         => $this->slug . '_breakfast',
234
+               'type'       => 'wysiwyg',
235
+               'show_on_cb' => 'cmb2_hide_if_no_cats',
236
+               'options'    => array(
237
+                    'textarea_rows' => 5,
238
+               ),
239
+          ) );
240 240
 
241
-		$cmb->add_field(
242
-			array(
243
-				'name'       => __( 'Post Breakfast Snack', 'lsx-health-plan' ),
244
-				'id'         => $this->slug . '_breakfast_snack',
245
-				'type'       => 'wysiwyg',
246
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
247
-				'options'    => array(
248
-					'textarea_rows' => 5,
249
-				),
250
-			)
251
-		);
241
+          $cmb->add_field(
242
+               array(
243
+                    'name'       => __( 'Post Breakfast Snack', 'lsx-health-plan' ),
244
+                    'id'         => $this->slug . '_breakfast_snack',
245
+                    'type'       => 'wysiwyg',
246
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
247
+                    'options'    => array(
248
+                         'textarea_rows' => 5,
249
+                    ),
250
+               )
251
+          );
252 252
 
253
-		if ( post_type_exists( 'recipe' ) ) {
254
-			$cmb->add_field(
255
-				array(
256
-					'name'       => __( 'Breakfast Recipes', 'lsx-health-plan' ),
257
-					'desc'       => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ),
258
-					'id'         => 'breakfast_recipes',
259
-					'type'       => 'post_search_ajax',
260
-					// Optional :
261
-					'limit'      => 15,  // Limit selection to X items only (default 1)
262
-					'sortable'   => true, // Allow selected items to be sortable (default false)
263
-					'query_args' => array(
264
-						'post_type'      => array( 'recipe' ),
265
-						'post_status'    => array( 'publish' ),
266
-						'posts_per_page' => -1,
267
-					),
268
-				)
269
-			);
270
-		}
253
+          if ( post_type_exists( 'recipe' ) ) {
254
+               $cmb->add_field(
255
+                    array(
256
+                         'name'       => __( 'Breakfast Recipes', 'lsx-health-plan' ),
257
+                         'desc'       => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ),
258
+                         'id'         => 'breakfast_recipes',
259
+                         'type'       => 'post_search_ajax',
260
+                         // Optional :
261
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
262
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
263
+                         'query_args' => array(
264
+                              'post_type'      => array( 'recipe' ),
265
+                              'post_status'    => array( 'publish' ),
266
+                              'posts_per_page' => -1,
267
+                         ),
268
+                    )
269
+               );
270
+          }
271 271
 
272
-		$cmb->add_field(
273
-			array(
274
-				'name'       => __( 'Pre Lunch Snack', 'lsx-health-plan' ),
275
-				'id'         => $this->slug . '_pre_lunch_snack',
276
-				'type'       => 'wysiwyg',
277
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
278
-				'options'    => array(
279
-					'textarea_rows' => 5,
280
-				),
281
-			)
282
-		);
283
-		$cmb->add_field(
284
-			array(
285
-				'name'       => __( 'Lunch', 'lsx-health-plan' ),
286
-				'id'         => $this->slug . '_lunch',
287
-				'type'       => 'wysiwyg',
288
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
289
-				'options'    => array(
290
-					'textarea_rows' => 5,
291
-				),
292
-			)
293
-		);
294
-		$cmb->add_field(
295
-			array(
296
-				'name'       => __( 'Post Lunch Snack', 'lsx-health-plan' ),
297
-				'id'         => $this->slug . '_lunch_snack',
298
-				'type'       => 'wysiwyg',
299
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
300
-				'options'    => array(
301
-					'textarea_rows' => 5,
302
-				),
303
-			)
304
-		);
272
+          $cmb->add_field(
273
+               array(
274
+                    'name'       => __( 'Pre Lunch Snack', 'lsx-health-plan' ),
275
+                    'id'         => $this->slug . '_pre_lunch_snack',
276
+                    'type'       => 'wysiwyg',
277
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
278
+                    'options'    => array(
279
+                         'textarea_rows' => 5,
280
+                    ),
281
+               )
282
+          );
283
+          $cmb->add_field(
284
+               array(
285
+                    'name'       => __( 'Lunch', 'lsx-health-plan' ),
286
+                    'id'         => $this->slug . '_lunch',
287
+                    'type'       => 'wysiwyg',
288
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
289
+                    'options'    => array(
290
+                         'textarea_rows' => 5,
291
+                    ),
292
+               )
293
+          );
294
+          $cmb->add_field(
295
+               array(
296
+                    'name'       => __( 'Post Lunch Snack', 'lsx-health-plan' ),
297
+                    'id'         => $this->slug . '_lunch_snack',
298
+                    'type'       => 'wysiwyg',
299
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
300
+                    'options'    => array(
301
+                         'textarea_rows' => 5,
302
+                    ),
303
+               )
304
+          );
305 305
 
306
-		if ( post_type_exists( 'recipe' ) ) {
307
-			$cmb->add_field(
308
-				array(
309
-					'name'       => __( 'Lunch Recipes', 'lsx-health-plan' ),
310
-					'desc'       => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ),
311
-					'id'         => 'lunch_recipes',
312
-					'type'       => 'post_search_ajax',
313
-					// Optional :
314
-					'limit'      => 15,  // Limit selection to X items only (default 1)
315
-					'sortable'   => true, // Allow selected items to be sortable (default false)
316
-					'query_args' => array(
317
-						'post_type'      => array( 'recipe' ),
318
-						'post_status'    => array( 'publish' ),
319
-						'posts_per_page' => -1,
320
-					),
321
-				)
322
-			);
323
-		}
306
+          if ( post_type_exists( 'recipe' ) ) {
307
+               $cmb->add_field(
308
+                    array(
309
+                         'name'       => __( 'Lunch Recipes', 'lsx-health-plan' ),
310
+                         'desc'       => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ),
311
+                         'id'         => 'lunch_recipes',
312
+                         'type'       => 'post_search_ajax',
313
+                         // Optional :
314
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
315
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
316
+                         'query_args' => array(
317
+                              'post_type'      => array( 'recipe' ),
318
+                              'post_status'    => array( 'publish' ),
319
+                              'posts_per_page' => -1,
320
+                         ),
321
+                    )
322
+               );
323
+          }
324 324
 
325
-		$cmb->add_field(
326
-			array(
327
-				'name'       => __( 'Pre Dinner Snack', 'lsx-health-plan' ),
328
-				'id'         => $this->slug . '_pre_dinner_snack',
329
-				'type'       => 'wysiwyg',
330
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
331
-				'options'    => array(
332
-					'textarea_rows' => 5,
333
-				),
334
-			)
335
-		);
336
-		$cmb->add_field(
337
-			array(
338
-				'name'       => __( 'Dinner', 'lsx-health-plan' ),
339
-				'id'         => $this->slug . '_dinner',
340
-				'type'       => 'wysiwyg',
341
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
342
-				'options'    => array(
343
-					'textarea_rows' => 5,
344
-				),
345
-			)
346
-		);
347
-		$cmb->add_field(
348
-			array(
349
-				'name'       => __( 'Post Dinner Snack', 'lsx-health-plan' ),
350
-				'id'         => $this->slug . '_dinner_snack',
351
-				'type'       => 'wysiwyg',
352
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
353
-				'options'    => array(
354
-					'textarea_rows' => 5,
355
-				),
356
-			)
357
-		);
325
+          $cmb->add_field(
326
+               array(
327
+                    'name'       => __( 'Pre Dinner Snack', 'lsx-health-plan' ),
328
+                    'id'         => $this->slug . '_pre_dinner_snack',
329
+                    'type'       => 'wysiwyg',
330
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
331
+                    'options'    => array(
332
+                         'textarea_rows' => 5,
333
+                    ),
334
+               )
335
+          );
336
+          $cmb->add_field(
337
+               array(
338
+                    'name'       => __( 'Dinner', 'lsx-health-plan' ),
339
+                    'id'         => $this->slug . '_dinner',
340
+                    'type'       => 'wysiwyg',
341
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
342
+                    'options'    => array(
343
+                         'textarea_rows' => 5,
344
+                    ),
345
+               )
346
+          );
347
+          $cmb->add_field(
348
+               array(
349
+                    'name'       => __( 'Post Dinner Snack', 'lsx-health-plan' ),
350
+                    'id'         => $this->slug . '_dinner_snack',
351
+                    'type'       => 'wysiwyg',
352
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
353
+                    'options'    => array(
354
+                         'textarea_rows' => 5,
355
+                    ),
356
+               )
357
+          );
358 358
 
359
-		if ( post_type_exists( 'recipe' ) ) {
360
-			$cmb->add_field(
361
-				array(
362
-					'name'       => __( 'Dinner Recipes', 'lsx-health-plan' ),
363
-					'desc'       => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ),
364
-					'id'         => 'dinner_recipes',
365
-					'type'       => 'post_search_ajax',
366
-					// Optional :
367
-					'limit'      => 15,  // Limit selection to X items only (default 1)
368
-					'sortable'   => true, // Allow selected items to be sortable (default false)
369
-					'query_args' => array(
370
-						'post_type'      => array( 'recipe' ),
371
-						'post_status'    => array( 'publish' ),
372
-						'posts_per_page' => -1,
373
-					),
374
-				)
375
-			);
376
-		}
377
-	}
359
+          if ( post_type_exists( 'recipe' ) ) {
360
+               $cmb->add_field(
361
+                    array(
362
+                         'name'       => __( 'Dinner Recipes', 'lsx-health-plan' ),
363
+                         'desc'       => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ),
364
+                         'id'         => 'dinner_recipes',
365
+                         'type'       => 'post_search_ajax',
366
+                         // Optional :
367
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
368
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
369
+                         'query_args' => array(
370
+                              'post_type'      => array( 'recipe' ),
371
+                              'post_status'    => array( 'publish' ),
372
+                              'posts_per_page' => -1,
373
+                         ),
374
+                    )
375
+               );
376
+          }
377
+     }
378 378
 }
Please login to merge, or discard this patch.