Passed
Push — add/multiplan ( efd4dd...2fc26f )
by Warwick
05:21 queued 14s
created
includes/conditionals.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
  * @return boolean
13 13
  */
14 14
 function lsx_health_plan_has_warmup( $post_id = '' ) {
15
-	if ( '' === $post_id ) {
16
-		$post_id = get_the_ID();
17
-	}
18
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'plan_warmup' );
15
+     if ( '' === $post_id ) {
16
+          $post_id = get_the_ID();
17
+     }
18
+     return \lsx_health_plan\functions\has_attached_post( $post_id, 'plan_warmup' );
19 19
 }
20 20
 
21 21
 /**
@@ -25,25 +25,25 @@  discard block
 block discarded – undo
25 25
  * @return boolean
26 26
  */
27 27
 function lsx_health_plan_has_workout( $post_id = '' ) {
28
-	if ( ! post_type_exists( 'workout' ) ) {
29
-		return false;
30
-	}
31
-	if ( '' === $post_id ) {
32
-		$post_id = get_the_ID();
33
-	}
34
-	$has_workouts = false;
35
-
36
-	$section_key = get_query_var( 'section', false );
37
-	if ( false !== $section_key ) {
38
-		$section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key );
39
-		if ( isset( $section_info['connected_workouts'] ) && ! empty( $section_info['connected_workouts'] ) ) {
40
-			$has_workouts = true;
41
-		}
42
-	} elseif ( \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_workouts' ) ) {
43
-		$has_workouts = true;
44
-	}
45
-
46
-	return $has_workouts;
28
+     if ( ! post_type_exists( 'workout' ) ) {
29
+          return false;
30
+     }
31
+     if ( '' === $post_id ) {
32
+          $post_id = get_the_ID();
33
+     }
34
+     $has_workouts = false;
35
+
36
+     $section_key = get_query_var( 'section', false );
37
+     if ( false !== $section_key ) {
38
+          $section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key );
39
+          if ( isset( $section_info['connected_workouts'] ) && ! empty( $section_info['connected_workouts'] ) ) {
40
+               $has_workouts = true;
41
+          }
42
+     } elseif ( \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_workouts' ) ) {
43
+          $has_workouts = true;
44
+     }
45
+
46
+     return $has_workouts;
47 47
 }
48 48
 
49 49
 /**
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
  * @return boolean
54 54
  */
55 55
 function lsx_health_plan_has_meal( $post_id = '' ) {
56
-	if ( ! post_type_exists( 'meal' ) ) {
57
-		return false;
58
-	}
59
-	if ( '' === $post_id ) {
60
-		$post_id = get_the_ID();
61
-	}
62
-
63
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' );
56
+     if ( ! post_type_exists( 'meal' ) ) {
57
+          return false;
58
+     }
59
+     if ( '' === $post_id ) {
60
+          $post_id = get_the_ID();
61
+     }
62
+
63
+     return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' );
64 64
 }
65 65
 
66 66
 /**
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
  * @return boolean
71 71
  */
72 72
 function lsx_health_plan_has_recipe( $post_id = '' ) {
73
-	if ( ! post_type_exists( 'recipe' ) ) {
74
-		return false;
75
-	}
76
-	if ( '' === $post_id ) {
77
-		$post_id = get_the_ID();
78
-	}
79
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_recipes' );
73
+     if ( ! post_type_exists( 'recipe' ) ) {
74
+          return false;
75
+     }
76
+     if ( '' === $post_id ) {
77
+          $post_id = get_the_ID();
78
+     }
79
+     return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_recipes' );
80 80
 }
81 81
 
82 82
 /**
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
  * @return boolean
87 87
  */
88 88
 function lsx_health_plan_has_downloads( $post_id = '' ) {
89
-	$has_downloads = false;
90
-	if ( '' === $post_id ) {
91
-		$post_id = get_the_ID();
92
-	}
93
-	$downloads = \lsx_health_plan\functions\get_downloads( 'all', $post_id );
94
-	if ( ! empty( $downloads ) ) {
95
-		$has_downloads = true;
96
-	}
97
-	return $has_downloads;
89
+     $has_downloads = false;
90
+     if ( '' === $post_id ) {
91
+          $post_id = get_the_ID();
92
+     }
93
+     $downloads = \lsx_health_plan\functions\get_downloads( 'all', $post_id );
94
+     if ( ! empty( $downloads ) ) {
95
+          $has_downloads = true;
96
+     }
97
+     return $has_downloads;
98 98
 }
99 99
 
100 100
 /**
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
  * @return boolean
105 105
  */
106 106
 function lsx_health_plan_has_tip( $post_id = '' ) {
107
-	if ( ! post_type_exists( 'tip' ) ) {
108
-		return false;
109
-	}
110
-	if ( '' === $post_id ) {
111
-		$post_id = get_the_ID();
112
-	}
113
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_tips' );
107
+     if ( ! post_type_exists( 'tip' ) ) {
108
+          return false;
109
+     }
110
+     if ( '' === $post_id ) {
111
+          $post_id = get_the_ID();
112
+     }
113
+     return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_tips' );
114 114
 }
115 115
 
116 116
 /**
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
  * @return boolean
121 121
  */
122 122
 function lsx_health_plan_has_video( $post_id = '' ) {
123
-	if ( ! post_type_exists( 'video' ) ) {
124
-		return false;
125
-	}
126
-	if ( '' === $post_id ) {
127
-		$post_id = get_the_ID();
128
-	}
129
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_videos' );
123
+     if ( ! post_type_exists( 'video' ) ) {
124
+          return false;
125
+     }
126
+     if ( '' === $post_id ) {
127
+          $post_id = get_the_ID();
128
+     }
129
+     return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_videos' );
130 130
 }
