@@ -32,16 +32,16 @@ discard block |
||
32 | 32 | * Contructor |
33 | 33 | */ |
34 | 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, 'recipe_type_taxonomy_setup' ) ); |
|
38 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
39 | - add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) ); |
|
40 | - add_action( 'lsx_hp_settings_page', array( $this, 'register_settings' ), 8, 1 ); |
|
41 | - add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
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, 'recipe_type_taxonomy_setup')); |
|
38 | + add_filter('lsx_health_plan_connections', array($this, 'enable_connections'), 10, 1); |
|
39 | + add_action('cmb2_admin_init', array($this, 'details_metaboxes')); |
|
40 | + add_action('lsx_hp_settings_page', array($this, 'register_settings'), 8, 1); |
|
41 | + add_filter('get_the_archive_title', array($this, 'get_the_archive_title'), 100); |
|
42 | 42 | |
43 | 43 | // Template Redirects. |
44 | - add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
44 | + add_filter('lsx_health_plan_archive_template', array($this, 'enable_post_type'), 10, 1); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public static function get_instance() { |
55 | 55 | // If the single instance hasn't been set, set it now. |
56 | - if ( null === self::$instance ) { |
|
56 | + if (null === self::$instance) { |
|
57 | 57 | self::$instance = new self(); |
58 | 58 | } |
59 | 59 | return self::$instance; |
@@ -63,19 +63,19 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function register_post_type() { |
65 | 65 | $labels = array( |
66 | - 'name' => esc_html__( 'Workouts', 'lsx-health-plan' ), |
|
67 | - 'singular_name' => esc_html__( 'Workout', 'lsx-health-plan' ), |
|
68 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
69 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
70 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
71 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
72 | - 'all_items' => esc_html__( 'All Workouts', 'lsx-health-plan' ), |
|
73 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
74 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
75 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
76 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
66 | + 'name' => esc_html__('Workouts', 'lsx-health-plan'), |
|
67 | + 'singular_name' => esc_html__('Workout', 'lsx-health-plan'), |
|
68 | + 'add_new' => esc_html_x('Add New', 'post type general name', 'lsx-health-plan'), |
|
69 | + 'add_new_item' => esc_html__('Add New', 'lsx-health-plan'), |
|
70 | + 'edit_item' => esc_html__('Edit', 'lsx-health-plan'), |
|
71 | + 'new_item' => esc_html__('New', 'lsx-health-plan'), |
|
72 | + 'all_items' => esc_html__('All Workouts', 'lsx-health-plan'), |
|
73 | + 'view_item' => esc_html__('View', 'lsx-health-plan'), |
|
74 | + 'search_items' => esc_html__('Search', 'lsx-health-plan'), |
|
75 | + 'not_found' => esc_html__('None found', 'lsx-health-plan'), |
|
76 | + 'not_found_in_trash' => esc_html__('None found in Trash', 'lsx-health-plan'), |
|
77 | 77 | 'parent_item_colon' => '', |
78 | - 'menu_name' => esc_html__( 'Workouts', 'lsx-health-plan' ), |
|
78 | + 'menu_name' => esc_html__('Workouts', 'lsx-health-plan'), |
|
79 | 79 | ); |
80 | 80 | $args = array( |
81 | 81 | 'labels' => $labels, |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | 'menu_icon' => 'dashicons-universal-access', |
88 | 88 | 'query_var' => true, |
89 | 89 | 'rewrite' => array( |
90 | - 'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ), |
|
90 | + 'slug' => \lsx_health_plan\functions\get_option('endpoint_workout', 'workout'), |
|
91 | 91 | ), |
92 | 92 | 'capability_type' => 'page', |
93 | - 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workouts' ), |
|
93 | + 'has_archive' => \lsx_health_plan\functions\get_option('endpoint_workout_archive', 'workouts'), |
|
94 | 94 | 'hierarchical' => true, |
95 | 95 | 'menu_position' => null, |
96 | 96 | 'supports' => array( |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | 'custom-fields', |
103 | 103 | ), |
104 | 104 | ); |
105 | - register_post_type( 'workout', $args ); |
|
105 | + register_post_type('workout', $args); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function recipe_type_taxonomy_setup() { |
112 | 112 | $labels = array( |
113 | - 'name' => esc_html_x( 'Workout Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
114 | - 'singular_name' => esc_html_x( 'Workout Type', 'taxonomy singular name', 'lsx-health-plan' ), |
|
115 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
116 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
117 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
118 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
119 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
120 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
121 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
122 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
123 | - 'menu_name' => esc_html__( 'Workout Types', 'lsx-health-plan' ), |
|
113 | + 'name' => esc_html_x('Workout Type', 'taxonomy general name', 'lsx-health-plan'), |
|
114 | + 'singular_name' => esc_html_x('Workout Type', 'taxonomy singular name', 'lsx-health-plan'), |
|
115 | + 'search_items' => esc_html__('Search', 'lsx-health-plan'), |
|
116 | + 'all_items' => esc_html__('All', 'lsx-health-plan'), |
|
117 | + 'parent_item' => esc_html__('Parent', 'lsx-health-plan'), |
|
118 | + 'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'), |
|
119 | + 'edit_item' => esc_html__('Edit', 'lsx-health-plan'), |
|
120 | + 'update_item' => esc_html__('Update', 'lsx-health-plan'), |
|
121 | + 'add_new_item' => esc_html__('Add New', 'lsx-health-plan'), |
|
122 | + 'new_item_name' => esc_html__('New Name', 'lsx-health-plan'), |
|
123 | + 'menu_name' => esc_html__('Workout Types', 'lsx-health-plan'), |
|
124 | 124 | ); |
125 | 125 | |
126 | 126 | $args = array( |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | ), |
135 | 135 | ); |
136 | 136 | |
137 | - register_taxonomy( 'workout-type', array( 'workout' ), $args ); |
|
137 | + register_taxonomy('workout-type', array('workout'), $args); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param array $post_types |
144 | 144 | * @return array |
145 | 145 | */ |
146 | - public function enable_post_type( $post_types = array() ) { |
|
146 | + public function enable_post_type($post_types = array()) { |
|
147 | 147 | $post_types[] = $this->slug; |
148 | 148 | return $post_types; |
149 | 149 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @param array $connections |
155 | 155 | * @return void |
156 | 156 | */ |
157 | - public function enable_connections( $connections = array() ) { |
|
157 | + public function enable_connections($connections = array()) { |
|
158 | 158 | $connections['workout']['connected_plans'] = 'connected_workouts'; |
159 | 159 | $connections['plan']['connected_workouts'] = 'connected_plans'; |
160 | 160 | |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * @param string $title the term title. |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public function get_the_archive_title( $title ) { |
|
176 | - if ( is_post_type_archive( 'workout' ) ) { |
|
177 | - $title = __( 'Workouts', 'lsx-health-plan' ); |
|
175 | + public function get_the_archive_title($title) { |
|
176 | + if (is_post_type_archive('workout')) { |
|
177 | + $title = __('Workouts', 'lsx-health-plan'); |
|
178 | 178 | } |
179 | 179 | return $title; |
180 | 180 | } |
@@ -184,43 +184,43 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function details_metaboxes() { |
186 | 186 | |
187 | - $cmb = new_cmb2_box( array( |
|
187 | + $cmb = new_cmb2_box(array( |
|
188 | 188 | 'id' => $this->slug . '_details_metabox', |
189 | - 'title' => __( 'Workout Details', 'lsx-health-plan' ), |
|
190 | - 'object_types' => array( $this->slug ), // Post type |
|
189 | + 'title' => __('Workout Details', 'lsx-health-plan'), |
|
190 | + 'object_types' => array($this->slug), // Post type |
|
191 | 191 | 'context' => 'normal', |
192 | 192 | 'priority' => 'high', |
193 | 193 | 'show_names' => true, |
194 | - ) ); |
|
194 | + )); |
|
195 | 195 | |
196 | - $cmb->add_field( array( |
|
197 | - 'name' => __( 'Workout Short Description', 'lsx-health-plan' ), |
|
196 | + $cmb->add_field(array( |
|
197 | + 'name' => __('Workout Short Description', 'lsx-health-plan'), |
|
198 | 198 | 'id' => $this->slug . '_short_description', |
199 | 199 | 'type' => 'textarea_small', |
200 | - 'desc' => __( 'Add a small description for this workout (optional)', 'lsx-health-plan' ), |
|
201 | - ) ); |
|
200 | + 'desc' => __('Add a small description for this workout (optional)', 'lsx-health-plan'), |
|
201 | + )); |
|
202 | 202 | |
203 | - $workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 ); |
|
204 | - if ( false !== $workout_sections && null !== $workout_sections ) { |
|
203 | + $workout_sections = apply_filters('lsx_health_plan_workout_sections_amount', 6); |
|
204 | + if (false !== $workout_sections && null !== $workout_sections) { |
|
205 | 205 | $i = 1; |
206 | - while ( $i <= $workout_sections ) { |
|
206 | + while ($i <= $workout_sections) { |
|
207 | 207 | |
208 | - $cmb_group = new_cmb2_box( array( |
|
208 | + $cmb_group = new_cmb2_box(array( |
|
209 | 209 | 'id' => $this->slug . '_section_' . $i . '_metabox', |
210 | - 'title' => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i, |
|
211 | - 'object_types' => array( $this->slug ), |
|
212 | - ) ); |
|
210 | + 'title' => esc_html__('Exercise Group ', 'lsx-health-plan') . $i, |
|
211 | + 'object_types' => array($this->slug), |
|
212 | + )); |
|
213 | 213 | |
214 | - $cmb_group->add_field( array( |
|
215 | - 'name' => __( 'Title', 'lsx-health-plan' ), |
|
214 | + $cmb_group->add_field(array( |
|
215 | + 'name' => __('Title', 'lsx-health-plan'), |
|
216 | 216 | 'id' => $this->slug . '_section_' . $i . '_title', |
217 | 217 | 'type' => 'text', |
218 | 218 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
219 | - ) ); |
|
219 | + )); |
|
220 | 220 | |
221 | 221 | $cmb_group->add_field( |
222 | 222 | array( |
223 | - 'name' => __( 'Description', 'lsx-health-plan' ), |
|
223 | + 'name' => __('Description', 'lsx-health-plan'), |
|
224 | 224 | 'id' => $this->slug . '_section_' . $i . '_description', |
225 | 225 | 'type' => 'wysiwyg', |
226 | 226 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
@@ -239,27 +239,27 @@ discard block |
||
239 | 239 | 'id' => $this->slug . '_section_' . $i, |
240 | 240 | 'type' => 'group', |
241 | 241 | 'options' => array( |
242 | - 'group_title' => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number |
|
243 | - 'add_button' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
244 | - 'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ), |
|
242 | + 'group_title' => esc_html__('Exercise {#}', 'lsx-health-plan'), // {#} gets replaced by row number |
|
243 | + 'add_button' => esc_html__('Add New', 'lsx-health-plan'), |
|
244 | + 'remove_button' => esc_html__('Delete', 'lsx-health-plan'), |
|
245 | 245 | 'sortable' => true, |
246 | 246 | ), |
247 | 247 | ) |
248 | 248 | ); |
249 | 249 | |
250 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
250 | + if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) { |
|
251 | 251 | $cmb_group->add_group_field( |
252 | 252 | $group_field_id, |
253 | 253 | array( |
254 | - 'name' => __( 'Exercise related to this workout', 'lsx-health-plan' ), |
|
254 | + 'name' => __('Exercise related to this workout', 'lsx-health-plan'), |
|
255 | 255 | 'id' => 'connected_exercises', |
256 | 256 | 'type' => 'post_search_ajax', |
257 | 257 | // Optional : |
258 | 258 | 'limit' => 1, // Limit selection to X items only (default 1) |
259 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
259 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
260 | 260 | 'query_args' => array( |
261 | - 'post_type' => array( 'exercise' ), |
|
262 | - 'post_status' => array( 'publish' ), |
|
261 | + 'post_type' => array('exercise'), |
|
262 | + 'post_status' => array('publish'), |
|
263 | 263 | 'posts_per_page' => -1, |
264 | 264 | ), |
265 | 265 | ) |
@@ -268,15 +268,15 @@ discard block |
||
268 | 268 | $cmb_group->add_group_field( |
269 | 269 | $group_field_id, |
270 | 270 | array( |
271 | - 'name' => __( 'Video related to this workout', 'lsx-health-plan' ), |
|
271 | + 'name' => __('Video related to this workout', 'lsx-health-plan'), |
|
272 | 272 | 'id' => 'connected_videos', |
273 | 273 | 'type' => 'post_search_ajax', |
274 | 274 | // Optional : |
275 | 275 | 'limit' => 1, // Limit selection to X items only (default 1) |
276 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
276 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
277 | 277 | 'query_args' => array( |
278 | - 'post_type' => array( 'video' ), |
|
279 | - 'post_status' => array( 'publish' ), |
|
278 | + 'post_type' => array('video'), |
|
279 | + 'post_status' => array('publish'), |
|
280 | 280 | 'posts_per_page' => -1, |
281 | 281 | ), |
282 | 282 | ) |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $cmb_group->add_group_field( |
285 | 285 | $group_field_id, |
286 | 286 | array( |
287 | - 'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ), |
|
287 | + 'name' => esc_html__('Workout Name', 'lsx-health-plan'), |
|
288 | 288 | 'id' => 'name', |
289 | 289 | 'type' => 'text', |
290 | 290 | // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | $cmb_group->add_group_field( |
295 | 295 | $group_field_id, |
296 | 296 | array( |
297 | - 'name' => __( 'Description', 'lsx-health-plan' ), |
|
297 | + 'name' => __('Description', 'lsx-health-plan'), |
|
298 | 298 | 'id' => 'description', |
299 | 299 | 'type' => 'wysiwyg', |
300 | 300 | 'options' => array( |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | $cmb_group->add_group_field( |
308 | 308 | $group_field_id, |
309 | 309 | array( |
310 | - 'name' => esc_html__( 'Exercise title (Optional)', 'lsx-health-plan' ), |
|
310 | + 'name' => esc_html__('Exercise title (Optional)', 'lsx-health-plan'), |
|
311 | 311 | 'id' => 'alt_title', |
312 | 312 | 'type' => 'text', |
313 | 313 | ) |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $cmb_group->add_group_field( |
316 | 316 | $group_field_id, |
317 | 317 | array( |
318 | - 'name' => esc_html__( 'Exercise Description (Optional)', 'lsx-health-plan' ), |
|
318 | + 'name' => esc_html__('Exercise Description (Optional)', 'lsx-health-plan'), |
|
319 | 319 | 'id' => 'alt_description', |
320 | 320 | 'type' => 'textarea_small', |
321 | 321 | ) |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $cmb_group->add_group_field( |
324 | 324 | $group_field_id, |
325 | 325 | array( |
326 | - 'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ), |
|
326 | + 'name' => esc_html__('Reps / Time / Distance', 'lsx-health-plan'), |
|
327 | 327 | 'id' => 'reps', |
328 | 328 | 'type' => 'text', |
329 | 329 | // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) |
@@ -332,13 +332,13 @@ discard block |
||
332 | 332 | $cmb_group->add_group_field( |
333 | 333 | $group_field_id, |
334 | 334 | array( |
335 | - 'name' => __( 'Exercise Image (Optional)', 'lsx-health-plan' ), |
|
335 | + 'name' => __('Exercise Image (Optional)', 'lsx-health-plan'), |
|
336 | 336 | 'id' => 'exercise_alt_thumbnail', |
337 | 337 | 'type' => 'file', |
338 | 338 | 'text' => array( |
339 | - 'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ), |
|
339 | + 'add_upload_file_text' => __('Add File', 'lsx-health-plan'), |
|
340 | 340 | ), |
341 | - 'desc' => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ), |
|
341 | + 'desc' => __('Upload an image 300px x 300px in size.', 'lsx-health-plan'), |
|
342 | 342 | 'query_args' => array( |
343 | 343 | 'type' => array( |
344 | 344 | 'image/gif', |
@@ -362,14 +362,14 @@ discard block |
||
362 | 362 | * @param object $cmb new_cmb2_box(). |
363 | 363 | * @return void |
364 | 364 | */ |
365 | - public function register_settings( $cmb ) { |
|
366 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
365 | + public function register_settings($cmb) { |
|
366 | + if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) { |
|
367 | 367 | $cmb->add_field( |
368 | 368 | array( |
369 | 369 | 'id' => 'workout_settings_title', |
370 | 370 | 'type' => 'title', |
371 | - 'name' => __( 'Workout Settings', 'lsx-health-plan' ), |
|
372 | - 'description' => __( 'Choose the layout, content and link settings for your exercises.', 'lsx-health-plan' ), |
|
371 | + 'name' => __('Workout Settings', 'lsx-health-plan'), |
|
372 | + 'description' => __('Choose the layout, content and link settings for your exercises.', 'lsx-health-plan'), |
|
373 | 373 | ) |
374 | 374 | ); |
375 | 375 | |
@@ -377,12 +377,12 @@ discard block |
||
377 | 377 | array( |
378 | 378 | 'id' => 'workout_tab_layout', |
379 | 379 | 'type' => 'select', |
380 | - 'name' => __( 'Workout Tab Layout', 'lsx-health-plan' ), |
|
381 | - 'description' => __( 'Choose the layout for the workouts.', 'lsx-health-plan' ), |
|
380 | + 'name' => __('Workout Tab Layout', 'lsx-health-plan'), |
|
381 | + 'description' => __('Choose the layout for the workouts.', 'lsx-health-plan'), |
|
382 | 382 | 'options' => array( |
383 | - 'table' => __( 'Table', 'lsx-health-plan' ), |
|
384 | - 'list' => __( 'List', 'lsx-health-plan' ), |
|
385 | - 'grid' => __( 'Grid', 'lsx-health-plan' ), |
|
383 | + 'table' => __('Table', 'lsx-health-plan'), |
|
384 | + 'list' => __('List', 'lsx-health-plan'), |
|
385 | + 'grid' => __('Grid', 'lsx-health-plan'), |
|
386 | 386 | ), |
387 | 387 | ) |
388 | 388 | ); |
@@ -390,12 +390,12 @@ discard block |
||
390 | 390 | array( |
391 | 391 | 'id' => 'workout_tab_link', |
392 | 392 | 'type' => 'select', |
393 | - 'name' => __( 'Workout Tab Link', 'lsx-health-plan' ), |
|
394 | - 'description' => __( 'Choose to show the excerpt, full content or nothing.', 'lsx-health-plan' ), |
|
393 | + 'name' => __('Workout Tab Link', 'lsx-health-plan'), |
|
394 | + 'description' => __('Choose to show the excerpt, full content or nothing.', 'lsx-health-plan'), |
|
395 | 395 | 'options' => array( |
396 | - '' => __( 'None', 'lsx-health-plan' ), |
|
397 | - 'single' => __( 'Single', 'lsx-health-plan' ), |
|
398 | - 'modal' => __( 'Modal', 'lsx-health-plan' ), |
|
396 | + '' => __('None', 'lsx-health-plan'), |
|
397 | + 'single' => __('Single', 'lsx-health-plan'), |
|
398 | + 'modal' => __('Modal', 'lsx-health-plan'), |
|
399 | 399 | ), |
400 | 400 | 'default' => 'modal', |
401 | 401 | ) |
@@ -404,12 +404,12 @@ discard block |
||
404 | 404 | array( |
405 | 405 | 'id' => 'workout_tab_modal_content', |
406 | 406 | 'type' => 'select', |
407 | - 'name' => __( 'Modal Content', 'lsx-health-plan' ), |
|
408 | - 'description' => __( 'Choose to show the excerpt, full content or nothing. For the modal content only', 'lsx-health-plan' ), |
|
407 | + 'name' => __('Modal Content', 'lsx-health-plan'), |
|
408 | + 'description' => __('Choose to show the excerpt, full content or nothing. For the modal content only', 'lsx-health-plan'), |
|
409 | 409 | 'options' => array( |
410 | - '' => __( 'None', 'lsx-health-plan' ), |
|
411 | - 'excerpt' => __( 'Excerpt', 'lsx-health-plan' ), |
|
412 | - 'full' => __( 'Full Content', 'lsx-health-plan' ), |
|
410 | + '' => __('None', 'lsx-health-plan'), |
|
411 | + 'excerpt' => __('Excerpt', 'lsx-health-plan'), |
|
412 | + 'full' => __('Full Content', 'lsx-health-plan'), |
|
413 | 413 | ), |
414 | 414 | 'default' => '', |
415 | 415 | ) |
@@ -418,14 +418,14 @@ discard block |
||
418 | 418 | array( |
419 | 419 | 'id' => 'workout_tab_columns', |
420 | 420 | 'type' => 'select', |
421 | - 'name' => __( 'Grid Columns', 'lsx-health-plan' ), |
|
422 | - 'description' => __( 'If you are displaying a grid, set the amount of columns you want to use.', 'lsx-health-plan' ), |
|
421 | + 'name' => __('Grid Columns', 'lsx-health-plan'), |
|
422 | + 'description' => __('If you are displaying a grid, set the amount of columns you want to use.', 'lsx-health-plan'), |
|
423 | 423 | 'options' => array( |
424 | - '12' => __( '1', 'lsx-health-plan' ), |
|
425 | - '6' => __( '2', 'lsx-health-plan' ), |
|
426 | - '4' => __( '3', 'lsx-health-plan' ), |
|
427 | - '3' => __( '4', 'lsx-health-plan' ), |
|
428 | - '2' => __( '6', 'lsx-health-plan' ), |
|
424 | + '12' => __('1', 'lsx-health-plan'), |
|
425 | + '6' => __('2', 'lsx-health-plan'), |
|
426 | + '4' => __('3', 'lsx-health-plan'), |
|
427 | + '3' => __('4', 'lsx-health-plan'), |
|
428 | + '2' => __('6', 'lsx-health-plan'), |
|
429 | 429 | ), |
430 | 430 | 'default' => '4', |
431 | 431 | ) |
@@ -434,18 +434,18 @@ discard block |
||
434 | 434 | array( |
435 | 435 | 'id' => 'workout_tab_content', |
436 | 436 | 'type' => 'select', |
437 | - 'name' => __( 'Grid Content', 'lsx-health-plan' ), |
|
438 | - 'description' => __( 'Choose to show the excerpt, full content or nothing. For the grid layout only', 'lsx-health-plan' ), |
|
437 | + 'name' => __('Grid Content', 'lsx-health-plan'), |
|
438 | + 'description' => __('Choose to show the excerpt, full content or nothing. For the grid layout only', 'lsx-health-plan'), |
|
439 | 439 | 'options' => array( |
440 | - '' => __( 'None', 'lsx-health-plan' ), |
|
441 | - 'excerpt' => __( 'Excerpt', 'lsx-health-plan' ), |
|
442 | - 'full' => __( 'Full Content', 'lsx-health-plan' ), |
|
440 | + '' => __('None', 'lsx-health-plan'), |
|
441 | + 'excerpt' => __('Excerpt', 'lsx-health-plan'), |
|
442 | + 'full' => __('Full Content', 'lsx-health-plan'), |
|
443 | 443 | ), |
444 | 444 | 'default' => '', |
445 | 445 | ) |
446 | 446 | ); |
447 | 447 | |
448 | - do_action( 'lsx_hp_workout_settings_page', $cmb ); |
|
448 | + do_action('lsx_hp_workout_settings_page', $cmb); |
|
449 | 449 | |
450 | 450 | $cmb->add_field( |
451 | 451 | array( |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // If this file is called directly, abort. |
15 | -if ( ! defined( 'WPINC' ) ) { |
|
15 | +if ( ! defined('WPINC')) { |
|
16 | 16 | die; |
17 | 17 | } |
18 | -define( 'LSX_HEALTH_PLAN_PATH', plugin_dir_path( __FILE__ ) ); |
|
19 | -define( 'LSX_HEALTH_PLAN_CORE', __FILE__ ); |
|
20 | -define( 'LSX_HEALTH_PLAN_URL', plugin_dir_url( __FILE__ ) ); |
|
21 | -define( 'LSX_HEALTH_PLAN_VER', '1.4.0' ); |
|
18 | +define('LSX_HEALTH_PLAN_PATH', plugin_dir_path(__FILE__)); |
|
19 | +define('LSX_HEALTH_PLAN_CORE', __FILE__); |
|
20 | +define('LSX_HEALTH_PLAN_URL', plugin_dir_url(__FILE__)); |
|
21 | +define('LSX_HEALTH_PLAN_VER', '1.4.0'); |
|
22 | 22 | |
23 | 23 | /* ======================= Below is the Plugin Class init ========================= */ |
24 | 24 | |
@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function lsx_remove_extra_meta_box() { |
33 | 33 | global $wp_meta_boxes; |
34 | - $all_post_types = [ 'plan', 'video', 'workout', 'tip', 'recipe', 'meal' ]; |
|
34 | + $all_post_types = ['plan', 'video', 'workout', 'tip', 'recipe', 'meal']; |
|
35 | 35 | //remove_meta_box( 'wpseo_meta', $all_post_types, 'normal' ); |
36 | - remove_meta_box( 'commentsdiv', $all_post_types, 'normal' ); |
|
37 | - remove_meta_box( 'commentstatusdiv', $all_post_types, 'normal' ); |
|
38 | - remove_meta_box( 'lsx_blocks_title_meta', $all_post_types, 'side' ); |
|
36 | + remove_meta_box('commentsdiv', $all_post_types, 'normal'); |
|
37 | + remove_meta_box('commentstatusdiv', $all_post_types, 'normal'); |
|
38 | + remove_meta_box('lsx_blocks_title_meta', $all_post_types, 'side'); |
|
39 | 39 | } |
40 | -add_action( 'add_meta_boxes', 'lsx_remove_extra_meta_box', 100 ); |
|
40 | +add_action('add_meta_boxes', 'lsx_remove_extra_meta_box', 100); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Redirect user after login or redirect |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | * @return void |
46 | 46 | */ |
47 | 47 | function lsx_login_redirect() { |
48 | - $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
49 | - if ( false === $plan_slug ) { |
|
48 | + $plan_slug = \lsx_health_plan\functions\get_option('my_plan_slug', false); |
|
49 | + if (false === $plan_slug) { |
|
50 | 50 | $plan_slug = 'my-plan'; |
51 | 51 | } |
52 | - return home_url( $plan_slug ); |
|
52 | + return home_url($plan_slug); |
|
53 | 53 | } |
54 | -add_filter( 'woocommerce_login_redirect', 'lsx_login_redirect' ); |
|
54 | +add_filter('woocommerce_login_redirect', 'lsx_login_redirect'); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Undocumented function |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return void |
70 | 70 | */ |
71 | -function lsx_get_svg_icon( $icon ) { |
|
71 | +function lsx_get_svg_icon($icon) { |
|
72 | 72 | $path = '/assets/images/'; |
73 | 73 | |
74 | - if ( file_exists( LSX_HEALTH_PLAN_PATH . $path . $icon ) ) { |
|
74 | + if (file_exists(LSX_HEALTH_PLAN_PATH . $path . $icon)) { |
|
75 | 75 | // Load and return the contents of the file |
76 | 76 | return include LSX_HEALTH_PLAN_PATH . $path . $icon; |
77 | 77 | } |
@@ -54,16 +54,16 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function __construct() { |
56 | 56 | $this->load_classes(); |
57 | - add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) ); |
|
58 | - add_action( 'lsx_hp_settings_page', array( $this, 'generate_tabs' ), 1, 1 ); |
|
59 | - |
|
60 | - add_action( 'lsx_hp_settings_page_general_top', array( $this, 'general_settings' ), 1, 1 ); |
|
61 | - add_action( 'lsx_hp_settings_page', array( $this, 'global_defaults' ), 3, 1 ); |
|
62 | - add_action( 'lsx_hp_settings_page', array( $this, 'global_downloads' ), 5, 1 ); |
|
63 | - add_action( 'lsx_hp_settings_page', array( $this, 'stat_disable' ), 6, 1 ); |
|
64 | - add_action( 'lsx_hp_settings_page', array( $this, 'endpoint_translations' ), 7, 1 ); |
|
65 | - add_action( 'lsx_hp_settings_page', array( $this, 'exercise_translations' ), 7, 1 ); |
|
66 | - add_action( 'lsx_hp_settings_page', array( $this, 'post_type_toggles' ), 9, 1 ); |
|
57 | + add_action('cmb2_admin_init', array($this, 'register_settings_page')); |
|
58 | + add_action('lsx_hp_settings_page', array($this, 'generate_tabs'), 1, 1); |
|
59 | + |
|
60 | + add_action('lsx_hp_settings_page_general_top', array($this, 'general_settings'), 1, 1); |
|
61 | + add_action('lsx_hp_settings_page', array($this, 'global_defaults'), 3, 1); |
|
62 | + add_action('lsx_hp_settings_page', array($this, 'global_downloads'), 5, 1); |
|
63 | + add_action('lsx_hp_settings_page', array($this, 'stat_disable'), 6, 1); |
|
64 | + add_action('lsx_hp_settings_page', array($this, 'endpoint_translations'), 7, 1); |
|
65 | + add_action('lsx_hp_settings_page', array($this, 'exercise_translations'), 7, 1); |
|
66 | + add_action('lsx_hp_settings_page', array($this, 'post_type_toggles'), 9, 1); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public static function get_instance() { |
77 | 77 | // If the single instance hasn't been set, set it now. |
78 | - if ( null === self::$instance ) { |
|
78 | + if (null === self::$instance) { |
|
79 | 79 | self::$instance = new self(); |
80 | 80 | } |
81 | 81 | return self::$instance; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | //'tip', |
96 | 96 | ); |
97 | 97 | |
98 | - foreach ( $this->post_types as $post_type ) { |
|
98 | + foreach ($this->post_types as $post_type) { |
|
99 | 99 | $this->$post_type = require_once LSX_HEALTH_PLAN_PATH . 'classes/admin/settings/class-' . $post_type . '.php'; |
100 | 100 | } |
101 | 101 | } |
@@ -107,124 +107,124 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function set_vars() { |
109 | 109 | |
110 | - $this->default_types = array( |
|
110 | + $this->default_types = array( |
|
111 | 111 | 'page' => array( |
112 | - 'title' => __( 'Warm Up', 'lsx-health-plan' ), |
|
113 | - 'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ), |
|
112 | + 'title' => __('Warm Up', 'lsx-health-plan'), |
|
113 | + 'description' => __('Set a default warm up routine.', 'lsx-health-plan'), |
|
114 | 114 | 'limit' => 1, |
115 | 115 | 'id' => 'plan_warmup', |
116 | 116 | ), |
117 | 117 | ); |
118 | 118 | $this->download_types = array( |
119 | 119 | 'page' => array( |
120 | - 'title' => __( 'Warm Up', 'lsx-health-plan' ), |
|
121 | - 'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ), |
|
120 | + 'title' => __('Warm Up', 'lsx-health-plan'), |
|
121 | + 'description' => __('Set a default warm up routine.', 'lsx-health-plan'), |
|
122 | 122 | 'limit' => 1, |
123 | 123 | ), |
124 | 124 | ); |
125 | - $this->endpoints = array( |
|
125 | + $this->endpoints = array( |
|
126 | 126 | 'endpoint_warm_up' => array( |
127 | - 'title' => __( 'Warm Up Endpoint', 'lsx-health-plan' ), |
|
127 | + 'title' => __('Warm Up Endpoint', 'lsx-health-plan'), |
|
128 | 128 | 'default' => 'warm-up', |
129 | 129 | ), |
130 | 130 | ); |
131 | 131 | |
132 | - if ( post_type_exists( 'meal' ) ) { |
|
133 | - $this->download_types['meal'] = array( |
|
134 | - 'title' => __( 'Meal Plan', 'lsx-health-plan' ), |
|
135 | - 'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ), |
|
132 | + if (post_type_exists('meal')) { |
|
133 | + $this->download_types['meal'] = array( |
|
134 | + 'title' => __('Meal Plan', 'lsx-health-plan'), |
|
135 | + 'description' => __('Set a default meal plan.', 'lsx-health-plan'), |
|
136 | 136 | ); |
137 | - $this->default_types['meal'] = array( |
|
138 | - 'title' => __( 'Meal Plan', 'lsx-health-plan' ), |
|
139 | - 'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ), |
|
137 | + $this->default_types['meal'] = array( |
|
138 | + 'title' => __('Meal Plan', 'lsx-health-plan'), |
|
139 | + 'description' => __('Set a default meal plan.', 'lsx-health-plan'), |
|
140 | 140 | 'id' => 'connected_meals', |
141 | 141 | ); |
142 | 142 | $this->endpoints['endpoint_meal'] = array( |
143 | - 'title' => __( 'Meal Endpoint', 'lsx-health-plan' ), |
|
143 | + 'title' => __('Meal Endpoint', 'lsx-health-plan'), |
|
144 | 144 | 'default' => 'meal', |
145 | - 'description' => __( 'Define the tab slug which shows on the single plan page.', 'lsx-health-plan' ), |
|
145 | + 'description' => __('Define the tab slug which shows on the single plan page.', 'lsx-health-plan'), |
|
146 | 146 | ); |
147 | 147 | $this->endpoints['endpoint_meal_archive'] = array( |
148 | - 'title' => __( 'Meals Archive Endpoint', 'lsx-health-plan' ), |
|
148 | + 'title' => __('Meals Archive Endpoint', 'lsx-health-plan'), |
|
149 | 149 | 'default' => 'meals', |
150 | 150 | ); |
151 | 151 | $this->endpoints['meal_single_slug'] = array( |
152 | - 'title' => __( 'Single Meal Slug', 'lsx-health-plan' ), |
|
152 | + 'title' => __('Single Meal Slug', 'lsx-health-plan'), |
|
153 | 153 | 'default' => 'meal', |
154 | 154 | ); |
155 | 155 | } |
156 | - if ( post_type_exists( 'recipe' ) ) { |
|
156 | + if (post_type_exists('recipe')) { |
|
157 | 157 | $this->download_types['recipe'] = array( |
158 | - 'title' => __( 'Recipe', 'lsx-health-plan' ), |
|
159 | - 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
158 | + 'title' => __('Recipe', 'lsx-health-plan'), |
|
159 | + 'description' => __('Set a default recipe.', 'lsx-health-plan'), |
|
160 | 160 | ); |
161 | 161 | $this->default_types['recipe'] = array( |
162 | - 'title' => __( 'Recipe', 'lsx-health-plan' ), |
|
163 | - 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
162 | + 'title' => __('Recipe', 'lsx-health-plan'), |
|
163 | + 'description' => __('Set a default recipe.', 'lsx-health-plan'), |
|
164 | 164 | 'id' => 'connected_recipes', |
165 | 165 | ); |
166 | 166 | $this->endpoints['endpoint_recipe'] = array( |
167 | - 'title' => __( 'Recipes Endpoint', 'lsx-health-plan' ), |
|
167 | + 'title' => __('Recipes Endpoint', 'lsx-health-plan'), |
|
168 | 168 | 'default' => 'recipe', |
169 | 169 | ); |
170 | 170 | } |
171 | - if ( post_type_exists( 'workout' ) ) { |
|
171 | + if (post_type_exists('workout')) { |
|
172 | 172 | $this->download_types['workout'] = array( |
173 | - 'title' => __( 'Workout', 'lsx-health-plan' ), |
|
174 | - 'description' => __( 'Set a default workout routine PDF.', 'lsx-health-plan' ), |
|
173 | + 'title' => __('Workout', 'lsx-health-plan'), |
|
174 | + 'description' => __('Set a default workout routine PDF.', 'lsx-health-plan'), |
|
175 | 175 | ); |
176 | 176 | $this->default_types['workout'] = array( |
177 | - 'title' => __( 'Workout', 'lsx-health-plan' ), |
|
178 | - 'description' => __( 'Set a default workout routine.', 'lsx-health-plan' ), |
|
177 | + 'title' => __('Workout', 'lsx-health-plan'), |
|
178 | + 'description' => __('Set a default workout routine.', 'lsx-health-plan'), |
|
179 | 179 | 'id' => 'connected_workouts', |
180 | 180 | ); |
181 | 181 | $this->endpoints['endpoint_workout_archive'] = array( |
182 | - 'title' => __( 'Workouts Archive Endpoint', 'lsx-health-plan' ), |
|
182 | + 'title' => __('Workouts Archive Endpoint', 'lsx-health-plan'), |
|
183 | 183 | 'default' => '', |
184 | 184 | ); |
185 | 185 | $this->endpoints['endpoint_workout'] = array( |
186 | - 'title' => __( 'Single Workout Endpoint', 'lsx-health-plan' ), |
|
186 | + 'title' => __('Single Workout Endpoint', 'lsx-health-plan'), |
|
187 | 187 | 'default' => 'workout', |
188 | 188 | ); |
189 | 189 | } |
190 | 190 | |
191 | 191 | $this->endpoints['login_slug'] = array( |
192 | - 'title' => __( 'Login Slug', 'lsx-health-plan' ), |
|
192 | + 'title' => __('Login Slug', 'lsx-health-plan'), |
|
193 | 193 | 'default' => 'login', |
194 | 194 | ); |
195 | 195 | $this->endpoints['my_plan_slug'] = array( |
196 | - 'title' => __( 'My Plan Slug', 'lsx-health-plan' ), |
|
196 | + 'title' => __('My Plan Slug', 'lsx-health-plan'), |
|
197 | 197 | 'default' => 'my-plan', |
198 | 198 | ); |
199 | 199 | $this->endpoints['plan_single_slug'] = array( |
200 | - 'title' => __( 'Single Plan Slug', 'lsx-health-plan' ), |
|
200 | + 'title' => __('Single Plan Slug', 'lsx-health-plan'), |
|
201 | 201 | 'default' => 'plan', |
202 | 202 | ); |
203 | 203 | $this->endpoints['endpoint_plan_archive'] = array( |
204 | - 'title' => __( 'Plans Archive Endpoint', 'lsx-health-plan' ), |
|
204 | + 'title' => __('Plans Archive Endpoint', 'lsx-health-plan'), |
|
205 | 205 | 'default' => 'plans', |
206 | 206 | ); |
207 | 207 | |
208 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
208 | + if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) { |
|
209 | 209 | $this->endpoints['exercise'] = array( |
210 | 210 | 'exercise_single' => array( |
211 | - 'title' => __( 'Single Exercise Slug', 'lsx-health-plan' ), |
|
211 | + 'title' => __('Single Exercise Slug', 'lsx-health-plan'), |
|
212 | 212 | 'default' => 'exercise', |
213 | 213 | ), |
214 | 214 | 'exercise_archive' => array( |
215 | - 'title' => __( 'Archive Exercise Slug', 'lsx-health-plan' ), |
|
215 | + 'title' => __('Archive Exercise Slug', 'lsx-health-plan'), |
|
216 | 216 | 'default' => 'exercises', |
217 | 217 | ), |
218 | 218 | 'exercise_type' => array( |
219 | - 'title' => __( 'Exercise Type Slug', 'lsx-health-plan' ), |
|
219 | + 'title' => __('Exercise Type Slug', 'lsx-health-plan'), |
|
220 | 220 | 'default' => 'exercise-type', |
221 | 221 | ), |
222 | 222 | 'exercise_equipment' => array( |
223 | - 'title' => __( 'Equipment Slug', 'lsx-health-plan' ), |
|
223 | + 'title' => __('Equipment Slug', 'lsx-health-plan'), |
|
224 | 224 | 'default' => 'equipment', |
225 | 225 | ), |
226 | 226 | 'exercise_musclegroup' => array( |
227 | - 'title' => __( 'Muscle Group Slug', 'lsx-health-plan' ), |
|
227 | + 'title' => __('Muscle Group Slug', 'lsx-health-plan'), |
|
228 | 228 | 'default' => 'muscle-group', |
229 | 229 | ), |
230 | 230 | ); |
@@ -239,14 +239,14 @@ discard block |
||
239 | 239 | $cmb = new_cmb2_box( |
240 | 240 | array( |
241 | 241 | 'id' => $this->screen_id, |
242 | - 'title' => esc_html__( 'Settings', 'lsx-health-plan' ), |
|
243 | - 'object_types' => array( 'options-page' ), |
|
242 | + 'title' => esc_html__('Settings', 'lsx-health-plan'), |
|
243 | + 'object_types' => array('options-page'), |
|
244 | 244 | 'option_key' => 'lsx_health_plan_options', // The option key and admin menu page slug. |
245 | 245 | 'parent_slug' => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu. |
246 | 246 | 'capability' => 'manage_options', // Cap required to view options-page. |
247 | 247 | ) |
248 | 248 | ); |
249 | - do_action( 'lsx_hp_settings_page', $cmb ); |
|
249 | + do_action('lsx_hp_settings_page', $cmb); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -255,17 +255,17 @@ discard block |
||
255 | 255 | * @param object $cmb new_cmb2_box(). |
256 | 256 | * @return void |
257 | 257 | */ |
258 | - public function general_settings( $cmb ) { |
|
258 | + public function general_settings($cmb) { |
|
259 | 259 | $cmb->add_field( |
260 | 260 | array( |
261 | - 'name' => __( 'Membership Product', 'lsx-health-plan' ), |
|
261 | + 'name' => __('Membership Product', 'lsx-health-plan'), |
|
262 | 262 | 'id' => 'membership_product', |
263 | 263 | 'type' => 'post_search_ajax', |
264 | 264 | 'limit' => 1, |
265 | 265 | 'sortable' => false, |
266 | 266 | 'query_args' => array( |
267 | - 'post_type' => array( 'product' ), |
|
268 | - 'post_status' => array( 'publish' ), |
|
267 | + 'post_type' => array('product'), |
|
268 | + 'post_status' => array('publish'), |
|
269 | 269 | 'posts_per_page' => -1, |
270 | 270 | ), |
271 | 271 | ) |
@@ -273,43 +273,43 @@ discard block |
||
273 | 273 | |
274 | 274 | $cmb->add_field( |
275 | 275 | array( |
276 | - 'name' => __( 'Your Warm-up Intro', 'lsx-health-plan' ), |
|
276 | + 'name' => __('Your Warm-up Intro', 'lsx-health-plan'), |
|
277 | 277 | 'id' => 'warmup_intro', |
278 | 278 | 'type' => 'textarea_small', |
279 | 279 | 'value' => '', |
280 | - 'default' => __( "Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan' ), |
|
280 | + 'default' => __("Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan'), |
|
281 | 281 | ) |
282 | 282 | ); |
283 | - if ( post_type_exists( 'workout' ) ) { |
|
283 | + if (post_type_exists('workout')) { |
|
284 | 284 | $cmb->add_field( |
285 | 285 | array( |
286 | - 'name' => __( 'Your Workout Intro', 'lsx-health-plan' ), |
|
286 | + 'name' => __('Your Workout Intro', 'lsx-health-plan'), |
|
287 | 287 | 'id' => 'workout_intro', |
288 | 288 | 'type' => 'textarea_small', |
289 | 289 | 'value' => '', |
290 | - 'default' => __( "Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan' ), |
|
290 | + 'default' => __("Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan'), |
|
291 | 291 | ) |
292 | 292 | ); |
293 | 293 | } |
294 | - if ( post_type_exists( 'meal' ) ) { |
|
294 | + if (post_type_exists('meal')) { |
|
295 | 295 | $cmb->add_field( |
296 | 296 | array( |
297 | - 'name' => __( 'Your Meal Plan Intro', 'lsx-health-plan' ), |
|
297 | + 'name' => __('Your Meal Plan Intro', 'lsx-health-plan'), |
|
298 | 298 | 'id' => 'meal_plan_intro', |
299 | 299 | 'type' => 'textarea_small', |
300 | 300 | 'value' => '', |
301 | - 'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ), |
|
301 | + 'default' => __('Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan'), |
|
302 | 302 | ) |
303 | 303 | ); |
304 | 304 | } |
305 | - if ( post_type_exists( 'recipe' ) ) { |
|
305 | + if (post_type_exists('recipe')) { |
|
306 | 306 | $cmb->add_field( |
307 | 307 | array( |
308 | - 'name' => __( 'Recipes Intro', 'lsx-health-plan' ), |
|
308 | + 'name' => __('Recipes Intro', 'lsx-health-plan'), |
|
309 | 309 | 'id' => 'recipes_intro', |
310 | 310 | 'type' => 'textarea_small', |
311 | 311 | 'value' => '', |
312 | - 'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan' ), |
|
312 | + 'default' => __("Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan'), |
|
313 | 313 | ) |
314 | 314 | ); |
315 | 315 | } |
@@ -321,27 +321,27 @@ discard block |
||
321 | 321 | * @param object $cmb new_cmb2_box(). |
322 | 322 | * @return void |
323 | 323 | */ |
324 | - public function global_defaults( $cmb ) { |
|
324 | + public function global_defaults($cmb) { |
|
325 | 325 | $cmb->add_field( |
326 | 326 | array( |
327 | 327 | 'id' => 'global_defaults_title', |
328 | 328 | 'type' => 'title', |
329 | - 'name' => __( 'Global Defaults', 'lsx-health-plan' ), |
|
330 | - 'default' => __( 'Global Defaults', 'lsx-health-plan' ), |
|
331 | - 'description' => __( 'If you have not connected a specific post to your day plan, set a default option below.', 'lsx-health-plan' ), |
|
329 | + 'name' => __('Global Defaults', 'lsx-health-plan'), |
|
330 | + 'default' => __('Global Defaults', 'lsx-health-plan'), |
|
331 | + 'description' => __('If you have not connected a specific post to your day plan, set a default option below.', 'lsx-health-plan'), |
|
332 | 332 | ) |
333 | 333 | ); |
334 | 334 | |
335 | - foreach ( $this->default_types as $type => $default_type ) { |
|
335 | + foreach ($this->default_types as $type => $default_type) { |
|
336 | 336 | $limit = 5; |
337 | 337 | $sortable = false; |
338 | - if ( isset( $default_type['limit'] ) ) { |
|
338 | + if (isset($default_type['limit'])) { |
|
339 | 339 | $limit = $default_type['limit']; |
340 | 340 | $sortable = true; |
341 | 341 | } |
342 | 342 | |
343 | - if ( 'page' === $type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
344 | - $type = array( 'page', 'workout' ); |
|
343 | + if ('page' === $type && false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) { |
|
344 | + $type = array('page', 'workout'); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | $cmb->add_field( |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | 'sortable' => $sortable, |
355 | 355 | 'query_args' => array( |
356 | 356 | 'post_type' => $type, |
357 | - 'post_status' => array( 'publish' ), |
|
357 | + 'post_status' => array('publish'), |
|
358 | 358 | 'posts_per_page' => -1, |
359 | 359 | ), |
360 | 360 | ) |
@@ -375,20 +375,20 @@ discard block |
||
375 | 375 | * @param object $cmb new_cmb2_box(). |
376 | 376 | * @return void |
377 | 377 | */ |
378 | - public function global_downloads( $cmb ) { |
|
378 | + public function global_downloads($cmb) { |
|
379 | 379 | $cmb->add_field( |
380 | 380 | array( |
381 | 381 | 'id' => 'global_downloads_title', |
382 | 382 | 'type' => 'title', |
383 | - 'name' => __( 'Global Downloads', 'lsx-health-plan' ), |
|
384 | - 'default' => __( 'Global Downloads', 'lsx-health-plan' ), |
|
383 | + 'name' => __('Global Downloads', 'lsx-health-plan'), |
|
384 | + 'default' => __('Global Downloads', 'lsx-health-plan'), |
|
385 | 385 | ) |
386 | 386 | ); |
387 | 387 | |
388 | - foreach ( $this->download_types as $type => $download_type ) { |
|
388 | + foreach ($this->download_types as $type => $download_type) { |
|
389 | 389 | $limit = 5; |
390 | 390 | $sortable = false; |
391 | - if ( isset( $download_type['limit'] ) ) { |
|
391 | + if (isset($download_type['limit'])) { |
|
392 | 392 | $limit = $download_type['limit']; |
393 | 393 | $sortable = true; |
394 | 394 | } |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | 'limit' => $limit, |
402 | 402 | 'sortable' => $sortable, |
403 | 403 | 'query_args' => array( |
404 | - 'post_type' => array( 'dlm_download' ), |
|
405 | - 'post_status' => array( 'publish' ), |
|
404 | + 'post_type' => array('dlm_download'), |
|
405 | + 'post_status' => array('publish'), |
|
406 | 406 | 'posts_per_page' => -1, |
407 | 407 | ), |
408 | 408 | ) |
@@ -422,18 +422,18 @@ discard block |
||
422 | 422 | * @param object $cmb new_cmb2_box(). |
423 | 423 | * @return void |
424 | 424 | */ |
425 | - public function endpoint_translations( $cmb ) { |
|
425 | + public function endpoint_translations($cmb) { |
|
426 | 426 | $cmb->add_field( |
427 | 427 | array( |
428 | 428 | 'id' => 'endpoints_title', |
429 | 429 | 'type' => 'title', |
430 | - 'name' => __( 'Set Endpoint Translations', 'lsx-health-plan' ), |
|
431 | - 'default' => __( 'Set Endpoint Translations', 'lsx-health-plan' ), |
|
432 | - 'description' => __( 'Endpoint is a web address (URL) at which the user can gain access to it. You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ), |
|
430 | + 'name' => __('Set Endpoint Translations', 'lsx-health-plan'), |
|
431 | + 'default' => __('Set Endpoint Translations', 'lsx-health-plan'), |
|
432 | + 'description' => __('Endpoint is a web address (URL) at which the user can gain access to it. You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan'), |
|
433 | 433 | ) |
434 | 434 | ); |
435 | - foreach ( $this->endpoints as $slug => $endpoint_vars ) { |
|
436 | - if ( 'exercise' === $slug ) { |
|
435 | + foreach ($this->endpoints as $slug => $endpoint_vars) { |
|
436 | + if ('exercise' === $slug) { |
|
437 | 437 | continue; |
438 | 438 | } |
439 | 439 | |
@@ -461,19 +461,19 @@ discard block |
||
461 | 461 | * @param object $cmb new_cmb2_box(). |
462 | 462 | * @return void |
463 | 463 | */ |
464 | - public function exercise_translations( $cmb ) { |
|
465 | - if ( isset( $this->endpoints['exercise'] ) && '' !== $this->endpoints['exercise'] && ! empty( $this->endpoints['exercise'] ) ) { |
|
464 | + public function exercise_translations($cmb) { |
|
465 | + if (isset($this->endpoints['exercise']) && '' !== $this->endpoints['exercise'] && ! empty($this->endpoints['exercise'])) { |
|
466 | 466 | $cmb->add_field( |
467 | 467 | array( |
468 | 468 | 'id' => 'exercise_endpoints_title', |
469 | 469 | 'type' => 'title', |
470 | - 'name' => __( 'Set Exercise Translations', 'lsx-health-plan' ), |
|
471 | - 'default' => __( 'Set Exercise Translations', 'lsx-health-plan' ), |
|
472 | - 'description' => __( 'You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ), |
|
470 | + 'name' => __('Set Exercise Translations', 'lsx-health-plan'), |
|
471 | + 'default' => __('Set Exercise Translations', 'lsx-health-plan'), |
|
472 | + 'description' => __('You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan'), |
|
473 | 473 | ) |
474 | 474 | ); |
475 | 475 | |
476 | - foreach ( $this->endpoints['exercise'] as $slug => $endpoint_vars ) { |
|
476 | + foreach ($this->endpoints['exercise'] as $slug => $endpoint_vars) { |
|
477 | 477 | $cmb->add_field( |
478 | 478 | array( |
479 | 479 | 'name' => $endpoint_vars['title'], |
@@ -499,27 +499,27 @@ discard block |
||
499 | 499 | * @param object $cmb new_cmb2_box(). |
500 | 500 | * @return void |
501 | 501 | */ |
502 | - public function post_type_toggles( $cmb ) { |
|
503 | - $post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) ); |
|
502 | + public function post_type_toggles($cmb) { |
|
503 | + $post_types = apply_filters('lsx_health_plan_post_types', isset($this->post_types)); |
|
504 | 504 | |
505 | 505 | $cmb->add_field( |
506 | 506 | array( |
507 | 507 | 'id' => 'post_type_toggles_title', |
508 | 508 | 'type' => 'title', |
509 | - 'name' => __( 'Disable Post Types', 'lsx-health-plan' ), |
|
510 | - 'default' => __( 'Disable Post Types', 'lsx-health-plan' ), |
|
511 | - 'description' => __( 'Disable post types if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
509 | + 'name' => __('Disable Post Types', 'lsx-health-plan'), |
|
510 | + 'default' => __('Disable Post Types', 'lsx-health-plan'), |
|
511 | + 'description' => __('Disable post types if you are wanting a minimal site.', 'lsx-health-plan'), |
|
512 | 512 | ) |
513 | 513 | ); |
514 | 514 | |
515 | - foreach ( $post_types as $post_type ) { |
|
516 | - if ( 'plan' === $post_type || 'exercise' === $post_type || ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) ) { |
|
515 | + foreach ($post_types as $post_type) { |
|
516 | + if ('plan' === $post_type || 'exercise' === $post_type || ('video' === $post_type && false !== \lsx_health_plan\functions\get_option('exercise_enabled', false))) { |
|
517 | 517 | continue; |
518 | 518 | } |
519 | 519 | |
520 | 520 | $cmb->add_field( |
521 | 521 | array( |
522 | - 'name' => ucwords( $post_type ), |
|
522 | + 'name' => ucwords($post_type), |
|
523 | 523 | 'id' => $post_type . '_disabled', |
524 | 524 | 'type' => 'checkbox', |
525 | 525 | 'value' => 1, |
@@ -539,19 +539,19 @@ discard block |
||
539 | 539 | array( |
540 | 540 | 'id' => 'post_type_toggles_enable_title', |
541 | 541 | 'type' => 'title', |
542 | - 'name' => __( 'Enable Post Types', 'lsx-health-plan' ), |
|
543 | - 'default' => __( 'Enable Post Types', 'lsx-health-plan' ), |
|
544 | - 'description' => __( 'Enable new functionailty like the "exercise" post type.', 'lsx-health-plan' ), |
|
542 | + 'name' => __('Enable Post Types', 'lsx-health-plan'), |
|
543 | + 'default' => __('Enable Post Types', 'lsx-health-plan'), |
|
544 | + 'description' => __('Enable new functionailty like the "exercise" post type.', 'lsx-health-plan'), |
|
545 | 545 | ) |
546 | 546 | ); |
547 | 547 | $cmb->add_field( |
548 | 548 | array( |
549 | - 'name' => __( 'Exercises', 'lsx-health-plan' ), |
|
549 | + 'name' => __('Exercises', 'lsx-health-plan'), |
|
550 | 550 | 'id' => 'exercise_enabled', |
551 | 551 | 'type' => 'checkbox', |
552 | 552 | 'value' => 1, |
553 | 553 | 'default' => 0, |
554 | - 'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ), |
|
554 | + 'description' => __('Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan'), |
|
555 | 555 | ) |
556 | 556 | ); |
557 | 557 | $cmb->add_field( |
@@ -568,18 +568,18 @@ discard block |
||
568 | 568 | * @return void |
569 | 569 | */ |
570 | 570 | |
571 | - public function stat_disable( $cmb ) { |
|
571 | + public function stat_disable($cmb) { |
|
572 | 572 | $cmb->add_field( |
573 | 573 | array( |
574 | 574 | 'id' => 'stat_disable_title', |
575 | 575 | 'type' => 'title', |
576 | - 'name' => __( 'Disable Profile Stats', 'lsx-health-plan' ), |
|
577 | - 'default' => __( 'Disable Profile Stats', 'lsx-health-plan' ), |
|
576 | + 'name' => __('Disable Profile Stats', 'lsx-health-plan'), |
|
577 | + 'default' => __('Disable Profile Stats', 'lsx-health-plan'), |
|
578 | 578 | ) |
579 | 579 | ); |
580 | 580 | $cmb->add_field( |
581 | 581 | array( |
582 | - 'name' => __( 'Disable All Stats', 'lsx-health-plan' ), |
|
582 | + 'name' => __('Disable All Stats', 'lsx-health-plan'), |
|
583 | 583 | 'desc' => 'Disable All Stats', |
584 | 584 | 'id' => 'disable_all_stats', |
585 | 585 | 'type' => 'checkbox', |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | ); |
590 | 590 | $cmb->add_field( |
591 | 591 | array( |
592 | - 'name' => __( 'Disable Weight', 'lsx-health-plan' ), |
|
592 | + 'name' => __('Disable Weight', 'lsx-health-plan'), |
|
593 | 593 | 'id' => 'disable_weight_checkbox', |
594 | 594 | 'type' => 'checkbox', |
595 | 595 | 'value' => 1, |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | ); |
599 | 599 | $cmb->add_field( |
600 | 600 | array( |
601 | - 'name' => __( 'Disable Waist', 'lsx-health-plan' ), |
|
601 | + 'name' => __('Disable Waist', 'lsx-health-plan'), |
|
602 | 602 | 'id' => 'disable_waist_checkbox', |
603 | 603 | 'type' => 'checkbox', |
604 | 604 | 'value' => 1, |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | ); |
608 | 608 | $cmb->add_field( |
609 | 609 | array( |
610 | - 'name' => __( 'Disable Fitness', 'lsx-health-plan' ), |
|
610 | + 'name' => __('Disable Fitness', 'lsx-health-plan'), |
|
611 | 611 | 'id' => 'disable_fitness_checkbox', |
612 | 612 | 'type' => 'checkbox', |
613 | 613 | 'value' => 1, |
@@ -629,10 +629,10 @@ discard block |
||
629 | 629 | * @param string $section either engine,archive or single. |
630 | 630 | * @return void |
631 | 631 | */ |
632 | - public function generate_tabs( $cmb ) { |
|
632 | + public function generate_tabs($cmb) { |
|
633 | 633 | $tabs = $this->get_settings_tabs(); |
634 | 634 | |
635 | - foreach ( $tabs as $tab_key => $tab ) { |
|
635 | + foreach ($tabs as $tab_key => $tab) { |
|
636 | 636 | $cmb->add_field( |
637 | 637 | array( |
638 | 638 | 'id' => 'settings_' . $tab_key . '_title', |
@@ -642,11 +642,11 @@ discard block |
||
642 | 642 | 'description' => $tab['desc'], |
643 | 643 | ) |
644 | 644 | ); |
645 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb ); |
|
645 | + do_action('lsx_hp_settings_page_' . $tab_key . '_top', $cmb); |
|
646 | 646 | |
647 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb ); |
|
647 | + do_action('lsx_hp_settings_page_' . $tab_key . '_middle', $cmb); |
|
648 | 648 | |
649 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb ); |
|
649 | + do_action('lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb); |
|
650 | 650 | |
651 | 651 | $cmb->add_field( |
652 | 652 | array( |
@@ -666,26 +666,26 @@ discard block |
||
666 | 666 | public function get_settings_tabs() { |
667 | 667 | $tabs = array( |
668 | 668 | 'general' => array( |
669 | - 'title' => __( 'General', 'lsx-health-plan' ), |
|
670 | - 'desc' => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ), |
|
669 | + 'title' => __('General', 'lsx-health-plan'), |
|
670 | + 'desc' => __('Control the sitewide settings for the LSX HP site.', 'lsx-health-plan'), |
|
671 | 671 | ), |
672 | 672 | ); |
673 | 673 | |
674 | - foreach ( $this->post_types as $post_type ) { |
|
675 | - switch ( $post_type ) { |
|
674 | + foreach ($this->post_types as $post_type) { |
|
675 | + switch ($post_type) { |
|
676 | 676 | default: |
677 | - if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) { |
|
678 | - $temp_post_type = get_post_type_object( $post_type ); |
|
679 | - if ( ! is_wp_error( $temp_post_type ) ) { |
|
680 | - $page_url = get_post_type_archive_link( $temp_post_type->name ); |
|
677 | + if ( ! in_array($post_type, \lsx\search\includes\get_restricted_post_types())) { |
|
678 | + $temp_post_type = get_post_type_object($post_type); |
|
679 | + if ( ! is_wp_error($temp_post_type)) { |
|
680 | + $page_url = get_post_type_archive_link($temp_post_type->name); |
|
681 | 681 | $description = sprintf( |
682 | 682 | /* translators: %s: The subscription info */ |
683 | - __( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ), |
|
683 | + __('Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search'), |
|
684 | 684 | $page_url, |
685 | 685 | $temp_post_type->label |
686 | 686 | ); |
687 | 687 | |
688 | - $tabs[ $post_type ] = array( |
|
688 | + $tabs[$post_type] = array( |
|
689 | 689 | 'title' => $temp_post_type->label, |
690 | 690 | 'desc' => $description, |
691 | 691 | ); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * Contructor |
26 | 26 | */ |
27 | 27 | public function __construct() { |
28 | - add_action( 'lsx_hp_settings_page_plan_top', array( $this, 'settings' ), 1, 1 ); |
|
28 | + add_action('lsx_hp_settings_page_plan_top', array($this, 'settings'), 1, 1); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public static function get_instance() { |
39 | 39 | // If the single instance hasn't been set, set it now. |
40 | - if ( null === self::$instance ) { |
|
40 | + if (null === self::$instance) { |
|
41 | 41 | self::$instance = new self(); |
42 | 42 | } |
43 | 43 | return self::$instance; |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | * @param object $cmb new_cmb2_box(). |
50 | 50 | * @return void |
51 | 51 | */ |
52 | - public function settings( $cmb ) { |
|
52 | + public function settings($cmb) { |
|
53 | 53 | $cmb->add_field( |
54 | 54 | array( |
55 | - 'name' => __( 'Plan Filters', 'lsx-health-plan' ), |
|
55 | + 'name' => __('Plan Filters', 'lsx-health-plan'), |
|
56 | 56 | 'id' => 'plan_filters_disabled', |
57 | 57 | 'type' => 'checkbox', |
58 | 58 | 'value' => 1, |
59 | 59 | 'default' => 0, |
60 | - 'description' => __( 'Toggle the display of the tab filters on the post type archive.', 'lsx-health-plan' ), |
|
60 | + 'description' => __('Toggle the display of the tab filters on the post type archive.', 'lsx-health-plan'), |
|
61 | 61 | ) |
62 | 62 | ); |
63 | 63 | } |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function __construct() { |
24 | 24 | // Before Output. |
25 | - add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 ); |
|
26 | - add_filter( 'wp_kses_allowed_html', array( $this, 'allow_html_tags_attributes' ), 100, 2 ); |
|
25 | + add_action('wp_enqueue_scripts', array($this, 'assets'), 5); |
|
26 | + add_filter('wp_kses_allowed_html', array($this, 'allow_html_tags_attributes'), 100, 2); |
|
27 | 27 | |
28 | 28 | // Output. |
29 | - add_action( 'body_class', array( $this, 'body_classes' ) ); |
|
30 | - add_filter( 'lsx_global_header_title', array( $this, 'single_title' ), 200, 1 ); |
|
31 | - add_action( 'wp_head', array( $this, 'remove_single_footer' ), 99 ); |
|
29 | + add_action('body_class', array($this, 'body_classes')); |
|
30 | + add_filter('lsx_global_header_title', array($this, 'single_title'), 200, 1); |
|
31 | + add_action('wp_head', array($this, 'remove_single_footer'), 99); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function get_instance() { |
42 | 42 | // If the single instance hasn't been set, set it now. |
43 | - if ( null === self::$instance ) { |
|
43 | + if (null === self::$instance) { |
|
44 | 44 | self::$instance = new self(); |
45 | 45 | } |
46 | 46 | return self::$instance; |
@@ -53,21 +53,21 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function assets() { |
55 | 55 | |
56 | - if ( is_post_type_archive( 'plan' ) && false === \lsx_health_plan\functions\plan\is_filters_disabled() ) { |
|
57 | - wp_enqueue_script( 'isotope', LSX_HEALTH_PLAN_URL . 'assets/js/vendor/isotope.pkgd.min.js', array( 'jquery' ), null, LSX_HEALTH_PLAN_URL, true ); |
|
56 | + if (is_post_type_archive('plan') && false === \lsx_health_plan\functions\plan\is_filters_disabled()) { |
|
57 | + wp_enqueue_script('isotope', LSX_HEALTH_PLAN_URL . 'assets/js/vendor/isotope.pkgd.min.js', array('jquery'), null, LSX_HEALTH_PLAN_URL, true); |
|
58 | 58 | } |
59 | 59 | |
60 | - wp_enqueue_style( 'lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER ); |
|
61 | - wp_style_add_data( 'lsx-health-plan', 'rtl', 'replace' ); |
|
62 | - wp_enqueue_script( 'lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array( 'jquery' ) ); |
|
60 | + wp_enqueue_style('lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER); |
|
61 | + wp_style_add_data('lsx-health-plan', 'rtl', 'replace'); |
|
62 | + wp_enqueue_script('lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array('jquery')); |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Adds the iframe and the progress HTML tags to the allowed WordPress list. |
68 | 68 | */ |
69 | - public function allow_html_tags_attributes( $tags, $context ) { |
|
70 | - if ( 'post' === $context ) { |
|
69 | + public function allow_html_tags_attributes($tags, $context) { |
|
70 | + if ('post' === $context) { |
|
71 | 71 | $tags['iframe'] = array( |
72 | 72 | 'src' => true, |
73 | 73 | 'height' => true, |
@@ -90,31 +90,31 @@ discard block |
||
90 | 90 | * @param array $classes |
91 | 91 | * @return void |
92 | 92 | */ |
93 | - public function body_classes( $classes = array() ) { |
|
93 | + public function body_classes($classes = array()) { |
|
94 | 94 | global $post; |
95 | 95 | |
96 | - if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'lsx_health_plan_my_profile_block' ) ) { |
|
96 | + if (isset($post->post_content) && has_shortcode($post->post_content, 'lsx_health_plan_my_profile_block')) { |
|
97 | 97 | $classes[] = 'my-plan-shortcode'; |
98 | 98 | } |
99 | 99 | |
100 | - if ( is_single() && is_singular( 'plan' ) ) { |
|
100 | + if (is_single() && is_singular('plan')) { |
|
101 | 101 | $args = array( |
102 | 102 | 'post_parent' => get_the_ID(), |
103 | 103 | 'post_type' => 'plan', |
104 | 104 | ); |
105 | 105 | |
106 | 106 | $post_id = get_the_ID(); |
107 | - $has_children = get_children( $args ); |
|
108 | - $has_parent = wp_get_post_parent_id( $post_id ); |
|
107 | + $has_children = get_children($args); |
|
108 | + $has_parent = wp_get_post_parent_id($post_id); |
|
109 | 109 | |
110 | - if ( ! empty( $has_children ) ) { |
|
110 | + if ( ! empty($has_children)) { |
|
111 | 111 | $plan_type_class = 'parent-plan-page'; |
112 | - if ( 0 !== $has_parent ) { |
|
112 | + if (0 !== $has_parent) { |
|
113 | 113 | $plan_type_class = 'parent-sub-plan-page'; |
114 | 114 | } |
115 | 115 | } else { |
116 | 116 | $plan_type_class = 'unique-plan-page'; |
117 | - if ( 0 !== $has_parent ) { |
|
117 | + if (0 !== $has_parent) { |
|
118 | 118 | $plan_type_class = 'child-plan-page'; |
119 | 119 | } |
120 | 120 | } |
@@ -126,16 +126,16 @@ discard block |
||
126 | 126 | /** |
127 | 127 | * Remove the single recipe and exercise title |
128 | 128 | */ |
129 | - public function single_title( $title ) { |
|
129 | + public function single_title($title) { |
|
130 | 130 | |
131 | - if ( is_single() && is_singular( 'recipe' ) ) { |
|
131 | + if (is_single() && is_singular('recipe')) { |
|
132 | 132 | |
133 | - $title = __( 'Recipe', 'lsx-health-plan' ); |
|
133 | + $title = __('Recipe', 'lsx-health-plan'); |
|
134 | 134 | } |
135 | 135 | |
136 | - if ( is_single() && is_singular( 'exercise' ) ) { |
|
136 | + if (is_single() && is_singular('exercise')) { |
|
137 | 137 | |
138 | - $title = __( 'Exercise', 'lsx-health-plan' ); |
|
138 | + $title = __('Exercise', 'lsx-health-plan'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | return $title; |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * @return void |
148 | 148 | */ |
149 | 149 | public function remove_single_footer() { |
150 | - if ( is_single() && is_singular( array( 'exercise', 'recipe', 'workout', 'meal' ) ) ) { |
|
151 | - remove_action( 'lsx_footer_before', 'lsx_add_footer_sidebar_area' ); |
|
150 | + if (is_single() && is_singular(array('exercise', 'recipe', 'workout', 'meal'))) { |
|
151 | + remove_action('lsx_footer_before', 'lsx_add_footer_sidebar_area'); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | * Contructor |
22 | 22 | */ |
23 | 23 | public function __construct() { |
24 | - add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 ); |
|
25 | - add_filter( 'template_include', array( $this, 'single_template_include' ), 99 ); |
|
26 | - add_filter( 'template_include', array( $this, 'taxonomy_template_include' ), 99 ); |
|
24 | + add_filter('template_include', array($this, 'archive_template_include'), 99); |
|
25 | + add_filter('template_include', array($this, 'single_template_include'), 99); |
|
26 | + add_filter('template_include', array($this, 'taxonomy_template_include'), 99); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function get_instance() { |
37 | 37 | // If the single instance hasn't been set, set it now. |
38 | - if ( null === self::$instance ) { |
|
38 | + if (null === self::$instance) { |
|
39 | 39 | self::$instance = new self(); |
40 | 40 | } |
41 | 41 | return self::$instance; |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * Archive template. |
46 | 46 | */ |
47 | - public function archive_template_include( $template ) { |
|
48 | - $applicable_post_types = apply_filters( 'lsx_health_plan_archive_template', array() ); |
|
49 | - if ( ! empty( $applicable_post_types ) && is_main_query() && is_post_type_archive( $applicable_post_types ) ) { |
|
47 | + public function archive_template_include($template) { |
|
48 | + $applicable_post_types = apply_filters('lsx_health_plan_archive_template', array()); |
|
49 | + if ( ! empty($applicable_post_types) && is_main_query() && is_post_type_archive($applicable_post_types)) { |
|
50 | 50 | $post_type = get_post_type(); |
51 | - if ( empty( locate_template( array( 'archive-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php' ) ) { |
|
51 | + if (empty(locate_template(array('archive-' . $post_type . '.php'))) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php')) { |
|
52 | 52 | $template = LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php'; |
53 | 53 | } |
54 | 54 | } |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | /** |
59 | 59 | * Single template. |
60 | 60 | */ |
61 | - public function single_template_include( $template ) { |
|
62 | - $applicable_post_types = apply_filters( 'lsx_health_plan_single_template', array() ); |
|
63 | - if ( ! empty( $applicable_post_types ) && is_main_query() && is_singular( $applicable_post_types ) ) { |
|
61 | + public function single_template_include($template) { |
|
62 | + $applicable_post_types = apply_filters('lsx_health_plan_single_template', array()); |
|
63 | + if ( ! empty($applicable_post_types) && is_main_query() && is_singular($applicable_post_types)) { |
|
64 | 64 | $post_type = get_post_type(); |
65 | - if ( empty( locate_template( array( 'single-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php' ) ) { |
|
65 | + if (empty(locate_template(array('single-' . $post_type . '.php'))) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php')) { |
|
66 | 66 | $template = LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php'; |
67 | 67 | } |
68 | 68 | } |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param $template string |
76 | 76 | * @return string |
77 | 77 | */ |
78 | - public function taxonomy_template_include( $template ) { |
|
79 | - $applicable_taxonomies = apply_filters( 'lsx_health_plan_taxonomies_template', array() ); |
|
80 | - if ( is_main_query() && is_tax( $applicable_taxonomies ) ) { |
|
81 | - $current_taxonomy = get_query_var( 'taxonomy' ); |
|
82 | - if ( '' === locate_template( array( 'taxonomy-' . $current_taxonomy . '.php' ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php' ) ) { |
|
78 | + public function taxonomy_template_include($template) { |
|
79 | + $applicable_taxonomies = apply_filters('lsx_health_plan_taxonomies_template', array()); |
|
80 | + if (is_main_query() && is_tax($applicable_taxonomies)) { |
|
81 | + $current_taxonomy = get_query_var('taxonomy'); |
|
82 | + if ('' === locate_template(array('taxonomy-' . $current_taxonomy . '.php')) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php')) { |
|
83 | 83 | $template = LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php'; |
84 | 84 | } |
85 | 85 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * Contructor |
22 | 22 | */ |
23 | 23 | public function __construct() { |
24 | - add_action( 'init', array( $this, 'handle_day_action' ), 100 ); |
|
24 | + add_action('init', array($this, 'handle_day_action'), 100); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public static function get_instance() { |
35 | 35 | // If the single instance hasn't been set, set it now. |
36 | - if ( null === self::$instance ) { |
|
36 | + if (null === self::$instance) { |
|
37 | 37 | self::$instance = new self(); |
38 | 38 | } |
39 | 39 | return self::$instance; |
@@ -43,18 +43,18 @@ discard block |
||
43 | 43 | * Registers the rewrites. |
44 | 44 | */ |
45 | 45 | public function handle_day_action() { |
46 | - if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'complete' ) ) { |
|
47 | - update_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete', true ); |
|
48 | - $plan_id = sanitize_key( $_POST['lsx-health-plan-id'] ); |
|
49 | - $plan_parent = wp_get_post_parent_id( $plan_id ); |
|
50 | - if ( 0 !== $plan_parent ) { |
|
46 | + if (isset($_POST['lsx-health-plan-actions']) && wp_verify_nonce($_POST['lsx-health-plan-actions'], 'complete')) { |
|
47 | + update_user_meta(get_current_user_id(), 'day_' . sanitize_key($_POST['lsx-health-plan-id']) . '_complete', true); |
|
48 | + $plan_id = sanitize_key($_POST['lsx-health-plan-id']); |
|
49 | + $plan_parent = wp_get_post_parent_id($plan_id); |
|
50 | + if (0 !== $plan_parent) { |
|
51 | 51 | $plan_id = $plan_parent; |
52 | 52 | } |
53 | - wp_safe_redirect( get_permalink( $plan_id ) ); |
|
53 | + wp_safe_redirect(get_permalink($plan_id)); |
|
54 | 54 | } |
55 | 55 | |
56 | - if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'unlock' ) ) { |
|
57 | - delete_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete' ); |
|
56 | + if (isset($_POST['lsx-health-plan-actions']) && wp_verify_nonce($_POST['lsx-health-plan-actions'], 'unlock')) { |
|
57 | + delete_user_meta(get_current_user_id(), 'day_' . sanitize_key($_POST['lsx-health-plan-id']) . '_complete'); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | } |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function __construct() { |
55 | 55 | $this->load_classes(); |
56 | - add_action( 'admin_menu', array( $this, 'order_menus' ), 200 ); |
|
57 | - add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); |
|
58 | - add_filter( 'cmb2_override_meta_save', array( $this, 'save_previous_values' ), 20, 4 ); |
|
59 | - add_filter( 'cmb2_override_meta_remove', array( $this, 'save_previous_values' ), 20, 4 ); |
|
60 | - add_action( 'cmb2_save_field', array( $this, 'post_relations' ), 20, 4 ); |
|
61 | - add_action( 'cmb2_save_field', array( $this, 'create_query_fields' ), 20, 4 ); |
|
62 | - add_action( 'before_delete_post', array( $this, 'delete_post_meta_connections' ), 20, 1 ); |
|
63 | - add_action( 'cmb2_save_post_fields', array( $this, 'extract_plan_fields' ), 10, 4 ); |
|
56 | + add_action('admin_menu', array($this, 'order_menus'), 200); |
|
57 | + add_action('admin_enqueue_scripts', array($this, 'assets')); |
|
58 | + add_filter('cmb2_override_meta_save', array($this, 'save_previous_values'), 20, 4); |
|
59 | + add_filter('cmb2_override_meta_remove', array($this, 'save_previous_values'), 20, 4); |
|
60 | + add_action('cmb2_save_field', array($this, 'post_relations'), 20, 4); |
|
61 | + add_action('cmb2_save_field', array($this, 'create_query_fields'), 20, 4); |
|
62 | + add_action('before_delete_post', array($this, 'delete_post_meta_connections'), 20, 1); |
|
63 | + add_action('cmb2_save_post_fields', array($this, 'extract_plan_fields'), 10, 4); |
|
64 | 64 | |
65 | 65 | // Customizer. |
66 | - add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 ); |
|
66 | + add_filter('lsx_customizer_colour_selectors_body', array($this, 'customizer_body_colours_handler'), 15, 2); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public static function get_instance() { |
75 | 75 | // If the single instance hasn't been set, set it now. |
76 | - if ( null === self::$instance ) { |
|
76 | + if (null === self::$instance) { |
|
77 | 77 | self::$instance = new self(); |
78 | 78 | } |
79 | 79 | return self::$instance; |
@@ -100,57 +100,57 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function order_menus() { |
102 | 102 | global $menu, $submenu; |
103 | - if ( ! empty( $submenu ) ) { |
|
103 | + if ( ! empty($submenu)) { |
|
104 | 104 | $parent_check = array( |
105 | 105 | 'edit.php?post_type=plan', |
106 | 106 | 'edit.php?post_type=workout', |
107 | 107 | 'edit.php?post_type=meal', |
108 | 108 | ); |
109 | - foreach ( $submenu as $menu_id => $menu_values ) { |
|
110 | - if ( in_array( $menu_id, $parent_check ) ) { |
|
111 | - foreach ( $menu_values as $sub_menu_key => $sub_menu_values ) { |
|
112 | - switch ( $sub_menu_values[0] ) { |
|
109 | + foreach ($submenu as $menu_id => $menu_values) { |
|
110 | + if (in_array($menu_id, $parent_check)) { |
|
111 | + foreach ($menu_values as $sub_menu_key => $sub_menu_values) { |
|
112 | + switch ($sub_menu_values[0]) { |
|
113 | 113 | |
114 | - case __( 'Add New', 'lsx-health-plan' ): |
|
115 | - unset( $submenu[ $menu_id ][ $sub_menu_key ] ); |
|
114 | + case __('Add New', 'lsx-health-plan'): |
|
115 | + unset($submenu[$menu_id][$sub_menu_key]); |
|
116 | 116 | break; |
117 | 117 | |
118 | - case __( 'All', 'lsx-health-plan' ): |
|
118 | + case __('All', 'lsx-health-plan'): |
|
119 | 119 | $title = $sub_menu_values[0]; |
120 | 120 | // Check and change the label. |
121 | - switch ( $sub_menu_values[2] ) { |
|
121 | + switch ($sub_menu_values[2]) { |
|
122 | 122 | case 'edit.php?post_type=meal': |
123 | - $title = esc_attr__( 'Meals', 'lsx-health-plan' ); |
|
123 | + $title = esc_attr__('Meals', 'lsx-health-plan'); |
|
124 | 124 | break; |
125 | 125 | |
126 | 126 | case 'edit.php?post_type=recipe': |
127 | - $title = esc_attr__( 'Recipes', 'lsx-health-plan' ); |
|
127 | + $title = esc_attr__('Recipes', 'lsx-health-plan'); |
|
128 | 128 | break; |
129 | 129 | |
130 | 130 | case 'edit.php?post_type=workout': |
131 | - $title = esc_attr__( 'Workouts', 'lsx-health-plan' ); |
|
131 | + $title = esc_attr__('Workouts', 'lsx-health-plan'); |
|
132 | 132 | break; |
133 | 133 | |
134 | 134 | case 'edit.php?post_type=plan': |
135 | - $title = esc_attr__( 'Plans', 'lsx-health-plan' ); |
|
135 | + $title = esc_attr__('Plans', 'lsx-health-plan'); |
|
136 | 136 | break; |
137 | 137 | |
138 | 138 | case 'edit.php?post_type=video': |
139 | - $title = esc_attr__( 'Videos', 'lsx-health-plan' ); |
|
139 | + $title = esc_attr__('Videos', 'lsx-health-plan'); |
|
140 | 140 | break; |
141 | 141 | |
142 | 142 | case 'edit.php?post_type=exercise': |
143 | - $title = esc_attr__( 'Exercises', 'lsx-health-plan' ); |
|
143 | + $title = esc_attr__('Exercises', 'lsx-health-plan'); |
|
144 | 144 | break; |
145 | 145 | |
146 | 146 | case 'edit.php?post_type=tip': |
147 | - $title = esc_attr__( 'Tips', 'lsx-health-plan' ); |
|
147 | + $title = esc_attr__('Tips', 'lsx-health-plan'); |
|
148 | 148 | break; |
149 | 149 | |
150 | 150 | default: |
151 | 151 | break; |
152 | 152 | } |
153 | - $submenu[ $menu_id ][ $sub_menu_key ][0] = $title; // @codingStandardsIgnoreLine |
|
153 | + $submenu[$menu_id][$sub_menu_key][0] = $title; // @codingStandardsIgnoreLine |
|
154 | 154 | break; |
155 | 155 | |
156 | 156 | default: |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | * @return void |
169 | 169 | */ |
170 | 170 | public function assets() { |
171 | - wp_enqueue_script( 'media-upload' ); |
|
172 | - wp_enqueue_script( 'thickbox' ); |
|
173 | - wp_enqueue_style( 'thickbox' ); |
|
171 | + wp_enqueue_script('media-upload'); |
|
172 | + wp_enqueue_script('thickbox'); |
|
173 | + wp_enqueue_style('thickbox'); |
|
174 | 174 | |
175 | - wp_enqueue_script( 'lsx-health-plan-admin', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-admin.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true ); |
|
176 | - wp_enqueue_style( 'lsx-health-plan-admin', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan-admin.css', array(), LSX_HEALTH_PLAN_VER ); |
|
175 | + wp_enqueue_script('lsx-health-plan-admin', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-admin.min.js', array('jquery'), LSX_HEALTH_PLAN_VER, true); |
|
176 | + wp_enqueue_style('lsx-health-plan-admin', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan-admin.css', array(), LSX_HEALTH_PLAN_VER); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @return void |
183 | 183 | */ |
184 | 184 | public function get_connections() { |
185 | - return apply_filters( 'lsx_health_plan_connections', $this->connections ); |
|
185 | + return apply_filters('lsx_health_plan_connections', $this->connections); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -194,13 +194,13 @@ discard block |
||
194 | 194 | * @param [type] $cmb2 |
195 | 195 | * @return void |
196 | 196 | */ |
197 | - public function save_previous_values( $value_to_save, $a, $args, $cmb2 ) { |
|
198 | - if ( isset( $cmb2->data_to_save['ID'] ) ) { |
|
197 | + public function save_previous_values($value_to_save, $a, $args, $cmb2) { |
|
198 | + if (isset($cmb2->data_to_save['ID'])) { |
|
199 | 199 | $connections = $this->get_connections(); |
200 | - $post_type = get_post_type( $cmb2->data_to_save['ID'] ); |
|
201 | - if ( isset( $connections[ $post_type ] ) && array_key_exists( $a['field_id'], $connections[ $post_type ] ) ) { |
|
200 | + $post_type = get_post_type($cmb2->data_to_save['ID']); |
|
201 | + if (isset($connections[$post_type]) && array_key_exists($a['field_id'], $connections[$post_type])) { |
|
202 | 202 | // Get the previous values if the field, so we can run through them and remove the current ID from them later. |
203 | - $this->previous_values = get_post_meta( $a['id'], $a['field_id'], true ); |
|
203 | + $this->previous_values = get_post_meta($a['id'], $a['field_id'], true); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | return $value_to_save; |
@@ -211,30 +211,30 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return void |
213 | 213 | */ |
214 | - public function post_relations( $field_id, $updated, $action, $cmb2 ) { |
|
214 | + public function post_relations($field_id, $updated, $action, $cmb2) { |
|
215 | 215 | // If the connections are empty then skip this function. |
216 | 216 | $connections = $this->get_connections(); |
217 | - if ( empty( $connections ) ) { |
|
217 | + if (empty($connections)) { |
|
218 | 218 | return; |
219 | 219 | } |
220 | 220 | |
221 | 221 | // If the field has been updated. |
222 | - if ( isset( $cmb2->data_to_save['ID'] ) ) { |
|
223 | - $post_type = get_post_type( $cmb2->data_to_save['ID'] ); |
|
224 | - if ( isset( $connections[ $post_type ] ) && array_key_exists( $field_id, $connections[ $post_type ] ) ) { |
|
225 | - $saved_values = get_post_meta( $cmb2->data_to_save['ID'], $field_id, true ); |
|
222 | + if (isset($cmb2->data_to_save['ID'])) { |
|
223 | + $post_type = get_post_type($cmb2->data_to_save['ID']); |
|
224 | + if (isset($connections[$post_type]) && array_key_exists($field_id, $connections[$post_type])) { |
|
225 | + $saved_values = get_post_meta($cmb2->data_to_save['ID'], $field_id, true); |
|
226 | 226 | |
227 | - if ( 'updated' === $action ) { |
|
228 | - $this->add_connected_posts( $saved_values, $cmb2->data_to_save['ID'], $connections[ $post_type ][ $field_id ] ); |
|
227 | + if ('updated' === $action) { |
|
228 | + $this->add_connected_posts($saved_values, $cmb2->data_to_save['ID'], $connections[$post_type][$field_id]); |
|
229 | 229 | // Check if any posts have been removed. |
230 | - if ( count( $this->previous_values ) > count( $saved_values ) ) { |
|
231 | - $posts_to_remove = array_diff( $this->previous_values, $saved_values ); |
|
232 | - if ( ! empty( $posts_to_remove ) ) { |
|
233 | - $this->remove_connected_posts( $posts_to_remove, $cmb2->data_to_save['ID'], $connections[ $post_type ][ $field_id ] ); |
|
230 | + if (count($this->previous_values) > count($saved_values)) { |
|
231 | + $posts_to_remove = array_diff($this->previous_values, $saved_values); |
|
232 | + if ( ! empty($posts_to_remove)) { |
|
233 | + $this->remove_connected_posts($posts_to_remove, $cmb2->data_to_save['ID'], $connections[$post_type][$field_id]); |
|
234 | 234 | } |
235 | 235 | } |
236 | - } else if ( 'removed' === $action && ! empty( $this->previous_values ) ) { |
|
237 | - $this->remove_connected_posts( $this->previous_values, $cmb2->data_to_save['ID'], $connections[ $post_type ][ $field_id ] ); |
|
236 | + } else if ('removed' === $action && ! empty($this->previous_values)) { |
|
237 | + $this->remove_connected_posts($this->previous_values, $cmb2->data_to_save['ID'], $connections[$post_type][$field_id]); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | } |
@@ -248,26 +248,26 @@ discard block |
||
248 | 248 | * @param [type] $connected_key |
249 | 249 | * @return void |
250 | 250 | */ |
251 | - public function add_connected_posts( $values, $current_id, $connected_key ) { |
|
252 | - foreach ( $values as $value ) { |
|
253 | - $current_post_array = get_post_meta( $value, $connected_key, true ); |
|
251 | + public function add_connected_posts($values, $current_id, $connected_key) { |
|
252 | + foreach ($values as $value) { |
|
253 | + $current_post_array = get_post_meta($value, $connected_key, true); |
|
254 | 254 | $previous_values = $current_post_array; |
255 | 255 | |
256 | - if ( ! empty( $current_post_array ) ) { |
|
257 | - $current_post_array = array_map( 'strval', $current_post_array ); |
|
258 | - array_unique( $current_post_array ); |
|
256 | + if ( ! empty($current_post_array)) { |
|
257 | + $current_post_array = array_map('strval', $current_post_array); |
|
258 | + array_unique($current_post_array); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | // If the current connected post has no saved connections then we create it. |
262 | - if ( false === $current_post_array || empty( $current_post_array ) ) { |
|
263 | - $current_post_array = array( $current_id ); |
|
264 | - } elseif ( ! in_array( (string) $current_id, $current_post_array, true ) ) { |
|
262 | + if (false === $current_post_array || empty($current_post_array)) { |
|
263 | + $current_post_array = array($current_id); |
|
264 | + } elseif ( ! in_array((string) $current_id, $current_post_array, true)) { |
|
265 | 265 | $current_post_array[] = $current_id; |
266 | 266 | } |
267 | 267 | |
268 | 268 | // Check if the values are empty, if not update them. |
269 | - if ( ! empty( $current_post_array ) ) { |
|
270 | - update_post_meta( $value, $connected_key, $current_post_array, $previous_values ); |
|
269 | + if ( ! empty($current_post_array)) { |
|
270 | + update_post_meta($value, $connected_key, $current_post_array, $previous_values); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | } |
@@ -280,25 +280,25 @@ discard block |
||
280 | 280 | * @param [type] $connected_key |
281 | 281 | * @return void |
282 | 282 | */ |
283 | - public function remove_connected_posts( $values, $current_ID, $connected_key ) { |
|
284 | - foreach ( $values as $value ) { |
|
285 | - $current_post_array = get_post_meta( $value, $connected_key, true ); |
|
283 | + public function remove_connected_posts($values, $current_ID, $connected_key) { |
|
284 | + foreach ($values as $value) { |
|
285 | + $current_post_array = get_post_meta($value, $connected_key, true); |
|
286 | 286 | $new_array = array(); |
287 | 287 | // Loop through only if the current ID has been saved against the post. |
288 | - if ( in_array( $current_ID, $current_post_array, false ) ) { |
|
288 | + if (in_array($current_ID, $current_post_array, false)) { |
|
289 | 289 | |
290 | 290 | // Loop through all the connected saved IDS. |
291 | - foreach ( $current_post_array as $cpa ) { |
|
292 | - if ( (int) $cpa !== (int) $current_ID ) { |
|
291 | + foreach ($current_post_array as $cpa) { |
|
292 | + if ((int) $cpa !== (int) $current_ID) { |
|
293 | 293 | $new_array[] = $cpa; |
294 | 294 | } |
295 | 295 | } |
296 | - if ( ! empty( $new_array ) ) { |
|
297 | - $new_array = array_unique( $new_array ); |
|
298 | - delete_post_meta( $value, $connected_key ); |
|
299 | - add_post_meta( $value, $connected_key, $new_array, true ); |
|
296 | + if ( ! empty($new_array)) { |
|
297 | + $new_array = array_unique($new_array); |
|
298 | + delete_post_meta($value, $connected_key); |
|
299 | + add_post_meta($value, $connected_key, $new_array, true); |
|
300 | 300 | } else { |
301 | - delete_post_meta( $value, $connected_key ); |
|
301 | + delete_post_meta($value, $connected_key); |
|
302 | 302 | } |
303 | 303 | } |
304 | 304 | } |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | * @param string $item_id |
311 | 311 | * @return void |
312 | 312 | */ |
313 | - public function delete_post_meta_connections( $item_id = '' ) { |
|
314 | - if ( '' !== $item_id ) { |
|
315 | - $post_type = get_post_type( $item_id ); |
|
313 | + public function delete_post_meta_connections($item_id = '') { |
|
314 | + if ('' !== $item_id) { |
|
315 | + $post_type = get_post_type($item_id); |
|
316 | 316 | $connections = $this->get_connections(); |
317 | - if ( isset( $connections[ $post_type ] ) && ! empty( $connections[ $post_type ] ) && is_array( $connections[ $post_type ] ) ) { |
|
318 | - foreach ( $connections[ $post_type ] as $this_key => $connected_key ) { |
|
319 | - $this->delete_connected_items( $item_id, $this_key, $connected_key ); |
|
317 | + if (isset($connections[$post_type]) && ! empty($connections[$post_type]) && is_array($connections[$post_type])) { |
|
318 | + foreach ($connections[$post_type] as $this_key => $connected_key) { |
|
319 | + $this->delete_connected_items($item_id, $this_key, $connected_key); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | } |
@@ -330,23 +330,23 @@ discard block |
||
330 | 330 | * @param string $connected_key |
331 | 331 | * @return void |
332 | 332 | */ |
333 | - public function delete_connected_items( $item_id = '', $this_key, $connected_key ) { |
|
334 | - if ( '' !== $item_id ) { |
|
335 | - $connected_items = get_post_meta( $item_id, $this_key, true ); |
|
336 | - if ( ! empty( $connected_items ) ) { |
|
337 | - foreach ( $connected_items as $con_id ) { |
|
333 | + public function delete_connected_items($item_id = '', $this_key, $connected_key) { |
|
334 | + if ('' !== $item_id) { |
|
335 | + $connected_items = get_post_meta($item_id, $this_key, true); |
|
336 | + if ( ! empty($connected_items)) { |
|
337 | + foreach ($connected_items as $con_id) { |
|
338 | 338 | // Get the connected item array from the connected item. |
339 | - $their_connections = get_post_meta( $con_id, $connected_key, true ); |
|
340 | - if ( ! empty( $their_connections ) ) { |
|
339 | + $their_connections = get_post_meta($con_id, $connected_key, true); |
|
340 | + if ( ! empty($their_connections)) { |
|
341 | 341 | $new_connections = $their_connections; |
342 | 342 | // Run through the array and remove the post to be deleteds ID. |
343 | - foreach ( $their_connections as $ckey => $cvalue ) { |
|
344 | - if ( (int) $item_id === (int) $cvalue ) { |
|
345 | - unset( $new_connections[ $ckey ] ); |
|
343 | + foreach ($their_connections as $ckey => $cvalue) { |
|
344 | + if ((int) $item_id === (int) $cvalue) { |
|
345 | + unset($new_connections[$ckey]); |
|
346 | 346 | } |
347 | 347 | } |
348 | 348 | // Now we save the field. |
349 | - update_post_meta( $con_id, $connected_key, $new_connections, $their_connections ); |
|
349 | + update_post_meta($con_id, $connected_key, $new_connections, $their_connections); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | } |
@@ -358,20 +358,20 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return void |
360 | 360 | */ |
361 | - public function create_query_fields( $field_id, $updated, $action, $cmb2 ) { |
|
361 | + public function create_query_fields($field_id, $updated, $action, $cmb2) { |
|
362 | 362 | // If the connections are empty then skip this function. |
363 | 363 | $search_fields = array( |
364 | 364 | 'plan_product', |
365 | 365 | ); |
366 | - if ( ! in_array( $field_id, $search_fields ) ) { |
|
366 | + if ( ! in_array($field_id, $search_fields)) { |
|
367 | 367 | return; |
368 | 368 | } |
369 | 369 | |
370 | 370 | // If the field has been updated. |
371 | - if ( isset( $cmb2->data_to_save['ID'] ) && isset( $cmb2->data_to_save[ $field_id . '_results' ] ) && ! empty( $cmb2->data_to_save[ $field_id . '_results' ] ) ) { |
|
372 | - delete_post_meta( $cmb2->data_to_save['ID'], '_' . $field_id . '_id' ); |
|
373 | - foreach ( $cmb2->data_to_save[ $field_id . '_results' ] as $temp ) { |
|
374 | - add_post_meta( $cmb2->data_to_save['ID'], '_' . $field_id . '_id', $temp, false ); |
|
371 | + if (isset($cmb2->data_to_save['ID']) && isset($cmb2->data_to_save[$field_id . '_results']) && ! empty($cmb2->data_to_save[$field_id . '_results'])) { |
|
372 | + delete_post_meta($cmb2->data_to_save['ID'], '_' . $field_id . '_id'); |
|
373 | + foreach ($cmb2->data_to_save[$field_id . '_results'] as $temp) { |
|
374 | + add_post_meta($cmb2->data_to_save['ID'], '_' . $field_id . '_id', $temp, false); |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | } |
@@ -385,26 +385,26 @@ discard block |
||
385 | 385 | * @param [type] $cmb2 |
386 | 386 | * @return void |
387 | 387 | */ |
388 | - public function extract_plan_fields( $object_id, $cmb_id, $updated, $cmb2 ) { |
|
389 | - if ( 'plan_sections_metabox' === $cmb_id ) { |
|
388 | + public function extract_plan_fields($object_id, $cmb_id, $updated, $cmb2) { |
|
389 | + if ('plan_sections_metabox' === $cmb_id) { |
|
390 | 390 | // Check if our fields are available, and cycle through them. |
391 | - if ( isset( $cmb2->data_to_save['plan_sections'] ) && ! empty( $cmb2->data_to_save['plan_sections'] ) ) { |
|
391 | + if (isset($cmb2->data_to_save['plan_sections']) && ! empty($cmb2->data_to_save['plan_sections'])) { |
|
392 | 392 | $fields_to_save = array(); |
393 | 393 | // Run through each row of fields. |
394 | - foreach ( $cmb2->data_to_save['plan_sections'] as $field_index => $fields ) { |
|
394 | + foreach ($cmb2->data_to_save['plan_sections'] as $field_index => $fields) { |
|
395 | 395 | // Run through each field in that section. |
396 | - foreach ( $fields as $field_key => $field_value ) { |
|
396 | + foreach ($fields as $field_key => $field_value) { |
|
397 | 397 | $stored_values_key = 'plan_sections_' . $field_index . '_' . $field_key . '_store'; |
398 | - if ( isset( $cmb2->data_to_save[ $stored_values_key ] ) && ! empty( $cmb2->data_to_save[ $stored_values_key ] ) ) { |
|
399 | - $stored_values = $cmb2->data_to_save[ $stored_values_key ]; |
|
400 | - $stored_values = explode( ',', $stored_values ); |
|
401 | - foreach ( $stored_values as $id_to_save ) { |
|
402 | - $fields_to_save[ $field_key ][] = $id_to_save; |
|
398 | + if (isset($cmb2->data_to_save[$stored_values_key]) && ! empty($cmb2->data_to_save[$stored_values_key])) { |
|
399 | + $stored_values = $cmb2->data_to_save[$stored_values_key]; |
|
400 | + $stored_values = explode(',', $stored_values); |
|
401 | + foreach ($stored_values as $id_to_save) { |
|
402 | + $fields_to_save[$field_key][] = $id_to_save; |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | } |
406 | 406 | } |
407 | - $this->save_field_array( $object_id, $fields_to_save ); |
|
407 | + $this->save_field_array($object_id, $fields_to_save); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | } |
@@ -416,16 +416,16 @@ discard block |
||
416 | 416 | * @param array $fields_to_save |
417 | 417 | * @return void |
418 | 418 | */ |
419 | - public function save_field_array( $object_id = 0, $fields_to_save = array() ) { |
|
419 | + public function save_field_array($object_id = 0, $fields_to_save = array()) { |
|
420 | 420 | |
421 | 421 | // Run through the fields and save the meta items. |
422 | - if ( ! empty( $fields_to_save ) ) { |
|
423 | - foreach ( $fields_to_save as $field_key => $field_values ) { |
|
424 | - delete_post_meta( $object_id, $field_key ); |
|
422 | + if ( ! empty($fields_to_save)) { |
|
423 | + foreach ($fields_to_save as $field_key => $field_values) { |
|
424 | + delete_post_meta($object_id, $field_key); |
|
425 | 425 | |
426 | - $field_values = array_unique( $field_values ); |
|
427 | - foreach ( $field_values as $field_value ) { |
|
428 | - add_post_meta( $object_id, $field_key, $field_value, false ); |
|
426 | + $field_values = array_unique($field_values); |
|
427 | + foreach ($field_values as $field_value) { |
|
428 | + add_post_meta($object_id, $field_key, $field_value, false); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | /** |
435 | 435 | * Handle body colours that might be change by LSX Customizer. |
436 | 436 | */ |
437 | - public function customizer_body_colours_handler( $css, $colors ) { |
|
437 | + public function customizer_body_colours_handler($css, $colors) { |
|
438 | 438 | $css .= ' |
439 | 439 | @import "' . LSX_HEALTH_PLAN_PATH . '/assets/css/scss/partials/customizer-health-plan-body-colours"; |
440 | 440 |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | * Contructor |
52 | 52 | */ |
53 | 53 | public function __construct() { |
54 | - if ( ! is_admin() ) { |
|
54 | + if ( ! is_admin()) { |
|
55 | 55 | $this->load_classes(); |
56 | - add_action( 'template_redirect', array( $this, 'redirect' ) ); |
|
56 | + add_action('template_redirect', array($this, 'redirect')); |
|
57 | 57 | |
58 | 58 | } |
59 | 59 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public static function get_instance() { |
69 | 69 | // If the single instance hasn't been set, set it now. |
70 | - if ( null === self::$instance ) { |
|
70 | + if (null === self::$instance) { |
|
71 | 71 | self::$instance = new self(); |
72 | 72 | } |
73 | 73 | return self::$instance; |
@@ -102,17 +102,17 @@ discard block |
||
102 | 102 | * @return void |
103 | 103 | */ |
104 | 104 | public function redirect() { |
105 | - if ( ! is_user_logged_in() || ! function_exists( 'wc_get_page_id' ) || is_home() ) { |
|
105 | + if ( ! is_user_logged_in() || ! function_exists('wc_get_page_id') || is_home()) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | - if ( lsx_health_plan_user_has_purchase() && ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) ) ) { |
|
109 | - wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) ); |
|
108 | + if (lsx_health_plan_user_has_purchase() && (is_page(wc_get_page_id('cart')) || is_page(wc_get_page_id('checkout')))) { |
|
109 | + wp_redirect(get_permalink(wc_get_page_id('myaccount'))); |
|
110 | 110 | die; |
111 | 111 | } |
112 | 112 | |
113 | - $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
114 | - if ( false !== $product_id && is_single( $product_id ) ) { |
|
115 | - wp_redirect( home_url() ); |
|
113 | + $product_id = \lsx_health_plan\functions\get_option('membership_product', false); |
|
114 | + if (false !== $product_id && is_single($product_id)) { |
|
115 | + wp_redirect(home_url()); |
|
116 | 116 | wp_die(); |
117 | 117 | } |
118 | 118 | } |