@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | * @return boolean |
13 | 13 | */ |
14 | 14 | function lsx_health_plan_has_warmup( $post_id = '' ) { |
15 | - if ( '' === $post_id ) { |
|
16 | - $post_id = get_the_ID(); |
|
17 | - } |
|
18 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'plan_warmup' ); |
|
15 | + if ( '' === $post_id ) { |
|
16 | + $post_id = get_the_ID(); |
|
17 | + } |
|
18 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'plan_warmup' ); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | * @return boolean |
26 | 26 | */ |
27 | 27 | function lsx_health_plan_has_workout( $post_id = '' ) { |
28 | - if ( ! post_type_exists( 'workout' ) ) { |
|
29 | - return false; |
|
30 | - } |
|
31 | - if ( '' === $post_id ) { |
|
32 | - $post_id = get_the_ID(); |
|
33 | - } |
|
34 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_workouts' ); |
|
28 | + if ( ! post_type_exists( 'workout' ) ) { |
|
29 | + return false; |
|
30 | + } |
|
31 | + if ( '' === $post_id ) { |
|
32 | + $post_id = get_the_ID(); |
|
33 | + } |
|
34 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_workouts' ); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | * @return boolean |
42 | 42 | */ |
43 | 43 | function lsx_health_plan_has_meal( $post_id = '' ) { |
44 | - if ( ! post_type_exists( 'meal' ) ) { |
|
45 | - return false; |
|
46 | - } |
|
47 | - if ( '' === $post_id ) { |
|
48 | - $post_id = get_the_ID(); |
|
49 | - } |
|
50 | - echo \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' ); |
|
51 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' ); |
|
44 | + if ( ! post_type_exists( 'meal' ) ) { |
|
45 | + return false; |
|
46 | + } |
|
47 | + if ( '' === $post_id ) { |
|
48 | + $post_id = get_the_ID(); |
|
49 | + } |
|
50 | + echo \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' ); |
|
51 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' ); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | * @return boolean |
59 | 59 | */ |
60 | 60 | function lsx_health_plan_has_recipe( $post_id = '' ) { |
61 | - if ( ! post_type_exists( 'recipe' ) ) { |
|
62 | - return false; |
|
63 | - } |
|
64 | - if ( '' === $post_id ) { |
|
65 | - $post_id = get_the_ID(); |
|
66 | - } |
|
67 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_recipes' ); |
|
61 | + if ( ! post_type_exists( 'recipe' ) ) { |
|
62 | + return false; |
|
63 | + } |
|
64 | + if ( '' === $post_id ) { |
|
65 | + $post_id = get_the_ID(); |
|
66 | + } |
|
67 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_recipes' ); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | * @return boolean |
75 | 75 | */ |
76 | 76 | function lsx_health_plan_has_downloads( $post_id = '' ) { |
77 | - $has_downloads = false; |
|
78 | - if ( '' === $post_id ) { |
|
79 | - $post_id = get_the_ID(); |
|
80 | - } |
|
81 | - $downloads = \lsx_health_plan\functions\get_downloads( 'all', $post_id ); |
|
82 | - if ( ! empty( $downloads ) ) { |
|
83 | - $has_downloads = true; |
|
84 | - } |
|
85 | - return $has_downloads; |
|
77 | + $has_downloads = false; |
|
78 | + if ( '' === $post_id ) { |
|
79 | + $post_id = get_the_ID(); |
|
80 | + } |
|
81 | + $downloads = \lsx_health_plan\functions\get_downloads( 'all', $post_id ); |
|
82 | + if ( ! empty( $downloads ) ) { |
|
83 | + $has_downloads = true; |
|
84 | + } |
|
85 | + return $has_downloads; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -92,13 +92,13 @@ discard block |
||
92 | 92 | * @return boolean |
93 | 93 | */ |
94 | 94 | function lsx_health_plan_has_tip( $post_id = '' ) { |
95 | - if ( ! post_type_exists( 'tip' ) ) { |
|
96 | - return false; |
|
97 | - } |
|
98 | - if ( '' === $post_id ) { |
|
99 | - $post_id = get_the_ID(); |
|
100 | - } |
|
101 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_tips' ); |
|
95 | + if ( ! post_type_exists( 'tip' ) ) { |
|
96 | + return false; |
|
97 | + } |
|
98 | + if ( '' === $post_id ) { |
|
99 | + $post_id = get_the_ID(); |
|
100 | + } |
|
101 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_tips' ); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | * @return boolean |
109 | 109 | */ |
110 | 110 | function lsx_health_plan_has_video( $post_id = '' ) { |
111 | - if ( ! post_type_exists( 'video' ) ) { |
|
112 | - return false; |
|
113 | - } |
|
114 | - if ( '' === $post_id ) { |
|
115 | - $post_id = get_the_ID(); |
|
116 | - } |
|
117 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_videos' ); |
|
111 | + if ( ! post_type_exists( 'video' ) ) { |
|
112 | + return false; |
|
113 | + } |
|
114 | + if ( '' === $post_id ) { |
|
115 | + $post_id = get_the_ID(); |
|
116 | + } |
|
117 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_videos' ); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -123,16 +123,16 @@ discard block |
||
123 | 123 | * @return boolean |
124 | 124 | */ |
125 | 125 | function lsx_health_plan_user_has_purchase() { |
126 | - $valid_order = false; |
|
127 | - $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
126 | + $valid_order = false; |
|
127 | + $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
128 | 128 | |
129 | - if ( is_user_logged_in() && false !== $product_id ) { |
|
130 | - $current_user = wp_get_current_user(); |
|
131 | - if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) { |
|
132 | - $valid_order = true; |
|
133 | - } |
|
134 | - } |
|
135 | - return $valid_order; |
|
129 | + if ( is_user_logged_in() && false !== $product_id ) { |
|
130 | + $current_user = wp_get_current_user(); |
|
131 | + if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) { |
|
132 | + $valid_order = true; |
|
133 | + } |
|
134 | + } |
|
135 | + return $valid_order; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -142,18 +142,18 @@ discard block |
||
142 | 142 | * @return boolean |
143 | 143 | */ |
144 | 144 | function lsx_health_plan_is_current_tab( $needle = '' ) { |
145 | - $is_tab = false; |
|
146 | - $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
147 | - if ( false === $plan_slug ) { |
|
148 | - $plan_slug = 'my-plan'; |
|
149 | - } |
|
150 | - if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) { |
|
151 | - $endpoint = get_query_var( 'endpoint' ); |
|
152 | - if ( false !== $endpoint && $needle === $endpoint ) { |
|
153 | - $is_tab = true; |
|
154 | - } |
|
155 | - } |
|
156 | - return $is_tab; |
|
145 | + $is_tab = false; |
|
146 | + $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
147 | + if ( false === $plan_slug ) { |
|
148 | + $plan_slug = 'my-plan'; |
|
149 | + } |
|
150 | + if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) { |
|
151 | + $endpoint = get_query_var( 'endpoint' ); |
|
152 | + if ( false !== $endpoint && $needle === $endpoint ) { |
|
153 | + $is_tab = true; |
|
154 | + } |
|
155 | + } |
|
156 | + return $is_tab; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -163,22 +163,22 @@ discard block |
||
163 | 163 | * @return boolean |
164 | 164 | */ |
165 | 165 | function lsx_health_plan_is_day_complete( $post_id = '', $section_key = '' ) { |
166 | - $is_complete = false; |
|
167 | - if ( '' === $post_id ) { |
|
168 | - $post_id = get_the_ID(); |
|
169 | - } |
|
170 | - $key = \lsx_health_plan\functions\plan\generate_section_id( $section_key ); |
|
171 | - $is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true ); |
|
172 | - if ( false !== $is_day_complete && '' !== $is_day_complete ) { |
|
173 | - $is_complete = true; |
|
174 | - } |
|
166 | + $is_complete = false; |
|
167 | + if ( '' === $post_id ) { |
|
168 | + $post_id = get_the_ID(); |
|
169 | + } |
|
170 | + $key = \lsx_health_plan\functions\plan\generate_section_id( $section_key ); |
|
171 | + $is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true ); |
|
172 | + if ( false !== $is_day_complete && '' !== $is_day_complete ) { |
|
173 | + $is_complete = true; |
|
174 | + } |
|
175 | 175 | |
176 | - return $is_complete; |
|
176 | + return $is_complete; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | function lsx_health_plan_is_plan_complete() { |
180 | - $complete = false; |
|
181 | - return $complete; |
|
180 | + $complete = false; |
|
181 | + return $complete; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | * @return boolean |
189 | 189 | */ |
190 | 190 | function lsx_health_plan_week_has_downloads( $week = '' ) { |
191 | - $has_downloads = false; |
|
192 | - if ( '' !== $week ) { |
|
193 | - $downloads = \lsx_health_plan\functions\get_weekly_downloads( $week ); |
|
194 | - if ( ! empty( $downloads ) ) { |
|
195 | - $has_downloads = true; |
|
196 | - } |
|
197 | - } |
|
198 | - return $has_downloads; |
|
191 | + $has_downloads = false; |
|
192 | + if ( '' !== $week ) { |
|
193 | + $downloads = \lsx_health_plan\functions\get_weekly_downloads( $week ); |
|
194 | + if ( ! empty( $downloads ) ) { |
|
195 | + $has_downloads = true; |
|
196 | + } |
|
197 | + } |
|
198 | + return $has_downloads; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | * @return boolean |
206 | 206 | */ |
207 | 207 | function lsx_health_plan_has_tips( $post_id = '' ) { |
208 | - $has_tips = false; |
|
209 | - if ( '' === $post_id ) { |
|
210 | - $post_id = get_the_ID(); |
|
211 | - } |
|
212 | - $post_type = get_post_type( $post_id ); |
|
213 | - $connected_tips = get_post_meta( get_the_ID(), $post_type . '_connected_tips', true ); |
|
214 | - $connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips ); |
|
215 | - if ( ! empty( $connected_tips ) ) { |
|
216 | - $has_tips = true; |
|
217 | - } |
|
218 | - return $has_tips; |
|
208 | + $has_tips = false; |
|
209 | + if ( '' === $post_id ) { |
|
210 | + $post_id = get_the_ID(); |
|
211 | + } |
|
212 | + $post_type = get_post_type( $post_id ); |
|
213 | + $connected_tips = get_post_meta( get_the_ID(), $post_type . '_connected_tips', true ); |
|
214 | + $connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips ); |
|
215 | + if ( ! empty( $connected_tips ) ) { |
|
216 | + $has_tips = true; |
|
217 | + } |
|
218 | + return $has_tips; |
|
219 | 219 | } |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | * @param string $post_id |
12 | 12 | * @return boolean |
13 | 13 | */ |
14 | -function lsx_health_plan_has_warmup( $post_id = '' ) { |
|
15 | - if ( '' === $post_id ) { |
|
14 | +function lsx_health_plan_has_warmup($post_id = '') { |
|
15 | + if ('' === $post_id) { |
|
16 | 16 | $post_id = get_the_ID(); |
17 | 17 | } |
18 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'plan_warmup' ); |
|
18 | + return \lsx_health_plan\functions\has_attached_post($post_id, 'plan_warmup'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * @param string $post_id |
25 | 25 | * @return boolean |
26 | 26 | */ |
27 | -function lsx_health_plan_has_workout( $post_id = '' ) { |
|
28 | - if ( ! post_type_exists( 'workout' ) ) { |
|
27 | +function lsx_health_plan_has_workout($post_id = '') { |
|
28 | + if ( ! post_type_exists('workout')) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | - if ( '' === $post_id ) { |
|
31 | + if ('' === $post_id) { |
|
32 | 32 | $post_id = get_the_ID(); |
33 | 33 | } |
34 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_workouts' ); |
|
34 | + return \lsx_health_plan\functions\has_attached_post($post_id, 'connected_workouts'); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | * @param string $post_id |
41 | 41 | * @return boolean |
42 | 42 | */ |
43 | -function lsx_health_plan_has_meal( $post_id = '' ) { |
|
44 | - if ( ! post_type_exists( 'meal' ) ) { |
|
43 | +function lsx_health_plan_has_meal($post_id = '') { |
|
44 | + if ( ! post_type_exists('meal')) { |
|
45 | 45 | return false; |
46 | 46 | } |
47 | - if ( '' === $post_id ) { |
|
47 | + if ('' === $post_id) { |
|
48 | 48 | $post_id = get_the_ID(); |
49 | 49 | } |
50 | - echo \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' ); |
|
51 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' ); |
|
50 | + echo \lsx_health_plan\functions\has_attached_post($post_id, 'connected_meals'); |
|
51 | + return \lsx_health_plan\functions\has_attached_post($post_id, 'connected_meals'); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | * @param string $post_id |
58 | 58 | * @return boolean |
59 | 59 | */ |
60 | -function lsx_health_plan_has_recipe( $post_id = '' ) { |
|
61 | - if ( ! post_type_exists( 'recipe' ) ) { |
|
60 | +function lsx_health_plan_has_recipe($post_id = '') { |
|
61 | + if ( ! post_type_exists('recipe')) { |
|
62 | 62 | return false; |
63 | 63 | } |
64 | - if ( '' === $post_id ) { |
|
64 | + if ('' === $post_id) { |
|
65 | 65 | $post_id = get_the_ID(); |
66 | 66 | } |
67 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_recipes' ); |
|
67 | + return \lsx_health_plan\functions\has_attached_post($post_id, 'connected_recipes'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | * @param string $post_id |
74 | 74 | * @return boolean |
75 | 75 | */ |
76 | -function lsx_health_plan_has_downloads( $post_id = '' ) { |
|
76 | +function lsx_health_plan_has_downloads($post_id = '') { |
|
77 | 77 | $has_downloads = false; |
78 | - if ( '' === $post_id ) { |
|
78 | + if ('' === $post_id) { |
|
79 | 79 | $post_id = get_the_ID(); |
80 | 80 | } |
81 | - $downloads = \lsx_health_plan\functions\get_downloads( 'all', $post_id ); |
|
82 | - if ( ! empty( $downloads ) ) { |
|
81 | + $downloads = \lsx_health_plan\functions\get_downloads('all', $post_id); |
|
82 | + if ( ! empty($downloads)) { |
|
83 | 83 | $has_downloads = true; |
84 | 84 | } |
85 | 85 | return $has_downloads; |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | * @param string $post_id |
92 | 92 | * @return boolean |
93 | 93 | */ |
94 | -function lsx_health_plan_has_tip( $post_id = '' ) { |
|
95 | - if ( ! post_type_exists( 'tip' ) ) { |
|
94 | +function lsx_health_plan_has_tip($post_id = '') { |
|
95 | + if ( ! post_type_exists('tip')) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | - if ( '' === $post_id ) { |
|
98 | + if ('' === $post_id) { |
|
99 | 99 | $post_id = get_the_ID(); |
100 | 100 | } |
101 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_tips' ); |
|
101 | + return \lsx_health_plan\functions\has_attached_post($post_id, 'connected_tips'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | * @param string $post_id |
108 | 108 | * @return boolean |
109 | 109 | */ |
110 | -function lsx_health_plan_has_video( $post_id = '' ) { |
|
111 | - if ( ! post_type_exists( 'video' ) ) { |
|
110 | +function lsx_health_plan_has_video($post_id = '') { |
|
111 | + if ( ! post_type_exists('video')) { |
|
112 | 112 | return false; |
113 | 113 | } |
114 | - if ( '' === $post_id ) { |
|
114 | + if ('' === $post_id) { |
|
115 | 115 | $post_id = get_the_ID(); |
116 | 116 | } |
117 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_videos' ); |
|
117 | + return \lsx_health_plan\functions\has_attached_post($post_id, 'connected_videos'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | */ |
125 | 125 | function lsx_health_plan_user_has_purchase() { |
126 | 126 | $valid_order = false; |
127 | - $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
127 | + $product_id = \lsx_health_plan\functions\get_option('membership_product', false); |
|
128 | 128 | |
129 | - if ( is_user_logged_in() && false !== $product_id ) { |
|
129 | + if (is_user_logged_in() && false !== $product_id) { |
|
130 | 130 | $current_user = wp_get_current_user(); |
131 | - if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) { |
|
131 | + if (wc_customer_bought_product($current_user->user_email, $current_user->ID, $product_id)) { |
|
132 | 132 | $valid_order = true; |
133 | 133 | } |
134 | 134 | } |
@@ -141,15 +141,15 @@ discard block |
||
141 | 141 | * @param string $post_id |
142 | 142 | * @return boolean |
143 | 143 | */ |
144 | -function lsx_health_plan_is_current_tab( $needle = '' ) { |
|
144 | +function lsx_health_plan_is_current_tab($needle = '') { |
|
145 | 145 | $is_tab = false; |
146 | - $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
147 | - if ( false === $plan_slug ) { |
|
146 | + $plan_slug = \lsx_health_plan\functions\get_option('my_plan_slug', false); |
|
147 | + if (false === $plan_slug) { |
|
148 | 148 | $plan_slug = 'my-plan'; |
149 | 149 | } |
150 | - if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) { |
|
151 | - $endpoint = get_query_var( 'endpoint' ); |
|
152 | - if ( false !== $endpoint && $needle === $endpoint ) { |
|
150 | + if (is_singular('plan') || is_page($plan_slug)) { |
|
151 | + $endpoint = get_query_var('endpoint'); |
|
152 | + if (false !== $endpoint && $needle === $endpoint) { |
|
153 | 153 | $is_tab = true; |
154 | 154 | } |
155 | 155 | } |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | * @param string $post_id |
163 | 163 | * @return boolean |
164 | 164 | */ |
165 | -function lsx_health_plan_is_day_complete( $post_id = '', $section_key = '' ) { |
|
165 | +function lsx_health_plan_is_day_complete($post_id = '', $section_key = '') { |
|
166 | 166 | $is_complete = false; |
167 | - if ( '' === $post_id ) { |
|
167 | + if ('' === $post_id) { |
|
168 | 168 | $post_id = get_the_ID(); |
169 | 169 | } |
170 | - $key = \lsx_health_plan\functions\plan\generate_section_id( $section_key ); |
|
171 | - $is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true ); |
|
172 | - if ( false !== $is_day_complete && '' !== $is_day_complete ) { |
|
170 | + $key = \lsx_health_plan\functions\plan\generate_section_id($section_key); |
|
171 | + $is_day_complete = get_user_meta(get_current_user_id(), 'day_' . $key . '_complete', true); |
|
172 | + if (false !== $is_day_complete && '' !== $is_day_complete) { |
|
173 | 173 | $is_complete = true; |
174 | 174 | } |
175 | 175 | |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | * @param string $week The week name 'week-1'. |
188 | 188 | * @return boolean |
189 | 189 | */ |
190 | -function lsx_health_plan_week_has_downloads( $week = '' ) { |
|
190 | +function lsx_health_plan_week_has_downloads($week = '') { |
|
191 | 191 | $has_downloads = false; |
192 | - if ( '' !== $week ) { |
|
193 | - $downloads = \lsx_health_plan\functions\get_weekly_downloads( $week ); |
|
194 | - if ( ! empty( $downloads ) ) { |
|
192 | + if ('' !== $week) { |
|
193 | + $downloads = \lsx_health_plan\functions\get_weekly_downloads($week); |
|
194 | + if ( ! empty($downloads)) { |
|
195 | 195 | $has_downloads = true; |
196 | 196 | } |
197 | 197 | } |
@@ -204,15 +204,15 @@ discard block |
||
204 | 204 | * @param string $post_id |
205 | 205 | * @return boolean |
206 | 206 | */ |
207 | -function lsx_health_plan_has_tips( $post_id = '' ) { |
|
207 | +function lsx_health_plan_has_tips($post_id = '') { |
|
208 | 208 | $has_tips = false; |
209 | - if ( '' === $post_id ) { |
|
209 | + if ('' === $post_id) { |
|
210 | 210 | $post_id = get_the_ID(); |
211 | 211 | } |
212 | - $post_type = get_post_type( $post_id ); |
|
213 | - $connected_tips = get_post_meta( get_the_ID(), $post_type . '_connected_tips', true ); |
|
214 | - $connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips ); |
|
215 | - if ( ! empty( $connected_tips ) ) { |
|
212 | + $post_type = get_post_type($post_id); |
|
213 | + $connected_tips = get_post_meta(get_the_ID(), $post_type . '_connected_tips', true); |
|
214 | + $connected_tips = \lsx_health_plan\functions\check_posts_exist($connected_tips); |
|
215 | + if ( ! empty($connected_tips)) { |
|
216 | 216 | $has_tips = true; |
217 | 217 | } |
218 | 218 | return $has_tips; |
@@ -8,428 +8,428 @@ |
||
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' => false, |
|
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_muscle_group', '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 | - 'classes' => 'lsx-admin-row', |
|
312 | - ) |
|
313 | - ); |
|
314 | - |
|
315 | - // Title. |
|
316 | - $cmb->add_group_field( |
|
317 | - $gallery_group, |
|
318 | - array( |
|
319 | - 'name' => __( 'Image', 'lsx-health-plan' ), |
|
320 | - 'id' => $this->slug . '_gallery_image', |
|
321 | - 'type' => 'file', |
|
322 | - 'text' => array( |
|
323 | - 'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ), |
|
324 | - ), |
|
325 | - 'desc' => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ), |
|
326 | - 'query_args' => array( |
|
327 | - 'type' => array( |
|
328 | - 'image/gif', |
|
329 | - 'image/jpeg', |
|
330 | - 'image/png', |
|
331 | - ), |
|
332 | - ), |
|
333 | - 'preview_size' => 'lsx-thumbnail-wide', |
|
334 | - ) |
|
335 | - ); |
|
336 | - |
|
337 | - // Title. |
|
338 | - $cmb->add_group_field( |
|
339 | - $gallery_group, |
|
340 | - array( |
|
341 | - 'name' => __( 'oEmbed', 'lsx-health-plan' ), |
|
342 | - 'id' => $this->slug . '_gallery_embed', |
|
343 | - 'type' => 'text', |
|
344 | - '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' ), |
|
345 | - ) |
|
346 | - ); |
|
347 | - |
|
348 | - $cmb->add_group_field( |
|
349 | - $gallery_group, |
|
350 | - array( |
|
351 | - 'name' => __( 'External Media', 'lsx-health-plan' ), |
|
352 | - 'id' => $this->slug . '_gallery_external', |
|
353 | - 'type' => 'textarea_code', |
|
354 | - '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' ), |
|
355 | - ) |
|
356 | - ); |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * Registers the general settings for the exercise. |
|
361 | - * |
|
362 | - * @return void |
|
363 | - */ |
|
364 | - public function exercise_details() { |
|
365 | - $cmb = new_cmb2_box( |
|
366 | - array( |
|
367 | - 'id' => $this->slug . '_general_details_metabox', |
|
368 | - 'title' => __( 'Details', 'lsx-health-plan' ), |
|
369 | - 'object_types' => array( $this->slug ), |
|
370 | - 'context' => 'normal', |
|
371 | - 'priority' => 'high', |
|
372 | - 'show_names' => true, |
|
373 | - ) |
|
374 | - ); |
|
375 | - |
|
376 | - $cmb->add_field( |
|
377 | - array( |
|
378 | - 'name' => __( 'Side', 'lsx-health-plan' ), |
|
379 | - 'id' => $this->slug . '_side', |
|
380 | - 'type' => 'select', |
|
381 | - 'options' => array( |
|
382 | - '' => __( 'Select', 'lsx-health-plan' ), |
|
383 | - 'left' => __( 'Left', 'lsx-health-plan' ), |
|
384 | - 'right' => __( 'Right', 'lsx-health-plan' ), |
|
385 | - ), |
|
386 | - 'desc' => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ), |
|
387 | - ) |
|
388 | - ); |
|
389 | - } |
|
390 | - |
|
391 | - /** |
|
392 | - * Holds the array for the single exercise breadcrumbs. |
|
393 | - * |
|
394 | - * @var array $crumbs |
|
395 | - * @return array |
|
396 | - */ |
|
397 | - public function exercise_breadcrumb_filter( $crumbs ) { |
|
398 | - $exercise = \lsx_health_plan\functions\get_option( 'endpoint_exercise', 'exercise' ); |
|
399 | - $exercises = \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercise' ); |
|
400 | - $url = get_post_type_archive_link( $exercise ); |
|
401 | - |
|
402 | - if ( is_singular( 'exercise' ) ) { |
|
403 | - $exercise_name = get_the_title(); |
|
404 | - $term_obj_list = get_the_terms( get_the_ID(), 'exercise-type' ); |
|
405 | - $exercise_type = $term_obj_list[0]->name; |
|
406 | - $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' => false, |
|
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_muscle_group', '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 | + 'classes' => 'lsx-admin-row', |
|
312 | + ) |
|
313 | + ); |
|
314 | + |
|
315 | + // Title. |
|
316 | + $cmb->add_group_field( |
|
317 | + $gallery_group, |
|
318 | + array( |
|
319 | + 'name' => __( 'Image', 'lsx-health-plan' ), |
|
320 | + 'id' => $this->slug . '_gallery_image', |
|
321 | + 'type' => 'file', |
|
322 | + 'text' => array( |
|
323 | + 'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ), |
|
324 | + ), |
|
325 | + 'desc' => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ), |
|
326 | + 'query_args' => array( |
|
327 | + 'type' => array( |
|
328 | + 'image/gif', |
|
329 | + 'image/jpeg', |
|
330 | + 'image/png', |
|
331 | + ), |
|
332 | + ), |
|
333 | + 'preview_size' => 'lsx-thumbnail-wide', |
|
334 | + ) |
|
335 | + ); |
|
336 | + |
|
337 | + // Title. |
|
338 | + $cmb->add_group_field( |
|
339 | + $gallery_group, |
|
340 | + array( |
|
341 | + 'name' => __( 'oEmbed', 'lsx-health-plan' ), |
|
342 | + 'id' => $this->slug . '_gallery_embed', |
|
343 | + 'type' => 'text', |
|
344 | + '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' ), |
|
345 | + ) |
|
346 | + ); |
|
347 | + |
|
348 | + $cmb->add_group_field( |
|
349 | + $gallery_group, |
|
350 | + array( |
|
351 | + 'name' => __( 'External Media', 'lsx-health-plan' ), |
|
352 | + 'id' => $this->slug . '_gallery_external', |
|
353 | + 'type' => 'textarea_code', |
|
354 | + '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' ), |
|
355 | + ) |
|
356 | + ); |
|
357 | + } |
|
358 | + |
|
359 | + /** |
|
360 | + * Registers the general settings for the exercise. |
|
361 | + * |
|
362 | + * @return void |
|
363 | + */ |
|
364 | + public function exercise_details() { |
|
365 | + $cmb = new_cmb2_box( |
|
366 | + array( |
|
367 | + 'id' => $this->slug . '_general_details_metabox', |
|
368 | + 'title' => __( 'Details', 'lsx-health-plan' ), |
|
369 | + 'object_types' => array( $this->slug ), |
|
370 | + 'context' => 'normal', |
|
371 | + 'priority' => 'high', |
|
372 | + 'show_names' => true, |
|
373 | + ) |
|
374 | + ); |
|
375 | + |
|
376 | + $cmb->add_field( |
|
377 | + array( |
|
378 | + 'name' => __( 'Side', 'lsx-health-plan' ), |
|
379 | + 'id' => $this->slug . '_side', |
|
380 | + 'type' => 'select', |
|
381 | + 'options' => array( |
|
382 | + '' => __( 'Select', 'lsx-health-plan' ), |
|
383 | + 'left' => __( 'Left', 'lsx-health-plan' ), |
|
384 | + 'right' => __( 'Right', 'lsx-health-plan' ), |
|
385 | + ), |
|
386 | + 'desc' => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ), |
|
387 | + ) |
|
388 | + ); |
|
389 | + } |
|
390 | + |
|
391 | + /** |
|
392 | + * Holds the array for the single exercise breadcrumbs. |
|
393 | + * |
|
394 | + * @var array $crumbs |
|
395 | + * @return array |
|
396 | + */ |
|
397 | + public function exercise_breadcrumb_filter( $crumbs ) { |
|
398 | + $exercise = \lsx_health_plan\functions\get_option( 'endpoint_exercise', 'exercise' ); |
|
399 | + $exercises = \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercise' ); |
|
400 | + $url = get_post_type_archive_link( $exercise ); |
|
401 | + |
|
402 | + if ( is_singular( 'exercise' ) ) { |
|
403 | + $exercise_name = get_the_title(); |
|
404 | + $term_obj_list = get_the_terms( get_the_ID(), 'exercise-type' ); |
|
405 | + $exercise_type = $term_obj_list[0]->name; |
|
406 | + $exercise_type_url = get_term_link( $term_obj_list[0]->term_id ); |
|
407 | 407 | |
408 | - $crumbs[1] = array( |
|
409 | - 0 => $exercises, |
|
410 | - 1 => $url, |
|
411 | - ); |
|
412 | - $crumbs[2] = array( |
|
413 | - 0 => $exercise_type, |
|
414 | - 1 => $exercise_type_url, |
|
415 | - ); |
|
416 | - $crumbs[3] = array( |
|
417 | - 0 => $exercise_name, |
|
418 | - ); |
|
419 | - } |
|
420 | - if ( is_tax( 'exercise-type' ) || is_tax( 'muscle-group' ) || is_tax( 'equipment' ) ) { |
|
421 | - $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); |
|
422 | - |
|
423 | - $single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name; |
|
424 | - |
|
425 | - $crumbs[1] = array( |
|
426 | - 0 => $exercises, |
|
427 | - 1 => $url, |
|
428 | - ); |
|
429 | - $crumbs[2] = array( |
|
430 | - 0 => $single_term_title, |
|
431 | - ); |
|
432 | - } |
|
433 | - return $crumbs; |
|
434 | - } |
|
408 | + $crumbs[1] = array( |
|
409 | + 0 => $exercises, |
|
410 | + 1 => $url, |
|
411 | + ); |
|
412 | + $crumbs[2] = array( |
|
413 | + 0 => $exercise_type, |
|
414 | + 1 => $exercise_type_url, |
|
415 | + ); |
|
416 | + $crumbs[3] = array( |
|
417 | + 0 => $exercise_name, |
|
418 | + ); |
|
419 | + } |
|
420 | + if ( is_tax( 'exercise-type' ) || is_tax( 'muscle-group' ) || is_tax( 'equipment' ) ) { |
|
421 | + $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); |
|
422 | + |
|
423 | + $single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name; |
|
424 | + |
|
425 | + $crumbs[1] = array( |
|
426 | + 0 => $exercises, |
|
427 | + 1 => $url, |
|
428 | + ); |
|
429 | + $crumbs[2] = array( |
|
430 | + 0 => $single_term_title, |
|
431 | + ); |
|
432 | + } |
|
433 | + return $crumbs; |
|
434 | + } |
|
435 | 435 | } |
@@ -31,25 +31,25 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct() { |
33 | 33 | |
34 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
34 | + if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) { |
|
35 | 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' ) ); |
|
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 | 41 | |
42 | 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 ); |
|
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 | 46 | |
47 | 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 ); |
|
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 | 50 | |
51 | 51 | //Breadcrumbs |
52 | - add_filter( 'woocommerce_get_breadcrumb', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 ); |
|
52 | + add_filter('woocommerce_get_breadcrumb', array($this, 'exercise_breadcrumb_filter'), 30, 1); |
|
53 | 53 | |
54 | 54 | } |
55 | 55 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public static function get_instance() { |
67 | 67 | // If the single instance hasn't been set, set it now. |
68 | - if ( null === self::$instance ) { |
|
68 | + if (null === self::$instance) { |
|
69 | 69 | self::$instance = new self(); |
70 | 70 | } |
71 | 71 | return self::$instance; |
@@ -75,21 +75,21 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function register_post_type() { |
77 | 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' ), |
|
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 | 89 | 'parent_item_colon' => '', |
90 | - 'menu_name' => esc_html__( 'Exercises', 'lsx-health-plan' ), |
|
90 | + 'menu_name' => esc_html__('Exercises', 'lsx-health-plan'), |
|
91 | 91 | ); |
92 | - $args = array( |
|
92 | + $args = array( |
|
93 | 93 | 'labels' => $labels, |
94 | 94 | 'public' => true, |
95 | 95 | 'publicly_queryable' => true, |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | 'menu_icon' => 'dashicons-universal-access', |
100 | 100 | 'query_var' => true, |
101 | 101 | 'rewrite' => array( |
102 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ), |
|
102 | + 'slug' => \lsx_health_plan\functions\get_option('endpoint_exercise_single', 'exercise'), |
|
103 | 103 | ), |
104 | 104 | 'capability_type' => 'page', |
105 | - 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercises' ), |
|
105 | + 'has_archive' => \lsx_health_plan\functions\get_option('endpoint_exercise_archive', 'exercises'), |
|
106 | 106 | 'hierarchical' => false, |
107 | 107 | 'menu_position' => null, |
108 | 108 | 'supports' => array( |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | 'custom-fields', |
114 | 114 | ), |
115 | 115 | ); |
116 | - register_post_type( 'exercise', $args ); |
|
116 | + register_post_type('exercise', $args); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -123,17 +123,17 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function exercise_type_taxonomy_setup() { |
125 | 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' ), |
|
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 | 137 | ); |
138 | 138 | |
139 | 139 | $args = array( |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | 'show_admin_column' => true, |
144 | 144 | 'query_var' => true, |
145 | 145 | 'rewrite' => array( |
146 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_type', 'exercise-type' ), |
|
146 | + 'slug' => \lsx_health_plan\functions\get_option('endpoint_exercise_type', 'exercise-type'), |
|
147 | 147 | ), |
148 | 148 | 'show_in_rest' => true, |
149 | 149 | ); |
150 | 150 | |
151 | - register_taxonomy( 'exercise-type', array( 'exercise' ), $args ); |
|
151 | + register_taxonomy('exercise-type', array('exercise'), $args); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function equipment_taxonomy_setup() { |
160 | 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' ), |
|
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 | 172 | ); |
173 | 173 | |
174 | 174 | $args = array( |
@@ -178,12 +178,12 @@ discard block |
||
178 | 178 | 'show_admin_column' => true, |
179 | 179 | 'query_var' => true, |
180 | 180 | 'rewrite' => array( |
181 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_equipment', 'equipment' ), |
|
181 | + 'slug' => \lsx_health_plan\functions\get_option('endpoint_exercise_equipment', 'equipment'), |
|
182 | 182 | ), |
183 | 183 | 'show_in_rest' => true, |
184 | 184 | ); |
185 | 185 | |
186 | - register_taxonomy( 'equipment', array( 'exercise' ), $args ); |
|
186 | + register_taxonomy('equipment', array('exercise'), $args); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -193,17 +193,17 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function muscle_group_taxonomy_setup() { |
195 | 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' ), |
|
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 | 207 | ); |
208 | 208 | |
209 | 209 | $args = array( |
@@ -213,12 +213,12 @@ discard block |
||
213 | 213 | 'show_admin_column' => true, |
214 | 214 | 'query_var' => true, |
215 | 215 | 'rewrite' => array( |
216 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_muscle_group', 'muscle-group' ), |
|
216 | + 'slug' => \lsx_health_plan\functions\get_option('endpoint_exercise_muscle_group', 'muscle-group'), |
|
217 | 217 | ), |
218 | 218 | 'show_in_rest' => true, |
219 | 219 | ); |
220 | 220 | |
221 | - register_taxonomy( 'muscle-group', array( 'exercise' ), $args ); |
|
221 | + register_taxonomy('muscle-group', array('exercise'), $args); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | * @return void |
228 | 228 | */ |
229 | 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' ); |
|
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 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @param array $post_types |
240 | 240 | * @return array |
241 | 241 | */ |
242 | - public function enable_post_type( $post_types = array() ) { |
|
242 | + public function enable_post_type($post_types = array()) { |
|
243 | 243 | $post_types[] = $this->slug; |
244 | 244 | return $post_types; |
245 | 245 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param array $connections |
251 | 251 | * @return void |
252 | 252 | */ |
253 | - public function enable_connections( $connections = array() ) { |
|
253 | + public function enable_connections($connections = array()) { |
|
254 | 254 | $connections['exercise']['connected_workouts'] = 'connected_exercises'; |
255 | 255 | $connections['workout']['connected_exercises'] = 'connected_workouts'; |
256 | 256 | return $connections; |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | $cmb = new_cmb2_box( |
264 | 264 | array( |
265 | 265 | 'id' => $this->slug . '_gallery_details_metabox', |
266 | - 'title' => __( 'Exercise Gallery', 'lsx-health-plan' ), |
|
267 | - 'object_types' => array( $this->slug ), |
|
266 | + 'title' => __('Exercise Gallery', 'lsx-health-plan'), |
|
267 | + 'object_types' => array($this->slug), |
|
268 | 268 | 'context' => 'normal', |
269 | 269 | 'priority' => 'low', |
270 | 270 | 'show_names' => true, |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | |
274 | 274 | $cmb->add_field( |
275 | 275 | array( |
276 | - 'name' => __( 'Layout', 'lsx-health-plan' ), |
|
276 | + 'name' => __('Layout', 'lsx-health-plan'), |
|
277 | 277 | 'id' => $this->slug . '_gallery_layout', |
278 | 278 | 'type' => 'radio', |
279 | 279 | 'options' => array( |
280 | - 'slider' => __( 'Slider', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number |
|
281 | - 'grid' => __( 'Grid', 'lsx-health-plan' ), |
|
280 | + 'slider' => __('Slider', 'lsx-health-plan') . ' {#}', // {#} gets replaced by row number |
|
281 | + 'grid' => __('Grid', 'lsx-health-plan'), |
|
282 | 282 | ), |
283 | 283 | 'default' => 'grid', |
284 | 284 | ) |
@@ -286,12 +286,12 @@ discard block |
||
286 | 286 | |
287 | 287 | $cmb->add_field( |
288 | 288 | array( |
289 | - 'name' => __( 'Grid Columns', 'lsx-health-plan' ), |
|
289 | + 'name' => __('Grid Columns', 'lsx-health-plan'), |
|
290 | 290 | 'id' => $this->slug . '_gallery_columns', |
291 | 291 | 'type' => 'select', |
292 | 292 | 'options' => array( |
293 | - '3' => __( '2 Columns', 'lsx-health-plan' ), |
|
294 | - '4' => __( '3 Columns', 'lsx-health-plan' ), |
|
293 | + '3' => __('2 Columns', 'lsx-health-plan'), |
|
294 | + '4' => __('3 Columns', 'lsx-health-plan'), |
|
295 | 295 | ), |
296 | 296 | 'default' => '1', |
297 | 297 | ) |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | 'id' => $this->slug . '_gallery', |
304 | 304 | 'type' => 'group', |
305 | 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' ), |
|
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 | 309 | 'sortable' => true, |
310 | 310 | ), |
311 | 311 | 'classes' => 'lsx-admin-row', |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | $cmb->add_group_field( |
317 | 317 | $gallery_group, |
318 | 318 | array( |
319 | - 'name' => __( 'Image', 'lsx-health-plan' ), |
|
319 | + 'name' => __('Image', 'lsx-health-plan'), |
|
320 | 320 | 'id' => $this->slug . '_gallery_image', |
321 | 321 | 'type' => 'file', |
322 | 322 | 'text' => array( |
323 | - 'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ), |
|
323 | + 'add_upload_file_text' => __('Add File', 'lsx-health-plan'), |
|
324 | 324 | ), |
325 | - 'desc' => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ), |
|
325 | + 'desc' => __('Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan'), |
|
326 | 326 | 'query_args' => array( |
327 | 327 | 'type' => array( |
328 | 328 | 'image/gif', |
@@ -338,20 +338,20 @@ discard block |
||
338 | 338 | $cmb->add_group_field( |
339 | 339 | $gallery_group, |
340 | 340 | array( |
341 | - 'name' => __( 'oEmbed', 'lsx-health-plan' ), |
|
341 | + 'name' => __('oEmbed', 'lsx-health-plan'), |
|
342 | 342 | 'id' => $this->slug . '_gallery_embed', |
343 | 343 | 'type' => 'text', |
344 | - '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' ), |
|
344 | + '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'), |
|
345 | 345 | ) |
346 | 346 | ); |
347 | 347 | |
348 | 348 | $cmb->add_group_field( |
349 | 349 | $gallery_group, |
350 | 350 | array( |
351 | - 'name' => __( 'External Media', 'lsx-health-plan' ), |
|
351 | + 'name' => __('External Media', 'lsx-health-plan'), |
|
352 | 352 | 'id' => $this->slug . '_gallery_external', |
353 | 353 | 'type' => 'textarea_code', |
354 | - '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' ), |
|
354 | + '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'), |
|
355 | 355 | ) |
356 | 356 | ); |
357 | 357 | } |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | $cmb = new_cmb2_box( |
366 | 366 | array( |
367 | 367 | 'id' => $this->slug . '_general_details_metabox', |
368 | - 'title' => __( 'Details', 'lsx-health-plan' ), |
|
369 | - 'object_types' => array( $this->slug ), |
|
368 | + 'title' => __('Details', 'lsx-health-plan'), |
|
369 | + 'object_types' => array($this->slug), |
|
370 | 370 | 'context' => 'normal', |
371 | 371 | 'priority' => 'high', |
372 | 372 | 'show_names' => true, |
@@ -375,15 +375,15 @@ discard block |
||
375 | 375 | |
376 | 376 | $cmb->add_field( |
377 | 377 | array( |
378 | - 'name' => __( 'Side', 'lsx-health-plan' ), |
|
378 | + 'name' => __('Side', 'lsx-health-plan'), |
|
379 | 379 | 'id' => $this->slug . '_side', |
380 | 380 | 'type' => 'select', |
381 | 381 | 'options' => array( |
382 | - '' => __( 'Select', 'lsx-health-plan' ), |
|
383 | - 'left' => __( 'Left', 'lsx-health-plan' ), |
|
384 | - 'right' => __( 'Right', 'lsx-health-plan' ), |
|
382 | + '' => __('Select', 'lsx-health-plan'), |
|
383 | + 'left' => __('Left', 'lsx-health-plan'), |
|
384 | + 'right' => __('Right', 'lsx-health-plan'), |
|
385 | 385 | ), |
386 | - 'desc' => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ), |
|
386 | + 'desc' => __('Select which side this exercise uses. ', 'lsx-health-plan'), |
|
387 | 387 | ) |
388 | 388 | ); |
389 | 389 | } |
@@ -394,16 +394,16 @@ discard block |
||
394 | 394 | * @var array $crumbs |
395 | 395 | * @return array |
396 | 396 | */ |
397 | - public function exercise_breadcrumb_filter( $crumbs ) { |
|
398 | - $exercise = \lsx_health_plan\functions\get_option( 'endpoint_exercise', 'exercise' ); |
|
399 | - $exercises = \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercise' ); |
|
400 | - $url = get_post_type_archive_link( $exercise ); |
|
397 | + public function exercise_breadcrumb_filter($crumbs) { |
|
398 | + $exercise = \lsx_health_plan\functions\get_option('endpoint_exercise', 'exercise'); |
|
399 | + $exercises = \lsx_health_plan\functions\get_option('endpoint_exercise_archive', 'exercise'); |
|
400 | + $url = get_post_type_archive_link($exercise); |
|
401 | 401 | |
402 | - if ( is_singular( 'exercise' ) ) { |
|
402 | + if (is_singular('exercise')) { |
|
403 | 403 | $exercise_name = get_the_title(); |
404 | - $term_obj_list = get_the_terms( get_the_ID(), 'exercise-type' ); |
|
404 | + $term_obj_list = get_the_terms(get_the_ID(), 'exercise-type'); |
|
405 | 405 | $exercise_type = $term_obj_list[0]->name; |
406 | - $exercise_type_url = get_term_link( $term_obj_list[0]->term_id ); |
|
406 | + $exercise_type_url = get_term_link($term_obj_list[0]->term_id); |
|
407 | 407 | |
408 | 408 | $crumbs[1] = array( |
409 | 409 | 0 => $exercises, |
@@ -417,10 +417,10 @@ discard block |
||
417 | 417 | 0 => $exercise_name, |
418 | 418 | ); |
419 | 419 | } |
420 | - if ( is_tax( 'exercise-type' ) || is_tax( 'muscle-group' ) || is_tax( 'equipment' ) ) { |
|
421 | - $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); |
|
420 | + if (is_tax('exercise-type') || is_tax('muscle-group') || is_tax('equipment')) { |
|
421 | + $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); |
|
422 | 422 | |
423 | - $single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name; |
|
423 | + $single_term_title = str_replace('-', ' ', $term->taxonomy) . ': ' . $term->name; |
|
424 | 424 | |
425 | 425 | $crumbs[1] = array( |
426 | 426 | 0 => $exercises, |