-
Notifications
You must be signed in to change notification settings - Fork 0
/
em-install.php
1798 lines (1734 loc) · 93.5 KB
/
em-install.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
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
function em_install() {
global $wp_rewrite;
switch_to_locale(EM_ML::$wplang); //switch to blog language (if applicable)
$wp_rewrite->flush_rules();
$old_version = get_option('dbem_version');
//Won't upgrade <4.300 anymore
if( $old_version != '' && $old_version < 4.1 ){
function em_update_required_notification(){
global $EM_Booking;
?><div class="error"><p><strong>Events Manager upgrade not complete, please upgrade to the version 4.300 or higher first from <a href="http://wordpress.org/extend/plugins/events-manager/download/">here</a> before upgrading to this version.</strong></p></div><?php
}
add_action ( 'admin_notices', 'em_update_required_notification' );
return;
}
if( EM_VERSION > $old_version || $old_version == '' || (is_multisite() && !EM_MS_GLOBAL && get_option('em_ms_global_install')) ){
if( get_option('dbem_upgrade_throttle') <= time() || !get_option('dbem_upgrade_throttle') ){
// Creates the events table if necessary
if( !EM_MS_GLOBAL || (EM_MS_GLOBAL && is_main_site()) ){
em_create_events_table();
em_create_events_meta_table();
em_create_locations_table();
em_create_bookings_table();
em_create_tickets_table();
em_create_tickets_bookings_table();
em_create_costumes_table(); // GGG
delete_option('em_ms_global_install'); //in case for some reason the user changed global settings
add_action('em_ml_init', 'EM_ML::toggle_languages_index');
}else{
update_option('em_ms_global_install',1); //in case for some reason the user changes global settings in the future
}
//New install, or Migrate?
if( $old_version < 5 && !empty($old_version) ){
update_option('dbem_upgrade_throttle', time()+300);
set_time_limit(300);
em_migrate_v4();
update_site_option('dbem_ms_update_nag',1);
}elseif( empty($old_version) ){
em_create_events_page();
update_option('dbem_hello_to_user',1);
}
//set caps and options
em_set_capabilities();
em_add_options();
em_upgrade_current_installation();
do_action('events_manager_updated', $old_version );
//Update Version
update_option('dbem_version', EM_VERSION);
delete_option('dbem_upgrade_throttle');
delete_option('dbem_upgrade_throttle_time');
//last but not least, flush the toilet
global $wp_rewrite;
$wp_rewrite->flush_rules();
update_option('dbem_flush_needed',1);
}else{
function em_upgrading_in_progress_notification(){
global $EM_Booking;
?><div class="error"><p>Events Manager upgrade still in progress. Please be patient, this message should disappear once the upgrade is complete.</p></div><?php
}
add_action ( 'admin_notices', 'em_upgrading_in_progress_notification' );
add_action ( 'network_admin_notices', 'em_upgrading_in_progress_notification' );
return;
}
}
restore_previous_locale(); //now that we're done, switch back to current language (if applicable)
}
/**
* Magic function that takes a table name and cleans all non-unique keys not present in the $clean_keys array. if no array is supplied, all but the primary key is removed.
* @param string $table_name
* @param array $clean_keys
*/
function em_sort_out_table_nu_keys($table_name, $clean_keys = array()){
global $wpdb;
//sort out the keys
$new_keys = $clean_keys;
$table_key_changes = array();
$table_keys = $wpdb->get_results("SHOW KEYS FROM $table_name WHERE Key_name != 'PRIMARY'", ARRAY_A);
foreach($table_keys as $table_key_row){
if( !in_array($table_key_row['Key_name'], $clean_keys) ){
$table_key_changes[] = "ALTER TABLE $table_name DROP INDEX ".$table_key_row['Key_name'];
}elseif( in_array($table_key_row['Key_name'], $clean_keys) ){
foreach($clean_keys as $key => $clean_key){
if($table_key_row['Key_name'] == $clean_key){
unset($new_keys[$key]);
}
}
}
}
//delete duplicates
foreach($table_key_changes as $sql){
$wpdb->query($sql);
}
//add new keys
foreach($new_keys as $key){
if( preg_match('/\(/', $key) ){
$wpdb->query("ALTER TABLE $table_name ADD INDEX $key");
}else{
$wpdb->query("ALTER TABLE $table_name ADD INDEX ($key)");
}
}
}
/**
* Since WP 4.2 tables are created with utf8mb4 collation. This creates problems when storing content in previous utf8 tables such as when using emojis.
* This function checks whether the table in WP was changed
* @return boolean
*/
function em_check_utf8mb4_tables(){
global $wpdb, $em_check_utf8mb4_tables;
if( $em_check_utf8mb4_tables || $em_check_utf8mb4_tables === false ) return $em_check_utf8mb4_tables;
$column = $wpdb->get_row( "SHOW FULL COLUMNS FROM {$wpdb->posts} WHERE Field='post_content';" );
if ( ! $column ) {
return false;
}
//if this doesn't become true further down, that means we couldn't find a correctly converted utf8mb4 posts table
$em_check_utf8mb4_tables = false;
if ( $column->Collation ) {
list( $charset ) = explode( '_', $column->Collation );
$em_check_utf8mb4_tables = ( 'utf8mb4' === strtolower( $charset ) );
}
return $em_check_utf8mb4_tables;
}
function em_create_events_table() {
global $wpdb;
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
$table_name = $wpdb->prefix.'em_events';
$sql = "CREATE TABLE ".$table_name." (
event_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
post_id bigint(20) unsigned NOT NULL,
event_parent bigint(20) unsigned NULL DEFAULT NULL,
event_slug VARCHAR( 200 ) NULL DEFAULT NULL,
event_owner bigint(20) unsigned DEFAULT NULL,
event_status tinyint(1) NULL DEFAULT NULL,
event_name text NULL DEFAULT NULL,
event_start_date date NULL DEFAULT NULL,
event_end_date date NULL DEFAULT NULL,
event_start_time time NULL DEFAULT NULL,
event_end_time time NULL DEFAULT NULL,
event_all_day tinyint(1) unsigned NULL DEFAULT NULL,
event_start datetime NULL DEFAULT NULL,
event_end datetime NULL DEFAULT NULL,
event_timezone tinytext NULL DEFAULT NULL,
post_content longtext NULL DEFAULT NULL,
event_rsvp tinyint(1) unsigned NOT NULL DEFAULT 0,
event_rsvp_date date NULL DEFAULT NULL,
event_rsvp_time time NULL DEFAULT NULL,
event_rsvp_spaces int(5) NULL DEFAULT NULL,
event_spaces int(5) NULL DEFAULT 0,
event_private tinyint(1) unsigned NOT NULL DEFAULT 0,
location_id bigint(20) unsigned NULL DEFAULT NULL,
event_location_type VARCHAR(15) NULL DEFAULT NULL,
recurrence_id bigint(20) unsigned NULL DEFAULT NULL,
event_date_created datetime NULL DEFAULT NULL,
event_date_modified datetime NULL DEFAULT NULL,
recurrence tinyint(1) unsigned NOT NULL DEFAULT 0,
recurrence_interval int(4) NULL DEFAULT NULL,
recurrence_freq tinytext NULL DEFAULT NULL,
recurrence_byday tinytext NULL DEFAULT NULL,
recurrence_byweekno int(4) NULL DEFAULT NULL,
recurrence_days int(4) NULL DEFAULT NULL,
recurrence_rsvp_days int(3) NULL DEFAULT NULL,
blog_id bigint(20) unsigned NULL DEFAULT NULL,
group_id bigint(20) unsigned NULL DEFAULT NULL,
event_language varchar(14) NULL DEFAULT NULL,
event_translation tinyint(1) unsigned NOT NULL DEFAULT 0,
event_ec_rsvp_date date NULL DEFAULT NULL,
PRIMARY KEY (event_id)
) DEFAULT CHARSET=utf8 ;";
if( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name ){
dbDelta($sql);
}elseif( get_option('dbem_version') != '' ){
if( get_option('dbem_version') < 5.984 ){
// change the recurrence flag to a required field defaulting to 0, to avoid missing recurrences in EM_Events::get() due to wayward null values
$wpdb->query("UPDATE $table_name SET recurrence = 0 WHERE recurrence IS NULL");
$wpdb->query("ALTER TABLE $table_name CHANGE `recurrence` `recurrence` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0'");
$wpdb->query("ALTER TABLE $table_name CHANGE `event_status` `event_status` TINYINT(1) NULL DEFAULT NULL;");
}
// GGG
if( get_option('dbem_version') != '' && get_option('dbem_version') < 5.956 ){
// If updating from version < 5.956, add in the RSVP Date for ECs
$wpdb->query("ALTER TABLE $table_name ADD event_ec_rsvp_date date NULL DEFAULT NULL");
}
dbDelta($sql);
}
em_sort_out_table_nu_keys($table_name, array('event_status','post_id','blog_id','group_id','location_id','event_start', 'event_end', 'event_start_date', 'event_end_date'));
if( em_check_utf8mb4_tables() ) maybe_convert_table_to_utf8mb4( $table_name );
}
function em_create_events_meta_table(){
global $wpdb, $user_level;
$table_name = $wpdb->prefix.'em_meta';
// Creating the events table
$sql = "CREATE TABLE ".$table_name." (
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
object_id bigint(20) unsigned NOT NULL,
meta_key varchar(255) DEFAULT NULL,
meta_value longtext,
meta_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (meta_id)
) DEFAULT CHARSET=utf8 ";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
em_sort_out_table_nu_keys($table_name, array('object_id','meta_key'));
if( em_check_utf8mb4_tables() ) maybe_convert_table_to_utf8mb4( $table_name );
}
function em_create_locations_table() {
global $wpdb, $user_level;
$table_name = $wpdb->prefix.'em_locations';
// Creating the events table
$sql = "CREATE TABLE ".$table_name." (
location_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
post_id bigint(20) unsigned NOT NULL,
blog_id bigint(20) unsigned NULL DEFAULT NULL,
location_parent bigint(20) unsigned NULL DEFAULT NULL,
location_slug VARCHAR( 200 ) NULL DEFAULT NULL,
location_name text NULL DEFAULT NULL,
location_owner bigint(20) unsigned NOT NULL DEFAULT 0,
location_address VARCHAR( 200 ) NULL DEFAULT NULL,
location_town VARCHAR( 200 ) NULL DEFAULT NULL,
location_state VARCHAR( 200 ) NULL DEFAULT NULL,
location_postcode VARCHAR( 10 ) NULL DEFAULT NULL,
location_region VARCHAR( 200 ) NULL DEFAULT NULL,
location_country CHAR( 2 ) NULL DEFAULT NULL,
location_latitude DECIMAL( 9, 6 ) NULL DEFAULT NULL,
location_longitude DECIMAL( 9, 6 ) NULL DEFAULT NULL,
post_content longtext NULL DEFAULT NULL,
location_status int(1) NULL DEFAULT NULL,
location_private tinyint(1) unsigned NOT NULL DEFAULT 0,
location_language varchar(14) NULL DEFAULT NULL,
location_translation tinyint(1) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (location_id)
) DEFAULT CHARSET=utf8 ;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
if( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name ) {
dbDelta($sql);
/*
DEPRICATED - kept here as an example for how migrations from the wp_em_events table is fairly easy
//Add default values
$wpdb->query("INSERT INTO ".$table_name." (location_name, location_address, location_town, location_state, location_country, location_latitude, location_longitude, location_slug, location_owner, location_status, post_id) VALUES ('Arts Millenium Building', 'Newcastle Road','Galway','Galway','IE', 53.275, -9.06532, 'arts-millenium-building','".get_current_user_id()."', 1,0)");
$wpdb->query("INSERT INTO ".$table_name." (location_name, location_address, location_town, location_state, location_country, location_latitude, location_longitude, location_slug, location_owner, location_status, post_id) VALUES ('The Crane Bar', '2, Sea Road','Galway','Galway','IE', 53.2692, -9.06151, 'the-crane-bar','".get_current_user_id()."', 1, 0)");
$wpdb->query("INSERT INTO ".$table_name." (location_name, location_address, location_town, location_state, location_country, location_latitude, location_longitude, location_slug, location_owner, location_status, post_id) VALUES ('Taaffes Bar', '19 Shop Street','Galway','Galway','IE', 53.2725, -9.05321, 'taffes-bar','".get_current_user_id()."', 1, 0)");
em_migrate_locations($wpdb->get_results('SELECT * FROM '.$table_name, ARRAY_A));
*/
}else{
if( get_option('dbem_version') != '' && get_option('dbem_version') < 4.938 ){
$wpdb->query("ALTER TABLE $table_name CHANGE location_description post_content longtext NULL DEFAULT NULL");
}
dbDelta($sql);
if( get_option('dbem_version') != '' && get_option('dbem_version') < 4.93 ){
//if updating from version 4 (4.93 is beta v5) then set all statuses to 1 since it's new
$wpdb->query("UPDATE ".$table_name." SET location_status=1");
}
}
if( em_check_utf8mb4_tables() ){
maybe_convert_table_to_utf8mb4( $table_name );
em_sort_out_table_nu_keys($table_name, array('location_state (location_state(191))','location_region (location_region(191))','location_country','post_id','blog_id'));
}else{
em_sort_out_table_nu_keys($table_name, array('location_state','location_region','location_country','post_id','blog_id'));
}
}
function em_create_bookings_table() {
global $wpdb, $user_level;
$table_name = $wpdb->prefix.'em_bookings';
$sql = "CREATE TABLE ".$table_name." (
booking_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
event_id bigint(20) unsigned NULL,
person_id bigint(20) unsigned NOT NULL,
booking_spaces int(5) NOT NULL,
booking_comment text DEFAULT NULL,
booking_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
booking_status bool NOT NULL DEFAULT 1,
booking_price decimal(14,4) unsigned NOT NULL DEFAULT 0,
booking_tax_rate decimal(7,4) NULL DEFAULT NULL,
booking_taxes decimal(14,4) NULL DEFAULT NULL,
booking_meta LONGTEXT NULL,
PRIMARY KEY (booking_id)
) DEFAULT CHARSET=utf8 ;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
em_sort_out_table_nu_keys($table_name, array('event_id','person_id','booking_status'));
if( em_check_utf8mb4_tables() ) maybe_convert_table_to_utf8mb4( $table_name );
}
//Add the categories table
function em_create_tickets_table() {
global $wpdb, $user_level;
$table_name = $wpdb->prefix.'em_tickets';
// Creating the events table
$sql = "CREATE TABLE {$table_name} (
ticket_id BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT,
event_id BIGINT( 20 ) UNSIGNED NOT NULL ,
ticket_name TINYTEXT NOT NULL ,
ticket_description TEXT NULL ,
ticket_price DECIMAL( 14 , 4 ) NULL ,
ticket_start DATETIME NULL ,
ticket_end DATETIME NULL ,
ticket_min INT( 10 ) NULL ,
ticket_max INT( 10 ) NULL ,
ticket_spaces INT NULL ,
ticket_members INT( 1 ) NULL ,
ticket_members_roles LONGTEXT NULL,
ticket_guests INT( 1 ) NULL ,
ticket_required INT( 1 ) NULL ,
ticket_parent BIGINT( 20 ) UNSIGNED NULL,
ticket_order INT( 2 ) UNSIGNED NULL,
ticket_meta LONGTEXT NULL,
PRIMARY KEY (ticket_id)
) DEFAULT CHARSET=utf8 ;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
em_sort_out_table_nu_keys($table_name, array('event_id'));
if( em_check_utf8mb4_tables() ) maybe_convert_table_to_utf8mb4( $table_name );
}
//Add the categories table
function em_create_tickets_bookings_table() {
global $wpdb, $user_level;
$table_name = $wpdb->prefix.'em_tickets_bookings';
// Creating the events table
$sql = "CREATE TABLE {$table_name} (
ticket_booking_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
booking_id bigint(20) unsigned NOT NULL,
ticket_id bigint(20) unsigned NOT NULL,
ticket_booking_spaces int(6) NOT NULL,
ticket_booking_price decimal(14,4) NOT NULL,
PRIMARY KEY (ticket_booking_id)
) DEFAULT CHARSET=utf8 ;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
em_sort_out_table_nu_keys($table_name, array('booking_id','ticket_id'));
if( em_check_utf8mb4_tables() ) maybe_convert_table_to_utf8mb4( $table_name );
}
// GGG Create the default costume lists table() {
function em_create_costumes_table() {
global $wpdb, $user_level;
$table_name = $wpdb->prefix.'em_costumes';
// Creating the events table
$sql = "CREATE TABLE IF NOT EXISTS {$table_name} (
costume_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
costume_name TINYTEXT NOT NULL,
PRIMARY KEY (costume_id)
) DEFAULT CHARSET=utf8 ;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
em_sort_out_table_nu_keys($table_name, array('costume_id'));
if( em_check_utf8mb4_tables() ) maybe_convert_table_to_utf8mb4( $table_name );
$sql = 'SELECT * FROM '.$table_name.' LIMIT 5';
$existing_costumes = $wpdb->get_results($sql, ARRAY_A);
// Don't delete the costumes already in the table
if (count($existing_costumes) > 0) {
return;
}
// Otherwise, populate with a default set
$costumes = array(
"AR: ARC Trooper",
"BH - Bounty Hunter",
"CB: Kaskyyyk Trooper",
"CC: Clone Commander",
"CP: Clone Pilot",
"CT: RotS Clone Trooper",
"CX: Special Ops Clone Troopers",
"DS: Dark Side Adept",
"DZ: Denizen",
"DZ: Jawa",
"DZ: Gamorrean Guard",
"DZ: Narkina 5 Inmate",
"GM: Galactic Marine",
"IC: Imperial Crew",
"IC: Death Star Scientist",
"ID: Imperial Officer",
"IG: Imperial Gunner",
"IN: Imperial Navy",
"IS: AT-ST Driver",
"MW: Death Watch",
"MW: Bo-Katan",
"RC: Republic Commando",
"SL: Sith",
"ST: Shoretrooper",
"TA: AT-AT Driver",
"TA: Tank Driver",
"TB: Scout Trooper",
"TC: Clone Trooper",
"TD: Sandtrooper",
"TI: TIE Pilot",
"TI: TIE Reserve",
"TK: Stormtrooper",
"TR: Royal Guard",
"TS: Snowtrooper",
"TX: Special Operations",
"ZZZ: Other (please indicate in comments)"
);
$costumes = array_map(function ($c) use ($wpdb) {
return $wpdb->prepare("('%s')", $c);
}, $costumes);
if( count($costumes) > 0 ){
$result = $wpdb->query("TRUNCATE TABLE `".$table_name."`");
$result = $wpdb->query("INSERT INTO ".$table_name." (costume_name) VALUES ".implode(',',$costumes));
}
}
function em_add_options() {
global $wp_locale, $wpdb;
$decimal_point = !empty($wp_locale->number_format['decimal_point']) ? $wp_locale->number_format['decimal_point']:'.';
$thousands_sep = !empty($wp_locale->number_format['thousands_sep']) ? $wp_locale->number_format['thousands_sep']:',';
$email_footer = '<br/><br/>-------------------------------<br/>Powered by Events Manager - http://wp-events-plugin.com';
$respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br/>You have successfully reserved #_BOOKINGSPACES space/spaces for #_EVENTNAME.<br/>When : #_EVENTDATES @ #_EVENTTIMES<br/>Where : #_LOCATIONNAME - #_LOCATIONFULLLINE<br/>Yours faithfully,<br/>#_CONTACTNAME",'events-manager').$email_footer;
$respondent_email_pending_body_localizable = __("Dear #_BOOKINGNAME, <br/>You have requested #_BOOKINGSPACES space/spaces for #_EVENTNAME.<br/>When : #_EVENTDATES @ #_EVENTTIMES<br/>Where : #_LOCATIONNAME - #_LOCATIONFULLLINE<br/>Your booking is currently pending approval by our administrators. Once approved you will receive an automatic confirmation.<br/>Yours faithfully,<br/>#_CONTACTNAME",'events-manager').$email_footer;
$respondent_email_rejected_body_localizable = __("Dear #_BOOKINGNAME, <br/>Your requested booking for #_BOOKINGSPACES spaces at #_EVENTNAME on #_EVENTDATES has been rejected.<br/>Yours faithfully,<br/>#_CONTACTNAME",'events-manager').$email_footer;
$respondent_email_cancelled_body_localizable = __("Dear #_BOOKINGNAME, <br/>Your requested booking for #_BOOKINGSPACES spaces at #_EVENTNAME on #_EVENTDATES has been cancelled.<br/>Yours faithfully,<br/>#_CONTACTNAME",'events-manager').$email_footer;
$event_approved_email_body = __("Dear #_CONTACTNAME, <br/>Your event #_EVENTNAME on #_EVENTDATES has been approved.<br/>You can view your event here: #_EVENTURL",'events-manager').$email_footer;
$event_submitted_email_body = __("A new event has been submitted by #_CONTACTNAME.<br/>Name : #_EVENTNAME <br/>Date : #_EVENTDATES <br/>Time : #_EVENTTIMES <br/>Please visit #_EDITEVENTURL to review this event for approval.",'events-manager').$email_footer;
$event_submitted_email_body = str_replace('#_EDITEVENTURL', admin_url().'post.php?action=edit&post=#_EVENTPOSTID', $event_submitted_email_body);
$event_published_email_body = __("A new event has been published by #_CONTACTNAME.<br/>Name : #_EVENTNAME <br/>Date : #_EVENTDATES <br/>Time : #_EVENTTIMES <br/>Edit this event - #_EDITEVENTURL <br/> View this event - #_EVENTURL",'events-manager').$email_footer;
$event_published_email_body = str_replace('#_EDITEVENTURL', admin_url().'post.php?action=edit&post=#_EVENTPOSTID', $event_published_email_body);
$event_resubmitted_email_body = __("A previously published event has been modified by #_CONTACTNAME, and this event is now unpublished and pending your approval.<br/>Name : #_EVENTNAME <br/>Date : #_EVENTDATES <br/>Time : #_EVENTTIMES <br/>Please visit #_EDITEVENTURL to review this event for approval.",'events-manager').$email_footer;
$event_resubmitted_email_body = str_replace('#_EDITEVENTURL', admin_url().'post.php?action=edit&post=#_EVENTPOSTID', $event_resubmitted_email_body);
//event admin emails - new format to the above, standard format plus one unique line per booking status at the top of the body and subject line
$contact_person_email_body_template = '#_EVENTNAME - #_EVENTDATES @ #_EVENTTIMES'.'<br/>'
.__('Now there are #_BOOKEDSPACES spaces reserved, #_AVAILABLESPACES are still available.','events-manager').'<br/>'.
strtoupper(__('Booking Details','events-manager')).'<br/>'.
__('Name','events-manager').' : #_BOOKINGNAME'.'<br/>'.
__('Email','events-manager').' : #_BOOKINGEMAIL'.'<br/>'.
'#_BOOKINGSUMMARY'.'<br/>'.
'<br/>Powered by Events Manager - http://wp-events-plugin.com';
$contact_person_emails['confirmed'] = sprintf(__('The following booking is %s :','events-manager'),strtolower(__('Confirmed','events-manager'))).'<br/>'.$contact_person_email_body_template;
$contact_person_emails['pending'] = sprintf(__('The following booking is %s :','events-manager'),strtolower(__('Pending','events-manager'))).'<br/>'.$contact_person_email_body_template;
$contact_person_emails['cancelled'] = sprintf(__('The following booking is %s :','events-manager'),strtolower(__('Cancelled','events-manager'))).'<br/>'.$contact_person_email_body_template;
$contact_person_emails['rejected'] = sprintf(__('The following booking is %s :','events-manager'),strtolower(__('Rejected','events-manager'))).'<br/>'.$contact_person_email_body_template;
//registration email content
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
$booking_registration_email_subject = sprintf(__('[%s] Your username and password', 'events-manager'), $blogname);
$booking_registration_email_body = sprintf(__('You have successfully created an account at %s', 'events-manager'), $blogname).
'<br/>'.sprintf(__('You can log into our site here : %s', 'events-manager'), get_bloginfo('wpurl').'/wp-login.php').
'<br/>'.__('Username', 'events-manager').' : %username%'.
'<br/>'.__('Password', 'events-manager').' : %password%'.
'<br/>'.sprintf(__('To view your bookings, please visit %s after logging in.', 'events-manager'), em_get_my_bookings_url());
//all the options
$dbem_options = array(
'dbem_data' => array(), //used to store admin-related data such as notice flags and other row keys that may not always exist in the wp_options table
//time formats
'dbem_time_format' => get_option('time_format'),
'dbem_date_format' => get_option('date_format'),
'dbem_date_format_js' => 'dd/mm/yy',
'dbem_dates_separator' => ' - ',
'dbem_times_separator' => ' - ',
//defaults
'dbem_default_category'=>0,
'dbem_default_location'=>0,
//Event List Options
'dbem_events_default_orderby' => 'event_start_date,event_start_time,event_name',
'dbem_events_default_order' => 'ASC',
'dbem_events_default_limit' => 10,
//Event Search Options
'dbem_search_form_submit' => __('Search','events-manager'),
'dbem_search_form_advanced' => 1,
'dbem_search_form_advanced_hidden' => 1,
'dbem_search_form_advanced_show' => __('Show Advanced Search','events-manager'),
'dbem_search_form_advanced_hide' => __('Hide Advanced Search','events-manager'),
'dbem_search_form_text' => 1,
'dbem_search_form_text_label' => __('Search','events-manager'),
'dbem_search_form_geo' => 1,
'dbem_search_form_geo_label' => __('Near...','events-manager'),
'dbem_search_form_geo_units' => 1,
'dbem_search_form_geo_units_label' => __('Within','events-manager'),
'dbem_search_form_geo_unit_default' => 'mi',
'dbem_search_form_geo_distance_default' => 25,
'dbem_search_form_geo_distance_options' => '5,10,25,50,100',
'dbem_search_form_dates' => 1,
'dbem_search_form_dates_label' => __('Dates','events-manager'),
'dbem_search_form_dates_separator' => __('and','events-manager'),
'dbem_search_form_categories' => 1,
'dbem_search_form_categories_label' => __('All Categories','events-manager'),
'dbem_search_form_category_label' => __('Category','events-manager'),
'dbem_search_form_countries' => 1,
'dbem_search_form_default_country' => get_option('dbem_location_default_country',''),
'dbem_search_form_countries_label' => __('All Countries','events-manager'),
'dbem_search_form_country_label' => __('Country','events-manager'),
'dbem_search_form_regions' => 1,
'dbem_search_form_regions_label' => __('All Regions','events-manager'),
'dbem_search_form_region_label' => __('Region','events-manager'),
'dbem_search_form_states' => 1,
'dbem_search_form_states_label' => __('All States','events-manager'),
'dbem_search_form_state_label' => __('State/County','events-manager'),
'dbem_search_form_towns' => 0,
'dbem_search_form_towns_label' => __('All Cities/Towns','events-manager'),
'dbem_search_form_town_label' => __('City/Town','events-manager'),
/*
//GeoCoding
'dbem_geo' => 1,
'dbem_geonames_username' => '',
*/
//Event Form and Anon Submissions
'dbem_events_form_editor' => 1,
'dbem_events_form_reshow' => 1,
'dbem_events_form_result_success' => __('You have successfully submitted your event, which will be published pending approval.','events-manager'),
'dbem_events_form_result_success_updated' => __('You have successfully updated your event, which will be republished pending approval.','events-manager'),
'dbem_events_anonymous_submissions' => 0,
'dbem_events_anonymous_user' => 0,
'dbem_events_anonymous_result_success' => __('You have successfully submitted your event, which will be published pending approval.','events-manager'),
//Event Emails
'dbem_event_submitted_email_admin' => '',
'dbem_event_submitted_email_subject' => __('Submitted Event Awaiting Approval', 'events-manager'),
'dbem_event_submitted_email_body' => str_replace("<br/>", "\n\r", $event_submitted_email_body),
'dbem_event_resubmitted_email_subject' => __('Re-Submitted Event Awaiting Approval', 'events-manager'),
'dbem_event_resubmitted_email_body' => str_replace("<br/>", "\n\r", $event_resubmitted_email_body),
'dbem_event_published_email_subject' => __('Published Event', 'events-manager').' - #_EVENTNAME',
'dbem_event_published_email_body' => str_replace("<br/>", "\n\r", $event_published_email_body),
'dbem_event_approved_email_subject' => __("Event Approved",'events-manager'). " - #_EVENTNAME" ,
'dbem_event_approved_email_body' => str_replace("<br/>", "\n\r", $event_approved_email_body),
'dbem_event_reapproved_email_subject' => __("Event Approved",'events-manager'). " - #_EVENTNAME" ,
'dbem_event_reapproved_email_body' => str_replace("<br/>", "\n\r", $event_approved_email_body),
//Event Formatting
'dbem_events_page_title' => __('Events','events-manager'),
'dbem_events_page_scope' => 'future',
'dbem_events_page_search_form' => 1,
'dbem_event_list_item_format_header' => '<table class="events-table" >
<thead>
<tr>
<th class="event-time" scope="col">'.__('Date/Time','events-manager').'</th>
<th class="event-description" scope="col">'.__('Event','events-manager').'</th>
</tr>
</thead>
<tbody>',
'dbem_event_list_item_format' => '<tr>
<td>
#_EVENTDATES<br/>
#_EVENTTIMES
</td>
<td>
#_EVENTLINK
{has_location}<br/><i>#_LOCATIONNAME, #_LOCATIONTOWN #_LOCATIONSTATE</i>{/has_location}
</td>
</tr>',
'dbem_event_list_item_format_footer' => '</tbody></table>',
'dbem_event_list_groupby' => 0,
'dbem_event_list_groupby_format' => '',
'dbem_event_list_groupby_header_format' => '<h2>#s</h2>',
'dbem_display_calendar_in_events_page' => 0,
'dbem_single_event_format' => '<div style="float:right; margin:0px 0px 15px 15px;">#_LOCATIONMAP</div>
<p>
<strong>'.esc_html__('Date/Time','events-manager').'</strong><br/>
Date(s) - #_EVENTDATES<br /><i>#_EVENTTIMES</i>
</p>
{has_location}
<p>
<strong>'.esc_html__('Location','events-manager').'</strong><br/>
#_LOCATIONLINK
</p>
{/has_location}
<p>
<strong>'.esc_html__('Categories','events-manager').'</strong>
#_CATEGORIES
</p>
<br style="clear:both" />
#_EVENTNOTES
{has_bookings}
<h3>'.esc_html__('Bookings','events-manager').'</h3>
#_BOOKINGFORM
{/has_bookings}',
'dbem_event_excerpt_format' => '#_EVENTDATES @ #_EVENTTIMES - #_EVENTEXCERPT',
'dbem_event_excerpt_alt_format' => '#_EVENTDATES @ #_EVENTTIMES - #_EVENTEXCERPT{55}',
'dbem_event_page_title_format' => '#_EVENTNAME',
'dbem_event_all_day_message' => __('All Day','events-manager'),
'dbem_no_events_message' => sprintf(__( 'No %s', 'events-manager'),__('Events','events-manager')),
//Location Formatting
'dbem_locations_default_orderby' => 'location_name',
'dbem_locations_default_order' => 'ASC',
'dbem_locations_default_limit' => 10,
'dbem_locations_page_title' => __('Event','events-manager')." ".__('Locations','events-manager'),
'dbem_locations_page_search_form' => 1,
'dbem_no_locations_message' => sprintf(__( 'No %s', 'events-manager'),__('Locations','events-manager')),
'dbem_location_default_country' => '',
'dbem_location_list_item_format_header' => '<ul class="em-locations-list">',
'dbem_location_list_item_format' => '<li>#_LOCATIONLINK<ul><li>#_LOCATIONFULLLINE</li></ul></li>',
'dbem_location_list_item_format_footer' => '</ul>',
'dbem_location_page_title_format' => '#_LOCATIONNAME',
'dbem_single_location_format' => '<div style="float:right; margin:0px 0px 15px 15px;">#_LOCATIONMAP</div>
<p>
<strong>'.__('Address','events-manager').'</strong><br/>
#_LOCATIONADDRESS<br/>
#_LOCATIONTOWN<br/>
#_LOCATIONSTATE<br/>
#_LOCATIONREGION<br/>
#_LOCATIONPOSTCODE<br/>
#_LOCATIONCOUNTRY
</p>
<br style="clear:both" />
#_LOCATIONNOTES
<h3>'.__('Upcoming Events','events-manager').'</h3>
<p>#_LOCATIONNEXTEVENTS</p>',
'dbem_location_excerpt_format' => '#_LOCATIONEXCERPT',
'dbem_location_excerpt_alt_format' => '#_LOCATIONEXCERPT{55}',
'dbem_location_no_events_message' => '<li>'.__('No events in this location', 'events-manager').'</li>',
'dbem_location_event_list_item_header_format' => "<ul>",
'dbem_location_event_list_item_format' => "<li>#_EVENTLINK - #_EVENTDATES - #_EVENTTIMES</li>",
'dbem_location_event_list_item_footer_format' => "</ul>",
'dbem_location_event_list_limit' => 20,
'dbem_location_event_list_orderby' => 'event_start_date,event_start_time,event_name',
'dbem_location_event_list_order' => 'ASC',
'dbem_location_event_single_format' => '#_EVENTLINK - #_EVENTDATES - #_EVENTTIMES',
'dbem_location_no_event_message' => __('No events in this location', 'events-manager'),
//Category page options
'dbem_categories_default_limit' => 10,
'dbem_categories_default_orderby' => 'name',
'dbem_categories_default_order' => 'ASC',
//Categories Page Formatting
'dbem_categories_list_item_format_header' => '<ul class="em-categories-list">',
'dbem_categories_list_item_format' => '<li>#_CATEGORYLINK</li>',
'dbem_categories_list_item_format_footer' => '</ul>',
'dbem_no_categories_message' => sprintf(__( 'No %s', 'events-manager'),__('Categories','events-manager')),
//Category Formatting
'dbem_category_page_title_format' => '#_CATEGORYNAME',
'dbem_category_page_format' => '#_CATEGORYNOTES<h3>'.__('Upcoming Events','events-manager').'</h3>#_CATEGORYNEXTEVENTS',
'dbem_category_no_events_message' => '<li>'.__('No events in this category', 'events-manager').'</li>',
'dbem_category_event_list_item_header_format' => '<ul>',
'dbem_category_event_list_item_format' => "<li>#_EVENTLINK - #_EVENTDATES - #_EVENTTIMES</li>",
'dbem_category_event_list_item_footer_format' => '</ul>',
'dbem_category_event_list_limit' => 20,
'dbem_category_event_list_orderby' => 'event_start_date,event_start_time,event_name',
'dbem_category_event_list_order' => 'ASC',
'dbem_category_event_single_format' => '#_EVENTLINK - #_EVENTDATES - #_EVENTTIMES',
'dbem_category_no_event_message' => __('No events in this category', 'events-manager'),
'dbem_category_default_color' => '#a8d144',
//Tags page options
'dbem_tags_default_limit' => 10,
'dbem_tags_default_orderby' => 'name',
'dbem_tags_default_order' => 'ASC',
//Tags Page Formatting
'dbem_tags_list_item_format_header' => '<ul class="em-tags-list">',
'dbem_tags_list_item_format' => '<li>#_TAGLINK</li>',
'dbem_tags_list_item_format_footer' => '</ul>',
'dbem_no_tags_message' => sprintf(__( 'No %s', 'events-manager'),__('Tags','events-manager')),
//Tag Page Formatting
'dbem_tag_page_title_format' => '#_TAGNAME',
'dbem_tag_page_format' => '<h3>'.__('Upcoming Events','events-manager').'</h3>#_TAGNEXTEVENTS',
'dbem_tag_no_events_message' => '<li>'.__('No events with this tag', 'events-manager').'</li>',
'dbem_tag_event_list_item_header_format' => '<ul class="em-tags-list">',
'dbem_tag_event_list_item_format' => "<li>#_EVENTLINK - #_EVENTDATES - #_EVENTTIMES</li>",
'dbem_tag_event_list_item_footer_format' => '</ul>',
'dbem_tag_event_single_format' => '#_EVENTLINK - #_EVENTDATES - #_EVENTTIMES',
'dbem_tag_no_event_message' => __('No events with this tag', 'events-manager'),
'dbem_tag_event_list_limit' => 20,
'dbem_tag_event_list_orderby' => 'event_start_date,event_start_time,event_name',
'dbem_tag_event_list_order' => 'ASC',
'dbem_tag_default_color' => '#a8d145',
//RSS Stuff
'dbem_rss_limit' => 50,
'dbem_rss_scope' => 'future',
'dbem_rss_main_title' => get_bloginfo('title')." - ".__('Events', 'events-manager'),
'dbem_rss_main_description' => get_bloginfo('description')." - ".__('Events', 'events-manager'),
'dbem_rss_description_format' => "#_EVENTDATES - #_EVENTTIMES <br/>#_LOCATIONNAME <br/>#_LOCATIONADDRESS <br/>#_LOCATIONTOWN",
'dbem_rss_title_format' => "#_EVENTNAME",
'dbem_rss_order' => get_option('dbem_events_default_order', 'ASC'), //get event order and orderby or use same new installation defaults
'dbem_rss_orderby' => get_option('dbem_events_default_orderby', 'event_start_date,event_start_time,event_name'),
'em_rss_pubdate' => date('D, d M Y H:i:s +0000'),
//iCal Stuff
'dbem_ical_limit' => 50,
'dbem_ical_scope' => "future",
'dbem_ical_description_format' => "#_EVENTNAME",
'dbem_ical_real_description_format' => "#_EVENTEXCERPT",
'dbem_ical_location_format' => "#_LOCATIONNAME, #_LOCATIONFULLLINE, #_LOCATIONCOUNTRY",
//Google Maps
'dbem_gmap_is_active'=> 1,
'dbem_google_maps_browser_key'=> '',
'dbem_map_default_width'=> '400px', //eventually will use %
'dbem_map_default_height'=> '300px',
'dbem_location_baloon_format' => '<strong>#_LOCATIONNAME</strong><br/>#_LOCATIONADDRESS - #_LOCATIONTOWN<br/><a href="#_LOCATIONPAGEURL">'.__('Events', 'events-manager').'</a>',
'dbem_map_text_format' => '<strong>#_LOCATIONNAME</strong><p>#_LOCATIONADDRESS</p><p>#_LOCATIONTOWN</p>',
//Email Config
'dbem_email_disable_registration' => 0,
'dbem_rsvp_mail_port' => 465,
'dbem_smtp_host' => 'localhost',
'dbem_mail_sender_name' => '',
'dbem_rsvp_mail_send_method' => 'wp_mail',
'dbem_rsvp_mail_SMTPAuth' => 1,
'dbem_smtp_html' => 1,
'dbem_smtp_html_br' => 1,
'dbem_smtp_encryption' => 'tls',
'dbem_smtp_autotls' => true,
//Image Manipulation
'dbem_image_max_width' => 700,
'dbem_image_max_height' => 700,
'dbem_image_min_width' => 50,
'dbem_image_min_height' => 50,
'dbem_image_max_size' => 204800,
//Calendar Options
'dbem_list_date_title' => __('Events', 'events-manager').' - #j #M #y',
'dbem_full_calendar_month_format' => 'M Y',
'dbem_full_calendar_event_format' => '<li>#_EVENTLINK</li>',
'dbem_full_calendar_long_events' => '0',
'dbem_full_calendar_initials_length' => 0,
'dbem_full_calendar_abbreviated_weekdays' => true,
'dbem_display_calendar_day_single_yes' => 1,
'dbem_small_calendar_month_format' => 'M Y',
'dbem_small_calendar_event_title_format' => "#_EVENTNAME",
'dbem_small_calendar_event_title_separator' => ", ",
'dbem_small_calendar_initials_length' => 1,
'dbem_small_calendar_abbreviated_weekdays' => false,
'dbem_small_calendar_long_events' => '0',
'dbem_display_calendar_order' => 'ASC',
'dbem_display_calendar_orderby' => 'event_name,event_start_time',
'dbem_display_calendar_events_limit' => get_option('dbem_full_calendar_events_limit',3),
'dbem_display_calendar_events_limit_msg' => __('more...','events-manager'),
'dbem_calendar_direct_links' => 1,
//General Settings
'dbem_timezone_enabled' => 1,
'dbem_timezone_default' => EM_DateTimeZone::create()->getName(),
'dbem_require_location' => 0,
'dbem_locations_enabled' => 1,
'dbem_location_types' => array('location' => 1, 'url' => 1),
'dbem_use_select_for_locations' => 0,
'dbem_attributes_enabled' => 1,
'dbem_recurrence_enabled'=> 1,
'dbem_rsvp_enabled'=> 1,
'dbem_categories_enabled'=> 1,
'dbem_tags_enabled' => 1,
'dbem_placeholders_custom' => '',
'dbem_location_attributes_enabled' => 1,
'dbem_location_placeholders_custom' => '',
//Bookings
'dbem_bookings_registration_disable' => 0,
'dbem_bookings_registration_disable_user_emails' => 0,
'dbem_bookings_approval' => 1, //approval is on by default
'dbem_bookings_approval_reserved' => 0, //overbooking before approval?
'dbem_bookings_approval_overbooking' => 0, //overbooking possible when approving?
'dbem_bookings_double'=>0,//double bookings or more, users can't double book by default
'dbem_bookings_user_cancellation' => 1, //can users cancel their booking?
'dbem_bookings_currency' => 'USD',
'dbem_bookings_currency_decimal_point' => $decimal_point,
'dbem_bookings_currency_thousands_sep' => $thousands_sep,
'dbem_bookings_currency_format' => '@#',
'dbem_bookings_tax' => 0, //extra tax
'dbem_bookings_tax_auto_add' => 0, //adjust prices to show tax?
//Form Options
'dbem_bookings_submit_button' => __('Send your booking', 'events-manager'),
'dbem_bookings_login_form' => 1, //show login form on booking area
'dbem_bookings_anonymous' => 1,
'dbem_bookings_form_max' => 20,
//Messages
'dbem_bookings_form_msg_disabled' => __('Online bookings are not available for this event.','events-manager'),
'dbem_bookings_form_msg_closed' => __('Bookings are closed for this event.','events-manager'),
'dbem_bookings_form_msg_full' => __('This event is fully booked.','events-manager'),
'dbem_bookings_form_msg_attending'=>__('You are currently attending this event.','events-manager'),
'dbem_bookings_form_msg_bookings_link'=>__('Manage my bookings','events-manager'),
//messages
'dbem_booking_warning_cancel' => __('Are you sure you want to cancel your booking?','events-manager'),
'dbem_booking_feedback_cancelled' =>sprintf(__('Booking %s','events-manager'), __('Cancelled','events-manager')),
'dbem_booking_feedback_pending' =>__('Booking successful, pending confirmation (you will also receive an email once confirmed).', 'events-manager'),
'dbem_booking_feedback' => __('Booking successful.', 'events-manager'),
'dbem_booking_feedback_full' => __('Booking cannot be made, not enough spaces available!', 'events-manager'),
'dbem_booking_feedback_log_in' => __('You must log in or register to make a booking.','events-manager'),
'dbem_booking_feedback_nomail' => __('However, there were some problems whilst sending confirmation emails to you and/or the event contact person. You may want to contact them directly and letting them know of this error.', 'events-manager'),
'dbem_booking_feedback_error' => __('Booking could not be created','events-manager').':',
'dbem_booking_feedback_email_exists' => __('This email already exists in our system, please log in to register to proceed with your booking.','events-manager'),
'dbem_booking_feedback_new_user' => __('A new user account has been created for you. Please check your email for access details.','events-manager'),
'dbem_booking_feedback_reg_error' => __('There was a problem creating a user account, please contact a website administrator.','events-manager'),
'dbem_booking_feedback_already_booked' => __('You already have booked a seat at this event.','events-manager'),
'dbem_booking_feedback_min_space' => __('You must request at least one space to book an event.','events-manager'),
'dbem_booking_feedback_spaces_limit' => __('You cannot book more than %d spaces for this event.','events-manager'),
//button messages
'dbem_booking_button_msg_book' => __('Book Now', 'events-manager'),
'dbem_booking_button_msg_booking' => __('Booking...','events-manager'),
'dbem_booking_button_msg_booked' => sprintf(__('%s Submitted','events-manager'), __('Booking','events-manager')),
'dbem_booking_button_msg_already_booked' => __('Already Booked','events-manager'),
'dbem_booking_button_msg_error' => sprintf(__('%s Error. Try again?','events-manager'), __('Booking','events-manager')),
'dbem_booking_button_msg_full' => __('Sold Out', 'events-manager'),
'dbem_booking_button_msg_closed' => ucwords(__( 'Bookings closed', 'events-manager')), //ucwords it to prevent extra translation
'dbem_booking_button_msg_cancel' => __('Cancel', 'events-manager'),
'dbem_booking_button_msg_canceling' => __('Canceling...','events-manager'),
'dbem_booking_button_msg_cancelled' => __('Cancelled','events-manager'),
'dbem_booking_button_msg_cancel_error' => sprintf(__('%s Error. Try again?','events-manager'), __('Cancellation','events-manager')),
//Emails
'dbem_bookings_notify_admin' => 0,
'dbem_bookings_contact_email' => 1,
'dbem_bookings_contact_email_pending_subject' => __("Booking Pending",'events-manager'),
'dbem_bookings_contact_email_pending_body' => str_replace("<br/>", "\n\r", $contact_person_emails['pending']),
'dbem_bookings_contact_email_confirmed_subject' => __('Booking Confirmed','events-manager'),
'dbem_bookings_contact_email_confirmed_body' => str_replace("<br/>", "\n\r", $contact_person_emails['confirmed']),
'dbem_bookings_contact_email_rejected_subject' => __("Booking Rejected",'events-manager'),
'dbem_bookings_contact_email_rejected_body' => str_replace("<br/>", "\n\r", $contact_person_emails['rejected']),
'dbem_bookings_contact_email_cancelled_subject' => __("Booking Cancelled",'events-manager'),
'dbem_bookings_contact_email_cancelled_body' => str_replace("<br/>", "\n\r", $contact_person_emails['cancelled']),
'dbem_bookings_email_pending_subject' => __("Booking Pending",'events-manager'),
'dbem_bookings_email_pending_body' => str_replace("<br/>", "\n\r", $respondent_email_pending_body_localizable),
'dbem_bookings_email_rejected_subject' => __("Booking Rejected",'events-manager'),
'dbem_bookings_email_rejected_body' => str_replace("<br/>", "\n\r", $respondent_email_rejected_body_localizable),
'dbem_bookings_email_confirmed_subject' => __('Booking Confirmed','events-manager'),
'dbem_bookings_email_confirmed_body' => str_replace("<br/>", "\n\r", $respondent_email_body_localizable),
'dbem_bookings_email_cancelled_subject' => __('Booking Cancelled','events-manager'),
'dbem_bookings_email_cancelled_body' => str_replace("<br/>", "\n\r", $respondent_email_cancelled_body_localizable),
//Registration Email
'dbem_bookings_email_registration_subject' => $booking_registration_email_subject,
'dbem_bookings_email_registration_body' => str_replace("<br/>", "\n\r", $booking_registration_email_body),
//Ticket Specific Options
'dbem_bookings_tickets_ordering' => 1,
'dbem_bookings_tickets_orderby' => 'ticket_price DESC, ticket_name ASC',
'dbem_bookings_tickets_priority' => 0,
'dbem_bookings_tickets_show_unavailable' => 0,
'dbem_bookings_tickets_show_loggedout' => 1,
'dbem_bookings_tickets_single' => 0,
'dbem_bookings_tickets_single_form' => 0,
//My Bookings Page
'dbem_bookings_my_title_format' => __('My Bookings','events-manager'),
//Flags
'dbem_hello_to_user' => 1,
//BP Settings
'dbem_bp_events_list_format_header' => '<ul class="em-events-list">',
'dbem_bp_events_list_format' => '<li>#_EVENTLINK - #_EVENTDATES - #_EVENTTIMES<ul><li>#_LOCATIONLINK - #_LOCATIONADDRESS, #_LOCATIONTOWN</li></ul></li>',
'dbem_bp_events_list_format_footer' => '</ul>',
'dbem_bp_events_list_none_format' => '<p class="em-events-list">'.__('No Events','events-manager').'</p>',
//custom CSS options for public pages
'dbem_css_editors' => 1,
'dbem_css_rsvp' => 1, //my bookings page
'dbem_css_rsvpadmin' => 1, //my event bookings page
'dbem_css_evlist' => 1,
'dbem_css_search' => 1,
'dbem_css_loclist' => 1,
'dbem_css_catlist' => 1,
'dbem_css_taglist' => 1,
/*
* Custom Post Options - set up to mimick old EM settings and install with minimal setup for most users
*/
//slugs
'dbem_cp_events_slug' => 'events',
'dbem_cp_locations_slug' => 'locations',
'dbem_taxonomy_category_slug' => 'events/categories',
'dbem_taxonomy_tag_slug' => 'events/tags',
//event cp options
'dbem_cp_events_template' => '',
//'dbem_cp_events_template_page' => 0, DEPREICATED
'dbem_cp_events_body_class' => '',
'dbem_cp_events_post_class' => '',
'dbem_cp_events_formats' => 1,
'dbem_cp_events_has_archive' => 1,
'dbem_events_default_archive_orderby' => '_event_start',
'dbem_events_default_archive_order' => 'ASC',
'dbem_events_archive_scope' => 'past',
'dbem_cp_events_archive_formats' => 1,
'dbem_cp_events_excerpt_formats' => 1,
'dbem_cp_events_search_results' => 0,
'dbem_cp_events_custom_fields' => 0,
'dbem_cp_events_comments' => 1,
//location cp options
'dbem_cp_locations_template' => '',
//'dbem_cp_locations_template_page' => 0, DEPREICATED
'dbem_cp_locations_body_class' => '',
'dbem_cp_locations_post_class' => '',
'dbem_cp_locations_formats' => 1,
'dbem_cp_locations_has_archive' => 1,
'dbem_locations_default_archive_orderby' => 'title',
'dbem_locations_default_archive_order' => 'ASC',
'dbem_cp_locations_archive_formats' => 1,
'dbem_cp_locations_excerpt_formats' => 1,
'dbem_cp_locations_search_results' => 0,
'dbem_cp_locations_custom_fields' => 0,
'dbem_cp_locations_comments' => 1,
//category cp options
'dbem_cp_categories_formats' => 1,
'dbem_categories_default_archive_orderby' => 'event_start_date,event_start_time,event_name',
'dbem_categories_default_archive_order' => 'ASC',
//category cp options
'dbem_cp_tags_formats' => 1,
'dbem_tags_default_archive_orderby' => 'event_start_date,event_start_time,event_name',
'dbem_tags_default_archive_order' => 'ASC',
//optimization options
'dbem_disable_thumbnails'=> false,
//feedback reminder
'dbem_feedback_reminder' => time(),
'dbem_events_page_ajax' => 0,
'dbem_conditional_recursions' => 1,
//data privacy/protection
'dbem_data_privacy_consent_text' => esc_html__('I consent to my submitted data being collected and stored as outlined by the site %s.','events-manager'),
'dbem_data_privacy_consent_remember' => 1,
'dbem_data_privacy_consent_events' => 1,
'dbem_data_privacy_consent_locations' => 1,
'dbem_data_privacy_consent_bookings' => 1,
'dbem_data_privacy_export_events' => 1,
'dbem_data_privacy_export_locations' => 1,
'dbem_data_privacy_export_bookings' => 1,
'dbem_data_privacy_erase_events' => 1,
'dbem_data_privacy_erase_locations' => 1,
'dbem_data_privacy_erase_bookings' => 1
);
//do date js according to locale:
$locale_code = substr ( get_locale (), 0, 2 );
$locale_dates = array('nl' => 'dd/mm/yy', 'af' => 'dd/mm/yy', 'ar' => 'dd/mm/yy', 'az' => 'dd.mm.yy', 'bg' => 'dd.mm.yy', 'bs' => 'dd.mm.yy', 'cs' => 'dd.mm.yy', 'da' => 'dd-mm-yy', 'de' => 'dd.mm.yy', 'el' => 'dd/mm/yy', 'en-GB' => 'dd/mm/yy', 'eo' => 'dd/mm/yy', 'et' => 'dd.mm.yy', 'eu' => 'yy/mm/dd', 'fa' => 'yy/mm/dd', 'fo' => 'dd-mm-yy', 'fr' => 'dd.mm.yy', 'fr' => 'dd/mm/yy', 'he' => 'dd/mm/yy', 'hu' => 'yy.mm.dd.', 'hr' => 'dd.mm.yy.', 'ja' => 'yy/mm/dd', 'ro' => 'dd.mm.yy', 'sk' => 'dd.mm.yy', 'sq' => 'dd.mm.yy', 'sr' => 'dd/mm/yy', 'sr' => 'dd/mm/yy', 'sv' => 'yy-mm-dd', 'ta' => 'dd/mm/yy', 'th' => 'dd/mm/yy', 'vi' => 'dd/mm/yy', 'zh' => 'yy/mm/dd', 'es' => 'dd/mm/yy', 'it' => 'dd/mm/yy');
if( array_key_exists($locale_code, $locale_dates) ){
$dbem_options['dbem_date_format_js'] = $locale_dates[$locale_code];
}
//add new options
foreach($dbem_options as $key => $value){
add_option($key, $value);
}
//set time localization for first time depending on current settings
if( get_option('dbem_time_24h','not set') == 'not set'){
//Localise vars regardless
$locale_code = substr ( get_locale(), 0, 2 );
if (preg_match('/^en_(?:GB|IE|AU|NZ|ZA|TT|JM)$/', get_locale())) {
$locale_code = 'en-GB';
}
//Set time
$show24Hours = ( !preg_match("/en|sk|zh|us|uk/", $locale_code ) ); // Setting 12 hours format for those countries using it
update_option('dbem_time_24h', $show24Hours);
}
}
function em_upgrade_current_installation(){
global $wpdb, $wp_locale, $EM_Notices;
// Check EM Pro update min
if( defined('EMP_VERSION') && EMP_VERSION < EM_PRO_MIN_VERSION && !defined('EMP_DISABLE_WARNINGS') ) {
$message = esc_html__('There is a newer version of Events Manager Pro which is recommended for this current version of Events Manager as new features have been added. Please go to the plugin website and download the latest update.','events-manager');
$EM_Admin_Notice = new EM_Admin_Notice(array('name' => 'em-pro-updates', 'who' => 'admin', 'where' => 'all', 'message' => "$message"));
EM_Admin_Notices::add($EM_Admin_Notice, is_multisite());
}
if( !get_option('dbem_version') ){ add_option('dbem_credits',1); }
if( get_option('dbem_version') != '' && get_option('dbem_version') < 5 ){
//make events, cats and locs pages
update_option('dbem_cp_events_template_page',1);
update_option('dbem_cp_locations_template_page',1);
//reset orderby, or convert fields to new fieldnames
$EM_Event = new EM_Event();
$orderbyvals = explode(',', get_option('dbem_events_default_orderby'));
$orderby = array();
foreach($orderbyvals as $val){
if(array_key_exists('event_'.$val, $EM_Event->fields)){
$orderby[] = 'event_'.$val;
}
}
$orderby = (count($orderby) > 0) ? implode(',',$orderby):$dbem_options['dbem_events_default_orderby'];
update_option('dbem_events_default_orderby',$orderby);
//Locations and categories weren't controlled in v4, so just reset them
update_option('dbem_locations_default_orderby','location_name');
update_option('dbem_categories_default_orderby','name');
//Update the slugs if necessary
$events_page_id = get_option ( 'dbem_events_page' );
$events_page = get_post($events_page_id);
update_option('dbem_cp_events_slug', $events_page->post_name);
update_option('dbem_taxonomy_tag_slug', $events_page->post_name.'/tags');
if( defined('EM_LOCATIONS_SLUG') && EM_LOCATIONS_SLUG != 'locations' ) update_option('dbem_cp_locations_slug', EM_LOCATIONS_SLUG);
if( defined('EM_CATEGORIES_SLUG') && EM_CATEGORIES_SLUG != 'categories' ) update_option('dbem_taxonomy_category_slug', $events_page->post_name.'/'.EM_CATEGORIES_SLUG);
}
if( get_option('dbem_version') != '' && get_option('dbem_version') < 5.19 ){
update_option('dbem_event_reapproved_email_subject', get_option('dbem_event_approved_email_subject'));
update_option('dbem_event_reapproved_email_body', get_option('dbem_event_approved_email_body'));
}
if( get_option('dbem_version') != '' && get_option('dbem_version') <= 5.21 ){
//just remove all rsvp cut-off info
$wpdb->query("UPDATE ".$wpdb->postmeta." SET meta_value = NULL WHERE meta_key IN ('_event_rsvp_date','_event_rsvp_time') AND post_id IN (SELECT post_id FROM ".EM_EVENTS_TABLE." WHERE recurrence_id > 0)");
$wpdb->query("UPDATE ".EM_EVENTS_TABLE." SET event_rsvp_time = NULL, event_rsvp_date = NULL WHERE recurrence_id > 0");
}
if( get_option('dbem_version') != '' && get_option('dbem_version') < 5.364 ){
if( get_option('dbem_cp_events_template_page') ){
update_option('dbem_cp_events_template', 'page');
delete_option('dbem_cp_events_template_page');
}
if( get_option('dbem_cp_locations_template_page') ){
update_option('dbem_cp_locations_template', 'page');
delete_option('dbem_cp_locations_template_page');
}