1
|
|
|
<?php |
2
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* Sensei Settings Class |
6
|
|
|
* |
7
|
|
|
* All functionality pertaining to the settings in Sensei. |
8
|
|
|
* |
9
|
|
|
* @package Core |
10
|
|
|
* @author Automattic |
11
|
|
|
* |
12
|
|
|
* @since 1.0.0 |
13
|
|
|
*/ |
14
|
|
|
class Sensei_Settings extends Sensei_Settings_API { |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Constructor. |
18
|
|
|
* @access public |
19
|
|
|
* @since 1.0.0 |
20
|
|
|
*/ |
21
|
|
|
public function __construct () { |
22
|
|
|
parent::__construct(); // Required in extended classes. |
23
|
|
|
|
24
|
|
|
$this->token = 'woothemes-sensei-settings'; |
25
|
|
|
add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) ); |
26
|
|
|
|
27
|
|
|
// Setup Admin Settings data |
28
|
|
|
if ( is_admin() ) { |
29
|
|
|
|
30
|
|
|
$this->has_tabs = true; |
31
|
|
|
$this->name = __( 'Sensei Settings', 'woothemes-sensei' ); |
32
|
|
|
$this->menu_label = __( 'Settings', 'woothemes-sensei' ); |
33
|
|
|
$this->page_slug = 'woothemes-sensei-settings'; |
34
|
|
|
|
35
|
|
|
} // End If Statement |
36
|
|
|
|
37
|
|
|
$this->register_hook_listener(); |
38
|
|
|
$this->get_settings(); |
39
|
|
|
|
40
|
|
|
} // End __construct() |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Get settings value |
44
|
|
|
* |
45
|
|
|
* @since 1.9.0 |
46
|
|
|
* @param string $setting_name |
47
|
|
|
* @return mixed |
48
|
|
|
*/ |
49
|
|
|
public function get( $setting_name ){ |
50
|
|
|
|
51
|
|
|
if( isset( $this->settings[ $setting_name ] ) ){ |
52
|
|
|
|
53
|
|
|
return $this->settings[ $setting_name ]; |
54
|
|
|
|
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return false; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @since 1.9.0 |
62
|
|
|
* |
63
|
|
|
* @param $setting |
64
|
|
|
* @param $new_value |
65
|
|
|
*/ |
66
|
|
|
public function set( $setting, $new_value ){ |
67
|
|
|
|
68
|
|
|
$settings = get_option( $this->token, array() ); |
69
|
|
|
|
70
|
|
|
if( isset( $settings[ $setting ] ) ){ |
71
|
|
|
|
72
|
|
|
$settings[ $setting ] = $new_value; |
73
|
|
|
return update_option( $this->token,$settings ); |
74
|
|
|
|
75
|
|
|
} |
76
|
|
|
return false; |
77
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Register the settings screen within the WordPress admin. |
82
|
|
|
* @access public |
83
|
|
|
* @since 1.0.0 |
84
|
|
|
* @return void |
85
|
|
|
*/ |
86
|
|
|
public function register_settings_screen () { |
87
|
|
|
|
88
|
|
|
$this->settings_version = Sensei()->version; // Use the global plugin version on this settings screen. |
89
|
|
|
$hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) ); |
90
|
|
|
$this->hook = $hook; |
|
|
|
|
91
|
|
|
|
92
|
|
|
if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) { |
93
|
|
|
add_action( 'admin_notices', array( $this, 'settings_errors' ) ); |
94
|
|
|
add_action( 'admin_notices', array( $this, 'language_pack_notices' ) ); |
95
|
|
|
add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) ); |
96
|
|
|
add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) ); |
97
|
|
|
} |
98
|
|
|
} // End register_settings_screen() |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Add settings sections. |
102
|
|
|
* @access public |
103
|
|
|
* @since 1.0.0 |
104
|
|
|
* @return void |
105
|
|
|
*/ |
106
|
|
|
public function init_sections () { |
107
|
|
|
$sections = array(); |
108
|
|
|
|
109
|
|
|
$sections['default-settings'] = array( |
110
|
|
|
'name' => __( 'General', 'woothemes-sensei' ), |
111
|
|
|
'description' => __( 'Settings that apply to the entire plugin.', 'woothemes-sensei' ) |
112
|
|
|
); |
113
|
|
|
|
114
|
|
|
$sections['course-settings'] = array( |
115
|
|
|
'name' => __( 'Courses', 'woothemes-sensei' ), |
116
|
|
|
'description' => __( 'Settings that apply to all Courses.', 'woothemes-sensei' ) |
117
|
|
|
); |
118
|
|
|
|
119
|
|
|
$sections['lesson-settings'] = array( |
120
|
|
|
'name' => __( 'Lessons', 'woothemes-sensei' ), |
121
|
|
|
'description' => __( 'Settings that apply to all Lessons.', 'woothemes-sensei' ) |
122
|
|
|
); |
123
|
|
|
|
124
|
|
|
$sections['email-notification-settings'] = array( |
125
|
|
|
'name' => __( 'Email Notifications', 'woothemes-sensei' ), |
126
|
|
|
'description' => __( 'Settings for email notifications sent from your site.', 'woothemes-sensei' ) |
127
|
|
|
); |
128
|
|
|
|
129
|
|
|
$sections['learner-profile-settings'] = array( |
130
|
|
|
'name' => __( 'Learner Profiles', 'woothemes-sensei' ), |
131
|
|
|
'description' => __( 'Settings for public Learner Profiles.', 'woothemes-sensei' ) |
132
|
|
|
); |
133
|
|
|
|
134
|
|
|
if ( Sensei_WC::is_woocommerce_present() ) { |
135
|
|
|
$sections['woocommerce-settings'] = array( |
136
|
|
|
'name' => __( 'WooCommerce', 'woothemes-sensei' ), |
137
|
|
|
'description' => __( 'Optional settings for WooCommerce functions.', 'woothemes-sensei' ) |
138
|
|
|
); |
139
|
|
|
} // End If Statement |
140
|
|
|
|
141
|
|
|
if ( 'en_US' !== get_locale() ) { |
142
|
|
|
$sections['language-settings'] = array( |
143
|
|
|
'name' => __( 'Language', 'woothemes-sensei' ), |
144
|
|
|
'description' => __( 'Language options.', 'woothemes-sensei' ) |
145
|
|
|
); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
$this->sections = apply_filters( 'sensei_settings_tabs', $sections ); |
149
|
|
|
} // End init_sections() |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Add settings fields. |
153
|
|
|
* @access public |
154
|
|
|
* @since 1.0.0 |
155
|
|
|
* @uses Sensei_Utils::get_slider_types() |
156
|
|
|
* @return void |
157
|
|
|
*/ |
158
|
|
|
public function init_fields () { |
159
|
|
|
global $pagenow; |
160
|
|
|
|
161
|
|
|
$pages_array = $this->pages_array(); |
162
|
|
|
$posts_per_page_array = array( '0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20' ); |
163
|
|
|
$complete_settings = array( 'passed' => __( 'Once all the course lessons have been completed', 'woothemes-sensei' ), 'complete' => __( 'At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei' ) ); |
164
|
|
|
$course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) ); |
165
|
|
|
|
166
|
|
|
$fields = array(); |
167
|
|
|
|
168
|
|
|
$fields['access_permission'] = array( |
169
|
|
|
'name' => __( 'Access Permissions', 'woothemes-sensei' ), |
170
|
|
|
'description' => __( 'Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei' ), |
171
|
|
|
'type' => 'checkbox', |
172
|
|
|
'default' => true, |
173
|
|
|
'section' => 'default-settings' |
174
|
|
|
); |
175
|
|
|
|
176
|
|
|
$fields['messages_disable'] = array( |
177
|
|
|
'name' => __( 'Disable Private Messages', 'woothemes-sensei' ), |
178
|
|
|
'description' => __( 'Disable the private message functions between learners and teachers.', 'woothemes-sensei' ), |
179
|
|
|
'type' => 'checkbox', |
180
|
|
|
'default' => false, |
181
|
|
|
'section' => 'default-settings' |
182
|
|
|
); |
183
|
|
|
|
184
|
|
|
$fields['course_page'] = array( |
185
|
|
|
'name' => __( 'Course Archive Page', 'woothemes-sensei' ), |
186
|
|
|
'description' => __( 'The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei' ), |
187
|
|
|
'type' => 'select', |
188
|
|
|
'default' => get_option( 'woothemes-sensei_courses_page_id', 0 ), |
189
|
|
|
'section' => 'default-settings', |
190
|
|
|
'required' => 0, |
191
|
|
|
'options' => $pages_array |
192
|
|
|
); |
193
|
|
|
|
194
|
|
|
$fields['my_course_page'] = array( |
195
|
|
|
'name' => __( 'My Courses Page', 'woothemes-sensei' ), |
196
|
|
|
'description' => __( 'The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei' ), |
197
|
|
|
'type' => 'select', |
198
|
|
|
'default' => get_option( 'woothemes-sensei_user_dashboard_page_id', 0 ), |
199
|
|
|
'section' => 'default-settings', |
200
|
|
|
'required' => 0, |
201
|
|
|
'options' => $pages_array |
202
|
|
|
); |
203
|
|
|
|
204
|
|
|
$fields['placeholder_images_enable'] = array( |
205
|
|
|
'name' => __( 'Use placeholder images', 'woothemes-sensei' ), |
206
|
|
|
'description' => __( 'Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei' ), |
207
|
|
|
'type' => 'checkbox', |
208
|
|
|
'default' => false, |
209
|
|
|
'section' => 'default-settings' |
210
|
|
|
); |
211
|
|
|
|
212
|
|
|
$fields['styles_disable'] = array( |
213
|
|
|
'name' => __( 'Disable Sensei Styles', 'woothemes-sensei' ), |
214
|
|
|
'description' => __( 'Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei' ), |
215
|
|
|
'type' => 'checkbox', |
216
|
|
|
'default' => false, |
217
|
|
|
'section' => 'default-settings' |
218
|
|
|
); |
219
|
|
|
|
220
|
|
|
$fields['js_disable'] = array( |
221
|
|
|
'name' => __( 'Disable Sensei Javascript', 'woothemes-sensei' ), |
222
|
|
|
'description' => __( 'Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei' ), |
223
|
|
|
'type' => 'checkbox', |
224
|
|
|
'default' => false, |
225
|
|
|
'section' => 'default-settings' |
226
|
|
|
); |
227
|
|
|
|
228
|
|
|
// Course Settings |
229
|
|
|
|
230
|
|
|
$fields['course_completion'] = array( |
231
|
|
|
'name' => __( 'Courses are complete:', 'woothemes-sensei' ), |
232
|
|
|
'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ), |
233
|
|
|
'type' => 'select', |
234
|
|
|
'default' => 'passed', |
235
|
|
|
'section' => 'course-settings', |
236
|
|
|
'required' => 0, |
237
|
|
|
'options' => $complete_settings |
238
|
|
|
); |
239
|
|
|
|
240
|
|
|
$fields['course_author'] = array( |
241
|
|
|
'name' => __( 'Display Course Author', 'woothemes-sensei' ), |
242
|
|
|
'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ), |
243
|
|
|
'type' => 'checkbox', |
244
|
|
|
'default' => true, |
245
|
|
|
'section' => 'course-settings' |
246
|
|
|
); |
247
|
|
|
|
248
|
|
|
$fields['my_course_amount'] = array( |
249
|
|
|
'name' => __( 'My Courses Pagination', 'woothemes-sensei' ), |
250
|
|
|
'description' => __( 'The number of courses to output for the my courses page.', 'woothemes-sensei' ), |
251
|
|
|
'type' => 'range', |
252
|
|
|
'default' => '0', |
253
|
|
|
'section' => 'course-settings', |
254
|
|
|
'required' => 0, |
255
|
|
|
'options' => $posts_per_page_array |
256
|
|
|
); |
257
|
|
|
|
258
|
|
|
$fields['course_archive_image_enable'] = array( |
259
|
|
|
'name' => __( 'Course Archive Image', 'woothemes-sensei' ), |
260
|
|
|
'description' => __( 'Output the Course Image on the Course Archive Page.', 'woothemes-sensei' ), |
261
|
|
|
'type' => 'checkbox', |
262
|
|
|
'default' => true, |
263
|
|
|
'section' => 'course-settings' |
264
|
|
|
); |
265
|
|
|
|
266
|
|
|
$fields['course_archive_image_width'] = array( |
267
|
|
|
'name' => __( 'Image Width - Archive', 'woothemes-sensei' ), |
268
|
|
|
'description' => __( 'The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ), |
269
|
|
|
'type' => 'text', |
270
|
|
|
'default' => '100', |
271
|
|
|
'section' => 'course-settings', |
272
|
|
|
'required' => 0 |
273
|
|
|
); |
274
|
|
|
|
275
|
|
|
$fields['course_archive_image_height'] = array( |
276
|
|
|
'name' => __( 'Image Height - Archive', 'woothemes-sensei' ), |
277
|
|
|
'description' => __( 'The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ), |
278
|
|
|
'type' => 'text', |
279
|
|
|
'default' => '100', |
280
|
|
|
'section' => 'course-settings', |
281
|
|
|
'required' => 0 |
282
|
|
|
); |
283
|
|
|
|
284
|
|
|
$fields['course_archive_image_hard_crop'] = array( |
285
|
|
|
'name' => __( 'Image Hard Crop - Archive', 'woothemes-sensei' ), |
286
|
|
|
'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
287
|
|
|
'type' => 'checkbox', |
288
|
|
|
'default' => false, |
289
|
|
|
'section' => 'course-settings' |
290
|
|
|
); |
291
|
|
|
|
292
|
|
|
$fields['course_single_image_enable'] = array( |
293
|
|
|
'name' => __( 'Single Course Image', 'woothemes-sensei' ), |
294
|
|
|
'description' => __( 'Output the Course Image on the Single Course Page.', 'woothemes-sensei' ), |
295
|
|
|
'type' => 'checkbox', |
296
|
|
|
'default' => false, |
297
|
|
|
'section' => 'course-settings' |
298
|
|
|
); |
299
|
|
|
|
300
|
|
|
$fields['course_single_image_width'] = array( |
301
|
|
|
'name' => __( 'Image Width - Single', 'woothemes-sensei' ), |
302
|
|
|
'description' => __( 'The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ), |
303
|
|
|
'type' => 'text', |
304
|
|
|
'default' => '100', |
305
|
|
|
'section' => 'course-settings', |
306
|
|
|
'required' => 0 |
307
|
|
|
); |
308
|
|
|
|
309
|
|
|
$fields['course_single_image_height'] = array( |
310
|
|
|
'name' => __( 'Image Height - Single', 'woothemes-sensei' ), |
311
|
|
|
'description' => __( 'The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ), |
312
|
|
|
'type' => 'text', |
313
|
|
|
'default' => '100', |
314
|
|
|
'section' => 'course-settings', |
315
|
|
|
'required' => 0 |
316
|
|
|
); |
317
|
|
|
|
318
|
|
|
$fields['course_single_image_hard_crop'] = array( |
319
|
|
|
'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ), |
320
|
|
|
'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
321
|
|
|
'type' => 'checkbox', |
322
|
|
|
'default' => false, |
323
|
|
|
'section' => 'course-settings' |
324
|
|
|
); |
325
|
|
|
|
326
|
|
|
$fields['course_single_content_display'] = array( |
327
|
|
|
'name' => __( 'Single Course page displays:', 'woothemes-sensei' ), |
328
|
|
|
'description' => __( 'Determines what content to display on the single course page.', 'woothemes-sensei' ), |
329
|
|
|
'type' => 'select', |
330
|
|
|
'default' => 'excerpt', |
331
|
|
|
'section' => 'course-settings', |
332
|
|
|
'required' => 0, |
333
|
|
|
'options' => $course_display_settings |
334
|
|
|
); |
335
|
|
|
|
336
|
|
|
$fields['course_archive_featured_enable'] = array( |
337
|
|
|
'name' => __( 'Featured Courses Panel', 'woothemes-sensei' ), |
338
|
|
|
'description' => __( 'Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
339
|
|
|
'type' => 'checkbox', |
340
|
|
|
'default' => true, |
341
|
|
|
'section' => 'course-settings' |
342
|
|
|
); |
343
|
|
|
|
344
|
|
|
$fields['course_archive_more_link_text'] = array( |
345
|
|
|
'name' => __( 'More link text', 'woothemes-sensei' ), |
346
|
|
|
'description' => __( 'The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei' ), |
347
|
|
|
'type' => 'text', |
348
|
|
|
'default' => __ ( 'More', 'woothemes-sensei' ), |
349
|
|
|
'section' => 'course-settings', |
350
|
|
|
'required' => 0 |
351
|
|
|
); |
352
|
|
|
|
353
|
|
|
// Lesson Settings |
354
|
|
|
|
355
|
|
|
$fields['lesson_comments'] = array( |
356
|
|
|
'name' => __( 'Allow Comments for Lessons', 'woothemes-sensei' ), |
357
|
|
|
'description' => __( 'This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei' ), |
358
|
|
|
'type' => 'checkbox', |
359
|
|
|
'default' => true, |
360
|
|
|
'section' => 'lesson-settings' |
361
|
|
|
); |
362
|
|
|
|
363
|
|
|
$fields['lesson_author'] = array( |
364
|
|
|
'name' => __( 'Display Lesson Author', 'woothemes-sensei' ), |
365
|
|
|
'description' => __( 'Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei' ), |
366
|
|
|
'type' => 'checkbox', |
367
|
|
|
'default' => true, |
368
|
|
|
'section' => 'lesson-settings' |
369
|
|
|
); |
370
|
|
|
|
371
|
|
|
$fields['course_lesson_image_enable'] = array( |
372
|
|
|
'name' => __( 'Course Lesson Images', 'woothemes-sensei' ), |
373
|
|
|
'description' => __( 'Output the Lesson Image on the Single Course Page.', 'woothemes-sensei' ), |
374
|
|
|
'type' => 'checkbox', |
375
|
|
|
'default' => false, |
376
|
|
|
'section' => 'lesson-settings' |
377
|
|
|
); |
378
|
|
|
|
379
|
|
|
$fields['lesson_archive_image_width'] = array( |
380
|
|
|
'name' => __( 'Image Width - Course Lessons', 'woothemes-sensei' ), |
381
|
|
|
'description' => __( 'The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ), |
382
|
|
|
'type' => 'text', |
383
|
|
|
'default' => '100', |
384
|
|
|
'section' => 'lesson-settings', |
385
|
|
|
'required' => 0 |
386
|
|
|
); |
387
|
|
|
|
388
|
|
|
$fields['lesson_archive_image_height'] = array( |
389
|
|
|
'name' => __( 'Image Height - Course Lessons', 'woothemes-sensei' ), |
390
|
|
|
'description' => __( 'The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ), |
391
|
|
|
'type' => 'text', |
392
|
|
|
'default' => '100', |
393
|
|
|
'section' => 'lesson-settings', |
394
|
|
|
'required' => 0 |
395
|
|
|
); |
396
|
|
|
|
397
|
|
|
$fields['lesson_archive_image_hard_crop'] = array( |
398
|
|
|
'name' => __( 'Image Hard Crop - Course Lessons', 'woothemes-sensei' ), |
399
|
|
|
'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
400
|
|
|
'type' => 'checkbox', |
401
|
|
|
'default' => false, |
402
|
|
|
'section' => 'lesson-settings' |
403
|
|
|
); |
404
|
|
|
|
405
|
|
|
$fields['lesson_single_image_enable'] = array( |
406
|
|
|
'name' => __( 'Single Lesson Images', 'woothemes-sensei' ), |
407
|
|
|
'description' => __( 'Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei' ), |
408
|
|
|
'type' => 'checkbox', |
409
|
|
|
'default' => false, |
410
|
|
|
'section' => 'lesson-settings' |
411
|
|
|
); |
412
|
|
|
|
413
|
|
|
$fields['lesson_single_image_width'] = array( |
414
|
|
|
'name' => __( 'Image Width - Single', 'woothemes-sensei' ), |
415
|
|
|
'description' => __( 'The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ), |
416
|
|
|
'type' => 'text', |
417
|
|
|
'default' => '100', |
418
|
|
|
'section' => 'lesson-settings', |
419
|
|
|
'required' => 0 |
420
|
|
|
); |
421
|
|
|
|
422
|
|
|
$fields['lesson_single_image_height'] = array( |
423
|
|
|
'name' => __( 'Image Height - Single', 'woothemes-sensei' ), |
424
|
|
|
'description' => __( 'The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ), |
425
|
|
|
'type' => 'text', |
426
|
|
|
'default' => '100', |
427
|
|
|
'section' => 'lesson-settings', |
428
|
|
|
'required' => 0 |
429
|
|
|
); |
430
|
|
|
|
431
|
|
|
$fields['lesson_single_image_hard_crop'] = array( |
432
|
|
|
'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ), |
433
|
|
|
'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
434
|
|
|
'type' => 'checkbox', |
435
|
|
|
'default' => false, |
436
|
|
|
'section' => 'lesson-settings' |
437
|
|
|
); |
438
|
|
|
|
439
|
|
|
// Learner Profile settings |
440
|
|
|
|
441
|
|
|
$profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') ); |
442
|
|
|
$profile_url_example = trailingslashit( get_site_url() ) . $profile_url_base . '/%username%'; |
443
|
|
|
|
444
|
|
|
$fields['learner_profile_enable'] = array( |
445
|
|
|
'name' => __( 'Public learner profiles', 'woothemes-sensei' ), |
446
|
|
|
'description' => sprintf( __( 'Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei' ), $profile_url_example ), |
447
|
|
|
'type' => 'checkbox', |
448
|
|
|
'default' => true, |
449
|
|
|
'section' => 'learner-profile-settings' |
450
|
|
|
); |
451
|
|
|
|
452
|
|
|
$fields['learner_profile_show_courses'] = array( |
453
|
|
|
'name' => __( 'Show learner\'s courses', 'woothemes-sensei' ), |
454
|
|
|
'description' => __( 'Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei' ), |
455
|
|
|
'type' => 'checkbox', |
456
|
|
|
'default' => true, |
457
|
|
|
'section' => 'learner-profile-settings' |
458
|
|
|
); |
459
|
|
|
|
460
|
|
|
// Email notifications |
461
|
|
|
|
462
|
|
|
$learner_email_options = array( |
463
|
|
|
'learner-graded-quiz' => __( 'Their quiz is graded (auto and manual grading)', 'woothemes-sensei' ), |
464
|
|
|
'learner-completed-course' => __( 'They complete a course', 'woothemes-sensei' ), |
465
|
|
|
); |
466
|
|
|
|
467
|
|
|
$teacher_email_options = array( |
468
|
|
|
'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ), |
469
|
|
|
'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ), |
470
|
|
|
'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ), |
471
|
|
|
'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ), |
472
|
|
|
'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ), |
473
|
|
|
); |
474
|
|
|
|
475
|
|
|
$global_email_options = array( |
476
|
|
|
'new-message-reply' => __( 'They receive a reply to their private message', 'woothemes-sensei' ), |
477
|
|
|
); |
478
|
|
|
|
479
|
|
|
$fields['email_learners'] = array( |
480
|
|
|
'name' => __( 'Emails Sent to Learners', 'woothemes-sensei' ), |
481
|
|
|
'description' => __( 'Select the notifications that will be sent to learners.', 'woothemes-sensei' ), |
482
|
|
|
'type' => 'multicheck', |
483
|
|
|
'options' => $learner_email_options, |
484
|
|
|
'defaults' => array( 'learner-graded-quiz', 'learner-completed-course' ), |
485
|
|
|
'section' => 'email-notification-settings' |
486
|
|
|
); |
487
|
|
|
|
488
|
|
|
$fields['email_teachers'] = array( |
489
|
|
|
'name' => __( 'Emails Sent to Teachers', 'woothemes-sensei' ), |
490
|
|
|
'description' => __( 'Select the notifications that will be sent to teachers.', 'woothemes-sensei' ), |
491
|
|
|
'type' => 'multicheck', |
492
|
|
|
'options' => $teacher_email_options, |
493
|
|
|
'defaults' => array( 'teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message' ), |
494
|
|
|
'section' => 'email-notification-settings' |
495
|
|
|
); |
496
|
|
|
|
497
|
|
|
$fields['email_global'] = array( |
498
|
|
|
'name' => __( 'Emails Sent to All Users', 'woothemes-sensei' ), |
499
|
|
|
'description' => __( 'Select the notifications that will be sent to all users.', 'woothemes-sensei' ), |
500
|
|
|
'type' => 'multicheck', |
501
|
|
|
'options' => $global_email_options, |
502
|
|
|
'defaults' => array( 'new-message-reply' ), |
503
|
|
|
'section' => 'email-notification-settings' |
504
|
|
|
); |
505
|
|
|
|
506
|
|
|
$fields['email_from_name'] = array( |
507
|
|
|
'name' => __( '"From" Name', 'woothemes-sensei' ), |
508
|
|
|
'description' => __( 'The name from which all emails will be sent.', 'woothemes-sensei' ), |
509
|
|
|
'type' => 'text', |
510
|
|
|
'default' => get_bloginfo( 'name' ), |
511
|
|
|
'section' => 'email-notification-settings', |
512
|
|
|
'required' => 1 |
513
|
|
|
); |
514
|
|
|
|
515
|
|
|
$fields['email_from_address'] = array( |
516
|
|
|
'name' => __( '"From" Address', 'woothemes-sensei' ), |
517
|
|
|
'description' => __( 'The address from which all emails will be sent.', 'woothemes-sensei' ), |
518
|
|
|
'type' => 'text', |
519
|
|
|
'default' => get_bloginfo( 'admin_email' ), |
520
|
|
|
'section' => 'email-notification-settings', |
521
|
|
|
'required' => 1 |
522
|
|
|
); |
523
|
|
|
|
524
|
|
|
$fields['email_header_image'] = array( |
525
|
|
|
'name' => __( 'Header Image', 'woothemes-sensei' ), |
526
|
|
|
'description' => sprintf( __( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'media-new.php' ) . '">', '</a>' ), |
527
|
|
|
'type' => 'text', |
528
|
|
|
'default' => '', |
529
|
|
|
'section' => 'email-notification-settings', |
530
|
|
|
'required' => 0 |
531
|
|
|
); |
532
|
|
|
|
533
|
|
|
$fields['email_footer_text'] = array( |
534
|
|
|
'name' => __( 'Email Footer Text', 'woothemes-sensei' ), |
535
|
|
|
'description' => __( 'The text to appear in the footer of Sensei emails.', 'woothemes-sensei' ), |
536
|
|
|
'type' => 'textarea', |
537
|
|
|
'default' => sprintf( __( '%1$s - Powered by Sensei', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), |
538
|
|
|
'section' => 'email-notification-settings', |
539
|
|
|
'required' => 0 |
540
|
|
|
); |
541
|
|
|
|
542
|
|
|
$fields['email_base_color'] = array( |
543
|
|
|
'name' => __( 'Base Colour', 'woothemes-sensei' ), |
544
|
|
|
'description' => sprintf( __( 'The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
545
|
|
|
'type' => 'color', |
546
|
|
|
'default' => '#557da1', |
547
|
|
|
'section' => 'email-notification-settings', |
548
|
|
|
'required' => 1 |
549
|
|
|
); |
550
|
|
|
|
551
|
|
|
$fields['email_background_color'] = array( |
552
|
|
|
'name' => __( 'Background Colour', 'woothemes-sensei' ), |
553
|
|
|
'description' => sprintf( __( 'The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
554
|
|
|
'type' => 'color', |
555
|
|
|
'default' => '#f5f5f5', |
556
|
|
|
'section' => 'email-notification-settings', |
557
|
|
|
'required' => 1 |
558
|
|
|
); |
559
|
|
|
|
560
|
|
|
$fields['email_body_background_color'] = array( |
561
|
|
|
'name' => __( 'Body Background Colour', 'woothemes-sensei' ), |
562
|
|
|
'description' => sprintf( __( 'The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
563
|
|
|
'type' => 'color', |
564
|
|
|
'default' => '#fdfdfd', |
565
|
|
|
'section' => 'email-notification-settings', |
566
|
|
|
'required' => 1 |
567
|
|
|
); |
568
|
|
|
|
569
|
|
|
$fields['email_text_color'] = array( |
570
|
|
|
'name' => __( 'Body Text Colour', 'woothemes-sensei' ), |
571
|
|
|
'description' => sprintf( __( 'The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
572
|
|
|
'type' => 'color', |
573
|
|
|
'default' => '#505050', |
574
|
|
|
'section' => 'email-notification-settings', |
575
|
|
|
'required' => 1 |
576
|
|
|
); |
577
|
|
|
|
578
|
|
|
if ( Sensei_WC::is_woocommerce_present() ) { |
579
|
|
|
// WooCommerce Settings |
580
|
|
|
$fields['woocommerce_enabled'] = array( |
581
|
|
|
'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ), |
582
|
|
|
'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ), |
583
|
|
|
'type' => 'checkbox', |
584
|
|
|
'default' => true, |
585
|
|
|
'section' => 'woocommerce-settings' |
586
|
|
|
); |
587
|
|
|
|
588
|
|
|
$fields['course_archive_free_enable'] = array( |
589
|
|
|
'name' => __( 'Free Courses Panel', 'woothemes-sensei' ), |
590
|
|
|
'description' => __( 'Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
591
|
|
|
'type' => 'checkbox', |
592
|
|
|
'default' => true, |
593
|
|
|
'section' => 'woocommerce-settings' |
594
|
|
|
); |
595
|
|
|
|
596
|
|
|
$fields['course_archive_paid_enable'] = array( |
597
|
|
|
'name' => __( 'Paid Courses Panel', 'woothemes-sensei' ), |
598
|
|
|
'description' => __( 'Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
599
|
|
|
'type' => 'checkbox', |
600
|
|
|
'default' => true, |
601
|
|
|
'section' => 'woocommerce-settings' |
602
|
|
|
); |
603
|
|
|
|
604
|
|
|
} // End If Statement |
605
|
|
|
|
606
|
|
|
if ( 'en_US' !== get_locale() ) { |
607
|
|
|
$fields['install_language_pack'] = array( |
608
|
|
|
'name' => __( 'Install Language Pack', 'woothemes-sensei' ), |
609
|
|
|
'description' => __( 'Use this action to install or re-install translation for your language if available.', 'woothemes-sensei' ), |
610
|
|
|
'type' => 'button', |
611
|
|
|
'section' => 'language-settings', |
612
|
|
|
'target' => Sensei_Language_Pack_Manager::get_install_uri(), |
613
|
|
|
'label' => __( 'Install', 'woothemes-sensei' ) |
614
|
|
|
); |
615
|
|
|
} |
616
|
|
|
|
617
|
|
|
$this->fields = apply_filters( 'sensei_settings_fields', $fields ); |
618
|
|
|
|
619
|
|
|
} // End init_fields() |
620
|
|
|
|
621
|
|
|
/** |
622
|
|
|
* Get options for the duration fields. |
623
|
|
|
* @since 1.0.0 |
624
|
|
|
* @param $include_milliseconds (default: true) Whether or not to include milliseconds between 0 and 1. |
625
|
|
|
* @return array Options between 0.1 and 10 seconds. |
626
|
|
|
*/ |
627
|
|
|
private function get_duration_options ( $include_milliseconds = true ) { |
628
|
|
|
$numbers = array( '1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0' ); |
629
|
|
|
$options = array(); |
630
|
|
|
|
631
|
|
|
if ( true == (bool)$include_milliseconds ) { |
|
|
|
|
632
|
|
|
$milliseconds = array( '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9' ); |
633
|
|
|
foreach ( $milliseconds as $k => $v ) { |
634
|
|
|
$options[$v] = $v; |
635
|
|
|
} |
636
|
|
|
} else { |
637
|
|
|
$options['0.5'] = '0.5'; |
638
|
|
|
} |
639
|
|
|
|
640
|
|
|
foreach ( $numbers as $k => $v ) { |
641
|
|
|
$options[$v] = $v; |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
return $options; |
645
|
|
|
} // End get_duration_options() |
646
|
|
|
|
647
|
|
|
/** |
648
|
|
|
* Return an array of pages. |
649
|
|
|
* @access private |
650
|
|
|
* @since 1.0.0 |
651
|
|
|
* @return array |
652
|
|
|
*/ |
653
|
|
|
private function pages_array() { |
654
|
|
|
// REFACTOR - Transform this into a field type instead. |
655
|
|
|
// Setup an array of portfolio gallery terms for a dropdown. |
656
|
|
|
$args = array( 'echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC' ); |
657
|
|
|
$pages_dropdown = wp_dropdown_pages( $args ); |
658
|
|
|
$page_items = array(); |
659
|
|
|
|
660
|
|
|
// Quick string hack to make sure we get the pages with the indents. |
661
|
|
|
$pages_dropdown = str_replace( "<select class='' name='page_id' id='page_id'>", '', $pages_dropdown ); |
662
|
|
|
$pages_dropdown = str_replace( '</select>', '', $pages_dropdown ); |
663
|
|
|
$pages_split = explode( '</option>', $pages_dropdown ); |
664
|
|
|
|
665
|
|
|
$page_items[] = __( 'Select a Page:', 'woothemes-sensei' ); |
666
|
|
|
|
667
|
|
|
foreach ( $pages_split as $k => $v ) { |
668
|
|
|
$id = ''; |
|
|
|
|
669
|
|
|
// Get the ID value. |
670
|
|
|
preg_match( '/value="(.*?)"/i', $v, $matches ); |
671
|
|
|
|
672
|
|
|
if ( isset( $matches[1] ) ) { |
673
|
|
|
$id = $matches[1]; |
674
|
|
|
$page_items[$id] = trim( strip_tags( $v ) ); |
675
|
|
|
} // End If Statement |
676
|
|
|
} // End For Loop |
677
|
|
|
|
678
|
|
|
$pages_array = $page_items; |
679
|
|
|
|
680
|
|
|
return $pages_array; |
681
|
|
|
} // End pages_array() |
682
|
|
|
|
683
|
|
|
/** |
684
|
|
|
* Language packs notices. |
685
|
|
|
* |
686
|
|
|
* @since 1.9.0 |
687
|
|
|
*/ |
688
|
|
|
public function language_pack_notices() { |
689
|
|
|
Sensei_Language_Pack_Manager::messages(); |
690
|
|
|
} |
691
|
|
|
|
692
|
|
|
/** |
693
|
|
|
* Flush the rewrite rules after the settings have been updated. |
694
|
|
|
* This is to ensure that the |
695
|
|
|
* |
696
|
|
|
* @since 1.9.0 |
697
|
|
|
*/ |
698
|
|
|
public static function flush_rewrite_rules(){ |
699
|
|
|
|
700
|
|
|
if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ] |
701
|
|
|
&& isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) { |
702
|
|
|
|
703
|
|
|
Sensei()->initiate_rewrite_rules_flush(); |
704
|
|
|
|
705
|
|
|
} |
706
|
|
|
|
707
|
|
|
}//end flush_cache |
708
|
|
|
} // End Class |
709
|
|
|
|
710
|
|
|
/** |
711
|
|
|
* Class WooThemes_Sensei_Settings |
712
|
|
|
* @ignore only for backward compatibility |
713
|
|
|
* @since 1.9.0 |
714
|
|
|
*/ |
715
|
|
|
class WooThemes_Sensei_Settings extends Sensei_Settings{} |
716
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: