Passed
Push — add/multiplan ( ad7e4c...0519d0 )
by Warwick
04:28 queued 12s
created
includes/conditionals.php 2 patches
Indentation   +107 added lines, -107 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,8 +135,8 @@  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
-	return $valid_order;
138
+     $valid_order = false;
139
+     return $valid_order;
140 140
 }
141 141
 
142 142
 /**
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
  * @return boolean
147 147
  */
148 148
 function lsx_health_plan_is_current_tab( $needle = '' ) {
149
-	$is_tab = false;
150
-	$plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false );
151
-	if ( false === $plan_slug ) {
152
-		$plan_slug = 'my-plan';
153
-	}
154
-	if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) {
155
-		$endpoint = get_query_var( 'endpoint' );
156
-		if ( false !== $endpoint && $needle === $endpoint ) {
157
-			$is_tab = true;
158
-		}
159
-	}
160
-	return $is_tab;
149
+     $is_tab = false;
150
+     $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false );
151
+     if ( false === $plan_slug ) {
152
+          $plan_slug = 'my-plan';
153
+     }
154
+     if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) {
155
+          $endpoint = get_query_var( 'endpoint' );
156
+          if ( false !== $endpoint && $needle === $endpoint ) {
157
+               $is_tab = true;
158
+          }
159
+     }
160
+     return $is_tab;
161 161
 }
162 162
 
163 163
 /**
@@ -167,22 +167,22 @@  discard block
 block discarded – undo
167 167
  * @return boolean
168 168
  */
169 169
 function lsx_health_plan_is_day_complete( $post_id = '', $section_key = '' ) {
170
-	$is_complete = false;
171
-	if ( '' === $post_id ) {
172
-		$post_id = get_the_ID();
173
-	}
174
-	$key             = \lsx_health_plan\functions\plan\generate_section_id( $section_key );
175
-	$is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true );
176
-	if ( false !== $is_day_complete && '' !== $is_day_complete ) {
177
-		$is_complete = true;
178
-	}
179
-
180
-	return $is_complete;
170
+     $is_complete = false;
171
+     if ( '' === $post_id ) {
172
+          $post_id = get_the_ID();
173
+     }
174
+     $key             = \lsx_health_plan\functions\plan\generate_section_id( $section_key );
175
+     $is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true );
176
+     if ( false !== $is_day_complete && '' !== $is_day_complete ) {
177
+          $is_complete = true;
178
+     }
179
+
180
+     return $is_complete;
181 181
 }
182 182
 
183 183
 function lsx_health_plan_is_plan_complete() {
184
-	$complete = false;
185
-	return $complete;
184
+     $complete = false;
185
+     return $complete;
186 186
 }
187 187
 
188 188
 /**
@@ -192,14 +192,14 @@  discard block
 block discarded – undo
192 192
  * @return boolean
193 193
  */
194 194
 function lsx_health_plan_week_has_downloads( $week = '' ) {
195
-	$has_downloads = false;
196
-	if ( '' !== $week ) {
197
-		$downloads = \lsx_health_plan\functions\get_weekly_downloads( $week );
198
-		if ( ! empty( $downloads ) ) {
199
-			$has_downloads = true;
200
-		}
201
-	}
202
-	return $has_downloads;
195
+     $has_downloads = false;
196
+     if ( '' !== $week ) {
197
+          $downloads = \lsx_health_plan\functions\get_weekly_downloads( $week );
198
+          if ( ! empty( $downloads ) ) {
199
+               $has_downloads = true;
200
+          }
201
+     }
202
+     return $has_downloads;
203 203
 }
204 204
 
205 205
 /**
@@ -209,15 +209,15 @@  discard block
 block discarded – undo
209 209
  * @return boolean
210 210
  */
211 211
 function lsx_health_plan_has_tips( $post_id = '' ) {
212
-	$has_tips = false;
213
-	if ( '' === $post_id ) {
214
-		$post_id = get_the_ID();
215
-	}
216
-	$post_type      = get_post_type( $post_id );
217
-	$connected_tips = get_post_meta( get_the_ID(), $post_type . '_connected_tips', true );
218
-	$connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips );
219
-	if ( ! empty( $connected_tips ) ) {
220
-		$has_tips = true;
221
-	}
222
-	return $has_tips;
212
+     $has_tips = false;
213
+     if ( '' === $post_id ) {
214
+          $post_id = get_the_ID();
215
+     }
216
+     $post_type      = get_post_type( $post_id );
217
+     $connected_tips = get_post_meta( get_the_ID(), $post_type . '_connected_tips', true );
218
+     $connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips );
219
+     if ( ! empty( $connected_tips ) ) {
220
+          $has_tips = true;
221
+     }
222
+     return $has_tips;
223 223
 }
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
  * @param string $post_id
