Passed
Push — master ( ff4a98...d2efa5 )
by Warwick
04:51
created

lsx_health_plan_day_plan_block()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 29
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 6
eloc 23
c 2
b 0
f 0
nc 4
nop 1
dl 0
loc 29
rs 8.9297
1
<?php
2
/**
3
 * LSX Health Plan Template Tags.
4
 *
5
 * @package lsx-health-plan
6
 */
7
8
/**
9
 * Outputs the warmup 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_warmup_box() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
14
	?>
15
	<div class="col-md-4" >
16
		<div class="lsx-health-plan-box">
17
			<h3 class="title warm-up-title title-lined"><?php esc_html_e( 'Your Warm-up', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'warm.svg' ); ?></h3>
18
			<div class="spacer"></div>
19
			<?php
20
			$intro_text = \lsx_health_plan\functions\get_option( 'warmup_intro', false );
21
			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...
22
				?>
23
				<div class="excerpt">
24
					<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

24
					<p><?php echo wp_kses_post( /** @scrutinizer ignore-type */ $intro_text ); ?></p>
Loading history...
25
				</div>
26
				<?php
27
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
28
			$warm_up = \lsx_health_plan\functions\get_option( 'endpoint_warm_up', false );
29
			if ( false === $warm_up ) {
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...
30
				$warm_up = 'warm-up';
31
			}
32
			?>
33
			<a href="<?php the_permalink(); ?><?php echo esc_attr( $warm_up ); ?>/" class="btn"><?php esc_html_e( 'Start your warm-up', 'lsx-health-plan' ); ?></a>
34
		</div>
35
	</div>
36
<?php
37
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
38
39
/**
40
 * Outputs the workout box on the single plan page.
41
*
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
42
* @return void
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
43
*/
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
44
function lsx_health_plan_workout_box() {
45
	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...
46
		return;
47
	}
48
	?>
49
	<div class="col-md-4" >
50
		<div class="lsx-health-plan-box">
51
			<h3 class="title work-out-title title-lined"><?php esc_html_e( 'Your Workout', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'work.svg' ); ?></h3>
52
			<div class="spacer"></div>
53
			<?php
54
			$intro_text = \lsx_health_plan\functions\get_option( 'workout_intro', false );
55
			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...
56
				?>
57
				<div class="excerpt">
58
					<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

58
					<p><?php echo wp_kses_post( /** @scrutinizer ignore-type */ $intro_text ); ?></p>
Loading history...
59
				</div>
60
				<?php
61
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
62
			$workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', false );
63
			if ( false === $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...
64
				$workout = 'workout';
65
			}
66
			?>
67
			<a href="<?php the_permalink(); ?><?php echo esc_attr( $workout ); ?>/" class="btn"><?php esc_html_e( 'Start your workout', 'lsx-health-plan' ); ?></a>
68
		</div>
69
	</div>
70
<?php
71
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
72
73
/**
74
 * Outputs the meal plan box on the single plan page.
75
*
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
76
* @return void
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
77
*/
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
78
function lsx_health_plan_meal_box() {
79
	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...
80
		return;
81
	}
82
	?>
83
	<div class="col-md-4" >
84
		<div class="lsx-health-plan-box">
85
			<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>
86
			<div class="spacer"></div>
87
			<?php
88
			$intro_text = \lsx_health_plan\functions\get_option( 'meal_plan_intro', false );
89
			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...
90
				?>
91
				<div class="excerpt">
92
					<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

92
					<p><?php echo wp_kses_post( /** @scrutinizer ignore-type */ $intro_text ); ?></p>
Loading history...
93
				</div>
94
				<?php
95
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
96
			$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false );
97
			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...
98
				$meal = 'meal';
99
			}
100
			?>
101
			<a href="<?php the_permalink(); ?><?php echo esc_attr( $meal ); ?>/" class="btn"><?php esc_html_e( 'View your meal plan', 'lsx-health-plan' ); ?></a>
102
		</div>
103
	</div>
