Passed
Push — add/multiplan ( dea22a...7aa48d )
by Virginia
10:43
created
includes/functions.php 1 patch
Indentation   +277 added lines, -277 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,46 +337,46 @@  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 = '';
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 = '';
345
+          $terms_ids    = wp_list_pluck( $term_obj_list, 'term_id' );
346 346
 		
347
-		foreach ( $term_obj_list as $term ) {
348
-			$term_link = get_term_link( $term );
349
-			$term_name = '<a href="' . $term_link . '">' .$term->name . '<span>, </span></a>';
347
+          foreach ( $term_obj_list as $term ) {
348
+               $term_link = get_term_link( $term );
349
+               $term_name = '<a href="' . $term_link . '">' .$term->name . '<span>, </span></a>';
350 350
 			
351
-			$terms_string .= $term_name;
352
-		}
351
+               $terms_string .= $term_name;
352
+          }
353 353
 		
354
-		foreach ( $terms_ids as $terms_id ) {
355
-			$term_thumbnail_id = get_term_meta( $terms_id, 'thumbnail', true );
356
-			$img               = wp_get_attachment_image_src( $term_thumbnail_id, 'thumbnail' );
357
-			if ( ! empty( $img ) ) {
358
-				$image_url = $img[0];
359
-				$img       = '<img loading="lazy" alt="thumbnail" style="width:24px; height: auto;" class="attachment-responsive wp-post-image lsx-responsive" src="' . esc_url( $image_url ) . '" />';
360
-			}
354
+          foreach ( $terms_ids as $terms_id ) {
355
+               $term_thumbnail_id = get_term_meta( $terms_id, 'thumbnail', true );
356
+               $img               = wp_get_attachment_image_src( $term_thumbnail_id, 'thumbnail' );
357
+               if ( ! empty( $img ) ) {
358
+                    $image_url = $img[0];
359
+                    $img       = '<img loading="lazy" alt="thumbnail" style="width:24px; height: auto;" class="attachment-responsive wp-post-image lsx-responsive" src="' . esc_url( $image_url ) . '" />';
360
+               }
361 361
 
362
-			$plan_meta .= $img;
363
-		}
362
+               $plan_meta .= $img;
363
+          }
364 364
 
365
-		$plan_meta = '<div class="plan-meta">' . $plan_meta . '<span>' . $terms_string . '</span></div>';
366
-	}
365
+          $plan_meta = '<div class="plan-meta">' . $plan_meta . '<span>' . $terms_string . '</span></div>';
366
+     }
367 367
 
368
-	return $plan_meta;
368
+     return $plan_meta;
369 369
 }
370 370
 
371 371
 /**
372 372
  * Limit media library access
373 373
  */
374 374
 function set_only_author( $wp_query ) {
375
-	global $current_user;
376
-	if ( is_admin() && ! current_user_can( 'edit_others_posts' ) ) {
377
-		$wp_query->set( 'administrator', $current_user->ID );
378
-		add_filter( 'views_upload', 'fix_media_counts' );
379
-	}
375
+     global $current_user;
376
+     if ( is_admin() && ! current_user_can( 'edit_others_posts' ) ) {
377
+          $wp_query->set( 'administrator', $current_user->ID );
378
+          add_filter( 'views_upload', 'fix_media_counts' );
379
+     }
380 380
 }
381 381
 add_action( 'pre_get_posts', '\lsx_health_plan\functions\set_only_author' );
382 382
 
@@ -387,12 +387,12 @@  discard block
 block discarded – undo
387 387
  * @return void
388 388
  */
389 389
 function hp_excerpt( $post_id ) {
390
-	if ( ! has_excerpt( $post_id ) ) {
391
-		$content = wp_trim_words( get_post_field( 'post_content', $post_id ), 10 );
392
-	} else {
393
-		$content = get_the_excerpt( $post_id );
394
-	}
395
-	return $content;
390
+     if ( ! has_excerpt( $post_id ) ) {
391
+          $content = wp_trim_words( get_post_field( 'post_content', $post_id ), 10 );
392
+     } else {
393
+          $content = get_the_excerpt( $post_id );
394
+     }
395
+     return $content;
396 396
 }
397 397
 
