@@ -11,10 +11,10 @@ discard block |
||
11 | 11 | * @return exercise_type |
12 | 12 | */ |
13 | 13 | function lsx_health_plan_exercise_type() { |
14 | - $term_obj_list = get_the_term_list( get_the_ID(), 'exercise-type', '', ', ' ); |
|
15 | - if ( ! empty( $term_obj_list ) ) { |
|
16 | - return $term_obj_list; |
|
17 | - } |
|
14 | + $term_obj_list = get_the_term_list( get_the_ID(), 'exercise-type', '', ', ' ); |
|
15 | + if ( ! empty( $term_obj_list ) ) { |
|
16 | + return $term_obj_list; |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | * @return muscle_group_equipment |
24 | 24 | */ |
25 | 25 | function lsx_health_plan_muscle_group_equipment() { |
26 | - $term_obj_list = get_the_term_list( get_the_ID(), 'muscle-group', '', ', ' ); |
|
27 | - if ( ! empty( $term_obj_list ) ) { |
|
28 | - return $term_obj_list; |
|
29 | - } |
|
26 | + $term_obj_list = get_the_term_list( get_the_ID(), 'muscle-group', '', ', ' ); |
|
27 | + if ( ! empty( $term_obj_list ) ) { |
|
28 | + return $term_obj_list; |
|
29 | + } |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | * @return exercise_equipment |
36 | 36 | */ |
37 | 37 | function lsx_health_plan_exercise_equipment() { |
38 | - $term_obj_list = get_the_term_list( get_the_ID(), 'equipment', '', ', ' ); |
|
39 | - if ( ! empty( $term_obj_list ) ) { |
|
40 | - return $term_obj_list; |
|
41 | - } |
|
38 | + $term_obj_list = get_the_term_list( get_the_ID(), 'equipment', '', ', ' ); |
|
39 | + if ( ! empty( $term_obj_list ) ) { |
|
40 | + return $term_obj_list; |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -47,81 +47,81 @@ discard block |
||
47 | 47 | * @return void |
48 | 48 | */ |
49 | 49 | function lsx_health_plan_exercise_data() { |
50 | - include LSX_HEALTH_PLAN_PATH . '/templates/table-exercise-data.php'; |
|
50 | + include LSX_HEALTH_PLAN_PATH . '/templates/table-exercise-data.php'; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | function lsx_health_plan_workout_exercise_alt_button( $m, $group, $echo = true, $args = array(), $alt_title, $alt_description, $alt_image ) { |
54 | - $defaults = array( |
|
55 | - 'modal_trigger' => 'button', |
|
56 | - 'modal_content' => 'excerpt', |
|
57 | - ); |
|
58 | - $args = wp_parse_args( $args, $defaults ); |
|
54 | + $defaults = array( |
|
55 | + 'modal_trigger' => 'button', |
|
56 | + 'modal_content' => 'excerpt', |
|
57 | + ); |
|
58 | + $args = wp_parse_args( $args, $defaults ); |
|
59 | 59 | |
60 | - $exercise_id = ''; |
|
61 | - if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) { |
|
62 | - $exercise_id = esc_html( $group['connected_exercises'] ); |
|
63 | - $content = get_post_field( 'post_content', $exercise_id ); |
|
64 | - $url = get_permalink( $exercise_id ); |
|
65 | - $equipment_group = get_the_term_list( $exercise_id, 'equipment', '', ', ' ); |
|
66 | - $muscle_group = get_the_term_list( $exercise_id, 'muscle-group', '', ', ' ); |
|
67 | - $lsx_hp = lsx_health_plan(); |
|
60 | + $exercise_id = ''; |
|
61 | + if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) { |
|
62 | + $exercise_id = esc_html( $group['connected_exercises'] ); |
|
63 | + $content = get_post_field( 'post_content', $exercise_id ); |
|
64 | + $url = get_permalink( $exercise_id ); |
|
65 | + $equipment_group = get_the_term_list( $exercise_id, 'equipment', '', ', ' ); |
|
66 | + $muscle_group = get_the_term_list( $exercise_id, 'muscle-group', '', ', ' ); |
|
67 | + $lsx_hp = lsx_health_plan(); |
|
68 | 68 | |
69 | - if ( 'excerpt' === $args['modal_content'] ) { |
|
70 | - $content = wp_trim_words( $content, 40 ); |
|
71 | - } |
|
69 | + if ( 'excerpt' === $args['modal_content'] ) { |
|
70 | + $content = wp_trim_words( $content, 40 ); |
|
71 | + } |
|
72 | 72 | |
73 | - if ( 'link' ) { |
|
74 | - $play_button = '<a data-toggle="modal" href="#workout-alt-exercise-modal-' . $m . '">' . get_the_title( $exercise_id ) . '</a>'; |
|
75 | - } else { |
|
76 | - $play_button = '<button data-toggle="alt-modal" data-target="#workout-alt-exercise-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>'; |
|
77 | - } |
|
73 | + if ( 'link' ) { |
|
74 | + $play_button = '<a data-toggle="modal" href="#workout-alt-exercise-modal-' . $m . '">' . get_the_title( $exercise_id ) . '</a>'; |
|
75 | + } else { |
|
76 | + $play_button = '<button data-toggle="alt-modal" data-target="#workout-alt-exercise-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>'; |
|
77 | + } |
|
78 | 78 | |
79 | - $modal_body = ''; |
|
79 | + $modal_body = ''; |
|
80 | 80 | |
81 | - if ( '' !== $alt_image && ! empty( $alt_image ) ) { |
|
82 | - $modal_body .= '<div class="modal-image"/><img alt="thumbnail" loading="lazy" class="aligncenter wp-post-image" src="' . $alt_image . '"></div>'; |
|
83 | - } else { |
|
84 | - if ( $lsx_hp->frontend->gallery->has_gallery( $exercise_id ) ) { |
|
85 | - $gallery_args = array( |
|
86 | - 'css_class' => 'modal-slider', |
|
87 | - ); |
|
88 | - $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
89 | - } else { |
|
90 | - $modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail( $exercise_id, 'large' ) . '</div>'; |
|
91 | - } |
|
92 | - } |
|
81 | + if ( '' !== $alt_image && ! empty( $alt_image ) ) { |
|
82 | + $modal_body .= '<div class="modal-image"/><img alt="thumbnail" loading="lazy" class="aligncenter wp-post-image" src="' . $alt_image . '"></div>'; |
|
83 | + } else { |
|
84 | + if ( $lsx_hp->frontend->gallery->has_gallery( $exercise_id ) ) { |
|
85 | + $gallery_args = array( |
|
86 | + 'css_class' => 'modal-slider', |
|
87 | + ); |
|
88 | + $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
89 | + } else { |
|
90 | + $modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail( $exercise_id, 'large' ) . '</div>'; |
|
91 | + } |
|
92 | + } |
|
93 | 93 | |
94 | - if ( '' !== $alt_title ) { |
|
95 | - $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . $alt_title . '</h5>'; |
|
96 | - } else { |
|
97 | - $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . get_the_title( $exercise_id ) . '</h5>'; |
|
98 | - } |
|
94 | + if ( '' !== $alt_title ) { |
|
95 | + $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . $alt_title . '</h5>'; |
|
96 | + } else { |
|
97 | + $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . get_the_title( $exercise_id ) . '</h5>'; |
|
98 | + } |
|
99 | 99 | |
100 | - if ( ! empty( $equipment_group ) ) { |
|
101 | - $modal_body .= '<span class="equipment-terms">Equipment: ' . $equipment_group . '</span>'; |
|
102 | - } |
|
103 | - if ( ! empty( $muscle_group ) ) { |
|
104 | - $modal_body .= '<span class="muscle-terms">Muscle: ' . $muscle_group . '</span>'; |
|
105 | - } |
|
106 | - $modal_body .= '</div>'; |
|
107 | - if ( '' !== $args['modal_content'] ) { |
|
108 | - if ( '' !== $alt_description ) { |
|
109 | - $modal_body .= '<div class="modal-excerpt"/>' . $alt_description . '</div>'; |
|
110 | - } else { |
|
111 | - $modal_body .= '<div class="modal-excerpt"/>' . $content . '</div>'; |
|
112 | - } |
|
113 | - } |
|
114 | - if ( 'excerpt' === $args['modal_content'] ) { |
|
115 | - $modal_body .= '<a class="moretag" target="_blank" href="' . $url . '">' . __( 'Read More', 'lsx-heal-plan' ) . '</a>'; |
|
116 | - } |
|
117 | - \lsx_health_plan\functions\register_modal( 'workout-alt-exercise-modal-' . $m, '', $modal_body ); |
|
100 | + if ( ! empty( $equipment_group ) ) { |
|
101 | + $modal_body .= '<span class="equipment-terms">Equipment: ' . $equipment_group . '</span>'; |
|
102 | + } |
|
103 | + if ( ! empty( $muscle_group ) ) { |
|
104 | + $modal_body .= '<span class="muscle-terms">Muscle: ' . $muscle_group . '</span>'; |
|
105 | + } |
|
106 | + $modal_body .= '</div>'; |
|
107 | + if ( '' !== $args['modal_content'] ) { |
|
108 | + if ( '' !== $alt_description ) { |
|
109 | + $modal_body .= '<div class="modal-excerpt"/>' . $alt_description . '</div>'; |
|
110 | + } else { |
|
111 | + $modal_body .= '<div class="modal-excerpt"/>' . $content . '</div>'; |
|
112 | + } |
|
113 | + } |
|
114 | + if ( 'excerpt' === $args['modal_content'] ) { |
|
115 | + $modal_body .= '<a class="moretag" target="_blank" href="' . $url . '">' . __( 'Read More', 'lsx-heal-plan' ) . '</a>'; |
|
116 | + } |
|
117 | + \lsx_health_plan\functions\register_modal( 'workout-alt-exercise-modal-' . $m, '', $modal_body ); |
|
118 | 118 | |
119 | - if ( true === $echo ) { |
|
120 | - echo wp_kses_post( $play_button ); |
|
121 | - } else { |
|
122 | - return $play_button; |
|
123 | - } |
|
124 | - } |
|
119 | + if ( true === $echo ) { |
|
120 | + echo wp_kses_post( $play_button ); |
|
121 | + } else { |
|
122 | + return $play_button; |
|
123 | + } |
|
124 | + } |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -134,65 +134,65 @@ discard block |
||
134 | 134 | * @return void |
135 | 135 | */ |
136 | 136 | function lsx_health_plan_workout_exercise_button( $m, $group, $echo = true, $args = array() ) { |
137 | - $defaults = array( |
|
138 | - 'modal_trigger' => 'button', |
|
139 | - 'modal_content' => 'excerpt', |
|
140 | - ); |
|
141 | - $args = wp_parse_args( $args, $defaults ); |
|
137 | + $defaults = array( |
|
138 | + 'modal_trigger' => 'button', |
|
139 | + 'modal_content' => 'excerpt', |
|
140 | + ); |
|
141 | + $args = wp_parse_args( $args, $defaults ); |
|
142 | 142 | |
143 | - $exercise_id = ''; |
|
144 | - if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) { |
|
145 | - $exercise_id = esc_html( $group['connected_exercises'] ); |
|
146 | - $content = get_post_field( 'post_content', $exercise_id ); |
|
147 | - $url = get_permalink( $exercise_id ); |
|
148 | - $equipment_group = get_the_term_list( $exercise_id, 'equipment', '', ', ' ); |
|
149 | - $muscle_group = get_the_term_list( $exercise_id, 'muscle-group', '', ', ' ); |
|
150 | - $lsx_hp = lsx_health_plan(); |
|
143 | + $exercise_id = ''; |
|
144 | + if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) { |
|
145 | + $exercise_id = esc_html( $group['connected_exercises'] ); |
|
146 | + $content = get_post_field( 'post_content', $exercise_id ); |
|
147 | + $url = get_permalink( $exercise_id ); |
|
148 | + $equipment_group = get_the_term_list( $exercise_id, 'equipment', '', ', ' ); |
|
149 | + $muscle_group = get_the_term_list( $exercise_id, 'muscle-group', '', ', ' ); |
|
150 | + $lsx_hp = lsx_health_plan(); |
|
151 | 151 | |
152 | - if ( 'excerpt' === $args['modal_content'] ) { |
|
153 | - $content = wp_trim_words( $content, 40 ); |
|
154 | - } |
|
152 | + if ( 'excerpt' === $args['modal_content'] ) { |
|
153 | + $content = wp_trim_words( $content, 40 ); |
|
154 | + } |
|
155 | 155 | |
156 | - if ( 'link' ) { |
|
157 | - $play_button = '<a data-toggle="modal" href="#workout-exercise-modal-' . $m . '">' . get_the_title( $exercise_id ) . '</a>'; |
|
158 | - } else { |
|
159 | - $play_button = '<button data-toggle="modal" data-target="#workout-exercise-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>'; |
|
160 | - } |
|
156 | + if ( 'link' ) { |
|
157 | + $play_button = '<a data-toggle="modal" href="#workout-exercise-modal-' . $m . '">' . get_the_title( $exercise_id ) . '</a>'; |
|
158 | + } else { |
|
159 | + $play_button = '<button data-toggle="modal" data-target="#workout-exercise-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>'; |
|
160 | + } |
|
161 | 161 | |
162 | - $modal_body = ''; |
|
162 | + $modal_body = ''; |
|
163 | 163 | |
164 | - if ( $lsx_hp->frontend->gallery->has_gallery( $exercise_id ) ) { |
|
165 | - $gallery_args = array( |
|
166 | - 'css_class' => 'modal-slider', |
|
167 | - ); |
|
168 | - $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
169 | - } else { |
|
170 | - $modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail( $exercise_id, 'large' ) . '</div>'; |
|
171 | - } |
|
164 | + if ( $lsx_hp->frontend->gallery->has_gallery( $exercise_id ) ) { |
|
165 | + $gallery_args = array( |
|
166 | + 'css_class' => 'modal-slider', |
|
167 | + ); |
|
168 | + $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
169 | + } else { |
|
170 | + $modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail( $exercise_id, 'large' ) . '</div>'; |
|
171 | + } |
|
172 | 172 | |
173 | - $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . get_the_title( $exercise_id ) . '</h5>'; |
|
173 | + $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . get_the_title( $exercise_id ) . '</h5>'; |
|
174 | 174 | |
175 | - if ( ! empty( $equipment_group ) ) { |
|
176 | - $modal_body .= '<span class="equipment-terms">' . __( 'Equipment', 'lsx-health-plan' ) . ': ' . $equipment_group . '</span>'; |
|
177 | - } |
|
178 | - if ( ! empty( $muscle_group ) ) { |
|
179 | - $modal_body .= '<span class="muscle-terms">' . __( 'Muscle', 'lsx-health-plan' ) . ': ' . $muscle_group . '</span>'; |
|
180 | - } |
|
181 | - $modal_body .= '</div>'; |
|
182 | - if ( '' !== $args['modal_content'] ) { |
|
183 | - $modal_body .= '<div class="modal-excerpt"/>' . $content . '</div>'; |
|
184 | - } |
|
185 | - if ( 'excerpt' === $args['modal_content'] ) { |
|
186 | - $modal_body .= '<a class="moretag" target="_blank" href="' . $url . '">' . __( 'Read More', 'lsx-health-plan' ) . '</a>'; |
|
187 | - } |
|
188 | - \lsx_health_plan\functions\register_modal( 'workout-exercise-modal-' . $m, '', $modal_body ); |
|
175 | + if ( ! empty( $equipment_group ) ) { |
|
176 | + $modal_body .= '<span class="equipment-terms">' . __( 'Equipment', 'lsx-health-plan' ) . ': ' . $equipment_group . '</span>'; |
|
177 | + } |
|
178 | + if ( ! empty( $muscle_group ) ) { |
|
179 | + $modal_body .= '<span class="muscle-terms">' . __( 'Muscle', 'lsx-health-plan' ) . ': ' . $muscle_group . '</span>'; |
|
180 | + } |
|
181 | + $modal_body .= '</div>'; |
|
182 | + if ( '' !== $args['modal_content'] ) { |
|
183 | + $modal_body .= '<div class="modal-excerpt"/>' . $content . '</div>'; |
|
184 | + } |
|
185 | + if ( 'excerpt' === $args['modal_content'] ) { |
|
186 | + $modal_body .= '<a class="moretag" target="_blank" href="' . $url . '">' . __( 'Read More', 'lsx-health-plan' ) . '</a>'; |
|
187 | + } |
|
188 | + \lsx_health_plan\functions\register_modal( 'workout-exercise-modal-' . $m, '', $modal_body ); |
|
189 | 189 | |
190 | - if ( true === $echo ) { |
|
191 | - echo wp_kses_post( $play_button ); |
|
192 | - } else { |
|
193 | - return $play_button; |
|
194 | - } |
|
195 | - } |
|
190 | + if ( true === $echo ) { |
|
191 | + echo wp_kses_post( $play_button ); |
|
192 | + } else { |
|
193 | + return $play_button; |
|
194 | + } |
|
195 | + } |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -203,38 +203,38 @@ discard block |
||
203 | 203 | * @return void |
204 | 204 | */ |
205 | 205 | function lsx_health_plan_shortcode_exercise_button( $m, $content = true ) { |
206 | - $equipment_group = get_the_term_list( $m, 'equipment', '', ', ' ); |
|
207 | - $muscle_group = get_the_term_list( $m, 'muscle-group', '', ', ' ); |
|
208 | - $title = get_the_title(); |
|
209 | - $lsx_hp = lsx_health_plan(); |
|
210 | - $button = '<a data-toggle="modal" href="#exercise-modal-' . $m . '" data-target="#exercise-modal-' . $m . '"></a>'; |
|
206 | + $equipment_group = get_the_term_list( $m, 'equipment', '', ', ' ); |
|
207 | + $muscle_group = get_the_term_list( $m, 'muscle-group', '', ', ' ); |
|
208 | + $title = get_the_title(); |
|
209 | + $lsx_hp = lsx_health_plan(); |
|
210 | + $button = '<a data-toggle="modal" href="#exercise-modal-' . $m . '" data-target="#exercise-modal-' . $m . '"></a>'; |
|
211 | 211 | |
212 | - if ( true === $content ) { |
|
213 | - $content = get_the_content(); |
|
214 | - } |
|
212 | + if ( true === $content ) { |
|
213 | + $content = get_the_content(); |
|
214 | + } |
|
215 | 215 | |
216 | - $modal_body = ''; |
|
217 | - if ( $lsx_hp->frontend->gallery->has_gallery( $m ) ) { |
|
218 | - $gallery_args = array( |
|
219 | - 'css_class' => 'modal-slider', |
|
220 | - ); |
|
221 | - $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
222 | - } else { |
|
223 | - $modal_body .= '<div class="modal-image">' . get_the_post_thumbnail( $m, 'large' ) . '</div>'; |
|
224 | - } |
|
225 | - $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . $title . '</h5>'; |
|
216 | + $modal_body = ''; |
|
217 | + if ( $lsx_hp->frontend->gallery->has_gallery( $m ) ) { |
|
218 | + $gallery_args = array( |
|
219 | + 'css_class' => 'modal-slider', |
|
220 | + ); |
|
221 | + $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
222 | + } else { |
|
223 | + $modal_body .= '<div class="modal-image">' . get_the_post_thumbnail( $m, 'large' ) . '</div>'; |
|
224 | + } |
|
225 | + $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . $title . '</h5>'; |
|
226 | 226 | |
227 | - if ( ! empty( $equipment_group ) ) { |
|
228 | - $modal_body .= '<span class="equipment-terms">Equipment: ' . $equipment_group . '</span>'; |
|
229 | - } |
|
230 | - if ( ! empty( $muscle_group ) ) { |
|
231 | - $modal_body .= '<span class="muscle-terms">Muscle: ' . $muscle_group . '</span>'; |
|
232 | - } |
|
233 | - $modal_body .= '</div>'; |
|
234 | - $modal_body .= $content; |
|
235 | - \lsx_health_plan\functions\register_modal( 'exercise-modal-' . $m, '', $modal_body ); |
|
227 | + if ( ! empty( $equipment_group ) ) { |
|
228 | + $modal_body .= '<span class="equipment-terms">Equipment: ' . $equipment_group . '</span>'; |
|
229 | + } |
|
230 | + if ( ! empty( $muscle_group ) ) { |
|
231 | + $modal_body .= '<span class="muscle-terms">Muscle: ' . $muscle_group . '</span>'; |
|
232 | + } |
|
233 | + $modal_body .= '</div>'; |
|
234 | + $modal_body .= $content; |
|
235 | + \lsx_health_plan\functions\register_modal( 'exercise-modal-' . $m, '', $modal_body ); |
|
236 | 236 | |
237 | - return ( $button ); |
|
237 | + return ( $button ); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -246,25 +246,25 @@ discard block |
||
246 | 246 | * @return string |
247 | 247 | */ |
248 | 248 | function lsx_health_plan_exercise_title( $before = '', $after = '', $url = true, $echo = true, $exercise_id = false ) { |
249 | - if ( false === $exercise_id ) { |
|
250 | - $exercise_id = get_the_ID(); |
|
251 | - } |
|
252 | - $link = get_the_permalink( $exercise_id ); |
|
253 | - $title = get_the_title( $exercise_id ); |
|
254 | - $side = get_post_meta( $exercise_id, 'exercise_side', true ); |
|
255 | - if ( '' !== $side ) { |
|
256 | - $title .= ' - ' . ucwords( $side ); |
|
257 | - } |
|
258 | - $link_before = ''; |
|
259 | - $link_after = ''; |
|
260 | - if ( true === $url ) { |
|
261 | - $link_before = '<a href="' . $link . '">'; |
|
262 | - $link_after = '</a>'; |
|
263 | - } |
|
264 | - $title = apply_filters( 'lsx_health_plan_exercise_title', $before . $link_before . $title . $link_after . $after, $title, $before, $after, $exercise_id ); |
|
265 | - if ( true === $echo ) { |
|
266 | - echo wp_kses_post( $title ); |
|
267 | - } else { |
|
268 | - return $title; |
|
269 | - } |
|
249 | + if ( false === $exercise_id ) { |
|
250 | + $exercise_id = get_the_ID(); |
|
251 | + } |
|
252 | + $link = get_the_permalink( $exercise_id ); |
|
253 | + $title = get_the_title( $exercise_id ); |
|
254 | + $side = get_post_meta( $exercise_id, 'exercise_side', true ); |
|
255 | + if ( '' !== $side ) { |
|
256 | + $title .= ' - ' . ucwords( $side ); |
|
257 | + } |
|
258 | + $link_before = ''; |
|
259 | + $link_after = ''; |
|
260 | + if ( true === $url ) { |
|
261 | + $link_before = '<a href="' . $link . '">'; |
|
262 | + $link_after = '</a>'; |
|
263 | + } |
|
264 | + $title = apply_filters( 'lsx_health_plan_exercise_title', $before . $link_before . $title . $link_after . $after, $title, $before, $after, $exercise_id ); |
|
265 | + if ( true === $echo ) { |
|
266 | + echo wp_kses_post( $title ); |
|
267 | + } else { |
|
268 | + return $title; |
|
269 | + } |
|
270 | 270 | } |
@@ -8,138 +8,138 @@ |
||
8 | 8 | */ |
9 | 9 | class Plans { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\integrations\woocommerce\Plans() |
|
17 | - */ |
|
18 | - protected static $instance = null; |
|
11 | + /** |
|
12 | + * Holds class instance |
|
13 | + * |
|
14 | + * @since 1.0.0 |
|
15 | + * |
|
16 | + * @var object \lsx_health_plan\classes\integrations\woocommerce\Plans() |
|
17 | + */ |
|
18 | + protected static $instance = null; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Holds the current screen var if it is active. |
|
22 | - * |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - public $screen = ''; |
|
20 | + /** |
|
21 | + * Holds the current screen var if it is active. |
|
22 | + * |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + public $screen = ''; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Holds the current array of product IDS. |
|
29 | - * |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - public $product_ids = array(); |
|
27 | + /** |
|
28 | + * Holds the current array of product IDS. |
|
29 | + * |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + public $product_ids = array(); |
|
33 | 33 | |
34 | - /** |
|
35 | - * Holds the curret parent ID. |
|
36 | - * |
|
37 | - * @var int |
|
38 | - */ |
|
39 | - public $parent_id = 0; |
|
34 | + /** |
|
35 | + * Holds the curret parent ID. |
|
36 | + * |
|
37 | + * @var int |
|
38 | + */ |
|
39 | + public $parent_id = 0; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor |
|
43 | - */ |
|
44 | - public function __construct() { |
|
45 | - // Remove the default restrictions, as we will add our own. |
|
46 | - add_action( 'wp', array( $this, 'set_screen' ), 1 ); |
|
47 | - add_action( 'wp', array( $this, 'disable_parent_plan_restrictions' ), 2 ); |
|
48 | - add_action( 'wp', array( $this, 'child_plan_redirect_restrictions' ), 2 ); |
|
41 | + /** |
|
42 | + * Constructor |
|
43 | + */ |
|
44 | + public function __construct() { |
|
45 | + // Remove the default restrictions, as we will add our own. |
|
46 | + add_action( 'wp', array( $this, 'set_screen' ), 1 ); |
|
47 | + add_action( 'wp', array( $this, 'disable_parent_plan_restrictions' ), 2 ); |
|
48 | + add_action( 'wp', array( $this, 'child_plan_redirect_restrictions' ), 2 ); |
|
49 | 49 | |
50 | - // Initiate the WP Head functions. |
|
51 | - add_action( 'wp_head', array( $this, 'set_screen' ) ); |
|
52 | - add_action( 'lsx_content_top', 'lsx_hp_single_plan_products' ); |
|
50 | + // Initiate the WP Head functions. |
|
51 | + add_action( 'wp_head', array( $this, 'set_screen' ) ); |
|
52 | + add_action( 'lsx_content_top', 'lsx_hp_single_plan_products' ); |
|
53 | 53 | |
54 | - // Plan Archive Actions. |
|
55 | - add_action( 'lsx_entry_before', array( $this, 'set_product_ids' ) ); |
|
56 | - } |
|
54 | + // Plan Archive Actions. |
|
55 | + add_action( 'lsx_entry_before', array( $this, 'set_product_ids' ) ); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Return an instance of this class. |
|
60 | - * |
|
61 | - * @since 1.0.0 |
|
62 | - * |
|
63 | - * @return object \lsx_health_plan\classes\integrations\woocommerce\Plans() A single instance of this class. |
|
64 | - */ |
|
65 | - public static function get_instance() { |
|
66 | - // If the single instance hasn't been set, set it now. |
|
67 | - if ( null === self::$instance ) { |
|
68 | - self::$instance = new self(); |
|
69 | - } |
|
70 | - return self::$instance; |
|
71 | - } |
|
58 | + /** |
|
59 | + * Return an instance of this class. |
|
60 | + * |
|
61 | + * @since 1.0.0 |
|
62 | + * |
|
63 | + * @return object \lsx_health_plan\classes\integrations\woocommerce\Plans() A single instance of this class. |
|
64 | + */ |
|
65 | + public static function get_instance() { |
|
66 | + // If the single instance hasn't been set, set it now. |
|
67 | + if ( null === self::$instance ) { |
|
68 | + self::$instance = new self(); |
|
69 | + } |
|
70 | + return self::$instance; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Define the product metabox on the plan post type |
|
75 | - */ |
|
76 | - public function set_screen() { |
|
77 | - if ( is_singular( 'plan' ) ) { |
|
78 | - $section = get_query_var( 'section' ); |
|
79 | - if ( ! empty( $section ) ) { |
|
80 | - $this->screen = 'child_plan'; |
|
81 | - } else { |
|
82 | - $this->screen = 'parent_plan'; |
|
83 | - } |
|
84 | - $product_ids = get_post_meta( get_the_ID(), 'plan_product', true ); |
|
85 | - if ( false !== $product_ids && ! empty( $product_ids ) ) { |
|
86 | - $this->product_ids = $product_ids; |
|
87 | - } |
|
88 | - } |
|
89 | - if ( is_post_type_archive( 'plan' ) ) { |
|
90 | - $this->screen = 'plan_archive'; |
|
91 | - } |
|
92 | - } |
|
73 | + /** |
|
74 | + * Define the product metabox on the plan post type |
|
75 | + */ |
|
76 | + public function set_screen() { |
|
77 | + if ( is_singular( 'plan' ) ) { |
|
78 | + $section = get_query_var( 'section' ); |
|
79 | + if ( ! empty( $section ) ) { |
|
80 | + $this->screen = 'child_plan'; |
|
81 | + } else { |
|
82 | + $this->screen = 'parent_plan'; |
|
83 | + } |
|
84 | + $product_ids = get_post_meta( get_the_ID(), 'plan_product', true ); |
|
85 | + if ( false !== $product_ids && ! empty( $product_ids ) ) { |
|
86 | + $this->product_ids = $product_ids; |
|
87 | + } |
|
88 | + } |
|
89 | + if ( is_post_type_archive( 'plan' ) ) { |
|
90 | + $this->screen = 'plan_archive'; |
|
91 | + } |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Sets the post type archive product ids. |
|
96 | - * |
|
97 | - * @return void |
|
98 | - */ |
|
99 | - public function set_product_ids() { |
|
100 | - $this->product_ids = false; |
|
101 | - if ( 'plan' === get_post_type() ) { |
|
102 | - $product_ids = get_post_meta( get_the_ID(), 'plan_product', true ); |
|
103 | - if ( false !== $product_ids && ! empty( $product_ids ) ) { |
|
104 | - $this->product_ids = $product_ids; |
|
105 | - } |
|
106 | - } |
|
107 | - } |
|
94 | + /** |
|
95 | + * Sets the post type archive product ids. |
|
96 | + * |
|
97 | + * @return void |
|
98 | + */ |
|
99 | + public function set_product_ids() { |
|
100 | + $this->product_ids = false; |
|
101 | + if ( 'plan' === get_post_type() ) { |
|
102 | + $product_ids = get_post_meta( get_the_ID(), 'plan_product', true ); |
|
103 | + if ( false !== $product_ids && ! empty( $product_ids ) ) { |
|
104 | + $this->product_ids = $product_ids; |
|
105 | + } |
|
106 | + } |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Disable WC Memberships restrictions for plan parents. We add our own custom |
|
111 | - * restriction functionality elsewhere. |
|
112 | - */ |
|
113 | - public function disable_parent_plan_restrictions() { |
|
114 | - if ( '' === $this->screen || ! function_exists( 'wc_memberships' ) ) { |
|
115 | - return; |
|
116 | - } |
|
109 | + /** |
|
110 | + * Disable WC Memberships restrictions for plan parents. We add our own custom |
|
111 | + * restriction functionality elsewhere. |
|
112 | + */ |
|
113 | + public function disable_parent_plan_restrictions() { |
|
114 | + if ( '' === $this->screen || ! function_exists( 'wc_memberships' ) ) { |
|
115 | + return; |
|
116 | + } |
|
117 | 117 | |
118 | - $restrictions = wc_memberships()->get_restrictions_instance()->get_posts_restrictions_instance(); |
|
119 | - remove_action( 'wp', array( $restrictions, 'handle_restriction_modes' ) ); |
|
120 | - } |
|
118 | + $restrictions = wc_memberships()->get_restrictions_instance()->get_posts_restrictions_instance(); |
|
119 | + remove_action( 'wp', array( $restrictions, 'handle_restriction_modes' ) ); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Disable WC Memberships restrictions for plan parents. We add our own custom |
|
124 | - * restriction functionality elsewhere. |
|
125 | - */ |
|
126 | - public function child_plan_redirect_restrictions() { |
|
127 | - if ( ! function_exists( 'wc_memberships' ) || ! is_singular( 'plan' ) || 'child_plan' !== $this->screen || ! function_exists( 'wc_memberships_is_post_content_restricted' ) ) { |
|
128 | - return; |
|
129 | - } |
|
130 | - $restricted = wc_memberships_is_post_content_restricted() && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() ); |
|
131 | - if ( true === $restricted ) { |
|
132 | - wp_redirect( get_permalink( get_the_ID() ) ); |
|
133 | - exit; |
|
134 | - } |
|
135 | - } |
|
122 | + /** |
|
123 | + * Disable WC Memberships restrictions for plan parents. We add our own custom |
|
124 | + * restriction functionality elsewhere. |
|
125 | + */ |
|
126 | + public function child_plan_redirect_restrictions() { |
|
127 | + if ( ! function_exists( 'wc_memberships' ) || ! is_singular( 'plan' ) || 'child_plan' !== $this->screen || ! function_exists( 'wc_memberships_is_post_content_restricted' ) ) { |
|
128 | + return; |
|
129 | + } |
|
130 | + $restricted = wc_memberships_is_post_content_restricted() && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() ); |
|
131 | + if ( true === $restricted ) { |
|
132 | + wp_redirect( get_permalink( get_the_ID() ) ); |
|
133 | + exit; |
|
134 | + } |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Returns the ids of the attached products. |
|
139 | - * |
|
140 | - * @return array |
|
141 | - */ |
|
142 | - public function get_products() { |
|
143 | - return $this->product_ids; |
|
144 | - } |
|
137 | + /** |
|
138 | + * Returns the ids of the attached products. |
|
139 | + * |
|
140 | + * @return array |
|
141 | + */ |
|
142 | + public function get_products() { |
|
143 | + return $this->product_ids; |
|
144 | + } |
|
145 | 145 | } |
@@ -8,263 +8,263 @@ |
||
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 | - * Constructor |
|
69 | - */ |
|
70 | - public function __construct() { |
|
71 | - } |
|
67 | + /** |
|
68 | + * Constructor |
|
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 | - if ( '' === $item_id ) { |
|
97 | - $this->item_id = get_the_ID(); |
|
98 | - } else { |
|
99 | - $this->item_id = $item_id; |
|
100 | - } |
|
101 | - $this->has_gallery = false; |
|
102 | - if ( '' === $post_type ) { |
|
103 | - $this->post_type = get_post_type( $this->item_id ); |
|
104 | - } |
|
105 | - $gallery = get_post_meta( $this->item_id, $this->post_type . '_gallery', true ); |
|
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 | + if ( '' === $item_id ) { |
|
97 | + $this->item_id = get_the_ID(); |
|
98 | + } else { |
|
99 | + $this->item_id = $item_id; |
|
100 | + } |
|
101 | + $this->has_gallery = false; |
|
102 | + if ( '' === $post_type ) { |
|
103 | + $this->post_type = get_post_type( $this->item_id ); |
|
104 | + } |
|
105 | + $gallery = get_post_meta( $this->item_id, $this->post_type . '_gallery', true ); |
|
106 | 106 | |
107 | - if ( ! empty( $gallery ) && ( '' !== $gallery ) ) { |
|
108 | - $this->gallery = $gallery; |
|
109 | - $this->has_gallery = true; |
|
110 | - wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/src/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true ); |
|
111 | - 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 ); |
|
112 | - } |
|
113 | - return $this->has_gallery; |
|
114 | - } |
|
107 | + if ( ! empty( $gallery ) && ( '' !== $gallery ) ) { |
|
108 | + $this->gallery = $gallery; |
|
109 | + $this->has_gallery = true; |
|
110 | + wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/src/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true ); |
|
111 | + 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 ); |
|
112 | + } |
|
113 | + return $this->has_gallery; |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Returns the defaults for the gallery, after grabbing the setting from the item. |
|
118 | - * |
|
119 | - * @param string $item_id |
|
120 | - * @param string $post_type |
|
121 | - * @return array |
|
122 | - */ |
|
123 | - public function get_defaults( $item_id = '', $post_type = '' ) { |
|
124 | - if ( '' === $item_id ) { |
|
125 | - $item_id = $this->item_id; |
|
126 | - } |
|
127 | - if ( '' === $post_type ) { |
|
128 | - $post_type = $this->post_type; |
|
129 | - } |
|
130 | - $this->defaults = array( |
|
131 | - 'columns' => '3', |
|
132 | - 'layout' => 'slider', |
|
133 | - 'interval' => false, |
|
134 | - 'css_class' => false, |
|
135 | - ); |
|
136 | - foreach ( $this->defaults as $key => $default ) { |
|
137 | - $override = get_post_meta( $item_id, $this->post_type . '_gallery_' . $key, true ); |
|
138 | - if ( '' !== $override && false !== $override && ! empty( $override ) ) { |
|
139 | - $this->defaults[ $key ] = $override; |
|
140 | - } |
|
141 | - } |
|
142 | - return $this->defaults; |
|
143 | - } |
|
116 | + /** |
|
117 | + * Returns the defaults for the gallery, after grabbing the setting from the item. |
|
118 | + * |
|
119 | + * @param string $item_id |
|
120 | + * @param string $post_type |
|
121 | + * @return array |
|
122 | + */ |
|
123 | + public function get_defaults( $item_id = '', $post_type = '' ) { |
|
124 | + if ( '' === $item_id ) { |
|
125 | + $item_id = $this->item_id; |
|
126 | + } |
|
127 | + if ( '' === $post_type ) { |
|
128 | + $post_type = $this->post_type; |
|
129 | + } |
|
130 | + $this->defaults = array( |
|
131 | + 'columns' => '3', |
|
132 | + 'layout' => 'slider', |
|
133 | + 'interval' => false, |
|
134 | + 'css_class' => false, |
|
135 | + ); |
|
136 | + foreach ( $this->defaults as $key => $default ) { |
|
137 | + $override = get_post_meta( $item_id, $this->post_type . '_gallery_' . $key, true ); |
|
138 | + if ( '' !== $override && false !== $override && ! empty( $override ) ) { |
|
139 | + $this->defaults[ $key ] = $override; |
|
140 | + } |
|
141 | + } |
|
142 | + return $this->defaults; |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Gets and returns the gallery html. |
|
147 | - * |
|
148 | - * @param string $item_id |
|
149 | - * @param string $post_type |
|
150 | - * @return void |
|
151 | - */ |
|
152 | - public function get_gallery( $item_id = '', $post_type = '', $args = array() ) { |
|
153 | - $return = ''; |
|
154 | - $this->html = array(); |
|
155 | - $this->args = wp_parse_args( $args, $this->get_defaults( $item_id, $post_type ) ); |
|
156 | - if ( ! empty( $this->gallery ) ) { |
|
157 | - $this->args['count'] = 1; |
|
158 | - if ( '' !== $post_type ) { |
|
159 | - $this->args['post_type'] = $post_type; |
|
160 | - } else { |
|
161 | - $this->args['post_type'] = $this->post_type; |
|
162 | - } |
|
145 | + /** |
|
146 | + * Gets and returns the gallery html. |
|
147 | + * |
|
148 | + * @param string $item_id |
|
149 | + * @param string $post_type |
|
150 | + * @return void |
|
151 | + */ |
|
152 | + public function get_gallery( $item_id = '', $post_type = '', $args = array() ) { |
|
153 | + $return = ''; |
|
154 | + $this->html = array(); |
|
155 | + $this->args = wp_parse_args( $args, $this->get_defaults( $item_id, $post_type ) ); |
|
156 | + if ( ! empty( $this->gallery ) ) { |
|
157 | + $this->args['count'] = 1; |
|
158 | + if ( '' !== $post_type ) { |
|
159 | + $this->args['post_type'] = $post_type; |
|
160 | + } else { |
|
161 | + $this->args['post_type'] = $this->post_type; |
|
162 | + } |
|
163 | 163 | |
164 | - // output the opening boostrap row divs. |
|
165 | - $this->before_loop(); |
|
164 | + // output the opening boostrap row divs. |
|
165 | + $this->before_loop(); |
|
166 | 166 | |
167 | - foreach ( $this->gallery as $key => $gallery ) { |
|
167 | + foreach ( $this->gallery as $key => $gallery ) { |
|
168 | 168 | |
169 | - $this->loop_start(); |
|
169 | + $this->loop_start(); |
|
170 | 170 | |
171 | - if ( isset( $gallery['exercise_gallery_image_id'] ) && ! empty( $gallery['exercise_gallery_image_id'] ) ) { |
|
172 | - $size = apply_filters( 'lsx_hp_exercise_gallery_size', 'full' ); |
|
173 | - $thumbnail = wp_get_attachment_image( $gallery['exercise_gallery_image_id'], $size ); |
|
174 | - $this->html[] = $thumbnail; |
|
175 | - } elseif ( isset( $gallery['exercise_gallery_external'] ) && ! empty( $gallery['exercise_gallery_external'] ) ) { |
|
176 | - $this->html[] = $gallery['exercise_gallery_external']; // WPCS: XSS OK. |
|
177 | - } elseif ( isset( $gallery['exercise_gallery_embed'] ) && ! empty( $gallery['exercise_gallery_embed'] ) ) { |
|
178 | - $embed_args = array( |
|
179 | - 'width' => '530', |
|
180 | - ); |
|
181 | - $embed = wp_oembed_get( $gallery['exercise_gallery_embed'], $embed_args ); |
|
182 | - $this->html[] = str_replace( 'width="530"', 'width="100%"', $embed ); // WPCS: XSS OK. |
|
183 | - } |
|
171 | + if ( isset( $gallery['exercise_gallery_image_id'] ) && ! empty( $gallery['exercise_gallery_image_id'] ) ) { |
|
172 | + $size = apply_filters( 'lsx_hp_exercise_gallery_size', 'full' ); |
|
173 | + $thumbnail = wp_get_attachment_image( $gallery['exercise_gallery_image_id'], $size ); |
|
174 | + $this->html[] = $thumbnail; |
|
175 | + } elseif ( isset( $gallery['exercise_gallery_external'] ) && ! empty( $gallery['exercise_gallery_external'] ) ) { |
|
176 | + $this->html[] = $gallery['exercise_gallery_external']; // WPCS: XSS OK. |
|
177 | + } elseif ( isset( $gallery['exercise_gallery_embed'] ) && ! empty( $gallery['exercise_gallery_embed'] ) ) { |
|
178 | + $embed_args = array( |
|
179 | + 'width' => '530', |
|
180 | + ); |
|
181 | + $embed = wp_oembed_get( $gallery['exercise_gallery_embed'], $embed_args ); |
|
182 | + $this->html[] = str_replace( 'width="530"', 'width="100%"', $embed ); // WPCS: XSS OK. |
|
183 | + } |
|
184 | 184 | |
185 | - $this->loop_end(); |
|
185 | + $this->loop_end(); |
|
186 | 186 | |
187 | - $this->args['count']++; |
|
188 | - } |
|
187 | + $this->args['count']++; |
|
188 | + } |
|
189 | 189 | |
190 | - // output the closing boostrap row divs. |
|
191 | - $this->after_loop(); |
|
192 | - } |
|
190 | + // output the closing boostrap row divs. |
|
191 | + $this->after_loop(); |
|
192 | + } |
|
193 | 193 | |
194 | - // Join the html output if its not empty. |
|
195 | - if ( ! empty( $this->html ) ) { |
|
196 | - $return = implode( '', $this->html ); |
|
197 | - } |
|
198 | - return $return; |
|
199 | - } |
|
194 | + // Join the html output if its not empty. |
|
195 | + if ( ! empty( $this->html ) ) { |
|
196 | + $return = implode( '', $this->html ); |
|
197 | + } |
|
198 | + return $return; |
|
199 | + } |
|
200 | 200 | |
201 | - /** |
|
202 | - * Outputs the CSS class for the panels |
|
203 | - * |
|
204 | - * @param string $columns |
|
205 | - * @return string |
|
206 | - */ |
|
207 | - public function column_class() { |
|
208 | - $cols = 'col-xs-12 col-sm-'; |
|
209 | - $cols .= '5' === $this->args['columns'] ? '15' : 12 / $this->args['columns']; |
|
210 | - return $cols; |
|
211 | - } |
|
201 | + /** |
|
202 | + * Outputs the CSS class for the panels |
|
203 | + * |
|
204 | + * @param string $columns |
|
205 | + * @return string |
|
206 | + */ |
|
207 | + public function column_class() { |
|
208 | + $cols = 'col-xs-12 col-sm-'; |
|
209 | + $cols .= '5' === $this->args['columns'] ? '15' : 12 / $this->args['columns']; |
|
210 | + return $cols; |
|
211 | + } |
|
212 | 212 | |
213 | - /** |
|
214 | - * Runs just after the if and before the while statement in $this->output() |
|
215 | - */ |
|
216 | - public function before_loop() { |
|
217 | - if ( 'slider' === $this->args['layout'] ) { |
|
218 | - $this->carousel_id = wp_rand( 20, 20000 ); |
|
219 | - $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\": 1, \"slidesToScroll\": 1'>"; |
|
220 | - } else { |
|
221 | - $this->html[] = "<div class='lsx-hp-widget-items widget-item-grid-layout'>"; |
|
222 | - } |
|
223 | - } |
|
213 | + /** |
|
214 | + * Runs just after the if and before the while statement in $this->output() |
|
215 | + */ |
|
216 | + public function before_loop() { |
|
217 | + if ( 'slider' === $this->args['layout'] ) { |
|
218 | + $this->carousel_id = wp_rand( 20, 20000 ); |
|
219 | + $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\": 1, \"slidesToScroll\": 1'>"; |
|
220 | + } else { |
|
221 | + $this->html[] = "<div class='lsx-hp-widget-items widget-item-grid-layout'>"; |
|
222 | + } |
|
223 | + } |
|
224 | 224 | |
225 | - /** |
|
226 | - * Runs at the very end of the loop before it runs again. |
|
227 | - */ |
|
228 | - public function loop_start() { |
|
229 | - // Get the call for the active slide. |
|
230 | - if ( 'slider' === $this->args['layout'] ) { |
|
231 | - $this->html[] = "<div class='lsx-hp-widget-item-wrap lsx-{$this->args['post_type']}'>"; |
|
232 | - } else { |
|
233 | - if ( 1 === $this->args['count'] ) { |
|
234 | - $this->html[] = "<div class='row'>"; |
|
235 | - } |
|
236 | - $this->html[] = '<div class="' . $this->column_class() . '">'; |
|
237 | - } |
|
238 | - } |
|
225 | + /** |
|
226 | + * Runs at the very end of the loop before it runs again. |
|
227 | + */ |
|
228 | + public function loop_start() { |
|
229 | + // Get the call for the active slide. |
|
230 | + if ( 'slider' === $this->args['layout'] ) { |
|
231 | + $this->html[] = "<div class='lsx-hp-widget-item-wrap lsx-{$this->args['post_type']}'>"; |
|
232 | + } else { |
|
233 | + if ( 1 === $this->args['count'] ) { |
|
234 | + $this->html[] = "<div class='row'>"; |
|
235 | + } |
|
236 | + $this->html[] = '<div class="' . $this->column_class() . '">'; |
|
237 | + } |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
241 | - * Runs at the very end of the loop before it runs again. |
|
242 | - */ |
|
243 | - public function loop_end() { |
|
244 | - if ( 'slider' !== $this->args['layout'] ) { |
|
245 | - $this->html[] = '</div>'; |
|
246 | - } |
|
247 | - // Close the current slide panel. |
|
248 | - if ( 'slider' === $this->args['layout'] ) { |
|
249 | - $this->html[] = '</div>'; |
|
250 | - } elseif ( 0 === $this->args['count'] % $this->args['columns'] || count( $this->gallery ) === $this->args['count'] ) { |
|
251 | - $this->html[] = '</div>'; |
|
240 | + /** |
|
241 | + * Runs at the very end of the loop before it runs again. |
|
242 | + */ |
|
243 | + public function loop_end() { |
|
244 | + if ( 'slider' !== $this->args['layout'] ) { |
|
245 | + $this->html[] = '</div>'; |
|
246 | + } |
|
247 | + // Close the current slide panel. |
|
248 | + if ( 'slider' === $this->args['layout'] ) { |
|
249 | + $this->html[] = '</div>'; |
|
250 | + } elseif ( 0 === $this->args['count'] % $this->args['columns'] || count( $this->gallery ) === $this->args['count'] ) { |
|
251 | + $this->html[] = '</div>'; |
|
252 | 252 | |
253 | - if ( $this->args['count'] < count( $this->gallery ) ) { |
|
254 | - $this->html[] = "<div class='row'>"; |
|
255 | - } |
|
256 | - } |
|
257 | - } |
|
253 | + if ( $this->args['count'] < count( $this->gallery ) ) { |
|
254 | + $this->html[] = "<div class='row'>"; |
|
255 | + } |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - /** |
|
260 | - * Runs just after the if and before the while statement in $this->output() |
|
261 | - */ |
|
262 | - public function after_loop() { |
|
263 | - // Slider output Closing. |
|
264 | - if ( 'slider' === $this->args['layout'] ) { |
|
265 | - $this->html[] = '</div>'; |
|
266 | - } else { |
|
267 | - $this->html[] = '</div>'; |
|
268 | - } |
|
269 | - } |
|
259 | + /** |
|
260 | + * Runs just after the if and before the while statement in $this->output() |
|
261 | + */ |
|
262 | + public function after_loop() { |
|
263 | + // Slider output Closing. |
|
264 | + if ( 'slider' === $this->args['layout'] ) { |
|
265 | + $this->html[] = '</div>'; |
|
266 | + } else { |
|
267 | + $this->html[] = '</div>'; |
|
268 | + } |
|
269 | + } |
|
270 | 270 | } |
@@ -8,432 +8,432 @@ |
||
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 | - * Constructor |
|
31 | - */ |
|
32 | - public function __construct() { |
|
33 | - |
|
34 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
35 | - // Post Type and Taxonomies. |
|
36 | - add_action( 'init', array( $this, 'register_post_type' ) ); |
|
37 | - add_action( 'init', array( $this, 'exercise_type_taxonomy_setup' ) ); |
|
38 | - add_action( 'init', array( $this, 'equipment_taxonomy_setup' ) ); |
|
39 | - add_action( 'init', array( $this, 'muscle_group_taxonomy_setup' ) ); |
|
40 | - add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
41 | - |
|
42 | - // Custom Fields. |
|
43 | - add_action( 'cmb2_admin_init', array( $this, 'exercise_details' ), 8 ); |
|
44 | - add_action( 'cmb2_admin_init', array( $this, 'gallery_metabox' ), 9 ); |
|
45 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
46 | - |
|
47 | - // Template Redirects. |
|
48 | - add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
49 | - add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
50 | - |
|
51 | - //Breadcrumbs |
|
52 | - add_filter( 'woocommerce_get_breadcrumb', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 ); |
|
53 | - |
|
54 | - } |
|
55 | - |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * Return an instance of this class. |
|
61 | - * |
|
62 | - * @since 1.0.0 |
|
63 | - * |
|
64 | - * @return object \lsx_health_plan\classes\Exercise() A single instance of this class. |
|
65 | - */ |
|
66 | - public static function get_instance() { |
|
67 | - // If the single instance hasn't been set, set it now. |
|
68 | - if ( null === self::$instance ) { |
|
69 | - self::$instance = new self(); |
|
70 | - } |
|
71 | - return self::$instance; |
|
72 | - } |
|
73 | - /** |
|
74 | - * Register the post type. |
|
75 | - */ |
|
76 | - public function register_post_type() { |
|
77 | - $labels = array( |
|
78 | - 'name' => esc_html__( 'Exercises', 'lsx-health-plan' ), |
|
79 | - 'singular_name' => esc_html__( 'Exercise', 'lsx-health-plan' ), |
|
80 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
81 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
82 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
83 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
84 | - 'all_items' => esc_html__( 'All Exercises', 'lsx-health-plan' ), |
|
85 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
86 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
87 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
88 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
89 | - 'parent_item_colon' => '', |
|
90 | - 'menu_name' => esc_html__( 'Exercises', 'lsx-health-plan' ), |
|
91 | - ); |
|
92 | - $args = array( |
|
93 | - 'labels' => $labels, |
|
94 | - 'public' => true, |
|
95 | - 'publicly_queryable' => true, |
|
96 | - 'show_ui' => true, |
|
97 | - 'show_in_menu' => 'edit.php?post_type=workout-pseudo', |
|
98 | - 'show_in_rest' => true, |
|
99 | - 'menu_icon' => 'dashicons-universal-access', |
|
100 | - 'query_var' => true, |
|
101 | - 'rewrite' => array( |
|
102 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ), |
|
103 | - ), |
|
104 | - 'capability_type' => 'page', |
|
105 | - 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercises' ), |
|
106 | - 'hierarchical' => false, |
|
107 | - 'menu_position' => null, |
|
108 | - 'supports' => array( |
|
109 | - 'title', |
|
110 | - 'thumbnail', |
|
111 | - 'editor', |
|
112 | - 'excerpt', |
|
113 | - 'custom-fields', |
|
114 | - ), |
|
115 | - ); |
|
116 | - register_post_type( 'exercise', $args ); |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Register the Exercise taxonomy. |
|
121 | - * |
|
122 | - * @return void |
|
123 | - */ |
|
124 | - public function exercise_type_taxonomy_setup() { |
|
125 | - $labels = array( |
|
126 | - 'name' => esc_html_x( 'Exercise Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
127 | - 'singular_name' => esc_html_x( 'Exercise Type', 'taxonomy singular name', 'lsx-health-plan' ), |
|
128 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
129 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
130 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
131 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
132 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
133 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
134 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
135 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
136 | - 'menu_name' => esc_html__( 'Exercise Types', 'lsx-health-plan' ), |
|
137 | - ); |
|
138 | - |
|
139 | - $args = array( |
|
140 | - 'hierarchical' => true, |
|
141 | - 'labels' => $labels, |
|
142 | - 'show_ui' => true, |
|
143 | - 'show_admin_column' => true, |
|
144 | - 'query_var' => true, |
|
145 | - 'rewrite' => array( |
|
146 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_type', 'exercise-type' ), |
|
147 | - ), |
|
148 | - 'show_in_rest' => true, |
|
149 | - ); |
|
150 | - |
|
151 | - register_taxonomy( 'exercise-type', array( 'exercise' ), $args ); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Register the Exercise taxonomy. |
|
156 | - * |
|
157 | - * @return void |
|
158 | - */ |
|
159 | - public function equipment_taxonomy_setup() { |
|
160 | - $labels = array( |
|
161 | - 'name' => esc_html_x( 'Equipment', 'taxonomy general name', 'lsx-health-plan' ), |
|
162 | - 'singular_name' => esc_html_x( 'Equipment', 'taxonomy singular name', 'lsx-health-plan' ), |
|
163 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
164 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
165 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
166 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
167 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
168 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
169 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
170 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
171 | - 'menu_name' => esc_html__( 'Equipment', 'lsx-health-plan' ), |
|
172 | - ); |
|
173 | - |
|
174 | - $args = array( |
|
175 | - 'hierarchical' => true, |
|
176 | - 'labels' => $labels, |
|
177 | - 'show_ui' => true, |
|
178 | - 'show_admin_column' => true, |
|
179 | - 'query_var' => true, |
|
180 | - 'rewrite' => array( |
|
181 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_equipment', 'equipment' ), |
|
182 | - ), |
|
183 | - 'show_in_rest' => true, |
|
184 | - ); |
|
185 | - |
|
186 | - register_taxonomy( 'equipment', array( 'exercise' ), $args ); |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Register the Muscle Group taxonomy. |
|
191 | - * |
|
192 | - * @return void |
|
193 | - */ |
|
194 | - public function muscle_group_taxonomy_setup() { |
|
195 | - $labels = array( |
|
196 | - 'name' => esc_html_x( 'Muscle Groups', 'taxonomy general name', 'lsx-health-plan' ), |
|
197 | - 'singular_name' => esc_html_x( 'Muscle Group', 'taxonomy singular name', 'lsx-health-plan' ), |
|
198 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
199 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
200 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
201 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
202 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
203 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
204 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
205 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
206 | - 'menu_name' => esc_html__( 'Muscle Groups', 'lsx-health-plan' ), |
|
207 | - ); |
|
208 | - |
|
209 | - $args = array( |
|
210 | - 'hierarchical' => true, |
|
211 | - 'labels' => $labels, |
|
212 | - 'show_ui' => true, |
|
213 | - 'show_admin_column' => true, |
|
214 | - 'query_var' => true, |
|
215 | - 'rewrite' => array( |
|
216 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_musclegroup', 'muscle-group' ), |
|
217 | - ), |
|
218 | - 'show_in_rest' => true, |
|
219 | - ); |
|
220 | - |
|
221 | - register_taxonomy( 'muscle-group', array( 'exercise' ), $args ); |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * Registers the Recipes under the Meals Post type menu. |
|
226 | - * |
|
227 | - * @return void |
|
228 | - */ |
|
229 | - public function register_menus() { |
|
230 | - 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' ); |
|
231 | - 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' ); |
|
232 | - 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' ); |
|
233 | - 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' ); |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * Adds the post type to the different arrays. |
|
238 | - * |
|
239 | - * @param array $post_types |
|
240 | - * @return array |
|
241 | - */ |
|
242 | - public function enable_post_type( $post_types = array() ) { |
|
243 | - $post_types[] = $this->slug; |
|
244 | - return $post_types; |
|
245 | - } |
|
246 | - |
|
247 | - /** |
|
248 | - * Enables the Bi Directional relationships |
|
249 | - * |
|
250 | - * @param array $connections |
|
251 | - * @return void |
|
252 | - */ |
|
253 | - public function enable_connections( $connections = array() ) { |
|
254 | - $connections['exercise']['connected_workouts'] = 'connected_exercises'; |
|
255 | - $connections['workout']['connected_exercises'] = 'connected_workouts'; |
|
256 | - return $connections; |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Define the metabox and field configurations. |
|
261 | - */ |
|
262 | - public function gallery_metabox() { |
|
263 | - $cmb = new_cmb2_box( |
|
264 | - array( |
|
265 | - 'id' => $this->slug . '_gallery_details_metabox', |
|
266 | - 'title' => __( 'Exercise Gallery', 'lsx-health-plan' ), |
|
267 | - 'object_types' => array( $this->slug ), |
|
268 | - 'context' => 'normal', |
|
269 | - 'priority' => 'low', |
|
270 | - 'show_names' => true, |
|
271 | - ) |
|
272 | - ); |
|
273 | - |
|
274 | - $cmb->add_field( |
|
275 | - array( |
|
276 | - 'name' => __( 'Layout', 'lsx-health-plan' ), |
|
277 | - 'id' => $this->slug . '_gallery_layout', |
|
278 | - 'type' => 'radio', |
|
279 | - 'options' => array( |
|
280 | - 'slider' => __( 'Slider', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number |
|
281 | - 'grid' => __( 'Grid', 'lsx-health-plan' ), |
|
282 | - ), |
|
283 | - 'default' => 'grid', |
|
284 | - ) |
|
285 | - ); |
|
286 | - |
|
287 | - $cmb->add_field( |
|
288 | - array( |
|
289 | - 'name' => __( 'Grid Columns', 'lsx-health-plan' ), |
|
290 | - 'id' => $this->slug . '_gallery_columns', |
|
291 | - 'type' => 'select', |
|
292 | - 'options' => array( |
|
293 | - '3' => __( '2 Columns', 'lsx-health-plan' ), |
|
294 | - '4' => __( '3 Columns', 'lsx-health-plan' ), |
|
295 | - ), |
|
296 | - 'default' => '1', |
|
297 | - ) |
|
298 | - ); |
|
299 | - |
|
300 | - // Repeatable group. |
|
301 | - $gallery_group = $cmb->add_field( |
|
302 | - array( |
|
303 | - 'id' => $this->slug . '_gallery', |
|
304 | - 'type' => 'group', |
|
305 | - 'options' => array( |
|
306 | - 'group_title' => __( 'Gallery', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number |
|
307 | - 'add_button' => __( 'Add Item', 'lsx-health-plan' ), |
|
308 | - 'remove_button' => __( 'Remove Item', 'lsx-health-plan' ), |
|
309 | - 'sortable' => true, |
|
310 | - ), |
|
311 | - 'desc' => __( 'Upload only one image, video or gif per gallery group, each group will only display 1 item.', 'lsx-health-plan' ), |
|
312 | - 'classes' => 'lsx-admin-row', |
|
313 | - ) |
|
314 | - ); |
|
315 | - |
|
316 | - // Title. |
|
317 | - $cmb->add_group_field( |
|
318 | - $gallery_group, |
|
319 | - array( |
|
320 | - 'name' => __( 'Image', 'lsx-health-plan' ), |
|
321 | - 'id' => $this->slug . '_gallery_image', |
|
322 | - 'type' => 'file', |
|
323 | - 'text' => array( |
|
324 | - 'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ), |
|
325 | - ), |
|
326 | - 'desc' => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ), |
|
327 | - 'query_args' => array( |
|
328 | - 'type' => array( |
|
329 | - 'image/gif', |
|
330 | - 'image/jpeg', |
|
331 | - 'image/png', |
|
332 | - ), |
|
333 | - ), |
|
334 | - 'preview_size' => 'lsx-thumbnail-wide', |
|
335 | - 'classes' => 'lsx-field-col lsx-field-col-80', |
|
336 | - ) |
|
337 | - ); |
|
338 | - |
|
339 | - // Title. |
|
340 | - $cmb->add_group_field( |
|
341 | - $gallery_group, |
|
342 | - array( |
|
343 | - 'name' => __( 'oEmbed', 'lsx-health-plan' ), |
|
344 | - 'id' => $this->slug . '_gallery_embed', |
|
345 | - 'type' => 'text', |
|
346 | - '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' ), |
|
347 | - 'classes' => 'test-apply-form lsx-field-col lsx-field-col-50', |
|
348 | - ) |
|
349 | - ); |
|
350 | - |
|
351 | - $cmb->add_group_field( |
|
352 | - $gallery_group, |
|
353 | - array( |
|
354 | - 'name' => __( 'External Media', 'lsx-health-plan' ), |
|
355 | - 'id' => $this->slug . '_gallery_external', |
|
356 | - 'type' => 'textarea_code', |
|
357 | - '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' ), |
|
358 | - 'classes' => 'lsx-field-col lsx-field-col-50', |
|
359 | - ) |
|
360 | - ); |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * Registers the general settings for the exercise. |
|
365 | - * |
|
366 | - * @return void |
|
367 | - */ |
|
368 | - public function exercise_details() { |
|
369 | - $cmb = new_cmb2_box( |
|
370 | - array( |
|
371 | - 'id' => $this->slug . '_general_details_metabox', |
|
372 | - 'title' => __( 'Details', 'lsx-health-plan' ), |
|
373 | - 'object_types' => array( $this->slug ), |
|
374 | - 'context' => 'normal', |
|
375 | - 'priority' => 'high', |
|
376 | - 'show_names' => true, |
|
377 | - ) |
|
378 | - ); |
|
379 | - |
|
380 | - $cmb->add_field( |
|
381 | - array( |
|
382 | - 'name' => __( 'Side', 'lsx-health-plan' ), |
|
383 | - 'id' => $this->slug . '_side', |
|
384 | - 'type' => 'select', |
|
385 | - 'options' => array( |
|
386 | - '' => __( 'Select', 'lsx-health-plan' ), |
|
387 | - 'left' => __( 'Left', 'lsx-health-plan' ), |
|
388 | - 'right' => __( 'Right', 'lsx-health-plan' ), |
|
389 | - ), |
|
390 | - 'desc' => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ), |
|
391 | - ) |
|
392 | - ); |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * Holds the array for the single exercise breadcrumbs. |
|
397 | - * |
|
398 | - * @var array $crumbs |
|
399 | - * @return array |
|
400 | - */ |
|
401 | - public function exercise_breadcrumb_filter( $crumbs ) { |
|
402 | - $exercise = \lsx_health_plan\functions\get_option( 'endpoint_exercise', 'exercise' ); |
|
403 | - $exercises = \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercise' ); |
|
404 | - $url = get_post_type_archive_link( $exercise ); |
|
405 | - |
|
406 | - if ( is_singular( 'exercise' ) ) { |
|
407 | - $exercise_name = get_the_title(); |
|
408 | - $term_obj_list = get_the_terms( get_the_ID(), 'exercise-type' ); |
|
409 | - $exercise_type = $term_obj_list[0]->name; |
|
410 | - $exercise_type_url = get_term_link( $term_obj_list[0]->term_id ); |
|
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 | + * Constructor |
|
31 | + */ |
|
32 | + public function __construct() { |
|
33 | + |
|
34 | + if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
35 | + // Post Type and Taxonomies. |
|
36 | + add_action( 'init', array( $this, 'register_post_type' ) ); |
|
37 | + add_action( 'init', array( $this, 'exercise_type_taxonomy_setup' ) ); |
|
38 | + add_action( 'init', array( $this, 'equipment_taxonomy_setup' ) ); |
|
39 | + add_action( 'init', array( $this, 'muscle_group_taxonomy_setup' ) ); |
|
40 | + add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
41 | + |
|
42 | + // Custom Fields. |
|
43 | + add_action( 'cmb2_admin_init', array( $this, 'exercise_details' ), 8 ); |
|
44 | + add_action( 'cmb2_admin_init', array( $this, 'gallery_metabox' ), 9 ); |
|
45 | + add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
46 | + |
|
47 | + // Template Redirects. |
|
48 | + add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
49 | + add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
50 | + |
|
51 | + //Breadcrumbs |
|
52 | + add_filter( 'woocommerce_get_breadcrumb', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 ); |
|
53 | + |
|
54 | + } |
|
55 | + |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * Return an instance of this class. |
|
61 | + * |
|
62 | + * @since 1.0.0 |
|
63 | + * |
|
64 | + * @return object \lsx_health_plan\classes\Exercise() A single instance of this class. |
|
65 | + */ |
|
66 | + public static function get_instance() { |
|
67 | + // If the single instance hasn't been set, set it now. |
|
68 | + if ( null === self::$instance ) { |
|
69 | + self::$instance = new self(); |
|
70 | + } |
|
71 | + return self::$instance; |
|
72 | + } |
|
73 | + /** |
|
74 | + * Register the post type. |
|
75 | + */ |
|
76 | + public function register_post_type() { |
|
77 | + $labels = array( |
|
78 | + 'name' => esc_html__( 'Exercises', 'lsx-health-plan' ), |
|
79 | + 'singular_name' => esc_html__( 'Exercise', 'lsx-health-plan' ), |
|
80 | + 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
81 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
82 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
83 | + 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
84 | + 'all_items' => esc_html__( 'All Exercises', 'lsx-health-plan' ), |
|
85 | + 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
86 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
87 | + 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
88 | + 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
89 | + 'parent_item_colon' => '', |
|
90 | + 'menu_name' => esc_html__( 'Exercises', 'lsx-health-plan' ), |
|
91 | + ); |
|
92 | + $args = array( |
|
93 | + 'labels' => $labels, |
|
94 | + 'public' => true, |
|
95 | + 'publicly_queryable' => true, |
|
96 | + 'show_ui' => true, |
|
97 | + 'show_in_menu' => 'edit.php?post_type=workout-pseudo', |
|
98 | + 'show_in_rest' => true, |
|
99 | + 'menu_icon' => 'dashicons-universal-access', |
|
100 | + 'query_var' => true, |
|
101 | + 'rewrite' => array( |
|
102 | + 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ), |
|
103 | + ), |
|
104 | + 'capability_type' => 'page', |
|
105 | + 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercises' ), |
|
106 | + 'hierarchical' => false, |
|
107 | + 'menu_position' => null, |
|
108 | + 'supports' => array( |
|
109 | + 'title', |
|
110 | + 'thumbnail', |
|
111 | + 'editor', |
|
112 | + 'excerpt', |
|
113 | + 'custom-fields', |
|
114 | + ), |
|
115 | + ); |
|
116 | + register_post_type( 'exercise', $args ); |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Register the Exercise taxonomy. |
|
121 | + * |
|
122 | + * @return void |
|
123 | + */ |
|
124 | + public function exercise_type_taxonomy_setup() { |
|
125 | + $labels = array( |
|
126 | + 'name' => esc_html_x( 'Exercise Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
127 | + 'singular_name' => esc_html_x( 'Exercise Type', 'taxonomy singular name', 'lsx-health-plan' ), |
|
128 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
129 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
130 | + 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
131 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
132 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
133 | + 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
134 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
135 | + 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
136 | + 'menu_name' => esc_html__( 'Exercise Types', 'lsx-health-plan' ), |
|
137 | + ); |
|
138 | + |
|
139 | + $args = array( |
|
140 | + 'hierarchical' => true, |
|
141 | + 'labels' => $labels, |
|
142 | + 'show_ui' => true, |
|
143 | + 'show_admin_column' => true, |
|
144 | + 'query_var' => true, |
|
145 | + 'rewrite' => array( |
|
146 | + 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_type', 'exercise-type' ), |
|
147 | + ), |
|
148 | + 'show_in_rest' => true, |
|
149 | + ); |
|
150 | + |
|
151 | + register_taxonomy( 'exercise-type', array( 'exercise' ), $args ); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Register the Exercise taxonomy. |
|
156 | + * |
|
157 | + * @return void |
|
158 | + */ |
|
159 | + public function equipment_taxonomy_setup() { |
|
160 | + $labels = array( |
|
161 | + 'name' => esc_html_x( 'Equipment', 'taxonomy general name', 'lsx-health-plan' ), |
|
162 | + 'singular_name' => esc_html_x( 'Equipment', 'taxonomy singular name', 'lsx-health-plan' ), |
|
163 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
164 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
165 | + 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
166 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
167 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
168 | + 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
169 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
170 | + 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
171 | + 'menu_name' => esc_html__( 'Equipment', 'lsx-health-plan' ), |
|
172 | + ); |
|
173 | + |
|
174 | + $args = array( |
|
175 | + 'hierarchical' => true, |
|
176 | + 'labels' => $labels, |
|
177 | + 'show_ui' => true, |
|
178 | + 'show_admin_column' => true, |
|
179 | + 'query_var' => true, |
|
180 | + 'rewrite' => array( |
|
181 | + 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_equipment', 'equipment' ), |
|
182 | + ), |
|
183 | + 'show_in_rest' => true, |
|
184 | + ); |
|
185 | + |
|
186 | + register_taxonomy( 'equipment', array( 'exercise' ), $args ); |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Register the Muscle Group taxonomy. |
|
191 | + * |
|
192 | + * @return void |
|
193 | + */ |
|
194 | + public function muscle_group_taxonomy_setup() { |
|
195 | + $labels = array( |
|
196 | + 'name' => esc_html_x( 'Muscle Groups', 'taxonomy general name', 'lsx-health-plan' ), |
|
197 | + 'singular_name' => esc_html_x( 'Muscle Group', 'taxonomy singular name', 'lsx-health-plan' ), |
|
198 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
199 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
200 | + 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
201 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
202 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
203 | + 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
204 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
205 | + 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
206 | + 'menu_name' => esc_html__( 'Muscle Groups', 'lsx-health-plan' ), |
|
207 | + ); |
|
208 | + |
|
209 | + $args = array( |
|
210 | + 'hierarchical' => true, |
|
211 | + 'labels' => $labels, |
|
212 | + 'show_ui' => true, |
|
213 | + 'show_admin_column' => true, |
|
214 | + 'query_var' => true, |
|
215 | + 'rewrite' => array( |
|
216 | + 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_musclegroup', 'muscle-group' ), |
|
217 | + ), |
|
218 | + 'show_in_rest' => true, |
|
219 | + ); |
|
220 | + |
|
221 | + register_taxonomy( 'muscle-group', array( 'exercise' ), $args ); |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * Registers the Recipes under the Meals Post type menu. |
|
226 | + * |
|
227 | + * @return void |
|
228 | + */ |
|
229 | + public function register_menus() { |
|
230 | + 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' ); |
|
231 | + 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' ); |
|
232 | + 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' ); |
|
233 | + 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' ); |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * Adds the post type to the different arrays. |
|
238 | + * |
|
239 | + * @param array $post_types |
|
240 | + * @return array |
|
241 | + */ |
|
242 | + public function enable_post_type( $post_types = array() ) { |
|
243 | + $post_types[] = $this->slug; |
|
244 | + return $post_types; |
|
245 | + } |
|
246 | + |
|
247 | + /** |
|
248 | + * Enables the Bi Directional relationships |
|
249 | + * |
|
250 | + * @param array $connections |
|
251 | + * @return void |
|
252 | + */ |
|
253 | + public function enable_connections( $connections = array() ) { |
|
254 | + $connections['exercise']['connected_workouts'] = 'connected_exercises'; |
|
255 | + $connections['workout']['connected_exercises'] = 'connected_workouts'; |
|
256 | + return $connections; |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Define the metabox and field configurations. |
|
261 | + */ |
|
262 | + public function gallery_metabox() { |
|
263 | + $cmb = new_cmb2_box( |
|
264 | + array( |
|
265 | + 'id' => $this->slug . '_gallery_details_metabox', |
|
266 | + 'title' => __( 'Exercise Gallery', 'lsx-health-plan' ), |
|
267 | + 'object_types' => array( $this->slug ), |
|
268 | + 'context' => 'normal', |
|
269 | + 'priority' => 'low', |
|
270 | + 'show_names' => true, |
|
271 | + ) |
|
272 | + ); |
|
273 | + |
|
274 | + $cmb->add_field( |
|
275 | + array( |
|
276 | + 'name' => __( 'Layout', 'lsx-health-plan' ), |
|
277 | + 'id' => $this->slug . '_gallery_layout', |
|
278 | + 'type' => 'radio', |
|
279 | + 'options' => array( |
|
280 | + 'slider' => __( 'Slider', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number |
|
281 | + 'grid' => __( 'Grid', 'lsx-health-plan' ), |
|
282 | + ), |
|
283 | + 'default' => 'grid', |
|
284 | + ) |
|
285 | + ); |
|
286 | + |
|
287 | + $cmb->add_field( |
|
288 | + array( |
|
289 | + 'name' => __( 'Grid Columns', 'lsx-health-plan' ), |
|
290 | + 'id' => $this->slug . '_gallery_columns', |
|
291 | + 'type' => 'select', |
|
292 | + 'options' => array( |
|
293 | + '3' => __( '2 Columns', 'lsx-health-plan' ), |
|
294 | + '4' => __( '3 Columns', 'lsx-health-plan' ), |
|
295 | + ), |
|
296 | + 'default' => '1', |
|
297 | + ) |
|
298 | + ); |
|
299 | + |
|
300 | + // Repeatable group. |
|
301 | + $gallery_group = $cmb->add_field( |
|
302 | + array( |
|
303 | + 'id' => $this->slug . '_gallery', |
|
304 | + 'type' => 'group', |
|
305 | + 'options' => array( |
|
306 | + 'group_title' => __( 'Gallery', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number |
|
307 | + 'add_button' => __( 'Add Item', 'lsx-health-plan' ), |
|
308 | + 'remove_button' => __( 'Remove Item', 'lsx-health-plan' ), |
|
309 | + 'sortable' => true, |
|
310 | + ), |
|
311 | + 'desc' => __( 'Upload only one image, video or gif per gallery group, each group will only display 1 item.', 'lsx-health-plan' ), |
|
312 | + 'classes' => 'lsx-admin-row', |
|
313 | + ) |
|
314 | + ); |
|
315 | + |
|
316 | + // Title. |
|
317 | + $cmb->add_group_field( |
|
318 | + $gallery_group, |
|
319 | + array( |
|
320 | + 'name' => __( 'Image', 'lsx-health-plan' ), |
|
321 | + 'id' => $this->slug . '_gallery_image', |
|
322 | + 'type' => 'file', |
|
323 | + 'text' => array( |
|
324 | + 'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ), |
|
325 | + ), |
|
326 | + 'desc' => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ), |
|
327 | + 'query_args' => array( |
|
328 | + 'type' => array( |
|
329 | + 'image/gif', |
|
330 | + 'image/jpeg', |
|
331 | + 'image/png', |
|
332 | + ), |
|
333 | + ), |
|
334 | + 'preview_size' => 'lsx-thumbnail-wide', |
|
335 | + 'classes' => 'lsx-field-col lsx-field-col-80', |
|
336 | + ) |
|
337 | + ); |
|
338 | + |
|
339 | + // Title. |
|
340 | + $cmb->add_group_field( |
|
341 | + $gallery_group, |
|
342 | + array( |
|
343 | + 'name' => __( 'oEmbed', 'lsx-health-plan' ), |
|
344 | + 'id' => $this->slug . '_gallery_embed', |
|
345 | + 'type' => 'text', |
|
346 | + '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' ), |
|
347 | + 'classes' => 'test-apply-form lsx-field-col lsx-field-col-50', |
|
348 | + ) |
|
349 | + ); |
|
350 | + |
|
351 | + $cmb->add_group_field( |
|
352 | + $gallery_group, |
|
353 | + array( |
|
354 | + 'name' => __( 'External Media', 'lsx-health-plan' ), |
|
355 | + 'id' => $this->slug . '_gallery_external', |
|
356 | + 'type' => 'textarea_code', |
|
357 | + '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' ), |
|
358 | + 'classes' => 'lsx-field-col lsx-field-col-50', |
|
359 | + ) |
|
360 | + ); |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * Registers the general settings for the exercise. |
|
365 | + * |
|
366 | + * @return void |
|
367 | + */ |
|
368 | + public function exercise_details() { |
|
369 | + $cmb = new_cmb2_box( |
|
370 | + array( |
|
371 | + 'id' => $this->slug . '_general_details_metabox', |
|
372 | + 'title' => __( 'Details', 'lsx-health-plan' ), |
|
373 | + 'object_types' => array( $this->slug ), |
|
374 | + 'context' => 'normal', |
|
375 | + 'priority' => 'high', |
|
376 | + 'show_names' => true, |
|
377 | + ) |
|
378 | + ); |
|
379 | + |
|
380 | + $cmb->add_field( |
|
381 | + array( |
|
382 | + 'name' => __( 'Side', 'lsx-health-plan' ), |
|
383 | + 'id' => $this->slug . '_side', |
|
384 | + 'type' => 'select', |
|
385 | + 'options' => array( |
|
386 | + '' => __( 'Select', 'lsx-health-plan' ), |
|
387 | + 'left' => __( 'Left', 'lsx-health-plan' ), |
|
388 | + 'right' => __( 'Right', 'lsx-health-plan' ), |
|
389 | + ), |
|
390 | + 'desc' => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ), |
|
391 | + ) |
|
392 | + ); |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * Holds the array for the single exercise breadcrumbs. |
|
397 | + * |
|
398 | + * @var array $crumbs |
|
399 | + * @return array |
|
400 | + */ |
|
401 | + public function exercise_breadcrumb_filter( $crumbs ) { |
|
402 | + $exercise = \lsx_health_plan\functions\get_option( 'endpoint_exercise', 'exercise' ); |
|
403 | + $exercises = \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercise' ); |
|
404 | + $url = get_post_type_archive_link( $exercise ); |
|
405 | + |
|
406 | + if ( is_singular( 'exercise' ) ) { |
|
407 | + $exercise_name = get_the_title(); |
|
408 | + $term_obj_list = get_the_terms( get_the_ID(), 'exercise-type' ); |
|
409 | + $exercise_type = $term_obj_list[0]->name; |
|
410 | + $exercise_type_url = get_term_link( $term_obj_list[0]->term_id ); |
|
411 | 411 | |
412 | - $crumbs[1] = array( |
|
413 | - 0 => $exercises, |
|
414 | - 1 => $url, |
|
415 | - ); |
|
416 | - $crumbs[2] = array( |
|
417 | - 0 => $exercise_type, |
|
418 | - 1 => $exercise_type_url, |
|
419 | - ); |
|
420 | - $crumbs[3] = array( |
|
421 | - 0 => $exercise_name, |
|
422 | - ); |
|
423 | - } |
|
424 | - if ( is_tax( 'exercise-type' ) || is_tax( 'muscle-group' ) || is_tax( 'equipment' ) ) { |
|
425 | - $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); |
|
426 | - |
|
427 | - $single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name; |
|
428 | - |
|
429 | - $crumbs[1] = array( |
|
430 | - 0 => $exercises, |
|
431 | - 1 => $url, |
|
432 | - ); |
|
433 | - $crumbs[2] = array( |
|
434 | - 0 => $single_term_title, |
|
435 | - ); |
|
436 | - } |
|
437 | - return $crumbs; |
|
438 | - } |
|
412 | + $crumbs[1] = array( |
|
413 | + 0 => $exercises, |
|
414 | + 1 => $url, |
|
415 | + ); |
|
416 | + $crumbs[2] = array( |
|
417 | + 0 => $exercise_type, |
|
418 | + 1 => $exercise_type_url, |
|
419 | + ); |
|
420 | + $crumbs[3] = array( |
|
421 | + 0 => $exercise_name, |
|
422 | + ); |
|
423 | + } |
|
424 | + if ( is_tax( 'exercise-type' ) || is_tax( 'muscle-group' ) || is_tax( 'equipment' ) ) { |
|
425 | + $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); |
|
426 | + |
|
427 | + $single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name; |
|
428 | + |
|
429 | + $crumbs[1] = array( |
|
430 | + 0 => $exercises, |
|
431 | + 1 => $url, |
|
432 | + ); |
|
433 | + $crumbs[2] = array( |
|
434 | + 0 => $single_term_title, |
|
435 | + ); |
|
436 | + } |
|
437 | + return $crumbs; |
|
438 | + } |
|
439 | 439 | } |
@@ -10,207 +10,207 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class Plan { |
12 | 12 | |
13 | - /** |
|
14 | - * Holds class instance |
|
15 | - * |
|
16 | - * @since 1.0.0 |
|
17 | - * |
|
18 | - * @var object \lsx_health_plan\classes\Plan() |
|
19 | - */ |
|
20 | - protected static $instance = null; |
|
21 | - |
|
22 | - /** |
|
23 | - * Holds post_type slug used as an index |
|
24 | - * |
|
25 | - * @since 1.0.0 |
|
26 | - * |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - public $slug = 'plan'; |
|
30 | - |
|
31 | - /** |
|
32 | - * Constructor |
|
33 | - */ |
|
34 | - public function __construct() { |
|
35 | - |
|
36 | - add_action( 'init', array( $this, 'register_post_type' ) ); |
|
37 | - add_action( 'init', array( $this, 'plan_type_taxonomy_setup' ) ); |
|
38 | - add_action( 'init', array( $this, 'week_taxonomy_setup' ) ); |
|
39 | - |
|
40 | - // Icons for the plan types. |
|
41 | - add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 ); |
|
42 | - add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 ); |
|
43 | - $prefix_taxonomy = 'plan-type'; |
|
44 | - add_action( sprintf( '%s_edit_form_fields', $prefix_taxonomy ), array( $this, 'add_thumbnail_form_field' ), 3, 1 ); |
|
45 | - |
|
46 | - // Register the Metaboxes. |
|
47 | - add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 ); |
|
48 | - add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ), 5 ); |
|
49 | - add_action( 'cmb2_admin_init', array( $this, 'plan_connections' ), 5 ); |
|
50 | - add_action( 'cmb2_admin_init', array( $this, 'sections_metabox_loop' ), 1 ); |
|
51 | - |
|
52 | - add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
53 | - //add_filter( 'lsx_global_header_title', array( $this, 'hp_recipe_header_title' ), 200, 1 ); |
|
54 | - |
|
55 | - // Template Redirects. |
|
56 | - add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
57 | - add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
58 | - |
|
59 | - // Plan Archive Actions. |
|
60 | - add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 ); |
|
61 | - add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
62 | - add_action( 'lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1 ); |
|
63 | - add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1 ); |
|
64 | - add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_filters_disabled', 10, 1 ); |
|
65 | - |
|
66 | - //Breadcrumbs |
|
67 | - add_filter( 'woocommerce_get_breadcrumb', array( $this, 'plan_breadcrumb_filter' ), 30, 1 ); |
|
13 | + /** |
|
14 | + * Holds class instance |
|
15 | + * |
|
16 | + * @since 1.0.0 |
|
17 | + * |
|
18 | + * @var object \lsx_health_plan\classes\Plan() |
|
19 | + */ |
|
20 | + protected static $instance = null; |
|
21 | + |
|
22 | + /** |
|
23 | + * Holds post_type slug used as an index |
|
24 | + * |
|
25 | + * @since 1.0.0 |
|
26 | + * |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + public $slug = 'plan'; |
|
30 | + |
|
31 | + /** |
|
32 | + * Constructor |
|
33 | + */ |
|
34 | + public function __construct() { |
|
35 | + |
|
36 | + add_action( 'init', array( $this, 'register_post_type' ) ); |
|
37 | + add_action( 'init', array( $this, 'plan_type_taxonomy_setup' ) ); |
|
38 | + add_action( 'init', array( $this, 'week_taxonomy_setup' ) ); |
|
39 | + |
|
40 | + // Icons for the plan types. |
|
41 | + add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 ); |
|
42 | + add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 ); |
|
43 | + $prefix_taxonomy = 'plan-type'; |
|
44 | + add_action( sprintf( '%s_edit_form_fields', $prefix_taxonomy ), array( $this, 'add_thumbnail_form_field' ), 3, 1 ); |
|
45 | + |
|
46 | + // Register the Metaboxes. |
|
47 | + add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 ); |
|
48 | + add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ), 5 ); |
|
49 | + add_action( 'cmb2_admin_init', array( $this, 'plan_connections' ), 5 ); |
|
50 | + add_action( 'cmb2_admin_init', array( $this, 'sections_metabox_loop' ), 1 ); |
|
51 | + |
|
52 | + add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
53 | + //add_filter( 'lsx_global_header_title', array( $this, 'hp_recipe_header_title' ), 200, 1 ); |
|
54 | + |
|
55 | + // Template Redirects. |
|
56 | + add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
57 | + add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
58 | + |
|
59 | + // Plan Archive Actions. |
|
60 | + add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 ); |
|
61 | + add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
62 | + add_action( 'lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1 ); |
|
63 | + add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1 ); |
|
64 | + add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_filters_disabled', 10, 1 ); |
|
65 | + |
|
66 | + //Breadcrumbs |
|
67 | + add_filter( 'woocommerce_get_breadcrumb', array( $this, 'plan_breadcrumb_filter' ), 30, 1 ); |
|
68 | 68 | |
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Return an instance of this class. |
|
73 | - * |
|
74 | - * @since 1.0.0 |
|
75 | - * |
|
76 | - * @return object \lsx_health_plan\classes\Meal_Plan() A single instance of this class. |
|
77 | - */ |
|
78 | - public static function get_instance() { |
|
79 | - // If the single instance hasn't been set, set it now. |
|
80 | - if ( null === self::$instance ) { |
|
81 | - self::$instance = new self(); |
|
82 | - } |
|
83 | - return self::$instance; |
|
84 | - } |
|
85 | - /** |
|
86 | - * Register the post type. |
|
87 | - */ |
|
88 | - public function register_post_type() { |
|
89 | - $labels = array( |
|
90 | - 'name' => esc_html__( 'Plans', 'lsx-health-plan' ), |
|
91 | - 'singular_name' => esc_html__( 'Plan', 'lsx-health-plan' ), |
|
92 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
93 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
94 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
95 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
96 | - 'all_items' => esc_html__( 'All Plans', 'lsx-health-plan' ), |
|
97 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
98 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
99 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
100 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
101 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
102 | - 'menu_name' => esc_html__( 'Plans', 'lsx-health-plan' ), |
|
103 | - ); |
|
104 | - $args = array( |
|
105 | - 'labels' => $labels, |
|
106 | - 'public' => true, |
|
107 | - 'publicly_queryable' => true, |
|
108 | - 'show_ui' => true, |
|
109 | - 'show_in_menu' => true, |
|
110 | - 'show_in_rest' => true, |
|
111 | - 'menu_icon' => 'dashicons-welcome-write-blog', |
|
112 | - 'query_var' => true, |
|
113 | - 'rewrite' => array( |
|
114 | - 'slug' => \lsx_health_plan\functions\get_option( 'plan_single_slug', 'plan' ), |
|
115 | - ), |
|
116 | - 'capability_type' => 'page', |
|
117 | - 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plans' ), |
|
118 | - 'hierarchical' => false, |
|
119 | - 'menu_position' => null, |
|
120 | - 'supports' => array( |
|
121 | - 'title', |
|
122 | - 'editor', |
|
123 | - 'thumbnail', |
|
124 | - 'page-attributes', |
|
125 | - 'custom-fields', |
|
126 | - ), |
|
127 | - ); |
|
128 | - register_post_type( 'plan', $args ); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Register the Type taxonomy. |
|
133 | - */ |
|
134 | - public function plan_type_taxonomy_setup() { |
|
135 | - $labels = array( |
|
136 | - 'name' => esc_html_x( 'Plan Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
137 | - 'singular_name' => esc_html_x( 'Plan Type', 'taxonomy singular name', 'lsx-health-plan' ), |
|
138 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
139 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
140 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
141 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
142 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
143 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
144 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
145 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
146 | - 'menu_name' => esc_html__( 'Plan Types', 'lsx-health-plan' ), |
|
147 | - ); |
|
148 | - |
|
149 | - $args = array( |
|
150 | - 'hierarchical' => true, |
|
151 | - 'labels' => $labels, |
|
152 | - 'show_ui' => true, |
|
153 | - 'show_admin_column' => true, |
|
154 | - 'query_var' => true, |
|
155 | - 'rewrite' => array( |
|
156 | - 'slug' => 'plan-type', |
|
157 | - ), |
|
158 | - ); |
|
159 | - |
|
160 | - register_taxonomy( 'plan-type', array( 'plan' ), $args ); |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Register the Week taxonomy. |
|
165 | - */ |
|
166 | - public function week_taxonomy_setup() { |
|
167 | - $labels = array( |
|
168 | - 'name' => esc_html_x( 'Week', 'taxonomy general name', 'lsx-health-plan' ), |
|
169 | - 'singular_name' => esc_html_x( 'Week', 'taxonomy singular name', 'lsx-health-plan' ), |
|
170 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
171 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
172 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
173 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
174 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
175 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
176 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
177 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
178 | - 'menu_name' => esc_html__( 'Weeks', 'lsx-health-plan' ), |
|
179 | - ); |
|
180 | - |
|
181 | - $args = array( |
|
182 | - 'hierarchical' => true, |
|
183 | - 'labels' => $labels, |
|
184 | - 'show_ui' => true, |
|
185 | - 'show_admin_column' => true, |
|
186 | - 'query_var' => true, |
|
187 | - 'show_in_rest' => true, |
|
188 | - 'rewrite' => array( |
|
189 | - 'slug' => 'week', |
|
190 | - ), |
|
191 | - ); |
|
192 | - |
|
193 | - register_taxonomy( 'week', array( 'plan' ), $args ); |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * Output the form field for this metadata when adding a new term |
|
198 | - * |
|
199 | - * @since 0.1.0 |
|
200 | - */ |
|
201 | - public function add_thumbnail_form_field( $term = false ) { |
|
202 | - if ( is_object( $term ) ) { |
|
203 | - $value = get_term_meta( $term->term_id, 'thumbnail', true ); |
|
204 | - $image_preview = wp_get_attachment_image_src( $value, 'thumbnail' ); |
|
205 | - |
|
206 | - if ( is_array( $image_preview ) ) { |
|
207 | - $image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url( $image_preview[0] ) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />'; |
|
208 | - } |
|
209 | - } else { |
|
210 | - $image_preview = false; |
|
211 | - $value = false; |
|
212 | - } |
|
213 | - ?> |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Return an instance of this class. |
|
73 | + * |
|
74 | + * @since 1.0.0 |
|
75 | + * |
|
76 | + * @return object \lsx_health_plan\classes\Meal_Plan() A single instance of this class. |
|
77 | + */ |
|
78 | + public static function get_instance() { |
|
79 | + // If the single instance hasn't been set, set it now. |
|
80 | + if ( null === self::$instance ) { |
|
81 | + self::$instance = new self(); |
|
82 | + } |
|
83 | + return self::$instance; |
|
84 | + } |
|
85 | + /** |
|
86 | + * Register the post type. |
|
87 | + */ |
|
88 | + public function register_post_type() { |
|
89 | + $labels = array( |
|
90 | + 'name' => esc_html__( 'Plans', 'lsx-health-plan' ), |
|
91 | + 'singular_name' => esc_html__( 'Plan', 'lsx-health-plan' ), |
|
92 | + 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
93 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
94 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
95 | + 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
96 | + 'all_items' => esc_html__( 'All Plans', 'lsx-health-plan' ), |
|
97 | + 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
98 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
99 | + 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
100 | + 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
101 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
102 | + 'menu_name' => esc_html__( 'Plans', 'lsx-health-plan' ), |
|
103 | + ); |
|
104 | + $args = array( |
|
105 | + 'labels' => $labels, |
|
106 | + 'public' => true, |
|
107 | + 'publicly_queryable' => true, |
|
108 | + 'show_ui' => true, |
|
109 | + 'show_in_menu' => true, |
|
110 | + 'show_in_rest' => true, |
|
111 | + 'menu_icon' => 'dashicons-welcome-write-blog', |
|
112 | + 'query_var' => true, |
|
113 | + 'rewrite' => array( |
|
114 | + 'slug' => \lsx_health_plan\functions\get_option( 'plan_single_slug', 'plan' ), |
|
115 | + ), |
|
116 | + 'capability_type' => 'page', |
|
117 | + 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plans' ), |
|
118 | + 'hierarchical' => false, |
|
119 | + 'menu_position' => null, |
|
120 | + 'supports' => array( |
|
121 | + 'title', |
|
122 | + 'editor', |
|
123 | + 'thumbnail', |
|
124 | + 'page-attributes', |
|
125 | + 'custom-fields', |
|
126 | + ), |
|
127 | + ); |
|
128 | + register_post_type( 'plan', $args ); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Register the Type taxonomy. |
|
133 | + */ |
|
134 | + public function plan_type_taxonomy_setup() { |
|
135 | + $labels = array( |
|
136 | + 'name' => esc_html_x( 'Plan Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
137 | + 'singular_name' => esc_html_x( 'Plan Type', 'taxonomy singular name', 'lsx-health-plan' ), |
|
138 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
139 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
140 | + 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
141 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
142 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
143 | + 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
144 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
145 | + 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
146 | + 'menu_name' => esc_html__( 'Plan Types', 'lsx-health-plan' ), |
|
147 | + ); |
|
148 | + |
|
149 | + $args = array( |
|
150 | + 'hierarchical' => true, |
|
151 | + 'labels' => $labels, |
|
152 | + 'show_ui' => true, |
|
153 | + 'show_admin_column' => true, |
|
154 | + 'query_var' => true, |
|
155 | + 'rewrite' => array( |
|
156 | + 'slug' => 'plan-type', |
|
157 | + ), |
|
158 | + ); |
|
159 | + |
|
160 | + register_taxonomy( 'plan-type', array( 'plan' ), $args ); |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Register the Week taxonomy. |
|
165 | + */ |
|
166 | + public function week_taxonomy_setup() { |
|
167 | + $labels = array( |
|
168 | + 'name' => esc_html_x( 'Week', 'taxonomy general name', 'lsx-health-plan' ), |
|
169 | + 'singular_name' => esc_html_x( 'Week', 'taxonomy singular name', 'lsx-health-plan' ), |
|
170 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
171 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
172 | + 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
173 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
174 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
175 | + 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
176 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
177 | + 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
178 | + 'menu_name' => esc_html__( 'Weeks', 'lsx-health-plan' ), |
|
179 | + ); |
|
180 | + |
|
181 | + $args = array( |
|
182 | + 'hierarchical' => true, |
|
183 | + 'labels' => $labels, |
|
184 | + 'show_ui' => true, |
|
185 | + 'show_admin_column' => true, |
|
186 | + 'query_var' => true, |
|
187 | + 'show_in_rest' => true, |
|
188 | + 'rewrite' => array( |
|
189 | + 'slug' => 'week', |
|
190 | + ), |
|
191 | + ); |
|
192 | + |
|
193 | + register_taxonomy( 'week', array( 'plan' ), $args ); |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * Output the form field for this metadata when adding a new term |
|
198 | + * |
|
199 | + * @since 0.1.0 |
|
200 | + */ |
|
201 | + public function add_thumbnail_form_field( $term = false ) { |
|
202 | + if ( is_object( $term ) ) { |
|
203 | + $value = get_term_meta( $term->term_id, 'thumbnail', true ); |
|
204 | + $image_preview = wp_get_attachment_image_src( $value, 'thumbnail' ); |
|
205 | + |
|
206 | + if ( is_array( $image_preview ) ) { |
|
207 | + $image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url( $image_preview[0] ) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />'; |
|
208 | + } |
|
209 | + } else { |
|
210 | + $image_preview = false; |
|
211 | + $value = false; |
|
212 | + } |
|
213 | + ?> |
|
214 | 214 | <tr class="form-field form-required term-thumbnail-wrap"> |
215 | 215 | <th scope="row"><label for="thumbnail"><?php esc_html_e( 'Icon Image', 'lsx-health-plan' ); ?></label></th> |
216 | 216 | <td> |
@@ -224,343 +224,343 @@ discard block |
||
224 | 224 | </td> |
225 | 225 | </tr> |
226 | 226 | <?php |
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * Saves the Taxonomy term icon image |
|
231 | - * |
|
232 | - * @since 0.1.0 |
|
233 | - * |
|
234 | - * @param int $term_id |
|
235 | - * @param string $taxonomy |
|
236 | - */ |
|
237 | - public function save_meta( $term_id = 0, $taxonomy = '' ) { |
|
238 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
239 | - return; |
|
240 | - } |
|
241 | - |
|
242 | - if ( ! isset( $_POST['thumbnail'] ) ) { |
|
243 | - return; |
|
244 | - } |
|
245 | - |
|
246 | - if ( check_admin_referer( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ) ) { |
|
247 | - if ( ! isset( $_POST['thumbnail'] ) ) { |
|
248 | - return; |
|
249 | - } |
|
250 | - |
|
251 | - $thumbnail_meta = sanitize_text_field( $_POST['thumbnail'] ); |
|
252 | - $thumbnail_meta = ! empty( $thumbnail_meta ) ? $thumbnail_meta : ''; |
|
253 | - |
|
254 | - if ( empty( $thumbnail_meta ) ) { |
|
255 | - delete_term_meta( $term_id, 'thumbnail' ); |
|
256 | - } else { |
|
257 | - update_term_meta( $term_id, 'thumbnail', $thumbnail_meta ); |
|
258 | - } |
|
259 | - } |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * Define the metabox and field configurations. |
|
264 | - */ |
|
265 | - public function details_metaboxes() { |
|
266 | - $cmb = new_cmb2_box( array( |
|
267 | - 'id' => $this->slug . '_details_metabox', |
|
268 | - 'title' => __( 'Details', 'lsx-health-plan' ), |
|
269 | - 'object_types' => array( $this->slug ), // Post type |
|
270 | - 'context' => 'normal', |
|
271 | - 'priority' => 'high', |
|
272 | - 'show_names' => true, |
|
273 | - ) ); |
|
274 | - |
|
275 | - $cmb->add_field( array( |
|
276 | - 'name' => __( 'Plan Short Description', 'lsx-health-plan' ), |
|
277 | - 'id' => $this->slug . '_short_description', |
|
278 | - 'type' => 'textarea_small', |
|
279 | - 'desc' => __( 'Add a small description for this plan (optional)', 'lsx-health-plan' ), |
|
280 | - ) ); |
|
281 | - |
|
282 | - $warmup_type = 'page'; |
|
283 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
284 | - $warmup_type = array( 'page', 'workout' ); |
|
285 | - } |
|
286 | - $cmb->add_field( array( |
|
287 | - 'name' => __( 'Warmup', 'lsx-health-plan' ), |
|
288 | - 'desc' => __( 'Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan' ), |
|
289 | - 'id' => $this->slug . '_warmup', |
|
290 | - 'type' => 'post_search_ajax', |
|
291 | - // Optional : |
|
292 | - 'limit' => 3, // Limit selection to X items only (default 1) |
|
293 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
294 | - 'query_args' => array( |
|
295 | - 'post_type' => $warmup_type, |
|
296 | - 'post_status' => array( 'publish' ), |
|
297 | - 'posts_per_page' => -1, |
|
298 | - ), |
|
299 | - ) ); |
|
300 | - } |
|
301 | - |
|
302 | - /** |
|
303 | - * Adds the post type to the different arrays. |
|
304 | - * |
|
305 | - * @param array $post_types |
|
306 | - * @return array |
|
307 | - */ |
|
308 | - public function enable_post_type( $post_types = array() ) { |
|
309 | - $post_types[] = $this->slug; |
|
310 | - return $post_types; |
|
311 | - } |
|
312 | - |
|
313 | - /** |
|
314 | - * Registers the workout connections on the plan post type. |
|
315 | - * |
|
316 | - * @return void |
|
317 | - */ |
|
318 | - public function plan_connections() { |
|
319 | - $cmb = new_cmb2_box( |
|
320 | - array( |
|
321 | - 'id' => $this->slug . '_connections_metabox', |
|
322 | - 'title' => __( 'Plans', 'lsx-health-plan' ), |
|
323 | - 'object_types' => array( 'workout', 'meal', 'tip', 'recipe' ), |
|
324 | - 'context' => 'normal', |
|
325 | - 'priority' => 'high', |
|
326 | - 'show_names' => true, |
|
327 | - ) |
|
328 | - ); |
|
329 | - $cmb->add_field( |
|
330 | - array( |
|
331 | - 'name' => __( 'Plan', 'lsx-health-plan' ), |
|
332 | - 'id' => 'connected_plans', |
|
333 | - 'desc' => __( 'Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan' ), |
|
334 | - 'type' => 'post_search_ajax', |
|
335 | - 'limit' => 15, |
|
336 | - 'sortable' => true, |
|
337 | - 'query_args' => array( |
|
338 | - 'post_type' => array( 'plan' ), |
|
339 | - 'post_status' => array( 'publish' ), |
|
340 | - 'posts_per_page' => -1, |
|
341 | - ), |
|
342 | - ) |
|
343 | - ); |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Remove the "Archives:" from the post type. |
|
348 | - * |
|
349 | - * @param string $title the term title. |
|
350 | - * @return string |
|
351 | - */ |
|
352 | - public function get_the_archive_title( $title ) { |
|
353 | - if ( is_post_type_archive( 'plan' ) ) { |
|
354 | - $title = __( 'Our health plans', 'lsx-health-plan' ); |
|
355 | - } |
|
356 | - return $title; |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * Set the post type archive to show the parent plans only. |
|
361 | - * |
|
362 | - * @param object $wp_query |
|
363 | - * @return array |
|
364 | - */ |
|
365 | - public function set_parent_only( $wp_query ) { |
|
366 | - if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'plan' ) || $wp_query->is_tax( 'plan-type' ) ) ) { |
|
367 | - $wp_query->set( 'post_parent', '0' ); |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * Define the metabox and field configurations. |
|
373 | - */ |
|
374 | - public function featured_metabox() { |
|
375 | - $cmb = new_cmb2_box( |
|
376 | - array( |
|
377 | - 'id' => $this->slug . '_featured_metabox_plan', |
|
378 | - 'title' => __( 'Featured Plan', 'lsx-health-plan' ), |
|
379 | - 'object_types' => array( $this->slug ), // Post type |
|
380 | - 'context' => 'side', |
|
381 | - 'priority' => 'high', |
|
382 | - 'show_names' => true, |
|
383 | - ) |
|
384 | - ); |
|
385 | - $cmb->add_field( |
|
386 | - array( |
|
387 | - 'name' => __( 'Featured Plan', 'lsx-health-plan' ), |
|
388 | - 'desc' => __( 'Enable a featured plan' ), |
|
389 | - 'id' => $this->slug . '_featured_plan', |
|
390 | - 'type' => 'checkbox', |
|
391 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
392 | - ) |
|
393 | - ); |
|
394 | - } |
|
395 | - |
|
396 | - /** |
|
397 | - * Define the metabox and field configurations. |
|
398 | - */ |
|
399 | - public function sections_metabox_loop() { |
|
400 | - $cmb = new_cmb2_box( |
|
401 | - array( |
|
402 | - 'id' => $this->slug . '_sections_metabox', |
|
403 | - 'title' => __( 'Sections', 'lsx-health-plan' ), |
|
404 | - 'object_types' => array( $this->slug ), // Post type. |
|
405 | - 'context' => 'normal', |
|
406 | - 'priority' => 'low', |
|
407 | - 'show_names' => true, |
|
408 | - ) |
|
409 | - ); |
|
410 | - |
|
411 | - /* |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * Saves the Taxonomy term icon image |
|
231 | + * |
|
232 | + * @since 0.1.0 |
|
233 | + * |
|
234 | + * @param int $term_id |
|
235 | + * @param string $taxonomy |
|
236 | + */ |
|
237 | + public function save_meta( $term_id = 0, $taxonomy = '' ) { |
|
238 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
239 | + return; |
|
240 | + } |
|
241 | + |
|
242 | + if ( ! isset( $_POST['thumbnail'] ) ) { |
|
243 | + return; |
|
244 | + } |
|
245 | + |
|
246 | + if ( check_admin_referer( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ) ) { |
|
247 | + if ( ! isset( $_POST['thumbnail'] ) ) { |
|
248 | + return; |
|
249 | + } |
|
250 | + |
|
251 | + $thumbnail_meta = sanitize_text_field( $_POST['thumbnail'] ); |
|
252 | + $thumbnail_meta = ! empty( $thumbnail_meta ) ? $thumbnail_meta : ''; |
|
253 | + |
|
254 | + if ( empty( $thumbnail_meta ) ) { |
|
255 | + delete_term_meta( $term_id, 'thumbnail' ); |
|
256 | + } else { |
|
257 | + update_term_meta( $term_id, 'thumbnail', $thumbnail_meta ); |
|
258 | + } |
|
259 | + } |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * Define the metabox and field configurations. |
|
264 | + */ |
|
265 | + public function details_metaboxes() { |
|
266 | + $cmb = new_cmb2_box( array( |
|
267 | + 'id' => $this->slug . '_details_metabox', |
|
268 | + 'title' => __( 'Details', 'lsx-health-plan' ), |
|
269 | + 'object_types' => array( $this->slug ), // Post type |
|
270 | + 'context' => 'normal', |
|
271 | + 'priority' => 'high', |
|
272 | + 'show_names' => true, |
|
273 | + ) ); |
|
274 | + |
|
275 | + $cmb->add_field( array( |
|
276 | + 'name' => __( 'Plan Short Description', 'lsx-health-plan' ), |
|
277 | + 'id' => $this->slug . '_short_description', |
|
278 | + 'type' => 'textarea_small', |
|
279 | + 'desc' => __( 'Add a small description for this plan (optional)', 'lsx-health-plan' ), |
|
280 | + ) ); |
|
281 | + |
|
282 | + $warmup_type = 'page'; |
|
283 | + if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
284 | + $warmup_type = array( 'page', 'workout' ); |
|
285 | + } |
|
286 | + $cmb->add_field( array( |
|
287 | + 'name' => __( 'Warmup', 'lsx-health-plan' ), |
|
288 | + 'desc' => __( 'Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan' ), |
|
289 | + 'id' => $this->slug . '_warmup', |
|
290 | + 'type' => 'post_search_ajax', |
|
291 | + // Optional : |
|
292 | + 'limit' => 3, // Limit selection to X items only (default 1) |
|
293 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
294 | + 'query_args' => array( |
|
295 | + 'post_type' => $warmup_type, |
|
296 | + 'post_status' => array( 'publish' ), |
|
297 | + 'posts_per_page' => -1, |
|
298 | + ), |
|
299 | + ) ); |
|
300 | + } |
|
301 | + |
|
302 | + /** |
|
303 | + * Adds the post type to the different arrays. |
|
304 | + * |
|
305 | + * @param array $post_types |
|
306 | + * @return array |
|
307 | + */ |
|
308 | + public function enable_post_type( $post_types = array() ) { |
|
309 | + $post_types[] = $this->slug; |
|
310 | + return $post_types; |
|
311 | + } |
|
312 | + |
|
313 | + /** |
|
314 | + * Registers the workout connections on the plan post type. |
|
315 | + * |
|
316 | + * @return void |
|
317 | + */ |
|
318 | + public function plan_connections() { |
|
319 | + $cmb = new_cmb2_box( |
|
320 | + array( |
|
321 | + 'id' => $this->slug . '_connections_metabox', |
|
322 | + 'title' => __( 'Plans', 'lsx-health-plan' ), |
|
323 | + 'object_types' => array( 'workout', 'meal', 'tip', 'recipe' ), |
|
324 | + 'context' => 'normal', |
|
325 | + 'priority' => 'high', |
|
326 | + 'show_names' => true, |
|
327 | + ) |
|
328 | + ); |
|
329 | + $cmb->add_field( |
|
330 | + array( |
|
331 | + 'name' => __( 'Plan', 'lsx-health-plan' ), |
|
332 | + 'id' => 'connected_plans', |
|
333 | + 'desc' => __( 'Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan' ), |
|
334 | + 'type' => 'post_search_ajax', |
|
335 | + 'limit' => 15, |
|
336 | + 'sortable' => true, |
|
337 | + 'query_args' => array( |
|
338 | + 'post_type' => array( 'plan' ), |
|
339 | + 'post_status' => array( 'publish' ), |
|
340 | + 'posts_per_page' => -1, |
|
341 | + ), |
|
342 | + ) |
|
343 | + ); |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Remove the "Archives:" from the post type. |
|
348 | + * |
|
349 | + * @param string $title the term title. |
|
350 | + * @return string |
|
351 | + */ |
|
352 | + public function get_the_archive_title( $title ) { |
|
353 | + if ( is_post_type_archive( 'plan' ) ) { |
|
354 | + $title = __( 'Our health plans', 'lsx-health-plan' ); |
|
355 | + } |
|
356 | + return $title; |
|
357 | + } |
|
358 | + |
|
359 | + /** |
|
360 | + * Set the post type archive to show the parent plans only. |
|
361 | + * |
|
362 | + * @param object $wp_query |
|
363 | + * @return array |
|
364 | + */ |
|
365 | + public function set_parent_only( $wp_query ) { |
|
366 | + if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'plan' ) || $wp_query->is_tax( 'plan-type' ) ) ) { |
|
367 | + $wp_query->set( 'post_parent', '0' ); |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * Define the metabox and field configurations. |
|
373 | + */ |
|
374 | + public function featured_metabox() { |
|
375 | + $cmb = new_cmb2_box( |
|
376 | + array( |
|
377 | + 'id' => $this->slug . '_featured_metabox_plan', |
|
378 | + 'title' => __( 'Featured Plan', 'lsx-health-plan' ), |
|
379 | + 'object_types' => array( $this->slug ), // Post type |
|
380 | + 'context' => 'side', |
|
381 | + 'priority' => 'high', |
|
382 | + 'show_names' => true, |
|
383 | + ) |
|
384 | + ); |
|
385 | + $cmb->add_field( |
|
386 | + array( |
|
387 | + 'name' => __( 'Featured Plan', 'lsx-health-plan' ), |
|
388 | + 'desc' => __( 'Enable a featured plan' ), |
|
389 | + 'id' => $this->slug . '_featured_plan', |
|
390 | + 'type' => 'checkbox', |
|
391 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
392 | + ) |
|
393 | + ); |
|
394 | + } |
|
395 | + |
|
396 | + /** |
|
397 | + * Define the metabox and field configurations. |
|
398 | + */ |
|
399 | + public function sections_metabox_loop() { |
|
400 | + $cmb = new_cmb2_box( |
|
401 | + array( |
|
402 | + 'id' => $this->slug . '_sections_metabox', |
|
403 | + 'title' => __( 'Sections', 'lsx-health-plan' ), |
|
404 | + 'object_types' => array( $this->slug ), // Post type. |
|
405 | + 'context' => 'normal', |
|
406 | + 'priority' => 'low', |
|
407 | + 'show_names' => true, |
|
408 | + ) |
|
409 | + ); |
|
410 | + |
|
411 | + /* |
|
412 | 412 | This is where the repeatable group is defined, each field has the same ID as the legacy field. |
413 | 413 | There is a function which runs and adds to looped fields to individual fields for WP Query compatability. |
414 | 414 | */ |
415 | - $group = $cmb->add_field( |
|
416 | - array( |
|
417 | - 'id' => $this->slug . '_sections', |
|
418 | - 'type' => 'group', |
|
419 | - 'options' => array( |
|
420 | - 'group_title' => __( 'Section', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number |
|
421 | - 'add_button' => __( 'Add section', 'lsx-health-plan' ), |
|
422 | - 'remove_button' => __( 'Remove section', 'lsx-health-plan' ), |
|
423 | - 'sortable' => true, |
|
424 | - 'closed' => true, // true to have the groups closed by default |
|
425 | - ), |
|
426 | - 'classes' => 'lsx-admin-row', |
|
415 | + $group = $cmb->add_field( |
|
416 | + array( |
|
417 | + 'id' => $this->slug . '_sections', |
|
418 | + 'type' => 'group', |
|
419 | + 'options' => array( |
|
420 | + 'group_title' => __( 'Section', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number |
|
421 | + 'add_button' => __( 'Add section', 'lsx-health-plan' ), |
|
422 | + 'remove_button' => __( 'Remove section', 'lsx-health-plan' ), |
|
423 | + 'sortable' => true, |
|
424 | + 'closed' => true, // true to have the groups closed by default |
|
425 | + ), |
|
426 | + 'classes' => 'lsx-admin-row', |
|
427 | 427 | |
428 | - ) |
|
429 | - ); |
|
430 | - |
|
431 | - $cmb->add_group_field( |
|
432 | - $group, |
|
433 | - array( |
|
434 | - 'name' => __( 'Title', 'lsx-health-plan' ), |
|
435 | - 'id' => 'title', |
|
436 | - 'type' => 'text', |
|
437 | - 'desc' => __( 'e.g Day 1 / Week 1', 'lsx-health-plan' ), |
|
438 | - 'classes' => 'lsx-field-col lsx-field-col-50', |
|
439 | - ) |
|
440 | - ); |
|
441 | - |
|
442 | - $cmb->add_group_field( |
|
443 | - $group, |
|
444 | - array( |
|
445 | - 'name' => __( 'Group', 'lsx-health-plan' ), |
|
446 | - 'id' => 'group', |
|
447 | - 'type' => 'text', |
|
448 | - 'desc' => __( 'e.g Week 1 / January', 'lsx-health-plan' ), |
|
449 | - 'classes' => 'lsx-field-col lsx-field-col-50', |
|
450 | - ) |
|
451 | - ); |
|
452 | - |
|
453 | - $cmb->add_group_field( |
|
454 | - $group, |
|
455 | - array( |
|
456 | - 'name' => __( 'Overview', 'lsx-health-plan' ), |
|
457 | - 'id' => 'description', |
|
458 | - 'type' => 'wysiwyg', |
|
459 | - ) |
|
460 | - ); |
|
461 | - |
|
462 | - if ( post_type_exists( 'workout' ) ) { |
|
463 | - $cmb->add_group_field( |
|
464 | - $group, |
|
465 | - array( |
|
466 | - 'name' => __( 'Workouts', 'lsx-health-plan' ), |
|
467 | - 'id' => 'connected_workouts', |
|
468 | - 'desc' => __( 'Connect the workout(s) that apply to this section.', 'lsx-health-plan' ), |
|
469 | - 'type' => 'post_search_ajax', |
|
470 | - 'limit' => 15, |
|
471 | - 'sortable' => true, |
|
472 | - 'query_args' => array( |
|
473 | - 'post_type' => array( 'workout' ), |
|
474 | - 'post_status' => array( 'publish' ), |
|
475 | - 'posts_per_page' => -1, |
|
476 | - ), |
|
477 | - 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-50', |
|
478 | - ) |
|
479 | - ); |
|
480 | - $cmb->add_group_field( |
|
481 | - $group, |
|
482 | - array( |
|
483 | - 'name' => __( 'Rest day', 'lsx-health-plan' ), |
|
484 | - 'id' => 'rest_day_enabled', |
|
485 | - 'type' => 'checkbox', |
|
486 | - 'value' => 1, |
|
487 | - 'default' => 0, |
|
488 | - 'description' => __( 'Enabling the rest day will add an item called "Rest" with no links.', 'lsx-health-plan' ), |
|
489 | - 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-50', |
|
490 | - ) |
|
491 | - ); |
|
492 | - } |
|
493 | - |
|
494 | - if ( post_type_exists( 'meal' ) ) { |
|
495 | - $cmb->add_group_field( |
|
496 | - $group, |
|
497 | - array( |
|
498 | - 'name' => __( 'Meals', 'lsx-health-plan' ), |
|
499 | - 'desc' => __( 'Connect the meal(s) that apply to this section.', 'lsx-health-plan' ), |
|
500 | - 'id' => 'connected_meals', |
|
501 | - 'type' => 'post_search_ajax', |
|
502 | - // Optional : |
|
503 | - 'limit' => 15, // Limit selection to X items only (default 1) |
|
504 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
505 | - 'query_args' => array( |
|
506 | - 'post_type' => array( 'meal' ), |
|
507 | - 'post_status' => array( 'publish' ), |
|
508 | - 'posts_per_page' => -1, |
|
509 | - ), |
|
510 | - 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-50', |
|
511 | - ) |
|
512 | - ); |
|
513 | - } |
|
514 | - if ( post_type_exists( 'tip' ) ) { |
|
515 | - $cmb->add_group_field( |
|
516 | - $group, |
|
517 | - array( |
|
518 | - 'name' => __( 'Tips', 'lsx-health-plan' ), |
|
519 | - 'id' => 'connected_tips', |
|
520 | - 'desc' => __( 'Connect the tip(s) that apply to this section.', 'lsx-health-plan' ), |
|
521 | - 'type' => 'post_search_ajax', |
|
522 | - // Optional : |
|
523 | - 'limit' => 15, // Limit selection to X items only (default 1) |
|
524 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
525 | - 'query_args' => array( |
|
526 | - 'post_type' => array( 'tip' ), |
|
527 | - 'post_status' => array( 'publish' ), |
|
528 | - 'posts_per_page' => -1, |
|
529 | - ), |
|
530 | - 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-50', |
|
531 | - ) |
|
532 | - ); |
|
533 | - } |
|
534 | - } |
|
535 | - |
|
536 | - /** |
|
537 | - * Holds the array for the single plan breadcrumbs. |
|
538 | - * |
|
539 | - * @var array $crumbs |
|
540 | - * @return array |
|
541 | - */ |
|
542 | - public function plan_breadcrumb_filter( $crumbs ) { |
|
543 | - if ( is_singular( 'plan' ) ) { |
|
544 | - $plan = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ); |
|
545 | - $plans = \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plan' ); |
|
546 | - $plan_name = get_the_title(); |
|
547 | - $url = get_post_type_archive_link( $plan ); |
|
548 | - $term_obj_list = get_the_terms( get_the_ID(), 'plan-type' ); |
|
549 | - $plan_type = $term_obj_list[0]->name; |
|
550 | - $plan_type_url = get_term_link( $term_obj_list[0]->term_id ); |
|
428 | + ) |
|
429 | + ); |
|
430 | + |
|
431 | + $cmb->add_group_field( |
|
432 | + $group, |
|
433 | + array( |
|
434 | + 'name' => __( 'Title', 'lsx-health-plan' ), |
|
435 | + 'id' => 'title', |
|
436 | + 'type' => 'text', |
|
437 | + 'desc' => __( 'e.g Day 1 / Week 1', 'lsx-health-plan' ), |
|
438 | + 'classes' => 'lsx-field-col lsx-field-col-50', |
|
439 | + ) |
|
440 | + ); |
|
441 | + |
|
442 | + $cmb->add_group_field( |
|
443 | + $group, |
|
444 | + array( |
|
445 | + 'name' => __( 'Group', 'lsx-health-plan' ), |
|
446 | + 'id' => 'group', |
|
447 | + 'type' => 'text', |
|
448 | + 'desc' => __( 'e.g Week 1 / January', 'lsx-health-plan' ), |
|
449 | + 'classes' => 'lsx-field-col lsx-field-col-50', |
|
450 | + ) |
|
451 | + ); |
|
452 | + |
|
453 | + $cmb->add_group_field( |
|
454 | + $group, |
|
455 | + array( |
|
456 | + 'name' => __( 'Overview', 'lsx-health-plan' ), |
|
457 | + 'id' => 'description', |
|
458 | + 'type' => 'wysiwyg', |
|
459 | + ) |
|
460 | + ); |
|
461 | + |
|
462 | + if ( post_type_exists( 'workout' ) ) { |
|
463 | + $cmb->add_group_field( |
|
464 | + $group, |
|
465 | + array( |
|
466 | + 'name' => __( 'Workouts', 'lsx-health-plan' ), |
|
467 | + 'id' => 'connected_workouts', |
|
468 | + 'desc' => __( 'Connect the workout(s) that apply to this section.', 'lsx-health-plan' ), |
|
469 | + 'type' => 'post_search_ajax', |
|
470 | + 'limit' => 15, |
|
471 | + 'sortable' => true, |
|
472 | + 'query_args' => array( |
|
473 | + 'post_type' => array( 'workout' ), |
|
474 | + 'post_status' => array( 'publish' ), |
|
475 | + 'posts_per_page' => -1, |
|
476 | + ), |
|
477 | + 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-50', |
|
478 | + ) |
|
479 | + ); |
|
480 | + $cmb->add_group_field( |
|
481 | + $group, |
|
482 | + array( |
|
483 | + 'name' => __( 'Rest day', 'lsx-health-plan' ), |
|
484 | + 'id' => 'rest_day_enabled', |
|
485 | + 'type' => 'checkbox', |
|
486 | + 'value' => 1, |
|
487 | + 'default' => 0, |
|
488 | + 'description' => __( 'Enabling the rest day will add an item called "Rest" with no links.', 'lsx-health-plan' ), |
|
489 | + 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-50', |
|
490 | + ) |
|
491 | + ); |
|
492 | + } |
|
493 | + |
|
494 | + if ( post_type_exists( 'meal' ) ) { |
|
495 | + $cmb->add_group_field( |
|
496 | + $group, |
|
497 | + array( |
|
498 | + 'name' => __( 'Meals', 'lsx-health-plan' ), |
|
499 | + 'desc' => __( 'Connect the meal(s) that apply to this section.', 'lsx-health-plan' ), |
|
500 | + 'id' => 'connected_meals', |
|
501 | + 'type' => 'post_search_ajax', |
|
502 | + // Optional : |
|
503 | + 'limit' => 15, // Limit selection to X items only (default 1) |
|
504 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
505 | + 'query_args' => array( |
|
506 | + 'post_type' => array( 'meal' ), |
|
507 | + 'post_status' => array( 'publish' ), |
|
508 | + 'posts_per_page' => -1, |
|
509 | + ), |
|
510 | + 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-50', |
|
511 | + ) |
|
512 | + ); |
|
513 | + } |
|
514 | + if ( post_type_exists( 'tip' ) ) { |
|
515 | + $cmb->add_group_field( |
|
516 | + $group, |
|
517 | + array( |
|
518 | + 'name' => __( 'Tips', 'lsx-health-plan' ), |
|
519 | + 'id' => 'connected_tips', |
|
520 | + 'desc' => __( 'Connect the tip(s) that apply to this section.', 'lsx-health-plan' ), |
|
521 | + 'type' => 'post_search_ajax', |
|
522 | + // Optional : |
|
523 | + 'limit' => 15, // Limit selection to X items only (default 1) |
|
524 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
525 | + 'query_args' => array( |
|
526 | + 'post_type' => array( 'tip' ), |
|
527 | + 'post_status' => array( 'publish' ), |
|
528 | + 'posts_per_page' => -1, |
|
529 | + ), |
|
530 | + 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-50', |
|
531 | + ) |
|
532 | + ); |
|
533 | + } |
|
534 | + } |
|
535 | + |
|
536 | + /** |
|
537 | + * Holds the array for the single plan breadcrumbs. |
|
538 | + * |
|
539 | + * @var array $crumbs |
|
540 | + * @return array |
|
541 | + */ |
|
542 | + public function plan_breadcrumb_filter( $crumbs ) { |
|
543 | + if ( is_singular( 'plan' ) ) { |
|
544 | + $plan = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ); |
|
545 | + $plans = \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plan' ); |
|
546 | + $plan_name = get_the_title(); |
|
547 | + $url = get_post_type_archive_link( $plan ); |
|
548 | + $term_obj_list = get_the_terms( get_the_ID(), 'plan-type' ); |
|
549 | + $plan_type = $term_obj_list[0]->name; |
|
550 | + $plan_type_url = get_term_link( $term_obj_list[0]->term_id ); |
|
551 | 551 | |
552 | - $crumbs[1] = array( |
|
553 | - 0 => $plans, |
|
554 | - 1 => $url, |
|
555 | - ); |
|
556 | - $crumbs[2] = array( |
|
557 | - 0 => $plan_type, |
|
558 | - 1 => $plan_type_url, |
|
559 | - ); |
|
560 | - $crumbs[3] = array( |
|
561 | - 0 => $plan_name, |
|
562 | - ); |
|
563 | - } |
|
564 | - return $crumbs; |
|
565 | - } |
|
552 | + $crumbs[1] = array( |
|
553 | + 0 => $plans, |
|
554 | + 1 => $url, |
|
555 | + ); |
|
556 | + $crumbs[2] = array( |
|
557 | + 0 => $plan_type, |
|
558 | + 1 => $plan_type_url, |
|
559 | + ); |
|
560 | + $crumbs[3] = array( |
|
561 | + 0 => $plan_name, |
|
562 | + ); |
|
563 | + } |
|
564 | + return $crumbs; |
|
565 | + } |
|
566 | 566 | } |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | <?php lsx_post_meta_single_bottom(); ?> |
25 | 25 | </div><!-- .entry-meta --> |
26 | 26 | <?php |
27 | - if ( is_singular( 'workout' ) ) { |
|
28 | - the_content(); |
|
29 | - } |
|
30 | - ?> |
|
27 | + if ( is_singular( 'workout' ) ) { |
|
28 | + the_content(); |
|
29 | + } |
|
30 | + ?> |
|
31 | 31 | <div class="entry-content"> |
32 | 32 | <div class="single-plan-inner workout-content"> |
33 | 33 | <?php |
34 | - if ( is_singular( 'workout' ) ) { ?> |
|
34 | + if ( is_singular( 'workout' ) ) { ?> |
|
35 | 35 | <div class="single-plan-section-title workout title-lined"> |
36 | 36 | <?php lsx_get_svg_icon( 'work.svg' ); ?> |
37 | 37 | <h2><?php the_title(); ?></h2> |
38 | 38 | <?php if ( class_exists( 'LSX_Sharing' ) ) { |
39 | - lsx_content_sharing(); |
|
40 | - } ?> |
|
39 | + lsx_content_sharing(); |
|
40 | + } ?> |
|
41 | 41 | </div> |
42 | 42 | <?php } else { ?> |
43 | 43 | <div class="single-plan-section-title workout title-lined"> |
@@ -60,5 +60,5 @@ discard block |
||
60 | 60 | <?php } ?> |
61 | 61 | <?php |
62 | 62 | if ( ! empty( $connected_articles ) ) { |
63 | - lsx_hp_single_related( $connected_articles, __( 'Related articles', 'lsx-health-plan' ) ); |
|
63 | + lsx_hp_single_related( $connected_articles, __( 'Related articles', 'lsx-health-plan' ) ); |
|
64 | 64 | } |
@@ -14,151 +14,151 @@ |
||
14 | 14 | */ |
15 | 15 | class Tip { |
16 | 16 | |
17 | - /** |
|
18 | - * Holds class instance |
|
19 | - * |
|
20 | - * @since 1.0.0 |
|
21 | - * |
|
22 | - * @var object \lsx_health_plan\classes\Tip() |
|
23 | - */ |
|
24 | - protected static $instance = null; |
|
17 | + /** |
|
18 | + * Holds class instance |
|
19 | + * |
|
20 | + * @since 1.0.0 |
|
21 | + * |
|
22 | + * @var object \lsx_health_plan\classes\Tip() |
|
23 | + */ |
|
24 | + protected static $instance = null; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Holds post_type slug used as an index |
|
28 | - * |
|
29 | - * @since 1.0.0 |
|
30 | - * |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - public $slug = 'tip'; |
|
26 | + /** |
|
27 | + * Holds post_type slug used as an index |
|
28 | + * |
|
29 | + * @since 1.0.0 |
|
30 | + * |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + public $slug = 'tip'; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Constructor |
|
37 | - */ |
|
38 | - public function __construct() { |
|
39 | - $this->default_types = array( |
|
40 | - \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' ), |
|
41 | - \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ), |
|
42 | - \lsx_health_plan\functions\get_option( 'endpoint_recipe_single', 'recipe' ), |
|
43 | - \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ), |
|
44 | - \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ), |
|
45 | - ); |
|
46 | - add_action( 'init', array( $this, 'register_post_type' ) ); |
|
47 | - add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
48 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
49 | - add_action( 'cmb2_admin_init', array( $this, 'tips_connections' ), 15 ); |
|
50 | - } |
|
35 | + /** |
|
36 | + * Constructor |
|
37 | + */ |
|
38 | + public function __construct() { |
|
39 | + $this->default_types = array( |
|
40 | + \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' ), |
|
41 | + \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ), |
|
42 | + \lsx_health_plan\functions\get_option( 'endpoint_recipe_single', 'recipe' ), |
|
43 | + \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ), |
|
44 | + \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ), |
|
45 | + ); |
|
46 | + add_action( 'init', array( $this, 'register_post_type' ) ); |
|
47 | + add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
48 | + add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
49 | + add_action( 'cmb2_admin_init', array( $this, 'tips_connections' ), 15 ); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Return an instance of this class. |
|
54 | - * |
|
55 | - * @since 1.0.0 |
|
56 | - * |
|
57 | - * @return object \lsx_health_plan\classes\Tip() A single instance of this class. |
|
58 | - */ |
|
59 | - public static function get_instance() { |
|
60 | - // If the single instance hasn't been set, set it now. |
|
61 | - if ( null === self::$instance ) { |
|
62 | - self::$instance = new self(); |
|
63 | - } |
|
64 | - return self::$instance; |
|
65 | - } |
|
66 | - /** |
|
67 | - * Register the post type. |
|
68 | - */ |
|
69 | - public function register_post_type() { |
|
70 | - $labels = array( |
|
71 | - 'name' => esc_html__( 'Tips', 'lsx-health-plan' ), |
|
72 | - 'singular_name' => esc_html__( 'Tip', 'lsx-health-plan' ), |
|
73 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
74 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
75 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
76 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
77 | - 'all_items' => esc_html__( 'All Tips', 'lsx-health-plan' ), |
|
78 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
79 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
80 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
81 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
82 | - 'parent_item_colon' => '', |
|
83 | - 'menu_name' => esc_html__( 'Tips', 'lsx-health-plan' ), |
|
84 | - ); |
|
85 | - $args = array( |
|
86 | - 'labels' => $labels, |
|
87 | - 'public' => true, |
|
88 | - 'publicly_queryable' => false, |
|
89 | - 'show_ui' => true, |
|
90 | - 'show_in_menu' => false, |
|
91 | - 'show_in_rest' => true, |
|
92 | - 'menu_icon' => 'dashicons-admin-post', |
|
93 | - 'query_var' => true, |
|
94 | - 'rewrite' => false, |
|
95 | - 'capability_type' => 'post', |
|
96 | - 'has_archive' => false, |
|
97 | - 'hierarchical' => false, |
|
98 | - 'menu_position' => null, |
|
99 | - 'supports' => array( |
|
100 | - 'title', |
|
101 | - 'editor', |
|
102 | - 'custom-fields', |
|
103 | - ), |
|
104 | - ); |
|
105 | - register_post_type( 'tip', $args ); |
|
106 | - } |
|
52 | + /** |
|
53 | + * Return an instance of this class. |
|
54 | + * |
|
55 | + * @since 1.0.0 |
|
56 | + * |
|
57 | + * @return object \lsx_health_plan\classes\Tip() A single instance of this class. |
|
58 | + */ |
|
59 | + public static function get_instance() { |
|
60 | + // If the single instance hasn't been set, set it now. |
|
61 | + if ( null === self::$instance ) { |
|
62 | + self::$instance = new self(); |
|
63 | + } |
|
64 | + return self::$instance; |
|
65 | + } |
|
66 | + /** |
|
67 | + * Register the post type. |
|
68 | + */ |
|
69 | + public function register_post_type() { |
|
70 | + $labels = array( |
|
71 | + 'name' => esc_html__( 'Tips', 'lsx-health-plan' ), |
|
72 | + 'singular_name' => esc_html__( 'Tip', 'lsx-health-plan' ), |
|
73 | + 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
74 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
75 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
76 | + 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
77 | + 'all_items' => esc_html__( 'All Tips', 'lsx-health-plan' ), |
|
78 | + 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
79 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
80 | + 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
81 | + 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
82 | + 'parent_item_colon' => '', |
|
83 | + 'menu_name' => esc_html__( 'Tips', 'lsx-health-plan' ), |
|
84 | + ); |
|
85 | + $args = array( |
|
86 | + 'labels' => $labels, |
|
87 | + 'public' => true, |
|
88 | + 'publicly_queryable' => false, |
|
89 | + 'show_ui' => true, |
|
90 | + 'show_in_menu' => false, |
|
91 | + 'show_in_rest' => true, |
|
92 | + 'menu_icon' => 'dashicons-admin-post', |
|
93 | + 'query_var' => true, |
|
94 | + 'rewrite' => false, |
|
95 | + 'capability_type' => 'post', |
|
96 | + 'has_archive' => false, |
|
97 | + 'hierarchical' => false, |
|
98 | + 'menu_position' => null, |
|
99 | + 'supports' => array( |
|
100 | + 'title', |
|
101 | + 'editor', |
|
102 | + 'custom-fields', |
|
103 | + ), |
|
104 | + ); |
|
105 | + register_post_type( 'tip', $args ); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Registers the Recipes under the Meals Post type menu. |
|
110 | - * |
|
111 | - * @return void |
|
112 | - */ |
|
113 | - public function register_menus() { |
|
114 | - add_submenu_page( 'edit.php?post_type=plan', esc_html__( 'Tips', 'lsx-health-plan' ), esc_html__( 'Tips', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=tip' ); |
|
115 | - } |
|
108 | + /** |
|
109 | + * Registers the Recipes under the Meals Post type menu. |
|
110 | + * |
|
111 | + * @return void |
|
112 | + */ |
|
113 | + public function register_menus() { |
|
114 | + add_submenu_page( 'edit.php?post_type=plan', esc_html__( 'Tips', 'lsx-health-plan' ), esc_html__( 'Tips', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=tip' ); |
|
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['tip']['connected_plans'] = 'plan_connected_tips'; |
|
125 | - $connections['plan']['plan_connected_tips'] = 'connected_plans'; |
|
126 | - return $connections; |
|
127 | - } |
|
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['tip']['connected_plans'] = 'plan_connected_tips'; |
|
125 | + $connections['plan']['plan_connected_tips'] = 'connected_plans'; |
|
126 | + return $connections; |
|
127 | + } |
|
128 | 128 | |
129 | - /** |
|
130 | - * Registers the workout connections on the plan post type. |
|
131 | - * |
|
132 | - * @return void |
|
133 | - */ |
|
134 | - public function tips_connections() { |
|
135 | - foreach ( $this->default_types as $type => $default_type ) { |
|
136 | - $cmb = new_cmb2_box( |
|
137 | - array( |
|
138 | - 'id' => $default_type . '_tips_connections_metabox', |
|
139 | - 'title' => __( 'Related Tips', 'lsx-health-plan' ), |
|
140 | - 'object_types' => array( $default_type ), // Post types. |
|
141 | - 'context' => 'normal', |
|
142 | - 'priority' => 'high', |
|
143 | - 'show_names' => false, |
|
144 | - ) |
|
145 | - ); |
|
146 | - $cmb->add_field( |
|
147 | - array( |
|
148 | - 'name' => __( 'Tips', 'lsx-health-plan' ), |
|
149 | - 'id' => $default_type . '_connected_tips', |
|
150 | - 'desc' => __( 'Connect the tips that apply to this ', 'lsx-health-plan' ) . $default_type, |
|
151 | - 'type' => 'post_search_ajax', |
|
152 | - 'limit' => 15, |
|
153 | - 'sortable' => true, |
|
154 | - 'query_args' => array( |
|
155 | - 'post_type' => array( 'tip' ), |
|
156 | - 'post_status' => array( 'publish' ), |
|
157 | - 'posts_per_page' => -1, |
|
158 | - ), |
|
159 | - ) |
|
160 | - ); |
|
161 | - } |
|
162 | - } |
|
129 | + /** |
|
130 | + * Registers the workout connections on the plan post type. |
|
131 | + * |
|
132 | + * @return void |
|
133 | + */ |
|
134 | + public function tips_connections() { |
|
135 | + foreach ( $this->default_types as $type => $default_type ) { |
|
136 | + $cmb = new_cmb2_box( |
|
137 | + array( |
|
138 | + 'id' => $default_type . '_tips_connections_metabox', |
|
139 | + 'title' => __( 'Related Tips', 'lsx-health-plan' ), |
|
140 | + 'object_types' => array( $default_type ), // Post types. |
|
141 | + 'context' => 'normal', |
|
142 | + 'priority' => 'high', |
|
143 | + 'show_names' => false, |
|
144 | + ) |
|
145 | + ); |
|
146 | + $cmb->add_field( |
|
147 | + array( |
|
148 | + 'name' => __( 'Tips', 'lsx-health-plan' ), |
|
149 | + 'id' => $default_type . '_connected_tips', |
|
150 | + 'desc' => __( 'Connect the tips that apply to this ', 'lsx-health-plan' ) . $default_type, |
|
151 | + 'type' => 'post_search_ajax', |
|
152 | + 'limit' => 15, |
|
153 | + 'sortable' => true, |
|
154 | + 'query_args' => array( |
|
155 | + 'post_type' => array( 'tip' ), |
|
156 | + 'post_status' => array( 'publish' ), |
|
157 | + 'posts_per_page' => -1, |
|
158 | + ), |
|
159 | + ) |
|
160 | + ); |
|
161 | + } |
|
162 | + } |
|
163 | 163 | |
164 | 164 | } |
@@ -12,239 +12,239 @@ |
||
12 | 12 | */ |
13 | 13 | class Workout { |
14 | 14 | |
15 | - /** |
|
16 | - * Holds class instance |
|
17 | - * |
|
18 | - * @since 1.0.0 |
|
19 | - * |
|
20 | - * @var object \lsx_health_plan\classes\admin\Workout() |
|
21 | - */ |
|
22 | - protected static $instance = null; |
|
15 | + /** |
|
16 | + * Holds class instance |
|
17 | + * |
|
18 | + * @since 1.0.0 |
|
19 | + * |
|
20 | + * @var object \lsx_health_plan\classes\admin\Workout() |
|
21 | + */ |
|
22 | + protected static $instance = null; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Constructor |
|
26 | - */ |
|
27 | - public function __construct() { |
|
28 | - add_action( 'lsx_hp_settings_page_workout_top', array( $this, 'settings' ), 1, 1 ); |
|
29 | - } |
|
24 | + /** |
|
25 | + * Constructor |
|
26 | + */ |
|
27 | + public function __construct() { |
|
28 | + add_action( 'lsx_hp_settings_page_workout_top', array( $this, 'settings' ), 1, 1 ); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Return an instance of this class. |
|
33 | - * |
|
34 | - * @since 1.0.0 |
|
35 | - * |
|
36 | - * @return object \lsx_health_plan\classes\admin\Workout() A single instance of this class. |
|
37 | - */ |
|
38 | - public static function get_instance() { |
|
39 | - // If the single instance hasn't been set, set it now. |
|
40 | - if ( null === self::$instance ) { |
|
41 | - self::$instance = new self(); |
|
42 | - } |
|
43 | - return self::$instance; |
|
44 | - } |
|
31 | + /** |
|
32 | + * Return an instance of this class. |
|
33 | + * |
|
34 | + * @since 1.0.0 |
|
35 | + * |
|
36 | + * @return object \lsx_health_plan\classes\admin\Workout() A single instance of this class. |
|
37 | + */ |
|
38 | + public static function get_instance() { |
|
39 | + // If the single instance hasn't been set, set it now. |
|
40 | + if ( null === self::$instance ) { |
|
41 | + self::$instance = new self(); |
|
42 | + } |
|
43 | + return self::$instance; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Registers the general settings. |
|
48 | - * |
|
49 | - * @param object $cmb new_cmb2_box(). |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - public function settings( $cmb ) { |
|
53 | - $cmb->add_field( |
|
54 | - array( |
|
55 | - 'name' => __( 'Disable Workouts', 'lsx-health-plan' ), |
|
56 | - 'id' => 'workout_disabled', |
|
57 | - 'type' => 'checkbox', |
|
58 | - 'value' => 1, |
|
59 | - 'default' => 0, |
|
60 | - 'description' => __( 'Disable workout post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
61 | - ) |
|
62 | - ); |
|
63 | - if ( post_type_exists( 'workout' ) ) { |
|
64 | - $cmb->add_field( |
|
65 | - array( |
|
66 | - 'name' => __( 'Your Workout Intro', 'lsx-health-plan' ), |
|
67 | - 'id' => 'workout_intro', |
|
68 | - 'type' => 'wysiwyg', |
|
69 | - 'value' => '', |
|
70 | - 'default' => __( "Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan' ), |
|
71 | - 'options' => array( |
|
72 | - 'textarea_rows' => get_option('default_post_edit_rows', 6), |
|
73 | - ), |
|
74 | - ) |
|
75 | - ); |
|
76 | - } |
|
77 | - $cmb->add_field( |
|
78 | - array( |
|
79 | - 'before_row' => '<h4><b><u>Layout Options</u></b></h4>', |
|
80 | - 'id' => 'workout_tab_layout', |
|
81 | - 'type' => 'select', |
|
82 | - 'name' => __( 'Workout Tab Layout', 'lsx-health-plan' ), |
|
83 | - 'description' => __( 'Choose the layout for the workouts.', 'lsx-health-plan' ), |
|
84 | - 'options' => array( |
|
85 | - 'table' => __( 'Table', 'lsx-health-plan' ), |
|
86 | - 'list' => __( 'List', 'lsx-health-plan' ), |
|
87 | - 'grid' => __( 'Grid', 'lsx-health-plan' ), |
|
88 | - ), |
|
89 | - ) |
|
90 | - ); |
|
91 | - $cmb->add_field( |
|
92 | - array( |
|
93 | - 'id' => 'workout_tab_link', |
|
94 | - 'type' => 'select', |
|
95 | - 'name' => __( 'Workout Tab Link', 'lsx-health-plan' ), |
|
96 | - 'description' => __( 'Choose to show the excerpt, full content or nothing.', 'lsx-health-plan' ), |
|
97 | - 'options' => array( |
|
98 | - 'none' => __( 'None', 'lsx-health-plan' ), |
|
99 | - 'single' => __( 'Single', 'lsx-health-plan' ), |
|
100 | - 'modal' => __( 'Modal', 'lsx-health-plan' ), |
|
101 | - ), |
|
102 | - 'default' => '', |
|
103 | - ) |
|
104 | - ); |
|
105 | - $cmb->add_field( |
|
106 | - array( |
|
107 | - 'id' => 'workout_tab_modal_content', |
|
108 | - 'type' => 'select', |
|
109 | - 'name' => __( 'Modal Content', 'lsx-health-plan' ), |
|
110 | - 'description' => __( 'Choose to show the excerpt, full content or nothing. For the modal content only', 'lsx-health-plan' ), |
|
111 | - 'options' => array( |
|
112 | - '' => __( 'None', 'lsx-health-plan' ), |
|
113 | - 'excerpt' => __( 'Excerpt', 'lsx-health-plan' ), |
|
114 | - 'full' => __( 'Full Content', 'lsx-health-plan' ), |
|
115 | - ), |
|
116 | - 'default' => '', |
|
117 | - ) |
|
118 | - ); |
|
119 | - $cmb->add_field( |
|
120 | - array( |
|
121 | - 'id' => 'workout_tab_columns', |
|
122 | - 'type' => 'select', |
|
123 | - 'name' => __( 'Grid Columns', 'lsx-health-plan' ), |
|
124 | - 'description' => __( 'If you are displaying a grid, set the amount of columns you want to use.', 'lsx-health-plan' ), |
|
125 | - 'options' => array( |
|
126 | - '12' => __( '1', 'lsx-health-plan' ), |
|
127 | - '6' => __( '2', 'lsx-health-plan' ), |
|
128 | - '4' => __( '3', 'lsx-health-plan' ), |
|
129 | - '3' => __( '4', 'lsx-health-plan' ), |
|
130 | - '2' => __( '6', 'lsx-health-plan' ), |
|
131 | - ), |
|
132 | - 'default' => '4', |
|
133 | - ) |
|
134 | - ); |
|
135 | - $cmb->add_field( |
|
136 | - array( |
|
137 | - 'id' => 'workout_tab_content', |
|
138 | - 'type' => 'select', |
|
139 | - 'name' => __( 'Grid Content', 'lsx-health-plan' ), |
|
140 | - 'description' => __( 'Choose to show the excerpt, full content or nothing. For the grid layout only', 'lsx-health-plan' ), |
|
141 | - 'options' => array( |
|
142 | - '' => __( 'None', 'lsx-health-plan' ), |
|
143 | - 'excerpt' => __( 'Excerpt', 'lsx-health-plan' ), |
|
144 | - 'full' => __( 'Full Content', 'lsx-health-plan' ), |
|
145 | - ), |
|
146 | - 'default' => '', |
|
147 | - ) |
|
148 | - ); |
|
46 | + /** |
|
47 | + * Registers the general settings. |
|
48 | + * |
|
49 | + * @param object $cmb new_cmb2_box(). |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + public function settings( $cmb ) { |
|
53 | + $cmb->add_field( |
|
54 | + array( |
|
55 | + 'name' => __( 'Disable Workouts', 'lsx-health-plan' ), |
|
56 | + 'id' => 'workout_disabled', |
|
57 | + 'type' => 'checkbox', |
|
58 | + 'value' => 1, |
|
59 | + 'default' => 0, |
|
60 | + 'description' => __( 'Disable workout post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
61 | + ) |
|
62 | + ); |
|
63 | + if ( post_type_exists( 'workout' ) ) { |
|
64 | + $cmb->add_field( |
|
65 | + array( |
|
66 | + 'name' => __( 'Your Workout Intro', 'lsx-health-plan' ), |
|
67 | + 'id' => 'workout_intro', |
|
68 | + 'type' => 'wysiwyg', |
|
69 | + 'value' => '', |
|
70 | + 'default' => __( "Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan' ), |
|
71 | + 'options' => array( |
|
72 | + 'textarea_rows' => get_option('default_post_edit_rows', 6), |
|
73 | + ), |
|
74 | + ) |
|
75 | + ); |
|
76 | + } |
|
77 | + $cmb->add_field( |
|
78 | + array( |
|
79 | + 'before_row' => '<h4><b><u>Layout Options</u></b></h4>', |
|
80 | + 'id' => 'workout_tab_layout', |
|
81 | + 'type' => 'select', |
|
82 | + 'name' => __( 'Workout Tab Layout', 'lsx-health-plan' ), |
|
83 | + 'description' => __( 'Choose the layout for the workouts.', 'lsx-health-plan' ), |
|
84 | + 'options' => array( |
|
85 | + 'table' => __( 'Table', 'lsx-health-plan' ), |
|
86 | + 'list' => __( 'List', 'lsx-health-plan' ), |
|
87 | + 'grid' => __( 'Grid', 'lsx-health-plan' ), |
|
88 | + ), |
|
89 | + ) |
|
90 | + ); |
|
91 | + $cmb->add_field( |
|
92 | + array( |
|
93 | + 'id' => 'workout_tab_link', |
|
94 | + 'type' => 'select', |
|
95 | + 'name' => __( 'Workout Tab Link', 'lsx-health-plan' ), |
|
96 | + 'description' => __( 'Choose to show the excerpt, full content or nothing.', 'lsx-health-plan' ), |
|
97 | + 'options' => array( |
|
98 | + 'none' => __( 'None', 'lsx-health-plan' ), |
|
99 | + 'single' => __( 'Single', 'lsx-health-plan' ), |
|
100 | + 'modal' => __( 'Modal', 'lsx-health-plan' ), |
|
101 | + ), |
|
102 | + 'default' => '', |
|
103 | + ) |
|
104 | + ); |
|
105 | + $cmb->add_field( |
|
106 | + array( |
|
107 | + 'id' => 'workout_tab_modal_content', |
|
108 | + 'type' => 'select', |
|
109 | + 'name' => __( 'Modal Content', 'lsx-health-plan' ), |
|
110 | + 'description' => __( 'Choose to show the excerpt, full content or nothing. For the modal content only', 'lsx-health-plan' ), |
|
111 | + 'options' => array( |
|
112 | + '' => __( 'None', 'lsx-health-plan' ), |
|
113 | + 'excerpt' => __( 'Excerpt', 'lsx-health-plan' ), |
|
114 | + 'full' => __( 'Full Content', 'lsx-health-plan' ), |
|
115 | + ), |
|
116 | + 'default' => '', |
|
117 | + ) |
|
118 | + ); |
|
119 | + $cmb->add_field( |
|
120 | + array( |
|
121 | + 'id' => 'workout_tab_columns', |
|
122 | + 'type' => 'select', |
|
123 | + 'name' => __( 'Grid Columns', 'lsx-health-plan' ), |
|
124 | + 'description' => __( 'If you are displaying a grid, set the amount of columns you want to use.', 'lsx-health-plan' ), |
|
125 | + 'options' => array( |
|
126 | + '12' => __( '1', 'lsx-health-plan' ), |
|
127 | + '6' => __( '2', 'lsx-health-plan' ), |
|
128 | + '4' => __( '3', 'lsx-health-plan' ), |
|
129 | + '3' => __( '4', 'lsx-health-plan' ), |
|
130 | + '2' => __( '6', 'lsx-health-plan' ), |
|
131 | + ), |
|
132 | + 'default' => '4', |
|
133 | + ) |
|
134 | + ); |
|
135 | + $cmb->add_field( |
|
136 | + array( |
|
137 | + 'id' => 'workout_tab_content', |
|
138 | + 'type' => 'select', |
|
139 | + 'name' => __( 'Grid Content', 'lsx-health-plan' ), |
|
140 | + 'description' => __( 'Choose to show the excerpt, full content or nothing. For the grid layout only', 'lsx-health-plan' ), |
|
141 | + 'options' => array( |
|
142 | + '' => __( 'None', 'lsx-health-plan' ), |
|
143 | + 'excerpt' => __( 'Excerpt', 'lsx-health-plan' ), |
|
144 | + 'full' => __( 'Full Content', 'lsx-health-plan' ), |
|
145 | + ), |
|
146 | + 'default' => '', |
|
147 | + ) |
|
148 | + ); |
|
149 | 149 | |
150 | - $cmb->add_field( |
|
151 | - array( |
|
152 | - 'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>', |
|
153 | - 'name' => __( 'Single Workout Slug', 'lsx-health-plan' ), |
|
154 | - 'id' => 'endpoint_workout', |
|
155 | - 'type' => 'input', |
|
156 | - 'value' => '', |
|
157 | - 'default' => 'workout', |
|
158 | - ) |
|
159 | - ); |
|
160 | - $cmb->add_field( |
|
161 | - array( |
|
162 | - 'name' => __( 'Workouts Archive Slug', 'lsx-health-plan' ), |
|
163 | - 'id' => 'endpoint_workout_archive', |
|
164 | - 'type' => 'input', |
|
165 | - 'value' => '', |
|
166 | - 'default' => 'workouts', |
|
167 | - ) |
|
168 | - ); |
|
169 | - $cmb->add_field( |
|
170 | - array( |
|
171 | - 'name' => __( 'Warm Up Slug', 'lsx-health-plan' ), |
|
172 | - 'id' => 'endpoint_warm_up', |
|
173 | - 'type' => 'input', |
|
174 | - 'value' => '', |
|
175 | - 'default' => 'warm-up', |
|
176 | - ) |
|
177 | - ); |
|
150 | + $cmb->add_field( |
|
151 | + array( |
|
152 | + 'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>', |
|
153 | + 'name' => __( 'Single Workout Slug', 'lsx-health-plan' ), |
|
154 | + 'id' => 'endpoint_workout', |
|
155 | + 'type' => 'input', |
|
156 | + 'value' => '', |
|
157 | + 'default' => 'workout', |
|
158 | + ) |
|
159 | + ); |
|
160 | + $cmb->add_field( |
|
161 | + array( |
|
162 | + 'name' => __( 'Workouts Archive Slug', 'lsx-health-plan' ), |
|
163 | + 'id' => 'endpoint_workout_archive', |
|
164 | + 'type' => 'input', |
|
165 | + 'value' => '', |
|
166 | + 'default' => 'workouts', |
|
167 | + ) |
|
168 | + ); |
|
169 | + $cmb->add_field( |
|
170 | + array( |
|
171 | + 'name' => __( 'Warm Up Slug', 'lsx-health-plan' ), |
|
172 | + 'id' => 'endpoint_warm_up', |
|
173 | + 'type' => 'input', |
|
174 | + 'value' => '', |
|
175 | + 'default' => 'warm-up', |
|
176 | + ) |
|
177 | + ); |
|
178 | 178 | |
179 | 179 | |
180 | - $cmb->add_field( |
|
181 | - array( |
|
182 | - 'before_row' => '<h4><b><u>Default Options</u></b></h4>', |
|
183 | - 'name' => __( 'Warm Up', 'lsx-health-plan' ), |
|
184 | - 'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ), |
|
185 | - 'limit' => 1, |
|
186 | - 'id' => 'plan_warmup', |
|
187 | - 'type' => 'post_search_ajax', |
|
188 | - 'query_args' => array( |
|
189 | - 'post_type' => 'post', |
|
190 | - 'post_status' => array( 'publish' ), |
|
191 | - 'posts_per_page' => -1, |
|
192 | - ), |
|
193 | - ) |
|
194 | - ); |
|
195 | - $cmb->add_field( |
|
196 | - array( |
|
197 | - 'name' => __( 'Workout', 'lsx-health-plan' ), |
|
198 | - 'description' => __( 'Set a default workout routine.', 'lsx-health-plan' ), |
|
199 | - 'limit' => 1, |
|
200 | - 'id' => 'connected_workouts', |
|
201 | - 'type' => 'post_search_ajax', |
|
202 | - 'query_args' => array( |
|
203 | - 'post_type' => 'workout', |
|
204 | - 'post_status' => array( 'publish' ), |
|
205 | - 'posts_per_page' => -1, |
|
206 | - ), |
|
207 | - ) |
|
208 | - ); |
|
209 | - if ( function_exists( 'download_monitor' ) ) { |
|
210 | - $page_url = 'https://wordpress.org/plugins/download-monitor/'; |
|
211 | - $plugin_name = 'Download Monitor'; |
|
212 | - $description = sprintf( |
|
213 | - /* translators: %s: The subscription info */ |
|
214 | - __( 'If you are using <a target="_blank" href="%1$s">%2$s</a> you can set a default download file for your meal here.', 'lsx-search' ), |
|
215 | - $page_url, |
|
216 | - $plugin_name |
|
217 | - ); |
|
218 | - $cmb->add_field( |
|
219 | - array( |
|
220 | - 'name' => __( 'Default Warm Up PDF', 'lsx-health-plan' ), |
|
221 | - 'description' => $description, |
|
222 | - 'id' => 'download_page', |
|
223 | - 'type' => 'post_search_ajax', |
|
224 | - 'limit' => 1, |
|
225 | - 'query_args' => array( |
|
226 | - 'post_type' => array( 'dlm_download' ), |
|
227 | - 'post_status' => array( 'publish' ), |
|
228 | - 'posts_per_page' => -1, |
|
229 | - ), |
|
230 | - ) |
|
231 | - ); |
|
232 | - $cmb->add_field( |
|
233 | - array( |
|
234 | - 'name' => __( 'Default Workout PDF', 'lsx-health-plan' ), |
|
235 | - 'description' => $description, |
|
236 | - 'id' => 'download_workout', |
|
237 | - 'type' => 'post_search_ajax', |
|
238 | - 'limit' => 1, |
|
239 | - 'query_args' => array( |
|
240 | - 'post_type' => array( 'dlm_download' ), |
|
241 | - 'post_status' => array( 'publish' ), |
|
242 | - 'posts_per_page' => -1, |
|
243 | - ), |
|
244 | - 'after_row' => __( '<p style="font-style: italic;">If you have changed any URL slugs, please remember re-save your permalinks in Settings > Permalinks.</p>', 'lsx-health-plan' ), |
|
245 | - ) |
|
246 | - ); |
|
247 | - } |
|
248 | - } |
|
180 | + $cmb->add_field( |
|
181 | + array( |
|
182 | + 'before_row' => '<h4><b><u>Default Options</u></b></h4>', |
|
183 | + 'name' => __( 'Warm Up', 'lsx-health-plan' ), |
|
184 | + 'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ), |
|
185 | + 'limit' => 1, |
|
186 | + 'id' => 'plan_warmup', |
|
187 | + 'type' => 'post_search_ajax', |
|
188 | + 'query_args' => array( |
|
189 | + 'post_type' => 'post', |
|
190 | + 'post_status' => array( 'publish' ), |
|
191 | + 'posts_per_page' => -1, |
|
192 | + ), |
|
193 | + ) |
|
194 | + ); |
|
195 | + $cmb->add_field( |
|
196 | + array( |
|
197 | + 'name' => __( 'Workout', 'lsx-health-plan' ), |
|
198 | + 'description' => __( 'Set a default workout routine.', 'lsx-health-plan' ), |
|
199 | + 'limit' => 1, |
|
200 | + 'id' => 'connected_workouts', |
|
201 | + 'type' => 'post_search_ajax', |
|
202 | + 'query_args' => array( |
|
203 | + 'post_type' => 'workout', |
|
204 | + 'post_status' => array( 'publish' ), |
|
205 | + 'posts_per_page' => -1, |
|
206 | + ), |
|
207 | + ) |
|
208 | + ); |
|
209 | + if ( function_exists( 'download_monitor' ) ) { |
|
210 | + $page_url = 'https://wordpress.org/plugins/download-monitor/'; |
|
211 | + $plugin_name = 'Download Monitor'; |
|
212 | + $description = sprintf( |
|
213 | + /* translators: %s: The subscription info */ |
|
214 | + __( 'If you are using <a target="_blank" href="%1$s">%2$s</a> you can set a default download file for your meal here.', 'lsx-search' ), |
|
215 | + $page_url, |
|
216 | + $plugin_name |
|
217 | + ); |
|
218 | + $cmb->add_field( |
|
219 | + array( |
|
220 | + 'name' => __( 'Default Warm Up PDF', 'lsx-health-plan' ), |
|
221 | + 'description' => $description, |
|
222 | + 'id' => 'download_page', |
|
223 | + 'type' => 'post_search_ajax', |
|
224 | + 'limit' => 1, |
|
225 | + 'query_args' => array( |
|
226 | + 'post_type' => array( 'dlm_download' ), |
|
227 | + 'post_status' => array( 'publish' ), |
|
228 | + 'posts_per_page' => -1, |
|
229 | + ), |
|
230 | + ) |
|
231 | + ); |
|
232 | + $cmb->add_field( |
|
233 | + array( |
|
234 | + 'name' => __( 'Default Workout PDF', 'lsx-health-plan' ), |
|
235 | + 'description' => $description, |
|
236 | + 'id' => 'download_workout', |
|
237 | + 'type' => 'post_search_ajax', |
|
238 | + 'limit' => 1, |
|
239 | + 'query_args' => array( |
|
240 | + 'post_type' => array( 'dlm_download' ), |
|
241 | + 'post_status' => array( 'publish' ), |
|
242 | + 'posts_per_page' => -1, |
|
243 | + ), |
|
244 | + 'after_row' => __( '<p style="font-style: italic;">If you have changed any URL slugs, please remember re-save your permalinks in Settings > Permalinks.</p>', 'lsx-health-plan' ), |
|
245 | + ) |
|
246 | + ); |
|
247 | + } |
|
248 | + } |
|
249 | 249 | } |
250 | 250 | Workout::get_instance(); |
@@ -10,387 +10,387 @@ |
||
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 | - * Constructor |
|
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_action( 'init', array( $this, 'workout_type_taxonomy_setup' ) ); |
|
38 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
39 | - add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 ); |
|
40 | - add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) ); |
|
41 | - add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
31 | + /** |
|
32 | + * Constructor |
|
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_action( 'init', array( $this, 'workout_type_taxonomy_setup' ) ); |
|
38 | + add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
39 | + add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 ); |
|
40 | + add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) ); |
|
41 | + add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
42 | 42 | |
43 | - // Template Redirects. |
|
44 | - add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 ); |
|
45 | - add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
46 | - } |
|
43 | + // Template Redirects. |
|
44 | + add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 ); |
|
45 | + add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Return an instance of this class. |
|
50 | - * |
|
51 | - * @since 1.0.0 |
|
52 | - * |
|
53 | - * @return object \lsx_health_plan\classes\Workout() A single instance of this class. |
|
54 | - */ |
|
55 | - public static function get_instance() { |
|
56 | - // If the single instance hasn't been set, set it now. |
|
57 | - if ( null === self::$instance ) { |
|
58 | - self::$instance = new self(); |
|
59 | - } |
|
60 | - return self::$instance; |
|
61 | - } |
|
62 | - /** |
|
63 | - * Register the post type. |
|
64 | - */ |
|
65 | - public function register_post_type() { |
|
66 | - $labels = array( |
|
67 | - 'name' => esc_html__( 'Workouts', 'lsx-health-plan' ), |
|
68 | - 'singular_name' => esc_html__( 'Workout', 'lsx-health-plan' ), |
|
69 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
70 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
71 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
72 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
73 | - 'all_items' => esc_html__( 'All Workouts', 'lsx-health-plan' ), |
|
74 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
75 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
76 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
77 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
78 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
79 | - 'menu_name' => esc_html__( 'Workouts', 'lsx-health-plan' ), |
|
80 | - ); |
|
81 | - $args = array( |
|
82 | - 'labels' => $labels, |
|
83 | - 'public' => true, |
|
84 | - 'publicly_queryable' => true, |
|
85 | - 'show_ui' => true, |
|
86 | - 'show_in_menu' => true, |
|
87 | - 'show_in_rest' => true, |
|
88 | - 'menu_icon' => 'dashicons-universal-access', |
|
89 | - 'query_var' => true, |
|
90 | - 'rewrite' => array( |
|
91 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ), |
|
92 | - ), |
|
93 | - 'capability_type' => 'page', |
|
94 | - 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workouts' ), |
|
95 | - 'hierarchical' => true, |
|
96 | - 'menu_position' => null, |
|
97 | - 'supports' => array( |
|
98 | - 'title', |
|
99 | - 'thumbnail', |
|
100 | - 'editor', |
|
101 | - 'excerpt', |
|
102 | - 'page-attributes', |
|
103 | - 'custom-fields', |
|
104 | - ), |
|
105 | - ); |
|
106 | - register_post_type( 'workout', $args ); |
|
107 | - } |
|
48 | + /** |
|
49 | + * Return an instance of this class. |
|
50 | + * |
|
51 | + * @since 1.0.0 |
|
52 | + * |
|
53 | + * @return object \lsx_health_plan\classes\Workout() A single instance of this class. |
|
54 | + */ |
|
55 | + public static function get_instance() { |
|
56 | + // If the single instance hasn't been set, set it now. |
|
57 | + if ( null === self::$instance ) { |
|
58 | + self::$instance = new self(); |
|
59 | + } |
|
60 | + return self::$instance; |
|
61 | + } |
|
62 | + /** |
|
63 | + * Register the post type. |
|
64 | + */ |
|
65 | + public function register_post_type() { |
|
66 | + $labels = array( |
|
67 | + 'name' => esc_html__( 'Workouts', 'lsx-health-plan' ), |
|
68 | + 'singular_name' => esc_html__( 'Workout', 'lsx-health-plan' ), |
|
69 | + 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
70 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
71 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
72 | + 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
73 | + 'all_items' => esc_html__( 'All Workouts', 'lsx-health-plan' ), |
|
74 | + 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
75 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
76 | + 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
77 | + 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
78 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
79 | + 'menu_name' => esc_html__( 'Workouts', 'lsx-health-plan' ), |
|
80 | + ); |
|
81 | + $args = array( |
|
82 | + 'labels' => $labels, |
|
83 | + 'public' => true, |
|
84 | + 'publicly_queryable' => true, |
|
85 | + 'show_ui' => true, |
|
86 | + 'show_in_menu' => true, |
|
87 | + 'show_in_rest' => true, |
|
88 | + 'menu_icon' => 'dashicons-universal-access', |
|
89 | + 'query_var' => true, |
|
90 | + 'rewrite' => array( |
|
91 | + 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ), |
|
92 | + ), |
|
93 | + 'capability_type' => 'page', |
|
94 | + 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workouts' ), |
|
95 | + 'hierarchical' => true, |
|
96 | + 'menu_position' => null, |
|
97 | + 'supports' => array( |
|
98 | + 'title', |
|
99 | + 'thumbnail', |
|
100 | + 'editor', |
|
101 | + 'excerpt', |
|
102 | + 'page-attributes', |
|
103 | + 'custom-fields', |
|
104 | + ), |
|
105 | + ); |
|
106 | + register_post_type( 'workout', $args ); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Register the Type taxonomy. |
|
111 | - */ |
|
112 | - public function workout_type_taxonomy_setup() { |
|
113 | - $labels = array( |
|
114 | - 'name' => esc_html_x( 'Workout Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
115 | - 'singular_name' => esc_html_x( 'Workout Type', 'taxonomy singular name', 'lsx-health-plan' ), |
|
116 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
117 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
118 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
119 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
120 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
121 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
122 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
123 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
124 | - 'menu_name' => esc_html__( 'Workout Types', 'lsx-health-plan' ), |
|
125 | - ); |
|
109 | + /** |
|
110 | + * Register the Type taxonomy. |
|
111 | + */ |
|
112 | + public function workout_type_taxonomy_setup() { |
|
113 | + $labels = array( |
|
114 | + 'name' => esc_html_x( 'Workout Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
115 | + 'singular_name' => esc_html_x( 'Workout Type', 'taxonomy singular name', 'lsx-health-plan' ), |
|
116 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
117 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
118 | + 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
119 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
120 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
121 | + 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
122 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
123 | + 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
124 | + 'menu_name' => esc_html__( 'Workout Types', 'lsx-health-plan' ), |
|
125 | + ); |
|
126 | 126 | |
127 | - $args = array( |
|
128 | - 'hierarchical' => true, |
|
129 | - 'labels' => $labels, |
|
130 | - 'show_ui' => true, |
|
131 | - 'show_admin_column' => true, |
|
132 | - 'query_var' => true, |
|
133 | - 'rewrite' => array( |
|
134 | - 'slug' => 'workout-type', |
|
135 | - ), |
|
136 | - ); |
|
127 | + $args = array( |
|
128 | + 'hierarchical' => true, |
|
129 | + 'labels' => $labels, |
|
130 | + 'show_ui' => true, |
|
131 | + 'show_admin_column' => true, |
|
132 | + 'query_var' => true, |
|
133 | + 'rewrite' => array( |
|
134 | + 'slug' => 'workout-type', |
|
135 | + ), |
|
136 | + ); |
|
137 | 137 | |
138 | - register_taxonomy( 'workout-type', array( 'workout' ), $args ); |
|
139 | - } |
|
138 | + register_taxonomy( 'workout-type', array( 'workout' ), $args ); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * Adds the post type to the different arrays. |
|
143 | - * |
|
144 | - * @param array $post_types |
|
145 | - * @return array |
|
146 | - */ |
|
147 | - public function enable_post_type( $post_types = array() ) { |
|
148 | - $post_types[] = $this->slug; |
|
149 | - return $post_types; |
|
150 | - } |
|
141 | + /** |
|
142 | + * Adds the post type to the different arrays. |
|
143 | + * |
|
144 | + * @param array $post_types |
|
145 | + * @return array |
|
146 | + */ |
|
147 | + public function enable_post_type( $post_types = array() ) { |
|
148 | + $post_types[] = $this->slug; |
|
149 | + return $post_types; |
|
150 | + } |
|
151 | 151 | |
152 | - /** |
|
153 | - * Enables the Bi Directional relationships |
|
154 | - * |
|
155 | - * @param array $connections |
|
156 | - * @return void |
|
157 | - */ |
|
158 | - public function enable_connections( $connections = array() ) { |
|
159 | - $connections['workout']['connected_plans'] = 'connected_workouts'; |
|
160 | - $connections['plan']['connected_workouts'] = 'connected_plans'; |
|
152 | + /** |
|
153 | + * Enables the Bi Directional relationships |
|
154 | + * |
|
155 | + * @param array $connections |
|
156 | + * @return void |
|
157 | + */ |
|
158 | + public function enable_connections( $connections = array() ) { |
|
159 | + $connections['workout']['connected_plans'] = 'connected_workouts'; |
|
160 | + $connections['plan']['connected_workouts'] = 'connected_plans'; |
|
161 | 161 | |
162 | - $connections['workout']['connected_videos'] = 'connected_workouts'; |
|
163 | - $connections['video']['connected_workouts'] = 'connected_videos'; |
|
162 | + $connections['workout']['connected_videos'] = 'connected_workouts'; |
|
163 | + $connections['video']['connected_workouts'] = 'connected_videos'; |
|
164 | 164 | |
165 | - $connections['workout']['connected_posts'] = 'connected_workouts'; |
|
166 | - $connections['post']['connected_workouts'] = 'connected_posts'; |
|
167 | - return $connections; |
|
168 | - } |
|
165 | + $connections['workout']['connected_posts'] = 'connected_workouts'; |
|
166 | + $connections['post']['connected_workouts'] = 'connected_posts'; |
|
167 | + return $connections; |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * Remove the "Archives:" from the post type workouts. |
|
172 | - * |
|
173 | - * @param string $title the term title. |
|
174 | - * @return string |
|
175 | - */ |
|
176 | - public function get_the_archive_title( $title ) { |
|
177 | - if ( is_post_type_archive( 'workout' ) ) { |
|
178 | - $title = __( 'Workouts', 'lsx-health-plan' ); |
|
179 | - } |
|
180 | - return $title; |
|
181 | - } |
|
170 | + /** |
|
171 | + * Remove the "Archives:" from the post type workouts. |
|
172 | + * |
|
173 | + * @param string $title the term title. |
|
174 | + * @return string |
|
175 | + */ |
|
176 | + public function get_the_archive_title( $title ) { |
|
177 | + if ( is_post_type_archive( 'workout' ) ) { |
|
178 | + $title = __( 'Workouts', 'lsx-health-plan' ); |
|
179 | + } |
|
180 | + return $title; |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * Define the metabox and field configurations. |
|
185 | - */ |
|
186 | - public function featured_metabox() { |
|
187 | - $cmb = new_cmb2_box( |
|
188 | - array( |
|
189 | - 'id' => $this->slug . '_featured_metabox_workout', |
|
190 | - 'title' => __( 'Featured Workout', 'lsx-health-plan' ), |
|
191 | - 'object_types' => array( $this->slug ), // Post type |
|
192 | - 'context' => 'side', |
|
193 | - 'priority' => 'high', |
|
194 | - 'show_names' => true, |
|
195 | - ) |
|
196 | - ); |
|
197 | - $cmb->add_field( |
|
198 | - array( |
|
199 | - 'name' => __( 'Featured Workout', 'lsx-health-plan' ), |
|
200 | - 'desc' => __( 'Enable a featured workout' ), |
|
201 | - 'id' => $this->slug . '_featured_workout', |
|
202 | - 'type' => 'checkbox', |
|
203 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
204 | - ) |
|
205 | - ); |
|
206 | - } |
|
183 | + /** |
|
184 | + * Define the metabox and field configurations. |
|
185 | + */ |
|
186 | + public function featured_metabox() { |
|
187 | + $cmb = new_cmb2_box( |
|
188 | + array( |
|
189 | + 'id' => $this->slug . '_featured_metabox_workout', |
|
190 | + 'title' => __( 'Featured Workout', 'lsx-health-plan' ), |
|
191 | + 'object_types' => array( $this->slug ), // Post type |
|
192 | + 'context' => 'side', |
|
193 | + 'priority' => 'high', |
|
194 | + 'show_names' => true, |
|
195 | + ) |
|
196 | + ); |
|
197 | + $cmb->add_field( |
|
198 | + array( |
|
199 | + 'name' => __( 'Featured Workout', 'lsx-health-plan' ), |
|
200 | + 'desc' => __( 'Enable a featured workout' ), |
|
201 | + 'id' => $this->slug . '_featured_workout', |
|
202 | + 'type' => 'checkbox', |
|
203 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
204 | + ) |
|
205 | + ); |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
209 | - * Define the metabox and field configurations. |
|
210 | - */ |
|
211 | - public function details_metaboxes() { |
|
208 | + /** |
|
209 | + * Define the metabox and field configurations. |
|
210 | + */ |
|
211 | + public function details_metaboxes() { |
|
212 | 212 | |
213 | - $cmb = new_cmb2_box( array( |
|
214 | - 'id' => $this->slug . '_details_metabox', |
|
215 | - 'title' => __( 'Workout Details', 'lsx-health-plan' ), |
|
216 | - 'object_types' => array( $this->slug ), // Post type |
|
217 | - 'context' => 'normal', |
|
218 | - 'priority' => 'high', |
|
219 | - 'show_names' => true, |
|
220 | - ) ); |
|
213 | + $cmb = new_cmb2_box( array( |
|
214 | + 'id' => $this->slug . '_details_metabox', |
|
215 | + 'title' => __( 'Workout Details', 'lsx-health-plan' ), |
|
216 | + 'object_types' => array( $this->slug ), // Post type |
|
217 | + 'context' => 'normal', |
|
218 | + 'priority' => 'high', |
|
219 | + 'show_names' => true, |
|
220 | + ) ); |
|
221 | 221 | |
222 | - $cmb->add_field( array( |
|
223 | - 'name' => __( 'Workout Short Description', 'lsx-health-plan' ), |
|
224 | - 'id' => $this->slug . '_short_description', |
|
225 | - 'type' => 'textarea_small', |
|
226 | - 'desc' => __( 'Add a small description for this workout (optional)', 'lsx-health-plan' ), |
|
227 | - ) ); |
|
222 | + $cmb->add_field( array( |
|
223 | + 'name' => __( 'Workout Short Description', 'lsx-health-plan' ), |
|
224 | + 'id' => $this->slug . '_short_description', |
|
225 | + 'type' => 'textarea_small', |
|
226 | + 'desc' => __( 'Add a small description for this workout (optional)', 'lsx-health-plan' ), |
|
227 | + ) ); |
|
228 | 228 | |
229 | - $workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 ); |
|
230 | - if ( false !== $workout_sections && null !== $workout_sections ) { |
|
231 | - $i = 1; |
|
232 | - while ( $i <= $workout_sections ) { |
|
229 | + $workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 ); |
|
230 | + if ( false !== $workout_sections && null !== $workout_sections ) { |
|
231 | + $i = 1; |
|
232 | + while ( $i <= $workout_sections ) { |
|
233 | 233 | |
234 | - $cmb_group = new_cmb2_box( array( |
|
235 | - 'id' => $this->slug . '_section_' . $i . '_metabox', |
|
236 | - 'title' => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i, |
|
237 | - 'object_types' => array( $this->slug ), |
|
238 | - ) ); |
|
234 | + $cmb_group = new_cmb2_box( array( |
|
235 | + 'id' => $this->slug . '_section_' . $i . '_metabox', |
|
236 | + 'title' => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i, |
|
237 | + 'object_types' => array( $this->slug ), |
|
238 | + ) ); |
|
239 | 239 | |
240 | - $cmb_group->add_field( array( |
|
241 | - 'name' => __( 'Title', 'lsx-health-plan' ), |
|
242 | - 'id' => $this->slug . '_section_' . $i . '_title', |
|
243 | - 'type' => 'text', |
|
244 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
245 | - ) ); |
|
240 | + $cmb_group->add_field( array( |
|
241 | + 'name' => __( 'Title', 'lsx-health-plan' ), |
|
242 | + 'id' => $this->slug . '_section_' . $i . '_title', |
|
243 | + 'type' => 'text', |
|
244 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
245 | + ) ); |
|
246 | 246 | |
247 | - $cmb_group->add_field( |
|
248 | - array( |
|
249 | - 'name' => __( 'Description', 'lsx-health-plan' ), |
|
250 | - 'id' => $this->slug . '_section_' . $i . '_description', |
|
251 | - 'type' => 'wysiwyg', |
|
252 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
253 | - 'options' => array( |
|
254 | - 'textarea_rows' => 5, |
|
255 | - ), |
|
256 | - ) |
|
257 | - ); |
|
247 | + $cmb_group->add_field( |
|
248 | + array( |
|
249 | + 'name' => __( 'Description', 'lsx-health-plan' ), |
|
250 | + 'id' => $this->slug . '_section_' . $i . '_description', |
|
251 | + 'type' => 'wysiwyg', |
|
252 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
253 | + 'options' => array( |
|
254 | + 'textarea_rows' => 5, |
|
255 | + ), |
|
256 | + ) |
|
257 | + ); |
|
258 | 258 | |
259 | - /** |
|
260 | - * Repeatable Field Groups |
|
261 | - */ |
|
262 | - // $group_field_id is the field id string, so in this case: $prefix . 'demo' |
|
263 | - $group_field_id = $cmb_group->add_field( |
|
264 | - array( |
|
265 | - 'id' => $this->slug . '_section_' . $i, |
|
266 | - 'type' => 'group', |
|
267 | - 'options' => array( |
|
268 | - 'group_title' => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number |
|
269 | - 'add_button' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
270 | - 'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ), |
|
271 | - 'sortable' => true, |
|
272 | - 'closed' => true, // true to have the groups closed by default |
|
273 | - ), |
|
274 | - ) |
|
275 | - ); |
|
259 | + /** |
|
260 | + * Repeatable Field Groups |
|
261 | + */ |
|
262 | + // $group_field_id is the field id string, so in this case: $prefix . 'demo' |
|
263 | + $group_field_id = $cmb_group->add_field( |
|
264 | + array( |
|
265 | + 'id' => $this->slug . '_section_' . $i, |
|
266 | + 'type' => 'group', |
|
267 | + 'options' => array( |
|
268 | + 'group_title' => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number |
|
269 | + 'add_button' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
270 | + 'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ), |
|
271 | + 'sortable' => true, |
|
272 | + 'closed' => true, // true to have the groups closed by default |
|
273 | + ), |
|
274 | + ) |
|
275 | + ); |
|
276 | 276 | |
277 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
278 | - $cmb_group->add_group_field( |
|
279 | - $group_field_id, |
|
280 | - array( |
|
281 | - 'name' => __( 'Exercise related to this workout', 'lsx-health-plan' ), |
|
282 | - 'id' => 'connected_exercises', |
|
283 | - 'type' => 'post_search_ajax', |
|
284 | - // Optional : |
|
285 | - 'limit' => 1, // Limit selection to X items only (default 1) |
|
286 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
287 | - 'query_args' => array( |
|
288 | - 'post_type' => array( 'exercise' ), |
|
289 | - 'post_status' => array( 'publish' ), |
|
290 | - 'posts_per_page' => -1, |
|
291 | - ), |
|
292 | - ) |
|
293 | - ); |
|
294 | - } else { |
|
295 | - $cmb_group->add_group_field( |
|
296 | - $group_field_id, |
|
297 | - array( |
|
298 | - 'name' => __( 'Video related to this workout', 'lsx-health-plan' ), |
|
299 | - 'id' => 'connected_videos', |
|
300 | - 'type' => 'post_search_ajax', |
|
301 | - // Optional : |
|
302 | - 'limit' => 1, // Limit selection to X items only (default 1) |
|
303 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
304 | - 'query_args' => array( |
|
305 | - 'post_type' => array( 'video' ), |
|
306 | - 'post_status' => array( 'publish' ), |
|
307 | - 'posts_per_page' => -1, |
|
308 | - ), |
|
309 | - ) |
|
310 | - ); |
|
311 | - $cmb_group->add_group_field( |
|
312 | - $group_field_id, |
|
313 | - array( |
|
314 | - 'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ), |
|
315 | - 'id' => 'name', |
|
316 | - 'type' => 'text', |
|
317 | - // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) |
|
318 | - ) |
|
319 | - ); |
|
277 | + if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
278 | + $cmb_group->add_group_field( |
|
279 | + $group_field_id, |
|
280 | + array( |
|
281 | + 'name' => __( 'Exercise related to this workout', 'lsx-health-plan' ), |
|
282 | + 'id' => 'connected_exercises', |
|
283 | + 'type' => 'post_search_ajax', |
|
284 | + // Optional : |
|
285 | + 'limit' => 1, // Limit selection to X items only (default 1) |
|
286 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
287 | + 'query_args' => array( |
|
288 | + 'post_type' => array( 'exercise' ), |
|
289 | + 'post_status' => array( 'publish' ), |
|
290 | + 'posts_per_page' => -1, |
|
291 | + ), |
|
292 | + ) |
|
293 | + ); |
|
294 | + } else { |
|
295 | + $cmb_group->add_group_field( |
|
296 | + $group_field_id, |
|
297 | + array( |
|
298 | + 'name' => __( 'Video related to this workout', 'lsx-health-plan' ), |
|
299 | + 'id' => 'connected_videos', |
|
300 | + 'type' => 'post_search_ajax', |
|
301 | + // Optional : |
|
302 | + 'limit' => 1, // Limit selection to X items only (default 1) |
|
303 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
304 | + 'query_args' => array( |
|
305 | + 'post_type' => array( 'video' ), |
|
306 | + 'post_status' => array( 'publish' ), |
|
307 | + 'posts_per_page' => -1, |
|
308 | + ), |
|
309 | + ) |
|
310 | + ); |
|
311 | + $cmb_group->add_group_field( |
|
312 | + $group_field_id, |
|
313 | + array( |
|
314 | + 'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ), |
|
315 | + 'id' => 'name', |
|
316 | + 'type' => 'text', |
|
317 | + // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) |
|
318 | + ) |
|
319 | + ); |
|
320 | 320 | |
321 | - $cmb_group->add_group_field( |
|
322 | - $group_field_id, |
|
323 | - array( |
|
324 | - 'name' => __( 'Description', 'lsx-health-plan' ), |
|
325 | - 'id' => 'description', |
|
326 | - 'type' => 'wysiwyg', |
|
327 | - 'options' => array( |
|
328 | - 'textarea_rows' => 2, |
|
329 | - ), |
|
330 | - ) |
|
331 | - ); |
|
332 | - } |
|
321 | + $cmb_group->add_group_field( |
|
322 | + $group_field_id, |
|
323 | + array( |
|
324 | + 'name' => __( 'Description', 'lsx-health-plan' ), |
|
325 | + 'id' => 'description', |
|
326 | + 'type' => 'wysiwyg', |
|
327 | + 'options' => array( |
|
328 | + 'textarea_rows' => 2, |
|
329 | + ), |
|
330 | + ) |
|
331 | + ); |
|
332 | + } |
|
333 | 333 | |
334 | - $cmb_group->add_group_field( |
|
335 | - $group_field_id, |
|
336 | - array( |
|
337 | - 'name' => esc_html__( 'Exercise title (Optional)', 'lsx-health-plan' ), |
|
338 | - 'id' => 'alt_title', |
|
339 | - 'type' => 'text', |
|
340 | - ) |
|
341 | - ); |
|
342 | - $cmb_group->add_group_field( |
|
343 | - $group_field_id, |
|
344 | - array( |
|
345 | - 'name' => esc_html__( 'Exercise Description (Optional)', 'lsx-health-plan' ), |
|
346 | - 'id' => 'alt_description', |
|
347 | - 'type' => 'textarea_small', |
|
348 | - ) |
|
349 | - ); |
|
350 | - $cmb_group->add_group_field( |
|
351 | - $group_field_id, |
|
352 | - array( |
|
353 | - 'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ), |
|
354 | - 'id' => 'reps', |
|
355 | - 'type' => 'text', |
|
356 | - // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) |
|
357 | - ) |
|
358 | - ); |
|
359 | - $cmb_group->add_group_field( |
|
360 | - $group_field_id, |
|
361 | - array( |
|
362 | - 'name' => __( 'Exercise Image (Optional)', 'lsx-health-plan' ), |
|
363 | - 'id' => 'exercise_alt_thumbnail', |
|
364 | - 'type' => 'file', |
|
365 | - 'text' => array( |
|
366 | - 'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ), |
|
367 | - ), |
|
368 | - 'desc' => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ), |
|
369 | - 'query_args' => array( |
|
370 | - 'type' => array( |
|
371 | - 'image/gif', |
|
372 | - 'image/jpeg', |
|
373 | - 'image/png', |
|
374 | - ), |
|
375 | - ), |
|
376 | - 'preview_size' => 'thumbnail', |
|
377 | - 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-25', |
|
378 | - ) |
|
379 | - ); |
|
334 | + $cmb_group->add_group_field( |
|
335 | + $group_field_id, |
|
336 | + array( |
|
337 | + 'name' => esc_html__( 'Exercise title (Optional)', 'lsx-health-plan' ), |
|
338 | + 'id' => 'alt_title', |
|
339 | + 'type' => 'text', |
|
340 | + ) |
|
341 | + ); |
|
342 | + $cmb_group->add_group_field( |
|
343 | + $group_field_id, |
|
344 | + array( |
|
345 | + 'name' => esc_html__( 'Exercise Description (Optional)', 'lsx-health-plan' ), |
|
346 | + 'id' => 'alt_description', |
|
347 | + 'type' => 'textarea_small', |
|
348 | + ) |
|
349 | + ); |
|
350 | + $cmb_group->add_group_field( |
|
351 | + $group_field_id, |
|
352 | + array( |
|
353 | + 'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ), |
|
354 | + 'id' => 'reps', |
|
355 | + 'type' => 'text', |
|
356 | + // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) |
|
357 | + ) |
|
358 | + ); |
|
359 | + $cmb_group->add_group_field( |
|
360 | + $group_field_id, |
|
361 | + array( |
|
362 | + 'name' => __( 'Exercise Image (Optional)', 'lsx-health-plan' ), |
|
363 | + 'id' => 'exercise_alt_thumbnail', |
|
364 | + 'type' => 'file', |
|
365 | + 'text' => array( |
|
366 | + 'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ), |
|
367 | + ), |
|
368 | + 'desc' => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ), |
|
369 | + 'query_args' => array( |
|
370 | + 'type' => array( |
|
371 | + 'image/gif', |
|
372 | + 'image/jpeg', |
|
373 | + 'image/png', |
|
374 | + ), |
|
375 | + ), |
|
376 | + 'preview_size' => 'thumbnail', |
|
377 | + 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-25', |
|
378 | + ) |
|
379 | + ); |
|
380 | 380 | |
381 | - $i++; |
|
382 | - }; |
|
383 | - } |
|
384 | - } |
|
385 | - /** |
|
386 | - * Set the post type archive to show the parent plans only. |
|
387 | - * |
|
388 | - * @param object $wp_query |
|
389 | - * @return array |
|
390 | - */ |
|
391 | - public function set_parent_only( $wp_query ) { |
|
392 | - if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'workout' ) || $wp_query->is_tax( array( 'workout-type' ) ) ) ) { |
|
393 | - $wp_query->set( 'post_parent', '0' ); |
|
394 | - } |
|
395 | - } |
|
381 | + $i++; |
|
382 | + }; |
|
383 | + } |
|
384 | + } |
|
385 | + /** |
|
386 | + * Set the post type archive to show the parent plans only. |
|
387 | + * |
|
388 | + * @param object $wp_query |
|
389 | + * @return array |
|
390 | + */ |
|
391 | + public function set_parent_only( $wp_query ) { |
|
392 | + if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'workout' ) || $wp_query->is_tax( array( 'workout-type' ) ) ) ) { |
|
393 | + $wp_query->set( 'post_parent', '0' ); |
|
394 | + } |
|
395 | + } |
|
396 | 396 | } |