104
<?php
105
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
106
107
/**
108
 * Outputs the recipe box on the single plan page.
109
*
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
110
* @return void
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
111
*/
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
112
function lsx_health_plan_recipe_box() {
113
	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...
114
		return;
115
	}
116
	?>
117
	<div class="col-md-4" >
118
		<div class="lsx-health-plan-box">
119
			<h3 class="title recipes-title title-lined"><?php esc_html_e( 'Recipes', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'recipes.svg' ); ?></h3>
120
			<div class="spacer"></div>
121
			<?php
122
			$intro_text = \lsx_health_plan\functions\get_option( 'recipes_intro', false );
123
			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...
124
				?>
125
				<div class="excerpt">
126
					<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

126
					<p><?php echo wp_kses_post( /** @scrutinizer ignore-type */ $intro_text ); ?></p>
Loading history...
127
				</div>
128
				<?php
129
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
130
			$recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false );
131
			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...
132
				$recipes = 'recipes';
133
			}
134
			?>
135
			<a href="<?php the_permalink(); ?><?php echo esc_attr( $recipes ); ?>/" class="btn"><?php esc_html_e( 'View all recipes', 'lsx-health-plan' ); ?></a>
136
		</div>
137
	</div>
138
<?php
139
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
140
141
/**
142
 * Outputs the downloads box on the single plan page.
143
*
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
144
* @return void
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
145
*/
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) before asterisk; 0 found
Loading history...
146
function lsx_health_plan_downloads_box() {
147
	global $current_user;
148
	?>
149
	<div class="col-md-4 day-download-box" >
150
		<div class="lsx-health-plan-box">
151
			<h3 class="title downloads-title title-lined"><?php esc_html_e( 'Downloads', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'download.svg' ); ?></h3>
152
			<div class="spacer"></div>
153
			<div class="download-list">
154
				<ul>
155
					<?php
156
					$downloads = \lsx_health_plan\functions\get_downloads();
157
					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...
158
						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...
159
							echo wp_kses_post( '<li><a href=""><i class="fa fa-file-pdf"></i>' . do_shortcode( '[download id="' . $download . '"]' ) . '</a></li>' );
160
						}
161
					}
162
					?>
163
				</ul>
164
			</div>
165
		</div>
166
	</div>
167
<?php
168
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
169
170
/**
171
 * 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...
172
 *
173
 * @param string $tab
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
174
 * @return void
175
 */
176
function lsx_health_plan_nav_class( $tab = '' ) {
177
	$nav_classes = array();
178
	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...
179
		$nav_classes[] = 'active';
180
	} 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...
181
		$nav_classes[] = 'active';
182
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
183
	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...
184
		echo wp_kses_post( implode( ' ', $nav_classes ) );
185
	}
186
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
187
188
/**
189
 * Outputs the my profile tabs
190
 *
191
 * @return void
192
 */
193
function lsx_health_plan_my_profile_tabs() {
194
	?>
195
	<div id="account-nav">
196
		<ul class="nav nav-pills">
197
			<li class="
198
			<?php
199
			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...
200
				echo esc_attr( 'active' );
201
			}
202
			?>
203
			"><a class="my-plan-tab" href="<?php the_permalink(); ?>"><?php esc_html_e( 'My Plans', 'lsx-health-plan' ); ?></a></li>
204
			<li class="
205
			<?php
206
			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...
207
				echo esc_attr( 'active' );
208
			}
209
			?>
210
			"><a class="account-details-tab" href="<?php the_permalink(); ?>edit-account/"><?php esc_html_e( 'Account Details', 'lsx-health-plan' ); ?></a></li>
211
			<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

211
			<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...
212
		</ul>
213
	</div>
214
	<?php
215
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
216
217
/**
218
 * Outputs the my profile box
219
 *
220
 * @return void
221
 */
