Completed
Branch FET-10416-autoload-b4-bootstra... (9a39f6)
by
unknown
119:38 queued 108:09
created
strategies/validation/EE_Email_Validation_Strategy.strategy.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -18,72 +18,72 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * @param string               $validation_error_message
23
-     */
24
-    public function __construct($validation_error_message = '')
25
-    {
26
-        if (! $validation_error_message) {
27
-            $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso');
28
-        }
29
-        parent::__construct($validation_error_message);
30
-    }
21
+	/**
22
+	 * @param string               $validation_error_message
23
+	 */
24
+	public function __construct($validation_error_message = '')
25
+	{
26
+		if (! $validation_error_message) {
27
+			$validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso');
28
+		}
29
+		parent::__construct($validation_error_message);
30
+	}
31 31
 
32 32
 
33 33
 
34
-    /**
35
-     * just checks the field isn't blank
36
-     *
37
-     * @param $normalized_value
38
-     * @return bool
39
-     * @throws InvalidArgumentException
40
-     * @throws InvalidInterfaceException
41
-     * @throws InvalidDataTypeException
42
-     * @throws EE_Validation_Error
43
-     */
44
-    public function validate($normalized_value)
45
-    {
46
-        if ($normalized_value && ! $this->_validate_email($normalized_value)) {
47
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'required');
48
-        }
49
-        return true;
50
-    }
34
+	/**
35
+	 * just checks the field isn't blank
36
+	 *
37
+	 * @param $normalized_value
38
+	 * @return bool
39
+	 * @throws InvalidArgumentException
40
+	 * @throws InvalidInterfaceException
41
+	 * @throws InvalidDataTypeException
42
+	 * @throws EE_Validation_Error
43
+	 */
44
+	public function validate($normalized_value)
45
+	{
46
+		if ($normalized_value && ! $this->_validate_email($normalized_value)) {
47
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'required');
48
+		}
49
+		return true;
50
+	}
51 51
 
52 52
 
53 53
 
54
-    /**
55
-     * @return array
56
-     */
57
-    public function get_jquery_validation_rule_array()
58
-    {
59
-        return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message()));
60
-    }
54
+	/**
55
+	 * @return array
56
+	 */
57
+	public function get_jquery_validation_rule_array()
58
+	{
59
+		return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message()));
60
+	}
61 61
 
62 62
 
63 63
 
64
-    /**
65
-     * Validate an email address.
66
-     * Provide email address (raw input)
67
-     *
68
-     * @param $email
69
-     * @return bool of whether the email is valid or not
70
-     * @throws InvalidArgumentException
71
-     * @throws InvalidInterfaceException
72
-     * @throws InvalidDataTypeException
73
-     * @throws EE_Validation_Error
74
-     */
75
-    private function _validate_email($email)
76
-    {
77
-        try {
78
-            EmailAddressFactory::create($email);
79
-        } catch (EmailValidationException $e) {
80
-            throw new EE_Validation_Error(
81
-                $e->getMessage(),
82
-                'invalid_email',
83
-                $this->_input,
84
-                $e
85
-            );
86
-        }
87
-        return true;
88
-    }
64
+	/**
65
+	 * Validate an email address.
66
+	 * Provide email address (raw input)
67
+	 *
68
+	 * @param $email
69
+	 * @return bool of whether the email is valid or not
70
+	 * @throws InvalidArgumentException
71
+	 * @throws InvalidInterfaceException
72
+	 * @throws InvalidDataTypeException
73
+	 * @throws EE_Validation_Error
74
+	 */
75
+	private function _validate_email($email)
76
+	{
77
+		try {
78
+			EmailAddressFactory::create($email);
79
+		} catch (EmailValidationException $e) {
80
+			throw new EE_Validation_Error(
81
+				$e->getMessage(),
82
+				'invalid_email',
83
+				$this->_input,
84
+				$e
85
+			);
86
+		}
87
+		return true;
88
+	}
89 89
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
      */
24 24
     public function __construct($validation_error_message = '')
