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
|
|
|
if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) { |
885
|
|
|
return; |
886
|
|
|
} |
887
|
|
|
// allow shortcodes to register with WP and to set hooks for the rest of the system |
888
|
|
|
EE_Registry::instance()->shortcodes =$this->_register_shortcodes(); |
889
|
|
|
// allow modules to set hooks for the rest of the system |
890
|
|
|
EE_Registry::instance()->modules = $this->_register_modules(); |
891
|
|
|
} |
892
|
|
|
|
893
|
|
|
|
894
|
|
|
/** |
895
|
|
|
* initialize_shortcodes_and_modules |
896
|
|
|
* meaning they can start adding their hooks to get stuff done |
897
|
|
|
* |
898
|
|
|
* @access public |
899
|
|
|
* @return void |
900
|
|
|
*/ |
901
|
|
|
public function initialize_shortcodes_and_modules() { |
902
|
|
|
if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) { |
903
|
|
|
return; |
904
|
|
|
} |
905
|
|
|
// allow shortcodes to set hooks for the rest of the system |
906
|
|
|
$this->_initialize_shortcodes(); |
907
|
|
|
// allow modules to set hooks for the rest of the system |
908
|
|
|
$this->_initialize_modules(); |
909
|
|
|
} |
910
|
|
|
|
911
|
|
|
|
912
|
|
|
|
913
|
|
|
|
914
|
|
|
/** |
915
|
|
|
* widgets_init |
916
|
|
|
* |
917
|
|
|
* @access private |
918
|
|
|
* @return void |
919
|
|
|
*/ |
920
|
|
|
public function widgets_init() { |
921
|
|
|
if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) { |
922
|
|
|
return; |
923
|
|
|
} |
924
|
|
|
//only init widgets on admin pages when not in complete maintenance, and |
925
|
|
|
//on frontend when not in any maintenance mode |
926
|
|
|
if (( is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) || ! EE_Maintenance_Mode::instance()->level() ) { |
927
|
|
|
// grab list of installed widgets |
928
|
|
|
$widgets_to_register = glob( EE_WIDGETS . '*', GLOB_ONLYDIR ); |
929
|
|
|
// filter list of modules to register |
930
|
|
|
$widgets_to_register = apply_filters( 'FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register ); |
931
|
|
|
|
932
|
|
|
if ( ! empty( $widgets_to_register ) ) { |
933
|
|
|
// cycle thru widget folders |
934
|
|
|
foreach ( $widgets_to_register as $widget_path ) { |
935
|
|
|
// add to list of installed widget modules |
936
|
|
|
EE_Config::register_ee_widget( $widget_path ); |
937
|
|
|
} |
938
|
|
|
} |
939
|
|
|
// filter list of installed modules |
940
|
|
|
EE_Registry::instance()->widgets = apply_filters( 'FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets ); |
941
|
|
|
} |
942
|
|
|
} |
943
|
|
|
|
944
|
|
|
|
945
|
|
|
|
946
|
|
|
/** |
947
|
|
|
* register_ee_widget - makes core aware of this widget |
948
|
|
|
* |
949
|
|
|
* @access public |
950
|
|
|
* @param string $widget_path - full path up to and including widget folder |
951
|
|
|
* @return void |
952
|
|
|
*/ |
953
|
|
|
public static function register_ee_widget( $widget_path = NULL ) { |
954
|
|
|
do_action( 'AHEE__EE_Config__register_widget__begin', $widget_path ); |
955
|
|
|
$widget_ext = '.widget.php'; |
956
|
|
|
// make all separators match |
957
|
|
|
$widget_path = rtrim( str_replace( '/\\', DS, $widget_path ), DS ); |
958
|
|
|
// does the file path INCLUDE the actual file name as part of the path ? |
959
|
|
|
if ( strpos( $widget_path, $widget_ext ) !== FALSE ) { |
960
|
|
|
// grab and shortcode file name from directory name and break apart at dots |
961
|
|
|
$file_name = explode( '.', basename( $widget_path )); |
962
|
|
|
// take first segment from file name pieces and remove class prefix if it exists |
963
|
|
|
$widget = strpos( $file_name[0], 'EEW_' ) === 0 ? substr( $file_name[0], 4 ) : $file_name[0]; |
964
|
|
|
// sanitize shortcode directory name |
965
|
|
|
$widget = sanitize_key( $widget ); |
966
|
|
|
// now we need to rebuild the shortcode path |
967
|
|
|
$widget_path = explode( DS, $widget_path ); |
968
|
|
|
// remove last segment |
969
|
|
|
array_pop( $widget_path ); |
970
|
|
|
// glue it back together |
971
|
|
|
$widget_path = implode( DS, $widget_path ); |
972
|
|
|
} else { |
973
|
|
|
// grab and sanitize widget directory name |
974
|
|
|
$widget = sanitize_key( basename( $widget_path )); |
975
|
|
|
} |
976
|
|
|
// create classname from widget directory name |
977
|
|
|
$widget = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget ))); |
978
|
|
|
// add class prefix |
979
|
|
|
$widget_class = 'EEW_' . $widget; |
980
|
|
|
// does the widget exist ? |
981
|
|
View Code Duplication |
if ( ! is_readable( $widget_path . DS . $widget_class . $widget_ext )) { |
|
|
|
|
982
|
|
|
$msg = sprintf( |
983
|
|
|
__( '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' ), |
984
|
|
|
$widget_class, |
985
|
|
|
$widget_path . DS . $widget_class . $widget_ext |
986
|
|
|
); |
987
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
988
|
|
|
return; |
989
|
|
|
} |
990
|
|
|
// load the widget class file |
991
|
|
|
require_once( $widget_path . DS . $widget_class . $widget_ext ); |
992
|
|
|
// verify that class exists |
993
|
|
|
if ( ! class_exists( $widget_class )) { |
994
|
|
|
$msg = sprintf( __( 'The requested %s widget class does not exist.', 'event_espresso' ), $widget_class ); |
995
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
996
|
|
|
return; |
997
|
|
|
} |
998
|
|
|
register_widget( $widget_class ); |
999
|
|
|
// add to array of registered widgets |
1000
|
|
|
EE_Registry::instance()->widgets->$widget_class = $widget_path . DS . $widget_class . $widget_ext; |
1001
|
|
|
} |
1002
|
|
|
|
1003
|
|
|
|
1004
|
|
|
|
1005
|
|
|
/** |
1006
|
|
|
* _register_shortcodes |
1007
|
|
|
* |
1008
|
|
|
* @access private |
1009
|
|
|
* @return array |
1010
|
|
|
*/ |
1011
|
|
|
private function _register_shortcodes() { |
1012
|
|
|
// grab list of installed shortcodes |
1013
|
|
|
$shortcodes_to_register = glob( EE_SHORTCODES . '*', GLOB_ONLYDIR ); |
1014
|
|
|
// filter list of modules to register |
1015
|
|
|
$shortcodes_to_register = apply_filters( 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register ); |
1016
|
|
|
if ( ! empty( $shortcodes_to_register ) ) { |
1017
|
|
|
// cycle thru shortcode folders |
1018
|
|
|
foreach ( $shortcodes_to_register as $shortcode_path ) { |
1019
|
|
|
// add to list of installed shortcode modules |
1020
|
|
|
EE_Config::register_shortcode( $shortcode_path ); |
1021
|
|
|
} |
1022
|
|
|
} |
1023
|
|
|
// filter list of installed modules |
1024
|
|
|
return apply_filters( 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes ); |
1025
|
|
|
} |
1026
|
|
|
|
1027
|
|
|
|
1028
|
|
|
|
1029
|
|
|
/** |
1030
|
|
|
* register_shortcode - makes core aware of this shortcode |
1031
|
|
|
* |
1032
|
|
|
* @access public |
1033
|
|
|
* @param string $shortcode_path - full path up to and including shortcode folder |
1034
|
|
|
* @return bool |
1035
|
|
|
*/ |
1036
|
|
|
public static function register_shortcode( $shortcode_path = NULL ) { |
1037
|
|
|
do_action( 'AHEE__EE_Config__register_shortcode__begin',$shortcode_path ); |
1038
|
|
|
$shortcode_ext = '.shortcode.php'; |
1039
|
|
|
// make all separators match |
1040
|
|
|
$shortcode_path = str_replace( array( '\\', '/' ), DS, $shortcode_path ); |
1041
|
|
|
// does the file path INCLUDE the actual file name as part of the path ? |
1042
|
|
|
if ( strpos( $shortcode_path, $shortcode_ext ) !== FALSE ) { |
1043
|
|
|
// grab shortcode file name from directory name and break apart at dots |
1044
|
|
|
$shortcode_file = explode( '.', basename( $shortcode_path )); |
1045
|
|
|
// take first segment from file name pieces and remove class prefix if it exists |
1046
|
|
|
$shortcode = strpos( $shortcode_file[0], 'EES_' ) === 0 ? substr( $shortcode_file[0], 4 ) : $shortcode_file[0]; |
1047
|
|
|
// sanitize shortcode directory name |
1048
|
|
|
$shortcode = sanitize_key( $shortcode ); |
1049
|
|
|
// now we need to rebuild the shortcode path |
1050
|
|
|
$shortcode_path = explode( DS, $shortcode_path ); |
1051
|
|
|
// remove last segment |
1052
|
|
|
array_pop( $shortcode_path ); |
1053
|
|
|
// glue it back together |
1054
|
|
|
$shortcode_path = implode( DS, $shortcode_path ) . DS; |
1055
|
|
|
} else { |
1056
|
|
|
// we need to generate the filename based off of the folder name |
1057
|
|
|
// grab and sanitize shortcode directory name |
1058
|
|
|
$shortcode = sanitize_key( basename( $shortcode_path )); |
1059
|
|
|
$shortcode_path = rtrim( $shortcode_path, DS ) . DS; |
1060
|
|
|
} |
1061
|
|
|
// create classname from shortcode directory or file name |
1062
|
|
|
$shortcode = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $shortcode ))); |
1063
|
|
|
// add class prefix |
1064
|
|
|
$shortcode_class = 'EES_' . $shortcode; |
1065
|
|
|
// does the shortcode exist ? |
1066
|
|
View Code Duplication |
if ( ! is_readable( $shortcode_path . DS . $shortcode_class . $shortcode_ext )) { |
|
|
|
|
1067
|
|
|
$msg = sprintf( |
1068
|
|
|
__( 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso' ), |
1069
|
|
|
$shortcode_class, |
1070
|
|
|
$shortcode_path . DS . $shortcode_class . $shortcode_ext |
1071
|
|
|
); |
1072
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1073
|
|
|
return FALSE; |
1074
|
|
|
} |
1075
|
|
|
// load the shortcode class file |
1076
|
|
|
require_once( $shortcode_path . $shortcode_class . $shortcode_ext ); |
1077
|
|
|
// verify that class exists |
1078
|
|
|
if ( ! class_exists( $shortcode_class )) { |
1079
|
|
|
$msg = sprintf( __( 'The requested %s shortcode class does not exist.', 'event_espresso' ), $shortcode_class ); |
1080
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1081
|
|
|
return FALSE; |
1082
|
|
|
} |
1083
|
|
|
$shortcode = strtoupper( $shortcode ); |
1084
|
|
|
// add to array of registered shortcodes |
1085
|
|
|
EE_Registry::instance()->shortcodes->$shortcode = $shortcode_path . $shortcode_class . $shortcode_ext; |
1086
|
|
|
return TRUE; |
1087
|
|
|
} |
1088
|
|
|
|
1089
|
|
|
|
1090
|
|
|
|
1091
|
|
|
|
1092
|
|
|
/** |
1093
|
|
|
* _register_modules |
1094
|
|
|
* |
1095
|
|
|
* @access private |
1096
|
|
|
* @return array |
1097
|
|
|
*/ |
1098
|
|
|
private function _register_modules() { |
1099
|
|
|
// grab list of installed modules |
1100
|
|
|
$modules_to_register = glob( EE_MODULES . '*', GLOB_ONLYDIR ); |
1101
|
|
|
// filter list of modules to register |
1102
|
|
|
$modules_to_register = apply_filters( 'FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register ); |
1103
|
|
|
|
1104
|
|
|
|
1105
|
|
|
if ( ! empty( $modules_to_register ) ) { |
1106
|
|
|
// loop through folders |
1107
|
|
|
foreach ( $modules_to_register as $module_path ) { |
1108
|
|
|
/**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
1109
|
|
|
if ( $module_path != EE_MODULES . 'zzz-copy-this-module-template' && $module_path != EE_MODULES . 'gateways' ) { |
1110
|
|
|
// add to list of installed modules |
1111
|
|
|
EE_Config::register_module( $module_path ); |
1112
|
|
|
} |
1113
|
|
|
} |
1114
|
|
|
} |
1115
|
|
|
// filter list of installed modules |
1116
|
|
|
return apply_filters( 'FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules ); |
1117
|
|
|
} |
1118
|
|
|
|
1119
|
|
|
|
1120
|
|
|
|
1121
|
|
|
|
1122
|
|
|
/** |
1123
|
|
|
* register_module - makes core aware of this module |
1124
|
|
|
* |
1125
|
|
|
* @access public |
1126
|
|
|
* @param string $module_path - full path up to and including module folder |
1127
|
|
|
* @return bool |
1128
|
|
|
*/ |
1129
|
|
|
public static function register_module( $module_path = NULL ) { |
1130
|
|
|
do_action( 'AHEE__EE_Config__register_module__begin', $module_path ); |
1131
|
|
|
$module_ext = '.module.php'; |
1132
|
|
|
// make all separators match |
1133
|
|
|
$module_path = str_replace( array( '\\', '/' ), DS, $module_path ); |
1134
|
|
|
// does the file path INCLUDE the actual file name as part of the path ? |
1135
|
|
|
if ( strpos( $module_path, $module_ext ) !== FALSE ) { |
1136
|
|
|
// grab and shortcode file name from directory name and break apart at dots |
1137
|
|
|
$module_file = explode( '.', basename( $module_path )); |
1138
|
|
|
// now we need to rebuild the shortcode path |
1139
|
|
|
$module_path = explode( DS, $module_path ); |
1140
|
|
|
// remove last segment |
1141
|
|
|
array_pop( $module_path ); |
1142
|
|
|
// glue it back together |
1143
|
|
|
$module_path = implode( DS, $module_path ) . DS; |
1144
|
|
|
// take first segment from file name pieces and sanitize it |
1145
|
|
|
$module = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $module_file[0] ); |
1146
|
|
|
// ensure class prefix is added |
1147
|
|
|
$module_class = strpos( $module, 'EED_' ) !== 0 ? 'EED_' . $module : $module; |
1148
|
|
|
} else { |
1149
|
|
|
// we need to generate the filename based off of the folder name |
1150
|
|
|
// grab and sanitize module name |
1151
|
|
|
$module = strtolower( basename( $module_path )); |
1152
|
|
|
$module = preg_replace( '/[^a-z0-9_\-]/', '', $module); |
1153
|
|
|
// like trailingslashit() |
1154
|
|
|
$module_path = rtrim( $module_path, DS ) . DS; |
1155
|
|
|
// create classname from module directory name |
1156
|
|
|
$module = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $module ))); |
1157
|
|
|
// add class prefix |
1158
|
|
|
$module_class = 'EED_' . $module; |
1159
|
|
|
} |
1160
|
|
|
// does the module exist ? |
1161
|
|
View Code Duplication |
if ( ! is_readable( $module_path . DS . $module_class . $module_ext )) { |
|
|
|
|
1162
|
|
|
$msg = sprintf( __( 'The requested %s module file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module ); |
1163
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1164
|
|
|
return FALSE; |
1165
|
|
|
} |
1166
|
|
|
// load the module class file |
1167
|
|
|
require_once( $module_path . $module_class . $module_ext ); |
1168
|
|
|
// verify that class exists |
1169
|
|
|
if ( ! class_exists( $module_class )) { |
1170
|
|
|
$msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
1171
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1172
|
|
|
return FALSE; |
1173
|
|
|
} |
1174
|
|
|
// add to array of registered modules |
1175
|
|
|
EE_Registry::instance()->modules->$module_class = $module_path . $module_class . $module_ext; |
1176
|
|
|
do_action( 'AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->$module_class ); |
1177
|
|
|
return TRUE; |
1178
|
|
|
} |
1179
|
|
|
|
1180
|
|
|
|
1181
|
|
|
/** |
1182
|
|
|
* _initialize_shortcodes |
1183
|
|
|
* allow shortcodes to set hooks for the rest of the system |
1184
|
|
|
* |
1185
|
|
|
* @access private |
1186
|
|
|
* @return void |
1187
|
|
|
*/ |
1188
|
|
|
private function _initialize_shortcodes() { |
1189
|
|
|
// cycle thru shortcode folders |
1190
|
|
|
foreach ( EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path ) { |
1191
|
|
|
// add class prefix |
1192
|
|
|
$shortcode_class = 'EES_' . $shortcode; |
1193
|
|
|
// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
1194
|
|
|
// which set hooks ? |
1195
|
|
|
if ( is_admin() ) { |
1196
|
|
|
// fire immediately |
1197
|
|
|
call_user_func( array( $shortcode_class, 'set_hooks_admin' )); |
1198
|
|
|
} else { |
1199
|
|
|
// delay until other systems are online |
1200
|
|
|
add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $shortcode_class,'set_hooks' )); |
1201
|
|
|
// convert classname to UPPERCASE and create WP shortcode. |
1202
|
|
|
$shortcode_tag = strtoupper( $shortcode ); |
1203
|
|
|
// but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor' |
1204
|
|
|
if ( ! shortcode_exists( $shortcode_tag )) { |
1205
|
|
|
// NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes() |
1206
|
|
|
add_shortcode( $shortcode_tag, array( $shortcode_class, 'fallback_shortcode_processor' )); |
1207
|
|
|
} |
1208
|
|
|
} |
1209
|
|
|
} |
1210
|
|
|
} |
1211
|
|
|
|
1212
|
|
|
|
1213
|
|
|
|
1214
|
|
|
/** |
1215
|
|
|
* _initialize_modules |
1216
|
|
|
* allow modules to set hooks for the rest of the system |
1217
|
|
|
* |
1218
|
|
|
* @access private |
1219
|
|
|
* @return void |
1220
|
|
|
*/ |
1221
|
|
|
private function _initialize_modules() { |
1222
|
|
|
// cycle thru shortcode folders |
1223
|
|
|
foreach ( EE_Registry::instance()->modules as $module_class => $module_path ) { |
1224
|
|
|
// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
1225
|
|
|
// which set hooks ? |
1226
|
|
|
if ( is_admin() ) { |
1227
|
|
|
// fire immediately |
1228
|
|
|
call_user_func( array( $module_class, 'set_hooks_admin' )); |
1229
|
|
|
} else { |
1230
|
|
|
// delay until other systems are online |
1231
|
|
|
add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $module_class,'set_hooks' )); |
1232
|
|
|
} |
1233
|
|
|
} |
1234
|
|
|
} |
1235
|
|
|
|
1236
|
|
|
|
1237
|
|
|
|
1238
|
|
|
|
1239
|
|
|
/** |
1240
|
|
|
* register_route - adds module method routes to route_map |
1241
|
|
|
* |
1242
|
|
|
* @access public |
1243
|
|
|
* @param string $route - "pretty" public alias for module method |
1244
|
|
|
* @param string $module - module name (classname without EED_ prefix) |
1245
|
|
|
* @param string $method_name - the actual module method to be routed to |
1246
|
|
|
* @param string $key - url param key indicating a route is being called |
1247
|
|
|
* @return bool |
1248
|
|
|
*/ |
1249
|
|
|
public static function register_route( $route = NULL, $module = NULL, $method_name = NULL, $key = 'ee' ) { |
1250
|
|
|
do_action( 'AHEE__EE_Config__register_route__begin', $route, $module, $method_name ); |
1251
|
|
|
$module = str_replace( 'EED_', '', $module ); |
1252
|
|
|
$module_class = 'EED_' . $module; |
1253
|
|
|
if ( ! isset( EE_Registry::instance()->modules->$module_class )) { |
1254
|
|
|
$msg = sprintf( __( 'The module %s has not been registered.', 'event_espresso' ), $module ); |
1255
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1256
|
|
|
return FALSE; |
1257
|
|
|
} |
1258
|
|
View Code Duplication |
if ( empty( $route )) { |
|
|
|
|
1259
|
|
|
$msg = sprintf( __( 'No route has been supplied.', 'event_espresso' ), $route ); |
1260
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1261
|
|
|
return FALSE; |
1262
|
|
|
} |
1263
|
|
View Code Duplication |
if ( ! method_exists ( 'EED_' . $module, $method_name )) { |
|
|
|
|
1264
|
|
|
$msg = sprintf( __( 'A valid class method for the %s route has not been supplied.', 'event_espresso' ), $route ); |
1265
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1266
|
|
|
return FALSE; |
1267
|
|
|
} |
1268
|
|
|
EE_Config::$_module_route_map[ $key ][ $route ] = array( 'EED_' . $module, $method_name ); |
1269
|
|
|
return TRUE; |
1270
|
|
|
} |
1271
|
|
|
|
1272
|
|
|
|
1273
|
|
|
|
1274
|
|
|
/** |
1275
|
|
|
* get_route - get module method route |
1276
|
|
|
* |
1277
|
|
|
* @access public |
1278
|
|
|
* @param string $route - "pretty" public alias for module method |
1279
|
|
|
* @param string $key - url param key indicating a route is being called |
1280
|
|
|
* @return string |
1281
|
|
|
*/ |
1282
|
|
|
public static function get_route( $route = NULL, $key = 'ee' ) { |
1283
|
|
|
do_action( 'AHEE__EE_Config__get_route__begin',$route ); |
1284
|
|
|
$route = apply_filters( 'FHEE__EE_Config__get_route',$route ); |
1285
|
|
|
if ( isset( EE_Config::$_module_route_map[ $key ][ $route ] )) { |
1286
|
|
|
return EE_Config::$_module_route_map[ $key ][ $route ]; |
1287
|
|
|
} |
1288
|
|
|
return NULL; |
1289
|
|
|
} |
1290
|
|
|
|
1291
|
|
|
|
1292
|
|
|
|
1293
|
|
|
/** |
1294
|
|
|
* get_routes - get ALL module method routes |
1295
|
|
|
* |
1296
|
|
|
* @access public |
1297
|
|
|
* @return array |
1298
|
|
|
*/ |
1299
|
|
|
public static function get_routes() { |
1300
|
|
|
return EE_Config::$_module_route_map; |
1301
|
|
|
} |
1302
|
|
|
|
1303
|
|
|
|
1304
|
|
|
|
1305
|
|
|
/** |
1306
|
|
|
* register_forward - allows modules to forward request to another module for further processing |
1307
|
|
|
* |
1308
|
|
|
* @access public |
1309
|
|
|
* @param string $route - "pretty" public alias for module method |
1310
|
|
|
* @param integer $status - integer value corresponding to status constant strings set in module parent class, allows different forwards to be served based on status |
1311
|
|
|
* @param array|string $forward - function name or array( class, method ) |
1312
|
|
|
* @param string $key - url param key indicating a route is being called |
1313
|
|
|
* @return bool |
1314
|
|
|
*/ |
1315
|
|
|
public static function register_forward( $route = NULL, $status = 0, $forward = NULL, $key = 'ee' ) { |
1316
|
|
|
do_action( 'AHEE__EE_Config__register_forward',$route,$status,$forward ); |
1317
|
|
View Code Duplication |
if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route )) { |
|
|
|
|
1318
|
|
|
$msg = sprintf( __( 'The module route %s for this forward has not been registered.', 'event_espresso' ), $route ); |
1319
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1320
|
|
|
return FALSE; |
1321
|
|
|
} |
1322
|
|
View Code Duplication |
if ( empty( $forward )) { |
|
|
|
|
1323
|
|
|
$msg = sprintf( __( 'No forwarding route has been supplied.', 'event_espresso' ), $route ); |
1324
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1325
|
|
|
return FALSE; |
1326
|
|
|
} |
1327
|
|
|
if ( is_array( $forward )) { |
1328
|
|
View Code Duplication |
if ( ! isset( $forward[1] )) { |
|
|
|
|
1329
|
|
|
$msg = sprintf( __( 'A class method for the %s forwarding route has not been supplied.', 'event_espresso' ), $route ); |
1330
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1331
|
|
|
return FALSE; |
1332
|
|
|
} |
1333
|
|
|
if ( ! method_exists( $forward[0], $forward[1] )) { |
1334
|
|
|
$msg = sprintf( __( 'The class method %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward[1], $route ); |
1335
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1336
|
|
|
return FALSE; |
1337
|
|
|
} |
1338
|
|
|
} else if ( ! function_exists( $forward )) { |
1339
|
|
|
$msg = sprintf( __( 'The function %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward, $route ); |
1340
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1341
|
|
|
return FALSE; |
1342
|
|
|
} |
1343
|
|
|
EE_Config::$_module_forward_map[ $key ][ $route ][ absint( $status ) ] = $forward; |
1344
|
|
|
return TRUE; |
1345
|
|
|
} |
1346
|
|
|
|
1347
|
|
|
|
1348
|
|
|
|
1349
|
|
|
/** |
1350
|
|
|
* get_forward - get forwarding route |
1351
|
|
|
* |
1352
|
|
|
* @access public |
1353
|
|
|
* @param string $route - "pretty" public alias for module method |
1354
|
|
|
* @param integer $status - integer value corresponding to status constant strings set in module parent class, allows different forwards to be served based on status |
1355
|
|
|
* @param string $key - url param key indicating a route is being called |
1356
|
|
|
* @return string |
1357
|
|
|
*/ |
1358
|
|
View Code Duplication |
public static function get_forward( $route = NULL, $status = 0, $key = 'ee' ) { |
|
|
|
|
1359
|
|
|
do_action( 'AHEE__EE_Config__get_forward__begin',$route,$status ); |
1360
|
|
|
if ( isset( EE_Config::$_module_forward_map[ $key ][ $route ][ $status ] )) { |
1361
|
|
|
return apply_filters( 'FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], $route,$status ); |
1362
|
|
|
} |
1363
|
|
|
return NULL; |
1364
|
|
|
} |
1365
|
|
|
|
1366
|
|
|
|
1367
|
|
|
|
1368
|
|
|
/** |
1369
|
|
|
* register_forward - allows modules to specify different view templates for different method routes and status results |
1370
|
|
|
* |
1371
|
|
|
* @access public |
1372
|
|
|
* @param string $route - "pretty" public alias for module method |
1373
|
|
|
* @param integer $status - integer value corresponding to status constant strings set in module parent class, allows different views to be served based on status |
1374
|
|
|
* @param string $view |
1375
|
|
|
* @param string $key - url param key indicating a route is being called |
1376
|
|
|
* @return bool |
1377
|
|
|
*/ |
1378
|
|
|
public static function register_view( $route = NULL, $status = 0, $view = NULL, $key = 'ee' ) { |
1379
|
|
|
do_action( 'AHEE__EE_Config__register_view__begin',$route,$status,$view ); |
1380
|
|
View Code Duplication |
if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route )) { |
|
|
|
|
1381
|
|
|
$msg = sprintf( __( 'The module route %s for this view has not been registered.', 'event_espresso' ), $route ); |
1382
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1383
|
|
|
return FALSE; |
1384
|
|
|
} |
1385
|
|
|
if ( ! is_readable( $view )) { |
1386
|
|
|
$msg = sprintf( __( 'The %s view file could not be found or is not readable due to file permissions.', 'event_espresso' ), $view ); |
1387
|
|
|
EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
1388
|
|
|
return FALSE; |
1389
|
|
|
} |
1390
|
|
|
EE_Config::$_module_view_map[ $key ][ $route ][ absint( $status ) ] = $view; |
1391
|
|
|
return TRUE; |
1392
|
|
|
} |
1393
|
|
|
|
1394
|
|
|
|
1395
|
|
|
|
1396
|
|
|
|
1397
|
|
|
|
1398
|
|
|
/** |
1399
|
|
|
* get_view - get view for route and status |
1400
|
|
|
* |
1401
|
|
|
* @access public |
1402
|
|
|
* @param string $route - "pretty" public alias for module method |
1403
|
|
|
* @param integer $status - integer value corresponding to status constant strings set in module parent class, allows different views to be served based on status |
1404
|
|
|
* @param string $key - url param key indicating a route is being called |
1405
|
|
|
* @return string |
1406
|
|
|
*/ |
1407
|
|
View Code Duplication |
public static function get_view( $route = NULL, $status = 0, $key = 'ee' ) { |
|
|
|
|
1408
|
|
|
do_action( 'AHEE__EE_Config__get_view__begin',$route,$status ); |
1409
|
|
|
if ( isset( EE_Config::$_module_view_map[ $key ][ $route ][ $status ] )) { |
1410
|
|
|
return apply_filters( 'FHEE__EE_Config__get_view', EE_Config::$_module_view_map[ $key ][ $route ][ $status ], $route,$status ); |
1411
|
|
|
} |
1412
|
|
|
return NULL; |
1413
|
|
|
} |
1414
|
|
|
|
1415
|
|
|
|
1416
|
|
|
|
1417
|
|
|
public function shutdown() { |
1418
|
|
|
update_option( 'ee_config_option_names', $this->_config_option_names ); |
1419
|
|
|
} |
1420
|
|
|
|
1421
|
|
|
|
1422
|
|
|
|
1423
|
|
|
} |
1424
|
|
|
|
1425
|
|
|
|
1426
|
|
|
|
1427
|
|
|
|
1428
|
|
|
|
1429
|
|
|
/** |
1430
|
|
|
* Base class used for config classes. These classes should generally not have |
1431
|
|
|
* magic functions in use, except we'll allow them to magically set and get stuff... |
1432
|
|
|
* basically, they should just be well-defined stdClasses |
1433
|
|
|
*/ |
1434
|
|
|
class EE_Config_Base{ |
1435
|
|
|
|
1436
|
|
|
/** |
1437
|
|
|
* Utility function for escaping the value of a property and returning. |
1438
|
|
|
* |
1439
|
|
|
* @param string $property property name (checks to see if exists). |
1440
|
|
|
* @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
1441
|
|
|
* @throws \EE_Error |
1442
|
|
|
*/ |
1443
|
|
|
public function get_pretty( $property ) { |
1444
|
|
|
if ( ! property_exists( $this, $property ) ) { |
1445
|
|
|
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 ) ); |
1446
|
|
|
} |
1447
|
|
|
//just handling escaping of strings for now. |
1448
|
|
|
if ( is_string( $this->$property ) ) { |
1449
|
|
|
return stripslashes( $this->$property ); |
1450
|
|
|
} |
1451
|
|
|
return $this->$property; |
1452
|
|
|
} |
1453
|
|
|
|
1454
|
|
|
|
1455
|
|
|
|
1456
|
|
|
public function populate() { |
1457
|
|
|
//grab defaults via a new instance of this class. |
1458
|
|
|
$class_name = get_class( $this ); |
1459
|
|
|
$defaults = new $class_name; |
1460
|
|
|
|
1461
|
|
|
//loop through the properties for this class and see if they are set. If they are NOT, then grab the |
1462
|
|
|
//default from our $defaults object. |
1463
|
|
|
foreach ( get_object_vars( $defaults ) as $property => $value ) { |
1464
|
|
|
if ( is_null( $this->$property ) ) { |
1465
|
|
|
$this->$property = $value; |
1466
|
|
|
} |
1467
|
|
|
} |
1468
|
|
|
|
1469
|
|
|
//cleanup |
1470
|
|
|
unset( $defaults ); |
1471
|
|
|
} |
1472
|
|
|
|
1473
|
|
|
|
1474
|
|
|
/** |
1475
|
|
|
* @ override magic methods |
1476
|
|
|
* @ return void |
1477
|
|
|
*/ |
1478
|
|
|
// public function __get($a) { return apply_filters('FHEE__'.get_class($this).'__get__'.$a,$this->$a); } |
1479
|
|
|
// public function __set($a,$b) { return apply_filters('FHEE__'.get_class($this).'__set__'.$a, $this->$a = $b ); } |
1480
|
|
|
/** |
1481
|
|
|
* __isset |
1482
|
|
|
* |
1483
|
|
|
* @param $a |
1484
|
|
|
* @return bool |
1485
|
|
|
*/ |
1486
|
|
|
public function __isset($a) { return FALSE; } |
|
|
|
|
1487
|
|
|
|
1488
|
|
|
/** |
1489
|
|
|
* __unset |
1490
|
|
|
* |
1491
|
|
|
* @param $a |
1492
|
|
|
* @return bool |
1493
|
|
|
*/ |
1494
|
|
|
public function __unset($a) { return FALSE; } |
|
|
|
|
1495
|
|
|
/** |
1496
|
|
|
* __clone |
1497
|
|
|
*/ |
1498
|
|
|
public function __clone() { return FALSE; } |
1499
|
|
|
/** |
1500
|
|
|
* __wakeup |
1501
|
|
|
*/ |
1502
|
|
|
public function __wakeup() { return FALSE; } |
1503
|
|
|
/** |
1504
|
|
|
* __destruct |
1505
|
|
|
*/ |
1506
|
|
|
public function __destruct() { return FALSE; } |
1507
|
|
|
} |
1508
|
|
|
|
1509
|
|
|
|
1510
|
|
|
|
1511
|
|
|
|
1512
|
|
|
/** |
1513
|
|
|
* Class for defining what's in the EE_Config relating to registration settings |
1514
|
|
|
*/ |
1515
|
|
|
class EE_Core_Config extends EE_Config_Base { |
1516
|
|
|
|
1517
|
|
|
public $current_blog_id; |
1518
|
|
|
public $ee_ueip_optin; |
1519
|
|
|
public $ee_ueip_has_notified; |
1520
|
|
|
/** |
1521
|
|
|
* Not to be confused with the 4 critical page variables (See |
1522
|
|
|
* get_critical_pages_array()), this is just an array of wp posts that have EE |
1523
|
|
|
* shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
1524
|
|
|
* in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
1525
|
|
|
* @var array |
1526
|
|
|
*/ |
1527
|
|
|
public $post_shortcodes; |
1528
|
|
|
public $module_route_map; |
1529
|
|
|
public $module_forward_map; |
1530
|
|
|
public $module_view_map; |
1531
|
|
|
/** |
1532
|
|
|
* The next 4 vars are the IDs of critical EE pages. |
1533
|
|
|
* @var int |
1534
|
|
|
*/ |
1535
|
|
|
public $reg_page_id; |
1536
|
|
|
public $txn_page_id; |
1537
|
|
|
public $thank_you_page_id; |
1538
|
|
|
public $cancel_page_id; |
1539
|
|
|
/** |
1540
|
|
|
* The next 4 vars are the URLs of critical EE pages. |
1541
|
|
|
* @var int |
1542
|
|
|
*/ |
1543
|
|
|
public $reg_page_url; |
1544
|
|
|
public $txn_page_url; |
1545
|
|
|
public $thank_you_page_url; |
1546
|
|
|
public $cancel_page_url; |
1547
|
|
|
|
1548
|
|
|
/** |
1549
|
|
|
* The next vars relate to the custom slugs for EE CPT routes |
1550
|
|
|
*/ |
1551
|
|
|
public $event_cpt_slug; |
1552
|
|
|
|
1553
|
|
|
|
1554
|
|
|
/** |
1555
|
|
|
* class constructor |
1556
|
|
|
* |
1557
|
|
|
* @access public |
1558
|
|
|
* @return \EE_Core_Config |
|
|
|
|
1559
|
|
|
*/ |
1560
|
|
|
public function __construct() { |
1561
|
|
|
$current_network_main_site = is_multisite() ? get_current_site() : NULL; |
1562
|
|
|
$current_main_site_id = !empty( $current_network_main_site ) ? $current_network_main_site->blog_id : 1; |
1563
|
|
|
// set default organization settings |
1564
|
|
|
$this->current_blog_id = get_current_blog_id(); |
1565
|
|
|
$this->current_blog_id = $this->current_blog_id === NULL ? 1 : $this->current_blog_id; |
1566
|
|
|
$this->ee_ueip_optin = is_main_site() ? get_option( 'ee_ueip_optin', TRUE ) : get_blog_option( $current_main_site_id, 'ee_ueip_optin', TRUE ); |
1567
|
|
|
$this->ee_ueip_has_notified = is_main_site() ? get_option( 'ee_ueip_has_notified', FALSE ) : TRUE; |
1568
|
|
|
$this->post_shortcodes = array(); |
1569
|
|
|
$this->module_route_map = array(); |
1570
|
|
|
$this->module_forward_map = array(); |
1571
|
|
|
$this->module_view_map = array(); |
1572
|
|
|
// critical EE page IDs |
1573
|
|
|
$this->reg_page_id = 0; |
1574
|
|
|
$this->txn_page_id = 0; |
1575
|
|
|
$this->thank_you_page_id = 0; |
1576
|
|
|
$this->cancel_page_id = 0; |
1577
|
|
|
// critical EE page URLs |
1578
|
|
|
$this->reg_page_url = ''; |
|
|
|
|
1579
|
|
|
$this->txn_page_url = ''; |
1580
|
|
|
$this->thank_you_page_url = ''; |
1581
|
|
|
$this->cancel_page_url = ''; |
1582
|
|
|
//cpt slugs |
1583
|
|
|
$this->event_cpt_slug = __('events', 'event_espresso'); |
1584
|
|
|
|
1585
|
|
|
//ueip constant check |
1586
|
|
|
if ( defined( 'EE_DISABLE_UXIP' ) && EE_DISABLE_UXIP ) { |
1587
|
|
|
$this->ee_ueip_optin = FALSE; |
1588
|
|
|
$this->ee_ueip_has_notified = TRUE; |
1589
|
|
|
} |
1590
|
|
|
} |
1591
|
|
|
|
1592
|
|
|
|
1593
|
|
|
|
1594
|
|
|
/** |
1595
|
|
|
* @return array |
1596
|
|
|
*/ |
1597
|
|
|
public function get_critical_pages_array() { |
1598
|
|
|
return array( |
1599
|
|
|
$this->reg_page_id, |
1600
|
|
|
$this->txn_page_id, |
1601
|
|
|
$this->thank_you_page_id, |
1602
|
|
|
$this->cancel_page_id |
1603
|
|
|
); |
1604
|
|
|
} |
1605
|
|
|
|
1606
|
|
|
|
1607
|
|
|
/** |
1608
|
|
|
* @return array |
1609
|
|
|
*/ |
1610
|
|
|
public function get_critical_pages_shortcodes_array() { |
1611
|
|
|
return array( |
1612
|
|
|
$this->reg_page_id => 'ESPRESSO_CHECKOUT', |
1613
|
|
|
$this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
1614
|
|
|
$this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
1615
|
|
|
$this->cancel_page_id => 'ESPRESSO_CANCELLED' |
1616
|
|
|
); |
1617
|
|
|
} |
1618
|
|
|
|
1619
|
|
|
/** |
1620
|
|
|
* gets/returns URL for EE reg_page |
1621
|
|
|
* |
1622
|
|
|
* @access public |
1623
|
|
|
* @return string |
1624
|
|
|
*/ |
1625
|
|
|
public function reg_page_url() { |
1626
|
|
|
if ( ! $this->reg_page_url ) { |
1627
|
|
|
$this->reg_page_url = get_permalink( $this->reg_page_id ) . '#checkout'; |
|
|
|
|
1628
|
|
|
} |
1629
|
|
|
return $this->reg_page_url; |
1630
|
|
|
} |
1631
|
|
|
/** |
1632
|
|
|
* gets/returns URL for EE txn_page |
1633
|
|
|
* @param array $query_args like what gets passed to |
1634
|
|
|
* add_query_arg() as the first argument |
1635
|
|
|
* |
1636
|
|
|
* @access public |
1637
|
|
|
* @return string |
1638
|
|
|
*/ |
1639
|
|
View Code Duplication |
public function txn_page_url($query_args = array()) { |
|
|
|
|
1640
|
|
|
if ( ! $this->txn_page_url ) { |
1641
|
|
|
$this->txn_page_url = get_permalink( $this->txn_page_id ); |
1642
|
|
|
} |
1643
|
|
|
if($query_args){ |
|
|
|
|
1644
|
|
|
return add_query_arg($query_args,$this->txn_page_url); |
1645
|
|
|
}else{ |
1646
|
|
|
return $this->txn_page_url; |
1647
|
|
|
} |
1648
|
|
|
} |
1649
|
|
|
/** |
1650
|
|
|
* gets/returns URL for EE thank_you_page |
1651
|
|
|
* @param array $query_args like what gets passed to |
1652
|
|
|
* add_query_arg() as the first argument |
1653
|
|
|
* @access public |
1654
|
|
|
* @return string |
1655
|
|
|
*/ |
1656
|
|
View Code Duplication |
public function thank_you_page_url($query_args = array()) { |
|
|
|
|
1657
|
|
|
if ( ! $this->thank_you_page_url ) { |
1658
|
|
|
$this->thank_you_page_url = get_permalink( $this->thank_you_page_id ); |
1659
|
|
|
} |
1660
|
|
|
if($query_args){ |
|
|
|
|
1661
|
|
|
return add_query_arg($query_args,$this->thank_you_page_url); |
1662
|
|
|
}else{ |
1663
|
|
|
return $this->thank_you_page_url; |
1664
|
|
|
} |
1665
|
|
|
} |
1666
|
|
|
/** |
1667
|
|
|
* gets/returns URL for EE cancel_page |
1668
|
|
|
* |
1669
|
|
|
* @access public |
1670
|
|
|
* @return string |
1671
|
|
|
*/ |
1672
|
|
|
public function cancel_page_url() { |
1673
|
|
|
if ( ! $this->cancel_page_url ) { |
1674
|
|
|
$this->cancel_page_url = get_permalink( $this->cancel_page_id ); |
1675
|
|
|
} |
1676
|
|
|
return $this->cancel_page_url; |
1677
|
|
|
} |
1678
|
|
|
|
1679
|
|
|
|
1680
|
|
|
/** |
1681
|
|
|
* Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
1682
|
|
|
* @since 4.7.5 |
1683
|
|
|
*/ |
1684
|
|
|
protected function _reset_urls() { |
1685
|
|
|
$this->reg_page_url = ''; |
|
|
|
|
1686
|
|
|
$this->txn_page_url = ''; |
1687
|
|
|
$this->cancel_page_url = ''; |
1688
|
|
|
$this->thank_you_page_url = ''; |
1689
|
|
|
|
1690
|
|
|
} |
1691
|
|
|
|
1692
|
|
|
|
1693
|
|
|
/** |
1694
|
|
|
* Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
1695
|
|
|
* on the object. |
1696
|
|
|
* @return array |
1697
|
|
|
*/ |
1698
|
|
|
public function __sleep() { |
1699
|
|
|
//reset all url properties |
1700
|
|
|
$this->_reset_urls(); |
1701
|
|
|
//return what to save to db |
1702
|
|
|
return array_keys( get_object_vars( $this ) ); |
1703
|
|
|
} |
1704
|
|
|
|
1705
|
|
|
} |
1706
|
|
|
|
1707
|
|
|
|
1708
|
|
|
|
1709
|
|
|
/** |
1710
|
|
|
* Config class for storing info on the Organization |
1711
|
|
|
*/ |
1712
|
|
|
class EE_Organization_Config extends EE_Config_Base { |
1713
|
|
|
|
1714
|
|
|
/** |
1715
|
|
|
* @var string $name |
1716
|
|
|
* eg EE4.1 |
1717
|
|
|
*/ |
1718
|
|
|
public $name; |
1719
|
|
|
|
1720
|
|
|
/** |
1721
|
|
|
* @var string $address_1 |
1722
|
|
|
* eg 123 Onna Road |
1723
|
|
|
*/ |
1724
|
|
|
public $address_1; |
1725
|
|
|
|
1726
|
|
|
/** |
1727
|
|
|
* @var string $address_2 |
1728
|
|
|
* eg PO Box 123 |
1729
|
|
|
*/ |
1730
|
|
|
public $address_2; |
1731
|
|
|
|
1732
|
|
|
/** |
1733
|
|
|
* @var string $city |
1734
|
|
|
* eg Inna City |
1735
|
|
|
*/ |
1736
|
|
|
public $city; |
1737
|
|
|
|
1738
|
|
|
/** |
1739
|
|
|
* @var int $STA_ID |
1740
|
|
|
* eg 4 |
1741
|
|
|
*/ |
1742
|
|
|
public $STA_ID; |
1743
|
|
|
|
1744
|
|
|
/** |
1745
|
|
|
* @var string $CNT_ISO |
1746
|
|
|
* eg US |
1747
|
|
|
*/ |
1748
|
|
|
public $CNT_ISO; |
1749
|
|
|
|
1750
|
|
|
/** |
1751
|
|
|
* @var string $zip |
1752
|
|
|
* eg 12345 or V1A 2B3 |
1753
|
|
|
*/ |
1754
|
|
|
public $zip; |
1755
|
|
|
|
1756
|
|
|
/** |
1757
|
|
|
* @var string $email |
1758
|
|
|
* eg [email protected] |
1759
|
|
|
*/ |
1760
|
|
|
public $email; |
1761
|
|
|
|
1762
|
|
|
|
1763
|
|
|
|
1764
|
|
|
/** |
1765
|
|
|
* @var string $phone |
1766
|
|
|
* eg. 111-111-1111 |
1767
|
|
|
*/ |
1768
|
|
|
public $phone; |
1769
|
|
|
|
1770
|
|
|
|
1771
|
|
|
/** |
1772
|
|
|
* @var string $vat |
1773
|
|
|
* VAT/Tax Number |
1774
|
|
|
*/ |
1775
|
|
|
public $vat; |
1776
|
|
|
|
1777
|
|
|
/** |
1778
|
|
|
* @var string $logo_url |
1779
|
|
|
* eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
1780
|
|
|
*/ |
1781
|
|
|
public $logo_url; |
1782
|
|
|
|
1783
|
|
|
|
1784
|
|
|
/** |
1785
|
|
|
* The below are all various properties for holding links to organization social network profiles |
1786
|
|
|
* @var string |
1787
|
|
|
*/ |
1788
|
|
|
|
1789
|
|
|
/** |
1790
|
|
|
* facebook (facebook.com/profile.name) |
1791
|
|
|
* @var string |
1792
|
|
|
*/ |
1793
|
|
|
public $facebook; |
1794
|
|
|
|
1795
|
|
|
|
1796
|
|
|
/** |
1797
|
|
|
* twitter (twitter.com/twitter_handle) |
1798
|
|
|
* @var string |
1799
|
|
|
*/ |
1800
|
|
|
public $twitter; |
1801
|
|
|
|
1802
|
|
|
|
1803
|
|
|
|
1804
|
|
|
/** |
1805
|
|
|
* linkedin (linkedin.com/in/profile_name) |
1806
|
|
|
* @var string |
1807
|
|
|
*/ |
1808
|
|
|
public $linkedin; |
1809
|
|
|
|
1810
|
|
|
|
1811
|
|
|
|
1812
|
|
|
/** |
1813
|
|
|
* pinterest (www.pinterest.com/profile_name) |
1814
|
|
|
* @var string |
1815
|
|
|
*/ |
1816
|
|
|
public $pinterest; |
1817
|
|
|
|
1818
|
|
|
|
1819
|
|
|
|
1820
|
|
|
/** |
1821
|
|
|
* google+ (google.com/+profileName) |
1822
|
|
|
* @var string |
1823
|
|
|
*/ |
1824
|
|
|
public $google; |
1825
|
|
|
|
1826
|
|
|
|
1827
|
|
|
|
1828
|
|
|
/** |
1829
|
|
|
* instagram (instagram.com/handle) |
1830
|
|
|
* @var string |
1831
|
|
|
*/ |
1832
|
|
|
public $instagram; |
1833
|
|
|
|
1834
|
|
|
|
1835
|
|
|
|
1836
|
|
|
/** |
1837
|
|
|
* class constructor |
1838
|
|
|
* |
1839
|
|
|
* @access public |
1840
|
|
|
* @return \EE_Organization_Config |
|
|
|
|
1841
|
|
|
*/ |
1842
|
|
|
public function __construct() { |
1843
|
|
|
// set default organization settings |
1844
|
|
|
$this->name = get_bloginfo('name'); |
1845
|
|
|
$this->address_1 = '123 Onna Road'; |
1846
|
|
|
$this->address_2 = 'PO Box 123'; |
1847
|
|
|
$this->city = 'Inna City'; |
1848
|
|
|
$this->STA_ID = 4; |
1849
|
|
|
$this->CNT_ISO = 'US'; |
1850
|
|
|
$this->zip = '12345'; |
1851
|
|
|
$this->email = get_bloginfo('admin_email'); |
1852
|
|
|
$this->phone = ''; |
1853
|
|
|
$this->vat = '123456789'; |
1854
|
|
|
$this->logo_url = ''; |
1855
|
|
|
$this->facebook = ''; |
1856
|
|
|
$this->twitter = ''; |
1857
|
|
|
$this->linkedin = ''; |
1858
|
|
|
$this->pinterest = ''; |
1859
|
|
|
$this->google = ''; |
1860
|
|
|
$this->instagram = ''; |
1861
|
|
|
} |
1862
|
|
|
|
1863
|
|
|
} |
1864
|
|
|
|
1865
|
|
|
|
1866
|
|
|
|
1867
|
|
|
|
1868
|
|
|
/** |
1869
|
|
|
* Class for defining what's in the EE_Config relating to currency |
1870
|
|
|
*/ |
1871
|
|
|
class EE_Currency_Config extends EE_Config_Base { |
1872
|
|
|
|
1873
|
|
|
/** |
1874
|
|
|
* @var string $code |
1875
|
|
|
* eg 'US' |
1876
|
|
|
*/ |
1877
|
|
|
public $code; |
1878
|
|
|
|
1879
|
|
|
/** |
1880
|
|
|
* @var string $name |
1881
|
|
|
* eg 'Dollar' |
1882
|
|
|
*/ |
1883
|
|
|
public $name; |
1884
|
|
|
|
1885
|
|
|
/** |
1886
|
|
|
* plural name |
1887
|
|
|
* @var string $plural |
1888
|
|
|
* eg 'Dollars' |
1889
|
|
|
*/ |
1890
|
|
|
public $plural; |
1891
|
|
|
|
1892
|
|
|
/** |
1893
|
|
|
* currency sign |
1894
|
|
|
* @var string $sign |
1895
|
|
|
* eg '$' |
1896
|
|
|
*/ |
1897
|
|
|
public $sign; |
1898
|
|
|
|
1899
|
|
|
/** |
1900
|
|
|
* Whether the currency sign should come before the number or not |
1901
|
|
|
* @var boolean $sign_b4 |
1902
|
|
|
*/ |
1903
|
|
|
public $sign_b4; |
1904
|
|
|
|
1905
|
|
|
/** |
1906
|
|
|
* How many digits should come after the decimal place |
1907
|
|
|
* @var int $dec_plc |
1908
|
|
|
*/ |
1909
|
|
|
public $dec_plc; |
1910
|
|
|
|
1911
|
|
|
/** |
1912
|
|
|
* Symbol to use for decimal mark |
1913
|
|
|
* @var string $dec_mrk |
1914
|
|
|
* eg '.' |
1915
|
|
|
*/ |
1916
|
|
|
public $dec_mrk; |
1917
|
|
|
|
1918
|
|
|
/** |
1919
|
|
|
* Symbol to use for thousands |
1920
|
|
|
* @var string $thsnds |
1921
|
|
|
* eg ',' |
1922
|
|
|
*/ |
1923
|
|
|
public $thsnds; |
1924
|
|
|
|
1925
|
|
|
|
1926
|
|
|
|
1927
|
|
|
/** |
1928
|
|
|
* class constructor |
1929
|
|
|
* |
1930
|
|
|
* @access public |
1931
|
|
|
* @param null $CNT_ISO |
1932
|
|
|
* @return \EE_Currency_Config |
|
|
|
|
1933
|
|
|
*/ |
1934
|
|
|
public function __construct( $CNT_ISO = NULL ) { |
1935
|
|
|
|
1936
|
|
|
// get country code from organization settings or use default |
1937
|
|
|
$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; |
1938
|
|
|
// but override if requested |
1939
|
|
|
$CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : $ORG_CNT; |
1940
|
|
|
EE_Registry::instance()->load_helper( 'Activation' ); |
1941
|
|
|
// 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 |
1942
|
|
|
if ( ! empty( $CNT_ISO ) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists( EE_Registry::instance()->load_model( 'Country' )->table() ) ) { |
|
|
|
|
1943
|
|
|
// retrieve the country settings from the db, just in case they have been customized |
1944
|
|
|
$country = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $CNT_ISO ); |
|
|
|
|
1945
|
|
|
if ( $country instanceof EE_Country ) { |
1946
|
|
|
$this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
|
|
|
1947
|
|
|
$this->name = $country->currency_name_single(); // Dollar |
|
|
|
|
1948
|
|
|
$this->plural = $country->currency_name_plural(); // Dollars |
|
|
|
|
1949
|
|
|
$this->sign = $country->currency_sign(); // currency sign: $ |
|
|
|
|
1950
|
|
|
$this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
1951
|
|
|
$this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
|
|
|
1952
|
|
|
$this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
|
|
|
1953
|
|
|
$this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
|
|
|
1954
|
|
|
} |
1955
|
|
|
} |
1956
|
|
|
// fallback to hardcoded defaults, in case the above failed |
1957
|
|
|
if ( empty( $this->code )) { |
1958
|
|
|
// set default currency settings |
1959
|
|
|
$this->code = 'USD'; // currency code: USD, CAD, EUR |
1960
|
|
|
$this->name = __( 'Dollar', 'event_espresso' ); // Dollar |
1961
|
|
|
$this->plural = __( 'Dollars', 'event_espresso' ); // Dollars |
1962
|
|
|
$this->sign = '$'; // currency sign: $ |
1963
|
|
|
$this->sign_b4 = TRUE; // currency sign before or after: $TRUE or FALSE$ |
1964
|
|
|
$this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
1965
|
|
|
$this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
1966
|
|
|
$this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
1967
|
|
|
} |
1968
|
|
|
} |
1969
|
|
|
} |
1970
|
|
|
|
1971
|
|
|
|
1972
|
|
|
|
1973
|
|
|
|
1974
|
|
|
/** |
1975
|
|
|
* Class for defining what's in the EE_Config relating to registration settings |
1976
|
|
|
*/ |
1977
|
|
|
class EE_Registration_Config extends EE_Config_Base { |
1978
|
|
|
|
1979
|
|
|
/** |
1980
|
|
|
* Default registration status |
1981
|
|
|
* @var string $default_STS_ID |
1982
|
|
|
* eg 'RPP' |
1983
|
|
|
*/ |
1984
|
|
|
public $default_STS_ID; |
1985
|
|
|
|
1986
|
|
|
/** |
1987
|
|
|
* whether or not to show alternate payment options during the reg process if payment status is pending |
1988
|
|
|
* @var boolean $show_pending_payment_options |
1989
|
|
|
*/ |
1990
|
|
|
public $show_pending_payment_options; |
1991
|
|
|
|
1992
|
|
|
/** |
1993
|
|
|
* Whether to skip the registration confirmation page |
1994
|
|
|
* @var boolean $skip_reg_confirmation |
1995
|
|
|
*/ |
1996
|
|
|
public $skip_reg_confirmation; |
1997
|
|
|
|
1998
|
|
|
/** |
1999
|
|
|
* an array of SPCO reg steps where: |
2000
|
|
|
* the keys denotes the reg step order |
2001
|
|
|
* each element consists of an array with the following elements: |
2002
|
|
|
* "file_path" => the file path to the EE_SPCO_Reg_Step class |
2003
|
|
|
* "class_name" => the specific EE_SPCO_Reg_Step child class name |
2004
|
|
|
* "slug" => the URL param used to trigger the reg step |
2005
|
|
|
* @var array $reg_steps |
2006
|
|
|
*/ |
2007
|
|
|
public $reg_steps; |
2008
|
|
|
|
2009
|
|
|
/** |
2010
|
|
|
* Whether registration confirmation should be the last page of SPCO |
2011
|
|
|
* @var boolean $reg_confirmation_last |
2012
|
|
|
*/ |
2013
|
|
|
public $reg_confirmation_last; |
2014
|
|
|
|
2015
|
|
|
/** |
2016
|
|
|
* Whether or not to enable the EE Bot Trap |
2017
|
|
|
* @var boolean $use_bot_trap |
2018
|
|
|
*/ |
2019
|
|
|
public $use_bot_trap; |
2020
|
|
|
|
2021
|
|
|
/** |
2022
|
|
|
* Whether or not to encrypt some data sent by the EE Bot Trap |
2023
|
|
|
* @var boolean $use_encryption |
2024
|
|
|
*/ |
2025
|
|
|
public $use_encryption; |
2026
|
|
|
|
2027
|
|
|
/** |
2028
|
|
|
* Whether or not to use ReCaptcha |
2029
|
|
|
* @var boolean $use_captcha |
2030
|
|
|
*/ |
2031
|
|
|
public $use_captcha; |
2032
|
|
|
|
2033
|
|
|
/** |
2034
|
|
|
* ReCaptcha Theme |
2035
|
|
|
* @var string $recaptcha_theme |
2036
|
|
|
* options: 'dark ', 'light' |
2037
|
|
|
*/ |
2038
|
|
|
public $recaptcha_theme; |
2039
|
|
|
|
2040
|
|
|
/** |
2041
|
|
|
* ReCaptcha Type |
2042
|
|
|
* @var string $recaptcha_type |
2043
|
|
|
* options: 'audio', 'image' |
2044
|
|
|
*/ |
2045
|
|
|
public $recaptcha_type; |
2046
|
|
|
|
2047
|
|
|
/** |
2048
|
|
|
* ReCaptcha language |
2049
|
|
|
* @var string $recaptcha_language |
2050
|
|
|
* eg 'en' |
2051
|
|
|
*/ |
2052
|
|
|
public $recaptcha_language; |
2053
|
|
|
|
2054
|
|
|
/** |
2055
|
|
|
* ReCaptcha public key |
2056
|
|
|
* @var string $recaptcha_publickey |
2057
|
|
|
*/ |
2058
|
|
|
public $recaptcha_publickey; |
2059
|
|
|
|
2060
|
|
|
/** |
2061
|
|
|
* ReCaptcha private key |
2062
|
|
|
* @var string $recaptcha_privatekey |
2063
|
|
|
*/ |
2064
|
|
|
public $recaptcha_privatekey; |
2065
|
|
|
|
2066
|
|
|
/** |
2067
|
|
|
* ReCaptcha width |
2068
|
|
|
* @var int $recaptcha_width |
2069
|
|
|
* @deprecated |
2070
|
|
|
*/ |
2071
|
|
|
public $recaptcha_width; |
2072
|
|
|
|
2073
|
|
|
|
2074
|
|
|
|
2075
|
|
|
|
2076
|
|
|
/** |
2077
|
|
|
* class constructor |
2078
|
|
|
* |
2079
|
|
|
* @access public |
2080
|
|
|
* @return \EE_Registration_Config |
|
|
|
|
2081
|
|
|
*/ |
2082
|
|
|
public function __construct() { |
2083
|
|
|
// set default registration settings |
2084
|
|
|
$this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
2085
|
|
|
$this->show_pending_payment_options = TRUE; |
2086
|
|
|
$this->skip_reg_confirmation = FALSE; |
2087
|
|
|
$this->reg_steps = array(); |
2088
|
|
|
$this->reg_confirmation_last = FALSE; |
2089
|
|
|
$this->use_bot_trap = true; |
2090
|
|
|
$this->use_encryption = true; |
2091
|
|
|
$this->use_captcha = FALSE; |
2092
|
|
|
$this->recaptcha_theme = 'light'; |
2093
|
|
|
$this->recaptcha_type = 'image'; |
2094
|
|
|
$this->recaptcha_language = 'en'; |
2095
|
|
|
$this->recaptcha_publickey = NULL; |
2096
|
|
|
$this->recaptcha_privatekey = NULL; |
2097
|
|
|
$this->recaptcha_width = 500; |
|
|
|
|
2098
|
|
|
} |
2099
|
|
|
|
2100
|
|
|
|
2101
|
|
|
/** |
2102
|
|
|
* This is called by the config loader and hooks are initialized AFTER the config has been populated. |
2103
|
|
|
* @since 4.8.8.rc.019 |
2104
|
|
|
*/ |
2105
|
|
|
public function do_hooks() { |
2106
|
|
|
add_action( 'AHEE__EE_Config___load_core_config__end', array( $this, 'set_default_reg_status_on_EEM_Event' )); |
2107
|
|
|
} |
2108
|
|
|
|
2109
|
|
|
|
2110
|
|
|
/** |
2111
|
|
|
* @return void |
2112
|
|
|
*/ |
2113
|
|
|
public function set_default_reg_status_on_EEM_Event() { |
2114
|
|
|
EEM_Event::set_default_reg_status( $this->default_STS_ID ); |
2115
|
|
|
} |
2116
|
|
|
|
2117
|
|
|
|
2118
|
|
|
|
2119
|
|
|
|
2120
|
|
|
} |
2121
|
|
|
|
2122
|
|
|
|
2123
|
|
|
|
2124
|
|
|
/** |
2125
|
|
|
* Class for defining what's in the EE_Config relating to admin settings |
2126
|
|
|
*/ |
2127
|
|
|
class EE_Admin_Config extends EE_Config_Base { |
2128
|
|
|
|
2129
|
|
|
/** |
2130
|
|
|
* @var boolean $use_personnel_manager |
2131
|
|
|
*/ |
2132
|
|
|
public $use_personnel_manager; |
2133
|
|
|
|
2134
|
|
|
/** |
2135
|
|
|
* @var boolean $use_dashboard_widget |
2136
|
|
|
*/ |
2137
|
|
|
public $use_dashboard_widget; |
2138
|
|
|
|
2139
|
|
|
/** |
2140
|
|
|
* @var int $events_in_dashboard |
2141
|
|
|
*/ |
2142
|
|
|
public $events_in_dashboard; |
2143
|
|
|
|
2144
|
|
|
/** |
2145
|
|
|
* @var boolean $use_event_timezones |
2146
|
|
|
*/ |
2147
|
|
|
public $use_event_timezones; |
2148
|
|
|
|
2149
|
|
|
/** |
2150
|
|
|
* @var boolean $use_full_logging |
2151
|
|
|
*/ |
2152
|
|
|
public $use_full_logging; |
2153
|
|
|
|
2154
|
|
|
/** |
2155
|
|
|
* @var string $log_file_name |
2156
|
|
|
*/ |
2157
|
|
|
public $log_file_name; |
2158
|
|
|
|
2159
|
|
|
/** |
2160
|
|
|
* @var string $debug_file_name |
2161
|
|
|
*/ |
2162
|
|
|
public $debug_file_name; |
2163
|
|
|
|
2164
|
|
|
/** |
2165
|
|
|
* @var boolean $use_remote_logging |
2166
|
|
|
*/ |
2167
|
|
|
public $use_remote_logging; |
2168
|
|
|
|
2169
|
|
|
/** |
2170
|
|
|
* @var string $remote_logging_url |
2171
|
|
|
*/ |
2172
|
|
|
public $remote_logging_url; |
2173
|
|
|
|
2174
|
|
|
/** |
2175
|
|
|
* @var boolean $show_reg_footer |
2176
|
|
|
*/ |
2177
|
|
|
public $show_reg_footer; |
2178
|
|
|
|
2179
|
|
|
/** |
2180
|
|
|
* @var string $affiliate_id |
2181
|
|
|
*/ |
2182
|
|
|
public $affiliate_id; |
2183
|
|
|
|
2184
|
|
|
|
2185
|
|
|
/** |
2186
|
|
|
* help tours on or off (global setting) |
2187
|
|
|
* @var boolean |
2188
|
|
|
*/ |
2189
|
|
|
public $help_tour_activation; |
2190
|
|
|
|
2191
|
|
|
|
2192
|
|
|
|
2193
|
|
|
/** |
2194
|
|
|
* class constructor |
2195
|
|
|
* |
2196
|
|
|
* @access public |
2197
|
|
|
* @return \EE_Admin_Config |
|
|
|
|
2198
|
|
|
*/ |
2199
|
|
|
public function __construct() { |
2200
|
|
|
// set default general admin settings |
2201
|
|
|
$this->use_personnel_manager = TRUE; |
2202
|
|
|
$this->use_dashboard_widget = TRUE; |
2203
|
|
|
$this->events_in_dashboard = 30; |
2204
|
|
|
$this->use_event_timezones = FALSE; |
2205
|
|
|
$this->use_full_logging = FALSE; |
2206
|
|
|
$this->use_remote_logging = FALSE; |
2207
|
|
|
$this->remote_logging_url = NULL; |
2208
|
|
|
$this->show_reg_footer = TRUE; |
2209
|
|
|
$this->affiliate_id = 'default'; |
2210
|
|
|
$this->help_tour_activation = TRUE; |
2211
|
|
|
} |
2212
|
|
|
|
2213
|
|
|
|
2214
|
|
|
|
2215
|
|
|
/** |
2216
|
|
|
* @param bool $reset |
2217
|
|
|
* @return string |
2218
|
|
|
*/ |
2219
|
|
View Code Duplication |
public function log_file_name( $reset = FALSE ) { |
|
|
|
|
2220
|
|
|
if ( empty( $this->log_file_name ) || $reset ) { |
2221
|
|
|
$this->log_file_name = sanitize_key( 'espresso_log_' . md5( uniqid( '', TRUE ))) . '.txt'; |
2222
|
|
|
EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
2223
|
|
|
} |
2224
|
|
|
return $this->log_file_name; |
2225
|
|
|
} |
2226
|
|
|
|
2227
|
|
|
|
2228
|
|
|
|
2229
|
|
|
|
2230
|
|
|
/** |
2231
|
|
|
* @param bool $reset |
2232
|
|
|
* @return string |
2233
|
|
|
*/ |
2234
|
|
View Code Duplication |
public function debug_file_name( $reset = FALSE ) { |
|
|
|
|
2235
|
|
|
if ( empty( $this->debug_file_name ) || $reset ) { |
2236
|
|
|
$this->debug_file_name = sanitize_key( 'espresso_debug_' . md5( uniqid( '', TRUE ))) . '.txt'; |
2237
|
|
|
EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
2238
|
|
|
} |
2239
|
|
|
return $this->debug_file_name; |
2240
|
|
|
} |
2241
|
|
|
|
2242
|
|
|
|
2243
|
|
|
|
2244
|
|
|
|
2245
|
|
|
} |
2246
|
|
|
|
2247
|
|
|
|
2248
|
|
|
|
2249
|
|
|
/** |
2250
|
|
|
* Class for defining what's in the EE_Config relating to template settings |
2251
|
|
|
*/ |
2252
|
|
|
class EE_Template_Config extends EE_Config_Base { |
2253
|
|
|
|
2254
|
|
|
/** |
2255
|
|
|
* @var boolean $enable_default_style |
2256
|
|
|
*/ |
2257
|
|
|
public $enable_default_style; |
2258
|
|
|
|
2259
|
|
|
/** |
2260
|
|
|
* @var string $custom_style_sheet |
2261
|
|
|
*/ |
2262
|
|
|
public $custom_style_sheet; |
2263
|
|
|
|
2264
|
|
|
/** |
2265
|
|
|
* @var boolean $display_address_in_regform |
2266
|
|
|
*/ |
2267
|
|
|
public $display_address_in_regform; |
2268
|
|
|
|
2269
|
|
|
/** |
2270
|
|
|
* @var int $display_description_on_multi_reg_page |
2271
|
|
|
*/ |
2272
|
|
|
public $display_description_on_multi_reg_page; |
2273
|
|
|
|
2274
|
|
|
/** |
2275
|
|
|
* @var boolean $use_custom_templates |
2276
|
|
|
*/ |
2277
|
|
|
public $use_custom_templates; |
2278
|
|
|
|
2279
|
|
|
/** |
2280
|
|
|
* @var string $current_espresso_theme |
2281
|
|
|
*/ |
2282
|
|
|
public $current_espresso_theme; |
2283
|
|
|
|
2284
|
|
|
/** |
2285
|
|
|
* @var EE_Event_Single_Config $EED_Event_Single |
2286
|
|
|
*/ |
2287
|
|
|
public $EED_Event_Single; |
2288
|
|
|
|
2289
|
|
|
/** |
2290
|
|
|
* @var EE_Events_Archive_Config $EED_Events_Archive |
2291
|
|
|
*/ |
2292
|
|
|
public $EED_Events_Archive; |
2293
|
|
|
|
2294
|
|
|
|
2295
|
|
|
|
2296
|
|
|
/** |
2297
|
|
|
* class constructor |
2298
|
|
|
* |
2299
|
|
|
* @access public |
2300
|
|
|
* @return \EE_Template_Config |
|
|
|
|
2301
|
|
|
*/ |
2302
|
|
|
public function __construct() { |
2303
|
|
|
// set default template settings |
2304
|
|
|
$this->enable_default_style = TRUE; |
2305
|
|
|
$this->custom_style_sheet = NULL; |
2306
|
|
|
$this->display_address_in_regform = TRUE; |
2307
|
|
|
$this->display_description_on_multi_reg_page = FALSE; |
|
|
|
|
2308
|
|
|
$this->use_custom_templates = FALSE; |
2309
|
|
|
$this->current_espresso_theme = 'Espresso_Arabica_2014'; |
2310
|
|
|
$this->EED_Event_Single = null; |
2311
|
|
|
$this->EED_Events_Archive = null; |
2312
|
|
|
} |
2313
|
|
|
|
2314
|
|
|
} |
2315
|
|
|
|
2316
|
|
|
|
2317
|
|
|
|
2318
|
|
|
/** |
2319
|
|
|
* Class for defining what's in the EE_Config relating to map settings |
2320
|
|
|
*/ |
2321
|
|
|
class EE_Map_Config extends EE_Config_Base { |
2322
|
|
|
|
2323
|
|
|
/** |
2324
|
|
|
* @var boolean $use_google_maps |
2325
|
|
|
*/ |
2326
|
|
|
public $use_google_maps; |
2327
|
|
|
|
2328
|
|
|
/** |
2329
|
|
|
* @var int $event_details_map_width |
2330
|
|
|
*/ |
2331
|
|
|
public $event_details_map_width; |
2332
|
|
|
|
2333
|
|
|
/** |
2334
|
|
|
* @var int $event_details_map_height |
2335
|
|
|
*/ |
2336
|
|
|
public $event_details_map_height; |
2337
|
|
|
|
2338
|
|
|
/** |
2339
|
|
|
* @var int $event_details_map_zoom |
2340
|
|
|
*/ |
2341
|
|
|
public $event_details_map_zoom; |
2342
|
|
|
|
2343
|
|
|
/** |
2344
|
|
|
* @var boolean $event_details_display_nav |
2345
|
|
|
*/ |
2346
|
|
|
public $event_details_display_nav; |
2347
|
|
|
|
2348
|
|
|
/** |
2349
|
|
|
* @var boolean $event_details_nav_size |
2350
|
|
|
*/ |
2351
|
|
|
public $event_details_nav_size; |
2352
|
|
|
|
2353
|
|
|
/** |
2354
|
|
|
* @var string $event_details_control_type |
2355
|
|
|
*/ |
2356
|
|
|
public $event_details_control_type; |
2357
|
|
|
|
2358
|
|
|
/** |
2359
|
|
|
* @var string $event_details_map_align |
2360
|
|
|
*/ |
2361
|
|
|
public $event_details_map_align; |
2362
|
|
|
|
2363
|
|
|
/** |
2364
|
|
|
* @var int $event_list_map_width |
2365
|
|
|
*/ |
2366
|
|
|
public $event_list_map_width; |
2367
|
|
|
|
2368
|
|
|
/** |
2369
|
|
|
* @var int $event_list_map_height |
2370
|
|
|
*/ |
2371
|
|
|
public $event_list_map_height; |
2372
|
|
|
|
2373
|
|
|
/** |
2374
|
|
|
* @var int $event_list_map_zoom |
2375
|
|
|
*/ |
2376
|
|
|
public $event_list_map_zoom; |
2377
|
|
|
|
2378
|
|
|
/** |
2379
|
|
|
* @var boolean $event_list_display_nav |
2380
|
|
|
*/ |
2381
|
|
|
public $event_list_display_nav; |
2382
|
|
|
|
2383
|
|
|
/** |
2384
|
|
|
* @var boolean $event_list_nav_size |
2385
|
|
|
*/ |
2386
|
|
|
public $event_list_nav_size; |
2387
|
|
|
|
2388
|
|
|
/** |
2389
|
|
|
* @var string $event_list_control_type |
2390
|
|
|
*/ |
2391
|
|
|
public $event_list_control_type; |
2392
|
|
|
|
2393
|
|
|
/** |
2394
|
|
|
* @var string $event_list_map_align |
2395
|
|
|
*/ |
2396
|
|
|
public $event_list_map_align; |
2397
|
|
|
|
2398
|
|
|
|
2399
|
|
|
|
2400
|
|
|
/** |
2401
|
|
|
* class constructor |
2402
|
|
|
* |
2403
|
|
|
* @access public |
2404
|
|
|
* @return \EE_Map_Config |
|
|
|
|
2405
|
|
|
*/ |
2406
|
|
|
public function __construct() { |
2407
|
|
|
// set default map settings |
2408
|
|
|
$this->use_google_maps = TRUE; |
2409
|
|
|
// for event details pages (reg page) |
2410
|
|
|
$this->event_details_map_width = 585; // ee_map_width_single |
2411
|
|
|
$this->event_details_map_height = 362; // ee_map_height_single |
2412
|
|
|
$this->event_details_map_zoom = 14; // ee_map_zoom_single |
2413
|
|
|
$this->event_details_display_nav = TRUE; // ee_map_nav_display_single |
2414
|
|
|
$this->event_details_nav_size = FALSE; // ee_map_nav_size_single |
2415
|
|
|
$this->event_details_control_type = 'default'; // ee_map_type_control_single |
2416
|
|
|
$this->event_details_map_align = 'center'; // ee_map_align_single |
2417
|
|
|
// for event list pages |
2418
|
|
|
$this->event_list_map_width = 300; // ee_map_width |
2419
|
|
|
$this->event_list_map_height = 185; // ee_map_height |
2420
|
|
|
$this->event_list_map_zoom = 12; // ee_map_zoom |
2421
|
|
|
$this->event_list_display_nav = FALSE; // ee_map_nav_display |
2422
|
|
|
$this->event_list_nav_size = TRUE; // ee_map_nav_size |
2423
|
|
|
$this->event_list_control_type = 'dropdown'; // ee_map_type_control |
2424
|
|
|
$this->event_list_map_align = 'center'; // ee_map_align |
2425
|
|
|
} |
2426
|
|
|
|
2427
|
|
|
} |
2428
|
|
|
|
2429
|
|
|
|
2430
|
|
|
|
2431
|
|
|
|
2432
|
|
|
/** |
2433
|
|
|
* stores Events_Archive settings |
2434
|
|
|
*/ |
2435
|
|
|
class EE_Events_Archive_Config extends EE_Config_Base{ |
2436
|
|
|
|
2437
|
|
|
public $display_status_banner; |
2438
|
|
|
public $display_description; |
2439
|
|
|
public $display_ticket_selector; |
2440
|
|
|
public $display_datetimes; |
2441
|
|
|
public $display_venue; |
2442
|
|
|
public $display_expired_events; |
2443
|
|
|
public $use_sortable_display_order; |
2444
|
|
|
public $display_order_tickets; |
2445
|
|
|
public $display_order_datetimes; |
2446
|
|
|
public $display_order_event; |
2447
|
|
|
public $display_order_venue; |
2448
|
|
|
|
2449
|
|
|
|
2450
|
|
|
|
2451
|
|
|
/** |
2452
|
|
|
* class constructor |
2453
|
|
|
*/ |
2454
|
|
|
public function __construct(){ |
2455
|
|
|
$this->display_status_banner = 0; |
2456
|
|
|
$this->display_description = 1; |
2457
|
|
|
$this->display_ticket_selector = 0; |
2458
|
|
|
$this->display_datetimes = 1; |
2459
|
|
|
$this->display_venue = 0; |
2460
|
|
|
$this->display_expired_events = 0; |
2461
|
|
|
$this->use_sortable_display_order = false; |
2462
|
|
|
$this->display_order_tickets = 100; |
2463
|
|
|
$this->display_order_datetimes = 110; |
2464
|
|
|
$this->display_order_event = 120; |
2465
|
|
|
$this->display_order_venue = 130; |
2466
|
|
|
} |
2467
|
|
|
} |
2468
|
|
|
|
2469
|
|
|
|
2470
|
|
|
|
2471
|
|
|
/** |
2472
|
|
|
* Stores Event_Single_Config settings |
2473
|
|
|
*/ |
2474
|
|
|
class EE_Event_Single_Config extends EE_Config_Base{ |
2475
|
|
|
|
2476
|
|
|
public $display_status_banner_single; |
2477
|
|
|
public $display_venue; |
2478
|
|
|
public $use_sortable_display_order; |
2479
|
|
|
public $display_order_tickets; |
2480
|
|
|
public $display_order_datetimes; |
2481
|
|
|
public $display_order_event; |
2482
|
|
|
public $display_order_venue; |
2483
|
|
|
|
2484
|
|
|
/** |
2485
|
|
|
* class constructor |
2486
|
|
|
*/ |
2487
|
|
|
public function __construct() { |
2488
|
|
|
$this->display_status_banner_single = 0; |
2489
|
|
|
$this->display_venue = 1; |
2490
|
|
|
$this->use_sortable_display_order = false; |
2491
|
|
|
$this->display_order_tickets = 100; |
2492
|
|
|
$this->display_order_datetimes = 110; |
2493
|
|
|
$this->display_order_event = 120; |
2494
|
|
|
$this->display_order_venue = 130; |
2495
|
|
|
} |
2496
|
|
|
} |
2497
|
|
|
|
2498
|
|
|
|
2499
|
|
|
|
2500
|
|
|
/** |
2501
|
|
|
* Stores Ticket_Selector_Config settings |
2502
|
|
|
*/ |
2503
|
|
|
class EE_Ticket_Selector_Config extends EE_Config_Base{ |
2504
|
|
|
public $show_ticket_sale_columns; |
2505
|
|
|
public $show_ticket_details; |
2506
|
|
|
public $show_expired_tickets; |
2507
|
|
|
|
2508
|
|
|
/** |
2509
|
|
|
* class constructor |
2510
|
|
|
*/ |
2511
|
|
|
public function __construct() { |
2512
|
|
|
$this->show_ticket_sale_columns = 1; |
2513
|
|
|
$this->show_ticket_details = 1; |
2514
|
|
|
$this->show_expired_tickets = 1; |
2515
|
|
|
} |
2516
|
|
|
} |
2517
|
|
|
|
2518
|
|
|
|
2519
|
|
|
|
2520
|
|
|
|
2521
|
|
|
|
2522
|
|
|
|
2523
|
|
|
/** |
2524
|
|
|
* Stores any EE Environment values that are referenced through the code. |
2525
|
|
|
* |
2526
|
|
|
* @since 4.4.0 |
2527
|
|
|
* @package Event Espresso |
2528
|
|
|
* @subpackage config |
2529
|
|
|
*/ |
2530
|
|
|
class EE_Environment_Config extends EE_Config_Base { |
2531
|
|
|
|
2532
|
|
|
/** |
2533
|
|
|
* Hold any php environment variables that we want to track. |
2534
|
|
|
* |
2535
|
|
|
* @var stdClass; |
2536
|
|
|
*/ |
2537
|
|
|
public $php; |
2538
|
|
|
|
2539
|
|
|
|
2540
|
|
|
|
2541
|
|
|
/** |
2542
|
|
|
* constructor |
2543
|
|
|
*/ |
2544
|
|
|
public function __construct() { |
2545
|
|
|
$this->php = new stdClass(); |
2546
|
|
|
$this->_set_php_values(); |
2547
|
|
|
} |
2548
|
|
|
|
2549
|
|
|
|
2550
|
|
|
/** |
2551
|
|
|
* This sets the php environment variables. |
2552
|
|
|
* |
2553
|
|
|
* @since 4.4.0 |
2554
|
|
|
* @return void |
2555
|
|
|
*/ |
2556
|
|
|
protected function _set_php_values() { |
2557
|
|
|
$this->php->max_input_vars = ini_get( 'max_input_vars' ); |
2558
|
|
|
$this->php->version = phpversion(); |
2559
|
|
|
} |
2560
|
|
|
|
2561
|
|
|
|
2562
|
|
|
|
2563
|
|
|
/** |
2564
|
|
|
* helper method for determining whether input_count is |
2565
|
|
|
* reaching the potential maximum the server can handle |
2566
|
|
|
* according to max_input_vars |
2567
|
|
|
* |
2568
|
|
|
* @param int $input_count the count of input vars. |
2569
|
|
|
* |
2570
|
|
|
* @return array { |
2571
|
|
|
* An array that represents whether available space and if no available space the error message. |
2572
|
|
|
* @type bool $has_space whether more inputs can be added. |
2573
|
|
|
* @type string $msg Any message to be displayed. |
2574
|
|
|
* } |
2575
|
|
|
*/ |
2576
|
|
|
public function max_input_vars_limit_check( $input_count = 0 ) { |
2577
|
|
|
if ( ( $input_count >= $this->php->max_input_vars ) && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >=9 ) ) { |
2578
|
|
|
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'); |
2579
|
|
|
} else { |
2580
|
|
|
return ''; |
|
|
|
|
2581
|
|
|
} |
2582
|
|
|
} |
2583
|
|
|
|
2584
|
|
|
|
2585
|
|
|
|
2586
|
|
|
|
2587
|
|
|
/** |
2588
|
|
|
* The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
2589
|
|
|
* |
2590
|
|
|
* @since 4.4.1 |
2591
|
|
|
* |
2592
|
|
|
* @return void |
2593
|
|
|
*/ |
2594
|
|
|
public function recheck_values() { |
2595
|
|
|
$this->_set_php_values(); |
2596
|
|
|
} |
2597
|
|
|
|
2598
|
|
|
|
2599
|
|
|
|
2600
|
|
|
} |
2601
|
|
|
|
2602
|
|
|
|
2603
|
|
|
|
2604
|
|
|
|
2605
|
|
|
|
2606
|
|
|
|
2607
|
|
|
|
2608
|
|
|
|
2609
|
|
|
/** |
2610
|
|
|
* stores payment gateway info |
2611
|
|
|
* @deprecated |
2612
|
|
|
*/ |
2613
|
|
|
class EE_Gateway_Config extends EE_Config_Base{ |
2614
|
|
|
|
2615
|
|
|
/** |
2616
|
|
|
* Array with keys that are payment gateways slugs, and values are arrays |
2617
|
|
|
* with any config info the gateway wants to store |
2618
|
|
|
* @var array |
2619
|
|
|
*/ |
2620
|
|
|
public $payment_settings; |
2621
|
|
|
|
2622
|
|
|
/** |
2623
|
|
|
* Where keys are gateway slugs, and values are booleans indicating whether or not |
2624
|
|
|
* the gateway is stored in the uploads directory |
2625
|
|
|
* @var array |
2626
|
|
|
*/ |
2627
|
|
|
public $active_gateways; |
2628
|
|
|
|
2629
|
|
|
|
2630
|
|
|
|
2631
|
|
|
/** |
2632
|
|
|
* class constructor |
2633
|
|
|
* @deprecated |
2634
|
|
|
*/ |
2635
|
|
|
public function __construct(){ |
2636
|
|
|
$this->payment_settings = array(); |
2637
|
|
|
$this->active_gateways = array( 'Invoice' => FALSE ); |
2638
|
|
|
} |
2639
|
|
|
} |
2640
|
|
|
|
2641
|
|
|
// End of file EE_Config.core.php |
2642
|
|
|
// Location: /core/EE_Config.core.php |
2643
|
|
|
|
Adding a
@return
annotation 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.