Passed
Push — master ( b08fc9...43702f )
by Virginia
04:52
created

lsx_health_plan_warmup_box()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 21
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

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

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

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

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

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

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

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

181
			<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...
182
		</ul>
183
	</div>
184
	<?php
185
}
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...
186
187
/**
188
 * Outputs the my profile box
189
 *
190
 * @return void
191
 */
192
function lsx_health_plan_my_profile_box() {
193
	?>
194
	<div class="lsx-health-plan my-profile-block wp-block-cover alignfull">
195
		<div class="wp-block-cover__inner-container">
196
			<h2><?php esc_html_e( 'My Dashboard', 'lsx-health-plan' ); ?></h2>
197
			<section id="dashboard-card">
198
				<div class="profile-navigation">
199
					<div class="profile-photo">
200
					<?php
201
						global $current_user;
202
						get_current_user();
203
						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

203
						echo /** @scrutinizer ignore-type */ get_avatar( $current_user->ID, 240 );
Loading history...
204
						?>
205
					</div>
206
				</div>
207
				<div class="profile-details">
208
					<h1 class="title-lined has-text-color"><?php echo esc_html( $current_user->display_name ); ?></h1>
209
					<?php
210
					$disable_stats = \lsx_health_plan\functions\get_option( 'disable_all_stats', false );
211
					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...
212
213
						$is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false );
214
						$is_height_disabled = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false );
215
						$is_waist_disabled  = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false );
216
						$is_bmi_disabled    = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false );
217
218
						$weight = get_user_meta( get_current_user_id(), 'weight', true );
219
						$waist  = get_user_meta( get_current_user_id(), 'waist', true );
220
						$height = get_user_meta( get_current_user_id(), 'height', true );
221
						
222
						$height_m = 0;
223
						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...
224
							$height_m = $height / 100;
225
						}
226
227
						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...
228
							$bmi = $weight / ( $height_m * $height_m );
229
							$bmi = number_format( $bmi, 1 );
230
						} else {
231
							$bmi = __( 'Add more data', 'lsx-health-plan' );
232
						}
233
234
						?>
235
236
						<div>
237
							<?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...
238
								<span><strong><?php esc_html_e( 'Weight:', 'lsx-health-plan' ); ?></strong>
239
								<?php
240
								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...
241
									echo wp_kses_post( $weight . ' kg' );
242
								} else {
243
									echo '/';
244
								}
245
								?>
246
								</span>
247
							<?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...
248
							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...
249
								?>
250
								<span><strong><?php esc_html_e( 'Waist:', 'lsx-health-plan' ); ?></strong>
251
								<?php
252
								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...
253
									echo wp_kses_post( $waist . ' cm' );
254
								} else {
255
									echo '/';
256
								}
257
								?>
258
								</span>
259
							<?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...
260
							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...
261
								?>
262
								<span><strong><?php esc_html_e( 'BMI:', 'lsx-health-plan' ); ?></strong>
263
								<?php
264
								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...
265
									echo wp_kses_post( $bmi );
266
								} else {
267
									echo '/';
268
								}
269
								?>
270
								</span>
271
							<?php } ?>
272
						</div>
273
					<?php
274
					}
275
					?>
276
					<div class="edit-profile">
277
						<?php
278
						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...
279
							$url_id = wc_get_page_id( 'myaccount' );
280
						} else {
281
							$url_id = '';
282
						}
283
						?>
284
						<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

284
						<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...
285
					</div>
286
				</div>
287
			</section>
288
		</div>
289
	</div>
290
	<?php
291
}
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...
292
293
/**
294
 * Outputs the my profile list of plans box
295
 *
296
 * @return void
297
 */
298
function lsx_health_plan_all_plans_block() {
299
	global $post, $product;
300
301
	$args = array(
302
		'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...
303
		'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...
304
		'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...
305
		'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...
306
		'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...
307
	);
308
309
	$product_ids = \lsx_health_plan\functions\woocommerce\get_membership_products();
310
	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...
311
		$args['meta_query'] = array(
0 ignored issues
show
introduced by
Detected usage of meta_query, possible slow query.
Loading history...
312
			'relation' => 'OR',
313
			array(
314
				'key'     => '_plan_product_id',
315
				'value'   => $product_ids,
316
				'compare' => 'IN',
317
			),
318
			array(
319
				'key'     => '_plan_product_id',
320
				'compare' => 'NOT EXISTS',
321
			),
322
		);
323
	}