25 25
     {
26
-        if (! $validation_error_message) {
26
+        if ( ! $validation_error_message) {
27 27
             $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso');
28 28
         }
29 29
         parent::__construct($validation_error_message);
Please login to merge, or discard this patch.
core/EE_Registry.core.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -272,6 +272,7 @@
 block discarded – undo
272 272
 
273 273
     /**
274 274
      * @param mixed string | EED_Module $module
275
+     * @param string $module
275 276
      * @throws EE_Error
276 277
      * @throws ReflectionException
277 278
      */
Please login to merge, or discard this patch.
Indentation   +1538 added lines, -1538 removed lines patch added patch discarded remove patch
@@ -22,1544 +22,1544 @@
 block discarded – undo
22 22
 class EE_Registry implements ResettableInterface
23 23
 {
24 24
 
25
-    /**
26
-     * @var EE_Registry $_instance
27
-     */
28
-    private static $_instance;
29
-
30
-    /**
31
-     * @var EE_Dependency_Map $_dependency_map
32
-     */
33
-    protected $_dependency_map;
34
-
35
-    /**
36
-     * @var array $_class_abbreviations
37
-     */
38
-    protected $_class_abbreviations = array();
39
-
40
-    /**
41
-     * @var CommandBusInterface $BUS
42
-     */
43
-    public $BUS;
44
-
45
-    /**
46
-     * @var EE_Cart $CART
47
-     */
48
-    public $CART;
49
-
50
-    /**
51
-     * @var EE_Config $CFG
52
-     */
53
-    public $CFG;
54
-
55
-    /**
56
-     * @var EE_Network_Config $NET_CFG
57
-     */
58
-    public $NET_CFG;
59
-
60
-    /**
61
-     * StdClass object for storing library classes in
62
-     *
63
-     * @var StdClass $LIB
64
-     */
65
-    public $LIB;
66
-
67
-    /**
68
-     * @var EE_Request_Handler $REQ
69
-     */
70
-    public $REQ;
71
-
72
-    /**
73
-     * @var EE_Session $SSN
74
-     */
75
-    public $SSN;
76
-
77
-    /**
78
-     * @since 4.5.0
79
-     * @var EE_Capabilities $CAP
80
-     */
81
-    public $CAP;
82
-
83
-    /**
84
-     * @since 4.9.0
85
-     * @var EE_Message_Resource_Manager $MRM
86
-     */
87
-    public $MRM;
88
-
89
-
90
-    /**
91
-     * @var Registry $AssetsRegistry
92
-     */
93
-    public $AssetsRegistry;
94
-
95
-    /**
96
-     * StdClass object for holding addons which have registered themselves to work with EE core
97
-     *
98
-     * @var EE_Addon[] $addons
99
-     */
100
-    public $addons;
101
-
102
-    /**
103
-     * keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
104
-     *
105
-     * @var EEM_Base[] $models
106
-     */
107
-    public $models = array();
108
-
109
-    /**
110
-     * @var EED_Module[] $modules
111
-     */
112
-    public $modules;
113
-
114
-    /**
115
-     * @var EES_Shortcode[] $shortcodes
116
-     */
117
-    public $shortcodes;
118
-
119
-    /**
120
-     * @var WP_Widget[] $widgets
121
-     */
122
-    public $widgets;
123
-
124
-    /**
125
-     * this is an array of all implemented model names (i.e. not the parent abstract models, or models
126
-     * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
127
-     * Keys are model "short names" (eg "Event") as used in model relations, and values are
128
-     * classnames (eg "EEM_Event")
129
-     *
130
-     * @var array $non_abstract_db_models
131
-     */
132
-    public $non_abstract_db_models = array();
133
-
134
-
135
-    /**
136
-     * internationalization for JS strings
137
-     *    usage:   EE_Registry::i18n_js_strings['string_key'] = esc_html__( 'string to translate.', 'event_espresso' );
138
-     *    in js file:  var translatedString = eei18n.string_key;
139
-     *
140
-     * @var array $i18n_js_strings
141
-     */
142
-    public static $i18n_js_strings = array();
143
-
144
-
145
-    /**
146
-     * $main_file - path to espresso.php
147
-     *
148
-     * @var array $main_file
149
-     */
150
-    public $main_file;
151
-
152
-    /**
153
-     * array of ReflectionClass objects where the key is the class name
154
-     *
155
-     * @var ReflectionClass[] $_reflectors
156
-     */
157
-    public $_reflectors;
158
-
159
-    /**
160
-     * boolean flag to indicate whether or not to load/save dependencies from/to the cache
161
-     *
162
-     * @var boolean $_cache_on
163
-     */
164
-    protected $_cache_on = true;
165
-
166
-
167
-
168
-    /**
169
-     * @singleton method used to instantiate class object
170
-     * @param  EE_Dependency_Map $dependency_map
171
-     * @return EE_Registry instance
172
-     * @throws InvalidArgumentException
173
-     * @throws InvalidInterfaceException
174
-     * @throws InvalidDataTypeException
175
-     */
176
-    public static function instance(EE_Dependency_Map $dependency_map = null)
177
-    {
178
-        // check if class object is instantiated
179
-        if (! self::$_instance instanceof EE_Registry) {
180
-            self::$_instance = new self($dependency_map);
181
-        }
182
-        return self::$_instance;
183
-    }
184
-
185
-
186
-
187
-    /**
188
-     * protected constructor to prevent direct creation
189
-     *
190
-     * @Constructor
191
-     * @param  EE_Dependency_Map $dependency_map
192
-     * @throws InvalidDataTypeException
193
-     * @throws InvalidInterfaceException
194
-     * @throws InvalidArgumentException
195
-     */
196
-    protected function __construct(EE_Dependency_Map $dependency_map)
197
-    {
198
-        $this->_dependency_map = $dependency_map;
199
-        $this->LIB = new stdClass();
200
-        $this->addons = new stdClass();
201
-        $this->modules = new stdClass();
202
-        $this->shortcodes = new stdClass();
203
-        $this->widgets = new stdClass();
204
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
205
-    }
206
-
207
-
208
-
209
-    /**
210
-     * initialize
211
-     *
212
-     * @throws EE_Error
213
-     * @throws ReflectionException
214
-     */
215
-    public function initialize()
216
-    {
217
-        $this->_class_abbreviations = apply_filters(
218
-            'FHEE__EE_Registry____construct___class_abbreviations',
219
-            array(
220
-                'EE_Config'                                       => 'CFG',
221
-                'EE_Session'                                      => 'SSN',
222
-                'EE_Capabilities'                                 => 'CAP',
223
-                'EE_Cart'                                         => 'CART',
224
-                'EE_Network_Config'                               => 'NET_CFG',
225
-                'EE_Request_Handler'                              => 'REQ',
226
-                'EE_Message_Resource_Manager'                     => 'MRM',
227
-                'EventEspresso\core\services\commands\CommandBus' => 'BUS',
228
-                'EventEspresso\core\services\assets\Registry'     => 'AssetsRegistry',
229
-            )
230
-        );
231
-        $this->load_core('Base', array(), true);
232
-        // add our request and response objects to the cache
233
-        $request_loader = $this->_dependency_map->class_loader('EE_Request');
234
-        $this->_set_cached_class(
235
-            $request_loader(),
236
-            'EE_Request'
237
-        );
238
-        $response_loader = $this->_dependency_map->class_loader('EE_Response');
239
-        $this->_set_cached_class(
240
-            $response_loader(),
241
-            'EE_Response'
242
-        );
243
-        add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
244
-    }
245
-
246
-
247
-
248
-    /**
249
-     * @return void
250
-     */
251
-    public function init()
252
-    {
253
-        // Get current page protocol
254
-        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
255
-        // Output admin-ajax.php URL with same protocol as current page
256
-        self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
257
-        self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
258
-    }
259
-
260
-
261
-
262
-    /**
263
-     * localize_i18n_js_strings
264
-     *
265
-     * @return string
266
-     */
267
-    public static function localize_i18n_js_strings()
268
-    {
269
-        $i18n_js_strings = (array)self::$i18n_js_strings;
270
-        foreach ($i18n_js_strings as $key => $value) {
271
-            if (is_scalar($value)) {
272
-                $i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
273
-            }
274
-        }
275
-        return '/* <![CDATA[ */ var eei18n = ' . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
276
-    }
277
-
278
-
279
-
280
-    /**
281
-     * @param mixed string | EED_Module $module
282
-     * @throws EE_Error
283
-     * @throws ReflectionException
284
-     */
285
-    public function add_module($module)
286
-    {
287
-        if ($module instanceof EED_Module) {
288
-            $module_class = get_class($module);
289
-            $this->modules->{$module_class} = $module;
290
-        } else {
291
-            if ( ! class_exists('EE_Module_Request_Router', false)) {
292
-                $this->load_core('Module_Request_Router');
293
-            }
294
-            EE_Module_Request_Router::module_factory($module);
295
-        }
296
-    }
297
-
298
-
299
-
300
-    /**
301
-     * @param string $module_name
302
-     * @return mixed EED_Module | NULL
303
-     */
304
-    public function get_module($module_name = '')
305
-    {
306
-        return isset($this->modules->{$module_name})
307
-            ? $this->modules->{$module_name}
308
-            : null;
309
-    }
310
-
311
-
312
-
313
-    /**
314
-     * loads core classes - must be singletons
315
-     *
316
-     * @param string $class_name - simple class name ie: session
317
-     * @param mixed  $arguments
318
-     * @param bool   $load_only
319
-     * @return mixed
320
-     * @throws EE_Error
321
-     * @throws ReflectionException
322
-     */
323
-    public function load_core($class_name, $arguments = array(), $load_only = false)
324
-    {
325
-        $core_paths = apply_filters(
326
-            'FHEE__EE_Registry__load_core__core_paths',
327
-            array(
328
-                EE_CORE,
329
-                EE_ADMIN,
330
-                EE_CPTS,
331
-                EE_CORE . 'data_migration_scripts' . DS,
332
-                EE_CORE . 'capabilities' . DS,
333
-                EE_CORE . 'request_stack' . DS,
334
-                EE_CORE . 'middleware' . DS,
335
-            )
336
-        );
337
-        // retrieve instantiated class
338
-        return $this->_load(
339
-            $core_paths,
340
-            'EE_',
341
-            $class_name,
342
-            'core',
343
-            $arguments,
344
-            false,
345
-            true,
346
-            $load_only
347
-        );
348
-    }
349
-
350
-
351
-
352
-    /**
353
-     * loads service classes
354
-     *
355
-     * @param string $class_name - simple class name ie: session
356
-     * @param mixed  $arguments
357
-     * @param bool   $load_only
358
-     * @return mixed
359
-     * @throws EE_Error
360
-     * @throws ReflectionException
361
-     */
362
-    public function load_service($class_name, $arguments = array(), $load_only = false)
363
-    {
364
-        $service_paths = apply_filters(
365
-            'FHEE__EE_Registry__load_service__service_paths',
366
-            array(
367
-                EE_CORE . 'services' . DS,
368
-            )
369
-        );
370
-        // retrieve instantiated class
371
-        return $this->_load(
372
-            $service_paths,
373
-            'EE_',
374
-            $class_name,
375
-            'class',
376
-            $arguments,
377
-            false,
378
-            true,
379
-            $load_only
380
-        );
381
-    }
382
-
383
-
384
-
385
-    /**
386
-     * loads data_migration_scripts
387
-     *
388
-     * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
389
-     * @param mixed  $arguments
390
-     * @return EE_Data_Migration_Script_Base|mixed
391
-     * @throws EE_Error
392
-     * @throws ReflectionException
393
-     */
394
-    public function load_dms($class_name, $arguments = array())
395
-    {
396
-        // retrieve instantiated class
397
-        return $this->_load(
398
-            EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(),
399
-            'EE_DMS_',
400
-            $class_name,
401
-            'dms',
402
-            $arguments,
403
-            false,
404
-            false
405
-        );
406
-    }
407
-
408
-
409
-
410
-    /**
411
-     * loads object creating classes - must be singletons
412
-     *
413
-     * @param string $class_name - simple class name ie: attendee
414
-     * @param mixed  $arguments  - an array of arguments to pass to the class
415
-     * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to
416
-     *                           instantiate
417
-     * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then
418
-     *                           set this to FALSE (ie. when instantiating model objects from client in a loop)
419
-     * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate
420
-     *                           (default)
421
-     * @return EE_Base_Class | bool
422
-     * @throws EE_Error
423
-     * @throws ReflectionException
424
-     */
425
-    public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
426
-    {
427
-        $paths = apply_filters(
428
-            'FHEE__EE_Registry__load_class__paths', array(
429
-            EE_CORE,
430
-            EE_CLASSES,
431
-            EE_BUSINESS,
432
-        )
433
-        );
434
-        // retrieve instantiated class
435
-        return $this->_load(
436
-            $paths,
437
-            'EE_',
438
-            $class_name,
439
-            'class',
440
-            $arguments,
441
-            $from_db,
442
-            $cache,
443
-            $load_only
444
-        );
445
-    }
446
-
447
-
448
-
449
-    /**
450
-     * loads helper classes - must be singletons
451
-     *
452
-     * @param string $class_name - simple class name ie: price
453
-     * @param mixed  $arguments
454
-     * @param bool   $load_only
455
-     * @return EEH_Base | bool
456
-     * @throws EE_Error
457
-     * @throws ReflectionException
458
-     */
459
-    public function load_helper($class_name, $arguments = array(), $load_only = true)
460
-    {
461
-        // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
462
-        $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
463
-        // retrieve instantiated class
464
-        return $this->_load(
465
-            $helper_paths,
466
-            'EEH_',
467
-            $class_name,
468
-            'helper',
469
-            $arguments,
470
-            false,
471
-            true,
472
-            $load_only
473
-        );
474
-    }
475
-
476
-
477
-
478
-    /**
479
-     * loads core classes - must be singletons
480
-     *
481
-     * @param string $class_name - simple class name ie: session
482
-     * @param mixed  $arguments
483
-     * @param bool   $load_only
484
-     * @param bool   $cache      whether to cache the object or not.
485
-     * @return mixed
486
-     * @throws EE_Error
487
-     * @throws ReflectionException
488
-     */
489
-    public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
490
-    {
491
-        $paths = array(
492
-            EE_LIBRARIES,
493
-            EE_LIBRARIES . 'messages' . DS,
494
-            EE_LIBRARIES . 'shortcodes' . DS,
495
-            EE_LIBRARIES . 'qtips' . DS,
496
-            EE_LIBRARIES . 'payment_methods' . DS,
497
-            EE_LIBRARIES . 'messages' . DS . 'defaults' . DS,
498
-        );
499
-        // retrieve instantiated class
500
-        return $this->_load(
501
-            $paths,
502
-            'EE_',
503
-            $class_name,
504
-            'lib',
505
-            $arguments,
506
-            false,
507
-            $cache,
508
-            $load_only
509
-        );
510
-    }
511
-
512
-
513
-
514
-    /**
515
-     * loads model classes - must be singletons
516
-     *
517
-     * @param string $class_name - simple class name ie: price
518
-     * @param mixed  $arguments
519
-     * @param bool   $load_only
520
-     * @return EEM_Base | bool
521
-     * @throws EE_Error
522
-     * @throws ReflectionException
523
-     */
524
-    public function load_model($class_name, $arguments = array(), $load_only = false)
525
-    {
526
-        $paths = apply_filters(
527
-            'FHEE__EE_Registry__load_model__paths', array(
528
-            EE_MODELS,
529
-            EE_CORE,
530
-        )
531
-        );
532
-        // retrieve instantiated class
533
-        return $this->_load(
534
-            $paths,
535
-            'EEM_',
536
-            $class_name,
537
-            'model',
538
-            $arguments,
539
-            false,
540
-            true,
541
-            $load_only
542
-        );
543
-    }
544
-
545
-
546
-
547
-    /**
548
-     * loads model classes - must be singletons
549
-     *
550
-     * @param string $class_name - simple class name ie: price
551
-     * @param mixed  $arguments
552
-     * @param bool   $load_only
553
-     * @return mixed | bool
554
-     * @throws EE_Error
555
-     * @throws ReflectionException
556
-     */
557
-    public function load_model_class($class_name, $arguments = array(), $load_only = true)
558
-    {
559
-        $paths = array(
560
-            EE_MODELS . 'fields' . DS,
561
-            EE_MODELS . 'helpers' . DS,
562
-            EE_MODELS . 'relations' . DS,
563
-            EE_MODELS . 'strategies' . DS,
564
-        );
565
-        // retrieve instantiated class
566
-        return $this->_load(
567
-            $paths,
568
-            'EE_',
569
-            $class_name,
570
-            '',
571
-            $arguments,
572
-            false,
573
-            true,
574
-            $load_only
575
-        );
576
-    }
577
-
578
-
579
-
580
-    /**
581
-     * Determines if $model_name is the name of an actual EE model.
582
-     *
583
-     * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
584
-     * @return boolean
585
-     */
586
-    public function is_model_name($model_name)
587
-    {
588
-        return isset($this->models[$model_name]);
589
-    }
590
-
591
-
592
-
593
-    /**
594
-     * generic class loader
595
-     *
596
-     * @param string $path_to_file - directory path to file location, not including filename
597
-     * @param string $file_name    - file name  ie:  my_file.php, including extension
598
-     * @param string $type         - file type - core? class? helper? model?
599
-     * @param mixed  $arguments
600
-     * @param bool   $load_only
601
-     * @return mixed
602
-     * @throws EE_Error
603
-     * @throws ReflectionException
604
-     */
605
-    public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
606
-    {
607
-        // retrieve instantiated class
608
-        return $this->_load(
609
-            $path_to_file,
610
-            '',
611
-            $file_name,
612
-            $type,
613
-            $arguments,
614
-            false,
615
-            true,
616
-            $load_only
617
-        );
618
-    }
619
-
620
-
621
-
622
-    /**
623
-     * @param string $path_to_file - directory path to file location, not including filename
624
-     * @param string $class_name   - full class name  ie:  My_Class
625
-     * @param string $type         - file type - core? class? helper? model?
626
-     * @param mixed  $arguments
627
-     * @param bool   $load_only
628
-     * @return bool|EE_Addon|object
629
-     * @throws EE_Error
630
-     * @throws ReflectionException
631
-     */
632
-    public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
633
-    {
634
-        // retrieve instantiated class
635
-        return $this->_load(
636
-            $path_to_file,
637
-            'addon',
638
-            $class_name,
639
-            $type,
640
-            $arguments,
641
-            false,
642
-            true,
643
-            $load_only
644
-        );
645
-    }
646
-
647
-
648
-
649
-    /**
650
-     * instantiates, caches, and automatically resolves dependencies
651
-     * for classes that use a Fully Qualified Class Name.
652
-     * if the class is not capable of being loaded using PSR-4 autoloading,
653
-     * then you need to use one of the existing load_*() methods
654
-     * which can resolve the classname and filepath from the passed arguments
655
-     *
656
-     * @param bool|string $class_name   Fully Qualified Class Name
657
-     * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
658
-     * @param bool        $cache        whether to cache the instantiated object for reuse
659
-     * @param bool        $from_db      some classes are instantiated from the db
660
-     *                                  and thus call a different method to instantiate
661
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
662
-     * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
663
-     * @return bool|null|mixed          null = failure to load or instantiate class object.
664
-     *                                  object = class loaded and instantiated successfully.
665
-     *                                  bool = fail or success when $load_only is true
666
-     * @throws EE_Error
667
-     * @throws ReflectionException
668
-     */
669
-    public function create(
670
-        $class_name = false,
671
-        $arguments = array(),
672
-        $cache = false,
673
-        $from_db = false,
674
-        $load_only = false,
675
-        $addon = false
676
-    ) {
677
-        $class_name = ltrim($class_name, '\\');
678
-        $class_name = $this->_dependency_map->get_alias($class_name);
679
-        $class_exists = $this->loadOrVerifyClassExists($class_name, $arguments);
680
-        // if a non-FQCN was passed, then verifyClassExists() might return an object
681
-        // or it could return null if the class just could not be found anywhere
682
-        if ($class_exists instanceof $class_name || $class_exists === null){
683
-            // either way, return the results
684
-            return $class_exists;
685
-        }
686
-        $class_name = $class_exists;
687
-        // if we're only loading the class and it already exists, then let's just return true immediately
688
-        if ($load_only) {
689
-            return true;
690
-        }
691
-        $addon = $addon
692
-            ? 'addon'
693
-            : '';
694
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
695
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
696
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
697
-        if ($this->_cache_on && $cache && ! $load_only) {
698
-            // return object if it's already cached
699
-            $cached_class = $this->_get_cached_class($class_name, $addon);
700
-            if ($cached_class !== null) {
701
-                return $cached_class;
702
-            }
703
-        }
704
-        // obtain the loader method from the dependency map
705
-        $loader = $this->_dependency_map->class_loader($class_name);
706
-        // instantiate the requested object
707
-        if ($loader instanceof Closure) {
708
-            $class_obj = $loader($arguments);
709
-        } else if ($loader && method_exists($this, $loader)) {
710
-            $class_obj = $this->{$loader}($class_name, $arguments);
711
-        } else {
712
-            $class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
713
-        }
714
-        if (($this->_cache_on && $cache) || $this->get_class_abbreviation($class_name, '')) {
715
-            // save it for later... kinda like gum  { : $
716
-            $this->_set_cached_class($class_obj, $class_name, $addon, $from_db);
717
-        }
718
-        $this->_cache_on = true;
719
-        return $class_obj;
720
-    }
721
-
722
-
723
-
724
-    /**
725
-     * Recursively checks that a class exists and potentially attempts to load classes with non-FQCNs
726
-     *
727
-     * @param string $class_name
728
-     * @param array  $arguments
729
-     * @param int    $attempt
730
-     * @return mixed
731
-     */
732
-    private function loadOrVerifyClassExists($class_name, array $arguments, $attempt = 1) {
733
-        if (is_object($class_name) || class_exists($class_name)) {
734
-            return $class_name;
735
-        }
736
-        switch ($attempt) {
737
-            case 1:
738
-                // if it's a FQCN then maybe the class is registered with a preceding \
739
-                $class_name = strpos($class_name, '\\') !== false
740
-                    ? '\\' . ltrim($class_name, '\\')
741
-                    : $class_name;
742
-                break;
743
-            case 2:
744
-                //
745
-                $loader = $this->_dependency_map->class_loader($class_name);
746
-                if ($loader && method_exists($this, $loader)) {
747
-                    return $this->{$loader}($class_name, $arguments);
748
-                }
749
-                break;
750
-            case 3:
751
-            default;
752
-                return null;
753
-        }
754
-        $attempt++;
755
-        return $this->loadOrVerifyClassExists($class_name, $arguments, $attempt);
756
-    }
757
-
758
-
759
-
760
-    /**
761
-     * instantiates, caches, and injects dependencies for classes
762
-     *
763
-     * @param array       $file_paths   an array of paths to folders to look in
764
-     * @param string      $class_prefix EE  or EEM or... ???
765
-     * @param bool|string $class_name   $class name
766
-     * @param string      $type         file type - core? class? helper? model?
767
-     * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
768
-     * @param bool        $from_db      some classes are instantiated from the db
769
-     *                                  and thus call a different method to instantiate
770
-     * @param bool        $cache        whether to cache the instantiated object for reuse
771
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
772
-     * @return bool|null|object null = failure to load or instantiate class object.
773
-     *                                  object = class loaded and instantiated successfully.
774
-     *                                  bool = fail or success when $load_only is true
775
-     * @throws EE_Error
776
-     * @throws ReflectionException
777
-     */
778
-    protected function _load(
779
-        $file_paths = array(),
780
-        $class_prefix = 'EE_',
781
-        $class_name = false,
782
-        $type = 'class',
783
-        $arguments = array(),
784
-        $from_db = false,
785
-        $cache = true,
786
-        $load_only = false
787
-    ) {
788
-        $class_name = ltrim($class_name, '\\');
789
-        // strip php file extension
790
-        $class_name = str_replace('.php', '', trim($class_name));
791
-        // does the class have a prefix ?
792
-        if (! empty($class_prefix) && $class_prefix !== 'addon') {
793
-            // make sure $class_prefix is uppercase
794
-            $class_prefix = strtoupper(trim($class_prefix));
795
-            // add class prefix ONCE!!!
796
-            $class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
797
-        }
798
-        $class_name = $this->_dependency_map->get_alias($class_name);
799
-        $class_exists = class_exists($class_name, false);
800
-        // if we're only loading the class and it already exists, then let's just return true immediately
801
-        if ($load_only && $class_exists) {
802
-            return true;
803
-        }
804
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
805
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
806
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
807
-        if ($this->_cache_on && $cache && ! $load_only) {
808
-            // return object if it's already cached
809
-            $cached_class = $this->_get_cached_class($class_name, $class_prefix);
810
-            if ($cached_class !== null) {
811
-                return $cached_class;
812
-            }
813
-        }
814
-        // if the class doesn't already exist.. then we need to try and find the file and load it
815
-        if (! $class_exists) {
816
-            // get full path to file
817
-            $path = $this->_resolve_path($class_name, $type, $file_paths);
818
-            // load the file
819
-            $loaded = $this->_require_file($path, $class_name, $type, $file_paths);
820
-            // if loading failed, or we are only loading a file but NOT instantiating an object
821
-            if (! $loaded || $load_only) {
822
-                // return boolean if only loading, or null if an object was expected
823
-                return $load_only
824
-                    ? $loaded
825
-                    : null;
826
-            }
827
-        }
828
-        // instantiate the requested object
829
-        $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
830
-        if ($this->_cache_on && $cache) {
831
-            // save it for later... kinda like gum  { : $
832
-            $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
833
-        }
834
-        $this->_cache_on = true;
835
-        return $class_obj;
836
-    }
837
-
838
-
839
-
840
-    /**
841
-     * @param string $class_name
842
-     * @param string $default have to specify something, but not anything that will conflict
843
-     * @return mixed|string
844
-     */
845
-    protected function get_class_abbreviation($class_name, $default = 'FANCY_BATMAN_PANTS')
846
-    {
847
-        return isset($this->_class_abbreviations[$class_name])
848
-            ? $this->_class_abbreviations[$class_name]
849
-            : $default;
850
-    }
851
-
852
-    /**
853
-     * attempts to find a cached version of the requested class
854
-     * by looking in the following places:
855
-     *        $this->{$class_abbreviation}            ie:    $this->CART
856
-     *        $this->{$class_name}                        ie:    $this->Some_Class
857
-     *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
858
-     *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
859
-     *
860
-     * @param string $class_name
861
-     * @param string $class_prefix
862
-     * @return mixed
863
-     */
864
-    protected function _get_cached_class($class_name, $class_prefix = '')
865
-    {
866
-        if ($class_name === 'EE_Registry') {
867
-            return $this;
868
-        }
869
-        $class_abbreviation = $this->get_class_abbreviation($class_name);
870
-        $class_name = str_replace('\\', '_', $class_name);
871
-        // check if class has already been loaded, and return it if it has been
872
-        if (isset($this->{$class_abbreviation})) {
873
-            return $this->{$class_abbreviation};
874
-        }
875
-        if (isset ($this->{$class_name})) {
876
-            return $this->{$class_name};
877
-        }
878
-        if (isset ($this->LIB->{$class_name})) {
879
-            return $this->LIB->{$class_name};
880
-        }
881
-        if ($class_prefix === 'addon' && isset ($this->addons->{$class_name})) {
882
-            return $this->addons->{$class_name};
883
-        }
884
-        return null;
885
-    }
886
-
887
-
888
-
889
-    /**
890
-     * removes a cached version of the requested class
891
-     *
892
-     * @param string  $class_name
893
-     * @param boolean $addon
894
-     * @return boolean
895
-     */
896
-    public function clear_cached_class($class_name, $addon = false)
897
-    {
898
-        $class_abbreviation = $this->get_class_abbreviation($class_name);
899
-        $class_name = str_replace('\\', '_', $class_name);
900
-        // check if class has already been loaded, and return it if it has been
901
-        if (isset($this->{$class_abbreviation})) {
902
-            $this->{$class_abbreviation} = null;
903
-            return true;
904
-        }
905
-        if (isset($this->{$class_name})) {
906
-            $this->{$class_name} = null;
907
-            return true;
908
-        }
909
-        if (isset($this->LIB->{$class_name})) {
910
-            unset($this->LIB->{$class_name});
911
-            return true;
912
-        }
913
-        if ($addon && isset($this->addons->{$class_name})) {
914
-            unset($this->addons->{$class_name});
915
-            return true;
916
-        }
917
-        return false;
918
-    }
919
-
920
-
921
-
922
-    /**
923
-     * attempts to find a full valid filepath for the requested class.
924
-     * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
925
-     * then returns that path if the target file has been found and is readable
926
-     *
927
-     * @param string $class_name
928
-     * @param string $type
929
-     * @param array  $file_paths
930
-     * @return string | bool
931
-     */
932
-    protected function _resolve_path($class_name, $type = '', $file_paths = array())
933
-    {
934
-        // make sure $file_paths is an array
935
-        $file_paths = is_array($file_paths)
936
-            ? $file_paths
937
-            : array($file_paths);
938
-        // cycle thru paths
939
-        foreach ($file_paths as $key => $file_path) {
940
-            // convert all separators to proper DS, if no filepath, then use EE_CLASSES
941
-            $file_path = $file_path
942
-                ? str_replace(array('/', '\\'), DS, $file_path)
943
-                : EE_CLASSES;
944
-            // prep file type
945
-            $type = ! empty($type)
946
-                ? trim($type, '.') . '.'
947
-                : '';
948
-            // build full file path
949
-            $file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
950
-            //does the file exist and can be read ?
951
-            if (is_readable($file_paths[$key])) {
952
-                return $file_paths[$key];
953
-            }
954
-        }
955
-        return false;
956
-    }
957
-
958
-
959
-
960
-    /**
961
-     * basically just performs a require_once()
962
-     * but with some error handling
963
-     *
964
-     * @param  string $path
965
-     * @param  string $class_name
966
-     * @param  string $type
967
-     * @param  array  $file_paths
968
-     * @return bool
969
-     * @throws EE_Error
970
-     * @throws ReflectionException
971
-     */
972
-    protected function _require_file($path, $class_name, $type = '', $file_paths = array())
973
-    {
974
-        $this->resolve_legacy_class_parent($class_name);
975
-        // don't give up! you gotta...
976
-        try {
977
-            //does the file exist and can it be read ?
978
-            if (! $path) {
979
-                // so sorry, can't find the file
980
-                throw new EE_Error (
981
-                    sprintf(
982
-                        esc_html__(
983
-                            'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s',
984
-                            'event_espresso'
985
-                        ),
986
-                        trim($type, '.'),
987
-                        $class_name,
988
-                        '<br />' . implode(',<br />', $file_paths)
989
-                    )
990
-                );
991
-            }
992
-            // get the file
993
-            require_once($path);
994
-            // if the class isn't already declared somewhere
995
-            if (class_exists($class_name, false) === false) {
996
-                // so sorry, not a class
997
-                throw new EE_Error(
998
-                    sprintf(
999
-                        esc_html__('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
1000
-                        $type,
1001
-                        $path,
1002
-                        $class_name
1003
-                    )
1004
-                );
1005
-            }
1006
-        } catch (EE_Error $e) {
1007
-            $e->get_error();
1008
-            return false;
1009
-        }
1010
-        return true;
1011
-    }
1012
-
1013
-
1014
-
1015
-    /**
1016
-     * Some of our legacy classes that extended a parent class would simply use a require() statement
1017
-     * before their class declaration in order to ensure that the parent class was loaded.
1018
-     * This is not ideal, but it's nearly impossible to determine the parent class of a non-namespaced class,
1019
-     * without triggering a fatal error because the parent class has yet to be loaded and therefore doesn't exist.
1020
-     *
1021
-     * @param string $class_name
1022
-     */
1023
-    protected function resolve_legacy_class_parent($class_name = '')
1024
-    {
1025
-        try {
1026
-            $legacy_parent_class_map = array(
1027
-                'EE_Payment_Processor' => 'core/business/EE_Processor_Base.class.php'
1028
-            );
1029
-            if(isset($legacy_parent_class_map[$class_name])) {
1030
-                require_once EE_PLUGIN_DIR_PATH . $legacy_parent_class_map[$class_name];
1031
-            }
1032
-        } catch (Exception $exception) {
1033
-        }
1034
-    }
1035
-
1036
-
1037
-
1038
-    /**
1039
-     * _create_object
1040
-     * Attempts to instantiate the requested class via any of the
1041
-     * commonly used instantiation methods employed throughout EE.
1042
-     * The priority for instantiation is as follows:
1043
-     *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
1044
-     *        - model objects via their 'new_instance_from_db' method
1045
-     *        - model objects via their 'new_instance' method
1046
-     *        - "singleton" classes" via their 'instance' method
1047
-     *    - standard instantiable classes via their __constructor
1048
-     * Prior to instantiation, if the classname exists in the dependency_map,
1049
-     * then the constructor for the requested class will be examined to determine
1050
-     * if any dependencies exist, and if they can be injected.
1051
-     * If so, then those classes will be added to the array of arguments passed to the constructor
1052
-     *
1053
-     * @param string $class_name
1054
-     * @param array  $arguments
1055
-     * @param string $type
1056
-     * @param bool   $from_db
1057
-     * @return null|object
1058
-     * @throws EE_Error
1059
-     * @throws ReflectionException
1060
-     */
1061
-    protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
1062
-    {
1063
-        // create reflection
1064
-        $reflector = $this->get_ReflectionClass($class_name);
1065
-        // make sure arguments are an array
1066
-        $arguments = is_array($arguments)
1067
-            ? $arguments
1068
-            : array($arguments);
1069
-        // and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
1070
-        // else wrap it in an additional array so that it doesn't get split into multiple parameters
1071
-        $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
1072
-            ? $arguments
1073
-            : array($arguments);
1074
-        // attempt to inject dependencies ?
1075
-        if ($this->_dependency_map->has($class_name)) {
1076
-            $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
1077
-        }
1078
-        // instantiate the class if possible
1079
-        if ($reflector->isAbstract()) {
1080
-            // nothing to instantiate, loading file was enough
1081
-            // does not throw an exception so $instantiation_mode is unused
1082
-            // $instantiation_mode = "1) no constructor abstract class";
1083
-            return true;
1084
-        }
1085
-        if (empty($arguments) && $reflector->getConstructor() === null && $reflector->isInstantiable()) {
1086
-            // no constructor = static methods only... nothing to instantiate, loading file was enough
1087
-            // $instantiation_mode = "2) no constructor but instantiable";
1088
-            return $reflector->newInstance();
1089
-        }
1090
-        if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
1091
-            // $instantiation_mode = "3) new_instance_from_db()";
1092
-            return call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
1093
-        }
1094
-        if (method_exists($class_name, 'new_instance')) {
1095
-            // $instantiation_mode = "4) new_instance()";
1096
-            return call_user_func_array(array($class_name, 'new_instance'), $arguments);
1097
-        }
1098
-        if (method_exists($class_name, 'instance')) {
1099
-            // $instantiation_mode = "5) instance()";
1100
-            return call_user_func_array(array($class_name, 'instance'), $arguments);
1101
-        }
1102
-        if ($reflector->isInstantiable()) {
1103
-            // $instantiation_mode = "6) constructor";
1104
-            return $reflector->newInstanceArgs($arguments);
1105
-        }
1106
-        // heh ? something's not right !
1107
-        throw new EE_Error(
1108
-            sprintf(
1109
-                __('The %s file %s could not be instantiated.', 'event_espresso'),
1110
-                $type,
1111
-                $class_name
1112
-            )
1113
-        );
1114
-    }
1115
-
1116
-
1117
-
1118
-    /**
1119
-     * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
1120
-     * @param array $array
1121
-     * @return bool
1122
-     */
1123
-    protected function _array_is_numerically_and_sequentially_indexed(array $array)
1124
-    {
1125
-        return ! empty($array)
1126
-            ? array_keys($array) === range(0, count($array) - 1)
1127
-            : true;
1128
-    }
1129
-
1130
-
1131
-
1132
-    /**
1133
-     * getReflectionClass
1134
-     * checks if a ReflectionClass object has already been generated for a class
1135
-     * and returns that instead of creating a new one
1136
-     *
1137
-     * @param string $class_name
1138
-     * @return ReflectionClass
1139
-     * @throws ReflectionException
1140
-     */
1141
-    public function get_ReflectionClass($class_name)
1142
-    {
1143
-        if (
1144
-            ! isset($this->_reflectors[$class_name])
1145
-            || ! $this->_reflectors[$class_name] instanceof ReflectionClass
1146
-        ) {
1147
-            $this->_reflectors[$class_name] = new ReflectionClass($class_name);
1148
-        }
1149
-        return $this->_reflectors[$class_name];
1150
-    }
1151
-
1152
-
1153
-
1154
-    /**
1155
-     * _resolve_dependencies
1156
-     * examines the constructor for the requested class to determine
1157
-     * if any dependencies exist, and if they can be injected.
1158
-     * If so, then those classes will be added to the array of arguments passed to the constructor
1159
-     * PLZ NOTE: this is achieved by type hinting the constructor params
1160
-     * For example:
1161
-     *        if attempting to load a class "Foo" with the following constructor:
1162
-     *        __construct( Bar $bar_class, Fighter $grohl_class )
1163
-     *        then $bar_class and $grohl_class will be added to the $arguments array,
1164
-     *        but only IF they are NOT already present in the incoming arguments array,
1165
-     *        and the correct classes can be loaded
1166
-     *
1167
-     * @param ReflectionClass $reflector
1168
-     * @param string          $class_name
1169
-     * @param array           $arguments
1170
-     * @return array
1171
-     * @throws EE_Error
1172
-     * @throws ReflectionException
1173
-     */
1174
-    protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array())
1175
-    {
1176
-        // let's examine the constructor
1177
-        $constructor = $reflector->getConstructor();
1178
-        // whu? huh? nothing?
1179
-        if (! $constructor) {
1180
-            return $arguments;
1181
-        }
1182
-        // get constructor parameters
1183
-        $params = $constructor->getParameters();
1184
-        // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
1185
-        $argument_keys = array_keys($arguments);
1186
-        // now loop thru all of the constructors expected parameters
1187
-        foreach ($params as $index => $param) {
1188
-            // is this a dependency for a specific class ?
1189
-            $param_class = $param->getClass()
1190
-                ? $param->getClass()->name
1191
-                : null;
1192
-            // BUT WAIT !!! This class may be an alias for something else (or getting replaced at runtime)
1193
-            $param_class = $this->_dependency_map->has_alias($param_class, $class_name)
1194
-                ? $this->_dependency_map->get_alias($param_class, $class_name)
1195
-                : $param_class;
1196
-            if (
1197
-                // param is not even a class
1198
-                $param_class === null
1199
-                // and something already exists in the incoming arguments for this param
1200
-                && array_key_exists($index, $argument_keys)
1201
-                && array_key_exists($argument_keys[$index], $arguments)
1202
-            ) {
1203
-                // so let's skip this argument and move on to the next
1204
-                continue;
1205
-            }
1206
-            if (
1207
-                // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
1208
-                $param_class !== null
1209
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
1210
-                && $arguments[$argument_keys[$index]] instanceof $param_class
1211
-            ) {
1212
-                // skip this argument and move on to the next
1213
-                continue;
1214
-            }
1215
-            if (
1216
-                // parameter is type hinted as a class, and should be injected
1217
-                $param_class !== null
1218
-                && $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1219
-            ) {
1220
-                $arguments = $this->_resolve_dependency(
1221
-                    $class_name,
1222
-                    $param_class,
1223
-                    $arguments,
1224
-                    $index,
1225
-                    $argument_keys
1226
-                );
1227
-            } else {
1228
-                try {
1229
-                    $arguments[$index] = $param->isDefaultValueAvailable()
1230
-                        ? $param->getDefaultValue()
1231
-                        : null;
1232
-                } catch (ReflectionException $e) {
1233
-                    throw new ReflectionException(
1234
-                        sprintf(
1235
-                            esc_html__('%1$s for parameter "$%2$s on classname "%3$s"', 'event_espresso'),
1236
-                            $e->getMessage(),
1237
-                            $param->getName(),
1238
-                            $class_name
1239
-                        )
1240
-                    );
1241
-                }
1242
-            }
1243
-        }
1244
-        return $arguments;
1245
-    }
1246
-
1247
-
1248
-
1249
-    /**
1250
-     * @param string $class_name
1251
-     * @param string $param_class
1252
-     * @param array  $arguments
1253
-     * @param mixed  $index
1254
-     * @param array  $argument_keys
1255
-     * @return array
1256
-     * @throws EE_Error
1257
-     * @throws ReflectionException
1258
-     * @throws InvalidArgumentException
1259
-     * @throws InvalidInterfaceException
1260
-     * @throws InvalidDataTypeException
1261
-     */
1262
-    protected function _resolve_dependency($class_name, $param_class, $arguments, $index, array $argument_keys)
1263
-    {
1264
-        $dependency = null;
1265
-        // should dependency be loaded from cache ?
1266
-        $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency(
1267
-            $class_name,
1268
-            $param_class
1269
-        );
1270
-        $cache_on = $cache_on !== EE_Dependency_Map::load_new_object;
1271
-        // we might have a dependency...
1272
-        // let's MAYBE try and find it in our cache if that's what's been requested
1273
-        $cached_class = $cache_on
1274
-            ? $this->_get_cached_class($param_class)
1275
-            : null;
1276
-        // and grab it if it exists
1277
-        if ($cached_class instanceof $param_class) {
1278
-            $dependency = $cached_class;
1279
-        } else if ($param_class !== $class_name) {
1280
-            // obtain the loader method from the dependency map
1281
-            $loader = $this->_dependency_map->class_loader($param_class);
1282
-            // is loader a custom closure ?
1283
-            if ($loader instanceof Closure) {
1284
-                $dependency = $loader($arguments);
1285
-            } else {
1286
-                // set the cache on property for the recursive loading call
1287
-                $this->_cache_on = $cache_on;
1288
-                // if not, then let's try and load it via the registry
1289
-                if ($loader && method_exists($this, $loader)) {
1290
-                    $dependency = $this->{$loader}($param_class);
1291
-                } else {
1292
-                    $dependency = LoaderFactory::getLoader()->load(
1293
-                        $param_class,
1294
-                        array(),
1295
-                        $cache_on
1296
-                    );
1297
-                }
1298
-            }
1299
-        }
1300
-        // did we successfully find the correct dependency ?
1301
-        if ($dependency instanceof $param_class) {
1302
-            // then let's inject it into the incoming array of arguments at the correct location
1303
-            $arguments[$index] = $dependency;
1304
-        }
1305
-        return $arguments;
1306
-    }
1307
-
1308
-
1309
-
1310
-    /**
1311
-     * _set_cached_class
1312
-     * attempts to cache the instantiated class locally
1313
-     * in one of the following places, in the following order:
1314
-     *        $this->{class_abbreviation}   ie:    $this->CART
1315
-     *        $this->{$class_name}          ie:    $this->Some_Class
1316
-     *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1317
-     *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1318
-     *
1319
-     * @param object $class_obj
1320
-     * @param string $class_name
1321
-     * @param string $class_prefix
1322
-     * @param bool   $from_db
1323
-     * @return void
1324
-     */
1325
-    protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false)
1326
-    {
1327
-        if ($class_name === 'EE_Registry' || empty($class_obj)) {
1328
-            return;
1329
-        }
1330
-        // return newly instantiated class
1331
-        $class_abbreviation = $this->get_class_abbreviation($class_name, '');
1332
-        if ($class_abbreviation) {
1333
-            $this->{$class_abbreviation} = $class_obj;
1334
-            return;
1335
-        }
1336
-        $class_name = str_replace('\\', '_', $class_name);
1337
-        if (property_exists($this, $class_name)) {
1338
-            $this->{$class_name} = $class_obj;
1339
-            return;
1340
-        }
1341
-        if ($class_prefix === 'addon') {
1342
-            $this->addons->{$class_name} = $class_obj;
1343
-            return;
1344
-        }
1345
-        if (! $from_db) {
1346
-            $this->LIB->{$class_name} = $class_obj;
1347
-        }
1348
-    }
1349
-
1350
-
1351
-
1352
-    /**
1353
-     * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1354
-     *
1355
-     * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1356
-     *                          in the EE_Dependency_Map::$_class_loaders array,
1357
-     *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1358
-     * @param array  $arguments
1359
-     * @return object
1360
-     */
1361
-    public static function factory($classname, $arguments = array())
1362
-    {
1363
-        $loader = self::instance()->_dependency_map->class_loader($classname);
1364
-        if ($loader instanceof Closure) {
1365
-            return $loader($arguments);
1366
-        }
1367
-        if (method_exists(self::instance(), $loader)) {
1368
-            return self::instance()->{$loader}($classname, $arguments);
1369
-        }
1370
-        return null;
1371
-    }
1372
-
1373
-
1374
-
1375
-    /**
1376
-     * Gets the addon by its name/slug (not classname. For that, just
1377
-     * use the classname as the property name on EE_Config::instance()->addons)
1378
-     *
1379
-     * @param string $name
1380
-     * @return EE_Addon
1381
-     */
1382
-    public function get_addon_by_name($name)
1383
-    {
1384
-        foreach ($this->addons as $addon) {
1385
-            if ($addon->name() === $name) {
1386
-                return $addon;
1387
-            }
1388
-        }
1389
-        return null;
1390
-    }
1391
-
1392
-
1393
-
1394
-    /**
1395
-     * Gets an array of all the registered addons, where the keys are their names. (ie, what each returns for their
1396
-     * name() function) They're already available on EE_Config::instance()->addons as properties, where each property's
1397
-     * name is the addon's classname. So if you just want to get the addon by classname, use
1398
-     * EE_Config::instance()->addons->{classname}
1399
-     *
1400
-     * @return EE_Addon[] where the KEYS are the addon's name()
1401
-     */
1402
-    public function get_addons_by_name()
1403
-    {
1404
-        $addons = array();
1405
-        foreach ($this->addons as $addon) {
1406
-            $addons[$addon->name()] = $addon;
1407
-        }
1408
-        return $addons;
1409
-    }
1410
-
1411
-
1412
-
1413
-    /**
1414
-     * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1415
-     * a stale copy of it around
1416
-     *
1417
-     * @param string $model_name
1418
-     * @return \EEM_Base
1419
-     * @throws \EE_Error
1420
-     */
1421
-    public function reset_model($model_name)
1422
-    {
1423
-        $model_class_name = strpos($model_name, 'EEM_') !== 0
1424
-            ? "EEM_{$model_name}"
1425
-            : $model_name;
1426
-        if (! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1427
-            return null;
1428
-        }
1429
-        //get that model reset it and make sure we nuke the old reference to it
1430
-        if ($this->LIB->{$model_class_name} instanceof $model_class_name
1431
-            && is_callable(
1432
-                array($model_class_name, 'reset')
1433
-            )) {
1434
-            $this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1435
-        } else {
1436
-            throw new EE_Error(sprintf(esc_html__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1437
-        }
1438
-        return $this->LIB->{$model_class_name};
1439
-    }
1440
-
1441
-
1442
-
1443
-    /**
1444
-     * Resets the registry.
1445
-     * The criteria for what gets reset is based on what can be shared between sites on the same request when
1446
-     * switch_to_blog is used in a multisite install.  Here is a list of things that are NOT reset.
1447
-     * - $_dependency_map
1448
-     * - $_class_abbreviations
1449
-     * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1450
-     * - $REQ:  Still on the same request so no need to change.
1451
-     * - $CAP: There is no site specific state in the EE_Capability class.
1452
-     * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only
1453
-     * one Session can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1454
-     * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1455
-     *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1456
-     *             switch or on the restore.
1457
-     * - $modules
1458
-     * - $shortcodes
1459
-     * - $widgets
1460
-     *
1461
-     * @param boolean $hard             [deprecated]
1462
-     * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1463
-     *                                  or just reset without re-instantiating (handy to set to FALSE if you're not
1464
-     *                                  sure if you CAN currently reinstantiate the singletons at the moment)
1465
-     * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so
1466
-     *                                  client
1467
-     *                                  code instead can just change the model context to a different blog id if
1468
-     *                                  necessary
1469
-     * @return EE_Registry
1470
-     * @throws EE_Error
1471
-     * @throws ReflectionException
1472
-     */
1473
-    public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1474
-    {
1475
-        $instance = self::instance();
1476
-        $instance->_cache_on = true;
1477
-        // reset some "special" classes
1478
-        EEH_Activation::reset();
1479
-        $hard = apply_filters( 'FHEE__EE_Registry__reset__hard', $hard);
1480
-        $instance->CFG = EE_Config::reset($hard, $reinstantiate);
1481
-        $instance->CART = null;
1482
-        $instance->MRM = null;
1483
-        $instance->AssetsRegistry = $instance->create('EventEspresso\core\services\assets\Registry');
1484
-        //messages reset
1485
-        EED_Messages::reset();
1486
-        //handle of objects cached on LIB
1487
-        foreach (array('LIB', 'modules') as $cache) {
1488
-            foreach ($instance->{$cache} as $class_name => $class) {
1489
-                if (self::_reset_and_unset_object($class, $reset_models)) {
1490
-                    unset($instance->{$cache}->{$class_name});
1491
-                }
1492
-            }
1493
-        }
1494
-        return $instance;
1495
-    }
1496
-
1497
-
1498
-
1499
-    /**
1500
-     * if passed object implements ResettableInterface, then call it's reset() method
1501
-     * if passed object implements InterminableInterface, then return false,
1502
-     * to indicate that it should NOT be cleared from the Registry cache
1503
-     *
1504
-     * @param      $object
1505
-     * @param bool $reset_models
1506
-     * @return bool returns true if cached object should be unset
1507
-     */
1508
-    private static function _reset_and_unset_object($object, $reset_models)
1509
-    {
1510
-        if (! is_object($object)) {
1511
-            // don't unset anything that's not an object
1512
-            return false;
1513
-        }
1514
-        if ($object instanceof EED_Module) {
1515
-            $object::reset();
1516
-            // don't unset modules
1517
-            return false;
1518
-        }
1519
-        if ($object instanceof ResettableInterface) {
1520
-            if ($object instanceof EEM_Base) {
1521
-                if ($reset_models) {
1522
-                    $object->reset();
1523
-                    return true;
1524
-                }
1525
-                return false;
1526
-            }
1527
-            $object->reset();
1528
-            return true;
1529
-        }
1530
-        if (! $object instanceof InterminableInterface) {
1531
-            return true;
1532
-        }
1533
-        return false;
1534
-    }
1535
-
1536
-
1537
-
1538
-    /**
1539
-     * Gets all the custom post type models defined
1540
-     *
1541
-     * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1542
-     */
1543
-    public function cpt_models()
1544
-    {
1545
-        $cpt_models = array();
1546
-        foreach ($this->non_abstract_db_models as $short_name => $classname) {
1547
-            if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1548
-                $cpt_models[$short_name] = $classname;
1549
-            }
1550
-        }
1551
-        return $cpt_models;
1552
-    }
1553
-
1554
-
1555
-
1556
-    /**
1557
-     * @return \EE_Config
1558
-     */
1559
-    public static function CFG()
1560
-    {
1561
-        return self::instance()->CFG;
1562
-    }
25
+	/**
26
+	 * @var EE_Registry $_instance
27
+	 */
28
+	private static $_instance;
29
+
30
+	/**
31
+	 * @var EE_Dependency_Map $_dependency_map
32
+	 */
33
+	protected $_dependency_map;
34
+
35
+	/**
36
+	 * @var array $_class_abbreviations
37
+	 */
38
+	protected $_class_abbreviations = array();
39
+
40
+	/**
41
+	 * @var CommandBusInterface $BUS
42
+	 */
43
+	public $BUS;
44
+
45
+	/**
46
+	 * @var EE_Cart $CART
47
+	 */
48
+	public $CART;
49
+
50
+	/**
51
+	 * @var EE_Config $CFG
52
+	 */
53
+	public $CFG;
54
+
55
+	/**
56
+	 * @var EE_Network_Config $NET_CFG
57
+	 */
58
+	public $NET_CFG;
59
+
60
+	/**
61
+	 * StdClass object for storing library classes in
62
+	 *
63
+	 * @var StdClass $LIB
64
+	 */
65
+	public $LIB;
66
+
67
+	/**
68
+	 * @var EE_Request_Handler $REQ
69
+	 */
70
+	public $REQ;
71
+
72
+	/**
73
+	 * @var EE_Session $SSN
74
+	 */
75
+	public $SSN;
76
+
77
+	/**
78
+	 * @since 4.5.0
79
+	 * @var EE_Capabilities $CAP
80
+	 */
81
+	public $CAP;
82
+
83
+	/**
84
+	 * @since 4.9.0
85
+	 * @var EE_Message_Resource_Manager $MRM
86
+	 */
87
+	public $MRM;
88
+
89
+
90
+	/**
91
+	 * @var Registry $AssetsRegistry
92
+	 */
93
+	public $AssetsRegistry;
94
+
95
+	/**
96
+	 * StdClass object for holding addons which have registered themselves to work with EE core
97
+	 *
98
+	 * @var EE_Addon[] $addons
99
+	 */
100
+	public $addons;
101
+
102
+	/**
103
+	 * keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
104
+	 *
105
+	 * @var EEM_Base[] $models
106
+	 */
107
+	public $models = array();
108
+
109
+	/**
110
+	 * @var EED_Module[] $modules
111
+	 */
112
+	public $modules;
113
+
114
+	/**
115
+	 * @var EES_Shortcode[] $shortcodes
116
+	 */
117
+	public $shortcodes;
118
+
119
+	/**
120
+	 * @var WP_Widget[] $widgets
121
+	 */
122
+	public $widgets;
123
+
124
+	/**
125
+	 * this is an array of all implemented model names (i.e. not the parent abstract models, or models
126
+	 * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
127
+	 * Keys are model "short names" (eg "Event") as used in model relations, and values are
128
+	 * classnames (eg "EEM_Event")
129
+	 *
130
+	 * @var array $non_abstract_db_models
131
+	 */
132
+	public $non_abstract_db_models = array();
133
+
134
+
135
+	/**
136
+	 * internationalization for JS strings
137
+	 *    usage:   EE_Registry::i18n_js_strings['string_key'] = esc_html__( 'string to translate.', 'event_espresso' );
138
+	 *    in js file:  var translatedString = eei18n.string_key;
139
+	 *
140
+	 * @var array $i18n_js_strings
141
+	 */
142
+	public static $i18n_js_strings = array();
143
+
144
+
145
+	/**
146
+	 * $main_file - path to espresso.php
147
+	 *
148
+	 * @var array $main_file
149
+	 */
150
+	public $main_file;
151
+
152
+	/**
153
+	 * array of ReflectionClass objects where the key is the class name
154
+	 *
155
+	 * @var ReflectionClass[] $_reflectors
156
+	 */
157
+	public $_reflectors;
158
+
159
+	/**
160
+	 * boolean flag to indicate whether or not to load/save dependencies from/to the cache
161
+	 *
162
+	 * @var boolean $_cache_on
163
+	 */
164
+	protected $_cache_on = true;
165
+
166
+
167
+
168
+	/**
169
+	 * @singleton method used to instantiate class object
170
+	 * @param  EE_Dependency_Map $dependency_map
171
+	 * @return EE_Registry instance
172
+	 * @throws InvalidArgumentException
173
+	 * @throws InvalidInterfaceException
174
+	 * @throws InvalidDataTypeException
175
+	 */
176
+	public static function instance(EE_Dependency_Map $dependency_map = null)
177
+	{
178
+		// check if class object is instantiated
179
+		if (! self::$_instance instanceof EE_Registry) {
180
+			self::$_instance = new self($dependency_map);
181
+		}
182
+		return self::$_instance;
183
+	}
184
+
185
+
186
+
187
+	/**
188
+	 * protected constructor to prevent direct creation
189
+	 *
190
+	 * @Constructor
191
+	 * @param  EE_Dependency_Map $dependency_map
192
+	 * @throws InvalidDataTypeException
193
+	 * @throws InvalidInterfaceException
194
+	 * @throws InvalidArgumentException
195
+	 */
196
+	protected function __construct(EE_Dependency_Map $dependency_map)
197
+	{
198
+		$this->_dependency_map = $dependency_map;
199
+		$this->LIB = new stdClass();
200
+		$this->addons = new stdClass();
201
+		$this->modules = new stdClass();
202
+		$this->shortcodes = new stdClass();
203
+		$this->widgets = new stdClass();
204
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
205
+	}
206
+
207
+
208
+
209
+	/**
210
+	 * initialize
211
+	 *
212
+	 * @throws EE_Error
213
+	 * @throws ReflectionException
214
+	 */
215
+	public function initialize()
216
+	{
217
+		$this->_class_abbreviations = apply_filters(
218
+			'FHEE__EE_Registry____construct___class_abbreviations',
219
+			array(
220
+				'EE_Config'                                       => 'CFG',
221
+				'EE_Session'                                      => 'SSN',
222
+				'EE_Capabilities'                                 => 'CAP',
223
+				'EE_Cart'                                         => 'CART',
224
+				'EE_Network_Config'                               => 'NET_CFG',
225
+				'EE_Request_Handler'                              => 'REQ',
226
+				'EE_Message_Resource_Manager'                     => 'MRM',
227
+				'EventEspresso\core\services\commands\CommandBus' => 'BUS',
228
+				'EventEspresso\core\services\assets\Registry'     => 'AssetsRegistry',
229
+			)
230
+		);
231
+		$this->load_core('Base', array(), true);
232
+		// add our request and response objects to the cache
233
+		$request_loader = $this->_dependency_map->class_loader('EE_Request');
234
+		$this->_set_cached_class(
235
+			$request_loader(),
236
+			'EE_Request'
237
+		);
238
+		$response_loader = $this->_dependency_map->class_loader('EE_Response');
239
+		$this->_set_cached_class(
240
+			$response_loader(),
241
+			'EE_Response'
242
+		);
243
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
244
+	}
245
+
246
+
247
+
248
+	/**
249
+	 * @return void
250
+	 */
251
+	public function init()
252
+	{
253
+		// Get current page protocol
254
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
255
+		// Output admin-ajax.php URL with same protocol as current page
256
+		self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
257
+		self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
258
+	}
259
+
260
+
261
+
262
+	/**
263
+	 * localize_i18n_js_strings
264
+	 *
265
+	 * @return string
266
+	 */
267
+	public static function localize_i18n_js_strings()
268
+	{
269
+		$i18n_js_strings = (array)self::$i18n_js_strings;
270
+		foreach ($i18n_js_strings as $key => $value) {
271
+			if (is_scalar($value)) {
272
+				$i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
273
+			}
274
+		}
275
+		return '/* <![CDATA[ */ var eei18n = ' . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
276
+	}
277
+
278
+
279
+
280
+	/**
281
+	 * @param mixed string | EED_Module $module
282
+	 * @throws EE_Error
283
+	 * @throws ReflectionException
284
+	 */
285
+	public function add_module($module)
286
+	{
287
+		if ($module instanceof EED_Module) {
288
+			$module_class = get_class($module);
289
+			$this->modules->{$module_class} = $module;
290
+		} else {
291
+			if ( ! class_exists('EE_Module_Request_Router', false)) {
292
+				$this->load_core('Module_Request_Router');
293
+			}
294
+			EE_Module_Request_Router::module_factory($module);
295
+		}
296
+	}
297
+
298
+
299
+
300
+	/**
301
+	 * @param string $module_name
302
+	 * @return mixed EED_Module | NULL
303
+	 */
304
+	public function get_module($module_name = '')
305
+	{
306
+		return isset($this->modules->{$module_name})
307
+			? $this->modules->{$module_name}
308
+			: null;
309
+	}
310
+
311
+
312
+
313
+	/**
314
+	 * loads core classes - must be singletons
315
+	 *
316
+	 * @param string $class_name - simple class name ie: session
317
+	 * @param mixed  $arguments
318
+	 * @param bool   $load_only
319
+	 * @return mixed
320
+	 * @throws EE_Error
321
+	 * @throws ReflectionException
322
+	 */
323
+	public function load_core($class_name, $arguments = array(), $load_only = false)
324
+	{
325
+		$core_paths = apply_filters(
326
+			'FHEE__EE_Registry__load_core__core_paths',
327
+			array(
328
+				EE_CORE,
329
+				EE_ADMIN,
330
+				EE_CPTS,
331
+				EE_CORE . 'data_migration_scripts' . DS,
332
+				EE_CORE . 'capabilities' . DS,
333
+				EE_CORE . 'request_stack' . DS,
334
+				EE_CORE . 'middleware' . DS,
335
+			)
336
+		);
337
+		// retrieve instantiated class
338
+		return $this->_load(
339
+			$core_paths,
340
+			'EE_',
341
+			$class_name,
342
+			'core',
343
+			$arguments,
344
+			false,
345
+			true,
346
+			$load_only
347
+		);
348
+	}
349
+
350
+
351
+
352
+	/**
353
+	 * loads service classes
354
+	 *
355
+	 * @param string $class_name - simple class name ie: session
356
+	 * @param mixed  $arguments
357
+	 * @param bool   $load_only
358
+	 * @return mixed
359
+	 * @throws EE_Error
360
+	 * @throws ReflectionException
361
+	 */
362
+	public function load_service($class_name, $arguments = array(), $load_only = false)
363
+	{
364
+		$service_paths = apply_filters(
365
+			'FHEE__EE_Registry__load_service__service_paths',
366
+			array(
367
+				EE_CORE . 'services' . DS,
368
+			)
369
+		);
370
+		// retrieve instantiated class
371
+		return $this->_load(
372
+			$service_paths,
373
+			'EE_',
374
+			$class_name,
375
+			'class',
376
+			$arguments,
377
+			false,
378
+			true,
379
+			$load_only
380
+		);
381
+	}
382
+
383
+
384
+
385
+	/**
386
+	 * loads data_migration_scripts
387
+	 *
388
+	 * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
389
+	 * @param mixed  $arguments
390
+	 * @return EE_Data_Migration_Script_Base|mixed
391
+	 * @throws EE_Error
392
+	 * @throws ReflectionException
393
+	 */
394
+	public function load_dms($class_name, $arguments = array())
395
+	{
396
+		// retrieve instantiated class
397
+		return $this->_load(
398
+			EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(),
399
+			'EE_DMS_',
400
+			$class_name,
401
+			'dms',
402
+			$arguments,
403
+			false,
404
+			false
405
+		);
406
+	}
407
+
408
+
409
+
410
+	/**
411
+	 * loads object creating classes - must be singletons
412
+	 *
413
+	 * @param string $class_name - simple class name ie: attendee
414
+	 * @param mixed  $arguments  - an array of arguments to pass to the class
415
+	 * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to
416
+	 *                           instantiate
417
+	 * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then
418
+	 *                           set this to FALSE (ie. when instantiating model objects from client in a loop)
419
+	 * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate
420
+	 *                           (default)
421
+	 * @return EE_Base_Class | bool
422
+	 * @throws EE_Error
423
+	 * @throws ReflectionException
424
+	 */
425
+	public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
426
+	{
427
+		$paths = apply_filters(
428
+			'FHEE__EE_Registry__load_class__paths', array(
429
+			EE_CORE,
430
+			EE_CLASSES,
431
+			EE_BUSINESS,
432
+		)
433
+		);
434
+		// retrieve instantiated class
435
+		return $this->_load(
436
+			$paths,
437
+			'EE_',
438
+			$class_name,
439
+			'class',
440
+			$arguments,
441
+			$from_db,
442
+			$cache,
443
+			$load_only
444
+		);
445
+	}
446
+
447
+
448
+
449
+	/**
450
+	 * loads helper classes - must be singletons
451
+	 *
452
+	 * @param string $class_name - simple class name ie: price
453
+	 * @param mixed  $arguments
454
+	 * @param bool   $load_only
455
+	 * @return EEH_Base | bool
456
+	 * @throws EE_Error
457
+	 * @throws ReflectionException
458
+	 */
459
+	public function load_helper($class_name, $arguments = array(), $load_only = true)
460
+	{
461
+		// todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
462
+		$helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
463
+		// retrieve instantiated class
464
+		return $this->_load(
465
+			$helper_paths,
466
+			'EEH_',
467
+			$class_name,
468
+			'helper',
469
+			$arguments,
470
+			false,
471
+			true,
472
+			$load_only
473
+		);
474
+	}
475
+
476
+
477
+
478
+	/**
479
+	 * loads core classes - must be singletons
480
+	 *
481
+	 * @param string $class_name - simple class name ie: session
482
+	 * @param mixed  $arguments
483
+	 * @param bool   $load_only
484
+	 * @param bool   $cache      whether to cache the object or not.
485
+	 * @return mixed
486
+	 * @throws EE_Error
487
+	 * @throws ReflectionException
488
+	 */
489
+	public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
490
+	{
491
+		$paths = array(
492
+			EE_LIBRARIES,
493
+			EE_LIBRARIES . 'messages' . DS,
494
+			EE_LIBRARIES . 'shortcodes' . DS,
495
+			EE_LIBRARIES . 'qtips' . DS,
496
+			EE_LIBRARIES . 'payment_methods' . DS,
497
+			EE_LIBRARIES . 'messages' . DS . 'defaults' . DS,
498
+		);
499
+		// retrieve instantiated class
500
+		return $this->_load(
501
+			$paths,
502
+			'EE_',
503
+			$class_name,
504
+			'lib',
505
+			$arguments,
506
+			false,
507
+			$cache,
508
+			$load_only
509
+		);
510
+	}
511
+
512
+
513
+
514
+	/**
515
+	 * loads model classes - must be singletons
516
+	 *
517
+	 * @param string $class_name - simple class name ie: price
518
+	 * @param mixed  $arguments
519
+	 * @param bool   $load_only
520
+	 * @return EEM_Base | bool
521
+	 * @throws EE_Error
522
+	 * @throws ReflectionException
523
+	 */
524
+	public function load_model($class_name, $arguments = array(), $load_only = false)
525
+	{
526
+		$paths = apply_filters(
527
+			'FHEE__EE_Registry__load_model__paths', array(
528
+			EE_MODELS,
529
+			EE_CORE,
530
+		)
531
+		);
532
+		// retrieve instantiated class
533
+		return $this->_load(
534
+			$paths,
535
+			'EEM_',
536
+			$class_name,
537
+			'model',
538
+			$arguments,
539
+			false,
540
+			true,
541
+			$load_only
542
+		);
543
+	}
544
+
545
+
546
+
547
+	/**
548
+	 * loads model classes - must be singletons
549
+	 *
550
+	 * @param string $class_name - simple class name ie: price
551
+	 * @param mixed  $arguments
552
+	 * @param bool   $load_only
553
+	 * @return mixed | bool
554
+	 * @throws EE_Error
555
+	 * @throws ReflectionException
556
+	 */
557
+	public function load_model_class($class_name, $arguments = array(), $load_only = true)
558
+	{
559
+		$paths = array(
560
+			EE_MODELS . 'fields' . DS,
561
+			EE_MODELS . 'helpers' . DS,
562
+			EE_MODELS . 'relations' . DS,
563
+			EE_MODELS . 'strategies' . DS,
564
+		);
565
+		// retrieve instantiated class
566
+		return $this->_load(
567
+			$paths,
568
+			'EE_',
569
+			$class_name,
570
+			'',
571
+			$arguments,
572
+			false,
573
+			true,
574
+			$load_only
575
+		);
576
+	}
577
+
578
+
579
+
580
+	/**
581
+	 * Determines if $model_name is the name of an actual EE model.
582
+	 *
583
+	 * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
584
+	 * @return boolean
585
+	 */
586
+	public function is_model_name($model_name)
587
+	{
588
+		return isset($this->models[$model_name]);
589
+	}
590
+
591
+
592
+
593
+	/**
594
+	 * generic class loader
595
+	 *
596
+	 * @param string $path_to_file - directory path to file location, not including filename
597
+	 * @param string $file_name    - file name  ie:  my_file.php, including extension
598
+	 * @param string $type         - file type - core? class? helper? model?
599
+	 * @param mixed  $arguments
600
+	 * @param bool   $load_only
601
+	 * @return mixed
602
+	 * @throws EE_Error
603
+	 * @throws ReflectionException
604
+	 */
605
+	public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
606
+	{
607
+		// retrieve instantiated class
608
+		return $this->_load(
609
+			$path_to_file,
610
+			'',
611
+			$file_name,
612
+			$type,
613
+			$arguments,
614
+			false,
615
+			true,
616
+			$load_only
617
+		);
618
+	}
619
+
620
+
621
+
622
+	/**
623
+	 * @param string $path_to_file - directory path to file location, not including filename
624
+	 * @param string $class_name   - full class name  ie:  My_Class
625
+	 * @param string $type         - file type - core? class? helper? model?
626
+	 * @param mixed  $arguments
627
+	 * @param bool   $load_only
628
+	 * @return bool|EE_Addon|object
629
+	 * @throws EE_Error
630
+	 * @throws ReflectionException
631
+	 */
632
+	public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
633
+	{
634
+		// retrieve instantiated class
635
+		return $this->_load(
636
+			$path_to_file,
637
+			'addon',
638
+			$class_name,
639
+			$type,
640
+			$arguments,
641
+			false,
642
+			true,
643
+			$load_only
644
+		);
645
+	}
646
+
647
+
648
+
649
+	/**
650
+	 * instantiates, caches, and automatically resolves dependencies
651
+	 * for classes that use a Fully Qualified Class Name.
652
+	 * if the class is not capable of being loaded using PSR-4 autoloading,
653
+	 * then you need to use one of the existing load_*() methods
654
+	 * which can resolve the classname and filepath from the passed arguments
655
+	 *
656
+	 * @param bool|string $class_name   Fully Qualified Class Name
657
+	 * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
658
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
659
+	 * @param bool        $from_db      some classes are instantiated from the db
660
+	 *                                  and thus call a different method to instantiate
661
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
662
+	 * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
663
+	 * @return bool|null|mixed          null = failure to load or instantiate class object.
664
+	 *                                  object = class loaded and instantiated successfully.
665
+	 *                                  bool = fail or success when $load_only is true
666
+	 * @throws EE_Error
667
+	 * @throws ReflectionException
668
+	 */
669
+	public function create(
670
+		$class_name = false,
671
+		$arguments = array(),
672
+		$cache = false,
673
+		$from_db = false,
674
+		$load_only = false,
675
+		$addon = false
676
+	) {
677
+		$class_name = ltrim($class_name, '\\');
678
+		$class_name = $this->_dependency_map->get_alias($class_name);
679
+		$class_exists = $this->loadOrVerifyClassExists($class_name, $arguments);
680
+		// if a non-FQCN was passed, then verifyClassExists() might return an object
681
+		// or it could return null if the class just could not be found anywhere
682
+		if ($class_exists instanceof $class_name || $class_exists === null){
683
+			// either way, return the results
684
+			return $class_exists;
685
+		}
686
+		$class_name = $class_exists;
687
+		// if we're only loading the class and it already exists, then let's just return true immediately
688
+		if ($load_only) {
689
+			return true;
690
+		}
691
+		$addon = $addon
692
+			? 'addon'
693
+			: '';
694
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
695
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
696
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
697
+		if ($this->_cache_on && $cache && ! $load_only) {
698
+			// return object if it's already cached
699
+			$cached_class = $this->_get_cached_class($class_name, $addon);
700
+			if ($cached_class !== null) {
701
+				return $cached_class;
702
+			}
703
+		}
704
+		// obtain the loader method from the dependency map
705
+		$loader = $this->_dependency_map->class_loader($class_name);
706
+		// instantiate the requested object
707
+		if ($loader instanceof Closure) {
708
+			$class_obj = $loader($arguments);
709
+		} else if ($loader && method_exists($this, $loader)) {
710
+			$class_obj = $this->{$loader}($class_name, $arguments);
711
+		} else {
712
+			$class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
713
+		}
714
+		if (($this->_cache_on && $cache) || $this->get_class_abbreviation($class_name, '')) {
715
+			// save it for later... kinda like gum  { : $
716
+			$this->_set_cached_class($class_obj, $class_name, $addon, $from_db);
717
+		}
718
+		$this->_cache_on = true;
719
+		return $class_obj;
720
+	}
721
+
722
+
723
+
724
+	/**
725
+	 * Recursively checks that a class exists and potentially attempts to load classes with non-FQCNs
726
+	 *
727
+	 * @param string $class_name
728
+	 * @param array  $arguments
729
+	 * @param int    $attempt
730
+	 * @return mixed
731
+	 */
732
+	private function loadOrVerifyClassExists($class_name, array $arguments, $attempt = 1) {
733
+		if (is_object($class_name) || class_exists($class_name)) {
734
+			return $class_name;
735
+		}
736
+		switch ($attempt) {
737
+			case 1:
738
+				// if it's a FQCN then maybe the class is registered with a preceding \
739
+				$class_name = strpos($class_name, '\\') !== false
740
+					? '\\' . ltrim($class_name, '\\')
741
+					: $class_name;
742
+				break;
743
+			case 2:
744
+				//
745
+				$loader = $this->_dependency_map->class_loader($class_name);
746
+				if ($loader && method_exists($this, $loader)) {
747
+					return $this->{$loader}($class_name, $arguments);
748
+				}
749
+				break;
750
+			case 3:
751
+			default;
752
+				return null;
753
+		}
754
+		$attempt++;
755
+		return $this->loadOrVerifyClassExists($class_name, $arguments, $attempt);
756
+	}
757
+
758
+
759
+
760
+	/**
761
+	 * instantiates, caches, and injects dependencies for classes
762
+	 *
763
+	 * @param array       $file_paths   an array of paths to folders to look in
764
+	 * @param string      $class_prefix EE  or EEM or... ???
765
+	 * @param bool|string $class_name   $class name
766
+	 * @param string      $type         file type - core? class? helper? model?
767
+	 * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
768
+	 * @param bool        $from_db      some classes are instantiated from the db
769
+	 *                                  and thus call a different method to instantiate
770
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
771
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
772
+	 * @return bool|null|object null = failure to load or instantiate class object.
773
+	 *                                  object = class loaded and instantiated successfully.
774
+	 *                                  bool = fail or success when $load_only is true
775
+	 * @throws EE_Error
776
+	 * @throws ReflectionException
777
+	 */
778
+	protected function _load(
779
+		$file_paths = array(),
780
+		$class_prefix = 'EE_',
781
+		$class_name = false,
782
+		$type = 'class',
783
+		$arguments = array(),
784
+		$from_db = false,
785
+		$cache = true,
786
+		$load_only = false
787
+	) {
788
+		$class_name = ltrim($class_name, '\\');
789
+		// strip php file extension
790
+		$class_name = str_replace('.php', '', trim($class_name));
791
+		// does the class have a prefix ?
792
+		if (! empty($class_prefix) && $class_prefix !== 'addon') {
793
+			// make sure $class_prefix is uppercase
794
+			$class_prefix = strtoupper(trim($class_prefix));
795
+			// add class prefix ONCE!!!
796
+			$class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
797
+		}
798
+		$class_name = $this->_dependency_map->get_alias($class_name);
799
+		$class_exists = class_exists($class_name, false);
800
+		// if we're only loading the class and it already exists, then let's just return true immediately
801
+		if ($load_only && $class_exists) {
802
+			return true;
803
+		}
804
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
805
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
806
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
807
+		if ($this->_cache_on && $cache && ! $load_only) {
808
+			// return object if it's already cached
809
+			$cached_class = $this->_get_cached_class($class_name, $class_prefix);
810
+			if ($cached_class !== null) {
811
+				return $cached_class;
812
+			}
813
+		}
814
+		// if the class doesn't already exist.. then we need to try and find the file and load it
815
+		if (! $class_exists) {
816
+			// get full path to file
817
+			$path = $this->_resolve_path($class_name, $type, $file_paths);
818
+			// load the file
819
+			$loaded = $this->_require_file($path, $class_name, $type, $file_paths);
820
+			// if loading failed, or we are only loading a file but NOT instantiating an object
821
+			if (! $loaded || $load_only) {
822
+				// return boolean if only loading, or null if an object was expected
823
+				return $load_only
824
+					? $loaded
825
+					: null;
826
+			}
827
+		}
828
+		// instantiate the requested object
829
+		$class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
830
+		if ($this->_cache_on && $cache) {
831
+			// save it for later... kinda like gum  { : $
832
+			$this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
833
+		}
834
+		$this->_cache_on = true;
835
+		return $class_obj;
836
+	}
837
+
838
+
839
+
840
+	/**
841
+	 * @param string $class_name
842
+	 * @param string $default have to specify something, but not anything that will conflict
843
+	 * @return mixed|string
844
+	 */
845
+	protected function get_class_abbreviation($class_name, $default = 'FANCY_BATMAN_PANTS')
846
+	{
847
+		return isset($this->_class_abbreviations[$class_name])
848
+			? $this->_class_abbreviations[$class_name]
849
+			: $default;
850
+	}
851
+
852
+	/**
853
+	 * attempts to find a cached version of the requested class
854
+	 * by looking in the following places:
855
+	 *        $this->{$class_abbreviation}            ie:    $this->CART
856
+	 *        $this->{$class_name}                        ie:    $this->Some_Class
857
+	 *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
858
+	 *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
859
+	 *
860
+	 * @param string $class_name
861
+	 * @param string $class_prefix
862
+	 * @return mixed
863
+	 */
864
+	protected function _get_cached_class($class_name, $class_prefix = '')
865
+	{
866
+		if ($class_name === 'EE_Registry') {
867
+			return $this;
868
+		}
869
+		$class_abbreviation = $this->get_class_abbreviation($class_name);
870
+		$class_name = str_replace('\\', '_', $class_name);
871
+		// check if class has already been loaded, and return it if it has been
872
+		if (isset($this->{$class_abbreviation})) {
873
+			return $this->{$class_abbreviation};
874
+		}
875
+		if (isset ($this->{$class_name})) {
876
+			return $this->{$class_name};
877
+		}
878
+		if (isset ($this->LIB->{$class_name})) {
879
+			return $this->LIB->{$class_name};
880
+		}
881
+		if ($class_prefix === 'addon' && isset ($this->addons->{$class_name})) {
882
+			return $this->addons->{$class_name};
883
+		}
884
+		return null;
885
+	}
886
+
887
+
888
+
889
+	/**
890
+	 * removes a cached version of the requested class
891
+	 *
892
+	 * @param string  $class_name
893
+	 * @param boolean $addon
894
+	 * @return boolean
895
+	 */
896
+	public function clear_cached_class($class_name, $addon = false)
897
+	{
898
+		$class_abbreviation = $this->get_class_abbreviation($class_name);
899
+		$class_name = str_replace('\\', '_', $class_name);
900
+		// check if class has already been loaded, and return it if it has been
901
+		if (isset($this->{$class_abbreviation})) {
902
+			$this->{$class_abbreviation} = null;
903
+			return true;
904
+		}
905
+		if (isset($this->{$class_name})) {
906
+			$this->{$class_name} = null;
907
+			return true;
908
+		}
909
+		if (isset($this->LIB->{$class_name})) {
910
+			unset($this->LIB->{$class_name});
911
+			return true;
912
+		}
913
+		if ($addon && isset($this->addons->{$class_name})) {
914
+			unset($this->addons->{$class_name});
915
+			return true;
916
+		}
917
+		return false;
918
+	}
919
+
920
+
921
+
922
+	/**
923
+	 * attempts to find a full valid filepath for the requested class.
924
+	 * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
925
+	 * then returns that path if the target file has been found and is readable
926
+	 *
927
+	 * @param string $class_name
928
+	 * @param string $type
929
+	 * @param array  $file_paths
930
+	 * @return string | bool
931
+	 */
932
+	protected function _resolve_path($class_name, $type = '', $file_paths = array())
933
+	{
934
+		// make sure $file_paths is an array
935
+		$file_paths = is_array($file_paths)
936
+			? $file_paths
937
+			: array($file_paths);
938
+		// cycle thru paths
939
+		foreach ($file_paths as $key => $file_path) {
940
+			// convert all separators to proper DS, if no filepath, then use EE_CLASSES
941
+			$file_path = $file_path
942
+				? str_replace(array('/', '\\'), DS, $file_path)
943
+				: EE_CLASSES;
944
+			// prep file type
945
+			$type = ! empty($type)
946
+				? trim($type, '.') . '.'
947
+				: '';
948
+			// build full file path
949
+			$file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
950
+			//does the file exist and can be read ?
951
+			if (is_readable($file_paths[$key])) {
952
+				return $file_paths[$key];
953
+			}
954
+		}
955
+		return false;
956
+	}
957
+
958
+
959
+
960
+	/**
961
+	 * basically just performs a require_once()
962
+	 * but with some error handling
963
+	 *
964
+	 * @param  string $path
965
+	 * @param  string $class_name
966
+	 * @param  string $type
967
+	 * @param  array  $file_paths
968
+	 * @return bool
969
+	 * @throws EE_Error
970
+	 * @throws ReflectionException
971
+	 */
972
+	protected function _require_file($path, $class_name, $type = '', $file_paths = array())
973
+	{
974
+		$this->resolve_legacy_class_parent($class_name);
975
+		// don't give up! you gotta...
976
+		try {
977
+			//does the file exist and can it be read ?
978
+			if (! $path) {
979
+				// so sorry, can't find the file
980
+				throw new EE_Error (
981
+					sprintf(
982
+						esc_html__(
983
+							'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s',
984
+							'event_espresso'
985
+						),
986
+						trim($type, '.'),
987
+						$class_name,
988
+						'<br />' . implode(',<br />', $file_paths)
989
+					)
990
+				);
991
+			}
992
+			// get the file
993
+			require_once($path);
994
+			// if the class isn't already declared somewhere
995
+			if (class_exists($class_name, false) === false) {
996
+				// so sorry, not a class
997
+				throw new EE_Error(
998
+					sprintf(
999
+						esc_html__('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
1000
+						$type,
1001
+						$path,
1002
+						$class_name
1003
+					)
1004
+				);
1005
+			}
1006
+		} catch (EE_Error $e) {
1007
+			$e->get_error();
1008
+			return false;
1009
+		}
1010
+		return true;
1011
+	}
1012
+
1013
+
1014
+
1015
+	/**
1016
+	 * Some of our legacy classes that extended a parent class would simply use a require() statement
1017
+	 * before their class declaration in order to ensure that the parent class was loaded.
1018
+	 * This is not ideal, but it's nearly impossible to determine the parent class of a non-namespaced class,
1019
+	 * without triggering a fatal error because the parent class has yet to be loaded and therefore doesn't exist.
1020
+	 *
1021
+	 * @param string $class_name
1022
+	 */
1023
+	protected function resolve_legacy_class_parent($class_name = '')
1024
+	{
1025
+		try {
1026
+			$legacy_parent_class_map = array(
1027
+				'EE_Payment_Processor' => 'core/business/EE_Processor_Base.class.php'
1028
+			);
1029
+			if(isset($legacy_parent_class_map[$class_name])) {
1030
+				require_once EE_PLUGIN_DIR_PATH . $legacy_parent_class_map[$class_name];
1031
+			}
1032
+		} catch (Exception $exception) {
1033
+		}
1034
+	}
1035
+
1036
+
1037
+
1038
+	/**
1039
+	 * _create_object
1040
+	 * Attempts to instantiate the requested class via any of the
1041
+	 * commonly used instantiation methods employed throughout EE.
1042
+	 * The priority for instantiation is as follows:
1043
+	 *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
1044
+	 *        - model objects via their 'new_instance_from_db' method
1045
+	 *        - model objects via their 'new_instance' method
1046
+	 *        - "singleton" classes" via their 'instance' method
1047
+	 *    - standard instantiable classes via their __constructor
1048
+	 * Prior to instantiation, if the classname exists in the dependency_map,
1049
+	 * then the constructor for the requested class will be examined to determine
1050
+	 * if any dependencies exist, and if they can be injected.
1051
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
1052
+	 *
1053
+	 * @param string $class_name
1054
+	 * @param array  $arguments
1055
+	 * @param string $type
1056
+	 * @param bool   $from_db
1057
+	 * @return null|object
1058
+	 * @throws EE_Error
1059
+	 * @throws ReflectionException
1060
+	 */
1061
+	protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
1062
+	{
1063
+		// create reflection
1064
+		$reflector = $this->get_ReflectionClass($class_name);
1065
+		// make sure arguments are an array
1066
+		$arguments = is_array($arguments)
1067
+			? $arguments
1068
+			: array($arguments);
1069
+		// and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
1070
+		// else wrap it in an additional array so that it doesn't get split into multiple parameters
1071
+		$arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
1072
+			? $arguments
1073
+			: array($arguments);
1074
+		// attempt to inject dependencies ?
1075
+		if ($this->_dependency_map->has($class_name)) {
1076
+			$arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
1077
+		}
1078
+		// instantiate the class if possible
1079
+		if ($reflector->isAbstract()) {
1080
+			// nothing to instantiate, loading file was enough
1081
+			// does not throw an exception so $instantiation_mode is unused
1082
+			// $instantiation_mode = "1) no constructor abstract class";
1083
+			return true;
1084
+		}
1085
+		if (empty($arguments) && $reflector->getConstructor() === null && $reflector->isInstantiable()) {
1086
+			// no constructor = static methods only... nothing to instantiate, loading file was enough
1087
+			// $instantiation_mode = "2) no constructor but instantiable";
1088
+			return $reflector->newInstance();
1089
+		}
1090
+		if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
1091
+			// $instantiation_mode = "3) new_instance_from_db()";
1092
+			return call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
1093
+		}
1094
+		if (method_exists($class_name, 'new_instance')) {
1095
+			// $instantiation_mode = "4) new_instance()";
1096
+			return call_user_func_array(array($class_name, 'new_instance'), $arguments);
1097
+		}
1098
+		if (method_exists($class_name, 'instance')) {
1099
+			// $instantiation_mode = "5) instance()";
1100
+			return call_user_func_array(array($class_name, 'instance'), $arguments);
1101
+		}
1102
+		if ($reflector->isInstantiable()) {
1103
+			// $instantiation_mode = "6) constructor";
1104
+			return $reflector->newInstanceArgs($arguments);
1105
+		}
1106
+		// heh ? something's not right !
1107
+		throw new EE_Error(
1108
+			sprintf(
1109
+				__('The %s file %s could not be instantiated.', 'event_espresso'),
1110
+				$type,
1111
+				$class_name
1112
+			)
1113
+		);
1114
+	}
1115
+
1116
+
1117
+
1118
+	/**
1119
+	 * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
1120
+	 * @param array $array
1121
+	 * @return bool
1122
+	 */
1123
+	protected function _array_is_numerically_and_sequentially_indexed(array $array)
1124
+	{
1125
+		return ! empty($array)
1126
+			? array_keys($array) === range(0, count($array) - 1)
1127
+			: true;
1128
+	}
1129
+
1130
+
1131
+
1132
+	/**
1133
+	 * getReflectionClass
1134
+	 * checks if a ReflectionClass object has already been generated for a class
1135
+	 * and returns that instead of creating a new one
1136
+	 *
1137
+	 * @param string $class_name
1138
+	 * @return ReflectionClass
1139
+	 * @throws ReflectionException
1140
+	 */
1141
+	public function get_ReflectionClass($class_name)
1142
+	{
1143
+		if (
1144
+			! isset($this->_reflectors[$class_name])
1145
+			|| ! $this->_reflectors[$class_name] instanceof ReflectionClass
1146
+		) {
1147
+			$this->_reflectors[$class_name] = new ReflectionClass($class_name);
1148
+		}
1149
+		return $this->_reflectors[$class_name];
1150
+	}
1151
+
1152
+
1153
+
1154
+	/**
1155
+	 * _resolve_dependencies
1156
+	 * examines the constructor for the requested class to determine
1157
+	 * if any dependencies exist, and if they can be injected.
1158
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
1159
+	 * PLZ NOTE: this is achieved by type hinting the constructor params
1160
+	 * For example:
1161
+	 *        if attempting to load a class "Foo" with the following constructor:
1162
+	 *        __construct( Bar $bar_class, Fighter $grohl_class )
1163
+	 *        then $bar_class and $grohl_class will be added to the $arguments array,
1164
+	 *        but only IF they are NOT already present in the incoming arguments array,
1165
+	 *        and the correct classes can be loaded
1166
+	 *
1167
+	 * @param ReflectionClass $reflector
1168
+	 * @param string          $class_name
1169
+	 * @param array           $arguments
1170
+	 * @return array
1171
+	 * @throws EE_Error
1172
+	 * @throws ReflectionException
1173
+	 */
1174
+	protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array())
1175
+	{
1176
+		// let's examine the constructor
1177
+		$constructor = $reflector->getConstructor();
1178
+		// whu? huh? nothing?
1179
+		if (! $constructor) {
1180
+			return $arguments;
1181
+		}
1182
+		// get constructor parameters
1183
+		$params = $constructor->getParameters();
1184
+		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
1185
+		$argument_keys = array_keys($arguments);
1186
+		// now loop thru all of the constructors expected parameters
1187
+		foreach ($params as $index => $param) {
1188
+			// is this a dependency for a specific class ?
1189
+			$param_class = $param->getClass()
1190
+				? $param->getClass()->name
1191
+				: null;
1192
+			// BUT WAIT !!! This class may be an alias for something else (or getting replaced at runtime)
1193
+			$param_class = $this->_dependency_map->has_alias($param_class, $class_name)
1194
+				? $this->_dependency_map->get_alias($param_class, $class_name)
1195
+				: $param_class;
1196
+			if (
1197
+				// param is not even a class
1198
+				$param_class === null
1199
+				// and something already exists in the incoming arguments for this param
1200
+				&& array_key_exists($index, $argument_keys)
1201
+				&& array_key_exists($argument_keys[$index], $arguments)
1202
+			) {
1203
+				// so let's skip this argument and move on to the next
1204
+				continue;
1205
+			}
1206
+			if (
1207
+				// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
1208
+				$param_class !== null
1209
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
1210
+				&& $arguments[$argument_keys[$index]] instanceof $param_class
1211
+			) {
1212
+				// skip this argument and move on to the next
1213
+				continue;
1214
+			}
1215
+			if (
1216
+				// parameter is type hinted as a class, and should be injected
1217
+				$param_class !== null
1218
+				&& $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1219
+			) {
1220
+				$arguments = $this->_resolve_dependency(
1221
+					$class_name,
1222
+					$param_class,
1223
+					$arguments,
1224
+					$index,
1225
+					$argument_keys
1226
+				);
1227
+			} else {
1228
+				try {
1229
+					$arguments[$index] = $param->isDefaultValueAvailable()
1230
+						? $param->getDefaultValue()
1231
+						: null;
1232
+				} catch (ReflectionException $e) {
1233
+					throw new ReflectionException(
1234
+						sprintf(
1235
+							esc_html__('%1$s for parameter "$%2$s on classname "%3$s"', 'event_espresso'),
1236
+							$e->getMessage(),
1237
+							$param->getName(),
1238
+							$class_name
1239
+						)
1240
+					);
1241
+				}
1242
+			}
1243
+		}
1244
+		return $arguments;
1245
+	}
1246
+
1247
+
1248
+
1249
+	/**
1250
+	 * @param string $class_name
1251
+	 * @param string $param_class
1252
+	 * @param array  $arguments
1253
+	 * @param mixed  $index
1254
+	 * @param array  $argument_keys
1255
+	 * @return array
1256
+	 * @throws EE_Error
1257
+	 * @throws ReflectionException
1258
+	 * @throws InvalidArgumentException
1259
+	 * @throws InvalidInterfaceException
1260
+	 * @throws InvalidDataTypeException
1261
+	 */
1262
+	protected function _resolve_dependency($class_name, $param_class, $arguments, $index, array $argument_keys)
1263
+	{
1264
+		$dependency = null;
1265
+		// should dependency be loaded from cache ?
1266
+		$cache_on = $this->_dependency_map->loading_strategy_for_class_dependency(
1267
+			$class_name,
1268
+			$param_class
1269
+		);
1270
+		$cache_on = $cache_on !== EE_Dependency_Map::load_new_object;
1271
+		// we might have a dependency...
1272
+		// let's MAYBE try and find it in our cache if that's what's been requested
1273
+		$cached_class = $cache_on
1274
+			? $this->_get_cached_class($param_class)
1275
+			: null;
1276
+		// and grab it if it exists
1277
+		if ($cached_class instanceof $param_class) {
1278
+			$dependency = $cached_class;
1279
+		} else if ($param_class !== $class_name) {
1280
+			// obtain the loader method from the dependency map
1281
+			$loader = $this->_dependency_map->class_loader($param_class);
1282
+			// is loader a custom closure ?
1283
+			if ($loader instanceof Closure) {
1284
+				$dependency = $loader($arguments);
1285
+			} else {
1286
+				// set the cache on property for the recursive loading call
1287
+				$this->_cache_on = $cache_on;
1288
+				// if not, then let's try and load it via the registry
1289
+				if ($loader && method_exists($this, $loader)) {
1290
+					$dependency = $this->{$loader}($param_class);
1291
+				} else {
1292
+					$dependency = LoaderFactory::getLoader()->load(
1293
+						$param_class,
1294
+						array(),
1295
+						$cache_on
1296
+					);
1297
+				}
1298
+			}
1299
+		}
1300
+		// did we successfully find the correct dependency ?
1301
+		if ($dependency instanceof $param_class) {
1302
+			// then let's inject it into the incoming array of arguments at the correct location
1303
+			$arguments[$index] = $dependency;
1304
+		}
1305
+		return $arguments;
1306
+	}
1307
+
1308
+
1309
+
1310
+	/**
1311
+	 * _set_cached_class
1312
+	 * attempts to cache the instantiated class locally
1313
+	 * in one of the following places, in the following order:
1314
+	 *        $this->{class_abbreviation}   ie:    $this->CART
1315
+	 *        $this->{$class_name}          ie:    $this->Some_Class
1316
+	 *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1317
+	 *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1318
+	 *
1319
+	 * @param object $class_obj
1320
+	 * @param string $class_name
1321
+	 * @param string $class_prefix
1322
+	 * @param bool   $from_db
1323
+	 * @return void
1324
+	 */
1325
+	protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false)
1326
+	{
1327
+		if ($class_name === 'EE_Registry' || empty($class_obj)) {
1328
+			return;
1329
+		}
1330
+		// return newly instantiated class
1331
+		$class_abbreviation = $this->get_class_abbreviation($class_name, '');
1332
+		if ($class_abbreviation) {
1333
+			$this->{$class_abbreviation} = $class_obj;
1334
+			return;
1335
+		}
1336
+		$class_name = str_replace('\\', '_', $class_name);
1337
+		if (property_exists($this, $class_name)) {
1338
+			$this->{$class_name} = $class_obj;
1339
+			return;
1340
+		}
1341
+		if ($class_prefix === 'addon') {
1342
+			$this->addons->{$class_name} = $class_obj;
1343
+			return;
1344
+		}
1345
+		if (! $from_db) {
1346
+			$this->LIB->{$class_name} = $class_obj;
1347
+		}
1348
+	}
1349
+
1350
+
1351
+
1352
+	/**
1353
+	 * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1354
+	 *
1355
+	 * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1356
+	 *                          in the EE_Dependency_Map::$_class_loaders array,
1357
+	 *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1358
+	 * @param array  $arguments
1359
+	 * @return object
1360
+	 */
1361
+	public static function factory($classname, $arguments = array())
1362
+	{
1363
+		$loader = self::instance()->_dependency_map->class_loader($classname);
1364
+		if ($loader instanceof Closure) {
1365
+			return $loader($arguments);
1366
+		}
1367
+		if (method_exists(self::instance(), $loader)) {
1368
+			return self::instance()->{$loader}($classname, $arguments);
1369
+		}
1370
+		return null;
1371
+	}
1372
+
1373
+
1374
+
1375
+	/**
1376
+	 * Gets the addon by its name/slug (not classname. For that, just
1377
+	 * use the classname as the property name on EE_Config::instance()->addons)
1378
+	 *
1379
+	 * @param string $name
1380
+	 * @return EE_Addon
1381
+	 */
1382
+	public function get_addon_by_name($name)
1383
+	{
1384
+		foreach ($this->addons as $addon) {
1385
+			if ($addon->name() === $name) {
1386
+				return $addon;
1387
+			}
1388
+		}
1389
+		return null;
1390
+	}
1391
+
1392
+
1393
+
1394
+	/**
1395
+	 * Gets an array of all the registered addons, where the keys are their names. (ie, what each returns for their
1396
+	 * name() function) They're already available on EE_Config::instance()->addons as properties, where each property's
1397
+	 * name is the addon's classname. So if you just want to get the addon by classname, use
1398
+	 * EE_Config::instance()->addons->{classname}
1399
+	 *
1400
+	 * @return EE_Addon[] where the KEYS are the addon's name()
1401
+	 */
1402
+	public function get_addons_by_name()
1403
+	{
1404
+		$addons = array();
1405
+		foreach ($this->addons as $addon) {
1406
+			$addons[$addon->name()] = $addon;
1407
+		}
1408
+		return $addons;
1409
+	}
1410
+
1411
+
1412
+
1413
+	/**
1414
+	 * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1415
+	 * a stale copy of it around
1416
+	 *
1417
+	 * @param string $model_name
1418
+	 * @return \EEM_Base
1419
+	 * @throws \EE_Error
1420
+	 */
1421
+	public function reset_model($model_name)
1422
+	{
1423
+		$model_class_name = strpos($model_name, 'EEM_') !== 0
1424
+			? "EEM_{$model_name}"
1425
+			: $model_name;
1426
+		if (! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1427
+			return null;
1428
+		}
1429
+		//get that model reset it and make sure we nuke the old reference to it
1430
+		if ($this->LIB->{$model_class_name} instanceof $model_class_name
1431
+			&& is_callable(
1432
+				array($model_class_name, 'reset')
1433
+			)) {
1434
+			$this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1435
+		} else {
1436
+			throw new EE_Error(sprintf(esc_html__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1437
+		}
1438
+		return $this->LIB->{$model_class_name};
1439
+	}
1440
+
1441
+
1442
+
1443
+	/**
1444
+	 * Resets the registry.
1445
+	 * The criteria for what gets reset is based on what can be shared between sites on the same request when
1446
+	 * switch_to_blog is used in a multisite install.  Here is a list of things that are NOT reset.
1447
+	 * - $_dependency_map
1448
+	 * - $_class_abbreviations
1449
+	 * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1450
+	 * - $REQ:  Still on the same request so no need to change.
1451
+	 * - $CAP: There is no site specific state in the EE_Capability class.
1452
+	 * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only
1453
+	 * one Session can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1454
+	 * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1455
+	 *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1456
+	 *             switch or on the restore.
1457
+	 * - $modules
1458
+	 * - $shortcodes
1459
+	 * - $widgets
1460
+	 *
1461
+	 * @param boolean $hard             [deprecated]
1462
+	 * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1463
+	 *                                  or just reset without re-instantiating (handy to set to FALSE if you're not
1464
+	 *                                  sure if you CAN currently reinstantiate the singletons at the moment)
1465
+	 * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so
1466
+	 *                                  client
1467
+	 *                                  code instead can just change the model context to a different blog id if
1468
+	 *                                  necessary
1469
+	 * @return EE_Registry
1470
+	 * @throws EE_Error
1471
+	 * @throws ReflectionException
1472
+	 */
1473
+	public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1474
+	{
1475
+		$instance = self::instance();
1476
+		$instance->_cache_on = true;
1477
+		// reset some "special" classes
1478
+		EEH_Activation::reset();
1479
+		$hard = apply_filters( 'FHEE__EE_Registry__reset__hard', $hard);
1480
+		$instance->CFG = EE_Config::reset($hard, $reinstantiate);
1481
+		$instance->CART = null;
1482
+		$instance->MRM = null;
1483
+		$instance->AssetsRegistry = $instance->create('EventEspresso\core\services\assets\Registry');
1484
+		//messages reset
1485
+		EED_Messages::reset();
1486
+		//handle of objects cached on LIB
1487
+		foreach (array('LIB', 'modules') as $cache) {
1488
+			foreach ($instance->{$cache} as $class_name => $class) {
1489
+				if (self::_reset_and_unset_object($class, $reset_models)) {
1490
+					unset($instance->{$cache}->{$class_name});
1491
+				}
1492
+			}
1493
+		}
1494
+		return $instance;
1495
+	}
1496
+
1497
+
1498
+
1499
+	/**
1500
+	 * if passed object implements ResettableInterface, then call it's reset() method
1501
+	 * if passed object implements InterminableInterface, then return false,
1502
+	 * to indicate that it should NOT be cleared from the Registry cache
1503
+	 *
1504
+	 * @param      $object
1505
+	 * @param bool $reset_models
1506
+	 * @return bool returns true if cached object should be unset
1507
+	 */
1508
+	private static function _reset_and_unset_object($object, $reset_models)
1509
+	{
1510
+		if (! is_object($object)) {
1511
+			// don't unset anything that's not an object
1512
+			return false;
1513
+		}
1514
+		if ($object instanceof EED_Module) {
1515
+			$object::reset();
1516
+			// don't unset modules
1517
+			return false;
1518
+		}
1519
+		if ($object instanceof ResettableInterface) {
1520
+			if ($object instanceof EEM_Base) {
1521
+				if ($reset_models) {
1522
+					$object->reset();
1523
+					return true;
1524
+				}
1525
+				return false;
1526
+			}
1527
+			$object->reset();
1528
+			return true;
1529
+		}
1530
+		if (! $object instanceof InterminableInterface) {
1531
+			return true;
1532
+		}
1533
+		return false;
1534
+	}
1535
+
1536
+
1537
+
1538
+	/**
1539
+	 * Gets all the custom post type models defined
1540
+	 *
1541
+	 * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1542
+	 */
1543
+	public function cpt_models()
1544
+	{
1545
+		$cpt_models = array();
1546
+		foreach ($this->non_abstract_db_models as $short_name => $classname) {
1547
+			if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1548
+				$cpt_models[$short_name] = $classname;
1549
+			}
1550
+		}
1551
+		return $cpt_models;
1552
+	}
1553
+
1554
+
1555
+
1556
+	/**
1557
+	 * @return \EE_Config
1558
+	 */
1559
+	public static function CFG()
1560
+	{
1561
+		return self::instance()->CFG;
1562
+	}
1563 1563
 
1564 1564
 
1565 1565
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     public static function instance(EE_Dependency_Map $dependency_map = null)
177 177
     {
178 178
         // check if class object is instantiated
179
-        if (! self::$_instance instanceof EE_Registry) {
179
+        if ( ! self::$_instance instanceof EE_Registry) {
180 180
             self::$_instance = new self($dependency_map);
181 181
         }
182 182
         return self::$_instance;
@@ -266,13 +266,13 @@  discard block
 block discarded – undo
266 266
      */
267 267
     public static function localize_i18n_js_strings()
268 268
     {
269
-        $i18n_js_strings = (array)self::$i18n_js_strings;
269
+        $i18n_js_strings = (array) self::$i18n_js_strings;
270 270
         foreach ($i18n_js_strings as $key => $value) {
271 271
             if (is_scalar($value)) {
272
-                $i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
272
+                $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
273 273
             }
274 274
         }
275
-        return '/* <![CDATA[ */ var eei18n = ' . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
275
+        return '/* <![CDATA[ */ var eei18n = '.wp_json_encode($i18n_js_strings).'; /* ]]> */';
276 276
     }
277 277
 
278 278
 
@@ -328,10 +328,10 @@  discard block
 block discarded – undo
328 328
                 EE_CORE,
329 329
                 EE_ADMIN,
330 330
                 EE_CPTS,
331
-                EE_CORE . 'data_migration_scripts' . DS,
332
-                EE_CORE . 'capabilities' . DS,
333
-                EE_CORE . 'request_stack' . DS,
334
-                EE_CORE . 'middleware' . DS,
331
+                EE_CORE.'data_migration_scripts'.DS,
332
+                EE_CORE.'capabilities'.DS,
333
+                EE_CORE.'request_stack'.DS,
334
+                EE_CORE.'middleware'.DS,
335 335
             )
336 336
         );
337 337
         // retrieve instantiated class
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
         $service_paths = apply_filters(
365 365
             'FHEE__EE_Registry__load_service__service_paths',
366 366
             array(
367
-                EE_CORE . 'services' . DS,
367
+                EE_CORE.'services'.DS,
368 368
             )
369 369
         );
370 370
         // retrieve instantiated class
@@ -490,11 +490,11 @@  discard block
 block discarded – undo
490 490
     {
491 491
         $paths = array(
492 492
             EE_LIBRARIES,
493
-            EE_LIBRARIES . 'messages' . DS,
494
-            EE_LIBRARIES . 'shortcodes' . DS,
495
-            EE_LIBRARIES . 'qtips' . DS,
496
-            EE_LIBRARIES . 'payment_methods' . DS,
497
-            EE_LIBRARIES . 'messages' . DS . 'defaults' . DS,
493
+            EE_LIBRARIES.'messages'.DS,
494
+            EE_LIBRARIES.'shortcodes'.DS,
495
+            EE_LIBRARIES.'qtips'.DS,
496
+            EE_LIBRARIES.'payment_methods'.DS,
497
+            EE_LIBRARIES.'messages'.DS.'defaults'.DS,
498 498
         );
499 499
         // retrieve instantiated class
500 500
         return $this->_load(
@@ -557,10 +557,10 @@  discard block
 block discarded – undo
557 557
     public function load_model_class($class_name, $arguments = array(), $load_only = true)
558 558
     {
559 559
         $paths = array(
560
-            EE_MODELS . 'fields' . DS,
561
-            EE_MODELS . 'helpers' . DS,
562
-            EE_MODELS . 'relations' . DS,
563
-            EE_MODELS . 'strategies' . DS,
560
+            EE_MODELS.'fields'.DS,
561
+            EE_MODELS.'helpers'.DS,
562
+            EE_MODELS.'relations'.DS,
563
+            EE_MODELS.'strategies'.DS,
564 564
         );
565 565
         // retrieve instantiated class
566 566
         return $this->_load(
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
         $class_exists = $this->loadOrVerifyClassExists($class_name, $arguments);
680 680
         // if a non-FQCN was passed, then verifyClassExists() might return an object
681 681
         // or it could return null if the class just could not be found anywhere
682
-        if ($class_exists instanceof $class_name || $class_exists === null){
682
+        if ($class_exists instanceof $class_name || $class_exists === null) {
683 683
             // either way, return the results
684 684
             return $class_exists;
685 685
         }
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
             case 1:
738 738
                 // if it's a FQCN then maybe the class is registered with a preceding \
739 739
                 $class_name = strpos($class_name, '\\') !== false
740
-                    ? '\\' . ltrim($class_name, '\\')
740
+                    ? '\\'.ltrim($class_name, '\\')
741 741
                     : $class_name;
742 742
                 break;
743 743
             case 2:
@@ -789,11 +789,11 @@  discard block
 block discarded – undo
789 789
         // strip php file extension
790 790
         $class_name = str_replace('.php', '', trim($class_name));
791 791
         // does the class have a prefix ?
792
-        if (! empty($class_prefix) && $class_prefix !== 'addon') {
792
+        if ( ! empty($class_prefix) && $class_prefix !== 'addon') {
793 793
             // make sure $class_prefix is uppercase
794 794
             $class_prefix = strtoupper(trim($class_prefix));
795 795
             // add class prefix ONCE!!!
796
-            $class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
796
+            $class_name = $class_prefix.str_replace($class_prefix, '', $class_name);
797 797
         }
798 798
         $class_name = $this->_dependency_map->get_alias($class_name);
799 799
         $class_exists = class_exists($class_name, false);
@@ -812,13 +812,13 @@  discard block
 block discarded – undo
812 812
             }
813 813
         }
814 814
         // if the class doesn't already exist.. then we need to try and find the file and load it
815
-        if (! $class_exists) {
815
+        if ( ! $class_exists) {
816 816
             // get full path to file
817 817
             $path = $this->_resolve_path($class_name, $type, $file_paths);
818 818
             // load the file
819 819
             $loaded = $this->_require_file($path, $class_name, $type, $file_paths);
820 820
             // if loading failed, or we are only loading a file but NOT instantiating an object
821
-            if (! $loaded || $load_only) {
821
+            if ( ! $loaded || $load_only) {
822 822
                 // return boolean if only loading, or null if an object was expected
823 823
                 return $load_only
824 824
                     ? $loaded
@@ -943,10 +943,10 @@  discard block
 block discarded – undo
943 943
                 : EE_CLASSES;
944 944
             // prep file type
945 945
             $type = ! empty($type)
946
-                ? trim($type, '.') . '.'
946
+                ? trim($type, '.').'.'
947 947
                 : '';
948 948
             // build full file path
949
-            $file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
949
+            $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php';
950 950
             //does the file exist and can be read ?
951 951
             if (is_readable($file_paths[$key])) {
952 952
                 return $file_paths[$key];
@@ -975,9 +975,9 @@  discard block
 block discarded – undo
975 975
         // don't give up! you gotta...
976 976
         try {
977 977
             //does the file exist and can it be read ?
978
-            if (! $path) {
978
+            if ( ! $path) {
979 979
                 // so sorry, can't find the file
980
-                throw new EE_Error (
980
+                throw new EE_Error(
981 981
                     sprintf(
982 982
                         esc_html__(
983 983
                             'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s',
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
                         ),
986 986
                         trim($type, '.'),
987 987
                         $class_name,
988
-                        '<br />' . implode(',<br />', $file_paths)
988
+                        '<br />'.implode(',<br />', $file_paths)
989 989
                     )
990 990
                 );
991 991
             }
@@ -1026,8 +1026,8 @@  discard block
 block discarded – undo
1026 1026
             $legacy_parent_class_map = array(
1027 1027
                 'EE_Payment_Processor' => 'core/business/EE_Processor_Base.class.php'
1028 1028
             );
1029
-            if(isset($legacy_parent_class_map[$class_name])) {
1030
-                require_once EE_PLUGIN_DIR_PATH . $legacy_parent_class_map[$class_name];
1029
+            if (isset($legacy_parent_class_map[$class_name])) {
1030
+                require_once EE_PLUGIN_DIR_PATH.$legacy_parent_class_map[$class_name];
1031 1031
             }
1032 1032
         } catch (Exception $exception) {
1033 1033
         }
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
         // let's examine the constructor
1177 1177
         $constructor = $reflector->getConstructor();
1178 1178
         // whu? huh? nothing?
1179
-        if (! $constructor) {
1179
+        if ( ! $constructor) {
1180 1180
             return $arguments;
1181 1181
         }
1182 1182
         // get constructor parameters
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
             $this->addons->{$class_name} = $class_obj;
1343 1343
             return;
1344 1344
         }
1345
-        if (! $from_db) {
1345
+        if ( ! $from_db) {
1346 1346
             $this->LIB->{$class_name} = $class_obj;
1347 1347
         }
1348 1348
     }
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
         $model_class_name = strpos($model_name, 'EEM_') !== 0
1424 1424
             ? "EEM_{$model_name}"
1425 1425
             : $model_name;
1426
-        if (! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1426
+        if ( ! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1427 1427
             return null;
1428 1428
         }
1429 1429
         //get that model reset it and make sure we nuke the old reference to it
@@ -1476,7 +1476,7 @@  discard block
 block discarded – undo
1476 1476
         $instance->_cache_on = true;
1477 1477
         // reset some "special" classes
1478 1478
         EEH_Activation::reset();
1479
-        $hard = apply_filters( 'FHEE__EE_Registry__reset__hard', $hard);
1479
+        $hard = apply_filters('FHEE__EE_Registry__reset__hard', $hard);
1480 1480
         $instance->CFG = EE_Config::reset($hard, $reinstantiate);
1481 1481
         $instance->CART = null;
1482 1482
         $instance->MRM = null;
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
      */
1508 1508
     private static function _reset_and_unset_object($object, $reset_models)
1509 1509
     {
1510
-        if (! is_object($object)) {
1510
+        if ( ! is_object($object)) {
1511 1511
             // don't unset anything that's not an object
1512 1512
             return false;
1513 1513
         }
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
             $object->reset();
1528 1528
             return true;
1529 1529
         }
1530
-        if (! $object instanceof InterminableInterface) {
1530
+        if ( ! $object instanceof InterminableInterface) {
1531 1531
             return true;
1532 1532
         }
1533 1533
         return false;
Please login to merge, or discard this patch.
core/domain/services/factories/EmailAddressFactory.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -23,21 +23,21 @@
 block discarded – undo
23 23
 class EmailAddressFactory implements FactoryInterface
24 24
 {
25 25
 
26
-    /**
27
-     * @param string $email_address
28
-     * @return EmailAddress
29
-     * @throws EmailValidationException
30
-     * @throws InvalidDataTypeException
31
-     * @throws InvalidInterfaceException
32
-     * @throws InvalidArgumentException
33
-     */
34
-    public static function create($email_address)
35
-    {
36
-        return LoaderFactory::getLoader()->getNew(
37
-            'EventEspresso\core\domain\values\EmailAddress',
38
-            array($email_address)
39
-        );
40
-    }
26
+	/**
27
+	 * @param string $email_address
28
+	 * @return EmailAddress
29
+	 * @throws EmailValidationException
30
+	 * @throws InvalidDataTypeException
31
+	 * @throws InvalidInterfaceException
32
+	 * @throws InvalidArgumentException
33
+	 */
34
+	public static function create($email_address)
35
+	{
36
+		return LoaderFactory::getLoader()->getNew(
37
+			'EventEspresso\core\domain\values\EmailAddress',
38
+			array($email_address)
39
+		);
40
+	}
41 41
 
42 42
 }
43 43
 // Location: core/domain/services/factories/EmailAddressFactory.php
Please login to merge, or discard this patch.
core/db_models/EEM_Transaction.model.php 2 patches
Indentation   +363 added lines, -363 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('No direct script access allowed');
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 require_once(EE_MODELS . 'EEM_Base.model.php');
7 7
 
@@ -17,193 +17,193 @@  discard block
 block discarded – undo
17 17
 class EEM_Transaction extends EEM_Base
18 18
 {
19 19
 
20
-    // private instance of the Transaction object
21
-    protected static $_instance;
22
-
23
-    /**
24
-     * Status ID(STS_ID on esp_status table) to indicate the transaction is complete,
25
-     * but payment is pending. This is the state for transactions where payment is promised
26
-     * from an offline gateway.
27
-     */
28
-    //	const open_status_code = 'TPN';
29
-
30
-    /**
31
-     * Status ID(STS_ID on esp_status table) to indicate the transaction failed,
32
-     * either due to a technical reason (server or computer crash during registration),
33
-     *  or some other reason that prevent the collection of any useful contact information from any of the registrants
34
-     */
35
-    const failed_status_code = 'TFL';
36
-
37
-    /**
38
-     * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned,
39
-     * either due to a technical reason (server or computer crash during registration),
40
-     * or due to an abandoned cart after registrant chose not to complete the registration process
41
-     * HOWEVER...
42
-     * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one
43
-     * registrant
44
-     */
45
-    const abandoned_status_code = 'TAB';
46
-
47
-    /**
48
-     * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction,
49
-     * meaning that monies are still owing: TXN_paid < TXN_total
50
-     */
51
-    const incomplete_status_code = 'TIN';
52
-
53
-    /**
54
-     * Status ID (STS_ID on esp_status table) to indicate a complete transaction.
55
-     * meaning that NO monies are owing: TXN_paid == TXN_total
56
-     */
57
-    const complete_status_code = 'TCM';
58
-
59
-    /**
60
-     *  Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid.
61
-     *  This is the same as complete, but site admins actually owe clients the moneys!  TXN_paid > TXN_total
62
-     */
63
-    const overpaid_status_code = 'TOP';
64
-
65
-
66
-    /**
67
-     *    private constructor to prevent direct creation
68
-     *
69
-     * @Constructor
70
-     * @access protected
71
-     *
72
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
73
-     *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
74
-     *                         date time model field objects.  Default is NULL (and will be assumed using the set
75
-     *                         timezone in the 'timezone_string' wp option)
76
-     *
77
-     * @return EEM_Transaction
78
-     * @throws \EE_Error
79
-     */
80
-    protected function __construct($timezone)
81
-    {
82
-        $this->singular_item = __('Transaction', 'event_espresso');
83
-        $this->plural_item   = __('Transactions', 'event_espresso');
84
-
85
-        $this->_tables                 = array(
86
-            'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID')
87
-        );
88
-        $this->_fields                 = array(
89
-            'TransactionTable' => array(
90
-                'TXN_ID'           => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')),
91
-                'TXN_timestamp'    => new EE_Datetime_Field('TXN_timestamp',
92
-                    __('date when transaction was created', 'event_espresso'), false, EE_Datetime_Field::now,
93
-                    $timezone),
94
-                'TXN_total'        => new EE_Money_Field('TXN_total',
95
-                    __('Total value of Transaction', 'event_espresso'), false, 0),
96
-                'TXN_paid'         => new EE_Money_Field('TXN_paid',
97
-                    __('Amount paid towards transaction to date', 'event_espresso'), false, 0),
98
-                'STS_ID'           => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'),
99
-                    false, EEM_Transaction::failed_status_code, 'Status'),
100
-                'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data',
101
-                    __('Serialized session data', 'event_espresso'), true, ''),
102
-                'TXN_hash_salt'    => new EE_Plain_Text_Field('TXN_hash_salt',
103
-                    __('Transaction Hash Salt', 'event_espresso'), true, ''),
104
-                'PMD_ID'           => new EE_Foreign_Key_Int_Field('PMD_ID',
105
-                    __("Last Used Payment Method", 'event_espresso'), true, null, 'Payment_Method'),
106
-                'TXN_reg_steps'    => new EE_Serialized_Text_Field('TXN_reg_steps',
107
-                    __('Registration Steps', 'event_espresso'), false, array()),
108
-            )
109
-        );
110
-        $this->_model_relations        = array(
111
-            'Registration'   => new EE_Has_Many_Relation(),
112
-            'Payment'        => new EE_Has_Many_Relation(),
113
-            'Status'         => new EE_Belongs_To_Relation(),
114
-            'Line_Item'      => new EE_Has_Many_Relation(false),
115
-            //you can delete a transaction without needing to delete its line items
116
-            'Payment_Method' => new EE_Belongs_To_Relation(),
117
-            'Message'        => new EE_Has_Many_Relation()
118
-        );
119
-        $this->_model_chain_to_wp_user = 'Registration.Event';
120
-        parent::__construct($timezone);
121
-
122
-    }
123
-
124
-
125
-    /**
126
-     *    txn_status_array
127
-     * get list of transaction statuses
128
-     *
129
-     * @access public
130
-     * @return array
131
-     */
132
-    public static function txn_status_array()
133
-    {
134
-        return apply_filters(
135
-            'FHEE__EEM_Transaction__txn_status_array',
136
-            array(
137
-                EEM_Transaction::overpaid_status_code,
138
-                EEM_Transaction::complete_status_code,
139
-                EEM_Transaction::incomplete_status_code,
140
-                EEM_Transaction::abandoned_status_code,
141
-                EEM_Transaction::failed_status_code,
142
-            )
143
-        );
144
-    }
145
-
146
-    /**
147
-     *        get the revenue per day  for the Transaction Admin page Reports Tab
148
-     *
149
-     * @access        public
150
-     *
151
-     * @param string $period
152
-     *
153
-     * @return \stdClass[]
154
-     */
155
-    public function get_revenue_per_day_report($period = '-1 month')
156
-    {
157
-        $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)),
158
-            'Y-m-d H:i:s', 'UTC');
159
-
160
-        $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp');
161
-
162
-        return $this->_get_all_wpdb_results(
163
-            array(
164
-                array(
165
-                    'TXN_timestamp' => array('>=', $sql_date)
166
-                ),
167
-                'group_by' => 'txnDate',
168
-                'order_by' => array('TXN_timestamp' => 'ASC')
169
-            ),
170
-            OBJECT,
171
-            array(
172
-                'txnDate' => array('DATE(' . $query_interval . ')', '%s'),
173
-                'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d')
174
-            )
175
-        );
176
-    }
177
-
178
-
179
-    /**
180
-     *        get the revenue per event  for the Transaction Admin page Reports Tab
181
-     *
182
-     * @access        public
183
-     *
184
-     * @param string $period
185
-     *
186
-     * @throws \EE_Error
187
-     * @return mixed
188
-     */
189
-    public function get_revenue_per_event_report($period = '-1 month')
190
-    {
191
-        global $wpdb;
192
-        $transaction_table          = $wpdb->prefix . 'esp_transaction';
193
-        $registration_table         = $wpdb->prefix . 'esp_registration';
194
-        $registration_payment_table = $wpdb->prefix . 'esp_registration_payment';
195
-        $event_table                = $wpdb->posts;
196
-        $payment_table              = $wpdb->prefix . 'esp_payment';
197
-        $sql_date                   = date('Y-m-d H:i:s', strtotime($period));
198
-        $approved_payment_status    = EEM_Payment::status_id_approved;
199
-        $extra_event_on_join        = '';
200
-        //exclude events not authored by user if permissions in effect
201
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
202
-            $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
203
-        }
204
-
205
-        return $wpdb->get_results(
206
-            "SELECT
20
+	// private instance of the Transaction object
21
+	protected static $_instance;
22
+
23
+	/**
24
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction is complete,
25
+	 * but payment is pending. This is the state for transactions where payment is promised
26
+	 * from an offline gateway.
27
+	 */
28
+	//	const open_status_code = 'TPN';
29
+
30
+	/**
31
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction failed,
32
+	 * either due to a technical reason (server or computer crash during registration),
33
+	 *  or some other reason that prevent the collection of any useful contact information from any of the registrants
34
+	 */
35
+	const failed_status_code = 'TFL';
36
+
37
+	/**
38
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned,
39
+	 * either due to a technical reason (server or computer crash during registration),
40
+	 * or due to an abandoned cart after registrant chose not to complete the registration process
41
+	 * HOWEVER...
42
+	 * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one
43
+	 * registrant
44
+	 */
45
+	const abandoned_status_code = 'TAB';
46
+
47
+	/**
48
+	 * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction,
49
+	 * meaning that monies are still owing: TXN_paid < TXN_total
50
+	 */
51
+	const incomplete_status_code = 'TIN';
52
+
53
+	/**
54
+	 * Status ID (STS_ID on esp_status table) to indicate a complete transaction.
55
+	 * meaning that NO monies are owing: TXN_paid == TXN_total
56
+	 */
57
+	const complete_status_code = 'TCM';
58
+
59
+	/**
60
+	 *  Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid.
61
+	 *  This is the same as complete, but site admins actually owe clients the moneys!  TXN_paid > TXN_total
62
+	 */
63
+	const overpaid_status_code = 'TOP';
64
+
65
+
66
+	/**
67
+	 *    private constructor to prevent direct creation
68
+	 *
69
+	 * @Constructor
70
+	 * @access protected
71
+	 *
72
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
73
+	 *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
74
+	 *                         date time model field objects.  Default is NULL (and will be assumed using the set
75
+	 *                         timezone in the 'timezone_string' wp option)
76
+	 *
77
+	 * @return EEM_Transaction
78
+	 * @throws \EE_Error
79
+	 */
80
+	protected function __construct($timezone)
81
+	{
82
+		$this->singular_item = __('Transaction', 'event_espresso');
83
+		$this->plural_item   = __('Transactions', 'event_espresso');
84
+
85
+		$this->_tables                 = array(
86
+			'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID')
87
+		);
88
+		$this->_fields                 = array(
89
+			'TransactionTable' => array(
90
+				'TXN_ID'           => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')),
91
+				'TXN_timestamp'    => new EE_Datetime_Field('TXN_timestamp',
92
+					__('date when transaction was created', 'event_espresso'), false, EE_Datetime_Field::now,
93
+					$timezone),
94
+				'TXN_total'        => new EE_Money_Field('TXN_total',
95
+					__('Total value of Transaction', 'event_espresso'), false, 0),
96
+				'TXN_paid'         => new EE_Money_Field('TXN_paid',
97
+					__('Amount paid towards transaction to date', 'event_espresso'), false, 0),
98
+				'STS_ID'           => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'),
99
+					false, EEM_Transaction::failed_status_code, 'Status'),
100
+				'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data',
101
+					__('Serialized session data', 'event_espresso'), true, ''),
102
+				'TXN_hash_salt'    => new EE_Plain_Text_Field('TXN_hash_salt',
103
+					__('Transaction Hash Salt', 'event_espresso'), true, ''),
104
+				'PMD_ID'           => new EE_Foreign_Key_Int_Field('PMD_ID',
105
+					__("Last Used Payment Method", 'event_espresso'), true, null, 'Payment_Method'),
106
+				'TXN_reg_steps'    => new EE_Serialized_Text_Field('TXN_reg_steps',
107
+					__('Registration Steps', 'event_espresso'), false, array()),
108
+			)
109
+		);
110
+		$this->_model_relations        = array(
111
+			'Registration'   => new EE_Has_Many_Relation(),
112
+			'Payment'        => new EE_Has_Many_Relation(),
113
+			'Status'         => new EE_Belongs_To_Relation(),
114
+			'Line_Item'      => new EE_Has_Many_Relation(false),
115
+			//you can delete a transaction without needing to delete its line items
116
+			'Payment_Method' => new EE_Belongs_To_Relation(),
117
+			'Message'        => new EE_Has_Many_Relation()
118
+		);
119
+		$this->_model_chain_to_wp_user = 'Registration.Event';
120
+		parent::__construct($timezone);
121
+
122
+	}
123
+
124
+
125
+	/**
126
+	 *    txn_status_array
127
+	 * get list of transaction statuses
128
+	 *
129
+	 * @access public
130
+	 * @return array
131
+	 */
132
+	public static function txn_status_array()
133
+	{
134
+		return apply_filters(
135
+			'FHEE__EEM_Transaction__txn_status_array',
136
+			array(
137
+				EEM_Transaction::overpaid_status_code,
138
+				EEM_Transaction::complete_status_code,
139
+				EEM_Transaction::incomplete_status_code,
140
+				EEM_Transaction::abandoned_status_code,
141
+				EEM_Transaction::failed_status_code,
142
+			)
143
+		);
144
+	}
145
+
146
+	/**
147
+	 *        get the revenue per day  for the Transaction Admin page Reports Tab
148
+	 *
149
+	 * @access        public
150
+	 *
151
+	 * @param string $period
152
+	 *
153
+	 * @return \stdClass[]
154
+	 */
155
+	public function get_revenue_per_day_report($period = '-1 month')
156
+	{
157
+		$sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)),
158
+			'Y-m-d H:i:s', 'UTC');
159
+
160
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp');
161
+
162
+		return $this->_get_all_wpdb_results(
163
+			array(
164
+				array(
165
+					'TXN_timestamp' => array('>=', $sql_date)
166
+				),
167
+				'group_by' => 'txnDate',
168
+				'order_by' => array('TXN_timestamp' => 'ASC')
169
+			),
170
+			OBJECT,
171
+			array(
172
+				'txnDate' => array('DATE(' . $query_interval . ')', '%s'),
173
+				'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d')
174
+			)
175
+		);
176
+	}
177
+
178
+
179
+	/**
180
+	 *        get the revenue per event  for the Transaction Admin page Reports Tab
181
+	 *
182
+	 * @access        public
183
+	 *
184
+	 * @param string $period
185
+	 *
186
+	 * @throws \EE_Error
187
+	 * @return mixed
188
+	 */
189
+	public function get_revenue_per_event_report($period = '-1 month')
190
+	{
191
+		global $wpdb;
192
+		$transaction_table          = $wpdb->prefix . 'esp_transaction';
193
+		$registration_table         = $wpdb->prefix . 'esp_registration';
194
+		$registration_payment_table = $wpdb->prefix . 'esp_registration_payment';
195
+		$event_table                = $wpdb->posts;
196
+		$payment_table              = $wpdb->prefix . 'esp_payment';
197
+		$sql_date                   = date('Y-m-d H:i:s', strtotime($period));
198
+		$approved_payment_status    = EEM_Payment::status_id_approved;
199
+		$extra_event_on_join        = '';
200
+		//exclude events not authored by user if permissions in effect
201
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
202
+			$extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
203
+		}
204
+
205
+		return $wpdb->get_results(
206
+			"SELECT
207 207
 			Transaction_Event.event_name AS event_name,
208 208
 			SUM(Transaction_Event.paid) AS revenue
209 209
 			FROM
@@ -230,185 +230,185 @@  discard block
 block discarded – undo
230 230
 					$extra_event_on_join
231 231
 				) AS Transaction_Event
232 232
 			GROUP BY event_name",
233
-            OBJECT
234
-        );
235
-    }
236
-
237
-
238
-    /**
239
-     * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the
240
-     * $_REQUEST global variable. Either way, tries to find the current transaction (through
241
-     * the registration pointed to by reg_url_link), if not returns null
242
-     *
243
-     * @param string $reg_url_link
244
-     *
245
-     * @return EE_Transaction
246
-     */
247
-    public function get_transaction_from_reg_url_link($reg_url_link = '')
248
-    {
249
-        return $this->get_one(array(
250
-            array(
251
-                'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link',
252
-                    '')
253
-            )
254
-        ));
255
-    }
256
-
257
-
258
-    /**
259
-     * Updates the provided EE_Transaction with all the applicable payments
260
-     * (or fetch the EE_Transaction from its ID)
261
-     *
262
-     * @deprecated
263
-     *
264
-     * @param EE_Transaction|int $transaction_obj_or_id
265
-     * @param boolean            $save_txn whether or not to save the transaction during this function call
266
-     *
267
-     * @return boolean
268
-     * @throws \EE_Error
269
-     */
270
-    public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
271
-    {
272
-        EE_Error::doing_it_wrong(
273
-            __CLASS__ . '::' . __FUNCTION__,
274
-            sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
275
-                'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
276
-            '4.6.0'
277
-        );
278
-        /** @type EE_Transaction_Processor $transaction_processor */
279
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
280
-
281
-        return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
282
-            $this->ensure_is_obj($transaction_obj_or_id)
283
-        );
284
-    }
285
-
286
-    /**
287
-     * Deletes "junk" transactions that were probably added by bots. There might be TONS
288
-     * of these, so we are very careful to NOT select (which the models do even when deleting),
289
-     * and so we only use wpdb directly and only do minimal joins.
290
-     * Transactions are considered "junk" if they're failed for longer than a week.
291
-     * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on
292
-     * it, it's probably not junk (regardless of what status it has).
293
-     * The downside to this approach is that is addons are listening for object deletions
294
-     * on EEM_Base::delete() they won't be notified of this.  However, there is an action that plugins can hook into
295
-     * to catch these types of deletions.
296
-     *
297
-     * @global WPDB $wpdb
298
-     * @return mixed
299
-     */
300
-    public function delete_junk_transactions()
301
-    {
302
-        /** @type WPDB $wpdb */
303
-        global $wpdb;
304
-        $deleted             = false;
305
-        $time_to_leave_alone = apply_filters(
306
-            'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone'
307
-            , WEEK_IN_SECONDS
308
-        );
309
-
310
-
311
-        /**
312
-         * This allows code to filter the query arguments used for retrieving the transaction IDs to delete.
313
-         * Useful for plugins that want to exclude transactions matching certain query parameters.
314
-         * The query parameters should be in the format accepted by the EEM_Base model queries.
315
-         */
316
-        $ids_query = apply_filters(
317
-            'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args',
318
-            array(
319
-                0 => array(
320
-                    'STS_ID'        => EEM_Transaction::failed_status_code,
321
-                    'Payment.PAY_ID' => array( 'IS NULL' ),
322
-                    'TXN_timestamp' => array('<', time() - $time_to_leave_alone)
323
-                )
324
-            ),
325
-            $time_to_leave_alone
326
-        );
327
-
328
-
329
-        /**
330
-         * This filter is for when code needs to filter the list of transaction ids that represent transactions
331
-         * about to be deleted based on some other criteria that isn't easily done via the query args filter.
332
-         */
333
-        $txn_ids = apply_filters(
334
-            'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete',
335
-            EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'),
336
-            $time_to_leave_alone
337
-        );
338
-        //now that we have the ids to delete
339
-        if (! empty($txn_ids) && is_array($txn_ids)) {
340
-            // first, make sure these TXN's are removed the "ee_locked_transactions" array
341
-            EEM_Transaction::unset_locked_transactions($txn_ids);
342
-            // let's get deletin'...
343
-            // Why no wpdb->prepare?  Because the data is trusted.
344
-            // We got the ids from the original query to get them FROM
345
-            // the db (which is sanitized) so no need to prepare them again.
346
-            $query   = '
233
+			OBJECT
234
+		);
235
+	}
236
+
237
+
238
+	/**
239
+	 * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the
240
+	 * $_REQUEST global variable. Either way, tries to find the current transaction (through
241
+	 * the registration pointed to by reg_url_link), if not returns null
242
+	 *
243
+	 * @param string $reg_url_link
244
+	 *
245
+	 * @return EE_Transaction
246
+	 */
247
+	public function get_transaction_from_reg_url_link($reg_url_link = '')
248
+	{
249
+		return $this->get_one(array(
250
+			array(
251
+				'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link',
252
+					'')
253
+			)
254
+		));
255
+	}
256
+
257
+
258
+	/**
259
+	 * Updates the provided EE_Transaction with all the applicable payments
260
+	 * (or fetch the EE_Transaction from its ID)
261
+	 *
262
+	 * @deprecated
263
+	 *
264
+	 * @param EE_Transaction|int $transaction_obj_or_id
265
+	 * @param boolean            $save_txn whether or not to save the transaction during this function call
266
+	 *
267
+	 * @return boolean
268
+	 * @throws \EE_Error
269
+	 */
270
+	public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
271
+	{
272
+		EE_Error::doing_it_wrong(
273
+			__CLASS__ . '::' . __FUNCTION__,
274
+			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
275
+				'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
276
+			'4.6.0'
277
+		);
278
+		/** @type EE_Transaction_Processor $transaction_processor */
279
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
280
+
281
+		return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
282
+			$this->ensure_is_obj($transaction_obj_or_id)
283
+		);
284
+	}
285
+
286
+	/**
287
+	 * Deletes "junk" transactions that were probably added by bots. There might be TONS
288
+	 * of these, so we are very careful to NOT select (which the models do even when deleting),
289
+	 * and so we only use wpdb directly and only do minimal joins.
290
+	 * Transactions are considered "junk" if they're failed for longer than a week.
291
+	 * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on
292
+	 * it, it's probably not junk (regardless of what status it has).
293
+	 * The downside to this approach is that is addons are listening for object deletions
294
+	 * on EEM_Base::delete() they won't be notified of this.  However, there is an action that plugins can hook into
295
+	 * to catch these types of deletions.
296
+	 *
297
+	 * @global WPDB $wpdb
298
+	 * @return mixed
299
+	 */
300
+	public function delete_junk_transactions()
301
+	{
302
+		/** @type WPDB $wpdb */
303
+		global $wpdb;
304
+		$deleted             = false;
305
+		$time_to_leave_alone = apply_filters(
306
+			'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone'
307
+			, WEEK_IN_SECONDS
308
+		);
309
+
310
+
311
+		/**
312
+		 * This allows code to filter the query arguments used for retrieving the transaction IDs to delete.
313
+		 * Useful for plugins that want to exclude transactions matching certain query parameters.
314
+		 * The query parameters should be in the format accepted by the EEM_Base model queries.
315
+		 */
316
+		$ids_query = apply_filters(
317
+			'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args',
318
+			array(
319
+				0 => array(
320
+					'STS_ID'        => EEM_Transaction::failed_status_code,
321
+					'Payment.PAY_ID' => array( 'IS NULL' ),
322
+					'TXN_timestamp' => array('<', time() - $time_to_leave_alone)
323
+				)
324
+			),
325
+			$time_to_leave_alone
326
+		);
327
+
328
+
329
+		/**
330
+		 * This filter is for when code needs to filter the list of transaction ids that represent transactions
331
+		 * about to be deleted based on some other criteria that isn't easily done via the query args filter.
332
+		 */
333
+		$txn_ids = apply_filters(
334
+			'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete',
335
+			EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'),
336
+			$time_to_leave_alone
337
+		);
338
+		//now that we have the ids to delete
339
+		if (! empty($txn_ids) && is_array($txn_ids)) {
340
+			// first, make sure these TXN's are removed the "ee_locked_transactions" array
341
+			EEM_Transaction::unset_locked_transactions($txn_ids);
342
+			// let's get deletin'...
343
+			// Why no wpdb->prepare?  Because the data is trusted.
344
+			// We got the ids from the original query to get them FROM
345
+			// the db (which is sanitized) so no need to prepare them again.
346
+			$query   = '
347 347
 				DELETE
348 348
 				FROM ' . $this->table() . '
349 349
 				WHERE
350 350
 					TXN_ID IN ( ' . implode(",", $txn_ids) . ')';
351
-            $deleted = $wpdb->query($query);
352
-        }
353
-        if ($deleted) {
354
-            /**
355
-             * Allows code to do something after the transactions have been deleted.
356
-             */
357
-            do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids);
358
-        }
359
-
360
-        return $deleted;
361
-    }
362
-
363
-
364
-    /**
365
-     * @param array $transaction_IDs
366
-     *
367
-     * @return bool
368
-     */
369
-    public static function unset_locked_transactions(array $transaction_IDs)
370
-    {
371
-        $locked_transactions = get_option('ee_locked_transactions', array());
372
-        $update              = false;
373
-        foreach ($transaction_IDs as $TXN_ID) {
374
-            if (isset($locked_transactions[$TXN_ID])) {
375
-                unset($locked_transactions[$TXN_ID]);
376
-                $update = true;
377
-            }
378
-        }
379
-        if ($update) {
380
-            update_option('ee_locked_transactions', $locked_transactions);
381
-        }
382
-
383
-        return $update;
384
-    }
385
-
386
-
387
-
388
-    /**
389
-     * returns an array of EE_Transaction objects whose timestamp is less than
390
-     * the current time minus the session lifespan, which defaults to 60 minutes
391
-     *
392
-     * @return EE_Base_Class[]|EE_Transaction[]
393
-     * @throws \EE_Error
394
-     */
395
-    public function get_transactions_in_progress()
396
-    {
397
-        return $this->get_all(
398
-            array(
399
-                array(
400
-                    'TXN_timestamp' => array(
401
-                        '>',
402
-                        time() - EE_Registry::instance()->SSN->lifespan()
403
-                    ),
404
-                    'STS_ID' => array(
405
-                        '!=',
406
-                        EEM_Transaction::complete_status_code
407
-                    ),
408
-                )
409
-            )
410
-        );
411
-    }
351
+			$deleted = $wpdb->query($query);
352
+		}
353
+		if ($deleted) {
354
+			/**
355
+			 * Allows code to do something after the transactions have been deleted.
356
+			 */
357
+			do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids);
358
+		}
359
+
360
+		return $deleted;
361
+	}
362
+
363
+
364
+	/**
365
+	 * @param array $transaction_IDs
366
+	 *
367
+	 * @return bool
368
+	 */
369
+	public static function unset_locked_transactions(array $transaction_IDs)
370
+	{
371
+		$locked_transactions = get_option('ee_locked_transactions', array());
372
+		$update              = false;
373
+		foreach ($transaction_IDs as $TXN_ID) {
374
+			if (isset($locked_transactions[$TXN_ID])) {
375
+				unset($locked_transactions[$TXN_ID]);
376
+				$update = true;
377
+			}
378
+		}
379
+		if ($update) {
380
+			update_option('ee_locked_transactions', $locked_transactions);
381
+		}
382
+
383
+		return $update;
384
+	}
385
+
386
+
387
+
388
+	/**
389
+	 * returns an array of EE_Transaction objects whose timestamp is less than
390
+	 * the current time minus the session lifespan, which defaults to 60 minutes
391
+	 *
392
+	 * @return EE_Base_Class[]|EE_Transaction[]
393
+	 * @throws \EE_Error
394
+	 */
395
+	public function get_transactions_in_progress()
396
+	{
397
+		return $this->get_all(
398
+			array(
399
+				array(
400
+					'TXN_timestamp' => array(
401
+						'>',
402
+						time() - EE_Registry::instance()->SSN->lifespan()
403
+					),
404
+					'STS_ID' => array(
405
+						'!=',
406
+						EEM_Transaction::complete_status_code
407
+					),
408
+				)
409
+			)
410
+		);
411
+	}
412 412
 
