@@ -17,24 +17,24 @@ discard block |
||
17 | 17 | * @return boolean |
18 | 18 | */ |
19 | 19 | function has_attached_post( $post_id = '', $meta_key = '', $single = true ) { |
20 | - $has_post = false; |
|
21 | - if ( '' === $post_id ) { |
|
22 | - $post_id = get_the_ID(); |
|
23 | - } |
|
24 | - $items = get_post_meta( $post_id, $meta_key, $single ); |
|
25 | - if ( '' !== $items && false !== $items && 0 !== $items ) { |
|
26 | - $items = check_posts_exist( $items ); |
|
27 | - if ( ! empty( $items ) ) { |
|
28 | - $has_post = true; |
|
29 | - } |
|
30 | - } else { |
|
31 | - // Check for defaults. |
|
32 | - $options = get_option( 'all' ); |
|
33 | - if ( isset( $options[ $meta_key ] ) && '' !== $options[ $meta_key ] && ! empty( $options[ $meta_key ] ) ) { |
|
34 | - $has_post = true; |
|
35 | - } |
|
36 | - } |
|
37 | - return $has_post; |
|
20 | + $has_post = false; |
|
21 | + if ( '' === $post_id ) { |
|
22 | + $post_id = get_the_ID(); |
|
23 | + } |
|
24 | + $items = get_post_meta( $post_id, $meta_key, $single ); |
|
25 | + if ( '' !== $items && false !== $items && 0 !== $items ) { |
|
26 | + $items = check_posts_exist( $items ); |
|
27 | + if ( ! empty( $items ) ) { |
|
28 | + $has_post = true; |
|
29 | + } |
|
30 | + } else { |
|
31 | + // Check for defaults. |
|
32 | + $options = get_option( 'all' ); |
|
33 | + if ( isset( $options[ $meta_key ] ) && '' !== $options[ $meta_key ] && ! empty( $options[ $meta_key ] ) ) { |
|
34 | + $has_post = true; |
|
35 | + } |
|
36 | + } |
|
37 | + return $has_post; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -45,18 +45,18 @@ discard block |
||
45 | 45 | * @return mixed Option value |
46 | 46 | */ |
47 | 47 | function get_option( $key = '', $default = false ) { |
48 | - if ( function_exists( 'cmb2_get_option' ) ) { |
|
49 | - return cmb2_get_option( 'lsx_health_plan_options', $key, $default ); |
|
50 | - } |
|
51 | - // Fallback to get_option if CMB2 is not loaded yet. |
|
52 | - $opts = \get_option( 'lsx_health_plan_options', $default ); |
|
53 | - $val = $default; |
|
54 | - if ( 'all' === $key ) { |
|
55 | - $val = $opts; |
|
56 | - } elseif ( is_array( $opts ) && array_key_exists( $key, $opts ) && false !== $opts[ $key ] ) { |
|
57 | - $val = $opts[ $key ]; |
|
58 | - } |
|
59 | - return $val; |
|
48 | + if ( function_exists( 'cmb2_get_option' ) ) { |
|
49 | + return cmb2_get_option( 'lsx_health_plan_options', $key, $default ); |
|
50 | + } |
|
51 | + // Fallback to get_option if CMB2 is not loaded yet. |
|
52 | + $opts = \get_option( 'lsx_health_plan_options', $default ); |
|
53 | + $val = $default; |
|
54 | + if ( 'all' === $key ) { |
|
55 | + $val = $opts; |
|
56 | + } elseif ( is_array( $opts ) && array_key_exists( $key, $opts ) && false !== $opts[ $key ] ) { |
|
57 | + $val = $opts[ $key ]; |
|
58 | + } |
|
59 | + return $val; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -67,54 +67,54 @@ discard block |
||
67 | 67 | * @return mixed Option value |
68 | 68 | */ |
69 | 69 | function get_downloads( $type = 'all', $post_id = '' ) { |
70 | - $lsx_health_plan = \lsx_health_plan(); |
|
71 | - $post_types = $lsx_health_plan->get_post_types(); |
|
72 | - if ( '' === $post_id ) { |
|
73 | - $post_id = get_the_ID(); |
|
74 | - } |
|
75 | - $downloads = array(); |
|
76 | - $options = get_option( 'all' ); |
|
70 | + $lsx_health_plan = \lsx_health_plan(); |
|
71 | + $post_types = $lsx_health_plan->get_post_types(); |
|
72 | + if ( '' === $post_id ) { |
|
73 | + $post_id = get_the_ID(); |
|
74 | + } |
|
75 | + $downloads = array(); |
|
76 | + $options = get_option( 'all' ); |
|
77 | 77 | |
78 | - foreach ( $post_types as $post_type ) { |
|
79 | - if ( 'all' === $type || in_array( $type, $post_types, true ) ) { |
|
78 | + foreach ( $post_types as $post_type ) { |
|
79 | + if ( 'all' === $type || in_array( $type, $post_types, true ) ) { |
|
80 | 80 | |
81 | - // Get the default downloads for this post type. |
|
82 | - $default_downloads = array(); |
|
83 | - $new_downloads = array(); |
|
84 | - if ( isset( $options[ 'download_' . $post_type ] ) ) { |
|
85 | - if ( is_array( $options[ 'download_' . $post_type ] ) ) { |
|
86 | - $default_downloads = $options[ 'download_' . $post_type ]; |
|
87 | - } else { |
|
88 | - $default_downloads[] = $options[ 'download_' . $post_type ]; |
|
89 | - } |
|
90 | - } |
|
81 | + // Get the default downloads for this post type. |
|
82 | + $default_downloads = array(); |
|
83 | + $new_downloads = array(); |
|
84 | + if ( isset( $options[ 'download_' . $post_type ] ) ) { |
|
85 | + if ( is_array( $options[ 'download_' . $post_type ] ) ) { |
|
86 | + $default_downloads = $options[ 'download_' . $post_type ]; |
|
87 | + } else { |
|
88 | + $default_downloads[] = $options[ 'download_' . $post_type ]; |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - if ( 'page' === $post_type ) { |
|
93 | - $key = 'plan_warmup'; |
|
94 | - } else { |
|
95 | - $key = 'connected_' . $post_type . 's'; |
|
96 | - } |
|
92 | + if ( 'page' === $post_type ) { |
|
93 | + $key = 'plan_warmup'; |
|
94 | + } else { |
|
95 | + $key = 'connected_' . $post_type . 's'; |
|
96 | + } |
|
97 | 97 | |
98 | - $connected_items = get_post_meta( $post_id, $key, true ); |
|
99 | - if ( ! empty( $connected_items ) ) { |
|
100 | - foreach ( $connected_items as $connected_item ) { |
|
101 | - $current_downloads = get_post_meta( $connected_item, 'connected_downloads', true ); |
|
102 | - if ( false !== $current_downloads && ! empty( $current_downloads ) ) { |
|
103 | - $new_downloads = array_merge( $new_downloads, $current_downloads ); |
|
104 | - } |
|
105 | - } |
|
106 | - } |
|
98 | + $connected_items = get_post_meta( $post_id, $key, true ); |
|
99 | + if ( ! empty( $connected_items ) ) { |
|
100 | + foreach ( $connected_items as $connected_item ) { |
|
101 | + $current_downloads = get_post_meta( $connected_item, 'connected_downloads', true ); |
|
102 | + if ( false !== $current_downloads && ! empty( $current_downloads ) ) { |
|
103 | + $new_downloads = array_merge( $new_downloads, $current_downloads ); |
|
104 | + } |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - if ( ! empty( $new_downloads ) ) { |
|
109 | - $downloads = array_merge( $downloads, $new_downloads ); |
|
110 | - } elseif ( ! empty( $default_downloads ) ) { |
|
111 | - $downloads = array_merge( $downloads, $default_downloads ); |
|
112 | - } |
|
113 | - $downloads = array_unique( $downloads ); |
|
114 | - } |
|
115 | - } |
|
116 | - $downloads = check_posts_exist( $downloads ); |
|
117 | - return $downloads; |
|
108 | + if ( ! empty( $new_downloads ) ) { |
|
109 | + $downloads = array_merge( $downloads, $new_downloads ); |
|
110 | + } elseif ( ! empty( $default_downloads ) ) { |
|
111 | + $downloads = array_merge( $downloads, $default_downloads ); |
|
112 | + } |
|
113 | + $downloads = array_unique( $downloads ); |
|
114 | + } |
|
115 | + } |
|
116 | + $downloads = check_posts_exist( $downloads ); |
|
117 | + return $downloads; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -124,35 +124,35 @@ discard block |
||
124 | 124 | * @return array an array of the downloads or empty. |
125 | 125 | */ |
126 | 126 | function get_weekly_downloads( $week = '' ) { |
127 | - $downloads = array(); |
|
128 | - if ( '' !== $week ) { |
|
129 | - $saved_downloads = get_transient( 'lsx_hp_weekly_downloads_' . $week ); |
|
130 | - if ( false !== $saved_downloads && ! empty( $saved_downloads ) ) { |
|
131 | - $downloads = $saved_downloads; |
|
132 | - } else { |
|
133 | - $args = array( |
|
134 | - 'orderby' => 'title', |
|
135 | - 'order' => 'ASC', |
|
136 | - 'post_type' => 'dlm_download', |
|
137 | - 'posts_per_page' => -1, |
|
138 | - 'nopagin' => true, |
|
139 | - 'fields' => 'ids', |
|
140 | - 'tax_query' => array( |
|
141 | - array( |
|
142 | - 'taxonomy' => 'dlm_download_category', |
|
143 | - 'field' => 'slug', |
|
144 | - 'terms' => array( $week ), |
|
145 | - ), |
|
146 | - ), |
|
147 | - ); |
|
148 | - $download_query = new \WP_Query( $args ); |
|
149 | - if ( $download_query->have_posts() ) { |
|
150 | - $downloads = $download_query->posts; |
|
151 | - } |
|
152 | - } |
|
153 | - } |
|
154 | - $downloads = check_posts_exist( $downloads ); |
|
155 | - return $downloads; |
|
127 | + $downloads = array(); |
|
128 | + if ( '' !== $week ) { |
|
129 | + $saved_downloads = get_transient( 'lsx_hp_weekly_downloads_' . $week ); |
|
130 | + if ( false !== $saved_downloads && ! empty( $saved_downloads ) ) { |
|
131 | + $downloads = $saved_downloads; |
|
132 | + } else { |
|
133 | + $args = array( |
|
134 | + 'orderby' => 'title', |
|
135 | + 'order' => 'ASC', |
|
136 | + 'post_type' => 'dlm_download', |
|
137 | + 'posts_per_page' => -1, |
|
138 | + 'nopagin' => true, |
|
139 | + 'fields' => 'ids', |
|
140 | + 'tax_query' => array( |
|
141 | + array( |
|
142 | + 'taxonomy' => 'dlm_download_category', |
|
143 | + 'field' => 'slug', |
|
144 | + 'terms' => array( $week ), |
|
145 | + ), |
|
146 | + ), |
|
147 | + ); |
|
148 | + $download_query = new \WP_Query( $args ); |
|
149 | + if ( $download_query->have_posts() ) { |
|
150 | + $downloads = $download_query->posts; |
|
151 | + } |
|
152 | + } |
|
153 | + } |
|
154 | + $downloads = check_posts_exist( $downloads ); |
|
155 | + return $downloads; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -162,22 +162,22 @@ discard block |
||
162 | 162 | * @return void |
163 | 163 | */ |
164 | 164 | function check_posts_exist( $post_ids = array() ) { |
165 | - $new_ids = array(); |
|
166 | - global $wpdb; |
|
167 | - if ( is_array( $post_ids ) && ! empty( $post_ids ) ) { |
|
168 | - $post_ids = "'" . implode( "','", $post_ids ) . "'"; |
|
169 | - $query = " |
|
165 | + $new_ids = array(); |
|
166 | + global $wpdb; |
|
167 | + if ( is_array( $post_ids ) && ! empty( $post_ids ) ) { |
|
168 | + $post_ids = "'" . implode( "','", $post_ids ) . "'"; |
|
169 | + $query = " |
|
170 | 170 | SELECT `ID` |
171 | 171 | FROM `{$wpdb->posts}` |
172 | 172 | WHERE `ID` IN ({$post_ids}) |
173 | 173 | AND `post_status` != 'trash' |
174 | 174 | "; |
175 | - $results = $wpdb->get_results( $query ); // WPCS: unprepared SQL |
|
176 | - if ( ! empty( $results ) ) { |
|
177 | - $new_ids = wp_list_pluck( $results, 'ID' ); |
|
178 | - } |
|
179 | - } |
|
180 | - return $new_ids; |
|
175 | + $results = $wpdb->get_results( $query ); // WPCS: unprepared SQL |
|
176 | + if ( ! empty( $results ) ) { |
|
177 | + $new_ids = wp_list_pluck( $results, 'ID' ); |
|
178 | + } |
|
179 | + } |
|
180 | + return $new_ids; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | * @return void |
190 | 190 | */ |
191 | 191 | function register_modal( $id = '', $title = '', $body = '' ) { |
192 | - lsx_health_plan()->frontend->modals->register_modal( |
|
193 | - array( |
|
194 | - 'title' => $title, |
|
195 | - 'body' => $body, |
|
196 | - ), |
|
197 | - $id |
|
198 | - ); |
|
192 | + lsx_health_plan()->frontend->modals->register_modal( |
|
193 | + array( |
|
194 | + 'title' => $title, |
|
195 | + 'body' => $body, |
|
196 | + ), |
|
197 | + $id |
|
198 | + ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -205,13 +205,13 @@ discard block |
||
205 | 205 | * @return void |
206 | 206 | */ |
207 | 207 | function output_modal( $args = array() ) { |
208 | - $defaults = array( |
|
209 | - 'id' => '', |
|
210 | - 'title' => '', |
|
211 | - 'body' => '', |
|
212 | - ); |
|
213 | - $args = wp_parse_args( $args, $defaults ); |
|
214 | - ?> |
|
208 | + $defaults = array( |
|
209 | + 'id' => '', |
|
210 | + 'title' => '', |
|
211 | + 'body' => '', |
|
212 | + ); |
|
213 | + $args = wp_parse_args( $args, $defaults ); |
|
214 | + ?> |
|
215 | 215 | <!-- Modal --> |
216 | 216 | <div class="modal fade lsx-health-plan-modal" id="<?php echo esc_html( $args['id'] ); ?>" tabindex="-1" role="dialog" aria-labelledby="<?php echo esc_html( $args['id'] ); ?>" aria-hidden="true"> |
217 | 217 | <div class="modal-dialog" role="document"> |
@@ -219,36 +219,36 @@ discard block |
||
219 | 219 | <button type="button" class="close" data-dismiss="modal">×</button> |
220 | 220 | <div class="modal-header"> |
221 | 221 | <?php |
222 | - if ( '' !== $args['title'] ) { |
|
223 | - echo wp_kses_post( '<h2>' . $args['title'] . '</h2>' ); |
|
224 | - } |
|
225 | - ?> |
|
222 | + if ( '' !== $args['title'] ) { |
|
223 | + echo wp_kses_post( '<h2>' . $args['title'] . '</h2>' ); |
|
224 | + } |
|
225 | + ?> |
|
226 | 226 | </div> |
227 | 227 | <div class="modal-body"> |
228 | 228 | <?php |
229 | - if ( '' !== $args['body'] ) { |
|
230 | - $allowed_html = array( |
|
231 | - 'iframe' => array( |
|
232 | - 'data-src' => array(), |
|
233 | - 'src' => array(), |
|
234 | - 'width' => array(), |
|
235 | - 'height' => array(), |
|
236 | - 'frameBorder' => array( '0' ), |
|
237 | - 'class' => array(), |
|
238 | - 'allowFullScreen' => array(), |
|
239 | - 'style' => array(), |
|
240 | - ), |
|
241 | - 'h5' => array( |
|
242 | - 'class' => array(), |
|
243 | - ), |
|
244 | - ); |
|
245 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
246 | - echo wp_kses_post( $args['body'] ); |
|
247 | - } else { |
|
248 | - echo wp_kses( $args['body'], $allowed_html ); |
|
249 | - } |
|
250 | - } |
|
251 | - ?> |
|
229 | + if ( '' !== $args['body'] ) { |
|
230 | + $allowed_html = array( |
|
231 | + 'iframe' => array( |
|
232 | + 'data-src' => array(), |
|
233 | + 'src' => array(), |
|
234 | + 'width' => array(), |
|
235 | + 'height' => array(), |
|
236 | + 'frameBorder' => array( '0' ), |
|
237 | + 'class' => array(), |
|
238 | + 'allowFullScreen' => array(), |
|
239 | + 'style' => array(), |
|
240 | + ), |
|
241 | + 'h5' => array( |
|
242 | + 'class' => array(), |
|
243 | + ), |
|
244 | + ); |
|
245 | + if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
246 | + echo wp_kses_post( $args['body'] ); |
|
247 | + } else { |
|
248 | + echo wp_kses( $args['body'], $allowed_html ); |
|
249 | + } |
|
250 | + } |
|
251 | + ?> |
|
252 | 252 | </div> |
253 | 253 | </div> |
254 | 254 | </div> |
@@ -264,18 +264,18 @@ discard block |
||
264 | 264 | * @return void |
265 | 265 | */ |
266 | 266 | function get_video_url( $embed ) { |
267 | - $url = ''; |
|
268 | - if ( false !== stripos( $embed, '<iframe' ) ) { |
|
269 | - preg_match( '/src="([^"]+)"/', $embed, $match ); |
|
270 | - if ( is_array( $match ) && isset( $match[1] ) ) { |
|
271 | - $url = '<iframe data-src="' . $match[1] . '" style="border: 0;" frameBorder="0" class="giphy-embed" allowFullScreen height="300" width="100%"></iframe>'; |
|
272 | - } else { |
|
273 | - $url = $embed; |
|
274 | - } |
|
275 | - } else { |
|
276 | - $url = $embed; |
|
277 | - } |
|
278 | - return $url; |
|
267 | + $url = ''; |
|
268 | + if ( false !== stripos( $embed, '<iframe' ) ) { |
|
269 | + preg_match( '/src="([^"]+)"/', $embed, $match ); |
|
270 | + if ( is_array( $match ) && isset( $match[1] ) ) { |
|
271 | + $url = '<iframe data-src="' . $match[1] . '" style="border: 0;" frameBorder="0" class="giphy-embed" allowFullScreen height="300" width="100%"></iframe>'; |
|
272 | + } else { |
|
273 | + $url = $embed; |
|
274 | + } |
|
275 | + } else { |
|
276 | + $url = $embed; |
|
277 | + } |
|
278 | + return $url; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -286,17 +286,17 @@ discard block |
||
286 | 286 | * @return boolean |
287 | 287 | */ |
288 | 288 | function is_week_complete( $term_id = false, $post_ids = array() ) { |
289 | - $return = false; |
|
290 | - if ( ! empty( $post_ids ) ) { |
|
291 | - foreach ( $post_ids as &$pid ) { |
|
292 | - $pid = 'day_' . $pid . '_complete'; |
|
293 | - } |
|
294 | - $days_complete = get_meta_amounts( $post_ids ); |
|
295 | - if ( 7 === $days_complete || '7' === $days_complete ) { |
|
296 | - $return = true; |
|
297 | - } |
|
298 | - } |
|
299 | - return $return; |
|
289 | + $return = false; |
|
290 | + if ( ! empty( $post_ids ) ) { |
|
291 | + foreach ( $post_ids as &$pid ) { |
|
292 | + $pid = 'day_' . $pid . '_complete'; |
|
293 | + } |
|
294 | + $days_complete = get_meta_amounts( $post_ids ); |
|
295 | + if ( 7 === $days_complete || '7' === $days_complete ) { |
|
296 | + $return = true; |
|
297 | + } |
|
298 | + } |
|
299 | + return $return; |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -307,34 +307,34 @@ discard block |
||
307 | 307 | * @return void |
308 | 308 | */ |
309 | 309 | function get_meta_amounts( $post_ids = array() ) { |
310 | - global $wpdb; |
|
311 | - $amount = 0; |
|
312 | - $current_user = wp_get_current_user(); |
|
313 | - if ( false !== $current_user && ! empty( $post_ids ) ) { |
|
314 | - $post_ids = "'" . implode( "','", $post_ids ) . "'"; |
|
315 | - $query = " |
|
310 | + global $wpdb; |
|
311 | + $amount = 0; |
|
312 | + $current_user = wp_get_current_user(); |
|
313 | + if ( false !== $current_user && ! empty( $post_ids ) ) { |
|
314 | + $post_ids = "'" . implode( "','", $post_ids ) . "'"; |
|
315 | + $query = " |
|
316 | 316 | SELECT COUNT(`meta_value`) |
317 | 317 | FROM `{$wpdb->usermeta}` |
318 | 318 | WHERE `meta_key` IN ({$post_ids}) |
319 | 319 | AND `user_id` = '{$current_user->ID}' |
320 | 320 | "; |
321 | - $results = $wpdb->get_var( $query ); // WPCS: unprepared SQL |
|
322 | - if ( ! empty( $results ) ) { |
|
323 | - $amount = $results; |
|
324 | - } |
|
325 | - } |
|
326 | - return $amount; |
|
321 | + $results = $wpdb->get_var( $query ); // WPCS: unprepared SQL |
|
322 | + if ( ! empty( $results ) ) { |
|
323 | + $amount = $results; |
|
324 | + } |
|
325 | + } |
|
326 | + return $amount; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
330 | 330 | * Limit media library access |
331 | 331 | */ |
332 | 332 | function set_only_author( $wp_query ) { |
333 | - global $current_user; |
|
334 | - if ( is_admin() && ! current_user_can( 'edit_others_posts' ) ) { |
|
335 | - $wp_query->set( 'administrator', $current_user->ID ); |
|
336 | - add_filter( 'views_upload', 'fix_media_counts' ); |
|
337 | - } |
|
333 | + global $current_user; |
|
334 | + if ( is_admin() && ! current_user_can( 'edit_others_posts' ) ) { |
|
335 | + $wp_query->set( 'administrator', $current_user->ID ); |
|
336 | + add_filter( 'views_upload', 'fix_media_counts' ); |
|
337 | + } |
|
338 | 338 | } |
339 | 339 | add_action( 'pre_get_posts', '\lsx_health_plan\functions\set_only_author' ); |
340 | 340 | |
@@ -345,13 +345,13 @@ discard block |
||
345 | 345 | * @return void |
346 | 346 | */ |
347 | 347 | function hp_excerpt( $post_id ) { |
348 | - if ( ! has_excerpt( $post_id ) ) { |
|
349 | - $content = wp_trim_words( get_the_content( $post_id ), 20 ); |
|
350 | - $content = '<p>' . $content . '</p>'; |
|
351 | - } else { |
|
352 | - $content = get_the_excerpt( $post_id ); |
|
353 | - } |
|
354 | - return $content; |
|
348 | + if ( ! has_excerpt( $post_id ) ) { |
|
349 | + $content = wp_trim_words( get_the_content( $post_id ), 20 ); |
|
350 | + $content = '<p>' . $content . '</p>'; |
|
351 | + } else { |
|
352 | + $content = get_the_excerpt( $post_id ); |
|
353 | + } |
|
354 | + return $content; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -361,8 +361,8 @@ discard block |
||
361 | 361 | * @return void |
362 | 362 | */ |
363 | 363 | function column_class( $columns = '3' ) { |
364 | - $cols .= '5' === $columns ? '15' : 12 / $columns; |
|
365 | - return $cols; |
|
364 | + $cols .= '5' === $columns ? '15' : 12 / $columns; |
|
365 | + return $cols; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -372,20 +372,20 @@ discard block |
||
372 | 372 | * @return void |
373 | 373 | */ |
374 | 374 | function get_exercises_by_workout( $workout = '' ) { |
375 | - $exercises = array(); |
|
376 | - $i = 1; |
|
377 | - $section_counter = 6; |
|
378 | - while ( $i <= $section_counter ) { |
|
379 | - $group_name = 'workout_section_' . $i; |
|
380 | - $groups = get_post_meta( $workout, $group_name, true ); |
|
381 | - if ( ! empty( $groups ) ) { |
|
382 | - foreach ( $groups as $group ) { |
|
383 | - if ( isset( $group['connected_exercises'] ) ) { |
|
384 | - $exercises[] = $group['connected_exercises']; |
|
385 | - } |
|
386 | - } |
|
387 | - } |
|
388 | - $i++; |
|
389 | - } |
|
390 | - return $exercises; |
|
375 | + $exercises = array(); |
|
376 | + $i = 1; |
|
377 | + $section_counter = 6; |
|
378 | + while ( $i <= $section_counter ) { |
|
379 | + $group_name = 'workout_section_' . $i; |
|
380 | + $groups = get_post_meta( $workout, $group_name, true ); |
|
381 | + if ( ! empty( $groups ) ) { |
|
382 | + foreach ( $groups as $group ) { |
|
383 | + if ( isset( $group['connected_exercises'] ) ) { |
|
384 | + $exercises[] = $group['connected_exercises']; |
|
385 | + } |
|
386 | + } |
|
387 | + } |
|
388 | + $i++; |
|
389 | + } |
|
390 | + return $exercises; |
|
391 | 391 | } |
@@ -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,17 +162,17 @@ discard block |
||
162 | 162 | * @return boolean |
163 | 163 | */ |
164 | 164 | function lsx_health_plan_is_day_complete( $post_id = '' ) { |
165 | - $is_complete = false; |
|
166 | - if ( '' === $post_id ) { |
|
167 | - $post_id = get_the_ID(); |
|
168 | - } |
|
169 | - if ( is_user_logged_in() ) { |
|
170 | - $is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $post_id . '_complete', true ); |
|
171 | - if ( false !== $is_day_complete && '' !== $is_day_complete ) { |
|
172 | - $is_complete = true; |
|
173 | - } |
|
174 | - } |
|
175 | - return $is_complete; |
|
165 | + $is_complete = false; |
|
166 | + if ( '' === $post_id ) { |
|
167 | + $post_id = get_the_ID(); |
|
168 | + } |
|
169 | + if ( is_user_logged_in() ) { |
|
170 | + $is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $post_id . '_complete', true ); |
|
171 | + if ( false !== $is_day_complete && '' !== $is_day_complete ) { |
|
172 | + $is_complete = true; |
|
173 | + } |
|
174 | + } |
|
175 | + return $is_complete; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | * @return boolean |
183 | 183 | */ |
184 | 184 | function lsx_health_plan_week_has_downloads( $week = '' ) { |
185 | - $has_downloads = false; |
|
186 | - if ( '' !== $week ) { |
|
187 | - $downloads = \lsx_health_plan\functions\get_weekly_downloads( $week ); |
|
188 | - if ( ! empty( $downloads ) ) { |
|
189 | - $has_downloads = true; |
|
190 | - } |
|
191 | - } |
|
192 | - return $has_downloads; |
|
185 | + $has_downloads = false; |
|
186 | + if ( '' !== $week ) { |
|
187 | + $downloads = \lsx_health_plan\functions\get_weekly_downloads( $week ); |
|
188 | + if ( ! empty( $downloads ) ) { |
|
189 | + $has_downloads = true; |
|
190 | + } |
|
191 | + } |
|
192 | + return $has_downloads; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -199,14 +199,14 @@ discard block |
||
199 | 199 | * @return boolean |
200 | 200 | */ |
201 | 201 | function lsx_health_plan_has_tips( $post_id = '' ) { |
202 | - $has_tips = false; |
|
203 | - if ( '' === $post_id ) { |
|
204 | - $post_id = get_the_ID(); |
|
205 | - } |
|
206 | - $connected_tips = get_post_meta( get_the_ID(), 'connected_tips', true ); |
|
207 | - $connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips ); |
|
208 | - if ( ! empty( $connected_tips ) ) { |
|
209 | - $has_tips = true; |
|
210 | - } |
|
211 | - return $has_tips; |
|
202 | + $has_tips = false; |
|
203 | + if ( '' === $post_id ) { |
|
204 | + $post_id = get_the_ID(); |
|
205 | + } |
|
206 | + $connected_tips = get_post_meta( get_the_ID(), 'connected_tips', true ); |
|
207 | + $connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips ); |
|
208 | + if ( ! empty( $connected_tips ) ) { |
|
209 | + $has_tips = true; |
|
210 | + } |
|
211 | + return $has_tips; |
|
212 | 212 | } |
@@ -8,112 +8,112 @@ |
||
8 | 8 | */ |
9 | 9 | class Core { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\Core() |
|
17 | - */ |
|
18 | - protected static $instance = null; |
|
19 | - |
|
20 | - /** |
|
21 | - * @var object \lsx_health_plan\classes\Setup(); |
|
22 | - */ |
|
23 | - public $setup; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var object \lsx_health_plan\classes\Admin(); |
|
27 | - */ |
|
28 | - public $admin; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var object \lsx_health_plan\classes\Frontend(); |
|
32 | - */ |
|
33 | - public $frontend; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var object \lsx_health_plan\classes\Integrations(); |
|
37 | - */ |
|
38 | - public $integrations; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var object \lsx_health_plan\classes\Integrations(); |
|
42 | - */ |
|
43 | - public $scpo_engine; |
|
44 | - |
|
45 | - /** |
|
46 | - * Contructor |
|
47 | - */ |
|
48 | - public function __construct() { |
|
49 | - $this->load_includes(); |
|
50 | - $this->load_classes(); |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Return an instance of this class. |
|
55 | - * |
|
56 | - * @since 1.0.0 |
|
57 | - * |
|
58 | - * @return object \lsx_health_plan\classes\Core() A single instance of this class. |
|
59 | - */ |
|
60 | - public static function get_instance() { |
|
61 | - |
|
62 | - // If the single instance hasn't been set, set it now. |
|
63 | - if ( null === self::$instance ) { |
|
64 | - self::$instance = new self(); |
|
65 | - } |
|
66 | - |
|
67 | - return self::$instance; |
|
68 | - |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Loads the variable classes and the static classes. |
|
73 | - */ |
|
74 | - private function load_classes() { |
|
75 | - |
|
76 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/class-setup.php'; |
|
77 | - $this->setup = Setup::get_instance(); |
|
78 | - |
|
79 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/class-admin.php'; |
|
80 | - $this->admin = Admin::get_instance(); |
|
81 | - |
|
82 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/class-frontend.php'; |
|
83 | - $this->frontend = Frontend::get_instance(); |
|
84 | - |
|
85 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/class-integrations.php'; |
|
86 | - $this->integrations = Integrations::get_instance(); |
|
87 | - |
|
88 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/class-scpo-engine.php'; |
|
89 | - $this->scpo_engine = SCPO_Engine::get_instance(); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Loads the plugin functions. |
|
94 | - */ |
|
95 | - private function load_includes() { |
|
96 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/functions.php'; |
|
97 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/conditionals.php'; |
|
98 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags.php'; |
|
99 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/exercise.php'; |
|
100 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/gallery.php'; |
|
101 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/shortcodes.php'; |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Returns the post types currently active |
|
106 | - * |
|
107 | - * @return void |
|
108 | - */ |
|
109 | - public function get_post_types() { |
|
110 | - $post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) ); |
|
111 | - foreach ( $post_types as $index => $post_type ) { |
|
112 | - $is_disabled = \cmb2_get_option( 'lsx_health_plan_options', $post_type . '_disabled', false ); |
|
113 | - if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) { |
|
114 | - unset( $post_types[ $index ] ); |
|
115 | - } |
|
116 | - } |
|
117 | - return $post_types; |
|
118 | - } |
|
11 | + /** |
|
12 | + * Holds class instance |
|
13 | + * |
|
14 | + * @since 1.0.0 |
|
15 | + * |
|
16 | + * @var object \lsx_health_plan\classes\Core() |
|
17 | + */ |
|
18 | + protected static $instance = null; |
|
19 | + |
|
20 | + /** |
|
21 | + * @var object \lsx_health_plan\classes\Setup(); |
|
22 | + */ |
|
23 | + public $setup; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var object \lsx_health_plan\classes\Admin(); |
|
27 | + */ |
|
28 | + public $admin; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var object \lsx_health_plan\classes\Frontend(); |
|
32 | + */ |
|
33 | + public $frontend; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var object \lsx_health_plan\classes\Integrations(); |
|
37 | + */ |
|
38 | + public $integrations; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var object \lsx_health_plan\classes\Integrations(); |
|
42 | + */ |
|
43 | + public $scpo_engine; |
|
44 | + |
|
45 | + /** |
|
46 | + * Contructor |
|
47 | + */ |
|
48 | + public function __construct() { |
|
49 | + $this->load_includes(); |
|
50 | + $this->load_classes(); |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Return an instance of this class. |
|
55 | + * |
|
56 | + * @since 1.0.0 |
|
57 | + * |
|
58 | + * @return object \lsx_health_plan\classes\Core() A single instance of this class. |
|
59 | + */ |
|
60 | + public static function get_instance() { |
|
61 | + |
|
62 | + // If the single instance hasn't been set, set it now. |
|
63 | + if ( null === self::$instance ) { |
|
64 | + self::$instance = new self(); |
|
65 | + } |
|
66 | + |
|
67 | + return self::$instance; |
|
68 | + |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Loads the variable classes and the static classes. |
|
73 | + */ |
|
74 | + private function load_classes() { |
|
75 | + |
|
76 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/class-setup.php'; |
|
77 | + $this->setup = Setup::get_instance(); |
|
78 | + |
|
79 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/class-admin.php'; |
|
80 | + $this->admin = Admin::get_instance(); |
|
81 | + |
|
82 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/class-frontend.php'; |
|
83 | + $this->frontend = Frontend::get_instance(); |
|
84 | + |
|
85 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/class-integrations.php'; |
|
86 | + $this->integrations = Integrations::get_instance(); |
|
87 | + |
|
88 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/class-scpo-engine.php'; |
|
89 | + $this->scpo_engine = SCPO_Engine::get_instance(); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Loads the plugin functions. |
|
94 | + */ |
|
95 | + private function load_includes() { |
|
96 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/functions.php'; |
|
97 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/conditionals.php'; |
|
98 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags.php'; |
|
99 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/exercise.php'; |
|
100 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/gallery.php'; |
|
101 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/shortcodes.php'; |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Returns the post types currently active |
|
106 | + * |
|
107 | + * @return void |
|
108 | + */ |
|
109 | + public function get_post_types() { |
|
110 | + $post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) ); |
|
111 | + foreach ( $post_types as $index => $post_type ) { |
|
112 | + $is_disabled = \cmb2_get_option( 'lsx_health_plan_options', $post_type . '_disabled', false ); |
|
113 | + if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) { |
|
114 | + unset( $post_types[ $index ] ); |
|
115 | + } |
|
116 | + } |
|
117 | + return $post_types; |
|
118 | + } |
|
119 | 119 | } |
@@ -8,83 +8,83 @@ |
||
8 | 8 | */ |
9 | 9 | class Endpoints { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\Endpoints() |
|
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\Endpoints() |
|
17 | + */ |
|
18 | + protected static $instance = null; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Contructor |
|
22 | - */ |
|
23 | - public function __construct() { |
|
24 | - add_action( 'init', array( $this, 'setup' ) ); |
|
25 | - } |
|
20 | + /** |
|
21 | + * Contructor |
|
22 | + */ |
|
23 | + public function __construct() { |
|
24 | + add_action( 'init', array( $this, 'setup' ) ); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Return an instance of this class. |
|
29 | - * |
|
30 | - * @since 1.0.0 |
|
31 | - * |
|
32 | - * @return object \lsx_health_plan\classes\Endpoints() A single instance of this class. |
|
33 | - */ |
|
34 | - public static function get_instance() { |
|
35 | - // If the single instance hasn't been set, set it now. |
|
36 | - if ( null === self::$instance ) { |
|
37 | - self::$instance = new self(); |
|
38 | - } |
|
39 | - return self::$instance; |
|
40 | - } |
|
27 | + /** |
|
28 | + * Return an instance of this class. |
|
29 | + * |
|
30 | + * @since 1.0.0 |
|
31 | + * |
|
32 | + * @return object \lsx_health_plan\classes\Endpoints() A single instance of this class. |
|
33 | + */ |
|
34 | + public static function get_instance() { |
|
35 | + // If the single instance hasn't been set, set it now. |
|
36 | + if ( null === self::$instance ) { |
|
37 | + self::$instance = new self(); |
|
38 | + } |
|
39 | + return self::$instance; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Runs on init |
|
44 | - */ |
|
45 | - public function setup() { |
|
46 | - $this->add_rewrite_rules(); |
|
47 | - } |
|
42 | + /** |
|
43 | + * Runs on init |
|
44 | + */ |
|
45 | + public function setup() { |
|
46 | + $this->add_rewrite_rules(); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Registers the rewrites. |
|
51 | - */ |
|
52 | - public function add_rewrite_rules() { |
|
53 | - // Here is where we add in the rewrite rules above the normal WP ones. |
|
54 | - add_rewrite_tag( '%endpoint%', '([^&]+)' ); |
|
49 | + /** |
|
50 | + * Registers the rewrites. |
|
51 | + */ |
|
52 | + public function add_rewrite_rules() { |
|
53 | + // Here is where we add in the rewrite rules above the normal WP ones. |
|
54 | + add_rewrite_tag( '%endpoint%', '([^&]+)' ); |
|
55 | 55 | |
56 | - // Warm up. |
|
57 | - $warm_up = \lsx_health_plan\functions\get_option( 'endpoint_warm_up', false ); |
|
58 | - if ( false === $warm_up ) { |
|
59 | - $warm_up = 'warm-up'; |
|
60 | - } |
|
61 | - add_rewrite_rule( 'plan/([^/]+)/' . $warm_up . '/?$', 'index.php?plan=$matches[1]&endpoint=warm-up', 'top' ); |
|
56 | + // Warm up. |
|
57 | + $warm_up = \lsx_health_plan\functions\get_option( 'endpoint_warm_up', false ); |
|
58 | + if ( false === $warm_up ) { |
|
59 | + $warm_up = 'warm-up'; |
|
60 | + } |
|
61 | + add_rewrite_rule( 'plan/([^/]+)/' . $warm_up . '/?$', 'index.php?plan=$matches[1]&endpoint=warm-up', 'top' ); |
|
62 | 62 | |
63 | - // Workout. |
|
64 | - if ( post_type_exists( 'workout' ) ) { |
|
65 | - $workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', false ); |
|
66 | - if ( false === $workout ) { |
|
67 | - $workout = 'workout'; |
|
68 | - } |
|
69 | - } |
|
70 | - add_rewrite_rule( 'plan/([^/]+)/' . $workout . '/?$', 'index.php?plan=$matches[1]&endpoint=workout', 'top' ); |
|
63 | + // Workout. |
|
64 | + if ( post_type_exists( 'workout' ) ) { |
|
65 | + $workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', false ); |
|
66 | + if ( false === $workout ) { |
|
67 | + $workout = 'workout'; |
|
68 | + } |
|
69 | + } |
|
70 | + add_rewrite_rule( 'plan/([^/]+)/' . $workout . '/?$', 'index.php?plan=$matches[1]&endpoint=workout', 'top' ); |
|
71 | 71 | |
72 | - // Meal. |
|
73 | - if ( post_type_exists( 'meal' ) ) { |
|
74 | - $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false ); |
|
75 | - if ( false === $meal ) { |
|
76 | - $meal = 'meal'; |
|
77 | - } |
|
78 | - } |
|
79 | - add_rewrite_rule( 'plan/([^/]+)/' . $meal . '/?$', 'index.php?plan=$matches[1]&endpoint=meal', 'top' ); |
|
72 | + // Meal. |
|
73 | + if ( post_type_exists( 'meal' ) ) { |
|
74 | + $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false ); |
|
75 | + if ( false === $meal ) { |
|
76 | + $meal = 'meal'; |
|
77 | + } |
|
78 | + } |
|
79 | + add_rewrite_rule( 'plan/([^/]+)/' . $meal . '/?$', 'index.php?plan=$matches[1]&endpoint=meal', 'top' ); |
|
80 | 80 | |
81 | - // Recipe. |
|
82 | - if ( post_type_exists( 'recipe' ) ) { |
|
83 | - $recipe = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false ); |
|
84 | - if ( false === $recipe ) { |
|
85 | - $recipe = 'recipes'; |
|
86 | - } |
|
87 | - } |
|
88 | - add_rewrite_rule( 'plan/([^/]+)/' . $recipe . '/?$', 'index.php?plan=$matches[1]&endpoint=recipes', 'top' ); |
|
89 | - } |
|
81 | + // Recipe. |
|
82 | + if ( post_type_exists( 'recipe' ) ) { |
|
83 | + $recipe = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false ); |
|
84 | + if ( false === $recipe ) { |
|
85 | + $recipe = 'recipes'; |
|
86 | + } |
|
87 | + } |
|
88 | + add_rewrite_rule( 'plan/([^/]+)/' . $recipe . '/?$', 'index.php?plan=$matches[1]&endpoint=recipes', 'top' ); |
|
89 | + } |
|
90 | 90 | } |
@@ -8,68 +8,68 @@ |
||
8 | 8 | */ |
9 | 9 | class Modals { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\Modals() |
|
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\Modals() |
|
17 | + */ |
|
18 | + protected static $instance = null; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Holds the modals to be outputted |
|
22 | - * |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - public $modals = array(); |
|
20 | + /** |
|
21 | + * Holds the modals to be outputted |
|
22 | + * |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + public $modals = array(); |
|
26 | 26 | |
27 | - /** |
|
28 | - * Contructor |
|
29 | - */ |
|
30 | - public function __construct() { |
|
31 | - add_action( 'wp_footer', array( $this, 'output_modals' ) ); |
|
32 | - } |
|
27 | + /** |
|
28 | + * Contructor |
|
29 | + */ |
|
30 | + public function __construct() { |
|
31 | + add_action( 'wp_footer', array( $this, 'output_modals' ) ); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Return an instance of this class. |
|
36 | - * |
|
37 | - * @since 1.0.0 |
|
38 | - * |
|
39 | - * @return object \lsx_health_plan\classes\Endpoints() A single instance of this class. |
|
40 | - */ |
|
41 | - public static function get_instance() { |
|
42 | - // If the single instance hasn't been set, set it now. |
|
43 | - if ( null === self::$instance ) { |
|
44 | - self::$instance = new self(); |
|
45 | - } |
|
46 | - return self::$instance; |
|
47 | - } |
|
34 | + /** |
|
35 | + * Return an instance of this class. |
|
36 | + * |
|
37 | + * @since 1.0.0 |
|
38 | + * |
|
39 | + * @return object \lsx_health_plan\classes\Endpoints() A single instance of this class. |
|
40 | + */ |
|
41 | + public static function get_instance() { |
|
42 | + // If the single instance hasn't been set, set it now. |
|
43 | + if ( null === self::$instance ) { |
|
44 | + self::$instance = new self(); |
|
45 | + } |
|
46 | + return self::$instance; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Registers a modal to be outputted |
|
51 | - * |
|
52 | - * @param array $modal |
|
53 | - * @param string $index |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public function register_modal( $modal = array(), $index = '' ) { |
|
57 | - if ( '' !== $index && ! empty( $modal ) ) { |
|
58 | - $modal['id'] = $index; |
|
59 | - $this->modals[ $index ] = $modal; |
|
60 | - } |
|
61 | - } |
|
49 | + /** |
|
50 | + * Registers a modal to be outputted |
|
51 | + * |
|
52 | + * @param array $modal |
|
53 | + * @param string $index |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public function register_modal( $modal = array(), $index = '' ) { |
|
57 | + if ( '' !== $index && ! empty( $modal ) ) { |
|
58 | + $modal['id'] = $index; |
|
59 | + $this->modals[ $index ] = $modal; |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Registers the rewrites. |
|
65 | - */ |
|
66 | - public function output_modals() { |
|
67 | - if ( ! empty( $this->modals ) ) { |
|
68 | - wp_enqueue_script( 'lsx-health-plan-modals', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-modals.min.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true ); |
|
63 | + /** |
|
64 | + * Registers the rewrites. |
|
65 | + */ |
|
66 | + public function output_modals() { |
|
67 | + if ( ! empty( $this->modals ) ) { |
|
68 | + wp_enqueue_script( 'lsx-health-plan-modals', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-modals.min.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true ); |
|
69 | 69 | |
70 | - foreach ( $this->modals as $index => $modal ) { |
|
71 | - \lsx_health_plan\functions\output_modal( $modal ); |
|
72 | - } |
|
73 | - } |
|
74 | - } |
|
70 | + foreach ( $this->modals as $index => $modal ) { |
|
71 | + \lsx_health_plan\functions\output_modal( $modal ); |
|
72 | + } |
|
73 | + } |
|
74 | + } |
|
75 | 75 | } |
@@ -8,262 +8,262 @@ |
||
8 | 8 | */ |
9 | 9 | class Gallery { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @var object \lsx_health_plan\classes\lib\Gallery() |
|
15 | - */ |
|
16 | - protected static $instance = null; |
|
11 | + /** |
|
12 | + * Holds class instance |
|
13 | + * |
|
14 | + * @var object \lsx_health_plan\classes\lib\Gallery() |
|
15 | + */ |
|
16 | + protected static $instance = null; |
|
17 | 17 | |
18 | - /** |
|
19 | - * The current item ID. |
|
20 | - * |
|
21 | - * @var boolean | int |
|
22 | - */ |
|
23 | - public $item_id = false; |
|
18 | + /** |
|
19 | + * The current item ID. |
|
20 | + * |
|
21 | + * @var boolean | int |
|
22 | + */ |
|
23 | + public $item_id = false; |
|
24 | 24 | |
25 | - /** |
|
26 | - * The current item post_type used in the custom field retrival.. |
|
27 | - * |
|
28 | - * @var boolean | int |
|
29 | - */ |
|
30 | - public $post_type = false; |
|
25 | + /** |
|
26 | + * The current item post_type used in the custom field retrival.. |
|
27 | + * |
|
28 | + * @var boolean | int |
|
29 | + */ |
|
30 | + public $post_type = false; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Holds the the default parameters for the gallery output. |
|
34 | - * |
|
35 | - * @var array |
|
36 | - */ |
|
37 | - public $defaults = array(); |
|
32 | + /** |
|
33 | + * Holds the the default parameters for the gallery output. |
|
34 | + * |
|
35 | + * @var array |
|
36 | + */ |
|
37 | + public $defaults = array(); |
|
38 | 38 | |
39 | - /** |
|
40 | - * If the current post has a gallery. |
|
41 | - * |
|
42 | - * @var boolean |
|
43 | - */ |
|
44 | - public $has_gallery = false; |
|
39 | + /** |
|
40 | + * If the current post has a gallery. |
|
41 | + * |
|
42 | + * @var boolean |
|
43 | + */ |
|
44 | + public $has_gallery = false; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Holds the array of gallery images. |
|
48 | - * |
|
49 | - * @var array |
|
50 | - */ |
|
51 | - public $gallery = array(); |
|
46 | + /** |
|
47 | + * Holds the array of gallery images. |
|
48 | + * |
|
49 | + * @var array |
|
50 | + */ |
|
51 | + public $gallery = array(); |
|
52 | 52 | |
53 | - /** |
|
54 | - * Holds the html for the current gallery being output. |
|
55 | - * |
|
56 | - * @var array |
|
57 | - */ |
|
58 | - public $html = array(); |
|
53 | + /** |
|
54 | + * Holds the html for the current gallery being output. |
|
55 | + * |
|
56 | + * @var array |
|
57 | + */ |
|
58 | + public $html = array(); |
|
59 | 59 | |
60 | - /** |
|
61 | - * Holds the parameters for the current gallery being output. |
|
62 | - * |
|
63 | - * @var array |
|
64 | - */ |
|
65 | - public $args = array(); |
|
60 | + /** |
|
61 | + * Holds the parameters for the current gallery being output. |
|
62 | + * |
|
63 | + * @var array |
|
64 | + */ |
|
65 | + public $args = array(); |
|
66 | 66 | |
67 | - /** |
|
68 | - * Contructor |
|
69 | - */ |
|
70 | - public function __construct() { |
|
71 | - } |
|
67 | + /** |
|
68 | + * Contructor |
|
69 | + */ |
|
70 | + public function __construct() { |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Return an instance of this class. |
|
75 | - * |
|
76 | - * @since 1.0.0 |
|
77 | - * |
|
78 | - * @return object \lsx_health_plan\classes\lib\Gallery() A single instance of this class. |
|
79 | - */ |
|
80 | - public static function get_instance() { |
|
81 | - // If the single instance hasn't been set, set it now. |
|
82 | - if ( null === self::$instance ) { |
|
83 | - self::$instance = new self(); |
|
84 | - } |
|
85 | - return self::$instance; |
|
86 | - } |
|
73 | + /** |
|
74 | + * Return an instance of this class. |
|
75 | + * |
|
76 | + * @since 1.0.0 |
|
77 | + * |
|
78 | + * @return object \lsx_health_plan\classes\lib\Gallery() A single instance of this class. |
|
79 | + */ |
|
80 | + public static function get_instance() { |
|
81 | + // If the single instance hasn't been set, set it now. |
|
82 | + if ( null === self::$instance ) { |
|
83 | + self::$instance = new self(); |
|
84 | + } |
|
85 | + return self::$instance; |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * Check if the item has a gallery of images returns true or false. |
|
90 | - * |
|
91 | - * @param string $item_id |
|
92 | - * @param string $post_type |
|
93 | - * @return boolean |
|
94 | - */ |
|
95 | - public function has_gallery( $item_id = '', $post_type = '' ) { |
|
96 | - $this->gallery = array(); |
|
97 | - $this->has_gallery = false; |
|
98 | - if ( '' === $item_id ) { |
|
99 | - $this->item_id = get_the_ID(); |
|
100 | - } else { |
|
101 | - $this->item_id = $item_id; |
|
102 | - } |
|
88 | + /** |
|
89 | + * Check if the item has a gallery of images returns true or false. |
|
90 | + * |
|
91 | + * @param string $item_id |
|
92 | + * @param string $post_type |
|
93 | + * @return boolean |
|
94 | + */ |
|
95 | + public function has_gallery( $item_id = '', $post_type = '' ) { |
|
96 | + $this->gallery = array(); |
|
97 | + $this->has_gallery = false; |
|
98 | + if ( '' === $item_id ) { |
|
99 | + $this->item_id = get_the_ID(); |
|
100 | + } else { |
|
101 | + $this->item_id = $item_id; |
|
102 | + } |
|
103 | 103 | |
104 | - if ( '' === $post_type ) { |
|
105 | - $this->post_type = get_post_type( $this->item_id ); |
|
106 | - } |
|
107 | - $gallery = get_post_meta( $this->item_id, $this->post_type . '_gallery', true ); |
|
108 | - if ( ! empty( $gallery ) ) { |
|
109 | - $this->gallery = $gallery; |
|
110 | - $this->has_gallery = true; |
|
111 | - wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/src/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true ); |
|
112 | - wp_enqueue_script( 'lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-slider.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true ); |
|
113 | - } |
|
114 | - return $this->has_gallery; |
|
115 | - } |
|
104 | + if ( '' === $post_type ) { |
|
105 | + $this->post_type = get_post_type( $this->item_id ); |
|
106 | + } |
|
107 | + $gallery = get_post_meta( $this->item_id, $this->post_type . '_gallery', true ); |
|
108 | + if ( ! empty( $gallery ) ) { |
|
109 | + $this->gallery = $gallery; |
|
110 | + $this->has_gallery = true; |
|
111 | + wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/src/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true ); |
|
112 | + wp_enqueue_script( 'lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-slider.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true ); |
|
113 | + } |
|
114 | + return $this->has_gallery; |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * Returns the defaults for the gallery, after grabbing the setting from the item. |
|
119 | - * |
|
120 | - * @param string $item_id |
|
121 | - * @param string $post_type |
|
122 | - * @return array |
|
123 | - */ |
|
124 | - public function get_defaults( $item_id = '', $post_type = '' ) { |
|
125 | - if ( '' === $item_id ) { |
|
126 | - $item_id = $this->item_id; |
|
127 | - } |
|
128 | - if ( '' === $post_type ) { |
|
129 | - $post_type = $this->post_type; |
|
130 | - } |
|
131 | - $this->defaults = array( |
|
132 | - 'columns' => '3', |
|
133 | - 'layout' => 'slider', |
|
134 | - 'interval' => false, |
|
135 | - 'css_class' => false, |
|
136 | - ); |
|
137 | - foreach ( $this->defaults as $key => $default ) { |
|
138 | - $override = get_post_meta( $item_id, $this->post_type . '_gallery_' . $key, true ); |
|
139 | - if ( '' !== $override && false !== $override && ! empty( $override ) ) { |
|
140 | - $this->defaults[ $key ] = $override; |
|
141 | - } |
|
142 | - } |
|
143 | - return $this->defaults; |
|
144 | - } |
|
117 | + /** |
|
118 | + * Returns the defaults for the gallery, after grabbing the setting from the item. |
|
119 | + * |
|
120 | + * @param string $item_id |
|
121 | + * @param string $post_type |
|
122 | + * @return array |
|
123 | + */ |
|
124 | + public function get_defaults( $item_id = '', $post_type = '' ) { |
|
125 | + if ( '' === $item_id ) { |
|
126 | + $item_id = $this->item_id; |
|
127 | + } |
|
128 | + if ( '' === $post_type ) { |
|
129 | + $post_type = $this->post_type; |
|
130 | + } |
|
131 | + $this->defaults = array( |
|
132 | + 'columns' => '3', |
|
133 | + 'layout' => 'slider', |
|
134 | + 'interval' => false, |
|
135 | + 'css_class' => false, |
|
136 | + ); |
|
137 | + foreach ( $this->defaults as $key => $default ) { |
|
138 | + $override = get_post_meta( $item_id, $this->post_type . '_gallery_' . $key, true ); |
|
139 | + if ( '' !== $override && false !== $override && ! empty( $override ) ) { |
|
140 | + $this->defaults[ $key ] = $override; |
|
141 | + } |
|
142 | + } |
|
143 | + return $this->defaults; |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * Gets and returns the gallery html. |
|
148 | - * |
|
149 | - * @param string $item_id |
|
150 | - * @param string $post_type |
|
151 | - * @return void |
|
152 | - */ |
|
153 | - public function get_gallery( $item_id = '', $post_type = '', $args = array() ) { |
|
154 | - $return = ''; |
|
155 | - $this->html = array(); |
|
156 | - $this->args = wp_parse_args( $args, $this->get_defaults( $item_id, $post_type ) ); |
|
157 | - if ( ! empty( $this->gallery ) ) { |
|
158 | - $this->args['count'] = 1; |
|
159 | - if ( '' !== $post_type ) { |
|
160 | - $this->args['post_type'] = $post_type; |
|
161 | - } else { |
|
162 | - $this->args['post_type'] = $this->post_type; |
|
163 | - } |
|
146 | + /** |
|
147 | + * Gets and returns the gallery html. |
|
148 | + * |
|
149 | + * @param string $item_id |
|
150 | + * @param string $post_type |
|
151 | + * @return void |
|
152 | + */ |
|
153 | + public function get_gallery( $item_id = '', $post_type = '', $args = array() ) { |
|
154 | + $return = ''; |
|
155 | + $this->html = array(); |
|
156 | + $this->args = wp_parse_args( $args, $this->get_defaults( $item_id, $post_type ) ); |
|
157 | + if ( ! empty( $this->gallery ) ) { |
|
158 | + $this->args['count'] = 1; |
|
159 | + if ( '' !== $post_type ) { |
|
160 | + $this->args['post_type'] = $post_type; |
|
161 | + } else { |
|
162 | + $this->args['post_type'] = $this->post_type; |
|
163 | + } |
|
164 | 164 | |
165 | - // output the opening boostrap row divs. |
|
166 | - $this->before_loop(); |
|
165 | + // output the opening boostrap row divs. |
|
166 | + $this->before_loop(); |
|
167 | 167 | |
168 | - foreach ( $this->gallery as $key => $gallery ) { |
|
168 | + foreach ( $this->gallery as $key => $gallery ) { |
|
169 | 169 | |
170 | - $this->loop_start(); |
|
170 | + $this->loop_start(); |
|
171 | 171 | |
172 | - if ( isset( $gallery['exercise_gallery_image_id'] ) && ! empty( $gallery['exercise_gallery_image_id'] ) ) { |
|
173 | - $this->html[] = '<img alt="' . get_the_title( $gallery['exercise_gallery_image_id'] ) . '" src="' . $gallery['exercise_gallery_image'] . '" />'; |
|
174 | - } elseif ( isset( $gallery['exercise_gallery_external'] ) && ! empty( $gallery['exercise_gallery_external'] ) ) { |
|
175 | - $this->html[] = $gallery['exercise_gallery_external']; // WPCS: XSS OK. |
|
176 | - } elseif ( isset( $gallery['exercise_gallery_embed'] ) && ! empty( $gallery['exercise_gallery_embed'] ) ) { |
|
177 | - $embed_args = array( |
|
178 | - 'width' => '530', |
|
179 | - ); |
|
180 | - $embed = wp_oembed_get( $gallery['exercise_gallery_embed'], $embed_args ); |
|
181 | - $this->html[] = str_replace( 'width="530"', 'width="100%"', $embed ); // WPCS: XSS OK. |
|
182 | - } |
|
172 | + if ( isset( $gallery['exercise_gallery_image_id'] ) && ! empty( $gallery['exercise_gallery_image_id'] ) ) { |
|
173 | + $this->html[] = '<img alt="' . get_the_title( $gallery['exercise_gallery_image_id'] ) . '" src="' . $gallery['exercise_gallery_image'] . '" />'; |
|
174 | + } elseif ( isset( $gallery['exercise_gallery_external'] ) && ! empty( $gallery['exercise_gallery_external'] ) ) { |
|
175 | + $this->html[] = $gallery['exercise_gallery_external']; // WPCS: XSS OK. |
|
176 | + } elseif ( isset( $gallery['exercise_gallery_embed'] ) && ! empty( $gallery['exercise_gallery_embed'] ) ) { |
|
177 | + $embed_args = array( |
|
178 | + 'width' => '530', |
|
179 | + ); |
|
180 | + $embed = wp_oembed_get( $gallery['exercise_gallery_embed'], $embed_args ); |
|
181 | + $this->html[] = str_replace( 'width="530"', 'width="100%"', $embed ); // WPCS: XSS OK. |
|
182 | + } |
|
183 | 183 | |
184 | - $this->loop_end(); |
|
184 | + $this->loop_end(); |
|
185 | 185 | |
186 | - $this->args['count']++; |
|
187 | - } |
|
186 | + $this->args['count']++; |
|
187 | + } |
|
188 | 188 | |
189 | - // output the closing boostrap row divs. |
|
190 | - $this->after_loop(); |
|
191 | - } |
|
189 | + // output the closing boostrap row divs. |
|
190 | + $this->after_loop(); |
|
191 | + } |
|
192 | 192 | |
193 | - // Join the html output if its not empty. |
|
194 | - if ( ! empty( $this->html ) ) { |
|
195 | - $return = implode( '', $this->html ); |
|
196 | - } |
|
197 | - return $return; |
|
198 | - } |
|
193 | + // Join the html output if its not empty. |
|
194 | + if ( ! empty( $this->html ) ) { |
|
195 | + $return = implode( '', $this->html ); |
|
196 | + } |
|
197 | + return $return; |
|
198 | + } |
|
199 | 199 | |
200 | - /** |
|
201 | - * Outputs the CSS class for the panels |
|
202 | - * |
|
203 | - * @param string $columns |
|
204 | - * @return string |
|
205 | - */ |
|
206 | - public function column_class() { |
|
207 | - $cols = 'col-xs-12 col-sm-'; |
|
208 | - $cols .= '5' === $this->args['columns'] ? '15' : 12 / $this->args['columns']; |
|
209 | - return $cols; |
|
210 | - } |
|
200 | + /** |
|
201 | + * Outputs the CSS class for the panels |
|
202 | + * |
|
203 | + * @param string $columns |
|
204 | + * @return string |
|
205 | + */ |
|
206 | + public function column_class() { |
|
207 | + $cols = 'col-xs-12 col-sm-'; |
|
208 | + $cols .= '5' === $this->args['columns'] ? '15' : 12 / $this->args['columns']; |
|
209 | + return $cols; |
|
210 | + } |
|
211 | 211 | |
212 | - /** |
|
213 | - * Runs just after the if and before the while statement in $this->output() |
|
214 | - */ |
|
215 | - public function before_loop() { |
|
216 | - if ( 'slider' === $this->args['layout'] ) { |
|
217 | - $this->carousel_id = wp_rand( 20, 20000 ); |
|
218 | - $this->html[] = "<div class='lsx-hp-widget-items slick-slider slick-dotted slick-has-arrows {$this->args['css_class']} ' data-interval='{$this->args['interval']}' data-slick='{ \"slidesToShow\": {$this->args['columns']}, \"slidesToScroll\": {$this->args['columns']} }'>"; |
|
219 | - } else { |
|
220 | - $this->html[] = "<div class='lsx-hp-widget-items widget-item-grid-layout'>"; |
|
221 | - } |
|
222 | - } |
|
212 | + /** |
|
213 | + * Runs just after the if and before the while statement in $this->output() |
|
214 | + */ |
|
215 | + public function before_loop() { |
|
216 | + if ( 'slider' === $this->args['layout'] ) { |
|
217 | + $this->carousel_id = wp_rand( 20, 20000 ); |
|
218 | + $this->html[] = "<div class='lsx-hp-widget-items slick-slider slick-dotted slick-has-arrows {$this->args['css_class']} ' data-interval='{$this->args['interval']}' data-slick='{ \"slidesToShow\": {$this->args['columns']}, \"slidesToScroll\": {$this->args['columns']} }'>"; |
|
219 | + } else { |
|
220 | + $this->html[] = "<div class='lsx-hp-widget-items widget-item-grid-layout'>"; |
|
221 | + } |
|
222 | + } |
|
223 | 223 | |
224 | - /** |
|
225 | - * Runs at the very end of the loop before it runs again. |
|
226 | - */ |
|
227 | - public function loop_start() { |
|
228 | - // Get the call for the active slide. |
|
229 | - if ( 'slider' === $this->args['layout'] ) { |
|
230 | - $this->html[] = "<div class='lsx-hp-widget-item-wrap lsx-{$this->args['post_type']}'>"; |
|
231 | - } else { |
|
232 | - if ( 1 === $this->args['count'] ) { |
|
233 | - $this->html[] = "<div class='row'>"; |
|
234 | - } |
|
235 | - $this->html[] = '<div class="' . $this->column_class() . '">'; |
|
236 | - } |
|
237 | - } |
|
224 | + /** |
|
225 | + * Runs at the very end of the loop before it runs again. |
|
226 | + */ |
|
227 | + public function loop_start() { |
|
228 | + // Get the call for the active slide. |
|
229 | + if ( 'slider' === $this->args['layout'] ) { |
|
230 | + $this->html[] = "<div class='lsx-hp-widget-item-wrap lsx-{$this->args['post_type']}'>"; |
|
231 | + } else { |
|
232 | + if ( 1 === $this->args['count'] ) { |
|
233 | + $this->html[] = "<div class='row'>"; |
|
234 | + } |
|
235 | + $this->html[] = '<div class="' . $this->column_class() . '">'; |
|
236 | + } |
|
237 | + } |
|
238 | 238 | |
239 | - /** |
|
240 | - * Runs at the very end of the loop before it runs again. |
|
241 | - */ |
|
242 | - public function loop_end() { |
|
243 | - if ( 'slider' !== $this->args['layout'] ) { |
|
244 | - $this->html[] = '</div>'; |
|
245 | - } |
|
246 | - // Close the current slide panel. |
|
247 | - if ( 'slider' === $this->args['layout'] ) { |
|
248 | - $this->html[] = '</div>'; |
|
249 | - } elseif ( 0 === $this->args['count'] % $this->args['columns'] || count( $this->gallery ) === $this->args['count'] ) { |
|
250 | - $this->html[] = '</div>'; |
|
239 | + /** |
|
240 | + * Runs at the very end of the loop before it runs again. |
|
241 | + */ |
|
242 | + public function loop_end() { |
|
243 | + if ( 'slider' !== $this->args['layout'] ) { |
|
244 | + $this->html[] = '</div>'; |
|
245 | + } |
|
246 | + // Close the current slide panel. |
|
247 | + if ( 'slider' === $this->args['layout'] ) { |
|
248 | + $this->html[] = '</div>'; |
|
249 | + } elseif ( 0 === $this->args['count'] % $this->args['columns'] || count( $this->gallery ) === $this->args['count'] ) { |
|
250 | + $this->html[] = '</div>'; |
|
251 | 251 | |
252 | - if ( $this->args['count'] < count( $this->gallery ) ) { |
|
253 | - $this->html[] = "<div class='row'>"; |
|
254 | - } |
|
255 | - } |
|
256 | - } |
|
252 | + if ( $this->args['count'] < count( $this->gallery ) ) { |
|
253 | + $this->html[] = "<div class='row'>"; |
|
254 | + } |
|
255 | + } |
|
256 | + } |
|
257 | 257 | |
258 | - /** |
|
259 | - * Runs just after the if and before the while statement in $this->output() |
|
260 | - */ |
|
261 | - public function after_loop() { |
|
262 | - // Slider output Closing. |
|
263 | - if ( 'slider' === $this->args['layout'] ) { |
|
264 | - $this->html[] = '</div>'; |
|
265 | - } else { |
|
266 | - $this->html[] = '</div>'; |
|
267 | - } |
|
268 | - } |
|
258 | + /** |
|
259 | + * Runs just after the if and before the while statement in $this->output() |
|
260 | + */ |
|
261 | + public function after_loop() { |
|
262 | + // Slider output Closing. |
|
263 | + if ( 'slider' === $this->args['layout'] ) { |
|
264 | + $this->html[] = '</div>'; |
|
265 | + } else { |
|
266 | + $this->html[] = '</div>'; |
|
267 | + } |
|
268 | + } |
|
269 | 269 | } |
@@ -8,265 +8,265 @@ |
||
8 | 8 | */ |
9 | 9 | class Meal { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\Meal() |
|
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\Meal() |
|
17 | + */ |
|
18 | + protected static $instance = null; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Holds post_type slug used as an index |
|
22 | - * |
|
23 | - * @since 1.0.0 |
|
24 | - * |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - public $slug = 'meal'; |
|
20 | + /** |
|
21 | + * Holds post_type slug used as an index |
|
22 | + * |
|
23 | + * @since 1.0.0 |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + public $slug = 'meal'; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Contructor |
|
31 | - */ |
|
32 | - public function __construct() { |
|
33 | - add_action( 'init', array( $this, 'register_post_type' ) ); |
|
29 | + /** |
|
30 | + * Contructor |
|
31 | + */ |
|
32 | + public function __construct() { |
|
33 | + add_action( 'init', array( $this, 'register_post_type' ) ); |
|
34 | 34 | |
35 | - add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
36 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
35 | + add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
36 | + add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
37 | 37 | |
38 | - add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) ); |
|
39 | - add_action( 'cmb2_admin_init', array( $this, 'meal_connections' ), 15 ); |
|
40 | - } |
|
38 | + add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) ); |
|
39 | + add_action( 'cmb2_admin_init', array( $this, 'meal_connections' ), 15 ); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Return an instance of this class. |
|
44 | - * |
|
45 | - * @since 1.0.0 |
|
46 | - * |
|
47 | - * @return object \lsx_health_plan\classes\Day() 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 | - * Register the post type. |
|
58 | - */ |
|
59 | - public function register_post_type() { |
|
60 | - $labels = array( |
|
61 | - 'name' => esc_html__( 'Meals', 'lsx-health-plan' ), |
|
62 | - 'singular_name' => esc_html__( 'Meal', 'lsx-health-plan' ), |
|
63 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
64 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
65 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
66 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
67 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
68 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
69 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
70 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
71 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
72 | - 'parent_item_colon' => '', |
|
73 | - 'menu_name' => esc_html__( 'Meals', 'lsx-health-plan' ), |
|
74 | - ); |
|
75 | - $args = array( |
|
76 | - 'labels' => $labels, |
|
77 | - 'public' => true, |
|
78 | - 'publicly_queryable' => true, |
|
79 | - 'show_ui' => true, |
|
80 | - 'show_in_menu' => true, |
|
81 | - 'show_in_rest' => true, |
|
82 | - 'menu_icon' => 'dashicons-carrot', |
|
83 | - 'query_var' => true, |
|
84 | - 'rewrite' => false, |
|
85 | - 'capability_type' => 'post', |
|
86 | - 'has_archive' => false, |
|
87 | - 'hierarchical' => false, |
|
88 | - 'menu_position' => null, |
|
89 | - 'supports' => array( |
|
90 | - 'title', |
|
91 | - ), |
|
92 | - ); |
|
93 | - register_post_type( 'meal', $args ); |
|
94 | - } |
|
42 | + /** |
|
43 | + * Return an instance of this class. |
|
44 | + * |
|
45 | + * @since 1.0.0 |
|
46 | + * |
|
47 | + * @return object \lsx_health_plan\classes\Day() 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 | + * Register the post type. |
|
58 | + */ |
|
59 | + public function register_post_type() { |
|
60 | + $labels = array( |
|
61 | + 'name' => esc_html__( 'Meals', 'lsx-health-plan' ), |
|
62 | + 'singular_name' => esc_html__( 'Meal', 'lsx-health-plan' ), |
|
63 | + 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
64 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
65 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
66 | + 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
67 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
68 | + 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
69 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
70 | + 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
71 | + 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
72 | + 'parent_item_colon' => '', |
|
73 | + 'menu_name' => esc_html__( 'Meals', 'lsx-health-plan' ), |
|
74 | + ); |
|
75 | + $args = array( |
|
76 | + 'labels' => $labels, |
|
77 | + 'public' => true, |
|
78 | + 'publicly_queryable' => true, |
|
79 | + 'show_ui' => true, |
|
80 | + 'show_in_menu' => true, |
|
81 | + 'show_in_rest' => true, |
|
82 | + 'menu_icon' => 'dashicons-carrot', |
|
83 | + 'query_var' => true, |
|
84 | + 'rewrite' => false, |
|
85 | + 'capability_type' => 'post', |
|
86 | + 'has_archive' => false, |
|
87 | + 'hierarchical' => false, |
|
88 | + 'menu_position' => null, |
|
89 | + 'supports' => array( |
|
90 | + 'title', |
|
91 | + ), |
|
92 | + ); |
|
93 | + register_post_type( 'meal', $args ); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Adds the post type to the different arrays. |
|
98 | - * |
|
99 | - * @param array $post_types |
|
100 | - * @return array |
|
101 | - */ |
|
102 | - public function enable_post_type( $post_types = array() ) { |
|
103 | - $post_types[] = $this->slug; |
|
104 | - return $post_types; |
|
105 | - } |
|
96 | + /** |
|
97 | + * Adds the post type to the different arrays. |
|
98 | + * |
|
99 | + * @param array $post_types |
|
100 | + * @return array |
|
101 | + */ |
|
102 | + public function enable_post_type( $post_types = array() ) { |
|
103 | + $post_types[] = $this->slug; |
|
104 | + return $post_types; |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * Enables the Bi Directional relationships |
|
109 | - * |
|
110 | - * @param array $connections |
|
111 | - * @return void |
|
112 | - */ |
|
113 | - public function enable_connections( $connections = array() ) { |
|
114 | - $connections['meal']['connected_plans'] = 'connected_meals'; |
|
115 | - $connections['plan']['connected_meals'] = 'connected_plans'; |
|
116 | - return $connections; |
|
117 | - } |
|
107 | + /** |
|
108 | + * Enables the Bi Directional relationships |
|
109 | + * |
|
110 | + * @param array $connections |
|
111 | + * @return void |
|
112 | + */ |
|
113 | + public function enable_connections( $connections = array() ) { |
|
114 | + $connections['meal']['connected_plans'] = 'connected_meals'; |
|
115 | + $connections['plan']['connected_meals'] = 'connected_plans'; |
|
116 | + return $connections; |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Define the metabox and field configurations. |
|
121 | - */ |
|
122 | - public function details_metaboxes() { |
|
123 | - $cmb = new_cmb2_box( array( |
|
124 | - 'id' => $this->slug . '_shopping_list_metabox', |
|
125 | - 'title' => __( 'Shopping List', 'lsx-health-plan' ), |
|
126 | - 'object_types' => array( $this->slug ), // Post type |
|
127 | - 'context' => 'normal', |
|
128 | - 'priority' => 'high', |
|
129 | - 'show_names' => true, |
|
130 | - ) ); |
|
131 | - $cmb->add_field( array( |
|
132 | - 'name' => __( 'Shopping List', 'lsx-health-plan' ), |
|
133 | - 'desc' => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ), |
|
134 | - 'id' => $this->slug . '_shopping_list', |
|
135 | - 'type' => 'post_search_ajax', |
|
136 | - // Optional : |
|
137 | - 'limit' => 1, // Limit selection to X items only (default 1) |
|
138 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
139 | - 'query_args' => array( |
|
140 | - 'post_type' => array( 'page' ), |
|
141 | - 'post_status' => array( 'publish' ), |
|
142 | - 'posts_per_page' => -1, |
|
143 | - ), |
|
144 | - ) ); |
|
145 | - $cmb = new_cmb2_box( array( |
|
146 | - 'id' => $this->slug . '_details_metabox', |
|
147 | - 'title' => __( 'Meal Details', 'lsx-health-plan' ), |
|
148 | - 'object_types' => array( $this->slug ), // Post type |
|
149 | - 'context' => 'normal', |
|
150 | - 'priority' => 'high', |
|
151 | - 'show_names' => true, |
|
152 | - ) ); |
|
153 | - $cmb->add_field( array( |
|
154 | - 'name' => __( 'Pre Breakfast Snack', 'lsx-health-plan' ), |
|
155 | - 'id' => $this->slug . '_pre_breakfast_snack', |
|
156 | - 'type' => 'wysiwyg', |
|
157 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
158 | - 'options' => array( |
|
159 | - 'textarea_rows' => 5, |
|
160 | - ), |
|
161 | - ) ); |
|
162 | - $cmb->add_field( array( |
|
163 | - 'name' => __( 'Breakfast', 'lsx-health-plan' ), |
|
164 | - 'id' => $this->slug . '_breakfast', |
|
165 | - 'type' => 'wysiwyg', |
|
166 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
167 | - 'options' => array( |
|
168 | - 'textarea_rows' => 5, |
|
169 | - ), |
|
170 | - ) ); |
|
171 | - $cmb->add_field( array( |
|
172 | - 'name' => __( 'Post Breakfast Snack', 'lsx-health-plan' ), |
|
173 | - 'id' => $this->slug . '_breakfast_snack', |
|
174 | - 'type' => 'wysiwyg', |
|
175 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
176 | - 'options' => array( |
|
177 | - 'textarea_rows' => 5, |
|
178 | - ), |
|
179 | - ) ); |
|
180 | - $cmb->add_field( array( |
|
181 | - 'name' => __( 'Pre Lunch Snack', 'lsx-health-plan' ), |
|
182 | - 'id' => $this->slug . '_pre_lunch_snack', |
|
183 | - 'type' => 'wysiwyg', |
|
184 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
185 | - 'options' => array( |
|
186 | - 'textarea_rows' => 5, |
|
187 | - ), |
|
188 | - ) ); |
|
189 | - $cmb->add_field( array( |
|
190 | - 'name' => __( 'Lunch', 'lsx-health-plan' ), |
|
191 | - 'id' => $this->slug . '_lunch', |
|
192 | - 'type' => 'wysiwyg', |
|
193 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
194 | - 'options' => array( |
|
195 | - 'textarea_rows' => 5, |
|
196 | - ), |
|
197 | - ) ); |
|
198 | - $cmb->add_field( array( |
|
199 | - 'name' => __( 'Post Lunch Snack', 'lsx-health-plan' ), |
|
200 | - 'id' => $this->slug . '_lunch_snack', |
|
201 | - 'type' => 'wysiwyg', |
|
202 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
203 | - 'options' => array( |
|
204 | - 'textarea_rows' => 5, |
|
205 | - ), |
|
206 | - ) ); |
|
207 | - $cmb->add_field( array( |
|
208 | - 'name' => __( 'Pre Dinner Snack', 'lsx-health-plan' ), |
|
209 | - 'id' => $this->slug . '_pre_dinner_snack', |
|
210 | - 'type' => 'wysiwyg', |
|
211 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
212 | - 'options' => array( |
|
213 | - 'textarea_rows' => 5, |
|
214 | - ), |
|
215 | - ) ); |
|
216 | - $cmb->add_field( array( |
|
217 | - 'name' => __( 'Dinner', 'lsx-health-plan' ), |
|
218 | - 'id' => $this->slug . '_dinner', |
|
219 | - 'type' => 'wysiwyg', |
|
220 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
221 | - 'options' => array( |
|
222 | - 'textarea_rows' => 5, |
|
223 | - ), |
|
224 | - ) ); |
|
225 | - $cmb->add_field( array( |
|
226 | - 'name' => __( 'Post Dinner Snack', 'lsx-health-plan' ), |
|
227 | - 'id' => $this->slug . '_dinner_snack', |
|
228 | - 'type' => 'wysiwyg', |
|
229 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
230 | - 'options' => array( |
|
231 | - 'textarea_rows' => 5, |
|
232 | - ), |
|
233 | - ) ); |
|
234 | - } |
|
119 | + /** |
|
120 | + * Define the metabox and field configurations. |
|
121 | + */ |
|
122 | + public function details_metaboxes() { |
|
123 | + $cmb = new_cmb2_box( array( |
|
124 | + 'id' => $this->slug . '_shopping_list_metabox', |
|
125 | + 'title' => __( 'Shopping List', 'lsx-health-plan' ), |
|
126 | + 'object_types' => array( $this->slug ), // Post type |
|
127 | + 'context' => 'normal', |
|
128 | + 'priority' => 'high', |
|
129 | + 'show_names' => true, |
|
130 | + ) ); |
|
131 | + $cmb->add_field( array( |
|
132 | + 'name' => __( 'Shopping List', 'lsx-health-plan' ), |
|
133 | + 'desc' => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ), |
|
134 | + 'id' => $this->slug . '_shopping_list', |
|
135 | + 'type' => 'post_search_ajax', |
|
136 | + // Optional : |
|
137 | + 'limit' => 1, // Limit selection to X items only (default 1) |
|
138 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
139 | + 'query_args' => array( |
|
140 | + 'post_type' => array( 'page' ), |
|
141 | + 'post_status' => array( 'publish' ), |
|
142 | + 'posts_per_page' => -1, |
|
143 | + ), |
|
144 | + ) ); |
|
145 | + $cmb = new_cmb2_box( array( |
|
146 | + 'id' => $this->slug . '_details_metabox', |
|
147 | + 'title' => __( 'Meal Details', 'lsx-health-plan' ), |
|
148 | + 'object_types' => array( $this->slug ), // Post type |
|
149 | + 'context' => 'normal', |
|
150 | + 'priority' => 'high', |
|
151 | + 'show_names' => true, |
|
152 | + ) ); |
|
153 | + $cmb->add_field( array( |
|
154 | + 'name' => __( 'Pre Breakfast Snack', 'lsx-health-plan' ), |
|
155 | + 'id' => $this->slug . '_pre_breakfast_snack', |
|
156 | + 'type' => 'wysiwyg', |
|
157 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
158 | + 'options' => array( |
|
159 | + 'textarea_rows' => 5, |
|
160 | + ), |
|
161 | + ) ); |
|
162 | + $cmb->add_field( array( |
|
163 | + 'name' => __( 'Breakfast', 'lsx-health-plan' ), |
|
164 | + 'id' => $this->slug . '_breakfast', |
|
165 | + 'type' => 'wysiwyg', |
|
166 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
167 | + 'options' => array( |
|
168 | + 'textarea_rows' => 5, |
|
169 | + ), |
|
170 | + ) ); |
|
171 | + $cmb->add_field( array( |
|
172 | + 'name' => __( 'Post Breakfast Snack', 'lsx-health-plan' ), |
|
173 | + 'id' => $this->slug . '_breakfast_snack', |
|
174 | + 'type' => 'wysiwyg', |
|
175 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
176 | + 'options' => array( |
|
177 | + 'textarea_rows' => 5, |
|
178 | + ), |
|
179 | + ) ); |
|
180 | + $cmb->add_field( array( |
|
181 | + 'name' => __( 'Pre Lunch Snack', 'lsx-health-plan' ), |
|
182 | + 'id' => $this->slug . '_pre_lunch_snack', |
|
183 | + 'type' => 'wysiwyg', |
|
184 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
185 | + 'options' => array( |
|
186 | + 'textarea_rows' => 5, |
|
187 | + ), |
|
188 | + ) ); |
|
189 | + $cmb->add_field( array( |
|
190 | + 'name' => __( 'Lunch', 'lsx-health-plan' ), |
|
191 | + 'id' => $this->slug . '_lunch', |
|
192 | + 'type' => 'wysiwyg', |
|
193 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
194 | + 'options' => array( |
|
195 | + 'textarea_rows' => 5, |
|
196 | + ), |
|
197 | + ) ); |
|
198 | + $cmb->add_field( array( |
|
199 | + 'name' => __( 'Post Lunch Snack', 'lsx-health-plan' ), |
|
200 | + 'id' => $this->slug . '_lunch_snack', |
|
201 | + 'type' => 'wysiwyg', |
|
202 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
203 | + 'options' => array( |
|
204 | + 'textarea_rows' => 5, |
|
205 | + ), |
|
206 | + ) ); |
|
207 | + $cmb->add_field( array( |
|
208 | + 'name' => __( 'Pre Dinner Snack', 'lsx-health-plan' ), |
|
209 | + 'id' => $this->slug . '_pre_dinner_snack', |
|
210 | + 'type' => 'wysiwyg', |
|
211 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
212 | + 'options' => array( |
|
213 | + 'textarea_rows' => 5, |
|
214 | + ), |
|
215 | + ) ); |
|
216 | + $cmb->add_field( array( |
|
217 | + 'name' => __( 'Dinner', 'lsx-health-plan' ), |
|
218 | + 'id' => $this->slug . '_dinner', |
|
219 | + 'type' => 'wysiwyg', |
|
220 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
221 | + 'options' => array( |
|
222 | + 'textarea_rows' => 5, |
|
223 | + ), |
|
224 | + ) ); |
|
225 | + $cmb->add_field( array( |
|
226 | + 'name' => __( 'Post Dinner Snack', 'lsx-health-plan' ), |
|
227 | + 'id' => $this->slug . '_dinner_snack', |
|
228 | + 'type' => 'wysiwyg', |
|
229 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
230 | + 'options' => array( |
|
231 | + 'textarea_rows' => 5, |
|
232 | + ), |
|
233 | + ) ); |
|
234 | + } |
|
235 | 235 | |
236 | - /** |
|
237 | - * Registers the workout connections on the plan post type. |
|
238 | - * |
|
239 | - * @return void |
|
240 | - */ |
|
241 | - public function meal_connections() { |
|
242 | - $cmb = new_cmb2_box( array( |
|
243 | - 'id' => $this->slug . '_meals_connections_metabox', |
|
244 | - 'title' => __( 'Meal Plan', 'lsx-health-plan' ), |
|
245 | - 'object_types' => array( 'plan' ), // Post type |
|
246 | - 'context' => 'normal', |
|
247 | - 'priority' => 'high', |
|
248 | - 'show_names' => true, |
|
249 | - ) ); |
|
250 | - /*$cmb->add_field( array( |
|
236 | + /** |
|
237 | + * Registers the workout connections on the plan post type. |
|
238 | + * |
|
239 | + * @return void |
|
240 | + */ |
|
241 | + public function meal_connections() { |
|
242 | + $cmb = new_cmb2_box( array( |
|
243 | + 'id' => $this->slug . '_meals_connections_metabox', |
|
244 | + 'title' => __( 'Meal Plan', 'lsx-health-plan' ), |
|
245 | + 'object_types' => array( 'plan' ), // Post type |
|
246 | + 'context' => 'normal', |
|
247 | + 'priority' => 'high', |
|
248 | + 'show_names' => true, |
|
249 | + ) ); |
|
250 | + /*$cmb->add_field( array( |
|
251 | 251 | 'name' => __( 'Box Description', 'lsx-health-plan' ), |
252 | 252 | 'id' => $this->slug . '_box_description', |
253 | 253 | 'desc' => __( 'This description displays on the single plan page.', 'lsx-health-plan' ), |
254 | 254 | 'type' => 'textarea_small', |
255 | 255 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
256 | 256 | ) );*/ |
257 | - $cmb->add_field( array( |
|
258 | - 'name' => __( 'Meals', 'lsx-health-plan' ), |
|
259 | - 'desc' => __( 'Connect the meal that applies to this day plan using the field provided.', 'lsx-health-plan' ), |
|
260 | - 'id' => 'connected_meals', |
|
261 | - 'type' => 'post_search_ajax', |
|
262 | - // Optional : |
|
263 | - 'limit' => 15, // Limit selection to X items only (default 1) |
|
264 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
265 | - 'query_args' => array( |
|
266 | - 'post_type' => array( $this->slug ), |
|
267 | - 'post_status' => array( 'publish' ), |
|
268 | - 'posts_per_page' => -1, |
|
269 | - ), |
|
270 | - ) ); |
|
271 | - } |
|
257 | + $cmb->add_field( array( |
|
258 | + 'name' => __( 'Meals', 'lsx-health-plan' ), |
|
259 | + 'desc' => __( 'Connect the meal that applies to this day plan using the field provided.', 'lsx-health-plan' ), |
|
260 | + 'id' => 'connected_meals', |
|
261 | + 'type' => 'post_search_ajax', |
|
262 | + // Optional : |
|
263 | + 'limit' => 15, // Limit selection to X items only (default 1) |
|
264 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
265 | + 'query_args' => array( |
|
266 | + 'post_type' => array( $this->slug ), |
|
267 | + 'post_status' => array( 'publish' ), |
|
268 | + 'posts_per_page' => -1, |
|
269 | + ), |
|
270 | + ) ); |
|
271 | + } |
|
272 | 272 | } |
@@ -8,473 +8,473 @@ |
||
8 | 8 | */ |
9 | 9 | class Exercise { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\Exercise() |
|
17 | - */ |
|
18 | - protected static $instance = null; |
|
19 | - |
|
20 | - /** |
|
21 | - * Holds post_type slug used as an index |
|
22 | - * |
|
23 | - * @since 1.0.0 |
|
24 | - * |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - public $slug = 'exercise'; |
|
28 | - |
|
29 | - /** |
|
30 | - * Contructor |
|
31 | - */ |
|
32 | - public function __construct() { |
|
33 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
34 | - // Post Type and Taxonomies. |
|
35 | - add_action( 'init', array( $this, 'register_post_type' ) ); |
|
36 | - add_action( 'init', array( $this, 'exercise_type_taxonomy_setup' ) ); |
|
37 | - add_action( 'init', array( $this, 'equipment_taxonomy_setup' ) ); |
|
38 | - add_action( 'init', array( $this, 'muscle_group_taxonomy_setup' ) ); |
|
39 | - add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
40 | - |
|
41 | - // Settings. |
|
42 | - add_action( 'lsx_hp_settings_page', array( $this, 'register_settings' ), 10, 1 ); |
|
43 | - |
|
44 | - // Custom Fields. |
|
45 | - add_action( 'cmb2_admin_init', array( $this, 'exercise_details' ), 8 ); |
|
46 | - add_action( 'cmb2_admin_init', array( $this, 'gallery_metabox' ), 9 ); |
|
47 | - add_action( 'cmb2_admin_init', array( $this, 'tips_metabox' ) ); |
|
48 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
49 | - |
|
50 | - // Template Redirects. |
|
51 | - add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
52 | - add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
53 | - } |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * Return an instance of this class. |
|
58 | - * |
|
59 | - * @since 1.0.0 |
|
60 | - * |
|
61 | - * @return object \lsx_health_plan\classes\Exercise() A single instance of this class. |
|
62 | - */ |
|
63 | - public static function get_instance() { |
|
64 | - // If the single instance hasn't been set, set it now. |
|
65 | - if ( null === self::$instance ) { |
|
66 | - self::$instance = new self(); |
|
67 | - } |
|
68 | - return self::$instance; |
|
69 | - } |
|
70 | - /** |
|
71 | - * Register the post type. |
|
72 | - */ |
|
73 | - public function register_post_type() { |
|
74 | - $labels = array( |
|
75 | - 'name' => esc_html__( 'Exercise', 'lsx-health-plan' ), |
|
76 | - 'singular_name' => esc_html__( 'Exercises', 'lsx-health-plan' ), |
|
77 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
78 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
79 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
80 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
81 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
82 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
83 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
84 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
85 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
86 | - 'parent_item_colon' => '', |
|
87 | - 'menu_name' => esc_html__( 'Exercises', 'lsx-health-plan' ), |
|
88 | - ); |
|
89 | - $args = array( |
|
90 | - 'labels' => $labels, |
|
91 | - 'public' => true, |
|
92 | - 'publicly_queryable' => true, |
|
93 | - 'show_ui' => true, |
|
94 | - 'show_in_menu' => false, |
|
95 | - 'show_in_rest' => true, |
|
96 | - 'menu_icon' => 'dashicons-universal-access', |
|
97 | - 'query_var' => true, |
|
98 | - 'rewrite' => array( |
|
99 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ), |
|
100 | - ), |
|
101 | - 'capability_type' => 'page', |
|
102 | - 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercises' ), |
|
103 | - 'hierarchical' => false, |
|
104 | - 'menu_position' => null, |
|
105 | - 'supports' => array( |
|
106 | - 'title', |
|
107 | - 'thumbnail', |
|
108 | - 'editor', |
|
109 | - 'excerpt', |
|
110 | - ), |
|
111 | - ); |
|
112 | - register_post_type( 'exercise', $args ); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Register the Exercise taxonomy. |
|
117 | - * |
|
118 | - * @return void |
|
119 | - */ |
|
120 | - public function exercise_type_taxonomy_setup() { |
|
121 | - $labels = array( |
|
122 | - 'name' => esc_html_x( 'Exercise Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
123 | - 'singular_name' => esc_html_x( 'Exercise Type', 'taxonomy singular name', 'lsx-health-plan' ), |
|
124 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
125 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
126 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
127 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
128 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
129 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
130 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
131 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
132 | - 'menu_name' => esc_html__( 'Exercise Types', 'lsx-health-plan' ), |
|
133 | - ); |
|
134 | - |
|
135 | - $args = array( |
|
136 | - 'hierarchical' => true, |
|
137 | - 'labels' => $labels, |
|
138 | - 'show_ui' => true, |
|
139 | - 'show_admin_column' => true, |
|
140 | - 'query_var' => true, |
|
141 | - 'rewrite' => array( |
|
142 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_type', 'exercise-type' ), |
|
143 | - ), |
|
144 | - 'show_in_rest' => true, |
|
145 | - ); |
|
146 | - |
|
147 | - register_taxonomy( 'exercise-type', array( 'exercise' ), $args ); |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * Register the Exercise taxonomy. |
|
152 | - * |
|
153 | - * @return void |
|
154 | - */ |
|
155 | - public function equipment_taxonomy_setup() { |
|
156 | - $labels = array( |
|
157 | - 'name' => esc_html_x( 'Equipment', 'taxonomy general name', 'lsx-health-plan' ), |
|
158 | - 'singular_name' => esc_html_x( 'Equipment', 'taxonomy singular name', 'lsx-health-plan' ), |
|
159 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
160 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
161 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
162 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
163 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
164 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
165 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
166 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
167 | - 'menu_name' => esc_html__( 'Equipment', 'lsx-health-plan' ), |
|
168 | - ); |
|
169 | - |
|
170 | - $args = array( |
|
171 | - 'hierarchical' => true, |
|
172 | - 'labels' => $labels, |
|
173 | - 'show_ui' => true, |
|
174 | - 'show_admin_column' => true, |
|
175 | - 'query_var' => true, |
|
176 | - 'rewrite' => array( |
|
177 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_equipment', 'equipment' ), |
|
178 | - ), |
|
179 | - 'show_in_rest' => true, |
|
180 | - ); |
|
181 | - |
|
182 | - register_taxonomy( 'equipment', array( 'exercise' ), $args ); |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Register the Muscle Group taxonomy. |
|
187 | - * |
|
188 | - * @return void |
|
189 | - */ |
|
190 | - public function muscle_group_taxonomy_setup() { |
|
191 | - $labels = array( |
|
192 | - 'name' => esc_html_x( 'Muscle Groups', 'taxonomy general name', 'lsx-health-plan' ), |
|
193 | - 'singular_name' => esc_html_x( 'Muscle Group', 'taxonomy singular name', 'lsx-health-plan' ), |
|
194 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
195 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
196 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
197 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
198 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
199 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
200 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
201 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
202 | - 'menu_name' => esc_html__( 'Muscle Groups', 'lsx-health-plan' ), |
|
203 | - ); |
|
204 | - |
|
205 | - $args = array( |
|
206 | - 'hierarchical' => true, |
|
207 | - 'labels' => $labels, |
|
208 | - 'show_ui' => true, |
|
209 | - 'show_admin_column' => true, |
|
210 | - 'query_var' => true, |
|
211 | - 'rewrite' => array( |
|
212 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_musclegroup', 'muscle-group' ), |
|
213 | - ), |
|
214 | - 'show_in_rest' => true, |
|
215 | - ); |
|
216 | - |
|
217 | - register_taxonomy( 'muscle-group', array( 'exercise' ), $args ); |
|
218 | - } |
|
219 | - |
|
220 | - /** |
|
221 | - * Registers the Recipes under the Meals Post type menu. |
|
222 | - * |
|
223 | - * @return void |
|
224 | - */ |
|
225 | - public function register_menus() { |
|
226 | - add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercises', 'lsx-health-plan' ), esc_html__( 'Exercises', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=exercise' ); |
|
227 | - add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercise Types', 'lsx-health-plan' ), esc_html__( 'Exercise Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=exercise-type&post_type=exercise' ); |
|
228 | - add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Equipment', 'lsx-health-plan' ), esc_html__( 'Equipment', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=equipment&post_type=exercise' ); |
|
229 | - add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Muscle Groups', 'lsx-health-plan' ), esc_html__( 'Muscle Groups', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=muscle-group&post_type=exercise' ); |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * Define the metabox and field configurations. |
|
234 | - */ |
|
235 | - public function tips_metabox() { |
|
236 | - $cmb = new_cmb2_box( |
|
237 | - array( |
|
238 | - 'id' => $this->slug . '_tips_details_metabox', |
|
239 | - 'title' => __( 'Exercise Tips', 'lsx-health-plan' ), |
|
240 | - 'object_types' => array( $this->slug ), // Post type |
|
241 | - 'context' => 'normal', |
|
242 | - 'priority' => 'low', |
|
243 | - 'show_names' => true, |
|
244 | - ) |
|
245 | - ); |
|
246 | - |
|
247 | - // Repeatable group. |
|
248 | - $tip_group = $cmb->add_field( |
|
249 | - array( |
|
250 | - 'id' => $this->slug . '_tips', |
|
251 | - 'type' => 'group', |
|
252 | - 'options' => array( |
|
253 | - 'group_title' => __( 'Tip', 'your-text-domain' ) . ' {#}', // {#} gets replaced by row number |
|
254 | - 'add_button' => __( 'Add another tip', 'your-text-domain' ), |
|
255 | - 'remove_button' => __( 'Remove tip', 'your-text-domain' ), |
|
256 | - 'sortable' => true, |
|
257 | - ), |
|
258 | - 'classes' => 'lsx-admin-row', |
|
259 | - ) |
|
260 | - ); |
|
261 | - |
|
262 | - // Title. |
|
263 | - $cmb->add_group_field( |
|
264 | - $tip_group, |
|
265 | - array( |
|
266 | - 'name' => __( 'Thumbnail', 'your-text-domain' ), |
|
267 | - 'id' => $this->slug . '_tip_thumbnail', |
|
268 | - 'type' => 'file', |
|
269 | - 'text' => array( |
|
270 | - 'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ), |
|
271 | - ), |
|
272 | - 'desc' => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ), |
|
273 | - 'query_args' => array( |
|
274 | - 'type' => array( |
|
275 | - 'image/gif', |
|
276 | - 'image/jpeg', |
|
277 | - 'image/png', |
|
278 | - ), |
|
279 | - ), |
|
280 | - 'preview_size' => 'thumbnail', |
|
281 | - 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-25', |
|
282 | - ) |
|
283 | - ); |
|
284 | - |
|
285 | - $cmb->add_group_field( |
|
286 | - $tip_group, |
|
287 | - array( |
|
288 | - 'name' => __( 'Description', 'your-text-domain' ), |
|
289 | - 'id' => $this->slug . '_tip_content', |
|
290 | - 'type' => 'textarea', |
|
291 | - 'classes' => 'lsx-field-col lsx-field-connect-field lsx-field-col-75', |
|
292 | - ) |
|
293 | - ); |
|
294 | - } |
|
295 | - |
|
296 | - /** |
|
297 | - * Adds the post type to the different arrays. |
|
298 | - * |
|
299 | - * @param array $post_types |
|
300 | - * @return array |
|
301 | - */ |
|
302 | - public function enable_post_type( $post_types = array() ) { |
|
303 | - $post_types[] = $this->slug; |
|
304 | - return $post_types; |
|
305 | - } |
|
306 | - |
|
307 | - /** |
|
308 | - * Enables the Bi Directional relationships |
|
309 | - * |
|
310 | - * @param array $connections |
|
311 | - * @return void |
|
312 | - */ |
|
313 | - public function enable_connections( $connections = array() ) { |
|
314 | - $connections['exercise']['connected_workouts'] = 'connected_exercises'; |
|
315 | - $connections['workout']['connected_exercises'] = 'connected_workouts'; |
|
316 | - return $connections; |
|
317 | - } |
|
318 | - |
|
319 | - /** |
|
320 | - * Registers the lsx_search_settings |
|
321 | - * |
|
322 | - * @param object $cmb new_cmb2_box(). |
|
323 | - * @return void |
|
324 | - */ |
|
325 | - public function register_settings( $cmb ) { |
|
326 | - $cmb->add_field( |
|
327 | - array( |
|
328 | - 'id' => 'exercise_archive_settings_title', |
|
329 | - 'type' => 'title', |
|
330 | - 'name' => __( 'Exercises Archive', 'lsx-health-plan' ), |
|
331 | - 'description' => __( 'All of the settings relating to the exercises post type archive.', 'lsx-health-plan' ), |
|
332 | - ) |
|
333 | - ); |
|
334 | - $cmb->add_field( |
|
335 | - array( |
|
336 | - 'id' => 'exercise_archive_description', |
|
337 | - 'type' => 'wysiwyg', |
|
338 | - 'name' => __( 'Archive Description', 'lsx-health-plan' ), |
|
339 | - 'description' => __( 'This will show up on the post type archive.', 'lsx-health-plan' ), |
|
340 | - ) |
|
341 | - ); |
|
342 | - do_action( 'lsx_hp_exercise_settings_page', $cmb ); |
|
343 | - $cmb->add_field( |
|
344 | - array( |
|
345 | - 'id' => 'settings_exercise_archive_closing', |
|
346 | - 'type' => 'tab_closing', |
|
347 | - ) |
|
348 | - ); |
|
349 | - } |
|
350 | - |
|
351 | - /** |
|
352 | - * Define the metabox and field configurations. |
|
353 | - */ |
|
354 | - public function gallery_metabox() { |
|
355 | - $cmb = new_cmb2_box( |
|
356 | - array( |
|
357 | - 'id' => $this->slug . '_gallery_details_metabox', |
|
358 | - 'title' => __( 'Exercise Gallery', 'lsx-health-plan' ), |
|
359 | - 'object_types' => array( $this->slug ), |
|
360 | - 'context' => 'normal', |
|
361 | - 'priority' => 'low', |
|
362 | - 'show_names' => true, |
|
363 | - ) |
|
364 | - ); |
|
365 | - |
|
366 | - $cmb->add_field( |
|
367 | - array( |
|
368 | - 'name' => __( 'Layout', 'lsx-health-plan' ), |
|
369 | - 'id' => $this->slug . '_gallery_layout', |
|
370 | - 'type' => 'radio', |
|
371 | - 'options' => array( |
|
372 | - 'slider' => __( 'Slider', 'your-text-domain' ) . ' {#}', // {#} gets replaced by row number |
|
373 | - 'grid' => __( 'Grid', 'your-text-domain' ), |
|
374 | - ), |
|
375 | - ) |
|
376 | - ); |
|
377 | - |
|
378 | - $cmb->add_field( |
|
379 | - array( |
|
380 | - 'name' => __( 'Grid Columns', 'lsx-health-plan' ), |
|
381 | - 'id' => $this->slug . '_gallery_columns', |
|
382 | - 'type' => 'text', |
|
383 | - 'default' => '3', |
|
384 | - ) |
|
385 | - ); |
|
386 | - |
|
387 | - // Repeatable group. |
|
388 | - $gallery_group = $cmb->add_field( |
|
389 | - array( |
|
390 | - 'id' => $this->slug . '_gallery', |
|
391 | - 'type' => 'group', |
|
392 | - 'options' => array( |
|
393 | - 'group_title' => __( 'Gallery', 'your-text-domain' ) . ' {#}', // {#} gets replaced by row number |
|
394 | - 'add_button' => __( 'Add Item', 'your-text-domain' ), |
|
395 | - 'remove_button' => __( 'Remove Item', 'your-text-domain' ), |
|
396 | - 'sortable' => true, |
|
397 | - ), |
|
398 | - 'classes' => 'lsx-admin-row', |
|
399 | - ) |
|
400 | - ); |
|
401 | - |
|
402 | - // Title. |
|
403 | - $cmb->add_group_field( |
|
404 | - $gallery_group, |
|
405 | - array( |
|
406 | - 'name' => __( 'Image', 'your-text-domain' ), |
|
407 | - 'id' => $this->slug . '_gallery_image', |
|
408 | - 'type' => 'file', |
|
409 | - 'text' => array( |
|
410 | - 'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ), |
|
411 | - ), |
|
412 | - 'desc' => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ), |
|
413 | - 'query_args' => array( |
|
414 | - 'type' => array( |
|
415 | - 'image/gif', |
|
416 | - 'image/jpeg', |
|
417 | - 'image/png', |
|
418 | - ), |
|
419 | - ), |
|
420 | - 'preview_size' => 'lsx-thumbnail-wide', |
|
421 | - 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-33', |
|
422 | - ) |
|
423 | - ); |
|
424 | - |
|
425 | - // Title. |
|
426 | - $cmb->add_group_field( |
|
427 | - $gallery_group, |
|
428 | - array( |
|
429 | - 'name' => __( 'oEmbed', 'your-text-domain' ), |
|
430 | - 'id' => $this->slug . '_gallery_embed', |
|
431 | - 'type' => 'text', |
|
432 | - 'desc' => __( 'Drop in the embed url for your video from YouTube, Vimeo or DailyMotion, e.g: "https://www.youtube.com/watch?v=9xwazD5SyVg". A full list of supports formats can be found at <a href="https://make.wordpress.org/support/user-manual/content/media/adding-media-to-your-pages-and-posts/embedding-media-from-other-sites/">WordPress</a>', 'lsx-health-plan' ), |
|
433 | - 'classes' => 'lsx-field-col lsx-field-connect-field lsx-field-col-33', |
|
434 | - ) |
|
435 | - ); |
|
436 | - |
|
437 | - $cmb->add_group_field( |
|
438 | - $gallery_group, |
|
439 | - array( |
|
440 | - 'name' => __( 'External Media', 'your-text-domain' ), |
|
441 | - 'id' => $this->slug . '_gallery_external', |
|
442 | - 'type' => 'textarea_code', |
|
443 | - 'desc' => __( 'Drop in the iFrame embed code from Giphy in this field, i.e: <iframe src="https://giphy.com/embed/3o7527Rn1HxXWqgxuo" width="480" height="270" frameborder="0" class="giphy-embed" allowfullscreen></iframe>', 'lsx-health-plan' ), |
|
444 | - 'classes' => 'lsx-field-col lsx-field-connect-field lsx-field-col-33', |
|
445 | - ) |
|
446 | - ); |
|
447 | - } |
|
448 | - |
|
449 | - /** |
|
450 | - * Registers the general settings for the exercise. |
|
451 | - * |
|
452 | - * @return void |
|
453 | - */ |
|
454 | - public function exercise_details() { |
|
455 | - $cmb = new_cmb2_box( |
|
456 | - array( |
|
457 | - 'id' => $this->slug . '_general_details_metabox', |
|
458 | - 'title' => __( 'Details', 'lsx-health-plan' ), |
|
459 | - 'object_types' => array( $this->slug ), |
|
460 | - 'context' => 'normal', |
|
461 | - 'priority' => 'high', |
|
462 | - 'show_names' => true, |
|
463 | - ) |
|
464 | - ); |
|
465 | - |
|
466 | - $cmb->add_field( |
|
467 | - array( |
|
468 | - 'name' => __( 'Side', 'lsx-health-plan' ), |
|
469 | - 'id' => $this->slug . '_side', |
|
470 | - 'type' => 'select', |
|
471 | - 'options' => array( |
|
472 | - '' => __( 'Select', 'your-text-domain' ), |
|
473 | - 'left' => __( 'Left', 'your-text-domain' ), |
|
474 | - 'right' => __( 'Right', 'your-text-domain' ), |
|
475 | - ), |
|
476 | - 'desc' => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ), |
|
477 | - ) |
|
478 | - ); |
|
479 | - } |
|
11 | + /** |
|
12 | + * Holds class instance |
|
13 | + * |
|
14 | + * @since 1.0.0 |
|
15 | + * |
|
16 | + * @var object \lsx_health_plan\classes\Exercise() |
|
17 | + */ |
|
18 | + protected static $instance = null; |
|
19 | + |
|
20 | + /** |
|
21 | + * Holds post_type slug used as an index |
|
22 | + * |
|
23 | + * @since 1.0.0 |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + public $slug = 'exercise'; |
|
28 | + |
|
29 | + /** |
|
30 | + * Contructor |
|
31 | + */ |
|
32 | + public function __construct() { |
|
33 | + if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
34 | + // Post Type and Taxonomies. |
|
35 | + add_action( 'init', array( $this, 'register_post_type' ) ); |
|
36 | + add_action( 'init', array( $this, 'exercise_type_taxonomy_setup' ) ); |
|
37 | + add_action( 'init', array( $this, 'equipment_taxonomy_setup' ) ); |
|
38 | + add_action( 'init', array( $this, 'muscle_group_taxonomy_setup' ) ); |
|
39 | + add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
40 | + |
|
41 | + // Settings. |
|
42 | + add_action( 'lsx_hp_settings_page', array( $this, 'register_settings' ), 10, 1 ); |
|
43 | + |
|
44 | + // Custom Fields. |
|
45 | + add_action( 'cmb2_admin_init', array( $this, 'exercise_details' ), 8 ); |
|
46 | + add_action( 'cmb2_admin_init', array( $this, 'gallery_metabox' ), 9 ); |
|
47 | + add_action( 'cmb2_admin_init', array( $this, 'tips_metabox' ) ); |
|
48 | + add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
49 | + |
|
50 | + // Template Redirects. |
|
51 | + add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
52 | + add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
53 | + } |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * Return an instance of this class. |
|
58 | + * |
|
59 | + * @since 1.0.0 |
|
60 | + * |
|
61 | + * @return object \lsx_health_plan\classes\Exercise() A single instance of this class. |
|
62 | + */ |
|
63 | + public static function get_instance() { |
|
64 | + // If the single instance hasn't been set, set it now. |
|
65 | + if ( null === self::$instance ) { |
|
66 | + self::$instance = new self(); |
|
67 | + } |
|
68 | + return self::$instance; |
|
69 | + } |
|
70 | + /** |
|
71 | + * Register the post type. |
|
72 | + */ |
|
73 | + public function register_post_type() { |
|
74 | + $labels = array( |
|
75 | + 'name' => esc_html__( 'Exercise', 'lsx-health-plan' ), |
|
76 | + 'singular_name' => esc_html__( 'Exercises', 'lsx-health-plan' ), |
|
77 | + 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
78 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
79 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
80 | + 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
81 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
82 | + 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
83 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
84 | + 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
85 | + 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
86 | + 'parent_item_colon' => '', |
|
87 | + 'menu_name' => esc_html__( 'Exercises', 'lsx-health-plan' ), |
|
88 | + ); |
|
89 | + $args = array( |
|
90 | + 'labels' => $labels, |
|
91 | + 'public' => true, |
|
92 | + 'publicly_queryable' => true, |
|
93 | + 'show_ui' => true, |
|
94 | + 'show_in_menu' => false, |
|
95 | + 'show_in_rest' => true, |
|
96 | + 'menu_icon' => 'dashicons-universal-access', |
|
97 | + 'query_var' => true, |
|
98 | + 'rewrite' => array( |
|
99 | + 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ), |
|
100 | + ), |
|
101 | + 'capability_type' => 'page', |
|
102 | + 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercises' ), |
|
103 | + 'hierarchical' => false, |
|
104 | + 'menu_position' => null, |
|
105 | + 'supports' => array( |
|
106 | + 'title', |
|
107 | + 'thumbnail', |
|
108 | + 'editor', |
|
109 | + 'excerpt', |
|
110 | + ), |
|
111 | + ); |
|
112 | + register_post_type( 'exercise', $args ); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Register the Exercise taxonomy. |
|
117 | + * |
|
118 | + * @return void |
|
119 | + */ |
|
120 | + public function exercise_type_taxonomy_setup() { |
|
121 | + $labels = array( |
|
122 | + 'name' => esc_html_x( 'Exercise Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
123 | + 'singular_name' => esc_html_x( 'Exercise Type', 'taxonomy singular name', 'lsx-health-plan' ), |
|
124 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
125 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
126 | + 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
127 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
128 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
129 | + 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
130 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
131 | + 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
132 | + 'menu_name' => esc_html__( 'Exercise Types', 'lsx-health-plan' ), |
|
133 | + ); |
|
134 | + |
|
135 | + $args = array( |
|
136 | + 'hierarchical' => true, |
|
137 | + 'labels' => $labels, |
|
138 | + 'show_ui' => true, |
|
139 | + 'show_admin_column' => true, |
|
140 | + 'query_var' => true, |
|
141 | + 'rewrite' => array( |
|
142 | + 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_type', 'exercise-type' ), |
|
143 | + ), |
|
144 | + 'show_in_rest' => true, |
|
145 | + ); |
|
146 | + |
|
147 | + register_taxonomy( 'exercise-type', array( 'exercise' ), $args ); |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * Register the Exercise taxonomy. |
|
152 | + * |
|
153 | + * @return void |
|
154 | + */ |
|
155 | + public function equipment_taxonomy_setup() { |
|
156 | + $labels = array( |
|
157 | + 'name' => esc_html_x( 'Equipment', 'taxonomy general name', 'lsx-health-plan' ), |
|
158 | + 'singular_name' => esc_html_x( 'Equipment', 'taxonomy singular name', 'lsx-health-plan' ), |
|
159 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
160 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
161 | + 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
162 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
163 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
164 | + 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
165 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
166 | + 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
167 | + 'menu_name' => esc_html__( 'Equipment', 'lsx-health-plan' ), |
|
168 | + ); |
|
169 | + |
|
170 | + $args = array( |
|
171 | + 'hierarchical' => true, |
|
172 | + 'labels' => $labels, |
|
173 | + 'show_ui' => true, |
|
174 | + 'show_admin_column' => true, |
|
175 | + 'query_var' => true, |
|
176 | + 'rewrite' => array( |
|
177 | + 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_equipment', 'equipment' ), |
|
178 | + ), |
|
179 | + 'show_in_rest' => true, |
|
180 | + ); |
|
181 | + |
|
182 | + register_taxonomy( 'equipment', array( 'exercise' ), $args ); |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Register the Muscle Group taxonomy. |
|
187 | + * |
|
188 | + * @return void |
|
189 | + */ |
|
190 | + public function muscle_group_taxonomy_setup() { |
|
191 | + $labels = array( |
|
192 | + 'name' => esc_html_x( 'Muscle Groups', 'taxonomy general name', 'lsx-health-plan' ), |
|
193 | + 'singular_name' => esc_html_x( 'Muscle Group', 'taxonomy singular name', 'lsx-health-plan' ), |
|
194 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
195 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
196 | + 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
197 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
198 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
199 | + 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
200 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
201 | + 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
202 | + 'menu_name' => esc_html__( 'Muscle Groups', 'lsx-health-plan' ), |
|
203 | + ); |
|
204 | + |
|
205 | + $args = array( |
|
206 | + 'hierarchical' => true, |
|
207 | + 'labels' => $labels, |
|
208 | + 'show_ui' => true, |
|
209 | + 'show_admin_column' => true, |
|
210 | + 'query_var' => true, |
|
211 | + 'rewrite' => array( |
|
212 | + 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_musclegroup', 'muscle-group' ), |
|
213 | + ), |
|
214 | + 'show_in_rest' => true, |
|
215 | + ); |
|
216 | + |
|
217 | + register_taxonomy( 'muscle-group', array( 'exercise' ), $args ); |
|
218 | + } |
|
219 | + |
|
220 | + /** |
|
221 | + * Registers the Recipes under the Meals Post type menu. |
|
222 | + * |
|
223 | + * @return void |
|
224 | + */ |
|
225 | + public function register_menus() { |
|
226 | + add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercises', 'lsx-health-plan' ), esc_html__( 'Exercises', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=exercise' ); |
|
227 | + add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercise Types', 'lsx-health-plan' ), esc_html__( 'Exercise Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=exercise-type&post_type=exercise' ); |
|
228 | + add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Equipment', 'lsx-health-plan' ), esc_html__( 'Equipment', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=equipment&post_type=exercise' ); |
|
229 | + add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Muscle Groups', 'lsx-health-plan' ), esc_html__( 'Muscle Groups', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=muscle-group&post_type=exercise' ); |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * Define the metabox and field configurations. |
|
234 | + */ |
|
235 | + public function tips_metabox() { |
|
236 | + $cmb = new_cmb2_box( |
|
237 | + array( |
|
238 | + 'id' => $this->slug . '_tips_details_metabox', |
|
239 | + 'title' => __( 'Exercise Tips', 'lsx-health-plan' ), |
|
240 | + 'object_types' => array( $this->slug ), // Post type |
|
241 | + 'context' => 'normal', |
|
242 | + 'priority' => 'low', |
|
243 | + 'show_names' => true, |
|
244 | + ) |
|
245 | + ); |
|
246 | + |
|
247 | + // Repeatable group. |
|
248 | + $tip_group = $cmb->add_field( |
|
249 | + array( |
|
250 | + 'id' => $this->slug . '_tips', |
|
251 | + 'type' => 'group', |
|
252 | + 'options' => array( |
|
253 | + 'group_title' => __( 'Tip', 'your-text-domain' ) . ' {#}', // {#} gets replaced by row number |
|
254 | + 'add_button' => __( 'Add another tip', 'your-text-domain' ), |
|
255 | + 'remove_button' => __( 'Remove tip', 'your-text-domain' ), |
|
256 | + 'sortable' => true, |
|
257 | + ), |
|
258 | + 'classes' => 'lsx-admin-row', |
|
259 | + ) |
|
260 | + ); |
|
261 | + |
|
262 | + // Title. |
|
263 | + $cmb->add_group_field( |
|
264 | + $tip_group, |
|
265 | + array( |
|
266 | + 'name' => __( 'Thumbnail', 'your-text-domain' ), |
|
267 | + 'id' => $this->slug . '_tip_thumbnail', |
|
268 | + 'type' => 'file', |
|
269 | + 'text' => array( |
|
270 | + 'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ), |
|
271 | + ), |
|
272 | + 'desc' => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ), |
|
273 | + 'query_args' => array( |
|
274 | + 'type' => array( |
|
275 | + 'image/gif', |
|
276 | + 'image/jpeg', |
|
277 | + 'image/png', |
|
278 | + ), |
|
279 | + ), |
|
280 | + 'preview_size' => 'thumbnail', |
|
281 | + 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-25', |
|
282 | + ) |
|
283 | + ); |
|
284 | + |
|
285 | + $cmb->add_group_field( |
|
286 | + $tip_group, |
|
287 | + array( |
|
288 | + 'name' => __( 'Description', 'your-text-domain' ), |
|
289 | + 'id' => $this->slug . '_tip_content', |
|
290 | + 'type' => 'textarea', |
|
291 | + 'classes' => 'lsx-field-col lsx-field-connect-field lsx-field-col-75', |
|
292 | + ) |
|
293 | + ); |
|
294 | + } |
|
295 | + |
|
296 | + /** |
|
297 | + * Adds the post type to the different arrays. |
|
298 | + * |
|
299 | + * @param array $post_types |
|
300 | + * @return array |
|
301 | + */ |
|
302 | + public function enable_post_type( $post_types = array() ) { |
|
303 | + $post_types[] = $this->slug; |
|
304 | + return $post_types; |
|
305 | + } |
|
306 | + |
|
307 | + /** |
|
308 | + * Enables the Bi Directional relationships |
|
309 | + * |
|
310 | + * @param array $connections |
|
311 | + * @return void |
|
312 | + */ |
|
313 | + public function enable_connections( $connections = array() ) { |
|
314 | + $connections['exercise']['connected_workouts'] = 'connected_exercises'; |
|
315 | + $connections['workout']['connected_exercises'] = 'connected_workouts'; |
|
316 | + return $connections; |
|
317 | + } |
|
318 | + |
|
319 | + /** |
|
320 | + * Registers the lsx_search_settings |
|
321 | + * |
|
322 | + * @param object $cmb new_cmb2_box(). |
|
323 | + * @return void |
|
324 | + */ |
|
325 | + public function register_settings( $cmb ) { |
|
326 | + $cmb->add_field( |
|
327 | + array( |
|
328 | + 'id' => 'exercise_archive_settings_title', |
|
329 | + 'type' => 'title', |
|
330 | + 'name' => __( 'Exercises Archive', 'lsx-health-plan' ), |
|
331 | + 'description' => __( 'All of the settings relating to the exercises post type archive.', 'lsx-health-plan' ), |
|
332 | + ) |
|
333 | + ); |
|
334 | + $cmb->add_field( |
|
335 | + array( |
|
336 | + 'id' => 'exercise_archive_description', |
|
337 | + 'type' => 'wysiwyg', |
|
338 | + 'name' => __( 'Archive Description', 'lsx-health-plan' ), |
|
339 | + 'description' => __( 'This will show up on the post type archive.', 'lsx-health-plan' ), |
|
340 | + ) |
|
341 | + ); |
|
342 | + do_action( 'lsx_hp_exercise_settings_page', $cmb ); |
|
343 | + $cmb->add_field( |
|
344 | + array( |
|
345 | + 'id' => 'settings_exercise_archive_closing', |
|
346 | + 'type' => 'tab_closing', |
|
347 | + ) |
|
348 | + ); |
|
349 | + } |
|
350 | + |
|
351 | + /** |
|
352 | + * Define the metabox and field configurations. |
|
353 | + */ |
|
354 | + public function gallery_metabox() { |
|
355 | + $cmb = new_cmb2_box( |
|
356 | + array( |
|
357 | + 'id' => $this->slug . '_gallery_details_metabox', |
|
358 | + 'title' => __( 'Exercise Gallery', 'lsx-health-plan' ), |
|
359 | + 'object_types' => array( $this->slug ), |
|
360 | + 'context' => 'normal', |
|
361 | + 'priority' => 'low', |
|
362 | + 'show_names' => true, |
|
363 | + ) |
|
364 | + ); |
|
365 | + |
|
366 | + $cmb->add_field( |
|
367 | + array( |
|
368 | + 'name' => __( 'Layout', 'lsx-health-plan' ), |
|
369 | + 'id' => $this->slug . '_gallery_layout', |
|
370 | + 'type' => 'radio', |
|
371 | + 'options' => array( |
|
372 | + 'slider' => __( 'Slider', 'your-text-domain' ) . ' {#}', // {#} gets replaced by row number |
|
373 | + 'grid' => __( 'Grid', 'your-text-domain' ), |
|
374 | + ), |
|
375 | + ) |
|
376 | + ); |
|
377 | + |
|
378 | + $cmb->add_field( |
|
379 | + array( |
|
380 | + 'name' => __( 'Grid Columns', 'lsx-health-plan' ), |
|
381 | + 'id' => $this->slug . '_gallery_columns', |
|
382 | + 'type' => 'text', |
|
383 | + 'default' => '3', |
|
384 | + ) |
|
385 | + ); |
|
386 | + |
|
387 | + // Repeatable group. |
|
388 | + $gallery_group = $cmb->add_field( |
|
389 | + array( |
|
390 | + 'id' => $this->slug . '_gallery', |
|
391 | + 'type' => 'group', |
|
392 | + 'options' => array( |
|
393 | + 'group_title' => __( 'Gallery', 'your-text-domain' ) . ' {#}', // {#} gets replaced by row number |
|
394 | + 'add_button' => __( 'Add Item', 'your-text-domain' ), |
|
395 | + 'remove_button' => __( 'Remove Item', 'your-text-domain' ), |
|
396 | + 'sortable' => true, |
|
397 | + ), |
|
398 | + 'classes' => 'lsx-admin-row', |
|
399 | + ) |
|
400 | + ); |
|
401 | + |
|
402 | + // Title. |
|
403 | + $cmb->add_group_field( |
|
404 | + $gallery_group, |
|
405 | + array( |
|
406 | + 'name' => __( 'Image', 'your-text-domain' ), |
|
407 | + 'id' => $this->slug . '_gallery_image', |
|
408 | + 'type' => 'file', |
|
409 | + 'text' => array( |
|
410 | + 'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ), |
|
411 | + ), |
|
412 | + 'desc' => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ), |
|
413 | + 'query_args' => array( |
|
414 | + 'type' => array( |
|
415 | + 'image/gif', |
|
416 | + 'image/jpeg', |
|
417 | + 'image/png', |
|
418 | + ), |
|
419 | + ), |
|
420 | + 'preview_size' => 'lsx-thumbnail-wide', |
|
421 | + 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-33', |
|
422 | + ) |
|
423 | + ); |
|
424 | + |
|
425 | + // Title. |
|
426 | + $cmb->add_group_field( |
|
427 | + $gallery_group, |
|
428 | + array( |
|
429 | + 'name' => __( 'oEmbed', 'your-text-domain' ), |
|
430 | + 'id' => $this->slug . '_gallery_embed', |
|
431 | + 'type' => 'text', |
|
432 | + 'desc' => __( 'Drop in the embed url for your video from YouTube, Vimeo or DailyMotion, e.g: "https://www.youtube.com/watch?v=9xwazD5SyVg". A full list of supports formats can be found at <a href="https://make.wordpress.org/support/user-manual/content/media/adding-media-to-your-pages-and-posts/embedding-media-from-other-sites/">WordPress</a>', 'lsx-health-plan' ), |
|
433 | + 'classes' => 'lsx-field-col lsx-field-connect-field lsx-field-col-33', |
|
434 | + ) |
|
435 | + ); |
|
436 | + |
|
437 | + $cmb->add_group_field( |
|
438 | + $gallery_group, |
|
439 | + array( |
|
440 | + 'name' => __( 'External Media', 'your-text-domain' ), |
|
441 | + 'id' => $this->slug . '_gallery_external', |
|
442 | + 'type' => 'textarea_code', |
|
443 | + 'desc' => __( 'Drop in the iFrame embed code from Giphy in this field, i.e: <iframe src="https://giphy.com/embed/3o7527Rn1HxXWqgxuo" width="480" height="270" frameborder="0" class="giphy-embed" allowfullscreen></iframe>', 'lsx-health-plan' ), |
|
444 | + 'classes' => 'lsx-field-col lsx-field-connect-field lsx-field-col-33', |
|
445 | + ) |
|
446 | + ); |
|
447 | + } |
|
448 | + |
|
449 | + /** |
|
450 | + * Registers the general settings for the exercise. |
|
451 | + * |
|
452 | + * @return void |
|
453 | + */ |
|
454 | + public function exercise_details() { |
|
455 | + $cmb = new_cmb2_box( |
|
456 | + array( |
|
457 | + 'id' => $this->slug . '_general_details_metabox', |
|
458 | + 'title' => __( 'Details', 'lsx-health-plan' ), |
|
459 | + 'object_types' => array( $this->slug ), |
|
460 | + 'context' => 'normal', |
|
461 | + 'priority' => 'high', |
|
462 | + 'show_names' => true, |
|
463 | + ) |
|
464 | + ); |
|
465 | + |
|
466 | + $cmb->add_field( |
|
467 | + array( |
|
468 | + 'name' => __( 'Side', 'lsx-health-plan' ), |
|
469 | + 'id' => $this->slug . '_side', |
|
470 | + 'type' => 'select', |
|
471 | + 'options' => array( |
|
472 | + '' => __( 'Select', 'your-text-domain' ), |
|
473 | + 'left' => __( 'Left', 'your-text-domain' ), |
|
474 | + 'right' => __( 'Right', 'your-text-domain' ), |
|
475 | + ), |
|
476 | + 'desc' => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ), |
|
477 | + ) |
|
478 | + ); |
|
479 | + } |
|
480 | 480 | } |
@@ -10,416 +10,416 @@ |
||
10 | 10 | */ |
11 | 11 | class Workout { |
12 | 12 | |
13 | - /** |
|
14 | - * Holds class instance |
|
15 | - * |
|
16 | - * @since 1.0.0 |
|
17 | - * |
|
18 | - * @var object \lsx_health_plan\classes\Workout() |
|
19 | - */ |
|
20 | - protected static $instance = null; |
|
13 | + /** |
|
14 | + * Holds class instance |
|
15 | + * |
|
16 | + * @since 1.0.0 |
|
17 | + * |
|
18 | + * @var object \lsx_health_plan\classes\Workout() |
|
19 | + */ |
|
20 | + protected static $instance = null; |
|
21 | 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 = 'workout'; |
|
22 | + /** |
|
23 | + * Holds post_type slug used as an index |
|
24 | + * |
|
25 | + * @since 1.0.0 |
|
26 | + * |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + public $slug = 'workout'; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Contructor |
|
33 | - */ |
|
34 | - public function __construct() { |
|
35 | - add_action( 'init', array( $this, 'register_post_type' ) ); |
|
36 | - add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
37 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
38 | - add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) ); |
|
39 | - add_action( 'cmb2_admin_init', array( $this, 'workout_connections' ), 15 ); |
|
40 | - add_action( 'lsx_hp_settings_page', array( $this, 'register_settings' ), 8, 1 ); |
|
41 | - add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
31 | + /** |
|
32 | + * Contructor |
|
33 | + */ |
|
34 | + public function __construct() { |
|
35 | + add_action( 'init', array( $this, 'register_post_type' ) ); |
|
36 | + add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
37 | + add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
38 | + add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) ); |
|
39 | + add_action( 'cmb2_admin_init', array( $this, 'workout_connections' ), 15 ); |
|
40 | + add_action( 'lsx_hp_settings_page', array( $this, 'register_settings' ), 8, 1 ); |
|
41 | + add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
42 | 42 | |
43 | - // Template Redirects. |
|
44 | - add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
45 | - } |
|
43 | + // Template Redirects. |
|
44 | + add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Return an instance of this class. |
|
49 | - * |
|
50 | - * @since 1.0.0 |
|
51 | - * |
|
52 | - * @return object \lsx_health_plan\classes\Workout() A single instance of this class. |
|
53 | - */ |
|
54 | - public static function get_instance() { |
|
55 | - // If the single instance hasn't been set, set it now. |
|
56 | - if ( null === self::$instance ) { |
|
57 | - self::$instance = new self(); |
|
58 | - } |
|
59 | - return self::$instance; |
|
60 | - } |
|
61 | - /** |
|
62 | - * Register the post type. |
|
63 | - */ |
|
64 | - public function register_post_type() { |
|
65 | - $labels = array( |
|
66 | - 'name' => esc_html__( 'Workout', 'lsx-health-plan' ), |
|
67 | - 'singular_name' => esc_html__( 'Workouts', 'lsx-health-plan' ), |
|
68 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
69 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
70 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
71 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
72 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
73 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
74 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
75 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
76 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
77 | - 'parent_item_colon' => '', |
|
78 | - 'menu_name' => esc_html__( 'Workouts', 'lsx-health-plan' ), |
|
79 | - ); |
|
80 | - $args = array( |
|
81 | - 'labels' => $labels, |
|
82 | - 'public' => true, |
|
83 | - 'publicly_queryable' => true, |
|
84 | - 'show_ui' => true, |
|
85 | - 'show_in_menu' => true, |
|
86 | - 'show_in_rest' => true, |
|
87 | - 'menu_icon' => 'dashicons-universal-access', |
|
88 | - 'query_var' => true, |
|
89 | - 'rewrite' => array( |
|
90 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ), |
|
91 | - ), |
|
92 | - 'capability_type' => 'page', |
|
93 | - 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', false ), |
|
94 | - 'hierarchical' => true, |
|
95 | - 'menu_position' => null, |
|
96 | - 'supports' => array( |
|
97 | - 'title', |
|
98 | - 'thumbnail', |
|
99 | - 'editor', |
|
100 | - 'excerpt', |
|
101 | - ), |
|
102 | - ); |
|
103 | - register_post_type( 'workout', $args ); |
|
104 | - } |
|
47 | + /** |
|
48 | + * Return an instance of this class. |
|
49 | + * |
|
50 | + * @since 1.0.0 |
|
51 | + * |
|
52 | + * @return object \lsx_health_plan\classes\Workout() A single instance of this class. |
|
53 | + */ |
|
54 | + public static function get_instance() { |
|
55 | + // If the single instance hasn't been set, set it now. |
|
56 | + if ( null === self::$instance ) { |
|
57 | + self::$instance = new self(); |
|
58 | + } |
|
59 | + return self::$instance; |
|
60 | + } |
|
61 | + /** |
|
62 | + * Register the post type. |
|
63 | + */ |
|
64 | + public function register_post_type() { |
|
65 | + $labels = array( |
|
66 | + 'name' => esc_html__( 'Workout', 'lsx-health-plan' ), |
|
67 | + 'singular_name' => esc_html__( 'Workouts', 'lsx-health-plan' ), |
|
68 | + 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
69 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
70 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
71 | + 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
72 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
73 | + 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
74 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
75 | + 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
76 | + 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
77 | + 'parent_item_colon' => '', |
|
78 | + 'menu_name' => esc_html__( 'Workouts', 'lsx-health-plan' ), |
|
79 | + ); |
|
80 | + $args = array( |
|
81 | + 'labels' => $labels, |
|
82 | + 'public' => true, |
|
83 | + 'publicly_queryable' => true, |
|
84 | + 'show_ui' => true, |
|
85 | + 'show_in_menu' => true, |
|
86 | + 'show_in_rest' => true, |
|
87 | + 'menu_icon' => 'dashicons-universal-access', |
|
88 | + 'query_var' => true, |
|
89 | + 'rewrite' => array( |
|
90 | + 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ), |
|
91 | + ), |
|
92 | + 'capability_type' => 'page', |
|
93 | + 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', false ), |
|
94 | + 'hierarchical' => true, |
|
95 | + 'menu_position' => null, |
|
96 | + 'supports' => array( |
|
97 | + 'title', |
|
98 | + 'thumbnail', |
|
99 | + 'editor', |
|
100 | + 'excerpt', |
|
101 | + ), |
|
102 | + ); |
|
103 | + register_post_type( 'workout', $args ); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Adds the post type to the different arrays. |
|
108 | - * |
|
109 | - * @param array $post_types |
|
110 | - * @return array |
|
111 | - */ |
|
112 | - public function enable_post_type( $post_types = array() ) { |
|
113 | - $post_types[] = $this->slug; |
|
114 | - return $post_types; |
|
115 | - } |
|
106 | + /** |
|
107 | + * Adds the post type to the different arrays. |
|
108 | + * |
|
109 | + * @param array $post_types |
|
110 | + * @return array |
|
111 | + */ |
|
112 | + public function enable_post_type( $post_types = array() ) { |
|
113 | + $post_types[] = $this->slug; |
|
114 | + return $post_types; |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * Enables the Bi Directional relationships |
|
119 | - * |
|
120 | - * @param array $connections |
|
121 | - * @return void |
|
122 | - */ |
|
123 | - public function enable_connections( $connections = array() ) { |
|
124 | - $connections['workout']['connected_plans'] = 'connected_workouts'; |
|
125 | - $connections['plan']['connected_workouts'] = 'connected_plans'; |
|
117 | + /** |
|
118 | + * Enables the Bi Directional relationships |
|
119 | + * |
|
120 | + * @param array $connections |
|
121 | + * @return void |
|
122 | + */ |
|
123 | + public function enable_connections( $connections = array() ) { |
|
124 | + $connections['workout']['connected_plans'] = 'connected_workouts'; |
|
125 | + $connections['plan']['connected_workouts'] = 'connected_plans'; |
|
126 | 126 | |
127 | - $connections['workout']['connected_videos'] = 'connected_workouts'; |
|
128 | - $connections['video']['connected_workouts'] = 'connected_videos'; |
|
127 | + $connections['workout']['connected_videos'] = 'connected_workouts'; |
|
128 | + $connections['video']['connected_workouts'] = 'connected_videos'; |
|
129 | 129 | |
130 | - $connections['workout']['connected_posts'] = 'connected_workouts'; |
|
131 | - $connections['post']['connected_workouts'] = 'connected_posts'; |
|
132 | - return $connections; |
|
133 | - } |
|
130 | + $connections['workout']['connected_posts'] = 'connected_workouts'; |
|
131 | + $connections['post']['connected_workouts'] = 'connected_posts'; |
|
132 | + return $connections; |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * Remove the "Archives:" from the post type workouts. |
|
137 | - * |
|
138 | - * @param string $title the term title. |
|
139 | - * @return string |
|
140 | - */ |
|
141 | - public function get_the_archive_title( $title ) { |
|
142 | - if ( is_post_type_archive( 'workout' ) ) { |
|
143 | - $title = __( 'Workouts', 'lsx-health-plan' ); |
|
144 | - } |
|
145 | - return $title; |
|
146 | - } |
|
135 | + /** |
|
136 | + * Remove the "Archives:" from the post type workouts. |
|
137 | + * |
|
138 | + * @param string $title the term title. |
|
139 | + * @return string |
|
140 | + */ |
|
141 | + public function get_the_archive_title( $title ) { |
|
142 | + if ( is_post_type_archive( 'workout' ) ) { |
|
143 | + $title = __( 'Workouts', 'lsx-health-plan' ); |
|
144 | + } |
|
145 | + return $title; |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * Define the metabox and field configurations. |
|
150 | - */ |
|
151 | - public function details_metaboxes() { |
|
152 | - $workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 ); |
|
153 | - if ( false !== $workout_sections && null !== $workout_sections ) { |
|
154 | - $i = 1; |
|
155 | - while ( $i <= $workout_sections ) { |
|
148 | + /** |
|
149 | + * Define the metabox and field configurations. |
|
150 | + */ |
|
151 | + public function details_metaboxes() { |
|
152 | + $workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 ); |
|
153 | + if ( false !== $workout_sections && null !== $workout_sections ) { |
|
154 | + $i = 1; |
|
155 | + while ( $i <= $workout_sections ) { |
|
156 | 156 | |
157 | - $cmb_group = new_cmb2_box( array( |
|
158 | - 'id' => $this->slug . '_section_' . $i . '_metabox', |
|
159 | - 'title' => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i, |
|
160 | - 'object_types' => array( $this->slug ), |
|
161 | - ) ); |
|
157 | + $cmb_group = new_cmb2_box( array( |
|
158 | + 'id' => $this->slug . '_section_' . $i . '_metabox', |
|
159 | + 'title' => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i, |
|
160 | + 'object_types' => array( $this->slug ), |
|
161 | + ) ); |
|
162 | 162 | |
163 | - $cmb_group->add_field( array( |
|
164 | - 'name' => __( 'Title', 'lsx-health-plan' ), |
|
165 | - 'id' => $this->slug . '_section_' . $i . '_title', |
|
166 | - 'type' => 'text', |
|
167 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
168 | - ) ); |
|
163 | + $cmb_group->add_field( array( |
|
164 | + 'name' => __( 'Title', 'lsx-health-plan' ), |
|
165 | + 'id' => $this->slug . '_section_' . $i . '_title', |
|
166 | + 'type' => 'text', |
|
167 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
168 | + ) ); |
|
169 | 169 | |
170 | - $cmb_group->add_field( |
|
171 | - array( |
|
172 | - 'name' => __( 'Description', 'lsx-health-plan' ), |
|
173 | - 'id' => $this->slug . '_section_' . $i . '_description', |
|
174 | - 'type' => 'wysiwyg', |
|
175 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
176 | - 'options' => array( |
|
177 | - 'textarea_rows' => 5, |
|
178 | - ), |
|
179 | - ) |
|
180 | - ); |
|
170 | + $cmb_group->add_field( |
|
171 | + array( |
|
172 | + 'name' => __( 'Description', 'lsx-health-plan' ), |
|
173 | + 'id' => $this->slug . '_section_' . $i . '_description', |
|
174 | + 'type' => 'wysiwyg', |
|
175 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
176 | + 'options' => array( |
|
177 | + 'textarea_rows' => 5, |
|
178 | + ), |
|
179 | + ) |
|
180 | + ); |
|
181 | 181 | |
182 | - /** |
|
183 | - * Repeatable Field Groups |
|
184 | - */ |
|
185 | - // $group_field_id is the field id string, so in this case: $prefix . 'demo' |
|
186 | - $group_field_id = $cmb_group->add_field( |
|
187 | - array( |
|
188 | - 'id' => $this->slug . '_section_' . $i, |
|
189 | - 'type' => 'group', |
|
190 | - 'options' => array( |
|
191 | - 'group_title' => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number |
|
192 | - 'add_button' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
193 | - 'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ), |
|
194 | - 'sortable' => true, |
|
195 | - ), |
|
196 | - ) |
|
197 | - ); |
|
182 | + /** |
|
183 | + * Repeatable Field Groups |
|
184 | + */ |
|
185 | + // $group_field_id is the field id string, so in this case: $prefix . 'demo' |
|
186 | + $group_field_id = $cmb_group->add_field( |
|
187 | + array( |
|
188 | + 'id' => $this->slug . '_section_' . $i, |
|
189 | + 'type' => 'group', |
|
190 | + 'options' => array( |
|
191 | + 'group_title' => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number |
|
192 | + 'add_button' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
193 | + 'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ), |
|
194 | + 'sortable' => true, |
|
195 | + ), |
|
196 | + ) |
|
197 | + ); |
|
198 | 198 | |
199 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
200 | - $cmb_group->add_group_field( |
|
201 | - $group_field_id, |
|
202 | - array( |
|
203 | - 'name' => __( 'Exercise related to this workout', 'lsx-health-plan' ), |
|
204 | - 'id' => 'connected_exercises', |
|
205 | - 'type' => 'post_search_ajax', |
|
206 | - // Optional : |
|
207 | - 'limit' => 1, // Limit selection to X items only (default 1) |
|
208 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
209 | - 'query_args' => array( |
|
210 | - 'post_type' => array( 'exercise' ), |
|
211 | - 'post_status' => array( 'publish' ), |
|
212 | - 'posts_per_page' => -1, |
|
213 | - ), |
|
214 | - ) |
|
215 | - ); |
|
216 | - } else { |
|
217 | - $cmb_group->add_group_field( |
|
218 | - $group_field_id, |
|
219 | - array( |
|
220 | - 'name' => __( 'Video related to this workout', 'lsx-health-plan' ), |
|
221 | - 'id' => 'connected_videos', |
|
222 | - 'type' => 'post_search_ajax', |
|
223 | - // Optional : |
|
224 | - 'limit' => 1, // Limit selection to X items only (default 1) |
|
225 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
226 | - 'query_args' => array( |
|
227 | - 'post_type' => array( 'video' ), |
|
228 | - 'post_status' => array( 'publish' ), |
|
229 | - 'posts_per_page' => -1, |
|
230 | - ), |
|
231 | - ) |
|
232 | - ); |
|
233 | - $cmb_group->add_group_field( |
|
234 | - $group_field_id, |
|
235 | - array( |
|
236 | - 'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ), |
|
237 | - 'id' => 'name', |
|
238 | - 'type' => 'text', |
|
239 | - // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) |
|
240 | - ) |
|
241 | - ); |
|
199 | + if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
200 | + $cmb_group->add_group_field( |
|
201 | + $group_field_id, |
|
202 | + array( |
|
203 | + 'name' => __( 'Exercise related to this workout', 'lsx-health-plan' ), |
|
204 | + 'id' => 'connected_exercises', |
|
205 | + 'type' => 'post_search_ajax', |
|
206 | + // Optional : |
|
207 | + 'limit' => 1, // Limit selection to X items only (default 1) |
|
208 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
209 | + 'query_args' => array( |
|
210 | + 'post_type' => array( 'exercise' ), |
|
211 | + 'post_status' => array( 'publish' ), |
|
212 | + 'posts_per_page' => -1, |
|
213 | + ), |
|
214 | + ) |
|
215 | + ); |
|
216 | + } else { |
|
217 | + $cmb_group->add_group_field( |
|
218 | + $group_field_id, |
|
219 | + array( |
|
220 | + 'name' => __( 'Video related to this workout', 'lsx-health-plan' ), |
|
221 | + 'id' => 'connected_videos', |
|
222 | + 'type' => 'post_search_ajax', |
|
223 | + // Optional : |
|
224 | + 'limit' => 1, // Limit selection to X items only (default 1) |
|
225 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
226 | + 'query_args' => array( |
|
227 | + 'post_type' => array( 'video' ), |
|
228 | + 'post_status' => array( 'publish' ), |
|
229 | + 'posts_per_page' => -1, |
|
230 | + ), |
|
231 | + ) |
|
232 | + ); |
|
233 | + $cmb_group->add_group_field( |
|
234 | + $group_field_id, |
|
235 | + array( |
|
236 | + 'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ), |
|
237 | + 'id' => 'name', |
|
238 | + 'type' => 'text', |
|
239 | + // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) |
|
240 | + ) |
|
241 | + ); |
|
242 | 242 | |
243 | - $cmb_group->add_group_field( |
|
244 | - $group_field_id, |
|
245 | - array( |
|
246 | - 'name' => __( 'Description', 'lsx-health-plan' ), |
|
247 | - 'id' => 'description', |
|
248 | - 'type' => 'wysiwyg', |
|
249 | - 'options' => array( |
|
250 | - 'textarea_rows' => 2, |
|
251 | - ), |
|
252 | - ) |
|
253 | - ); |
|
254 | - } |
|
243 | + $cmb_group->add_group_field( |
|
244 | + $group_field_id, |
|
245 | + array( |
|
246 | + 'name' => __( 'Description', 'lsx-health-plan' ), |
|
247 | + 'id' => 'description', |
|
248 | + 'type' => 'wysiwyg', |
|
249 | + 'options' => array( |
|
250 | + 'textarea_rows' => 2, |
|
251 | + ), |
|
252 | + ) |
|
253 | + ); |
|
254 | + } |
|
255 | 255 | |
256 | - $cmb_group->add_group_field( |
|
257 | - $group_field_id, |
|
258 | - array( |
|
259 | - 'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ), |
|
260 | - 'id' => 'reps', |
|
261 | - 'type' => 'text', |
|
262 | - // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) |
|
263 | - ) |
|
264 | - ); |
|
265 | - $i++; |
|
266 | - }; |
|
267 | - } |
|
268 | - } |
|
256 | + $cmb_group->add_group_field( |
|
257 | + $group_field_id, |
|
258 | + array( |
|
259 | + 'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ), |
|
260 | + 'id' => 'reps', |
|
261 | + 'type' => 'text', |
|
262 | + // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) |
|
263 | + ) |
|
264 | + ); |
|
265 | + $i++; |
|
266 | + }; |
|
267 | + } |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * Registers the workout connections on the plan post type. |
|
272 | - * |
|
273 | - * @return void |
|
274 | - */ |
|
275 | - public function workout_connections() { |
|
276 | - $cmb = new_cmb2_box( |
|
277 | - array( |
|
278 | - 'id' => $this->slug . '_workout_connections_metabox', |
|
279 | - 'title' => __( 'Workouts', 'lsx-health-plan' ), |
|
280 | - 'desc' => __( 'Start typing to search for your workouts', 'lsx-health-plan' ), |
|
281 | - 'object_types' => array( 'plan' ), |
|
282 | - 'context' => 'normal', |
|
283 | - 'priority' => 'high', |
|
284 | - 'show_names' => true, |
|
285 | - ) |
|
286 | - ); |
|
287 | - $cmb->add_field( |
|
288 | - array( |
|
289 | - 'name' => __( 'Workouts', 'lsx-health-plan' ), |
|
290 | - 'id' => 'connected_workouts', |
|
291 | - 'desc' => __( 'Connect the workout that applies to this day plan using the field provided.', 'lsx-health-plan' ), |
|
292 | - 'type' => 'post_search_ajax', |
|
293 | - 'limit' => 15, |
|
294 | - 'sortable' => true, |
|
295 | - 'query_args' => array( |
|
296 | - 'post_type' => array( 'workout' ), |
|
297 | - 'post_status' => array( 'publish' ), |
|
298 | - 'posts_per_page' => -1, |
|
299 | - ), |
|
300 | - ) |
|
301 | - ); |
|
302 | - $cmb->add_field( |
|
303 | - array( |
|
304 | - 'name' => __( 'Pre Workout Snack', 'lsx-health-plan' ), |
|
305 | - 'id' => 'pre_workout_snack', |
|
306 | - 'type' => 'wysiwyg', |
|
307 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
308 | - 'options' => array( |
|
309 | - 'textarea_rows' => 5, |
|
310 | - ), |
|
311 | - ) |
|
312 | - ); |
|
313 | - $cmb->add_field( |
|
314 | - array( |
|
315 | - 'name' => __( 'Post Workout Snack', 'lsx-health-plan' ), |
|
316 | - 'id' => 'post_workout_snack', |
|
317 | - 'type' => 'wysiwyg', |
|
318 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
319 | - 'options' => array( |
|
320 | - 'textarea_rows' => 5, |
|
321 | - ), |
|
322 | - ) |
|
323 | - ); |
|
324 | - } |
|
270 | + /** |
|
271 | + * Registers the workout connections on the plan post type. |
|
272 | + * |
|
273 | + * @return void |
|
274 | + */ |
|
275 | + public function workout_connections() { |
|
276 | + $cmb = new_cmb2_box( |
|
277 | + array( |
|
278 | + 'id' => $this->slug . '_workout_connections_metabox', |
|
279 | + 'title' => __( 'Workouts', 'lsx-health-plan' ), |
|
280 | + 'desc' => __( 'Start typing to search for your workouts', 'lsx-health-plan' ), |
|
281 | + 'object_types' => array( 'plan' ), |
|
282 | + 'context' => 'normal', |
|
283 | + 'priority' => 'high', |
|
284 | + 'show_names' => true, |
|
285 | + ) |
|
286 | + ); |
|
287 | + $cmb->add_field( |
|
288 | + array( |
|
289 | + 'name' => __( 'Workouts', 'lsx-health-plan' ), |
|
290 | + 'id' => 'connected_workouts', |
|
291 | + 'desc' => __( 'Connect the workout that applies to this day plan using the field provided.', 'lsx-health-plan' ), |
|
292 | + 'type' => 'post_search_ajax', |
|
293 | + 'limit' => 15, |
|
294 | + 'sortable' => true, |
|
295 | + 'query_args' => array( |
|
296 | + 'post_type' => array( 'workout' ), |
|
297 | + 'post_status' => array( 'publish' ), |
|
298 | + 'posts_per_page' => -1, |
|
299 | + ), |
|
300 | + ) |
|
301 | + ); |
|
302 | + $cmb->add_field( |
|
303 | + array( |
|
304 | + 'name' => __( 'Pre Workout Snack', 'lsx-health-plan' ), |
|
305 | + 'id' => 'pre_workout_snack', |
|
306 | + 'type' => 'wysiwyg', |
|
307 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
308 | + 'options' => array( |
|
309 | + 'textarea_rows' => 5, |
|
310 | + ), |
|
311 | + ) |
|
312 | + ); |
|
313 | + $cmb->add_field( |
|
314 | + array( |
|
315 | + 'name' => __( 'Post Workout Snack', 'lsx-health-plan' ), |
|
316 | + 'id' => 'post_workout_snack', |
|
317 | + 'type' => 'wysiwyg', |
|
318 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
319 | + 'options' => array( |
|
320 | + 'textarea_rows' => 5, |
|
321 | + ), |
|
322 | + ) |
|
323 | + ); |
|
324 | + } |
|
325 | 325 | |
326 | - /** |
|
327 | - * Registers the lsx_search_settings |
|
328 | - * |
|
329 | - * @param object $cmb new_cmb2_box(). |
|
330 | - * @return void |
|
331 | - */ |
|
332 | - public function register_settings( $cmb ) { |
|
333 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
334 | - $cmb->add_field( |
|
335 | - array( |
|
336 | - 'id' => 'workout_settings_title', |
|
337 | - 'type' => 'title', |
|
338 | - 'name' => __( 'Workout Settings', 'lsx-health-plan' ), |
|
339 | - 'description' => __( 'Choose the layout, content and link settings for your exercises.', 'lsx-health-plan' ), |
|
340 | - ) |
|
341 | - ); |
|
326 | + /** |
|
327 | + * Registers the lsx_search_settings |
|
328 | + * |
|
329 | + * @param object $cmb new_cmb2_box(). |
|
330 | + * @return void |
|
331 | + */ |
|
332 | + public function register_settings( $cmb ) { |
|
333 | + if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
334 | + $cmb->add_field( |
|
335 | + array( |
|
336 | + 'id' => 'workout_settings_title', |
|
337 | + 'type' => 'title', |
|
338 | + 'name' => __( 'Workout Settings', 'lsx-health-plan' ), |
|
339 | + 'description' => __( 'Choose the layout, content and link settings for your exercises.', 'lsx-health-plan' ), |
|
340 | + ) |
|
341 | + ); |
|
342 | 342 | |
343 | - $cmb->add_field( |
|
344 | - array( |
|
345 | - 'id' => 'workout_tab_layout', |
|
346 | - 'type' => 'select', |
|
347 | - 'name' => __( 'Workout Tab Layout', 'lsx-health-plan' ), |
|
348 | - 'description' => __( 'Choose the layout for the workouts.', 'lsx-health-plan' ), |
|
349 | - 'options' => array( |
|
350 | - 'table' => __( 'Table', 'lsx-health-plan' ), |
|
351 | - 'list' => __( 'List', 'lsx-health-plan' ), |
|
352 | - 'grid' => __( 'Grid', 'lsx-health-plan' ), |
|
353 | - ), |
|
354 | - ) |
|
355 | - ); |
|
356 | - $cmb->add_field( |
|
357 | - array( |
|
358 | - 'id' => 'workout_tab_link', |
|
359 | - 'type' => 'select', |
|
360 | - 'name' => __( 'Workout Tab Link', 'lsx-health-plan' ), |
|
361 | - 'description' => __( 'Choose to show the excerpt, full content or nothing.', 'lsx-health-plan' ), |
|
362 | - 'options' => array( |
|
363 | - '' => __( 'None', 'lsx-health-plan' ), |
|
364 | - 'single' => __( 'Single', 'lsx-health-plan' ), |
|
365 | - 'modal' => __( 'Modal', 'lsx-health-plan' ), |
|
366 | - ), |
|
367 | - 'default' => 'modal', |
|
368 | - ) |
|
369 | - ); |
|
370 | - $cmb->add_field( |
|
371 | - array( |
|
372 | - 'id' => 'workout_tab_modal_content', |
|
373 | - 'type' => 'select', |
|
374 | - 'name' => __( 'Modal Content', 'lsx-health-plan' ), |
|
375 | - 'description' => __( 'Choose to show the excerpt, full content or nothing. For the modal content only', 'lsx-health-plan' ), |
|
376 | - 'options' => array( |
|
377 | - '' => __( 'None', 'lsx-health-plan' ), |
|
378 | - 'excerpt' => __( 'Excerpt', 'lsx-health-plan' ), |
|
379 | - 'full' => __( 'Full Content', 'lsx-health-plan' ), |
|
380 | - ), |
|
381 | - 'default' => '', |
|
382 | - ) |
|
383 | - ); |
|
384 | - $cmb->add_field( |
|
385 | - array( |
|
386 | - 'id' => 'workout_tab_columns', |
|
387 | - 'type' => 'select', |
|
388 | - 'name' => __( 'Grid Columns', 'lsx-health-plan' ), |
|
389 | - 'description' => __( 'If you are displaying a grid, set the amount of columns you want to use.', 'lsx-health-plan' ), |
|
390 | - 'options' => array( |
|
391 | - '12' => __( '1', 'lsx-health-plan' ), |
|
392 | - '6' => __( '2', 'lsx-health-plan' ), |
|
393 | - '4' => __( '3', 'lsx-health-plan' ), |
|
394 | - '3' => __( '4', 'lsx-health-plan' ), |
|
395 | - '2' => __( '6', 'lsx-health-plan' ), |
|
396 | - ), |
|
397 | - 'default' => '4', |
|
398 | - ) |
|
399 | - ); |
|
400 | - $cmb->add_field( |
|
401 | - array( |
|
402 | - 'id' => 'workout_tab_content', |
|
403 | - 'type' => 'select', |
|
404 | - 'name' => __( 'Grid Content', 'lsx-health-plan' ), |
|
405 | - 'description' => __( 'Choose to show the excerpt, full content or nothing. For the grid layout only', 'lsx-health-plan' ), |
|
406 | - 'options' => array( |
|
407 | - '' => __( 'None', 'lsx-health-plan' ), |
|
408 | - 'excerpt' => __( 'Excerpt', 'lsx-health-plan' ), |
|
409 | - 'full' => __( 'Full Content', 'lsx-health-plan' ), |
|
410 | - ), |
|
411 | - 'default' => '', |
|
412 | - ) |
|
413 | - ); |
|
343 | + $cmb->add_field( |
|
344 | + array( |
|
345 | + 'id' => 'workout_tab_layout', |
|
346 | + 'type' => 'select', |
|
347 | + 'name' => __( 'Workout Tab Layout', 'lsx-health-plan' ), |
|
348 | + 'description' => __( 'Choose the layout for the workouts.', 'lsx-health-plan' ), |
|
349 | + 'options' => array( |
|
350 | + 'table' => __( 'Table', 'lsx-health-plan' ), |
|
351 | + 'list' => __( 'List', 'lsx-health-plan' ), |
|
352 | + 'grid' => __( 'Grid', 'lsx-health-plan' ), |
|
353 | + ), |
|
354 | + ) |
|
355 | + ); |
|
356 | + $cmb->add_field( |
|
357 | + array( |
|
358 | + 'id' => 'workout_tab_link', |
|
359 | + 'type' => 'select', |
|
360 | + 'name' => __( 'Workout Tab Link', 'lsx-health-plan' ), |
|
361 | + 'description' => __( 'Choose to show the excerpt, full content or nothing.', 'lsx-health-plan' ), |
|
362 | + 'options' => array( |
|
363 | + '' => __( 'None', 'lsx-health-plan' ), |
|
364 | + 'single' => __( 'Single', 'lsx-health-plan' ), |
|
365 | + 'modal' => __( 'Modal', 'lsx-health-plan' ), |
|
366 | + ), |
|
367 | + 'default' => 'modal', |
|
368 | + ) |
|
369 | + ); |
|
370 | + $cmb->add_field( |
|
371 | + array( |
|
372 | + 'id' => 'workout_tab_modal_content', |
|
373 | + 'type' => 'select', |
|
374 | + 'name' => __( 'Modal Content', 'lsx-health-plan' ), |
|
375 | + 'description' => __( 'Choose to show the excerpt, full content or nothing. For the modal content only', 'lsx-health-plan' ), |
|
376 | + 'options' => array( |
|
377 | + '' => __( 'None', 'lsx-health-plan' ), |
|
378 | + 'excerpt' => __( 'Excerpt', 'lsx-health-plan' ), |
|
379 | + 'full' => __( 'Full Content', 'lsx-health-plan' ), |
|
380 | + ), |
|
381 | + 'default' => '', |
|
382 | + ) |
|
383 | + ); |
|
384 | + $cmb->add_field( |
|
385 | + array( |
|
386 | + 'id' => 'workout_tab_columns', |
|
387 | + 'type' => 'select', |
|
388 | + 'name' => __( 'Grid Columns', 'lsx-health-plan' ), |
|
389 | + 'description' => __( 'If you are displaying a grid, set the amount of columns you want to use.', 'lsx-health-plan' ), |
|
390 | + 'options' => array( |
|
391 | + '12' => __( '1', 'lsx-health-plan' ), |
|
392 | + '6' => __( '2', 'lsx-health-plan' ), |
|
393 | + '4' => __( '3', 'lsx-health-plan' ), |
|
394 | + '3' => __( '4', 'lsx-health-plan' ), |
|
395 | + '2' => __( '6', 'lsx-health-plan' ), |
|
396 | + ), |
|
397 | + 'default' => '4', |
|
398 | + ) |
|
399 | + ); |
|
400 | + $cmb->add_field( |
|
401 | + array( |
|
402 | + 'id' => 'workout_tab_content', |
|
403 | + 'type' => 'select', |
|
404 | + 'name' => __( 'Grid Content', 'lsx-health-plan' ), |
|
405 | + 'description' => __( 'Choose to show the excerpt, full content or nothing. For the grid layout only', 'lsx-health-plan' ), |
|
406 | + 'options' => array( |
|
407 | + '' => __( 'None', 'lsx-health-plan' ), |
|
408 | + 'excerpt' => __( 'Excerpt', 'lsx-health-plan' ), |
|
409 | + 'full' => __( 'Full Content', 'lsx-health-plan' ), |
|
410 | + ), |
|
411 | + 'default' => '', |
|
412 | + ) |
|
413 | + ); |
|
414 | 414 | |
415 | - do_action( 'lsx_hp_workout_settings_page', $cmb ); |
|
415 | + do_action( 'lsx_hp_workout_settings_page', $cmb ); |
|
416 | 416 | |
417 | - $cmb->add_field( |
|
418 | - array( |
|
419 | - 'id' => 'settings_workouts_closing', |
|
420 | - 'type' => 'tab_closing', |
|
421 | - ) |
|
422 | - ); |
|
423 | - } |
|
424 | - } |
|
417 | + $cmb->add_field( |
|
418 | + array( |
|
419 | + 'id' => 'settings_workouts_closing', |
|
420 | + 'type' => 'tab_closing', |
|
421 | + ) |
|
422 | + ); |
|
423 | + } |
|
424 | + } |
|
425 | 425 | } |