324
325
	$the_query = new WP_Query( $args );
326
	?>
327
	<div class="all-plans-block plan-grid block-all-plans-block">
328
		<div class="row">
329
			<?php
330
			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...
331
				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...
332
					$the_query->the_post();
333
					lsx_entry_before();
334
					$completed_class = '';
335
					$linked_product  = false;
336
					$restricted      = false;
337
					$product         = null;
338
					if ( function_exists( 'lsx_health_plan\functions\woocommerce\plan_has_products' ) && \lsx_health_plan\functions\woocommerce\plan_has_products() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
339
						$products       = \lsx_health_plan\functions\woocommerce\get_plan_products();
340
						$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

340
						$linked_product = /** @scrutinizer ignore-call */ wc_get_product( $products[0] );
Loading history...
341
						$product        = $linked_product;
342
					}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
343
					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...
344
						$restricted = wc_memberships_is_post_content_restricted( get_the_ID() ) && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() );
345
					}
346
347
					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...
348
						$completed_class = 'completed';
349
					}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
350
					$round_progress     = '';
351
					$completed_progress = '100';
352
					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...
353
						$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

353
						$round_progress = round( \lsx_health_plan\functions\get_progress( /** @scrutinizer ignore-type */ get_the_ID() ), 0 );
Loading history...
354
					}
355
					?>
356
					<div class="col-xs-12 col-sm-6 col-md-4">
357
						<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...
358
							<div class="plan-feature-img">
359
								<?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...
360
									<span class="featured-plan"><?php lsx_get_svg_icon( 'icon-completed.svg' ); ?></span>
361
								<?php } ?>
362
								<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

362
								<a href="<?php echo esc_url( /** @scrutinizer ignore-type */ get_permalink() ); ?>">
Loading history...
363
								<?php
364
								$featured_image = get_the_post_thumbnail();
365
								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...
366
									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...
367
										'class' => 'aligncenter',
368
									) );
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...
369
								} else {
370
									?>
371
									<img loading="lazy"  class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
372
									<?php
373
								}
374
								?>
375
								</a>
376
							</div>
377
							<div class="content-box plan-content-box">
378
								<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>
379
								<?php
380
									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

380
									echo wp_kses_post( /** @scrutinizer ignore-type */ \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) );
Loading history...
381
								?>
382
								<?php
383
								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...
384
									echo wp_kses_post( $linked_product->get_price_html() );
385
								}
386
								?>
387
								<div class="excerpt">
388
									<?php
389
									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...
390
										$content = wp_trim_words( get_the_content(), 20 );
391
										$content = '<p>' . $content . '</pre>';
392
									} else {
393
										$content = apply_filters( 'the_excerpt', get_the_excerpt() );
394
									}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
395
									echo wp_kses_post( $content );
396
									?>
397
								</div>
398
								<?php
399
								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...
400
									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>' );
401
								}
402
								?>
403
							</div>
404
						</article>
405
					</div>
406
				<?php endwhile; ?>
407
			<?php endif; ?>
408
		</div>
409
		<?php wp_reset_postdata(); ?>
410
	</div>
411
412
<?php
413
}
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...
414
415
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$args" missing
Loading history...
416
 * Outputs the my profile day view box
417
 *
418
 * @return void
419
 */
420
function lsx_health_plan_day_plan_block( $args = array() ) {
421
	$defaults = array(
422
		'plan' => '',
423
	);
424
	$args     = wp_parse_args( $args, $defaults );
425
426
	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...
427
		$sections = \lsx_health_plan\functions\plan\get_sections();
428
		?>
429
		<div class="daily-plan-block day-grid">
430
			<?php
431
			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...
432
				$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...
433
					'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ),
434
				);
435
				$section_args = wp_parse_args( $section_values, $defaults );
