lightspeeddevelopment /
lsx-health-plan
| 1 | <?php |
||||
| 2 | /** |
||||
| 3 | * Template used to loop through the meal plans |
||||
| 4 | * |
||||
| 5 | * @package lsx-health-plan |
||||
| 6 | */ |
||||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||||
| 7 | global $connected_meals, $shortcode_args; |
||||
| 8 | |||||
| 9 | if ( is_singular( 'plan' ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 10 | $section_key = get_query_var( 'section' ); |
||||
| 11 | if ( '' !== $section_key && \lsx_health_plan\functions\plan\has_sections() ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 12 | $section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key ); |
||||
| 13 | if ( isset( $section_info['connected_meals'] ) && '' !== $section_info['connected_meals'] ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 14 | $connected_meals = \lsx_health_plan\functions\prep_array( $section_info['connected_meals'] ); |
||||
| 15 | } |
||||
| 16 | } |
||||
| 17 | } |
||||
| 18 | |||||
| 19 | // Check for any shortcode overrides. |
||||
| 20 | if ( null !== $shortcode_args && isset( $shortcode_args['include'] ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 21 | $connected_meals = array( get_the_ID() ); |
||||
| 22 | } |
||||
| 23 | ?> |
||||
| 24 | |||||
| 25 | <div class="meals"> |
||||
| 26 | |||||
| 27 | <?php |
||||
| 28 | |||||
| 29 | // Looking for meals. |
||||
| 30 | if ( empty( $connected_meals ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 31 | $connected_meals = get_post_meta( get_the_ID(), 'connected_meals', 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
Loading history...
|
|||||
| 32 | |||||
| 33 | if ( empty( $connected_meals ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 34 | $options = \lsx_health_plan\functions\get_option( 'all' ); |
||||
| 35 | if ( isset( $options['connected_meals'] ) && '' !== $options['connected_meals'] && ! empty( $options['connected_meals'] ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 36 | $connected_meals = $options['connected_meals']; |
||||
| 37 | if ( ! array( $connected_meals ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 38 | $connected_meals = array( $connected_meals ); |
||||
| 39 | } |
||||
| 40 | } |
||||
| 41 | } |
||||
| 42 | } |
||||
| 43 | |||||
| 44 | // This is for the meal single template. |
||||
| 45 | if ( is_single() && is_singular( 'meal' ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 46 | $connected_meals = array( get_the_ID() ); |
||||
| 47 | } |
||||
| 48 | |||||
| 49 | // The top part |
||||
|
0 ignored issues
–
show
|
|||||
| 50 | echo wp_kses_post( wp_kses_post( lsx_health_plan_meal_main_content() ) ); |
||||
|
0 ignored issues
–
show
lsx_health_plan_meal_main_content() 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
Loading history...
|
|||||
| 51 | |||||
| 52 | if ( false !== $connected_meals && '' !== $connected_meals && ! empty( $connected_meals ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 53 | |||||
| 54 | $args = array( |
||||
| 55 | 'orderby' => 'date', |
||||
| 56 | 'order' => 'DESC', |
||||
| 57 | 'post_type' => 'meal', |
||||
| 58 | 'post__in' => $connected_meals, |
||||
| 59 | ); |
||||
| 60 | $meals = new WP_Query( $args ); |
||||
| 61 | if ( $meals->have_posts() ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 62 | while ( $meals->have_posts() ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 63 | $meals->the_post(); |
||||
| 64 | $meal_id = get_the_ID(); |
||||
|
0 ignored issues
–
show
Equals sign not aligned correctly; expected 1 space but found 7 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...
|
|||||
| 65 | |||||
| 66 | |||||
| 67 | // Breakfast. |
||||
| 68 | $pre_breakfast_snack = get_post_meta( get_the_ID(), 'meal_pre_breakfast_snack', true ); |
||||
| 69 | $breakfast = get_post_meta( get_the_ID(), 'meal_breakfast', true ); |
||||
| 70 | $post_breakfast_snack = get_post_meta( get_the_ID(), 'meal_breakfast_snack', true ); |
||||
| 71 | |||||
| 72 | // Lunch. |
||||
| 73 | $pre_lunch_snack = get_post_meta( get_the_ID(), 'meal_pre_lunch_snack', true ); |
||||
| 74 | $lunch = get_post_meta( get_the_ID(), 'meal_lunch', true ); |
||||
| 75 | $post_lunch_snack = get_post_meta( get_the_ID(), 'meal_lunch_snack', true ); |
||||
| 76 | |||||
| 77 | // Dinner. |
||||
| 78 | $pre_dinner_snack = get_post_meta( get_the_ID(), 'meal_pre_dinner_snack', true ); |
||||
| 79 | $dinner = get_post_meta( get_the_ID(), 'meal_dinner', true ); |
||||
| 80 | $post_dinner_snack = get_post_meta( get_the_ID(), 'meal_dinner_snack', true ); |
||||
| 81 | |||||
| 82 | //Main Meals Title |
||||
|
0 ignored issues
–
show
|
|||||
| 83 | //echo '<h3 class="meals-section-title">' . esc_html__( 'Meal Plan', 'lsx-health-plan' ) . '</h3>'; |
||||
|
0 ignored issues
–
show
|
|||||
| 84 | ?> |
||||
| 85 | <div class="row eating-row"> |
||||
| 86 | <div class="col-md-4 eating-column"> |
||||
| 87 | <?php |
||||
| 88 | if ( ! empty( $pre_breakfast_snack ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 89 | echo '<div class="content-box"><h3 class="eating-title snack-title">' . esc_html__( 'Snack', 'lsx-health-plan' ) . '</h3>'; |
||||
| 90 | echo wp_kses_post( apply_filters( 'the_content', $pre_breakfast_snack ) ); |
||||
| 91 | echo '</div>'; |
||||
| 92 | } |
||||
|
0 ignored issues
–
show
|
|||||
| 93 | if ( ! empty( $breakfast ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 94 | echo '<div class="content-box"><h3 class="eating-title">' . esc_html__( 'Breakfast', 'lsx-health-plan' ) . '</h3>'; |
||||
| 95 | echo wp_kses_post( apply_filters( 'the_content', $breakfast ) ); |
||||
| 96 | echo '</div>'; |
||||
| 97 | } |
||||
|
0 ignored issues
–
show
|
|||||
| 98 | if ( ! empty( $post_breakfast_snack ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 99 | echo '<div class="content-box"><h3 class="eating-title snack-title">' . esc_html__( 'Snack', 'lsx-health-plan' ) . '</h3>'; |
||||
| 100 | echo wp_kses_post( apply_filters( 'the_content', $post_breakfast_snack ) ); |
||||
| 101 | echo '</div>'; |
||||
| 102 | } |
||||
| 103 | |||||
| 104 | $args = array( |
||||
| 105 | 'meal_id' => $meal_id, |
||||
| 106 | 'meal_time' => 'breakfast', |
||||
| 107 | ); |
||||
| 108 | lsx_hp_meal_plan_recipes( $args ); |
||||
| 109 | ?> |
||||
| 110 | </div> |
||||
| 111 | <div class="col-md-4 eating-column"> |
||||
| 112 | <?php |
||||
| 113 | if ( ! empty( $pre_lunch_snack ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 114 | echo '<div class="content-box"><h3 class="eating-title snack-title">' . esc_html__( 'Snack', 'lsx-health-plan' ) . '</h3>'; |
||||
| 115 | echo wp_kses_post( apply_filters( 'the_content', $pre_lunch_snack ) ); |
||||
| 116 | echo '</div>'; |
||||
| 117 | } |
||||
|
0 ignored issues
–
show
|
|||||
| 118 | if ( ! empty( $lunch ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 119 | echo '<div class="content-box"><h3 class="eating-title">' . esc_html__( 'Lunch', 'lsx-health-plan' ) . '</h3>'; |
||||
| 120 | echo wp_kses_post( apply_filters( 'the_content', $lunch ) ); |
||||
| 121 | echo '</div>'; |
||||
| 122 | } |
||||
|
0 ignored issues
–
show
|
|||||
| 123 | if ( ! empty( $post_lunch_snack ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 124 | echo '<div class="content-box"><h3 class="eating-title snack-title">' . esc_html__( 'Snack', 'lsx-health-plan' ) . '</h3>'; |
||||
| 125 | echo wp_kses_post( apply_filters( 'the_content', $post_lunch_snack ) ); |
||||
| 126 | echo '</div>'; |
||||
| 127 | } |
||||
| 128 | |||||
| 129 | $args = array( |
||||
| 130 | 'meal_id' => $meal_id, |
||||
| 131 | 'meal_time' => 'lunch', |
||||
| 132 | ); |
||||
| 133 | lsx_hp_meal_plan_recipes( $args ); |
||||
| 134 | ?> |
||||
| 135 | </div> |
||||
| 136 | <div class="col-md-4 eating-column"> |
||||
| 137 | <?php |
||||
| 138 | if ( ! empty( $pre_dinner_snack ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 139 | echo '<div class="content-box"><h3 class="eating-title snack-title">' . esc_html__( 'Snack', 'lsx-health-plan' ) . '</h3>'; |
||||
| 140 | echo wp_kses_post( apply_filters( 'the_content', $pre_dinner_snack ) ); |
||||
| 141 | echo '</div>'; |
||||
| 142 | } |
||||
|
0 ignored issues
–
show
|
|||||
| 143 | if ( ! empty( $dinner ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 144 | echo '<div class="content-box"><h3 class="eating-title">' . esc_html__( 'Dinner', 'lsx-health-plan' ) . '</h3>'; |
||||
| 145 | echo wp_kses_post( apply_filters( 'the_content', $dinner ) ); |
||||
| 146 | echo '</div>'; |
||||
| 147 | } |
||||
|
0 ignored issues
–
show
|
|||||
| 148 | if ( ! empty( $post_dinner_snack ) ) { |
||||
|
0 ignored issues
–
show
|
|||||
| 149 | echo '<div class="content-box"><h3 class="eating-title snack-title">' . esc_html__( 'Snack', 'lsx-health-plan' ) . '</h3>'; |
||||
| 150 | echo wp_kses_post( apply_filters( 'the_content', $post_dinner_snack ) ); |
||||
| 151 | echo '</div>'; |
||||
| 152 | } |
||||
| 153 | |||||
| 154 | $args = array( |
||||
| 155 | 'meal_id' => $meal_id, |
||||
| 156 | 'meal_time' => 'dinner', |
||||
| 157 | ); |
||||
| 158 | lsx_hp_meal_plan_recipes( $args ); |
||||
| 159 | ?> |
||||
| 160 | </div> |
||||
| 161 | </div> |
||||
| 162 | <?php |
||||
| 163 | } |
||||
| 164 | } |
||||
| 165 | } |
||||
| 166 | ?> |
||||
| 167 | <?php wp_reset_postdata(); ?> |
||||
| 168 | </div> |
||||
| 169 | <?php |
||||
| 170 |