Passed
Push — add/multiplan ( 309a59...7c1ede )
by
unknown
03:38
created
classes/admin/class-settings.php 2 patches
Indentation   +697 added lines, -697 removed lines patch added patch discarded remove patch
@@ -12,701 +12,701 @@
 block discarded – undo
12 12
  */
13 13
 class Settings {
14 14
 
15
-	/**
16
-	 * Holds class instance
17
-	 *
18
-	 * @since 1.0.0
19
-	 *
20
-	 * @var      object \lsx_health_plan\classes\admin\Settings()
21
-	 */
22
-	protected static $instance = null;
23
-
24
-	/**
25
-	 * Option key, and option page slug
26
-	 *
27
-	 * @var string
28
-	 */
29
-	protected $screen_id = 'lsx_health_plan_settings';
30
-
31
-	/**
32
-	 * An array of the post types for the Global Downloads field.
33
-	 *
34
-	 * @var array
35
-	 */
36
-	public $download_types = array();
37
-
38
-	/**
39
-	 * An array of the post types for the Global Defaults field.
40
-	 *
41
-	 * @var array
42
-	 */
43
-	public $default_types = array();
44
-
45
-	/**
46
-	 * An array of the endpoints for the Endpoint Translation field.
47
-	 *
48
-	 * @var array
49
-	 */
50
-	public $endpoints = array();
51
-
52
-	/**
53
-	 * Constructor
54
-	 */
55
-	public function __construct() {
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 );
67
-	}
68
-
69
-	/**
70
-	 * Return an instance of this class.
71
-	 *
72
-	 * @since 1.0.0
73
-	 *
74
-	 * @return    object \lsx_health_plan\classes\admin\Settings()    A single instance of this class.
75
-	 */
76
-	public static function get_instance() {
77
-		// If the single instance hasn't been set, set it now.
78
-		if ( null === self::$instance ) {
79
-			self::$instance = new self();
80
-		}
81
-		return self::$instance;
82
-	}
83
-
84
-	/**
85
-	 * Loads the variable classes and the static classes.
86
-	 */
87
-	private function load_classes() {
88
-
89
-		$this->post_types = array(
90
-			'plan',
91
-			'workout',
92
-			'exercise',
93
-			//'meal',
94
-			'recipe',
95
-			//'tip',
96
-		);
97
-
98
-		foreach ( $this->post_types as $post_type ) {
99
-			$this->$post_type = require_once LSX_HEALTH_PLAN_PATH . 'classes/admin/settings/class-' . $post_type . '.php';
100
-		}
101
-	}
102
-
103
-	/**
104
-	 * Sets the variables needed for the fields.
105
-	 *
106
-	 * @return void
107
-	 */
108
-	public function set_vars() {
109
-
110
-		$this->default_types  = array(
111
-			'page' => array(
112
-				'title'       => __( 'Warm Up', 'lsx-health-plan' ),
113
-				'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ),
114
-				'limit'       => 1,
115
-				'id'          => 'plan_warmup',
116
-			),
117
-		);
118
-		$this->download_types = array(
119
-			'page' => array(
120
-				'title'       => __( 'Warm Up', 'lsx-health-plan' ),
121
-				'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ),
122
-				'limit'       => 1,
123
-			),
124
-		);
125
-		$this->endpoints      = array(
126
-			'endpoint_warm_up' => array(
127
-				'title'       => __( 'Warm Up Endpoint', 'lsx-health-plan' ),
128
-				'default'     => 'warm-up',
129
-			),
130
-		);
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' ),
136
-			);
137
-			$this->default_types['meal']      = array(
138
-				'title'       => __( 'Meal Plan', 'lsx-health-plan' ),
139
-				'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ),
140
-				'id'          => 'connected_meals',
141
-			);
142
-			$this->endpoints['endpoint_meal'] = array(
143
-				'title'       => __( 'Meal Endpoint', 'lsx-health-plan' ),
144
-				'default'     => 'meal',
145
-				'description' => __( 'Define the tab slug which shows on the single plan page.', 'lsx-health-plan' ),
146
-			);
147
-			$this->endpoints['endpoint_meal_archive'] = array(
148
-				'title'   => __( 'Meals Archive Endpoint', 'lsx-health-plan' ),
149
-				'default' => 'meals',
150
-			);
151
-			$this->endpoints['meal_single_slug'] = array(
152
-				'title'   => __( 'Single Meal Slug', 'lsx-health-plan' ),
153
-				'default' => 'meal',
154
-			);
155
-		}
156
-		if ( post_type_exists( 'recipe' ) ) {
157
-			$this->download_types['recipe'] = array(
158
-				'title'       => __( 'Recipe', 'lsx-health-plan' ),
159
-				'description' => __( 'Set a default recipe.', 'lsx-health-plan' ),
160
-			);
161
-			$this->default_types['recipe'] = array(
162
-				'title'       => __( 'Recipe', 'lsx-health-plan' ),
163
-				'description' => __( 'Set a default recipe.', 'lsx-health-plan' ),
164
-				'id'          => 'connected_recipes',
165
-			);
166
-			$this->endpoints['endpoint_recipe'] = array(
167
-				'title'   => __( 'Recipes Endpoint', 'lsx-health-plan' ),
168
-				'default' => 'recipe',
169
-			);
170
-		}
171
-		if ( post_type_exists( 'workout' ) ) {
172
-			$this->download_types['workout'] = array(
173
-				'title'       => __( 'Workout', 'lsx-health-plan' ),
174
-				'description' => __( 'Set a default workout routine PDF.', 'lsx-health-plan' ),
175
-			);
176
-			$this->default_types['workout'] = array(
177
-				'title'       => __( 'Workout', 'lsx-health-plan' ),
178
-				'description' => __( 'Set a default workout routine.', 'lsx-health-plan' ),
179
-				'id'          => 'connected_workouts',
180
-			);
181
-			$this->endpoints['endpoint_workout_archive'] = array(
182
-				'title'   => __( 'Workouts Archive Endpoint', 'lsx-health-plan' ),
183
-				'default' => '',
184
-			);
185
-			$this->endpoints['endpoint_workout'] = array(
186
-				'title'   => __( 'Single Workout Endpoint', 'lsx-health-plan' ),
187
-				'default' => 'workout',
188
-			);
189
-		}
190
-
191
-		$this->endpoints['login_slug'] = array(
192
-			'title'   => __( 'Login Slug', 'lsx-health-plan' ),
193
-			'default' => 'login',
194
-		);
195
-		$this->endpoints['my_plan_slug'] = array(
196
-			'title'   => __( 'My Plan Slug', 'lsx-health-plan' ),
197
-			'default' => 'my-plan',
198
-		);
199
-		$this->endpoints['plan_single_slug'] = array(
200
-			'title'   => __( 'Single Plan Slug', 'lsx-health-plan' ),
201
-			'default' => 'plan',
202
-		);
203
-		$this->endpoints['endpoint_plan_archive'] = array(
204
-			'title'   => __( 'Plans Archive Endpoint', 'lsx-health-plan' ),
205
-			'default' => 'plans',
206
-		);
207
-
208
-		if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
209
-			$this->endpoints['exercise'] = array(
210
-				'exercise_single' => array(
211
-					'title'   => __( 'Single Exercise Slug', 'lsx-health-plan' ),
212
-					'default' => 'exercise',
213
-				),
214
-				'exercise_archive' => array(
215
-					'title'   => __( 'Archive Exercise Slug', 'lsx-health-plan' ),
216
-					'default' => 'exercises',
217
-				),
218
-				'exercise_type' => array(
219
-					'title'   => __( 'Exercise Type Slug', 'lsx-health-plan' ),
220
-					'default' => 'exercise-type',
221
-				),
222
-				'exercise_equipment' => array(
223
-					'title'   => __( 'Equipment Slug', 'lsx-health-plan' ),
224
-					'default' => 'equipment',
225
-				),
226
-				'exercise_musclegroup' => array(
227
-					'title'   => __( 'Muscle Group Slug', 'lsx-health-plan' ),
228
-					'default' => 'muscle-group',
229
-				),
230
-			);
231
-		}
232
-	}
233
-
234
-	/**
235
-	 * Hook in and register a submenu options page for the Page post-type menu.
236
-	 */
237
-	public function register_settings_page() {
238
-		$this->set_vars();
239
-		$cmb = new_cmb2_box(
240
-			array(
241
-				'id'           => $this->screen_id,
242
-				'title'        => esc_html__( 'Settings', 'lsx-health-plan' ),
243
-				'object_types' => array( 'options-page' ),
244
-				'option_key'   => 'lsx_health_plan_options', // The option key and admin menu page slug.
245
-				'parent_slug'  => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu.
246
-				'capability'   => 'manage_options', // Cap required to view options-page.
247
-			)
248
-		);
249
-		do_action( 'lsx_hp_settings_page', $cmb );
250
-	}
251
-
252
-	/**
253
-	 * Registers the general settings.
254
-	 *
255
-	 * @param object $cmb new_cmb2_box().
256
-	 * @return void
257
-	 */
258
-	public function general_settings( $cmb ) {
259
-		$cmb->add_field(
260
-			array(
261
-				'name'       => __( 'Membership Product', 'lsx-health-plan' ),
262
-				'id'         => 'membership_product',
263
-				'type'       => 'post_search_ajax',
264
-				'limit'      => 1,
265
-				'sortable'   => false,
266
-				'query_args' => array(
267
-					'post_type'      => array( 'product' ),
268
-					'post_status'    => array( 'publish' ),
269
-					'posts_per_page' => -1,
270
-				),
271
-			)
272
-		);
273
-
274
-		$cmb->add_field(
275
-			array(
276
-				'name'    => __( 'Your Warm-up Intro', 'lsx-health-plan' ),
277
-				'id'      => 'warmup_intro',
278
-				'type'    => 'textarea_small',
279
-				'value'   => '',
280
-				'default' => __( "Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan' ),
281
-			)
282
-		);
283
-		if ( post_type_exists( 'workout' ) ) {
284
-			$cmb->add_field(
285
-				array(
286
-					'name'    => __( 'Your Workout Intro', 'lsx-health-plan' ),
287
-					'id'      => 'workout_intro',
288
-					'type'    => 'textarea_small',
289
-					'value'   => '',
290
-					'default' => __( "Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan' ),
291
-				)
292
-			);
293
-		}
294
-		if ( post_type_exists( 'meal' ) ) {
295
-			$cmb->add_field(
296
-				array(
297
-					'name'    => __( 'Your Meal Plan Intro', 'lsx-health-plan' ),
298
-					'id'      => 'meal_plan_intro',
299
-					'type'    => 'textarea_small',
300
-					'value'   => '',
301
-					'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ),
302
-				)
303
-			);
304
-		}
305
-		if ( post_type_exists( 'recipe' ) ) {
306
-			$cmb->add_field(
307
-				array(
308
-					'name'    => __( 'Recipes Intro', 'lsx-health-plan' ),
309
-					'id'      => 'recipes_intro',
310
-					'type'    => 'textarea_small',
311
-					'value'   => '',
312
-					'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan' ),
313
-				)
314
-			);
315
-		}
316
-	}
317
-
318
-	/**
319
-	 * Registers the global default settings.
320
-	 *
321
-	 * @param object $cmb new_cmb2_box().
322
-	 * @return void
323
-	 */
324
-	public function global_defaults( $cmb ) {
325
-		$cmb->add_field(
326
-			array(
327
-				'id'      => 'global_defaults_title',
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' ),
332
-			)
333
-		);
334
-
335
-		foreach ( $this->default_types as $type => $default_type ) {
336
-			$limit    = 5;
337
-			$sortable = false;
338
-			if ( isset( $default_type['limit'] ) ) {
339
-				$limit    = $default_type['limit'];
340
-				$sortable = true;
341
-			}
342
-
343
-			if ( 'page' === $type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
344
-				$type = array( 'page', 'workout' );
345
-			}
346
-
347
-			$cmb->add_field(
348
-				array(
349
-					'name'       => $default_type['title'],
350
-					'desc'       => $default_type['description'],
351
-					'id'         => $default_type['id'],
352
-					'type'       => 'post_search_ajax',
353
-					'limit'      => $limit,
354
-					'sortable'   => $sortable,
355
-					'query_args' => array(
356
-						'post_type'      => $type,
357
-						'post_status'    => array( 'publish' ),
358
-						'posts_per_page' => -1,
359
-					),
360
-				)
361
-			);
362
-		}
363
-
364
-		$cmb->add_field(
365
-			array(
366
-				'id'   => 'settings_global_defaults_closing',
367
-				'type' => 'tab_closing',
368
-			)
369
-		);
370
-	}
371
-
372
-	/**
373
-	 * Registers the global dowloads settings
374
-	 *
375
-	 * @param object $cmb new_cmb2_box().
376
-	 * @return void
377
-	 */
378
-	public function global_downloads( $cmb ) {
379
-		$cmb->add_field(
380
-			array(
381
-				'id'          => 'global_downloads_title',
382
-				'type'        => 'title',
383
-				'name'        => __( 'Global Downloads', 'lsx-health-plan' ),
384
-				'default'     => __( 'Global Downloads', 'lsx-health-plan' ),
385
-				'description' => __( 'If you have not connected a specific download file to your plans, set a default option below', 'lsx-health-plan' ),
386
-			)
387
-		);
388
-
389
-		foreach ( $this->download_types as $type => $download_type ) {
390
-			$limit    = 5;
391
-			$sortable = false;
392
-			if ( isset( $download_type['limit'] ) ) {
393
-				$limit    = $download_type['limit'];
394
-				$sortable = true;
395
-			}
396
-
397
-			$cmb->add_field(
398
-				array(
399
-					'name'       => $download_type['title'],
400
-					'id'         => 'download_' . $type,
401
-					'type'       => 'post_search_ajax',
402
-					'limit'      => $limit,
403
-					'sortable'   => $sortable,
404
-					'query_args' => array(
405
-						'post_type'      => array( 'dlm_download' ),
406
-						'post_status'    => array( 'publish' ),
407
-						'posts_per_page' => -1,
408
-					),
409
-				)
410
-			);
411
-		}
412
-		$cmb->add_field(
413
-			array(
414
-				'id'   => 'settings_global_downloads_closing',
415
-				'type' => 'tab_closing',
416
-			)
417
-		);
418
-	}
419
-
420
-	/**
421
-	 * Registers the endpoint translation settings.
422
-	 *
423
-	 * @param object $cmb new_cmb2_box().
424
-	 * @return void
425
-	 */
426
-	public function endpoint_translations( $cmb ) {
427
-		$cmb->add_field(
428
-			array(
429
-				'id'          => 'endpoints_title',
430
-				'type'        => 'title',
431
-				'name'        => __( 'Set Endpoint Translations', 'lsx-health-plan' ),
432
-				'default'     => __( 'Set Endpoint Translations', 'lsx-health-plan' ),
433
-				// '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' ),
434
-			)
435
-		);
436
-		foreach ( $this->endpoints as $slug => $endpoint_vars ) {
437
-			if ( 'exercise' === $slug ) {
438
-				continue;
439
-			}
440
-
441
-			$cmb->add_field(
442
-				array(
443
-					'name'    => $endpoint_vars['title'],
444
-					'id'      => $slug,
445
-					'type'    => 'input',
446
-					'value'   => '',
447
-					'default' => $endpoint_vars['default'],
448
-				)
449
-			);
450
-		}
451
-		$cmb->add_field(
452
-			array(
453
-				'id'   => 'settings_endpoints_closing',
454
-				'type' => 'tab_closing',
455
-				'before_row'    => '<p style="margin-top:20px; font-style: italic;">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.</p>',
456
-			)
457
-		);
458
-	}
459
-
460
-	/**
461
-	 * Registers the endpoint translation settings.
462
-	 *
463
-	 * @param object $cmb new_cmb2_box().
464
-	 * @return void
465
-	 */
466
-	public function exercise_translations( $cmb ) {
467
-		if ( isset( $this->endpoints['exercise'] ) && '' !== $this->endpoints['exercise'] && ! empty( $this->endpoints['exercise'] ) ) {
468
-			$cmb->add_field(
469
-				array(
470
-					'id'          => 'exercise_endpoints_title',
471
-					'type'        => 'title',
472
-					'name'        => __( 'Set Exercise Translations', 'lsx-health-plan' ),
473
-					'default'     => __( 'Set Exercise Translations', 'lsx-health-plan' ),
474
-					'description' => __( 'Change the exercise endpoints.', 'lsx-health-plan' ),
475
-				)
476
-			);
477
-
478
-			foreach ( $this->endpoints['exercise'] as $slug => $endpoint_vars ) {
479
-				$cmb->add_field(
480
-					array(
481
-						'name'    => $endpoint_vars['title'],
482
-						'id'      => 'endpoint_' . $slug,
483
-						'type'    => 'input',
484
-						'value'   => '',
485
-						'default' => $endpoint_vars['default'],
486
-					)
487
-				);
488
-			}
489
-
490
-			$cmb->add_field(
491
-				array(
492
-					'id'   => 'settings_exercise_closing',
493
-					'type' => 'tab_closing',
494
-					'before_row'    => '<p style="margin-top:20px; font-style: italic;">If you need to translate the exercise URL endpoints, do so below.</p>',
495
-				)
496
-			);
497
-		}
498
-	}
499
-
500
-	/**
501
-	 * Registers the post type toggle settings
502
-	 *
503
-	 * @param object $cmb new_cmb2_box().
504
-	 * @return void
505
-	 */
506
-	public function post_type_toggles( $cmb ) {
507
-		$post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) );
508
-
509
-		$cmb->add_field(
510
-			array(
511
-				'id'          => 'post_type_toggles_title',
512
-				'type'        => 'title',
513
-				'name'        => __( 'Disable Post Types', 'lsx-health-plan' ),
514
-				'default'     => __( 'Disable Post Types', 'lsx-health-plan' ),
515
-				'description' => __( 'Disable post types if you are wanting a minimal site.', 'lsx-health-plan' ),
516
-			)
517
-		);
518
-
519
-		foreach ( $post_types as $post_type ) {
520
-			if ( 'plan' === $post_type || 'exercise' === $post_type || ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) ) {
521
-				continue;
522
-			}
523
-
524
-			$cmb->add_field(
525
-				array(
526
-					'name'    => ucwords( $post_type ),
527
-					'id'      => $post_type . '_disabled',
528
-					'type'    => 'checkbox',
529
-					'value'   => 1,
530
-					'default' => 0,
531
-				)
532
-			);
533
-		}
534
-
535
-		$cmb->add_field(
536
-			array(
537
-				'id'   => 'settings_post_type_toggles_closing',
538
-				'type' => 'tab_closing',
539
-			)
540
-		);
541
-
542
-		$cmb->add_field(
543
-			array(
544
-				'id'          => 'post_type_toggles_enable_title',
545
-				'type'        => 'title',
546
-				'name'        => __( 'Enable Post Types', 'lsx-health-plan' ),
547
-				'default'     => __( 'Enable Post Types', 'lsx-health-plan' ),
548
-				'description' => __( 'Enable new functionality like the "exercise" post type.', 'lsx-health-plan' ),
549
-			)
550
-		);
551
-		$cmb->add_field(
552
-			array(
553
-				'name'        => __( 'Exercises', 'lsx-health-plan' ),
554
-				'id'          => 'exercise_enabled',
555
-				'type'        => 'checkbox',
556
-				'value'       => 1,
557
-				'default'     => 0,
558
-				'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ),
559
-			)
560
-		);
561
-		$cmb->add_field(
562
-			array(
563
-				'id'   => 'settings_post_type_toggles_enable_closing',
564
-				'type' => 'tab_closing',
565
-			)
566
-		);
567
-	}
568
-	/**
569
-	 * Registers the Profile Stat Toggle settings
570
-	 *
571
-	 * @param object $cmb new_cmb2_box().
572
-	 * @return void
573
-	 */
574
-
575
-	public function stat_disable( $cmb ) {
576
-		$cmb->add_field(
577
-			array(
578
-				'id'      => 'stat_disable_title',
579
-				'type'    => 'title',
580
-				'name'    => __( 'Disable Profile Stats', 'lsx-health-plan' ),
581
-				'default' => __( 'Disable Profile Stats', 'lsx-health-plan' ),
582
-			)
583
-		);
584
-		$cmb->add_field(
585
-			array(
586
-				'name'    => __( 'Disable All Stats', 'lsx-health-plan' ),
587
-				'desc'    => 'Disable All Stats',
588
-				'id'      => 'disable_all_stats',
589
-				'type'    => 'checkbox',
590
-				'value'   => 1,
591
-				'default' => 0,
592
-			)
593
-		);
594
-		$cmb->add_field(
595
-			array(
596
-				'name'    => __( 'Disable Weight', 'lsx-health-plan' ),
597
-				'id'      => 'disable_weight_checkbox',
598
-				'type'    => 'checkbox',
599
-				'value'   => 1,
600
-				'default' => 0,
601
-			)
602
-		);
603
-		$cmb->add_field(
604
-			array(
605
-				'name'    => __( 'Disable Height', 'lsx-health-plan' ),
606
-				'id'      => 'disable_height_checkbox',
607
-				'type'    => 'checkbox',
608
-				'value'   => 1,
609
-				'default' => 0,
610
-			)
611
-		);
612
-		$cmb->add_field(
613
-			array(
614
-				'name'    => __( 'Disable Waist', 'lsx-health-plan' ),
615
-				'id'      => 'disable_waist_checkbox',
616
-				'type'    => 'checkbox',
617
-				'value'   => 1,
618
-				'default' => 0,
619
-			)
620
-		);
621
-		$cmb->add_field(
622
-			array(
623
-				'name'    => __( 'Disable BMI', 'lsx-health-plan' ),
624
-				'id'      => 'disable_bmi_checkbox',
625
-				'type'    => 'checkbox',
626
-				'value'   => 1,
627
-				'default' => 0,
628
-			)
629
-		);
630
-		$cmb->add_field(
631
-			array(
632
-				'id'   => 'settings_stat_disable_closing',
633
-				'type' => 'tab_closing',
634
-			)
635
-		);
636
-	}
637
-
638
-	/**
639
-	 * Enable Business Directory Search settings only if LSX Search plugin is enabled.
640
-	 *
641
-	 * @param object $cmb The CMB2() class.
642
-	 * @param string $section either engine,archive or single.
643
-	 * @return void
644
-	 */
645
-	public function generate_tabs( $cmb ) {
646
-		$tabs = $this->get_settings_tabs();
647
-
648
-		foreach ( $tabs as $tab_key => $tab ) {
649
-			$cmb->add_field(
650
-				array(
651
-					'id'          => 'settings_' . $tab_key . '_title',
652
-					'type'        => 'title',
653
-					'name'        => $tab['title'],
654
-					'default'     => $tab['title'],
655
-					'description' => $tab['desc'],
656
-				)
657
-			);
658
-			do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb );
659
-
660
-			do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb );
661
-
662
-			do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb );
663
-
664
-			$cmb->add_field(
665
-				array(
666
-					'id'   => 'settings_' . $tab_key . '_closing',
667
-					'type' => 'tab_closing',
668
-				)
669
-			);
670
-		}
671
-	}
672
-
673
-
674
-	/**
675
-	 * Returns the tabs and their descriptions.
676
-	 *
677
-	 * @return array
678
-	 */
679
-	public function get_settings_tabs() {
680
-		$tabs = array(
681
-			'general' => array(
682
-				'title' => __( 'General', 'lsx-health-plan' ),
683
-				'desc'  => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ),
684
-			),
685
-		);
686
-
687
-		foreach ( $this->post_types as $post_type ) {
688
-			switch ( $post_type ) {
689
-				default:
690
-					//if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) {
691
-						$temp_post_type = get_post_type_object( $post_type );
692
-						if ( ! is_wp_error( $temp_post_type ) ) {
693
-							$page_url    = get_post_type_archive_link( $temp_post_type->name );
694
-							$description = sprintf(
695
-								/* translators: %s: The subscription info */
696
-								__( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ),
697
-								$page_url,
698
-								$temp_post_type->label
699
-							);
700
-
701
-							$tabs[ $post_type ] = array(
702
-								'title' => $temp_post_type->label,
703
-								'desc'  => $description,
704
-							);
705
-						}
706
-					//}
707
-					break;
708
-			}
709
-		}
710
-		return $tabs;
711
-	}
15
+     /**
16
+      * Holds class instance
17
+      *
18
+      * @since 1.0.0
19
+      *
20
+      * @var      object \lsx_health_plan\classes\admin\Settings()
21
+      */
22
+     protected static $instance = null;
23
+
24
+     /**
25
+      * Option key, and option page slug
26
+      *
27
+      * @var string
28
+      */
29
+     protected $screen_id = 'lsx_health_plan_settings';
30
+
31
+     /**
32
+      * An array of the post types for the Global Downloads field.
33
+      *
34
+      * @var array
35
+      */
36
+     public $download_types = array();
37
+
38
+     /**
39
+      * An array of the post types for the Global Defaults field.
40
+      *
41
+      * @var array
42
+      */
43
+     public $default_types = array();
44
+
45
+     /**
46
+      * An array of the endpoints for the Endpoint Translation field.
47
+      *
48
+      * @var array
49
+      */
50
+     public $endpoints = array();
51
+
52
+     /**
53
+      * Constructor
54
+      */
55
+     public function __construct() {
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 );
67
+     }
68
+
69
+     /**
70
+      * Return an instance of this class.
71
+      *
72
+      * @since 1.0.0
73
+      *
74
+      * @return    object \lsx_health_plan\classes\admin\Settings()    A single instance of this class.
75
+      */
76
+     public static function get_instance() {
77
+          // If the single instance hasn't been set, set it now.
78
+          if ( null === self::$instance ) {
79
+               self::$instance = new self();
80
+          }
81
+          return self::$instance;
82
+     }
83
+
84
+     /**
85
+      * Loads the variable classes and the static classes.
86
+      */
87
+     private function load_classes() {
88
+
89
+          $this->post_types = array(
90
+               'plan',
91
+               'workout',
92
+               'exercise',
93
+               //'meal',
94
+               'recipe',
95
+               //'tip',
96
+          );
97
+
98
+          foreach ( $this->post_types as $post_type ) {
99
+               $this->$post_type = require_once LSX_HEALTH_PLAN_PATH . 'classes/admin/settings/class-' . $post_type . '.php';
100
+          }
101
+     }
102
+
103
+     /**
104
+      * Sets the variables needed for the fields.
105
+      *
106
+      * @return void
107
+      */
108
+     public function set_vars() {
109
+
110
+          $this->default_types  = array(
111
+               'page' => array(
112
+                    'title'       => __( 'Warm Up', 'lsx-health-plan' ),
113
+                    'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ),
114
+                    'limit'       => 1,
115
+                    'id'          => 'plan_warmup',
116
+               ),
117
+          );
118
+          $this->download_types = array(
119
+               'page' => array(
120
+                    'title'       => __( 'Warm Up', 'lsx-health-plan' ),
121
+                    'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ),
122
+                    'limit'       => 1,
123
+               ),
124
+          );
125
+          $this->endpoints      = array(
126
+               'endpoint_warm_up' => array(
127
+                    'title'       => __( 'Warm Up Endpoint', 'lsx-health-plan' ),
128
+                    'default'     => 'warm-up',
129
+               ),
130
+          );
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' ),
136
+               );
137
+               $this->default_types['meal']      = array(
138
+                    'title'       => __( 'Meal Plan', 'lsx-health-plan' ),
139
+                    'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ),
140
+                    'id'          => 'connected_meals',
141
+               );
142
+               $this->endpoints['endpoint_meal'] = array(
143
+                    'title'       => __( 'Meal Endpoint', 'lsx-health-plan' ),
144
+                    'default'     => 'meal',
145
+                    'description' => __( 'Define the tab slug which shows on the single plan page.', 'lsx-health-plan' ),
146
+               );
147
+               $this->endpoints['endpoint_meal_archive'] = array(
148
+                    'title'   => __( 'Meals Archive Endpoint', 'lsx-health-plan' ),
149
+                    'default' => 'meals',
150
+               );
151
+               $this->endpoints['meal_single_slug'] = array(
152
+                    'title'   => __( 'Single Meal Slug', 'lsx-health-plan' ),
153
+                    'default' => 'meal',
154
+               );
155
+          }
156
+          if ( post_type_exists( 'recipe' ) ) {
157
+               $this->download_types['recipe'] = array(
158
+                    'title'       => __( 'Recipe', 'lsx-health-plan' ),
159
+                    'description' => __( 'Set a default recipe.', 'lsx-health-plan' ),
160
+               );
161
+               $this->default_types['recipe'] = array(
162
+                    'title'       => __( 'Recipe', 'lsx-health-plan' ),
163
+                    'description' => __( 'Set a default recipe.', 'lsx-health-plan' ),
164
+                    'id'          => 'connected_recipes',
165
+               );
166
+               $this->endpoints['endpoint_recipe'] = array(
167
+                    'title'   => __( 'Recipes Endpoint', 'lsx-health-plan' ),
168
+                    'default' => 'recipe',
169
+               );
170
+          }
171
+          if ( post_type_exists( 'workout' ) ) {
172
+               $this->download_types['workout'] = array(
173
+                    'title'       => __( 'Workout', 'lsx-health-plan' ),
174
+                    'description' => __( 'Set a default workout routine PDF.', 'lsx-health-plan' ),
175
+               );
176
+               $this->default_types['workout'] = array(
177
+                    'title'       => __( 'Workout', 'lsx-health-plan' ),
178
+                    'description' => __( 'Set a default workout routine.', 'lsx-health-plan' ),
179
+                    'id'          => 'connected_workouts',
180
+               );
181
+               $this->endpoints['endpoint_workout_archive'] = array(
182
+                    'title'   => __( 'Workouts Archive Endpoint', 'lsx-health-plan' ),
183
+                    'default' => '',
184
+               );
185
+               $this->endpoints['endpoint_workout'] = array(
186
+                    'title'   => __( 'Single Workout Endpoint', 'lsx-health-plan' ),
187
+                    'default' => 'workout',
188
+               );
189
+          }
190
+
191
+          $this->endpoints['login_slug'] = array(
192
+               'title'   => __( 'Login Slug', 'lsx-health-plan' ),
193
+               'default' => 'login',
194
+          );
195
+          $this->endpoints['my_plan_slug'] = array(
196
+               'title'   => __( 'My Plan Slug', 'lsx-health-plan' ),
197
+               'default' => 'my-plan',
198
+          );
199
+          $this->endpoints['plan_single_slug'] = array(
200
+               'title'   => __( 'Single Plan Slug', 'lsx-health-plan' ),
201
+               'default' => 'plan',
202
+          );
203
+          $this->endpoints['endpoint_plan_archive'] = array(
204
+               'title'   => __( 'Plans Archive Endpoint', 'lsx-health-plan' ),
205
+               'default' => 'plans',
206
+          );
207
+
208
+          if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
209
+               $this->endpoints['exercise'] = array(
210
+                    'exercise_single' => array(
211
+                         'title'   => __( 'Single Exercise Slug', 'lsx-health-plan' ),
212
+                         'default' => 'exercise',
213
+                    ),
214
+                    'exercise_archive' => array(
215
+                         'title'   => __( 'Archive Exercise Slug', 'lsx-health-plan' ),
216
+                         'default' => 'exercises',
217
+                    ),
218
+                    'exercise_type' => array(
219
+                         'title'   => __( 'Exercise Type Slug', 'lsx-health-plan' ),
220
+                         'default' => 'exercise-type',
221
+                    ),
222
+                    'exercise_equipment' => array(
223
+                         'title'   => __( 'Equipment Slug', 'lsx-health-plan' ),
224
+                         'default' => 'equipment',
225
+                    ),
226
+                    'exercise_musclegroup' => array(
227
+                         'title'   => __( 'Muscle Group Slug', 'lsx-health-plan' ),
228
+                         'default' => 'muscle-group',
229
+                    ),
230
+               );
231
+          }
232
+     }
233
+
234
+     /**
235
+      * Hook in and register a submenu options page for the Page post-type menu.
236
+      */
237
+     public function register_settings_page() {
238
+          $this->set_vars();
239
+          $cmb = new_cmb2_box(
240
+               array(
241
+                    'id'           => $this->screen_id,
242
+                    'title'        => esc_html__( 'Settings', 'lsx-health-plan' ),
243
+                    'object_types' => array( 'options-page' ),
244
+                    'option_key'   => 'lsx_health_plan_options', // The option key and admin menu page slug.
245
+                    'parent_slug'  => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu.
246
+                    'capability'   => 'manage_options', // Cap required to view options-page.
247
+               )
248
+          );
249
+          do_action( 'lsx_hp_settings_page', $cmb );
250
+     }
251
+
252
+     /**
253
+      * Registers the general settings.
254
+      *
255
+      * @param object $cmb new_cmb2_box().
256
+      * @return void
257
+      */
258
+     public function general_settings( $cmb ) {
259
+          $cmb->add_field(
260
+               array(
261
+                    'name'       => __( 'Membership Product', 'lsx-health-plan' ),
262
+                    'id'         => 'membership_product',
263
+                    'type'       => 'post_search_ajax',
264
+                    'limit'      => 1,
265
+                    'sortable'   => false,
266
+                    'query_args' => array(
267
+                         'post_type'      => array( 'product' ),
268
+                         'post_status'    => array( 'publish' ),
269
+                         'posts_per_page' => -1,
270
+                    ),
271
+               )
272
+          );
273
+
274
+          $cmb->add_field(
275
+               array(
276
+                    'name'    => __( 'Your Warm-up Intro', 'lsx-health-plan' ),
277
+                    'id'      => 'warmup_intro',
278
+                    'type'    => 'textarea_small',
279
+                    'value'   => '',
280
+                    'default' => __( "Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan' ),
281
+               )
282
+          );
283
+          if ( post_type_exists( 'workout' ) ) {
284
+               $cmb->add_field(
285
+                    array(
286
+                         'name'    => __( 'Your Workout Intro', 'lsx-health-plan' ),
287
+                         'id'      => 'workout_intro',
288
+                         'type'    => 'textarea_small',
289
+                         'value'   => '',
290
+                         'default' => __( "Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan' ),
291
+                    )
292
+               );
293
+          }
294
+          if ( post_type_exists( 'meal' ) ) {
295
+               $cmb->add_field(
296
+                    array(
297
+                         'name'    => __( 'Your Meal Plan Intro', 'lsx-health-plan' ),
298
+                         'id'      => 'meal_plan_intro',
299
+                         'type'    => 'textarea_small',
300
+                         'value'   => '',
301
+                         'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ),
302
+                    )
303
+               );
304
+          }
305
+          if ( post_type_exists( 'recipe' ) ) {
306
+               $cmb->add_field(
307
+                    array(
308
+                         'name'    => __( 'Recipes Intro', 'lsx-health-plan' ),
309
+                         'id'      => 'recipes_intro',
310
+                         'type'    => 'textarea_small',
311
+                         'value'   => '',
312
+                         'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan' ),
313
+                    )
314
+               );
315
+          }
316
+     }
317
+
318
+     /**
319
+      * Registers the global default settings.
320
+      *
321
+      * @param object $cmb new_cmb2_box().
322
+      * @return void
323
+      */
324
+     public function global_defaults( $cmb ) {
325
+          $cmb->add_field(
326
+               array(
327
+                    'id'      => 'global_defaults_title',
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' ),
332
+               )
333
+          );
334
+
335
+          foreach ( $this->default_types as $type => $default_type ) {
336
+               $limit    = 5;
337
+               $sortable = false;
338
+               if ( isset( $default_type['limit'] ) ) {
339
+                    $limit    = $default_type['limit'];
340
+                    $sortable = true;
341
+               }
342
+
343
+               if ( 'page' === $type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
344
+                    $type = array( 'page', 'workout' );
345
+               }
346
+
347
+               $cmb->add_field(
348
+                    array(
349
+                         'name'       => $default_type['title'],
350
+                         'desc'       => $default_type['description'],
351
+                         'id'         => $default_type['id'],
352
+                         'type'       => 'post_search_ajax',
353
+                         'limit'      => $limit,
354
+                         'sortable'   => $sortable,
355
+                         'query_args' => array(
356
+                              'post_type'      => $type,
357
+                              'post_status'    => array( 'publish' ),
358
+                              'posts_per_page' => -1,
359
+                         ),
360
+                    )
361
+               );
362
+          }
363
+
364
+          $cmb->add_field(
365
+               array(
366
+                    'id'   => 'settings_global_defaults_closing',
367
+                    'type' => 'tab_closing',
368
+               )
369
+          );
370
+     }
371
+
372
+     /**
373
+      * Registers the global dowloads settings
374
+      *
375
+      * @param object $cmb new_cmb2_box().
376
+      * @return void
377
+      */
378
+     public function global_downloads( $cmb ) {
379
+          $cmb->add_field(
380
+               array(
381
+                    'id'          => 'global_downloads_title',
382
+                    'type'        => 'title',
383
+                    'name'        => __( 'Global Downloads', 'lsx-health-plan' ),
384
+                    'default'     => __( 'Global Downloads', 'lsx-health-plan' ),
385
+                    'description' => __( 'If you have not connected a specific download file to your plans, set a default option below', 'lsx-health-plan' ),
386
+               )
387
+          );
388
+
389
+          foreach ( $this->download_types as $type => $download_type ) {
390
+               $limit    = 5;
391
+               $sortable = false;
392
+               if ( isset( $download_type['limit'] ) ) {
393
+                    $limit    = $download_type['limit'];
394
+                    $sortable = true;
395
+               }
396
+
397
+               $cmb->add_field(
398
+                    array(
399
+                         'name'       => $download_type['title'],
400
+                         'id'         => 'download_' . $type,
401
+                         'type'       => 'post_search_ajax',
402
+                         'limit'      => $limit,
403
+                         'sortable'   => $sortable,
404
+                         'query_args' => array(
405
+                              'post_type'      => array( 'dlm_download' ),
406
+                              'post_status'    => array( 'publish' ),
407
+                              'posts_per_page' => -1,
408
+                         ),
409
+                    )
410
+               );
411
+          }
412
+          $cmb->add_field(
413
+               array(
414
+                    'id'   => 'settings_global_downloads_closing',
415
+                    'type' => 'tab_closing',
416
+               )
417
+          );
418
+     }
419
+
420
+     /**
421
+      * Registers the endpoint translation settings.
422
+      *
423
+      * @param object $cmb new_cmb2_box().
424
+      * @return void
425
+      */
426
+     public function endpoint_translations( $cmb ) {
427
+          $cmb->add_field(
428
+               array(
429
+                    'id'          => 'endpoints_title',
430
+                    'type'        => 'title',
431
+                    'name'        => __( 'Set Endpoint Translations', 'lsx-health-plan' ),
432
+                    'default'     => __( 'Set Endpoint Translations', 'lsx-health-plan' ),
433
+                    // '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' ),
434
+               )
435
+          );
436
+          foreach ( $this->endpoints as $slug => $endpoint_vars ) {
437
+               if ( 'exercise' === $slug ) {
438
+                    continue;
439
+               }
440
+
441
+               $cmb->add_field(
442
+                    array(
443
+                         'name'    => $endpoint_vars['title'],
444
+                         'id'      => $slug,
445
+                         'type'    => 'input',
446
+                         'value'   => '',
447
+                         'default' => $endpoint_vars['default'],
448
+                    )
449
+               );
450
+          }
451
+          $cmb->add_field(
452
+               array(
453
+                    'id'   => 'settings_endpoints_closing',
454
+                    'type' => 'tab_closing',
455
+                    'before_row'    => '<p style="margin-top:20px; font-style: italic;">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.</p>',
456
+               )
457
+          );
458
+     }
459
+
460
+     /**
461
+      * Registers the endpoint translation settings.
462
+      *
463
+      * @param object $cmb new_cmb2_box().
464
+      * @return void
465
+      */
466
+     public function exercise_translations( $cmb ) {
467
+          if ( isset( $this->endpoints['exercise'] ) && '' !== $this->endpoints['exercise'] && ! empty( $this->endpoints['exercise'] ) ) {
468
+               $cmb->add_field(
469
+                    array(
470
+                         'id'          => 'exercise_endpoints_title',
471
+                         'type'        => 'title',
472
+                         'name'        => __( 'Set Exercise Translations', 'lsx-health-plan' ),
473
+                         'default'     => __( 'Set Exercise Translations', 'lsx-health-plan' ),
474
+                         'description' => __( 'Change the exercise endpoints.', 'lsx-health-plan' ),
475
+                    )
476
+               );
477
+
478
+               foreach ( $this->endpoints['exercise'] as $slug => $endpoint_vars ) {
479
+                    $cmb->add_field(
480
+                         array(
481
+                              'name'    => $endpoint_vars['title'],
482
+                              'id'      => 'endpoint_' . $slug,
483
+                              'type'    => 'input',
484
+                              'value'   => '',
485
+                              'default' => $endpoint_vars['default'],
486
+                         )
487
+                    );
488
+               }
489
+
490
+               $cmb->add_field(
491
+                    array(
492
+                         'id'   => 'settings_exercise_closing',
493
+                         'type' => 'tab_closing',
494
+                         'before_row'    => '<p style="margin-top:20px; font-style: italic;">If you need to translate the exercise URL endpoints, do so below.</p>',
495
+                    )
496
+               );
497
+          }
498
+     }
499
+
500
+     /**
501
+      * Registers the post type toggle settings
502
+      *
503
+      * @param object $cmb new_cmb2_box().
504
+      * @return void
505
+      */
506
+     public function post_type_toggles( $cmb ) {
507
+          $post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) );
508
+
509
+          $cmb->add_field(
510
+               array(
511
+                    'id'          => 'post_type_toggles_title',
512
+                    'type'        => 'title',
513
+                    'name'        => __( 'Disable Post Types', 'lsx-health-plan' ),
514
+                    'default'     => __( 'Disable Post Types', 'lsx-health-plan' ),
515
+                    'description' => __( 'Disable post types if you are wanting a minimal site.', 'lsx-health-plan' ),
516
+               )
517
+          );
518
+
519
+          foreach ( $post_types as $post_type ) {
520
+               if ( 'plan' === $post_type || 'exercise' === $post_type || ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) ) {
521
+                    continue;
522
+               }
523
+
524
+               $cmb->add_field(
525
+                    array(
526
+                         'name'    => ucwords( $post_type ),
527
+                         'id'      => $post_type . '_disabled',
528
+                         'type'    => 'checkbox',
529
+                         'value'   => 1,
530
+                         'default' => 0,
531
+                    )
532
+               );
533
+          }
534
+
535
+          $cmb->add_field(
536
+               array(
537
+                    'id'   => 'settings_post_type_toggles_closing',
538
+                    'type' => 'tab_closing',
539
+               )
540
+          );
541
+
542
+          $cmb->add_field(
543
+               array(
544
+                    'id'          => 'post_type_toggles_enable_title',
545
+                    'type'        => 'title',
546
+                    'name'        => __( 'Enable Post Types', 'lsx-health-plan' ),
547
+                    'default'     => __( 'Enable Post Types', 'lsx-health-plan' ),
548
+                    'description' => __( 'Enable new functionality like the "exercise" post type.', 'lsx-health-plan' ),
549
+               )
550
+          );
551
+          $cmb->add_field(
552
+               array(
553
+                    'name'        => __( 'Exercises', 'lsx-health-plan' ),
554
+                    'id'          => 'exercise_enabled',
555
+                    'type'        => 'checkbox',
556
+                    'value'       => 1,
557
+                    'default'     => 0,
558
+                    'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ),
559
+               )
560
+          );
561
+          $cmb->add_field(
562
+               array(
563
+                    'id'   => 'settings_post_type_toggles_enable_closing',
564
+                    'type' => 'tab_closing',
565
+               )
566
+          );
567
+     }
568
+     /**
569
+      * Registers the Profile Stat Toggle settings
570
+      *
571
+      * @param object $cmb new_cmb2_box().
572
+      * @return void
573
+      */
574
+
575
+     public function stat_disable( $cmb ) {
576
+          $cmb->add_field(
577
+               array(
578
+                    'id'      => 'stat_disable_title',
579
+                    'type'    => 'title',
580
+                    'name'    => __( 'Disable Profile Stats', 'lsx-health-plan' ),
581
+                    'default' => __( 'Disable Profile Stats', 'lsx-health-plan' ),
582
+               )
583
+          );
584
+          $cmb->add_field(
585
+               array(
586
+                    'name'    => __( 'Disable All Stats', 'lsx-health-plan' ),
587
+                    'desc'    => 'Disable All Stats',
588
+                    'id'      => 'disable_all_stats',
589
+                    'type'    => 'checkbox',
590
+                    'value'   => 1,
591
+                    'default' => 0,
592
+               )
593
+          );
594
+          $cmb->add_field(
595
+               array(
596
+                    'name'    => __( 'Disable Weight', 'lsx-health-plan' ),
597
+                    'id'      => 'disable_weight_checkbox',
598
+                    'type'    => 'checkbox',
599
+                    'value'   => 1,
600
+                    'default' => 0,
601
+               )
602
+          );
603
+          $cmb->add_field(
604
+               array(
605
+                    'name'    => __( 'Disable Height', 'lsx-health-plan' ),
606
+                    'id'      => 'disable_height_checkbox',
607
+                    'type'    => 'checkbox',
608
+                    'value'   => 1,
609
+                    'default' => 0,
610
+               )
611
+          );
612
+          $cmb->add_field(
613
+               array(
614
+                    'name'    => __( 'Disable Waist', 'lsx-health-plan' ),
615
+                    'id'      => 'disable_waist_checkbox',
616
+                    'type'    => 'checkbox',
617
+                    'value'   => 1,
618
+                    'default' => 0,
619
+               )
620
+          );
621
+          $cmb->add_field(
622
+               array(
623
+                    'name'    => __( 'Disable BMI', 'lsx-health-plan' ),
624
+                    'id'      => 'disable_bmi_checkbox',
625
+                    'type'    => 'checkbox',
626
+                    'value'   => 1,
627
+                    'default' => 0,
628
+               )
629
+          );
630
+          $cmb->add_field(
631
+               array(
632
+                    'id'   => 'settings_stat_disable_closing',
633
+                    'type' => 'tab_closing',
634
+               )
635
+          );
636
+     }
637
+
638
+     /**
639
+      * Enable Business Directory Search settings only if LSX Search plugin is enabled.
640
+      *
641
+      * @param object $cmb The CMB2() class.
642
+      * @param string $section either engine,archive or single.
643
+      * @return void
644
+      */
645
+     public function generate_tabs( $cmb ) {
646
+          $tabs = $this->get_settings_tabs();
647
+
648
+          foreach ( $tabs as $tab_key => $tab ) {
649
+               $cmb->add_field(
650
+                    array(
651
+                         'id'          => 'settings_' . $tab_key . '_title',
652
+                         'type'        => 'title',
653
+                         'name'        => $tab['title'],
654
+                         'default'     => $tab['title'],
655
+                         'description' => $tab['desc'],
656
+                    )
657
+               );
658
+               do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb );
659
+
660
+               do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb );
661
+
662
+               do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb );
663
+
664
+               $cmb->add_field(
665
+                    array(
666
+                         'id'   => 'settings_' . $tab_key . '_closing',
667
+                         'type' => 'tab_closing',
668
+                    )
669
+               );
670
+          }
671
+     }
672
+
673
+
674
+     /**
675
+      * Returns the tabs and their descriptions.
676
+      *
677
+      * @return array
678
+      */
679
+     public function get_settings_tabs() {
680
+          $tabs = array(
681
+               'general' => array(
682
+                    'title' => __( 'General', 'lsx-health-plan' ),
683
+                    'desc'  => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ),
684
+               ),
685
+          );
686
+
687
+          foreach ( $this->post_types as $post_type ) {
688
+               switch ( $post_type ) {
689
+                    default:
690
+                         //if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) {
691
+                              $temp_post_type = get_post_type_object( $post_type );
692
+                              if ( ! is_wp_error( $temp_post_type ) ) {
693
+                                   $page_url    = get_post_type_archive_link( $temp_post_type->name );
694
+                                   $description = sprintf(
695
+                                        /* translators: %s: The subscription info */
696
+                                        __( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ),
697
+                                        $page_url,
698
+                                        $temp_post_type->label
699
+                                   );
700
+
701
+                                   $tabs[ $post_type ] = array(
702
+                                        'title' => $temp_post_type->label,
703
+                                        'desc'  => $description,
704
+                                   );
705
+                              }
706
+                         //}
707
+                         break;
708
+               }
709
+          }
710
+          return $tabs;
711
+     }
712 712
 }
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,21 +375,21 @@  discard block
 block discarded – undo
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' ),
385
-				'description' => __( 'If you have not connected a specific download file to your plans, set a default option below', 'lsx-health-plan' ),
383
+				'name'        => __('Global Downloads', 'lsx-health-plan'),
384
+				'default'     => __('Global Downloads', 'lsx-health-plan'),
385
+				'description' => __('If you have not connected a specific download file to your plans, set a default option below', 'lsx-health-plan'),
386 386
 			)