398 398
 /**
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
  * @return void
403 403
  */
404 404
 function column_class( $columns = '3' ) {
405
-	$cols  = '';
406
-	$cols .= '5' === $columns ? '15' : 12 / $columns;
407
-	return $cols;
405
+     $cols  = '';
406
+     $cols .= '5' === $columns ? '15' : 12 / $columns;
407
+     return $cols;
408 408
 }
409 409
 
410 410
 /**
@@ -414,22 +414,22 @@  discard block
 block discarded – undo
414 414
  * @return void
415 415
  */
416 416
 function get_exercises_by_workout( $workout = '' ) {
417
-	$exercises = array();
418
-	$i               = 1;
419
-	$section_counter = 6;
420
-	while ( $i <= $section_counter ) {
421
-		$group_name = 'workout_section_' . $i;
422
-		$groups     = get_post_meta( $workout, $group_name, true );
423
-		if ( ! empty( $groups ) ) {
424
-			foreach ( $groups as $group ) {
425
-				if ( isset( $group['connected_exercises'] ) ) {
426
-					$exercises[] = $group['connected_exercises'];
427
-				}
428
-			}
429
-		}
430
-		$i++;
431
-	}
432
-	return $exercises;
417
+     $exercises = array();
418
+     $i               = 1;
419
+     $section_counter = 6;
420
+     while ( $i <= $section_counter ) {
421
+          $group_name = 'workout_section_' . $i;
422
+          $groups     = get_post_meta( $workout, $group_name, true );
423
+          if ( ! empty( $groups ) ) {
424
+               foreach ( $groups as $group ) {
425
+                    if ( isset( $group['connected_exercises'] ) ) {
426
+                         $exercises[] = $group['connected_exercises'];
427
+                    }
428
+               }
429
+          }
430
+          $i++;
431
+     }
432
+     return $exercises;
433 433
 }
434 434
 
435 435
 
@@ -440,20 +440,20 @@  discard block
 block discarded – undo
440 440
  * @return int
441 441
  */
442 442
 function get_progress( $plan_id = false ) {
443
-	$progress = 0;
444
-	$complete = array();
445
-	$count    = 0;
446
-	if ( false !== $plan_id &&  \lsx_health_plan\functions\plan\has_sections( $plan_id ) ) {
447
-		$sections = \lsx_health_plan\functions\plan\get_sections();
448
-		$all_count = count( $sections );
449
-		foreach ( $sections as $section_key => $section_values ) {
450
-			if ( lsx_health_plan_is_day_complete( $plan_id, $section_values['title'] ) ) {
451
-				$complete[] = true;
452
-			}
453
-		}
454
-		$progress = (int) count( $complete ) / (int) $all_count * 100;
455
-	}
456
-	return $progress;
443
+     $progress = 0;
444
+     $complete = array();
445
+     $count    = 0;
446
+     if ( false !== $plan_id &&  \lsx_health_plan\functions\plan\has_sections( $plan_id ) ) {
447
+          $sections = \lsx_health_plan\functions\plan\get_sections();
448
+          $all_count = count( $sections );
449
+          foreach ( $sections as $section_key => $section_values ) {
450
+               if ( lsx_health_plan_is_day_complete( $plan_id, $section_values['title'] ) ) {
451
+                    $complete[] = true;
452
+               }
453
+          }
454
+          $progress = (int) count( $complete ) / (int) $all_count * 100;
455
+     }
456
+     return $progress;
457 457
 }
458 458
 
459 459
 
@@ -464,18 +464,18 @@  discard block
 block discarded – undo
464 464
  * @return void
465 465
  */
466 466
 function hp_back_archive_link() {
467
-	global $wp_taxonomies;
467
+     global $wp_taxonomies;
468 468
 	
469
-	$post_type = get_queried_object()->taxonomy;
470
-	$post_type = $wp_taxonomies[$post_type]->object_type;
469
+     $post_type = get_queried_object()->taxonomy;
470
+     $post_type = $wp_taxonomies[$post_type]->object_type;
471 471
 
472
-	if ( is_tax() ) {
473
-		?>
472
+     if ( is_tax() ) {
473
+          ?>
474 474
 		<div class="archive-category-title hp-archive-category-title">
475 475
 			<a class="back-to-blog" href="<?php echo ( esc_url( get_post_type_archive_link( $post_type[0] ) ) ); ?>"><?php echo esc_html__( 'Back To ', 'lsx' ) . esc_html( $post_type[0] ) . 's'; ?></a>
476 476
 		</div>
477 477
 		<?php
478
-	}
478
+     }
479 479
 }