222
function lsx_health_plan_my_profile_box() {
223
	?>
224
	<div class="lsx-health-plan my-profile-block wp-block-cover alignfull">
225
		<div class="wp-block-cover__inner-container">
226
			<h2><?php esc_html_e( 'My Dashboard', 'lsx-health-plan' ); ?></h2>
227
			<section id="dashboard-card">
228
				<div class="profile-navigation">
229
					<div class="profile-photo">
230
					<?php
231
						global $current_user;
232
						get_current_user();
233
						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

233
						echo /** @scrutinizer ignore-type */ get_avatar( $current_user->ID, 240 );
Loading history...
234
						?>
235
					</div>
236
				</div>
237
				<div class="profile-details">
238
					<h1 class="title-lined has-text-color"><?php echo esc_html( $current_user->display_name ); ?></h1>
239
					<?php
240
					$disable_stats = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
241
					if ( 'on' !== $disable_stats ) {
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...
242
243
						$is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false );
244
						$is_height_disabled = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false );
245
						$is_waist_disabled  = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false );
246
						$is_bmi_disabled    = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false );
247
248
						$weight = get_user_meta( get_current_user_id(), 'weight', true );
249
						$waist  = get_user_meta( get_current_user_id(), 'waist', true );
250
						$height = get_user_meta( get_current_user_id(), 'height', true );
251
						
252
						$height_m = 0;
253
						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 1 spaces before closing parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
254
							$height_m = $height / 100;
255
						}
256
257
						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...
258
							$bmi = $weight / ( $height_m * $height_m );
259
							$bmi = number_format( $bmi, 1 );
260
						} else {
261
							$bmi = __( 'Add more data', 'lsx-health-plan' );
262
						}
263
264
						?>
265
266
						<div>
267
							<?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...
268
								<span><strong><?php esc_html_e( 'Weight:', 'lsx-health-plan' ); ?></strong>
269
								<?php
270
								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...
271
									echo wp_kses_post( $weight . ' kg' );
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_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...
279
								?>
280
								<span><strong><?php esc_html_e( 'Waist:', 'lsx-health-plan' ); ?></strong>
281
								<?php
282
								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...
283
									echo wp_kses_post( $waist . ' cm' );
284
								} else {
285
									echo '/';
286
								}
287
								?>
288
								</span>
289
							<?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...
290
							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...
291
								?>
292
								<span><strong><?php esc_html_e( 'BMI:', 'lsx-health-plan' ); ?></strong>
293
								<?php
294
								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...
295
									echo wp_kses_post( $bmi );
296
								} else {
297
									echo '/';
298
								}
299
								?>
300
								</span>
301
							<?php } ?>
302
						</div>
303
					<?php
304
					}
305
					?>
306
					<div class="edit-profile">
307
						<?php
308
						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...
309
							$url_id = wc_get_page_id( 'myaccount' );
310
						} else {
311
							$url_id = '';
312
						}
313
						?>
314
						<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

314
						<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...
315
					</div>
316
				</div>
317
			</section>
318
		</div>
319
	</div>
320
	<?php
321
}
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...
322
323
/**
324
 * Outputs the my profile list of plans box
325
 *
326
 * @return void
327
 */
328
function lsx_health_plan_all_plans_block() {
329
	global $post, $product;
330
331
	$args = array(
332
		'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...
333
		'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...
334
		'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...
335
		'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...
336
		'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...
337
	);
338
339
	$product_ids = \lsx_health_plan\functions\woocommerce\get_membership_products();
340
	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...
341
		$args['meta_query'] = array(
0 ignored issues
show
introduced by
Detected usage of meta_query, possible slow query.
Loading history...
342
			'relation' => 'OR',
343
			array(
344
				'key'     => '_plan_product_id',
345
				'value'   => $product_ids,
346
				'compare' => 'IN',
347
			),
348
			array(
349
				'key'     => '_plan_product_id',
350
				'compare' => 'NOT EXISTS',
351
			),
352
		);
353
	}
354
355
	$the_query = new WP_Query( $args );
356
	?>
357
	<div class="all-plans-block plan-grid block-all-plans-block">
358
		<div class="row">
359
			<?php
360
			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...
361
				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...
362
					$the_query->the_post();
363
					lsx_entry_before();
364
					$completed_class = '';
365
					$linked_product  = false;
366
					$restricted      = false;
