1 | <?php |
||||
2 | /** |
||||
3 | * LSX Health Plan Items Shortcode. |
||||
4 | * |
||||
5 | * @package lsx-health-plan |
||||
6 | */ |
||||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||||
7 | global $shortcode_args; |
||||
8 | $args = $shortcode_args; |
||||
9 | $taxonomy = $args['taxonomy']; |
||||
10 | $term = $args['term']; |
||||
11 | $columns = $args['columns']; |
||||
12 | $limit = $args['limit']; |
||||
13 | $description = $args['description']; |
||||
14 | $link = $args['link']; |
||||
15 | $link_class = $args['link_class']; |
||||
16 | $image_size = $args['image_size']; |
||||
17 | |||||
18 | $query_array = array( |
||||
19 | 'orderby' => $args['orderby'], |
||||
20 | 'order' => $args['order'], |
||||
21 | 'post_type' => $args['post_type'], |
||||
22 | 'posts_per_page' => $limit, |
||||
23 | ); |
||||
24 | |||||
25 | // If we are calling the exercises with the parent workout. |
||||
26 | if ( false !== 'parent' && 'exercise' === $args['post_type'] ) { |
||||
0 ignored issues
–
show
|
|||||
27 | $items = \lsx_health_plan\functions\get_exercises_by_workout( $args['parent'] ); |
||||
28 | if ( ! empty( $items ) ) { |
||||
0 ignored issues
–
show
|
|||||
29 | $args['include'] = $items; |
||||
30 | } |
||||
31 | } |
||||
32 | |||||
33 | if ( isset( $args['include'] ) && ( '' !== $args['include'] ) ) { |
||||
0 ignored issues
–
show
|
|||||
34 | if ( is_array( $args['include'] ) ) { |
||||
0 ignored issues
–
show
|
|||||
35 | $include = $args['include']; |
||||
36 | } else { |
||||
37 | $include = explode( ',', $args['include'] ); |
||||
38 | } |
||||
0 ignored issues
–
show
|
|||||
39 | $include_filter = $include; |
||||
40 | $query_array['post__in'] = $include_filter; |
||||
41 | $query_array['orderby'] = 'post__in'; |
||||
42 | } |
||||
43 | |||||
44 | if ( isset( $taxonomy ) && ( '' !== $taxonomy ) && isset( $term ) && ( '' !== $term ) ) { |
||||
0 ignored issues
–
show
|
|||||
45 | $taxonomy_filter = array( |
||||
46 | array( |
||||
47 | 'taxonomy' => $taxonomy, |
||||
48 | 'field' => 'slug', |
||||
49 | 'terms' => $term, |
||||
50 | ), |
||||
51 | ); |
||||
52 | $query_array['tax_query'] = $taxonomy_filter; |
||||
0 ignored issues
–
show
|
|||||
53 | } |
||||
54 | |||||
55 | $exercises = new WP_Query( $query_array ); |
||||
56 | ?> |
||||
57 | |||||
58 | <div id="lsx-exercises-shortcode" class="daily-plan-block layout-<?php echo esc_html( $args['layout'] ); ?> columns-<?php echo esc_html( $args['columns'] ); ?> shortcode-type-<?php echo esc_html( $args['post_type'] ); ?>"> |
||||
59 | <div class="lsx-exercises-shortcode" > |
||||
60 | <?php |
||||
61 | if ( $exercises->have_posts() ) { |
||||
0 ignored issues
–
show
|
|||||
62 | while ( $exercises->have_posts() ) { |
||||
0 ignored issues
–
show
|
|||||
63 | $exercises->the_post(); |
||||
64 | switch ( $args['post_type'] ) { |
||||
0 ignored issues
–
show
|
|||||
65 | case 'workout': |
||||
66 | include LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php'; |
||||
67 | break; |
||||
68 | |||||
69 | case 'meal': |
||||
70 | include LSX_HEALTH_PLAN_PATH . 'templates/partials/meal-plans.php'; |
||||
71 | break; |
||||
72 | |||||
73 | /*case 'exercise': |
||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% 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. ![]() |
|||||
74 | include LSX_HEALTH_PLAN_PATH . 'templates/partials/content-shortcode-exercise.php'; |
||||
75 | break;*/ |
||||
76 | |||||
77 | case 'exercise': |
||||
78 | case 'recipe': |
||||
79 | case 'tip': |
||||
80 | include LSX_HEALTH_PLAN_PATH . 'templates/content-archive-' . $args['post_type'] . '.php'; |
||||
81 | break; |
||||
82 | |||||
83 | default: |
||||
84 | include LSX_HEALTH_PLAN_PATH . 'templates/partials/content-default.php'; |
||||
85 | break; |
||||
86 | } |
||||
87 | } |
||||
88 | } |
||||
0 ignored issues
–
show
|
|||||
89 | wp_reset_postdata(); |
||||
90 | ?> |
||||
91 | </div> |
||||
92 | <?php |
||||
93 | if ( isset( $args['view_more'] ) && false !== $args['view_more'] ) { |
||||
0 ignored issues
–
show
|
|||||
94 | ?> |
||||
95 | <div class="col-md-12"> |
||||
96 | <a class="<?php echo esc_html( $link_class ); ?>" href="<?php echo esc_url( get_post_type_archive_link( $args['post_type'] ) ); ?>"><?php echo esc_html_e( 'Show More', 'lsx-health-plan' ); ?></a> |
||||
0 ignored issues
–
show
It seems like
get_post_type_archive_link($args['post_type']) 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
![]() |
|||||
97 | </div> |
||||
98 | <?php |
||||
99 | } |
||||
100 | ?> |
||||
101 | </div> |
||||
102 | <?php |
||||
103 | $shortcode_args = null; |
||||
104 |