387 387
 		);
388 388
 
389
-		foreach ( $this->download_types as $type => $download_type ) {
389
+		foreach ($this->download_types as $type => $download_type) {
390 390
 			$limit    = 5;
391 391
 			$sortable = false;
392
-			if ( isset( $download_type['limit'] ) ) {
392
+			if (isset($download_type['limit'])) {
393 393
 				$limit    = $download_type['limit'];
394 394
 				$sortable = true;
395 395
 			}
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
 					'limit'      => $limit,
403 403
 					'sortable'   => $sortable,
404 404
 					'query_args' => array(
405
-						'post_type'      => array( 'dlm_download' ),
406
-						'post_status'    => array( 'publish' ),
405
+						'post_type'      => array('dlm_download'),
406
+						'post_status'    => array('publish'),
407 407
 						'posts_per_page' => -1,
408 408
 					),
409 409
 				)
@@ -423,18 +423,18 @@  discard block
 block discarded – undo
423 423
 	 * @param object $cmb new_cmb2_box().
424 424
 	 * @return void
425 425
 	 */
426
-	public function endpoint_translations( $cmb ) {
426
+	public function endpoint_translations($cmb) {
427 427
 		$cmb->add_field(
428 428
 			array(
429 429
 				'id'          => 'endpoints_title',
430 430
 				'type'        => 'title',
431
-				'name'        => __( 'Set Endpoint Translations', 'lsx-health-plan' ),
432
-				'default'     => __( 'Set Endpoint Translations', 'lsx-health-plan' ),
431
+				'name'        => __('Set Endpoint Translations', 'lsx-health-plan'),
432
+				'default'     => __('Set Endpoint Translations', 'lsx-health-plan'),
433 433
 				// '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' ),
434 434
 			)
435 435
 		);
436
-		foreach ( $this->endpoints as $slug => $endpoint_vars ) {
437
-			if ( 'exercise' === $slug ) {
436
+		foreach ($this->endpoints as $slug => $endpoint_vars) {
437
+			if ('exercise' === $slug) {
438 438
 				continue;
439 439
 			}
440 440
 
@@ -463,19 +463,19 @@  discard block
 block discarded – undo
463 463
 	 * @param object $cmb new_cmb2_box().
464 464
 	 * @return void
465 465
 	 */
466
-	public function exercise_translations( $cmb ) {
467
-		if ( isset( $this->endpoints['exercise'] ) && '' !== $this->endpoints['exercise'] && ! empty( $this->endpoints['exercise'] ) ) {
466
+	public function exercise_translations($cmb) {
467
+		if (isset($this->endpoints['exercise']) && '' !== $this->endpoints['exercise'] && ! empty($this->endpoints['exercise'])) {
468 468
 			$cmb->add_field(
469 469
 				array(
470 470
 					'id'          => 'exercise_endpoints_title',
471 471
 					'type'        => 'title',
472
-					'name'        => __( 'Set Exercise Translations', 'lsx-health-plan' ),
473
-					'default'     => __( 'Set Exercise Translations', 'lsx-health-plan' ),
474
-					'description' => __( 'Change the exercise endpoints.', 'lsx-health-plan' ),
472
+					'name'        => __('Set Exercise Translations', 'lsx-health-plan'),
473
+					'default'     => __('Set Exercise Translations', 'lsx-health-plan'),
474
+					'description' => __('Change the exercise endpoints.', 'lsx-health-plan'),
475 475
 				)
476 476
 			);
477 477
 
478
-			foreach ( $this->endpoints['exercise'] as $slug => $endpoint_vars ) {
478
+			foreach ($this->endpoints['exercise'] as $slug => $endpoint_vars) {
479 479
 				$cmb->add_field(
480 480
 					array(
481 481
 						'name'    => $endpoint_vars['title'],
@@ -503,27 +503,27 @@  discard block
 block discarded – undo
503 503
 	 * @param object $cmb new_cmb2_box().
504 504
 	 * @return void
505 505
 	 */
506
-	public function post_type_toggles( $cmb ) {
507
-		$post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) );
506
+	public function post_type_toggles($cmb) {
507
+		$post_types = apply_filters('lsx_health_plan_post_types', isset($this->post_types));
508 508
 
509 509
 		$cmb->add_field(
510 510
 			array(
511 511
 				'id'          => 'post_type_toggles_title',
512 512
 				'type'        => 'title',
513
-				'name'        => __( 'Disable Post Types', 'lsx-health-plan' ),
514
-				'default'     => __( 'Disable Post Types', 'lsx-health-plan' ),
515
-				'description' => __( 'Disable post types if you are wanting a minimal site.', 'lsx-health-plan' ),
513
+				'name'        => __('Disable Post Types', 'lsx-health-plan'),
514
+				'default'     => __('Disable Post Types', 'lsx-health-plan'),
515
+				'description' => __('Disable post types if you are wanting a minimal site.', 'lsx-health-plan'),
516 516
 			)
517 517
 		);
518 518
 
519
-		foreach ( $post_types as $post_type ) {
520
-			if ( 'plan' === $post_type || 'exercise' === $post_type || ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) ) {
519
+		foreach ($post_types as $post_type) {
520
+			if ('plan' === $post_type || 'exercise' === $post_type || ('video' === $post_type && false !== \lsx_health_plan\functions\get_option('exercise_enabled', false))) {
521 521
 				continue;
522 522
 			}
523 523
 
524 524
 			$cmb->add_field(
525 525
 				array(
526
-					'name'    => ucwords( $post_type ),
526
+					'name'    => ucwords($post_type),
527 527
 					'id'      => $post_type . '_disabled',
528 528
 					'type'    => 'checkbox',
529 529
 					'value'   => 1,
@@ -543,19 +543,19 @@  discard block
 block discarded – undo
543 543
 			array(
544 544
 				'id'          => 'post_type_toggles_enable_title',
545 545
 				'type'        => 'title',
546
-				'name'        => __( 'Enable Post Types', 'lsx-health-plan' ),
547
-				'default'     => __( 'Enable Post Types', 'lsx-health-plan' ),
548
-				'description' => __( 'Enable new functionality like the "exercise" post type.', 'lsx-health-plan' ),
546
+				'name'        => __('Enable Post Types', 'lsx-health-plan'),
547
+				'default'     => __('Enable Post Types', 'lsx-health-plan'),
548
+				'description' => __('Enable new functionality like the "exercise" post type.', 'lsx-health-plan'),
549 549
 			)
550 550
 		);
551 551
 		$cmb->add_field(
552 552
 			array(
553
-				'name'        => __( 'Exercises', 'lsx-health-plan' ),
553
+				'name'        => __('Exercises', 'lsx-health-plan'),
554 554
 				'id'          => 'exercise_enabled',
555 555
 				'type'        => 'checkbox',
556 556
 				'value'       => 1,
557 557
 				'default'     => 0,
558
-				'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ),
558
+				'description' => __('Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan'),
559 559
 			)
560 560
 		);
561 561
 		$cmb->add_field(
@@ -572,18 +572,18 @@  discard block
 block discarded – undo
572 572
 	 * @return void
573 573
 	 */
574 574
 
575
-	public function stat_disable( $cmb ) {
575
+	public function stat_disable($cmb) {
576 576
 		$cmb->add_field(
577 577
 			array(
578 578
 				'id'      => 'stat_disable_title',
579 579
 				'type'    => 'title',
580
-				'name'    => __( 'Disable Profile Stats', 'lsx-health-plan' ),
581
-				'default' => __( 'Disable Profile Stats', 'lsx-health-plan' ),
580
+				'name'    => __('Disable Profile Stats', 'lsx-health-plan'),
581
+				'default' => __('Disable Profile Stats', 'lsx-health-plan'),
582 582
 			)
583 583
 		);
584 584
 		$cmb->add_field(
585 585
 			array(
586
-				'name'    => __( 'Disable All Stats', 'lsx-health-plan' ),
586
+				'name'    => __('Disable All Stats', 'lsx-health-plan'),
587 587
 				'desc'    => 'Disable All Stats',
588 588
 				'id'      => 'disable_all_stats',
589 589
 				'type'    => 'checkbox',
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 		);
594 594
 		$cmb->add_field(
595 595
 			array(
596
-				'name'    => __( 'Disable Weight', 'lsx-health-plan' ),
596
+				'name'    => __('Disable Weight', 'lsx-health-plan'),
597 597
 				'id'      => 'disable_weight_checkbox',
598 598
 				'type'    => 'checkbox',
599 599
 				'value'   => 1,
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 		);
603 603
 		$cmb->add_field(
604 604
 			array(
605
-				'name'    => __( 'Disable Height', 'lsx-health-plan' ),
605
+				'name'    => __('Disable Height', 'lsx-health-plan'),
606 606
 				'id'      => 'disable_height_checkbox',
607 607
 				'type'    => 'checkbox',
608 608
 				'value'   => 1,
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 		);
612 612
 		$cmb->add_field(
613 613
 			array(
614
-				'name'    => __( 'Disable Waist', 'lsx-health-plan' ),
614
+				'name'    => __('Disable Waist', 'lsx-health-plan'),
615 615
 				'id'      => 'disable_waist_checkbox',
616 616
 				'type'    => 'checkbox',
617 617
 				'value'   => 1,
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 		);
621 621
 		$cmb->add_field(
622 622
 			array(
623
-				'name'    => __( 'Disable BMI', 'lsx-health-plan' ),
623
+				'name'    => __('Disable BMI', 'lsx-health-plan'),
624 624
 				'id'      => 'disable_bmi_checkbox',
625 625
 				'type'    => 'checkbox',
626 626
 				'value'   => 1,
@@ -642,10 +642,10 @@  discard block
 block discarded – undo
642 642
 	 * @param string $section either engine,archive or single.
643 643
 	 * @return void
644 644
 	 */
645
-	public function generate_tabs( $cmb ) {
645
+	public function generate_tabs($cmb) {
646 646
 		$tabs = $this->get_settings_tabs();
647 647
 
648
-		foreach ( $tabs as $tab_key => $tab ) {
648
+		foreach ($tabs as $tab_key => $tab) {
649 649
 			$cmb->add_field(
650 650
 				array(
651 651
 					'id'          => 'settings_' . $tab_key . '_title',
@@ -655,11 +655,11 @@  discard block
 block discarded – undo
655 655
 					'description' => $tab['desc'],
656 656
 				)
657 657
 			);
658
-			do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb );
658
+			do_action('lsx_hp_settings_page_' . $tab_key . '_top', $cmb);
659 659
 
660
-			do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb );
660
+			do_action('lsx_hp_settings_page_' . $tab_key . '_middle', $cmb);
661 661
 
662
-			do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb );
662
+			do_action('lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb);
663 663
 
664 664
 			$cmb->add_field(
665 665
 				array(
@@ -679,26 +679,26 @@  discard block
 block discarded – undo
679 679
 	public function get_settings_tabs() {
680 680
 		$tabs = array(
681 681
 			'general' => array(
682
-				'title' => __( 'General', 'lsx-health-plan' ),
683
-				'desc'  => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ),
682
+				'title' => __('General', 'lsx-health-plan'),
683
+				'desc'  => __('Control the sitewide settings for the LSX HP site.', 'lsx-health-plan'),
684 684
 			),
685 685
 		);
686 686
 
687
-		foreach ( $this->post_types as $post_type ) {
688
-			switch ( $post_type ) {
687
+		foreach ($this->post_types as $post_type) {
688
+			switch ($post_type) {
689 689
 				default:
690 690
 					//if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) {
691
-						$temp_post_type = get_post_type_object( $post_type );
692
-						if ( ! is_wp_error( $temp_post_type ) ) {
693
-							$page_url    = get_post_type_archive_link( $temp_post_type->name );
691
+						$temp_post_type = get_post_type_object($post_type);
692
+						if ( ! is_wp_error($temp_post_type)) {
693
+							$page_url    = get_post_type_archive_link($temp_post_type->name);
694 694
 							$description = sprintf(
695 695
 								/* translators: %s: The subscription info */
696
-								__( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ),
696
+								__('Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search'),
697 697
 								$page_url,
698 698
 								$temp_post_type->label
699 699
 							);
700 700
 
701
-							$tabs[ $post_type ] = array(
701
+							$tabs[$post_type] = array(
702 702
 								'title' => $temp_post_type->label,
703 703
 								'desc'  => $description,
704 704
 							);
Please login to merge, or discard this patch.