413 413
 
414 414
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
     exit('No direct script access allowed');
5 5
 }
6
-require_once(EE_MODELS . 'EEM_Base.model.php');
6
+require_once(EE_MODELS.'EEM_Base.model.php');
7 7
 
8 8
 /**
9 9
  *
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                     __('Registration Steps', 'event_espresso'), false, array()),
108 108
             )
109 109
         );
110
-        $this->_model_relations        = array(
110
+        $this->_model_relations = array(
111 111
             'Registration'   => new EE_Has_Many_Relation(),
112 112
             'Payment'        => new EE_Has_Many_Relation(),
113 113
             'Status'         => new EE_Belongs_To_Relation(),
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             ),
170 170
             OBJECT,
171 171
             array(
172
-                'txnDate' => array('DATE(' . $query_interval . ')', '%s'),
172
+                'txnDate' => array('DATE('.$query_interval.')', '%s'),
173 173
                 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d')
174 174
             )
175 175
         );
@@ -189,17 +189,17 @@  discard block
 block discarded – undo
189 189
     public function get_revenue_per_event_report($period = '-1 month')
190 190
     {
191 191
         global $wpdb;
192
-        $transaction_table          = $wpdb->prefix . 'esp_transaction';
193
-        $registration_table         = $wpdb->prefix . 'esp_registration';
194
-        $registration_payment_table = $wpdb->prefix . 'esp_registration_payment';
192
+        $transaction_table          = $wpdb->prefix.'esp_transaction';
193
+        $registration_table         = $wpdb->prefix.'esp_registration';
194
+        $registration_payment_table = $wpdb->prefix.'esp_registration_payment';
195 195
         $event_table                = $wpdb->posts;
196
-        $payment_table              = $wpdb->prefix . 'esp_payment';
196
+        $payment_table              = $wpdb->prefix.'esp_payment';
197 197
         $sql_date                   = date('Y-m-d H:i:s', strtotime($period));
198 198
         $approved_payment_status    = EEM_Payment::status_id_approved;
199 199
         $extra_event_on_join        = '';
200 200
         //exclude events not authored by user if permissions in effect
201 201
         if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
202
-            $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
202
+            $extra_event_on_join = ' AND Event.post_author = '.get_current_user_id();
203 203
         }
204 204
 
205 205
         return $wpdb->get_results(
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
271 271
     {
272 272
         EE_Error::doing_it_wrong(
273
-            __CLASS__ . '::' . __FUNCTION__,
273
+            __CLASS__.'::'.__FUNCTION__,
274 274
             sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
275 275
                 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
276 276
             '4.6.0'
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
             array(
319 319
                 0 => array(
320 320
                     'STS_ID'        => EEM_Transaction::failed_status_code,
321
-                    'Payment.PAY_ID' => array( 'IS NULL' ),
321
+                    'Payment.PAY_ID' => array('IS NULL'),
322 322
                     'TXN_timestamp' => array('<', time() - $time_to_leave_alone)
323 323
                 )
324 324
             ),
@@ -336,18 +336,18 @@  discard block
 block discarded – undo
336 336
             $time_to_leave_alone
337 337
         );
338 338
         //now that we have the ids to delete
339
-        if (! empty($txn_ids) && is_array($txn_ids)) {
339
+        if ( ! empty($txn_ids) && is_array($txn_ids)) {
340 340
             // first, make sure these TXN's are removed the "ee_locked_transactions" array
341 341
             EEM_Transaction::unset_locked_transactions($txn_ids);
342 342
             // let's get deletin'...
343 343
             // Why no wpdb->prepare?  Because the data is trusted.
344 344
             // We got the ids from the original query to get them FROM
345 345
             // the db (which is sanitized) so no need to prepare them again.
346
-            $query   = '
346
+            $query = '
347 347
 				DELETE
348
-				FROM ' . $this->table() . '
348
+				FROM ' . $this->table().'
349 349
 				WHERE
350
-					TXN_ID IN ( ' . implode(",", $txn_ids) . ')';
350
+					TXN_ID IN ( ' . implode(",", $txn_ids).')';
351 351
             $deleted = $wpdb->query($query);
352 352
         }
353 353
         if ($deleted) {
Please login to merge, or discard this patch.
core/db_models/EEM_Answer.model.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -125,14 +125,14 @@
 block discarded – undo
125 125
 	public function get_attendee_property_answer_value( EE_Registration $registration, $question_system_id = NULL, $pretty_answer = FALSE ){
126 126
 		$field_name = NULL;
127 127
 		$value = NULL;
128
-                //backward compat: we still want to find the question's ID
129
-                if( is_numeric( $question_system_id ) ) {
130
-                    //find this question's QST_system value
131
-                    $question_id = $question_system_id;
132
-                    $question_system_id = EEM_Question::instance()->get_var( array( array( 'QST_ID' => $question_system_id ) ), 'QST_system' );
133
-                } else {
134
-                    $question_id = (int) EEM_Question::instance()->get_var( array( array( 'QST_system' => $question_system_id ) ), 'QST_ID' );
135
-                }
128
+				//backward compat: we still want to find the question's ID
129
+				if( is_numeric( $question_system_id ) ) {
130
+					//find this question's QST_system value
131
+					$question_id = $question_system_id;
132
+					$question_system_id = EEM_Question::instance()->get_var( array( array( 'QST_ID' => $question_system_id ) ), 'QST_system' );
133
+				} else {
134
+					$question_id = (int) EEM_Question::instance()->get_var( array( array( 'QST_system' => $question_system_id ) ), 'QST_ID' );
135
+				}
136 136
 		//only bother checking if the registration has an attendee
137 137
 		if( $registration->attendee() instanceof EE_Attendee ) {
138 138
 			$field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question( $question_system_id );
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -51,18 +51,18 @@  discard block
 block discarded – undo
51 51
 	/**
52 52
 	 * 	constructor
53 53
 	 */
