Issues (4138)

templates/content-archive-plan.php (50 issues)

1
<?php
2
/**
3
 * Template used to display post content on widgets and archive pages.
4
 *
5
 * @package lsx-health-plan
6
 */
0 ignored issues
show
There must be exactly one blank line after the file comment
Loading history...
7
global $shortcode_args, $product;
8
?>
9
10
<?php lsx_entry_before(); ?>
11
12
<?php
13
$content_setting = '';
14
$column_class    = '4';
15
$completed_class = '4';
16
$link_html       = '';
17
$link_close      = '';
18
$linked_product  = false;
19
$restricted      = '';
20
if ( function_exists( 'lsx_health_plan\functions\woocommerce\plan_has_products' ) && \lsx_health_plan\functions\woocommerce\plan_has_products() ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
21
	$products       = \lsx_health_plan\functions\woocommerce\get_plan_products();
22
	$linked_product = wc_get_product( $products[0] );
0 ignored issues
show
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

22
	$linked_product = /** @scrutinizer ignore-call */ wc_get_product( $products[0] );
Loading history...
23
	$product        = $linked_product;
24
25
	if ( function_exists( 'wc_memberships_is_post_content_restricted' ) && wc_memberships_is_post_content_restricted( get_the_ID() ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
26
		$restricted = ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() );
27
	}
28
}
29
30
// Check for shortcode overrides.
31
if ( null !== $shortcode_args ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
32
	if ( isset( $shortcode_args['columns'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
33
		$column_class = $shortcode_args['columns'];
34
		$column_class = \lsx_health_plan\functions\column_class( $column_class );
35
	}
0 ignored issues
show
No blank line found after control structure
Loading history...
36
	if ( isset( $shortcode_args['link'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
37
		$link_setting = $shortcode_args['link'];
38
		// Setup our link and content.
39
		switch ( $link_setting ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
40
			case 'single':
41
				$link_html  = '<a href="' . get_permalink( $group['connected_plans'] ) . '">';
0 ignored issues
show
Are you sure get_permalink($group['connected_plans']) 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

41
				$link_html  = '<a href="' . /** @scrutinizer ignore-type */ get_permalink( $group['connected_plans'] ) . '">';
Loading history...
42
				$link_close = '</a>';
43
				break;
44
45
			case 'modal':
46
				$link_html  = '<a data-toggle="modal" href="#workout-plan-modal-' . $group['connected_plans'] . '">';
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 13 spaces but found 2 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...
47
				$link_close = '</a>';
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 12 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...
48
				$modal_content_setting = \lsx_health_plan\functions\get_option( 'workout_tab_modal_content', 'excerpt' );
49
				$modal_args = array(
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 12 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...
50
					'modal_content' => $modal_content_setting,
51
				);
52
				// We call the button to register the modal, but we do not output it.
53
				lsx_health_plan_workout_plan_button( $group['connected_plans'], $group, false, $modal_args );
0 ignored issues
show
The function lsx_health_plan_workout_plan_button 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

53
				/** @scrutinizer ignore-call */ 
54
    lsx_health_plan_workout_plan_button( $group['connected_plans'], $group, false, $modal_args );
Loading history...
54
				break;
55
56
			case 'none':
57
			default:
58
				$link_html  = '';
59
				$link_close = '';
60
				break;
61
		}
62
	}
0 ignored issues
show
No blank line found after control structure
Loading history...
63
	if ( isset( $shortcode_args['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...
64
		$content_setting = $shortcode_args['description'];
65
	}
66
}
67
68
$featured      = get_post_meta( get_the_ID(), 'plan_featured_plan', 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

68
$featured      = get_post_meta( /** @scrutinizer ignore-type */ get_the_ID(), 'plan_featured_plan', true );
Loading history...
Equals sign not aligned correctly; expected 1 space but found 6 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...
69
?>
70
71
<div class="lsx-plan-column col-xs-12 col-sm-6 col-md-<?php echo esc_attr( $column_class ); ?> <?php echo esc_attr( lsx_hp_plan_get_classes() ); ?>">
72
	<article class="lsx-slot box-shadow">
73
		<?php lsx_entry_top(); ?>
74
75
		<div class="plan-feature-img">
76
			<?php if ( $featured ) { ?>
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
77
				<span class="featured-plan"><?php //lsx_get_svg_icon( 'icon-featured.svg' ); ?></span>
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
No space found before comment text; expected "// lsx_get_svg_icon( 'icon-featured.svg' );" but found "//lsx_get_svg_icon( 'icon-featured.svg' );"
Loading history...
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
78
			<?php } ?>
79
			<a href="<?php echo esc_url( get_permalink() ); ?>">
0 ignored issues
show
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

79
			<a href="<?php echo esc_url( /** @scrutinizer ignore-type */ get_permalink() ); ?>">
Loading history...
80
			<?php
81
			$featured_image = get_the_post_thumbnail();
82
			if ( ! empty( $featured_image ) && '' !== $featured_image ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
83
				the_post_thumbnail( 'lsx-thumbnail', array(
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
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...
84
					'class' => 'aligncenter',
85
				) );
0 ignored issues
show
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...
86
			} else {
87
				?>
88
				<img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
89
				<?php
90
			}
91
			?>
92
			</a>
93
		</div>
94
		<div class="content-box plan-content-box white-bg">
95
			<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>
96
			<?php
97
				echo wp_kses_post( \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) );
0 ignored issues
show
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

97
				echo wp_kses_post( /** @scrutinizer ignore-type */ \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) );
Loading history...
98
			?>
99
			<?php
100
			if ( false !== $linked_product ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
101
				echo '<div class="plan-price">';
102
				echo wp_kses_post( $linked_product->get_price_html() );
103
				echo '</div>';
104
			}
105
			?>
106
			<div class="excerpt">
107
				<?php
108
				if ( ! has_excerpt() ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
109
					$content = wp_trim_words( get_the_content(), 20 );
110
					$content = '<p>' . $content . '</p>';
111
				} else {
112
					$content = apply_filters( 'the_excerpt', get_the_excerpt() );
113
				}
0 ignored issues
show
No blank line found after control structure
Loading history...
114
				echo wp_kses_post( $content );
115
				?>
116
			</div>
117
118
			<?php
119
			$button_link  = get_permalink();
120
			$button_text  = __( 'Sign Up', 'lsx-health-plan' );
121
			$button_class = '';
122
123
			if ( true === $restricted ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
124
				if ( 1 < count( $products ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
125
					$button_text = __( 'Select Options', 'lsx-health-plan' );
126
				} else {
127
					$button_link = $linked_product->add_to_cart_url() . '&plan_id=' . get_the_ID();
0 ignored issues
show
Are you sure get_the_ID() of type false|integer 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

127
					$button_link = $linked_product->add_to_cart_url() . '&plan_id=' . /** @scrutinizer ignore-type */ get_the_ID();
Loading history...
128
					$button_text = $linked_product->add_to_cart_text();
129
				}
130
				?>
131
				<?php
132
			} elseif ( false === $restricted ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
133
				$button_text  = __( 'Already Signed Up', 'lsx-health-plan' );
134
				$button_class = 'btn-disabled';
135
			}
136
			?>
137
			<a class="btn <?php echo esc_attr( $button_class ); ?>" href="<?php echo esc_attr( $button_link ); ?>"><?php echo esc_attr( $button_text ); ?></a>
0 ignored issues
show
It seems like $button_link 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

137
			<a class="btn <?php echo esc_attr( $button_class ); ?>" href="<?php echo esc_attr( /** @scrutinizer ignore-type */ $button_link ); ?>"><?php echo esc_attr( $button_text ); ?></a>
Loading history...
138
		</div>
139
		<?php lsx_entry_bottom(); ?>
140
	</article>
141
</div>
142
143
<?php
144
lsx_entry_after();
145