436
437
				$completed_class = '';
438
				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...
439
					$completed_class = 'completed';
440
				}
441
				?>
442
				<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

442
				<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...
443
					<div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div>
444
				</a>
445
				<?php
446
			}
447
			?>
448
		</div>
449
		<?php
450
	}
451
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
452
453
/**
454
 * Outputs the my profile week view box
455
 *
456
 * @param  array $args An array of arguments.
457
 * @return void
458
 */
459
function lsx_health_plan_week_plan_block( $args = array() ) {
460
	$defaults = array(
461
		'show_downloads' => false,
462
		'plan'           => '',
463
	);
464
	$args     = wp_parse_args( $args, $defaults );
465
466
	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...
467
		$groups = \lsx_health_plan\functions\plan\get_sections( true );
468
469
		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...
470
			$counter    = 1;
471
			$group_open = false;
472
473
			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...
474
				$collapse_class = '';
475
				$group_title    = \lsx_health_plan\functions\plan\get_group_title( $sections );
476
477
				// Determine if the current week is complete.
478
				$day_ids = wp_list_pluck( $sections, 'title' );
479
				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...
480
					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...
481
						$collapse_class = 'in';
482
						$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...
483
					} 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...
484
						$collapse_class = 'in';
485
						$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...
486
					}
487
				}
488
489
				// Determine if there are any weekly downloads.
490
				$week_downloads_view = '';
491
				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...
492
					$weekly_downloads = \lsx_health_plan\functions\get_weekly_downloads( $group_key );
493
					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...
494
						$week_downloads_view = 'week-downloads-view-on';
495
					}
496
				}
497
				?>
498
				<div class="daily-plan-block week-grid">
499
					<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

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

735
	$term_obj_list = get_the_terms( /** @scrutinizer ignore-type */ get_the_ID(), 'recipe-type' );
Loading history...
736
	$recipe_type   = $term_obj_list[0]->name;
737
	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...
738
		return $recipe_type;
739
	}
740
}
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...
741
742
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$echo" missing
Loading history...
743
 * Outputs the modal button and registers the video modal to show.
744
 *
745
 * @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...
746
 * @param array $group
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
747
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
748
 */
749
function lsx_health_plan_workout_video_play_button( $m, $group, $echo = true ) {
750
	$workout_video = '';
751
	$giphy         = '';
752
	$youtube       = '';
753
	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...
754
		$workout_video = esc_html( $group['connected_videos'] );
755
		$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

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

757
		$content       = get_post_field( 'post_content', /** @scrutinizer ignore-type */ $workout_video );
Loading history...
758
		$play_button   = '<button data-toggle="modal" data-target="#workout-video-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>';
759
760
		$modal_body = '';
761
		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...
762
			$giphy      = \lsx_health_plan\functions\get_video_url( $giphy );
763
			$modal_body = $giphy; // WPCS: XSS OK.
764
		} 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...
765
			$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...
766
				'width' => 480,
767
			) );
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...
768
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
769
		$modal_body .= '<h5 class="modal-title title-lined">' . $group['name'] . '</h5>';
770
		$modal_body .= $content;
771
		\lsx_health_plan\functions\register_modal( 'workout-video-modal-' . $m, '', $modal_body );
772
773
		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...
774
			echo wp_kses_post( $play_button );
775
		} else {
776
			return $play_button;
777
		}
778
	}
779
}
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...
780
781
/**
782
 * Outputs the recipe description if it is included.
783
 *
784
 * @return void
785
 */
786
function lsx_health_plan_recipe_archive_description() {
787
	$description = '';
788
	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...
789
		$description = \lsx_health_plan\functions\get_option( 'recipe_archive_description', '' );
790
	} 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...
791
		$description = \lsx_health_plan\functions\get_option( 'exercise_archive_description', '' );
792
	} 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...
793
		$description = get_the_archive_description();
794
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
795
	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...
796
		?>
797
		<div class="lsx-hp-archive-description row">
798
			<div class="col-xs-12 description-wrapper"><?php echo wp_kses_post( wpautop( $description ) ); ?></div>
799
		</div>
800
		<?php
