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