367
					$product         = null;
368
					if ( \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...
369
						$products       = \lsx_health_plan\functions\woocommerce\get_plan_products();
370
						$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

370
						$linked_product = /** @scrutinizer ignore-call */ wc_get_product( $products[0] );
Loading history...
371
						$product        = $linked_product;
372
					}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
373
					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...
374
						$restricted = wc_memberships_is_post_content_restricted( get_the_ID() ) && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() );
375
					}
376
377
					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...
378
						$completed_class = 'completed';
379
					}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
380
					$round_progress     = '';
381
					$completed_progress = '100';
382
					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...
383
						$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

383
						$round_progress = round( \lsx_health_plan\functions\get_progress( /** @scrutinizer ignore-type */ get_the_ID() ), 0 );
Loading history...
384
					}
385
					?>
386
					<div class="col-xs-12 col-sm-6 col-md-4">
387
						<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...
388
							<div class="plan-feature-img">
389
								<?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...
390
									<span class="featured-plan"><?php lsx_get_svg_icon( 'icon-completed.svg' ); ?></span>
391
								<?php } ?>
392
								<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

392
								<a href="<?php echo esc_url( /** @scrutinizer ignore-type */ get_permalink() ); ?>">
Loading history...
393
								<?php
394
								$featured_image = get_the_post_thumbnail();
395
								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...
396
									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...
397
										'class' => 'aligncenter',
398
									) );
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...
399
								} else {
400
									?>
401
									<img loading="lazy"  class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
402
									<?php
403
								}
404
								?>
405
								</a>
406
							</div>
407
							<div class="content-box plan-content-box">
408
								<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>
409
								<?php
410
									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

410
									echo wp_kses_post( /** @scrutinizer ignore-type */ \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) );
Loading history...
411
								?>
412
								<?php
413
								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...
414
									echo wp_kses_post( $linked_product->get_price_html() );
415
								}
416
								?>
417
								<div class="excerpt">
418
									<?php
419
									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...
420
										$content = wp_trim_words( get_the_content(), 20 );
421
										$content = '<p>' . $content . '</pre>';
422
									} else {
423
										$content = apply_filters( 'the_excerpt', get_the_excerpt() );
424
									}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
425
									echo wp_kses_post( $content );
426
									?>
427
								</div>
428
								<?php
429
								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...
430
									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>' );
431
								}
432
								?>
433
							</div>
434
						</article>
435
					</div>
436
				<?php endwhile; ?>
437
			<?php endif; ?>
438
		</div>
439
		<?php wp_reset_postdata(); ?>
440
	</div>
441
442
<?php
443
}
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...
444
445
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$args" missing
Loading history...
446
 * Outputs the my profile day view box
447
 *
448
 * @return void
449
 */
450
function lsx_health_plan_day_plan_block( $args = array() ) {
451
	$defaults = array(
452
		'plan' => '',
453
	);
454
	$args     = wp_parse_args( $args, $defaults );
455
456
	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...
457
		$sections = \lsx_health_plan\functions\plan\get_sections();
458
		?>
459
		<div class="daily-plan-block day-grid">
460
			<?php
461
			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...
462
				$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...
463
					'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
464
				);
465
				$section_args = wp_parse_args( $section_values, $defaults );
466
467
				$completed_class = '';
468
				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...
469
					$completed_class = 'completed';
470
				}
471
				?>
472
				<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

472
				<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...
473
					<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
474
				</a>
475
				<?php
476
			}
477
			?>
478
		</div>
479
		<?php
480
	}
481
}
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...
482
483
/**
484
 * Outputs the my profile week view box
485
 *
486
 * @param  array $args An array of arguments.
487
 * @return void
488
 */
