Issues (4138)

templates/featured-recipes.php (10 issues)

1
<?php
2
/**
3
 * LSX Recipes Shortcode.
4
 *
5
 * @package lsx-health-plan
6
 */
7
8
$args    = array(
9
	'orderby'        => 'date',
10
	'order'          => 'DESC',
11
	'post_type'      => 'recipe',
12
	'posts_per_page' => 3,
13
	'meta_key'       => 'recipe_featured',
0 ignored issues
show
Detected usage of meta_key, possible slow query.
Loading history...
14
	'meta_compare'   => 'EXISTS',
15
);
16
$recipes = new WP_Query( $args );
17
?>
18
19
<div id="lsx-recipes-shortcode" class="daily-plan-block">
20
	<h2 class="title-lined"><?php esc_html_e( 'Featured Recipe', 'lsx-health-plan' ); ?></h2>
21
	<div class="lsx-recipes-shortcode lsx-recipes-slider slick-slider slick-dotted slick-has-arrows" data-slick="{'slidesToShow': 1, 'slidesToScroll': 1}" >
22
23
		<?php
24
		if ( $recipes->have_posts() ) :
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
25
			while ( $recipes->have_posts() ) :
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
				$recipes->the_post();
27
				$post_id        = get_the_id();
28
				$featured_image = get_the_post_thumbnail( $post_id, array( 600, 300 ) );
0 ignored issues
show
It seems like $post_id can also be of type false; however, parameter $post of get_the_post_thumbnail() 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

28
				$featured_image = get_the_post_thumbnail( /** @scrutinizer ignore-type */ $post_id, array( 600, 300 ) );
Loading history...
29
				?>
30
				<div class="lsx-recipes-slot">
31
					<div class="row">
32
						<div class="col-md-5 col-sm-6">
33
							<h4 class="lsx-recipes-title"><?php the_title(); ?></h4>
34
							<?php lsx_health_plan_recipe_data(); ?>
35
							<a href="<?php echo esc_url( get_permalink() ); ?>" class="btn"><?php esc_html_e( 'View Recipe', 'lsx-health-plan' ); ?></a>
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

35
							<a href="<?php echo esc_url( /** @scrutinizer ignore-type */ get_permalink() ); ?>" class="btn"><?php esc_html_e( 'View Recipe', 'lsx-health-plan' ); ?></a>
Loading history...
36
						</div>
37
						<div class="col-md-7 col-sm-6">
38
							<?php
39
							if ( ! empty( $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...
40
								echo wp_kses_post( $featured_image );
41
							}
42
							?>
43
						</div>
44
					</div>
45
				</div>
46
		<?php endwhile; ?>
0 ignored issues
show
Closing brace indented incorrectly; expected 12 spaces, found 8
Loading history...
47
		<?php endif; ?>
48
		<?php wp_reset_postdata(); ?>
49
	</div>
50
</div>
51