54
-	protected function __construct( $timezone = NULL ){
55
-		$this->singular_item = __('Answer','event_espresso');
56
-		$this->plural_item = __('Answers','event_espresso');
54
+	protected function __construct($timezone = NULL) {
55
+		$this->singular_item = __('Answer', 'event_espresso');
56
+		$this->plural_item = __('Answers', 'event_espresso');
57 57
 		$this->_tables = array(
58 58
 			'Answer'=> new EE_Primary_Table('esp_answer', 'ANS_ID')
59 59
 		);
60 60
 		$this->_fields = array(
61 61
 			'Answer'=>array(
62
-				'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID','event_espresso')),
63
-				'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID','event_espresso'), false, 0, 'Registration'),
64
-				'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID','event_espresso'), false, 0, 'Question'),
65
-				'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value','event_espresso'), false, '')
62
+				'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')),
63
+				'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'),
64
+				'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'),
65
+				'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '')
66 66
 			));
67 67
 		$this->_model_relations = array(
68 68
 			'Registration'=>new EE_Belongs_To_Relation(),
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		);
71 71
 		$this->_model_chain_to_wp_user = 'Registration.Event';
72 72
 		$this->_caps_slug = 'registrations';
73
-		parent::__construct( $timezone );
73
+		parent::__construct($timezone);
74 74
 	}
