-
Notifications
You must be signed in to change notification settings - Fork 1
/
wpsstm-settings.php
846 lines (667 loc) · 26 KB
/
wpsstm-settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
<?php
class WPSSTM_Settings {
static $menu_slug = 'wpsstm';
var $menu_page;
function __construct() {
add_action( 'admin_menu', array( $this, 'create_admin_menu' ), 8 );
add_action( 'admin_init', array( $this, 'settings_init' ), 5 );
add_action( 'admin_init', array( $this, 'system_settings_init' ), 15 );
}
function create_admin_menu(){
//http://wordpress.stackexchange.com/questions/236896/remove-or-move-admin-submenus-under-a-new-menu/236897#236897
/////Create our custom menu
$menu_page = add_menu_page(
__( 'Music', 'wpsstm' ), //page title
__( 'Music', 'wpsstm' ), //menu title
'manage_options', //capability
self::$menu_slug,
array($this,'settings_page'), //this function will output the content of the 'Music' page.
'dashicons-album', // an image would be 'plugins_url( 'myplugin/images/icon.png' )'; but for core icons, see https://developer.wordpress.org/resource/dashicons
6
);
//create a submenu page that has the same slug so we don't have the menu title name for the first submenu page, see http://wordpress.stackexchange.com/questions/66498/add-menu-page-with-different-name-for-first-submenu-item
add_submenu_page(
self::$menu_slug,
__( 'WP SoundSystem Settings', 'wpsstm' ),
__( 'Settings' ),
'manage_options',
self::$menu_slug, // same slug than the menu page
array($this,'settings_page') // same output function too
);
//custom hook to add submenu pages.
do_action('wpsstm_register_submenus',self::$menu_slug);
}
static function is_settings_reset(){
return wpsstm_get_array_value(array('wpsstm_options','reset_options'),$_POST);
}
function settings_sanitize( $input ){
$new_input = array();
/*
Maintenance
*/
self::clear_premium_transients();
//reset
if ( self::is_settings_reset() ) return;
//orphan tracks
if ( wpsstm_get_array_value(array('wpsstm_options','batch_delete_orphan_tracks'),$_POST) ){
WPSSTM_Core_Tracks::batch_delete_orphan_tracks();
}
//orphan links
if ( wpsstm_get_array_value(array('wpsstm_options','batch_delete_orphan_links'),$_POST) ){
WPSSTM_Core_Track_Links::batch_delete_orphan_links();
}
//excluded host links
if ( wpsstm_get_array_value(array('wpsstm_options','batch_delete_excluded_hosts_links'),$_POST) ){
WPSSTM_Core_Track_Links::batch_delete_excluded_hosts_links();
}
//unused terms
if ( wpsstm_get_array_value(array('wpsstm_options','batch_delete_unused_music_terms'),$_POST) ){
WP_SoundSystem::batch_delete_unused_music_terms();
}
//autolink
if ( wpsstm_get_array_value(array('wpsstm_options','batch_delete_autolink_time'),$_POST) ){
WP_SoundSystem::batch_delete_autolink_time();
}
/*
Bot user
*/
//user id
if ( isset ($input['bot_user_id']) && ctype_digit($input['bot_user_id']) ){
$new_input['bot_user_id'] = $input['bot_user_id'];
}
/*
Player
*/
$new_input['player_enabled'] = isset($input['player_enabled']);
/*
Tracklists
*/
$new_input['playlists_manager'] = isset($input['playlists_manager']);
/*
Track Links
*/
$new_input['autolink'] = isset($input['autolink']);
if ( isset($input['excluded_track_link_hosts']) ){
$domains = explode(',',$input['excluded_track_link_hosts']);
$domains = array_filter(array_unique($domains));
$new_input['excluded_track_link_hosts'] = $domains;
//rebuild cache ?
if ( $domains != wpsstm()->get_options('excluded_track_link_hosts') ){
WPSSTM_Core_Track_Links::rebuild_excluded_hosts_cache();
}
}
/*
Importer
*/
//post ID
if ( isset ($input['importer_page_id']) && ctype_digit($input['importer_page_id']) ){
if ( get_post_type($input['importer_page_id'] ) ){ //check page exists
$new_input['importer_page_id'] = $input['importer_page_id'];
}
}
/*
Now Playing
*/
//post ID
if ( isset ($input['nowplaying_id']) && get_post_type($input['nowplaying_id']) ){
if ( get_post_type($input['nowplaying_id'] ) ){ //check page exists
$new_input['nowplaying_id'] = $input['nowplaying_id'];
}
}
//delay
if ( isset ($input['play_history_timeout']) && ctype_digit($input['play_history_timeout']) ){
$new_input['play_history_timeout'] = $input['play_history_timeout'] * HOUR_IN_SECONDS;
}
/*
Sitewide favorites
*/
//post ID
if ( isset ($input['sitewide_favorites_id']) && get_post_type($input['sitewide_favorites_id']) ){
if ( get_post_type($input['sitewide_favorites_id'] ) ){ //check page exists
$new_input['sitewide_favorites_id'] = $input['sitewide_favorites_id'];
}
}
/*
WPSSTM API
*/
$old_token = wpsstm()->get_options('wpsstmapi_key');
$new_input['wpsstmapi_key'] = trim( wpsstm_get_array_value('wpsstmapi_key',$input) );
$new_input['details_engines'] = (array)$input['details_engines'];
return $new_input;
}
public static function clear_premium_transients(){
WP_SoundSystem::debug_log('deleted premium transients...');
delete_transient( WPSSTM_Core_Importer::$importers_transient_name );
delete_transient( WPSSTM_Core_API::$token_transient_name );
delete_transient( WPSSTM_Core_API::$premium_userdata_transient_name );
}
function settings_init(){
register_setting(
'wpsstm_option_group', // Option group
wpsstm()->meta_name_options, // Option name
array( $this, 'settings_sanitize' ) // Sanitize
);
/*
WPSSTM API
*/
add_settings_section(
'wpsstmapi_settings', // ID
'WP SoundSystem API', // Title
array( $this, 'section_desc_empty' ), // Callback
'wpsstm-settings-page' // Page
);
add_settings_field(
'wpsstmapi_key',
__('API Key','wpsstm'),
array( $this, 'wpsstmapi_apitoken_callback' ),
'wpsstm-settings-page',
'wpsstmapi_settings'
);
add_settings_field(
'wpsstmapi_premium',
__('Membership','wpsstm'),
array( $this, 'wpsstmapi_apipremium_callback' ),
'wpsstm-settings-page',
'wpsstmapi_settings'
);
add_settings_field(
'details_engines',
__('Music Details','wpsstm'),
array( $this, 'details_engines_callback' ),
'wpsstm-settings-page',
'wpsstmapi_settings'
);
/*
Bot user
*/
add_settings_section(
'bot_user_settings', // ID
__('Import bot user','wpsstm'), // Title
array( $this, 'section_bot_user_desc' ), // Callback
'wpsstm-settings-page' // Page
);
add_settings_field(
'bot_user_id',
__('User ID','wpsstm'),
array( $this, 'bot_user_id_callback' ),
'wpsstm-settings-page',
'bot_user_settings'
);
/*
Importer page
*/
add_settings_section(
'tracklist_importer', // ID
__('Import page','wpsstm'), // Title
array( $this, 'section_importer_page_desc' ), // Callback
'wpsstm-settings-page' // Page
);
add_settings_field(
'importer_page_id',
__('Page ID','wpsstm'),
array( $this, 'importer_page_callback' ),
'wpsstm-settings-page',
'tracklist_importer'
);
/*
Now Playing
*/
add_settings_section(
'now_playing', // ID
__("Now playing",'wpsstm'), // Title
array( $this, 'now_playing_desc' ), // Callback
'wpsstm-settings-page' // Page
);
add_settings_field(
'now_playing_id',
__('Playlist ID','wpsstm'),
array( $this, 'now_playing_callback' ),
'wpsstm-settings-page',
'now_playing'
);
add_settings_field(
'now_playing_delay',
__('Delay','wpsstm'),
array( $this, 'now_playing_delay_callback' ),
'wpsstm-settings-page',
'now_playing'
);
/*
Sitewide favorites
*/
add_settings_section(
'sitewide_favorites', // ID
__("Sitewide favorites",'wpsstm'), // Title
array( $this, 'sitewide_favorites_desc' ), // Callback
'wpsstm-settings-page' // Page
);
add_settings_field(
'sitewide_favorites_id',
__('Playlist ID','wpsstm'),
array( $this, 'sitewide_favorites_callback' ),
'wpsstm-settings-page',
'sitewide_favorites'
);
/*
Player
*/
add_settings_section(
'player_settings', // ID
__('Player','wpsstm'), // Title
array( $this, 'section_desc_empty' ), // Callback
'wpsstm-settings-page' // Page
);
add_settings_field(
'player_enabled',
__('Enabled','wpsstm'),
array( $this, 'player_enabled_callback' ),
'wpsstm-settings-page',
'player_settings'
);
/*
Radios
*/
/*
add_settings_section(
'radio_settings', // ID
__('Radios','wpsstm'), // Title
array( $this, 'section_radios_desc' ), // Callback
'wpsstm-settings-page' // Page
);
*/
/*
Tracks
*/
add_settings_section(
'track_settings', // ID
__('Tracks','wpsstm'), // Title
array( $this, 'section_desc_empty' ), // Callback
'wpsstm-settings-page' // Page
);
add_settings_field(
'playlists_manager',
__('Enable Playlists Manager','wpsstm'),
array( $this, 'playlists_manager_callback' ),
'wpsstm-settings-page',
'track_settings'
);
/*
Track links
*/
add_settings_section(
'track_link_settings', // ID
__('Track Links','wpsstm'), // Title
array( $this, 'section_desc_empty' ), // Callback
'wpsstm-settings-page' // Page
);
add_settings_field(
'autolink',
__('Autolink','wpsstm'),
array( $this, 'autolink_callback' ),
'wpsstm-settings-page',
'track_link_settings'
);
add_settings_field(
'excluded_track_link_hosts',
__('Exclude hosts','wpsstm'),
array( $this, 'exclude_hosts_callback' ),
'wpsstm-settings-page',
'track_link_settings'
);
}
function system_settings_init(){
add_settings_section(
'settings_maintenance', // ID
__('Maintenance','wpsstm'), // Title
array( $this, 'section_maintenance_desc' ), // Callback
'wpsstm-settings-page' // Page
);
add_settings_field(
'reset_options',
__('Reset Options','wpsstm'),
array( $this, 'reset_options_callback' ),
'wpsstm-settings-page', // Page
'settings_maintenance'//section
);
add_settings_field(
'batch_delete_orphan_tracks',
__('Delete orphan tracks','wpsstm'),
array( $this, 'batch_delete_orphan_tracks_callback' ),
'wpsstm-settings-page', // Page
'settings_maintenance'//section
);
add_settings_field(
'batch_delete_orphan_links',
__('Delete orphan links','wpsstm'),
array( $this, 'batch_delete_orphan_links_callback' ),
'wpsstm-settings-page', // Page
'settings_maintenance'//section
);
add_settings_field(
'batch_delete_excluded_hosts_links',
__('Delete excluded hosts links','wpsstm'),
array( $this, 'batch_delete_excluded_hosts_links_callback' ),
'wpsstm-settings-page', // Page
'settings_maintenance'//section
);
add_settings_field(
'batch_delete_unused_music_terms',
__('Delete unused music terms','wpsstm'),
array( $this, 'batch_delete_unused_music_terms_callback' ),
'wpsstm-settings-page', // Page
'settings_maintenance'//section
);
if ( wpsstm()->get_options('autolink_timeout') ){
add_settings_field(
'batch_delete_autolink_time',
__('Delete autolink timelock','wpsstm'),
array( $this, 'batch_delete_autolink_time_callback' ),
'wpsstm-settings-page', // Page
'settings_maintenance'//section
);
}
}
public static function section_desc_empty(){
}
public static function section_maintenance_desc(){
_e('Please make a backup of your database before doing maintenance.','wpsstm');
}
function player_enabled_callback(){
$option = wpsstm()->get_options('player_enabled');
$desc = '';
printf(
'<input type="checkbox" name="%s[player_enabled]" value="on" %s /> %s',
wpsstm()->meta_name_options,
checked( $option,true, false ),
$desc
);
}
function autolink_callback(){
if ( $enabled = wpsstm()->get_options('autolink') ){
$can_autolink = WPSSTM_Core_Track_Links::can_autolink();
if ( is_wp_error($can_autolink) ){
add_settings_error('autolink',$can_autolink->get_error_code(),$can_autolink->get_error_message(),'inline');
}
}
/*
form
*/
printf(
'<input type="checkbox" name="%s[autolink]" value="on" %s /> %s',
wpsstm()->meta_name_options,
checked( $enabled, true, false ),
__("Try to get track links (stream URLs, ...) automatically if none have been set.","wpsstm")
);
//display errors
settings_errors('autolink');
}
function playlists_manager_callback(){
global $wp_roles;
$enabled = wpsstm()->get_options('playlists_manager');
$matching_roles = array();
$post_type_obj = get_post_type_object(wpsstm()->post_type_playlist);
$required_cap = $post_type_obj->cap->edit_posts;
$help = array();
$help[]= __("If enabled, you have to give your users the capability to create new playlists.","wpsstm");
foreach($wp_roles->roles as $role_arr){
if ( wpsstm_get_array_value(array('capabilities',$required_cap),$role_arr) ){
$matching_roles[] = $role_arr['name'];
}
}
if ($matching_roles){
$help[]= sprintf(__("Those roles have the required capability: %s.","wpsstm"),'<em>' . implode(',',$matching_roles) . '</em>');
}else{
$help[]= __("Currently, no roles have this capability.","wpsstm");
}
printf(
'<input type="checkbox" name="%s[playlists_manager]" value="on" %s /><label>%s</label><br/><small>%s</small>',
wpsstm()->meta_name_options,
checked( $enabled, true, false ),
__("Users can favorite tracks and queue them to custom playlists.","wpsstm"),
implode(' ',$help)
);
}
function exclude_hosts_callback(){
$excluded_hosts = wpsstm()->get_options('excluded_track_link_hosts');
printf(
'<p><label>%s</label><input type="text" name="%s[excluded_track_link_hosts]" class="wpsstm-fullwidth" placeholder="%s" value="%s" /></p>',
__("Ignore the track links belonging to those hosts (comma-separated):","wpsstm"),
wpsstm()->meta_name_options,
__('eg. yandex.ru,itunes.apple.com','wpsstm'),
implode(',',$excluded_hosts)
);
}
function section_bot_user_desc(){
$desc = array();
$desc[]= __("Importing data requires a bot user with specific capabitilies.","wpsstm");
$faq_url = 'https://github.com/gordielachance/wp-soundsystem/wiki/Frequently-Asked-Questions';
$plugin_link = sprintf('<a href="%s" target="_blank">%s</a>',$faq_url,__('FAQ','wpsstm'));
$desc[] = sprintf( __("See the plugin's %s for more information.","wpsstm"), $plugin_link );
echo implode(" ",$desc);
}
function details_engines_callback(){
$enabled_services = wpsstm()->get_options('details_engines');
$available_engines = wpsstm()->get_available_detail_engines();
foreach((array)$available_engines as $engine){
$is_checked = in_array($engine->slug,$enabled_services);
printf(
'<input type="checkbox" name="%s[details_engines][]" value="%s" %s /> <label>%s</label> ',
wpsstm()->meta_name_options,
$engine->slug,
checked($is_checked,true, false ),
$engine->name
);
}
}
function wpsstmapi_apitoken_callback(){
//client secret
$client_secret = wpsstm()->get_options('wpsstmapi_key');
$valid_token = WPSSTM_Core_API::get_token();
printf(
'<p><input type="text" name="%s[wpsstmapi_key]" value="%s" class="wpsstm-fullwidth" /></p>',
wpsstm()->meta_name_options,
$client_secret
);
//display errors
settings_errors('api_token');
}
function wpsstmapi_apipremium_callback(){
if ( !WPSSTM_Core_API::is_premium() ){
//check for errors
$token = WPSSTM_Core_API::get_token();
if ( is_wp_error($token) ){
add_settings_error('api_premium',$token->get_error_code(),$token->get_error_message(),'inline');
}
$link = sprintf('<a href="%s" target="_blank">%s</a>',WPSSTM_API_REGISTER_URL,__('Get premium','wpsstm'));
$desc = sprintf(__('%s and unlock powerful features : Tracklists Importer, Tracks Autolink... First and foremost, it is a nice way to support this plugin, and to ensure its durability. Thanks for your help!','wppstm'),$link);
add_settings_error('api_premium','api_get_premium',$desc,'inline');
}
//user datas
$membership = WPSSTM_Core_API::get_api_userdatas();
if ( !is_wp_error($membership) ){
unset($membership['is_premium']);
foreach($membership as $key=>$data){
switch($key){
case 'activated_at':
case 'last_request_at':
case 'expires_at':
$data = date( 'Y-m-d H:i:s', strtotime($data) );
$date = get_date_from_gmt($data , get_option( 'date_format' ) );
$time = get_date_from_gmt($data , get_option( 'time_format' ) );
$data = sprintf('%s @ %s',$date,$time);
}
printf('<span><strong>%s:</strong> %s</span> ',$key,$data);
}
}
/*
errors
*/
//display errors
settings_errors('api_premium');
}
function section_importer_page_desc(){
_e('Page used as placeholder to import tracklists frontend.','wppstm');
}
function now_playing_desc(){
_e('Playlist displaying the last tracks played.','wppstm');
}
function sitewide_favorites_desc(){
_e('Playlist displaying the last favorited tracks among members.','wppstm');
}
function section_radios_desc(){
$desc[] = __('Radios are how we call live playlists. Those are automatically synced with remote datas, like a web page or a Spotify playlist.','wppstm');
//wrap
$desc = array_map(
function ($el) {
return "<p>{$el}</p>";
},
$desc
);
echo implode("\n",$desc);
}
function importer_page_callback(){
$page_id = wpsstm()->get_options('importer_page_id');
printf(
'<input type="number" name="%s[importer_page_id]" size="4" min="0" value="%s"/>',
wpsstm()->meta_name_options,
$page_id
);
if ( get_post_type($page_id) ){
$page_title = get_the_title( $page_id );
$edit_url = get_edit_post_link($page_id);
$link_txt = sprintf(__('Edit %s','wpsstm'),'<em>' . $page_title . '</em>');
printf(' <a href="%s">%s</a>',$edit_url,$link_txt);
}
}
function now_playing_callback(){
$page_id = wpsstm()->get_options('nowplaying_id');
printf(
'<input type="number" name="%s[nowplaying_id]" value="%s"/>',
wpsstm()->meta_name_options,
$page_id
);
if ( get_post_type($page_id) ){
$page_title = get_the_title( $page_id );
$edit_url = get_edit_post_link($page_id);
$link_txt = sprintf(__('Edit %s','wpsstm'),'<em>' . $page_title . '</em>');
printf(' <a href="%s">%s</a>',$edit_url,$link_txt);
}
}
function now_playing_delay_callback(){
$delay = wpsstm()->get_options('play_history_timeout');
printf(
'<input type="number" name="%s[play_history_timeout]" value="%s"/>',
wpsstm()->meta_name_options,
$delay / HOUR_IN_SECONDS
);
_e('Hours a track remains in the playlist','wpsstm');
}
function sitewide_favorites_callback(){
$page_id = wpsstm()->get_options('sitewide_favorites_id');
printf(
'<input type="number" name="%s[sitewide_favorites_id]" value="%s"/>',
wpsstm()->meta_name_options,
$page_id
);
if ( get_post_type($page_id) ){
$page_title = get_the_title( $page_id );
$edit_url = get_edit_post_link($page_id);
$link_txt = sprintf(__('Edit %s','wpsstm'),'<em>' . $page_title . '</em>');
printf(' <a href="%s">%s</a>',$edit_url,$link_txt);
}
}
function bot_user_id_callback(){
$bot_id = wpsstm()->get_options('bot_user_id');
$bot_ready = wpsstm()->is_bot_ready();
if ( is_wp_error($bot_ready) ){
add_settings_error('bot_user',$bot_ready->get_error_code(),$bot_ready->get_error_message(),'inline');
}
/*
form
*/
printf(
'<input type="number" name="%s[bot_user_id]" size="4" min="0" value="%s" />',
wpsstm()->meta_name_options,
$bot_id
);
if ( $bot_id = wpsstm()->get_options('bot_user_id') ){
$userdata = get_userdata( $bot_id );
$edit_url = get_edit_user_link($bot_id);
$link_txt = sprintf(__('Edit %s','wpsstm'),'<em>' . $userdata->user_login . '</em>');
printf(' <a href="%s">%s</a>',$edit_url,$link_txt);
}
/*
errors
*/
settings_errors('bot_user');
}
/*
System
*/
function reset_options_callback(){
printf(
'<input type="checkbox" name="%s[reset_options]" value="on"/><label>%s</label>',
wpsstm()->meta_name_options,
__("Reset options to their default values.","wpsstm")
);
}
function batch_delete_orphan_tracks_callback(){
printf(
'<input type="checkbox" name="%s[batch_delete_orphan_tracks]" value="on"/><label>%s</label>',
wpsstm()->meta_name_options,
__("Batch delete orphan tracks.","wpsstm")
);
}
function batch_delete_orphan_links_callback(){
printf(
'<input type="checkbox" name="%s[batch_delete_orphan_links]" value="on"/><label>%s</label>',
wpsstm()->meta_name_options,
__("Batch delete orphan links.","wpsstm")
);
}
function batch_delete_excluded_hosts_links_callback(){
printf(
'<input type="checkbox" name="%s[batch_delete_excluded_hosts_links]" value="on"/><label>%s</label>',
wpsstm()->meta_name_options,
__("Batch delete excluded hosts tracks links.","wpsstm")
);
}
function batch_delete_unused_music_terms_callback(){
printf(
'<input type="checkbox" name="%s[batch_delete_unused_music_terms]" value="on"/><label>%s</label>',
wpsstm()->meta_name_options,
__("Batch delete unused music terms.","wpsstm")
);
}
function batch_delete_autolink_time_callback(){
$hours = floor(wpsstm()->get_options('autolink_timeout') / 60 / 60);
printf(
'<input type="checkbox" name="%s[batch_delete_autolink_time]" value="on"/><label>%s</label>',
wpsstm()->meta_name_options,
sprintf(__("Batch delete the time tracks were autosourced - so sources will be queried again without waiting the %s hours delay.","wpsstm"),$hours)
);
}
function settings_page() {
?>
<div class="wrap">
<h2><?php _e('WP SoundSystem Settings','wpsstm');?></h2>
<?php
if( isset($_GET['settings-updated']) ) {
$notice = __('Settings have been saved; and API data has been reloaded.','wpsstm');
printf('<div class="notice inline"><p>%s</p></div>',$notice);
}
settings_errors('wpsstm_option_group');
?>
<form method="post" action="options.php">
<?php
// This prints out all hidden setting fields
settings_fields( 'wpsstm_option_group' );
do_settings_sections( 'wpsstm-settings-page' );
submit_button();
?>
</form>
</div>
<?php
}
}
new WPSSTM_Settings;