489
function lsx_health_plan_week_plan_block( $args = array() ) {
490
	$defaults = array(
491
		'show_downloads' => false,
492
		'plan'           => '',
493
	);
494
	$args     = wp_parse_args( $args, $defaults );
495
496
	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...
497
		$groups = \lsx_health_plan\functions\plan\get_sections( true );
498
499
		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...
500
			$counter    = 1;
501
			$group_open = false;
502
503
			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...
504
				$collapse_class = '';
505
				$group_title    = \lsx_health_plan\functions\plan\get_group_title( $sections );
506
507
				// Determine if the current week is complete.
508
				$day_ids = wp_list_pluck( $sections, 'title' );
509
				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...
510
					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...
511
						$collapse_class = 'in';
512
						$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...
513
					} 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...
514
						$collapse_class = 'in';
515
						$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...
516
					}
517
				}
518
519
				// Determine if there are any weekly downloads.
520
				$week_downloads_view = '';
521
				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...
522
					$weekly_downloads = \lsx_health_plan\functions\get_weekly_downloads( $group_key );
523
					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...
524
						$week_downloads_view = 'week-downloads-view-on';
525
					}
526
				}
527
				?>
528
				<div class="daily-plan-block week-grid">
529
					<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

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

765
	$term_obj_list = get_the_terms( /** @scrutinizer ignore-type */ get_the_ID(), 'recipe-type' );
Loading history...
766
	$recipe_type   = $term_obj_list[0]->name;
767
	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...
768
		return $recipe_type;
769
	}
770
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
771
772
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$echo" missing
Loading history...
773
 * Outputs the modal button and registers the video modal to show.
774
 *
775
 * @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...
776
 * @param array $group
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
777
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
778
 */
779
function lsx_health_plan_workout_video_play_button( $m, $group, $echo = true ) {
780
	$workout_video = '';
781
	$giphy         = '';
782
	$youtube       = '';
783
	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...
784
		$workout_video = esc_html( $group['connected_videos'] );
785
		$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

785
		$giphy         = get_post_meta( /** @scrutinizer ignore-type */ $workout_video, 'video_giphy_source', true );
Loading history...
786
		$youtube       = esc_url( get_post_meta( $workout_video, 'video_youtube_source', 1 ) );
787
		$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

787
		$content       = get_post_field( 'post_content', /** @scrutinizer ignore-type */ $workout_video );
Loading history...
788
		$play_button   = '<button data-toggle="modal" data-target="#workout-video-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>';
789
790
		$modal_body = '';
791
		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...
792
			$giphy      = \lsx_health_plan\functions\get_video_url( $giphy );
793
			$modal_body = $giphy; // WPCS: XSS OK.
794
		} 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...
795
			$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...
796
				'width' => 480,
797
			) );
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...
798
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
799
		$modal_body .= '<h5 class="modal-title title-lined">' . $group['name'] . '</h5>';
800
		$modal_body .= $content;
801
		\lsx_health_plan\functions\register_modal( 'workout-video-modal-' . $m, '', $modal_body );
802
803
		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...
804
			echo wp_kses_post( $play_button );
805
		} else {
806
			return $play_button;
807
		}
808
	}
809
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
810
811
/**
812
 * Outputs the recipe description if it is included.
813
 *
814
 * @return void
815
 */
816
function lsx_health_plan_recipe_archive_description() {
817
	$description = '';
818
	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...
819
		$description = \lsx_health_plan\functions\get_option( 'recipe_archive_description', '' );
820
	} 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...
821
		$description = \lsx_health_plan\functions\get_option( 'exercise_archive_description', '' );
822
	} 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...
823
		$description = get_the_archive_description();
824
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
825
	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...
826
		?>
827
		<div class="lsx-hp-archive-description row">
828
			<div class="col-xs-12 description-wrapper"><?php echo wp_kses_post( wpautop( $description ) ); ?></div>
829
		</div>
830
		<?php
831
	}
832
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
833
834
/**
835
 * Outputs the Single Plan Workout main content.
836
 *
837
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
838
 */
