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