-
Notifications
You must be signed in to change notification settings - Fork 0
/
espresso.php
1327 lines (1067 loc) · 50.3 KB
/
espresso.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
/*
Plugin Name: Event Espresso
Plugin URI: http://eventespresso.com/
Description: Out-of-the-box Events Registration integrated with PayPal IPN for your WordPress blog/website. <a href="admin.php?page=support" >Support</a>
Reporting features provide a list of events, list of attendees, and excel export.
Version: 3.1.37.19.P
Author: Event Espresso
Author URI: http://www.eventespresso.com
Copyright (c) 2008-2013 Event Espresso All Rights Reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//Returns the plugin version if another version is not already activated.
if ( ! function_exists( 'espresso_version' ) ) {
/**
* espresso_version
* @return string
*/
function espresso_version() {
do_action( 'action_hook_espresso_log', __FILE__, __FUNCTION__, '' );
return '3.1.37.19.P';
}
} else {
add_action( 'admin_notices', 'espresso3_duplicate_plugin_error', 1 );
unset( $_GET[ 'activate' ] );
if ( ! function_exists( 'deactivate_plugins' ) ) {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}
deactivate_plugins( plugin_basename( __FILE__ ) );
}
/**
* espresso3_duplicate_plugin_error
* displays if more than one version of EE is activated at the same time
*/
function espresso3_duplicate_plugin_error() {
?>
<div class="error">
<p><?php _e( 'Can not run multiple versions of Event Espresso! Please deactivate one of the versions.', 'event_espresso' ); ?></p>
</div>
<?php
}
define("EVENT_ESPRESSO_VERSION", espresso_version());
define('EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - ' . EVENT_ESPRESSO_VERSION);
//This tells the system to check for updates to the paid version
global $espresso_check_for_updates;
$espresso_check_for_updates = true;
function ee_init_session($admin_override = false) {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
//Keep sessions from loading in the WP admin
if ( is_admin() && (!isset($_REQUEST['events']) && !isset($_REQUEST['event_admin_reports'])) ) {
return;
}
global $org_options;
if (!isset($_SESSION)) {
session_start();
}
if (( isset($_REQUEST['page_id'])
&& ($_REQUEST['page_id'] == $org_options['return_url']
|| $_REQUEST['page_id'] == $org_options['notify_url'] ) )
|| !isset($_SESSION['espresso_session']['id'])
|| $_SESSION['espresso_session']['id'] == array()) {
$_SESSION['espresso_session'] = array();
$_SESSION['espresso_session']['id'] = session_id() . '-' . uniqid('', true);
$_SESSION['espresso_session']['events_in_session'] = array();
$_SESSION['espresso_session']['grand_total'] = '';
do_action( 'action_hook_espresso_zero_vlm_dscnt_in_session' );
}
}
add_action('init', 'ee_init_session', 1);
function ee_check_for_export() {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
if (isset($_REQUEST['export'])) {
if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/functions/export.php')) {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/functions/export.php');
espresso_export_stuff();
}
}
}
add_action('admin_init', 'ee_check_for_export');
function espresso_info_header() {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
print( "<meta name='generator' content='Event Espresso Version " . EVENT_ESPRESSO_VERSION . "' />");
}
add_action('wp_head', 'espresso_info_header');
//Globals
global $org_options, $wpdb, $this_is_a_reg_page, $espresso_content;
$espresso_content = '';
$this_is_a_reg_page = FALSE;
$org_options = get_option('events_organization_settings');
if (empty($org_options['event_page_id'])) {
$org_options['event_page_id'] = '';
$org_options['return_url'] = '';
$org_options['cancel_return'] = '';
$org_options['notify_url'] = '';
}
if (is_ssl()) {
$find = str_replace('https://', '', site_url());
} else {
$find = str_replace('http://', '', site_url());
}
function espresso_shortcode_pages( $page_id ) {
global $org_options, $this_is_a_reg_page;
$reg_page_ids = array(
$org_options['event_page_id'] => 'event_page_id',
$org_options['return_url'] => 'return_url',
$org_options['cancel_return'] => 'cancel_return',
$org_options['notify_url'] => 'notify_url'
);
if ( isset( $reg_page_ids[ $page_id ] )) {
switch( $reg_page_ids[ $page_id ] ) {
case 'event_page_id' :
$this_is_a_reg_page = TRUE;
add_action( 'init', 'event_espresso_run', 100 );
break;
case 'return_url' :
$this_is_a_reg_page = TRUE;
//Various attendee functions
require_once("includes/functions/attendee_functions.php");
//Payment/Registration Processing - Used to display the payment options and the payment link in the email. Used with the [ESPRESSO_PAYMENTS] tag
require_once("includes/process-registration/payment_page.php");
add_action( 'init', 'event_espresso_pay', 100 );
break;
case 'notify_url' :
$this_is_a_reg_page = TRUE;
add_action( 'init', 'event_espresso_txn', 100 );
break;
}
}
}
$page_id = isset($_REQUEST['page_id']) ? $_REQUEST['page_id'] : '';
if ( ! empty( $page_id )) {
espresso_shortcode_pages( $page_id );
} else {
// try to find post_name via the url
$find = str_replace($_SERVER['SERVER_NAME'], '', $find);
$uri_string = str_replace($find, '', $_SERVER['REQUEST_URI']);
$uri_string = isset($_SERVER['QUERY_STRING'])?str_replace($_SERVER['QUERY_STRING'], '', $uri_string):$uri_string;
$uri_string = rtrim($uri_string, '?');
$uri_string = trim($uri_string, '/');
$uri_segments = explode('/', $uri_string);
// then find the page id via the post_name
foreach ( $uri_segments as $uri_segment ) {
if ( $uri_segment != '' ) {
$page_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->posts WHERE post_name = %s ", $uri_segment ));
if ( $wpdb->num_rows > 0 ) {
espresso_shortcode_pages( $page_id );
}
} else {
if ( get_option('show_on_front') == 'page' ) {
$frontpage = get_option('page_on_front');
espresso_shortcode_pages( $frontpage );
}
}
}
}
if ( is_admin() ) {
$this_is_a_reg_page = TRUE;
}
//This will (should) make sure everything is loaded via SSL
//So that the "..not everything is secure.." message doesn't appear
//Still will be a problem if other themes and plugins do not implement ssl correctly
$wp_plugin_url = WP_PLUGIN_URL;
$wp_content_url = WP_CONTENT_URL;
if (is_ssl()) {
$wp_plugin_url = str_replace('http://', 'https://', WP_PLUGIN_URL);
$wp_content_url = str_replace('http://', 'https://', WP_CONTENT_URL);
//force admin-ajax.php to use https:// ssl
if ( !is_admin() )
add_filter('admin_url', 'ee_force_admin_ajax_ssl', 200, 2);
}
//Define the plugin directory and path
define("EVENT_ESPRESSO_PLUGINPATH", "/" . plugin_basename(dirname(__FILE__)) . "/");
define('EVENT_ESPRESSO_WPPLUGINPATH', plugin_basename(__FILE__) );
define("EVENT_ESPRESSO_PLUGINFULLPATH", WP_PLUGIN_DIR . EVENT_ESPRESSO_PLUGINPATH);
define("EVENT_ESPRESSO_PLUGINFULLURL", $wp_plugin_url . EVENT_ESPRESSO_PLUGINPATH);
//End - Define the plugin directory and path
$upload_path = WP_CONTENT_DIR . "/uploads";
$event_espresso_upload_dir = "{$upload_path}/espresso/";
$event_espresso_template_dir = "{$event_espresso_upload_dir}templates/";
$includes_directory = EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/';
define("EVENT_ESPRESSO_INCLUDES_DIR", $includes_directory);
define("EVENT_ESPRESSO_UPLOAD_DIR", $event_espresso_upload_dir);
define("EVENT_ESPRESSO_UPLOAD_URL", $wp_content_url . '/uploads/espresso/');
define("EVENT_ESPRESSO_TEMPLATE_DIR", $event_espresso_template_dir);
$event_espresso_gateway_dir = EVENT_ESPRESSO_UPLOAD_DIR . "gateways/";
define("EVENT_ESPRESSO_GATEWAY_DIR", $event_espresso_gateway_dir);
define("EVENT_ESPRESSO_GATEWAY_URL", $wp_content_url . '/uploads/espresso/gateways/');
//End - Define dierectory structure for uploads
//Languages folder/path
define( 'EE_LANGUAGES_SAFE_LOC', '../uploads/espresso/languages/');
define( 'EE_LANGUAGES_SAFE_DIR', $event_espresso_upload_dir.'languages/');
require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'class/espresso_log.php';
foreach ($_REQUEST as $key => $value) {
if ($key == 'cc' || $key == 'card_num' || $key == 'EPS_CARDNUMBER') {
$value = substr($value, 0, 4) . "-XXXX-XXXX-XXXX";
}
}
if ( isset( $GLOBALS['pagenow'] ) && ! in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ))) {
do_action( 'action_hook_espresso_log', __FILE__, __FUNCTION__, $_REQUEST );
}
//Define all of the plugins database tables
define("EVENTS_CATEGORY_TABLE", $wpdb->prefix . "events_category_detail");
define("EVENTS_CATEGORY_REL_TABLE", $wpdb->prefix . "events_category_rel");
define("EVENTS_DETAIL_TABLE", $wpdb->prefix . "events_detail");
define("EVENTS_ATTENDEE_TABLE", $wpdb->prefix . "events_attendee");
define("EVENTS_ATTENDEE_META_TABLE", $wpdb->prefix . "events_attendee_meta");
define("EVENTS_START_END_TABLE", $wpdb->prefix . "events_start_end");
define("EVENTS_QUESTION_TABLE", $wpdb->prefix . "events_question");
define("EVENTS_QST_GROUP_REL_TABLE", $wpdb->prefix . "events_qst_group_rel");
define("EVENTS_QST_GROUP_TABLE", $wpdb->prefix . "events_qst_group");
define("EVENTS_ANSWER_TABLE", $wpdb->prefix . "events_answer");
define("EVENTS_DISCOUNT_CODES_TABLE", $wpdb->prefix . "events_discount_codes");
define("EVENTS_DISCOUNT_REL_TABLE", $wpdb->prefix . "events_discount_rel");
define("EVENTS_PRICES_TABLE", $wpdb->prefix . "events_prices");
define("EVENTS_EMAIL_TABLE", $wpdb->prefix . "events_email");
//define("EVENTS_SESSION_TABLE", $wpdb->prefix . "events_sessions");
define("EVENTS_VENUE_TABLE", $wpdb->prefix . "events_venue");
define("EVENTS_VENUE_REL_TABLE", $wpdb->prefix . "events_venue_rel");
define("EVENTS_LOCALE_TABLE", $wpdb->prefix . "events_locale");
define("EVENTS_LOCALE_REL_TABLE", $wpdb->prefix . "events_locale_rel");
define("EVENTS_PERSONNEL_TABLE", $wpdb->prefix . "events_personnel");
define("EVENTS_PERSONNEL_REL_TABLE", $wpdb->prefix . "events_personnel_rel");
//$ten_thousand = 3000;
//$count = 2;
//global $wpdb;
//while($count++<$ten_thousand){
// $wpdb->insert(EVENTS_DISCOUNT_CODES_TABLE,array('coupon_code'=>"code$count",'use_percentage'=>'Y','coupon_code_price'=>$count),array('%s','%s','%s'));
//}
//Added by Imon
define("EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE", $wpdb->prefix . "events_multi_event_registration_id_group");
//define("EVENTS_ATTENDEE_COST_TABLE", $wpdb->prefix . "events_attendee_cost");
//Wordpress function for setting the locale.
//print get_locale();
//setlocale(LC_ALL, get_locale());
setlocale(LC_TIME, get_locale());
//Get language files
function espresso_load_language_files() {
$lang = get_locale();
espresso_sideload_current_lang();
if ( !empty($lang) && file_exists(EE_LANGUAGES_SAFE_DIR.'event_espresso-'.$lang.'.mo') ){
load_plugin_textdomain('event_espresso', false, EE_LANGUAGES_SAFE_LOC);
}else{
load_plugin_textdomain('event_espresso', false, dirname(plugin_basename(__FILE__)) . '/languages/');
}
}
add_action( 'plugins_loaded', 'espresso_load_language_files', 11 );
function ee_force_admin_ajax_ssl( $url, $scheme ) {
if ( preg_match('/admin-ajax.php/', $url ) ) {
$url = preg_replace( '#^.+://#', 'https' . '://', $url );
}
return $url;
}
function espresso_sideload_current_lang() {
$lang = get_locale();
//first let's see if we've already done an existing file check. || if $lang has a value
if ( $has_check = get_option('lang_file_check_' . $lang . '_' . EVENT_ESPRESSO_VERSION) || empty($lang) )
return;
//made it here so let's get the file from the github repo
$git_path = 'https://github.com/eventespresso/languages/blob/master/event_espresso-' . $lang . '.mo?raw=true';
//here's the download stuff
$temp_dir = get_temp_dir();
$tmp_file = basename($git_path);
$tmp_file = preg_replace('|\..*$|', '.tmp', $tmp_file);
$tmp_file = $temp_dir . wp_unique_filename($temp_dir, $tmp_file);
touch($tmp_file);
if ( !$tmp_file ) {
add_action('admin_notices', 'espresso_lang_sideload_error');
update_option('lang_file_check_' . $lang . '_' . EVENT_ESPRESSO_VERSION, 1);
return;
}
$response = wp_remote_get( $git_path, array( 'timeout' => 500, 'stream' => true, 'filename' => $tmp_file ) );
if ( is_wp_error($response) || 200 != wp_remote_retrieve_response_code( $response ) ) {
@unlink($tmp_file);
add_action('admin_notices', 'espresso_lang_sideload_error');
update_option('lang_file_check_' . $lang . '_' . EVENT_ESPRESSO_VERSION, 1);
return;
}
$file = $tmp_file;
//k we have the file now let's get it in the right directory with the right name.
$new_name = 'event_espresso-' . $lang . '.mo';
$new_path = EVENT_ESPRESSO_PLUGINFULLPATH . '/languages/' . $new_name;
//move file in
if ( false === @ rename( $file, $new_path ) ) {
add_action('admin_notices', 'espresso_lang_sideload_error_file_move');
update_option('lang_file_check_' . $lang . '_' . EVENT_ESPRESSO_VERSION, 1);
return;
}
//set correct permissions
$file_permissions = apply_filters( 'espresso_file_permissions', 0644 );
@ chmod( $new_path, $file_permissions);
//made it this far all looks good. So let's save option flag
update_option('lang_file_check_' . $lang . '_' . EVENT_ESPRESSO_VERSION, 1);
return;
}
function espresso_lang_sideload_error() {
$content = '<div class="updated">' . "\n\t";
$content .= '<p>' . _e('Something went wrong while trying to download the current language file for Event Espresso. Either github is not available, or we don\'t have a language file for your existing language.', 'event_espresso') . '</p>' . "\n";
$content .= '</div>' . "\n";
echo $content;
}
function espresso_lang_sideload_error_file_move() {
$content = '<div class="updated">' . "\n\t";
$content .= '<p>' . _e('Something went wrong while trying to download the current language file for Event Espresso. It looks like event-espresso was unable to move the file into the correct directory (possible permissions errors)', 'event_espresso') . '</p>' . "\n";
$content .= '</div>' . "\n";
echo $content;
}
//Addons
//Ticketing
if ( file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "ticketing/template.php") || function_exists('espresso_ticketing_version') ) {
global $ticketing_installed;
$ticketing_installed = true;
//echo '<h1>IN !!!</h1>'; die();
}
//Seating chart
if ($this_is_a_reg_page == TRUE && file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "/seatingchart/seatingchart.php")) {
require_once( EVENT_ESPRESSO_UPLOAD_DIR . "/seatingchart/seatingchart.php");
}
//Global files
//Premium funtions. If this is a paid version, then we need to include these files.
global $espresso_premium;
if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/misc_functions.php')) {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/misc_functions.php');
$espresso_premium = espresso_system_check();
}else{
$espresso_premium = false;
}
//Build the addon files
if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/addons_includes.php')) {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/addons_includes.php');
}
//Core function files
require_once("includes/functions/main.php");
function espresso_load_pricing_functions() {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
require_once("includes/functions/pricing.php");
}
add_action('plugins_loaded', 'espresso_load_pricing_functions', 2);
require_once("includes/functions/time_date.php");
require_once("includes/shortcodes.php");
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . "includes/functions/ical.php");
/* Core template files used by this plugin */
//These may be laoded in posts and pages outside of the default EE pages
// prevent firefox prefetching of the rel='next' link, which could be one of the
// pages that clears the ee session id
// http://www.ebrueggeman.com/blog/wordpress-relnext-and-firefox-prefetching
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
//Events Listing - Shows the events on your page. Used with the [ESPRESSO_EVENTS] shortcode
event_espresso_require_template('event_list.php');
//This is the form page for registering the attendee
event_espresso_require_template('registration_page.php');
//Registration forms
require_once("includes/functions/form_build.php");
//List Attendees - Used with the [LISTATTENDEES] shortcode
event_espresso_require_template('attendee_list.php');
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . "includes/functions/cart.php");
//Custom post type integration
if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/custom_post_type.php')
&& isset($org_options['use_custom_post_types']) && $org_options['use_custom_post_types'] == 'Y') {
require('includes/admin-files/custom_post_type.php');
}
//Widget - Display the list of events in your sidebar
//The widget can be over-ridden with the custom files addon
event_espresso_require_template('widget.php');
function load_event_espresso_widget() {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
if (!class_exists('Event_Espresso_Widget')) return;
register_widget('Event_Espresso_Widget');
}
add_action('widgets_init', 'load_event_espresso_widget');
/* End Core template files used by this plugin */
function event_espresso_pagination() {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
event_espresso_require_template('event_list.php');
$_REQUEST['use_wrapper'] = false;
event_espresso_get_event_details($_REQUEST);
die();
}
/**
* displays HTML for the discoutn code page within the widget
* onthe event details page. Assumed to be used for JSON, so we
* DIE at the end of the function
* @return void
*/
function event_espresso_discount_code_pagination(){
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
require(EVENT_ESPRESSO_PLUGINFULLPATH.'/includes/admin-files/event-management/promotions_page_for_box.php');
die();
}
add_action('wp_ajax_event_espresso_get_discount_codes', 'event_espresso_discount_code_pagination');
//add_action('wp_ajax_nopriv_event_espresso_add_item', 'event_espresso_add_item_to_session');
function event_espresso_get_discount_codes_for_jquery_datatables(){
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
require(EVENT_ESPRESSO_PLUGINFULLPATH.'/includes/admin-files/coupon-management/search.php');
espresso_promocodes_datatables_search();
die();
}
add_action('wp_ajax_event_espresso_get_discount_codes_for_jquery_datatables', 'event_espresso_get_discount_codes_for_jquery_datatables');
//Load these files if we are in an actuial registration page
if ($this_is_a_reg_page == TRUE) {
//Process email confirmations
require_once("includes/functions/email.php");
//Payment processing - Used for onsite payment processing. Used with the [ESPRESSO_TXN_PAGE] shortcode
event_espresso_require_gateway('process_payments.php');
event_espresso_require_gateway('PaymentGateway.php');
// AJAX functions
add_action('wp_ajax_event_espresso_add_item', 'event_espresso_add_item_to_session');
add_action('wp_ajax_nopriv_event_espresso_add_item', 'event_espresso_add_item_to_session');
add_action('wp_ajax_event_espresso_delete_item', 'event_espresso_delete_item_from_session');
add_action('wp_ajax_nopriv_event_espresso_delete_item', 'event_espresso_delete_item_from_session');
add_action('wp_ajax_event_espresso_update_item', 'event_espresso_update_item_in_session');
add_action('wp_ajax_nopriv_event_espresso_update_item', 'event_espresso_update_item_in_session');
add_action('wp_ajax_event_espresso_calculate_total', 'event_espresso_calculate_total');
add_action('wp_ajax_nopriv_event_espresso_calculate_total', 'event_espresso_calculate_total');
add_action('wp_ajax_event_espresso_load_regis_form', 'event_espresso_load_regis_form');
add_action('wp_ajax_nopriv_event_espresso_load_regis_form', 'event_espresso_load_regis_form');
add_action('wp_ajax_event_espresso_confirm_and_pay', 'event_espresso_confirm_and_pay');
add_action('wp_ajax_nopriv_event_espresso_confirm_and_pay', 'event_espresso_confirm_and_pay');
add_action('wp_ajax_events_pagination','event_espresso_pagination');
add_action('wp_ajax_nopriv_events_pagination','event_espresso_pagination');
}
if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/coupon-management/index.php')) {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/coupon-management/index.php');
//Include dicount codes
require_once("includes/admin-files/coupon-management/use_coupon_code.php");
} else {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/coupon_management.php');
}
require_once("includes/functions/admin.php");
//Admin only files
if (is_admin()) {
do_action('action_hook_espresso_include_admin_files_start');
if ($espresso_premium != true)
require_once("includes/test_drive_pro.php");
//Load the roles and permissions functions
do_action('action_hook_espresso_permissions');
//Update notifications
do_action('action_hook_espresso_core_update_api');
do_action('action_hook_espresso_members_update_api');
do_action('action_hook_espresso_multiple_update_api');
do_action('action_hook_espresso_calendar_update_api');
do_action('action_hook_espresso_groupon_update_api');
do_action('action_hook_espresso_permissions_basic_update_api');
do_action('action_hook_espresso_permissions_pro_update_api');
do_action('action_hook_espresso_seating_update_api');
do_action('action_hook_espresso_social_update_api');
do_action('action_hook_espresso_recurring_update_api');
do_action('action_hook_espresso_ticketing_update_api');
do_action('action_hook_espresso_mailchimp_update_api');
do_action('action_hook_espresso_json_update_api');
do_action('action_hook_espresso_epm_update_api');
do_action('action_hook_espresso_infusionsoft_update_api');
do_action('action_hook_espresso_attendee_mover_update_api');
//Custom templates addon
do_action('action_hook_espresso_custom_templates_update_api');
do_action('action_hook_espresso_template_calendar_table_update_api');
do_action('action_hook_espresso_template_category_accordion_update_api');
do_action('action_hook_espresso_template_date_range_update_api');
do_action('action_hook_espresso_template_grid_update_api');
do_action('action_hook_espresso_template_masonry_grid_update_api');
do_action('action_hook_espresso_template_recurring_dropdown_update_api');
do_action('action_hook_espresso_template_vector_map_update_api');
//New form builder
require_once("includes/form-builder/index.php");
require_once("includes/form-builder/groups/index.php");
//Install/Update Tables when plugin is activated
register_activation_hook(__FILE__, 'espresso_check_data_tables');
register_activation_hook(__FILE__, 'espresso_update_active_gateways');
register_activation_hook(__FILE__, 'espresso_migrate_atos_gateway');
//Premium funtions. If this is a paid version, then we need to include these files.
//Premium upgrade options if the piad plugin is not installed
require_once("includes/premium_upgrade.php");
//Get the payment settings page
event_espresso_require_gateway('payment_gateways.php');
//Email Manager
if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/email-manager/index.php')) {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/email-manager/index.php');
} else {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/email-manager.php');
}
//Event Registration Subpage - Add/Delete/Edit Venues
if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/venue-management/index.php')) {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/venue-management/index.php');
} else {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/venue_management.php');
}
//Add/Delete/Edit Locales
if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/locale-management/index.php')) {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/locale-management/index.php');
} else {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/locale_management.php');
}
//Add/Delete/Edit Staff
if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/staff-management/index.php')) {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/staff-management/index.php');
} else {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/staff-management.php');
}
//Main functions
if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/functions.php')) {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/functions.php');
}
//Available addons
if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/admin_addons.php')) {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/admin_addons.php');
} else {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin_addons.php');
}
//Admin Widget - Display event stats in your admin dashboard
event_espresso_require_file('dashboard_widget.php', EVENT_ESPRESSO_PLUGINFULLPATH . "includes/admin-files/", '', false, true);
//Admin only functions
require_once("includes/functions/admin_menu.php");
//Event Registration Subpage - Configure Organization
if ( isset($_REQUEST['page']) && $_REQUEST['page'] == 'event_espresso' ) {
require_once("includes/organization_config.php");
}
//Event Registration Subpage - Add/Delete/Edit Events
if ( isset($_REQUEST['page']) && $_REQUEST['page'] == 'events' ) {
require_once("includes/event-management/index.php");
}
//Event styles & template layouts Subpage
if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/template_settings/index.php')) {
require_once(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/template_settings/index.php');
}
//Plugin Support
if ( isset($_REQUEST['page']) && $_REQUEST['page'] == 'support' ) {
require_once("includes/admin_support.php");
}
//System Status
if ( isset($_REQUEST['page']) && $_REQUEST['page'] == 'espresso-system-status' ) {
require_once("includes/espresso-admin-status.php");
}
//Admin Reporting
//require_once("includes/admin-reports/index.php");
//Event Registration Subpage - Category Manager
require_once("includes/category-management/index.php");
//Load scripts and styles for the admin
if (isset($_REQUEST['page'])) {
$espresso_pages = apply_filters('filter_hook_espresso_admin_pages_list',array(
'event_espresso',
'discounts',
'groupons',
'event_categories',
'admin_reports',
'form_builder',
'form_groups',
'my-events',
'event_emails',
'event_venues',
'event_staff',
'events',
'espresso_reports',
'support',
'template_confg',
'payment_gateways',
'members',
'admin_addons',
'espresso_calendar',
'event_tickets',
'espresso-mailchimp',
'espresso_social',
'espresso_permissions',
'roles',
'event_locales',
'espresso-system-status',
'event_groups'
));
if (in_array($_REQUEST['page'], $espresso_pages)) {
add_action('admin_print_scripts', 'event_espresso_config_page_scripts');
add_action('admin_print_styles', 'event_espresso_config_page_styles');
}
}
add_action('wp_ajax_update_sequence', 'event_espresso_questions_config_mnu'); //Update the question sequences
add_action('wp_ajax_update_qgr_sequence', 'event_espresso_question_groups_config_mnu'); //Update the question group sequences
}
//Load the required Javascripts
add_action('wp_enqueue_scripts', 'espresso_load_javascript_files');
add_action('wp_enqueue_scripts', 'espresso_register_validation_for_shortcodes');
add_action('wp_enqueue_scripts', 'espresso_load_jquery', 10);
add_action('admin_enqueue_scripts', 'espresso_load_EEGlobals_jquery', 10);
add_action('wp_enqueue_scripts', 'espresso_load_pagination_scripts');
if (!function_exists('espresso_load_javascript_files')) {
function espresso_load_javascript_files() {
global $load_espresso_scripts;
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
if (!$load_espresso_scripts)
return;
wp_register_script('reCopy', (EVENT_ESPRESSO_PLUGINFULLURL . "scripts/reCopy.js"), array('jquery'), '1.1.0', TRUE);
wp_enqueue_script('reCopy');
wp_register_script('jquery.validate.js', (EVENT_ESPRESSO_PLUGINFULLURL . "scripts/jquery.validate.min.js"), array('jquery'), '1.8.1', TRUE);
wp_enqueue_script('jquery.validate.js');
wp_register_script('validation', (EVENT_ESPRESSO_PLUGINFULLURL . "scripts/validation.js"), array('jquery.validate.js'), EVENT_ESPRESSO_VERSION, TRUE);
wp_enqueue_script('validation');
}
}
if (!function_exists('espresso_register_validation_for_shortcodes')) {
function espresso_register_validation_for_shortcodes() {
// registers the jQuery validation scripts for use with the [ESPRESSO_REG_PAGE], [ESPRESSO_REG_FORM], and [SINGLEEVENT] shortcodes
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
wp_register_script('jquery.validate.js', (EVENT_ESPRESSO_PLUGINFULLURL . "scripts/jquery.validate.min.js"), array('jquery'), '1.8.1', TRUE);
wp_register_script('validation', (EVENT_ESPRESSO_PLUGINFULLURL . "scripts/validation.js"), array('jquery.validate.js'), EVENT_ESPRESSO_VERSION, TRUE);
}
}
if (!function_exists('espresso_load_pagination_scripts')) {
function espresso_load_pagination_scripts() {
wp_register_script('ee_pagination_plugin', (EVENT_ESPRESSO_PLUGINFULLURL . "scripts/jquery.pajinate.min.js"), array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
wp_enqueue_script('ee_pagination_plugin');
wp_register_script('ee_pagination', (EVENT_ESPRESSO_PLUGINFULLURL . "scripts/pagination.js"), array('ee_pagination_plugin'), EVENT_ESPRESSO_VERSION, TRUE);
wp_enqueue_script('ee_pagination');
$data = array( 'ajaxurl' => admin_url( 'admin-ajax.php' ));
wp_localize_script( 'ee_pagination', 'ee_pagination', $data );
}
}
//Used for the drag and drop questions
if (!function_exists('espresso_load_EEGlobals_jquery')) {
function espresso_load_EEGlobals_jquery(){
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
if ( isset($_REQUEST['page']) && ( $_REQUEST['page'] == 'form_builder' || $_REQUEST['page'] == 'form_groups') ){
//wp_enqueue_script( 'jquery' );
wp_enqueue_script('ee_ajax_request', EVENT_ESPRESSO_PLUGINFULLURL . 'scripts/espresso_EEGlobals_functions.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
wp_localize_script( 'ee_ajax_request', 'EEGlobals', array('ajaxurl' => admin_url('admin-ajax.php'), 'plugin_url' => EVENT_ESPRESSO_PLUGINFULLURL) );
}
}
}
//Used for the event cart
if (!function_exists('espresso_load_jquery')) {
function espresso_load_jquery() {
global $wp_version;
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
if (!is_admin() ) {
global $org_options;
//wp_enqueue_script('jquery');
if ( function_exists('event_espresso_multi_reg_init') ) {
wp_enqueue_script('ee_ajax_request', EVENT_ESPRESSO_PLUGINFULLURL . 'scripts/espresso_cart_functions.js', array('jquery'), EVENT_ESPRESSO_VERSION);
$EEGlobals = array('ajaxurl' => admin_url('admin-ajax.php'), 'plugin_url' => EVENT_ESPRESSO_PLUGINFULLURL, 'event_page_id' => $org_options['event_page_id']);
wp_localize_script('ee_ajax_request', 'EEGlobals',$EEGlobals );
//Load the jQuery migrate scripts if WP is older than 3.6
if ( !version_compare($wp_version, '3.6', '>=' ) ) {
wp_register_script('jquery-migrate', EVENT_ESPRESSO_PLUGINFULLURL . 'scripts/jquery-migrate-1.1.1.min.js', array('jquery'), EVENT_ESPRESSO_VERSION);
}
wp_enqueue_script('jquery-migrate');
}
}
}
}
//End Javascript files
//Load the style sheets for the reegistration pages
//This is the old style settings. Will be deprecated/removed soon.
add_action('wp_enqueue_scripts', 'add_event_espresso_stylesheet');
if (!function_exists('add_event_espresso_stylesheet')) {
function add_event_espresso_stylesheet() {
global $org_options;
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
if (isset($org_options['enable_default_style']) && $org_options['enable_default_style'] != 'Y')
return;
if (!empty($org_options['style_settings']['enable_default_style']) && $org_options['style_settings']['enable_default_style'] == 'Y')
return;
// for backpat we check options to see if event_espresso_style.css is set if is or no option is set we load it from original folder
if (empty($org_options['selected_style']) || $org_options['selected_style'] == 'event_espresso_style.css') {
$style_path = 'templates/event_espresso_style.css';
} else {
$style_path = 'templates/css/' . $org_options['selected_style'];
}
$event_espresso_style_sheet = EVENT_ESPRESSO_PLUGINFULLURL . $style_path;
if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "templates/event_espresso_style.css")) {
$event_espresso_style_sheet = EVENT_ESPRESSO_UPLOAD_URL . 'templates/event_espresso_style.css';
}
wp_register_style('event_espresso_style_sheets', $event_espresso_style_sheet, array(), EVENT_ESPRESSO_VERSION );
wp_enqueue_style('event_espresso_style_sheets');
if (!file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "templates/event_espresso_style.css") && !empty($org_options['style_color'])) {
$event_espresso_style_color = EVENT_ESPRESSO_PLUGINFULLURL . 'templates/css/colors/' . $org_options['style_color'];
wp_register_style('event_espresso_style_color', $event_espresso_style_color, array(), EVENT_ESPRESSO_VERSION);
wp_enqueue_style('event_espresso_style_color');
}
}
}
//Themeroller stuff
add_action('wp_enqueue_scripts', 'add_espresso_themeroller_stylesheet');
function add_espresso_themeroller_stylesheet() {
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
global $org_options;
//Load the ThemeRoller styles if enabled
if (!empty($org_options['style_settings']['enable_default_style']) && $org_options['style_settings']['enable_default_style'] == 'Y') {
//Define the path to the ThemeRoller files
if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "themeroller/index.php")) {
$themeroller_style_path = EVENT_ESPRESSO_UPLOAD_URL . 'themeroller/';
} else {
$themeroller_style_path = EVENT_ESPRESSO_PLUGINFULLURL . 'templates/css/themeroller/';
}
//Load custom style sheet if available
if (!empty($org_options['style_settings']['css_name'])) {
wp_register_style('espresso_custom_css', EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $org_options['style_settings']['css_name'], array(), EVENT_ESPRESSO_VERSION);
wp_enqueue_style('espresso_custom_css');
}
//Register the ThemeRoller styles
if (!empty($org_options['themeroller']) && !is_admin()) {
//Load the themeroller base style sheet
//If the themeroller-base.css is in the uploads folder, then we will use it instead of the one in the core
if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'themeroller/themeroller-base.css')) {
wp_register_style('espresso_themeroller_base', $themeroller_style_path . 'themeroller-base.css');
} else {
wp_register_style('espresso_themeroller_base', EVENT_ESPRESSO_PLUGINFULLURL . 'templates/css/themeroller/themeroller-base.css', array(), EVENT_ESPRESSO_VERSION);
}
wp_enqueue_style('espresso_themeroller_base');
//Load the smoothness style by default<br />
if (!isset($org_options['themeroller']['themeroller_style']) || empty($org_options['themeroller']['themeroller_style']) || $org_options['themeroller']['themeroller_style'] == 'N' ) {
$org_options['themeroller']['themeroller_style'] = 'smoothness';
}
//Load the selected themeroller style
wp_register_style('espresso_themeroller', $themeroller_style_path . $org_options['themeroller']['themeroller_style'] . '/style.css', array(), EVENT_ESPRESSO_VERSION);
wp_enqueue_style('espresso_themeroller');
}
}else{
if (!empty($org_options['style_settings']['enable_default_style']) && $org_options['style_settings']['enable_default_style'] == 'Y')
return;
//Load a default style sheet
$event_espresso_style_sheet = EVENT_ESPRESSO_PLUGINFULLURL . 'templates/css/espresso_default.css';
if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "templates/css/espresso_default.css")) {
$event_espresso_style_sheet = EVENT_ESPRESSO_UPLOAD_URL . 'templates/css/espresso_default.css';
}
wp_register_style('event_espresso_style_sheets', $event_espresso_style_sheet, array(), EVENT_ESPRESSO_VERSION);
wp_enqueue_style('event_espresso_style_sheets');
}
}
/**
* Add a settings link to the Plugins page, so people can go straight from the plugin page to the
* settings page.
*/
function event_espresso_filter_plugin_actions($links, $file) {
// Static so we don't call plugin_basename on every plugin row.
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
static $this_plugin;
if (!$this_plugin)
$this_plugin = plugin_basename(__FILE__);
if ($file == $this_plugin) {
$org_settings_link = '<a href="admin.php?page=event_espresso">' . __('Settings') . '</a>';
$events_link = '<a href="admin.php?page=events">' . __('Events') . '</a>';
array_unshift($links, $org_settings_link, $events_link); // before other links
}
return $links;
}
//Settings link in the plugins overview page
add_filter('plugin_action_links', 'event_espresso_filter_plugin_actions', 10, 2);
//Admin menu
add_action('admin_menu', 'add_event_espresso_menus');
//Run the program
if (!function_exists('event_espresso_run')) {
function event_espresso_run() {
global $wpdb, $org_options, $load_espresso_scripts, $espresso_content;
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
$load_espresso_scripts = true; //This tells the plugin to load the required scripts
ob_start();
//Make sure scripts are loading
echo espresso_check_scripts();
// Get action type
$regevent_action = isset($_REQUEST['regevent_action']) ? $_REQUEST['regevent_action'] : '';
if (isset($_REQUEST['event_id']) && !empty($_REQUEST['event_id'])) {
$_REQUEST['event_id'] = wp_strip_all_tags( absint($_REQUEST['event_id']) );
}
if (isset($_REQUEST['form_action']) && !empty($_REQUEST['form_action'])) {
if (isset($_REQUEST['form_action']) && !$_REQUEST['form_action'] == 'edit_attendee' ) {
$_REQUEST['primary'] = wp_strip_all_tags( absint($_REQUEST['primary']) );
}
}
if (isset($_REQUEST['ee']) && !empty($_REQUEST['ee'])) {
$regevent_action = "register";
$_REQUEST['ee'] = wp_strip_all_tags( absint($_REQUEST['ee']) );
$_REQUEST['event_id'] = $_REQUEST['ee'];
}
if ((isset($_REQUEST['form_action']) && $_REQUEST['form_action'] == 'edit_attendee') || (isset($_REQUEST['edit_attendee']) && $_REQUEST['edit_attendee'] == 'true')) {
$regevent_action = "edit_attendee";
}
switch ($regevent_action) {
case "register":
register_attendees();
break;
case "post_attendee":
//Various attendee functions
require_once("includes/functions/attendee_functions.php");
//Add attendees to the database
require_once("includes/process-registration/add_attendees_to_db.php");
//Payment/Registration Processing - Used to display the payment options and the payment link in the email. Used with the [ESPRESSO_PAYMENTS] tag
require_once("includes/process-registration/payment_page.php");
event_espresso_add_attendees_to_db( NULL, NULL, FALSE );
break;