839
function lsx_health_plan_workout_main_content() {
840
	// Getting translated endpoint.
841
	$workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
842
843
	$connected_members = get_post_meta( get_the_ID(), ( $workout . '_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

843
	$connected_members = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), ( $workout . '_connected_team_member' ), true );
Loading history...
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

843
	$connected_members = get_post_meta( get_the_ID(), ( /** @scrutinizer ignore-type */ $workout . '_connected_team_member' ), true );
Loading history...
844
	$small_description = get_post_meta( get_the_ID(), ( $workout . '_short_description' ), true );
845
846
	$content = '';
847
	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...
848
		$content .= '<div class="set-box set content-box entry-content">';
849
		$content .= '<div class="the-content">';
850
		$content .= lsx_hp_member_connected( $connected_members, $workout );
851
		$content .= '<span>' . $small_description . '</span>';
852
		$content .= '</div>';
853
		$content .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
854
		$content .= '</div>';
855
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
856
	return $content;
857
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
858
859
/**
860
 * Outputs the Single Plan Workout main content.
861
 *
862
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
863
 */
864
function lsx_health_plan_meal_main_content() {
865
	// Getting translated endpoint.
866
	$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
867
868
	$connected_members = get_post_meta( get_the_ID(), ( $meal . '_connected_team_member' ), true );
0 ignored issues
show
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

868
	$connected_members = get_post_meta( get_the_ID(), ( /** @scrutinizer ignore-type */ $meal . '_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

868
	$connected_members = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), ( $meal . '_connected_team_member' ), true );
Loading history...
869
	$small_description = get_post_meta( get_the_ID(), ( $meal . '_short_description' ), true );
870
871
	$content_meal = '';
872
	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...
873
		$content_meal .= '<div class="set-box set content-box entry-content">';
874
		$content_meal .= '<div class="the-content">';
875
		$content_meal .= lsx_hp_member_connected( $connected_members, $meal );
876
		$content_meal .= '<span>' . $small_description . '</span>';
877
		$content_meal .= '</div>';
878
		$content_meal .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
879
		$content_meal .= '</div>';
880
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
881
	return $content_meal;
882
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
883
884
885
/**
886
 * Outputs the Single Plan Workout Tab based on the layout selected.
887
 *
888
 * @param  string $index
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
889
 * @return void
890
 */
891
function lsx_health_plan_workout_tab_content( $index = 1 ) {
892
	global $group_name,$shortcode_args;
893
	$group_name = 'workout_section_' . $index;
894
	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...
895
		$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 $str 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

895
		$layout = strtolower( /** @scrutinizer ignore-type */ \lsx_health_plan\functions\get_option( 'workout_tab_layout', 'table' ) );
Loading history...
896
897
		// Check for shortcode overrides.
898
		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...
899
			$layout = $shortcode_args['layout'];
900
		}
901
	} else {
902
		$layout = 'table';
903
	}
904
905
	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...
906
		case 'list':
907
			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-list.php';
908
			break;
909
910
		case 'grid':
911
			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-grid.php';
912
			break;
913
914
		case 'table':
915
			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-table.php';
916
			break;
917
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
918
	$tab_template_path = apply_filters( 'lsx_health_plan_workout_tab_content_path', $tab_template_path );
919
	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...
920
		include $tab_template_path;
921
	}
922
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
923
924
/**
925
 * This will detect and include the Workout sets loop.
926
 *
927
 * @return void
928
 */
929
function lsx_health_plan_workout_sets() {
930
	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...
931
		global $connected_workouts;
932
		$connected_workouts = array( get_the_ID() );
933
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
934
	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...
935
936
		global $connected_workouts;
937
938
		$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...
939
		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...
940
			$section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key );
941
			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...
942
943
				$connected_workouts = \lsx_health_plan\functions\prep_array( $section_info['connected_workouts'] );
944
			}
945
		}
946
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
947
	$template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
948
	$template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
949
	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...
950
		include $template_path;
951
	}
952
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
953
954
/**
955
 * This will detect and include the Warmup sets loop.
956
 *
957
 * @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...
958
 * @return void
959
 */
960
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...
961
	
962
	$template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
963
	$template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
964
	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...
965
		include $template_path;
966
	}
967
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
968
969
/**
970
 * Outputs the recipes connected to the meal plan.
971
 *
972
 * @param array $args
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
973
 * @return void
974
 */
