@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | * @return boolean |
13 | 13 | */ |
14 | 14 | function lsx_health_plan_has_warmup( $post_id = '' ) { |
15 | - if ( '' === $post_id ) { |
|
16 | - $post_id = get_the_ID(); |
|
17 | - } |
|
18 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'plan_warmup' ); |
|
15 | + if ( '' === $post_id ) { |
|
16 | + $post_id = get_the_ID(); |
|
17 | + } |
|
18 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'plan_warmup' ); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | * @return boolean |
26 | 26 | */ |
27 | 27 | function lsx_health_plan_has_workout( $post_id = '' ) { |
28 | - if ( ! post_type_exists( 'workout' ) ) { |
|
29 | - return false; |
|
30 | - } |
|
31 | - if ( '' === $post_id ) { |
|
32 | - $post_id = get_the_ID(); |
|
33 | - } |
|
34 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_workouts' ); |
|
28 | + if ( ! post_type_exists( 'workout' ) ) { |
|
29 | + return false; |
|
30 | + } |
|
31 | + if ( '' === $post_id ) { |
|
32 | + $post_id = get_the_ID(); |
|
33 | + } |
|
34 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_workouts' ); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | * @return boolean |
42 | 42 | */ |
43 | 43 | function lsx_health_plan_has_meal( $post_id = '' ) { |
44 | - if ( ! post_type_exists( 'meal' ) ) { |
|
45 | - return false; |
|
46 | - } |
|
47 | - if ( '' === $post_id ) { |
|
48 | - $post_id = get_the_ID(); |
|
49 | - } |
|
50 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' ); |
|
44 | + if ( ! post_type_exists( 'meal' ) ) { |
|
45 | + return false; |
|
46 | + } |
|
47 | + if ( '' === $post_id ) { |
|
48 | + $post_id = get_the_ID(); |
|
49 | + } |
|
50 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | * @return boolean |
58 | 58 | */ |
59 | 59 | function lsx_health_plan_has_recipe( $post_id = '' ) { |
60 | - if ( ! post_type_exists( 'recipe' ) ) { |
|
61 | - return false; |
|
62 | - } |
|
63 | - if ( '' === $post_id ) { |
|
64 | - $post_id = get_the_ID(); |
|
65 | - } |
|
66 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_recipes' ); |
|
60 | + if ( ! post_type_exists( 'recipe' ) ) { |
|
61 | + return false; |
|
62 | + } |
|
63 | + if ( '' === $post_id ) { |
|
64 | + $post_id = get_the_ID(); |
|
65 | + } |
|
66 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_recipes' ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | * @return boolean |
74 | 74 | */ |
75 | 75 | function lsx_health_plan_has_downloads( $post_id = '' ) { |
76 | - $has_downloads = false; |
|
77 | - if ( '' === $post_id ) { |
|
78 | - $post_id = get_the_ID(); |
|
79 | - } |
|
80 | - $downloads = \lsx_health_plan\functions\get_downloads( 'all', $post_id ); |
|
81 | - if ( ! empty( $downloads ) ) { |
|
82 | - $has_downloads = true; |
|
83 | - } |
|
84 | - return $has_downloads; |
|
76 | + $has_downloads = false; |
|
77 | + if ( '' === $post_id ) { |
|
78 | + $post_id = get_the_ID(); |
|
79 | + } |
|
80 | + $downloads = \lsx_health_plan\functions\get_downloads( 'all', $post_id ); |
|
81 | + if ( ! empty( $downloads ) ) { |
|
82 | + $has_downloads = true; |
|
83 | + } |
|
84 | + return $has_downloads; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * @return boolean |
92 | 92 | */ |
93 | 93 | function lsx_health_plan_has_tip( $post_id = '' ) { |
94 | - if ( ! post_type_exists( 'tip' ) ) { |
|
95 | - return false; |
|
96 | - } |
|
97 | - if ( '' === $post_id ) { |
|
98 | - $post_id = get_the_ID(); |
|
99 | - } |
|
100 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_tips' ); |
|
94 | + if ( ! post_type_exists( 'tip' ) ) { |
|
95 | + return false; |
|
96 | + } |
|
97 | + if ( '' === $post_id ) { |
|
98 | + $post_id = get_the_ID(); |
|
99 | + } |
|
100 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_tips' ); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | * @return boolean |
108 | 108 | */ |
109 | 109 | function lsx_health_plan_has_video( $post_id = '' ) { |
110 | - if ( ! post_type_exists( 'video' ) ) { |
|
111 | - return false; |
|
112 | - } |
|
113 | - if ( '' === $post_id ) { |
|
114 | - $post_id = get_the_ID(); |
|
115 | - } |
|
116 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_videos' ); |
|
110 | + if ( ! post_type_exists( 'video' ) ) { |
|
111 | + return false; |
|
112 | + } |
|
113 | + if ( '' === $post_id ) { |
|
114 | + $post_id = get_the_ID(); |
|
115 | + } |
|
116 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_videos' ); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | * @return boolean |
123 | 123 | */ |
124 | 124 | function lsx_health_plan_user_has_purchase() { |
125 | - $valid_order = false; |
|
126 | - $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
125 | + $valid_order = false; |
|
126 | + $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
127 | 127 | |
128 | - if ( is_user_logged_in() && false !== $product_id ) { |
|
129 | - $current_user = wp_get_current_user(); |
|
130 | - if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) { |
|
131 | - $valid_order = true; |
|
132 | - } |
|
133 | - } |
|
134 | - return $valid_order; |
|
128 | + if ( is_user_logged_in() && false !== $product_id ) { |
|
129 | + $current_user = wp_get_current_user(); |
|
130 | + if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) { |
|
131 | + $valid_order = true; |
|
132 | + } |
|
133 | + } |
|
134 | + return $valid_order; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -141,18 +141,18 @@ discard block |
||
141 | 141 | * @return boolean |
142 | 142 | */ |
143 | 143 | function lsx_health_plan_is_current_tab( $needle = '' ) { |
144 | - $is_tab = false; |
|
145 | - $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
146 | - if ( false === $plan_slug ) { |
|
147 | - $plan_slug = 'my-plan'; |
|
148 | - } |
|
149 | - if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) { |
|
150 | - $endpoint = get_query_var( 'endpoint' ); |
|
151 | - if ( false !== $endpoint && $needle === $endpoint ) { |
|
152 | - $is_tab = true; |
|
153 | - } |
|
154 | - } |
|
155 | - return $is_tab; |
|
144 | + $is_tab = false; |
|
145 | + $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
146 | + if ( false === $plan_slug ) { |
|
147 | + $plan_slug = 'my-plan'; |
|
148 | + } |
|
149 | + if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) { |
|
150 | + $endpoint = get_query_var( 'endpoint' ); |
|
151 | + if ( false !== $endpoint && $needle === $endpoint ) { |
|
152 | + $is_tab = true; |
|
153 | + } |
|
154 | + } |
|
155 | + return $is_tab; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -162,22 +162,22 @@ discard block |
||
162 | 162 | * @return boolean |
163 | 163 | */ |
164 | 164 | function lsx_health_plan_is_day_complete( $post_id = '', $section_key = '' ) { |
165 | - $is_complete = false; |
|
166 | - if ( '' === $post_id ) { |
|
167 | - $post_id = get_the_ID(); |
|
168 | - } |
|
169 | - $key = \lsx_health_plan\functions\plan\generate_section_id( $section_key ); |
|
170 | - $is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true ); |
|
171 | - if ( false !== $is_day_complete && '' !== $is_day_complete ) { |
|
172 | - $is_complete = true; |
|
173 | - } |
|
165 | + $is_complete = false; |
|
166 | + if ( '' === $post_id ) { |
|
167 | + $post_id = get_the_ID(); |
|
168 | + } |
|
169 | + $key = \lsx_health_plan\functions\plan\generate_section_id( $section_key ); |
|
170 | + $is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true ); |
|
171 | + if ( false !== $is_day_complete && '' !== $is_day_complete ) { |
|
172 | + $is_complete = true; |
|
173 | + } |
|
174 | 174 | |
175 | - return $is_complete; |
|
175 | + return $is_complete; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | function lsx_health_plan_is_plan_complete() { |
179 | - $complete = false; |
|
180 | - return $complete; |
|
179 | + $complete = false; |
|
180 | + return $complete; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -187,14 +187,14 @@ discard block |
||
187 | 187 | * @return boolean |
188 | 188 | */ |
189 | 189 | function lsx_health_plan_week_has_downloads( $week = '' ) { |
190 | - $has_downloads = false; |
|
191 | - if ( '' !== $week ) { |
|
192 | - $downloads = \lsx_health_plan\functions\get_weekly_downloads( $week ); |
|
193 | - if ( ! empty( $downloads ) ) { |
|
194 | - $has_downloads = true; |
|
195 | - } |
|
196 | - } |
|
197 | - return $has_downloads; |
|
190 | + $has_downloads = false; |
|
191 | + if ( '' !== $week ) { |
|
192 | + $downloads = \lsx_health_plan\functions\get_weekly_downloads( $week ); |
|
193 | + if ( ! empty( $downloads ) ) { |
|
194 | + $has_downloads = true; |
|
195 | + } |
|
196 | + } |
|
197 | + return $has_downloads; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -204,15 +204,15 @@ discard block |
||
204 | 204 | * @return boolean |
205 | 205 | */ |
206 | 206 | function lsx_health_plan_has_tips( $post_id = '' ) { |
207 | - $has_tips = false; |
|
208 | - if ( '' === $post_id ) { |
|
209 | - $post_id = get_the_ID(); |
|
210 | - } |
|
211 | - $post_type = get_post_type( $post_id ); |
|
212 | - $connected_tips = get_post_meta( get_the_ID(), $post_type . '_connected_tips', true ); |
|
213 | - $connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips ); |
|
214 | - if ( ! empty( $connected_tips ) ) { |
|
215 | - $has_tips = true; |
|
216 | - } |
|
217 | - return $has_tips; |
|
207 | + $has_tips = false; |
|
208 | + if ( '' === $post_id ) { |
|
209 | + $post_id = get_the_ID(); |
|
210 | + } |
|
211 | + $post_type = get_post_type( $post_id ); |
|
212 | + $connected_tips = get_post_meta( get_the_ID(), $post_type . '_connected_tips', true ); |
|
213 | + $connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips ); |
|
214 | + if ( ! empty( $connected_tips ) ) { |
|
215 | + $has_tips = true; |
|
216 | + } |
|
217 | + return $has_tips; |
|
218 | 218 | } |
@@ -7,18 +7,18 @@ discard block |
||
7 | 7 | global $connected_meals, $shortcode_args; |
8 | 8 | |
9 | 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 | - } |
|
16 | - } |
|
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 | + } |
|
16 | + } |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | // Check for any shortcode overrides. |
20 | 20 | if ( null !== $shortcode_args && isset( $shortcode_args['include'] ) ) { |
21 | - $connected_meals = array( get_the_ID() ); |
|
21 | + $connected_meals = array( get_the_ID() ); |
|
22 | 22 | } |
23 | 23 | ?> |
24 | 24 | |
@@ -26,144 +26,144 @@ discard block |
||
26 | 26 | |
27 | 27 | <?php |
28 | 28 | |
29 | - // Looking for meals. |
|
30 | - if ( empty( $connected_meals ) ) { |
|
31 | - $connected_meals = get_post_meta( get_the_ID(), 'connected_meals', true ); |
|
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'] ) ) { |
|
36 | - $connected_meals = $options['connected_meals']; |
|
37 | - if ( ! array( $connected_meals ) ) { |
|
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' ) ) { |
|
46 | - $connected_meals = array( get_the_ID() ); |
|
47 | - } |
|
48 | - |
|
49 | - // The top part |
|
50 | - echo wp_kses_post( wp_kses_post( lsx_health_plan_meal_main_content() ) ); |
|
51 | - |
|
52 | - if ( false !== $connected_meals && '' !== $connected_meals && ! empty( $connected_meals ) ) { |
|
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() ) { |
|
62 | - while ( $meals->have_posts() ) { |
|
63 | - $meals->the_post(); |
|
64 | - $meal_id = get_the_ID(); |
|
29 | + // Looking for meals. |
|
30 | + if ( empty( $connected_meals ) ) { |
|
31 | + $connected_meals = get_post_meta( get_the_ID(), 'connected_meals', true ); |
|
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'] ) ) { |
|
36 | + $connected_meals = $options['connected_meals']; |
|
37 | + if ( ! array( $connected_meals ) ) { |
|
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' ) ) { |
|
46 | + $connected_meals = array( get_the_ID() ); |
|
47 | + } |
|
48 | + |
|
49 | + // The top part |
|
50 | + echo wp_kses_post( wp_kses_post( lsx_health_plan_meal_main_content() ) ); |
|
51 | + |
|
52 | + if ( false !== $connected_meals && '' !== $connected_meals && ! empty( $connected_meals ) ) { |
|
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() ) { |
|
62 | + while ( $meals->have_posts() ) { |
|
63 | + $meals->the_post(); |
|
64 | + $meal_id = get_the_ID(); |
|
65 | 65 | |
66 | 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 ); |
|
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 | 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 ); |
|
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 | 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 ); |
|
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 | 81 | |
82 | - //Main Meals Title |
|
83 | - //echo '<h3 class="meals-section-title">' . esc_html__( 'Meal Plan', 'lsx-health-plan' ) . '</h3>'; |
|
84 | - ?> |
|
82 | + //Main Meals Title |
|
83 | + //echo '<h3 class="meals-section-title">' . esc_html__( 'Meal Plan', 'lsx-health-plan' ) . '</h3>'; |
|
84 | + ?> |
|
85 | 85 | <div class="row eating-row"> |
86 | 86 | <div class="col-md-4 eating-column"> |
87 | 87 | <?php |
88 | - if ( ! empty( $pre_breakfast_snack ) ) { |
|
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 | - } |
|
93 | - if ( ! empty( $breakfast ) ) { |
|
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 | - } |
|
98 | - if ( ! empty( $post_breakfast_snack ) ) { |
|
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 | - ?> |
|
88 | + if ( ! empty( $pre_breakfast_snack ) ) { |
|
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 | + } |
|
93 | + if ( ! empty( $breakfast ) ) { |
|
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 | + } |
|
98 | + if ( ! empty( $post_breakfast_snack ) ) { |
|
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 | 110 | </div> |
111 | 111 | <div class="col-md-4 eating-column"> |
112 | 112 | <?php |
113 | - if ( ! empty( $pre_lunch_snack ) ) { |
|
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 | - } |
|
118 | - if ( ! empty( $lunch ) ) { |
|
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 | - } |
|
123 | - if ( ! empty( $post_lunch_snack ) ) { |
|
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 | - ?> |
|
113 | + if ( ! empty( $pre_lunch_snack ) ) { |
|
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 | + } |
|
118 | + if ( ! empty( $lunch ) ) { |
|
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 | + } |
|
123 | + if ( ! empty( $post_lunch_snack ) ) { |
|
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 | 135 | </div> |
136 | 136 | <div class="col-md-4 eating-column"> |
137 | 137 | <?php |
138 | - if ( ! empty( $pre_dinner_snack ) ) { |
|
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 | - } |
|
143 | - if ( ! empty( $dinner ) ) { |
|
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 | - } |
|
148 | - if ( ! empty( $post_dinner_snack ) ) { |
|
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 | - ?> |
|
138 | + if ( ! empty( $pre_dinner_snack ) ) { |
|
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 | + } |
|
143 | + if ( ! empty( $dinner ) ) { |
|
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 | + } |
|
148 | + if ( ! empty( $post_dinner_snack ) ) { |
|
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 | 160 | </div> |
161 | 161 | </div> |
162 | 162 | <?php |
163 | - } |
|
164 | - } |
|
165 | - } |
|
166 | - ?> |
|
163 | + } |
|
164 | + } |
|
165 | + } |
|
166 | + ?> |
|
167 | 167 | <?php wp_reset_postdata(); ?> |
168 | 168 | </div> |
169 | 169 | <?php |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | <?php } ?> |
23 | 23 | <a href="<?php echo esc_url( get_permalink() ); ?>"> |
24 | 24 | <?php |
25 | - $featured_image = get_the_post_thumbnail(); |
|
26 | - if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
27 | - the_post_thumbnail( 'lsx-thumbnail-square', array( |
|
28 | - 'class' => 'aligncenter', |
|
29 | - ) ); |
|
30 | - } else { |
|
31 | - ?> |
|
25 | + $featured_image = get_the_post_thumbnail(); |
|
26 | + if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
27 | + the_post_thumbnail( 'lsx-thumbnail-square', array( |
|
28 | + 'class' => 'aligncenter', |
|
29 | + ) ); |
|
30 | + } else { |
|
31 | + ?> |
|
32 | 32 | <img loading="lazy" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>"> |
33 | 33 | <?php |
34 | - } |
|
35 | - ?> |
|
34 | + } |
|
35 | + ?> |
|
36 | 36 | </a> |
37 | 37 | </div> |
38 | 38 | <div class="content-box meal-content-box white-bg"> |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | <?php the_title( '<h3 class="meal-title">', '</h3>' ); ?> |
41 | 41 | </a> |
42 | 42 | <?php |
43 | - if ( ! has_excerpt() ) { |
|
44 | - $content = wp_trim_words( get_the_content(), 20 ); |
|
45 | - $content = '<p>' . $content . '</p>'; |
|
46 | - } else { |
|
47 | - $content = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
48 | - } |
|
49 | - echo wp_kses_post( $content ); |
|
50 | - ?> |
|
43 | + if ( ! has_excerpt() ) { |
|
44 | + $content = wp_trim_words( get_the_content(), 20 ); |
|
45 | + $content = '<p>' . $content . '</p>'; |
|
46 | + } else { |
|
47 | + $content = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
48 | + } |
|
49 | + echo wp_kses_post( $content ); |
|
50 | + ?> |
|
51 | 51 | <a href="<?php echo esc_url( get_permalink() ); ?>" class="btn border-btn"><?php esc_html_e( 'See meal', 'lsx-health-plan' ); ?></a> |
52 | 52 | </div> |
53 | 53 | <?php lsx_entry_bottom(); ?> |
@@ -14,152 +14,152 @@ |
||
14 | 14 | */ |
15 | 15 | class Tip { |
16 | 16 | |
17 | - /** |
|
18 | - * Holds class instance |
|
19 | - * |
|
20 | - * @since 1.0.0 |
|
21 | - * |
|
22 | - * @var object \lsx_health_plan\classes\Tip() |
|
23 | - */ |
|
24 | - protected static $instance = null; |
|
17 | + /** |
|
18 | + * Holds class instance |
|
19 | + * |
|
20 | + * @since 1.0.0 |
|
21 | + * |
|
22 | + * @var object \lsx_health_plan\classes\Tip() |
|
23 | + */ |
|
24 | + protected static $instance = null; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Holds post_type slug used as an index |
|
28 | - * |
|
29 | - * @since 1.0.0 |
|
30 | - * |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - public $slug = 'tip'; |
|
26 | + /** |
|
27 | + * Holds post_type slug used as an index |
|
28 | + * |
|
29 | + * @since 1.0.0 |
|
30 | + * |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + public $slug = 'tip'; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Constructor |
|
37 | - */ |
|
38 | - public function __construct() { |
|
39 | - $this->default_types = array( |
|
40 | - \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' ), |
|
41 | - \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ), |
|
42 | - \lsx_health_plan\functions\get_option( 'endpoint_recipe_single', 'recipe' ), |
|
43 | - \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ), |
|
44 | - \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ), |
|
45 | - ); |
|
46 | - add_action( 'init', array( $this, 'register_post_type' ) ); |
|
47 | - add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
48 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
49 | - add_action( 'cmb2_admin_init', array( $this, 'tips_connections' ), 15 ); |
|
50 | - } |
|
35 | + /** |
|
36 | + * Constructor |
|
37 | + */ |
|
38 | + public function __construct() { |
|
39 | + $this->default_types = array( |
|
40 | + \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' ), |
|
41 | + \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ), |
|
42 | + \lsx_health_plan\functions\get_option( 'endpoint_recipe_single', 'recipe' ), |
|
43 | + \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ), |
|
44 | + \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ), |
|
45 | + ); |
|
46 | + add_action( 'init', array( $this, 'register_post_type' ) ); |
|
47 | + add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
48 | + add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
49 | + add_action( 'cmb2_admin_init', array( $this, 'tips_connections' ), 15 ); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Return an instance of this class. |
|
54 | - * |
|
55 | - * @since 1.0.0 |
|
56 | - * |
|
57 | - * @return object \lsx_health_plan\classes\Tip() A single instance of this class. |
|
58 | - */ |
|
59 | - public static function get_instance() { |
|
60 | - // If the single instance hasn't been set, set it now. |
|
61 | - if ( null === self::$instance ) { |
|
62 | - self::$instance = new self(); |
|
63 | - } |
|
64 | - return self::$instance; |
|
65 | - } |
|
66 | - /** |
|
67 | - * Register the post type. |
|
68 | - */ |
|
69 | - public function register_post_type() { |
|
70 | - $labels = array( |
|
71 | - 'name' => esc_html__( 'Tips', 'lsx-health-plan' ), |
|
72 | - 'singular_name' => esc_html__( 'Tip', 'lsx-health-plan' ), |
|
73 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
74 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
75 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
76 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
77 | - 'all_items' => esc_html__( 'All Tips', 'lsx-health-plan' ), |
|
78 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
79 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
80 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
81 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
82 | - 'parent_item_colon' => '', |
|
83 | - 'menu_name' => esc_html__( 'Tips', 'lsx-health-plan' ), |
|
84 | - ); |
|
85 | - $args = array( |
|
86 | - 'labels' => $labels, |
|
87 | - 'public' => true, |
|
88 | - 'publicly_queryable' => false, |
|
89 | - 'show_ui' => true, |
|
90 | - 'show_in_menu' => false, |
|
91 | - 'show_in_rest' => true, |
|
92 | - 'menu_icon' => 'dashicons-admin-post', |
|
93 | - 'query_var' => true, |
|
94 | - 'rewrite' => false, |
|
95 | - 'capability_type' => 'post', |
|
96 | - 'has_archive' => false, |
|
97 | - 'hierarchical' => false, |
|
98 | - 'menu_position' => null, |
|
99 | - 'supports' => array( |
|
100 | - 'title', |
|
101 | - 'editor', |
|
102 | - 'thumbnail', |
|
103 | - 'custom-fields', |
|
104 | - ), |
|
105 | - ); |
|
106 | - register_post_type( 'tip', $args ); |
|
107 | - } |
|
52 | + /** |
|
53 | + * Return an instance of this class. |
|
54 | + * |
|
55 | + * @since 1.0.0 |
|
56 | + * |
|
57 | + * @return object \lsx_health_plan\classes\Tip() A single instance of this class. |
|
58 | + */ |
|
59 | + public static function get_instance() { |
|
60 | + // If the single instance hasn't been set, set it now. |
|
61 | + if ( null === self::$instance ) { |
|
62 | + self::$instance = new self(); |
|
63 | + } |
|
64 | + return self::$instance; |
|
65 | + } |
|
66 | + /** |
|
67 | + * Register the post type. |
|
68 | + */ |
|
69 | + public function register_post_type() { |
|
70 | + $labels = array( |
|
71 | + 'name' => esc_html__( 'Tips', 'lsx-health-plan' ), |
|
72 | + 'singular_name' => esc_html__( 'Tip', 'lsx-health-plan' ), |
|
73 | + 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
74 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
75 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
76 | + 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
77 | + 'all_items' => esc_html__( 'All Tips', 'lsx-health-plan' ), |
|
78 | + 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
79 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
80 | + 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
81 | + 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
82 | + 'parent_item_colon' => '', |
|
83 | + 'menu_name' => esc_html__( 'Tips', 'lsx-health-plan' ), |
|
84 | + ); |
|
85 | + $args = array( |
|
86 | + 'labels' => $labels, |
|
87 | + 'public' => true, |
|
88 | + 'publicly_queryable' => false, |
|
89 | + 'show_ui' => true, |
|
90 | + 'show_in_menu' => false, |
|
91 | + 'show_in_rest' => true, |
|
92 | + 'menu_icon' => 'dashicons-admin-post', |
|
93 | + 'query_var' => true, |
|
94 | + 'rewrite' => false, |
|
95 | + 'capability_type' => 'post', |
|
96 | + 'has_archive' => false, |
|
97 | + 'hierarchical' => false, |
|
98 | + 'menu_position' => null, |
|
99 | + 'supports' => array( |
|
100 | + 'title', |
|
101 | + 'editor', |
|
102 | + 'thumbnail', |
|
103 | + 'custom-fields', |
|
104 | + ), |
|
105 | + ); |
|
106 | + register_post_type( 'tip', $args ); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Registers the Recipes under the Meals Post type menu. |
|
111 | - * |
|
112 | - * @return void |
|
113 | - */ |
|
114 | - public function register_menus() { |
|
115 | - add_submenu_page( 'edit.php?post_type=plan', esc_html__( 'Tips', 'lsx-health-plan' ), esc_html__( 'Tips', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=tip' ); |
|
116 | - } |
|
109 | + /** |
|
110 | + * Registers the Recipes under the Meals Post type menu. |
|
111 | + * |
|
112 | + * @return void |
|
113 | + */ |
|
114 | + public function register_menus() { |
|
115 | + add_submenu_page( 'edit.php?post_type=plan', esc_html__( 'Tips', 'lsx-health-plan' ), esc_html__( 'Tips', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=tip' ); |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Enables the Bi Directional relationships |
|
120 | - * |
|
121 | - * @param array $connections |
|
122 | - * @return void |
|
123 | - */ |
|
124 | - public function enable_connections( $connections = array() ) { |
|
125 | - $connections['tip']['connected_plans'] = 'plan_connected_tips'; |
|
126 | - $connections['plan']['plan_connected_tips'] = 'connected_plans'; |
|
127 | - return $connections; |
|
128 | - } |
|
118 | + /** |
|
119 | + * Enables the Bi Directional relationships |
|
120 | + * |
|
121 | + * @param array $connections |
|
122 | + * @return void |
|
123 | + */ |
|
124 | + public function enable_connections( $connections = array() ) { |
|
125 | + $connections['tip']['connected_plans'] = 'plan_connected_tips'; |
|
126 | + $connections['plan']['plan_connected_tips'] = 'connected_plans'; |
|
127 | + return $connections; |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * Registers the workout connections on the plan post type. |
|
132 | - * |
|
133 | - * @return void |
|
134 | - */ |
|
135 | - public function tips_connections() { |
|
136 | - foreach ( $this->default_types as $type => $default_type ) { |
|
137 | - $cmb = new_cmb2_box( |
|
138 | - array( |
|
139 | - 'id' => $default_type . '_tips_connections_metabox', |
|
140 | - 'title' => __( 'Related Tips', 'lsx-health-plan' ), |
|
141 | - 'object_types' => array( $default_type ), // Post types. |
|
142 | - 'context' => 'normal', |
|
143 | - 'priority' => 'high', |
|
144 | - 'show_names' => false, |
|
145 | - ) |
|
146 | - ); |
|
147 | - $cmb->add_field( |
|
148 | - array( |
|
149 | - 'name' => __( 'Tips', 'lsx-health-plan' ), |
|
150 | - 'id' => $default_type . '_connected_tips', |
|
151 | - 'desc' => __( 'Connect the tips that apply to this ', 'lsx-health-plan' ) . $default_type, |
|
152 | - 'type' => 'post_search_ajax', |
|
153 | - 'limit' => 15, |
|
154 | - 'sortable' => true, |
|
155 | - 'query_args' => array( |
|
156 | - 'post_type' => array( 'tip' ), |
|
157 | - 'post_status' => array( 'publish' ), |
|
158 | - 'posts_per_page' => -1, |
|
159 | - ), |
|
160 | - ) |
|
161 | - ); |
|
162 | - } |
|
163 | - } |
|
130 | + /** |
|
131 | + * Registers the workout connections on the plan post type. |
|
132 | + * |
|
133 | + * @return void |
|
134 | + */ |
|
135 | + public function tips_connections() { |
|
136 | + foreach ( $this->default_types as $type => $default_type ) { |
|
137 | + $cmb = new_cmb2_box( |
|
138 | + array( |
|
139 | + 'id' => $default_type . '_tips_connections_metabox', |
|
140 | + 'title' => __( 'Related Tips', 'lsx-health-plan' ), |
|
141 | + 'object_types' => array( $default_type ), // Post types. |
|
142 | + 'context' => 'normal', |
|
143 | + 'priority' => 'high', |
|
144 | + 'show_names' => false, |
|
145 | + ) |
|
146 | + ); |
|
147 | + $cmb->add_field( |
|
148 | + array( |
|
149 | + 'name' => __( 'Tips', 'lsx-health-plan' ), |
|
150 | + 'id' => $default_type . '_connected_tips', |
|
151 | + 'desc' => __( 'Connect the tips that apply to this ', 'lsx-health-plan' ) . $default_type, |
|
152 | + 'type' => 'post_search_ajax', |
|
153 | + 'limit' => 15, |
|
154 | + 'sortable' => true, |
|
155 | + 'query_args' => array( |
|
156 | + 'post_type' => array( 'tip' ), |
|
157 | + 'post_status' => array( 'publish' ), |
|
158 | + 'posts_per_page' => -1, |
|
159 | + ), |
|
160 | + ) |
|
161 | + ); |
|
162 | + } |
|
163 | + } |
|
164 | 164 | |
165 | 165 | } |
@@ -1,19 +1,19 @@ |
||
1 | 1 | <?php |
2 | - $lsx_hp_documentation = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/getting-started/' ); |
|
3 | - $lsx_hp_settings = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/installation/' ); |
|
4 | - $lsx_hp_features = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/' ); |
|
5 | - $version = esc_html( LSX_HEALTH_PLAN_VER ); |
|
2 | + $lsx_hp_documentation = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/getting-started/' ); |
|
3 | + $lsx_hp_settings = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/installation/' ); |
|
4 | + $lsx_hp_features = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/' ); |
|
5 | + $version = esc_html( LSX_HEALTH_PLAN_VER ); |
|
6 | 6 | |
7 | - //Product Urls |
|
8 | - $health_plan_link = esc_url( 'https://wordpress.org/plugins/lsx-health-plan/' ); |
|
9 | - $lsx_hp_plans = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/plans/' ); |
|
10 | - $lsx_hp_weeks = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/plans/#week' ); |
|
11 | - $lsx_hp_tips = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/tips/' ); |
|
12 | - $lsx_hp_workouts = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/workouts/' ); |
|
13 | - $lsx_hp_exercises = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/exercises/' ); |
|
14 | - $lsx_hp_meals = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/meals/' ); |
|
15 | - $lsx_hp_recipes = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/recipes/' ); |
|
16 | - $lsx_hp_shortcodes = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/shortcodes/' ); |
|
7 | + //Product Urls |
|
8 | + $health_plan_link = esc_url( 'https://wordpress.org/plugins/lsx-health-plan/' ); |
|
9 | + $lsx_hp_plans = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/plans/' ); |
|
10 | + $lsx_hp_weeks = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/plans/#week' ); |
|
11 | + $lsx_hp_tips = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/tips/' ); |
|
12 | + $lsx_hp_workouts = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/workouts/' ); |
|
13 | + $lsx_hp_exercises = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/exercises/' ); |
|
14 | + $lsx_hp_meals = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/meals/' ); |
|
15 | + $lsx_hp_recipes = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/recipes/' ); |
|
16 | + $lsx_hp_shortcodes = esc_url( 'https://www.lsdev.biz/lsx/documentation/lsx-health/shortcodes/' ); |
|
17 | 17 | |
18 | 18 | ?> |
19 | 19 |
@@ -12,134 +12,134 @@ |
||
12 | 12 | */ |
13 | 13 | class Help_Page { |
14 | 14 | |
15 | - /** |
|
16 | - * Holds class instance |
|
17 | - * |
|
18 | - * @since 1.0.0 |
|
19 | - * |
|
20 | - * @var object \lsx_health_plan\classes\admin\Help_Page() |
|
21 | - */ |
|
22 | - protected static $instance = null; |
|
23 | - |
|
24 | - /** |
|
25 | - * Option key, and option page slug |
|
26 | - * |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - protected $screen_id = 'lsx_hp_help'; |
|
30 | - |
|
31 | - /** |
|
32 | - * Constructor |
|
33 | - */ |
|
34 | - public function __construct() { |
|
35 | - add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); |
|
36 | - add_action( 'admin_menu', array( $this, 'register_menu' ) ); |
|
37 | - add_action( 'lsx_hp_help', array( $this, 'header' ), 10 ); |
|
38 | - add_action( 'lsx_hp_help', array( $this, 'body' ), 20 ); |
|
39 | - add_action( 'lsx_hp_help', array( $this, 'footer' ), 30 ); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Return an instance of this class. |
|
44 | - * |
|
45 | - * @since 1.0.0 |
|
46 | - * |
|
47 | - * @return object \lsx_health_plan\classes\admin\Help_Page() A single instance of this class. |
|
48 | - */ |
|
49 | - public static function get_instance() { |
|
50 | - // If the single instance hasn't been set, set it now. |
|
51 | - if ( null === self::$instance ) { |
|
52 | - self::$instance = new self(); |
|
53 | - } |
|
54 | - return self::$instance; |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * Load hp_help screen css. |
|
61 | - * |
|
62 | - * @package lsx |
|
63 | - * @subpackage hp-help-page |
|
64 | - * |
|
65 | - * @param string $hook_suffix the current page hook suffix. |
|
66 | - */ |
|
67 | - public function assets( $hook_suffix ) { |
|
68 | - if ( 'plan_page_help' === $hook_suffix ) { |
|
69 | - wp_enqueue_style( 'lsx-hp-help-screen', LSX_HEALTH_PLAN_URL . 'assets/css/help.css', array(), LSX_HEALTH_PLAN_VER ); |
|
70 | - wp_style_add_data( 'lsx-hp-help-screen', 'rtl', 'replace' ); |
|
71 | - } |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Creates the dashboard page. |
|
76 | - * |
|
77 | - * @package lsx |
|
78 | - * @subpackage hp-help-page |
|
79 | - */ |
|
80 | - public function register_menu() { |
|
81 | - add_submenu_page( 'edit.php?post_type=plan', __( 'Help', 'lsx-health-plan' ), __( 'Help', 'lsx-health-plan' ), 'manage_options', 'help', array( $this, 'screen' ) ); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * The help screen. |
|
87 | - * |
|
88 | - * @package lsx |
|
89 | - * @subpackage hp-help-page |
|
90 | - */ |
|
91 | - public function screen() { |
|
92 | - require_once ABSPATH . 'wp-load.php'; |
|
93 | - require_once ABSPATH . 'wp-admin/admin.php'; |
|
94 | - require_once ABSPATH . 'wp-admin/admin-header.php'; |
|
95 | - ?> |
|
15 | + /** |
|
16 | + * Holds class instance |
|
17 | + * |
|
18 | + * @since 1.0.0 |
|
19 | + * |
|
20 | + * @var object \lsx_health_plan\classes\admin\Help_Page() |
|
21 | + */ |
|
22 | + protected static $instance = null; |
|
23 | + |
|
24 | + /** |
|
25 | + * Option key, and option page slug |
|
26 | + * |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + protected $screen_id = 'lsx_hp_help'; |
|
30 | + |
|
31 | + /** |
|
32 | + * Constructor |
|
33 | + */ |
|
34 | + public function __construct() { |
|
35 | + add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); |
|
36 | + add_action( 'admin_menu', array( $this, 'register_menu' ) ); |
|
37 | + add_action( 'lsx_hp_help', array( $this, 'header' ), 10 ); |
|
38 | + add_action( 'lsx_hp_help', array( $this, 'body' ), 20 ); |
|
39 | + add_action( 'lsx_hp_help', array( $this, 'footer' ), 30 ); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Return an instance of this class. |
|
44 | + * |
|
45 | + * @since 1.0.0 |
|
46 | + * |
|
47 | + * @return object \lsx_health_plan\classes\admin\Help_Page() A single instance of this class. |
|
48 | + */ |
|
49 | + public static function get_instance() { |
|
50 | + // If the single instance hasn't been set, set it now. |
|
51 | + if ( null === self::$instance ) { |
|
52 | + self::$instance = new self(); |
|
53 | + } |
|
54 | + return self::$instance; |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * Load hp_help screen css. |
|
61 | + * |
|
62 | + * @package lsx |
|
63 | + * @subpackage hp-help-page |
|
64 | + * |
|
65 | + * @param string $hook_suffix the current page hook suffix. |
|
66 | + */ |
|
67 | + public function assets( $hook_suffix ) { |
|
68 | + if ( 'plan_page_help' === $hook_suffix ) { |
|
69 | + wp_enqueue_style( 'lsx-hp-help-screen', LSX_HEALTH_PLAN_URL . 'assets/css/help.css', array(), LSX_HEALTH_PLAN_VER ); |
|
70 | + wp_style_add_data( 'lsx-hp-help-screen', 'rtl', 'replace' ); |
|
71 | + } |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Creates the dashboard page. |
|
76 | + * |
|
77 | + * @package lsx |
|
78 | + * @subpackage hp-help-page |
|
79 | + */ |
|
80 | + public function register_menu() { |
|
81 | + add_submenu_page( 'edit.php?post_type=plan', __( 'Help', 'lsx-health-plan' ), __( 'Help', 'lsx-health-plan' ), 'manage_options', 'help', array( $this, 'screen' ) ); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * The help screen. |
|
87 | + * |
|
88 | + * @package lsx |
|
89 | + * @subpackage hp-help-page |
|
90 | + */ |
|
91 | + public function screen() { |
|
92 | + require_once ABSPATH . 'wp-load.php'; |
|
93 | + require_once ABSPATH . 'wp-admin/admin.php'; |
|
94 | + require_once ABSPATH . 'wp-admin/admin-header.php'; |
|
95 | + ?> |
|
96 | 96 | <div class="wrap about-wrap"> |
97 | 97 | <?php |
98 | - /** |
|
99 | - * Functions hooked into lsx_hp_help action |
|
100 | - * |
|
101 | - * @hooked lsx_hp_help_header - 10 |
|
102 | - * @hooked lsx_hp_help_body - 20 |
|
103 | - * @hooked lsx_hp_help_footer - 30 |
|
104 | - */ |
|
105 | - do_action( 'lsx_hp_help' ); |
|
106 | - ?> |
|
98 | + /** |
|
99 | + * Functions hooked into lsx_hp_help action |
|
100 | + * |
|
101 | + * @hooked lsx_hp_help_header - 10 |
|
102 | + * @hooked lsx_hp_help_body - 20 |
|
103 | + * @hooked lsx_hp_help_footer - 30 |
|
104 | + */ |
|
105 | + do_action( 'lsx_hp_help' ); |
|
106 | + ?> |
|
107 | 107 | </div> |
108 | 108 | <?php |
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Help screen intro. |
|
113 | - * |
|
114 | - * @package lsx |
|
115 | - * @subpackage hp-help-page |
|
116 | - */ |
|
117 | - public function header() { |
|
118 | - ?> |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Help screen intro. |
|
113 | + * |
|
114 | + * @package lsx |
|
115 | + * @subpackage hp-help-page |
|
116 | + */ |
|
117 | + public function header() { |
|
118 | + ?> |
|
119 | 119 | <div class="enrich"> |
120 | 120 | <h2><?php esc_html_e( 'LightSpeed’s LSX Health Plugin', 'lsx-health-plan' ); ?></h2> |
121 | 121 | <p><?php esc_html_e( "Thank you for using the LSX Health plugin. All of us here at LightSpeed appreciate your ongoing support and we can't wait to see what people create with the plugin. We're committed to ensuring you have all the help you need to make the most of the plugin.", 'lsx-health-plan' ); ?></p> |
122 | 122 | </div> |
123 | 123 | <?php |
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Help screen body section. |
|
128 | - * |
|
129 | - * @package lsx |
|
130 | - * @subpackage hp-help-page |
|
131 | - */ |
|
132 | - public function body() { |
|
133 | - include LSX_HEALTH_PLAN_PATH . 'templates/partials/help.php'; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Help screen contribute section. |
|
138 | - * |
|
139 | - * @package lsx |
|
140 | - * @subpackage hp-help-page |
|
141 | - */ |
|
142 | - public function footer() { |
|
143 | - |
|
144 | - } |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Help screen body section. |
|
128 | + * |
|
129 | + * @package lsx |
|
130 | + * @subpackage hp-help-page |
|
131 | + */ |
|
132 | + public function body() { |
|
133 | + include LSX_HEALTH_PLAN_PATH . 'templates/partials/help.php'; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Help screen contribute section. |
|
138 | + * |
|
139 | + * @package lsx |
|
140 | + * @subpackage hp-help-page |
|
141 | + */ |
|
142 | + public function footer() { |
|
143 | + |
|
144 | + } |
|
145 | 145 | } |
@@ -10,207 +10,207 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class Plan { |
12 | 12 | |
13 | - /** |
|
14 | - * Holds class instance |
|
15 | - * |
|
16 | - * @since 1.0.0 |
|
17 | - * |
|
18 | - * @var object \lsx_health_plan\classes\Plan() |
|
19 | - */ |
|
20 | - protected static $instance = null; |
|
21 | - |
|
22 | - /** |
|
23 | - * Holds post_type slug used as an index |
|
24 | - * |
|
25 | - * @since 1.0.0 |
|
26 | - * |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - public $slug = 'plan'; |
|
30 | - |
|
31 | - /** |
|
32 | - * Constructor |
|
33 | - */ |
|
34 | - public function __construct() { |
|
35 | - |
|
36 | - add_action( 'init', array( $this, 'register_post_type' ) ); |
|
37 | - add_action( 'init', array( $this, 'plan_type_taxonomy_setup' ) ); |
|
38 | - add_action( 'init', array( $this, 'week_taxonomy_setup' ) ); |
|
39 | - |
|
40 | - // Icons for the plan types. |
|
41 | - add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 ); |
|
42 | - add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 ); |
|
43 | - $prefix_taxonomy = 'plan-type'; |
|
44 | - add_action( sprintf( '%s_edit_form_fields', $prefix_taxonomy ), array( $this, 'add_thumbnail_form_field' ), 3, 1 ); |
|
45 | - |
|
46 | - // Register the Metaboxes. |
|
47 | - add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 ); |
|
48 | - add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ), 5 ); |
|
49 | - add_action( 'cmb2_admin_init', array( $this, 'plan_connections' ), 5 ); |
|
50 | - add_action( 'cmb2_admin_init', array( $this, 'sections_metabox_loop' ), 1 ); |
|
51 | - |
|
52 | - add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
53 | - //add_filter( 'lsx_global_header_title', array( $this, 'hp_recipe_header_title' ), 200, 1 ); |
|
54 | - |
|
55 | - // Template Redirects. |
|
56 | - add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
57 | - add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
58 | - |
|
59 | - // Plan Archive Actions. |
|
60 | - add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 ); |
|
61 | - add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
62 | - add_action( 'lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1 ); |
|
63 | - add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1 ); |
|
64 | - add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_filters_disabled', 10, 1 ); |
|
65 | - |
|
66 | - //Breadcrumbs |
|
67 | - add_filter( 'woocommerce_get_breadcrumb', array( $this, 'plan_breadcrumb_filter' ), 30, 1 ); |
|
13 | + /** |
|
14 | + * Holds class instance |
|
15 | + * |
|
16 | + * @since 1.0.0 |
|
17 | + * |
|
18 | + * @var object \lsx_health_plan\classes\Plan() |
|
19 | + */ |
|
20 | + protected static $instance = null; |
|
21 | + |
|
22 | + /** |
|
23 | + * Holds post_type slug used as an index |
|
24 | + * |
|
25 | + * @since 1.0.0 |
|
26 | + * |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + public $slug = 'plan'; |
|
30 | + |
|
31 | + /** |
|
32 | + * Constructor |
|
33 | + */ |
|
34 | + public function __construct() { |
|
35 | + |
|
36 | + add_action( 'init', array( $this, 'register_post_type' ) ); |
|
37 | + add_action( 'init', array( $this, 'plan_type_taxonomy_setup' ) ); |
|
38 | + add_action( 'init', array( $this, 'week_taxonomy_setup' ) ); |
|
39 | + |
|
40 | + // Icons for the plan types. |
|
41 | + add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 ); |
|
42 | + add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 ); |
|
43 | + $prefix_taxonomy = 'plan-type'; |
|
44 | + add_action( sprintf( '%s_edit_form_fields', $prefix_taxonomy ), array( $this, 'add_thumbnail_form_field' ), 3, 1 ); |
|
45 | + |
|
46 | + // Register the Metaboxes. |
|
47 | + add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 ); |
|
48 | + add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ), 5 ); |
|
49 | + add_action( 'cmb2_admin_init', array( $this, 'plan_connections' ), 5 ); |
|
50 | + add_action( 'cmb2_admin_init', array( $this, 'sections_metabox_loop' ), 1 ); |
|
51 | + |
|
52 | + add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
53 | + //add_filter( 'lsx_global_header_title', array( $this, 'hp_recipe_header_title' ), 200, 1 ); |
|
54 | + |
|
55 | + // Template Redirects. |
|
56 | + add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
57 | + add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
58 | + |
|
59 | + // Plan Archive Actions. |
|
60 | + add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 ); |
|
61 | + add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
62 | + add_action( 'lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1 ); |
|
63 | + add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1 ); |
|
64 | + add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_filters_disabled', 10, 1 ); |
|
65 | + |
|
66 | + //Breadcrumbs |
|
67 | + add_filter( 'woocommerce_get_breadcrumb', array( $this, 'plan_breadcrumb_filter' ), 30, 1 ); |
|
68 | 68 | |
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Return an instance of this class. |
|
73 | - * |
|
74 | - * @since 1.0.0 |
|
75 | - * |
|
76 | - * @return object \lsx_health_plan\classes\Meal_Plan() A single instance of this class. |
|
77 | - */ |
|
78 | - public static function get_instance() { |
|
79 | - // If the single instance hasn't been set, set it now. |
|
80 | - if ( null === self::$instance ) { |
|
81 | - self::$instance = new self(); |
|
82 | - } |
|
83 | - return self::$instance; |
|
84 | - } |
|
85 | - /** |
|
86 | - * Register the post type. |
|
87 | - */ |
|
88 | - public function register_post_type() { |
|
89 | - $labels = array( |
|
90 | - 'name' => esc_html__( 'Plans', 'lsx-health-plan' ), |
|
91 | - 'singular_name' => esc_html__( 'Plan', 'lsx-health-plan' ), |
|
92 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
93 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
94 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
95 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
96 | - 'all_items' => esc_html__( 'All Plans', 'lsx-health-plan' ), |
|
97 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
98 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
99 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
100 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
101 | - 'parent_item_colon' => '', |
|
102 | - 'menu_name' => esc_html__( 'Plans', 'lsx-health-plan' ), |
|
103 | - ); |
|
104 | - $args = array( |
|
105 | - 'labels' => $labels, |
|
106 | - 'public' => true, |
|
107 | - 'publicly_queryable' => true, |
|
108 | - 'show_ui' => true, |
|
109 | - 'show_in_menu' => true, |
|
110 | - 'show_in_rest' => true, |
|
111 | - 'menu_icon' => 'dashicons-welcome-write-blog', |
|
112 | - 'query_var' => true, |
|
113 | - 'rewrite' => array( |
|
114 | - 'slug' => \lsx_health_plan\functions\get_option( 'plan_single_slug', 'plan' ), |
|
115 | - ), |
|
116 | - 'capability_type' => 'page', |
|
117 | - 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plans' ), |
|
118 | - 'hierarchical' => false, |
|
119 | - 'menu_position' => null, |
|
120 | - 'supports' => array( |
|
121 | - 'title', |
|
122 | - 'editor', |
|
123 | - 'thumbnail', |
|
124 | - 'page-attributes', |
|
125 | - 'custom-fields', |
|
126 | - ), |
|
127 | - ); |
|
128 | - register_post_type( 'plan', $args ); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Register the Type taxonomy. |
|
133 | - */ |
|
134 | - public function plan_type_taxonomy_setup() { |
|
135 | - $labels = array( |
|
136 | - 'name' => esc_html_x( 'Plan Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
137 | - 'singular_name' => esc_html_x( 'Plan Type', 'taxonomy singular name', 'lsx-health-plan' ), |
|
138 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
139 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
140 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
141 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
142 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
143 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
144 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
145 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
146 | - 'menu_name' => esc_html__( 'Plan Types', 'lsx-health-plan' ), |
|
147 | - ); |
|
148 | - |
|
149 | - $args = array( |
|
150 | - 'hierarchical' => true, |
|
151 | - 'labels' => $labels, |
|
152 | - 'show_ui' => true, |
|
153 | - 'show_admin_column' => true, |
|
154 | - 'query_var' => true, |
|
155 | - 'rewrite' => array( |
|
156 | - 'slug' => 'plan-type', |
|
157 | - ), |
|
158 | - ); |
|
159 | - |
|
160 | - register_taxonomy( 'plan-type', array( 'plan' ), $args ); |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Register the Week taxonomy. |
|
165 | - */ |
|
166 | - public function week_taxonomy_setup() { |
|
167 | - $labels = array( |
|
168 | - 'name' => esc_html_x( 'Week', 'taxonomy general name', 'lsx-health-plan' ), |
|
169 | - 'singular_name' => esc_html_x( 'Week', 'taxonomy singular name', 'lsx-health-plan' ), |
|
170 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
171 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
172 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
173 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
174 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
175 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
176 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
177 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
178 | - 'menu_name' => esc_html__( 'Weeks', 'lsx-health-plan' ), |
|
179 | - ); |
|
180 | - |
|
181 | - $args = array( |
|
182 | - 'hierarchical' => true, |
|
183 | - 'labels' => $labels, |
|
184 | - 'show_ui' => true, |
|
185 | - 'show_admin_column' => true, |
|
186 | - 'query_var' => true, |
|
187 | - 'show_in_rest' => true, |
|
188 | - 'rewrite' => array( |
|
189 | - 'slug' => 'week', |
|
190 | - ), |
|
191 | - ); |
|
192 | - |
|
193 | - register_taxonomy( 'week', array( 'plan' ), $args ); |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * Output the form field for this metadata when adding a new term |
|
198 | - * |
|
199 | - * @since 0.1.0 |
|
200 | - */ |
|
201 | - public function add_thumbnail_form_field( $term = false ) { |
|
202 | - if ( is_object( $term ) ) { |
|
203 | - $value = get_term_meta( $term->term_id, 'thumbnail', true ); |
|
204 | - $image_preview = wp_get_attachment_image_src( $value, 'thumbnail' ); |
|
205 | - |
|
206 | - if ( is_array( $image_preview ) ) { |
|
207 | - $image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url( $image_preview[0] ) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />'; |
|
208 | - } |
|
209 | - } else { |
|
210 | - $image_preview = false; |
|
211 | - $value = false; |
|
212 | - } |
|
213 | - ?> |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Return an instance of this class. |
|
73 | + * |
|
74 | + * @since 1.0.0 |
|
75 | + * |
|
76 | + * @return object \lsx_health_plan\classes\Meal_Plan() A single instance of this class. |
|
77 | + */ |
|
78 | + public static function get_instance() { |
|
79 | + // If the single instance hasn't been set, set it now. |
|
80 | + if ( null === self::$instance ) { |
|
81 | + self::$instance = new self(); |
|
82 | + } |
|
83 | + return self::$instance; |
|
84 | + } |
|
85 | + /** |
|
86 | + * Register the post type. |
|
87 | + */ |
|
88 | + public function register_post_type() { |
|
89 | + $labels = array( |
|
90 | + 'name' => esc_html__( 'Plans', 'lsx-health-plan' ), |
|
91 | + 'singular_name' => esc_html__( 'Plan', 'lsx-health-plan' ), |
|
92 | + 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
93 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
94 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
95 | + 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
96 | + 'all_items' => esc_html__( 'All Plans', 'lsx-health-plan' ), |
|
97 | + 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
98 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
99 | + 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
100 | + 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
101 | + 'parent_item_colon' => '', |
|
102 | + 'menu_name' => esc_html__( 'Plans', 'lsx-health-plan' ), |
|
103 | + ); |
|
104 | + $args = array( |
|
105 | + 'labels' => $labels, |
|
106 | + 'public' => true, |
|
107 | + 'publicly_queryable' => true, |
|
108 | + 'show_ui' => true, |
|
109 | + 'show_in_menu' => true, |
|
110 | + 'show_in_rest' => true, |
|
111 | + 'menu_icon' => 'dashicons-welcome-write-blog', |
|
112 | + 'query_var' => true, |
|
113 | + 'rewrite' => array( |
|
114 | + 'slug' => \lsx_health_plan\functions\get_option( 'plan_single_slug', 'plan' ), |
|
115 | + ), |
|
116 | + 'capability_type' => 'page', |
|
117 | + 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plans' ), |
|
118 | + 'hierarchical' => false, |
|
119 | + 'menu_position' => null, |
|
120 | + 'supports' => array( |
|
121 | + 'title', |
|
122 | + 'editor', |
|
123 | + 'thumbnail', |
|
124 | + 'page-attributes', |
|
125 | + 'custom-fields', |
|
126 | + ), |
|
127 | + ); |
|
128 | + register_post_type( 'plan', $args ); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Register the Type taxonomy. |
|
133 | + */ |
|
134 | + public function plan_type_taxonomy_setup() { |
|
135 | + $labels = array( |
|
136 | + 'name' => esc_html_x( 'Plan Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
137 | + 'singular_name' => esc_html_x( 'Plan Type', 'taxonomy singular name', 'lsx-health-plan' ), |
|
138 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
139 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
140 | + 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
141 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
142 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
143 | + 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
144 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
145 | + 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
146 | + 'menu_name' => esc_html__( 'Plan Types', 'lsx-health-plan' ), |
|
147 | + ); |
|
148 | + |
|
149 | + $args = array( |
|
150 | + 'hierarchical' => true, |
|
151 | + 'labels' => $labels, |
|
152 | + 'show_ui' => true, |
|
153 | + 'show_admin_column' => true, |
|
154 | + 'query_var' => true, |
|
155 | + 'rewrite' => array( |
|
156 | + 'slug' => 'plan-type', |
|
157 | + ), |
|
158 | + ); |
|
159 | + |
|
160 | + register_taxonomy( 'plan-type', array( 'plan' ), $args ); |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Register the Week taxonomy. |
|
165 | + */ |
|
166 | + public function week_taxonomy_setup() { |
|
167 | + $labels = array( |
|
168 | + 'name' => esc_html_x( 'Week', 'taxonomy general name', 'lsx-health-plan' ), |
|
169 | + 'singular_name' => esc_html_x( 'Week', 'taxonomy singular name', 'lsx-health-plan' ), |
|
170 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
171 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
172 | + 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
173 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
174 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
175 | + 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
176 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
177 | + 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
178 | + 'menu_name' => esc_html__( 'Weeks', 'lsx-health-plan' ), |
|
179 | + ); |
|
180 | + |
|
181 | + $args = array( |
|
182 | + 'hierarchical' => true, |
|
183 | + 'labels' => $labels, |
|
184 | + 'show_ui' => true, |
|
185 | + 'show_admin_column' => true, |
|
186 | + 'query_var' => true, |
|
187 | + 'show_in_rest' => true, |
|
188 | + 'rewrite' => array( |
|
189 | + 'slug' => 'week', |
|
190 | + ), |
|
191 | + ); |
|
192 | + |
|
193 | + register_taxonomy( 'week', array( 'plan' ), $args ); |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * Output the form field for this metadata when adding a new term |
|
198 | + * |
|
199 | + * @since 0.1.0 |
|
200 | + */ |
|
201 | + public function add_thumbnail_form_field( $term = false ) { |
|
202 | + if ( is_object( $term ) ) { |
|
203 | + $value = get_term_meta( $term->term_id, 'thumbnail', true ); |
|
204 | + $image_preview = wp_get_attachment_image_src( $value, 'thumbnail' ); |
|
205 | + |
|
206 | + if ( is_array( $image_preview ) ) { |
|
207 | + $image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url( $image_preview[0] ) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />'; |
|
208 | + } |
|
209 | + } else { |
|
210 | + $image_preview = false; |
|
211 | + $value = false; |
|
212 | + } |
|
213 | + ?> |
|
214 | 214 | <tr class="form-field form-required term-thumbnail-wrap"> |
215 | 215 | <th scope="row"><label for="thumbnail"><?php esc_html_e( 'Icon Image', 'lsx-health-plan' ); ?></label></th> |
216 | 216 | <td> |
@@ -224,331 +224,331 @@ discard block |
||
224 | 224 | </td> |
225 | 225 | </tr> |
226 | 226 | <?php |
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * Saves the Taxonomy term icon image |
|
231 | - * |
|
232 | - * @since 0.1.0 |
|
233 | - * |
|
234 | - * @param int $term_id |
|
235 | - * @param string $taxonomy |
|
236 | - */ |
|
237 | - public function save_meta( $term_id = 0, $taxonomy = '' ) { |
|
238 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
239 | - return; |
|
240 | - } |
|
241 | - |
|
242 | - if ( ! isset( $_POST['thumbnail'] ) ) { |
|
243 | - return; |
|
244 | - } |
|
245 | - |
|
246 | - if ( check_admin_referer( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ) ) { |
|
247 | - if ( ! isset( $_POST['thumbnail'] ) ) { |
|
248 | - return; |
|
249 | - } |
|
250 | - |
|
251 | - $thumbnail_meta = sanitize_text_field( $_POST['thumbnail'] ); |
|
252 | - $thumbnail_meta = ! empty( $thumbnail_meta ) ? $thumbnail_meta : ''; |
|
253 | - |
|
254 | - if ( empty( $thumbnail_meta ) ) { |
|
255 | - delete_term_meta( $term_id, 'thumbnail' ); |
|
256 | - } else { |
|
257 | - update_term_meta( $term_id, 'thumbnail', $thumbnail_meta ); |
|
258 | - } |
|
259 | - } |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * Define the metabox and field configurations. |
|
264 | - */ |
|
265 | - public function details_metaboxes() { |
|
266 | - $cmb = new_cmb2_box( array( |
|
267 | - 'id' => $this->slug . '_details_metabox', |
|
268 | - 'title' => __( 'Details', 'lsx-health-plan' ), |
|
269 | - 'object_types' => array( $this->slug ), // Post type |
|
270 | - 'context' => 'normal', |
|
271 | - 'priority' => 'high', |
|
272 | - 'show_names' => true, |
|
273 | - ) ); |
|
274 | - |
|
275 | - $cmb->add_field( array( |
|
276 | - 'name' => __( 'Plan Short Description', 'lsx-health-plan' ), |
|
277 | - 'id' => $this->slug . '_short_description', |
|
278 | - 'type' => 'textarea_small', |
|
279 | - 'desc' => __( 'Add a small description for this plan (optional)', 'lsx-health-plan' ), |
|
280 | - ) ); |
|
281 | - |
|
282 | - $warmup_type = 'page'; |
|
283 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
284 | - $warmup_type = array( 'page', 'workout' ); |
|
285 | - } |
|
286 | - $cmb->add_field( array( |
|
287 | - 'name' => __( 'Warmup', 'lsx-health-plan' ), |
|
288 | - 'desc' => __( 'Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan' ), |
|
289 | - 'id' => $this->slug . '_warmup', |
|
290 | - 'type' => 'post_search_ajax', |
|
291 | - // Optional : |
|
292 | - 'limit' => 3, // Limit selection to X items only (default 1) |
|
293 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
294 | - 'query_args' => array( |
|
295 | - 'post_type' => $warmup_type, |
|
296 | - 'post_status' => array( 'publish' ), |
|
297 | - 'posts_per_page' => -1, |
|
298 | - ), |
|
299 | - ) ); |
|
300 | - } |
|
301 | - |
|
302 | - /** |
|
303 | - * Adds the post type to the different arrays. |
|
304 | - * |
|
305 | - * @param array $post_types |
|
306 | - * @return array |
|
307 | - */ |
|
308 | - public function enable_post_type( $post_types = array() ) { |
|
309 | - $post_types[] = $this->slug; |
|
310 | - return $post_types; |
|
311 | - } |
|
312 | - |
|
313 | - /** |
|
314 | - * Registers the workout connections on the plan post type. |
|
315 | - * |
|
316 | - * @return void |
|
317 | - */ |
|
318 | - public function plan_connections() { |
|
319 | - $cmb = new_cmb2_box( |
|
320 | - array( |
|
321 | - 'id' => $this->slug . '_connections_metabox', |
|
322 | - 'title' => __( 'Plans', 'lsx-health-plan' ), |
|
323 | - 'object_types' => array( 'workout', 'meal', 'tip', 'recipe' ), |
|
324 | - 'context' => 'normal', |
|
325 | - 'priority' => 'high', |
|
326 | - 'show_names' => true, |
|
327 | - ) |
|
328 | - ); |
|
329 | - $cmb->add_field( |
|
330 | - array( |
|
331 | - 'name' => __( 'Plan', 'lsx-health-plan' ), |
|
332 | - 'id' => 'connected_plans', |
|
333 | - 'desc' => __( 'Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan' ), |
|
334 | - 'type' => 'post_search_ajax', |
|
335 | - 'limit' => 15, |
|
336 | - 'sortable' => true, |
|
337 | - 'query_args' => array( |
|
338 | - 'post_type' => array( 'plan' ), |
|
339 | - 'post_status' => array( 'publish' ), |
|
340 | - 'posts_per_page' => -1, |
|
341 | - ), |
|
342 | - ) |
|
343 | - ); |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Remove the "Archives:" from the post type. |
|
348 | - * |
|
349 | - * @param string $title the term title. |
|
350 | - * @return string |
|
351 | - */ |
|
352 | - public function get_the_archive_title( $title ) { |
|
353 | - if ( is_post_type_archive( 'plan' ) ) { |
|
354 | - $title = __( 'Our health plans', 'lsx-health-plan' ); |
|
355 | - } |
|
356 | - return $title; |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * Set the post type archive to show the parent plans only. |
|
361 | - * |
|
362 | - * @param object $wp_query |
|
363 | - * @return array |
|
364 | - */ |
|
365 | - public function set_parent_only( $wp_query ) { |
|
366 | - if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'plan' ) || $wp_query->is_tax( 'plan-type' ) ) ) { |
|
367 | - $wp_query->set( 'post_parent', '0' ); |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * Define the metabox and field configurations. |
|
373 | - */ |
|
374 | - public function featured_metabox() { |
|
375 | - $cmb = new_cmb2_box( |
|
376 | - array( |
|
377 | - 'id' => $this->slug . '_featured_metabox_plan', |
|
378 | - 'title' => __( 'Featured Plan', 'lsx-health-plan' ), |
|
379 | - 'object_types' => array( $this->slug ), // Post type |
|
380 | - 'context' => 'side', |
|
381 | - 'priority' => 'high', |
|
382 | - 'show_names' => true, |
|
383 | - ) |
|
384 | - ); |
|
385 | - $cmb->add_field( |
|
386 | - array( |
|
387 | - 'name' => __( 'Featured Plan', 'lsx-health-plan' ), |
|
388 | - 'desc' => __( 'Enable a featured plan' ), |
|
389 | - 'id' => $this->slug . '_featured_plan', |
|
390 | - 'type' => 'checkbox', |
|
391 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
392 | - ) |
|
393 | - ); |
|
394 | - } |
|
395 | - |
|
396 | - /** |
|
397 | - * Define the metabox and field configurations. |
|
398 | - */ |
|
399 | - public function sections_metabox_loop() { |
|
400 | - $cmb = new_cmb2_box( |
|
401 | - array( |
|
402 | - 'id' => $this->slug . '_sections_metabox', |
|
403 | - 'title' => __( 'Sections', 'lsx-health-plan' ), |
|
404 | - 'object_types' => array( $this->slug ), // Post type. |
|
405 | - 'context' => 'normal', |
|
406 | - 'priority' => 'low', |
|
407 | - 'show_names' => true, |
|
408 | - ) |
|
409 | - ); |
|
410 | - |
|
411 | - /* |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * Saves the Taxonomy term icon image |
|
231 | + * |
|
232 | + * @since 0.1.0 |
|
233 | + * |
|
234 | + * @param int $term_id |
|
235 | + * @param string $taxonomy |
|
236 | + */ |
|
237 | + public function save_meta( $term_id = 0, $taxonomy = '' ) { |
|
238 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
239 | + return; |
|
240 | + } |
|
241 | + |
|
242 | + if ( ! isset( $_POST['thumbnail'] ) ) { |
|
243 | + return; |
|
244 | + } |
|
245 | + |
|
246 | + if ( check_admin_referer( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ) ) { |
|
247 | + if ( ! isset( $_POST['thumbnail'] ) ) { |
|
248 | + return; |
|
249 | + } |
|
250 | + |
|
251 | + $thumbnail_meta = sanitize_text_field( $_POST['thumbnail'] ); |
|
252 | + $thumbnail_meta = ! empty( $thumbnail_meta ) ? $thumbnail_meta : ''; |
|
253 | + |
|
254 | + if ( empty( $thumbnail_meta ) ) { |
|
255 | + delete_term_meta( $term_id, 'thumbnail' ); |
|
256 | + } else { |
|
257 | + update_term_meta( $term_id, 'thumbnail', $thumbnail_meta ); |
|
258 | + } |
|
259 | + } |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * Define the metabox and field configurations. |
|
264 | + */ |
|
265 | + public function details_metaboxes() { |
|
266 | + $cmb = new_cmb2_box( array( |
|
267 | + 'id' => $this->slug . '_details_metabox', |
|
268 | + 'title' => __( 'Details', 'lsx-health-plan' ), |
|
269 | + 'object_types' => array( $this->slug ), // Post type |
|
270 | + 'context' => 'normal', |
|
271 | + 'priority' => 'high', |
|
272 | + 'show_names' => true, |
|
273 | + ) ); |
|
274 | + |
|
275 | + $cmb->add_field( array( |
|
276 | + 'name' => __( 'Plan Short Description', 'lsx-health-plan' ), |
|
277 | + 'id' => $this->slug . '_short_description', |
|
278 | + 'type' => 'textarea_small', |
|
279 | + 'desc' => __( 'Add a small description for this plan (optional)', 'lsx-health-plan' ), |
|
280 | + ) ); |
|
281 | + |
|
282 | + $warmup_type = 'page'; |
|
283 | + if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
284 | + $warmup_type = array( 'page', 'workout' ); |
|
285 | + } |
|
286 | + $cmb->add_field( array( |
|
287 | + 'name' => __( 'Warmup', 'lsx-health-plan' ), |
|
288 | + 'desc' => __( 'Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan' ), |
|
289 | + 'id' => $this->slug . '_warmup', |
|
290 | + 'type' => 'post_search_ajax', |
|
291 | + // Optional : |
|
292 | + 'limit' => 3, // Limit selection to X items only (default 1) |
|
293 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
294 | + 'query_args' => array( |
|
295 | + 'post_type' => $warmup_type, |
|
296 | + 'post_status' => array( 'publish' ), |
|
297 | + 'posts_per_page' => -1, |
|
298 | + ), |
|
299 | + ) ); |
|
300 | + } |
|
301 | + |
|
302 | + /** |
|
303 | + * Adds the post type to the different arrays. |
|
304 | + * |
|
305 | + * @param array $post_types |
|
306 | + * @return array |
|
307 | + */ |
|
308 | + public function enable_post_type( $post_types = array() ) { |
|
309 | + $post_types[] = $this->slug; |
|
310 | + return $post_types; |
|
311 | + } |
|
312 | + |
|
313 | + /** |
|
314 | + * Registers the workout connections on the plan post type. |
|
315 | + * |
|
316 | + * @return void |
|
317 | + */ |
|
318 | + public function plan_connections() { |
|
319 | + $cmb = new_cmb2_box( |
|
320 | + array( |
|
321 | + 'id' => $this->slug . '_connections_metabox', |
|
322 | + 'title' => __( 'Plans', 'lsx-health-plan' ), |
|
323 | + 'object_types' => array( 'workout', 'meal', 'tip', 'recipe' ), |
|
324 | + 'context' => 'normal', |
|
325 | + 'priority' => 'high', |
|
326 | + 'show_names' => true, |
|
327 | + ) |
|
328 | + ); |
|
329 | + $cmb->add_field( |
|
330 | + array( |
|
331 | + 'name' => __( 'Plan', 'lsx-health-plan' ), |
|
332 | + 'id' => 'connected_plans', |
|
333 | + 'desc' => __( 'Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan' ), |
|
334 | + 'type' => 'post_search_ajax', |
|
335 | + 'limit' => 15, |
|
336 | + 'sortable' => true, |
|
337 | + 'query_args' => array( |
|
338 | + 'post_type' => array( 'plan' ), |
|
339 | + 'post_status' => array( 'publish' ), |
|
340 | + 'posts_per_page' => -1, |
|
341 | + ), |
|
342 | + ) |
|
343 | + ); |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Remove the "Archives:" from the post type. |
|
348 | + * |
|
349 | + * @param string $title the term title. |
|
350 | + * @return string |
|
351 | + */ |
|
352 | + public function get_the_archive_title( $title ) { |
|
353 | + if ( is_post_type_archive( 'plan' ) ) { |
|
354 | + $title = __( 'Our health plans', 'lsx-health-plan' ); |
|
355 | + } |
|
356 | + return $title; |
|
357 | + } |
|
358 | + |
|
359 | + /** |
|
360 | + * Set the post type archive to show the parent plans only. |
|
361 | + * |
|
362 | + * @param object $wp_query |
|
363 | + * @return array |
|
364 | + */ |
|
365 | + public function set_parent_only( $wp_query ) { |
|
366 | + if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'plan' ) || $wp_query->is_tax( 'plan-type' ) ) ) { |
|
367 | + $wp_query->set( 'post_parent', '0' ); |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * Define the metabox and field configurations. |
|
373 | + */ |
|
374 | + public function featured_metabox() { |
|
375 | + $cmb = new_cmb2_box( |
|
376 | + array( |
|
377 | + 'id' => $this->slug . '_featured_metabox_plan', |
|
378 | + 'title' => __( 'Featured Plan', 'lsx-health-plan' ), |
|
379 | + 'object_types' => array( $this->slug ), // Post type |
|
380 | + 'context' => 'side', |
|
381 | + 'priority' => 'high', |
|
382 | + 'show_names' => true, |
|
383 | + ) |
|
384 | + ); |
|
385 | + $cmb->add_field( |
|
386 | + array( |
|
387 | + 'name' => __( 'Featured Plan', 'lsx-health-plan' ), |
|
388 | + 'desc' => __( 'Enable a featured plan' ), |
|
389 | + 'id' => $this->slug . '_featured_plan', |
|
390 | + 'type' => 'checkbox', |
|
391 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
392 | + ) |
|
393 | + ); |
|
394 | + } |
|
395 | + |
|
396 | + /** |
|
397 | + * Define the metabox and field configurations. |
|
398 | + */ |
|
399 | + public function sections_metabox_loop() { |
|
400 | + $cmb = new_cmb2_box( |
|
401 | + array( |
|
402 | + 'id' => $this->slug . '_sections_metabox', |
|
403 | + 'title' => __( 'Sections', 'lsx-health-plan' ), |
|
404 | + 'object_types' => array( $this->slug ), // Post type. |
|
405 | + 'context' => 'normal', |
|
406 | + 'priority' => 'low', |
|
407 | + 'show_names' => true, |
|
408 | + ) |
|
409 | + ); |
|
410 | + |
|
411 | + /* |
|
412 | 412 | This is where the repeatable group is defined, each field has the same ID as the legacy field. |
413 | 413 | There is a function which runs and adds to looped fields to individual fields for WP Query compatability. |
414 | 414 | */ |
415 | - $group = $cmb->add_field( |
|
416 | - array( |
|
417 | - 'id' => $this->slug . '_sections', |
|
418 | - 'type' => 'group', |
|
419 | - 'options' => array( |
|
420 | - 'group_title' => __( 'Section', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number |
|
421 | - 'add_button' => __( 'Add section', 'lsx-health-plan' ), |
|
422 | - 'remove_button' => __( 'Remove section', 'lsx-health-plan' ), |
|
423 | - 'sortable' => true, |
|
424 | - 'closed' => true, // true to have the groups closed by default |
|
425 | - ), |
|
426 | - 'classes' => 'lsx-admin-row', |
|
415 | + $group = $cmb->add_field( |
|
416 | + array( |
|
417 | + 'id' => $this->slug . '_sections', |
|
418 | + 'type' => 'group', |
|
419 | + 'options' => array( |
|
420 | + 'group_title' => __( 'Section', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number |
|
421 | + 'add_button' => __( 'Add section', 'lsx-health-plan' ), |
|
422 | + 'remove_button' => __( 'Remove section', 'lsx-health-plan' ), |
|
423 | + 'sortable' => true, |
|
424 | + 'closed' => true, // true to have the groups closed by default |
|
425 | + ), |
|
426 | + 'classes' => 'lsx-admin-row', |
|
427 | 427 | |
428 | - ) |
|
429 | - ); |
|
430 | - |
|
431 | - $cmb->add_group_field( |
|
432 | - $group, |
|
433 | - array( |
|
434 | - 'name' => __( 'Title', 'lsx-health-plan' ), |
|
435 | - 'id' => 'title', |
|
436 | - 'type' => 'text', |
|
437 | - 'desc' => __( 'e.g Day 1 / Week 1', 'lsx-health-plan' ), |
|
438 | - 'classes' => 'lsx-field-col lsx-field-col-50', |
|
439 | - ) |
|
440 | - ); |
|
441 | - |
|
442 | - $cmb->add_group_field( |
|
443 | - $group, |
|
444 | - array( |
|
445 | - 'name' => __( 'Group', 'lsx-health-plan' ), |
|
446 | - 'id' => 'group', |
|
447 | - 'type' => 'text', |
|
448 | - 'desc' => __( 'e.g Week 1 / January', 'lsx-health-plan' ), |
|
449 | - 'classes' => 'lsx-field-col lsx-field-col-50', |
|
450 | - ) |
|
451 | - ); |
|
452 | - |
|
453 | - $cmb->add_group_field( |
|
454 | - $group, |
|
455 | - array( |
|
456 | - 'name' => __( 'Overview', 'lsx-health-plan' ), |
|
457 | - 'id' => 'description', |
|
458 | - 'type' => 'wysiwyg', |
|
459 | - ) |
|
460 | - ); |
|
461 | - |
|
462 | - if ( post_type_exists( 'workout' ) ) { |
|
463 | - $cmb->add_group_field( |
|
464 | - $group, |
|
465 | - array( |
|
466 | - 'name' => __( 'Workouts', 'lsx-health-plan' ), |
|
467 | - 'id' => 'connected_workouts', |
|
468 | - 'desc' => __( 'Connect the workout(s) that apply to this section.', 'lsx-health-plan' ), |
|
469 | - 'type' => 'post_search_ajax', |
|
470 | - 'limit' => 15, |
|
471 | - 'sortable' => true, |
|
472 | - 'query_args' => array( |
|
473 | - 'post_type' => array( 'workout' ), |
|
474 | - 'post_status' => array( 'publish' ), |
|
475 | - 'posts_per_page' => -1, |
|
476 | - ), |
|
477 | - 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-33', |
|
478 | - ) |
|
479 | - ); |
|
480 | - } |
|
481 | - |
|
482 | - if ( post_type_exists( 'meal' ) ) { |
|
483 | - $cmb->add_group_field( |
|
484 | - $group, |
|
485 | - array( |
|
486 | - 'name' => __( 'Meals', 'lsx-health-plan' ), |
|
487 | - 'desc' => __( 'Connect the meal(s) that apply to this section.', 'lsx-health-plan' ), |
|
488 | - 'id' => 'connected_meals', |
|
489 | - 'type' => 'post_search_ajax', |
|
490 | - // Optional : |
|
491 | - 'limit' => 15, // Limit selection to X items only (default 1) |
|
492 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
493 | - 'query_args' => array( |
|
494 | - 'post_type' => array( 'meal' ), |
|
495 | - 'post_status' => array( 'publish' ), |
|
496 | - 'posts_per_page' => -1, |
|
497 | - ), |
|
498 | - 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-33', |
|
499 | - ) |
|
500 | - ); |
|
501 | - } |
|
502 | - if ( post_type_exists( 'tip' ) ) { |
|
503 | - $cmb->add_group_field( |
|
504 | - $group, |
|
505 | - array( |
|
506 | - 'name' => __( 'Tips', 'lsx-health-plan' ), |
|
507 | - 'id' => 'connected_tips', |
|
508 | - 'desc' => __( 'Connect the tip(s) that apply to this section.', 'lsx-health-plan' ), |
|
509 | - 'type' => 'post_search_ajax', |
|
510 | - // Optional : |
|
511 | - 'limit' => 15, // Limit selection to X items only (default 1) |
|
512 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
513 | - 'query_args' => array( |
|
514 | - 'post_type' => array( 'tip' ), |
|
515 | - 'post_status' => array( 'publish' ), |
|
516 | - 'posts_per_page' => -1, |
|
517 | - ), |
|
518 | - 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-33', |
|
519 | - ) |
|
520 | - ); |
|
521 | - } |
|
522 | - } |
|
523 | - |
|
524 | - /** |
|
525 | - * Holds the array for the single plan breadcrumbs. |
|
526 | - * |
|
527 | - * @var array $crumbs |
|
528 | - * @return array |
|
529 | - */ |
|
530 | - public function plan_breadcrumb_filter( $crumbs ) { |
|
531 | - if ( is_singular( 'plan' ) ) { |
|
532 | - $plan = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ); |
|
533 | - $plans = \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plan' ); |
|
534 | - $plan_name = get_the_title(); |
|
535 | - $url = get_post_type_archive_link( $plan ); |
|
536 | - $term_obj_list = get_the_terms( get_the_ID(), 'plan-type' ); |
|
537 | - $plan_type = $term_obj_list[0]->name; |
|
538 | - $plan_type_url = get_term_link( $term_obj_list[0]->term_id ); |
|
428 | + ) |
|
429 | + ); |
|
430 | + |
|
431 | + $cmb->add_group_field( |
|
432 | + $group, |
|
433 | + array( |
|
434 | + 'name' => __( 'Title', 'lsx-health-plan' ), |
|
435 | + 'id' => 'title', |
|
436 | + 'type' => 'text', |
|
437 | + 'desc' => __( 'e.g Day 1 / Week 1', 'lsx-health-plan' ), |
|
438 | + 'classes' => 'lsx-field-col lsx-field-col-50', |
|
439 | + ) |
|
440 | + ); |
|
441 | + |
|
442 | + $cmb->add_group_field( |
|
443 | + $group, |
|
444 | + array( |
|
445 | + 'name' => __( 'Group', 'lsx-health-plan' ), |
|
446 | + 'id' => 'group', |
|
447 | + 'type' => 'text', |
|
448 | + 'desc' => __( 'e.g Week 1 / January', 'lsx-health-plan' ), |
|
449 | + 'classes' => 'lsx-field-col lsx-field-col-50', |
|
450 | + ) |
|
451 | + ); |
|
452 | + |
|
453 | + $cmb->add_group_field( |
|
454 | + $group, |
|
455 | + array( |
|
456 | + 'name' => __( 'Overview', 'lsx-health-plan' ), |
|
457 | + 'id' => 'description', |
|
458 | + 'type' => 'wysiwyg', |
|
459 | + ) |
|
460 | + ); |
|
461 | + |
|
462 | + if ( post_type_exists( 'workout' ) ) { |
|
463 | + $cmb->add_group_field( |
|
464 | + $group, |
|
465 | + array( |
|
466 | + 'name' => __( 'Workouts', 'lsx-health-plan' ), |
|
467 | + 'id' => 'connected_workouts', |
|
468 | + 'desc' => __( 'Connect the workout(s) that apply to this section.', 'lsx-health-plan' ), |
|
469 | + 'type' => 'post_search_ajax', |
|
470 | + 'limit' => 15, |
|
471 | + 'sortable' => true, |
|
472 | + 'query_args' => array( |
|
473 | + 'post_type' => array( 'workout' ), |
|
474 | + 'post_status' => array( 'publish' ), |
|
475 | + 'posts_per_page' => -1, |
|
476 | + ), |
|
477 | + 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-33', |
|
478 | + ) |
|
479 | + ); |
|
480 | + } |
|
481 | + |
|
482 | + if ( post_type_exists( 'meal' ) ) { |
|
483 | + $cmb->add_group_field( |
|
484 | + $group, |
|
485 | + array( |
|
486 | + 'name' => __( 'Meals', 'lsx-health-plan' ), |
|
487 | + 'desc' => __( 'Connect the meal(s) that apply to this section.', 'lsx-health-plan' ), |
|
488 | + 'id' => 'connected_meals', |
|
489 | + 'type' => 'post_search_ajax', |
|
490 | + // Optional : |
|
491 | + 'limit' => 15, // Limit selection to X items only (default 1) |
|
492 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
493 | + 'query_args' => array( |
|
494 | + 'post_type' => array( 'meal' ), |
|
495 | + 'post_status' => array( 'publish' ), |
|
496 | + 'posts_per_page' => -1, |
|
497 | + ), |
|
498 | + 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-33', |
|
499 | + ) |
|
500 | + ); |
|
501 | + } |
|
502 | + if ( post_type_exists( 'tip' ) ) { |
|
503 | + $cmb->add_group_field( |
|
504 | + $group, |
|
505 | + array( |
|
506 | + 'name' => __( 'Tips', 'lsx-health-plan' ), |
|
507 | + 'id' => 'connected_tips', |
|
508 | + 'desc' => __( 'Connect the tip(s) that apply to this section.', 'lsx-health-plan' ), |
|
509 | + 'type' => 'post_search_ajax', |
|
510 | + // Optional : |
|
511 | + 'limit' => 15, // Limit selection to X items only (default 1) |
|
512 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
513 | + 'query_args' => array( |
|
514 | + 'post_type' => array( 'tip' ), |
|
515 | + 'post_status' => array( 'publish' ), |
|
516 | + 'posts_per_page' => -1, |
|
517 | + ), |
|
518 | + 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-33', |
|
519 | + ) |
|
520 | + ); |
|
521 | + } |
|
522 | + } |
|
523 | + |
|
524 | + /** |
|
525 | + * Holds the array for the single plan breadcrumbs. |
|
526 | + * |
|
527 | + * @var array $crumbs |
|
528 | + * @return array |
|
529 | + */ |
|
530 | + public function plan_breadcrumb_filter( $crumbs ) { |
|
531 | + if ( is_singular( 'plan' ) ) { |
|
532 | + $plan = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ); |
|
533 | + $plans = \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plan' ); |
|
534 | + $plan_name = get_the_title(); |
|
535 | + $url = get_post_type_archive_link( $plan ); |
|
536 | + $term_obj_list = get_the_terms( get_the_ID(), 'plan-type' ); |
|
537 | + $plan_type = $term_obj_list[0]->name; |
|
538 | + $plan_type_url = get_term_link( $term_obj_list[0]->term_id ); |
|
539 | 539 | |
540 | - $crumbs[1] = array( |
|
541 | - 0 => $plans, |
|
542 | - 1 => $url, |
|
543 | - ); |
|
544 | - $crumbs[2] = array( |
|
545 | - 0 => $plan_type, |
|
546 | - 1 => $plan_type_url, |
|
547 | - ); |
|
548 | - $crumbs[3] = array( |
|
549 | - 0 => $plan_name, |
|
550 | - ); |
|
551 | - } |
|
552 | - return $crumbs; |
|
553 | - } |
|
540 | + $crumbs[1] = array( |
|
541 | + 0 => $plans, |
|
542 | + 1 => $url, |
|
543 | + ); |
|
544 | + $crumbs[2] = array( |
|
545 | + 0 => $plan_type, |
|
546 | + 1 => $plan_type_url, |
|
547 | + ); |
|
548 | + $crumbs[3] = array( |
|
549 | + 0 => $plan_name, |
|
550 | + ); |
|
551 | + } |
|
552 | + return $crumbs; |
|
553 | + } |
|
554 | 554 | } |
@@ -8,169 +8,169 @@ |
||
8 | 8 | */ |
9 | 9 | class General { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\frontend\General() |
|
17 | - */ |
|
18 | - protected static $instance = null; |
|
19 | - |
|
20 | - /** |
|
21 | - * Constructor |
|
22 | - */ |
|
23 | - public function __construct() { |
|
24 | - // Before Output. |
|
25 | - add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 ); |
|
26 | - add_filter( 'wp_kses_allowed_html', array( $this, 'allow_html_tags_attributes' ), 100, 2 ); |
|
27 | - |
|
28 | - // Output. |
|
29 | - add_action( 'body_class', array( $this, 'body_classes' ) ); |
|
30 | - add_filter( 'lsx_global_header_title', array( $this, 'single_title' ), 200, 1 ); |
|
31 | - add_action( 'wp_head', array( $this, 'remove_single_footer' ), 99 ); |
|
32 | - add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 9 ); |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * Return an instance of this class. |
|
37 | - * |
|
38 | - * @since 1.0.0 |
|
39 | - * |
|
40 | - * @return object \lsx_health_plan\classes\frontend\General() A single instance of this class. |
|
41 | - */ |
|
42 | - public static function get_instance() { |
|
43 | - // If the single instance hasn't been set, set it now. |
|
44 | - if ( null === self::$instance ) { |
|
45 | - self::$instance = new self(); |
|
46 | - } |
|
47 | - return self::$instance; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * Registers the plugin frontend assets |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function assets() { |
|
56 | - |
|
57 | - if ( is_post_type_archive( 'plan' ) && false === \lsx_health_plan\functions\plan\is_filters_disabled() ) { |
|
58 | - wp_enqueue_script( 'isotope', LSX_HEALTH_PLAN_URL . 'assets/js/vendor/isotope.pkgd.min.js', array( 'jquery' ), null, LSX_HEALTH_PLAN_URL, true ); |
|
59 | - } |
|
60 | - |
|
61 | - wp_enqueue_style( 'lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER ); |
|
62 | - wp_style_add_data( 'lsx-health-plan', 'rtl', 'replace' ); |
|
63 | - wp_enqueue_script( 'lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array( 'jquery' ) ); |
|
64 | - |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Adds the iframe and the progress HTML tags to the allowed WordPress list. |
|
69 | - */ |
|
70 | - public function allow_html_tags_attributes( $tags, $context ) { |
|
71 | - if ( 'post' === $context ) { |
|
72 | - $tags['iframe'] = array( |
|
73 | - 'src' => true, |
|
74 | - 'height' => true, |
|
75 | - 'width' => true, |
|
76 | - 'frameborder' => true, |
|
77 | - 'allowfullscreen' => true, |
|
78 | - ); |
|
79 | - } |
|
80 | - $tags['progress'] = array( |
|
81 | - 'id' => true, |
|
82 | - 'value' => true, |
|
83 | - 'max' => true, |
|
84 | - ); |
|
85 | - return $tags; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Add body classes to body. |
|
90 | - * |
|
91 | - * @param array $classes |
|
92 | - * @return void |
|
93 | - */ |
|
94 | - public function body_classes( $classes = array() ) { |
|
95 | - global $post; |
|
96 | - |
|
97 | - if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'lsx_health_plan_my_profile_block' ) ) { |
|
98 | - $classes[] = 'my-plan-shortcode'; |
|
99 | - } |
|
100 | - |
|
101 | - if ( is_single() && is_singular( 'plan' ) ) { |
|
102 | - $args = array( |
|
103 | - 'post_parent' => get_the_ID(), |
|
104 | - 'post_type' => 'plan', |
|
105 | - ); |
|
106 | - |
|
107 | - $post_id = get_the_ID(); |
|
108 | - $has_children = get_children( $args ); |
|
109 | - $has_parent = wp_get_post_parent_id( $post_id ); |
|
110 | - |
|
111 | - if ( ! empty( $has_children ) ) { |
|
112 | - $plan_type_class = 'parent-plan-page'; |
|
113 | - if ( 0 !== $has_parent ) { |
|
114 | - $plan_type_class = 'parent-sub-plan-page'; |
|
115 | - } |
|
116 | - } else { |
|
117 | - $plan_type_class = 'unique-plan-page'; |
|
118 | - if ( 0 !== $has_parent ) { |
|
119 | - $plan_type_class = 'child-plan-page'; |
|
120 | - } |
|
121 | - } |
|
122 | - $classes[] = $plan_type_class; |
|
123 | - } |
|
124 | - return $classes; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * Remove the single recipe and exercise title |
|
129 | - */ |
|
130 | - public function single_title( $title ) { |
|
131 | - |
|
132 | - if ( is_single() && is_singular( 'recipe' ) ) { |
|
133 | - |
|
134 | - $title = __( 'Recipe', 'lsx-health-plan' ); |
|
135 | - } |
|
136 | - |
|
137 | - if ( is_single() && is_singular( 'exercise' ) ) { |
|
138 | - |
|
139 | - $title = __( 'Exercise', 'lsx-health-plan' ); |
|
140 | - } |
|
141 | - |
|
142 | - return $title; |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Removing footer for HP single pages. |
|
147 | - * |
|
148 | - * @return void |
|
149 | - */ |
|
150 | - public function remove_single_footer() { |
|
151 | - if ( ( is_single() && is_singular( array( 'exercise', 'recipe', 'workout', 'meal' ) ) ) || ( is_archive() && is_post_type_archive( array( 'exercise', 'recipe', 'workout', 'meal' ) ) )) { |
|
152 | - remove_action( 'lsx_footer_before', 'lsx_add_footer_sidebar_area' ); |
|
153 | - } |
|
154 | - } |
|
155 | - /** |
|
156 | - * Remove the "Archives:" from the post type recipes. |
|
157 | - * |
|
158 | - * @param string $title the term title. |
|
159 | - * @return string |
|
160 | - */ |
|
161 | - public function get_the_archive_title( $title ) { |
|
162 | - if ( is_post_type_archive( 'recipe' ) ) { |
|
163 | - $title = __( 'Recipes', 'lsx-health-plan' ); |
|
164 | - } |
|
165 | - if ( is_post_type_archive( 'exercise' ) ) { |
|
166 | - $title = __( 'Exercises', 'lsx-health-plan' ); |
|
167 | - } |
|
168 | - if ( is_tax() ) { |
|
169 | - $queried_object = get_queried_object(); |
|
170 | - if ( isset( $queried_object->name ) ) { |
|
171 | - $title = $queried_object->name; |
|
172 | - } |
|
173 | - } |
|
174 | - return $title; |
|
175 | - } |
|
11 | + /** |
|
12 | + * Holds class instance |
|
13 | + * |
|
14 | + * @since 1.0.0 |
|
15 | + * |
|
16 | + * @var object \lsx_health_plan\classes\frontend\General() |
|
17 | + */ |
|
18 | + protected static $instance = null; |
|
19 | + |
|
20 | + /** |
|
21 | + * Constructor |
|
22 | + */ |
|
23 | + public function __construct() { |
|
24 | + // Before Output. |
|
25 | + add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 ); |
|
26 | + add_filter( 'wp_kses_allowed_html', array( $this, 'allow_html_tags_attributes' ), 100, 2 ); |
|
27 | + |
|
28 | + // Output. |
|
29 | + add_action( 'body_class', array( $this, 'body_classes' ) ); |
|
30 | + add_filter( 'lsx_global_header_title', array( $this, 'single_title' ), 200, 1 ); |
|
31 | + add_action( 'wp_head', array( $this, 'remove_single_footer' ), 99 ); |
|
32 | + add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 9 ); |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * Return an instance of this class. |
|
37 | + * |
|
38 | + * @since 1.0.0 |
|
39 | + * |
|
40 | + * @return object \lsx_health_plan\classes\frontend\General() A single instance of this class. |
|
41 | + */ |
|
42 | + public static function get_instance() { |
|
43 | + // If the single instance hasn't been set, set it now. |
|
44 | + if ( null === self::$instance ) { |
|
45 | + self::$instance = new self(); |
|
46 | + } |
|
47 | + return self::$instance; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * Registers the plugin frontend assets |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function assets() { |
|
56 | + |
|
57 | + if ( is_post_type_archive( 'plan' ) && false === \lsx_health_plan\functions\plan\is_filters_disabled() ) { |
|
58 | + wp_enqueue_script( 'isotope', LSX_HEALTH_PLAN_URL . 'assets/js/vendor/isotope.pkgd.min.js', array( 'jquery' ), null, LSX_HEALTH_PLAN_URL, true ); |
|
59 | + } |
|
60 | + |
|
61 | + wp_enqueue_style( 'lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER ); |
|
62 | + wp_style_add_data( 'lsx-health-plan', 'rtl', 'replace' ); |
|
63 | + wp_enqueue_script( 'lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array( 'jquery' ) ); |
|
64 | + |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Adds the iframe and the progress HTML tags to the allowed WordPress list. |
|
69 | + */ |
|
70 | + public function allow_html_tags_attributes( $tags, $context ) { |
|
71 | + if ( 'post' === $context ) { |
|
72 | + $tags['iframe'] = array( |
|
73 | + 'src' => true, |
|
74 | + 'height' => true, |
|
75 | + 'width' => true, |
|
76 | + 'frameborder' => true, |
|
77 | + 'allowfullscreen' => true, |
|
78 | + ); |
|
79 | + } |
|
80 | + $tags['progress'] = array( |
|
81 | + 'id' => true, |
|
82 | + 'value' => true, |
|
83 | + 'max' => true, |
|
84 | + ); |
|
85 | + return $tags; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Add body classes to body. |
|
90 | + * |
|
91 | + * @param array $classes |
|
92 | + * @return void |
|
93 | + */ |
|
94 | + public function body_classes( $classes = array() ) { |
|
95 | + global $post; |
|
96 | + |
|
97 | + if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'lsx_health_plan_my_profile_block' ) ) { |
|
98 | + $classes[] = 'my-plan-shortcode'; |
|
99 | + } |
|
100 | + |
|
101 | + if ( is_single() && is_singular( 'plan' ) ) { |
|
102 | + $args = array( |
|
103 | + 'post_parent' => get_the_ID(), |
|
104 | + 'post_type' => 'plan', |
|
105 | + ); |
|
106 | + |
|
107 | + $post_id = get_the_ID(); |
|
108 | + $has_children = get_children( $args ); |
|
109 | + $has_parent = wp_get_post_parent_id( $post_id ); |
|
110 | + |
|
111 | + if ( ! empty( $has_children ) ) { |
|
112 | + $plan_type_class = 'parent-plan-page'; |
|
113 | + if ( 0 !== $has_parent ) { |
|
114 | + $plan_type_class = 'parent-sub-plan-page'; |
|
115 | + } |
|
116 | + } else { |
|
117 | + $plan_type_class = 'unique-plan-page'; |
|
118 | + if ( 0 !== $has_parent ) { |
|
119 | + $plan_type_class = 'child-plan-page'; |
|
120 | + } |
|
121 | + } |
|
122 | + $classes[] = $plan_type_class; |
|
123 | + } |
|
124 | + return $classes; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * Remove the single recipe and exercise title |
|
129 | + */ |
|
130 | + public function single_title( $title ) { |
|
131 | + |
|
132 | + if ( is_single() && is_singular( 'recipe' ) ) { |
|
133 | + |
|
134 | + $title = __( 'Recipe', 'lsx-health-plan' ); |
|
135 | + } |
|
136 | + |
|
137 | + if ( is_single() && is_singular( 'exercise' ) ) { |
|
138 | + |
|
139 | + $title = __( 'Exercise', 'lsx-health-plan' ); |
|
140 | + } |
|
141 | + |
|
142 | + return $title; |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Removing footer for HP single pages. |
|
147 | + * |
|
148 | + * @return void |
|
149 | + */ |
|
150 | + public function remove_single_footer() { |
|
151 | + if ( ( is_single() && is_singular( array( 'exercise', 'recipe', 'workout', 'meal' ) ) ) || ( is_archive() && is_post_type_archive( array( 'exercise', 'recipe', 'workout', 'meal' ) ) )) { |
|
152 | + remove_action( 'lsx_footer_before', 'lsx_add_footer_sidebar_area' ); |
|
153 | + } |
|
154 | + } |
|
155 | + /** |
|
156 | + * Remove the "Archives:" from the post type recipes. |
|
157 | + * |
|
158 | + * @param string $title the term title. |
|
159 | + * @return string |
|
160 | + */ |
|
161 | + public function get_the_archive_title( $title ) { |
|
162 | + if ( is_post_type_archive( 'recipe' ) ) { |
|
163 | + $title = __( 'Recipes', 'lsx-health-plan' ); |
|
164 | + } |
|
165 | + if ( is_post_type_archive( 'exercise' ) ) { |
|
166 | + $title = __( 'Exercises', 'lsx-health-plan' ); |
|
167 | + } |
|
168 | + if ( is_tax() ) { |
|
169 | + $queried_object = get_queried_object(); |
|
170 | + if ( isset( $queried_object->name ) ) { |
|
171 | + $title = $queried_object->name; |
|
172 | + } |
|
173 | + } |
|
174 | + return $title; |
|
175 | + } |
|
176 | 176 | } |
@@ -8,110 +8,110 @@ |
||
8 | 8 | */ |
9 | 9 | class Checkout { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\integrations\woocommerce\Checkout() |
|
17 | - */ |
|
18 | - protected static $instance = null; |
|
11 | + /** |
|
12 | + * Holds class instance |
|
13 | + * |
|
14 | + * @since 1.0.0 |
|
15 | + * |
|
16 | + * @var object \lsx_health_plan\classes\integrations\woocommerce\Checkout() |
|
17 | + */ |
|
18 | + protected static $instance = null; |
|
19 | 19 | |
20 | - /** |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - public $plan_id = ''; |
|
20 | + /** |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + public $plan_id = ''; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Constructor |
|
27 | - */ |
|
28 | - public function __construct() { |
|
29 | - add_filter( 'woocommerce_order_button_text', array( $this, 'checkout_button_text' ), 10, 1 ); |
|
25 | + /** |
|
26 | + * Constructor |
|
27 | + */ |
|
28 | + public function __construct() { |
|
29 | + add_filter( 'woocommerce_order_button_text', array( $this, 'checkout_button_text' ), 10, 1 ); |
|
30 | 30 | |
31 | - // Cart Messages. |
|
32 | - add_action( 'lsx_content_wrap_before', array( $this, 'cart_notices' ) ); |
|
33 | - add_filter( 'wc_add_to_cart_message_html', array( $this, 'add_to_cart_message' ), 10, 3 ); |
|
34 | - } |
|
31 | + // Cart Messages. |
|
32 | + add_action( 'lsx_content_wrap_before', array( $this, 'cart_notices' ) ); |
|
33 | + add_filter( 'wc_add_to_cart_message_html', array( $this, 'add_to_cart_message' ), 10, 3 ); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * Return an instance of this class. |
|
38 | - * |
|
39 | - * @since 1.0.0 |
|
40 | - * |
|
41 | - * @return object \lsx_health_plan\classes\integrations\woocommerce\Checkout() A single instance of this class. |
|
42 | - */ |
|
43 | - public static function get_instance() { |
|
44 | - // If the single instance hasn't been set, set it now. |
|
45 | - if ( null === self::$instance ) { |
|
46 | - self::$instance = new self(); |
|
47 | - } |
|
48 | - return self::$instance; |
|
49 | - } |
|
36 | + /** |
|
37 | + * Return an instance of this class. |
|
38 | + * |
|
39 | + * @since 1.0.0 |
|
40 | + * |
|
41 | + * @return object \lsx_health_plan\classes\integrations\woocommerce\Checkout() A single instance of this class. |
|
42 | + */ |
|
43 | + public static function get_instance() { |
|
44 | + // If the single instance hasn't been set, set it now. |
|
45 | + if ( null === self::$instance ) { |
|
46 | + self::$instance = new self(); |
|
47 | + } |
|
48 | + return self::$instance; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Return the Place Order Text |
|
53 | - * |
|
54 | - * @param string $label |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public function checkout_button_text( $label = '' ) { |
|
58 | - $label = __( 'Place order', 'lsx-health-plan' ); |
|
59 | - return $label; |
|
60 | - } |
|
51 | + /** |
|
52 | + * Return the Place Order Text |
|
53 | + * |
|
54 | + * @param string $label |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public function checkout_button_text( $label = '' ) { |
|
58 | + $label = __( 'Place order', 'lsx-health-plan' ); |
|
59 | + return $label; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Saves the Plan ID to the cart data, so we can attach it to the order later. |
|
64 | - * |
|
65 | - * @param array $cart_item_data |
|
66 | - * @param string $product_id |
|
67 | - * @param string $variation_id |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - public function add_plan_id_to_cart( $cart_item_data, $product_id, $variation_id ) { |
|
71 | - $plan_id = filter_input( INPUT_GET, 'plan_id' ); |
|
72 | - if ( empty( $plan_id ) || '' === $plan_id ) { |
|
73 | - return $cart_item_data; |
|
74 | - } |
|
75 | - $cart_item_data['plan_id'] = $plan_id; |
|
76 | - return $cart_item_data; |
|
77 | - } |
|
62 | + /** |
|
63 | + * Saves the Plan ID to the cart data, so we can attach it to the order later. |
|
64 | + * |
|
65 | + * @param array $cart_item_data |
|
66 | + * @param string $product_id |
|
67 | + * @param string $variation_id |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + public function add_plan_id_to_cart( $cart_item_data, $product_id, $variation_id ) { |
|
71 | + $plan_id = filter_input( INPUT_GET, 'plan_id' ); |
|
72 | + if ( empty( $plan_id ) || '' === $plan_id ) { |
|
73 | + return $cart_item_data; |
|
74 | + } |
|
75 | + $cart_item_data['plan_id'] = $plan_id; |
|
76 | + return $cart_item_data; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Output the WooCommerce Cart Notices. |
|
81 | - * |
|
82 | - * @return void |
|
83 | - */ |
|
84 | - public function cart_notices() { |
|
85 | - if ( function_exists( 'woocommerce_output_all_notices' ) && is_post_type_archive( 'plan' ) ) { |
|
86 | - echo wp_kses_post( '<div class="col-md-12 col-sm-12 woocommerce-notices-wrapper">' ); |
|
87 | - wc_print_notices(); |
|
88 | - echo wp_kses_post( '</div>' ); |
|
89 | - } |
|
90 | - } |
|
79 | + /** |
|
80 | + * Output the WooCommerce Cart Notices. |
|
81 | + * |
|
82 | + * @return void |
|
83 | + */ |
|
84 | + public function cart_notices() { |
|
85 | + if ( function_exists( 'woocommerce_output_all_notices' ) && is_post_type_archive( 'plan' ) ) { |
|
86 | + echo wp_kses_post( '<div class="col-md-12 col-sm-12 woocommerce-notices-wrapper">' ); |
|
87 | + wc_print_notices(); |
|
88 | + echo wp_kses_post( '</div>' ); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Changes the add to cart message and adds our course name. |
|
94 | - * |
|
95 | - * @param string $message |
|
96 | - * @param array $products |
|
97 | - * @param boolean $show_qty |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - public function add_to_cart_message( $message, $products, $show_qty ) { |
|
101 | - if ( isset( $_GET['plan_id'] ) ) { // @codingStandardsIgnoreLine. |
|
102 | - $this->plan_id = sanitize_text_field( wp_slash( $_GET['plan_id'] ) ); // @codingStandardsIgnoreLine. |
|
92 | + /** |
|
93 | + * Changes the add to cart message and adds our course name. |
|
94 | + * |
|
95 | + * @param string $message |
|
96 | + * @param array $products |
|
97 | + * @param boolean $show_qty |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + public function add_to_cart_message( $message, $products, $show_qty ) { |
|
101 | + if ( isset( $_GET['plan_id'] ) ) { // @codingStandardsIgnoreLine. |
|
102 | + $this->plan_id = sanitize_text_field( wp_slash( $_GET['plan_id'] ) ); // @codingStandardsIgnoreLine. |
|
103 | 103 | |
104 | - $title = '<strong>' . get_the_title( $this->plan_id ) . '</strong>'; |
|
105 | - $title = sprintf( _n( '%s has been added to your cart.', '%s have been added to your cart.', 1, 'lsx-health-plan' ), $title ); |
|
104 | + $title = '<strong>' . get_the_title( $this->plan_id ) . '</strong>'; |
|
105 | + $title = sprintf( _n( '%s has been added to your cart.', '%s have been added to your cart.', 1, 'lsx-health-plan' ), $title ); |
|
106 | 106 | |
107 | - // Output success messages. |
|
108 | - if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) { |
|
109 | - $return_to = apply_filters( 'woocommerce_continue_shopping_redirect', wc_get_raw_referer() ? wp_validate_redirect( wc_get_raw_referer(), false ) : wc_get_page_permalink( 'shop' ) ); |
|
110 | - $message = sprintf( '<a href="%s" tabindex="1" class="btn button wc-forward">%s</a> %s', esc_url( $return_to ), esc_html__( 'Continue shopping', 'lsx-health-plan' ), $title ); |
|
111 | - } else { |
|
112 | - $message = sprintf( '<a href="%s" tabindex="1" class="btn button wc-forward">%s</a> %s', esc_url( wc_get_cart_url() ), esc_html__( 'View cart', 'lsx-health-plan' ), $title ); |
|
113 | - } |
|
114 | - } |
|
115 | - return $message; |
|
116 | - } |
|
107 | + // Output success messages. |
|
108 | + if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) { |
|
109 | + $return_to = apply_filters( 'woocommerce_continue_shopping_redirect', wc_get_raw_referer() ? wp_validate_redirect( wc_get_raw_referer(), false ) : wc_get_page_permalink( 'shop' ) ); |
|
110 | + $message = sprintf( '<a href="%s" tabindex="1" class="btn button wc-forward">%s</a> %s', esc_url( $return_to ), esc_html__( 'Continue shopping', 'lsx-health-plan' ), $title ); |
|
111 | + } else { |
|
112 | + $message = sprintf( '<a href="%s" tabindex="1" class="btn button wc-forward">%s</a> %s', esc_url( wc_get_cart_url() ), esc_html__( 'View cart', 'lsx-health-plan' ), $title ); |
|
113 | + } |
|
114 | + } |
|
115 | + return $message; |
|
116 | + } |
|
117 | 117 | } |