Issues (4138)

templates/partials/workout-table.php (59 issues)

1
<?php
2
/**
3
 * Template used to display the workout content in table form
4
 *
5
 * @package lsx-health-plan
6
 */
7
8
global $group_name;
9
$groups = get_post_meta( get_the_ID(), $group_name, true );
0 ignored issues
show
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

9
$groups = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), $group_name, true );
Loading history...
10
if ( is_singular( 'workout' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
11
	$groups = get_post_meta( get_queried_object_id(), $group_name, true );
12
}
0 ignored issues
show
No blank line found after control structure
Loading history...
13
if ( ! empty( $groups ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
14
	?>
15
	<div class="set-table">
16
		<table class="workout-table">
17
			<?php
18
			$table_headers = array();
19
			$table_body    = array();
20
21
			foreach ( $groups as $group ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
22
				$this_row = array();
23
24
				$this_row[] = '<tr>';
25
26
				// Getting the connected exercise.
27
				if ( post_type_exists( 'exercise' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
28
					if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] && ! empty( \lsx_health_plan\functions\check_posts_exist( array( $group['connected_exercises'] ) ) ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
29
						$exercise    = $group['connected_exercises'];
30
						$exercise_id = get_post( $exercise );
31
					}
32
				} else {
33
					$exercise    = false;
34
					$exercise_id = false;
35
				}
36
37
				if ( false !== $exercise && '' !== $exercise ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
38
					$exercise_name         = get_the_title( $exercise_id );
39
					$this_row[]            = '<td class="workout-title-item">' . esc_html( $exercise_name ) . '</td>';
40
					$table_headers['name'] = true;
41
				} else {
42
					if ( isset( $group['name'] ) && '' !== $group['name'] ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
43
						$this_row[]            = '<td class="workout-title-item">' . esc_html( $group['name'] ) . '</td>';
44
						$table_headers['name'] = true;
45
					}
46
				}
0 ignored issues
show
No blank line found after control structure
Loading history...
47
				// Only display this is exercise is disabled.
48
				if ( false === $exercise && isset( $group['description'] ) && '' !== $group['description'] ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
49
					$this_row[]                   = '<td class="workout-desc-item"><p>' . esc_html( $group['description'] ) . '</td>';
50
					$table_headers['description'] = true;
51
				}
52
53
				if ( isset( $group['reps'] ) && '' !== $group['reps'] ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
54
					$this_row[]            = '<td class="reps-field-item center-mobile">' . esc_html( $group['reps'] ) . '</td>';
55
					$table_headers['reps'] = true;
56
				}
57
58
				// Only display this is exercise is disabled.
59
				if ( false === $exercise ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
60
					if ( isset( $group['equipment'] ) && '' !== $group['equipment'] ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
61
						$this_row[]                 = '<td class="equipment-field-item center-mobile">' . esc_html( $group['equipment'] ) . '</td>';
62
						$table_headers['equipment'] = true;
63
					}
0 ignored issues
show
No blank line found after control structure
Loading history...
64
					if ( isset( $group['muscle'] ) && '' !== $group['muscle'] ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
65
						$this_row[]              = '<td class="muscle-field-item center-mobile">' . esc_html( $group['muscle'] ) . '</td>';
66
						$table_headers['muscle'] = true;
67
					}
68
				}
0 ignored issues
show
No blank line found after control structure
Loading history...
69
				if ( post_type_exists( 'video' ) && isset( $group['connected_videos'] ) && '' !== $group['connected_videos'] && ! empty( \lsx_health_plan\functions\check_posts_exist( array( $group['connected_videos'] ) ) ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
70
					$this_row[]             = '<td class="video-button-item center-mobile">' . lsx_health_plan_workout_video_play_button( $m, $group, false ) . '</td>';
0 ignored issues
show
Are you sure lsx_health_plan_workout_...tton($m, $group, false) of type void 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

70
					$this_row[]             = '<td class="video-button-item center-mobile">' . /** @scrutinizer ignore-type */ lsx_health_plan_workout_video_play_button( $m, $group, false ) . '</td>';
Loading history...
71
					$table_headers['video'] = true;
72
				}
0 ignored issues
show
No blank line found after control structure
Loading history...
73
				if ( post_type_exists( 'exercise' ) && isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] && ! empty( \lsx_health_plan\functions\check_posts_exist( array( $group['connected_exercises'] ) ) ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
74
					$this_row[]             = '<td class="video-button-item center-mobile">' . lsx_health_plan_workout_exercise_button( $m, $group, false ) . '</td>';
0 ignored issues
show
Are you sure lsx_health_plan_workout_...tton($m, $group, false) of type void 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

74
					$this_row[]             = '<td class="video-button-item center-mobile">' . /** @scrutinizer ignore-type */ lsx_health_plan_workout_exercise_button( $m, $group, false ) . '</td>';
Loading history...
Equals sign not aligned with surrounding assignments; expected 16 spaces but found 13 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...
75
					$table_headers['exercise'] = true;
76
				}
0 ignored issues
show
No blank line found after control structure
Loading history...
77
				$this_row[] = '</tr>';
78
79
				$table_body[] = implode( '', $this_row );
80
				$m++;
81
			}
82
83
			// Now we build the table header.
84
			$table_header   = array();
85
			$table_header[] = '<tr>';
86
			if ( isset( $table_headers['name'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
87
				$table_header[] = '<th class="center-mobile">' . __( 'Workout', 'lsx-health-plan' ) . '</th>';
88
			}
0 ignored issues
show
No blank line found after control structure
Loading history...
89
			if ( isset( $table_headers['description'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
90
				$table_header[] = '<th class="center-mobile">' . __( 'Description', 'lsx-health-plan' ) . '</th>';
91
			}
0 ignored issues
show
No blank line found after control structure
Loading history...
92
			if ( isset( $table_headers['reps'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
93
				$table_header[] = '<th class="center-mobile">' . __( 'Reps / Time / Distance', 'lsx-health-plan' ) . '</th>';
94
			}
0 ignored issues
show
No blank line found after control structure
Loading history...
95
			if ( isset( $table_headers['equipment'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
96
				$table_header[] = '<th class="center-mobile">' . __( 'Equipment', 'lsx-health-plan' ) . '</th>';
97
			}
0 ignored issues
show
No blank line found after control structure
Loading history...
98
			if ( isset( $table_headers['muscle'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
99
				$table_header[] = '<th class="center-mobile">' . __( 'Muscle', 'lsx-health-plan' ) . '</th>';
100
			}
0 ignored issues
show
No blank line found after control structure
Loading history...
101
			if ( isset( $table_headers['video'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
102
				$table_header[] = '<th class="center-mobile">' . __( 'How To', 'lsx-health-plan' ) . '</th>';
103
			}
0 ignored issues
show
No blank line found after control structure
Loading history...
104
			if ( isset( $table_headers['exercise'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
105
				$table_header[] = '<th class="center-mobile">' . __( 'How To', 'lsx-health-plan' ) . '</th>';
106
			}
0 ignored issues
show
No blank line found after control structure
Loading history...
107
			$table_header[] = '</tr>';
108
			?>
109
			<thead>
110
				<?php echo wp_kses_post( implode( '', $table_header ) ); ?>
111
			</thead>
112
			<tbody>
113
				<?php echo wp_kses_post( implode( '', $table_body ) ); ?>
114
			</tbody>
115
		</table>
116
	</div>
117
	<?php
118
}
119