1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Contains the settings class for LSX |
4
|
|
|
* |
5
|
|
|
* @package lsx-health-plan |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace lsx_health_plan\classes\admin; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Contains the settings for each post type \lsx_health_plan\classes\admin\Settings(). |
12
|
|
|
*/ |
13
|
|
|
class Settings { |
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
|
|
|
$cmb = new_cmb2_box( |
239
|
|
|
array( |
240
|
|
|
'id' => $this->screen_id, |
241
|
|
|
'title' => esc_html__( 'Settings', 'lsx-health-plan' ), |
242
|
|
|
'object_types' => array( 'options-page' ), |
243
|
|
|
'option_key' => 'lsx_health_plan_options', // The option key and admin menu page slug. |
244
|
|
|
'parent_slug' => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu. |
245
|
|
|
'capability' => 'manage_options', // Cap required to view options-page. |
246
|
|
|
) |
247
|
|
|
); |
248
|
|
|
do_action( 'lsx_hp_settings_page', $cmb ); |
249
|
|
|
} |
|
|
|
|
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Registers the general settings. |
253
|
|
|
* |
254
|
|
|
* @param object $cmb new_cmb2_box(). |
255
|
|
|
* @return void |
256
|
|
|
*/ |
257
|
|
|
public function general_settings( $cmb ) { |
258
|
|
|
if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) { |
|
|
|
|
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
|
|
|
|
275
|
|
|
$cmb->add_field( |
276
|
|
|
array( |
277
|
|
|
'name' => __( 'Login Slug', 'lsx-health-plan' ), |
|
|
|
|
278
|
|
|
'id' => 'login_slug', |
279
|
|
|
'type' => 'input', |
280
|
|
|
'value' => '', |
281
|
|
|
'default' => 'login', |
282
|
|
|
) |
283
|
|
|
); |
284
|
|
|
|
285
|
|
|
} |
|
|
|
|
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* Registers the global default settings. |
289
|
|
|
* |
290
|
|
|
* @param object $cmb new_cmb2_box(). |
291
|
|
|
* @return void |
292
|
|
|
*/ |
293
|
|
|
// public function global_defaults( $cmb ) { |
|
|
|
|
294
|
|
|
// $cmb->add_field( |
|
|
|
|
295
|
|
|
// array( |
|
|
|
|
296
|
|
|
// 'id' => 'global_defaults_title', |
|
|
|
|
297
|
|
|
// 'type' => 'title', |
|
|
|
|
298
|
|
|
// 'name' => __( 'Global Defaults', 'lsx-health-plan' ), |
|
|
|
|
299
|
|
|
// 'default' => __( 'Global Defaults', 'lsx-health-plan' ), |
|
|
|
|
300
|
|
|
// 'description' => __( 'If you have not connected a specific post to your day plan, set a default option below.', 'lsx-health-plan' ), |
|
|
|
|
301
|
|
|
// ) |
|
|
|
|
302
|
|
|
// ); |
|
|
|
|
303
|
|
|
|
304
|
|
|
// foreach ( $this->default_types as $type => $default_type ) { |
|
|
|
|
305
|
|
|
// $limit = 5; |
|
|
|
|
306
|
|
|
// $sortable = false; |
|
|
|
|
307
|
|
|
// if ( isset( $default_type['limit'] ) ) { |
|
|
|
|
308
|
|
|
// $limit = $default_type['limit']; |
|
|
|
|
309
|
|
|
// $sortable = true; |
|
|
|
|
310
|
|
|
// } |
|
|
|
|
311
|
|
|
|
312
|
|
|
// if ( 'page' === $type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
|
|
|
313
|
|
|
// $type = array( 'page', 'workout' ); |
|
|
|
|
314
|
|
|
// } |
|
|
|
|
315
|
|
|
|
316
|
|
|
// $cmb->add_field( |
|
|
|
|
317
|
|
|
// array( |
|
|
|
|
318
|
|
|
// 'name' => $default_type['title'], |
|
|
|
|
319
|
|
|
// 'desc' => $default_type['description'], |
|
|
|
|
320
|
|
|
// 'id' => $default_type['id'], |
|
|
|
|
321
|
|
|
// 'type' => 'post_search_ajax', |
|
|
|
|
322
|
|
|
// 'limit' => $limit, |
|
|
|
|
323
|
|
|
// 'sortable' => $sortable, |
|
|
|
|
324
|
|
|
// 'query_args' => array( |
|
|
|
|
325
|
|
|
// 'post_type' => $type, |
|
|
|
|
326
|
|
|
// 'post_status' => array( 'publish' ), |
|
|
|
|
327
|
|
|
// 'posts_per_page' => -1, |
|
|
|
|
328
|
|
|
// ), |
|
|
|
|
329
|
|
|
// ) |
|
|
|
|
330
|
|
|
// ); |
|
|
|
|
331
|
|
|
// } |
|
|
|
|
332
|
|
|
|
333
|
|
|
// $cmb->add_field( |
|
|
|
|
334
|
|
|
// array( |
|
|
|
|
335
|
|
|
// 'id' => 'settings_global_defaults_closing', |
|
|
|
|
336
|
|
|
// 'type' => 'tab_closing', |
|
|
|
|
337
|
|
|
// ) |
|
|
|
|
338
|
|
|
// ); |
|
|
|
|
339
|
|
|
// } |
340
|
|
|
|
341
|
|
|
/** |
342
|
|
|
* Registers the global dowloads settings |
343
|
|
|
* |
344
|
|
|
* @param object $cmb new_cmb2_box(). |
345
|
|
|
* @return void |
346
|
|
|
*/ |
347
|
|
|
// public function global_downloads( $cmb ) { |
|
|
|
|
348
|
|
|
// if ( ! function_exists( 'download_monitor' ) ) { |
|
|
|
|
349
|
|
|
// return; |
|
|
|
|
350
|
|
|
// } |
|
|
|
|
351
|
|
|
// $page_url = 'https://wordpress.org/plugins/download-monitor/'; |
|
|
|
|
352
|
|
|
// $plugin_name = 'Download Monitor'; |
|
|
|
|
353
|
|
|
// $description = sprintf( |
|
|
|
|
354
|
|
|
// /* translators: %s: The subscription info */ |
|
|
|
|
355
|
|
|
// __( 'If you are using <a target="_blank" href="%1$s">%2$s</a> you can set a default download file for your plan here.', 'lsx-search' ), |
|
|
|
|
356
|
|
|
// $page_url, |
|
|
|
|
357
|
|
|
// $plugin_name |
|
|
|
|
358
|
|
|
// ); |
|
|
|
|
359
|
|
|
// $cmb->add_field( |
|
|
|
|
360
|
|
|
// array( |
|
|
|
|
361
|
|
|
// 'id' => 'global_downloads_title', |
|
|
|
|
362
|
|
|
// 'type' => 'title', |
|
|
|
|
363
|
|
|
// 'name' => __( 'Global Downloads', 'lsx-health-plan' ), |
|
|
|
|
364
|
|
|
// 'default' => __( 'Global Downloads', 'lsx-health-plan' ), |
|
|
|
|
365
|
|
|
// 'description' => $description, |
|
|
|
|
366
|
|
|
// ) |
|
|
|
|
367
|
|
|
// ); |
|
|
|
|
368
|
|
|
|
369
|
|
|
// foreach ( $this->download_types as $type => $download_type ) { |
|
|
|
|
370
|
|
|
// $limit = 5; |
|
|
|
|
371
|
|
|
// $sortable = false; |
|
|
|
|
372
|
|
|
// if ( isset( $download_type['limit'] ) ) { |
|
|
|
|
373
|
|
|
// $limit = $download_type['limit']; |
|
|
|
|
374
|
|
|
// $sortable = true; |
|
|
|
|
375
|
|
|
// } |
|
|
|
|
376
|
|
|
|
377
|
|
|
// $cmb->add_field( |
|
|
|
|
378
|
|
|
// array( |
|
|
|
|
379
|
|
|
// 'name' => $download_type['title'], |
|
|
|
|
380
|
|
|
// 'id' => 'download_' . $type, |
|
|
|
|
381
|
|
|
// 'type' => 'post_search_ajax', |
|
|
|
|
382
|
|
|
// 'limit' => $limit, |
|
|
|
|
383
|
|
|
// 'sortable' => $sortable, |
|
|
|
|
384
|
|
|
// 'query_args' => array( |
|
|
|
|
385
|
|
|
// 'post_type' => array( 'dlm_download' ), |
|
|
|
|
386
|
|
|
// 'post_status' => array( 'publish' ), |
|
|
|
|
387
|
|
|
// 'posts_per_page' => -1, |
|
|
|
|
388
|
|
|
// ), |
|
|
|
|
389
|
|
|
// ) |
|
|
|
|
390
|
|
|
// ); |
|
|
|
|
391
|
|
|
// } |
|
|
|
|
392
|
|
|
// $cmb->add_field( |
|
|
|
|
393
|
|
|
// array( |
|
|
|
|
394
|
|
|
// 'id' => 'settings_global_downloads_closing', |
|
|
|
|
395
|
|
|
// 'type' => 'tab_closing', |
|
|
|
|
396
|
|
|
// ) |
|
|
|
|
397
|
|
|
// ); |
|
|
|
|
398
|
|
|
// } |
399
|
|
|
|
400
|
|
|
/** |
401
|
|
|
* Registers the endpoint translation settings. |
402
|
|
|
* |
403
|
|
|
* @param object $cmb new_cmb2_box(). |
404
|
|
|
* @return void |
405
|
|
|
*/ |
406
|
|
|
// public function endpoint_translations( $cmb ) { |
|
|
|
|
407
|
|
|
// $cmb->add_field( |
|
|
|
|
408
|
|
|
// array( |
|
|
|
|
409
|
|
|
// 'id' => 'endpoints_title', |
|
|
|
|
410
|
|
|
// 'type' => 'title', |
|
|
|
|
411
|
|
|
// 'name' => __( 'Set Endpoint Translations', 'lsx-health-plan' ), |
|
|
|
|
412
|
|
|
// 'default' => __( 'Set Endpoint Translations', 'lsx-health-plan' ), |
|
|
|
|
413
|
|
|
// ) |
|
|
|
|
414
|
|
|
// ); |
|
|
|
|
415
|
|
|
// foreach ( $this->endpoints as $slug => $endpoint_vars ) { |
|
|
|
|
416
|
|
|
// if ( 'exercise' === $slug ) { |
|
|
|
|
417
|
|
|
// continue; |
|
|
|
|
418
|
|
|
// } |
|
|
|
|
419
|
|
|
|
420
|
|
|
// $cmb->add_field( |
|
|
|
|
421
|
|
|
// array( |
|
|
|
|
422
|
|
|
// 'name' => $slug, |
|
|
|
|
423
|
|
|
// 'id' => $slug, |
|
|
|
|
424
|
|
|
// 'type' => 'input', |
|
|
|
|
425
|
|
|
// 'value' => '', |
|
|
|
|
426
|
|
|
// 'default' => $endpoint_vars['default'], |
|
|
|
|
427
|
|
|
// ) |
|
|
|
|
428
|
|
|
// ); |
|
|
|
|
429
|
|
|
// } |
|
|
|
|
430
|
|
|
// $cmb->add_field( |
|
|
|
|
431
|
|
|
// array( |
|
|
|
|
432
|
|
|
// 'id' => 'settings_endpoints_closing', |
|
|
|
|
433
|
|
|
// 'type' => 'tab_closing', |
|
|
|
|
434
|
|
|
// '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>', |
|
|
|
|
435
|
|
|
// ) |
|
|
|
|
436
|
|
|
// ); |
|
|
|
|
437
|
|
|
// } |
438
|
|
|
|
439
|
|
|
/** |
440
|
|
|
* Registers the endpoint translation settings. |
441
|
|
|
* |
442
|
|
|
* @param object $cmb new_cmb2_box(). |
443
|
|
|
* @return void |
444
|
|
|
*/ |
445
|
|
|
// public function exercise_translations( $cmb ) { |
|
|
|
|
446
|
|
|
// if ( isset( $this->endpoints['exercise'] ) && '' !== $this->endpoints['exercise'] && ! empty( $this->endpoints['exercise'] ) ) { |
|
|
|
|
447
|
|
|
// $cmb->add_field( |
|
|
|
|
448
|
|
|
// array( |
|
|
|
|
449
|
|
|
// 'id' => 'exercise_endpoints_title', |
|
|
|
|
450
|
|
|
// 'type' => 'title', |
|
|
|
|
451
|
|
|
// 'name' => __( 'Set Exercise Translations', 'lsx-health-plan' ), |
|
|
|
|
452
|
|
|
// 'default' => __( 'Set Exercise Translations', 'lsx-health-plan' ), |
|
|
|
|
453
|
|
|
// 'description' => __( 'Change the exercise endpoints.', 'lsx-health-plan' ), |
|
|
|
|
454
|
|
|
// ) |
|
|
|
|
455
|
|
|
// ); |
|
|
|
|
456
|
|
|
|
457
|
|
|
// foreach ( $this->endpoints['exercise'] as $slug => $endpoint_vars ) { |
|
|
|
|
458
|
|
|
// $cmb->add_field( |
|
|
|
|
459
|
|
|
// array( |
|
|
|
|
460
|
|
|
// 'name' => 'endpoint_' . $slug, |
|
|
|
|
461
|
|
|
// 'id' => 'endpoint_' . $slug, |
|
|
|
|
462
|
|
|
// 'type' => 'input', |
|
|
|
|
463
|
|
|
// 'value' => '', |
|
|
|
|
464
|
|
|
// 'default' => $endpoint_vars['default'], |
|
|
|
|
465
|
|
|
// ) |
|
|
|
|
466
|
|
|
// ); |
|
|
|
|
467
|
|
|
// } |
|
|
|
|
468
|
|
|
|
469
|
|
|
// $cmb->add_field( |
|
|
|
|
470
|
|
|
// array( |
|
|
|
|
471
|
|
|
// 'id' => 'settings_exercise_endpoints_closing', |
|
|
|
|
472
|
|
|
// 'type' => 'tab_closing', |
|
|
|
|
473
|
|
|
// 'before_row' => '<p style="margin-top:20px; font-style: italic;">If you need to translate the exercise URL slugs, do so below.</p>', |
|
|
|
|
474
|
|
|
// ) |
|
|
|
|
475
|
|
|
// ); |
|
|
|
|
476
|
|
|
// } |
|
|
|
|
477
|
|
|
// } |
478
|
|
|
|
479
|
|
|
/** |
480
|
|
|
* Registers the post type toggle settings |
481
|
|
|
* |
482
|
|
|
* @param object $cmb new_cmb2_box(). |
483
|
|
|
* @return void |
484
|
|
|
*/ |
485
|
|
|
// public function post_type_toggles( $cmb ) { |
|
|
|
|
486
|
|
|
// $post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) ); |
|
|
|
|
487
|
|
|
|
488
|
|
|
// $cmb->add_field( |
|
|
|
|
489
|
|
|
// array( |
|
|
|
|
490
|
|
|
// 'id' => 'post_type_toggles_title', |
|
|
|
|
491
|
|
|
// 'type' => 'title', |
|
|
|
|
492
|
|
|
// 'name' => __( 'Disable Post Types', 'lsx-health-plan' ), |
|
|
|
|
493
|
|
|
// 'default' => __( 'Disable Post Types', 'lsx-health-plan' ), |
|
|
|
|
494
|
|
|
// 'description' => __( 'Disable post types if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
|
|
|
495
|
|
|
// ) |
|
|
|
|
496
|
|
|
// ); |
|
|
|
|
497
|
|
|
|
498
|
|
|
// foreach ( $post_types as $post_type ) { |
|
|
|
|
499
|
|
|
// if ( 'plan' === $post_type || 'exercise' === $post_type || ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) ) { |
|
|
|
|
500
|
|
|
// continue; |
|
|
|
|
501
|
|
|
// } |
|
|
|
|
502
|
|
|
|
503
|
|
|
// $cmb->add_field( |
|
|
|
|
504
|
|
|
// array( |
|
|
|
|
505
|
|
|
// 'name' => $post_type . '_disabled', |
|
|
|
|
506
|
|
|
// 'id' => $post_type . '_disabled', |
|
|
|
|
507
|
|
|
// 'type' => 'checkbox', |
|
|
|
|
508
|
|
|
// 'value' => 1, |
|
|
|
|
509
|
|
|
// 'default' => 0, |
|
|
|
|
510
|
|
|
// ) |
|
|
|
|
511
|
|
|
// ); |
|
|
|
|
512
|
|
|
// } |
|
|
|
|
513
|
|
|
|
514
|
|
|
// $cmb->add_field( |
|
|
|
|
515
|
|
|
// array( |
|
|
|
|
516
|
|
|
// 'id' => 'settings_post_type_toggles_closing', |
|
|
|
|
517
|
|
|
// 'type' => 'tab_closing', |
|
|
|
|
518
|
|
|
// ) |
|
|
|
|
519
|
|
|
// ); |
|
|
|
|
520
|
|
|
|
521
|
|
|
|
522
|
|
|
// } |
523
|
|
|
|
524
|
|
|
/** |
525
|
|
|
* Registers the Profile Stat Toggle settings |
526
|
|
|
* |
527
|
|
|
* @param object $cmb new_cmb2_box(). |
528
|
|
|
* @return void |
529
|
|
|
*/ |
530
|
|
|
|
531
|
|
|
// public function stat_disable( $cmb ) { |
|
|
|
|
532
|
|
|
// $cmb->add_field( |
|
|
|
|
533
|
|
|
// array( |
|
|
|
|
534
|
|
|
// 'id' => 'stat_disable_title', |
|
|
|
|
535
|
|
|
// 'type' => 'title', |
|
|
|
|
536
|
|
|
// 'name' => __( 'My Plans', 'lsx-health-plan' ), |
|
|
|
|
537
|
|
|
// 'default' => __( 'My Plans', 'lsx-health-plan' ), |
|
|
|
|
538
|
|
|
// ) |
|
|
|
|
539
|
|
|
// ); |
|
|
|
|
540
|
|
|
|
541
|
|
|
// $cmb->add_field( |
|
|
|
|
542
|
|
|
// array( |
|
|
|
|
543
|
|
|
// 'id' => 'settings_stat_disable_closing', |
|
|
|
|
544
|
|
|
// 'type' => 'tab_closing', |
|
|
|
|
545
|
|
|
// ) |
|
|
|
|
546
|
|
|
// ); |
|
|
|
|
547
|
|
|
// } |
548
|
|
|
|
549
|
|
|
/** |
550
|
|
|
* Enable Business Directory Search settings only if LSX Search plugin is enabled. |
551
|
|
|
* |
552
|
|
|
* @param object $cmb The CMB2() class. |
553
|
|
|
* @param string $section either engine,archive or single. |
|
|
|
|
554
|
|
|
* @return void |
555
|
|
|
*/ |
556
|
|
|
public function generate_tabs( $cmb ) { |
|
|
|
|
557
|
|
|
$tabs = $this->get_settings_tabs(); |
558
|
|
|
|
559
|
|
|
foreach ( $tabs as $tab_key => $tab ) { |
|
|
|
|
560
|
|
|
$cmb->add_field( |
561
|
|
|
array( |
562
|
|
|
'id' => 'settings_' . $tab_key . '_title', |
563
|
|
|
'type' => 'title', |
564
|
|
|
'name' => $tab['title'], |
565
|
|
|
'default' => $tab['title'], |
566
|
|
|
'description' => $tab['desc'], |
567
|
|
|
) |
568
|
|
|
); |
569
|
|
|
do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb ); |
570
|
|
|
|
571
|
|
|
do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb ); |
572
|
|
|
|
573
|
|
|
do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb ); |
574
|
|
|
|
575
|
|
|
$cmb->add_field( |
576
|
|
|
array( |
577
|
|
|
'id' => 'settings_' . $tab_key . '_closing', |
578
|
|
|
'type' => 'tab_closing', |
579
|
|
|
) |
580
|
|
|
); |
581
|
|
|
} |
582
|
|
|
} |
|
|
|
|
583
|
|
|
|
584
|
|
|
|
585
|
|
|
/** |
586
|
|
|
* Returns the tabs and their descriptions. |
587
|
|
|
* |
588
|
|
|
* @return array |
589
|
|
|
*/ |
590
|
|
|
public function get_settings_tabs() { |
591
|
|
|
$tabs = array( |
592
|
|
|
'general' => array( |
593
|
|
|
'title' => __( 'General', 'lsx-health-plan' ), |
594
|
|
|
'desc' => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ), |
595
|
|
|
), |
596
|
|
|
); |
597
|
|
|
|
598
|
|
|
foreach ( $this->post_types as $post_type ) { |
|
|
|
|
599
|
|
|
switch ( $post_type ) { |
|
|
|
|
600
|
|
|
default: |
601
|
|
|
//if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) { |
|
|
|
|
602
|
|
|
$temp_post_type = get_post_type_object( $post_type ); |
603
|
|
|
if ( ! is_wp_error( $temp_post_type ) ) { |
|
|
|
|
604
|
|
|
$page_url = get_post_type_archive_link( $temp_post_type->name ); |
605
|
|
|
$description = sprintf( |
606
|
|
|
/* translators: %s: The subscription info */ |
607
|
|
|
__( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ), |
608
|
|
|
$page_url, |
|
|
|
|
609
|
|
|
$temp_post_type->label |
610
|
|
|
); |
611
|
|
|
|
612
|
|
|
$tabs[ $post_type ] = array( |
613
|
|
|
'title' => $temp_post_type->label, |
614
|
|
|
'desc' => $description, |
615
|
|
|
); |
616
|
|
|
} |
|
|
|
|
617
|
|
|
//} |
|
|
|
|
618
|
|
|
break; |
619
|
|
|
} |
620
|
|
|
} |
|
|
|
|
621
|
|
|
return $tabs; |
622
|
|
|
} |
|
|
|
|
623
|
|
|
} |
624
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.