75 75
 
76 76
 
@@ -83,19 +83,19 @@  discard block
 block discarded – undo
83 83
 	 * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value'
84 84
 	 * @return string
85 85
 	 */
86
-	public function get_answer_value_to_question( EE_Registration $registration, $question_id = NULL,$pretty_answer = FALSE ){
87
-		$value = $this->get_attendee_property_answer_value( $registration, $question_id, $pretty_answer );
88
-		if (  $value === NULL ){
89
-			$answer_obj = $this->get_registration_question_answer_object( $registration, $question_id);
90
-			if( $answer_obj instanceof EE_Answer ){
91
-				if($pretty_answer){
86
+	public function get_answer_value_to_question(EE_Registration $registration, $question_id = NULL, $pretty_answer = FALSE) {
87
+		$value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer);
88
+		if ($value === NULL) {
89
+			$answer_obj = $this->get_registration_question_answer_object($registration, $question_id);
90
+			if ($answer_obj instanceof EE_Answer) {
91
+				if ($pretty_answer) {
92 92
 					$value = $answer_obj->pretty_value();
93
-				}else{
93
+				} else {
94 94
 					$value = $answer_obj->value();
95 95
 				}
96 96
 			}
97 97
 		}
98
-		return apply_filters( 'FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id );
98
+		return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id);
99 99
 	}
100 100
 
101 101
 
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 	 * @param int $question_id
107 107
 	 * @return EE_Answer
108 108
 	 */
109
-	public function get_registration_question_answer_object( EE_Registration $registration, $question_id = NULL){
110
-		$answer_obj = $this->get_one( array( array( 'QST_ID'=>$question_id, 'REG_ID'=>$registration->ID() )));
111
-		return apply_filters( 'FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id );
109
+	public function get_registration_question_answer_object(EE_Registration $registration, $question_id = NULL) {
110
+		$answer_obj = $this->get_one(array(array('QST_ID'=>$question_id, 'REG_ID'=>$registration->ID())));
111
+		return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id);
112 112
 	}
113 113
 
114 114
 
@@ -122,39 +122,39 @@  discard block
 block discarded – undo
122 122
 	 * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for
123 123
 	 * a question corresponding to an attendee field, returns null)
124 124
 	 */
125
-	public function get_attendee_property_answer_value( EE_Registration $registration, $question_system_id = NULL, $pretty_answer = FALSE ){
125
+	public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = NULL, $pretty_answer = FALSE) {
126 126
 		$field_name = NULL;
127 127
 		$value = NULL;
128 128
                 //backward compat: we still want to find the question's ID
129
-                if( is_numeric( $question_system_id ) ) {
129
+                if (is_numeric($question_system_id)) {
130 130
                     //find this question's QST_system value
131 131
                     $question_id = $question_system_id;
132
-                    $question_system_id = EEM_Question::instance()->get_var( array( array( 'QST_ID' => $question_system_id ) ), 'QST_system' );
132
+                    $question_system_id = EEM_Question::instance()->get_var(array(array('QST_ID' => $question_system_id)), 'QST_system');
133 133
                 } else {
134
-                    $question_id = (int) EEM_Question::instance()->get_var( array( array( 'QST_system' => $question_system_id ) ), 'QST_ID' );
134
+                    $question_id = (int) EEM_Question::instance()->get_var(array(array('QST_system' => $question_system_id)), 'QST_ID');
135 135
                 }
136 136
 		//only bother checking if the registration has an attendee
137
-		if( $registration->attendee() instanceof EE_Attendee ) {
138
-			$field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question( $question_system_id );
139
-			if( $field_name ) {
140
-				if( $pretty_answer ) {
141
-					if( $field_name === 'STA_ID' ) {
137
+		if ($registration->attendee() instanceof EE_Attendee) {
138
+			$field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id);
139
+			if ($field_name) {
140
+				if ($pretty_answer) {
141
+					if ($field_name === 'STA_ID') {
142 142
 						$state = $registration->attendee()->state_obj();
143
-						$value = $state instanceof EE_State ? $state->name() : sprintf( __('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID() );
144
-					} else if($field_name === 'CNT_ISO') {
143
+						$value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID());
144
+					} else if ($field_name === 'CNT_ISO') {
145 145
 						$country = $registration->attendee()->country_obj();
146
-						$value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"),$registration->attendee()->country_ID());
146
+						$value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID());
147 147
 					} else {
148
-						$value = $registration->attendee()->get_pretty( $field_name );
148
+						$value = $registration->attendee()->get_pretty($field_name);
149 149
 					}
150 150
 					//if field name is blank, leave the value as null too
151
-				}else{
152
-					$value = $registration->attendee()->get( $field_name );
151
+				} else {
152
+					$value = $registration->attendee()->get($field_name);
153 153
 				}
154 154
 			}
155 155
 			//if no field was found, leave value blank
156 156
 		}
157
-		return apply_filters( 'FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id );
157
+		return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id);
158 158
 	}
159 159
 
160 160
 
Please login to merge, or discard this patch.
core/services/collections/CollectionInterface.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 	public function previous();
114 114
 
115 115
 		/**
116
-	 * Returns the index of a given object, or false if not found
117
-	 *
118
-	 * @see http://stackoverflow.com/a/8736013
119
-	 * @param $object
120
-	 * @return boolean|int|string
121
-	 */
116
+		 * Returns the index of a given object, or false if not found
117
+		 *
118
+		 * @see http://stackoverflow.com/a/8736013
119
+		 * @param $object
120
+		 * @return boolean|int|string
121
+		 */
122 122
 	public function indexOf( $object );
123 123
 
124 124
 
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 
161 161
 
162 162
 
163
-    /**
164
-     * detaches ALL objects from the Collection
165
-     */
166
-    public function detachAll();
163
+	/**
164
+	 * detaches ALL objects from the Collection
165
+	 */
166
+	public function detachAll();
167 167
 
168 168
 
169 169
 
170
-    /**
171
-     * unsets and detaches ALL objects from the Collection
172
-     */
173
-    public function trashAndDetachAll();
170
+	/**
171
+	 * unsets and detaches ALL objects from the Collection
172
+	 */
173
+	public function trashAndDetachAll();
174 174
 
175 175
 }
176 176
 // End of file CollectionInterface.php
Please login to merge, or discard this patch.
core/services/collections/Collection.php 1 patch
Indentation   +28 added lines, -29 removed lines patch added patch discarded remove patch
@@ -83,7 +83,6 @@  discard block
 block discarded – undo
83 83
 
84 84
 	 /**
85 85
 	  * setIdentifier
86
-
87 86
 	  * Sets the data associated with an object in the Collection
88 87
 	  * if no $identifier is supplied, then the spl_object_hash() is used
89 88
 	  *
@@ -352,34 +351,34 @@  discard block
 block discarded – undo
352 351
 
353 352
 
354 353
 
355
-     /**
356
-      * detaches ALL objects from the Collection
357
-      */
358
-     public function detachAll()
359
-     {
360
-         $this->rewind();
361
-         while ($this->valid()) {
362
-             $object = $this->current();
363
-             $this->next();
364
-             $this->detach($object);
365
-         }
366
-     }
367
-
368
-
369
-
370
-     /**
371
-      * unsets and detaches ALL objects from the Collection
372
-      */
373
-     public function trashAndDetachAll()
374
-     {
375
-         $this->rewind();
376
-         while ($this->valid()) {
377
-             $object = $this->current();
378
-             $this->next();
379
-             $this->detach($object);
380
-             unset($object);
381
-         }
382
-     }
354
+	 /**
355
+	  * detaches ALL objects from the Collection
356
+	  */
357
+	 public function detachAll()
358
+	 {
359
+		 $this->rewind();
360
+		 while ($this->valid()) {
361
+			 $object = $this->current();
362
+			 $this->next();
363
+			 $this->detach($object);
364
+		 }
365
+	 }
366
+
367
+
368
+
369
+	 /**
370
+	  * unsets and detaches ALL objects from the Collection
371
+	  */
372
+	 public function trashAndDetachAll()
373
+	 {
374
+		 $this->rewind();
375
+		 while ($this->valid()) {
376
+			 $object = $this->current();
377
+			 $this->next();
378
+			 $this->detach($object);
379
+			 unset($object);
380
+		 }
381
+	 }
383 382
 
384 383
 
385 384
 
Please login to merge, or discard this patch.
core/services/loaders/LoaderFactory.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -79,37 +79,37 @@
 block discarded – undo
79 79
 class LoaderFactory
80 80
 {
81 81
 
82
-    /**
83
-     * @var LoaderInterface $loader ;
84
-     */
85
-    private static $loader;
82
+	/**
83
+	 * @var LoaderInterface $loader ;
84
+	 */
85
+	private static $loader;
86 86
 
87 87
 
88 88
 
89
-    /**
90
-     * @param mixed $generator      provided during  very first instantiation in
91
-     *                              EE_Load_Espresso_Core::handle_request()
92
-     *                              otherwise can be left null
93
-     * @return LoaderInterface
94
-     * @throws InvalidArgumentException
95
-     * @throws InvalidInterfaceException
96
-     * @throws InvalidDataTypeException
97
-     */
98
-    public static function getLoader($generator = null)
99
-    {
100
-        if (! LoaderFactory::$loader instanceof LoaderInterface) {
101
-            $generator = $generator !== null ? $generator : EE_Registry::instance();
102
-            $core_loader = new CoreLoader($generator);
103
-            LoaderFactory::$loader = new Loader(
104
-                $core_loader,
105
-                new CachingLoader(
106
-                    $core_loader,
107
-                    new LooseCollection('')
108
-                )
109
-            );
110
-        }
111
-        return LoaderFactory::$loader;
112
-    }
89
+	/**
90
+	 * @param mixed $generator      provided during  very first instantiation in
91
+	 *                              EE_Load_Espresso_Core::handle_request()
92
+	 *                              otherwise can be left null
93
+	 * @return LoaderInterface
94
+	 * @throws InvalidArgumentException
95
+	 * @throws InvalidInterfaceException
96
+	 * @throws InvalidDataTypeException
97
+	 */
98
+	public static function getLoader($generator = null)
99
+	{
100
+		if (! LoaderFactory::$loader instanceof LoaderInterface) {
101
+			$generator = $generator !== null ? $generator : EE_Registry::instance();
102
+			$core_loader = new CoreLoader($generator);
103
+			LoaderFactory::$loader = new Loader(
104
+				$core_loader,
105
+				new CachingLoader(
106
+					$core_loader,
107
+					new LooseCollection('')
108
+				)
109
+			);
110
+		}
111
+		return LoaderFactory::$loader;
112
+	}
113 113
 
114 114
 
115 115
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@
 block discarded – undo
97 97
      */
98 98
     public static function getLoader($generator = null)
99 99
     {
100
-        if (! LoaderFactory::$loader instanceof LoaderInterface) {
100
+        if ( ! LoaderFactory::$loader instanceof LoaderInterface) {
101 101
             $generator = $generator !== null ? $generator : EE_Registry::instance();
102 102
             $core_loader = new CoreLoader($generator);
103 103
             LoaderFactory::$loader = new Loader(
Please login to merge, or discard this patch.
core/helpers/EEH_Event_View.helper.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -32,51 +32,51 @@  discard block
 block discarded – undo
32 32
 
33 33
 
34 34
 
35
-    /**
36
-     * get_event
37
-     * attempts to retrieve an EE_Event object any way it can
38
-     *
39
-     * @param int|WP_Post $EVT_ID
40
-     * @return EE_Event|null
41
-     * @throws \EE_Error
42
-     */
43
-    public static function get_event($EVT_ID = 0)
44
-    {
45
-        // international newspaper?
46
-        global $post;
47
-        $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events'
48
-            ? $EVT_ID->ID
49
-            : absint($EVT_ID);
50
-        // do we already have the Event  you are looking for?
51
-        if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
52
-            return EEH_Event_View::$_event;
53
-        }
54
-        //reset property so that the new event is cached.
55
-        EEH_Event_View::$_event = null;
56
-        if (! $EVT_ID && $post instanceof EE_Event) {
57
-            EEH_Event_View::$_event = $post;
58
-            return EEH_Event_View::$_event;
59
-        }
60
-        //if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID
61
-        //then let's just use that cached event on the $post object.
62
-        if (
63
-            $post instanceof WP_Post
64
-            && $post->post_type === 'espresso_events'
65
-            && isset($post->EE_Event)
66
-            && (
67
-                $EVT_ID === 0
68
-                || $EVT_ID === $post->ID
69
-            )
70
-        ) {
71
-            EEH_Event_View::$_event = $post->EE_Event;
72
-            return EEH_Event_View::$_event;
73
-        }
74
-        //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
75
-        if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
76
-            EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
77
-        }
78
-        return EEH_Event_View::$_event;
79
-    }
35
+	/**
36
+	 * get_event
37
+	 * attempts to retrieve an EE_Event object any way it can
38
+	 *
39
+	 * @param int|WP_Post $EVT_ID
40
+	 * @return EE_Event|null
41
+	 * @throws \EE_Error
42
+	 */
43
+	public static function get_event($EVT_ID = 0)
44
+	{
45
+		// international newspaper?
46
+		global $post;
47
+		$EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events'
48
+			? $EVT_ID->ID
49
+			: absint($EVT_ID);
50
+		// do we already have the Event  you are looking for?
51
+		if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
52
+			return EEH_Event_View::$_event;
53
+		}
54
+		//reset property so that the new event is cached.
55
+		EEH_Event_View::$_event = null;
56
+		if (! $EVT_ID && $post instanceof EE_Event) {
57
+			EEH_Event_View::$_event = $post;
58
+			return EEH_Event_View::$_event;
59
+		}
60
+		//if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID
61
+		//then let's just use that cached event on the $post object.
62
+		if (
63
+			$post instanceof WP_Post
64
+			&& $post->post_type === 'espresso_events'
65
+			&& isset($post->EE_Event)
66
+			&& (
67
+				$EVT_ID === 0
68
+				|| $EVT_ID === $post->ID
69
+			)
70
+		) {
71
+			EEH_Event_View::$_event = $post->EE_Event;
72
+			return EEH_Event_View::$_event;
73
+		}
74
+		//If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
75
+		if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
76
+			EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
77
+		}
78
+		return EEH_Event_View::$_event;
79
+	}
80 80
 
81 81
 
82 82
 
@@ -152,58 +152,58 @@  discard block
 block discarded – undo
152 152
 	 * @return    string
153 153
 	 */
154 154
 	public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) {
155
-        global $post;
155
+		global $post;
156 156
 		ob_start();
157 157
 		if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) {
158 158
 			// admin has chosen "full description"
159
-            // for the "Event Espresso - Events > Templates > Display Description" option
159
+			// for the "Event Espresso - Events > Templates > Display Description" option
160 160
 			the_content();
161 161
 		} else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) {
162
-            if ( has_excerpt( $post->ID )) {
163
-                // admin has chosen "excerpt (short desc)"
164
-                // for the "Event Espresso - Events > Templates > Display Description" option
165
-                // AND an excerpt actually exists
166
-                the_excerpt();
167
-            } else {
168
-                // admin has chosen "excerpt (short desc)"
169
-                // for the "Event Espresso - Events > Templates > Display Description" option
170
-                // but NO excerpt actually exists, so we need to create one
171
-                if ( ! empty( $num_words )) {
172
-                    if ( empty( $more )) {
173
-                        $more_link_text = __( '(more&hellip;)' );
174
-                        $more = ' <a href="' . get_permalink() . '"';
175
-                        $more .= ' class="more-link"';
176
-                        $more .= \EED_Events_Archive::link_target();
177
-                        $more .= '>' . $more_link_text . '</a>';
178
-                        $more = apply_filters( 'the_content_more_link', $more, $more_link_text );
179
-                    }
180
-                    $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
181
-
182
-                    $content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
183
-                } else {
184
-                    $content =  get_the_content();
185
-                }
186
-                global $allowedtags;
187
-                // make sure links are allowed
188
-                $allowedtags['a'] = isset($allowedtags['a'])
189
-                    ? $allowedtags['a']
190
-                    : array();
191
-                // as well as target attribute
192
-                $allowedtags['a']['target'] = isset($allowedtags['a']['target'])
193
-                    ? $allowedtags['a']['target']
194
-                    : false;
195
-                // but get previous value so we can reset it
196
-                $prev_value = $allowedtags['a']['target'];
197
-                $allowedtags['a']['target'] = true;
198
-                $content = wp_kses( $content, $allowedtags );
199
-                $content = strip_shortcodes( $content );
200
-                echo apply_filters( 'the_content', $content );
201
-                $allowedtags['a']['target'] = $prev_value;
202
-            }
203
-        } else {
204
-            // admin has chosen "none"
205
-            // for the "Event Espresso - Events > Templates > Display Description" option
206
-            echo apply_filters( 'the_content', '' );
162
+			if ( has_excerpt( $post->ID )) {
163
+				// admin has chosen "excerpt (short desc)"
164
+				// for the "Event Espresso - Events > Templates > Display Description" option
165
+				// AND an excerpt actually exists
166
+				the_excerpt();
167
+			} else {
168
+				// admin has chosen "excerpt (short desc)"
169
+				// for the "Event Espresso - Events > Templates > Display Description" option
170
+				// but NO excerpt actually exists, so we need to create one
171
+				if ( ! empty( $num_words )) {
172
+					if ( empty( $more )) {
173
+						$more_link_text = __( '(more&hellip;)' );
174
+						$more = ' <a href="' . get_permalink() . '"';
175
+						$more .= ' class="more-link"';
176
+						$more .= \EED_Events_Archive::link_target();
177
+						$more .= '>' . $more_link_text . '</a>';
178
+						$more = apply_filters( 'the_content_more_link', $more, $more_link_text );
179
+					}
180
+					$content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
181
+
182
+					$content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
183
+				} else {
184
+					$content =  get_the_content();
185
+				}
186
+				global $allowedtags;
187
+				// make sure links are allowed
188
+				$allowedtags['a'] = isset($allowedtags['a'])
189
+					? $allowedtags['a']
190
+					: array();
191
+				// as well as target attribute
192
+				$allowedtags['a']['target'] = isset($allowedtags['a']['target'])
193
+					? $allowedtags['a']['target']
194
+					: false;
195
+				// but get previous value so we can reset it
196
+				$prev_value = $allowedtags['a']['target'];
197
+				$allowedtags['a']['target'] = true;
198
+				$content = wp_kses( $content, $allowedtags );
199
+				$content = strip_shortcodes( $content );
200
+				echo apply_filters( 'the_content', $content );
201
+				$allowedtags['a']['target'] = $prev_value;
202
+			}
203
+		} else {
204
+			// admin has chosen "none"
205
+			// for the "Event Espresso - Events > Templates > Display Description" option
206
+			echo apply_filters( 'the_content', '' );
207 207
 		}
208 208
 		return ob_get_clean();
209 209
 	}
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
 					$url = get_term_link( $term, 'espresso_venue_categories' );
251 251
 					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
252 252
 						$category_links[] = '<a href="' . esc_url( $url )
253
-                                            . '" rel="tag"'
254
-                                            . \EED_Events_Archive::link_target()
255
-                                            .'>'
256
-                                            . $term->name
257
-                                            . '</a>';
253
+											. '" rel="tag"'
254
+											. \EED_Events_Archive::link_target()
255
+											.'>'
256
+											. $term->name
257
+											. '</a>';
258 258
 					}
259 259
 				}
260 260
 			}
Please login to merge, or discard this patch.
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         }
54 54
         //reset property so that the new event is cached.