801
	}
802
}
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...
803
804
/**
805
 * Outputs the Single Plan Workout main content.
806
 *
807
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
808
 */
809
function lsx_health_plan_workout_main_content() {
810
	// Getting translated endpoint.
811
	$workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
812
813
	$connected_members = get_post_meta( get_the_ID(), ( $workout . '_connected_team_member' ), true );
0 ignored issues
show
Bug introduced by
Are you sure $workout of type array|mixed can be used in concatenation? ( Ignorable by Annotation )

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

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

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

813
	$connected_members = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), ( $workout . '_connected_team_member' ), true );
Loading history...
814
	$small_description = get_post_meta( get_the_ID(), ( $workout . '_short_description' ), true );
815
816
	$content = '';
817
	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...
818
		$content .= '<div class="short-desc set-box set content-box entry-content">';
819
		$content .= '<div class="the-content">';
820
		$content .= lsx_hp_member_connected( $connected_members, $workout );
821
		$content .= '<span>' . $small_description . '</span>';
822
		$content .= '</div>';
823
		$content .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
824
		$content .= '</div>';
825
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
826
	return $content;
827
}
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...
828
829
/**
830
 * Outputs the Single Plan Workout main content.
831
 *
832
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
833
 */
834
function lsx_health_plan_meal_main_content() {
835
	// Getting translated endpoint.
836
	$meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
837
838
	$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

838
	$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

838
	$connected_members = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), ( $meal . '_connected_team_member' ), true );
Loading history...
839
	$small_description = get_post_meta( get_the_ID(), ( $meal . '_short_description' ), true );
840
841
	$content_meal = '';
842
	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...
843
		$content_meal .= '<div class="set-box set content-box entry-content">';
844
		$content_meal .= '<div class="the-content">';
845
		$content_meal .= lsx_hp_member_connected( $connected_members, $meal );
846
		$content_meal .= '<span>' . $small_description . '</span>';
847
		$content_meal .= '</div>';
848
		$content_meal .= do_shortcode( '[lsx_health_plan_featured_tips_block]' );
849
		$content_meal .= '</div>';
850
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
851
	return $content_meal;
852
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
853
854
855
/**
856
 * Outputs the Single Plan Workout Tab based on the layout selected.
857
 *
858
 * @param  string $index
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
859
 * @return void
860
 */
861
function lsx_health_plan_workout_tab_content( $index = 1 ) {
862
	global $group_name,$shortcode_args;
863
	$group_name = 'workout_section_' . $index;
864
	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...
865
		$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

865
		$layout = strtolower( /** @scrutinizer ignore-type */ \lsx_health_plan\functions\get_option( 'workout_tab_layout', 'table' ) );
Loading history...
866
867
		// Check for shortcode overrides.
868
		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...
869
			$layout = $shortcode_args['layout'];
870
		}
871
	} else {
872
		$layout = 'table';
873
	}
874
875
	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...
876
		case 'list':
877
			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-list.php';
878
			break;
879
880
		case 'grid':
881
			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-grid.php';
882
			break;
883
884
		case 'table':
885
			$tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-table.php';
886
			break;
887
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
888
	$tab_template_path = apply_filters( 'lsx_health_plan_workout_tab_content_path', $tab_template_path );
889
	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...
890
		include $tab_template_path;
891
	}
892
}
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...
893
894
/**
895
 * This will detect and include the Workout sets loop.
896
 *
897
 * @return void
898
 */
899
function lsx_health_plan_workout_sets() {
900
	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...
901
		global $connected_workouts;
902
		$connected_workouts = array( get_the_ID() );
903
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
904
	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...
905
906
		global $connected_workouts;
907
908
		$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...
909
		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...
910
			$section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key );
911
			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...
912
913
				$connected_workouts = \lsx_health_plan\functions\prep_array( $section_info['connected_workouts'] );
914
			}
915
		}
916
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
917
	$template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
918
	$template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
919
	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...
920
		include $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 Warmup sets loop.
926
 *
927
 * @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...
928
 * @return void
929
 */
930
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...
931
	
932
	$template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php';
933
	$template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path );