975
function lsx_hp_meal_plan_recipes( $args = array() ) {
976
	$defaults = array(
977
		'meal_id'   => false,
978
		'meal_time' => '',
979
		'modal'     => true,
980
	);
981
	$args     = wp_parse_args( $args, $defaults );
982
	// Looking for recipes.
983
	$connected_recipes = get_post_meta( $args['meal_id'], $args['meal_time'] . '_recipes', true );
984
	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...
985
		$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...
986
			'orderby'   => 'date',
987
			'order'     => 'DESC',
988
			'post_type' => 'recipe',
989
			'post__in'  => $connected_recipes,
990
		);
991
		$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...
992
		?>
993
		<div class="recipes">
994
			<div class="row eating-row">
995
			<?php
996
			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...
997
				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...
998
					$recipes->the_post();
999
					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...
1000
						\lsx_health_plan\functions\recipes\register_recipe_modal();
1001
					}
1002
					?>
1003
					<div class="recipe-column">
1004
						<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

1004
						<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...
1005
							<div class="recipe-feature-img">
1006
								<?php
1007
								$featured_image = get_the_post_thumbnail();
1008
								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...
1009
									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...
1010
										'class' => 'aligncenter',
1011
									) );
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...
1012
								} else {
1013
									?>
1014
									<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __DIR__ ) . 'assets/images/placeholder.jpg' ); ?>">
1015
									<?php
1016
								}
1017
								?>
1018
							</div>
1019
							<div class="recipe-content">
1020
								<h3 class="recipe-title"><?php the_title(); ?></h3>
1021
								<?php lsx_health_plan_recipe_data(); ?>
1022
							</div>
1023
						</a>
1024
					</div>
1025
				<?php
1026
				}
1027
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1028
			wp_reset_postdata();
1029
			?>
1030
			</div>
1031
		</div>
1032
		<?php
1033
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
1034
	}
1035
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
1036
1037
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$args" missing
Loading history...
1038
 * Output the connected.
1039
 */
1040
function lsx_hp_recipe_plan_meta( $args = array() ) {
1041
	$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...
1042
	$top_level_plans = array();
1043
	// Get meals this exercise is connected to.
1044
	$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

1044
	$plans = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'connected_plans', true );
Loading history...
1045
	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...
1046
		$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, 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

1046
		$plan       = end( /** @scrutinizer ignore-type */ $plans );
Loading history...
1047
		$has_parent = wp_get_post_parent_id( $plan );
1048
		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...
1049
			$top_level_plans[] = $plan;
1050
		} 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...
1051
			$top_level_plans[] = $has_parent;
1052
		}
1053
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1054
	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...
1055
		$top_level_plans = array_unique( $top_level_plans );
1056
		$top_level_plan  = end( $top_level_plans );
1057
		?>
1058
			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1059
		<?php
1060
	}
1061
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
1062
1063
/**
1064
 * Output the connected.
1065
 */
1066
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...
1067
1068
	$top_level_plans = array();
1069
1070
	// Get workouts this exercise is connected to.
1071
	$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

1071
	$workouts = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'connected_workouts', true );
Loading history...
1072
1073
	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...
1074
		$workouts = array( $workouts );
1075
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1076
	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...
1077
		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...
1078
			// Get the plans this workout is connected to.
1079
			$plans = get_post_meta( $workout, 'connected_plans', true );
1080
1081
			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...
1082
				$plans = array( $plans );
1083
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1084
			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...
1085
				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...
1086
					$has_parent = wp_get_post_parent_id( $plan );
1087
					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...
1088
						$top_level_plans = $plan;
1089
					} else {
1090
						$top_level_plans = $has_parent;
1091
					}
1092
				}
1093
			}
1094
		}
1095
	}
1096
1097
	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...
1098
		$top_level_plans = array_unique( $top_level_plans );
1099
		$top_level_plan  = end( $top_level_plans );
1100
		?>
1101
			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1102
		<?php
1103
	}
1104
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
1105
1106
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$post_type_text" missing
Loading history...
1107
 * Template for related content box for all singles.
1108
 *
1109
 * @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...