480 480
 add_action( 'lsx_content_wrap_before', '\lsx_health_plan\functions\hp_back_archive_link', 20 );
481 481
 
@@ -486,11 +486,11 @@  discard block
 block discarded – undo
486 486
  * @return array
487 487
  */
488 488
 function prep_array( $item ) {
489
-	if ( ! is_array( $item ) ) {
490
-		$item = explode( ',', $item );
491
-		if ( ! is_array( $item ) ) {
492
-			$item = array( $item );
493
-		}
494
-	}
495
-	return $item;
489
+     if ( ! is_array( $item ) ) {
490
+          $item = explode( ',', $item );
491
+          if ( ! is_array( $item ) ) {
492
+               $item = array( $item );
493
+          }
494
+     }
495
+     return $item;
496 496
 }
Please login to merge, or discard this patch.
templates/tab-content-workout.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,18 +24,18 @@  discard block
 block discarded – undo
24 24
 		<?php lsx_post_meta_single_bottom(); ?>
25 25
 	</div><!-- .entry-meta -->
26 26
 	<?php
27
-		the_content();
28
-	?>
27
+          the_content();
28
+     ?>
29 29
 	<div class="entry-content">
30 30
 		<div class="single-plan-inner workout-content">
31 31
 			<?php
32
-			if ( is_singular( 'workout' ) ) { ?>
32
+               if ( is_singular( 'workout' ) ) { ?>
33 33
 				<div class="single-plan-section-title workout title-lined">
34 34
 					<?php lsx_get_svg_icon( 'work.svg' ); ?>
35 35
 					<h2><?php the_title(); ?></h2>
36 36
 					<?php if ( class_exists( 'LSX_Sharing' ) ) {
37
-						lsx_content_sharing();
38
-					} ?>
37
+                              lsx_content_sharing();
38
+                         } ?>
39 39
 				</div>
40 40
 			<?php } else { ?>
41 41
 				<div class="single-plan-section-title workout title-lined">
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 				</div>
45 45
 			<?php } ?>
46 46
 			<?php
47
-			if ( lsx_health_plan_has_warmup() && ( ! is_singular( 'workout' ) ) ) {
48
-				?>
47
+               if ( lsx_health_plan_has_warmup() && ( ! is_singular( 'workout' ) ) ) {
48
+                    ?>
49 49
 				<div class="workout-instructions">
50 50
 					<div class="row">
51 51
 						<div class="col-md-12">
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 					</div>
58 58
 				</div>
59 59
 				<?php
60
-			}
61
-			?>
60
+               }
61
+               ?>
62 62
 
63 63
 			<?php lsx_health_plan_workout_sets(); ?>
64 64
 		</div>
@@ -74,5 +74,5 @@  discard block
 block discarded – undo
74 74
 <?php } ?>
75 75
 <?php
76 76
 if ( ! empty( $connected_articles ) ) {
77
-	lsx_hp_single_related( $connected_articles, __( 'Related articles', 'lsx-health-plan' ) );
77
+     lsx_hp_single_related( $connected_articles, __( 'Related articles', 'lsx-health-plan' ) );
78 78
 }
Please login to merge, or discard this patch.
templates/tab-content-warm-up.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@  discard block
 block discarded – undo
8 8
 
9 9
 $warm_up = get_post_meta( get_the_ID(), 'plan_warmup', true );
10 10
 if ( false === $warm_up || '' === $warm_up ) {
11
-	$options = \lsx_health_plan\functions\get_option( 'all' );
12
-	if ( isset( $options['plan_warmup'] ) && '' !== $options['plan_warmup'] && ! empty( $options['plan_warmup'] ) ) {
13
-		$warm_up = $options['plan_warmup'];
14
-	}
11
+     $options = \lsx_health_plan\functions\get_option( 'all' );
12
+     if ( isset( $options['plan_warmup'] ) && '' !== $options['plan_warmup'] && ! empty( $options['plan_warmup'] ) ) {
13
+          $warm_up = $options['plan_warmup'];
14
+     }
15 15
 }