934
	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...
935
		include $template_path;
936
	}
937
}
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...
938
939
/**
940
 * Outputs the recipes connected to the meal plan.
941
 *
942
 * @param array $args
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
943
 * @return void
944
 */
945
function lsx_hp_meal_plan_recipes( $args = array() ) {
946
	$defaults = array(
947
		'meal_id'   => false,
948
		'meal_time' => '',
949
		'modal'     => true,
950
	);
951
	$args     = wp_parse_args( $args, $defaults );
952
	// Looking for recipes.
953
	$connected_recipes = get_post_meta( $args['meal_id'], $args['meal_time'] . '_recipes', true );
954
	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...
955
		$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...
956
			'orderby'   => 'date',
957
			'order'     => 'DESC',
958
			'post_type' => 'recipe',
959
			'post__in'  => $connected_recipes,
960
		);
961
		$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...
962
		?>
963
		<div class="recipes">
964
			<div class="row eating-row">
965
			<?php
966
			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...
967
				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...
968
					$recipes->the_post();
969
					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...
970
						\lsx_health_plan\functions\recipes\register_recipe_modal();
971
					}
972
					?>
973
					<div class="recipe-column">
974
						<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

974
						<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...
975
							<div class="recipe-feature-img">
976
								<?php
977
								$featured_image = get_the_post_thumbnail();
978
								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...
979
									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...
980
										'class' => 'aligncenter',
981
									) );
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...
982
								} else {
983
									?>
984
									<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __DIR__ ) . 'assets/images/placeholder.jpg' ); ?>">
985
									<?php
986
								}
987
								?>
988
							</div>
989
							<div class="recipe-content">
990
								<h3 class="recipe-title"><?php the_title(); ?></h3>
991
								<?php lsx_health_plan_recipe_data(); ?>
992
							</div>
993
						</a>
994
					</div>
995
				<?php
996
				}
997
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
998
			wp_reset_postdata();
999
			?>
1000
			</div>
1001
		</div>
1002
		<?php
1003
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
1004
	}
1005
}
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...
1006
1007
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$args" missing
Loading history...
1008
 * Output the connected.
1009
 */
1010
function lsx_hp_recipe_plan_meta( $args = array() ) {
1011
	$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...
1012
	$top_level_plans = array();
1013
	// Get meals this exercise is connected to.
1014
	$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

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

1016
		$plan       = end( /** @scrutinizer ignore-type */ $plans );
Loading history...
1017
		$has_parent = wp_get_post_parent_id( $plan );
1018
		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...
1019
			$top_level_plans[] = $plan;
1020
		} 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...
1021
			$top_level_plans[] = $has_parent;
1022
		}
1023
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1024
	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...
1025
		$top_level_plans = array_unique( $top_level_plans );
1026
		$top_level_plan  = end( $top_level_plans );
1027
		?>
1028
			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1029
		<?php
1030
	}
1031
}
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...
1032
1033
/**
1034
 * Output the connected.
1035
 */
1036
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...
1037
1038
	$top_level_plans = array();
1039
1040
	// Get workouts this exercise is connected to.
1041
	$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

1041
	$workouts = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'connected_workouts', true );
Loading history...
1042
1043
	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...
1044
		$workouts = array( $workouts );
1045
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1046
	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...
1047
		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...
1048
			// Get the plans this workout is connected to.
1049
			$plans = get_post_meta( $workout, 'connected_plans', true );
1050
1051
			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...
1052
				$plans = array( $plans );
1053
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1054
			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...
1055
				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...
1056
					$has_parent = wp_get_post_parent_id( $plan );
1057
					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...
1058
						$top_level_plans = $plan;
1059
					} else {
1060
						$top_level_plans = $has_parent;
1061
					}
1062
				}
1063
			}
1064
		}
1065
	}
1066
1067
	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...
1068
		$top_level_plans = array_unique( $top_level_plans );
1069
		$top_level_plan  = end( $top_level_plans );
1070
		?>
1071
			<span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span>
1072
		<?php
1073
	}
1074
}
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...
1075
1076
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$post_type_text" missing
Loading history...
1077
 * Template for related content box for all singles.
