lsx_health_plan_workout_exercise_button()   C
last analyzed

Complexity

Conditions 11
Paths 257

Size

Total Lines 58
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 11
eloc 40
c 2
b 0
f 0
nc 257
nop 4
dl 0
loc 58
rs 5.7708

How to fix   Long Method    Complexity   

Long Method

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

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

Commonly applied refactorings include:

1
<?php
2
/**
3
 * LSX Health Plan Template Tags.
4
 *
5
 * @package lsx-health-plan
6
 */
7
8
/**
9
 * Outputs the exercise type.
10
 *
11
 * @return exercise_type
0 ignored issues
show
Bug introduced by
The type exercise_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...
12
 */
13
function lsx_health_plan_exercise_type() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
14
	$term_obj_list = get_the_term_list( get_the_ID(), 'exercise-type', '', ', ' );
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_the_term_list() 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

14
	$term_obj_list = get_the_term_list( /** @scrutinizer ignore-type */ get_the_ID(), 'exercise-type', '', ', ' );
Loading history...
15
	if ( ! empty( $term_obj_list ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
16
		return $term_obj_list;
17
	}
18
}
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...
19
20
/**
21
 * Outputs the exercise Muscle Groups.
22
 *
23
 * @return muscle_group_equipment
0 ignored issues
show
Bug introduced by
The type muscle_group_equipment 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...
24
 */
