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\Workout(). |
12
|
|
|
*/ |
13
|
|
|
class Workout { |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Holds class instance |
17
|
|
|
* |
18
|
|
|
* @since 1.0.0 |
19
|
|
|
* |
20
|
|
|
* @var object \lsx_health_plan\classes\admin\Workout() |
21
|
|
|
*/ |
22
|
|
|
protected static $instance = null; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Constructor |
26
|
|
|
*/ |
27
|
|
|
public function __construct() { |
|
|
|
|
28
|
|
|
add_action( 'lsx_hp_settings_page_workout_top', array( $this, 'settings' ), 1, 1 ); |
29
|
|
|
} |
|
|
|
|
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Return an instance of this class. |
33
|
|
|
* |
34
|
|
|
* @since 1.0.0 |
35
|
|
|
* |
36
|
|
|
* @return object \lsx_health_plan\classes\admin\Workout() A single instance of this class. |
37
|
|
|
*/ |
38
|
|
|
public static function get_instance() { |
39
|
|
|
// If the single instance hasn't been set, set it now. |
40
|
|
|
if ( null === self::$instance ) { |
|
|
|
|
41
|
|
|
self::$instance = new self(); |
42
|
|
|
} |
|
|
|
|
43
|
|
|
return self::$instance; |
44
|
|
|
} |
|
|
|
|
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Registers the general settings. |
48
|
|
|
* |
49
|
|
|
* @param object $cmb new_cmb2_box(). |
50
|
|
|
* @return void |
51
|
|
|
*/ |
52
|
|
|
public function settings( $cmb ) { |
53
|
|
|
$cmb->add_field( |
54
|
|
|
array( |
55
|
|
|
'name' => __( 'Disable Workouts', 'lsx-health-plan' ), |
56
|
|
|
'id' => 'workout_disabled', |
57
|
|
|
'type' => 'checkbox', |
58
|
|
|
'value' => 1, |
59
|
|
|
'default' => 0, |
60
|
|
|
'description' => __( 'Disable workout post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
61
|
|
|
) |
62
|
|
|
); |
63
|
|
|
if ( post_type_exists( 'workout' ) ) { |
|
|
|
|
64
|
|
|
$cmb->add_field( |
65
|
|
|
array( |
66
|
|
|
'name' => __( 'Your Workout Intro', 'lsx-health-plan' ), |
67
|
|
|
'id' => 'workout_intro', |
68
|
|
|
'type' => 'wysiwyg', |
69
|
|
|
'value' => '', |
70
|
|
|
'default' => __( "Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan' ), |
71
|
|
|
'options' => array( |
|
|
|
|
72
|
|
|
'textarea_rows' => get_option('default_post_edit_rows', 6), |
|
|
|
|
73
|
|
|
), |
74
|
|
|
) |
75
|
|
|
); |
76
|
|
|
} |
|
|
|
|
77
|
|
|
$cmb->add_field( |
78
|
|
|
array( |
79
|
|
|
'before_row' => '<h4><b><u>Layout Options</u></b></h4>', |
80
|
|
|
'id' => 'workout_tab_layout', |
81
|
|
|
'type' => 'select', |
82
|
|
|
'name' => __( 'Workout Tab Layout', 'lsx-health-plan' ), |
83
|
|
|
'description' => __( 'Choose the layout for the workouts.', 'lsx-health-plan' ), |
84
|
|
|
'options' => array( |
85
|
|
|
'table' => __( 'Table', 'lsx-health-plan' ), |
86
|
|
|
'list' => __( 'List', 'lsx-health-plan' ), |
87
|
|
|
'grid' => __( 'Grid', 'lsx-health-plan' ), |
88
|
|
|
), |
89
|
|
|
) |
90
|
|
|
); |
91
|
|
|
$cmb->add_field( |
92
|
|
|
array( |
93
|
|
|
'id' => 'workout_tab_link', |
94
|
|
|
'type' => 'select', |
95
|
|
|
'name' => __( 'Workout Tab Link', 'lsx-health-plan' ), |
96
|
|
|
'description' => __( 'Choose to show the excerpt, full content or nothing.', 'lsx-health-plan' ), |
97
|
|
|
'options' => array( |
98
|
|
|
'none' => __( 'None', 'lsx-health-plan' ), |
99
|
|
|
'single' => __( 'Single', 'lsx-health-plan' ), |
100
|
|
|
'modal' => __( 'Modal', 'lsx-health-plan' ), |
101
|
|
|
), |
102
|
|
|
'default' => '', |
|
|
|
|
103
|
|
|
) |
104
|
|
|
); |
105
|
|
|
$cmb->add_field( |
106
|
|
|
array( |
107
|
|
|
'id' => 'workout_tab_modal_content', |
108
|
|
|
'type' => 'select', |
109
|
|
|
'name' => __( 'Modal Content', 'lsx-health-plan' ), |
110
|
|
|
'description' => __( 'Choose to show the excerpt, full content or nothing. For the modal content only', 'lsx-health-plan' ), |
111
|
|
|
'options' => array( |
112
|
|
|
'' => __( 'None', 'lsx-health-plan' ), |
113
|
|
|
'excerpt' => __( 'Excerpt', 'lsx-health-plan' ), |
114
|
|
|
'full' => __( 'Full Content', 'lsx-health-plan' ), |
115
|
|
|
), |
116
|
|
|
'default' => '', |
|
|
|
|
117
|
|
|
) |
118
|
|
|
); |
119
|
|
|
$cmb->add_field( |
120
|
|
|
array( |
121
|
|
|
'id' => 'workout_tab_columns', |
122
|
|
|
'type' => 'select', |
123
|
|
|
'name' => __( 'Grid Columns', 'lsx-health-plan' ), |
124
|
|
|
'description' => __( 'If you are displaying a grid, set the amount of columns you want to use.', 'lsx-health-plan' ), |
125
|
|
|
'options' => array( |
126
|
|
|
'12' => __( '1', 'lsx-health-plan' ), |
127
|
|
|
'6' => __( '2', 'lsx-health-plan' ), |
128
|
|
|
'4' => __( '3', 'lsx-health-plan' ), |
129
|
|
|
'3' => __( '4', 'lsx-health-plan' ), |
130
|
|
|
'2' => __( '6', 'lsx-health-plan' ), |
131
|
|
|
), |
132
|
|
|
'default' => '4', |
|
|
|
|
133
|
|
|
) |
134
|
|
|
); |
135
|
|
|
$cmb->add_field( |
136
|
|
|
array( |
137
|
|
|
'id' => 'workout_tab_content', |
138
|
|
|
'type' => 'select', |
139
|
|
|
'name' => __( 'Grid Content', 'lsx-health-plan' ), |
140
|
|
|
'description' => __( 'Choose to show the excerpt, full content or nothing. For the grid layout only', 'lsx-health-plan' ), |
141
|
|
|
'options' => array( |
142
|
|
|
'' => __( 'None', 'lsx-health-plan' ), |
143
|
|
|
'excerpt' => __( 'Excerpt', 'lsx-health-plan' ), |
144
|
|
|
'full' => __( 'Full Content', 'lsx-health-plan' ), |
145
|
|
|
), |
146
|
|
|
'default' => '', |
147
|
|
|
) |
148
|
|
|
); |
149
|
|
|
|
150
|
|
|
$cmb->add_field( |
151
|
|
|
array( |
152
|
|
|
'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>', |
153
|
|
|
'name' => __( 'Single Workout Slug', 'lsx-health-plan' ), |
|
|
|
|
154
|
|
|
'id' => 'endpoint_workout', |
155
|
|
|
'type' => 'input', |
156
|
|
|
'value' => '', |
157
|
|
|
'default' => 'workout', |
158
|
|
|
) |
159
|
|
|
); |
160
|
|
|
$cmb->add_field( |
161
|
|
|
array( |
162
|
|
|
'name' => __( 'Workouts Archive Slug', 'lsx-health-plan' ), |
|
|
|
|
163
|
|
|
'id' => 'endpoint_workout_archive', |
164
|
|
|
'type' => 'input', |
165
|
|
|
'value' => '', |
166
|
|
|
'default' => 'workouts', |
167
|
|
|
) |
168
|
|
|
); |
169
|
|
|
$cmb->add_field( |
170
|
|
|
array( |
171
|
|
|
'name' => __( 'Warm Up Slug', 'lsx-health-plan' ), |
|
|
|
|
172
|
|
|
'id' => 'endpoint_warm_up', |
173
|
|
|
'type' => 'input', |
174
|
|
|
'value' => '', |
175
|
|
|
'default' => 'warm-up', |
176
|
|
|
) |
177
|
|
|
); |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
180
|
|
|
$cmb->add_field( |
181
|
|
|
array( |
182
|
|
|
'before_row' => '<h4><b><u>Default Options</u></b></h4>', |
183
|
|
|
'name' => __( 'Warm Up', 'lsx-health-plan' ), |
184
|
|
|
'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ), |
185
|
|
|
'limit' => 1, |
186
|
|
|
'id' => 'plan_warmup', |
187
|
|
|
'type' => 'post_search_ajax', |
188
|
|
|
'query_args' => array( |
189
|
|
|
'post_type' => 'post', |
190
|
|
|
'post_status' => array( 'publish' ), |
191
|
|
|
'posts_per_page' => -1, |
192
|
|
|
), |
193
|
|
|
) |
194
|
|
|
); |
195
|
|
|
$cmb->add_field( |
196
|
|
|
array( |
197
|
|
|
'name' => __( 'Workout', 'lsx-health-plan' ), |
198
|
|
|
'description' => __( 'Set a default workout routine.', 'lsx-health-plan' ), |
199
|
|
|
'limit' => 1, |
200
|
|
|
'id' => 'connected_workouts', |
201
|
|
|
'type' => 'post_search_ajax', |
202
|
|
|
'query_args' => array( |
203
|
|
|
'post_type' => 'workout', |
204
|
|
|
'post_status' => array( 'publish' ), |
205
|
|
|
'posts_per_page' => -1, |
206
|
|
|
), |
207
|
|
|
) |
208
|
|
|
); |
209
|
|
|
if ( function_exists( 'download_monitor' ) ) { |
|
|
|
|
210
|
|
|
$page_url = 'https://wordpress.org/plugins/download-monitor/'; |
211
|
|
|
$plugin_name = 'Download Monitor'; |
212
|
|
|
$description = sprintf( |
213
|
|
|
/* translators: %s: The subscription info */ |
214
|
|
|
__( 'If you are using <a target="_blank" href="%1$s">%2$s</a> you can set a default download file for your meal here.', 'lsx-search' ), |
215
|
|
|
$page_url, |
216
|
|
|
$plugin_name |
217
|
|
|
); |
218
|
|
|
$cmb->add_field( |
219
|
|
|
array( |
220
|
|
|
'name' => __( 'Default Warm Up PDF', 'lsx-health-plan' ), |
221
|
|
|
'description' => $description, |
222
|
|
|
'id' => 'download_page', |
223
|
|
|
'type' => 'post_search_ajax', |
224
|
|
|
'limit' => 1, |
225
|
|
|
'query_args' => array( |
226
|
|
|
'post_type' => array( 'dlm_download' ), |
227
|
|
|
'post_status' => array( 'publish' ), |
228
|
|
|
'posts_per_page' => -1, |
229
|
|
|
), |
230
|
|
|
) |
231
|
|
|
); |
232
|
|
|
$cmb->add_field( |
233
|
|
|
array( |
234
|
|
|
'name' => __( 'Default Workout PDF', 'lsx-health-plan' ), |
235
|
|
|
'description' => $description, |
236
|
|
|
'id' => 'download_workout', |
237
|
|
|
'type' => 'post_search_ajax', |
238
|
|
|
'limit' => 1, |
239
|
|
|
'query_args' => array( |
240
|
|
|
'post_type' => array( 'dlm_download' ), |
241
|
|
|
'post_status' => array( 'publish' ), |
242
|
|
|
'posts_per_page' => -1, |
243
|
|
|
), |
244
|
|
|
'after_row' => __( '<p style="font-style: italic;">If you have changed any URL slugs, please remember re-save your permalinks in Settings > Permalinks.</p>', 'lsx-health-plan' ), |
245
|
|
|
) |
246
|
|
|
); |
247
|
|
|
} |
248
|
|
|
} |
|
|
|
|
249
|
|
|
} |
250
|
|
|
Workout::get_instance(); |
251
|
|
|
|