12 12
  * @return boolean
13 13
  */
14
-function lsx_health_plan_has_warmup( $post_id = '' ) {
15
-	if ( '' === $post_id ) {
14
+function lsx_health_plan_has_warmup($post_id = '') {
15
+	if ('' === $post_id) {
16 16
 		$post_id = get_the_ID();
17 17
 	}
18
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'plan_warmup' );
18
+	return \lsx_health_plan\functions\has_attached_post($post_id, 'plan_warmup');
19 19
 }
20 20
 
21 21
 /**
@@ -24,22 +24,22 @@  discard block
 block discarded – undo
24 24
  * @param string $post_id
25 25
  * @return boolean
26 26
  */
27
-function lsx_health_plan_has_workout( $post_id = '' ) {
28
-	if ( ! post_type_exists( 'workout' ) ) {
27
+function lsx_health_plan_has_workout($post_id = '') {
28
+	if ( ! post_type_exists('workout')) {
29 29
 		return false;
30 30
 	}
31
-	if ( '' === $post_id ) {
31
+	if ('' === $post_id) {
32 32
 		$post_id = get_the_ID();
33 33
 	}
34 34
 	$has_workouts = false;
35 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'] ) ) {
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 40
 			$has_workouts = true;
41 41
 		}
42
-	} elseif ( \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_workouts' ) ) {
42
+	} elseif (\lsx_health_plan\functions\has_attached_post($post_id, 'connected_workouts')) {
43 43
 		$has_workouts = true;
44 44
 	}
45 45
 
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
  * @param string $post_id
53 53
  * @return boolean
54 54
  */
55
-function lsx_health_plan_has_meal( $post_id = '' ) {
56
-	if ( ! post_type_exists( 'meal' ) ) {
55
+function lsx_health_plan_has_meal($post_id = '') {
56
+	if ( ! post_type_exists('meal')) {
57 57
 		return false;
58 58
 	}
59
-	if ( '' === $post_id ) {
59
+	if ('' === $post_id) {
60 60
 		$post_id = get_the_ID();
61 61
 	}
62 62
 
63
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' );
63
+	return \lsx_health_plan\functions\has_attached_post($post_id, 'connected_meals');
64 64
 }
65 65
 
66 66
 /**
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
  * @param string $post_id
70 70
  * @return boolean
71 71
  */
72
-function lsx_health_plan_has_recipe( $post_id = '' ) {
73
-	if ( ! post_type_exists( 'recipe' ) ) {
72
+function lsx_health_plan_has_recipe($post_id = '') {
73
+	if ( ! post_type_exists('recipe')) {
74 74
 		return false;
75 75
 	}
76
-	if ( '' === $post_id ) {
76
+	if ('' === $post_id) {
77 77
 		$post_id = get_the_ID();
78 78
 	}
79
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_recipes' );
79
+	return \lsx_health_plan\functions\has_attached_post($post_id, 'connected_recipes');
80 80
 }
81 81
 
82 82
 /**
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
  * @param string $post_id
86 86
  * @return boolean
87 87
  */
88
-function lsx_health_plan_has_downloads( $post_id = '' ) {
88
+function lsx_health_plan_has_downloads($post_id = '') {
89 89
 	$has_downloads = false;
90
-	if ( '' === $post_id ) {
90
+	if ('' === $post_id) {
91 91
 		$post_id = get_the_ID();
92 92
 	}
93
-	$downloads = \lsx_health_plan\functions\get_downloads( 'all', $post_id );
94
-	if ( ! empty( $downloads ) ) {
93
+	$downloads = \lsx_health_plan\functions\get_downloads('all', $post_id);
94
+	if ( ! empty($downloads)) {
95 95
 		$has_downloads = true;
96 96
 	}
97 97
 	return $has_downloads;
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
  * @param string $post_id
104 104
  * @return boolean
105 105
  */
106
-function lsx_health_plan_has_tip( $post_id = '' ) {
107
-	if ( ! post_type_exists( 'tip' ) ) {
106
+function lsx_health_plan_has_tip($post_id = '') {
107
+	if ( ! post_type_exists('tip')) {
108 108
 		return false;
109 109
 	}
110
-	if ( '' === $post_id ) {
110
+	if ('' === $post_id) {
111 111
 		$post_id = get_the_ID();
112 112
 	}
113
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_tips' );
113
+	return \lsx_health_plan\functions\has_attached_post($post_id, 'connected_tips');
114 114
 }
115 115
 
116 116
 /**
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
  * @param string $post_id
120 120
  * @return boolean
121 121
  */
122
-function lsx_health_plan_has_video( $post_id = '' ) {
123
-	if ( ! post_type_exists( 'video' ) ) {
122
+function lsx_health_plan_has_video($post_id = '') {
123
+	if ( ! post_type_exists('video')) {
124 124
 		return false;
125 125
 	}
126
-	if ( '' === $post_id ) {
126
+	if ('' === $post_id) {
127 127
 		$post_id = get_the_ID();
128 128
 	}
129
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_videos' );
129
+	return \lsx_health_plan\functions\has_attached_post($post_id, 'connected_videos');
130 130
 }
131 131
 
132 132
 /**
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
  * @param string $post_id
146 146
  * @return boolean
147 147
  */
148
-function lsx_health_plan_is_current_tab( $needle = '' ) {
148
+function lsx_health_plan_is_current_tab($needle = '') {
149 149
 	$is_tab = false;
150
-	$plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false );
151
-	if ( false === $plan_slug ) {
150
+	$plan_slug = \lsx_health_plan\functions\get_option('my_plan_slug', false);
151
+	if (false === $plan_slug) {
152 152
 		$plan_slug = 'my-plan';
153 153
 	}
154
-	if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) {
155
-		$endpoint = get_query_var( 'endpoint' );
156
-		if ( false !== $endpoint && $needle === $endpoint ) {
154
+	if (is_singular('plan') || is_page($plan_slug)) {
155
+		$endpoint = get_query_var('endpoint');
156
+		if (false !== $endpoint && $needle === $endpoint) {
157 157
 			$is_tab = true;
158 158
 		}
159 159
 	}
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
  * @param string $post_id
167 167
  * @return boolean
168 168
  */
169
-function lsx_health_plan_is_day_complete( $post_id = '', $section_key = '' ) {
169
+function lsx_health_plan_is_day_complete($post_id = '', $section_key = '') {
170 170
 	$is_complete = false;
171
-	if ( '' === $post_id ) {
171
+	if ('' === $post_id) {
172 172
 		$post_id = get_the_ID();
173 173
 	}
174
-	$key             = \lsx_health_plan\functions\plan\generate_section_id( $section_key );
175
-	$is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true );
176
-	if ( false !== $is_day_complete && '' !== $is_day_complete ) {
174
+	$key             = \lsx_health_plan\functions\plan\generate_section_id($section_key);
175
+	$is_day_complete = get_user_meta(get_current_user_id(), 'day_' . $key . '_complete', true);
176
+	if (false !== $is_day_complete && '' !== $is_day_complete) {
177 177
 		$is_complete = true;
178 178
 	}
179 179
 
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
  * @param string $week The week name 'week-1'.
192 192
  * @return boolean
193 193
  */
194
-function lsx_health_plan_week_has_downloads( $week = '' ) {
194
+function lsx_health_plan_week_has_downloads($week = '') {
195 195
 	$has_downloads = false;
196
-	if ( '' !== $week ) {
197
-		$downloads = \lsx_health_plan\functions\get_weekly_downloads( $week );
198
-		if ( ! empty( $downloads ) ) {
196
+	if ('' !== $week) {
197
+		$downloads = \lsx_health_plan\functions\get_weekly_downloads($week);
198
+		if ( ! empty($downloads)) {
199 199
 			$has_downloads = true;
200 200
 		}
201 201
 	}
@@ -208,15 +208,15 @@  discard block
 block discarded – undo
208 208
  * @param string $post_id
209 209
  * @return boolean
210 210
  */
211
-function lsx_health_plan_has_tips( $post_id = '' ) {
211
+function lsx_health_plan_has_tips($post_id = '') {
212 212
 	$has_tips = false;
213
-	if ( '' === $post_id ) {
213
+	if ('' === $post_id) {
214 214
 		$post_id = get_the_ID();
215 215
 	}
216
-	$post_type      = get_post_type( $post_id );
217
-	$connected_tips = get_post_meta( get_the_ID(), $post_type . '_connected_tips', true );
218
-	$connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips );
219
-	if ( ! empty( $connected_tips ) ) {
216
+	$post_type      = get_post_type($post_id);
217
+	$connected_tips = get_post_meta(get_the_ID(), $post_type . '_connected_tips', true);
218
+	$connected_tips = \lsx_health_plan\functions\check_posts_exist($connected_tips);
219
+	if ( ! empty($connected_tips)) {
220 220
 		$has_tips = true;
221 221
 	}
222 222
 	return $has_tips;
Please login to merge, or discard this patch.