|
1
|
|
|
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2
|
|
|
/** |
|
3
|
|
|
* Event Espresso |
|
4
|
|
|
* |
|
5
|
|
|
* Event Registration and Management Plugin for WordPress |
|
6
|
|
|
* |
|
7
|
|
|
* @ package Event Espresso |
|
8
|
|
|
* @ author Event Espresso |
|
9
|
|
|
* @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10
|
|
|
* @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11
|
|
|
* @ link http://www.eventespresso.com |
|
12
|
|
|
* @ version 4.0 |
|
13
|
|
|
* |
|
14
|
|
|
* ------------------------------------------------------------------------ |
|
15
|
|
|
* |
|
16
|
|
|
* EE_Config |
|
17
|
|
|
* |
|
18
|
|
|
* @package Event Espresso |
|
19
|
|
|
* @subpackage core/ |
|
20
|
|
|
* @author Brent Christensen |
|
21
|
|
|
* |
|
22
|
|
|
* ------------------------------------------------------------------------ |
|
23
|
|
|
*/ |
|
24
|
|
|
final class EE_Config { |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* instance of the EE_Config object |
|
29
|
|
|
* @var EE_Config $_instance |
|
30
|
|
|
* @access private |
|
31
|
|
|
*/ |
|
32
|
|
|
private static $_instance = NULL; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* An StdClass whose property names are addon slugs, |
|
36
|
|
|
* and values are their config classes |
|
37
|
|
|
* @var StdClass |
|
38
|
|
|
*/ |
|
39
|
|
|
public $addons = null; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* |
|
43
|
|
|
* @var EE_Admin_Config |
|
44
|
|
|
*/ |
|
45
|
|
|
public $admin = null; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* |
|
49
|
|
|
* @var EE_Core_Config |
|
50
|
|
|
*/ |
|
51
|
|
|
public $core = null; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* |
|
55
|
|
|
* @var EE_Currency_Config |
|
56
|
|
|
*/ |
|
57
|
|
|
public $currency = null; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* |
|
61
|
|
|
* @var EE_Organization_Config |
|
62
|
|
|
*/ |
|
63
|
|
|
public $organization = null; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* |
|
67
|
|
|
* @var EE_Registration_Config |
|
68
|
|
|
*/ |
|
69
|
|
|
public $registration = null; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* |
|
73
|
|
|
* @var EE_Template_Config |
|
74
|
|
|
*/ |
|
75
|
|
|
public $template_settings = null; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Holds EE environment values. |
|
79
|
|
|
* |
|
80
|
|
|
* @var EE_Environment_Config |
|
81
|
|
|
*/ |
|
82
|
|
|
public $environment = null; |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* settings pertaining to Google maps |
|
86
|
|
|
* |
|
87
|
|
|
* @var EE_Map_Config |
|
88
|
|
|
*/ |
|
89
|
|
|
public $map_settings = null; |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* |
|
93
|
|
|
* @deprecated |
|
94
|
|
|
* @var EE_Gateway_Config |
|
95
|
|
|
*/ |
|
96
|
|
|
public $gateway = null; |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @var array $_config_option_names |
|
100
|
|
|
* @access private |
|
101
|
|
|
*/ |
|
102
|
|
|
private $_config_option_names = array(); |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @var array $_module_route_map |
|
106
|
|
|
* @access private |
|
107
|
|
|
*/ |
|
108
|
|
|
private static $_module_route_map = array(); |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @var array $_module_forward_map |
|
112
|
|
|
* @access private |
|
113
|
|
|
*/ |
|
114
|
|
|
private static $_module_forward_map = array(); |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @var array $_module_view_map |
|
118
|
|
|
* @access private |
|
119
|
|
|
*/ |
|
120
|
|
|
private static $_module_view_map = array(); |
|
121
|
|
|
|
|
122
|
|
|
|
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @singleton method used to instantiate class object |
|
126
|
|
|
* @access public |
|
127
|
|
|
* @return EE_Config instance |
|
128
|
|
|
*/ |
|
129
|
|
|
public static function instance() { |
|
130
|
|
|
// check if class object is instantiated, and instantiated properly |
|
131
|
|
|
if ( ! self::$_instance instanceof EE_Config ) { |
|
132
|
|
|
self::$_instance = new self(); |
|
133
|
|
|
} |
|
134
|
|
|
return self::$_instance; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
|
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* Resets the config |
|
141
|
|
|
* @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
142
|
|
|
* (default) leaves the database alone, and merely resets the EE_Config object to reflect its state in the database |
|
143
|
|
|
* @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
144
|
|
|
* $_instance as NULL. Useful in case you want to forget about the old instance on EE_Config, but might |
|
145
|
|
|
* not be ready to instantiate EE_Config currently (eg if the site was put into maintenance mode) |
|
146
|
|
|
* @return EE_Config |
|
147
|
|
|
*/ |
|
148
|
|
|
public static function reset( $hard_reset = FALSE, $reinstantiate = TRUE ){ |
|
149
|
|
|
if ( $hard_reset ) { |
|
150
|
|
|
self::$_instance->_config_option_names = array(); |
|
151
|
|
|
self::$_instance->_initialize_config(); |
|
152
|
|
|
self::$_instance->update_espresso_config(); |
|
153
|
|
|
} |
|
154
|
|
|
if( self::$_instance instanceof EE_Config ){ |
|
155
|
|
|
self::$_instance->shutdown(); |
|
156
|
|
|
} |
|
157
|
|
|
self::$_instance = NULL; |
|
158
|
|
|
//we don't need to reset the static properties imo because those should |
|
159
|
|
|
//only change when a module is added or removed. Currently we don't |
|
160
|
|
|
//support removing a module during a request when it previously existed |
|
161
|
|
|
if( $reinstantiate ){ |
|
162
|
|
|
return self::instance(); |
|
163
|
|
|
}else{ |
|
164
|
|
|
return NULL; |
|
165
|
|
|
} |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
|
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* class constructor |
|
172
|
|
|
* |
|
173
|
|
|
* @access private |
|
174
|
|
|
* @return \EE_Config |
|
|
|
|
|
|
175
|
|
|
*/ |
|
176
|
|
|
private function __construct() { |
|
177
|
|
|
do_action( 'AHEE__EE_Config__construct__begin',$this ); |
|
178
|
|
|
$this->_config_option_names = get_option( 'ee_config_option_names', array() ); |
|
179
|
|
|
// setup empty config classes |
|
180
|
|
|
$this->_initialize_config(); |
|
181
|
|
|
// load existing EE site settings |
|
182
|
|
|
$this->_load_core_config(); |
|
183
|
|
|
// confirm everything loaded correctly and set filtered defaults if not |
|
184
|
|
|
$this->_verify_config(); |
|
185
|
|
|
// register shortcodes and modules |
|
186
|
|
|
add_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_and_modules' ), 999 ); |
|
187
|
|
|
// initialize shortcodes and modules |
|
188
|
|
|
add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'initialize_shortcodes_and_modules' )); |
|
189
|
|
|
// register widgets |
|
190
|
|
|
add_action( 'widgets_init', array( $this, 'widgets_init' ), 10 ); |
|
191
|
|
|
// shutdown |
|
192
|
|
|
add_action( 'shutdown', array( $this, 'shutdown' ), 10 ); |
|
193
|
|
|
// construct__end hook |
|
194
|
|
|
do_action( 'AHEE__EE_Config__construct__end',$this ); |
|
195
|
|
|
// hardcoded hack |
|
196
|
|
|
$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
|
|
200
|
|
|
|
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* use to get the current theme if needed from static context |
|
204
|
|
|
* @return string current theme set. |
|
205
|
|
|
*/ |
|
206
|
|
|
public static function get_current_theme() { |
|
207
|
|
|
return isset( self::$_instance->template_settings->current_espresso_theme ) ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
|
|
211
|
|
|
|
|
212
|
|
|
|
|
213
|
|
|
/** |
|
214
|
|
|
* _initialize_config |
|
215
|
|
|
* |
|
216
|
|
|
* @access private |
|
217
|
|
|
* @return void |
|
218
|
|
|
*/ |
|
219
|
|
|
private function _initialize_config() { |
|
220
|
|
|
//set defaults |
|
221
|
|
|
$this->addons = new stdClass(); |
|
222
|
|
|
// set _module_route_map |
|
223
|
|
|
EE_Config::$_module_route_map = array(); |
|
224
|
|
|
// set _module_forward_map |
|
225
|
|
|
EE_Config::$_module_forward_map = array(); |
|
226
|
|
|
// set _module_view_map |
|
227
|
|
|
EE_Config::$_module_view_map = array(); |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
|
|
231
|
|
|
|
|
232
|
|
|
|
|
233
|
|
|
/** |
|
234
|
|
|
* load core plugin configuration |
|
235
|
|
|
* |
|
236
|
|
|
* @access private |
|
237
|
|
|
* @return void |
|
238
|
|
|
*/ |
|
239
|
|
|
private function _load_core_config() { |
|
240
|
|
|
// load_core_config__start hook |
|
241
|
|
|
do_action( 'AHEE__EE_Config___load_core_config__start', $this ); |
|
242
|
|
|
$espresso_config = $this->get_espresso_config(); |
|
243
|
|
|
foreach ( $espresso_config as $config => $settings ) { |
|
244
|
|
|
// load_core_config__start hook |
|
245
|
|
|
$settings = apply_filters( 'FHEE__EE_Config___load_core_config__config_settings', $settings, $config, $this ); |
|
246
|
|
|
if ( is_object( $settings ) && property_exists( $this, $config ) ) { |
|
247
|
|
|
$this->{$config} = apply_filters( 'FHEE__EE_Config___load_core_config__' . $config, $settings ); |
|
248
|
|
|
//call configs populate method to ensure any defaults are set for empty values. |
|
249
|
|
|
if ( method_exists( $settings, 'populate' ) ) { |
|
250
|
|
|
$this->{$config}->populate(); |
|
251
|
|
|
} |
|
252
|
|
|
if ( method_exists( $settings, 'do_hooks' ) ) { |
|
253
|
|
|
$this->{$config}->do_hooks(); |
|
254
|
|
|
} |
|
255
|
|
|
} |
|
256
|
|
|
} |
|
257
|
|
|
if ( apply_filters( 'FHEE__EE_Config___load_core_config__update_espresso_config', FALSE ) ) { |
|
258
|
|
|
$this->update_espresso_config(); |
|
259
|
|
|
} |
|
260
|
|
|
// load_core_config__end hook |
|
261
|
|
|
do_action( 'AHEE__EE_Config___load_core_config__end', $this ); |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
|
|
265
|
|
|
|
|
266
|
|
|
/** |
|
267
|
|
|
* _verify_config |
|
268
|
|
|
* |
|
269
|
|
|
* @access protected |
|
270
|
|
|
* @return void |
|
271
|
|
|
*/ |
|
272
|
|
|
protected function _verify_config() { |
|
273
|
|
|
|
|
274
|
|
|
$this->core = $this->core instanceof EE_Core_Config |
|
275
|
|
|
? $this->core : new EE_Core_Config(); |
|
276
|
|
|
$this->core = apply_filters( 'FHEE__EE_Config___initialize_config__core', $this->core ); |
|
277
|
|
|
|
|
278
|
|
|
$this->organization = $this->organization instanceof EE_Organization_Config |
|
279
|
|
|
? $this->organization : new EE_Organization_Config(); |
|
280
|
|
|
$this->organization = apply_filters( 'FHEE__EE_Config___initialize_config__organization', $this->organization ); |
|
281
|
|
|
|
|
282
|
|
|
$this->currency = $this->currency instanceof EE_Currency_Config |
|
283
|
|
|
? $this->currency : new EE_Currency_Config(); |
|
284
|
|
|
$this->currency = apply_filters( 'FHEE__EE_Config___initialize_config__currency', $this->currency ); |
|
285
|
|
|
|
|
286
|
|
|
$this->registration = $this->registration instanceof EE_Registration_Config |
|
287
|
|
|
? $this->registration : new EE_Registration_Config(); |
|
288
|
|
|
$this->registration = apply_filters( 'FHEE__EE_Config___initialize_config__registration', $this->registration ); |
|
289
|
|
|
|
|
290
|
|
|
$this->admin = $this->admin instanceof EE_Admin_Config |
|
291
|
|
|
? $this->admin : new EE_Admin_Config(); |
|
292
|
|
|
$this->admin = apply_filters( 'FHEE__EE_Config___initialize_config__admin', $this->admin ); |
|
293
|
|
|
|
|
294
|
|
|
$this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
295
|
|
|
? $this->template_settings : new EE_Template_Config(); |
|
296
|
|
|
$this->template_settings = apply_filters( 'FHEE__EE_Config___initialize_config__template_settings', $this->template_settings ); |
|
297
|
|
|
|
|
298
|
|
|
$this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
299
|
|
|
? $this->map_settings : new EE_Map_Config(); |
|
300
|
|
|
$this->map_settings = apply_filters( 'FHEE__EE_Config___initialize_config__map_settings', $this->map_settings ); |
|
301
|
|
|
|
|
302
|
|
|
$this->environment = $this->environment instanceof EE_Environment_Config |
|
303
|
|
|
? $this->environment : new EE_Environment_Config(); |
|
304
|
|
|
$this->environment = apply_filters( 'FHEE__EE_Config___initialize_config__environment', $this->environment ); |
|
305
|
|
|
|
|
306
|
|
|
$this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
|
|
|
|
|
307
|
|
|
? $this->gateway : new EE_Gateway_Config(); |
|
|
|
|
|
|
308
|
|
|
$this->gateway = apply_filters( 'FHEE__EE_Config___initialize_config__gateway', $this->gateway ); |
|
|
|
|
|
|
309
|
|
|
|
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
|
|
313
|
|
|
|
|
314
|
|
|
/** |
|
315
|
|
|
* get_espresso_config |
|
316
|
|
|
* |
|
317
|
|
|
* @access public |
|
318
|
|
|
* @return array of espresso config stuff |
|
319
|
|
|
*/ |
|
320
|
|
|
public function get_espresso_config() { |
|
321
|
|
|
// grab espresso configuration |
|
322
|
|
|
return apply_filters( 'FHEE__EE_Config__get_espresso_config__CFG', get_option( 'ee_config', array() )); |
|
323
|
|
|
} |
|
324
|
|
|
|
|
325
|
|
|
|
|
326
|
|
|
|
|
327
|
|
|
/** |
|
328
|
|
|
* double_check_config_comparison |
|
329
|
|
|
* |
|
330
|
|
|
* @access public |
|
331
|
|
|
* @param string $option |
|
332
|
|
|
* @param $old_value |
|
333
|
|
|
* @param $value |
|
334
|
|
|
*/ |
|
335
|
|
|
public function double_check_config_comparison( $option = '', $old_value, $value ) { |
|
336
|
|
|
// make sure we're checking the ee config |
|
337
|
|
|
if ( $option == 'ee_config' ) { |
|
338
|
|
|
// run a loose comparison of the old value against the new value for type and properties, |
|
339
|
|
|
// but NOT exact instance like WP update_option does |
|
340
|
|
|
if ( $value != $old_value ) { |
|
341
|
|
|
// if they are NOT the same, then remove the hook, |
|
342
|
|
|
// which means the subsequent update results will be based solely on the update query results |
|
343
|
|
|
// the reason we do this is because, as stated above, |
|
344
|
|
|
// WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
345
|
|
|
// this happens PRIOR to serialization and any subsequent update. |
|
346
|
|
|
// If values are found to match their previous old value, |
|
347
|
|
|
// then WP bails before performing any update. |
|
348
|
|
|
// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
349
|
|
|
// it just pulled from the db, with the one being passed to it (which will not match). |
|
350
|
|
|
// HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
351
|
|
|
// MySQL MAY ALSO NOT perform the update because |
|
352
|
|
|
// the string it sees in the db looks the same as the new one it has been passed!!! |
|
353
|
|
|
// This results in the query returning an "affected rows" value of ZERO, |
|
354
|
|
|
// which gets returned immediately by WP update_option and looks like an error. |
|
355
|
|
|
remove_action( 'update_option', array( $this, 'check_config_updated' )); |
|
356
|
|
|
} |
|
357
|
|
|
} |
|
358
|
|
|
} |
|
359
|
|
|
|
|
360
|
|
|
|
|
361
|
|
|
|
|
362
|
|
|
/** |
|
363
|
|
|
* update_espresso_config |
|
364
|
|
|
* |
|
365
|
|
|
* @access public |
|
366
|
|
|
* @return bool |
|
367
|
|
|
*/ |
|
368
|
|
|
protected function _reset_espresso_addon_config() { |
|
369
|
|
|
$this->_config_option_names = array(); |
|
370
|
|
|
foreach( $this->addons as $addon_name => $addon_config_obj ) { |
|
|
|
|
|
|
371
|
|
|
$addon_config_obj = maybe_unserialize( $addon_config_obj ); |
|
372
|
|
|
$config_class = get_class( $addon_config_obj ); |
|
373
|
|
|
if ( $addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class ) { |
|
374
|
|
|
$this->update_config( 'addons', $addon_name, $addon_config_obj, FALSE ); |
|
375
|
|
|
} |
|
376
|
|
|
$this->addons->{$addon_name} = NULL; |
|
377
|
|
|
} |
|
378
|
|
|
} |
|
379
|
|
|
|
|
380
|
|
|
|
|
381
|
|
|
|
|
382
|
|
|
/** |
|
383
|
|
|
* update_espresso_config |
|
384
|
|
|
* |
|
385
|
|
|
* @access public |
|
386
|
|
|
* @param bool $add_success |
|
387
|
|
|
* @param bool $add_error |
|
388
|
|
|
* @return bool |
|
389
|
|
|
*/ |
|
390
|
|
|
public function update_espresso_config( $add_success = FALSE, $add_error = TRUE ) { |
|
391
|
|
|
// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
392
|
|
|
//$clone = clone( self::$_instance ); |
|
393
|
|
|
//self::$_instance = NULL; |
|
394
|
|
|
do_action( 'AHEE__EE_Config__update_espresso_config__begin',$this ); |
|
395
|
|
|
$this->_reset_espresso_addon_config(); |
|
396
|
|
|
// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
397
|
|
|
// but BEFORE the actual update occurs |
|
398
|
|
|
add_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1, 3 ); |
|
399
|
|
|
// now update "ee_config" |
|
400
|
|
|
$saved = update_option( 'ee_config', $this ); |
|
401
|
|
|
// if not saved... check if the hook we just added still exists; |
|
402
|
|
|
// if it does, it means one of two things: |
|
403
|
|
|
// that update_option bailed at the ( $value === $old_value ) conditional, |
|
404
|
|
|
// or... |
|
405
|
|
|
// the db update query returned 0 rows affected |
|
406
|
|
|
// (probably because the data value was the same from it's perspective) |
|
407
|
|
|
// so the existence of the hook means that a negative result from update_option is NOT an error, |
|
408
|
|
|
// but just means no update occurred, so don't display an error to the user. |
|
409
|
|
|
// BUT... if update_option returns FALSE, AND the hook is missing, |
|
410
|
|
|
// then it means that something truly went wrong |
|
411
|
|
|
$saved = ! $saved ? has_action( 'update_option', array( $this, 'double_check_config_comparison' )) : $saved; |
|
412
|
|
|
// remove our action since we don't want it in the system anymore |
|
413
|
|
|
remove_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1 ); |
|
414
|
|
|
do_action( 'AHEE__EE_Config__update_espresso_config__end', $this, $saved ); |
|
415
|
|
|
//self::$_instance = $clone; |
|
416
|
|
|
//unset( $clone ); |
|
417
|
|
|
// if config remains the same or was updated successfully |
|
418
|
|
|
if ( $saved ) { |
|
419
|
|
|
if ( $add_success ) { |
|
420
|
|
|
EE_Error::add_success( |
|
421
|
|
|
__( 'The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso' ), |
|
422
|
|
|
__FILE__, __FUNCTION__, __LINE__ |
|
423
|
|
|
); |
|
424
|
|
|
} |
|
425
|
|
|
return TRUE; |
|
426
|
|
|
} else { |
|
427
|
|
|
if ( $add_error ) { |
|
428
|
|
|
EE_Error::add_error( |
|
429
|
|
|
__( 'The Event Espresso Configuration Settings were not updated.', 'event_espresso' ), |
|
430
|
|
|
__FILE__, __FUNCTION__, __LINE__ |
|
431
|
|
|
); |
|
432
|
|
|
} |
|
433
|
|
|
return FALSE; |
|
434
|
|
|
} |
|
435
|
|
|
} |
|
436
|
|
|
|
|
437
|
|
|
|
|
438
|
|
|
/** |
|
439
|
|
|
* _verify_config_params |
|
440
|
|
|
* |
|
441
|
|
|
* @access private |
|
442
|
|
|
* @param string $section |
|
443
|
|
|
* @param string $name |
|
444
|
|
|
* @param string $config_class |
|
445
|
|
|
* @param EE_Config_Base $config_obj |
|
446
|
|
|
* @param array $tests_to_run |
|
447
|
|
|
* @param bool $display_errors |
|
448
|
|
|
* @return bool TRUE on success, FALSE on fail |
|
449
|
|
|
*/ |
|
450
|
|
|
private function _verify_config_params( |
|
451
|
|
|
$section = '', |
|
452
|
|
|
$name = '', |
|
453
|
|
|
$config_class = '', |
|
454
|
|
|
$config_obj = NULL, |
|
455
|
|
|
$tests_to_run = array( 1, 2, 3, 4, 5, 6, 7, 8 ), |
|
456
|
|
|
$display_errors = TRUE |
|
457
|
|
|
) { |
|
458
|
|
|
try { |
|
459
|
|
|
foreach ( $tests_to_run as $test ) { |
|
460
|
|
|
switch ( $test ) { |
|
461
|
|
|
|
|
462
|
|
|
// TEST #1 : check that section was set |
|
463
|
|
View Code Duplication |
case 1 : |
|
464
|
|
|
if ( empty( $section ) ) { |
|
465
|
|
|
if ( $display_errors ) { |
|
466
|
|
|
throw new EE_Error( |
|
467
|
|
|
sprintf( |
|
468
|
|
|
__( 'No configuration section has been provided while attempting to save "%s".', 'event_espresso' ), |
|
469
|
|
|
$config_class |
|
470
|
|
|
) |
|
471
|
|
|
); |
|
472
|
|
|
} |
|
473
|
|
|
return false; |
|
474
|
|
|
} |
|
475
|
|
|
break; |
|
476
|
|
|
|
|
477
|
|
|
// TEST #2 : check that settings section exists |
|
478
|
|
View Code Duplication |
case 2 : |
|
479
|
|
|
if ( ! isset( $this->{$section} ) ) { |
|
480
|
|
|
if ( $display_errors ) { |
|
481
|
|
|
throw new EE_Error( |
|
482
|
|
|
sprintf( __( 'The "%s" configuration section does not exist.', 'event_espresso' ), |
|
483
|
|
|
$section ) |
|
484
|
|
|
); |
|
485
|
|
|
} |
|
486
|
|
|
return false; |
|
487
|
|
|
} |
|
488
|
|
|
break; |
|
489
|
|
|
|
|
490
|
|
|
// TEST #3 : check that section is the proper format |
|
491
|
|
|
case 3 : |
|
492
|
|
|
if ( |
|
493
|
|
|
! ( $this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass ) |
|
494
|
|
|
) { |
|
495
|
|
|
if ( $display_errors ) { |
|
496
|
|
|
throw new EE_Error( |
|
497
|
|
|
sprintf( |
|
498
|
|
|
__( 'The "%s" configuration settings have not been formatted correctly.', 'event_espresso' ), |
|
499
|
|
|
$section |
|
500
|
|
|
) |
|
501
|
|
|
); |
|
502
|
|
|
} |
|
503
|
|
|
return false; |
|
504
|
|
|
} |
|
505
|
|
|
break; |
|
506
|
|
|
|
|
507
|
|
|
// TEST #4 : check that config section name has been set |
|
508
|
|
View Code Duplication |
case 4 : |
|
509
|
|
|
if ( empty( $name ) ) { |
|
510
|
|
|
if ( $display_errors ) { |
|
511
|
|
|
throw new EE_Error( |
|
512
|
|
|
__( 'No name has been provided for the specific configuration section.', 'event_espresso' ) |
|
513
|
|
|
); |
|
514
|
|
|
} |
|
515
|
|
|
return false; |
|
516
|
|
|
} |
|
517
|
|
|
break; |
|
518
|
|
|
|
|
519
|
|
|
// TEST #5 : check that a config class name has been set |
|
520
|
|
View Code Duplication |
case 5 : |
|
521
|
|
|
if ( empty( $config_class ) ) { |
|
522
|
|
|
if ( $display_errors ) { |
|
523
|
|
|
throw new EE_Error( |
|
524
|
|
|
__( 'No class name has been provided for the specific configuration section.', 'event_espresso' ) |
|
525
|
|
|
); |
|
526
|
|
|
} |
|
527
|
|
|
return false; |
|
528
|
|
|
} |
|
529
|
|
|
break; |
|
530
|
|
|
|
|
531
|
|
|
// TEST #6 : verify config class is accessible |
|
532
|
|
View Code Duplication |
case 6 : |
|
533
|
|
|
if ( ! class_exists( $config_class ) ) { |
|
534
|
|
|
if ( $display_errors ) { |
|
535
|
|
|
throw new EE_Error( |
|
536
|
|
|
sprintf( |
|
537
|
|
|
__( 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', 'event_espresso' ), |
|
538
|
|
|
$config_class |
|
539
|
|
|
) |
|
540
|
|
|
); |
|
541
|
|
|
} |
|
542
|
|
|
return false; |
|
543
|
|
|
} |
|
544
|
|
|
break; |
|
545
|
|
|
|
|
546
|
|
|
// TEST #7 : check that config has even been set |
|
547
|
|
|
case 7 : |
|
548
|
|
|
if ( ! isset( $this->{$section}->{$name} ) ) { |
|
549
|
|
|
if ( $display_errors ) { |
|
550
|
|
|
throw new EE_Error( |
|
551
|
|
|
sprintf( |
|
552
|
|
|
__( 'No configuration has been set for "%1$s->%2$s".', 'event_espresso' ), |
|
553
|
|
|
$section, |
|
554
|
|
|
$name |
|
555
|
|
|
) |
|
556
|
|
|
); |
|
557
|
|
|
} |
|
558
|
|
|
return false; |
|
559
|
|
|
} else { |
|
560
|
|
|
// and make sure it's not serialized |
|
561
|
|
|
$this->{$section}->{$name} = maybe_unserialize( $this->{$section}->{$name} ); |
|
562
|
|
|
} |
|
563
|
|
|
break; |
|
564
|
|
|
|
|
565
|
|
|
// TEST #8 : check that config is the requested type |
|
566
|
|
|
case 8 : |
|
567
|
|
|
if ( ! $this->{$section}->{$name} instanceof $config_class ) { |
|
568
|
|
|
if ( $display_errors ) { |
|
569
|
|
|
throw new EE_Error( |
|
570
|
|
|
sprintf( |
|
571
|
|
|
__( 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', 'event_espresso' ), |
|
572
|
|
|
$section, |
|
573
|
|
|
$name, |
|
574
|
|
|
$config_class |
|
575
|
|
|
) |
|
576
|
|
|
); |
|
577
|
|
|
} |
|
578
|
|
|
return false; |
|
579
|
|
|
} |
|
580
|
|
|
break; |
|
581
|
|
|
|
|
582
|
|
|
// TEST #9 : verify config object |
|
583
|
|
View Code Duplication |
case 9 : |
|
584
|
|
|
if ( ! $config_obj instanceof EE_Config_Base ) { |
|
585
|
|
|
if ( $display_errors ) { |
|
586
|
|
|
throw new EE_Error( |
|
587
|
|
|
sprintf( |
|
588
|
|
|
__( 'The "%s" class is not an instance of EE_Config_Base.', 'event_espresso' ), |
|
589
|
|
|
print_r( $config_obj, true ) |
|
590
|
|
|
) |
|
591
|
|
|
); |
|
592
|
|
|
} |
|
593
|
|
|
return false; |
|
594
|
|
|
} |
|
595
|
|
|
break; |
|
596
|
|
|
|
|
597
|
|
|
} |
|
598
|
|
|
} |
|
599
|
|
|
|
|
600
|
|
|
} catch( EE_Error $e ) { |
|
601
|
|
|
$e->get_error(); |
|
602
|
|
|
} |
|
603
|
|
|
// you have successfully run the gauntlet |
|
604
|
|
|
return TRUE; |
|
605
|
|
|
} |
|
606
|
|
|
|
|
607
|
|
|
|
|
608
|
|
|
|
|
609
|
|
|
/** |
|
610
|
|
|
* _generate_config_option_name |
|
611
|
|
|
* |
|
612
|
|
|
* @access protected |
|
613
|
|
|
* @param string $section |
|
614
|
|
|
* @param string $name |
|
615
|
|
|
* @return string |
|
616
|
|
|
*/ |
|
617
|
|
|
private function _generate_config_option_name( $section = '', $name = '' ) { |
|
618
|
|
|
return 'ee_config-' . strtolower( $section . '-' . str_replace( array( 'EE_', 'EED_' ), '', $name ) ); |
|
619
|
|
|
} |
|
620
|
|
|
|
|
621
|
|
|
|
|
622
|
|
|
|
|
623
|
|
|
/** |
|
624
|
|
|
* _set_config_class |
|
625
|
|
|
* ensures that a config class is set, either from a passed config class or one generated from the config name |
|
626
|
|
|
* |
|
627
|
|
|
* @access private |
|
628
|
|
|
* @param string $config_class |
|
629
|
|
|
* @param string $name |
|
630
|
|
|
* @return string |
|
631
|
|
|
*/ |
|
632
|
|
|
private function _set_config_class( $config_class = '', $name = '' ) { |
|
633
|
|
|
return ! empty( $config_class ) |
|
634
|
|
|
? $config_class |
|
635
|
|
|
: str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $name ) ) ) . '_Config'; |
|
636
|
|
|
} |
|
637
|
|
|
|
|
638
|
|
|
|
|
639
|
|
|
/** |
|
640
|
|
|
* set_config |
|
641
|
|
|
* |
|
642
|
|
|
* @access protected |
|
643
|
|
|
* @param string $section |
|
644
|
|
|
* @param string $name |
|
645
|
|
|
* @param string $config_class |
|
646
|
|
|
* @param EE_Config_Base $config_obj |
|
647
|
|
|
* @return EE_Config_Base |
|
648
|
|
|
*/ |
|
649
|
|
|
public function set_config( $section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null ) { |
|
650
|
|
|
// ensure config class is set to something |
|
651
|
|
|
$config_class = $this->_set_config_class( $config_class, $name ); |
|
652
|
|
|
// run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
653
|
|
View Code Duplication |
if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ))) { |
|
654
|
|
|
return null; |
|
655
|
|
|
} |
|
656
|
|
|
$config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
657
|
|
|
// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
658
|
|
|
if ( ! isset( $this->_config_option_names[ $config_option_name ] )) { |
|
659
|
|
|
$this->_config_option_names[ $config_option_name ] = $config_class; |
|
660
|
|
|
} |
|
661
|
|
|
// verify the incoming config object but suppress errors |
|
662
|
|
|
if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false )) { |
|
663
|
|
|
$config_obj = new $config_class(); |
|
664
|
|
|
} |
|
665
|
|
|
if ( get_option( $config_option_name ) ) { |
|
666
|
|
|
update_option( $config_option_name, $config_obj ); |
|
667
|
|
|
$this->{$section}->{$name} = $config_obj; |
|
668
|
|
|
return $this->{$section}->{$name}; |
|
669
|
|
|
} else { |
|
670
|
|
|
// create a wp-option for this config |
|
671
|
|
|
if ( add_option( $config_option_name, $config_obj, '', 'no' )) { |
|
672
|
|
|
$this->{$section}->{$name} = maybe_unserialize( $config_obj ); |
|
673
|
|
|
return $this->{$section}->{$name}; |
|
674
|
|
|
} else { |
|
675
|
|
|
EE_Error::add_error( |
|
676
|
|
|
sprintf( __( 'The "%s" could not be saved to the database.', 'event_espresso' ), $config_class ), |
|
677
|
|
|
__FILE__, __FUNCTION__, __LINE__ |
|
678
|
|
|
); |
|
679
|
|
|
return null; |
|
680
|
|
|
} |
|
681
|
|
|
} |
|
682
|
|
|
} |
|
683
|
|
|
|
|
684
|
|
|
|
|
685
|
|
|
|
|
686
|
|
|
/** |
|
687
|
|
|
* update_config |
|
688
|
|
|
* Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
689
|
|
|
* |
|
690
|
|
|
* @access public |
|
691
|
|
|
* @param string $section |
|
692
|
|
|
* @param string $name |
|
693
|
|
|
* @param EE_Config_Base|string $config_obj |
|
694
|
|
|
* @param bool $throw_errors |
|
695
|
|
|
* @return bool |
|
696
|
|
|
*/ |
|
697
|
|
|
public function update_config( $section = '', $name = '', $config_obj = '', $throw_errors = true ) { |
|
698
|
|
|
$config_obj = maybe_unserialize( $config_obj ); |
|
699
|
|
|
// get class name of the incoming object |
|
700
|
|
|
$config_class = get_class( $config_obj ); |
|
701
|
|
|
// run tests 1-5 and 9 to verify config |
|
702
|
|
View Code Duplication |
if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 1, 2, 3, 4, 7, 9 ))) { |
|
703
|
|
|
return false; |
|
704
|
|
|
} |
|
705
|
|
|
$config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
706
|
|
|
// check if config object has been added to db by seeing if config option name is in $this->_config_option_names array |
|
707
|
|
|
if ( ! isset( $this->_config_option_names[ $config_option_name ] )) { |
|
708
|
|
|
// save new config to db |
|
709
|
|
|
return $this->set_config( $section, $name, $config_class, $config_obj ); |
|
710
|
|
|
} else { |
|
711
|
|
|
// first check if the record already exists |
|
712
|
|
|
$existing_config = get_option( $config_option_name ); |
|
713
|
|
|
$config_obj = serialize( $config_obj ); |
|
714
|
|
|
// just return if db record is already up to date |
|
715
|
|
|
if ( $existing_config == $config_obj ) { |
|
716
|
|
|
$this->{$section}->{$name} = $config_obj; |
|
717
|
|
|
return true; |
|
718
|
|
|
} else if ( update_option( $config_option_name, $config_obj )) { |
|
719
|
|
|
// update wp-option for this config class |
|
720
|
|
|
$this->{$section}->{$name} = $config_obj; |
|
721
|
|
|
return true; |
|
722
|
|
|
} elseif ( $throw_errors ) { |
|
723
|
|
|
EE_Error::add_error( |
|
724
|
|
|
sprintf( |
|
725
|
|
|
__( 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', 'event_espresso' ), |
|
726
|
|
|
$config_class, |
|
727
|
|
|
'EE_Config->' . $section . '->' . $name |
|
728
|
|
|
), |
|
729
|
|
|
__FILE__, __FUNCTION__, __LINE__ |
|
730
|
|
|
); |
|
731
|
|
|
} |
|
732
|
|
|
} |
|
733
|
|
|
return false; |
|
734
|
|
|
} |
|
735
|
|
|
|
|
736
|
|
|
|
|
737
|
|
|
|
|
738
|
|
|
/** |
|
739
|
|
|
* get_config |
|
740
|
|
|
* |
|
741
|
|
|
* @access public |
|
742
|
|
|
* @param string $section |
|
743
|
|
|
* @param string $name |
|
744
|
|
|
* @param string $config_class |
|
745
|
|
|
* @return mixed EE_Config_Base | NULL |
|
746
|
|
|
*/ |
|
747
|
|
|
public function get_config( $section = '', $name = '', $config_class = '' ) { |
|
748
|
|
|
// ensure config class is set to something |
|
749
|
|
|
$config_class = $this->_set_config_class( $config_class, $name ); |
|
750
|
|
|
// run tests 1-4, 6 and 7 to verify that all params have been set |
|
751
|
|
View Code Duplication |
if ( ! $this->_verify_config_params( $section, $name, $config_class, NULL, array( 1, 2, 3, 4, 5, 6 ))) { |
|
752
|
|
|
return NULL; |
|
753
|
|
|
} |
|
754
|
|
|
// now test if the requested config object exists, but suppress errors |
|
755
|
|
|
if ( $this->_verify_config_params( $section, $name, $config_class, NULL, array( 7, 8 ), FALSE )) { |
|
756
|
|
|
// config already exists, so pass it back |
|
757
|
|
|
return $this->{$section}->{$name}; |
|
758
|
|
|
} |
|
759
|
|
|
// load config option from db if it exists |
|
760
|
|
|
$config_obj = $this->get_config_option( $this->_generate_config_option_name( $section, $name )); |
|
761
|
|
|
// verify the newly retrieved config object, but suppress errors |
|
762
|
|
|
if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), FALSE )) { |
|
763
|
|
|
// config is good, so set it and pass it back |
|
764
|
|
|
$this->{$section}->{$name} = $config_obj; |
|
765
|
|
|
return $this->{$section}->{$name}; |
|
766
|
|
|
} |
|
767
|
|
|
// oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
768
|
|
|
$config_obj =$this->set_config( $section, $name, $config_class ); |
|
769
|
|
|
// verify the newly created config object |
|
770
|
|
|
if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ))) { |
|
771
|
|
|
return $this->{$section}->{$name}; |
|
772
|
|
|
} else { |
|
773
|
|
|
EE_Error::add_error( |
|
774
|
|
|
sprintf( __( 'The "%s" could not be retrieved from the database.', 'event_espresso' ), $config_class ), |
|
775
|
|
|
__FILE__, __FUNCTION__, __LINE__ |
|
776
|
|
|
); |
|
777
|
|
|
} |
|
778
|
|
|
return NULL; |
|
779
|
|
|
} |
|
780
|
|
|
|
|
781
|
|
|
|
|
782
|
|
|
/** |
|
783
|
|
|
* get_config_option |
|
784
|
|
|
* |
|
785
|
|
|
* @access public |
|
786
|
|
|
* @param string $config_option_name |
|
787
|
|
|
* @return mixed EE_Config_Base | FALSE |
|
788
|
|
|
*/ |
|
789
|
|
|
public function get_config_option( $config_option_name = '' ) { |
|
790
|
|
|
// retrieve the wp-option for this config class. |
|
791
|
|
|
return maybe_unserialize( get_option( $config_option_name )); |
|
792
|
|
|
} |
|
793
|
|
|
|
|
794
|
|
|
|
|
795
|
|
|
|
|
796
|
|
|
|
|
797
|
|
|
/** |
|
798
|
|
|
* update_post_shortcodes |
|
799
|
|
|
* |
|
800
|
|
|
* @access public |
|
801
|
|
|
* @param $page_for_posts |
|
802
|
|
|
* @return void |
|
803
|
|
|
*/ |
|
804
|
|
|
public function update_post_shortcodes( $page_for_posts = '' ) { |
|
805
|
|
|
// make sure page_for_posts is set |
|
806
|
|
|
$page_for_posts = ! empty( $page_for_posts ) ? $page_for_posts : EE_Config::get_page_for_posts(); |
|
807
|
|
|
// critical page shortcodes that we do NOT want added to the Posts page (blog) |
|
808
|
|
|
$critical_shortcodes = $this->core->get_critical_pages_shortcodes_array(); |
|
809
|
|
|
// allow others to mess stuff up :D |
|
810
|
|
|
do_action( 'AHEE__EE_Config__update_post_shortcodes', $this->core->post_shortcodes, $page_for_posts ); |
|
811
|
|
|
// verify that post_shortcodes is set |
|
812
|
|
|
$this->core->post_shortcodes = isset( $this->core->post_shortcodes ) && is_array( $this->core->post_shortcodes ) ? $this->core->post_shortcodes : array(); |
|
813
|
|
|
// cycle thru post_shortcodes |
|
814
|
|
|
foreach( $this->core->post_shortcodes as $post_name => $shortcodes ){ |
|
815
|
|
|
// are there any shortcodes to track ? |
|
816
|
|
|
if ( ! empty( $shortcodes )) { |
|
817
|
|
|
// loop thru list of tracked shortcodes |
|
818
|
|
|
foreach( $shortcodes as $shortcode => $post_id ) { |
|
819
|
|
|
// if shortcode is for a critical page, BUT this is NOT the corresponding critical page for that shortcode |
|
820
|
|
|
if ( isset( $critical_shortcodes[ $post_id ] ) && $post_name == $page_for_posts ) { |
|
821
|
|
|
// then remove this shortcode, because we don't want critical page shortcodes like ESPRESSO_TXN_PAGE running on the "Posts Page" (blog) |
|
822
|
|
|
unset( $this->core->post_shortcodes[ $post_name ][ $shortcode ] ); |
|
823
|
|
|
} |
|
824
|
|
|
// skip the posts page, because we want all shortcodes registered for it |
|
825
|
|
|
if ( $post_name == $page_for_posts ) { |
|
826
|
|
|
continue; |
|
827
|
|
|
} |
|
828
|
|
|
// make sure post still exists |
|
829
|
|
|
$post = get_post( $post_id ); |
|
830
|
|
|
if ( $post ) { |
|
831
|
|
|
// check that the post name matches what we have saved |
|
832
|
|
|
if ( $post->post_name == $post_name ) { |
|
833
|
|
|
// if so, then break before hitting the unset below |
|
834
|
|
|
continue; |
|
835
|
|
|
} |
|
836
|
|
|
} |
|
837
|
|
|
// we don't like missing posts around here >:( |
|
838
|
|
|
unset( $this->core->post_shortcodes[ $post_name ] ); |
|
839
|
|
|
} |
|
840
|
|
|
} else { |
|
841
|
|
|
// you got no shortcodes to keep track of ! |
|
842
|
|
|
unset( $this->core->post_shortcodes[ $post_name ] ); |
|
843
|
|
|
} |
|
844
|
|
|
} |
|
845
|
|
|
//only show errors |
|
846
|
|
|
$this->update_espresso_config(); |
|
847
|
|
|
} |
|
848
|
|
|
|
|
849
|
|
|
|
|
850
|
|
|
|
|
851
|
|
|
/** |
|
852
|
|
|
* get_page_for_posts |
|
853
|
|
|
* |
|
854
|
|
|
* if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the wp-option "page_for_posts", or "posts" if no page is selected |
|
855
|
|
|
* |
|
856
|
|
|
* |
|
857
|
|
|
* @access public |
|
858
|
|
|
* @return string |
|
859
|
|
|
*/ |
|
860
|
|
View Code Duplication |
public static function get_page_for_posts() { |
|
|
|
|
|
|
861
|
|
|
$page_for_posts = get_option( 'page_for_posts' ); |
|
862
|
|
|
if ( ! $page_for_posts ) { |
|
863
|
|
|
return 'posts'; |
|
864
|
|
|
} |
|
865
|
|
|
/** @type WPDB $wpdb */ |
|
866
|
|
|
global $wpdb; |
|
867
|
|
|
$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
868
|
|
|
return $wpdb->get_var( $wpdb->prepare( $SQL, $page_for_posts )); |
|
869
|
|
|
} |
|
870
|
|
|
|
|
871
|
|
|
|
|
872
|
|
|
|
|
873
|
|
|
/** |
|
874
|
|
|
* register_shortcodes_and_modules. |
|
875
|
|
|
* |
|
876
|
|
|
* At this point, it's too early to tell if we're maintenance mode or not. |
|
877
|
|
|
* In fact, this is where we give modules a chance to let core know they exist |
|
878
|
|
|
* so they can help trigger maintenance mode if it's needed |
|
879
|
|
|
* |
|
880
|
|
|
* @access public |
|
881
|
|
|
* @return void |
|
882
|
|
|
*/ |
|
883
|
|
|
public function register_shortcodes_and_modules() { |
|
884
|
|
|
// allow shortcodes to register with WP and to set hooks for the rest of the system |
|
885
|
|
|
EE_Registry::instance()->shortcodes =$this->_register_shortcodes(); |
|
886
|
|
|
// allow modules to set hooks for the rest of the system |
|
887
|
|
|
EE_Registry::instance()->modules = $this->_register_modules(); |
|
888
|
|
|
} |
|
889
|
|
|
|
|
890
|
|
|
|
|
891
|
|
|
/** |
|
892
|
|
|
* initialize_shortcodes_and_modules |
|
893
|
|
|
* meaning they can start adding their hooks to get stuff done |
|
894
|
|
|
* |
|
895
|
|
|
* @access public |
|
896
|
|
|
* @return void |
|
897
|
|
|
*/ |
|
898
|
|
|
public function initialize_shortcodes_and_modules() { |
|
899
|
|
|
// allow shortcodes to set hooks for the rest of the system |
|
900
|
|
|
$this->_initialize_shortcodes(); |
|
901
|
|
|
// allow modules to set hooks for the rest of the system |
|
902
|
|
|
$this->_initialize_modules(); |
|
903
|
|
|
} |
|
904
|
|
|
|
|
905
|
|
|
|
|
906
|
|
|
|
|
907
|
|
|
|
|
908
|
|
|
/** |
|
909
|
|
|
* widgets_init |
|
910
|
|
|
* |
|
911
|
|
|
* @access private |
|
912
|
|
|
* @return void |
|
913
|
|
|
*/ |
|
914
|
|
|
public function widgets_init() { |
|
915
|
|
|
//only init widgets on admin pages when not in complete maintenance, and |
|
916
|
|
|
//on frontend when not in any maintenance mode |
|
917
|
|
|
if (( is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) || ! EE_Maintenance_Mode::instance()->level() ) { |
|
918
|
|
|
// grab list of installed widgets |
|
919
|
|
|
$widgets_to_register = glob( EE_WIDGETS . '*', GLOB_ONLYDIR ); |
|
920
|
|
|
// filter list of modules to register |
|
921
|
|
|
$widgets_to_register = apply_filters( 'FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register ); |
|
922
|
|
|
|
|
923
|
|
|
if ( ! empty( $widgets_to_register ) ) { |
|
924
|
|
|
// cycle thru widget folders |
|
925
|
|
|
foreach ( $widgets_to_register as $widget_path ) { |
|
926
|
|
|
// add to list of installed widget modules |
|
927
|
|
|
EE_Config::register_ee_widget( $widget_path ); |
|
928
|
|
|
} |
|
929
|
|
|
} |
|
930
|
|
|
// filter list of installed modules |
|
931
|
|
|
EE_Registry::instance()->widgets = apply_filters( 'FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets ); |
|
932
|
|
|
} |
|
933
|
|
|
} |
|
934
|
|
|
|
|
935
|
|
|
|
|
936
|
|
|
|
|
937
|
|
|
/** |
|
938
|
|
|
* register_ee_widget - makes core aware of this widget |
|
939
|
|
|
* |
|
940
|
|
|
* @access public |
|
941
|
|
|
* @param string $widget_path - full path up to and including widget folder |
|
942
|
|
|
* @return void |
|
943
|
|
|
*/ |
|
944
|
|
|
public static function register_ee_widget( $widget_path = NULL ) { |
|
945
|
|
|
do_action( 'AHEE__EE_Config__register_widget__begin', $widget_path ); |
|
946
|
|
|
$widget_ext = '.widget.php'; |
|
947
|
|
|
// make all separators match |
|
948
|
|
|
$widget_path = rtrim( str_replace( '/\\', DS, $widget_path ), DS ); |
|
949
|
|
|
// does the file path INCLUDE the actual file name as part of the path ? |
|
950
|
|
|
if ( strpos( $widget_path, $widget_ext ) !== FALSE ) { |
|
951
|
|
|
// grab and shortcode file name from directory name and break apart at dots |
|
952
|
|
|
$file_name = explode( '.', basename( $widget_path )); |
|
953
|
|
|
// take first segment from file name pieces and remove class prefix if it exists |
|
954
|
|
|
$widget = strpos( $file_name[0], 'EEW_' ) === 0 ? substr( $file_name[0], 4 ) : $file_name[0]; |
|
955
|
|
|
// sanitize shortcode directory name |
|
956
|
|
|
$widget = sanitize_key( $widget ); |
|
957
|
|
|
// now we need to rebuild the shortcode path |
|
958
|
|
|
$widget_path = explode( DS, $widget_path ); |
|
959
|
|
|
// remove last segment |
|
960
|
|
|
array_pop( $widget_path ); |
|
961
|
|
|
// glue it back together |
|
962
|
|
|
$widget_path = implode( DS, $widget_path ); |
|
963
|
|
|
} else { |
|
964
|
|
|
// grab and sanitize widget directory name |
|
965
|
|
|
$widget = sanitize_key( basename( $widget_path )); |
|
966
|
|
|
} |
|
967
|
|
|
// create classname from widget directory name |
|
968
|
|
|
$widget = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget ))); |
|
969
|
|
|
// add class prefix |
|
970
|
|
|
$widget_class = 'EEW_' . $widget; |
|
971
|
|
|
// does the widget exist ? |
|
972
|
|
View Code Duplication |
if ( ! is_readable( $widget_path . DS . $widget_class . $widget_ext )) { |
|
973
|
|
|
$msg = sprintf( |
|
974
|
|
|
__( 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso' ), |
|
975
|
|
|
$widget_class, |
|
976
|
|
|
$widget_path . DS . $widget_class . $widget_ext |
|
977
|
|
|
); |
|
978
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
979
|
|
|
return; |
|
980
|
|
|
} |
|
981
|
|
|
// load the widget class file |
|
982
|
|
|
require_once( $widget_path . DS . $widget_class . $widget_ext ); |
|
983
|
|
|
// verify that class exists |
|
984
|
|
|
if ( ! class_exists( $widget_class )) { |
|
985
|
|
|
$msg = sprintf( __( 'The requested %s widget class does not exist.', 'event_espresso' ), $widget_class ); |
|
986
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
987
|
|
|
return; |
|
988
|
|
|
} |
|
989
|
|
|
register_widget( $widget_class ); |
|
990
|
|
|
// add to array of registered widgets |
|
991
|
|
|
EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
992
|
|
|
} |
|
993
|
|
|
|
|
994
|
|
|
|
|
995
|
|
|
|
|
996
|
|
|
/** |
|
997
|
|
|
* _register_shortcodes |
|
998
|
|
|
* |
|
999
|
|
|
* @access private |
|
1000
|
|
|
* @return array |
|
1001
|
|
|
*/ |
|
1002
|
|
|
private function _register_shortcodes() { |
|
1003
|
|
|
// grab list of installed shortcodes |
|
1004
|
|
|
$shortcodes_to_register = glob( EE_SHORTCODES . '*', GLOB_ONLYDIR ); |
|
1005
|
|
|
// filter list of modules to register |
|
1006
|
|
|
$shortcodes_to_register = apply_filters( 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register ); |
|
1007
|
|
|
if ( ! empty( $shortcodes_to_register ) ) { |
|
1008
|
|
|
// cycle thru shortcode folders |
|
1009
|
|
|
foreach ( $shortcodes_to_register as $shortcode_path ) { |
|
1010
|
|
|
// add to list of installed shortcode modules |
|
1011
|
|
|
EE_Config::register_shortcode( $shortcode_path ); |
|
1012
|
|
|
} |
|
1013
|
|
|
} |
|
1014
|
|
|
// filter list of installed modules |
|
1015
|
|
|
return apply_filters( 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes ); |
|
1016
|
|
|
} |
|
1017
|
|
|
|
|
1018
|
|
|
|
|
1019
|
|
|
|
|
1020
|
|
|
/** |
|
1021
|
|
|
* register_shortcode - makes core aware of this shortcode |
|
1022
|
|
|
* |
|
1023
|
|
|
* @access public |
|
1024
|
|
|
* @param string $shortcode_path - full path up to and including shortcode folder |
|
1025
|
|
|
* @return bool |
|
1026
|
|
|
*/ |
|
1027
|
|
|
public static function register_shortcode( $shortcode_path = NULL ) { |
|
1028
|
|
|
do_action( 'AHEE__EE_Config__register_shortcode__begin',$shortcode_path ); |
|
1029
|
|
|
$shortcode_ext = '.shortcode.php'; |
|
1030
|
|
|
// make all separators match |
|
1031
|
|
|
$shortcode_path = str_replace( array( '\\', '/' ), DS, $shortcode_path ); |
|
1032
|
|
|
// does the file path INCLUDE the actual file name as part of the path ? |
|
1033
|
|
|
if ( strpos( $shortcode_path, $shortcode_ext ) !== FALSE ) { |
|
1034
|
|
|
// grab shortcode file name from directory name and break apart at dots |
|
1035
|
|
|
$shortcode_file = explode( '.', basename( $shortcode_path )); |
|
1036
|
|
|
// take first segment from file name pieces and remove class prefix if it exists |
|
1037
|
|
|
$shortcode = strpos( $shortcode_file[0], 'EES_' ) === 0 ? substr( $shortcode_file[0], 4 ) : $shortcode_file[0]; |
|
1038
|
|
|
// sanitize shortcode directory name |
|
1039
|
|
|
$shortcode = sanitize_key( $shortcode ); |
|
1040
|
|
|
// now we need to rebuild the shortcode path |
|
1041
|
|
|
$shortcode_path = explode( DS, $shortcode_path ); |
|
1042
|
|
|
// remove last segment |
|
1043
|
|
|
array_pop( $shortcode_path ); |
|
1044
|
|
|
// glue it back together |
|
1045
|
|
|
$shortcode_path = implode( DS, $shortcode_path ) . DS; |
|
1046
|
|
|
} else { |
|
1047
|
|
|
// we need to generate the filename based off of the folder name |
|
1048
|
|
|
// grab and sanitize shortcode directory name |
|
1049
|
|
|
$shortcode = sanitize_key( basename( $shortcode_path )); |
|
1050
|
|
|
$shortcode_path = rtrim( $shortcode_path, DS ) . DS; |
|
1051
|
|
|
} |
|
1052
|
|
|
// create classname from shortcode directory or file name |
|
1053
|
|
|
$shortcode = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $shortcode ))); |
|
1054
|
|
|
// add class prefix |
|
1055
|
|
|
$shortcode_class = 'EES_' . $shortcode; |
|
1056
|
|
|
// does the shortcode exist ? |
|
1057
|
|
View Code Duplication |
if ( ! is_readable( $shortcode_path . DS . $shortcode_class . $shortcode_ext )) { |
|
1058
|
|
|
$msg = sprintf( |
|
1059
|
|
|
__( 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso' ), |
|
1060
|
|
|
$shortcode_class, |
|
1061
|
|
|
$shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
1062
|
|
|
); |
|
1063
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1064
|
|
|
return FALSE; |
|
1065
|
|
|
} |
|
1066
|
|
|
// load the shortcode class file |
|
1067
|
|
|
require_once( $shortcode_path . $shortcode_class . $shortcode_ext ); |
|
1068
|
|
|
// verify that class exists |
|
1069
|
|
|
if ( ! class_exists( $shortcode_class )) { |
|
1070
|
|
|
$msg = sprintf( __( 'The requested %s shortcode class does not exist.', 'event_espresso' ), $shortcode_class ); |
|
1071
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1072
|
|
|
return FALSE; |
|
1073
|
|
|
} |
|
1074
|
|
|
$shortcode = strtoupper( $shortcode ); |
|
1075
|
|
|
// add to array of registered shortcodes |
|
1076
|
|
|
EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
1077
|
|
|
return TRUE; |
|
1078
|
|
|
} |
|
1079
|
|
|
|
|
1080
|
|
|
|
|
1081
|
|
|
|
|
1082
|
|
|
|
|
1083
|
|
|
/** |
|
1084
|
|
|
* _register_modules |
|
1085
|
|
|
* |
|
1086
|
|
|
* @access private |
|
1087
|
|
|
* @return array |
|
1088
|
|
|
*/ |
|
1089
|
|
|
private function _register_modules() { |
|
1090
|
|
|
// grab list of installed modules |
|
1091
|
|
|
$modules_to_register = glob( EE_MODULES . '*', GLOB_ONLYDIR ); |
|
1092
|
|
|
// filter list of modules to register |
|
1093
|
|
|
$modules_to_register = apply_filters( 'FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register ); |
|
1094
|
|
|
|
|
1095
|
|
|
|
|
1096
|
|
|
if ( ! empty( $modules_to_register ) ) { |
|
1097
|
|
|
// loop through folders |
|
1098
|
|
|
foreach ( $modules_to_register as $module_path ) { |
|
1099
|
|
|
/**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
1100
|
|
|
if ( $module_path != EE_MODULES . 'zzz-copy-this-module-template' && $module_path != EE_MODULES . 'gateways' ) { |
|
1101
|
|
|
// add to list of installed modules |
|
1102
|
|
|
EE_Config::register_module( $module_path ); |
|
1103
|
|
|
} |
|
1104
|
|
|
} |
|
1105
|
|
|
} |
|
1106
|
|
|
// filter list of installed modules |
|
1107
|
|
|
return apply_filters( 'FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules ); |
|
1108
|
|
|
} |
|
1109
|
|
|
|
|
1110
|
|
|
|
|
1111
|
|
|
|
|
1112
|
|
|
|
|
1113
|
|
|
/** |
|
1114
|
|
|
* register_module - makes core aware of this module |
|
1115
|
|
|
* |
|
1116
|
|
|
* @access public |
|
1117
|
|
|
* @param string $module_path - full path up to and including module folder |
|
1118
|
|
|
* @return bool |
|
1119
|
|
|
*/ |
|
1120
|
|
|
public static function register_module( $module_path = NULL ) { |
|
1121
|
|
|
do_action( 'AHEE__EE_Config__register_module__begin', $module_path ); |
|
1122
|
|
|
$module_ext = '.module.php'; |
|
1123
|
|
|
// make all separators match |
|
1124
|
|
|
$module_path = str_replace( array( '\\', '/' ), DS, $module_path ); |
|
1125
|
|
|
// does the file path INCLUDE the actual file name as part of the path ? |
|
1126
|
|
|
if ( strpos( $module_path, $module_ext ) !== FALSE ) { |
|
1127
|
|
|
// grab and shortcode file name from directory name and break apart at dots |
|
1128
|
|
|
$module_file = explode( '.', basename( $module_path )); |
|
1129
|
|
|
// now we need to rebuild the shortcode path |
|
1130
|
|
|
$module_path = explode( DS, $module_path ); |
|
1131
|
|
|
// remove last segment |
|
1132
|
|
|
array_pop( $module_path ); |
|
1133
|
|
|
// glue it back together |
|
1134
|
|
|
$module_path = implode( DS, $module_path ) . DS; |
|
1135
|
|
|
// take first segment from file name pieces and sanitize it |
|
1136
|
|
|
$module = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $module_file[0] ); |
|
1137
|
|
|
// ensure class prefix is added |
|
1138
|
|
|
$module_class = strpos( $module, 'EED_' ) !== 0 ? 'EED_' . $module : $module; |
|
1139
|
|
|
} else { |
|
1140
|
|
|
// we need to generate the filename based off of the folder name |
|
1141
|
|
|
// grab and sanitize module name |
|
1142
|
|
|
$module = strtolower( basename( $module_path )); |
|
1143
|
|
|
$module = preg_replace( '/[^a-z0-9_\-]/', '', $module); |
|
1144
|
|
|
// like trailingslashit() |
|
1145
|
|
|
$module_path = rtrim( $module_path, DS ) . DS; |
|
1146
|
|
|
// create classname from module directory name |
|
1147
|
|
|
$module = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $module ))); |
|
1148
|
|
|
// add class prefix |
|
1149
|
|
|
$module_class = 'EED_' . $module; |
|
1150
|
|
|
} |
|
1151
|
|
|
// does the module exist ? |
|
1152
|
|
View Code Duplication |
if ( ! is_readable( $module_path . DS . $module_class . $module_ext )) { |
|
1153
|
|
|
$msg = sprintf( __( 'The requested %s module file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module ); |
|
1154
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1155
|
|
|
return FALSE; |
|
1156
|
|
|
} |
|
1157
|
|
|
// load the module class file |
|
1158
|
|
|
require_once( $module_path . $module_class . $module_ext ); |
|
1159
|
|
|
// verify that class exists |
|
1160
|
|
|
if ( ! class_exists( $module_class )) { |
|
1161
|
|
|
$msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
1162
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1163
|
|
|
return FALSE; |
|
1164
|
|
|
} |
|
1165
|
|
|
// add to array of registered modules |
|
1166
|
|
|
EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1167
|
|
|
do_action( 'AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->{$module_class} ); |
|
1168
|
|
|
return TRUE; |
|
1169
|
|
|
} |
|
1170
|
|
|
|
|
1171
|
|
|
|
|
1172
|
|
|
/** |
|
1173
|
|
|
* _initialize_shortcodes |
|
1174
|
|
|
* allow shortcodes to set hooks for the rest of the system |
|
1175
|
|
|
* |
|
1176
|
|
|
* @access private |
|
1177
|
|
|
* @return void |
|
1178
|
|
|
*/ |
|
1179
|
|
|
private function _initialize_shortcodes() { |
|
1180
|
|
|
// cycle thru shortcode folders |
|
1181
|
|
|
foreach ( EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path ) { |
|
1182
|
|
|
// add class prefix |
|
1183
|
|
|
$shortcode_class = 'EES_' . $shortcode; |
|
1184
|
|
|
// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1185
|
|
|
// which set hooks ? |
|
1186
|
|
|
if ( is_admin() ) { |
|
1187
|
|
|
// fire immediately |
|
1188
|
|
|
call_user_func( array( $shortcode_class, 'set_hooks_admin' )); |
|
1189
|
|
|
} else { |
|
1190
|
|
|
// delay until other systems are online |
|
1191
|
|
|
add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $shortcode_class,'set_hooks' )); |
|
1192
|
|
|
// convert classname to UPPERCASE and create WP shortcode. |
|
1193
|
|
|
$shortcode_tag = strtoupper( $shortcode ); |
|
1194
|
|
|
// but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor' |
|
1195
|
|
|
if ( ! shortcode_exists( $shortcode_tag )) { |
|
1196
|
|
|
// NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes() |
|
1197
|
|
|
add_shortcode( $shortcode_tag, array( $shortcode_class, 'fallback_shortcode_processor' )); |
|
1198
|
|
|
} |
|
1199
|
|
|
} |
|
1200
|
|
|
} |
|
1201
|
|
|
} |
|
1202
|
|
|
|
|
1203
|
|
|
|
|
1204
|
|
|
|
|
1205
|
|
|
/** |
|
1206
|
|
|
* _initialize_modules |
|
1207
|
|
|
* allow modules to set hooks for the rest of the system |
|
1208
|
|
|
* |
|
1209
|
|
|
* @access private |
|
1210
|
|
|
* @return void |
|
1211
|
|
|
*/ |
|
1212
|
|
|
private function _initialize_modules() { |
|
1213
|
|
|
// cycle thru shortcode folders |
|
1214
|
|
|
foreach ( EE_Registry::instance()->modules as $module_class => $module_path ) { |
|
1215
|
|
|
// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1216
|
|
|
// which set hooks ? |
|
1217
|
|
|
if ( is_admin() ) { |
|
1218
|
|
|
// fire immediately |
|
1219
|
|
|
call_user_func( array( $module_class, 'set_hooks_admin' )); |
|
1220
|
|
|
} else { |
|
1221
|
|
|
// delay until other systems are online |
|
1222
|
|
|
add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $module_class,'set_hooks' )); |
|
1223
|
|
|
} |
|
1224
|
|
|
} |
|
1225
|
|
|
} |
|
1226
|
|
|
|
|
1227
|
|
|
|
|
1228
|
|
|
|
|
1229
|
|
|
|
|
1230
|
|
|
/** |
|
1231
|
|
|
* register_route - adds module method routes to route_map |
|
1232
|
|
|
* |
|
1233
|
|
|
* @access public |
|
1234
|
|
|
* @param string $route - "pretty" public alias for module method |
|
1235
|
|
|
* @param string $module - module name (classname without EED_ prefix) |
|
1236
|
|
|
* @param string $method_name - the actual module method to be routed to |
|
1237
|
|
|
* @param string $key - url param key indicating a route is being called |
|
1238
|
|
|
* @return bool |
|
1239
|
|
|
*/ |
|
1240
|
|
|
public static function register_route( $route = NULL, $module = NULL, $method_name = NULL, $key = 'ee' ) { |
|
1241
|
|
|
do_action( 'AHEE__EE_Config__register_route__begin', $route, $module, $method_name ); |
|
1242
|
|
|
$module = str_replace( 'EED_', '', $module ); |
|
1243
|
|
|
$module_class = 'EED_' . $module; |
|
1244
|
|
|
if ( ! isset( EE_Registry::instance()->modules->{$module_class} )) { |
|
1245
|
|
|
$msg = sprintf( __( 'The module %s has not been registered.', 'event_espresso' ), $module ); |
|
1246
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1247
|
|
|
return FALSE; |
|
1248
|
|
|
} |
|
1249
|
|
View Code Duplication |
if ( empty( $route )) { |
|
1250
|
|
|
$msg = sprintf( __( 'No route has been supplied.', 'event_espresso' ), $route ); |
|
1251
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1252
|
|
|
return FALSE; |
|
1253
|
|
|
} |
|
1254
|
|
View Code Duplication |
if ( ! method_exists ( 'EED_' . $module, $method_name )) { |
|
1255
|
|
|
$msg = sprintf( __( 'A valid class method for the %s route has not been supplied.', 'event_espresso' ), $route ); |
|
1256
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1257
|
|
|
return FALSE; |
|
1258
|
|
|
} |
|
1259
|
|
|
EE_Config::$_module_route_map[ $key ][ $route ] = array( 'EED_' . $module, $method_name ); |
|
1260
|
|
|
return TRUE; |
|
1261
|
|
|
} |
|
1262
|
|
|
|
|
1263
|
|
|
|
|
1264
|
|
|
|
|
1265
|
|
|
/** |
|
1266
|
|
|
* get_route - get module method route |
|
1267
|
|
|
* |
|
1268
|
|
|
* @access public |
|
1269
|
|
|
* @param string $route - "pretty" public alias for module method |
|
1270
|
|
|
* @param string $key - url param key indicating a route is being called |
|
1271
|
|
|
* @return string |
|
1272
|
|
|
*/ |
|
1273
|
|
|
public static function get_route( $route = NULL, $key = 'ee' ) { |
|
1274
|
|
|
do_action( 'AHEE__EE_Config__get_route__begin',$route ); |
|
1275
|
|
|
$route = apply_filters( 'FHEE__EE_Config__get_route',$route ); |
|
1276
|
|
|
if ( isset( EE_Config::$_module_route_map[ $key ][ $route ] )) { |
|
1277
|
|
|
return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
1278
|
|
|
} |
|
1279
|
|
|
return NULL; |
|
1280
|
|
|
} |
|
1281
|
|
|
|
|
1282
|
|
|
|
|
1283
|
|
|
|
|
1284
|
|
|
/** |
|
1285
|
|
|
* get_routes - get ALL module method routes |
|
1286
|
|
|
* |
|
1287
|
|
|
* @access public |
|
1288
|
|
|
* @return array |
|
1289
|
|
|
*/ |
|
1290
|
|
|
public static function get_routes() { |
|
1291
|
|
|
return EE_Config::$_module_route_map; |
|
1292
|
|
|
} |
|
1293
|
|
|
|
|
1294
|
|
|
|
|
1295
|
|
|
|
|
1296
|
|
|
/** |
|
1297
|
|
|
* register_forward - allows modules to forward request to another module for further processing |
|
1298
|
|
|
* |
|
1299
|
|
|
* @access public |
|
1300
|
|
|
* @param string $route - "pretty" public alias for module method |
|
1301
|
|
|
* @param integer $status - integer value corresponding to status constant strings set in module parent class, allows different forwards to be served based on status |
|
1302
|
|
|
* @param array|string $forward - function name or array( class, method ) |
|
1303
|
|
|
* @param string $key - url param key indicating a route is being called |
|
1304
|
|
|
* @return bool |
|
1305
|
|
|
*/ |
|
1306
|
|
|
public static function register_forward( $route = NULL, $status = 0, $forward = NULL, $key = 'ee' ) { |
|
1307
|
|
|
do_action( 'AHEE__EE_Config__register_forward',$route,$status,$forward ); |
|
1308
|
|
View Code Duplication |
if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route )) { |
|
1309
|
|
|
$msg = sprintf( __( 'The module route %s for this forward has not been registered.', 'event_espresso' ), $route ); |
|
1310
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1311
|
|
|
return FALSE; |
|
1312
|
|
|
} |
|
1313
|
|
View Code Duplication |
if ( empty( $forward )) { |
|
1314
|
|
|
$msg = sprintf( __( 'No forwarding route has been supplied.', 'event_espresso' ), $route ); |
|
1315
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1316
|
|
|
return FALSE; |
|
1317
|
|
|
} |
|
1318
|
|
|
if ( is_array( $forward )) { |
|
1319
|
|
View Code Duplication |
if ( ! isset( $forward[1] )) { |
|
1320
|
|
|
$msg = sprintf( __( 'A class method for the %s forwarding route has not been supplied.', 'event_espresso' ), $route ); |
|
1321
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1322
|
|
|
return FALSE; |
|
1323
|
|
|
} |
|
1324
|
|
|
if ( ! method_exists( $forward[0], $forward[1] )) { |
|
1325
|
|
|
$msg = sprintf( __( 'The class method %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward[1], $route ); |
|
1326
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1327
|
|
|
return FALSE; |
|
1328
|
|
|
} |
|
1329
|
|
|
} else if ( ! function_exists( $forward )) { |
|
1330
|
|
|
$msg = sprintf( __( 'The function %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward, $route ); |
|
1331
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1332
|
|
|
return FALSE; |
|
1333
|
|
|
} |
|
1334
|
|
|
EE_Config::$_module_forward_map[ $key ][ $route ][ absint( $status ) ] = $forward; |
|
1335
|
|
|
return TRUE; |
|
1336
|
|
|
} |
|
1337
|
|
|
|
|
1338
|
|
|
|
|
1339
|
|
|
|
|
1340
|
|
|
/** |
|
1341
|
|
|
* get_forward - get forwarding route |
|
1342
|
|
|
* |
|
1343
|
|
|
* @access public |
|
1344
|
|
|
* @param string $route - "pretty" public alias for module method |
|
1345
|
|
|
* @param integer $status - integer value corresponding to status constant strings set in module parent class, allows different forwards to be served based on status |
|
1346
|
|
|
* @param string $key - url param key indicating a route is being called |
|
1347
|
|
|
* @return string |
|
1348
|
|
|
*/ |
|
1349
|
|
View Code Duplication |
public static function get_forward( $route = NULL, $status = 0, $key = 'ee' ) { |
|
|
|
|
|
|
1350
|
|
|
do_action( 'AHEE__EE_Config__get_forward__begin',$route,$status ); |
|
1351
|
|
|
if ( isset( EE_Config::$_module_forward_map[ $key ][ $route ][ $status ] )) { |
|
1352
|
|
|
return apply_filters( 'FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], $route,$status ); |
|
1353
|
|
|
} |
|
1354
|
|
|
return NULL; |
|
1355
|
|
|
} |
|
1356
|
|
|
|
|
1357
|
|
|
|
|
1358
|
|
|
|
|
1359
|
|
|
/** |
|
1360
|
|
|
* register_forward - allows modules to specify different view templates for different method routes and status results |
|
1361
|
|
|
* |
|
1362
|
|
|
* @access public |
|
1363
|
|
|
* @param string $route - "pretty" public alias for module method |
|
1364
|
|
|
* @param integer $status - integer value corresponding to status constant strings set in module parent class, allows different views to be served based on status |
|
1365
|
|
|
* @param string $view |
|
1366
|
|
|
* @param string $key - url param key indicating a route is being called |
|
1367
|
|
|
* @return bool |
|
1368
|
|
|
*/ |
|
1369
|
|
|
public static function register_view( $route = NULL, $status = 0, $view = NULL, $key = 'ee' ) { |
|
1370
|
|
|
do_action( 'AHEE__EE_Config__register_view__begin',$route,$status,$view ); |
|
1371
|
|
View Code Duplication |
if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route )) { |
|
1372
|
|
|
$msg = sprintf( __( 'The module route %s for this view has not been registered.', 'event_espresso' ), $route ); |
|
1373
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1374
|
|
|
return FALSE; |
|
1375
|
|
|
} |
|
1376
|
|
|
if ( ! is_readable( $view )) { |
|
1377
|
|
|
$msg = sprintf( __( 'The %s view file could not be found or is not readable due to file permissions.', 'event_espresso' ), $view ); |
|
1378
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1379
|
|
|
return FALSE; |
|
1380
|
|
|
} |
|
1381
|
|
|
EE_Config::$_module_view_map[ $key ][ $route ][ absint( $status ) ] = $view; |
|
1382
|
|
|
return TRUE; |
|
1383
|
|
|
} |
|
1384
|
|
|
|
|
1385
|
|
|
|
|
1386
|
|
|
|
|
1387
|
|
|
|
|
1388
|
|
|
|
|
1389
|
|
|
/** |
|
1390
|
|
|
* get_view - get view for route and status |
|
1391
|
|
|
* |
|
1392
|
|
|
* @access public |
|
1393
|
|
|
* @param string $route - "pretty" public alias for module method |
|
1394
|
|
|
* @param integer $status - integer value corresponding to status constant strings set in module parent class, allows different views to be served based on status |
|
1395
|
|
|
* @param string $key - url param key indicating a route is being called |
|
1396
|
|
|
* @return string |
|
1397
|
|
|
*/ |
|
1398
|
|
View Code Duplication |
public static function get_view( $route = NULL, $status = 0, $key = 'ee' ) { |
|
|
|
|
|
|
1399
|
|
|
do_action( 'AHEE__EE_Config__get_view__begin',$route,$status ); |
|
1400
|
|
|
if ( isset( EE_Config::$_module_view_map[ $key ][ $route ][ $status ] )) { |
|
1401
|
|
|
return apply_filters( 'FHEE__EE_Config__get_view', EE_Config::$_module_view_map[ $key ][ $route ][ $status ], $route,$status ); |
|
1402
|
|
|
} |
|
1403
|
|
|
return NULL; |
|
1404
|
|
|
} |
|
1405
|
|
|
|
|
1406
|
|
|
|
|
1407
|
|
|
|
|
1408
|
|
|
public function shutdown() { |
|
1409
|
|
|
update_option( 'ee_config_option_names', $this->_config_option_names ); |
|
1410
|
|
|
} |
|
1411
|
|
|
|
|
1412
|
|
|
|
|
1413
|
|
|
|
|
1414
|
|
|
} |
|
1415
|
|
|
|
|
1416
|
|
|
|
|
1417
|
|
|
|
|
1418
|
|
|
|
|
1419
|
|
|
|
|
1420
|
|
|
/** |
|
1421
|
|
|
* Base class used for config classes. These classes should generally not have |
|
1422
|
|
|
* magic functions in use, except we'll allow them to magically set and get stuff... |
|
1423
|
|
|
* basically, they should just be well-defined stdClasses |
|
1424
|
|
|
*/ |
|
1425
|
|
|
class EE_Config_Base{ |
|
1426
|
|
|
|
|
1427
|
|
|
/** |
|
1428
|
|
|
* Utility function for escaping the value of a property and returning. |
|
1429
|
|
|
* |
|
1430
|
|
|
* @param string $property property name (checks to see if exists). |
|
1431
|
|
|
* @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1432
|
|
|
* @throws \EE_Error |
|
1433
|
|
|
*/ |
|
1434
|
|
|
public function get_pretty( $property ) { |
|
1435
|
|
|
if ( ! property_exists( $this, $property ) ) { |
|
1436
|
|
|
throw new EE_Error( sprintf( __('%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', 'event_espresso' ), get_class( $this ), $property ) ); |
|
1437
|
|
|
} |
|
1438
|
|
|
//just handling escaping of strings for now. |
|
1439
|
|
|
if ( is_string( $this->{$property} ) ) { |
|
1440
|
|
|
return stripslashes( $this->{$property} ); |
|
1441
|
|
|
} |
|
1442
|
|
|
return $this->{$property}; |
|
1443
|
|
|
} |
|
1444
|
|
|
|
|
1445
|
|
|
|
|
1446
|
|
|
|
|
1447
|
|
|
public function populate() { |
|
1448
|
|
|
//grab defaults via a new instance of this class. |
|
1449
|
|
|
$class_name = get_class( $this ); |
|
1450
|
|
|
$defaults = new $class_name; |
|
1451
|
|
|
|
|
1452
|
|
|
//loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
1453
|
|
|
//default from our $defaults object. |
|
1454
|
|
|
foreach ( get_object_vars( $defaults ) as $property => $value ) { |
|
1455
|
|
|
if ( is_null( $this->{$property} ) ) { |
|
1456
|
|
|
$this->{$property} = $value; |
|
1457
|
|
|
} |
|
1458
|
|
|
} |
|
1459
|
|
|
|
|
1460
|
|
|
//cleanup |
|
1461
|
|
|
unset( $defaults ); |
|
1462
|
|
|
} |
|
1463
|
|
|
|
|
1464
|
|
|
|
|
1465
|
|
|
/** |
|
1466
|
|
|
* @ override magic methods |
|
1467
|
|
|
* @ return void |
|
1468
|
|
|
*/ |
|
1469
|
|
|
// public function __get($a) { return apply_filters('FHEE__'.get_class($this).'__get__'.$a,$this->{$a}); } |
|
1470
|
|
|
// public function __set($a,$b) { return apply_filters('FHEE__'.get_class($this).'__set__'.$a, $this->{$a} = $b ); } |
|
1471
|
|
|
/** |
|
1472
|
|
|
* __isset |
|
1473
|
|
|
* |
|
1474
|
|
|
* @param $a |
|
1475
|
|
|
* @return bool |
|
1476
|
|
|
*/ |
|
1477
|
|
|
public function __isset($a) { return FALSE; } |
|
|
|
|
|
|
1478
|
|
|
|
|
1479
|
|
|
/** |
|
1480
|
|
|
* __unset |
|
1481
|
|
|
* |
|
1482
|
|
|
* @param $a |
|
1483
|
|
|
* @return bool |
|
1484
|
|
|
*/ |
|
1485
|
|
|
public function __unset($a) { return FALSE; } |
|
|
|
|
|
|
1486
|
|
|
/** |
|
1487
|
|
|
* __clone |
|
1488
|
|
|
*/ |
|
1489
|
|
|
public function __clone() { return FALSE; } |
|
1490
|
|
|
/** |
|
1491
|
|
|
* __wakeup |
|
1492
|
|
|
*/ |
|
1493
|
|
|
public function __wakeup() { return FALSE; } |
|
1494
|
|
|
/** |
|
1495
|
|
|
* __destruct |
|
1496
|
|
|
*/ |
|
1497
|
|
|
public function __destruct() { return FALSE; } |
|
1498
|
|
|
} |
|
1499
|
|
|
|
|
1500
|
|
|
|
|
1501
|
|
|
|
|
1502
|
|
|
|
|
1503
|
|
|
/** |
|
1504
|
|
|
* Class for defining what's in the EE_Config relating to registration settings |
|
1505
|
|
|
*/ |
|
1506
|
|
|
class EE_Core_Config extends EE_Config_Base { |
|
1507
|
|
|
|
|
1508
|
|
|
public $current_blog_id; |
|
1509
|
|
|
public $ee_ueip_optin; |
|
1510
|
|
|
public $ee_ueip_has_notified; |
|
1511
|
|
|
/** |
|
1512
|
|
|
* Not to be confused with the 4 critical page variables (See |
|
1513
|
|
|
* get_critical_pages_array()), this is just an array of wp posts that have EE |
|
1514
|
|
|
* shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
1515
|
|
|
* in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
1516
|
|
|
* @var array |
|
1517
|
|
|
*/ |
|
1518
|
|
|
public $post_shortcodes; |
|
1519
|
|
|
public $module_route_map; |
|
1520
|
|
|
public $module_forward_map; |
|
1521
|
|
|
public $module_view_map; |
|
1522
|
|
|
/** |
|
1523
|
|
|
* The next 4 vars are the IDs of critical EE pages. |
|
1524
|
|
|
* @var int |
|
1525
|
|
|
*/ |
|
1526
|
|
|
public $reg_page_id; |
|
1527
|
|
|
public $txn_page_id; |
|
1528
|
|
|
public $thank_you_page_id; |
|
1529
|
|
|
public $cancel_page_id; |
|
1530
|
|
|
/** |
|
1531
|
|
|
* The next 4 vars are the URLs of critical EE pages. |
|
1532
|
|
|
* @var int |
|
1533
|
|
|
*/ |
|
1534
|
|
|
public $reg_page_url; |
|
1535
|
|
|
public $txn_page_url; |
|
1536
|
|
|
public $thank_you_page_url; |
|
1537
|
|
|
public $cancel_page_url; |
|
1538
|
|
|
|
|
1539
|
|
|
/** |
|
1540
|
|
|
* The next vars relate to the custom slugs for EE CPT routes |
|
1541
|
|
|
*/ |
|
1542
|
|
|
public $event_cpt_slug; |
|
1543
|
|
|
|
|
1544
|
|
|
|
|
1545
|
|
|
/** |
|
1546
|
|
|
* class constructor |
|
1547
|
|
|
* |
|
1548
|
|
|
* @access public |
|
1549
|
|
|
* @return \EE_Core_Config |
|
|
|
|
|
|
1550
|
|
|
*/ |
|
1551
|
|
|
public function __construct() { |
|
1552
|
|
|
$current_network_main_site = is_multisite() ? get_current_site() : NULL; |
|
1553
|
|
|
$current_main_site_id = !empty( $current_network_main_site ) ? $current_network_main_site->blog_id : 1; |
|
1554
|
|
|
// set default organization settings |
|
1555
|
|
|
$this->current_blog_id = get_current_blog_id(); |
|
1556
|
|
|
$this->current_blog_id = $this->current_blog_id === NULL ? 1 : $this->current_blog_id; |
|
1557
|
|
|
$this->ee_ueip_optin = is_main_site() ? get_option( 'ee_ueip_optin', TRUE ) : get_blog_option( $current_main_site_id, 'ee_ueip_optin', TRUE ); |
|
1558
|
|
|
$this->ee_ueip_has_notified = is_main_site() ? get_option( 'ee_ueip_has_notified', FALSE ) : TRUE; |
|
1559
|
|
|
$this->post_shortcodes = array(); |
|
1560
|
|
|
$this->module_route_map = array(); |
|
1561
|
|
|
$this->module_forward_map = array(); |
|
1562
|
|
|
$this->module_view_map = array(); |
|
1563
|
|
|
// critical EE page IDs |
|
1564
|
|
|
$this->reg_page_id = 0; |
|
1565
|
|
|
$this->txn_page_id = 0; |
|
1566
|
|
|
$this->thank_you_page_id = 0; |
|
1567
|
|
|
$this->cancel_page_id = 0; |
|
1568
|
|
|
// critical EE page URLs |
|
1569
|
|
|
$this->reg_page_url = ''; |
|
|
|
|
|
|
1570
|
|
|
$this->txn_page_url = ''; |
|
1571
|
|
|
$this->thank_you_page_url = ''; |
|
1572
|
|
|
$this->cancel_page_url = ''; |
|
1573
|
|
|
//cpt slugs |
|
1574
|
|
|
$this->event_cpt_slug = __('events', 'event_espresso'); |
|
1575
|
|
|
|
|
1576
|
|
|
//ueip constant check |
|
1577
|
|
|
if ( defined( 'EE_DISABLE_UXIP' ) && EE_DISABLE_UXIP ) { |
|
1578
|
|
|
$this->ee_ueip_optin = FALSE; |
|
1579
|
|
|
$this->ee_ueip_has_notified = TRUE; |
|
1580
|
|
|
} |
|
1581
|
|
|
} |
|
1582
|
|
|
|
|
1583
|
|
|
|
|
1584
|
|
|
|
|
1585
|
|
|
/** |
|
1586
|
|
|
* @return array |
|
1587
|
|
|
*/ |
|
1588
|
|
|
public function get_critical_pages_array() { |
|
1589
|
|
|
return array( |
|
1590
|
|
|
$this->reg_page_id, |
|
1591
|
|
|
$this->txn_page_id, |
|
1592
|
|
|
$this->thank_you_page_id, |
|
1593
|
|
|
$this->cancel_page_id |
|
1594
|
|
|
); |
|
1595
|
|
|
} |
|
1596
|
|
|
|
|
1597
|
|
|
|
|
1598
|
|
|
/** |
|
1599
|
|
|
* @return array |
|
1600
|
|
|
*/ |
|
1601
|
|
|
public function get_critical_pages_shortcodes_array() { |
|
1602
|
|
|
return array( |
|
1603
|
|
|
$this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
1604
|
|
|
$this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
1605
|
|
|
$this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
1606
|
|
|
$this->cancel_page_id => 'ESPRESSO_CANCELLED' |
|
1607
|
|
|
); |
|
1608
|
|
|
} |
|
1609
|
|
|
|
|
1610
|
|
|
/** |
|
1611
|
|
|
* gets/returns URL for EE reg_page |
|
1612
|
|
|
* |
|
1613
|
|
|
* @access public |
|
1614
|
|
|
* @return string |
|
1615
|
|
|
*/ |
|
1616
|
|
|
public function reg_page_url() { |
|
1617
|
|
|
if ( ! $this->reg_page_url ) { |
|
1618
|
|
|
$this->reg_page_url = get_permalink( $this->reg_page_id ) . '#checkout'; |
|
|
|
|
|
|
1619
|
|
|
} |
|
1620
|
|
|
return $this->reg_page_url; |
|
1621
|
|
|
} |
|
1622
|
|
|
/** |
|
1623
|
|
|
* gets/returns URL for EE txn_page |
|
1624
|
|
|
* @param array $query_args like what gets passed to |
|
1625
|
|
|
* add_query_arg() as the first argument |
|
1626
|
|
|
* |
|
1627
|
|
|
* @access public |
|
1628
|
|
|
* @return string |
|
1629
|
|
|
*/ |
|
1630
|
|
View Code Duplication |
public function txn_page_url($query_args = array()) { |
|
|
|
|
|
|
1631
|
|
|
if ( ! $this->txn_page_url ) { |
|
1632
|
|
|
$this->txn_page_url = get_permalink( $this->txn_page_id ); |
|
1633
|
|
|
} |
|
1634
|
|
|
if($query_args){ |
|
|
|
|
|
|
1635
|
|
|
return add_query_arg($query_args,$this->txn_page_url); |
|
1636
|
|
|
}else{ |
|
1637
|
|
|
return $this->txn_page_url; |
|
1638
|
|
|
} |
|
1639
|
|
|
} |
|
1640
|
|
|
/** |
|
1641
|
|
|
* gets/returns URL for EE thank_you_page |
|
1642
|
|
|
* @param array $query_args like what gets passed to |
|
1643
|
|
|
* add_query_arg() as the first argument |
|
1644
|
|
|
* @access public |
|
1645
|
|
|
* @return string |
|
1646
|
|
|
*/ |
|
1647
|
|
View Code Duplication |
public function thank_you_page_url($query_args = array()) { |
|
|
|
|
|
|
1648
|
|
|
if ( ! $this->thank_you_page_url ) { |
|
1649
|
|
|
$this->thank_you_page_url = get_permalink( $this->thank_you_page_id ); |
|
1650
|
|
|
} |
|
1651
|
|
|
if($query_args){ |
|
|
|
|
|
|
1652
|
|
|
return add_query_arg($query_args,$this->thank_you_page_url); |
|
1653
|
|
|
}else{ |
|
1654
|
|
|
return $this->thank_you_page_url; |
|
1655
|
|
|
} |
|
1656
|
|
|
} |
|
1657
|
|
|
/** |
|
1658
|
|
|
* gets/returns URL for EE cancel_page |
|
1659
|
|
|
* |
|
1660
|
|
|
* @access public |
|
1661
|
|
|
* @return string |
|
1662
|
|
|
*/ |
|
1663
|
|
|
public function cancel_page_url() { |
|
1664
|
|
|
if ( ! $this->cancel_page_url ) { |
|
1665
|
|
|
$this->cancel_page_url = get_permalink( $this->cancel_page_id ); |
|
1666
|
|
|
} |
|
1667
|
|
|
return $this->cancel_page_url; |
|
1668
|
|
|
} |
|
1669
|
|
|
|
|
1670
|
|
|
|
|
1671
|
|
|
/** |
|
1672
|
|
|
* Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
1673
|
|
|
* @since 4.7.5 |
|
1674
|
|
|
*/ |
|
1675
|
|
|
protected function _reset_urls() { |
|
1676
|
|
|
$this->reg_page_url = ''; |
|
|
|
|
|
|
1677
|
|
|
$this->txn_page_url = ''; |
|
1678
|
|
|
$this->cancel_page_url = ''; |
|
1679
|
|
|
$this->thank_you_page_url = ''; |
|
1680
|
|
|
|
|
1681
|
|
|
} |
|
1682
|
|
|
|
|
1683
|
|
|
|
|
1684
|
|
|
/** |
|
1685
|
|
|
* Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
1686
|
|
|
* on the object. |
|
1687
|
|
|
* @return array |
|
1688
|
|
|
*/ |
|
1689
|
|
|
public function __sleep() { |
|
1690
|
|
|
//reset all url properties |
|
1691
|
|
|
$this->_reset_urls(); |
|
1692
|
|
|
//return what to save to db |
|
1693
|
|
|
return array_keys( get_object_vars( $this ) ); |
|
1694
|
|
|
} |
|
1695
|
|
|
|
|
1696
|
|
|
} |
|
1697
|
|
|
|
|
1698
|
|
|
|
|
1699
|
|
|
|
|
1700
|
|
|
/** |
|
1701
|
|
|
* Config class for storing info on the Organization |
|
1702
|
|
|
*/ |
|
1703
|
|
|
class EE_Organization_Config extends EE_Config_Base { |
|
1704
|
|
|
|
|
1705
|
|
|
/** |
|
1706
|
|
|
* @var string $name |
|
1707
|
|
|
* eg EE4.1 |
|
1708
|
|
|
*/ |
|
1709
|
|
|
public $name; |
|
1710
|
|
|
|
|
1711
|
|
|
/** |
|
1712
|
|
|
* @var string $address_1 |
|
1713
|
|
|
* eg 123 Onna Road |
|
1714
|
|
|
*/ |
|
1715
|
|
|
public $address_1; |
|
1716
|
|
|
|
|
1717
|
|
|
/** |
|
1718
|
|
|
* @var string $address_2 |
|
1719
|
|
|
* eg PO Box 123 |
|
1720
|
|
|
*/ |
|
1721
|
|
|
public $address_2; |
|
1722
|
|
|
|
|
1723
|
|
|
/** |
|
1724
|
|
|
* @var string $city |
|
1725
|
|
|
* eg Inna City |
|
1726
|
|
|
*/ |
|
1727
|
|
|
public $city; |
|
1728
|
|
|
|
|
1729
|
|
|
/** |
|
1730
|
|
|
* @var int $STA_ID |
|
1731
|
|
|
* eg 4 |
|
1732
|
|
|
*/ |
|
1733
|
|
|
public $STA_ID; |
|
1734
|
|
|
|
|
1735
|
|
|
/** |
|
1736
|
|
|
* @var string $CNT_ISO |
|
1737
|
|
|
* eg US |
|
1738
|
|
|
*/ |
|
1739
|
|
|
public $CNT_ISO; |
|
1740
|
|
|
|
|
1741
|
|
|
/** |
|
1742
|
|
|
* @var string $zip |
|
1743
|
|
|
* eg 12345 or V1A 2B3 |
|
1744
|
|
|
*/ |
|
1745
|
|
|
public $zip; |
|
1746
|
|
|
|
|
1747
|
|
|
/** |
|
1748
|
|
|
* @var string $email |
|
1749
|
|
|
* eg [email protected] |
|
1750
|
|
|
*/ |
|
1751
|
|
|
public $email; |
|
1752
|
|
|
|
|
1753
|
|
|
|
|
1754
|
|
|
|
|
1755
|
|
|
/** |
|
1756
|
|
|
* @var string $phone |
|
1757
|
|
|
* eg. 111-111-1111 |
|
1758
|
|
|
*/ |
|
1759
|
|
|
public $phone; |
|
1760
|
|
|
|
|
1761
|
|
|
|
|
1762
|
|
|
/** |
|
1763
|
|
|
* @var string $vat |
|
1764
|
|
|
* VAT/Tax Number |
|
1765
|
|
|
*/ |
|
1766
|
|
|
public $vat; |
|
1767
|
|
|
|
|
1768
|
|
|
/** |
|
1769
|
|
|
* @var string $logo_url |
|
1770
|
|
|
* eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
1771
|
|
|
*/ |
|
1772
|
|
|
public $logo_url; |
|
1773
|
|
|
|
|
1774
|
|
|
|
|
1775
|
|
|
/** |
|
1776
|
|
|
* The below are all various properties for holding links to organization social network profiles |
|
1777
|
|
|
* @var string |
|
1778
|
|
|
*/ |
|
1779
|
|
|
|
|
1780
|
|
|
/** |
|
1781
|
|
|
* facebook (facebook.com/profile.name) |
|
1782
|
|
|
* @var string |
|
1783
|
|
|
*/ |
|
1784
|
|
|
public $facebook; |
|
1785
|
|
|
|
|
1786
|
|
|
|
|
1787
|
|
|
/** |
|
1788
|
|
|
* twitter (twitter.com/twitter_handle) |
|
1789
|
|
|
* @var string |
|
1790
|
|
|
*/ |
|
1791
|
|
|
public $twitter; |
|
1792
|
|
|
|
|
1793
|
|
|
|
|
1794
|
|
|
|
|
1795
|
|
|
/** |
|
1796
|
|
|
* linkedin (linkedin.com/in/profile_name) |
|
1797
|
|
|
* @var string |
|
1798
|
|
|
*/ |
|
1799
|
|
|
public $linkedin; |
|
1800
|
|
|
|
|
1801
|
|
|
|
|
1802
|
|
|
|
|
1803
|
|
|
/** |
|
1804
|
|
|
* pinterest (www.pinterest.com/profile_name) |
|
1805
|
|
|
* @var string |
|
1806
|
|
|
*/ |
|
1807
|
|
|
public $pinterest; |
|
1808
|
|
|
|
|
1809
|
|
|
|
|
1810
|
|
|
|
|
1811
|
|
|
/** |
|
1812
|
|
|
* google+ (google.com/+profileName) |
|
1813
|
|
|
* @var string |
|
1814
|
|
|
*/ |
|
1815
|
|
|
public $google; |
|
1816
|
|
|
|
|
1817
|
|
|
|
|
1818
|
|
|
|
|
1819
|
|
|
/** |
|
1820
|
|
|
* instagram (instagram.com/handle) |
|
1821
|
|
|
* @var string |
|
1822
|
|
|
*/ |
|
1823
|
|
|
public $instagram; |
|
1824
|
|
|
|
|
1825
|
|
|
|
|
1826
|
|
|
|
|
1827
|
|
|
/** |
|
1828
|
|
|
* class constructor |
|
1829
|
|
|
* |
|
1830
|
|
|
* @access public |
|
1831
|
|
|
* @return \EE_Organization_Config |
|
|
|
|
|
|
1832
|
|
|
*/ |
|
1833
|
|
|
public function __construct() { |
|
1834
|
|
|
// set default organization settings |
|
1835
|
|
|
$this->name = get_bloginfo('name'); |
|
1836
|
|
|
$this->address_1 = '123 Onna Road'; |
|
1837
|
|
|
$this->address_2 = 'PO Box 123'; |
|
1838
|
|
|
$this->city = 'Inna City'; |
|
1839
|
|
|
$this->STA_ID = 4; |
|
1840
|
|
|
$this->CNT_ISO = 'US'; |
|
1841
|
|
|
$this->zip = '12345'; |
|
1842
|
|
|
$this->email = get_bloginfo('admin_email'); |
|
1843
|
|
|
$this->phone = ''; |
|
1844
|
|
|
$this->vat = '123456789'; |
|
1845
|
|
|
$this->logo_url = ''; |
|
1846
|
|
|
$this->facebook = ''; |
|
1847
|
|
|
$this->twitter = ''; |
|
1848
|
|
|
$this->linkedin = ''; |
|
1849
|
|
|
$this->pinterest = ''; |
|
1850
|
|
|
$this->google = ''; |
|
1851
|
|
|
$this->instagram = ''; |
|
1852
|
|
|
} |
|
1853
|
|
|
|
|
1854
|
|
|
} |
|
1855
|
|
|
|
|
1856
|
|
|
|
|
1857
|
|
|
|
|
1858
|
|
|
|
|
1859
|
|
|
/** |
|
1860
|
|
|
* Class for defining what's in the EE_Config relating to currency |
|
1861
|
|
|
*/ |
|
1862
|
|
|
class EE_Currency_Config extends EE_Config_Base { |
|
1863
|
|
|
|
|
1864
|
|
|
/** |
|
1865
|
|
|
* @var string $code |
|
1866
|
|
|
* eg 'US' |
|
1867
|
|
|
*/ |
|
1868
|
|
|
public $code; |
|
1869
|
|
|
|
|
1870
|
|
|
/** |
|
1871
|
|
|
* @var string $name |
|
1872
|
|
|
* eg 'Dollar' |
|
1873
|
|
|
*/ |
|
1874
|
|
|
public $name; |
|
1875
|
|
|
|
|
1876
|
|
|
/** |
|
1877
|
|
|
* plural name |
|
1878
|
|
|
* @var string $plural |
|
1879
|
|
|
* eg 'Dollars' |
|
1880
|
|
|
*/ |
|
1881
|
|
|
public $plural; |
|
1882
|
|
|
|
|
1883
|
|
|
/** |
|
1884
|
|
|
* currency sign |
|
1885
|
|
|
* @var string $sign |
|
1886
|
|
|
* eg '$' |
|
1887
|
|
|
*/ |
|
1888
|
|
|
public $sign; |
|
1889
|
|
|
|
|
1890
|
|
|
/** |
|
1891
|
|
|
* Whether the currency sign should come before the number or not |
|
1892
|
|
|
* @var boolean $sign_b4 |
|
1893
|
|
|
*/ |
|
1894
|
|
|
public $sign_b4; |
|
1895
|
|
|
|
|
1896
|
|
|
/** |
|
1897
|
|
|
* How many digits should come after the decimal place |
|
1898
|
|
|
* @var int $dec_plc |
|
1899
|
|
|
*/ |
|
1900
|
|
|
public $dec_plc; |
|
1901
|
|
|
|
|
1902
|
|
|
/** |
|
1903
|
|
|
* Symbol to use for decimal mark |
|
1904
|
|
|
* @var string $dec_mrk |
|
1905
|
|
|
* eg '.' |
|
1906
|
|
|
*/ |
|
1907
|
|
|
public $dec_mrk; |
|
1908
|
|
|
|
|
1909
|
|
|
/** |
|
1910
|
|
|
* Symbol to use for thousands |
|
1911
|
|
|
* @var string $thsnds |
|
1912
|
|
|
* eg ',' |
|
1913
|
|
|
*/ |
|
1914
|
|
|
public $thsnds; |
|
1915
|
|
|
|
|
1916
|
|
|
|
|
1917
|
|
|
|
|
1918
|
|
|
/** |
|
1919
|
|
|
* class constructor |
|
1920
|
|
|
* |
|
1921
|
|
|
* @access public |
|
1922
|
|
|
* @param null $CNT_ISO |
|
1923
|
|
|
* @return \EE_Currency_Config |
|
|
|
|
|
|
1924
|
|
|
*/ |
|
1925
|
|
|
public function __construct( $CNT_ISO = NULL ) { |
|
1926
|
|
|
|
|
1927
|
|
|
// get country code from organization settings or use default |
|
1928
|
|
|
$ORG_CNT = isset( EE_Registry::instance()->CFG->organization ) && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ? EE_Registry::instance()->CFG->organization->CNT_ISO : NULL; |
|
1929
|
|
|
// but override if requested |
|
1930
|
|
|
$CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : $ORG_CNT; |
|
1931
|
|
|
EE_Registry::instance()->load_helper( 'Activation' ); |
|
1932
|
|
|
// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
1933
|
|
|
if ( ! empty( $CNT_ISO ) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists( EE_Registry::instance()->load_model( 'Country' )->table() ) ) { |
|
1934
|
|
|
// retrieve the country settings from the db, just in case they have been customized |
|
1935
|
|
|
$country = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $CNT_ISO ); |
|
1936
|
|
|
if ( $country instanceof EE_Country ) { |
|
1937
|
|
|
$this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
|
|
|
|
|
1938
|
|
|
$this->name = $country->currency_name_single(); // Dollar |
|
|
|
|
|
|
1939
|
|
|
$this->plural = $country->currency_name_plural(); // Dollars |
|
|
|
|
|
|
1940
|
|
|
$this->sign = $country->currency_sign(); // currency sign: $ |
|
|
|
|
|
|
1941
|
|
|
$this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
1942
|
|
|
$this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
|
|
|
|
|
1943
|
|
|
$this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
|
|
|
|
|
1944
|
|
|
$this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
|
|
|
|
|
1945
|
|
|
} |
|
1946
|
|
|
} |
|
1947
|
|
|
// fallback to hardcoded defaults, in case the above failed |
|
1948
|
|
|
if ( empty( $this->code )) { |
|
1949
|
|
|
// set default currency settings |
|
1950
|
|
|
$this->code = 'USD'; // currency code: USD, CAD, EUR |
|
1951
|
|
|
$this->name = __( 'Dollar', 'event_espresso' ); // Dollar |
|
1952
|
|
|
$this->plural = __( 'Dollars', 'event_espresso' ); // Dollars |
|
1953
|
|
|
$this->sign = '$'; // currency sign: $ |
|
1954
|
|
|
$this->sign_b4 = TRUE; // currency sign before or after: $TRUE or FALSE$ |
|
1955
|
|
|
$this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
1956
|
|
|
$this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
1957
|
|
|
$this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
1958
|
|
|
} |
|
1959
|
|
|
} |
|
1960
|
|
|
} |
|
1961
|
|
|
|
|
1962
|
|
|
|
|
1963
|
|
|
|
|
1964
|
|
|
|
|
1965
|
|
|
/** |
|
1966
|
|
|
* Class for defining what's in the EE_Config relating to registration settings |
|
1967
|
|
|
*/ |
|
1968
|
|
|
class EE_Registration_Config extends EE_Config_Base { |
|
1969
|
|
|
|
|
1970
|
|
|
/** |
|
1971
|
|
|
* Default registration status |
|
1972
|
|
|
* @var string $default_STS_ID |
|
1973
|
|
|
* eg 'RPP' |
|
1974
|
|
|
*/ |
|
1975
|
|
|
public $default_STS_ID; |
|
1976
|
|
|
|
|
1977
|
|
|
/** |
|
1978
|
|
|
* whether or not to show alternate payment options during the reg process if payment status is pending |
|
1979
|
|
|
* @var boolean $show_pending_payment_options |
|
1980
|
|
|
*/ |
|
1981
|
|
|
public $show_pending_payment_options; |
|
1982
|
|
|
|
|
1983
|
|
|
/** |
|
1984
|
|
|
* Whether to skip the registration confirmation page |
|
1985
|
|
|
* @var boolean $skip_reg_confirmation |
|
1986
|
|
|
*/ |
|
1987
|
|
|
public $skip_reg_confirmation; |
|
1988
|
|
|
|
|
1989
|
|
|
/** |
|
1990
|
|
|
* an array of SPCO reg steps where: |
|
1991
|
|
|
* the keys denotes the reg step order |
|
1992
|
|
|
* each element consists of an array with the following elements: |
|
1993
|
|
|
* "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
1994
|
|
|
* "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
1995
|
|
|
* "slug" => the URL param used to trigger the reg step |
|
1996
|
|
|
* @var array $reg_steps |
|
1997
|
|
|
*/ |
|
1998
|
|
|
public $reg_steps; |
|
1999
|
|
|
|
|
2000
|
|
|
/** |
|
2001
|
|
|
* Whether registration confirmation should be the last page of SPCO |
|
2002
|
|
|
* @var boolean $reg_confirmation_last |
|
2003
|
|
|
*/ |
|
2004
|
|
|
public $reg_confirmation_last; |
|
2005
|
|
|
|
|
2006
|
|
|
/** |
|
2007
|
|
|
* Whether or not to enable the EE Bot Trap |
|
2008
|
|
|
* @var boolean $use_bot_trap |
|
2009
|
|
|
*/ |
|
2010
|
|
|
public $use_bot_trap; |
|
2011
|
|
|
|
|
2012
|
|
|
/** |
|
2013
|
|
|
* Whether or not to encrypt some data sent by the EE Bot Trap |
|
2014
|
|
|
* @var boolean $use_encryption |
|
2015
|
|
|
*/ |
|
2016
|
|
|
public $use_encryption; |
|
2017
|
|
|
|
|
2018
|
|
|
/** |
|
2019
|
|
|
* Whether or not to use ReCaptcha |
|
2020
|
|
|
* @var boolean $use_captcha |
|
2021
|
|
|
*/ |
|
2022
|
|
|
public $use_captcha; |
|
2023
|
|
|
|
|
2024
|
|
|
/** |
|
2025
|
|
|
* ReCaptcha Theme |
|
2026
|
|
|
* @var string $recaptcha_theme |
|
2027
|
|
|
* options: 'dark ', 'light' |
|
2028
|
|
|
*/ |
|
2029
|
|
|
public $recaptcha_theme; |
|
2030
|
|
|
|
|
2031
|
|
|
/** |
|
2032
|
|
|
* ReCaptcha Type |
|
2033
|
|
|
* @var string $recaptcha_type |
|
2034
|
|
|
* options: 'audio', 'image' |
|
2035
|
|
|
*/ |
|
2036
|
|
|
public $recaptcha_type; |
|
2037
|
|
|
|
|
2038
|
|
|
/** |
|
2039
|
|
|
* ReCaptcha language |
|
2040
|
|
|
* @var string $recaptcha_language |
|
2041
|
|
|
* eg 'en' |
|
2042
|
|
|
*/ |
|
2043
|
|
|
public $recaptcha_language; |
|
2044
|
|
|
|
|
2045
|
|
|
/** |
|
2046
|
|
|
* ReCaptcha public key |
|
2047
|
|
|
* @var string $recaptcha_publickey |
|
2048
|
|
|
*/ |
|
2049
|
|
|
public $recaptcha_publickey; |
|
2050
|
|
|
|
|
2051
|
|
|
/** |
|
2052
|
|
|
* ReCaptcha private key |
|
2053
|
|
|
* @var string $recaptcha_privatekey |
|
2054
|
|
|
*/ |
|
2055
|
|
|
public $recaptcha_privatekey; |
|
2056
|
|
|
|
|
2057
|
|
|
/** |
|
2058
|
|
|
* ReCaptcha width |
|
2059
|
|
|
* @var int $recaptcha_width |
|
2060
|
|
|
* @deprecated |
|
2061
|
|
|
*/ |
|
2062
|
|
|
public $recaptcha_width; |
|
2063
|
|
|
|
|
2064
|
|
|
|
|
2065
|
|
|
|
|
2066
|
|
|
|
|
2067
|
|
|
/** |
|
2068
|
|
|
* class constructor |
|
2069
|
|
|
* |
|
2070
|
|
|
* @access public |
|
2071
|
|
|
* @return \EE_Registration_Config |
|
|
|
|
|
|
2072
|
|
|
*/ |
|
2073
|
|
|
public function __construct() { |
|
2074
|
|
|
// set default registration settings |
|
2075
|
|
|
$this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
2076
|
|
|
$this->show_pending_payment_options = TRUE; |
|
2077
|
|
|
$this->skip_reg_confirmation = FALSE; |
|
2078
|
|
|
$this->reg_steps = array(); |
|
2079
|
|
|
$this->reg_confirmation_last = FALSE; |
|
2080
|
|
|
$this->use_bot_trap = true; |
|
2081
|
|
|
$this->use_encryption = true; |
|
2082
|
|
|
$this->use_captcha = FALSE; |
|
2083
|
|
|
$this->recaptcha_theme = 'light'; |
|
2084
|
|
|
$this->recaptcha_type = 'image'; |
|
2085
|
|
|
$this->recaptcha_language = 'en'; |
|
2086
|
|
|
$this->recaptcha_publickey = NULL; |
|
2087
|
|
|
$this->recaptcha_privatekey = NULL; |
|
2088
|
|
|
$this->recaptcha_width = 500; |
|
|
|
|
|
|
2089
|
|
|
} |
|
2090
|
|
|
|
|
2091
|
|
|
|
|
2092
|
|
|
/** |
|
2093
|
|
|
* This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
2094
|
|
|
* @since 4.8.8.rc.019 |
|
2095
|
|
|
*/ |
|
2096
|
|
|
public function do_hooks() { |
|
2097
|
|
|
add_action( 'AHEE__EE_Config___load_core_config__end', array( $this, 'set_default_reg_status_on_EEM_Event' )); |
|
2098
|
|
|
} |
|
2099
|
|
|
|
|
2100
|
|
|
|
|
2101
|
|
|
/** |
|
2102
|
|
|
* @return void |
|
2103
|
|
|
*/ |
|
2104
|
|
|
public function set_default_reg_status_on_EEM_Event() { |
|
2105
|
|
|
EEM_Event::set_default_reg_status( $this->default_STS_ID ); |
|
2106
|
|
|
} |
|
2107
|
|
|
|
|
2108
|
|
|
|
|
2109
|
|
|
|
|
2110
|
|
|
|
|
2111
|
|
|
} |
|
2112
|
|
|
|
|
2113
|
|
|
|
|
2114
|
|
|
|
|
2115
|
|
|
/** |
|
2116
|
|
|
* Class for defining what's in the EE_Config relating to admin settings |
|
2117
|
|
|
*/ |
|
2118
|
|
|
class EE_Admin_Config extends EE_Config_Base { |
|
2119
|
|
|
|
|
2120
|
|
|
/** |
|
2121
|
|
|
* @var boolean $use_personnel_manager |
|
2122
|
|
|
*/ |
|
2123
|
|
|
public $use_personnel_manager; |
|
2124
|
|
|
|
|
2125
|
|
|
/** |
|
2126
|
|
|
* @var boolean $use_dashboard_widget |
|
2127
|
|
|
*/ |
|
2128
|
|
|
public $use_dashboard_widget; |
|
2129
|
|
|
|
|
2130
|
|
|
/** |
|
2131
|
|
|
* @var int $events_in_dashboard |
|
2132
|
|
|
*/ |
|
2133
|
|
|
public $events_in_dashboard; |
|
2134
|
|
|
|
|
2135
|
|
|
/** |
|
2136
|
|
|
* @var boolean $use_event_timezones |
|
2137
|
|
|
*/ |
|
2138
|
|
|
public $use_event_timezones; |
|
2139
|
|
|
|
|
2140
|
|
|
/** |
|
2141
|
|
|
* @var boolean $use_full_logging |
|
2142
|
|
|
*/ |
|
2143
|
|
|
public $use_full_logging; |
|
2144
|
|
|
|
|
2145
|
|
|
/** |
|
2146
|
|
|
* @var string $log_file_name |
|
2147
|
|
|
*/ |
|
2148
|
|
|
public $log_file_name; |
|
2149
|
|
|
|
|
2150
|
|
|
/** |
|
2151
|
|
|
* @var string $debug_file_name |
|
2152
|
|
|
*/ |
|
2153
|
|
|
public $debug_file_name; |
|
2154
|
|
|
|
|
2155
|
|
|
/** |
|
2156
|
|
|
* @var boolean $use_remote_logging |
|
2157
|
|
|
*/ |
|
2158
|
|
|
public $use_remote_logging; |
|
2159
|
|
|
|
|
2160
|
|
|
/** |
|
2161
|
|
|
* @var string $remote_logging_url |
|
2162
|
|
|
*/ |
|
2163
|
|
|
public $remote_logging_url; |
|
2164
|
|
|
|
|
2165
|
|
|
/** |
|
2166
|
|
|
* @var boolean $show_reg_footer |
|
2167
|
|
|
*/ |
|
2168
|
|
|
public $show_reg_footer; |
|
2169
|
|
|
|
|
2170
|
|
|
/** |
|
2171
|
|
|
* @var string $affiliate_id |
|
2172
|
|
|
*/ |
|
2173
|
|
|
public $affiliate_id; |
|
2174
|
|
|
|
|
2175
|
|
|
|
|
2176
|
|
|
/** |
|
2177
|
|
|
* help tours on or off (global setting) |
|
2178
|
|
|
* @var boolean |
|
2179
|
|
|
*/ |
|
2180
|
|
|
public $help_tour_activation; |
|
2181
|
|
|
|
|
2182
|
|
|
|
|
2183
|
|
|
|
|
2184
|
|
|
/** |
|
2185
|
|
|
* class constructor |
|
2186
|
|
|
* |
|
2187
|
|
|
* @access public |
|
2188
|
|
|
* @return \EE_Admin_Config |
|
|
|
|
|
|
2189
|
|
|
*/ |
|
2190
|
|
|
public function __construct() { |
|
2191
|
|
|
// set default general admin settings |
|
2192
|
|
|
$this->use_personnel_manager = TRUE; |
|
2193
|
|
|
$this->use_dashboard_widget = TRUE; |
|
2194
|
|
|
$this->events_in_dashboard = 30; |
|
2195
|
|
|
$this->use_event_timezones = FALSE; |
|
2196
|
|
|
$this->use_full_logging = FALSE; |
|
2197
|
|
|
$this->use_remote_logging = FALSE; |
|
2198
|
|
|
$this->remote_logging_url = NULL; |
|
2199
|
|
|
$this->show_reg_footer = TRUE; |
|
2200
|
|
|
$this->affiliate_id = 'default'; |
|
2201
|
|
|
$this->help_tour_activation = TRUE; |
|
2202
|
|
|
} |
|
2203
|
|
|
|
|
2204
|
|
|
|
|
2205
|
|
|
|
|
2206
|
|
|
/** |
|
2207
|
|
|
* @param bool $reset |
|
2208
|
|
|
* @return string |
|
2209
|
|
|
*/ |
|
2210
|
|
View Code Duplication |
public function log_file_name( $reset = FALSE ) { |
|
|
|
|
|
|
2211
|
|
|
if ( empty( $this->log_file_name ) || $reset ) { |
|
2212
|
|
|
$this->log_file_name = sanitize_key( 'espresso_log_' . md5( uniqid( '', TRUE ))) . '.txt'; |
|
2213
|
|
|
EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
|
2214
|
|
|
} |
|
2215
|
|
|
return $this->log_file_name; |
|
2216
|
|
|
} |
|
2217
|
|
|
|
|
2218
|
|
|
|
|
2219
|
|
|
|
|
2220
|
|
|
|
|
2221
|
|
|
/** |
|
2222
|
|
|
* @param bool $reset |
|
2223
|
|
|
* @return string |
|
2224
|
|
|
*/ |
|
2225
|
|
View Code Duplication |
public function debug_file_name( $reset = FALSE ) { |
|
|
|
|
|
|
2226
|
|
|
if ( empty( $this->debug_file_name ) || $reset ) { |
|
2227
|
|
|
$this->debug_file_name = sanitize_key( 'espresso_debug_' . md5( uniqid( '', TRUE ))) . '.txt'; |
|
2228
|
|
|
EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
|
2229
|
|
|
} |
|
2230
|
|
|
return $this->debug_file_name; |
|
2231
|
|
|
} |
|
2232
|
|
|
|
|
2233
|
|
|
|
|
2234
|
|
|
|
|
2235
|
|
|
|
|
2236
|
|
|
} |
|
2237
|
|
|
|
|
2238
|
|
|
|
|
2239
|
|
|
|
|
2240
|
|
|
/** |
|
2241
|
|
|
* Class for defining what's in the EE_Config relating to template settings |
|
2242
|
|
|
*/ |
|
2243
|
|
|
class EE_Template_Config extends EE_Config_Base { |
|
2244
|
|
|
|
|
2245
|
|
|
/** |
|
2246
|
|
|
* @var boolean $enable_default_style |
|
2247
|
|
|
*/ |
|
2248
|
|
|
public $enable_default_style; |
|
2249
|
|
|
|
|
2250
|
|
|
/** |
|
2251
|
|
|
* @var string $custom_style_sheet |
|
2252
|
|
|
*/ |
|
2253
|
|
|
public $custom_style_sheet; |
|
2254
|
|
|
|
|
2255
|
|
|
/** |
|
2256
|
|
|
* @var boolean $display_address_in_regform |
|
2257
|
|
|
*/ |
|
2258
|
|
|
public $display_address_in_regform; |
|
2259
|
|
|
|
|
2260
|
|
|
/** |
|
2261
|
|
|
* @var int $display_description_on_multi_reg_page |
|
2262
|
|
|
*/ |
|
2263
|
|
|
public $display_description_on_multi_reg_page; |
|
2264
|
|
|
|
|
2265
|
|
|
/** |
|
2266
|
|
|
* @var boolean $use_custom_templates |
|
2267
|
|
|
*/ |
|
2268
|
|
|
public $use_custom_templates; |
|
2269
|
|
|
|
|
2270
|
|
|
/** |
|
2271
|
|
|
* @var string $current_espresso_theme |
|
2272
|
|
|
*/ |
|
2273
|
|
|
public $current_espresso_theme; |
|
2274
|
|
|
|
|
2275
|
|
|
/** |
|
2276
|
|
|
* @var EE_Event_Single_Config $EED_Event_Single |
|
2277
|
|
|
*/ |
|
2278
|
|
|
public $EED_Event_Single; |
|
2279
|
|
|
|
|
2280
|
|
|
/** |
|
2281
|
|
|
* @var EE_Events_Archive_Config $EED_Events_Archive |
|
2282
|
|
|
*/ |
|
2283
|
|
|
public $EED_Events_Archive; |
|
2284
|
|
|
|
|
2285
|
|
|
|
|
2286
|
|
|
|
|
2287
|
|
|
/** |
|
2288
|
|
|
* class constructor |
|
2289
|
|
|
* |
|
2290
|
|
|
* @access public |
|
2291
|
|
|
* @return \EE_Template_Config |
|
|
|
|
|
|
2292
|
|
|
*/ |
|
2293
|
|
|
public function __construct() { |
|
2294
|
|
|
// set default template settings |
|
2295
|
|
|
$this->enable_default_style = TRUE; |
|
2296
|
|
|
$this->custom_style_sheet = NULL; |
|
2297
|
|
|
$this->display_address_in_regform = TRUE; |
|
2298
|
|
|
$this->display_description_on_multi_reg_page = FALSE; |
|
|
|
|
|
|
2299
|
|
|
$this->use_custom_templates = FALSE; |
|
2300
|
|
|
$this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
2301
|
|
|
$this->EED_Event_Single = null; |
|
2302
|
|
|
$this->EED_Events_Archive = null; |
|
2303
|
|
|
} |
|
2304
|
|
|
|
|
2305
|
|
|
} |
|
2306
|
|
|
|
|
2307
|
|
|
|
|
2308
|
|
|
|
|
2309
|
|
|
/** |
|
2310
|
|
|
* Class for defining what's in the EE_Config relating to map settings |
|
2311
|
|
|
*/ |
|
2312
|
|
|
class EE_Map_Config extends EE_Config_Base { |
|
2313
|
|
|
|
|
2314
|
|
|
/** |
|
2315
|
|
|
* @var boolean $use_google_maps |
|
2316
|
|
|
*/ |
|
2317
|
|
|
public $use_google_maps; |
|
2318
|
|
|
|
|
2319
|
|
|
/** |
|
2320
|
|
|
* @var int $event_details_map_width |
|
2321
|
|
|
*/ |
|
2322
|
|
|
public $event_details_map_width; |
|
2323
|
|
|
|
|
2324
|
|
|
/** |
|
2325
|
|
|
* @var int $event_details_map_height |
|
2326
|
|
|
*/ |
|
2327
|
|
|
public $event_details_map_height; |
|
2328
|
|
|
|
|
2329
|
|
|
/** |
|
2330
|
|
|
* @var int $event_details_map_zoom |
|
2331
|
|
|
*/ |
|
2332
|
|
|
public $event_details_map_zoom; |
|
2333
|
|
|
|
|
2334
|
|
|
/** |
|
2335
|
|
|
* @var boolean $event_details_display_nav |
|
2336
|
|
|
*/ |
|
2337
|
|
|
public $event_details_display_nav; |
|
2338
|
|
|
|
|
2339
|
|
|
/** |
|
2340
|
|
|
* @var boolean $event_details_nav_size |
|
2341
|
|
|
*/ |
|
2342
|
|
|
public $event_details_nav_size; |
|
2343
|
|
|
|
|
2344
|
|
|
/** |
|
2345
|
|
|
* @var string $event_details_control_type |
|
2346
|
|
|
*/ |
|
2347
|
|
|
public $event_details_control_type; |
|
2348
|
|
|
|
|
2349
|
|
|
/** |
|
2350
|
|
|
* @var string $event_details_map_align |
|
2351
|
|
|
*/ |
|
2352
|
|
|
public $event_details_map_align; |
|
2353
|
|
|
|
|
2354
|
|
|
/** |
|
2355
|
|
|
* @var int $event_list_map_width |
|
2356
|
|
|
*/ |
|
2357
|
|
|
public $event_list_map_width; |
|
2358
|
|
|
|
|
2359
|
|
|
/** |
|
2360
|
|
|
* @var int $event_list_map_height |
|
2361
|
|
|
*/ |
|
2362
|
|
|
public $event_list_map_height; |
|
2363
|
|
|
|
|
2364
|
|
|
/** |
|
2365
|
|
|
* @var int $event_list_map_zoom |
|
2366
|
|
|
*/ |
|
2367
|
|
|
public $event_list_map_zoom; |
|
2368
|
|
|
|
|
2369
|
|
|
/** |
|
2370
|
|
|
* @var boolean $event_list_display_nav |
|
2371
|
|
|
*/ |
|
2372
|
|
|
public $event_list_display_nav; |
|
2373
|
|
|
|
|
2374
|
|
|
/** |
|
2375
|
|
|
* @var boolean $event_list_nav_size |
|
2376
|
|
|
*/ |
|
2377
|
|
|
public $event_list_nav_size; |
|
2378
|
|
|
|
|
2379
|
|
|
/** |
|
2380
|
|
|
* @var string $event_list_control_type |
|
2381
|
|
|
*/ |
|
2382
|
|
|
public $event_list_control_type; |
|
2383
|
|
|
|
|
2384
|
|
|
/** |
|
2385
|
|
|
* @var string $event_list_map_align |
|
2386
|
|
|
*/ |
|
2387
|
|
|
public $event_list_map_align; |
|
2388
|
|
|
|
|
2389
|
|
|
|
|
2390
|
|
|
|
|
2391
|
|
|
/** |
|
2392
|
|
|
* class constructor |
|
2393
|
|
|
* |
|
2394
|
|
|
* @access public |
|
2395
|
|
|
* @return \EE_Map_Config |
|
|
|
|
|
|
2396
|
|
|
*/ |
|
2397
|
|
|
public function __construct() { |
|
2398
|
|
|
// set default map settings |
|
2399
|
|
|
$this->use_google_maps = TRUE; |
|
2400
|
|
|
// for event details pages (reg page) |
|
2401
|
|
|
$this->event_details_map_width = 585; // ee_map_width_single |
|
2402
|
|
|
$this->event_details_map_height = 362; // ee_map_height_single |
|
2403
|
|
|
$this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2404
|
|
|
$this->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
2405
|
|
|
$this->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
2406
|
|
|
$this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2407
|
|
|
$this->event_details_map_align = 'center'; // ee_map_align_single |
|
2408
|
|
|
// for event list pages |
|
2409
|
|
|
$this->event_list_map_width = 300; // ee_map_width |
|
2410
|
|
|
$this->event_list_map_height = 185; // ee_map_height |
|
2411
|
|
|
$this->event_list_map_zoom = 12; // ee_map_zoom |
|
2412
|
|
|
$this->event_list_display_nav = FALSE; // ee_map_nav_display |
|
2413
|
|
|
$this->event_list_nav_size = TRUE; // ee_map_nav_size |
|
2414
|
|
|
$this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2415
|
|
|
$this->event_list_map_align = 'center'; // ee_map_align |
|
2416
|
|
|
} |
|
2417
|
|
|
|
|
2418
|
|
|
} |
|
2419
|
|
|
|
|
2420
|
|
|
|
|
2421
|
|
|
|
|
2422
|
|
|
|
|
2423
|
|
|
/** |
|
2424
|
|
|
* stores Events_Archive settings |
|
2425
|
|
|
*/ |
|
2426
|
|
|
class EE_Events_Archive_Config extends EE_Config_Base{ |
|
2427
|
|
|
|
|
2428
|
|
|
public $display_status_banner; |
|
2429
|
|
|
public $display_description; |
|
2430
|
|
|
public $display_ticket_selector; |
|
2431
|
|
|
public $display_datetimes; |
|
2432
|
|
|
public $display_venue; |
|
2433
|
|
|
public $display_expired_events; |
|
2434
|
|
|
public $use_sortable_display_order; |
|
2435
|
|
|
public $display_order_tickets; |
|
2436
|
|
|
public $display_order_datetimes; |
|
2437
|
|
|
public $display_order_event; |
|
2438
|
|
|
public $display_order_venue; |
|
2439
|
|
|
|
|
2440
|
|
|
|
|
2441
|
|
|
|
|
2442
|
|
|
/** |
|
2443
|
|
|
* class constructor |
|
2444
|
|
|
*/ |
|
2445
|
|
|
public function __construct(){ |
|
2446
|
|
|
$this->display_status_banner = 0; |
|
2447
|
|
|
$this->display_description = 1; |
|
2448
|
|
|
$this->display_ticket_selector = 0; |
|
2449
|
|
|
$this->display_datetimes = 1; |
|
2450
|
|
|
$this->display_venue = 0; |
|
2451
|
|
|
$this->display_expired_events = 0; |
|
2452
|
|
|
$this->use_sortable_display_order = false; |
|
2453
|
|
|
$this->display_order_tickets = 100; |
|
2454
|
|
|
$this->display_order_datetimes = 110; |
|
2455
|
|
|
$this->display_order_event = 120; |
|
2456
|
|
|
$this->display_order_venue = 130; |
|
2457
|
|
|
} |
|
2458
|
|
|
} |
|
2459
|
|
|
|
|
2460
|
|
|
|
|
2461
|
|
|
|
|
2462
|
|
|
/** |
|
2463
|
|
|
* Stores Event_Single_Config settings |
|
2464
|
|
|
*/ |
|
2465
|
|
|
class EE_Event_Single_Config extends EE_Config_Base{ |
|
2466
|
|
|
|
|
2467
|
|
|
public $display_status_banner_single; |
|
2468
|
|
|
public $display_venue; |
|
2469
|
|
|
public $use_sortable_display_order; |
|
2470
|
|
|
public $display_order_tickets; |
|
2471
|
|
|
public $display_order_datetimes; |
|
2472
|
|
|
public $display_order_event; |
|
2473
|
|
|
public $display_order_venue; |
|
2474
|
|
|
|
|
2475
|
|
|
/** |
|
2476
|
|
|
* class constructor |
|
2477
|
|
|
*/ |
|
2478
|
|
|
public function __construct() { |
|
2479
|
|
|
$this->display_status_banner_single = 0; |
|
2480
|
|
|
$this->display_venue = 1; |
|
2481
|
|
|
$this->use_sortable_display_order = false; |
|
2482
|
|
|
$this->display_order_tickets = 100; |
|
2483
|
|
|
$this->display_order_datetimes = 110; |
|
2484
|
|
|
$this->display_order_event = 120; |
|
2485
|
|
|
$this->display_order_venue = 130; |
|
2486
|
|
|
} |
|
2487
|
|
|
} |
|
2488
|
|
|
|
|
2489
|
|
|
|
|
2490
|
|
|
|
|
2491
|
|
|
/** |
|
2492
|
|
|
* Stores Ticket_Selector_Config settings |
|
2493
|
|
|
*/ |
|
2494
|
|
|
class EE_Ticket_Selector_Config extends EE_Config_Base{ |
|
2495
|
|
|
public $show_ticket_sale_columns; |
|
2496
|
|
|
public $show_ticket_details; |
|
2497
|
|
|
public $show_expired_tickets; |
|
2498
|
|
|
|
|
2499
|
|
|
/** |
|
2500
|
|
|
* class constructor |
|
2501
|
|
|
*/ |
|
2502
|
|
|
public function __construct() { |
|
2503
|
|
|
$this->show_ticket_sale_columns = 1; |
|
2504
|
|
|
$this->show_ticket_details = 1; |
|
2505
|
|
|
$this->show_expired_tickets = 1; |
|
2506
|
|
|
} |
|
2507
|
|
|
} |
|
2508
|
|
|
|
|
2509
|
|
|
|
|
2510
|
|
|
|
|
2511
|
|
|
|
|
2512
|
|
|
|
|
2513
|
|
|
|
|
2514
|
|
|
/** |
|
2515
|
|
|
* Stores any EE Environment values that are referenced through the code. |
|
2516
|
|
|
* |
|
2517
|
|
|
* @since 4.4.0 |
|
2518
|
|
|
* @package Event Espresso |
|
2519
|
|
|
* @subpackage config |
|
2520
|
|
|
*/ |
|
2521
|
|
|
class EE_Environment_Config extends EE_Config_Base { |
|
2522
|
|
|
|
|
2523
|
|
|
/** |
|
2524
|
|
|
* Hold any php environment variables that we want to track. |
|
2525
|
|
|
* |
|
2526
|
|
|
* @var stdClass; |
|
2527
|
|
|
*/ |
|
2528
|
|
|
public $php; |
|
2529
|
|
|
|
|
2530
|
|
|
|
|
2531
|
|
|
|
|
2532
|
|
|
/** |
|
2533
|
|
|
* constructor |
|
2534
|
|
|
*/ |
|
2535
|
|
|
public function __construct() { |
|
2536
|
|
|
$this->php = new stdClass(); |
|
2537
|
|
|
$this->_set_php_values(); |
|
2538
|
|
|
} |
|
2539
|
|
|
|
|
2540
|
|
|
|
|
2541
|
|
|
/** |
|
2542
|
|
|
* This sets the php environment variables. |
|
2543
|
|
|
* |
|
2544
|
|
|
* @since 4.4.0 |
|
2545
|
|
|
* @return void |
|
2546
|
|
|
*/ |
|
2547
|
|
|
protected function _set_php_values() { |
|
2548
|
|
|
$this->php->max_input_vars = ini_get( 'max_input_vars' ); |
|
2549
|
|
|
$this->php->version = phpversion(); |
|
2550
|
|
|
} |
|
2551
|
|
|
|
|
2552
|
|
|
|
|
2553
|
|
|
|
|
2554
|
|
|
/** |
|
2555
|
|
|
* helper method for determining whether input_count is |
|
2556
|
|
|
* reaching the potential maximum the server can handle |
|
2557
|
|
|
* according to max_input_vars |
|
2558
|
|
|
* |
|
2559
|
|
|
* @param int $input_count the count of input vars. |
|
2560
|
|
|
* |
|
2561
|
|
|
* @return array { |
|
2562
|
|
|
* An array that represents whether available space and if no available space the error message. |
|
2563
|
|
|
* @type bool $has_space whether more inputs can be added. |
|
2564
|
|
|
* @type string $msg Any message to be displayed. |
|
2565
|
|
|
* } |
|
2566
|
|
|
*/ |
|
2567
|
|
|
public function max_input_vars_limit_check( $input_count = 0 ) { |
|
2568
|
|
|
if ( ( $input_count >= $this->php->max_input_vars ) && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >=9 ) ) { |
|
2569
|
|
|
return __('The number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.', 'event_espresso'); |
|
2570
|
|
|
} else { |
|
2571
|
|
|
return ''; |
|
|
|
|
|
|
2572
|
|
|
} |
|
2573
|
|
|
} |
|
2574
|
|
|
|
|
2575
|
|
|
|
|
2576
|
|
|
|
|
2577
|
|
|
|
|
2578
|
|
|
/** |
|
2579
|
|
|
* The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
2580
|
|
|
* |
|
2581
|
|
|
* @since 4.4.1 |
|
2582
|
|
|
* |
|
2583
|
|
|
* @return void |
|
2584
|
|
|
*/ |
|
2585
|
|
|
public function recheck_values() { |
|
2586
|
|
|
$this->_set_php_values(); |
|
2587
|
|
|
} |
|
2588
|
|
|
|
|
2589
|
|
|
|
|
2590
|
|
|
|
|
2591
|
|
|
} |
|
2592
|
|
|
|
|
2593
|
|
|
|
|
2594
|
|
|
|
|
2595
|
|
|
|
|
2596
|
|
|
|
|
2597
|
|
|
|
|
2598
|
|
|
|
|
2599
|
|
|
|
|
2600
|
|
|
/** |
|
2601
|
|
|
* stores payment gateway info |
|
2602
|
|
|
* @deprecated |
|
2603
|
|
|
*/ |
|
2604
|
|
|
class EE_Gateway_Config extends EE_Config_Base{ |
|
2605
|
|
|
|
|
2606
|
|
|
/** |
|
2607
|
|
|
* Array with keys that are payment gateways slugs, and values are arrays |
|
2608
|
|
|
* with any config info the gateway wants to store |
|
2609
|
|
|
* @var array |
|
2610
|
|
|
*/ |
|
2611
|
|
|
public $payment_settings; |
|
2612
|
|
|
|
|
2613
|
|
|
/** |
|
2614
|
|
|
* Where keys are gateway slugs, and values are booleans indicating whether or not |
|
2615
|
|
|
* the gateway is stored in the uploads directory |
|
2616
|
|
|
* @var array |
|
2617
|
|
|
*/ |
|
2618
|
|
|
public $active_gateways; |
|
2619
|
|
|
|
|
2620
|
|
|
|
|
2621
|
|
|
|
|
2622
|
|
|
/** |
|
2623
|
|
|
* class constructor |
|
2624
|
|
|
* @deprecated |
|
2625
|
|
|
*/ |
|
2626
|
|
|
public function __construct(){ |
|
2627
|
|
|
$this->payment_settings = array(); |
|
2628
|
|
|
$this->active_gateways = array( 'Invoice' => FALSE ); |
|
2629
|
|
|
} |
|
2630
|
|
|
} |
|
2631
|
|
|
|
|
2632
|
|
|
// End of file EE_Config.core.php |
|
2633
|
|
|
// Location: /core/EE_Config.core.php |
|
2634
|
|
|
|
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.