1078
 *
1079
 * @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...
1080
 * @return void
1081
 */
1082
function lsx_hp_single_related( $related_content, $post_type_text ) {
1083
	?>
1084
	<section id="lsx-hp-related">
1085
		<div class="row lsx-related-posts lsx-related-posts-title">
1086
			<div class="col-xs-12">
1087
				<h2 class="lsx-related-posts-headline"><?php echo esc_html( $post_type_text ); ?></h2>
1088
			</div>
1089
		</div>
1090
		<div class="row lsx-related-posts lsx-related-posts-content">
1091
			<div class="col-xs-12">
1092
				<div class="lsx-related-posts-wrapper">
1093
					<?php
1094
					$i = 0;
1095
					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...
1096
						$post_title      = get_the_title( $article );
1097
						$post_categories = wp_get_post_categories( $article );
1098
						$post_link       = get_permalink( $article );
1099
1100
						$cats = array();
1101
						?>
1102
						<article id="post-<?php echo esc_html( $article ); ?>" class="lsx-slot post">
1103
							<div class="entry-layout lsx-hp-shadow">
1104
								<div class="entry-layout-content">
1105
									<header class="entry-header">
1106
										<div class="entry-image">
1107
											<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

1107
											<a href="<?php echo esc_url( /** @scrutinizer ignore-type */ $post_link ); ?>" class="thumbnail">
Loading history...
1108
											<?php
1109
											$featured_image = get_the_post_thumbnail( $article, 'lsx-thumbnail-wide' );
1110
											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...
1111
												echo wp_kses_post( $featured_image );
1112
											} else {
1113
												?>
1114
												<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
1115
												<?php
1116
											}
1117
											?>
1118
											</a>
1119
										</div>
1120
										<div class="entry-meta">
1121
										<?php
1122
										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...
1123
											$cat = get_category( $c );
1124
											/* Translators: %s: category name */
1125
											$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...
1126
										}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1127
										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...
1128
											<div class="post-categories"><span></span><?php echo wp_kses_post( implode( ', ', $cats ) ); ?></div>
1129
										<?php } ?>
1130
										</div>
1131
										<h2 class="entry-title">
1132
											<a href="<?php echo esc_url( $post_link ); ?>">
1133
												<?php echo esc_html( $post_title ); ?>
1134
											</a>
1135
										</h2>
1136
									</header>
1137
								</div>
1138
							</div>
1139
						</article>
1140
1141
					<?php
1142
					if (++$i === 3) break;
0 ignored issues
show
introduced by
Use Yoda Condition checks, you must.
Loading history...
1143
					} ?>
0 ignored issues
show
Coding Style introduced by
Closing PHP tag must be on a line by itself
Loading history...
1144
				</div>
1145
			</div>
1146
		</div>
1147
	</section>
1148
	<?php
1149
}
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...
1150
1151
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$post_type" missing
Loading history...
1152
 * Template for connected members.
1153
 *
1154
 * @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...
1155
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
1156
 */
1157
function lsx_hp_member_connected( $connected_members, $post_type ) {
1158
	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...
1159
		$content = '<div id="hp-connected-members" class="hp-connected-members connected-' . $post_type . '">';
1160
		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...
1161
			$post_link   = get_permalink( $member );
1162
			$member_name = get_the_title( $member );
1163
			$member_name = '<span class="lsx-team-name">' . $member_name . '</span>';
1164
1165
			$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

1165
			$member_link = '<a href="' . /** @scrutinizer ignore-type */ $post_link . '" >' . $member_name . '</a>';
Loading history...
1166
1167
			$roles = '';
1168
			$terms = get_the_terms( $member, 'team_role' );
1169
1170
			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...
1171
				$roles = array();
1172
1173
				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...
1174
					$roles[] = $term->name;
1175
				}
1176
1177
				$roles = join( ', ', $roles );
1178
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1179
			$member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : '';
1180
1181
			$content .= '<p>' . $member_roles . ': ' . $member_link . '</p>';
1182
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
1183
		$content .= '</div>';
1184
		return $content;
1185
	}
1186
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
1187