131 131
 
132 132
 /**
@@ -135,16 +135,16 @@  discard block
 block discarded – undo
135 135
  * @return boolean
136 136
  */
137 137
 function lsx_health_plan_user_has_purchase() {
138
-	$valid_order = false;
139
-	$product_id  = \lsx_health_plan\functions\get_option( 'membership_product', false );
140
-
141
-	if ( is_user_logged_in() && false !== $product_id ) {
142
-		$current_user = wp_get_current_user();
143
-		if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) {
144
-			$valid_order = true;
145
-		}
146
-	}
147
-	return $valid_order;
138
+     $valid_order = false;
139
+     $product_id  = \lsx_health_plan\functions\get_option( 'membership_product', false );
140
+
141
+     if ( is_user_logged_in() && false !== $product_id ) {
142
+          $current_user = wp_get_current_user();
143
+          if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) {
144
+               $valid_order = true;
145
+          }
146
+     }
147
+     return $valid_order;
148 148
 }
149 149
 
150 150
 /**
@@ -154,18 +154,18 @@  discard block
 block discarded – undo
154 154
  * @return boolean
155 155
  */
156 156
 function lsx_health_plan_is_current_tab( $needle = '' ) {
157
-	$is_tab = false;
158
-	$plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false );
159
-	if ( false === $plan_slug ) {
160
-		$plan_slug = 'my-plan';
161
-	}
162
-	if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) {
163
-		$endpoint = get_query_var( 'endpoint' );
164
-		if ( false !== $endpoint && $needle === $endpoint ) {
165
-			$is_tab = true;
166
-		}
167
-	}
168
-	return $is_tab;
157
+     $is_tab = false;
158
+     $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false );
159
+     if ( false === $plan_slug ) {
160
+          $plan_slug = 'my-plan';
161
+     }
162
+     if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) {
163
+          $endpoint = get_query_var( 'endpoint' );
164
+          if ( false !== $endpoint && $needle === $endpoint ) {
165
+               $is_tab = true;
166
+          }
167
+     }
168
+     return $is_tab;
169 169
 }
170 170
 
171 171
 /**
@@ -175,22 +175,22 @@  discard block
 block discarded – undo
175 175
  * @return boolean
176 176
  */
177 177
 function lsx_health_plan_is_day_complete( $post_id = '', $section_key = '' ) {
178
-	$is_complete = false;
179
-	if ( '' === $post_id ) {
180
-		$post_id = get_the_ID();
181
-	}
182
-	$key             = \lsx_health_plan\functions\plan\generate_section_id( $section_key );
183
-	$is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true );
184
-	if ( false !== $is_day_complete && '' !== $is_day_complete ) {
185
-		$is_complete = true;
186
-	}
187
-
188
-	return $is_complete;
178
+     $is_complete = false;
179
+     if ( '' === $post_id ) {
180
+          $post_id = get_the_ID();
181
+     }
182
+     $key             = \lsx_health_plan\functions\plan\generate_section_id( $section_key );
183
+     $is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true );
184
+     if ( false !== $is_day_complete && '' !== $is_day_complete ) {
185
+          $is_complete = true;
186
+     }
187
+
188
+     return $is_complete;
189 189
 }
190 190
 
191 191
 function lsx_health_plan_is_plan_complete() {
192
-	$complete = false;
193
-	return $complete;
192
+     $complete = false;
193
+     return $complete;
194 194
 }
195 195
 
196 196
 /**
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
  * @return boolean
201 201
  */
202 202
 function lsx_health_plan_week_has_downloads( $week = '' ) {
203
-	$has_downloads = false;
204
-	if ( '' !== $week ) {
205
-		$downloads = \lsx_health_plan\functions\get_weekly_downloads( $week );
206
-		if ( ! empty( $downloads ) ) {
207
-			$has_downloads = true;
208
-		}
209
-	}
210
-	return $has_downloads;
203
+     $has_downloads = false;
204
+     if ( '' !== $week ) {
205
+          $downloads = \lsx_health_plan\functions\get_weekly_downloads( $week );
206
+          if ( ! empty( $downloads ) ) {
207
+               $has_downloads = true;
208
+          }
209
+     }
210
+     return $has_downloads;
211 211
 }
212 212
 
213 213
 /**
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
  * @return boolean
218 218
  */
219 219
 function lsx_health_plan_has_tips( $post_id = '' ) {
220
-	$has_tips = false;
221
-	if ( '' === $post_id ) {
222
-		$post_id = get_the_ID();
223
-	}
224
-	$post_type      = get_post_type( $post_id );
225
-	$connected_tips = get_post_meta( get_the_ID(), $post_type . '_connected_tips', true );
226
-	$connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips );
227
-	if ( ! empty( $connected_tips ) ) {
228
-		$has_tips = true;
229
-	}
230
-	return $has_tips;
220
+     $has_tips = false;
221
+     if ( '' === $post_id ) {
222
+          $post_id = get_the_ID();
223
+     }
224
+     $post_type      = get_post_type( $post_id );
225
+     $connected_tips = get_post_meta( get_the_ID(), $post_type . '_connected_tips', true );
226
+     $connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips );
227
+     if ( ! empty( $connected_tips ) ) {
228
+          $has_tips = true;
229
+     }
230
+     return $has_tips;
231 231
 }
Please login to merge, or discard this patch.