1110
 * @return void
1111
 */
1112
function lsx_hp_single_related( $related_content, $post_type_text ) {
1113
	?>
1114
	<section id="lsx-hp-related">
1115
		<div class="row lsx-related-posts lsx-related-posts-title">
1116
			<div class="col-xs-12">
1117
				<h2 class="lsx-related-posts-headline"><?php echo esc_html( $post_type_text ); ?></h2>
1118
			</div>
1119
		</div>
1120
		<div class="row lsx-related-posts lsx-related-posts-content">
1121
			<div class="col-xs-12">
1122
				<div class="lsx-related-posts-wrapper">
1123
					<?php
1124
					$i = 0;
1125
					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...
1126
						$post_title      = get_the_title( $article );
1127
						$post_categories = wp_get_post_categories( $article );
1128
						$post_link       = get_permalink( $article );
1129
1130
						$cats = array();
1131
						?>
1132
						<article id="post-<?php echo esc_html( $article ); ?>" class="lsx-slot post">
1133
							<div class="entry-layout lsx-hp-shadow">
1134
								<div class="entry-layout-content">
1135
									<header class="entry-header">
1136
										<div class="entry-image">
1137
											<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

1137
											<a href="<?php echo esc_url( /** @scrutinizer ignore-type */ $post_link ); ?>" class="thumbnail">
Loading history...
1138
											<?php
1139
											$featured_image = get_the_post_thumbnail( $article, 'lsx-thumbnail-wide' );
1140
											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...
1141
												echo wp_kses_post( $featured_image );
1142
											} else {
1143
												?>
1144
												<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
1145
												<?php
1146
											}
1147
											?>
1148
											</a>
1149
										</div>
1150
										<div class="entry-meta">
1151
										<?php
1152
										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...
1153
											$cat = get_category( $c );
1154
											/* Translators: %s: category name */
1155
											$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...
1156
										}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1157
										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...
1158
											<div class="post-categories"><span></span><?php echo wp_kses_post( implode( ', ', $cats ) ); ?></div>
1159
										<?php } ?>
1160
										</div>
1161
										<h2 class="entry-title">
1162
											<a href="<?php echo esc_url( $post_link ); ?>">
1163
												<?php echo esc_html( $post_title ); ?>
1164
											</a>
1165
										</h2>
1166
									</header>
1167
								</div>
1168
							</div>
1169
						</article>
1170
1171
					<?php
1172
					if (++$i === 3) break;
0 ignored issues
show
introduced by
Use Yoda Condition checks, you must.
Loading history...
1173
					} ?>
0 ignored issues
show
Coding Style introduced by
Closing PHP tag must be on a line by itself
Loading history...
1174
				</div>
1175
			</div>
1176
		</div>
1177
	</section>
1178
	<?php
1179
}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
1180
1181
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$post_type" missing
Loading history...
1182
 * Template for connected members.
1183
 *
1184
 * @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...
1185
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
1186
 */
1187
function lsx_hp_member_connected( $connected_members, $post_type ) {
1188
	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...
1189
		$content = '<div id="hp-connected-members" class="hp-connected-members connected-' . $post_type . '">';
1190
		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...
1191
			$post_link   = get_permalink( $member );
1192
			$member_name = get_the_title( $member );
1193
			$member_name = '<span class="lsx-team-name">' . $member_name . '</span>';
1194
1195
			$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

1195
			$member_link = '<a href="' . /** @scrutinizer ignore-type */ $post_link . '" >' . $member_name . '</a>';
Loading history...
1196
1197
			$roles = '';
1198
			$terms = get_the_terms( $member, 'team_role' );
1199
1200
			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...
1201
				$roles = array();
1202
1203
				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...
1204
					$roles[] = $term->name;
1205
				}
1206
1207
				$roles = join( ', ', $roles );
1208
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1209
			$member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : '';
1210
1211
			$content .= '<p>' . $member_roles . ': ' . $member_link . '</p>';
1212
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1213
		$content .= '</div>';
1214
		return $content;
1215
	}
1216
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
1217