55 55
         EEH_Event_View::$_event = null;
56
-        if (! $EVT_ID && $post instanceof EE_Event) {
56
+        if ( ! $EVT_ID && $post instanceof EE_Event) {
57 57
             EEH_Event_View::$_event = $post;
58 58
             return EEH_Event_View::$_event;
59 59
         }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             return EEH_Event_View::$_event;
73 73
         }
74 74
         //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
75
-        if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
75
+        if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
76 76
             EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
77 77
         }
78 78
         return EEH_Event_View::$_event;
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 * @param    int $EVT_ID
88 88
 	 * @return    boolean
89 89
 	 */
90
-	public static function display_ticket_selector( $EVT_ID = 0 ) {
91
-		$event = EEH_Event_View::get_event( $EVT_ID );
90
+	public static function display_ticket_selector($EVT_ID = 0) {
91
+		$event = EEH_Event_View::get_event($EVT_ID);
92 92
 		return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE;
93 93
 	}
94 94
 
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	 * @param    int $EVT_ID
102 102
 	 * @return    string
103 103
 	 */
104
-	public static function event_status( $EVT_ID = 0 ) {
105
-		$event = EEH_Event_View::get_event( $EVT_ID );
106
-		return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : '';
104
+	public static function event_status($EVT_ID = 0) {
105
+		$event = EEH_Event_View::get_event($EVT_ID);
106
+		return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : '';
107 107
 	}
108 108
 
109 109
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 * @param    int $EVT_ID
116 116
 	 *  @return 	string
117 117
 	 */
118
-	public static function event_active_status( $EVT_ID = 0 ) {
119
-		$event = EEH_Event_View::get_event( $EVT_ID );
118
+	public static function event_active_status($EVT_ID = 0) {
119
+		$event = EEH_Event_View::get_event($EVT_ID);
120 120
 		return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive';
121 121
 	}
122 122
 
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 * @param    int $EVT_ID
130 130
 	 *  @return 	string
131 131
 	 */
132
-	public static function event_has_content_or_excerpt( $EVT_ID = 0 ) {
133
-		$event = EEH_Event_View::get_event( $EVT_ID );
132
+	public static function event_has_content_or_excerpt($EVT_ID = 0) {
133
+		$event = EEH_Event_View::get_event($EVT_ID);
134 134
 		$has_content_or_excerpt = FALSE;
135
-		if ( $event instanceof EE_Event ) {
136
-			$has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE;
135
+		if ($event instanceof EE_Event) {
136
+			$has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE;
137 137
 		}
138
-		if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) {
138
+		if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) {
139 139
 			$has_content_or_excerpt = FALSE;
140 140
 		}
141 141
 		return $has_content_or_excerpt;
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
 	 * @param null $more
152 152
 	 * @return    string
153 153
 	 */
154
-	public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) {
154
+	public static function event_content_or_excerpt($num_words = NULL, $more = NULL) {
155 155
         global $post;
156 156
 		ob_start();
157
-		if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) {
157
+		if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) {
158 158
 			// admin has chosen "full description"
159 159
             // for the "Event Espresso - Events > Templates > Display Description" option
160 160
 			the_content();
161
-		} else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) {
162
-            if ( has_excerpt( $post->ID )) {
161
+		} else if ((is_archive() && espresso_display_excerpt_in_event_list())) {
162
+            if (has_excerpt($post->ID)) {
163 163
                 // admin has chosen "excerpt (short desc)"
164 164
                 // for the "Event Espresso - Events > Templates > Display Description" option
165 165
                 // AND an excerpt actually exists
@@ -168,20 +168,20 @@  discard block
 block discarded – undo
168 168
                 // admin has chosen "excerpt (short desc)"
169 169
                 // for the "Event Espresso - Events > Templates > Display Description" option
170 170
                 // but NO excerpt actually exists, so we need to create one
171
-                if ( ! empty( $num_words )) {
172
-                    if ( empty( $more )) {
173
-                        $more_link_text = __( '(more&hellip;)' );
174
-                        $more = ' <a href="' . get_permalink() . '"';
171
+                if ( ! empty($num_words)) {
172
+                    if (empty($more)) {
173
+                        $more_link_text = __('(more&hellip;)');
174
+                        $more = ' <a href="'.get_permalink().'"';
175 175
                         $more .= ' class="more-link"';
176 176
                         $more .= \EED_Events_Archive::link_target();
177
-                        $more .= '>' . $more_link_text . '</a>';
178
-                        $more = apply_filters( 'the_content_more_link', $more, $more_link_text );
177
+                        $more .= '>'.$more_link_text.'</a>';
178
+                        $more = apply_filters('the_content_more_link', $more, $more_link_text);
179 179
                     }
180
-                    $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
180
+                    $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK'));
181 181
 
182
-                    $content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
182
+                    $content = wp_trim_words($content, $num_words, ' ').$more;
183 183
                 } else {
184
-                    $content =  get_the_content();
184
+                    $content = get_the_content();
185 185
                 }
186 186
                 global $allowedtags;
187 187
                 // make sure links are allowed
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
                 // but get previous value so we can reset it
196 196
                 $prev_value = $allowedtags['a']['target'];
197 197
                 $allowedtags['a']['target'] = true;
198
-                $content = wp_kses( $content, $allowedtags );
199
-                $content = strip_shortcodes( $content );
200
-                echo apply_filters( 'the_content', $content );
198
+                $content = wp_kses($content, $allowedtags);
199
+                $content = strip_shortcodes($content);
200
+                echo apply_filters('the_content', $content);
201 201
                 $allowedtags['a']['target'] = $prev_value;
202 202
             }
203 203
         } else {
204 204
             // admin has chosen "none"
205 205
             // for the "Event Espresso - Events > Templates > Display Description" option
206
-            echo apply_filters( 'the_content', '' );
206
+            echo apply_filters('the_content', '');
207 207
 		}
208 208
 		return ob_get_clean();
209 209
 	}
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 	 * @param    int $EVT_ID
218 218
 	 *  @return 	EE_Ticket[]
219 219
 	 */
220
-	public static function event_tickets_available( $EVT_ID = 0 ) {
221
-		$event = EEH_Event_View::get_event( $EVT_ID );
220
+	public static function event_tickets_available($EVT_ID = 0) {
221
+		$event = EEH_Event_View::get_event($EVT_ID);
222 222
 		$tickets_available_for_purchase = array();
223
-		if( $event instanceof EE_Event ) {
224
-			$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE );
225
-			foreach( $datetimes as $datetime ) {
226
-				$tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() );
223
+		if ($event instanceof EE_Event) {
224
+			$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE);
225
+			foreach ($datetimes as $datetime) {
226
+				$tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase());
227 227
 			}
228 228
 		}
229 229
 		return $tickets_available_for_purchase;
@@ -239,17 +239,17 @@  discard block
 block discarded – undo
239 239
 	 * @param 	  bool   $hide_uncategorized
240 240
 	 * @return    string
241 241
 	 */
242
-	public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) {
242
+	public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) {
243 243
 		$category_links = array();
244
-		$event = EEH_Event_View::get_event( $EVT_ID );
245
-		if ( $event instanceof EE_Event ) {
246
-			$event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' );
247
-			if ( $event_categories ) {
244
+		$event = EEH_Event_View::get_event($EVT_ID);
245
+		if ($event instanceof EE_Event) {
246
+			$event_categories = get_the_terms($event->ID(), 'espresso_event_categories');
247
+			if ($event_categories) {
248 248
 				// loop thru terms and create links
249
-				foreach ( $event_categories as $term ) {
250
-					$url = get_term_link( $term, 'espresso_venue_categories' );
251
-					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
252
-						$category_links[] = '<a href="' . esc_url( $url )
249
+				foreach ($event_categories as $term) {
250
+					$url = get_term_link($term, 'espresso_venue_categories');
251
+					if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) {
252
+						$category_links[] = '<a href="'.esc_url($url)
253 253
                                             . '" rel="tag"'
254 254
                                             . \EED_Events_Archive::link_target()
255 255
                                             .'>'
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 				}
260 260
 			}
261 261
 		}
262
-		return implode( ', ', $category_links );
262
+		return implode(', ', $category_links);
263 263
 	}
264 264
 
265 265
 
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 	 * @param int    $EVT_ID
274 274
 	 * @return    string
275 275
 	 */
276
-	public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
277
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
278
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
279
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) :  '';
276
+	public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
277
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
278
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
279
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
280 280
 	}
281 281
 
282 282
 
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 	 * @param int    $EVT_ID
291 291
 	 * @return    string
292 292
 	 */
293
-	public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
294
-		$datetime = EEH_Event_View::get_last_date_obj( $EVT_ID );
295
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
296
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
293
+	public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
294
+		$datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
295
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
296
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
297 297
 	}
298 298
 
299 299
 
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	 * @param int    $EVT_ID
308 308
 	 * @return    string
309 309
 	 */
310
-	public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
311
-		$datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID );
312
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
313
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : '';
310
+	public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
311
+		$datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID);
312
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
313
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
314 314
 	}
315 315
 
316 316
 
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 	 * @param int    $EVT_ID
325 325
 	 * @return    string
326 326
 	 */
327
-	public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
328
-		$datetime = EEH_Event_View::get_latest_date_obj( $EVT_ID );
329
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
330
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
327
+	public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
328
+		$datetime = EEH_Event_View::get_latest_date_obj($EVT_ID);
329
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
330
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
331 331
 	}
332 332
 
333 333
 
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
 	 * @param int $EVT_ID
340 340
 	 * @return    string
341 341
 	 */
342
-	public static function event_date_as_calendar_page( $EVT_ID = 0 ) {
343
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
344
-		if ( $datetime instanceof EE_Datetime ) {
342
+	public static function event_date_as_calendar_page($EVT_ID = 0) {
343
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
344
+		if ($datetime instanceof EE_Datetime) {
345 345
 	?>
346 346
 		<div class="event-date-calendar-page-dv">
347
-			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div>
348
-			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div>
347
+			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div>
348
+			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div>
349 349
 		</div>
350 350
 	<?php
351 351
 		}
@@ -360,17 +360,17 @@  discard block
 block discarded – undo
360 360
 	 * @param int $EVT_ID
361 361
 	 * @return    string
362 362
 	 */
363
-	public static function get_primary_date_obj( $EVT_ID = 0 ) {
364
-		$event = EEH_Event_View::get_event( $EVT_ID );
365
-		if ( $event instanceof EE_Event ) {
363
+	public static function get_primary_date_obj($EVT_ID = 0) {
364
+		$event = EEH_Event_View::get_event($EVT_ID);
365
+		if ($event instanceof EE_Event) {
366 366
 			$datetimes = $event->get_many_related(
367 367
 				'Datetime',
368 368
 				array(
369 369
 					'limit' => 1,
370
-					'order_by' => array( 'DTT_order' => 'ASC' )
370
+					'order_by' => array('DTT_order' => 'ASC')
371 371
 				)
372 372
 			);
373
-			return reset( $datetimes );
373
+			return reset($datetimes);
374 374
 		} else {
375 375
 			 return FALSE;
376 376
 		}
@@ -385,17 +385,17 @@  discard block
 block discarded – undo
385 385
 	 * @param int $EVT_ID
386 386
 	 * @return    string
387 387
 	 */
388
-	public static function get_last_date_obj( $EVT_ID = 0 ) {
389
-		$event = EEH_Event_View::get_event( $EVT_ID );
390
-		if ( $event instanceof EE_Event ) {
388
+	public static function get_last_date_obj($EVT_ID = 0) {
389
+		$event = EEH_Event_View::get_event($EVT_ID);
390
+		if ($event instanceof EE_Event) {
391 391
 			$datetimes = $event->get_many_related(
392 392
 				'Datetime',
393 393
 				array(
394 394
 					'limit' => 1,
395
-					'order_by' => array( 'DTT_order' => 'DESC' )
395
+					'order_by' => array('DTT_order' => 'DESC')
396 396
 				)
397 397
 			);
398
-			return end( $datetimes );
398
+			return end($datetimes);
399 399
 		} else {
400 400
 			return FALSE;
401 401
 		}
@@ -410,17 +410,17 @@  discard block
 block discarded – undo
410 410
 	 * @param int $EVT_ID
411 411
 	 * @return    string
412 412
 	 */
413
-	public static function get_earliest_date_obj( $EVT_ID = 0 ) {
414
-		$event = EEH_Event_View::get_event( $EVT_ID );
415
-		if ( $event instanceof EE_Event ) {
413
+	public static function get_earliest_date_obj($EVT_ID = 0) {
414
+		$event = EEH_Event_View::get_event($EVT_ID);
415
+		if ($event instanceof EE_Event) {
416 416
 			$datetimes = $event->get_many_related(
417 417
 				'Datetime',
418 418
 				array(
419 419
 					'limit' => 1,
420
-					'order_by' => array( 'DTT_EVT_start' => 'ASC' )
420
+					'order_by' => array('DTT_EVT_start' => 'ASC')
421 421
 				)
422 422
 			);
423
-			return reset( $datetimes );
423
+			return reset($datetimes);
424 424
 		} else {
425 425
 			 return FALSE;
426 426
 		}
@@ -435,17 +435,17 @@  discard block
 block discarded – undo
435 435
 	 * @param int $EVT_ID
436 436
 	 * @return    string
437 437
 	 */
438
-	public static function get_latest_date_obj( $EVT_ID = 0 ) {
439
-		$event = EEH_Event_View::get_event( $EVT_ID );
440
-		if ( $event instanceof EE_Event ) {
438
+	public static function get_latest_date_obj($EVT_ID = 0) {
439
+		$event = EEH_Event_View::get_event($EVT_ID);
440
+		if ($event instanceof EE_Event) {
441 441
 			$datetimes = $event->get_many_related(
442 442
 				'Datetime',
443 443
 				array(
444 444
 					'limit' => 1,
445
-					'order_by' => array( 'DTT_EVT_start' => 'DESC' )
445
+					'order_by' => array('DTT_EVT_start' => 'DESC')
446 446
 				)
447 447
 			);
448
-			return end( $datetimes );
448
+			return end($datetimes);
449 449
 		} else {
450 450
 			return FALSE;
451 451
 		}
@@ -463,17 +463,17 @@  discard block
 block discarded – undo
463 463
 	 * @param null $limit
464 464
 	 * @return EE_Datetime[]
465 465
 	 */
466
-	public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) {
467
-		$event = EEH_Event_View::get_event( $EVT_ID );
468
-		if($include_expired === null){
469
-			if($event instanceof EE_Event && $event->is_expired()){
466
+	public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) {
467
+		$event = EEH_Event_View::get_event($EVT_ID);
468
+		if ($include_expired === null) {
469
+			if ($event instanceof EE_Event && $event->is_expired()) {
470 470
 				$include_expired = true;
471
-			}else{
471
+			} else {
472 472
 				$include_expired = false;
473 473
 			}
474 474
 		}
475 475
 
476
-		if ( $event instanceof EE_Event ) {
476
+		if ($event instanceof EE_Event) {
477 477
 			return $event->datetimes_ordered($include_expired, $include_deleted, $limit);
478 478
 		} else {
479 479
 			 return array();
@@ -489,11 +489,11 @@  discard block
 block discarded – undo
489 489
 	 * @param int $EVT_ID
490 490
 	 * @return    string
491 491
 	 */
492
-	public static function event_link_url( $EVT_ID = 0 ) {
493
-		$event = EEH_Event_View::get_event( $EVT_ID );
494
-		if ( $event instanceof EE_Event ) {
495
-			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() );
496
-			return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url;
492
+	public static function event_link_url($EVT_ID = 0) {
493
+		$event = EEH_Event_View::get_event($EVT_ID);
494
+		if ($event instanceof EE_Event) {
495
+			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID());
496
+			return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url;
497 497
 		}
498 498
 		return NULL;
499 499
 	}
@@ -507,10 +507,10 @@  discard block
 block discarded – undo
507 507
 	 * @param int $EVT_ID
508 508
 	 * @return    string
509 509
 	 */
510
-	public static function event_phone( $EVT_ID = 0 ) {
511
-		$event = EEH_Event_View::get_event( $EVT_ID );
512
-		if ( $event instanceof EE_Event ) {
513
-			return EEH_Schema::telephone( $event->phone() );
510
+	public static function event_phone($EVT_ID = 0) {
511
+		$event = EEH_Event_View::get_event($EVT_ID);
512
+		if ($event instanceof EE_Event) {
513
+			return EEH_Schema::telephone($event->phone());
514 514
 		}
515 515
 		return NULL;
516 516
 	}
@@ -527,26 +527,26 @@  discard block
 block discarded – undo
527 527
 	 * @param string $after
528 528
 	 * @return    string
529 529
 	 */
530
-	public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) {
531
-		$event = EEH_Event_View::get_event( $EVT_ID );
532
-		if ( $event instanceof EE_Event ) {
530
+	public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') {
531
+		$event = EEH_Event_View::get_event($EVT_ID);
532
+		if ($event instanceof EE_Event) {
533 533
 			// can the user edit this post ?
534
-			if ( current_user_can( 'edit_post', $event->ID() )) {
534
+			if (current_user_can('edit_post', $event->ID())) {
535 535
 				// set link text
536
-				$link_text = ! empty( $link ) ? $link : __('edit this event');
536
+				$link_text = ! empty($link) ? $link : __('edit this event');
537 537
 				// generate nonce
538
-				$nonce = wp_create_nonce( 'edit_nonce' );
538
+				$nonce = wp_create_nonce('edit_nonce');
539 539
 				// generate url to event editor for this event
540
-				$url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() );
540
+				$url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url());
541 541
 				// get edit CPT text
542
-				$post_type_obj = get_post_type_object( 'espresso_events' );
542
+				$post_type_obj = get_post_type_object('espresso_events');
543 543
 				// build final link html
544
-				$link = '<a class="post-edit-link" href="' . $url . '" ';
545
-				$link .= ' title="' . esc_attr( $post_type_obj->labels->edit_item ) . '"';
544
+				$link = '<a class="post-edit-link" href="'.$url.'" ';
545
+				$link .= ' title="'.esc_attr($post_type_obj->labels->edit_item).'"';
546 546
 				$link .= \EED_Events_Archive::link_target();
547
-				$link .='>' . $link_text . '</a>';
547
+				$link .= '>'.$link_text.'</a>';
548 548
 				// put it all together
549
-				return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after;
549
+				return $before.apply_filters('edit_post_link', $link, $event->ID()).$after;
550 550
 			}
551 551
 		}
552 552
 		return '';
Please login to merge, or discard this patch.