lsx_health_plan_all_plans_block()   F
last analyzed

Complexity

Conditions 22
Paths 7

Size

Total Lines 125
Code Lines 104

Duplication

Lines 0
Ratio 0 %

Importance

Changes 9
Bugs 0 Features 0
Metric Value
cc 22
eloc 104
c 9
b 0
f 0
nc 7
nop 0
dl 0
loc 125
rs 3.3333

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * LSX Health Plan Template Tags.
4
 *
5
 * @package lsx-health-plan
6
 */
7
8
/**
9
 * Outputs the workout box on the single plan page.
10
*
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
11
* @return void
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
12
*/
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
13
function lsx_health_plan_workout_box() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
14
	if ( ! post_type_exists( 'workout' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
15
		return;
16
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
17
	$intro_text = \lsx_health_plan\functions\get_option( 'workout_intro', false );
18
	?>
19
	<div class="workout-instructions">
20
		<div class="row">
21
			<div class="col-md-12">
22
			<?php
23
			if ( false !== $intro_text ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
24
				?>
25
				<div class="excerpt">
26
					<p><?php echo wp_kses_post( wpautop( $intro_text ) ); ?></p>
0 ignored issues
show
Bug introduced by
It seems like $intro_text can also be of type array; however, parameter $text of wpautop() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
					<p><?php echo wp_kses_post( wpautop( /** @scrutinizer ignore-type */ $intro_text ) ); ?></p>
Loading history...
27
				</div>
28
				<?php
29
			} else {
30
				?>
31
				<div class="content-intro">
32
					<h3><?php esc_html_e( "Don't forget your warm up!", 'lsx-health-plan' ); ?></h3>
33
					<p><?php esc_html_e( 'Be sure to do the warm-up before every workout session.', 'lsx-health-plan' ); ?></p>
34
				</div>
35
				<?php
36
			} ?>
0 ignored issues
show
Coding Style introduced by
Closing PHP tag must be on a line by itself
Loading history...
37
			</div>
38
		</div>
39
	</div>
40
<?php
41
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
42
43
/**
44
 * Outputs the meal plan box on the single plan page.
45
*
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
46
* @return void
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
47
*/
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
48
function lsx_health_plan_meal_box() {
49
	if ( ! post_type_exists( 'meal' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
50
		return;
51
	}
52
	?>
53
	<div class="col-md-4" >
54
		<div class="lsx-health-plan-box">
55
			<h3 class="title meal-plan-title title-lined"><?php esc_html_e( 'Your Meal Plan', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'meal.svg' ); ?></h3>
56
			<div class="spacer"></div>
57
			<?php
58
			$intro_text = \lsx_health_plan\functions\get_option( 'meal_plan_intro', false );
59
			if ( false !== $intro_text ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
60
				?>
61
				<div class="excerpt">
62
					<p><?php echo wp_kses_post( $intro_text ); ?></p>
0 ignored issues
show
Bug introduced by
It seems like $intro_text can also be of type array; however, parameter $data of wp_kses_post() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

62
					<p><?php echo wp_kses_post( /** @scrutinizer ignore-type */ $intro_text ); ?></p>
Loading history...
63
				</div>
64
				<?php
65
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
66
			$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false );
67
			if ( false === $meal ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
68
				$meal = 'meal';
69
			}
70
			?>
71
			<a href="<?php the_permalink(); ?><?php echo esc_attr( $meal ); ?>/" class="btn"><?php esc_html_e( 'View your meal plan', 'lsx-health-plan' ); ?></a>
72
		</div>
73
	</div>
74
<?php
75
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
76
77
/**
78
 * Outputs the recipe box on the single plan page.
79
*
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
80
* @return void
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
81
*/
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
82
function lsx_health_plan_recipe_box() {
83
	if ( ! post_type_exists( 'recipe' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
84
		return;
85
	}
86
	?>
87
	<div class="col-md-4" >
88
		<div class="lsx-health-plan-box">
89
			<h3 class="title recipes-title title-lined"><?php esc_html_e( 'Recipes', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'recipes.svg' ); ?></h3>
90
			<div class="spacer"></div>
91
			<?php
92
			$intro_text = \lsx_health_plan\functions\get_option( 'recipes_intro', false );
93
			if ( false !== $intro_text ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
94
				?>
95
				<div class="excerpt">
96
					<p><?php echo wp_kses_post( $intro_text ); ?></p>
0 ignored issues
show
Bug introduced by
It seems like $intro_text can also be of type array; however, parameter $data of wp_kses_post() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

96
					<p><?php echo wp_kses_post( /** @scrutinizer ignore-type */ $intro_text ); ?></p>
Loading history...
97
				</div>
98
				<?php
99
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
100
			$recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false );
101
			if ( false === $recipes ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
102
				$recipes = 'recipes';
103
			}
104
			?>
105
			<a href="<?php the_permalink(); ?><?php echo esc_attr( $recipes ); ?>/" class="btn"><?php esc_html_e( 'View all recipes', 'lsx-health-plan' ); ?></a>
106
		</div>
107
	</div>
108
<?php
109
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
110
111
/**
112
 * Outputs the downloads box on the single plan page.
113
*
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
114
* @return void
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
115
*/
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
116
function lsx_health_plan_downloads_box() {
117
	global $current_user;
118
	?>
119
	<div class="col-md-4 day-download-box" >
120
		<div class="lsx-health-plan-box">
121
			<h3 class="title downloads-title title-lined"><?php esc_html_e( 'Downloads', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'download.svg' ); ?></h3>
122
			<div class="spacer"></div>
123
			<div class="download-list">
124
				<ul>
125
					<?php
126
					$downloads = \lsx_health_plan\functions\get_downloads();
127
					if ( ! empty( $downloads ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
128
						foreach ( $downloads as $download ) {
0 ignored issues
show
Bug introduced by
The expression $downloads of type void is not traversable.
Loading history...
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
129
							echo wp_kses_post( '<li><a href=""><i class="fa fa-file-pdf"></i>' . do_shortcode( '[download id="' . $download . '"]' ) . '</a></li>' );
130
						}
131
					}
132
					?>
133
				</ul>
134
			</div>
135
		</div>
136
	</div>
137
<?php
138
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
139
140
/**
141
 * outputs the dynamic classes for the nav tabs.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
142
 *
143
 * @param string $tab
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
144
 * @return void
145
 */
146
function lsx_health_plan_nav_class( $tab = '' ) {
147
	$nav_classes = array();
148
	if ( function_exists( 'is_wc_endpoint_url' ) && 'edit-account' === $tab && is_wc_endpoint_url( 'edit-account' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
149
		$nav_classes[] = 'active';
150
	} elseif ( lsx_health_plan_is_current_tab( $tab ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
151
		$nav_classes[] = 'active';
152
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
153
	if ( ! empty( $nav_classes ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
154
		echo wp_kses_post( implode( ' ', $nav_classes ) );
155
	}
156
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
157
158
/**
159
 * Outputs the my profile tabs
160
 *
161
 * @return void
162
 */
163
function lsx_health_plan_my_profile_tabs() {
164
	?>
165
	<div id="account-nav">
166
		<ul class="nav nav-pills">
167
			<li class="
168
			<?php
169
			if ( ( function_exists( 'is_wc_endpoint_url' ) && ! is_wc_endpoint_url( 'edit-account' ) ) || ! function_exists( 'is_wc_endpoint_url' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
170
				echo esc_attr( 'active' );
171
			}
172
			?>
173
			"><a class="my-plan-tab" href="<?php the_permalink(); ?>"><?php esc_html_e( 'My Plans', 'lsx-health-plan' ); ?></a></li>
174
			<?php
175
			if ( function_exists( 'WC' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
176
				?>
177
				<li class="
178
				<?php
179
				if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'edit-account' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
180
					echo esc_attr( 'active' );
181
				}
182
				?>
183
				"><a class="account-details-tab" href="<?php the_permalink(); ?>edit-account/"><?php esc_html_e( 'Account Details', 'lsx-health-plan' ); ?></a></li>
184
				<?php
185
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
186
			if ( is_user_logged_in() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
187
				?>
188
					<li class=""><a class="logout-tab" href="<?php echo esc_url( wp_logout_url( get_permalink() ) ); ?>"><?php esc_html_e( 'Logout', 'lsx-health-plan' ); ?></a></li>
0 ignored issues
show
Bug introduced by
It seems like get_permalink() can also be of type false; however, parameter $redirect of wp_logout_url() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

188
					<li class=""><a class="logout-tab" href="<?php echo esc_url( wp_logout_url( /** @scrutinizer ignore-type */ get_permalink() ) ); ?>"><?php esc_html_e( 'Logout', 'lsx-health-plan' ); ?></a></li>
Loading history...
189
				<?php
190
			}
191
			?>
192
		</ul>
193
	</div>
194
	<?php
195
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
196
197
/**
198
 * Outputs the my profile box
199
 *
200
 * @return void
201
 */
202
function lsx_health_plan_my_profile_box() {
203
	?>
204
	<div class="lsx-health-plan my-profile-block wp-block-cover alignfull">
205
		<div class="wp-block-cover__inner-container">
206
			<h2><?php esc_html_e( 'My Dashboard', 'lsx-health-plan' ); ?></h2>
207
			<?php if ( ( function_exists( 'WC' ) || class_exists( 'WP_User_Avatar_Setup' ) ) && is_user_logged_in() ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
208
				<section id="dashboard-card">
209
					<?php if ( function_exists( 'WC' ) || class_exists( 'WP_User_Avatar_Setup' ) ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
210
						<div class="profile-navigation">
211
							<div class="profile-photo">
212
							<?php
213
								global $current_user;
214
								if ( function_exists( 'WC' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
215
									get_current_user();
216
								}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
217
								if ( class_exists( 'WP_User_Avatar_Setup' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
218
									echo get_avatar( $current_user->ID, 240 );
0 ignored issues
show
Bug introduced by
Are you sure get_avatar($current_user->ID, 240) of type false|string can be used in echo? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

218
									echo /** @scrutinizer ignore-type */ get_avatar( $current_user->ID, 240 );
Loading history...
219
								}
220
								?>
221
							</div>
222
						</div>
223
					<?php } ?>
224
					<?php if ( function_exists( 'WC' ) ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
225
						<div class="profile-details">
226
							<h1 class="title-lined has-text-color"><?php echo esc_html( $current_user->display_name ); ?></h1>
227
							<?php
228
							$disable_stats = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
229
							if ( 'on' !== $disable_stats && function_exists( 'WC' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Blank line found at start of control structure
Loading history...
230
231
								$is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false );
232
								$is_height_disabled = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false );
233
								$is_waist_disabled  = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false );
234
								$is_bmi_disabled    = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false );
235
236
								$weight = get_user_meta( get_current_user_id(), 'weight', true );
237
								$waist  = get_user_meta( get_current_user_id(), 'waist', true );
238
								$height = get_user_meta( get_current_user_id(), 'height', true );
239
240
								$height_m = 0;
241
								if ( is_numeric( $height ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
242
									$height_m = $height / 100;
243
								}
244
245
								if ( 1 < $weight && 1 < $height_m ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
246
									$bmi = $weight / ( $height_m * $height_m );
247
									$bmi = number_format( $bmi, 1 );
248
								} else {
249
									$bmi = __( 'Add more data', 'lsx-health-plan' );
250
								}
251
252
								?>
253
254
								<div>
255
									<?php if ( 'on' !== $is_weight_disabled ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
256
										<span><strong><?php esc_html_e( 'Weight:', 'lsx-health-plan' ); ?></strong>
257
										<?php
258
										if ( '' !== $weight ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
259
											echo wp_kses_post( $weight . ' kg' );
260
										} else {
261
											echo '/';
262
										}
263
										?>
264
										</span>
265
									<?php }
0 ignored issues
show
Coding Style introduced by
Opening PHP tag must be on a line by itself
Loading history...
Coding Style introduced by
No blank line found after control structure
Loading history...
266
									if ( 'on' !== $is_waist_disabled ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
267
										?>
268
										<span><strong><?php esc_html_e( 'Waist:', 'lsx-health-plan' ); ?></strong>
269
										<?php
270
										if ( '' !== $waist ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
271
											echo wp_kses_post( $waist . ' cm' );
272
										} else {
273
											echo '/';
274
										}
275
										?>
276
										</span>
277
									<?php }
0 ignored issues
show
Coding Style introduced by
Opening PHP tag must be on a line by itself
Loading history...
Coding Style introduced by
No blank line found after control structure
Loading history...
278
									if ( 'on' !== $is_bmi_disabled ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
279
										?>
280
										<span><strong><?php esc_html_e( 'BMI:', 'lsx-health-plan' ); ?></strong>
281
										<?php
282
										if ( '' !== $bmi ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
283
											echo wp_kses_post( $bmi );
284
										} else {
285
											echo '/';
286
										}
287
										?>
288
										</span>
289
									<?php } ?>
290
								</div>
291
							<?php
292
							}
293
294
							// Only display the edit account link if woocommerce is active.
295
							if ( function_exists( 'WC' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
296
								?>
297
								<div class="edit-profile">
298
									<?php
299
									if ( function_exists( 'wc_get_page_id' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
300
										$url_id = wc_get_page_id( 'myaccount' );
301
									} else {
302
										$url_id = '';
303
									}
304
									?>
305
									<a href="<?php echo esc_url( get_permalink( $url_id ) ); ?>edit-account/"><?php esc_html_e( 'Edit', 'lsx-health-plan' ); ?></a>
0 ignored issues
show
Bug introduced by
It seems like get_permalink($url_id) can also be of type false; however, parameter $url of esc_url() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

305
									<a href="<?php echo esc_url( /** @scrutinizer ignore-type */ get_permalink( $url_id ) ); ?>edit-account/"><?php esc_html_e( 'Edit', 'lsx-health-plan' ); ?></a>
Loading history...
306
								</div>
307
								<?php
308
							}
309
							?>
310
						</div>
311
					<?php } ?>
312
				</section>
313
			<?php } ?>
314
		</div>
315
	</div>
316
	<?php
317
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
318
319
/**
320
 * Outputs the my profile list of plans box
321
 *
322
 * @return void
323
 */
324
function lsx_health_plan_all_plans_block() {
325
	global $post, $product;
326
327
	// If this is the my plan page, and the user is logged out, show to WC login.
328
	$plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false );
329
	if ( function_exists( 'is_wc_endpoint_url' ) && false !== $plan_slug && is_page( $plan_slug ) && ! is_user_logged_in() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
330
		echo wp_kses_post( '<div id="edit-account-tab"><div class="edit-account-section">' );
331
		echo wp_kses_post( '<h2 class="title-lined my-plan"></h2>' );
332
		echo do_shortcode( '[woocommerce_my_account]' );
333
		echo wp_kses_post( '</div></div>' );
334
		return;
335
	}
336
337
	$args = array(
338
		'orderby'        => 'menu_order',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 5 space(s) between "'orderby'" and double arrow, but found 8.
Loading history...
339
		'order'          => 'ASC',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 7 space(s) between "'order'" and double arrow, but found 10.
Loading history...
340
		'post_type'      => 'plan',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 3 space(s) between "'post_type'" and double arrow, but found 6.
Loading history...
341
		'nopagin'        => true,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 5 space(s) between "'nopagin'" and double arrow, but found 8.
Loading history...
342
		'post_parent'    => 0,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 1 space(s) between "'post_parent'" and double arrow, but found 4.
Loading history...
343
	);
344
345
	if ( function_exists( '\lsx_health_plan\functions\woocommerce\get_membership_products' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
346
		$product_ids = \lsx_health_plan\functions\woocommerce\get_membership_products();
347
		if ( ! empty( $product_ids ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
348
			$args['meta_query'] = array(
0 ignored issues
show
introduced by
Detected usage of meta_query, possible slow query.
Loading history...
349
				'relation' => 'OR',
350
				array(
351
					'key'     => '_plan_product_id',
352
					'value'   => $product_ids,
353
					'compare' => 'IN',
354
				),
355
				array(
356
					'key'     => '_plan_product_id',
357
					'compare' => 'NOT EXISTS',
358
				),
359
			);
360
		}
361
	}
362
363
	$the_query = new WP_Query( $args );
364
	?>
365
	<div class="all-plans-block plan-grid block-all-plans-block">
366
		<div class="row">
367
			<?php
368
			if ( $the_query->have_posts() ) :
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
369
				while ( $the_query->have_posts() ) :
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
370
					$the_query->the_post();
371
					lsx_entry_before();
372
					$completed_class = '';
373
					$linked_product  = false;
374
					$restricted      = false;
375
					$product         = null;
376
					if ( function_exists( 'lsx_health_plan\functions\woocommerce\plan_has_products' ) && \lsx_health_plan\functions\woocommerce\plan_has_products() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
377
						$products       = \lsx_health_plan\functions\woocommerce\get_plan_products();
378
						$linked_product = wc_get_product( $products[0] );
0 ignored issues
show
Bug introduced by
The function wc_get_product was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

378
						$linked_product = /** @scrutinizer ignore-call */ wc_get_product( $products[0] );
Loading history...
379
						$product        = $linked_product;
380
					}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
381
					if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
382
						$restricted = wc_memberships_is_post_content_restricted( get_the_ID() ) && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() );
383
					}
384
385
					if ( lsx_health_plan_is_plan_complete() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
386
						$completed_class = 'completed';
387
					}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
388
					$round_progress     = '';
389
					$completed_progress = '100';
390
					if ( false === $restricted ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
391
						$round_progress = round( \lsx_health_plan\functions\get_progress( get_the_ID() ), 0 );
0 ignored issues
show
Bug introduced by
It seems like get_the_ID() can also be of type false; however, parameter $plan_id of lsx_health_plan\functions\get_progress() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

391
						$round_progress = round( \lsx_health_plan\functions\get_progress( /** @scrutinizer ignore-type */ get_the_ID() ), 0 );
Loading history...
392
					}
393
					?>
394
					<div class="col-xs-12 col-sm-6 col-md-4">
395
						<article class="lsx-slot lsx-hp-shadow <?php echo esc_html( 'progress-') . $round_progress; ?>">
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
introduced by
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$round_progress'.
Loading history...
396
							<div class="plan-feature-img">
397
								<?php if ( (int)$completed_progress === (int)$round_progress ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 1 space(s) after cast statement; 0 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
398
									<span class="featured-plan"><?php lsx_get_svg_icon( 'icon-completed.svg' ); ?></span>
399
								<?php } ?>
400
								<a href="<?php echo esc_url( get_permalink() ); ?>">
0 ignored issues
show
Bug introduced by
It seems like get_permalink() can also be of type false; however, parameter $url of esc_url() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

400
								<a href="<?php echo esc_url( /** @scrutinizer ignore-type */ get_permalink() ); ?>">
Loading history...
401
								<?php
402
								$featured_image = get_the_post_thumbnail();
403
								if ( ! empty( $featured_image ) && '' !== $featured_image ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
404
									the_post_thumbnail( 'lsx-thumbnail', array(
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
405
										'class' => 'aligncenter',
406
									) );
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
407
								} else {
408
									?>
409
									<img loading="lazy"  class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
410
									<?php
411
								}
412
								?>
413
								</a>
414
							</div>
415
							<div class="content-box plan-content-box">
416
								<h3 class="plan id-<?php the_ID(); ?> <?php echo esc_attr( $completed_class ); ?>"><a href="<?php echo esc_url( get_permalink() ); ?>"><?php the_title(); ?></a></h3>
417
								<?php
418
									echo wp_kses_post( \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) );
0 ignored issues
show
Bug introduced by
hp_get_plan_type_meta($post) of type void is incompatible with the type string expected by parameter $data of wp_kses_post(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

418
									echo wp_kses_post( /** @scrutinizer ignore-type */ \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) );
Loading history...
419
								?>
420
								<?php
421
								if ( false !== $linked_product && false !== $restricted ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
422
									echo wp_kses_post( $linked_product->get_price_html() );
423
								}
424
								?>
425
								<div class="excerpt">
426
									<?php
427
									if ( ! has_excerpt() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
428
										$content = wp_trim_words( get_the_content(), 20 );
429
										$content = '<p>' . $content . '</pre>';
430
									} else {
431
										$content = apply_filters( 'the_excerpt', get_the_excerpt() );
432
									}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
433
									echo wp_kses_post( $content );
434
									?>
435
								</div>
436
								<?php
437
								if ( false === $restricted ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
438
									echo wp_kses_post( '<span class="progress"><progress class="bar" value="' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '" max="100"> ' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '% </progress><span>' . $round_progress . '%</span></span>' );
439
								}
440
								?>
441
							</div>
442
						</article>
443
					</div>
444
				<?php endwhile; ?>
445
			<?php endif; ?>
446
		</div>
447
		<?php wp_reset_postdata(); ?>
448
	</div>
449
450
<?php
451
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
452
453
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$args" missing
Loading history...
454
 * Outputs the my profile day view box
455
 *
456
 * @return void
457
 */
458
function lsx_health_plan_day_plan_block( $args = array() ) {
459
	$defaults = array(
460
		'plan' => '',
461
	);
462
	$args     = wp_parse_args( $args, $defaults );
463
464
	if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
465
		$sections = \lsx_health_plan\functions\plan\get_sections();
466
		?>
467
		<div class="daily-plan-block day-grid">
468
			<?php
469
			foreach ( $sections as $section_key => $section_values ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
470
				$defaults    = array(
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 4 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
471
					'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
472
				);
473
				$section_args = wp_parse_args( $section_values, $defaults );
474
475
				$completed_class = '';
476
				if ( lsx_health_plan_is_day_complete() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
477
					$completed_class = 'completed';
478
				}
479
				?>
480
				<a href="<?php echo esc_attr( \lsx_health_plan\functions\plan\get_permalink( $args['plan'], $section_args['title'] ) ); ?>" class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>">
0 ignored issues
show
Bug introduced by
get_permalink($args['pla...$section_args['title']) of type array is incompatible with the type string expected by parameter $text of esc_attr(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

480
				<a href="<?php echo esc_attr( /** @scrutinizer ignore-type */ \lsx_health_plan\functions\plan\get_permalink( $args['plan'], $section_args['title'] ) ); ?>" class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>">
Loading history...
481
					<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
482
				</a>
483
				<?php
484
			}
485
			?>
486
		</div>
487
		<?php
488
	}
489
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
490
491
/**
492
 * Outputs the my profile week view box
493
 *
494
 * @param  array $args An array of arguments.
495
 * @return void
496
 */
497
function lsx_health_plan_week_plan_block( $args = array() ) {
498
	$defaults = array(
499
		'show_downloads' => false,
500
		'plan'           => '',
501
	);
502
	$args     = wp_parse_args( $args, $defaults );
503
504
	if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
505
		$groups = \lsx_health_plan\functions\plan\get_sections( true );
506
507
		if ( ! empty( $groups ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
508
			$counter    = 1;
509
			$group_open = false;
510
511
			foreach ( $groups as $group_key => $sections ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
512
				$collapse_class = '';
513
				$group_title    = \lsx_health_plan\functions\plan\get_group_title( $sections );
514
515
				// Determine if the current week is complete.
516
				$day_ids = wp_list_pluck( $sections, 'title' );
517
				if ( false === $group_open ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
518
					if ( 1 === $counter && ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
519
						$collapse_class = 'in';
520
						$group_open   = true;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 3 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
521
					} elseif ( ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
522
						$collapse_class = 'in';
523
						$group_open   = true;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 3 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
524
					}
525
				}
526
527
				// Determine if there are any weekly downloads.
528
				$week_downloads_view = '';
529
				if ( isset( $args['show_downloads'] ) && false !== $args['show_downloads'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
530
					$weekly_downloads = \lsx_health_plan\functions\get_weekly_downloads( $group_key );
531
					if ( ! empty( $weekly_downloads ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
532
						$week_downloads_view = 'week-downloads-view-on';
533
					}
534
				}
535
				?>
536
				<div class="daily-plan-block week-grid">
537
					<a href="#group-<?php echo esc_attr( $group_key ); ?>" data-toggle="collapse" class="week-title"><?php echo esc_attr( $group_title ); ?></a>
0 ignored issues
show
Bug introduced by
$group_title of type array is incompatible with the type string expected by parameter $text of esc_attr(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

537
					<a href="#group-<?php echo esc_attr( $group_key ); ?>" data-toggle="collapse" class="week-title"><?php echo esc_attr( /** @scrutinizer ignore-type */ $group_title ); ?></a>
Loading history...
538
					<div id="group-<?php echo esc_attr( $group_key ); ?>" class="week-row collapse <?php echo esc_attr( $collapse_class ); ?>">
539
						<div class="week-row-inner <?php echo esc_html( $week_downloads_view ); ?>">
540
							<div class="week-meals-recipes-box">
541
542
								<?php if ( ! empty( $week_downloads_view ) ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
543
									<h3 class="title"><?php lsx_get_svg_icon( 'daily-plan.svg' ); ?><?php echo esc_html_e( 'Plan', 'lsx-health-plan' ); ?></h3>
544
								<?php } ?>
545
546
								<div class="week-meals-recipes-box-inner">
547
								<?php
548
549
								foreach ( $sections as $section_key => $section_values ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Blank line found at start of control structure
Loading history...
550
551
									$defaults    = array(
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 4 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
552
										'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
553
									);
554
									$section_args = wp_parse_args( $section_values, $defaults );
555
556
									$completed_class = '';
557
									if ( lsx_health_plan_is_day_complete( $args['plan'], $section_args['title'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
558
										$completed_class = 'completed';
559
									}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
560
									if ( $section_args['rest_day_enabled'] && ! $section_args['connected_meals'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
561
										?>
562
										<span class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>">
563
											<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
564
										</span>
565
										<?php
566
									} else {
567
										?>
568
										<a href="<?php echo esc_attr( \lsx_health_plan\functions\plan\get_permalink( $args['plan'], $section_args['title'] ) ); ?>" class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>">
569
											<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
570
										</a>
571
										<?php
572
									}
573
								}
574
								?>
575
								</div>
576
							</div>
577
							<?php
578
							if ( ! empty( $week_downloads_view ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
579
								lsx_health_plan_weekly_downloads( $weekly_downloads );
580
							}
581
							?>
582
						</div>
583
					</div>
584
				</div>
585
				<?php
586
			}
587
		}
588
	}
589
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
590
591
/**
592
 * Outputs the weekly downloads box.
593
 *
594
 * @param array $weekly_downloads An array of the download ids.
595
 * @return void
596
 */
597
function lsx_health_plan_weekly_downloads( $weekly_downloads = array() ) {
598
	if ( ! empty( $weekly_downloads ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
599
		?>
600
		<div class="week-download-box">
601
			<h3 class="title"><?php lsx_get_svg_icon( 'download.svg' ); ?><?php echo esc_html_e( 'Downloads', 'lsx-health-plan' ); ?></h3>
602
			<ul class="week-download-box-list">
603
				<?php
604
				foreach ( $weekly_downloads as $weekly_download ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
605
					?>
606
					<li><?php echo wp_kses_post( do_shortcode( '[download id="' . $weekly_download . '"]' ) ); ?></li>
607
					<?php
608
				}
609
				?>
610
			</ul>
611
		</div>
612
		<?php
613
	}
614
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
615
616
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$args" missing
Loading history...
617
 * Outputs the featured items of any type shortcode (intended for exercises)
618
 *
619
 * @return void
620
 */
621
function lsx_health_plan_items( $args = array() ) {
622
	global $shortcode_args;
623
	$shortcode_args = $args;
624
	include LSX_HEALTH_PLAN_PATH . '/templates/partials/shortcode-loop.php';
625
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
626
627
/**
628
 * Outputs the featured video shortcode
629
 *
630
 * @return void
631
 */
632
function lsx_health_plan_featured_video_block() {
633
	if ( ! post_type_exists( 'video' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
634
		return;
635
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
636
	include LSX_HEALTH_PLAN_PATH . '/templates/featured-videos.php';
637
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
638
639
/**
640
 * Outputs the featured recipes shortcode
641
 *
642
 * @return void
643
 */
644
function lsx_health_plan_featured_recipes_block() {
645
	if ( ! post_type_exists( 'recipe' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
646
		return;
647
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
648
	include LSX_HEALTH_PLAN_PATH . '/templates/featured-recipes.php';
649
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
650
651
/**
652
 * Outputs the featured tips shortcode
653
 *
654
 * @return void
655
 */
656
function lsx_health_plan_featured_tips_block() {
657
	include LSX_HEALTH_PLAN_PATH . '/templates/featured-tips.php';
658
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
659
660
/**
661
 * Outputs the Health Plan Buttons
662
 *
663
 * @param string $button
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Superfluous parameter comment
Loading history...
664
 * @return void
665
 */
666
function lsx_health_plan_day_button() {
667
	if ( lsx_health_plan_is_day_complete() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
668
		lsx_health_plan_unlock_button();
669
	} else {
670
		lsx_health_plan_complete_button();
671
	}
672
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
673
674
/**
675
 * Outputs the health plan complete button.
676
 *
677
 * @return void
678
 */
679
function lsx_health_plan_complete_button() {
680
	?>
681
	<div class="single-plan-inner-buttons">
682
		<form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn">
683
			<?php wp_nonce_field( 'complete', 'lsx-health-plan-actions' ); ?>
684
			<input type="hidden" name="lsx-health-plan-id" value="<?php echo esc_attr( \lsx_health_plan\functions\plan\generate_section_id() ); ?>" />
685
			<button class="btn cta-btn" type="submit"><?php esc_html_e( 'Complete Day', 'lsx-health-plan' ); ?></button>
686
		</form>
687
		<?php lsx_health_plan_back_to_plan_button(); ?>
688
	</div>
689
	<?php
690
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
691
692
/**
693
 * Outputs the health plan unlock button.
694
 *
695
 * @return void
696
 */
697
function lsx_health_plan_unlock_button() {
698
	?>
699
	<div class="single-plan-inner-buttons">
700
		<form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn">
701
			<?php wp_nonce_field( 'unlock', 'lsx-health-plan-actions' ); ?>
702
			<input type="hidden" name="lsx-health-plan-id" value="<?php echo esc_attr( \lsx_health_plan\functions\plan\generate_section_id() ); ?>" />
703
			<button class="btn secondary-btn" type="submit"><?php esc_html_e( 'Im not done!', 'lsx-health-plan' ); ?></button>
704
		</form>
705
		<?php lsx_health_plan_back_to_plan_button(); ?>
706
	</div>
707
	<?php
708
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
709
710
/**
711
 * Outputs the Single Plan Endpoint Tabs
712
 *
713
 * @param string $button
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Superfluous parameter comment
Loading history...
714
 * @return void
715
 */
716
function lsx_health_plan_single_nav() {
717
	$tab_template_path = apply_filters( 'lsx_health_plan_single_nav_path', LSX_HEALTH_PLAN_PATH . '/templates/single-plan-tabs.php' );
718
	if ( '' !== $tab_template_path ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
719
		require $tab_template_path;
720
	}
721
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
722
723
/**
724
 * Outputs the Single Plan Tab based on the endpoint
725
 *
726
 * @param string $button
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Superfluous parameter comment
Loading history...
727
 * @return void
728
 */
729
function lsx_health_plan_single_tabs() {
730
	$endpoint = get_query_var( 'endpoint' );
731
	switch ( $endpoint ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
732
		case 'meal':
733
			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-meal.php';
734
			break;
735
736
		case 'recipes':
737
			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-recipes.php';
738
			break;
739
740
		case 'workout':
741
			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-workout.php';
742
			break;
743
744
		case 'warm-up':
745
			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-warm-up.php';
746
			break;
747
748
		default:
749
			$tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-plan.php';
750
			break;
751
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
752
	$tab_template_path = apply_filters( 'lsx_health_plan_single_tab_path', $tab_template_path );
753
	if ( '' !== $tab_template_path ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
754
		include $tab_template_path;
755
	}
756
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
757
758
/**
759
 * Outputs the recipe info on a table.
760
 *
761
 * @return void
762
 */
763
function lsx_health_plan_recipe_data() {
764
	include LSX_HEALTH_PLAN_PATH . '/templates/table-recipe-data.php';
765
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
766
767
/**
768
 * Outputs the recipe type.
769
 *
770
 * @return recipe_type
0 ignored issues
show
Bug introduced by
The type recipe_type was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
771
 */
772
function lsx_health_plan_recipe_type() {
773
	$term_obj_list = get_the_terms( get_the_ID(), 'recipe-type' );
0 ignored issues
show
Bug introduced by
It seems like get_the_ID() can also be of type false; however, parameter $post of get_the_terms() does only seem to accept WP_Post|integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

773
	$term_obj_list = get_the_terms( /** @scrutinizer ignore-type */ get_the_ID(), 'recipe-type' );
Loading history...
774
	$recipe_type   = $term_obj_list[0]->name;
775
	if ( ! empty( $recipe_type ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
776
		return $recipe_type;
777
	}
778
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
779
780
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$echo" missing
Loading history...
781
 * Outputs the modal button and registers the video modal to show.
782
 *
783
 * @param int $m
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
784
 * @param array $group
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
785
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
786
 */
787
function lsx_health_plan_workout_video_play_button( $m, $group, $echo = true ) {
788
	$workout_video = '';
789
	$giphy         = '';
790
	$youtube       = '';
791
	if ( isset( $group['connected_videos'] ) && '' !== $group['connected_videos'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
792
		$workout_video = esc_html( $group['connected_videos'] );
793
		$giphy         = get_post_meta( $workout_video, 'video_giphy_source', true );
0 ignored issues
show
Bug introduced by
$workout_video of type string is incompatible with the type integer expected by parameter $post_id of get_post_meta(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

793
		$giphy         = get_post_meta( /** @scrutinizer ignore-type */ $workout_video, 'video_giphy_source', true );
Loading history...
794
		$youtube       = esc_url( get_post_meta( $workout_video, 'video_youtube_source', 1 ) );
795
		$content       = get_post_field( 'post_content', $workout_video );
0 ignored issues
show
Bug introduced by
$workout_video of type string is incompatible with the type WP_Post|integer expected by parameter $post of get_post_field(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

795
		$content       = get_post_field( 'post_content', /** @scrutinizer ignore-type */ $workout_video );
Loading history...
796
		$play_button   = '<button data-toggle="modal" data-target="#workout-video-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>';
797
798
		$modal_body = '';
799
		if ( ! empty( $giphy ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
800
			$giphy      = \lsx_health_plan\functions\get_video_url( $giphy );
801
			$modal_body = $giphy; // WPCS: XSS OK.
802
		} elseif ( ! empty( $youtube ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
803
			$modal_body = wp_oembed_get( $youtube, array( // WPCS: XSS OK.
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
804
				'width' => 480,
805
			) );
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
806
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
807
		$modal_body .= '<h5 class="modal-title title-lined">' . $group['name'] . '</h5>';
808
		$modal_body .= $content;
809
		\lsx_health_plan\functions\register_modal( 'workout-video-modal-' . $m, '', $modal_body );
810
811
		if ( true === $echo ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
812
			echo wp_kses_post( $play_button );
813
		} else {
814
			return $play_button;
815
		}
816
	}
817
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
818
819
/**
820
 * Outputs the recipe description if it is included.
821
 *
822
 * @return void
823
 */
824
function lsx_health_plan_recipe_archive_description() {
825
	$description = '';
826
	if ( is_post_type_archive( 'recipe' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
827
		$description = \lsx_health_plan\functions\get_option( 'recipe_archive_description', '' );
828
	} elseif ( is_post_type_archive( 'exercise' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
829
		$description = \lsx_health_plan\functions\get_option( 'exercise_archive_description', '' );
830
	} elseif ( is_tax() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
831
		$description = get_the_archive_description();
832
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
833
	if ( '' !== $description ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
834
		?>
835
		<div class="lsx-hp-archive-description row">
836
			<div class="col-xs-12 description-wrapper"><?php echo wp_kses_post( wpautop( $description ) ); ?></div>
837
		</div>
838
		<?php
839
	}
840
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
841
842
/**
843
 * Outputs the Single Plan Workout main content.
844
 *
845
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
846
 */
847
function lsx_health_plan_workout_main_content() {
848
	// Getting translated endpoint.
849
	$workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
850
851
	$connected_members = get_post_meta( get_the_ID(), ( $workout . '_connected_team_member' ), true );
0 ignored issues
show
Bug introduced by
Are you sure $workout of type array|mixed can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

851
	$connected_members = get_post_meta( get_the_ID(), ( /** @scrutinizer ignore-type */ $workout . '_connected_team_member' ), true );
Loading history...
Bug introduced by
It seems like get_the_ID() can also be of type false; however, parameter $post_id of get_post_meta() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

851
	$connected_members = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), ( $workout . '_connected_team_member' ), true );
Loading history...
852
	$small_description = get_post_meta( get_the_ID(), ( $workout . '_short_description' ), true );
853
854
	$content = '';
855
	if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
856
		$content .= '<div class="short-desc set-box set content-box entry-content">';
857
		$content .= '<div class="the-content">';
858
		$content .= lsx_hp_member_connected( $connected_members, $workout );
859
		$content .= '<span>' . $small_description . '</span>';
860
		$content .= '</div>';
861
		$content .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
862
		$content .= '</div>';
863
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
864
	return $content;
865
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
866
867
/**
868
 * Outputs the Single Plan Workout main content.
869
 *
870
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
871
 */
872
function lsx_health_plan_meal_main_content() {
873
	// Getting translated endpoint.
874
	$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
875
876
	$connected_members = get_post_meta( get_the_ID(), ( $meal . '_connected_team_member' ), true );
0 ignored issues
show
Bug introduced by
It seems like get_the_ID() can also be of type false; however, parameter $post_id of get_post_meta() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

876
	$connected_members = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), ( $meal . '_connected_team_member' ), true );
Loading history...
Bug introduced by
Are you sure $meal of type array|mixed can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

876
	$connected_members = get_post_meta( get_the_ID(), ( /** @scrutinizer ignore-type */ $meal . '_connected_team_member' ), true );
Loading history...
877
	$small_description = get_post_meta( get_the_ID(), ( $meal . '_short_description' ), true );
878
879
	$content_meal = '';
880
	if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
881
		$content_meal .= '<div class="set-box set content-box entry-content">';
882
		$content_meal .= '<div class="the-content">';
883
		$content_meal .= lsx_hp_member_connected( $connected_members, $meal );
884
		$content_meal .= '<span>' . $small_description . '</span>';
885
		$content_meal .= '</div>';
886
		$content_meal .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
887
		$content_meal .= '</div>';
888
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
889
	return $content_meal;
890
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
891
892
893
/**
894
 * Outputs the Single Plan Workout Tab based on the layout selected.
895
 *
896
 * @param  string $index
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
897
 * @return void
898
 */
899
function lsx_health_plan_workout_tab_content( $index = 1 ) {
900
	global $group_name,$shortcode_args;
901
	$group_name = 'workout_section_' . $index;
902
	if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
903
		$layout = strtolower( \lsx_health_plan\functions\get_option( 'workout_tab_layout', 'table' ) );
0 ignored issues
show
Bug introduced by
It seems like get_option('workout_tab_layout', 'table') can also be of type array; however, parameter $string of strtolower() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

903
		$layout = strtolower( /** @scrutinizer ignore-type */ \lsx_health_plan\functions\get_option( 'workout_tab_layout', 'table' ) );
Loading history...
904
905
		// Check for shortcode overrides.
906
		if ( null !== $shortcode_args && isset( $shortcode_args['layout'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
907
			$layout = $shortcode_args['layout'];
908
		}
909
	} else {
910
		$layout = 'table';
911
	}
912
913
	switch ( $layout ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
914
		case 'list':
915
			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-list.php';
916
			break;
917
918
		case 'grid':
919
			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-grid.php';
920
			break;
921
922
		case 'table':
923
			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-table.php';
924
			break;
925
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
926
	$tab_template_path = apply_filters( 'lsx_health_plan_workout_tab_content_path', $tab_template_path );
927
	if ( '' !== $tab_template_path ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
928
		include $tab_template_path;
929
	}
930
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
931
932
/**
933
 * This will detect and include the Workout sets loop.
934
 *
935
 * @return void
936
 */
937
function lsx_health_plan_workout_sets() {
938
	if ( is_singular( 'workout' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
939
		global $connected_workouts;
940
		$connected_workouts = array( get_the_ID() );
941
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
942
	if ( is_singular( 'plan' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Blank line found at start of control structure
Loading history...
943
944
		global $connected_workouts;
945
946
		$section_key  = get_query_var( 'section' );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned correctly; expected 1 space but found 2 spaces

This check looks for improperly formatted assignments.

Every assignment must have exactly one space before and one space after the equals operator.

To illustrate:

$a = "a";
$ab = "ab";
$abc = "abc";

will have no issues, while

$a   = "a";
$ab  = "ab";
$abc = "abc";

will report issues in lines 1 and 2.

Loading history...
947
		if ( '' !== $section && \lsx_health_plan\functions\plan\has_sections() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
948
			$section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key );
949
			if ( isset( $section_info['connected_workouts'] ) && '' !== $section_info['connected_workouts'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Blank line found at start of control structure
Loading history...
950
951
				$connected_workouts = \lsx_health_plan\functions\prep_array( $section_info['connected_workouts'] );
952
			}
953
		}
954
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
955
	$template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
956
	$template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
957
	if ( '' !== $template_path && ! empty( $template_path ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
958
		include $template_path;
959
	}
960
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
961
962
/**
963
 * This will detect and include the Warmup sets loop.
964
 *
965
 * @param [type] $connected_workouts
0 ignored issues
show
Documentation Bug introduced by
The doc comment [type] at position 0 could not be parsed: Unknown type name '[' at position 0 in [type].
Loading history...
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
966
 * @return void
967
 */
968
function lsx_health_plan_warmup_sets( $connected_workouts ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 blank lines after opening function brace; 1 found
Loading history...
969
	
970
	$template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
971
	$template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
972
	if ( '' !== $template_path && ! empty( $template_path ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
973
		include $template_path;
974
	}
975
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
976
977
/**
978
 * Outputs the recipes connected to the meal plan.
979
 *
980
 * @param array $args
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
981
 * @return void
982
 */
983
function lsx_hp_meal_plan_recipes( $args = array() ) {
984
	$defaults = array(
985
		'meal_id'   => false,
986
		'meal_time' => '',
987
		'modal'     => true,
988
	);
989
	$args     = wp_parse_args( $args, $defaults );
990
	// Looking for recipes.
991
	$connected_recipes = get_post_meta( $args['meal_id'], $args['meal_time'] . '_recipes', true );
992
	if ( ! empty( $connected_recipes ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
993
		$query_args    = array(
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 1 space but found 4 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
994
			'orderby'   => 'date',
995
			'order'     => 'DESC',
996
			'post_type' => 'recipe',
997
			'post__in'  => $connected_recipes,
998
		);
999
		$recipes = new WP_Query( $query_args );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
1000
		?>
1001
		<div class="recipes">
1002
			<div class="row eating-row">
1003
			<?php
1004
			if ( $recipes->have_posts() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1005
				while ( $recipes->have_posts() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1006
					$recipes->the_post();
1007
					if ( false !== $args['modal'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1008
						\lsx_health_plan\functions\recipes\register_recipe_modal();
1009
					}
1010
					?>
1011
					<div class="recipe-column">
1012
						<a data-toggle="modal" data-target="#recipe-modal-<?php echo esc_attr( get_the_ID() ); ?>" href="#recipe-modal-<?php echo esc_attr( get_the_ID() ); ?>" class="recipe-box box-shadow">
0 ignored issues
show
Bug introduced by
It seems like get_the_ID() can also be of type false; however, parameter $text of esc_attr() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1012
						<a data-toggle="modal" data-target="#recipe-modal-<?php echo esc_attr( /** @scrutinizer ignore-type */ get_the_ID() ); ?>" href="#recipe-modal-<?php echo esc_attr( get_the_ID() ); ?>" class="recipe-box box-shadow">
Loading history...
1013
							<div class="recipe-feature-img">
1014
								<?php
1015
								$featured_image = get_the_post_thumbnail();
1016
								if ( ! empty( $featured_image ) && '' !== $featured_image ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1017
									the_post_thumbnail( 'lsx-thumbnail-square', array(
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
1018
										'class' => 'aligncenter',
1019
									) );
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
1020
								} else {
1021
									?>
1022
									<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __DIR__ ) . 'assets/images/placeholder.jpg' ); ?>">
1023
									<?php
1024
								}
1025
								?>
1026
							</div>
1027
							<div class="recipe-content">
1028
								<h3 class="recipe-title"><?php the_title(); ?></h3>
1029
								<?php lsx_health_plan_recipe_data(); ?>
1030
							</div>
1031
						</a>
1032
					</div>
1033
				<?php
1034
				}
1035
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1036
			wp_reset_postdata();
1037
			?>
1038
			</div>
1039
		</div>
1040
		<?php
1041
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
1042
	}
1043
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
1044
1045
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$args" missing
Loading history...
1046
 * Output the connected.
1047
 */
1048
function lsx_hp_recipe_plan_meta( $args = array() ) {
1049
	$defaults = array();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
1050
	$top_level_plans = array();
1051
	// Get meals this exercise is connected to.
1052
	$plans = get_post_meta( get_the_ID(), 'connected_plans', true );
0 ignored issues
show
Bug introduced by
It seems like get_the_ID() can also be of type false; however, parameter $post_id of get_post_meta() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1052
	$plans = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'connected_plans', true );
Loading history...
1053
	if ( ! empty( $plans ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1054
		$plan       = end( $plans );
0 ignored issues
show
Bug introduced by
It seems like $plans can also be of type string; however, parameter $array of end() does only seem to accept array|object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1054
		$plan       = end( /** @scrutinizer ignore-type */ $plans );
Loading history...
1055
		$has_parent = wp_get_post_parent_id( $plan );
1056
		if ( 0 === $has_parent ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1057
			$top_level_plans[] = $plan;
1058
		} elseif ( false !== $top_level_plans ) {
0 ignored issues
show
introduced by
The condition false !== $top_level_plans is always true.
Loading history...
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1059
			$top_level_plans[] = $has_parent;
1060
		}
1061
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1062
	if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1063
		$top_level_plans = array_unique( $top_level_plans );
1064
		$top_level_plan  = end( $top_level_plans );
1065
		?>
1066
			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1067
		<?php
1068
	}
1069
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
1070
1071
/**
1072
 * Output the connected.
1073
 */
1074
function lsx_hp_exercise_plan_meta() {
0 ignored issues
show
Coding Style introduced by
Expected 0 blank lines after opening function brace; 1 found
Loading history...
1075
1076
	$top_level_plans = array();
1077
1078
	// Get workouts this exercise is connected to.
1079
	$workouts = get_post_meta( get_the_ID(), 'connected_workouts', true );
0 ignored issues
show
Bug introduced by
It seems like get_the_ID() can also be of type false; however, parameter $post_id of get_post_meta() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1079
	$workouts = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'connected_workouts', true );
Loading history...
1080
1081
	if ( '' !== $workouts && ! is_array( $workouts ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1082
		$workouts = array( $workouts );
1083
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1084
	if ( ! empty( $workouts ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1085
		foreach ( $workouts as $workout ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1086
			// Get the plans this workout is connected to.
1087
			$plans = get_post_meta( $workout, 'connected_plans', true );
1088
1089
			if ( '' !== $plans && ! is_array( $plans ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1090
				$plans = array( $plans );
1091
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1092
			if ( ! empty( $plans ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1093
				foreach ( $plans as $plan ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1094
					$has_parent = wp_get_post_parent_id( $plan );
1095
					if ( 0 === $has_parent ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1096
						$top_level_plans = $plan;
1097
					} else {
1098
						$top_level_plans = $has_parent;
1099
					}
1100
				}
1101
			}
1102
		}
1103
	}
1104
1105
	if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1106
		$top_level_plans = array_unique( $top_level_plans );
1107
		$top_level_plan  = end( $top_level_plans );
1108
		?>
1109
			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1110
		<?php
1111
	}
1112
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
1113
1114
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$post_type_text" missing
Loading history...
1115
 * Template for related content box for all singles.
1116
 *
1117
 * @param [type] $related_content
0 ignored issues
show
Documentation Bug introduced by
The doc comment [type] at position 0 could not be parsed: Unknown type name '[' at position 0 in [type].
Loading history...
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
1118
 * @return void
1119
 */
1120
function lsx_hp_single_related( $related_content, $post_type_text ) {
1121
	?>
1122
	<section id="lsx-hp-related">
1123
		<div class="row lsx-related-posts lsx-related-posts-title">
1124
			<div class="col-xs-12">
1125
				<h2 class="lsx-related-posts-headline"><?php echo esc_html( $post_type_text ); ?></h2>
1126
			</div>
1127
		</div>
1128
		<div class="row lsx-related-posts lsx-related-posts-content">
1129
			<div class="col-xs-12">
1130
				<div class="lsx-related-posts-wrapper">
1131
					<?php
1132
					$i = 0;
1133
					foreach ( $related_content as $article ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1134
						$post_title      = get_the_title( $article );
1135
						$post_categories = wp_get_post_categories( $article );
1136
						$post_link       = get_permalink( $article );
1137
1138
						$cats = array();
1139
						?>
1140
						<article id="post-<?php echo esc_html( $article ); ?>" class="lsx-slot post">
1141
							<div class="entry-layout lsx-hp-shadow">
1142
								<div class="entry-layout-content">
1143
									<header class="entry-header">
1144
										<div class="entry-image">
1145
											<a href="<?php echo esc_url( $post_link ); ?>" class="thumbnail">
0 ignored issues
show
Bug introduced by
It seems like $post_link can also be of type false; however, parameter $url of esc_url() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1145
											<a href="<?php echo esc_url( /** @scrutinizer ignore-type */ $post_link ); ?>" class="thumbnail">
Loading history...
1146
											<?php
1147
											$featured_image = get_the_post_thumbnail( $article, 'lsx-thumbnail-wide' );
1148
											if ( ! empty( $featured_image ) && '' !== $featured_image ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1149
												echo wp_kses_post( $featured_image );
1150
											} else {
1151
												?>
1152
												<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
1153
												<?php
1154
											}
1155
											?>
1156
											</a>
1157
										</div>
1158
										<div class="entry-meta">
1159
										<?php
1160
										foreach ( $post_categories as $c ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1161
											$cat = get_category( $c );
1162
											/* Translators: %s: category name */
1163
											$cats[] = '<a href="' . esc_url( get_category_link( $cat->term_id ) ) . '" title="' . sprintf( esc_html__( 'Posts in %s', 'lsx-blog-customizer' ), $cat->name ) . '">' . $cat->name . '</a>';
0 ignored issues
show
Bug introduced by
The property name does not seem to exist on WP_Error.
Loading history...
Bug introduced by
The property term_id does not seem to exist on WP_Error.
Loading history...
1164
										}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1165
										if ( ! empty( $cats ) ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
Coding Style introduced by
Closing PHP tag must be on a line by itself
Loading history...
1166
											<div class="post-categories"><span></span><?php echo wp_kses_post( implode( ', ', $cats ) ); ?></div>
1167
										<?php } ?>
1168
										</div>
1169
										<h2 class="entry-title">
1170
											<a href="<?php echo esc_url( $post_link ); ?>">
1171
												<?php echo esc_html( $post_title ); ?>
1172
											</a>
1173
										</h2>
1174
									</header>
1175
								</div>
1176
							</div>
1177
						</article>
1178
1179
					<?php
1180
					if (++$i === 3) break;
0 ignored issues
show
introduced by
Use Yoda Condition checks, you must.
Loading history...
1181
					} ?>
0 ignored issues
show
Coding Style introduced by
Closing PHP tag must be on a line by itself
Loading history...
1182
				</div>
1183
			</div>
1184
		</div>
1185
	</section>
1186
	<?php
1187
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
1188
1189
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$post_type" missing
Loading history...
1190
 * Template for connected members.
1191
 *
1192
 * @param [type] $connected_members
0 ignored issues
show
Documentation Bug introduced by
The doc comment [type] at position 0 could not be parsed: Unknown type name '[' at position 0 in [type].
Loading history...
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
1193
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
1194
 */
1195
function lsx_hp_member_connected( $connected_members, $post_type ) {
1196
	if ( ! empty( $connected_members ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1197
		$content = '<div id="hp-connected-members" class="hp-connected-members connected-' . $post_type . '">';
1198
		foreach ( $connected_members as $member ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1199
			$post_link   = get_permalink( $member );
1200
			$member_name = get_the_title( $member );
1201
			$member_name = '<span class="lsx-team-name">' . $member_name . '</span>';
1202
1203
			$member_link = '<a href="' . $post_link . '" >' . $member_name . '</a>';
0 ignored issues
show
Bug introduced by
Are you sure $post_link of type false|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1203
			$member_link = '<a href="' . /** @scrutinizer ignore-type */ $post_link . '" >' . $member_name . '</a>';
Loading history...
1204
1205
			$roles = '';
1206
			$terms = get_the_terms( $member, 'team_role' );
1207
1208
			if ( $terms && ! is_wp_error( $terms ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1209
				$roles = array();
1210
1211
				foreach ( $terms as $term ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
1212
					$roles[] = $term->name;
1213
				}
1214
1215
				$roles = join( ', ', $roles );
1216
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1217
			$member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : '';
1218
1219
			$content .= '<p>' . $member_roles . ': ' . $member_link . '</p>';
1220
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1221
		$content .= '</div>';
1222
		return $content;
1223
	}
1224
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
1225