-
Notifications
You must be signed in to change notification settings - Fork 1
/
wp-events-manager.php
178 lines (152 loc) · 4.42 KB
/
wp-events-manager.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
<?php
/**
* Plugin Name: WP Events Manager
* Plugin URI: http://thimpress.com/
* Description: A complete plugin for Events management and online booking system
* Author: ThimPress
* Version: 2.2.0
* Requires PHP: 7.4
* Author URI: http://thimpress.com
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
/**
* WPEMS class
*/
if ( ! class_exists( 'WPEMS' ) ) {
final class WPEMS {
private static $_instance = null;
public $_session = null;
public $settings = null;
/**
* WPEMS constructor.
*/
public function __construct() {
try {
$this->define_constants();
$this->includes();
$this->init_hooks();
} catch ( Throwable $e ) {
error_log( $e->getMessage() );
}
}
/**
* Define Plugins Constants
*/
public function define_constants() {
$this->set_define( 'WPEMS_PATH', plugin_dir_path( __FILE__ ) );
$this->set_define( 'WPEMS_URI', plugin_dir_url( __FILE__ ) );
$this->set_define( 'WPEMS_INC', WPEMS_PATH . 'inc/' );
$this->set_define( 'WPEMS_INC_URI', WPEMS_URI . 'inc/' );
$this->set_define( 'WPEMS_ASSETS_URI', WPEMS_URI . 'assets/' );
$this->set_define( 'WPEMS_LIB_URI', WPEMS_INC_URI . 'libraries/' );
$this->set_define( 'WPEMS_VER', '2.1.8' );
$this->set_define( 'WPEMS_MAIN_FILE', __FILE__ );
}
public function set_define( $name = '', $value = '' ) {
if ( $name && ! defined( $name ) ) {
define( $name, $value );
}
}
/**
* Init hooks plugins
* @since 2.0
*/
public function init_hooks() {
// plugin loaded
add_action( 'plugins_loaded', array( $this, 'loaded' ) );
}
/**
* Load components when plugin loaded
*/
public function loaded() {
// load text domain
$this->text_domain();
$this->_session = new WPEMS_Session();
do_action( 'wpems_init', $this );
}
/**
* Include files.
*/
public function includes() {
$this->_include( 'inc/wpems-core-functions.php' );
$this->_include( 'inc/class-wpems-autoloader.php' );
$this->_include( 'inc/class-wpems-assets.php' );
$this->_include( 'inc/class-wpems-ajax.php' );
$this->_include( 'inc/class-wpems-post-types.php' );
$this->_include( 'inc/emails/class-wpems-register-event.php' );
$this->_include( 'inc/class-wpems-payment-gateways.php' );
$this->_include( 'inc/class-wpems-install.php' );
$this->_include( 'inc/class-wpems-settings.php' );
$this->_include( 'inc/class-wpems-session.php' );
$this->_include( 'inc/class-wpems-booking.php' );
$this->_include( 'inc/class-wpems-event.php' );
$this->settings = WPEMS_Settings::instance();
if ( is_admin() ) {
$this->_include( 'inc/admin/class-wpems-admin.php' );
} else {
$this->_include( 'inc/class-wpems-template.php' );
$this->_include( 'inc/class-wpems-frontend-assets.php' );
$this->_include( 'inc/class-wpems-user-process.php' );
$this->_include( 'inc/class-wpems-shortcodes.php' );
}
$this->_include( 'inc/class-wpems-gdpr.php' );
}
/**
* Include single file
*
* @param $file
*/
public function _include( $file = null ) {
if ( is_array( $file ) ) {
foreach ( $file as $key => $f ) {
if ( file_exists( WPEMS_PATH . $f ) ) {
require_once WPEMS_PATH . $f;
}
}
} else {
if ( file_exists( WPEMS_PATH . $file ) ) {
require_once WPEMS_PATH . $file;
} elseif ( file_exists( $file ) ) {
require_once $file;
}
}
}
/**
* load text domain
* @return null
*/
public function text_domain() {
// Get mo file
$text_domain = 'wp-events-manager';
$locale = apply_filters( 'plugin_locale', get_locale(), $text_domain );
$mo_file = $text_domain . '-' . $locale . '.mo';
// Check mo file global
$mo_global = WP_LANG_DIR . '/plugins/' . $mo_file;
// Load translate file
if ( file_exists( $mo_global ) ) {
load_textdomain( $text_domain, $mo_global );
} else {
load_textdomain( $text_domain, WPEMS_PATH . '/languages/' . $mo_file );
}
}
/**
* get instance class
* @return WPEMS
*/
public static function instance() {
if ( ! empty( self::$_instance ) ) {
return self::$_instance;
}
return self::$_instance = new self();
}
}
if ( ! function_exists( 'WPEMS' ) ) {
function WPEMS() {
return WPEMS::instance();
}
}
WPEMS();
}
$GLOBALS['WPEMS'] = WPEMS();