25
function lsx_health_plan_muscle_group_equipment() {
26
	$term_obj_list = get_the_term_list( get_the_ID(), 'muscle-group', '', ', ' );
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_the_term_list() 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

26
	$term_obj_list = get_the_term_list( /** @scrutinizer ignore-type */ get_the_ID(), 'muscle-group', '', ', ' );
Loading history...
27
	if ( ! empty( $term_obj_list ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
28
		return $term_obj_list;
29
	}
30
}
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...
31
32
/**
33
 * Outputs the exercise equipment.
34
 *
35
 * @return exercise_equipment
0 ignored issues
show
Bug introduced by
The type exercise_equipment 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...
36
 */
37
function lsx_health_plan_exercise_equipment() {
38
	$term_obj_list = get_the_term_list( get_the_ID(), 'equipment', '', ', ' );
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_the_term_list() 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

38
	$term_obj_list = get_the_term_list( /** @scrutinizer ignore-type */ get_the_ID(), 'equipment', '', ', ' );
Loading history...
39
	if ( ! empty( $term_obj_list ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
40
		return $term_obj_list;
41
	}
42
}
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...
43
44
/**
45
 * Outputs the exercise info on a table.
46
 *
47
 * @return void
48
 */
49
function lsx_health_plan_exercise_data() {
50
	include LSX_HEALTH_PLAN_PATH . '/templates/table-exercise-data.php';
51
}
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...
52
53
function lsx_health_plan_workout_exercise_alt_button( $m, $group, $echo = true, $args = array(), $alt_title, $alt_description, $alt_image ) {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function lsx_health_plan_workout_exercise_alt_button()
Loading history...
54
	$defaults = array(
55
		'modal_trigger' => 'button',
56
		'modal_content' => 'excerpt',
57
	);
58
	$args     = wp_parse_args( $args, $defaults );
59
60
	$exercise_id = '';
61
	if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
62
		$exercise_id     = esc_html( $group['connected_exercises'] );
63
		$content         = get_post_field( 'post_content', $exercise_id );
0 ignored issues
show
Bug introduced by
$exercise_id 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

63
		$content         = get_post_field( 'post_content', /** @scrutinizer ignore-type */ $exercise_id );
Loading history...
64
		$url             = get_permalink( $exercise_id );
0 ignored issues
show
Bug introduced by
$exercise_id of type string is incompatible with the type WP_Post|integer expected by parameter $post of get_permalink(). ( Ignorable by Annotation )

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

64
		$url             = get_permalink( /** @scrutinizer ignore-type */ $exercise_id );
Loading history...
65
		$equipment_group = get_the_term_list( $exercise_id, 'equipment', '', ', ' );
0 ignored issues
show
Bug introduced by
$exercise_id of type string is incompatible with the type integer expected by parameter $post_id of get_the_term_list(). ( Ignorable by Annotation )

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

65
		$equipment_group = get_the_term_list( /** @scrutinizer ignore-type */ $exercise_id, 'equipment', '', ', ' );
Loading history...
66
		$muscle_group    = get_the_term_list( $exercise_id, 'muscle-group', '', ', ' );
67
		$lsx_hp          = lsx_health_plan();
68
69
		if ( 'excerpt' === $args['modal_content'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
70
			$content = wp_trim_words( $content, 40 );
71
		}
72
73
		if ( 'link' ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
74
			$play_button = '<a data-toggle="modal" href="#workout-alt-exercise-modal-' . $m . '">' . get_the_title( $exercise_id ) . '</a>';
0 ignored issues
show
Bug introduced by
$exercise_id of type string is incompatible with the type WP_Post|integer expected by parameter $post of get_the_title(). ( Ignorable by Annotation )

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

74
			$play_button = '<a data-toggle="modal" href="#workout-alt-exercise-modal-' . $m . '">' . get_the_title( /** @scrutinizer ignore-type */ $exercise_id ) . '</a>';
Loading history...
75
		} else {
76
			$play_button = '<button data-toggle="alt-modal" data-target="#workout-alt-exercise-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>';
77
		}
78
79
		$modal_body  = '';
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...
80
81
		if ( '' !== $alt_image && ! empty( $alt_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...
82
			$modal_body .= '<div class="modal-image"/><img alt="thumbnail" loading="lazy" class="aligncenter wp-post-image" src="' . $alt_image . '"></div>';
83
		} else {
84
			if ( $lsx_hp->frontend->gallery->has_gallery( $exercise_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...
85
				$gallery_args = array(
86
					'css_class' => 'modal-slider',
87
				);
88
				$modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 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...
89
			} else {
90
				$modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail( $exercise_id, 'large' ) . '</div>';
0 ignored issues
show
Bug introduced by
$exercise_id of type string is incompatible with the type WP_Post|integer expected by parameter $post of get_the_post_thumbnail(). ( Ignorable by Annotation )

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

90
				$modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail( /** @scrutinizer ignore-type */ $exercise_id, 'large' ) . '</div>';
Loading history...
91
			}
92
		}
93
94
		if ( '' !== $alt_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...
95
			$modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . $alt_title . '</h5>';
96
		} else {
97
			$modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . get_the_title( $exercise_id ) . '</h5>';
98
		}
99
100
		if ( ! empty( $equipment_group ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
101
			$modal_body .= '<span class="equipment-terms">Equipment: ' . $equipment_group . '</span>';
0 ignored issues
show
Bug introduced by
Are you sure $equipment_group of type WP_Error|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

101
			$modal_body .= '<span class="equipment-terms">Equipment: ' . /** @scrutinizer ignore-type */ $equipment_group . '</span>';
Loading history...
102
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
103
		if ( ! empty( $muscle_group ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
104
			$modal_body .= '<span class="muscle-terms">Muscle: ' . $muscle_group . '</span>';
0 ignored issues
show
Bug introduced by
Are you sure $muscle_group of type WP_Error|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

104
			$modal_body .= '<span class="muscle-terms">Muscle: ' . /** @scrutinizer ignore-type */ $muscle_group . '</span>';
Loading history...
105
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
106
		$modal_body .= '</div>';
107
		if ( '' !== $args['modal_content'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
108
			if ( '' !== $alt_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...
109
				$modal_body .= '<div class="modal-excerpt"/>' . $alt_description . '</div>';
110
			} else {
111
				$modal_body .= '<div class="modal-excerpt"/>' . $content . '</div>';
112
			}
113
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
114
		if ( 'excerpt' === $args['modal_content'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
115
			$modal_body .= '<a class="moretag" target="_blank" href="' . $url . '">' . __( 'Read More', 'lsx-heal-plan' ) . '</a>';
0 ignored issues
show
Bug introduced by
Are you sure $url 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

115
			$modal_body .= '<a class="moretag" target="_blank" href="' . /** @scrutinizer ignore-type */ $url . '">' . __( 'Read More', 'lsx-heal-plan' ) . '</a>';
Loading history...
116
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
117
		\lsx_health_plan\functions\register_modal( 'workout-alt-exercise-modal-' . $m, '', $modal_body );
118
119
		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...
120
			echo wp_kses_post( $play_button );
121
		} else {
122
			return $play_button;
123
		}
124
	}
125
}
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...
126
127
/**
128
 * A function to call the play button
129
 *
130
 * @param string  $m A unique ID for the modal.
131
 * @param array   $group The current workout set being looped through.
132
 * @param boolean $echo
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
133
 * @param array   $args
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
134
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
135
 */
136
function lsx_health_plan_workout_exercise_button( $m, $group, $echo = true, $args = array() ) {
137
	$defaults = array(
138
		'modal_trigger' => 'button',
139
		'modal_content' => 'excerpt',
140
	);
141
	$args     = wp_parse_args( $args, $defaults );
142
143
	$exercise_id = '';
144
	if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
145
		$exercise_id     = esc_html( $group['connected_exercises'] );
146
		$content         = get_post_field( 'post_content', $exercise_id );
0 ignored issues
show
Bug introduced by
$exercise_id 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

146
		$content         = get_post_field( 'post_content', /** @scrutinizer ignore-type */ $exercise_id );
Loading history...
147
		$url             = get_permalink( $exercise_id );
0 ignored issues
show
Bug introduced by
$exercise_id of type string is incompatible with the type WP_Post|integer expected by parameter $post of get_permalink(). ( Ignorable by Annotation )

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

147
		$url             = get_permalink( /** @scrutinizer ignore-type */ $exercise_id );
Loading history...
148
		$equipment_group = get_the_term_list( $exercise_id, 'equipment', '', ', ' );
0 ignored issues
show
Bug introduced by
$exercise_id of type string is incompatible with the type integer expected by parameter $post_id of get_the_term_list(). ( Ignorable by Annotation )

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

148
		$equipment_group = get_the_term_list( /** @scrutinizer ignore-type */ $exercise_id, 'equipment', '', ', ' );
Loading history...
149
		$muscle_group    = get_the_term_list( $exercise_id, 'muscle-group', '', ', ' );
150
		$lsx_hp          = lsx_health_plan();
151
152
		if ( 'excerpt' === $args['modal_content'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
153
			$content = wp_trim_words( $content, 40 );
154
		}
155
156
		if ( 'link' ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
157
			$play_button = '<a data-toggle="modal" href="#workout-exercise-modal-' . $m . '">' . get_the_title( $exercise_id ) . '</a>';
0 ignored issues
show
Bug introduced by
$exercise_id of type string is incompatible with the type WP_Post|integer expected by parameter $post of get_the_title(). ( Ignorable by Annotation )

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

157
			$play_button = '<a data-toggle="modal" href="#workout-exercise-modal-' . $m . '">' . get_the_title( /** @scrutinizer ignore-type */ $exercise_id ) . '</a>';
Loading history...
158
		} else {
159
			$play_button = '<button data-toggle="modal" data-target="#workout-exercise-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>';
160
		}
161
162
		$modal_body  = '';
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...
163
164
		if ( $lsx_hp->frontend->gallery->has_gallery( $exercise_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...
165
			$gallery_args = array(
166
				'css_class' => 'modal-slider',
167
			);
168
			$modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 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...
169
		} else {
170
			$modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail( $exercise_id, 'large' ) . '</div>';
0 ignored issues
show
Bug introduced by
$exercise_id of type string is incompatible with the type WP_Post|integer expected by parameter $post of get_the_post_thumbnail(). ( Ignorable by Annotation )

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

170
			$modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail( /** @scrutinizer ignore-type */ $exercise_id, 'large' ) . '</div>';
Loading history...
171
		}
172
173
		$modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . get_the_title( $exercise_id ) . '</h5>';
174
175
		if ( ! empty( $equipment_group ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
176
			$modal_body .= '<span class="equipment-terms">' . __( 'Equipment', 'lsx-health-plan' ) . ': ' . $equipment_group . '</span>';
0 ignored issues
show
Bug introduced by
Are you sure $equipment_group of type WP_Error|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

176
			$modal_body .= '<span class="equipment-terms">' . __( 'Equipment', 'lsx-health-plan' ) . ': ' . /** @scrutinizer ignore-type */ $equipment_group . '</span>';
Loading history...
177
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
178
		if ( ! empty( $muscle_group ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
179
			$modal_body .= '<span class="muscle-terms">' . __( 'Muscle', 'lsx-health-plan' ) . ': ' . $muscle_group . '</span>';
0 ignored issues
show
Bug introduced by
Are you sure $muscle_group of type WP_Error|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

179
			$modal_body .= '<span class="muscle-terms">' . __( 'Muscle', 'lsx-health-plan' ) . ': ' . /** @scrutinizer ignore-type */ $muscle_group . '</span>';
Loading history...
180
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
181
		$modal_body .= '</div>';
182
		if ( '' !== $args['modal_content'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
183
			$modal_body .= '<div class="modal-excerpt"/>' . $content . '</div>';
184
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
185
		if ( 'excerpt' === $args['modal_content'] ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
186
			$modal_body .= '<a class="moretag" target="_blank" href="' . $url . '">' . __( 'Read More', 'lsx-health-plan' ) . '</a>';
0 ignored issues
show
Bug introduced by
Are you sure $url 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

186
			$modal_body .= '<a class="moretag" target="_blank" href="' . /** @scrutinizer ignore-type */ $url . '">' . __( 'Read More', 'lsx-health-plan' ) . '</a>';
Loading history...
187
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
188
		\lsx_health_plan\functions\register_modal( 'workout-exercise-modal-' . $m, '', $modal_body );
189
190
		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...
191
			echo wp_kses_post( $play_button );
192
		} else {
193
			return $play_button;
194
		}
195
	}
196
}
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...
197
198
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$content" missing
Loading history...
199
 * Outputs the modal button and registers the exercise modal to show.
200
 *
201
 * @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...
202
 * @param array $group
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Doc comment for parameter $group does not match actual variable name $content
Loading history...
203
 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
204
 */
205
function lsx_health_plan_shortcode_exercise_button( $m, $content = true ) {
206
	$equipment_group = get_the_term_list( $m, 'equipment', '', ', ' );
207
	$muscle_group    = get_the_term_list( $m, 'muscle-group', '', ', ' );
208
	$title           = get_the_title();
209
	$lsx_hp          = lsx_health_plan();
210
	$button     = '<a data-toggle="modal" href="#exercise-modal-' . $m . '" data-target="#exercise-modal-' . $m . '"></a>';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 10 spaces but found 5 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...
211
212
	if ( true === $content ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
213
		$content = get_the_content();
214
	}
215
216
	$modal_body = '';
217
	if ( $lsx_hp->frontend->gallery->has_gallery( $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...
218
		$gallery_args = array(
219
			'css_class' => 'modal-slider',
220
		);
221
		$modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 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...
222
	} else {
223
		$modal_body .= '<div class="modal-image">' . get_the_post_thumbnail( $m, 'large' ) . '</div>';
224
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
225
	$modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . $title . '</h5>';
226
227
	if ( ! empty( $equipment_group ) ) {
0 ignored issues
show
Coding Style introduced by
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
		$modal_body .= '<span class="equipment-terms">Equipment: ' . $equipment_group . '</span>';
0 ignored issues
show
Bug introduced by
Are you sure $equipment_group of type WP_Error|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

228
		$modal_body .= '<span class="equipment-terms">Equipment: ' . /** @scrutinizer ignore-type */ $equipment_group . '</span>';
Loading history...
229
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
230
	if ( ! empty( $muscle_group ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
231
		$modal_body .= '<span class="muscle-terms">Muscle: ' . $muscle_group . '</span>';
0 ignored issues
show
Bug introduced by
Are you sure $muscle_group of type WP_Error|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

231
		$modal_body .= '<span class="muscle-terms">Muscle: ' . /** @scrutinizer ignore-type */ $muscle_group . '</span>';
Loading history...
232
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
233
	$modal_body .= '</div>';
234
	$modal_body .= $content;
235
	\lsx_health_plan\functions\register_modal( 'exercise-modal-' . $m, '', $modal_body );
236
237
	return ( $button );
238
}
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...
239
240
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$exercise_id" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$url" missing
Loading history...
241
 * Gets the exercise title along with the side its on.
242
 *
243
 * @param  string $before
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
244
 * @param  string $after
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
245
 * @param  boolean $echo
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Doc comment for parameter $echo does not match actual variable name $url
Loading history...
246
 * @return string
247
 */
248
function lsx_health_plan_exercise_title( $before = '', $after = '', $url = true, $echo = true, $exercise_id = false ) {
249
	if ( false === $exercise_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...
250
		$exercise_id = get_the_ID();
251
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
252
	$link  = get_the_permalink( $exercise_id );
253
	$title = get_the_title( $exercise_id );
254
	$side  = get_post_meta( $exercise_id, 'exercise_side', true );
255
	if ( '' !== $side ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
256
		$title .= ' - ' . ucwords( $side );
0 ignored issues
show
Bug introduced by
It seems like $side can also be of type false and null; however, parameter $string of ucwords() 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

256
		$title .= ' - ' . ucwords( /** @scrutinizer ignore-type */ $side );
Loading history...
257
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
258
	$link_before = '';
259
	$link_after  = '';
260
	if ( true === $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...
261
		$link_before = '<a href="' . $link . '">';
0 ignored issues
show
Bug introduced by
Are you sure $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

261
		$link_before = '<a href="' . /** @scrutinizer ignore-type */ $link . '">';
Loading history...
262
		$link_after  = '</a>';
263
	}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
264
	$title = apply_filters( 'lsx_health_plan_exercise_title', $before . $link_before  . $title . $link_after . $after, $title, $before, $after, $exercise_id );
0 ignored issues
show
Coding Style introduced by
Concat operator must be surrounded by a single space
Loading history...
265
	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...
266
		echo wp_kses_post( $title );
267
	} else {
268
		return $title;
269
	}
270
}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
271