16 16
 
17 17
 ?>
@@ -19,30 +19,30 @@  discard block
 block discarded – undo
19 19
 <?php
20 20
 
21 21
 if ( false !== $warm_up && '' !== $warm_up ) {
22
-	if ( ! is_array( $warm_up ) ) {
23
-		$warm_up = array( $warm_up );
24
-	}
22
+     if ( ! is_array( $warm_up ) ) {
23
+          $warm_up = array( $warm_up );
24
+     }
25 25
 
26
-	$warmup_type  = array( 'page', 'workout', 'exercise' );
27
-	$warmup_query = new WP_Query(
28
-		array(
29
-			'post__in'  => $warm_up,
30
-			'post_type' => $warmup_type,
31
-		)
32
-	);
26
+     $warmup_type  = array( 'page', 'workout', 'exercise' );
27
+     $warmup_query = new WP_Query(
28
+          array(
29
+               'post__in'  => $warm_up,
30
+               'post_type' => $warmup_type,
31
+          )
32
+     );
33 33
 
34
-	if ( $warmup_query->have_posts() ) {
35
-		while ( $warmup_query->have_posts() ) {
36
-			$warmup_query->the_post();
37
-			lsx_entry_before();
38
-			if ( 'workout' === get_post_type() ) {
39
-				$connected_workouts = array( get_the_ID() );
40
-				?>
34
+     if ( $warmup_query->have_posts() ) {
35
+          while ( $warmup_query->have_posts() ) {
36
+               $warmup_query->the_post();
37
+               lsx_entry_before();
38
+               if ( 'workout' === get_post_type() ) {
39
+                    $connected_workouts = array( get_the_ID() );
40
+                    ?>
41 41
 				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
42 42
 					<?php lsx_entry_top(); ?>
43 43
 					<?php
44
-						the_content();
45
-					?>
44
+                              the_content();
45
+                         ?>
46 46
 					<div class="entry-content">
47 47
 						<div class="single-plan-inner warmup-content">
48 48
 							<div class="single-plan-section-title warmup-plan title-lined">
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 					<?php lsx_entry_bottom(); ?>
55 55
 				</article><!-- #post-## -->
56 56
 				<?php
57
-				lsx_health_plan_workout_sets();
58
-			} else {
59
-				?>
57
+                    lsx_health_plan_workout_sets();
58
+               } else {
59
+                    ?>
60 60
 				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
61 61
 					<?php lsx_entry_top(); ?>
62 62
 					<div class="entry-content">
@@ -66,24 +66,24 @@  discard block
 block discarded – undo
66 66
 								<h2><?php esc_html_e( 'Warm Up', 'lsx-health-plan' ); ?></h2>
67 67
 							</div>
68 68
 						<?php
69
-							the_content();
70
-							wp_link_pages( array(
71
-								'before'      => '<div class="lsx-postnav-wrapper"><div class="lsx-postnav">',
72
-								'after'       => '</div></div>',
73
-								'link_before' => '<span>',
74
-								'link_after'  => '</span>',
75
-							) );
76
-						?>
69
+                                   the_content();
70
+                                   wp_link_pages( array(
71
+                                        'before'      => '<div class="lsx-postnav-wrapper"><div class="lsx-postnav">',
72
+                                        'after'       => '</div></div>',
73
+                                        'link_before' => '<span>',
74
+                                        'link_after'  => '</span>',
75
+                                   ) );
76
+                              ?>
77 77
 						</div>
78 78
 					</div><!-- .entry-content -->
79 79
 					<?php lsx_entry_bottom(); ?>
80 80
 				</article><!-- #post-## -->
81 81
 				<?php
82
-			}
82
+               }
83 83
 
84
-		}
85
-		wp_reset_postdata();
86
-	}
84
+          }
85
+          wp_reset_postdata();
86
+     }
87 87
 }
88 88
 ?>
89 89
 </div>
Please login to merge, or discard this patch.