Completed
Branch FET-8385-datetime-ticket-selec... (ec342c)
by
unknown
45:18 queued 34:32
created
core/EE_Registry.core.php 1 patch
Indentation   +1334 added lines, -1334 removed lines patch added patch discarded remove patch
@@ -16,1370 +16,1370 @@
 block discarded – undo
16 16
 class EE_Registry
17 17
 {
18 18
 
19
-    /**
20
-     *    EE_Registry Object
21
-     *
22
-     * @var EE_Registry $_instance
23
-     * @access    private
24
-     */
25
-    private static $_instance = null;
26
-
27
-    /**
28
-     * @var EE_Dependency_Map $_dependency_map
29
-     * @access    protected
30
-     */
31
-    protected $_dependency_map = null;
32
-
33
-    /**
34
-     * @var array $_class_abbreviations
35
-     * @access    protected
36
-     */
37
-    protected $_class_abbreviations = array();
38
-
39
-    /**
40
-     * @access public
41
-     * @var \EventEspresso\core\services\commands\CommandBusInterface $BUS
42
-     */
43
-    public $BUS;
44
-
45
-    /**
46
-     *    EE_Cart Object
47
-     *
48
-     * @access    public
49
-     * @var    EE_Cart $CART
50
-     */
51
-    public $CART = null;
52
-
53
-    /**
54
-     *    EE_Config Object
55
-     *
56
-     * @access    public
57
-     * @var    EE_Config $CFG
58
-     */
59
-    public $CFG = null;
60
-
61
-    /**
62
-     * EE_Network_Config Object
63
-     *
64
-     * @access public
65
-     * @var EE_Network_Config $NET_CFG
66
-     */
67
-    public $NET_CFG = null;
68
-
69
-    /**
70
-     *    StdClass object for storing library classes in
71
-     *
72
-     * @public LIB
73
-     * @var StdClass $LIB
74
-     */
75
-    public $LIB = null;
76
-
77
-    /**
78
-     *    EE_Request_Handler Object
79
-     *
80
-     * @access    public
81
-     * @var    EE_Request_Handler $REQ
82
-     */
83
-    public $REQ = null;
84
-
85
-    /**
86
-     *    EE_Session Object
87
-     *
88
-     * @access    public
89
-     * @var    EE_Session $SSN
90
-     */
91
-    public $SSN = null;
92
-
93
-    /**
94
-     * holds the ee capabilities object.
95
-     *
96
-     * @since 4.5.0
97
-     * @var EE_Capabilities
98
-     */
99
-    public $CAP = null;
100
-
101
-    /**
102
-     * holds the EE_Message_Resource_Manager object.
103
-     *
104
-     * @since 4.9.0
105
-     * @var EE_Message_Resource_Manager
106
-     */
107
-    public $MRM = null;
108
-
109
-
110
-    /**
111
-     * Holds the Assets Registry instance
112
-     * @var Registry
113
-     */
114
-    public $AssetsRegistry = null;
115
-
116
-    /**
117
-     *    $addons - StdClass object for holding addons which have registered themselves to work with EE core
118
-     *
119
-     * @access    public
120
-     * @var    EE_Addon[]
121
-     */
122
-    public $addons = null;
123
-
124
-    /**
125
-     *    $models
126
-     * @access    public
127
-     * @var    EEM_Base[] $models keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
128
-     */
129
-    public $models = array();
130
-
131
-    /**
132
-     *    $modules
133
-     * @access    public
134
-     * @var    EED_Module[] $modules
135
-     */
136
-    public $modules = null;
137
-
138
-    /**
139
-     *    $shortcodes
140
-     * @access    public
141
-     * @var    EES_Shortcode[] $shortcodes
142
-     */
143
-    public $shortcodes = null;
144
-
145
-    /**
146
-     *    $widgets
147
-     * @access    public
148
-     * @var    WP_Widget[] $widgets
149
-     */
150
-    public $widgets = null;
151
-
152
-    /**
153
-     * $non_abstract_db_models
154
-     * @access public
155
-     * @var array this is an array of all implemented model names (i.e. not the parent abstract models, or models
156
-     * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
157
-     * Keys are model "short names" (eg "Event") as used in model relations, and values are
158
-     * classnames (eg "EEM_Event")
159
-     */
160
-    public $non_abstract_db_models = array();
161
-
162
-    /**
163
-     *    $i18n_js_strings - internationalization for JS strings
164
-     *    usage:   EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' );
165
-     *    in js file:  var translatedString = eei18n.string_key;
166
-     *
167
-     * @access    public
168
-     * @var    array
169
-     */
170
-    public static $i18n_js_strings = array();
171
-
172
-    /**
173
-     *    $main_file - path to espresso.php
174
-     *
175
-     * @access    public
176
-     * @var    array
177
-     */
178
-    public $main_file;
179
-
180
-    /**
181
-     * array of ReflectionClass objects where the key is the class name
182
-     *
183
-     * @access    public
184
-     * @var ReflectionClass[]
185
-     */
186
-    public $_reflectors;
187
-
188
-    /**
189
-     * boolean flag to indicate whether or not to load/save dependencies from/to the cache
190
-     *
191
-     * @access    protected
192
-     * @var boolean $_cache_on
193
-     */
194
-    protected $_cache_on = true;
195
-
196
-
197
-
198
-    /**
199
-     * @singleton method used to instantiate class object
200
-     * @access    public
201
-     * @param  \EE_Dependency_Map $dependency_map
202
-     * @return \EE_Registry instance
203
-     */
204
-    public static function instance(\EE_Dependency_Map $dependency_map = null)
205
-    {
206
-        // check if class object is instantiated
207
-        if ( ! self::$_instance instanceof EE_Registry) {
208
-            self::$_instance = new EE_Registry($dependency_map);
209
-        }
210
-        return self::$_instance;
211
-    }
212
-
213
-
214
-
215
-    /**
216
-     *protected constructor to prevent direct creation
217
-     *
218
-     * @Constructor
219
-     * @access protected
220
-     * @param  \EE_Dependency_Map $dependency_map
221
-     * @return \EE_Registry
222
-     */
223
-    protected function __construct(\EE_Dependency_Map $dependency_map)
224
-    {
225
-        $this->_dependency_map = $dependency_map;
226
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
227
-    }
228
-
229
-
230
-
231
-    /**
232
-     * initialize
233
-     */
234
-    public function initialize()
235
-    {
236
-        $this->_class_abbreviations = apply_filters(
237
-            'FHEE__EE_Registry____construct___class_abbreviations',
238
-            array(
239
-                'EE_Config'                                       => 'CFG',
240
-                'EE_Session'                                      => 'SSN',
241
-                'EE_Capabilities'                                 => 'CAP',
242
-                'EE_Cart'                                         => 'CART',
243
-                'EE_Network_Config'                               => 'NET_CFG',
244
-                'EE_Request_Handler'                              => 'REQ',
245
-                'EE_Message_Resource_Manager'                     => 'MRM',
246
-                'EventEspresso\core\services\commands\CommandBus' => 'BUS',
247
-            )
248
-        );
249
-        // class library
250
-        $this->LIB = new stdClass();
251
-        $this->addons = new stdClass();
252
-        $this->modules = new stdClass();
253
-        $this->shortcodes = new stdClass();
254
-        $this->widgets = new stdClass();
255
-        $this->load_core('Base', array(), true);
256
-        // add our request and response objects to the cache
257
-        $request_loader = $this->_dependency_map->class_loader('EE_Request');
258
-        $this->_set_cached_class(
259
-            $request_loader(),
260
-            'EE_Request'
261
-        );
262
-        $response_loader = $this->_dependency_map->class_loader('EE_Response');
263
-        $this->_set_cached_class(
264
-            $response_loader(),
265
-            'EE_Response'
266
-        );
267
-        add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
268
-    }
269
-
270
-
271
-
272
-    /**
273
-     *    init
274
-     *
275
-     * @access    public
276
-     * @return    void
277
-     */
278
-    public function init()
279
-    {
280
-        $this->AssetsRegistry = new Registry();
281
-        // Get current page protocol
282
-        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
283
-        // Output admin-ajax.php URL with same protocol as current page
284
-        self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
285
-        self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
286
-    }
287
-
288
-
289
-
290
-    /**
291
-     * localize_i18n_js_strings
292
-     *
293
-     * @return string
294
-     */
295
-    public static function localize_i18n_js_strings()
296
-    {
297
-        $i18n_js_strings = (array)EE_Registry::$i18n_js_strings;
298
-        foreach ($i18n_js_strings as $key => $value) {
299
-            if (is_scalar($value)) {
300
-                $i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
301
-            }
302
-        }
303
-        return "/* <![CDATA[ */ var eei18n = " . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
304
-    }
305
-
306
-
307
-
308
-    /**
309
-     * @param mixed string | EED_Module $module
310
-     */
311
-    public function add_module($module)
312
-    {
313
-        if ($module instanceof EED_Module) {
314
-            $module_class = get_class($module);
315
-            $this->modules->{$module_class} = $module;
316
-        } else {
317
-            if ( ! class_exists('EE_Module_Request_Router')) {
318
-                $this->load_core('Module_Request_Router');
319
-            }
320
-            $this->modules->{$module} = EE_Module_Request_Router::module_factory($module);
321
-        }
322
-    }
323
-
324
-
325
-
326
-    /**
327
-     * @param string $module_name
328
-     * @return mixed EED_Module | NULL
329
-     */
330
-    public function get_module($module_name = '')
331
-    {
332
-        return isset($this->modules->{$module_name}) ? $this->modules->{$module_name} : null;
333
-    }
334
-
335
-
336
-
337
-    /**
338
-     *    loads core classes - must be singletons
339
-     *
340
-     * @access    public
341
-     * @param string $class_name - simple class name ie: session
342
-     * @param mixed  $arguments
343
-     * @param bool   $load_only
344
-     * @return mixed
345
-     */
346
-    public function load_core($class_name, $arguments = array(), $load_only = false)
347
-    {
348
-        $core_paths = apply_filters(
349
-            'FHEE__EE_Registry__load_core__core_paths',
350
-            array(
351
-                EE_CORE,
352
-                EE_ADMIN,
353
-                EE_CPTS,
354
-                EE_CORE . 'data_migration_scripts' . DS,
355
-                EE_CORE . 'request_stack' . DS,
356
-                EE_CORE . 'middleware' . DS,
357
-            )
358
-        );
359
-        // retrieve instantiated class
360
-        return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only);
361
-    }
362
-
363
-
364
-
365
-    /**
366
-     *    loads service classes
367
-     *
368
-     * @access    public
369
-     * @param string $class_name - simple class name ie: session
370
-     * @param mixed  $arguments
371
-     * @param bool   $load_only
372
-     * @return mixed
373
-     */
374
-    public function load_service($class_name, $arguments = array(), $load_only = false)
375
-    {
376
-        $service_paths = apply_filters(
377
-            'FHEE__EE_Registry__load_service__service_paths',
378
-            array(
379
-                EE_CORE . 'services' . DS,
380
-            )
381
-        );
382
-        // retrieve instantiated class
383
-        return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only);
384
-    }
385
-
386
-
387
-
388
-    /**
389
-     *    loads data_migration_scripts
390
-     *
391
-     * @access    public
392
-     * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
393
-     * @param mixed  $arguments
394
-     * @return EE_Data_Migration_Script_Base|mixed
395
-     */
396
-    public function load_dms($class_name, $arguments = array())
397
-    {
398
-        // retrieve instantiated class
399
-        return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false);
400
-    }
401
-
402
-
403
-
404
-    /**
405
-     *    loads object creating classes - must be singletons
406
-     *
407
-     * @param string $class_name - simple class name ie: attendee
408
-     * @param mixed  $arguments  - an array of arguments to pass to the class
409
-     * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to instantiate
410
-     * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then set this to FALSE (ie. when instantiating model objects from client in a loop)
411
-     * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate (default)
412
-     * @return EE_Base_Class | bool
413
-     */
414
-    public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
415
-    {
416
-        $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array(
417
-            EE_CORE,
418
-            EE_CLASSES,
419
-            EE_BUSINESS,
420
-        ));
421
-        // retrieve instantiated class
422
-        return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only);
423
-    }
424
-
425
-
426
-
427
-    /**
428
-     *    loads helper classes - must be singletons
429
-     *
430
-     * @param string $class_name - simple class name ie: price
431
-     * @param mixed  $arguments
432
-     * @param bool   $load_only
433
-     * @return EEH_Base | bool
434
-     */
435
-    public function load_helper($class_name, $arguments = array(), $load_only = true)
436
-    {
437
-        // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
438
-        $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
439
-        // retrieve instantiated class
440
-        return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only);
441
-    }
442
-
443
-
444
-
445
-    /**
446
-     *    loads core classes - must be singletons
447
-     *
448
-     * @access    public
449
-     * @param string $class_name - simple class name ie: session
450
-     * @param mixed  $arguments
451
-     * @param bool   $load_only
452
-     * @param bool   $cache      whether to cache the object or not.
453
-     * @return mixed
454
-     */
455
-    public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
456
-    {
457
-        $paths = array(
458
-            EE_LIBRARIES,
459
-            EE_LIBRARIES . 'messages' . DS,
460
-            EE_LIBRARIES . 'shortcodes' . DS,
461
-            EE_LIBRARIES . 'qtips' . DS,
462
-            EE_LIBRARIES . 'payment_methods' . DS,
463
-        );
464
-        // retrieve instantiated class
465
-        return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only);
466
-    }
467
-
468
-
469
-
470
-    /**
471
-     *    loads model classes - must be singletons
472
-     *
473
-     * @param string $class_name - simple class name ie: price
474
-     * @param mixed  $arguments
475
-     * @param bool   $load_only
476
-     * @return EEM_Base | bool
477
-     */
478
-    public function load_model($class_name, $arguments = array(), $load_only = false)
479
-    {
480
-        $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array(
481
-            EE_MODELS,
482
-            EE_CORE,
483
-        ));
484
-        // retrieve instantiated class
485
-        return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only);
486
-    }
487
-
488
-
489
-
490
-    /**
491
-     *    loads model classes - must be singletons
492
-     *
493
-     * @param string $class_name - simple class name ie: price
494
-     * @param mixed  $arguments
495
-     * @param bool   $load_only
496
-     * @return mixed | bool
497
-     */
498
-    public function load_model_class($class_name, $arguments = array(), $load_only = true)
499
-    {
500
-        $paths = array(
501
-            EE_MODELS . 'fields' . DS,
502
-            EE_MODELS . 'helpers' . DS,
503
-            EE_MODELS . 'relations' . DS,
504
-            EE_MODELS . 'strategies' . DS,
505
-        );
506
-        // retrieve instantiated class
507
-        return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only);
508
-    }
509
-
510
-
511
-
512
-    /**
513
-     * Determines if $model_name is the name of an actual EE model.
514
-     *
515
-     * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
516
-     * @return boolean
517
-     */
518
-    public function is_model_name($model_name)
519
-    {
520
-        return isset($this->models[$model_name]) ? true : false;
521
-    }
522
-
523
-
524
-
525
-    /**
526
-     *    generic class loader
527
-     *
528
-     * @param string $path_to_file - directory path to file location, not including filename
529
-     * @param string $file_name    - file name  ie:  my_file.php, including extension
530
-     * @param string $type         - file type - core? class? helper? model?
531
-     * @param mixed  $arguments
532
-     * @param bool   $load_only
533
-     * @return mixed
534
-     */
535
-    public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
536
-    {
537
-        // retrieve instantiated class
538
-        return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only);
539
-    }
540
-
541
-
542
-
543
-    /**
544
-     *    load_addon
545
-     *
546
-     * @param string $path_to_file - directory path to file location, not including filename
547
-     * @param string $class_name   - full class name  ie:  My_Class
548
-     * @param string $type         - file type - core? class? helper? model?
549
-     * @param mixed  $arguments
550
-     * @param bool   $load_only
551
-     * @return EE_Addon
552
-     */
553
-    public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
554
-    {
555
-        // retrieve instantiated class
556
-        return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only);
557
-    }
558
-
559
-
560
-
561
-    /**
562
-     * instantiates, caches, and automatically resolves dependencies
563
-     * for classes that use a Fully Qualified Class Name.
564
-     * if the class is not capable of being loaded using PSR-4 autoloading,
565
-     * then you need to use one of the existing load_*() methods
566
-     * which can resolve the classname and filepath from the passed arguments
567
-     *
568
-     * @param bool|string $class_name   Fully Qualified Class Name
569
-     * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
570
-     * @param bool        $cache        whether to cache the instantiated object for reuse
571
-     * @param bool        $from_db      some classes are instantiated from the db
572
-     *                                  and thus call a different method to instantiate
573
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
574
-     * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
575
-     * @return mixed                    null = failure to load or instantiate class object.
576
-     *                                  object = class loaded and instantiated successfully.
577
-     *                                  bool = fail or success when $load_only is true
578
-     */
579
-    public function create(
580
-        $class_name = false,
581
-        $arguments = array(),
582
-        $cache = false,
583
-        $from_db = false,
584
-        $load_only = false,
585
-        $addon = false
586
-    ) {
587
-        $class_name = $this->_dependency_map->get_alias($class_name);
588
-        if ( ! class_exists($class_name)) {
589
-            // maybe the class is registered with a preceding \
590
-            $class_name = strpos($class_name, '\\') !== 0 ? '\\' . $class_name : $class_name;
591
-            // still doesn't exist ?
592
-            if ( ! class_exists($class_name)) {
593
-                return null;
594
-            }
595
-        }
596
-        // if we're only loading the class and it already exists, then let's just return true immediately
597
-        if ($load_only) {
598
-            return true;
599
-        }
600
-        $addon = $addon ? 'addon' : '';
601
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
602
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
603
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
604
-        if ($this->_cache_on && $cache && ! $load_only) {
605
-            // return object if it's already cached
606
-            $cached_class = $this->_get_cached_class($class_name, $addon);
607
-            if ($cached_class !== null) {
608
-                return $cached_class;
609
-            }
610
-        }
611
-        // instantiate the requested object
612
-        $class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
613
-        if ($this->_cache_on && $cache) {
614
-            // save it for later... kinda like gum  { : $
615
-            $this->_set_cached_class($class_obj, $class_name, $addon, $from_db);
616
-        }
617
-        $this->_cache_on = true;
618
-        return $class_obj;
619
-    }
620
-
621
-
622
-
623
-    /**
624
-     * instantiates, caches, and injects dependencies for classes
625
-     *
626
-     * @param array       $file_paths   an array of paths to folders to look in
627
-     * @param string      $class_prefix EE  or EEM or... ???
628
-     * @param bool|string $class_name   $class name
629
-     * @param string      $type         file type - core? class? helper? model?
630
-     * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
631
-     * @param bool        $from_db      some classes are instantiated from the db
632
-     *                                  and thus call a different method to instantiate
633
-     * @param bool        $cache        whether to cache the instantiated object for reuse
634
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
635
-     * @return null|object|bool         null = failure to load or instantiate class object.
636
-     *                                  object = class loaded and instantiated successfully.
637
-     *                                  bool = fail or success when $load_only is true
638
-     */
639
-    protected function _load(
640
-        $file_paths = array(),
641
-        $class_prefix = 'EE_',
642
-        $class_name = false,
643
-        $type = 'class',
644
-        $arguments = array(),
645
-        $from_db = false,
646
-        $cache = true,
647
-        $load_only = false
648
-    ) {
649
-        // strip php file extension
650
-        $class_name = str_replace('.php', '', trim($class_name));
651
-        // does the class have a prefix ?
652
-        if ( ! empty($class_prefix) && $class_prefix != 'addon') {
653
-            // make sure $class_prefix is uppercase
654
-            $class_prefix = strtoupper(trim($class_prefix));
655
-            // add class prefix ONCE!!!
656
-            $class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
657
-        }
658
-        $class_name = $this->_dependency_map->get_alias($class_name);
659
-        $class_exists = class_exists($class_name);
660
-        // if we're only loading the class and it already exists, then let's just return true immediately
661
-        if ($load_only && $class_exists) {
662
-            return true;
663
-        }
664
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
665
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
666
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
667
-        if ($this->_cache_on && $cache && ! $load_only) {
668
-            // return object if it's already cached
669
-            $cached_class = $this->_get_cached_class($class_name, $class_prefix);
670
-            if ($cached_class !== null) {
671
-                return $cached_class;
672
-            }
673
-        }
674
-        // if the class doesn't already exist.. then we need to try and find the file and load it
675
-        if ( ! $class_exists) {
676
-            // get full path to file
677
-            $path = $this->_resolve_path($class_name, $type, $file_paths);
678
-            // load the file
679
-            $loaded = $this->_require_file($path, $class_name, $type, $file_paths);
680
-            // if loading failed, or we are only loading a file but NOT instantiating an object
681
-            if ( ! $loaded || $load_only) {
682
-                // return boolean if only loading, or null if an object was expected
683
-                return $load_only ? $loaded : null;
684
-            }
685
-        }
686
-        // instantiate the requested object
687
-        $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
688
-        if ($this->_cache_on && $cache) {
689
-            // save it for later... kinda like gum  { : $
690
-            $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
691
-        }
692
-        $this->_cache_on = true;
693
-        return $class_obj;
694
-    }
695
-
696
-
697
-
698
-    /**
699
-     * _get_cached_class
700
-     * attempts to find a cached version of the requested class
701
-     * by looking in the following places:
702
-     *        $this->{$class_abbreviation}            ie:    $this->CART
703
-     *        $this->{$class_name}                        ie:    $this->Some_Class
704
-     *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
705
-     *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
706
-     *
707
-     * @access protected
708
-     * @param string $class_name
709
-     * @param string $class_prefix
710
-     * @return mixed
711
-     */
712
-    protected function _get_cached_class($class_name, $class_prefix = '')
713
-    {
714
-        if (isset($this->_class_abbreviations[$class_name])) {
715
-            $class_abbreviation = $this->_class_abbreviations[$class_name];
716
-        } else {
717
-            // have to specify something, but not anything that will conflict
718
-            $class_abbreviation = 'FANCY_BATMAN_PANTS';
719
-        }
720
-        // check if class has already been loaded, and return it if it has been
721
-        if (isset($this->{$class_abbreviation}) && ! is_null($this->{$class_abbreviation})) {
722
-            return $this->{$class_abbreviation};
723
-        } else if (isset ($this->{$class_name})) {
724
-            return $this->{$class_name};
725
-        } else if (isset ($this->LIB->{$class_name})) {
726
-            return $this->LIB->{$class_name};
727
-        } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name})) {
728
-            return $this->addons->{$class_name};
729
-        }
730
-        return null;
731
-    }
732
-
733
-
734
-
735
-    /**
736
-     * _resolve_path
737
-     * attempts to find a full valid filepath for the requested class.
738
-     * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
739
-     * then returns that path if the target file has been found and is readable
740
-     *
741
-     * @access protected
742
-     * @param string $class_name
743
-     * @param string $type
744
-     * @param array  $file_paths
745
-     * @return string | bool
746
-     */
747
-    protected function _resolve_path($class_name, $type = '', $file_paths = array())
748
-    {
749
-        // make sure $file_paths is an array
750
-        $file_paths = is_array($file_paths) ? $file_paths : array($file_paths);
751
-        // cycle thru paths
752
-        foreach ($file_paths as $key => $file_path) {
753
-            // convert all separators to proper DS, if no filepath, then use EE_CLASSES
754
-            $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES;
755
-            // prep file type
756
-            $type = ! empty($type) ? trim($type, '.') . '.' : '';
757
-            // build full file path
758
-            $file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
759
-            //does the file exist and can be read ?
760
-            if (is_readable($file_paths[$key])) {
761
-                return $file_paths[$key];
762
-            }
763
-        }
764
-        return false;
765
-    }
766
-
767
-
768
-
769
-    /**
770
-     * _require_file
771
-     * basically just performs a require_once()
772
-     * but with some error handling
773
-     *
774
-     * @access protected
775
-     * @param  string $path
776
-     * @param  string $class_name
777
-     * @param  string $type
778
-     * @param  array  $file_paths
779
-     * @return boolean
780
-     * @throws \EE_Error
781
-     */
782
-    protected function _require_file($path, $class_name, $type = '', $file_paths = array())
783
-    {
784
-        // don't give up! you gotta...
785
-        try {
786
-            //does the file exist and can it be read ?
787
-            if ( ! $path) {
788
-                // so sorry, can't find the file
789
-                throw new EE_Error (
790
-                    sprintf(
791
-                        __('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', 'event_espresso'),
792
-                        trim($type, '.'),
793
-                        $class_name,
794
-                        '<br />' . implode(',<br />', $file_paths)
795
-                    )
796
-                );
797
-            }
798
-            // get the file
799
-            require_once($path);
800
-            // if the class isn't already declared somewhere
801
-            if (class_exists($class_name, false) === false) {
802
-                // so sorry, not a class
803
-                throw new EE_Error(
804
-                    sprintf(
805
-                        __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
806
-                        $type,
807
-                        $path,
808
-                        $class_name
809
-                    )
810
-                );
811
-            }
812
-        } catch (EE_Error $e) {
813
-            $e->get_error();
814
-            return false;
815
-        }
816
-        return true;
817
-    }
818
-
819
-
820
-
821
-    /**
822
-     * _create_object
823
-     * Attempts to instantiate the requested class via any of the
824
-     * commonly used instantiation methods employed throughout EE.
825
-     * The priority for instantiation is as follows:
826
-     *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
827
-     *        - model objects via their 'new_instance_from_db' method
828
-     *        - model objects via their 'new_instance' method
829
-     *        - "singleton" classes" via their 'instance' method
830
-     *    - standard instantiable classes via their __constructor
831
-     * Prior to instantiation, if the classname exists in the dependency_map,
832
-     * then the constructor for the requested class will be examined to determine
833
-     * if any dependencies exist, and if they can be injected.
834
-     * If so, then those classes will be added to the array of arguments passed to the constructor
835
-     *
836
-     * @access protected
837
-     * @param string $class_name
838
-     * @param array  $arguments
839
-     * @param string $type
840
-     * @param bool   $from_db
841
-     * @return null | object
842
-     * @throws \EE_Error
843
-     */
844
-    protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
845
-    {
846
-        $class_obj = null;
847
-        $instantiation_mode = '0) none';
848
-        // don't give up! you gotta...
849
-        try {
850
-            // create reflection
851
-            $reflector = $this->get_ReflectionClass($class_name);
852
-            // make sure arguments are an array
853
-            $arguments = is_array($arguments) ? $arguments : array($arguments);
854
-            // and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
855
-            // else wrap it in an additional array so that it doesn't get split into multiple parameters
856
-            $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
857
-                ? $arguments
858
-                : array($arguments);
859
-            // attempt to inject dependencies ?
860
-            if ($this->_dependency_map->has($class_name)) {
861
-                $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
862
-            }
863
-            // instantiate the class if possible
864
-            if ($reflector->isAbstract()) {
865
-                // nothing to instantiate, loading file was enough
866
-                // does not throw an exception so $instantiation_mode is unused
867
-                // $instantiation_mode = "1) no constructor abstract class";
868
-                $class_obj = true;
869
-            } else if ($reflector->getConstructor() === null && $reflector->isInstantiable() && empty($arguments)) {
870
-                // no constructor = static methods only... nothing to instantiate, loading file was enough
871
-                $instantiation_mode = "2) no constructor but instantiable";
872
-                $class_obj = $reflector->newInstance();
873
-            } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
874
-                $instantiation_mode = "3) new_instance_from_db()";
875
-                $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
876
-            } else if (method_exists($class_name, 'new_instance')) {
877
-                $instantiation_mode = "4) new_instance()";
878
-                $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
879
-            } else if (method_exists($class_name, 'instance')) {
880
-                $instantiation_mode = "5) instance()";
881
-                $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
882
-            } else if ($reflector->isInstantiable()) {
883
-                $instantiation_mode = "6) constructor";
884
-                $class_obj = $reflector->newInstanceArgs($arguments);
885
-            } else {
886
-                // heh ? something's not right !
887
-                throw new EE_Error(
888
-                    sprintf(
889
-                        __('The %s file %s could not be instantiated.', 'event_espresso'),
890
-                        $type,
891
-                        $class_name
892
-                    )
893
-                );
894
-            }
895
-        } catch (Exception $e) {
896
-            if ( ! $e instanceof EE_Error) {
897
-                $e = new EE_Error(
898
-                    sprintf(
899
-                        __('The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso'),
900
-                        $class_name,
901
-                        '<br />',
902
-                        $e->getMessage(),
903
-                        $instantiation_mode
904
-                    )
905
-                );
906
-            }
907
-            $e->get_error();
908
-        }
909
-        return $class_obj;
910
-    }
911
-
912
-
913
-
914
-    /**
915
-     * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
916
-     * @param array $array
917
-     * @return bool
918
-     */
919
-    protected function _array_is_numerically_and_sequentially_indexed(array $array)
920
-    {
921
-        return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
922
-    }
923
-
924
-
925
-
926
-    /**
927
-     * getReflectionClass
928
-     * checks if a ReflectionClass object has already been generated for a class
929
-     * and returns that instead of creating a new one
930
-     *
931
-     * @access public
932
-     * @param string $class_name
933
-     * @return ReflectionClass
934
-     */
935
-    public function get_ReflectionClass($class_name)
936
-    {
937
-        if (
938
-            ! isset($this->_reflectors[$class_name])
939
-            || ! $this->_reflectors[$class_name] instanceof ReflectionClass
940
-        ) {
941
-            $this->_reflectors[$class_name] = new ReflectionClass($class_name);
942
-        }
943
-        return $this->_reflectors[$class_name];
944
-    }
945
-
946
-
947
-
948
-    /**
949
-     * _resolve_dependencies
950
-     * examines the constructor for the requested class to determine
951
-     * if any dependencies exist, and if they can be injected.
952
-     * If so, then those classes will be added to the array of arguments passed to the constructor
953
-     * PLZ NOTE: this is achieved by type hinting the constructor params
954
-     * For example:
955
-     *        if attempting to load a class "Foo" with the following constructor:
956
-     *        __construct( Bar $bar_class, Fighter $grohl_class )
957
-     *        then $bar_class and $grohl_class will be added to the $arguments array,
958
-     *        but only IF they are NOT already present in the incoming arguments array,
959
-     *        and the correct classes can be loaded
960
-     *
961
-     * @access protected
962
-     * @param ReflectionClass $reflector
963
-     * @param string          $class_name
964
-     * @param array           $arguments
965
-     * @return array
966
-     * @throws \ReflectionException
967
-     */
968
-    protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array())
969
-    {
970
-        // let's examine the constructor
971
-        $constructor = $reflector->getConstructor();
972
-        // whu? huh? nothing?
973
-        if ( ! $constructor) {
974
-            return $arguments;
975
-        }
976
-        // get constructor parameters
977
-        $params = $constructor->getParameters();
978
-        // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
979
-        $argument_keys = array_keys($arguments);
980
-        // now loop thru all of the constructors expected parameters
981
-        foreach ($params as $index => $param) {
982
-            // is this a dependency for a specific class ?
983
-            $param_class = $param->getClass() ? $param->getClass()->name : null;
984
-            if (
985
-                // param is not even a class
986
-                empty($param_class)
987
-                // and something already exists in the incoming arguments for this param
988
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
989
-            ) {
990
-                // so let's skip this argument and move on to the next
991
-                continue;
992
-            } else if (
993
-                // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
994
-                ! empty($param_class)
995
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
996
-                && $arguments[$argument_keys[$index]] instanceof $param_class
997
-            ) {
998
-                // skip this argument and move on to the next
999
-                continue;
1000
-            } else if (
1001
-                // parameter is type hinted as a class, and should be injected
1002
-                ! empty($param_class)
1003
-                && $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1004
-            ) {
1005
-                $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index);
1006
-            } else {
1007
-                try {
1008
-                    $arguments[$index] = $param->getDefaultValue();
1009
-                } catch (ReflectionException $e) {
1010
-                    throw new ReflectionException(
1011
-                        sprintf(
1012
-                            __('%1$s for parameter "$%2$s"', 'event_espresso'),
1013
-                            $e->getMessage(),
1014
-                            $param->getName()
1015
-                        )
1016
-                    );
1017
-                }
1018
-            }
1019
-        }
1020
-        return $arguments;
1021
-    }
1022
-
1023
-
1024
-
1025
-    /**
1026
-     * @access protected
1027
-     * @param string $class_name
1028
-     * @param string $param_class
1029
-     * @param array  $arguments
1030
-     * @param mixed  $index
1031
-     * @return array
1032
-     */
1033
-    protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1034
-    {
1035
-        $dependency = null;
1036
-        // should dependency be loaded from cache ?
1037
-        $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class)
1038
-                    !== EE_Dependency_Map::load_new_object
1039
-            ? true
1040
-            : false;
1041
-        // we might have a dependency...
1042
-        // let's MAYBE try and find it in our cache if that's what's been requested
1043
-        $cached_class = $cache_on ? $this->_get_cached_class($param_class) : null;
1044
-        // and grab it if it exists
1045
-        if ($cached_class instanceof $param_class) {
1046
-            $dependency = $cached_class;
1047
-        } else if ($param_class != $class_name) {
1048
-            // obtain the loader method from the dependency map
1049
-            $loader = $this->_dependency_map->class_loader($param_class);
1050
-            // is loader a custom closure ?
1051
-            if ($loader instanceof Closure) {
1052
-                $dependency = $loader();
1053
-            } else {
1054
-                // set the cache on property for the recursive loading call
1055
-                $this->_cache_on = $cache_on;
1056
-                // if not, then let's try and load it via the registry
1057
-                if (method_exists($this, $loader)) {
1058
-                    $dependency = $this->{$loader}($param_class);
1059
-                } else {
1060
-                    $dependency = $this->create($param_class, array(), $cache_on);
1061
-                }
1062
-            }
1063
-        }
1064
-        // did we successfully find the correct dependency ?
1065
-        if ($dependency instanceof $param_class) {
1066
-            // then let's inject it into the incoming array of arguments at the correct location
1067
-            if (isset($argument_keys[$index])) {
1068
-                $arguments[$argument_keys[$index]] = $dependency;
1069
-            } else {
1070
-                $arguments[$index] = $dependency;
1071
-            }
1072
-        }
1073
-        return $arguments;
1074
-    }
1075
-
1076
-
1077
-
1078
-    /**
1079
-     * _set_cached_class
1080
-     * attempts to cache the instantiated class locally
1081
-     * in one of the following places, in the following order:
1082
-     *        $this->{class_abbreviation}   ie:    $this->CART
1083
-     *        $this->{$class_name}          ie:    $this->Some_Class
1084
-     *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1085
-     *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1086
-     *
1087
-     * @access protected
1088
-     * @param object $class_obj
1089
-     * @param string $class_name
1090
-     * @param string $class_prefix
1091
-     * @param bool   $from_db
1092
-     * @return void
1093
-     */
1094
-    protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false)
1095
-    {
1096
-        if (empty($class_obj)) {
1097
-            return;
1098
-        }
1099
-        // return newly instantiated class
1100
-        if (isset($this->_class_abbreviations[$class_name])) {
1101
-            $class_abbreviation = $this->_class_abbreviations[$class_name];
1102
-            $this->{$class_abbreviation} = $class_obj;
1103
-        } else if (property_exists($this, $class_name)) {
1104
-            $this->{$class_name} = $class_obj;
1105
-        } else if ($class_prefix == 'addon') {
1106
-            $this->addons->{$class_name} = $class_obj;
1107
-        } else if ( ! $from_db) {
1108
-            $this->LIB->{$class_name} = $class_obj;
1109
-        }
1110
-    }
1111
-
1112
-
1113
-
1114
-    /**
1115
-     * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1116
-     *
1117
-     * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1118
-     *                          in the EE_Dependency_Map::$_class_loaders array,
1119
-     *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1120
-     * @param array  $arguments
1121
-     * @return object
1122
-     */
1123
-    public static function factory($classname, $arguments = array())
1124
-    {
1125
-        $loader = self::instance()->_dependency_map->class_loader($classname);
1126
-        if ($loader instanceof Closure) {
1127
-            return $loader($arguments);
1128
-        } else if (method_exists(EE_Registry::instance(), $loader)) {
1129
-            return EE_Registry::instance()->{$loader}($classname, $arguments);
1130
-        }
1131
-        return null;
1132
-    }
1133
-
1134
-
1135
-
1136
-    /**
1137
-     * Gets the addon by its name/slug (not classname. For that, just
1138
-     * use the classname as the property name on EE_Config::instance()->addons)
1139
-     *
1140
-     * @param string $name
1141
-     * @return EE_Addon
1142
-     */
1143
-    public function get_addon_by_name($name)
1144
-    {
1145
-        foreach ($this->addons as $addon) {
1146
-            if ($addon->name() == $name) {
1147
-                return $addon;
1148
-            }
1149
-        }
1150
-        return null;
1151
-    }
1152
-
1153
-
1154
-
1155
-    /**
1156
-     * Gets an array of all the registered addons, where the keys are their names. (ie, what each returns for their name() function) They're already available on EE_Config::instance()->addons as properties, where each property's name is
1157
-     * the addon's classname. So if you just want to get the addon by classname, use EE_Config::instance()->addons->{classname}
1158
-     *
1159
-     * @return EE_Addon[] where the KEYS are the addon's name()
1160
-     */
1161
-    public function get_addons_by_name()
1162
-    {
1163
-        $addons = array();
1164
-        foreach ($this->addons as $addon) {
1165
-            $addons[$addon->name()] = $addon;
1166
-        }
1167
-        return $addons;
1168
-    }
1169
-
1170
-
1171
-
1172
-    /**
1173
-     * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1174
-     * a stale copy of it around
1175
-     *
1176
-     * @param string $model_name
1177
-     * @return \EEM_Base
1178
-     * @throws \EE_Error
1179
-     */
1180
-    public function reset_model($model_name)
1181
-    {
1182
-        $model_class_name = strpos($model_name, 'EEM_') !== 0 ? "EEM_{$model_name}" : $model_name;
1183
-        if ( ! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1184
-            return null;
1185
-        }
1186
-        //get that model reset it and make sure we nuke the old reference to it
1187
-        if ($this->LIB->{$model_class_name} instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) {
1188
-            $this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1189
-        } else {
1190
-            throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1191
-        }
1192
-        return $this->LIB->{$model_class_name};
1193
-    }
1194
-
1195
-
1196
-
1197
-    /**
1198
-     * Resets the registry.
1199
-     * The criteria for what gets reset is based on what can be shared between sites on the same request when switch_to_blog
1200
-     * is used in a multisite install.  Here is a list of things that are NOT reset.
1201
-     * - $_dependency_map
1202
-     * - $_class_abbreviations
1203
-     * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1204
-     * - $REQ:  Still on the same request so no need to change.
1205
-     * - $CAP: There is no site specific state in the EE_Capability class.
1206
-     * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only one Session
1207
-     *         can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1208
-     * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1209
-     *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1210
-     *             switch or on the restore.
1211
-     * - $modules
1212
-     * - $shortcodes
1213
-     * - $widgets
1214
-     *
1215
-     * @param boolean $hard             whether to reset data in the database too, or just refresh
1216
-     *                                  the Registry to its state at the beginning of the request
1217
-     * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1218
-     *                                  or just reset without re-instantiating (handy to set to FALSE if you're not sure if you CAN
1219
-     *                                  currently reinstantiate the singletons at the moment)
1220
-     * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so client
1221
-     *                                  code instead can just change the model context to a different blog id if necessary
1222
-     * @return EE_Registry
1223
-     */
1224
-    public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1225
-    {
1226
-        $instance = self::instance();
1227
-        EEH_Activation::reset();
1228
-        //properties that get reset
1229
-        $instance->_cache_on = true;
1230
-        $instance->CFG = EE_Config::reset($hard, $reinstantiate);
1231
-        $instance->CART = null;
1232
-        $instance->MRM = null;
1233
-        $instance->AssetsRegistry = new Registry();
1234
-        //messages reset
1235
-        EED_Messages::reset();
1236
-        if ($reset_models) {
1237
-            foreach (array_keys($instance->non_abstract_db_models) as $model_name) {
1238
-                $instance->reset_model($model_name);
1239
-            }
1240
-        }
1241
-        $instance->LIB = new stdClass();
1242
-        return $instance;
1243
-    }
1244
-
1245
-
1246
-
1247
-    /**
1248
-     * @override magic methods
1249
-     * @return void
1250
-     */
1251
-    final function __destruct()
1252
-    {
1253
-    }
1254
-
1255
-
1256
-
1257
-    /**
1258
-     * @param $a
1259
-     * @param $b
1260
-     */
1261
-    final function __call($a, $b)
1262
-    {
1263
-    }
1264
-
1265
-
1266
-
1267
-    /**
1268
-     * @param $a
1269
-     */
1270
-    final function __get($a)
1271
-    {
1272
-    }
1273
-
1274
-
1275
-
1276
-    /**
1277
-     * @param $a
1278
-     * @param $b
1279
-     */
1280
-    final function __set($a, $b)
1281
-    {
1282
-    }
1283
-
1284
-
1285
-
1286
-    /**
1287
-     * @param $a
1288
-     */
1289
-    final function __isset($a)
1290
-    {
1291
-    }
19
+	/**
20
+	 *    EE_Registry Object
21
+	 *
22
+	 * @var EE_Registry $_instance
23
+	 * @access    private
24
+	 */
25
+	private static $_instance = null;
26
+
27
+	/**
28
+	 * @var EE_Dependency_Map $_dependency_map
29
+	 * @access    protected
30
+	 */
31
+	protected $_dependency_map = null;
32
+
33
+	/**
34
+	 * @var array $_class_abbreviations
35
+	 * @access    protected
36
+	 */
37
+	protected $_class_abbreviations = array();
38
+
39
+	/**
40
+	 * @access public
41
+	 * @var \EventEspresso\core\services\commands\CommandBusInterface $BUS
42
+	 */
43
+	public $BUS;
44
+
45
+	/**
46
+	 *    EE_Cart Object
47
+	 *
48
+	 * @access    public
49
+	 * @var    EE_Cart $CART
50
+	 */
51
+	public $CART = null;
52
+
53
+	/**
54
+	 *    EE_Config Object
55
+	 *
56
+	 * @access    public
57
+	 * @var    EE_Config $CFG
58
+	 */
59
+	public $CFG = null;
60
+
61
+	/**
62
+	 * EE_Network_Config Object
63
+	 *
64
+	 * @access public
65
+	 * @var EE_Network_Config $NET_CFG
66
+	 */
67
+	public $NET_CFG = null;
68
+
69
+	/**
70
+	 *    StdClass object for storing library classes in
71
+	 *
72
+	 * @public LIB
73
+	 * @var StdClass $LIB
74
+	 */
75
+	public $LIB = null;
76
+
77
+	/**
78
+	 *    EE_Request_Handler Object
79
+	 *
80
+	 * @access    public
81
+	 * @var    EE_Request_Handler $REQ
82
+	 */
83
+	public $REQ = null;
84
+
85
+	/**
86
+	 *    EE_Session Object
87
+	 *
88
+	 * @access    public
89
+	 * @var    EE_Session $SSN
90
+	 */
91
+	public $SSN = null;
92
+
93
+	/**
94
+	 * holds the ee capabilities object.
95
+	 *
96
+	 * @since 4.5.0
97
+	 * @var EE_Capabilities
98
+	 */
99
+	public $CAP = null;
100
+
101
+	/**
102
+	 * holds the EE_Message_Resource_Manager object.
103
+	 *
104
+	 * @since 4.9.0
105
+	 * @var EE_Message_Resource_Manager
106
+	 */
107
+	public $MRM = null;
108
+
109
+
110
+	/**
111
+	 * Holds the Assets Registry instance
112
+	 * @var Registry
113
+	 */
114
+	public $AssetsRegistry = null;
115
+
116
+	/**
117
+	 *    $addons - StdClass object for holding addons which have registered themselves to work with EE core
118
+	 *
119
+	 * @access    public
120
+	 * @var    EE_Addon[]
121
+	 */
122
+	public $addons = null;
123
+
124
+	/**
125
+	 *    $models
126
+	 * @access    public
127
+	 * @var    EEM_Base[] $models keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
128
+	 */
129
+	public $models = array();
130
+
131
+	/**
132
+	 *    $modules
133
+	 * @access    public
134
+	 * @var    EED_Module[] $modules
135
+	 */
136
+	public $modules = null;
137
+
138
+	/**
139
+	 *    $shortcodes
140
+	 * @access    public
141
+	 * @var    EES_Shortcode[] $shortcodes
142
+	 */
143
+	public $shortcodes = null;
144
+
145
+	/**
146
+	 *    $widgets
147
+	 * @access    public
148
+	 * @var    WP_Widget[] $widgets
149
+	 */
150
+	public $widgets = null;
151
+
152
+	/**
153
+	 * $non_abstract_db_models
154
+	 * @access public
155
+	 * @var array this is an array of all implemented model names (i.e. not the parent abstract models, or models
156
+	 * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
157
+	 * Keys are model "short names" (eg "Event") as used in model relations, and values are
158
+	 * classnames (eg "EEM_Event")
159
+	 */
160
+	public $non_abstract_db_models = array();
161
+
162
+	/**
163
+	 *    $i18n_js_strings - internationalization for JS strings
164
+	 *    usage:   EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' );
165
+	 *    in js file:  var translatedString = eei18n.string_key;
166
+	 *
167
+	 * @access    public
168
+	 * @var    array
169
+	 */
170
+	public static $i18n_js_strings = array();
171
+
172
+	/**
173
+	 *    $main_file - path to espresso.php
174
+	 *
175
+	 * @access    public
176
+	 * @var    array
177
+	 */
178
+	public $main_file;
179
+
180
+	/**
181
+	 * array of ReflectionClass objects where the key is the class name
182
+	 *
183
+	 * @access    public
184
+	 * @var ReflectionClass[]
185
+	 */
186
+	public $_reflectors;
187
+
188
+	/**
189
+	 * boolean flag to indicate whether or not to load/save dependencies from/to the cache
190
+	 *
191
+	 * @access    protected
192
+	 * @var boolean $_cache_on
193
+	 */
194
+	protected $_cache_on = true;
195
+
196
+
197
+
198
+	/**
199
+	 * @singleton method used to instantiate class object
200
+	 * @access    public
201
+	 * @param  \EE_Dependency_Map $dependency_map
202
+	 * @return \EE_Registry instance
203
+	 */
204
+	public static function instance(\EE_Dependency_Map $dependency_map = null)
205
+	{
206
+		// check if class object is instantiated
207
+		if ( ! self::$_instance instanceof EE_Registry) {
208
+			self::$_instance = new EE_Registry($dependency_map);
209
+		}
210
+		return self::$_instance;
211
+	}
212
+
213
+
214
+
215
+	/**
216
+	 *protected constructor to prevent direct creation
217
+	 *
218
+	 * @Constructor
219
+	 * @access protected
220
+	 * @param  \EE_Dependency_Map $dependency_map
221
+	 * @return \EE_Registry
222
+	 */
223
+	protected function __construct(\EE_Dependency_Map $dependency_map)
224
+	{
225
+		$this->_dependency_map = $dependency_map;
226
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
227
+	}
228
+
229
+
230
+
231
+	/**
232
+	 * initialize
233
+	 */
234
+	public function initialize()
235
+	{
236
+		$this->_class_abbreviations = apply_filters(
237
+			'FHEE__EE_Registry____construct___class_abbreviations',
238
+			array(
239
+				'EE_Config'                                       => 'CFG',
240
+				'EE_Session'                                      => 'SSN',
241
+				'EE_Capabilities'                                 => 'CAP',
242
+				'EE_Cart'                                         => 'CART',
243
+				'EE_Network_Config'                               => 'NET_CFG',
244
+				'EE_Request_Handler'                              => 'REQ',
245
+				'EE_Message_Resource_Manager'                     => 'MRM',
246
+				'EventEspresso\core\services\commands\CommandBus' => 'BUS',
247
+			)
248
+		);
249
+		// class library
250
+		$this->LIB = new stdClass();
251
+		$this->addons = new stdClass();
252
+		$this->modules = new stdClass();
253
+		$this->shortcodes = new stdClass();
254
+		$this->widgets = new stdClass();
255
+		$this->load_core('Base', array(), true);
256
+		// add our request and response objects to the cache
257
+		$request_loader = $this->_dependency_map->class_loader('EE_Request');
258
+		$this->_set_cached_class(
259
+			$request_loader(),
260
+			'EE_Request'
261
+		);
262
+		$response_loader = $this->_dependency_map->class_loader('EE_Response');
263
+		$this->_set_cached_class(
264
+			$response_loader(),
265
+			'EE_Response'
266
+		);
267
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
268
+	}
269
+
270
+
271
+
272
+	/**
273
+	 *    init
274
+	 *
275
+	 * @access    public
276
+	 * @return    void
277
+	 */
278
+	public function init()
279
+	{
280
+		$this->AssetsRegistry = new Registry();
281
+		// Get current page protocol
282
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
283
+		// Output admin-ajax.php URL with same protocol as current page
284
+		self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
285
+		self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
286
+	}
287
+
288
+
289
+
290
+	/**
291
+	 * localize_i18n_js_strings
292
+	 *
293
+	 * @return string
294
+	 */
295
+	public static function localize_i18n_js_strings()
296
+	{
297
+		$i18n_js_strings = (array)EE_Registry::$i18n_js_strings;
298
+		foreach ($i18n_js_strings as $key => $value) {
299
+			if (is_scalar($value)) {
300
+				$i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
301
+			}
302
+		}
303
+		return "/* <![CDATA[ */ var eei18n = " . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
304
+	}
305
+
306
+
307
+
308
+	/**
309
+	 * @param mixed string | EED_Module $module
310
+	 */
311
+	public function add_module($module)
312
+	{
313
+		if ($module instanceof EED_Module) {
314
+			$module_class = get_class($module);
315
+			$this->modules->{$module_class} = $module;
316
+		} else {
317
+			if ( ! class_exists('EE_Module_Request_Router')) {
318
+				$this->load_core('Module_Request_Router');
319
+			}
320
+			$this->modules->{$module} = EE_Module_Request_Router::module_factory($module);
321
+		}
322
+	}
323
+
324
+
325
+
326
+	/**
327
+	 * @param string $module_name
328
+	 * @return mixed EED_Module | NULL
329
+	 */
330
+	public function get_module($module_name = '')
331
+	{
332
+		return isset($this->modules->{$module_name}) ? $this->modules->{$module_name} : null;
333
+	}
334
+
335
+
336
+
337
+	/**
338
+	 *    loads core classes - must be singletons
339
+	 *
340
+	 * @access    public
341
+	 * @param string $class_name - simple class name ie: session
342
+	 * @param mixed  $arguments
343
+	 * @param bool   $load_only
344
+	 * @return mixed
345
+	 */
346
+	public function load_core($class_name, $arguments = array(), $load_only = false)
347
+	{
348
+		$core_paths = apply_filters(
349
+			'FHEE__EE_Registry__load_core__core_paths',
350
+			array(
351
+				EE_CORE,
352
+				EE_ADMIN,
353
+				EE_CPTS,
354
+				EE_CORE . 'data_migration_scripts' . DS,
355
+				EE_CORE . 'request_stack' . DS,
356
+				EE_CORE . 'middleware' . DS,
357
+			)
358
+		);
359
+		// retrieve instantiated class
360
+		return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only);
361
+	}
362
+
363
+
364
+
365
+	/**
366
+	 *    loads service classes
367
+	 *
368
+	 * @access    public
369
+	 * @param string $class_name - simple class name ie: session
370
+	 * @param mixed  $arguments
371
+	 * @param bool   $load_only
372
+	 * @return mixed
373
+	 */
374
+	public function load_service($class_name, $arguments = array(), $load_only = false)
375
+	{
376
+		$service_paths = apply_filters(
377
+			'FHEE__EE_Registry__load_service__service_paths',
378
+			array(
379
+				EE_CORE . 'services' . DS,
380
+			)
381
+		);
382
+		// retrieve instantiated class
383
+		return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only);
384
+	}
385
+
386
+
387
+
388
+	/**
389
+	 *    loads data_migration_scripts
390
+	 *
391
+	 * @access    public
392
+	 * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
393
+	 * @param mixed  $arguments
394
+	 * @return EE_Data_Migration_Script_Base|mixed
395
+	 */
396
+	public function load_dms($class_name, $arguments = array())
397
+	{
398
+		// retrieve instantiated class
399
+		return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false);
400
+	}
401
+
402
+
403
+
404
+	/**
405
+	 *    loads object creating classes - must be singletons
406
+	 *
407
+	 * @param string $class_name - simple class name ie: attendee
408
+	 * @param mixed  $arguments  - an array of arguments to pass to the class
409
+	 * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to instantiate
410
+	 * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then set this to FALSE (ie. when instantiating model objects from client in a loop)
411
+	 * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate (default)
412
+	 * @return EE_Base_Class | bool
413
+	 */
414
+	public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
415
+	{
416
+		$paths = apply_filters('FHEE__EE_Registry__load_class__paths', array(
417
+			EE_CORE,
418
+			EE_CLASSES,
419
+			EE_BUSINESS,
420
+		));
421
+		// retrieve instantiated class
422
+		return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only);
423
+	}
424
+
425
+
426
+
427
+	/**
428
+	 *    loads helper classes - must be singletons
429
+	 *
430
+	 * @param string $class_name - simple class name ie: price
431
+	 * @param mixed  $arguments
432
+	 * @param bool   $load_only
433
+	 * @return EEH_Base | bool
434
+	 */
435
+	public function load_helper($class_name, $arguments = array(), $load_only = true)
436
+	{
437
+		// todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
438
+		$helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
439
+		// retrieve instantiated class
440
+		return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only);
441
+	}
442
+
443
+
444
+
445
+	/**
446
+	 *    loads core classes - must be singletons
447
+	 *
448
+	 * @access    public
449
+	 * @param string $class_name - simple class name ie: session
450
+	 * @param mixed  $arguments
451
+	 * @param bool   $load_only
452
+	 * @param bool   $cache      whether to cache the object or not.
453
+	 * @return mixed
454
+	 */
455
+	public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
456
+	{
457
+		$paths = array(
458
+			EE_LIBRARIES,
459
+			EE_LIBRARIES . 'messages' . DS,
460
+			EE_LIBRARIES . 'shortcodes' . DS,
461
+			EE_LIBRARIES . 'qtips' . DS,
462
+			EE_LIBRARIES . 'payment_methods' . DS,
463
+		);
464
+		// retrieve instantiated class
465
+		return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only);
466
+	}
467
+
468
+
469
+
470
+	/**
471
+	 *    loads model classes - must be singletons
472
+	 *
473
+	 * @param string $class_name - simple class name ie: price
474
+	 * @param mixed  $arguments
475
+	 * @param bool   $load_only
476
+	 * @return EEM_Base | bool
477
+	 */
478
+	public function load_model($class_name, $arguments = array(), $load_only = false)
479
+	{
480
+		$paths = apply_filters('FHEE__EE_Registry__load_model__paths', array(
481
+			EE_MODELS,
482
+			EE_CORE,
483
+		));
484
+		// retrieve instantiated class
485
+		return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only);
486
+	}
487
+
488
+
489
+
490
+	/**
491
+	 *    loads model classes - must be singletons
492
+	 *
493
+	 * @param string $class_name - simple class name ie: price
494
+	 * @param mixed  $arguments
495
+	 * @param bool   $load_only
496
+	 * @return mixed | bool
497
+	 */
498
+	public function load_model_class($class_name, $arguments = array(), $load_only = true)
499
+	{
500
+		$paths = array(
501
+			EE_MODELS . 'fields' . DS,
502
+			EE_MODELS . 'helpers' . DS,
503
+			EE_MODELS . 'relations' . DS,
504
+			EE_MODELS . 'strategies' . DS,
505
+		);
506
+		// retrieve instantiated class
507
+		return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only);
508
+	}
509
+
510
+
511
+
512
+	/**
513
+	 * Determines if $model_name is the name of an actual EE model.
514
+	 *
515
+	 * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
516
+	 * @return boolean
517
+	 */
518
+	public function is_model_name($model_name)
519
+	{
520
+		return isset($this->models[$model_name]) ? true : false;
521
+	}
522
+
523
+
524
+
525
+	/**
526
+	 *    generic class loader
527
+	 *
528
+	 * @param string $path_to_file - directory path to file location, not including filename
529
+	 * @param string $file_name    - file name  ie:  my_file.php, including extension
530
+	 * @param string $type         - file type - core? class? helper? model?
531
+	 * @param mixed  $arguments
532
+	 * @param bool   $load_only
533
+	 * @return mixed
534
+	 */
535
+	public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
536
+	{
537
+		// retrieve instantiated class
538
+		return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only);
539
+	}
540
+
541
+
542
+
543
+	/**
544
+	 *    load_addon
545
+	 *
546
+	 * @param string $path_to_file - directory path to file location, not including filename
547
+	 * @param string $class_name   - full class name  ie:  My_Class
548
+	 * @param string $type         - file type - core? class? helper? model?
549
+	 * @param mixed  $arguments
550
+	 * @param bool   $load_only
551
+	 * @return EE_Addon
552
+	 */
553
+	public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
554
+	{
555
+		// retrieve instantiated class
556
+		return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only);
557
+	}
558
+
559
+
560
+
561
+	/**
562
+	 * instantiates, caches, and automatically resolves dependencies
563
+	 * for classes that use a Fully Qualified Class Name.
564
+	 * if the class is not capable of being loaded using PSR-4 autoloading,
565
+	 * then you need to use one of the existing load_*() methods
566
+	 * which can resolve the classname and filepath from the passed arguments
567
+	 *
568
+	 * @param bool|string $class_name   Fully Qualified Class Name
569
+	 * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
570
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
571
+	 * @param bool        $from_db      some classes are instantiated from the db
572
+	 *                                  and thus call a different method to instantiate
573
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
574
+	 * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
575
+	 * @return mixed                    null = failure to load or instantiate class object.
576
+	 *                                  object = class loaded and instantiated successfully.
577
+	 *                                  bool = fail or success when $load_only is true
578
+	 */
579
+	public function create(
580
+		$class_name = false,
581
+		$arguments = array(),
582
+		$cache = false,
583
+		$from_db = false,
584
+		$load_only = false,
585
+		$addon = false
586
+	) {
587
+		$class_name = $this->_dependency_map->get_alias($class_name);
588
+		if ( ! class_exists($class_name)) {
589
+			// maybe the class is registered with a preceding \
590
+			$class_name = strpos($class_name, '\\') !== 0 ? '\\' . $class_name : $class_name;
591
+			// still doesn't exist ?
592
+			if ( ! class_exists($class_name)) {
593
+				return null;
594
+			}
595
+		}
596
+		// if we're only loading the class and it already exists, then let's just return true immediately
597
+		if ($load_only) {
598
+			return true;
599
+		}
600
+		$addon = $addon ? 'addon' : '';
601
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
602
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
603
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
604
+		if ($this->_cache_on && $cache && ! $load_only) {
605
+			// return object if it's already cached
606
+			$cached_class = $this->_get_cached_class($class_name, $addon);
607
+			if ($cached_class !== null) {
608
+				return $cached_class;
609
+			}
610
+		}
611
+		// instantiate the requested object
612
+		$class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
613
+		if ($this->_cache_on && $cache) {
614
+			// save it for later... kinda like gum  { : $
615
+			$this->_set_cached_class($class_obj, $class_name, $addon, $from_db);
616
+		}
617
+		$this->_cache_on = true;
618
+		return $class_obj;
619
+	}
620
+
621
+
622
+
623
+	/**
624
+	 * instantiates, caches, and injects dependencies for classes
625
+	 *
626
+	 * @param array       $file_paths   an array of paths to folders to look in
627
+	 * @param string      $class_prefix EE  or EEM or... ???
628
+	 * @param bool|string $class_name   $class name
629
+	 * @param string      $type         file type - core? class? helper? model?
630
+	 * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
631
+	 * @param bool        $from_db      some classes are instantiated from the db
632
+	 *                                  and thus call a different method to instantiate
633
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
634
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
635
+	 * @return null|object|bool         null = failure to load or instantiate class object.
636
+	 *                                  object = class loaded and instantiated successfully.
637
+	 *                                  bool = fail or success when $load_only is true
638
+	 */
639
+	protected function _load(
640
+		$file_paths = array(),
641
+		$class_prefix = 'EE_',
642
+		$class_name = false,
643
+		$type = 'class',
644
+		$arguments = array(),
645
+		$from_db = false,
646
+		$cache = true,
647
+		$load_only = false
648
+	) {
649
+		// strip php file extension
650
+		$class_name = str_replace('.php', '', trim($class_name));
651
+		// does the class have a prefix ?
652
+		if ( ! empty($class_prefix) && $class_prefix != 'addon') {
653
+			// make sure $class_prefix is uppercase
654
+			$class_prefix = strtoupper(trim($class_prefix));
655
+			// add class prefix ONCE!!!
656
+			$class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
657
+		}
658
+		$class_name = $this->_dependency_map->get_alias($class_name);
659
+		$class_exists = class_exists($class_name);
660
+		// if we're only loading the class and it already exists, then let's just return true immediately
661
+		if ($load_only && $class_exists) {
662
+			return true;
663
+		}
664
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
665
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
666
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
667
+		if ($this->_cache_on && $cache && ! $load_only) {
668
+			// return object if it's already cached
669
+			$cached_class = $this->_get_cached_class($class_name, $class_prefix);
670
+			if ($cached_class !== null) {
671
+				return $cached_class;
672
+			}
673
+		}
674
+		// if the class doesn't already exist.. then we need to try and find the file and load it
675
+		if ( ! $class_exists) {
676
+			// get full path to file
677
+			$path = $this->_resolve_path($class_name, $type, $file_paths);
678
+			// load the file
679
+			$loaded = $this->_require_file($path, $class_name, $type, $file_paths);
680
+			// if loading failed, or we are only loading a file but NOT instantiating an object
681
+			if ( ! $loaded || $load_only) {
682
+				// return boolean if only loading, or null if an object was expected
683
+				return $load_only ? $loaded : null;
684
+			}
685
+		}
686
+		// instantiate the requested object
687
+		$class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
688
+		if ($this->_cache_on && $cache) {
689
+			// save it for later... kinda like gum  { : $
690
+			$this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
691
+		}
692
+		$this->_cache_on = true;
693
+		return $class_obj;
694
+	}
695
+
696
+
697
+
698
+	/**
699
+	 * _get_cached_class
700
+	 * attempts to find a cached version of the requested class
701
+	 * by looking in the following places:
702
+	 *        $this->{$class_abbreviation}            ie:    $this->CART
703
+	 *        $this->{$class_name}                        ie:    $this->Some_Class
704
+	 *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
705
+	 *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
706
+	 *
707
+	 * @access protected
708
+	 * @param string $class_name
709
+	 * @param string $class_prefix
710
+	 * @return mixed
711
+	 */
712
+	protected function _get_cached_class($class_name, $class_prefix = '')
713
+	{
714
+		if (isset($this->_class_abbreviations[$class_name])) {
715
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
716
+		} else {
717
+			// have to specify something, but not anything that will conflict
718
+			$class_abbreviation = 'FANCY_BATMAN_PANTS';
719
+		}
720
+		// check if class has already been loaded, and return it if it has been
721
+		if (isset($this->{$class_abbreviation}) && ! is_null($this->{$class_abbreviation})) {
722
+			return $this->{$class_abbreviation};
723
+		} else if (isset ($this->{$class_name})) {
724
+			return $this->{$class_name};
725
+		} else if (isset ($this->LIB->{$class_name})) {
726
+			return $this->LIB->{$class_name};
727
+		} else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name})) {
728
+			return $this->addons->{$class_name};
729
+		}
730
+		return null;
731
+	}
732
+
733
+
734
+
735
+	/**
736
+	 * _resolve_path
737
+	 * attempts to find a full valid filepath for the requested class.
738
+	 * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
739
+	 * then returns that path if the target file has been found and is readable
740
+	 *
741
+	 * @access protected
742
+	 * @param string $class_name
743
+	 * @param string $type
744
+	 * @param array  $file_paths
745
+	 * @return string | bool
746
+	 */
747
+	protected function _resolve_path($class_name, $type = '', $file_paths = array())
748
+	{
749
+		// make sure $file_paths is an array
750
+		$file_paths = is_array($file_paths) ? $file_paths : array($file_paths);
751
+		// cycle thru paths
752
+		foreach ($file_paths as $key => $file_path) {
753
+			// convert all separators to proper DS, if no filepath, then use EE_CLASSES
754
+			$file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES;
755
+			// prep file type
756
+			$type = ! empty($type) ? trim($type, '.') . '.' : '';
757
+			// build full file path
758
+			$file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
759
+			//does the file exist and can be read ?
760
+			if (is_readable($file_paths[$key])) {
761
+				return $file_paths[$key];
762
+			}
763
+		}
764
+		return false;
765
+	}
766
+
767
+
768
+
769
+	/**
770
+	 * _require_file
771
+	 * basically just performs a require_once()
772
+	 * but with some error handling
773
+	 *
774
+	 * @access protected
775
+	 * @param  string $path
776
+	 * @param  string $class_name
777
+	 * @param  string $type
778
+	 * @param  array  $file_paths
779
+	 * @return boolean
780
+	 * @throws \EE_Error
781
+	 */
782
+	protected function _require_file($path, $class_name, $type = '', $file_paths = array())
783
+	{
784
+		// don't give up! you gotta...
785
+		try {
786
+			//does the file exist and can it be read ?
787
+			if ( ! $path) {
788
+				// so sorry, can't find the file
789
+				throw new EE_Error (
790
+					sprintf(
791
+						__('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', 'event_espresso'),
792
+						trim($type, '.'),
793
+						$class_name,
794
+						'<br />' . implode(',<br />', $file_paths)
795
+					)
796
+				);
797
+			}
798
+			// get the file
799
+			require_once($path);
800
+			// if the class isn't already declared somewhere
801
+			if (class_exists($class_name, false) === false) {
802
+				// so sorry, not a class
803
+				throw new EE_Error(
804
+					sprintf(
805
+						__('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
806
+						$type,
807
+						$path,
808
+						$class_name
809
+					)
810
+				);
811
+			}
812
+		} catch (EE_Error $e) {
813
+			$e->get_error();
814
+			return false;
815
+		}
816
+		return true;
817
+	}
818
+
819
+
820
+
821
+	/**
822
+	 * _create_object
823
+	 * Attempts to instantiate the requested class via any of the
824
+	 * commonly used instantiation methods employed throughout EE.
825
+	 * The priority for instantiation is as follows:
826
+	 *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
827
+	 *        - model objects via their 'new_instance_from_db' method
828
+	 *        - model objects via their 'new_instance' method
829
+	 *        - "singleton" classes" via their 'instance' method
830
+	 *    - standard instantiable classes via their __constructor
831
+	 * Prior to instantiation, if the classname exists in the dependency_map,
832
+	 * then the constructor for the requested class will be examined to determine
833
+	 * if any dependencies exist, and if they can be injected.
834
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
835
+	 *
836
+	 * @access protected
837
+	 * @param string $class_name
838
+	 * @param array  $arguments
839
+	 * @param string $type
840
+	 * @param bool   $from_db
841
+	 * @return null | object
842
+	 * @throws \EE_Error
843
+	 */
844
+	protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
845
+	{
846
+		$class_obj = null;
847
+		$instantiation_mode = '0) none';
848
+		// don't give up! you gotta...
849
+		try {
850
+			// create reflection
851
+			$reflector = $this->get_ReflectionClass($class_name);
852
+			// make sure arguments are an array
853
+			$arguments = is_array($arguments) ? $arguments : array($arguments);
854
+			// and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
855
+			// else wrap it in an additional array so that it doesn't get split into multiple parameters
856
+			$arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
857
+				? $arguments
858
+				: array($arguments);
859
+			// attempt to inject dependencies ?
860
+			if ($this->_dependency_map->has($class_name)) {
861
+				$arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
862
+			}
863
+			// instantiate the class if possible
864
+			if ($reflector->isAbstract()) {
865
+				// nothing to instantiate, loading file was enough
866
+				// does not throw an exception so $instantiation_mode is unused
867
+				// $instantiation_mode = "1) no constructor abstract class";
868
+				$class_obj = true;
869
+			} else if ($reflector->getConstructor() === null && $reflector->isInstantiable() && empty($arguments)) {
870
+				// no constructor = static methods only... nothing to instantiate, loading file was enough
871
+				$instantiation_mode = "2) no constructor but instantiable";
872
+				$class_obj = $reflector->newInstance();
873
+			} else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
874
+				$instantiation_mode = "3) new_instance_from_db()";
875
+				$class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
876
+			} else if (method_exists($class_name, 'new_instance')) {
877
+				$instantiation_mode = "4) new_instance()";
878
+				$class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
879
+			} else if (method_exists($class_name, 'instance')) {
880
+				$instantiation_mode = "5) instance()";
881
+				$class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
882
+			} else if ($reflector->isInstantiable()) {
883
+				$instantiation_mode = "6) constructor";
884
+				$class_obj = $reflector->newInstanceArgs($arguments);
885
+			} else {
886
+				// heh ? something's not right !
887
+				throw new EE_Error(
888
+					sprintf(
889
+						__('The %s file %s could not be instantiated.', 'event_espresso'),
890
+						$type,
891
+						$class_name
892
+					)
893
+				);
894
+			}
895
+		} catch (Exception $e) {
896
+			if ( ! $e instanceof EE_Error) {
897
+				$e = new EE_Error(
898
+					sprintf(
899
+						__('The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso'),
900
+						$class_name,
901
+						'<br />',
902
+						$e->getMessage(),
903
+						$instantiation_mode
904
+					)
905
+				);
906
+			}
907
+			$e->get_error();
908
+		}
909
+		return $class_obj;
910
+	}
911
+
912
+
913
+
914
+	/**
915
+	 * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
916
+	 * @param array $array
917
+	 * @return bool
918
+	 */
919
+	protected function _array_is_numerically_and_sequentially_indexed(array $array)
920
+	{
921
+		return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
922
+	}
923
+
924
+
925
+
926
+	/**
927
+	 * getReflectionClass
928
+	 * checks if a ReflectionClass object has already been generated for a class
929
+	 * and returns that instead of creating a new one
930
+	 *
931
+	 * @access public
932
+	 * @param string $class_name
933
+	 * @return ReflectionClass
934
+	 */
935
+	public function get_ReflectionClass($class_name)
936
+	{
937
+		if (
938
+			! isset($this->_reflectors[$class_name])
939
+			|| ! $this->_reflectors[$class_name] instanceof ReflectionClass
940
+		) {
941
+			$this->_reflectors[$class_name] = new ReflectionClass($class_name);
942
+		}
943
+		return $this->_reflectors[$class_name];
944
+	}
945
+
946
+
947
+
948
+	/**
949
+	 * _resolve_dependencies
950
+	 * examines the constructor for the requested class to determine
951
+	 * if any dependencies exist, and if they can be injected.
952
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
953
+	 * PLZ NOTE: this is achieved by type hinting the constructor params
954
+	 * For example:
955
+	 *        if attempting to load a class "Foo" with the following constructor:
956
+	 *        __construct( Bar $bar_class, Fighter $grohl_class )
957
+	 *        then $bar_class and $grohl_class will be added to the $arguments array,
958
+	 *        but only IF they are NOT already present in the incoming arguments array,
959
+	 *        and the correct classes can be loaded
960
+	 *
961
+	 * @access protected
962
+	 * @param ReflectionClass $reflector
963
+	 * @param string          $class_name
964
+	 * @param array           $arguments
965
+	 * @return array
966
+	 * @throws \ReflectionException
967
+	 */
968
+	protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array())
969
+	{
970
+		// let's examine the constructor
971
+		$constructor = $reflector->getConstructor();
972
+		// whu? huh? nothing?
973
+		if ( ! $constructor) {
974
+			return $arguments;
975
+		}
976
+		// get constructor parameters
977
+		$params = $constructor->getParameters();
978
+		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
979
+		$argument_keys = array_keys($arguments);
980
+		// now loop thru all of the constructors expected parameters
981
+		foreach ($params as $index => $param) {
982
+			// is this a dependency for a specific class ?
983
+			$param_class = $param->getClass() ? $param->getClass()->name : null;
984
+			if (
985
+				// param is not even a class
986
+				empty($param_class)
987
+				// and something already exists in the incoming arguments for this param
988
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
989
+			) {
990
+				// so let's skip this argument and move on to the next
991
+				continue;
992
+			} else if (
993
+				// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
994
+				! empty($param_class)
995
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
996
+				&& $arguments[$argument_keys[$index]] instanceof $param_class
997
+			) {
998
+				// skip this argument and move on to the next
999
+				continue;
1000
+			} else if (
1001
+				// parameter is type hinted as a class, and should be injected
1002
+				! empty($param_class)
1003
+				&& $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1004
+			) {
1005
+				$arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index);
1006
+			} else {
1007
+				try {
1008
+					$arguments[$index] = $param->getDefaultValue();
1009
+				} catch (ReflectionException $e) {
1010
+					throw new ReflectionException(
1011
+						sprintf(
1012
+							__('%1$s for parameter "$%2$s"', 'event_espresso'),
1013
+							$e->getMessage(),
1014
+							$param->getName()
1015
+						)
1016
+					);
1017
+				}
1018
+			}
1019
+		}
1020
+		return $arguments;
1021
+	}
1022
+
1023
+
1024
+
1025
+	/**
1026
+	 * @access protected
1027
+	 * @param string $class_name
1028
+	 * @param string $param_class
1029
+	 * @param array  $arguments
1030
+	 * @param mixed  $index
1031
+	 * @return array
1032
+	 */
1033
+	protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1034
+	{
1035
+		$dependency = null;
1036
+		// should dependency be loaded from cache ?
1037
+		$cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class)
1038
+					!== EE_Dependency_Map::load_new_object
1039
+			? true
1040
+			: false;
1041
+		// we might have a dependency...
1042
+		// let's MAYBE try and find it in our cache if that's what's been requested
1043
+		$cached_class = $cache_on ? $this->_get_cached_class($param_class) : null;
1044
+		// and grab it if it exists
1045
+		if ($cached_class instanceof $param_class) {
1046
+			$dependency = $cached_class;
1047
+		} else if ($param_class != $class_name) {
1048
+			// obtain the loader method from the dependency map
1049
+			$loader = $this->_dependency_map->class_loader($param_class);
1050
+			// is loader a custom closure ?
1051
+			if ($loader instanceof Closure) {
1052
+				$dependency = $loader();
1053
+			} else {
1054
+				// set the cache on property for the recursive loading call
1055
+				$this->_cache_on = $cache_on;
1056
+				// if not, then let's try and load it via the registry
1057
+				if (method_exists($this, $loader)) {
1058
+					$dependency = $this->{$loader}($param_class);
1059
+				} else {
1060
+					$dependency = $this->create($param_class, array(), $cache_on);
1061
+				}
1062
+			}
1063
+		}
1064
+		// did we successfully find the correct dependency ?
1065
+		if ($dependency instanceof $param_class) {
1066
+			// then let's inject it into the incoming array of arguments at the correct location
1067
+			if (isset($argument_keys[$index])) {
1068
+				$arguments[$argument_keys[$index]] = $dependency;
1069
+			} else {
1070
+				$arguments[$index] = $dependency;
1071
+			}
1072
+		}
1073
+		return $arguments;
1074
+	}
1075
+
1076
+
1077
+
1078
+	/**
1079
+	 * _set_cached_class
1080
+	 * attempts to cache the instantiated class locally
1081
+	 * in one of the following places, in the following order:
1082
+	 *        $this->{class_abbreviation}   ie:    $this->CART
1083
+	 *        $this->{$class_name}          ie:    $this->Some_Class
1084
+	 *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1085
+	 *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1086
+	 *
1087
+	 * @access protected
1088
+	 * @param object $class_obj
1089
+	 * @param string $class_name
1090
+	 * @param string $class_prefix
1091
+	 * @param bool   $from_db
1092
+	 * @return void
1093
+	 */
1094
+	protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false)
1095
+	{
1096
+		if (empty($class_obj)) {
1097
+			return;
1098
+		}
1099
+		// return newly instantiated class
1100
+		if (isset($this->_class_abbreviations[$class_name])) {
1101
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
1102
+			$this->{$class_abbreviation} = $class_obj;
1103
+		} else if (property_exists($this, $class_name)) {
1104
+			$this->{$class_name} = $class_obj;
1105
+		} else if ($class_prefix == 'addon') {
1106
+			$this->addons->{$class_name} = $class_obj;
1107
+		} else if ( ! $from_db) {
1108
+			$this->LIB->{$class_name} = $class_obj;
1109
+		}
1110
+	}
1111
+
1112
+
1113
+
1114
+	/**
1115
+	 * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1116
+	 *
1117
+	 * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1118
+	 *                          in the EE_Dependency_Map::$_class_loaders array,
1119
+	 *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1120
+	 * @param array  $arguments
1121
+	 * @return object
1122
+	 */
1123
+	public static function factory($classname, $arguments = array())
1124
+	{
1125
+		$loader = self::instance()->_dependency_map->class_loader($classname);
1126
+		if ($loader instanceof Closure) {
1127
+			return $loader($arguments);
1128
+		} else if (method_exists(EE_Registry::instance(), $loader)) {
1129
+			return EE_Registry::instance()->{$loader}($classname, $arguments);
1130
+		}
1131
+		return null;
1132
+	}
1133
+
1134
+
1135
+
1136
+	/**
1137
+	 * Gets the addon by its name/slug (not classname. For that, just
1138
+	 * use the classname as the property name on EE_Config::instance()->addons)
1139
+	 *
1140
+	 * @param string $name
1141
+	 * @return EE_Addon
1142
+	 */
1143
+	public function get_addon_by_name($name)
1144
+	{
1145
+		foreach ($this->addons as $addon) {
1146
+			if ($addon->name() == $name) {
1147
+				return $addon;
1148
+			}
1149
+		}
1150
+		return null;
1151
+	}
1152
+
1153
+
1154
+
1155
+	/**
1156
+	 * Gets an array of all the registered addons, where the keys are their names. (ie, what each returns for their name() function) They're already available on EE_Config::instance()->addons as properties, where each property's name is
1157
+	 * the addon's classname. So if you just want to get the addon by classname, use EE_Config::instance()->addons->{classname}
1158
+	 *
1159
+	 * @return EE_Addon[] where the KEYS are the addon's name()
1160
+	 */
1161
+	public function get_addons_by_name()
1162
+	{
1163
+		$addons = array();
1164
+		foreach ($this->addons as $addon) {
1165
+			$addons[$addon->name()] = $addon;
1166
+		}
1167
+		return $addons;
1168
+	}
1169
+
1170
+
1171
+
1172
+	/**
1173
+	 * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1174
+	 * a stale copy of it around
1175
+	 *
1176
+	 * @param string $model_name
1177
+	 * @return \EEM_Base
1178
+	 * @throws \EE_Error
1179
+	 */
1180
+	public function reset_model($model_name)
1181
+	{
1182
+		$model_class_name = strpos($model_name, 'EEM_') !== 0 ? "EEM_{$model_name}" : $model_name;
1183
+		if ( ! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1184
+			return null;
1185
+		}
1186
+		//get that model reset it and make sure we nuke the old reference to it
1187
+		if ($this->LIB->{$model_class_name} instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) {
1188
+			$this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1189
+		} else {
1190
+			throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1191
+		}
1192
+		return $this->LIB->{$model_class_name};
1193
+	}
1194
+
1195
+
1196
+
1197
+	/**
1198
+	 * Resets the registry.
1199
+	 * The criteria for what gets reset is based on what can be shared between sites on the same request when switch_to_blog
1200
+	 * is used in a multisite install.  Here is a list of things that are NOT reset.
1201
+	 * - $_dependency_map
1202
+	 * - $_class_abbreviations
1203
+	 * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1204
+	 * - $REQ:  Still on the same request so no need to change.
1205
+	 * - $CAP: There is no site specific state in the EE_Capability class.
1206
+	 * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only one Session
1207
+	 *         can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1208
+	 * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1209
+	 *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1210
+	 *             switch or on the restore.
1211
+	 * - $modules
1212
+	 * - $shortcodes
1213
+	 * - $widgets
1214
+	 *
1215
+	 * @param boolean $hard             whether to reset data in the database too, or just refresh
1216
+	 *                                  the Registry to its state at the beginning of the request
1217
+	 * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1218
+	 *                                  or just reset without re-instantiating (handy to set to FALSE if you're not sure if you CAN
1219
+	 *                                  currently reinstantiate the singletons at the moment)
1220
+	 * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so client
1221
+	 *                                  code instead can just change the model context to a different blog id if necessary
1222
+	 * @return EE_Registry
1223
+	 */
1224
+	public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1225
+	{
1226
+		$instance = self::instance();
1227
+		EEH_Activation::reset();
1228
+		//properties that get reset
1229
+		$instance->_cache_on = true;
1230
+		$instance->CFG = EE_Config::reset($hard, $reinstantiate);
1231
+		$instance->CART = null;
1232
+		$instance->MRM = null;
1233
+		$instance->AssetsRegistry = new Registry();
1234
+		//messages reset
1235
+		EED_Messages::reset();
1236
+		if ($reset_models) {
1237
+			foreach (array_keys($instance->non_abstract_db_models) as $model_name) {
1238
+				$instance->reset_model($model_name);
1239
+			}
1240
+		}
1241
+		$instance->LIB = new stdClass();
1242
+		return $instance;
1243
+	}
1244
+
1245
+
1246
+
1247
+	/**
1248
+	 * @override magic methods
1249
+	 * @return void
1250
+	 */
1251
+	final function __destruct()
1252
+	{
1253
+	}
1254
+
1255
+
1256
+
1257
+	/**
1258
+	 * @param $a
1259
+	 * @param $b
1260
+	 */
1261
+	final function __call($a, $b)
1262
+	{
1263
+	}
1264
+
1265
+
1266
+
1267
+	/**
1268
+	 * @param $a
1269
+	 */
1270
+	final function __get($a)
1271
+	{
1272
+	}
1273
+
1274
+
1275
+
1276
+	/**
1277
+	 * @param $a
1278
+	 * @param $b
1279
+	 */
1280
+	final function __set($a, $b)
1281
+	{
1282
+	}
1283
+
1284
+
1285
+
1286
+	/**
1287
+	 * @param $a
1288
+	 */
1289
+	final function __isset($a)
1290
+	{
1291
+	}
1292 1292
 
1293 1293
 
1294 1294
 
1295
-    /**
1296
-     * @param $a
1297
-     */
1298
-    final function __unset($a)
1299
-    {
1300
-    }
1295
+	/**
1296
+	 * @param $a
1297
+	 */
1298
+	final function __unset($a)
1299
+	{
1300
+	}
1301 1301
 
1302 1302
 
1303 1303
 
1304
-    /**
1305
-     * @return array
1306
-     */
1307
-    final function __sleep()
1308
-    {
1309
-        return array();
1310
-    }
1304
+	/**
1305
+	 * @return array
1306
+	 */
1307
+	final function __sleep()
1308
+	{
1309
+		return array();
1310
+	}
1311 1311
 
1312 1312
 
1313 1313
 
1314
-    final function __wakeup()
1315
-    {
1316
-    }
1314
+	final function __wakeup()
1315
+	{
1316
+	}
1317 1317
 
1318 1318
 
1319 1319
 
1320
-    /**
1321
-     * @return string
1322
-     */
1323
-    final function __toString()
1324
-    {
1325
-        return '';
1326
-    }
1320
+	/**
1321
+	 * @return string
1322
+	 */
1323
+	final function __toString()
1324
+	{
1325
+		return '';
1326
+	}
1327 1327
 
1328 1328
 
1329 1329
 
1330
-    final function __invoke()
1331
-    {
1332
-    }
1330
+	final function __invoke()
1331
+	{
1332
+	}
1333 1333
 
1334 1334
 
1335 1335
 
1336
-    final function __set_state()
1337
-    {
1338
-    }
1336
+	final function __set_state()
1337
+	{
1338
+	}
1339 1339
 
1340 1340
 
1341 1341
 
1342
-    final function __clone()
1343
-    {
1344
-    }
1342
+	final function __clone()
1343
+	{
1344
+	}
1345 1345
 
1346 1346
 
1347 1347
 
1348
-    /**
1349
-     * @param $a
1350
-     * @param $b
1351
-     */
1352
-    final static function __callStatic($a, $b)
1353
-    {
1354
-    }
1348
+	/**
1349
+	 * @param $a
1350
+	 * @param $b
1351
+	 */
1352
+	final static function __callStatic($a, $b)
1353
+	{
1354
+	}
1355 1355
 
1356 1356
 
1357 1357
 
1358
-    /**
1359
-     * Gets all the custom post type models defined
1360
-     *
1361
-     * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1362
-     */
1363
-    public function cpt_models()
1364
-    {
1365
-        $cpt_models = array();
1366
-        foreach ($this->non_abstract_db_models as $short_name => $classname) {
1367
-            if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1368
-                $cpt_models[$short_name] = $classname;
1369
-            }
1370
-        }
1371
-        return $cpt_models;
1372
-    }
1358
+	/**
1359
+	 * Gets all the custom post type models defined
1360
+	 *
1361
+	 * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1362
+	 */
1363
+	public function cpt_models()
1364
+	{
1365
+		$cpt_models = array();
1366
+		foreach ($this->non_abstract_db_models as $short_name => $classname) {
1367
+			if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1368
+				$cpt_models[$short_name] = $classname;
1369
+			}
1370
+		}
1371
+		return $cpt_models;
1372
+	}
1373 1373
 
1374 1374
 
1375 1375
 
1376
-    /**
1377
-     * @return \EE_Config
1378
-     */
1379
-    public static function CFG()
1380
-    {
1381
-        return self::instance()->CFG;
1382
-    }
1376
+	/**
1377
+	 * @return \EE_Config
1378
+	 */
1379
+	public static function CFG()
1380
+	{
1381
+		return self::instance()->CFG;
1382
+	}
1383 1383
 
1384 1384
 
1385 1385
 }
Please login to merge, or discard this patch.
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
  /**
3
- *
4
- * Class EE_SPCO_Reg_Step_Attendee_Information
5
- *
6
- * Description
7
- *
8
- * @package 			Event Espresso
9
- * @subpackage 	core
10
- * @author 				Brent Christensen
11
- * @since 				4.5.0
12
- *
13
- */
3
+  *
4
+  * Class EE_SPCO_Reg_Step_Attendee_Information
5
+  *
6
+  * Description
7
+  *
8
+  * @package 			Event Espresso
9
+  * @subpackage 	core
10
+  * @author 				Brent Christensen
11
+  * @since 				4.5.0
12
+  *
13
+  */
14 14
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step {
15 15
 
16 16
 	/**
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 				// generate hidden input
170 170
 				if (
171 171
 					isset( $subsections[ $primary_registrant ] )
172
-				     && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
172
+					 && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
173 173
 				) {
174 174
 					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
175 175
 				}
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 					if ( isset( $valid_data[ $reg_url_link ] ) ) {
905 905
 						// do we need to copy basic info from primary attendee ?
906 906
 						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] )
907
-						                && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
907
+										&& absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
908 908
 							? true
909 909
 							: false;
910 910
 						// filter form input data for this registration
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 			? $form_input
1080 1080
 			: $form_input . '-' . $registration->reg_url_link();
1081 1081
 		$answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] )
1082
-		                 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1082
+						 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1083 1083
 			? true
1084 1084
 			: false;
1085 1085
 		//rename form_inputs if they are EE_Attendee properties
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 		// then attempt to copy them from the primary attendee
1200 1200
 		if (
1201 1201
 			$this->checkout->primary_attendee_obj instanceof EE_Attendee
1202
-            && ! isset( $attendee_data['ATT_fname'], $attendee_data['ATT_email'] )
1202
+			&& ! isset( $attendee_data['ATT_fname'], $attendee_data['ATT_email'] )
1203 1203
 		) {
1204 1204
 			return $this->checkout->primary_attendee_obj;
1205 1205
 		}
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
 		}
1318 1318
 		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1319 1319
 			if ( ! isset( $attendee_data[ $critical_attendee_detail ] )
1320
-			     || empty( $attendee_data[ $critical_attendee_detail ] )
1320
+				 || empty( $attendee_data[ $critical_attendee_detail ] )
1321 1321
 			) {
1322 1322
 				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1323 1323
 					$critical_attendee_detail
Please login to merge, or discard this patch.
Spacing   +230 added lines, -231 removed lines patch added patch discarded remove patch
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
 	 * @access    public
42 42
 	 * @param    EE_Checkout $checkout
43 43
 	 */
44
-	public function __construct( EE_Checkout $checkout ) {
44
+	public function __construct(EE_Checkout $checkout) {
45 45
 		$this->_slug = 'attendee_information';
46 46
 		$this->_name = __('Attendee Information', 'event_espresso');
47
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
47
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php';
48 48
 		$this->checkout = $checkout;
49 49
 		$this->_reset_success_message();
50 50
 		$this->set_instructions(
51
-			__( 'Please answer the following registration questions before proceeding.', 'event_espresso' )
51
+			__('Please answer the following registration questions before proceeding.', 'event_espresso')
52 52
 		);
53 53
 	}
54 54
 
55 55
 
56 56
 
57 57
 	public function translate_js_strings() {
58
-		EE_Registry::$i18n_js_strings['required_field'] = __( ' is a required question.', 'event_espresso' );
58
+		EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso');
59 59
 		EE_Registry::$i18n_js_strings['required_multi_field'] = __(
60 60
 			' is a required question. Please enter a value for at least one of the options.',
61 61
 			'event_espresso'
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		// calculate taxes
116 116
 		$Line_Item_Display->display_line_item(
117 117
 			$this->checkout->cart->get_grand_total(),
118
-			array( 'set_tax_rate' => true )
118
+			array('set_tax_rate' => true)
119 119
 		);
120 120
 		/** @var $subsections EE_Form_Section_Proper[] */
121 121
 		$subsections = array(
@@ -127,51 +127,51 @@  discard block
 block discarded – undo
127 127
 			'ticket_count' 	=> array()
128 128
 		);
129 129
 		// grab the saved registrations from the transaction
130
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
131
-		if ( $registrations ) {
132
-			foreach ( $registrations as $registration ) {
130
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
131
+		if ($registrations) {
132
+			foreach ($registrations as $registration) {
133 133
 				// can this registration be processed during this visit ?
134 134
 				if (
135 135
 					$registration instanceof EE_Registration
136
-					&& $this->checkout->visit_allows_processing_of_this_registration( $registration )
136
+					&& $this->checkout->visit_allows_processing_of_this_registration($registration)
137 137
 				) {
138
-					$subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form( $registration );
139
-					if ( ! $this->checkout->admin_request ) {
140
-						$template_args['registrations'][ $registration->reg_url_link() ] = $registration;
141
-						$template_args['ticket_count'][ $registration->ticket()->ID() ] = isset(
142
-							$template_args['ticket_count'][ $registration->ticket()->ID() ]
138
+					$subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
139
+					if ( ! $this->checkout->admin_request) {
140
+						$template_args['registrations'][$registration->reg_url_link()] = $registration;
141
+						$template_args['ticket_count'][$registration->ticket()->ID()] = isset(
142
+							$template_args['ticket_count'][$registration->ticket()->ID()]
143 143
 						)
144
-							? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1
144
+							? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
145 145
 							: 1;
146 146
 						$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
147 147
 							$this->checkout->cart->get_grand_total(),
148 148
 							'Ticket',
149
-							array( $registration->ticket()->ID() )
149
+							array($registration->ticket()->ID())
150 150
 						);
151
-						$ticket_line_item = is_array( $ticket_line_item )
152
-							? reset( $ticket_line_item )
151
+						$ticket_line_item = is_array($ticket_line_item)
152
+							? reset($ticket_line_item)
153 153
 							: $ticket_line_item;
154
-						$template_args['ticket_line_item'][ $registration->ticket()->ID() ] = $Line_Item_Display->display_line_item(
154
+						$template_args['ticket_line_item'][$registration->ticket()->ID()] = $Line_Item_Display->display_line_item(
155 155
 							$ticket_line_item
156 156
 						);
157 157
 					}
158
-					if ( $registration->is_primary_registrant() ) {
158
+					if ($registration->is_primary_registrant()) {
159 159
 						$primary_registrant = $registration->reg_url_link();
160 160
 					}
161 161
 				}
162 162
 			}
163 163
 			// print_copy_info ?
164
-			if ( $primary_registrant && ! $this->checkout->admin_request && count( $registrations ) > 1 ) {
164
+			if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) {
165 165
 				// TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info
166 166
 				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
167 167
 					? $this->_copy_attendee_info_form()
168 168
 					: $this->_auto_copy_attendee_info();
169 169
 				// generate hidden input
170 170
 				if (
171
-					isset( $subsections[ $primary_registrant ] )
172
-				     && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
171
+					isset($subsections[$primary_registrant])
172
+				     && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper
173 173
 				) {
174
-					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
174
+					$subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false);
175 175
 				}
176 176
 			}
177 177
 
@@ -183,8 +183,7 @@  discard block
 block discarded – undo
183 183
 				'html_id' 					=> $this->reg_form_name(),
184 184
 				'subsections' 			=> $subsections,
185 185
 				'layout_strategy'		=> $this->checkout->admin_request ?
186
-					new EE_Div_Per_Section_Layout() :
187
-					new EE_Template_Layout(
186
+					new EE_Div_Per_Section_Layout() : new EE_Template_Layout(
188 187
 						array(
189 188
 							'layout_template_file' 	=> $this->_template, // layout_template
190 189
 							'template_args' 				=> $template_args
@@ -202,11 +201,11 @@  discard block
 block discarded – undo
202 201
 	 * @return EE_Form_Section_Proper
203 202
 	 * @throws \EE_Error
204 203
 	 */
205
-	private function _registrations_reg_form( EE_Registration $registration ) {
204
+	private function _registrations_reg_form(EE_Registration $registration) {
206 205
 		static $attendee_nmbr = 1;
207 206
 		// array of params to pass to parent constructor
208 207
 		$form_args = array(
209
-			'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
208
+			'html_id'         => 'ee-registration-'.$registration->reg_url_link(),
210 209
 			'html_class'      => 'ee-reg-form-attendee-dv',
211 210
 			'html_style'      => $this->checkout->admin_request
212 211
 				? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
@@ -215,24 +214,24 @@  discard block
 block discarded – undo
215 214
 			'layout_strategy' => new EE_Fieldset_Section_Layout(
216 215
 				array(
217 216
 					'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
218
-					'legend_text'  => sprintf( __( 'Attendee %d', 'event_espresso' ), $attendee_nmbr )
217
+					'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr)
219 218
 				)
220 219
 			)
221 220
 		);
222 221
 		// verify that registration has valid event
223
-		if ( $registration->event() instanceof EE_Event ) {
222
+		if ($registration->event() instanceof EE_Event) {
224 223
 			$query_params = array(
225 224
 				array(
226 225
 					'Event.EVT_ID' => $registration->event()->ID(),
227 226
 					'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false
228 227
 				),
229
-				'order_by'=>array( 'QSG_order'=>'ASC' )
228
+				'order_by'=>array('QSG_order'=>'ASC')
230 229
 			);
231
-			$question_groups = $registration->event()->question_groups( $query_params );
232
-			if ( $question_groups ) {
233
-				foreach ( $question_groups as $question_group ) {
234
-					if ( $question_group instanceof EE_Question_Group ) {
235
-						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
230
+			$question_groups = $registration->event()->question_groups($query_params);
231
+			if ($question_groups) {
232
+				foreach ($question_groups as $question_group) {
233
+					if ($question_group instanceof EE_Question_Group) {
234
+						$form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form(
236 235
 							$registration,
237 236
 							$question_group
238 237
 						);
@@ -245,10 +244,10 @@  discard block
 block discarded – undo
245 244
 				// if we have question groups for additional attendees, then display the copy options
246 245
 				$this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info;
247 246
 			} else {
248
-				$form_args['subsections'][ 'attendee_info_not_required_' . $registration->reg_url_link(
249
-				) ] = new EE_Form_Section_HTML(
247
+				$form_args['subsections']['attendee_info_not_required_'.$registration->reg_url_link(
248
+				)] = new EE_Form_Section_HTML(
250 249
 					EEH_Template::locate_template(
251
-						SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_not_required.template.php',
250
+						SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_not_required.template.php',
252 251
 						apply_filters(
253 252
 							'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__attendee_info_not_required_template_args',
254 253
 							array()
@@ -267,12 +266,12 @@  discard block
 block discarded – undo
267 266
 
268 267
 			}
269 268
 		}
270
-		if ( $registration->is_primary_registrant() ) {
269
+		if ($registration->is_primary_registrant()) {
271 270
 			// generate hidden input
272
-			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( $registration );
271
+			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration);
273 272
 		}
274 273
 		$attendee_nmbr++;
275
-		return new EE_Form_Section_Proper( $form_args );
274
+		return new EE_Form_Section_Proper($form_args);
276 275
 	}
277 276
 
278 277
 
@@ -293,7 +292,7 @@  discard block
 block discarded – undo
293 292
 		// generate hidden input
294 293
 		return new EE_Hidden_Input(
295 294
 			array(
296
-				'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
295
+				'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(),
297 296
 				'default' => $additional_attendee_reg_info
298 297
 			)
299 298
 		);
@@ -307,26 +306,26 @@  discard block
 block discarded – undo
307 306
 	 * @return EE_Form_Section_Proper
308 307
 	 * @throws \EE_Error
309 308
 	 */
310
-	private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){
309
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) {
311 310
 		// array of params to pass to parent constructor
312 311
 		$form_args = array(
313
-			'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
312
+			'html_id'         => 'ee-reg-form-qstn-grp-'.$question_group->identifier(),
314 313
 			'html_class'      => $this->checkout->admin_request
315 314
 				? 'form-table ee-reg-form-qstn-grp-dv'
316 315
 				: 'ee-reg-form-qstn-grp-dv',
317
-			'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
316
+			'html_label_id'   => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl',
318 317
 			'subsections'     => array(
319
-				'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group )
318
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group)
320 319
 			),
321 320
 			'layout_strategy' => $this->checkout->admin_request
322 321
 				? new EE_Admin_Two_Column_Layout()
323 322
 				: new EE_Div_Per_Section_Layout()
324 323
 		);
325 324
 		// where params
326
-		$query_params = array( 'QST_deleted' => 0 );
325
+		$query_params = array('QST_deleted' => 0);
327 326
 		// don't load admin only questions on the frontend
328
-		if ( ! $this->checkout->admin_request ) {
329
-			$query_params['QST_admin_only'] = array( '!=', true );
327
+		if ( ! $this->checkout->admin_request) {
328
+			$query_params['QST_admin_only'] = array('!=', true);
330 329
 		}
331 330
 		$questions = $question_group->get_many_related(
332 331
 			'Question',
@@ -348,10 +347,10 @@  discard block
 block discarded – undo
348 347
 			)
349 348
 		);
350 349
 		// loop thru questions
351
-		foreach ( $questions as $question ) {
352
-			if( $question instanceof EE_Question ){
350
+		foreach ($questions as $question) {
351
+			if ($question instanceof EE_Question) {
353 352
 				$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
354
-				$form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question );
353
+				$form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
355 354
 			}
356 355
 		}
357 356
 		$form_args['subsections'] = apply_filters(
@@ -372,7 +371,7 @@  discard block
 block discarded – undo
372 371
 			)
373 372
 		);
374 373
 //		d( $form_args );
375
-		$question_group_reg_form = new EE_Form_Section_Proper( $form_args );
374
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
376 375
 		return apply_filters(
377 376
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
378 377
 			$question_group_reg_form,
@@ -389,11 +388,11 @@  discard block
 block discarded – undo
389 388
 	 * @param EE_Question_Group $question_group
390 389
 	 * @return 	EE_Form_Section_HTML
391 390
 	 */
392
-	private function _question_group_header( EE_Question_Group $question_group ){
391
+	private function _question_group_header(EE_Question_Group $question_group) {
393 392
 		$html = '';
394 393
 		// group_name
395
-		if ( $question_group->show_group_name() && $question_group->name() !== '' ) {
396
-			if ( $this->checkout->admin_request ) {
394
+		if ($question_group->show_group_name() && $question_group->name() !== '') {
395
+			if ($this->checkout->admin_request) {
397 396
 				$html .= EEH_HTML::br();
398 397
 				$html .= EEH_HTML::h3(
399 398
 					$question_group->name(),
@@ -407,7 +406,7 @@  discard block
 block discarded – undo
407 406
 			}
408 407
 		}
409 408
 		// group_desc
410
-		if ( $question_group->show_group_desc() && $question_group->desc() !== '' ) {
409
+		if ($question_group->show_group_desc() && $question_group->desc() !== '') {
411 410
 			$html .= EEH_HTML::p(
412 411
 				$question_group->desc(),
413 412
 				'',
@@ -417,7 +416,7 @@  discard block
 block discarded – undo
417 416
 			);
418 417
 
419 418
 		}
420
-		return new EE_Form_Section_HTML( $html );
419
+		return new EE_Form_Section_HTML($html);
421 420
 	}
422 421
 
423 422
 
@@ -427,7 +426,7 @@  discard block
 block discarded – undo
427 426
 	 * @return    EE_Form_Section_Proper
428 427
 	 * @throws \EE_Error
429 428
 	 */
430
-	private function _copy_attendee_info_form(){
429
+	private function _copy_attendee_info_form() {
431 430
 		// array of params to pass to parent constructor
432 431
 		return new EE_Form_Section_Proper(
433 432
 			array(
@@ -456,7 +455,7 @@  discard block
 block discarded – undo
456 455
 	private function _auto_copy_attendee_info() {
457 456
 		return new EE_Form_Section_HTML(
458 457
 			EEH_Template::locate_template(
459
-				SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
458
+				SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php',
460 459
 				apply_filters(
461 460
 					'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
462 461
 					array()
@@ -480,32 +479,32 @@  discard block
 block discarded – undo
480 479
 		$copy_attendee_info_inputs = array();
481 480
 		$prev_ticket = NULL;
482 481
 		// grab the saved registrations from the transaction
483
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
484
-		foreach ( $registrations as $registration ) {
482
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
483
+		foreach ($registrations as $registration) {
485 484
 			// for all  attendees other than the primary attendee
486
-			if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) {
485
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
487 486
 				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
488
-				if ( $registration->ticket()->ID() !== $prev_ticket ) {
487
+				if ($registration->ticket()->ID() !== $prev_ticket) {
489 488
 					$item_name = $registration->ticket()->name();
490 489
 					$item_name .= $registration->ticket()->description() !== ''
491
-						? ' - ' . $registration->ticket()->description()
490
+						? ' - '.$registration->ticket()->description()
492 491
 						: '';
493
-					$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML(
494
-						'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
492
+					$copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML(
493
+						'<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>'
495 494
 					);
496 495
 					$prev_ticket = $registration->ticket()->ID();
497 496
 				}
498 497
 
499
-				$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new
498
+				$copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new
500 499
 				EE_Checkbox_Multi_Input(
501 500
 					array(
502 501
 						$registration->ID() => sprintf(
503
-							__( 'Attendee #%s', 'event_espresso' ),
502
+							__('Attendee #%s', 'event_espresso'),
504 503
 							$registration->count()
505 504
 						)
506 505
 					),
507 506
 					array(
508
-						'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
507
+						'html_id'                 => 'spco-copy-attendee-chk-'.$registration->reg_url_link(),
509 508
 						'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
510 509
 						'display_html_label_text' => false
511 510
 					)
@@ -525,7 +524,7 @@  discard block
 block discarded – undo
525 524
 	 * @return    EE_Form_Input_Base
526 525
 	 * @throws \EE_Error
527 526
 	 */
528
-	private function _additional_primary_registrant_inputs( EE_Registration $registration ){
527
+	private function _additional_primary_registrant_inputs(EE_Registration $registration) {
529 528
 		// generate hidden input
530 529
 		return new EE_Hidden_Input(
531 530
 			array(
@@ -544,7 +543,7 @@  discard block
 block discarded – undo
544 543
 	 * @return    EE_Form_Input_Base
545 544
 	 * @throws \EE_Error
546 545
 	 */
547
-	public function reg_form_question( EE_Registration $registration, EE_Question $question ){
546
+	public function reg_form_question(EE_Registration $registration, EE_Question $question) {
548 547
 
549 548
 		// if this question was for an attendee detail, then check for that answer
550 549
 		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
@@ -553,32 +552,32 @@  discard block
 block discarded – undo
553 552
 		);
554 553
 		$answer = $answer_value === null
555 554
 			? EEM_Answer::instance()->get_one(
556
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
555
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
557 556
 			)
558 557
 			: null;
559 558
 		// if NOT returning to edit an existing registration
560 559
 		// OR if this question is for an attendee property
561 560
 		// OR we still don't have an EE_Answer object
562
-		if( $answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link() ) {
561
+		if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
563 562
 			// create an EE_Answer object for storing everything in
564
-			$answer = EE_Answer::new_instance ( array(
563
+			$answer = EE_Answer::new_instance(array(
565 564
 				'QST_ID'=> $question->ID(),
566 565
 				'REG_ID'=> $registration->ID()
567 566
 			));
568 567
 		}
569 568
 		// verify instance
570
-		if( $answer instanceof EE_Answer ){
571
-			if ( ! empty( $answer_value )) {
572
-				$answer->set( 'ANS_value', $answer_value );
569
+		if ($answer instanceof EE_Answer) {
570
+			if ( ! empty($answer_value)) {
571
+				$answer->set('ANS_value', $answer_value);
573 572
 			}
574
-			$answer->cache( 'Question', $question );
573
+			$answer->cache('Question', $question);
575 574
 			//remember system ID had a bug where sometimes it could be null
576
-			$answer_cache_id =$question->is_system_question()
577
-				? $question->system_ID() . '-' . $registration->reg_url_link()
578
-				: $question->ID() . '-' . $registration->reg_url_link();
579
-			$registration->cache( 'Answer', $answer, $answer_cache_id );
575
+			$answer_cache_id = $question->is_system_question()
576
+				? $question->system_ID().'-'.$registration->reg_url_link()
577
+				: $question->ID().'-'.$registration->reg_url_link();
578
+			$registration->cache('Answer', $answer, $answer_cache_id);
580 579
 		}
581
-		return $this->_generate_question_input( $registration, $question, $answer );
580
+		return $this->_generate_question_input($registration, $question, $answer);
582 581
 
583 582
 	}
584 583
 
@@ -591,46 +590,46 @@  discard block
 block discarded – undo
591 590
 	 * @return EE_Form_Input_Base
592 591
 	 * @throws \EE_Error
593 592
 	 */
594
-	private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){
593
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) {
595 594
 		$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
596
-		$this->_required_questions[ $identifier ] = $question->required() ? true : false;
595
+		$this->_required_questions[$identifier] = $question->required() ? true : false;
597 596
 		add_filter(
598 597
 			'FHEE__EE_Question__generate_form_input__country_options',
599
-			array( $this, 'use_cached_countries_for_form_input' ),
598
+			array($this, 'use_cached_countries_for_form_input'),
600 599
 			10,
601 600
 			4
602 601
 		);
603 602
 		add_filter(
604 603
 			'FHEE__EE_Question__generate_form_input__state_options',
605
-			array( $this, 'use_cached_states_for_form_input' ),
604
+			array($this, 'use_cached_states_for_form_input'),
606 605
 			10,
607 606
 			4
608 607
 		);
609 608
 		$input_constructor_args = array(
610
-			'html_name'     => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
611
-			'html_id'       => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
612
-			'html_class'    => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
613
-			'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
609
+			'html_name'     => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']',
610
+			'html_id'       => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
611
+			'html_class'    => 'ee-reg-qstn ee-reg-qstn-'.$identifier,
612
+			'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
614 613
 			'html_label_class'	=> 'ee-reg-qstn',
615 614
 		);
616
-		$input_constructor_args['html_label_id'] 	.= '-lbl';
617
-		if ( $answer instanceof EE_Answer && $answer->ID() ) {
618
-			$input_constructor_args[ 'html_name' ] .= '[' . $answer->ID() . ']';
619
-			$input_constructor_args[ 'html_id' ] .= '-' . $answer->ID();
620
-			$input_constructor_args[ 'html_label_id' ] .= '-' . $answer->ID();
615
+		$input_constructor_args['html_label_id'] .= '-lbl';
616
+		if ($answer instanceof EE_Answer && $answer->ID()) {
617
+			$input_constructor_args['html_name'] .= '['.$answer->ID().']';
618
+			$input_constructor_args['html_id'] .= '-'.$answer->ID();
619
+			$input_constructor_args['html_label_id'] .= '-'.$answer->ID();
621 620
 		}
622
-		$form_input =  $question->generate_form_input(
621
+		$form_input = $question->generate_form_input(
623 622
 			$registration,
624 623
 			$answer,
625 624
 			$input_constructor_args
626 625
 		);
627 626
 		remove_filter(
628 627
 			'FHEE__EE_Question__generate_form_input__country_options',
629
-			array( $this, 'use_cached_countries_for_form_input' )
628
+			array($this, 'use_cached_countries_for_form_input')
630 629
 		);
631 630
 		remove_filter(
632 631
 			'FHEE__EE_Question__generate_form_input__state_options',
633
-			array( $this, 'use_cached_states_for_form_input' )
632
+			array($this, 'use_cached_states_for_form_input')
634 633
 		);
635 634
 		return $form_input;
636 635
 	}
@@ -652,22 +651,22 @@  discard block
 block discarded – undo
652 651
 		\EE_Registration $registration = null,
653 652
 		\EE_Answer $answer = null
654 653
 	) {
655
-		$country_options = array( '' => '' );
654
+		$country_options = array('' => '');
656 655
 		// get possibly cached list of countries
657 656
 		$countries = $this->checkout->action === 'process_reg_step'
658 657
 			? EEM_Country::instance()->get_all_countries()
659 658
 			: EEM_Country::instance()->get_all_active_countries();
660
-		if ( ! empty( $countries )) {
661
-			foreach( $countries as $country ){
662
-				if ( $country instanceof EE_Country ) {
663
-					$country_options[ $country->ID() ] = $country->name();
659
+		if ( ! empty($countries)) {
660
+			foreach ($countries as $country) {
661
+				if ($country instanceof EE_Country) {
662
+					$country_options[$country->ID()] = $country->name();
664 663
 				}
665 664
 			}
666 665
 		}
667
-		if( $question instanceof EE_Question
668
-			&& $registration instanceof EE_Registration ) {
666
+		if ($question instanceof EE_Question
667
+			&& $registration instanceof EE_Registration) {
669 668
 			$answer = EEM_Answer::instance()->get_one(
670
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
669
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
671 670
 			);
672 671
 		} else {
673 672
 			$answer = EE_Answer::new_instance();
@@ -700,14 +699,14 @@  discard block
 block discarded – undo
700 699
 		\EE_Registration $registration = null,
701 700
 		\EE_Answer $answer = null
702 701
 	) {
703
-		$state_options = array( '' => array( '' => ''));
702
+		$state_options = array('' => array('' => ''));
704 703
 		$states = $this->checkout->action === 'process_reg_step'
705 704
 			? EEM_State::instance()->get_all_states()
706 705
 			: EEM_State::instance()->get_all_active_states();
707
-		if ( ! empty( $states )) {
708
-			foreach( $states as $state ){
709
-				if ( $state instanceof EE_State ) {
710
-					$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
706
+		if ( ! empty($states)) {
707
+			foreach ($states as $state) {
708
+				if ($state instanceof EE_State) {
709
+					$state_options[$state->country()->name()][$state->ID()] = $state->name();
711 710
 				}
712 711
 			}
713 712
 		}
@@ -735,24 +734,24 @@  discard block
 block discarded – undo
735 734
 	 * @throws \EE_Error
736 735
 	 */
737 736
 	public function process_reg_step() {
738
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
737
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
739 738
 		// grab validated data from form
740 739
 		$valid_data = $this->checkout->current_step->valid_data();
741 740
 		// EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
742 741
 		// EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
743 742
 		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
744
-		if ( empty( $valid_data ))  {
743
+		if (empty($valid_data)) {
745 744
 			EE_Error::add_error(
746
-				__( 'No valid question responses were received.', 'event_espresso' ),
745
+				__('No valid question responses were received.', 'event_espresso'),
747 746
 				__FILE__,
748 747
 				__FUNCTION__,
749 748
 				__LINE__
750 749
 			);
751 750
 			return false;
752 751
 		}
753
-		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) {
752
+		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
754 753
 			EE_Error::add_error(
755
-				__( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ),
754
+				__('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'),
756 755
 				__FILE__,
757 756
 				__FUNCTION__,
758 757
 				__LINE__
@@ -760,11 +759,11 @@  discard block
 block discarded – undo
760 759
 			return false;
761 760
 		}
762 761
 		// get cached registrations
763
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
762
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
764 763
 		// verify we got the goods
765
-		if ( empty( $registrations )) {
764
+		if (empty($registrations)) {
766 765
 			EE_Error::add_error(
767
-				__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ),
766
+				__('Your form data could not be applied to any valid registrations.', 'event_espresso'),
768 767
 				__FILE__,
769 768
 				__FUNCTION__,
770 769
 				__LINE__
@@ -772,15 +771,15 @@  discard block
 block discarded – undo
772 771
 			return false;
773 772
 		}
774 773
 		// extract attendee info from form data and save to model objects
775
-		$registrations_processed = $this->_process_registrations( $registrations, $valid_data );
774
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
776 775
 		// if first pass thru SPCO,
777 776
 		// then let's check processed registrations against the total number of tickets in the cart
778
-		if ( $registrations_processed === false ) {
777
+		if ($registrations_processed === false) {
779 778
 			// but return immediately if the previous step exited early due to errors
780 779
 			return false;
781
-		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) {
780
+		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
782 781
 			// generate a correctly translated string for all possible singular/plural combinations
783
-			if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) {
782
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
784 783
 				$error_msg = sprintf(
785 784
 					__(
786 785
 						'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
@@ -789,7 +788,7 @@  discard block
 block discarded – undo
789 788
 					$this->checkout->total_ticket_count,
790 789
 					$registrations_processed
791 790
 				);
792
-			} else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) {
791
+			} else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
793 792
 				$error_msg = sprintf(
794 793
 					__(
795 794
 						'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
@@ -808,17 +807,17 @@  discard block
 block discarded – undo
808 807
 					$registrations_processed
809 808
 				);
810 809
 			}
811
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
810
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
812 811
 			return false;
813 812
 		}
814 813
 		// mark this reg step as completed
815 814
 		$this->set_completed();
816 815
 		$this->_set_success_message(
817
-			__( 'The Attendee Information Step has been successfully completed.', 'event_espresso' )
816
+			__('The Attendee Information Step has been successfully completed.', 'event_espresso')
818 817
 		);
819 818
 		//do action in case a plugin wants to do something with the data submitted in step 1.
820 819
 		//passes EE_Single_Page_Checkout, and it's posted data
821
-		do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data );
820
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
822 821
 		return true;
823 822
 	}
824 823
 
@@ -832,9 +831,9 @@  discard block
 block discarded – undo
832 831
 	 * @return boolean | int
833 832
 	 * @throws \EE_Error
834 833
 	 */
835
-	private function _process_registrations( $registrations = array(), $valid_data = array() ) {
834
+	private function _process_registrations($registrations = array(), $valid_data = array()) {
836 835
 		// load resources and set some defaults
837
-		EE_Registry::instance()->load_model( 'Attendee' );
836
+		EE_Registry::instance()->load_model('Attendee');
838 837
 		// holder for primary registrant attendee object
839 838
 		$this->checkout->primary_attendee_obj = NULL;
840 839
 		// array for tracking reg form data for the primary registrant
@@ -851,9 +850,9 @@  discard block
 block discarded – undo
851 850
 		// attendee counter
852 851
 		$att_nmbr = 0;
853 852
 		// grab the saved registrations from the transaction
854
-		foreach ( $registrations  as $registration ) {
853
+		foreach ($registrations  as $registration) {
855 854
 			// verify EE_Registration object
856
-			if ( ! $registration instanceof EE_Registration ) {
855
+			if ( ! $registration instanceof EE_Registration) {
857 856
 				EE_Error::add_error(
858 857
 					__(
859 858
 						'An invalid Registration object was discovered when attempting to process your registration information.',
@@ -868,12 +867,12 @@  discard block
 block discarded – undo
868 867
 			/** @var string $reg_url_link */
869 868
 			$reg_url_link = $registration->reg_url_link();
870 869
 			// reg_url_link exists ?
871
-			if ( ! empty( $reg_url_link ) ) {
870
+			if ( ! empty($reg_url_link)) {
872 871
 				// should this registration be processed during this visit ?
873
-				if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) {
872
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
874 873
 					// if NOT revisiting, then let's save the registration now,
875 874
 					// so that we have a REG_ID to use when generating other objects
876
-					if ( ! $this->checkout->revisit ) {
875
+					if ( ! $this->checkout->revisit) {
877 876
 						$registration->save();
878 877
 					}
879 878
 					/**
@@ -883,7 +882,7 @@  discard block
 block discarded – undo
883 882
 					 * @var bool   if true is returned by the plugin then the
884 883
 					 *      		registration processing is halted.
885 884
 					 */
886
-					if ( apply_filters(
885
+					if (apply_filters(
887 886
 						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
888 887
 						false,
889 888
 						$att_nmbr,
@@ -891,38 +890,38 @@  discard block
 block discarded – undo
891 890
 						$registrations,
892 891
 						$valid_data,
893 892
 						$this
894
-					) ) {
893
+					)) {
895 894
 						return false;
896 895
 					}
897 896
 
898 897
 					// Houston, we have a registration!
899 898
 					$att_nmbr++;
900
-					$this->_attendee_data[ $reg_url_link ] = array();
899
+					$this->_attendee_data[$reg_url_link] = array();
901 900
 					// grab any existing related answer objects
902 901
 					$this->_registration_answers = $registration->answers();
903 902
 					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
904
-					if ( isset( $valid_data[ $reg_url_link ] ) ) {
903
+					if (isset($valid_data[$reg_url_link])) {
905 904
 						// do we need to copy basic info from primary attendee ?
906
-						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] )
907
-						                && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
905
+						$copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info'])
906
+						                && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0
908 907
 							? true
909 908
 							: false;
910 909
 						// filter form input data for this registration
911
-						$valid_data[ $reg_url_link ] = (array)apply_filters(
910
+						$valid_data[$reg_url_link] = (array) apply_filters(
912 911
 							'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
913
-							$valid_data[ $reg_url_link ]
912
+							$valid_data[$reg_url_link]
914 913
 						);
915 914
 						// EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ );
916
-						if ( isset( $valid_data['primary_attendee'] )) {
917
-							$primary_registrant['line_item_id'] =  ! empty( $valid_data['primary_attendee'] )
915
+						if (isset($valid_data['primary_attendee'])) {
916
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
918 917
 								? $valid_data['primary_attendee']
919 918
 								: false;
920
-							unset( $valid_data['primary_attendee'] );
919
+							unset($valid_data['primary_attendee']);
921 920
 						}
922 921
 						// now loop through our array of valid post data && process attendee reg forms
923
-						foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) {
924
-							if ( ! in_array( $form_section, $non_input_form_sections )) {
925
-								foreach ( $form_inputs as $form_input => $input_value ) {
922
+						foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
923
+							if ( ! in_array($form_section, $non_input_form_sections)) {
924
+								foreach ($form_inputs as $form_input => $input_value) {
926 925
 									// \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
927 926
 									// check for critical inputs
928 927
 									if (
@@ -936,16 +935,16 @@  discard block
 block discarded – undo
936 935
 									// store a bit of data about the primary attendee
937 936
 									if (
938 937
 										$att_nmbr === 1
939
-										&& ! empty( $input_value )
938
+										&& ! empty($input_value)
940 939
 										&& $reg_url_link === $primary_registrant['line_item_id']
941 940
 									) {
942
-										$primary_registrant[ $form_input ] = $input_value;
941
+										$primary_registrant[$form_input] = $input_value;
943 942
 									} else if (
944 943
 										$copy_primary
945 944
 										&& $input_value === null
946
-										&& isset( $primary_registrant[ $form_input ] )
945
+										&& isset($primary_registrant[$form_input])
947 946
 									) {
948
-										$input_value = $primary_registrant[ $form_input ];
947
+										$input_value = $primary_registrant[$form_input];
949 948
 									}
950 949
 									// now attempt to save the input data
951 950
 									if (
@@ -987,55 +986,55 @@  discard block
 block discarded – undo
987 986
 						// have we met before?
988 987
 						$attendee = $this->_find_existing_attendee(
989 988
 							$registration,
990
-							$this->_attendee_data[ $reg_url_link ]
989
+							$this->_attendee_data[$reg_url_link]
991 990
 						);
992 991
 						// did we find an already existing record for this attendee ?
993
-						if ( $attendee instanceof EE_Attendee ) {
992
+						if ($attendee instanceof EE_Attendee) {
994 993
 							$attendee = $this->_update_existing_attendee_data(
995 994
 								$attendee,
996
-								$this->_attendee_data[ $reg_url_link ]
995
+								$this->_attendee_data[$reg_url_link]
997 996
 							);
998 997
 						} else {
999 998
 							// ensure critical details are set for additional attendees
1000
-							$this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
999
+							$this->_attendee_data[$reg_url_link] = $att_nmbr > 1
1001 1000
 								? $this->_copy_critical_attendee_details_from_primary_registrant(
1002
-									$this->_attendee_data[ $reg_url_link ]
1001
+									$this->_attendee_data[$reg_url_link]
1003 1002
 								)
1004
-								: $this->_attendee_data[ $reg_url_link ];
1003
+								: $this->_attendee_data[$reg_url_link];
1005 1004
 							$attendee = $this->_create_new_attendee(
1006 1005
 								$registration,
1007
-								$this->_attendee_data[ $reg_url_link ]
1006
+								$this->_attendee_data[$reg_url_link]
1008 1007
 							);
1009 1008
 						}
1010 1009
 						// who's #1 ?
1011
-						if ( $att_nmbr === 1 ) {
1010
+						if ($att_nmbr === 1) {
1012 1011
 							$this->checkout->primary_attendee_obj = $attendee;
1013 1012
 						}
1014 1013
 					}
1015 1014
 					// EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1016 1015
 					// add relation to registration, set attendee ID, and cache attendee
1017
-					$this->_associate_attendee_with_registration( $registration, $attendee );
1016
+					$this->_associate_attendee_with_registration($registration, $attendee);
1018 1017
 					// \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1019
-					if ( ! $registration->attendee() instanceof EE_Attendee ) {
1020
-						EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ );
1018
+					if ( ! $registration->attendee() instanceof EE_Attendee) {
1019
+						EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__);
1021 1020
 						return false;
1022 1021
 					}
1023 1022
 					/** @type EE_Registration_Processor $registration_processor */
1024
-					$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
1023
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1025 1024
 					// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
1026
-					$registration_processor->toggle_incomplete_registration_status_to_default( $registration, false );
1025
+					$registration_processor->toggle_incomplete_registration_status_to_default($registration, false);
1027 1026
 					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1028 1027
 					$this->checkout->transaction->toggle_failed_transaction_status();
1029 1028
 					// if we've gotten this far, then let's save what we have
1030 1029
 					$registration->save();
1031 1030
 					// add relation between TXN and registration
1032
-					$this->_associate_registration_with_transaction( $registration );
1031
+					$this->_associate_registration_with_transaction($registration);
1033 1032
 				} // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) {
1034 1033
 
1035
-			}  else {
1036
-				EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1034
+			} else {
1035
+				EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1037 1036
 				// remove malformed data
1038
-				unset( $valid_data[ $reg_url_link ] );
1037
+				unset($valid_data[$reg_url_link]);
1039 1038
 				return false;
1040 1039
 			}
1041 1040
 
@@ -1064,26 +1063,26 @@  discard block
 block discarded – undo
1064 1063
 		// \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1065 1064
 		// allow for plugins to hook in and do their own processing of the form input.
1066 1065
 		// For plugins to bypass normal processing here, they just need to return a boolean value.
1067
-		if ( apply_filters(
1066
+		if (apply_filters(
1068 1067
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1069 1068
 			false,
1070 1069
 			$registration,
1071 1070
 			$form_input,
1072 1071
 			$input_value,
1073 1072
 			$this
1074
-		) ) {
1073
+		)) {
1075 1074
 			return true;
1076 1075
 		}
1077 1076
 		// $answer_cache_id is the key used to find the EE_Answer we want
1078 1077
 		$answer_cache_id = $this->checkout->reg_url_link
1079 1078
 			? $form_input
1080
-			: $form_input . '-' . $registration->reg_url_link();
1081
-		$answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] )
1082
-		                 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1079
+			: $form_input.'-'.$registration->reg_url_link();
1080
+		$answer_is_obj = isset($this->_registration_answers[$answer_cache_id])
1081
+		                 && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
1083 1082
 			? true
1084 1083
 			: false;
1085 1084
 		//rename form_inputs if they are EE_Attendee properties
1086
-		switch( (string)$form_input ) {
1085
+		switch ((string) $form_input) {
1087 1086
 
1088 1087
 			case 'state' :
1089 1088
 			case 'STA_ID' :
@@ -1098,32 +1097,32 @@  discard block
 block discarded – undo
1098 1097
 				break;
1099 1098
 
1100 1099
 			default :
1101
-				$ATT_input = 'ATT_' . $form_input;
1100
+				$ATT_input = 'ATT_'.$form_input;
1102 1101
 				//EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1103
-				$attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? true : false;
1104
-				$form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1102
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1103
+				$form_input = $attendee_property ? 'ATT_'.$form_input : $form_input;
1105 1104
 		}
1106 1105
 		// EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1107 1106
 		// EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1108 1107
 		// EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1109 1108
 		// if this form input has a corresponding attendee property
1110
-		if ( $attendee_property ) {
1111
-			$this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1112
-			if ( $answer_is_obj ) {
1109
+		if ($attendee_property) {
1110
+			$this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
1111
+			if ($answer_is_obj) {
1113 1112
 				// and delete the corresponding answer since we won't be storing this data in that object
1114
-				$registration->_remove_relation_to( $this->_registration_answers[ $answer_cache_id ], 'Answer' );
1115
-				$this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1113
+				$registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer');
1114
+				$this->_registration_answers[$answer_cache_id]->delete_permanently();
1116 1115
 			}
1117 1116
 			return true;
1118
-		} elseif ( $answer_is_obj ) {
1117
+		} elseif ($answer_is_obj) {
1119 1118
 			// save this data to the answer object
1120
-			$this->_registration_answers[ $answer_cache_id ]->set_value( $input_value );
1121
-			$result = $this->_registration_answers[ $answer_cache_id ]->save();
1119
+			$this->_registration_answers[$answer_cache_id]->set_value($input_value);
1120
+			$result = $this->_registration_answers[$answer_cache_id]->save();
1122 1121
 			return $result !== false ? true : false;
1123 1122
 		} else {
1124
-			foreach ( $this->_registration_answers as $answer ) {
1125
-				if ( $answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id ) {
1126
-					$answer->set_value( $input_value );
1123
+			foreach ($this->_registration_answers as $answer) {
1124
+				if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1125
+					$answer->set_value($input_value);
1127 1126
 					$result = $answer->save();
1128 1127
 					return $result !== false ? true : false;
1129 1128
 				}
@@ -1145,15 +1144,15 @@  discard block
 block discarded – undo
1145 1144
 		$form_input = '',
1146 1145
 		$input_value = ''
1147 1146
 	) {
1148
-		if ( empty( $input_value ) ) {
1147
+		if (empty($input_value)) {
1149 1148
 			// if the form input isn't marked as being required, then just return
1150
-			if ( ! isset( $this->_required_questions[ $form_input ] ) || ! $this->_required_questions[ $form_input ] ) {
1149
+			if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1151 1150
 				return true;
1152 1151
 			}
1153
-			switch ( $form_input ) {
1152
+			switch ($form_input) {
1154 1153
 				case 'fname' :
1155 1154
 					EE_Error::add_error(
1156
-						__( 'First Name is a required value.', 'event_espresso' ),
1155
+						__('First Name is a required value.', 'event_espresso'),
1157 1156
 						__FILE__,
1158 1157
 						__FUNCTION__,
1159 1158
 						__LINE__
@@ -1162,7 +1161,7 @@  discard block
 block discarded – undo
1162 1161
 					break;
1163 1162
 				case 'lname' :
1164 1163
 					EE_Error::add_error(
1165
-						__( 'Last Name is a required value.', 'event_espresso' ),
1164
+						__('Last Name is a required value.', 'event_espresso'),
1166 1165
 						__FILE__,
1167 1166
 						__FUNCTION__,
1168 1167
 						__LINE__
@@ -1171,7 +1170,7 @@  discard block
 block discarded – undo
1171 1170
 					break;
1172 1171
 				case 'email' :
1173 1172
 					EE_Error::add_error(
1174
-						__( 'Please enter a valid email address.', 'event_espresso' ),
1173
+						__('Please enter a valid email address.', 'event_espresso'),
1175 1174
 						__FILE__,
1176 1175
 						__FUNCTION__,
1177 1176
 						__LINE__
@@ -1193,30 +1192,30 @@  discard block
 block discarded – undo
1193 1192
 	 * @return boolean|EE_Attendee
1194 1193
 	 * @throws \EE_Error
1195 1194
 	 */
1196
-	private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) {
1195
+	private function _find_existing_attendee(EE_Registration $registration, $attendee_data = array()) {
1197 1196
 		$existing_attendee = null;
1198 1197
 		// if none of the critical properties are set in the incoming attendee data...
1199 1198
 		// then attempt to copy them from the primary attendee
1200 1199
 		if (
1201 1200
 			$this->checkout->primary_attendee_obj instanceof EE_Attendee
1202
-            && ! isset( $attendee_data['ATT_fname'], $attendee_data['ATT_email'] )
1201
+            && ! isset($attendee_data['ATT_fname'], $attendee_data['ATT_email'])
1203 1202
 		) {
1204 1203
 			return $this->checkout->primary_attendee_obj;
1205 1204
 		}
1206 1205
 		// does this attendee already exist in the db ?
1207 1206
 		// we're searching using a combination of first name, last name, AND email address
1208
-		$ATT_fname = isset( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_fname'] )
1207
+		$ATT_fname = isset($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_fname'])
1209 1208
 			? $attendee_data['ATT_fname']
1210 1209
 			: '';
1211
-		$ATT_lname = isset( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_lname'] )
1210
+		$ATT_lname = isset($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_lname'])
1212 1211
 			? $attendee_data['ATT_lname']
1213 1212
 			: '';
1214
-		$ATT_email = isset( $attendee_data['ATT_email'] ) && ! empty( $attendee_data['ATT_email'] )
1213
+		$ATT_email = isset($attendee_data['ATT_email']) && ! empty($attendee_data['ATT_email'])
1215 1214
 			? $attendee_data['ATT_email']
1216 1215
 			: '';
1217 1216
 		// but only if those have values
1218
-		if ( $ATT_fname && $ATT_lname && $ATT_email ) {
1219
-			$existing_attendee = EEM_Attendee::instance()->find_existing_attendee( array(
1217
+		if ($ATT_fname && $ATT_lname && $ATT_email) {
1218
+			$existing_attendee = EEM_Attendee::instance()->find_existing_attendee(array(
1220 1219
 				'ATT_fname' => $ATT_fname,
1221 1220
 				'ATT_lname' => $ATT_lname,
1222 1221
 				'ATT_email' => $ATT_email
@@ -1240,13 +1239,13 @@  discard block
 block discarded – undo
1240 1239
 	 * @return \EE_Attendee
1241 1240
 	 * @throws \EE_Error
1242 1241
 	 */
1243
-	private function _update_existing_attendee_data( EE_Attendee $existing_attendee, $attendee_data = array() ) {
1242
+	private function _update_existing_attendee_data(EE_Attendee $existing_attendee, $attendee_data = array()) {
1244 1243
 		// first remove fname, lname, and email from attendee data
1245
-		$dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1244
+		$dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email');
1246 1245
 		// now loop thru what's left and add to attendee CPT
1247
-		foreach ( $attendee_data as $property_name => $property_value ) {
1248
-			if ( ! in_array( $property_name, $dont_set ) && EEM_Attendee::instance()->has_field( $property_name )) {
1249
-				$existing_attendee->set( $property_name, $property_value );
1246
+		foreach ($attendee_data as $property_name => $property_value) {
1247
+			if ( ! in_array($property_name, $dont_set) && EEM_Attendee::instance()->has_field($property_name)) {
1248
+				$existing_attendee->set($property_name, $property_value);
1250 1249
 			}
1251 1250
 		}
1252 1251
 		// better save that now
@@ -1264,11 +1263,11 @@  discard block
 block discarded – undo
1264 1263
 	 * @return void
1265 1264
 	 * @throws \EE_Error
1266 1265
 	 */
1267
-	private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) {
1266
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) {
1268 1267
 		// add relation to attendee
1269
-		$registration->_add_relation_to( $attendee, 'Attendee' );
1270
-		$registration->set_attendee_id( $attendee->ID() );
1271
-		$registration->update_cache_after_object_save( 'Attendee', $attendee );
1268
+		$registration->_add_relation_to($attendee, 'Attendee');
1269
+		$registration->set_attendee_id($attendee->ID());
1270
+		$registration->update_cache_after_object_save('Attendee', $attendee);
1272 1271
 	}
1273 1272
 
1274 1273
 
@@ -1280,10 +1279,10 @@  discard block
 block discarded – undo
1280 1279
 	 * @return void
1281 1280
 	 * @throws \EE_Error
1282 1281
 	 */
1283
-	private function _associate_registration_with_transaction( EE_Registration $registration ) {
1282
+	private function _associate_registration_with_transaction(EE_Registration $registration) {
1284 1283
 		// add relation to attendee
1285
-		$this->checkout->transaction->_add_relation_to( $registration, 'Registration' );
1286
-		$this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration );
1284
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1285
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1287 1286
 	}
1288 1287
 
1289 1288
 
@@ -1296,14 +1295,14 @@  discard block
 block discarded – undo
1296 1295
 	 * @return array
1297 1296
 	 * @throws \EE_Error
1298 1297
 	 */
1299
-	private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) {
1298
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) {
1300 1299
 		// bare minimum critical details include first name, last name, email address
1301
-		$critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1300
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1302 1301
 		// add address info to critical details?
1303
-		if ( apply_filters(
1302
+		if (apply_filters(
1304 1303
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1305 1304
 			false
1306
-		) ) {
1305
+		)) {
1307 1306
 			$address_details = array(
1308 1307
 				'ATT_address',
1309 1308
 				'ATT_address2',
@@ -1313,13 +1312,13 @@  discard block
 block discarded – undo
1313 1312
 				'ATT_zip',
1314 1313
 				'ATT_phone'
1315 1314
 			);
1316
-			$critical_attendee_details = array_merge( $critical_attendee_details, $address_details );
1315
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1317 1316
 		}
1318
-		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1319
-			if ( ! isset( $attendee_data[ $critical_attendee_detail ] )
1320
-			     || empty( $attendee_data[ $critical_attendee_detail ] )
1317
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1318
+			if ( ! isset($attendee_data[$critical_attendee_detail])
1319
+			     || empty($attendee_data[$critical_attendee_detail])
1321 1320
 			) {
1322
-				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1321
+				$attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
1323 1322
 					$critical_attendee_detail
1324 1323
 				);
1325 1324
 			}
@@ -1337,11 +1336,11 @@  discard block
 block discarded – undo
1337 1336
 	 * @return \EE_Attendee
1338 1337
 	 * @throws \EE_Error
1339 1338
 	 */
1340
-	private function _create_new_attendee( EE_Registration $registration, $attendee_data = array() ) {
1339
+	private function _create_new_attendee(EE_Registration $registration, $attendee_data = array()) {
1341 1340
 		// create new attendee object
1342
-		$new_attendee = EE_Attendee::new_instance( $attendee_data );
1341
+		$new_attendee = EE_Attendee::new_instance($attendee_data);
1343 1342
 		// set author to event creator
1344
-		$new_attendee->set( 'ATT_author', $registration->event()->wp_user() );
1343
+		$new_attendee->set('ATT_author', $registration->event()->wp_user());
1345 1344
 		$new_attendee->save();
1346 1345
 		return $new_attendee;
1347 1346
 	}
@@ -1358,7 +1357,7 @@  discard block
 block discarded – undo
1358 1357
 	 */
1359 1358
 	public function update_reg_step() {
1360 1359
 		// save everything
1361
-		if ( $this->process_reg_step() ) {
1360
+		if ($this->process_reg_step()) {
1362 1361
 			$this->checkout->redirect = true;
1363 1362
 			$this->checkout->redirect_url = add_query_arg(
1364 1363
 				array(
@@ -1367,7 +1366,7 @@  discard block
 block discarded – undo
1367 1366
 				),
1368 1367
 				$this->checkout->thank_you_page_url
1369 1368
 			);
1370
-			$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1369
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1371 1370
 			return true;
1372 1371
 		}
1373 1372
 		return false;
Please login to merge, or discard this patch.
core/EE_Config.core.php 2 patches
Spacing   +398 added lines, -398 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	public static function instance() {
135 135
 		// check if class object is instantiated, and instantiated properly
136
-		if ( ! self::$_instance instanceof EE_Config ) {
136
+		if ( ! self::$_instance instanceof EE_Config) {
137 137
 			self::$_instance = new self();
138 138
 		}
139 139
 		return self::$_instance;
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 	 *                               site was put into maintenance mode)
154 154
 	 * @return EE_Config
155 155
 	 */
156
-	public static function reset( $hard_reset = false, $reinstantiate = true ) {
157
-		if ( self::$_instance instanceof EE_Config ) {
156
+	public static function reset($hard_reset = false, $reinstantiate = true) {
157
+		if (self::$_instance instanceof EE_Config) {
158 158
             if ($hard_reset) {
159 159
                 self::$_instance->_addon_option_names = array();
160 160
                 self::$_instance->_initialize_config();
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 		//we don't need to reset the static properties imo because those should
167 167
 		//only change when a module is added or removed. Currently we don't
168 168
 		//support removing a module during a request when it previously existed
169
-		if ( $reinstantiate ) {
169
+		if ($reinstantiate) {
170 170
 			return self::instance();
171 171
 		} else {
172 172
 			return null;
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	 * @access    private
182 182
 	 */
183 183
 	private function __construct() {
184
-		do_action( 'AHEE__EE_Config__construct__begin', $this );
185
-		EE_Config::$_logging_enabled = apply_filters( 'FHEE__EE_Config___construct__logging_enabled', false );
184
+		do_action('AHEE__EE_Config__construct__begin', $this);
185
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
186 186
 		// setup empty config classes
187 187
 		$this->_initialize_config();
188 188
 		// load existing EE site settings
@@ -192,17 +192,17 @@  discard block
 block discarded – undo
192 192
 		//  register shortcodes and modules
193 193
 		add_action(
194 194
 			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
195
-			array( $this, 'register_shortcodes_and_modules' ),
195
+			array($this, 'register_shortcodes_and_modules'),
196 196
 			999
197 197
 		);
198 198
 		//  initialize shortcodes and modules
199
-		add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'initialize_shortcodes_and_modules' ) );
199
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
200 200
 		// register widgets
201
-		add_action( 'widgets_init', array( $this, 'widgets_init' ), 10 );
201
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
202 202
 		// shutdown
203
-		add_action( 'shutdown', array( $this, 'shutdown' ), 10 );
203
+		add_action('shutdown', array($this, 'shutdown'), 10);
204 204
 		// construct__end hook
205
-		do_action( 'AHEE__EE_Config__construct__end', $this );
205
+		do_action('AHEE__EE_Config__construct__end', $this);
206 206
 		// hardcoded hack
207 207
 		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
208 208
 	}
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 * @return string current theme set.
225 225
 	 */
226 226
 	public static function get_current_theme() {
227
-		return isset( self::$_instance->template_settings->current_espresso_theme )
227
+		return isset(self::$_instance->template_settings->current_espresso_theme)
228 228
 			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
229 229
 	}
230 230
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	private function _initialize_config() {
240 240
 		EE_Config::trim_log();
241 241
 		//set defaults
242
-		$this->_addon_option_names = get_option( EE_Config::ADDON_OPTION_NAMES, array() );
242
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
243 243
 		$this->addons = new stdClass();
244 244
 		// set _module_route_map
245 245
 		EE_Config::$_module_route_map = array();
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
 	 */
260 260
 	private function _load_core_config() {
261 261
 		// load_core_config__start hook
262
-		do_action( 'AHEE__EE_Config___load_core_config__start', $this );
262
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
263 263
 		$espresso_config = $this->get_espresso_config();
264
-		foreach ( $espresso_config as $config => $settings ) {
264
+		foreach ($espresso_config as $config => $settings) {
265 265
 			// load_core_config__start hook
266 266
 			$settings = apply_filters(
267 267
 				'FHEE__EE_Config___load_core_config__config_settings',
@@ -269,22 +269,22 @@  discard block
 block discarded – undo
269 269
 				$config,
270 270
 				$this
271 271
 			);
272
-			if ( is_object( $settings ) && property_exists( $this, $config ) ) {
273
-				$this->{$config} = apply_filters( 'FHEE__EE_Config___load_core_config__' . $config, $settings );
272
+			if (is_object($settings) && property_exists($this, $config)) {
273
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
274 274
 				//call configs populate method to ensure any defaults are set for empty values.
275
-				if ( method_exists( $settings, 'populate' ) ) {
275
+				if (method_exists($settings, 'populate')) {
276 276
 					$this->{$config}->populate();
277 277
 				}
278
-				if ( method_exists( $settings, 'do_hooks' ) ) {
278
+				if (method_exists($settings, 'do_hooks')) {
279 279
 					$this->{$config}->do_hooks();
280 280
 				}
281 281
 			}
282 282
 		}
283
-		if ( apply_filters( 'FHEE__EE_Config___load_core_config__update_espresso_config', false ) ) {
283
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
284 284
 			$this->update_espresso_config();
285 285
 		}
286 286
 		// load_core_config__end hook
287
-		do_action( 'AHEE__EE_Config___load_core_config__end', $this );
287
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
288 288
 	}
289 289
 
290 290
 
@@ -299,23 +299,23 @@  discard block
 block discarded – undo
299 299
 		$this->core = $this->core instanceof EE_Core_Config
300 300
 			? $this->core
301 301
 			: new EE_Core_Config();
302
-		$this->core = apply_filters( 'FHEE__EE_Config___initialize_config__core', $this->core );
302
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
303 303
 		$this->organization = $this->organization instanceof EE_Organization_Config
304 304
 			? $this->organization
305 305
 			: new EE_Organization_Config();
306
-		$this->organization = apply_filters( 'FHEE__EE_Config___initialize_config__organization', $this->organization );
306
+		$this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', $this->organization);
307 307
 		$this->currency = $this->currency instanceof EE_Currency_Config
308 308
 			? $this->currency
309 309
 			: new EE_Currency_Config();
310
-		$this->currency = apply_filters( 'FHEE__EE_Config___initialize_config__currency', $this->currency );
310
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
311 311
 		$this->registration = $this->registration instanceof EE_Registration_Config
312 312
 			? $this->registration
313 313
 			: new EE_Registration_Config();
314
-		$this->registration = apply_filters( 'FHEE__EE_Config___initialize_config__registration', $this->registration );
314
+		$this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', $this->registration);
315 315
 		$this->admin = $this->admin instanceof EE_Admin_Config
316 316
 			? $this->admin
317 317
 			: new EE_Admin_Config();
318
-		$this->admin = apply_filters( 'FHEE__EE_Config___initialize_config__admin', $this->admin );
318
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
319 319
 		$this->template_settings = $this->template_settings instanceof EE_Template_Config
320 320
 			? $this->template_settings
321 321
 			: new EE_Template_Config();
@@ -326,19 +326,19 @@  discard block
 block discarded – undo
326 326
 		$this->map_settings = $this->map_settings instanceof EE_Map_Config
327 327
 			? $this->map_settings
328 328
 			: new EE_Map_Config();
329
-		$this->map_settings = apply_filters( 'FHEE__EE_Config___initialize_config__map_settings', $this->map_settings );
329
+		$this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', $this->map_settings);
330 330
 		$this->environment = $this->environment instanceof EE_Environment_Config
331 331
 			? $this->environment
332 332
 			: new EE_Environment_Config();
333
-		$this->environment = apply_filters( 'FHEE__EE_Config___initialize_config__environment', $this->environment );
333
+		$this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', $this->environment);
334 334
 		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
335 335
 			? $this->tax_settings
336 336
 			: new EE_Tax_Config();
337
-		$this->tax_settings = apply_filters( 'FHEE__EE_Config___initialize_config__tax_settings', $this->tax_settings );
337
+		$this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', $this->tax_settings);
338 338
 		$this->gateway = $this->gateway instanceof EE_Gateway_Config
339 339
 			? $this->gateway
340 340
 			: new EE_Gateway_Config();
341
-		$this->gateway = apply_filters( 'FHEE__EE_Config___initialize_config__gateway', $this->gateway );
341
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
342 342
 	}
343 343
 
344 344
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		// grab espresso configuration
354 354
 		return apply_filters(
355 355
 			'FHEE__EE_Config__get_espresso_config__CFG',
356
-			get_option( EE_Config::OPTION_NAME, array() )
356
+			get_option(EE_Config::OPTION_NAME, array())
357 357
 		);
358 358
 	}
359 359
 
@@ -367,12 +367,12 @@  discard block
 block discarded – undo
367 367
 	 * @param        $old_value
368 368
 	 * @param        $value
369 369
 	 */
370
-	public function double_check_config_comparison( $option = '', $old_value, $value ) {
370
+	public function double_check_config_comparison($option = '', $old_value, $value) {
371 371
 		// make sure we're checking the ee config
372
-		if ( $option === EE_Config::OPTION_NAME ) {
372
+		if ($option === EE_Config::OPTION_NAME) {
373 373
 			// run a loose comparison of the old value against the new value for type and properties,
374 374
 			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
375
-			if ( $value != $old_value ) {
375
+			if ($value != $old_value) {
376 376
 				// if they are NOT the same, then remove the hook,
377 377
 				// which means the subsequent update results will be based solely on the update query results
378 378
 				// the reason we do this is because, as stated above,
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 				// the string it sees in the db looks the same as the new one it has been passed!!!
388 388
 				// This results in the query returning an "affected rows" value of ZERO,
389 389
 				// which gets returned immediately by WP update_option and looks like an error.
390
-				remove_action( 'update_option', array( $this, 'check_config_updated' ) );
390
+				remove_action('update_option', array($this, 'check_config_updated'));
391 391
 			}
392 392
 		}
393 393
 	}
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
 	 */
402 402
 	protected function _reset_espresso_addon_config() {
403 403
 		$this->_addon_option_names = array();
404
-		foreach ( $this->addons as $addon_name => $addon_config_obj ) {
405
-			$addon_config_obj = maybe_unserialize( $addon_config_obj );
406
-			$config_class = get_class( $addon_config_obj );
407
-			if ( $addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class ) {
408
-				$this->update_config( 'addons', $addon_name, $addon_config_obj, false );
404
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
405
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
406
+			$config_class = get_class($addon_config_obj);
407
+			if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
408
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
409 409
 			}
410 410
 			$this->addons->{$addon_name} = null;
411 411
 		}
@@ -421,22 +421,22 @@  discard block
 block discarded – undo
421 421
 	 * @param   bool $add_error
422 422
 	 * @return   bool
423 423
 	 */
424
-	public function update_espresso_config( $add_success = false, $add_error = true ) {
424
+	public function update_espresso_config($add_success = false, $add_error = true) {
425 425
 		// don't allow config updates during WP heartbeats
426
-		if ( \EE_Registry::instance()->REQ->get( 'action', '' ) === 'heartbeat' ) {
426
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
427 427
 			return false;
428 428
 		}
429 429
 		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
430 430
 		//$clone = clone( self::$_instance );
431 431
 		//self::$_instance = NULL;
432
-		do_action( 'AHEE__EE_Config__update_espresso_config__begin', $this );
432
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
433 433
 		$this->_reset_espresso_addon_config();
434 434
 		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
435 435
 		// but BEFORE the actual update occurs
436
-		add_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1, 3 );
436
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
437 437
 		// now update "ee_config"
438
-		$saved = update_option( EE_Config::OPTION_NAME, $this );
439
-		EE_Config::log( EE_Config::OPTION_NAME );
438
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
439
+		EE_Config::log(EE_Config::OPTION_NAME);
440 440
 		// if not saved... check if the hook we just added still exists;
441 441
 		// if it does, it means one of two things:
442 442
 		// 		that update_option bailed at the ( $value === $old_value ) conditional,
@@ -447,17 +447,17 @@  discard block
 block discarded – undo
447 447
 		// but just means no update occurred, so don't display an error to the user.
448 448
 		// BUT... if update_option returns FALSE, AND the hook is missing,
449 449
 		// then it means that something truly went wrong
450
-		$saved = ! $saved ? has_action( 'update_option', array( $this, 'double_check_config_comparison' ) ) : $saved;
450
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
451 451
 		// remove our action since we don't want it in the system anymore
452
-		remove_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1 );
453
-		do_action( 'AHEE__EE_Config__update_espresso_config__end', $this, $saved );
452
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
453
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
454 454
 		//self::$_instance = $clone;
455 455
 		//unset( $clone );
456 456
 		// if config remains the same or was updated successfully
457
-		if ( $saved ) {
458
-			if ( $add_success ) {
457
+		if ($saved) {
458
+			if ($add_success) {
459 459
 				EE_Error::add_success(
460
-					__( 'The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso' ),
460
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
461 461
 					__FILE__,
462 462
 					__FUNCTION__,
463 463
 					__LINE__
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
 			}
466 466
 			return true;
467 467
 		} else {
468
-			if ( $add_error ) {
468
+			if ($add_error) {
469 469
 				EE_Error::add_error(
470
-					__( 'The Event Espresso Configuration Settings were not updated.', 'event_espresso' ),
470
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
471 471
 					__FILE__,
472 472
 					__FUNCTION__,
473 473
 					__LINE__
@@ -496,16 +496,16 @@  discard block
 block discarded – undo
496 496
 		$name = '',
497 497
 		$config_class = '',
498 498
 		$config_obj = null,
499
-		$tests_to_run = array( 1, 2, 3, 4, 5, 6, 7, 8 ),
499
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
500 500
 		$display_errors = true
501 501
 	) {
502 502
 		try {
503
-			foreach ( $tests_to_run as $test ) {
504
-				switch ( $test ) {
503
+			foreach ($tests_to_run as $test) {
504
+				switch ($test) {
505 505
 					// TEST #1 : check that section was set
506 506
 					case 1 :
507
-						if ( empty( $section ) ) {
508
-							if ( $display_errors ) {
507
+						if (empty($section)) {
508
+							if ($display_errors) {
509 509
 								throw new EE_Error(
510 510
 									sprintf(
511 511
 										__(
@@ -521,11 +521,11 @@  discard block
 block discarded – undo
521 521
 						break;
522 522
 					// TEST #2 : check that settings section exists
523 523
 					case 2 :
524
-						if ( ! isset( $this->{$section} ) ) {
525
-							if ( $display_errors ) {
524
+						if ( ! isset($this->{$section} )) {
525
+							if ($display_errors) {
526 526
 								throw new EE_Error(
527 527
 									sprintf(
528
-										__( 'The "%s" configuration section does not exist.', 'event_espresso' ),
528
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
529 529
 										$section
530 530
 									)
531 531
 								);
@@ -536,9 +536,9 @@  discard block
 block discarded – undo
536 536
 					// TEST #3 : check that section is the proper format
537 537
 					case 3 :
538 538
 						if (
539
-						! ( $this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass )
539
+						! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
540 540
 						) {
541
-							if ( $display_errors ) {
541
+							if ($display_errors) {
542 542
 								throw new EE_Error(
543 543
 									sprintf(
544 544
 										__(
@@ -554,8 +554,8 @@  discard block
 block discarded – undo
554 554
 						break;
555 555
 					// TEST #4 : check that config section name has been set
556 556
 					case 4 :
557
-						if ( empty( $name ) ) {
558
-							if ( $display_errors ) {
557
+						if (empty($name)) {
558
+							if ($display_errors) {
559 559
 								throw new EE_Error(
560 560
 									__(
561 561
 										'No name has been provided for the specific configuration section.',
@@ -568,8 +568,8 @@  discard block
 block discarded – undo
568 568
 						break;
569 569
 					// TEST #5 : check that a config class name has been set
570 570
 					case 5 :
571
-						if ( empty( $config_class ) ) {
572
-							if ( $display_errors ) {
571
+						if (empty($config_class)) {
572
+							if ($display_errors) {
573 573
 								throw new EE_Error(
574 574
 									__(
575 575
 										'No class name has been provided for the specific configuration section.',
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 						break;
583 583
 					// TEST #6 : verify config class is accessible
584 584
 					case 6 :
585
-						if ( ! class_exists( $config_class ) ) {
586
-							if ( $display_errors ) {
585
+						if ( ! class_exists($config_class)) {
586
+							if ($display_errors) {
587 587
 								throw new EE_Error(
588 588
 									sprintf(
589 589
 										__(
@@ -599,11 +599,11 @@  discard block
 block discarded – undo
599 599
 						break;
600 600
 					// TEST #7 : check that config has even been set
601 601
 					case 7 :
602
-						if ( ! isset( $this->{$section}->{$name} ) ) {
603
-							if ( $display_errors ) {
602
+						if ( ! isset($this->{$section}->{$name} )) {
603
+							if ($display_errors) {
604 604
 								throw new EE_Error(
605 605
 									sprintf(
606
-										__( 'No configuration has been set for "%1$s->%2$s".', 'event_espresso' ),
606
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
607 607
 										$section,
608 608
 										$name
609 609
 									)
@@ -612,13 +612,13 @@  discard block
 block discarded – undo
612 612
 							return false;
613 613
 						} else {
614 614
 							// and make sure it's not serialized
615
-							$this->{$section}->{$name} = maybe_unserialize( $this->{$section}->{$name} );
615
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name} );
616 616
 						}
617 617
 						break;
618 618
 					// TEST #8 : check that config is the requested type
619 619
 					case 8 :
620
-						if ( ! $this->{$section}->{$name} instanceof $config_class ) {
621
-							if ( $display_errors ) {
620
+						if ( ! $this->{$section}->{$name} instanceof $config_class) {
621
+							if ($display_errors) {
622 622
 								throw new EE_Error(
623 623
 									sprintf(
624 624
 										__(
@@ -636,12 +636,12 @@  discard block
 block discarded – undo
636 636
 						break;
637 637
 					// TEST #9 : verify config object
638 638
 					case 9 :
639
-						if ( ! $config_obj instanceof EE_Config_Base ) {
640
-							if ( $display_errors ) {
639
+						if ( ! $config_obj instanceof EE_Config_Base) {
640
+							if ($display_errors) {
641 641
 								throw new EE_Error(
642 642
 									sprintf(
643
-										__( 'The "%s" class is not an instance of EE_Config_Base.', 'event_espresso' ),
644
-										print_r( $config_obj, true )
643
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
644
+										print_r($config_obj, true)
645 645
 									)
646 646
 								);
647 647
 							}
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 						break;
651 651
 				}
652 652
 			}
653
-		} catch ( EE_Error $e ) {
653
+		} catch (EE_Error $e) {
654 654
 			$e->get_error();
655 655
 		}
656 656
 		// you have successfully run the gauntlet
@@ -667,8 +667,8 @@  discard block
 block discarded – undo
667 667
 	 * @param        string $name
668 668
 	 * @return        string
669 669
 	 */
670
-	private function _generate_config_option_name( $section = '', $name = '' ) {
671
-		return 'ee_config-' . strtolower( $section . '-' . str_replace( array( 'EE_', 'EED_' ), '', $name ) );
670
+	private function _generate_config_option_name($section = '', $name = '') {
671
+		return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
672 672
 	}
673 673
 
674 674
 
@@ -682,10 +682,10 @@  discard block
 block discarded – undo
682 682
 	 * @param    string $name
683 683
 	 * @return    string
684 684
 	 */
685
-	private function _set_config_class( $config_class = '', $name = '' ) {
686
-		return ! empty( $config_class )
685
+	private function _set_config_class($config_class = '', $name = '') {
686
+		return ! empty($config_class)
687 687
 			? $config_class
688
-			: str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $name ) ) ) . '_Config';
688
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
689 689
 	}
690 690
 
691 691
 
@@ -700,36 +700,36 @@  discard block
 block discarded – undo
700 700
 	 * @param    EE_Config_Base $config_obj
701 701
 	 * @return    EE_Config_Base
702 702
 	 */
703
-	public function set_config( $section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null ) {
703
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) {
704 704
 		// ensure config class is set to something
705
-		$config_class = $this->_set_config_class( $config_class, $name );
705
+		$config_class = $this->_set_config_class($config_class, $name);
706 706
 		// run tests 1-4, 6, and 7 to verify all config params are set and valid
707
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ) ) ) {
707
+		if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
708 708
 			return null;
709 709
 		}
710
-		$config_option_name = $this->_generate_config_option_name( $section, $name );
710
+		$config_option_name = $this->_generate_config_option_name($section, $name);
711 711
 		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
712
-		if ( ! isset( $this->_addon_option_names[ $config_option_name ] ) ) {
713
-			$this->_addon_option_names[ $config_option_name ] = $config_class;
712
+		if ( ! isset($this->_addon_option_names[$config_option_name])) {
713
+			$this->_addon_option_names[$config_option_name] = $config_class;
714 714
 			$this->update_addon_option_names();
715 715
 		}
716 716
 		// verify the incoming config object but suppress errors
717
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false ) ) {
717
+		if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
718 718
 			$config_obj = new $config_class();
719 719
 		}
720
-		if ( get_option( $config_option_name ) ) {
721
-			EE_Config::log( $config_option_name );
722
-			update_option( $config_option_name, $config_obj );
720
+		if (get_option($config_option_name)) {
721
+			EE_Config::log($config_option_name);
722
+			update_option($config_option_name, $config_obj);
723 723
 			$this->{$section}->{$name} = $config_obj;
724 724
 			return $this->{$section}->{$name};
725 725
 		} else {
726 726
 			// create a wp-option for this config
727
-			if ( add_option( $config_option_name, $config_obj, '', 'no' ) ) {
728
-				$this->{$section}->{$name} = maybe_unserialize( $config_obj );
727
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
728
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
729 729
 				return $this->{$section}->{$name};
730 730
 			} else {
731 731
 				EE_Error::add_error(
732
-					sprintf( __( 'The "%s" could not be saved to the database.', 'event_espresso' ), $config_class ),
732
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
733 733
 					__FILE__,
734 734
 					__FUNCTION__,
735 735
 					__LINE__
@@ -752,46 +752,46 @@  discard block
 block discarded – undo
752 752
 	 * @param    bool                  $throw_errors
753 753
 	 * @return    bool
754 754
 	 */
755
-	public function update_config( $section = '', $name = '', $config_obj = '', $throw_errors = true ) {
755
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) {
756 756
 		// don't allow config updates during WP heartbeats
757
-		if ( \EE_Registry::instance()->REQ->get( 'action', '' ) === 'heartbeat' ) {
757
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
758 758
 			return false;
759 759
 		}
760
-		$config_obj = maybe_unserialize( $config_obj );
760
+		$config_obj = maybe_unserialize($config_obj);
761 761
 		// get class name of the incoming object
762
-		$config_class = get_class( $config_obj );
762
+		$config_class = get_class($config_obj);
763 763
 		// run tests 1-5 and 9 to verify config
764 764
 		if ( ! $this->_verify_config_params(
765 765
 			$section,
766 766
 			$name,
767 767
 			$config_class,
768 768
 			$config_obj,
769
-			array( 1, 2, 3, 4, 7, 9 )
769
+			array(1, 2, 3, 4, 7, 9)
770 770
 		)
771 771
 		) {
772 772
 			return false;
773 773
 		}
774
-		$config_option_name = $this->_generate_config_option_name( $section, $name );
774
+		$config_option_name = $this->_generate_config_option_name($section, $name);
775 775
 		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
776
-		if ( ! isset( $this->_addon_option_names[ $config_option_name ] ) ) {
776
+		if ( ! isset($this->_addon_option_names[$config_option_name])) {
777 777
 			// save new config to db
778
-			if( $this->set_config( $section, $name, $config_class, $config_obj ) ) {
778
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
779 779
 				return true;
780 780
 			}
781 781
 		} else {
782 782
 			// first check if the record already exists
783
-			$existing_config = get_option( $config_option_name );
784
-			$config_obj = serialize( $config_obj );
783
+			$existing_config = get_option($config_option_name);
784
+			$config_obj = serialize($config_obj);
785 785
 			// just return if db record is already up to date (NOT type safe comparison)
786
-			if ( $existing_config == $config_obj ) {
786
+			if ($existing_config == $config_obj) {
787 787
 				$this->{$section}->{$name} = $config_obj;
788 788
 				return true;
789
-			} else if ( update_option( $config_option_name, $config_obj ) ) {
790
-				EE_Config::log( $config_option_name );
789
+			} else if (update_option($config_option_name, $config_obj)) {
790
+				EE_Config::log($config_option_name);
791 791
 				// update wp-option for this config class
792 792
 				$this->{$section}->{$name} = $config_obj;
793 793
 				return true;
794
-			} elseif ( $throw_errors ) {
794
+			} elseif ($throw_errors) {
795 795
 				EE_Error::add_error(
796 796
 					sprintf(
797 797
 						__(
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 							'event_espresso'
800 800
 						),
801 801
 						$config_class,
802
-						'EE_Config->' . $section . '->' . $name
802
+						'EE_Config->'.$section.'->'.$name
803 803
 					),
804 804
 					__FILE__,
805 805
 					__FUNCTION__,
@@ -821,34 +821,34 @@  discard block
 block discarded – undo
821 821
 	 * @param    string $config_class
822 822
 	 * @return    mixed EE_Config_Base | NULL
823 823
 	 */
824
-	public function get_config( $section = '', $name = '', $config_class = '' ) {
824
+	public function get_config($section = '', $name = '', $config_class = '') {
825 825
 		// ensure config class is set to something
826
-		$config_class = $this->_set_config_class( $config_class, $name );
826
+		$config_class = $this->_set_config_class($config_class, $name);
827 827
 		// run tests 1-4, 6 and 7 to verify that all params have been set
828
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ) ) ) {
828
+		if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
829 829
 			return null;
830 830
 		}
831 831
 		// now test if the requested config object exists, but suppress errors
832
-		if ( $this->_verify_config_params( $section, $name, $config_class, null, array( 7, 8 ), false ) ) {
832
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
833 833
 			// config already exists, so pass it back
834 834
 			return $this->{$section}->{$name};
835 835
 		}
836 836
 		// load config option from db if it exists
837
-		$config_obj = $this->get_config_option( $this->_generate_config_option_name( $section, $name ) );
837
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
838 838
 		// verify the newly retrieved config object, but suppress errors
839
-		if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false ) ) {
839
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
840 840
 			// config is good, so set it and pass it back
841 841
 			$this->{$section}->{$name} = $config_obj;
842 842
 			return $this->{$section}->{$name};
843 843
 		}
844 844
 		// oops! $config_obj is not already set and does not exist in the db, so create a new one
845
-		$config_obj = $this->set_config( $section, $name, $config_class );
845
+		$config_obj = $this->set_config($section, $name, $config_class);
846 846
 		// verify the newly created config object
847
-		if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ) ) ) {
847
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
848 848
 			return $this->{$section}->{$name};
849 849
 		} else {
850 850
 			EE_Error::add_error(
851
-				sprintf( __( 'The "%s" could not be retrieved from the database.', 'event_espresso' ), $config_class ),
851
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
852 852
 				__FILE__,
853 853
 				__FUNCTION__,
854 854
 				__LINE__
@@ -866,11 +866,11 @@  discard block
 block discarded – undo
866 866
 	 * @param    string $config_option_name
867 867
 	 * @return    mixed EE_Config_Base | FALSE
868 868
 	 */
869
-	public function get_config_option( $config_option_name = '' ) {
869
+	public function get_config_option($config_option_name = '') {
870 870
 		// retrieve the wp-option for this config class.
871
-		$config_option = maybe_unserialize( get_option( $config_option_name, array() ) );
872
-		if ( empty( $config_option ) ) {
873
-			EE_Config::log( $config_option_name . '-NOT-FOUND' );
871
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
872
+		if (empty($config_option)) {
873
+			EE_Config::log($config_option_name.'-NOT-FOUND');
874 874
 		}
875 875
 		return $config_option;
876 876
 	}
@@ -882,17 +882,17 @@  discard block
 block discarded – undo
882 882
 	 *
883 883
 	 * @param string $config_option_name
884 884
 	 */
885
-	public static function log( $config_option_name = '' ) {
886
-		if ( EE_Config::logging_enabled() && ! empty( $config_option_name ) ) {
887
-			$config_log = get_option( EE_Config::LOG_NAME, array() );
885
+	public static function log($config_option_name = '') {
886
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
887
+			$config_log = get_option(EE_Config::LOG_NAME, array());
888 888
 			//copy incoming $_REQUEST and sanitize it so we can save it
889 889
 			$_request = $_REQUEST;
890
-			array_walk_recursive( $_request, 'sanitize_text_field' );
891
-			$config_log[ (string) microtime( true ) ] = array(
890
+			array_walk_recursive($_request, 'sanitize_text_field');
891
+			$config_log[(string) microtime(true)] = array(
892 892
 				'config_name' => $config_option_name,
893 893
 				'request'     => $_request,
894 894
 			);
895
-			update_option( EE_Config::LOG_NAME, $config_log );
895
+			update_option(EE_Config::LOG_NAME, $config_log);
896 896
 		}
897 897
 	}
898 898
 
@@ -903,15 +903,15 @@  discard block
 block discarded – undo
903 903
 	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
904 904
 	 */
905 905
 	public static function trim_log() {
906
-		if ( ! EE_Config::logging_enabled() ) {
906
+		if ( ! EE_Config::logging_enabled()) {
907 907
 			return;
908 908
 		}
909
-		$config_log = maybe_unserialize( get_option( EE_Config::LOG_NAME, array() ) );
910
-		$log_length = count( $config_log );
911
-		if ( $log_length > EE_Config::LOG_LENGTH ) {
912
-			ksort( $config_log );
913
-			$config_log = array_slice( $config_log, $log_length - EE_Config::LOG_LENGTH, null, true );
914
-			update_option( EE_Config::LOG_NAME, $config_log );
909
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
910
+		$log_length = count($config_log);
911
+		if ($log_length > EE_Config::LOG_LENGTH) {
912
+			ksort($config_log);
913
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
914
+			update_option(EE_Config::LOG_NAME, $config_log);
915 915
 		}
916 916
 	}
917 917
 
@@ -926,14 +926,14 @@  discard block
 block discarded – undo
926 926
 	 * @return    string
927 927
 	 */
928 928
 	public static function get_page_for_posts() {
929
-		$page_for_posts = get_option( 'page_for_posts' );
930
-		if ( ! $page_for_posts ) {
929
+		$page_for_posts = get_option('page_for_posts');
930
+		if ( ! $page_for_posts) {
931 931
 			return 'posts';
932 932
 		}
933 933
 		/** @type WPDB $wpdb */
934 934
 		global $wpdb;
935 935
 		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
936
-		return $wpdb->get_var( $wpdb->prepare( $SQL, $page_for_posts ) );
936
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
937 937
 	}
938 938
 
939 939
 
@@ -989,17 +989,17 @@  discard block
 block discarded – undo
989 989
 			)
990 990
 		) {
991 991
 			// grab list of installed widgets
992
-			$widgets_to_register = glob( EE_WIDGETS . '*', GLOB_ONLYDIR );
992
+			$widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
993 993
 			// filter list of modules to register
994 994
 			$widgets_to_register = apply_filters(
995 995
 				'FHEE__EE_Config__register_widgets__widgets_to_register',
996 996
 				$widgets_to_register
997 997
 			);
998
-			if ( ! empty( $widgets_to_register ) ) {
998
+			if ( ! empty($widgets_to_register)) {
999 999
 				// cycle thru widget folders
1000
-				foreach ( $widgets_to_register as $widget_path ) {
1000
+				foreach ($widgets_to_register as $widget_path) {
1001 1001
 					// add to list of installed widget modules
1002
-					EE_Config::register_ee_widget( $widget_path );
1002
+					EE_Config::register_ee_widget($widget_path);
1003 1003
 				}
1004 1004
 			}
1005 1005
 			// filter list of installed modules
@@ -1019,57 +1019,57 @@  discard block
 block discarded – undo
1019 1019
 	 * @param    string $widget_path - full path up to and including widget folder
1020 1020
 	 * @return    void
1021 1021
 	 */
1022
-	public static function register_ee_widget( $widget_path = null ) {
1023
-		do_action( 'AHEE__EE_Config__register_widget__begin', $widget_path );
1022
+	public static function register_ee_widget($widget_path = null) {
1023
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1024 1024
 		$widget_ext = '.widget.php';
1025 1025
 		// make all separators match
1026
-		$widget_path = rtrim( str_replace( '/\\', DS, $widget_path ), DS );
1026
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1027 1027
 		// does the file path INCLUDE the actual file name as part of the path ?
1028
-		if ( strpos( $widget_path, $widget_ext ) !== false ) {
1028
+		if (strpos($widget_path, $widget_ext) !== false) {
1029 1029
 			// grab and shortcode file name from directory name and break apart at dots
1030
-			$file_name = explode( '.', basename( $widget_path ) );
1030
+			$file_name = explode('.', basename($widget_path));
1031 1031
 			// take first segment from file name pieces and remove class prefix if it exists
1032
-			$widget = strpos( $file_name[0], 'EEW_' ) === 0 ? substr( $file_name[0], 4 ) : $file_name[0];
1032
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1033 1033
 			// sanitize shortcode directory name
1034
-			$widget = sanitize_key( $widget );
1034
+			$widget = sanitize_key($widget);
1035 1035
 			// now we need to rebuild the shortcode path
1036
-			$widget_path = explode( DS, $widget_path );
1036
+			$widget_path = explode(DS, $widget_path);
1037 1037
 			// remove last segment
1038
-			array_pop( $widget_path );
1038
+			array_pop($widget_path);
1039 1039
 			// glue it back together
1040
-			$widget_path = implode( DS, $widget_path );
1040
+			$widget_path = implode(DS, $widget_path);
1041 1041
 		} else {
1042 1042
 			// grab and sanitize widget directory name
1043
-			$widget = sanitize_key( basename( $widget_path ) );
1043
+			$widget = sanitize_key(basename($widget_path));
1044 1044
 		}
1045 1045
 		// create classname from widget directory name
1046
-		$widget = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget ) ) );
1046
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1047 1047
 		// add class prefix
1048
-		$widget_class = 'EEW_' . $widget;
1048
+		$widget_class = 'EEW_'.$widget;
1049 1049
 		// does the widget exist ?
1050
-		if ( ! is_readable( $widget_path . DS . $widget_class . $widget_ext ) ) {
1050
+		if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) {
1051 1051
 			$msg = sprintf(
1052 1052
 				__(
1053 1053
 					'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1054 1054
 					'event_espresso'
1055 1055
 				),
1056 1056
 				$widget_class,
1057
-				$widget_path . DS . $widget_class . $widget_ext
1057
+				$widget_path.DS.$widget_class.$widget_ext
1058 1058
 			);
1059
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1059
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1060 1060
 			return;
1061 1061
 		}
1062 1062
 		// load the widget class file
1063
-		require_once( $widget_path . DS . $widget_class . $widget_ext );
1063
+		require_once($widget_path.DS.$widget_class.$widget_ext);
1064 1064
 		// verify that class exists
1065
-		if ( ! class_exists( $widget_class ) ) {
1066
-			$msg = sprintf( __( 'The requested %s widget class does not exist.', 'event_espresso' ), $widget_class );
1067
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1065
+		if ( ! class_exists($widget_class)) {
1066
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1067
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1068 1068
 			return;
1069 1069
 		}
1070
-		register_widget( $widget_class );
1070
+		register_widget($widget_class);
1071 1071
 		// add to array of registered widgets
1072
-		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1072
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext;
1073 1073
 	}
1074 1074
 
1075 1075
 
@@ -1082,17 +1082,17 @@  discard block
 block discarded – undo
1082 1082
 	 */
1083 1083
 	private function _register_shortcodes() {
1084 1084
 		// grab list of installed shortcodes
1085
-		$shortcodes_to_register = glob( EE_SHORTCODES . '*', GLOB_ONLYDIR );
1085
+		$shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR);
1086 1086
 		// filter list of modules to register
1087 1087
 		$shortcodes_to_register = apply_filters(
1088 1088
 			'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
1089 1089
 			$shortcodes_to_register
1090 1090
 		);
1091
-		if ( ! empty( $shortcodes_to_register ) ) {
1091
+		if ( ! empty($shortcodes_to_register)) {
1092 1092
 			// cycle thru shortcode folders
1093
-			foreach ( $shortcodes_to_register as $shortcode_path ) {
1093
+			foreach ($shortcodes_to_register as $shortcode_path) {
1094 1094
 				// add to list of installed shortcode modules
1095
-				EE_Config::register_shortcode( $shortcode_path );
1095
+				EE_Config::register_shortcode($shortcode_path);
1096 1096
 			}
1097 1097
 		}
1098 1098
 		// filter list of installed modules
@@ -1111,64 +1111,64 @@  discard block
 block discarded – undo
1111 1111
 	 * @param    string $shortcode_path - full path up to and including shortcode folder
1112 1112
 	 * @return    bool
1113 1113
 	 */
1114
-	public static function register_shortcode( $shortcode_path = null ) {
1115
-		do_action( 'AHEE__EE_Config__register_shortcode__begin', $shortcode_path );
1114
+	public static function register_shortcode($shortcode_path = null) {
1115
+		do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
1116 1116
 		$shortcode_ext = '.shortcode.php';
1117 1117
 		// make all separators match
1118
-		$shortcode_path = str_replace( array( '\\', '/' ), DS, $shortcode_path );
1118
+		$shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path);
1119 1119
 		// does the file path INCLUDE the actual file name as part of the path ?
1120
-		if ( strpos( $shortcode_path, $shortcode_ext ) !== false ) {
1120
+		if (strpos($shortcode_path, $shortcode_ext) !== false) {
1121 1121
 			// grab shortcode file name from directory name and break apart at dots
1122
-			$shortcode_file = explode( '.', basename( $shortcode_path ) );
1122
+			$shortcode_file = explode('.', basename($shortcode_path));
1123 1123
 			// take first segment from file name pieces and remove class prefix if it exists
1124
-			$shortcode = strpos( $shortcode_file[0], 'EES_' ) === 0
1125
-				? substr( $shortcode_file[0], 4 )
1124
+			$shortcode = strpos($shortcode_file[0], 'EES_') === 0
1125
+				? substr($shortcode_file[0], 4)
1126 1126
 				: $shortcode_file[0];
1127 1127
 			// sanitize shortcode directory name
1128
-			$shortcode = sanitize_key( $shortcode );
1128
+			$shortcode = sanitize_key($shortcode);
1129 1129
 			// now we need to rebuild the shortcode path
1130
-			$shortcode_path = explode( DS, $shortcode_path );
1130
+			$shortcode_path = explode(DS, $shortcode_path);
1131 1131
 			// remove last segment
1132
-			array_pop( $shortcode_path );
1132
+			array_pop($shortcode_path);
1133 1133
 			// glue it back together
1134
-			$shortcode_path = implode( DS, $shortcode_path ) . DS;
1134
+			$shortcode_path = implode(DS, $shortcode_path).DS;
1135 1135
 		} else {
1136 1136
 			// we need to generate the filename based off of the folder name
1137 1137
 			// grab and sanitize shortcode directory name
1138
-			$shortcode = sanitize_key( basename( $shortcode_path ) );
1139
-			$shortcode_path = rtrim( $shortcode_path, DS ) . DS;
1138
+			$shortcode = sanitize_key(basename($shortcode_path));
1139
+			$shortcode_path = rtrim($shortcode_path, DS).DS;
1140 1140
 		}
1141 1141
 		// create classname from shortcode directory or file name
1142
-		$shortcode = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $shortcode ) ) );
1142
+		$shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
1143 1143
 		// add class prefix
1144
-		$shortcode_class = 'EES_' . $shortcode;
1144
+		$shortcode_class = 'EES_'.$shortcode;
1145 1145
 		// does the shortcode exist ?
1146
-		if ( ! is_readable( $shortcode_path . DS . $shortcode_class . $shortcode_ext ) ) {
1146
+		if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) {
1147 1147
 			$msg = sprintf(
1148 1148
 				__(
1149 1149
 					'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s',
1150 1150
 					'event_espresso'
1151 1151
 				),
1152 1152
 				$shortcode_class,
1153
-				$shortcode_path . DS . $shortcode_class . $shortcode_ext
1153
+				$shortcode_path.DS.$shortcode_class.$shortcode_ext
1154 1154
 			);
1155
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1155
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1156 1156
 			return false;
1157 1157
 		}
1158 1158
 		// load the shortcode class file
1159
-		require_once( $shortcode_path . $shortcode_class . $shortcode_ext );
1159
+		require_once($shortcode_path.$shortcode_class.$shortcode_ext);
1160 1160
 		// verify that class exists
1161
-		if ( ! class_exists( $shortcode_class ) ) {
1161
+		if ( ! class_exists($shortcode_class)) {
1162 1162
 			$msg = sprintf(
1163
-				__( 'The requested %s shortcode class does not exist.', 'event_espresso' ),
1163
+				__('The requested %s shortcode class does not exist.', 'event_espresso'),
1164 1164
 				$shortcode_class
1165 1165
 			);
1166
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1166
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1167 1167
 			return false;
1168 1168
 		}
1169
-		$shortcode = strtoupper( $shortcode );
1169
+		$shortcode = strtoupper($shortcode);
1170 1170
 		// add to array of registered shortcodes
1171
-		EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
1171
+		EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext;
1172 1172
 		return true;
1173 1173
 	}
1174 1174
 
@@ -1182,22 +1182,22 @@  discard block
 block discarded – undo
1182 1182
 	 */
1183 1183
 	private function _register_modules() {
1184 1184
 		// grab list of installed modules
1185
-		$modules_to_register = glob( EE_MODULES . '*', GLOB_ONLYDIR );
1185
+		$modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1186 1186
 		// filter list of modules to register
1187 1187
 		$modules_to_register = apply_filters(
1188 1188
 			'FHEE__EE_Config__register_modules__modules_to_register',
1189 1189
 			$modules_to_register
1190 1190
 		);
1191
-		if ( ! empty( $modules_to_register ) ) {
1191
+		if ( ! empty($modules_to_register)) {
1192 1192
 			// loop through folders
1193
-			foreach ( $modules_to_register as $module_path ) {
1193
+			foreach ($modules_to_register as $module_path) {
1194 1194
 				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1195 1195
 				if (
1196
-					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1197
-					&& $module_path !== EE_MODULES . 'gateways'
1196
+					$module_path !== EE_MODULES.'zzz-copy-this-module-template'
1197
+					&& $module_path !== EE_MODULES.'gateways'
1198 1198
 				) {
1199 1199
 					// add to list of installed modules
1200
-					EE_Config::register_module( $module_path );
1200
+					EE_Config::register_module($module_path);
1201 1201
 				}
1202 1202
 			}
1203 1203
 		}
@@ -1217,39 +1217,39 @@  discard block
 block discarded – undo
1217 1217
 	 * @param    string $module_path - full path up to and including module folder
1218 1218
 	 * @return    bool
1219 1219
 	 */
1220
-	public static function register_module( $module_path = null ) {
1221
-		do_action( 'AHEE__EE_Config__register_module__begin', $module_path );
1220
+	public static function register_module($module_path = null) {
1221
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1222 1222
 		$module_ext = '.module.php';
1223 1223
 		// make all separators match
1224
-		$module_path = str_replace( array( '\\', '/' ), DS, $module_path );
1224
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1225 1225
 		// does the file path INCLUDE the actual file name as part of the path ?
1226
-		if ( strpos( $module_path, $module_ext ) !== false ) {
1226
+		if (strpos($module_path, $module_ext) !== false) {
1227 1227
 			// grab and shortcode file name from directory name and break apart at dots
1228
-			$module_file = explode( '.', basename( $module_path ) );
1228
+			$module_file = explode('.', basename($module_path));
1229 1229
 			// now we need to rebuild the shortcode path
1230
-			$module_path = explode( DS, $module_path );
1230
+			$module_path = explode(DS, $module_path);
1231 1231
 			// remove last segment
1232
-			array_pop( $module_path );
1232
+			array_pop($module_path);
1233 1233
 			// glue it back together
1234
-			$module_path = implode( DS, $module_path ) . DS;
1234
+			$module_path = implode(DS, $module_path).DS;
1235 1235
 			// take first segment from file name pieces and sanitize it
1236
-			$module = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $module_file[0] );
1236
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1237 1237
 			// ensure class prefix is added
1238
-			$module_class = strpos( $module, 'EED_' ) !== 0 ? 'EED_' . $module : $module;
1238
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1239 1239
 		} else {
1240 1240
 			// we need to generate the filename based off of the folder name
1241 1241
 			// grab and sanitize module name
1242
-			$module = strtolower( basename( $module_path ) );
1243
-			$module = preg_replace( '/[^a-z0-9_\-]/', '', $module );
1242
+			$module = strtolower(basename($module_path));
1243
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1244 1244
 			// like trailingslashit()
1245
-			$module_path = rtrim( $module_path, DS ) . DS;
1245
+			$module_path = rtrim($module_path, DS).DS;
1246 1246
 			// create classname from module directory name
1247
-			$module = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $module ) ) );
1247
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1248 1248
 			// add class prefix
1249
-			$module_class = 'EED_' . $module;
1249
+			$module_class = 'EED_'.$module;
1250 1250
 		}
1251 1251
 		// does the module exist ?
1252
-		if ( ! is_readable( $module_path . DS . $module_class . $module_ext ) ) {
1252
+		if ( ! is_readable($module_path.DS.$module_class.$module_ext)) {
1253 1253
 			$msg = sprintf(
1254 1254
 				__(
1255 1255
 					'The requested %s module file could not be found or is not readable due to file permissions.',
@@ -1257,19 +1257,19 @@  discard block
 block discarded – undo
1257 1257
 				),
1258 1258
 				$module
1259 1259
 			);
1260
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1260
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1261 1261
 			return false;
1262 1262
 		}
1263 1263
 		// load the module class file
1264
-		require_once( $module_path . $module_class . $module_ext );
1264
+		require_once($module_path.$module_class.$module_ext);
1265 1265
 		// verify that class exists
1266
-		if ( ! class_exists( $module_class ) ) {
1267
-			$msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class );
1268
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1266
+		if ( ! class_exists($module_class)) {
1267
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1268
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1269 1269
 			return false;
1270 1270
 		}
1271 1271
 		// add to array of registered modules
1272
-		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1272
+		EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1273 1273
 		do_action(
1274 1274
 			'AHEE__EE_Config__register_module__complete',
1275 1275
 			$module_class,
@@ -1289,26 +1289,26 @@  discard block
 block discarded – undo
1289 1289
 	 */
1290 1290
 	private function _initialize_shortcodes() {
1291 1291
 		// cycle thru shortcode folders
1292
-		foreach ( EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path ) {
1292
+		foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) {
1293 1293
 			// add class prefix
1294
-			$shortcode_class = 'EES_' . $shortcode;
1294
+			$shortcode_class = 'EES_'.$shortcode;
1295 1295
 			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1296 1296
 			// which set hooks ?
1297
-			if ( is_admin() ) {
1297
+			if (is_admin()) {
1298 1298
 				// fire immediately
1299
-				call_user_func( array( $shortcode_class, 'set_hooks_admin' ) );
1299
+				call_user_func(array($shortcode_class, 'set_hooks_admin'));
1300 1300
 			} else {
1301 1301
 				// delay until other systems are online
1302 1302
 				add_action(
1303 1303
 					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1304
-					array( $shortcode_class, 'set_hooks' )
1304
+					array($shortcode_class, 'set_hooks')
1305 1305
 				);
1306 1306
 				// convert classname to UPPERCASE and create WP shortcode.
1307
-				$shortcode_tag = strtoupper( $shortcode );
1307
+				$shortcode_tag = strtoupper($shortcode);
1308 1308
 				// but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor'
1309
-				if ( ! shortcode_exists( $shortcode_tag ) ) {
1309
+				if ( ! shortcode_exists($shortcode_tag)) {
1310 1310
 					// NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes()
1311
-					add_shortcode( $shortcode_tag, array( $shortcode_class, 'fallback_shortcode_processor' ) );
1311
+					add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
1312 1312
 				}
1313 1313
 			}
1314 1314
 		}
@@ -1325,17 +1325,17 @@  discard block
 block discarded – undo
1325 1325
 	 */
1326 1326
 	private function _initialize_modules() {
1327 1327
 		// cycle thru shortcode folders
1328
-		foreach ( EE_Registry::instance()->modules as $module_class => $module_path ) {
1328
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1329 1329
 			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1330 1330
 			// which set hooks ?
1331
-			if ( is_admin() ) {
1331
+			if (is_admin()) {
1332 1332
 				// fire immediately
1333
-				call_user_func( array( $module_class, 'set_hooks_admin' ) );
1333
+				call_user_func(array($module_class, 'set_hooks_admin'));
1334 1334
 			} else {
1335 1335
 				// delay until other systems are online
1336 1336
 				add_action(
1337 1337
 					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1338
-					array( $module_class, 'set_hooks' )
1338
+					array($module_class, 'set_hooks')
1339 1339
 				);
1340 1340
 			}
1341 1341
 		}
@@ -1353,29 +1353,29 @@  discard block
 block discarded – undo
1353 1353
 	 * @param    string $key         - url param key indicating a route is being called
1354 1354
 	 * @return    bool
1355 1355
 	 */
1356
-	public static function register_route( $route = null, $module = null, $method_name = null, $key = 'ee' ) {
1357
-		do_action( 'AHEE__EE_Config__register_route__begin', $route, $module, $method_name );
1358
-		$module = str_replace( 'EED_', '', $module );
1359
-		$module_class = 'EED_' . $module;
1360
-		if ( ! isset( EE_Registry::instance()->modules->{$module_class} ) ) {
1361
-			$msg = sprintf( __( 'The module %s has not been registered.', 'event_espresso' ), $module );
1362
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1356
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') {
1357
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1358
+		$module = str_replace('EED_', '', $module);
1359
+		$module_class = 'EED_'.$module;
1360
+		if ( ! isset(EE_Registry::instance()->modules->{$module_class} )) {
1361
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1362
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1363 1363
 			return false;
1364 1364
 		}
1365
-		if ( empty( $route ) ) {
1366
-			$msg = sprintf( __( 'No route has been supplied.', 'event_espresso' ), $route );
1367
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1365
+		if (empty($route)) {
1366
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1367
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1368 1368
 			return false;
1369 1369
 		}
1370
-		if ( ! method_exists( 'EED_' . $module, $method_name ) ) {
1370
+		if ( ! method_exists('EED_'.$module, $method_name)) {
1371 1371
 			$msg = sprintf(
1372
-				__( 'A valid class method for the %s route has not been supplied.', 'event_espresso' ),
1372
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1373 1373
 				$route
1374 1374
 			);
1375
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1375
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1376 1376
 			return false;
1377 1377
 		}
1378
-		EE_Config::$_module_route_map[ $key ][ $route ] = array( 'EED_' . $module, $method_name );
1378
+		EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name);
1379 1379
 		return true;
1380 1380
 	}
1381 1381
 
@@ -1389,11 +1389,11 @@  discard block
 block discarded – undo
1389 1389
 	 * @param    string $key   - url param key indicating a route is being called
1390 1390
 	 * @return    string
1391 1391
 	 */
1392
-	public static function get_route( $route = null, $key = 'ee' ) {
1393
-		do_action( 'AHEE__EE_Config__get_route__begin', $route );
1394
-		$route = (string) apply_filters( 'FHEE__EE_Config__get_route', $route );
1395
-		if ( isset( EE_Config::$_module_route_map[ $key ][ $route ] ) ) {
1396
-			return EE_Config::$_module_route_map[ $key ][ $route ];
1392
+	public static function get_route($route = null, $key = 'ee') {
1393
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1394
+		$route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1395
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1396
+			return EE_Config::$_module_route_map[$key][$route];
1397 1397
 		}
1398 1398
 		return null;
1399 1399
 	}
@@ -1423,49 +1423,49 @@  discard block
 block discarded – undo
1423 1423
 	 * @param    string       $key     - url param key indicating a route is being called
1424 1424
 	 * @return    bool
1425 1425
 	 */
1426
-	public static function register_forward( $route = null, $status = 0, $forward = null, $key = 'ee' ) {
1427
-		do_action( 'AHEE__EE_Config__register_forward', $route, $status, $forward );
1428
-		if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route ) ) {
1426
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') {
1427
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1428
+		if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1429 1429
 			$msg = sprintf(
1430
-				__( 'The module route %s for this forward has not been registered.', 'event_espresso' ),
1430
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1431 1431
 				$route
1432 1432
 			);
1433
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1433
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1434 1434
 			return false;
1435 1435
 		}
1436
-		if ( empty( $forward ) ) {
1437
-			$msg = sprintf( __( 'No forwarding route has been supplied.', 'event_espresso' ), $route );
1438
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1436
+		if (empty($forward)) {
1437
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1438
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1439 1439
 			return false;
1440 1440
 		}
1441
-		if ( is_array( $forward ) ) {
1442
-			if ( ! isset( $forward[1] ) ) {
1441
+		if (is_array($forward)) {
1442
+			if ( ! isset($forward[1])) {
1443 1443
 				$msg = sprintf(
1444
-					__( 'A class method for the %s forwarding route has not been supplied.', 'event_espresso' ),
1444
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1445 1445
 					$route
1446 1446
 				);
1447
-				EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1447
+				EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1448 1448
 				return false;
1449 1449
 			}
1450
-			if ( ! method_exists( $forward[0], $forward[1] ) ) {
1450
+			if ( ! method_exists($forward[0], $forward[1])) {
1451 1451
 				$msg = sprintf(
1452
-					__( 'The class method %s for the %s forwarding route is in invalid.', 'event_espresso' ),
1452
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1453 1453
 					$forward[1],
1454 1454
 					$route
1455 1455
 				);
1456
-				EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1456
+				EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1457 1457
 				return false;
1458 1458
 			}
1459
-		} else if ( ! function_exists( $forward ) ) {
1459
+		} else if ( ! function_exists($forward)) {
1460 1460
 			$msg = sprintf(
1461
-				__( 'The function %s for the %s forwarding route is in invalid.', 'event_espresso' ),
1461
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1462 1462
 				$forward,
1463 1463
 				$route
1464 1464
 			);
1465
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1465
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1466 1466
 			return false;
1467 1467
 		}
1468
-		EE_Config::$_module_forward_map[ $key ][ $route ][ absint( $status ) ] = $forward;
1468
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1469 1469
 		return true;
1470 1470
 	}
1471 1471
 
@@ -1481,12 +1481,12 @@  discard block
 block discarded – undo
1481 1481
 	 * @param    string  $key    - url param key indicating a route is being called
1482 1482
 	 * @return    string
1483 1483
 	 */
1484
-	public static function get_forward( $route = null, $status = 0, $key = 'ee' ) {
1485
-		do_action( 'AHEE__EE_Config__get_forward__begin', $route, $status );
1486
-		if ( isset( EE_Config::$_module_forward_map[ $key ][ $route ][ $status ] ) ) {
1484
+	public static function get_forward($route = null, $status = 0, $key = 'ee') {
1485
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1486
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1487 1487
 			return apply_filters(
1488 1488
 				'FHEE__EE_Config__get_forward',
1489
-				EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1489
+				EE_Config::$_module_forward_map[$key][$route][$status],
1490 1490
 				$route,
1491 1491
 				$status
1492 1492
 			);
@@ -1508,17 +1508,17 @@  discard block
 block discarded – undo
1508 1508
 	 * @param    string  $key    - url param key indicating a route is being called
1509 1509
 	 * @return    bool
1510 1510
 	 */
1511
-	public static function register_view( $route = null, $status = 0, $view = null, $key = 'ee' ) {
1512
-		do_action( 'AHEE__EE_Config__register_view__begin', $route, $status, $view );
1513
-		if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route ) ) {
1511
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') {
1512
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1513
+		if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1514 1514
 			$msg = sprintf(
1515
-				__( 'The module route %s for this view has not been registered.', 'event_espresso' ),
1515
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1516 1516
 				$route
1517 1517
 			);
1518
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1518
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1519 1519
 			return false;
1520 1520
 		}
1521
-		if ( ! is_readable( $view ) ) {
1521
+		if ( ! is_readable($view)) {
1522 1522
 			$msg = sprintf(
1523 1523
 				__(
1524 1524
 					'The %s view file could not be found or is not readable due to file permissions.',
@@ -1526,10 +1526,10 @@  discard block
 block discarded – undo
1526 1526
 				),
1527 1527
 				$view
1528 1528
 			);
1529
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1529
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1530 1530
 			return false;
1531 1531
 		}
1532
-		EE_Config::$_module_view_map[ $key ][ $route ][ absint( $status ) ] = $view;
1532
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1533 1533
 		return true;
1534 1534
 	}
1535 1535
 
@@ -1545,12 +1545,12 @@  discard block
 block discarded – undo
1545 1545
 	 * @param    string  $key    - url param key indicating a route is being called
1546 1546
 	 * @return    string
1547 1547
 	 */
1548
-	public static function get_view( $route = null, $status = 0, $key = 'ee' ) {
1549
-		do_action( 'AHEE__EE_Config__get_view__begin', $route, $status );
1550
-		if ( isset( EE_Config::$_module_view_map[ $key ][ $route ][ $status ] ) ) {
1548
+	public static function get_view($route = null, $status = 0, $key = 'ee') {
1549
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1550
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1551 1551
 			return apply_filters(
1552 1552
 				'FHEE__EE_Config__get_view',
1553
-				EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1553
+				EE_Config::$_module_view_map[$key][$route][$status],
1554 1554
 				$route,
1555 1555
 				$status
1556 1556
 			);
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
 
1562 1562
 
1563 1563
 	public function update_addon_option_names() {
1564
-		update_option( EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names );
1564
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1565 1565
 	}
1566 1566
 
1567 1567
 
@@ -1589,22 +1589,22 @@  discard block
 block discarded – undo
1589 1589
 	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1590 1590
 	 * @throws \EE_Error
1591 1591
 	 */
1592
-	public function get_pretty( $property ) {
1593
-		if ( ! property_exists( $this, $property ) ) {
1592
+	public function get_pretty($property) {
1593
+		if ( ! property_exists($this, $property)) {
1594 1594
 			throw new EE_Error(
1595 1595
 				sprintf(
1596 1596
 					__(
1597 1597
 						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1598 1598
 						'event_espresso'
1599 1599
 					),
1600
-					get_class( $this ),
1600
+					get_class($this),
1601 1601
 					$property
1602 1602
 				)
1603 1603
 			);
1604 1604
 		}
1605 1605
 		//just handling escaping of strings for now.
1606
-		if ( is_string( $this->{$property} ) ) {
1607
-			return stripslashes( $this->{$property} );
1606
+		if (is_string($this->{$property} )) {
1607
+			return stripslashes($this->{$property} );
1608 1608
 		}
1609 1609
 		return $this->{$property};
1610 1610
 	}
@@ -1613,17 +1613,17 @@  discard block
 block discarded – undo
1613 1613
 
1614 1614
 	public function populate() {
1615 1615
 		//grab defaults via a new instance of this class.
1616
-		$class_name = get_class( $this );
1616
+		$class_name = get_class($this);
1617 1617
 		$defaults = new $class_name;
1618 1618
 		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1619 1619
 		//default from our $defaults object.
1620
-		foreach ( get_object_vars( $defaults ) as $property => $value ) {
1621
-			if ( $this->{$property} === null ) {
1620
+		foreach (get_object_vars($defaults) as $property => $value) {
1621
+			if ($this->{$property} === null) {
1622 1622
 				$this->{$property} = $value;
1623 1623
 			}
1624 1624
 		}
1625 1625
 		//cleanup
1626
-		unset( $defaults );
1626
+		unset($defaults);
1627 1627
 	}
1628 1628
 
1629 1629
 
@@ -1639,7 +1639,7 @@  discard block
 block discarded – undo
1639 1639
 	 * @param $a
1640 1640
 	 * @return bool
1641 1641
 	 */
1642
-	public function __isset( $a ) {
1642
+	public function __isset($a) {
1643 1643
 		return false;
1644 1644
 	}
1645 1645
 
@@ -1651,7 +1651,7 @@  discard block
 block discarded – undo
1651 1651
 	 * @param $a
1652 1652
 	 * @return bool
1653 1653
 	 */
1654
-	public function __unset( $a ) {
1654
+	public function __unset($a) {
1655 1655
 		return false;
1656 1656
 	}
1657 1657
 
@@ -1761,7 +1761,7 @@  discard block
 block discarded – undo
1761 1761
 		$this->current_blog_id = get_current_blog_id();
1762 1762
 		$this->current_blog_id = $this->current_blog_id === NULL ? 1 : $this->current_blog_id;
1763 1763
 		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1764
-		$this->ee_ueip_has_notified = is_main_site() ? get_option( 'ee_ueip_has_notified', false ) : true;
1764
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1765 1765
 		$this->post_shortcodes = array();
1766 1766
 		$this->module_route_map = array();
1767 1767
 		$this->module_forward_map = array();
@@ -1777,9 +1777,9 @@  discard block
 block discarded – undo
1777 1777
 		$this->thank_you_page_url = '';
1778 1778
 		$this->cancel_page_url = '';
1779 1779
 		//cpt slugs
1780
-		$this->event_cpt_slug = __( 'events', 'event_espresso' );
1780
+		$this->event_cpt_slug = __('events', 'event_espresso');
1781 1781
 		//ueip constant check
1782
-		if ( defined( 'EE_DISABLE_UXIP' ) && EE_DISABLE_UXIP ) {
1782
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1783 1783
 			$this->ee_ueip_optin = false;
1784 1784
 			$this->ee_ueip_has_notified = true;
1785 1785
 		}
@@ -1822,11 +1822,11 @@  discard block
 block discarded – undo
1822 1822
 	 * @return    string
1823 1823
 	 */
1824 1824
 	public function reg_page_url() {
1825
-		if ( ! $this->reg_page_url ) {
1825
+		if ( ! $this->reg_page_url) {
1826 1826
 			$this->reg_page_url = add_query_arg(
1827
-				array( 'uts' => time() ),
1828
-				get_permalink( $this->reg_page_id )
1829
-			) . '#checkout';
1827
+				array('uts' => time()),
1828
+				get_permalink($this->reg_page_id)
1829
+			).'#checkout';
1830 1830
 		}
1831 1831
 		return $this->reg_page_url;
1832 1832
 	}
@@ -1841,12 +1841,12 @@  discard block
 block discarded – undo
1841 1841
 	 * @access    public
1842 1842
 	 * @return    string
1843 1843
 	 */
1844
-	public function txn_page_url( $query_args = array() ) {
1845
-		if ( ! $this->txn_page_url ) {
1846
-			$this->txn_page_url = get_permalink( $this->txn_page_id );
1844
+	public function txn_page_url($query_args = array()) {
1845
+		if ( ! $this->txn_page_url) {
1846
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1847 1847
 		}
1848
-		if ( $query_args ) {
1849
-			return add_query_arg( $query_args, $this->txn_page_url );
1848
+		if ($query_args) {
1849
+			return add_query_arg($query_args, $this->txn_page_url);
1850 1850
 		} else {
1851 1851
 			return $this->txn_page_url;
1852 1852
 		}
@@ -1862,12 +1862,12 @@  discard block
 block discarded – undo
1862 1862
 	 * @access    public
1863 1863
 	 * @return    string
1864 1864
 	 */
1865
-	public function thank_you_page_url( $query_args = array() ) {
1866
-		if ( ! $this->thank_you_page_url ) {
1867
-			$this->thank_you_page_url = get_permalink( $this->thank_you_page_id );
1865
+	public function thank_you_page_url($query_args = array()) {
1866
+		if ( ! $this->thank_you_page_url) {
1867
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1868 1868
 		}
1869
-		if ( $query_args ) {
1870
-			return add_query_arg( $query_args, $this->thank_you_page_url );
1869
+		if ($query_args) {
1870
+			return add_query_arg($query_args, $this->thank_you_page_url);
1871 1871
 		} else {
1872 1872
 			return $this->thank_you_page_url;
1873 1873
 		}
@@ -1882,8 +1882,8 @@  discard block
 block discarded – undo
1882 1882
 	 * @return    string
1883 1883
 	 */
1884 1884
 	public function cancel_page_url() {
1885
-		if ( ! $this->cancel_page_url ) {
1886
-			$this->cancel_page_url = get_permalink( $this->cancel_page_id );
1885
+		if ( ! $this->cancel_page_url) {
1886
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1887 1887
 		}
1888 1888
 		return $this->cancel_page_url;
1889 1889
 	}
@@ -1912,22 +1912,22 @@  discard block
 block discarded – undo
1912 1912
 	 */
1913 1913
 	protected function _get_main_ee_ueip_optin() {
1914 1914
 		//if this is the main site then we can just bypass our direct query.
1915
-		if ( is_main_site() ) {
1916
-			return get_option( 'ee_ueip_optin', false );
1915
+		if (is_main_site()) {
1916
+			return get_option('ee_ueip_optin', false);
1917 1917
 		}
1918 1918
 
1919 1919
 		//is this already cached for this request?  If so use it.
1920
-		if ( ! empty( EE_Core_Config::$ee_ueip_option ) ) {
1920
+		if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1921 1921
 			return EE_Core_Config::$ee_ueip_option;
1922 1922
 		}
1923 1923
 
1924 1924
 		global $wpdb;
1925 1925
 		$current_network_main_site = is_multisite() ? get_current_site() : null;
1926
-		$current_main_site_id = ! empty( $current_network_main_site ) ? $current_network_main_site->blog_id : 1;
1926
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1927 1927
 		$option = 'ee_ueip_optin';
1928 1928
 
1929 1929
 		//set correct table for query
1930
-		$table_name = $wpdb->get_blog_prefix( $current_main_site_id ) . 'options';
1930
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1931 1931
 
1932 1932
 
1933 1933
 		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
@@ -1935,20 +1935,20 @@  discard block
 block discarded – undo
1935 1935
 		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1936 1936
 		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1937 1937
 		//for the purpose of caching.
1938
-		$pre = apply_filters( 'pre_option_' . $option, false, $option );
1939
-		if ( false !== $pre ) {
1938
+		$pre = apply_filters('pre_option_'.$option, false, $option);
1939
+		if (false !== $pre) {
1940 1940
 			EE_Core_Config::$ee_ueip_option = $pre;
1941 1941
 			return EE_Core_Config::$ee_ueip_option;
1942 1942
 		}
1943 1943
 
1944
-		$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", $option ) );
1945
-		if ( is_object( $row ) ) {
1944
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", $option));
1945
+		if (is_object($row)) {
1946 1946
 			$value = $row->option_value;
1947 1947
 		} else { //option does not exist so use default.
1948
-			return apply_filters( 'default_option_' . $option, false, $option );
1948
+			return apply_filters('default_option_'.$option, false, $option);
1949 1949
 		}
1950 1950
 
1951
-		EE_Core_Config::$ee_ueip_option = apply_filters( 'option_' . $option, maybe_unserialize( $value ), $option );
1951
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
1952 1952
 		return EE_Core_Config::$ee_ueip_option;
1953 1953
 	}
1954 1954
 
@@ -1964,7 +1964,7 @@  discard block
 block discarded – undo
1964 1964
 		//reset all url properties
1965 1965
 		$this->_reset_urls();
1966 1966
 		//return what to save to db
1967
-		return array_keys( get_object_vars( $this ) );
1967
+		return array_keys(get_object_vars($this));
1968 1968
 	}
1969 1969
 
1970 1970
 }
@@ -2111,14 +2111,14 @@  discard block
 block discarded – undo
2111 2111
 	 */
2112 2112
 	public function __construct() {
2113 2113
 		// set default organization settings
2114
-		$this->name = get_bloginfo( 'name' );
2114
+		$this->name = get_bloginfo('name');
2115 2115
 		$this->address_1 = '123 Onna Road';
2116 2116
 		$this->address_2 = 'PO Box 123';
2117 2117
 		$this->city = 'Inna City';
2118 2118
 		$this->STA_ID = 4;
2119 2119
 		$this->CNT_ISO = 'US';
2120 2120
 		$this->zip = '12345';
2121
-		$this->email = get_bloginfo( 'admin_email' );
2121
+		$this->email = get_bloginfo('admin_email');
2122 2122
 		$this->phone = '';
2123 2123
 		$this->vat = '123456789';
2124 2124
 		$this->logo_url = '';
@@ -2206,46 +2206,46 @@  discard block
 block discarded – undo
2206 2206
 	 * @param string $CNT_ISO
2207 2207
 	 * @throws \EE_Error
2208 2208
 	 */
2209
-	public function __construct( $CNT_ISO = '' ) {
2209
+	public function __construct($CNT_ISO = '') {
2210 2210
 		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2211
-		$table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true );
2211
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2212 2212
 		// get country code from organization settings or use default
2213
-		$ORG_CNT = isset( EE_Registry::instance()->CFG->organization )
2213
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2214 2214
 		           && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2215 2215
 			? EE_Registry::instance()->CFG->organization->CNT_ISO
2216 2216
 			: '';
2217 2217
 		// but override if requested
2218
-		$CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : $ORG_CNT;
2218
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2219 2219
 		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2220 2220
 		if (
2221
-			! empty( $CNT_ISO )
2221
+			! empty($CNT_ISO)
2222 2222
 			&& EE_Maintenance_Mode::instance()->models_can_query()
2223
-			&& $table_analysis->tableExists( EE_Registry::instance()->load_model( 'Country' )->table() )
2223
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2224 2224
 		) {
2225 2225
 			// retrieve the country settings from the db, just in case they have been customized
2226
-			$country = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $CNT_ISO );
2227
-			if ( $country instanceof EE_Country ) {
2228
-				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2229
-				$this->name = $country->currency_name_single();    // Dollar
2230
-				$this->plural = $country->currency_name_plural();    // Dollars
2231
-				$this->sign = $country->currency_sign();            // currency sign: $
2232
-				$this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2233
-				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2234
-				$this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2235
-				$this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2226
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2227
+			if ($country instanceof EE_Country) {
2228
+				$this->code = $country->currency_code(); // currency code: USD, CAD, EUR
2229
+				$this->name = $country->currency_name_single(); // Dollar
2230
+				$this->plural = $country->currency_name_plural(); // Dollars
2231
+				$this->sign = $country->currency_sign(); // currency sign: $
2232
+				$this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE  or  FALSE$
2233
+				$this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
2234
+				$this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2235
+				$this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2236 2236
 			}
2237 2237
 		}
2238 2238
 		// fallback to hardcoded defaults, in case the above failed
2239
-		if ( empty( $this->code ) ) {
2239
+		if (empty($this->code)) {
2240 2240
 			// set default currency settings
2241
-			$this->code = 'USD';    // currency code: USD, CAD, EUR
2242
-			$this->name = __( 'Dollar', 'event_espresso' );    // Dollar
2243
-			$this->plural = __( 'Dollars', 'event_espresso' );    // Dollars
2244
-			$this->sign = '$';    // currency sign: $
2245
-			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2246
-			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2247
-			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2248
-			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2241
+			$this->code = 'USD'; // currency code: USD, CAD, EUR
2242
+			$this->name = __('Dollar', 'event_espresso'); // Dollar
2243
+			$this->plural = __('Dollars', 'event_espresso'); // Dollars
2244
+			$this->sign = '$'; // currency sign: $
2245
+			$this->sign_b4 = true; // currency sign before or after: $TRUE  or  FALSE$
2246
+			$this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
2247
+			$this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2248
+			$this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2249 2249
 		}
2250 2250
 	}
2251 2251
 }
@@ -2414,7 +2414,7 @@  discard block
 block discarded – undo
2414 2414
 	 * @since 4.8.8.rc.019
2415 2415
 	 */
2416 2416
 	public function do_hooks() {
2417
-		add_action( 'AHEE__EE_Config___load_core_config__end', array( $this, 'set_default_reg_status_on_EEM_Event' ) );
2417
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2418 2418
 	}
2419 2419
 
2420 2420
 
@@ -2423,7 +2423,7 @@  discard block
 block discarded – undo
2423 2423
 	 * @return void
2424 2424
 	 */
2425 2425
 	public function set_default_reg_status_on_EEM_Event() {
2426
-		EEM_Event::set_default_reg_status( $this->default_STS_ID );
2426
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2427 2427
 	}
2428 2428
 
2429 2429
 
@@ -2440,7 +2440,7 @@  discard block
 block discarded – undo
2440 2440
 	/**
2441 2441
 	 * @param boolean $track_invalid_checkout_access
2442 2442
 	 */
2443
-	public function set_track_invalid_checkout_access( $track_invalid_checkout_access ) {
2443
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access) {
2444 2444
 		$this->track_invalid_checkout_access = filter_var(
2445 2445
 			$track_invalid_checkout_access,
2446 2446
 			FILTER_VALIDATE_BOOLEAN
@@ -2558,10 +2558,10 @@  discard block
 block discarded – undo
2558 2558
 	 * @param bool $reset
2559 2559
 	 * @return string
2560 2560
 	 */
2561
-	public function log_file_name( $reset = false ) {
2562
-		if ( empty( $this->log_file_name ) || $reset ) {
2563
-			$this->log_file_name = sanitize_key( 'espresso_log_' . md5( uniqid( '', true ) ) ) . '.txt';
2564
-			EE_Config::instance()->update_espresso_config( false, false );
2561
+	public function log_file_name($reset = false) {
2562
+		if (empty($this->log_file_name) || $reset) {
2563
+			$this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt';
2564
+			EE_Config::instance()->update_espresso_config(false, false);
2565 2565
 		}
2566 2566
 		return $this->log_file_name;
2567 2567
 	}
@@ -2572,10 +2572,10 @@  discard block
 block discarded – undo
2572 2572
 	 * @param bool $reset
2573 2573
 	 * @return string
2574 2574
 	 */
2575
-	public function debug_file_name( $reset = false ) {
2576
-		if ( empty( $this->debug_file_name ) || $reset ) {
2577
-			$this->debug_file_name = sanitize_key( 'espresso_debug_' . md5( uniqid( '', true ) ) ) . '.txt';
2578
-			EE_Config::instance()->update_espresso_config( false, false );
2575
+	public function debug_file_name($reset = false) {
2576
+		if (empty($this->debug_file_name) || $reset) {
2577
+			$this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt';
2578
+			EE_Config::instance()->update_espresso_config(false, false);
2579 2579
 		}
2580 2580
 		return $this->debug_file_name;
2581 2581
 	}
@@ -2586,7 +2586,7 @@  discard block
 block discarded – undo
2586 2586
 	 * @return string
2587 2587
 	 */
2588 2588
 	public function affiliate_id() {
2589
-		return ! empty( $this->affiliate_id ) ? $this->affiliate_id : 'default';
2589
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2590 2590
 	}
2591 2591
 
2592 2592
 
@@ -2595,7 +2595,7 @@  discard block
 block discarded – undo
2595 2595
      * @return boolean
2596 2596
      */
2597 2597
     public function encode_session_data() {
2598
-        return filter_var( $this->encode_session_data, FILTER_VALIDATE_BOOLEAN );
2598
+        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2599 2599
     }
2600 2600
 
2601 2601
 
@@ -2603,8 +2603,8 @@  discard block
 block discarded – undo
2603 2603
     /**
2604 2604
      * @param boolean $encode_session_data
2605 2605
      */
2606
-    public function set_encode_session_data( $encode_session_data ) {
2607
-        $this->encode_session_data = filter_var( $encode_session_data, FILTER_VALIDATE_BOOLEAN );
2606
+    public function set_encode_session_data($encode_session_data) {
2607
+        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2608 2608
     }
2609 2609
 
2610 2610
 
@@ -2784,21 +2784,21 @@  discard block
 block discarded – undo
2784 2784
 		$this->use_google_maps = true;
2785 2785
 		$this->google_map_api_key = '';
2786 2786
 		// for event details pages (reg page)
2787
-		$this->event_details_map_width = 585;            // ee_map_width_single
2788
-		$this->event_details_map_height = 362;            // ee_map_height_single
2789
-		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2790
-		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2791
-		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2792
-		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2793
-		$this->event_details_map_align = 'center';            // ee_map_align_single
2787
+		$this->event_details_map_width = 585; // ee_map_width_single
2788
+		$this->event_details_map_height = 362; // ee_map_height_single
2789
+		$this->event_details_map_zoom = 14; // ee_map_zoom_single
2790
+		$this->event_details_display_nav = true; // ee_map_nav_display_single
2791
+		$this->event_details_nav_size = false; // ee_map_nav_size_single
2792
+		$this->event_details_control_type = 'default'; // ee_map_type_control_single
2793
+		$this->event_details_map_align = 'center'; // ee_map_align_single
2794 2794
 		// for event list pages
2795
-		$this->event_list_map_width = 300;            // ee_map_width
2796
-		$this->event_list_map_height = 185;        // ee_map_height
2797
-		$this->event_list_map_zoom = 12;            // ee_map_zoom
2798
-		$this->event_list_display_nav = false;        // ee_map_nav_display
2799
-		$this->event_list_nav_size = true;            // ee_map_nav_size
2800
-		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2801
-		$this->event_list_map_align = 'center';            // ee_map_align
2795
+		$this->event_list_map_width = 300; // ee_map_width
2796
+		$this->event_list_map_height = 185; // ee_map_height
2797
+		$this->event_list_map_zoom = 12; // ee_map_zoom
2798
+		$this->event_list_display_nav = false; // ee_map_nav_display
2799
+		$this->event_list_nav_size = true; // ee_map_nav_size
2800
+		$this->event_list_control_type = 'dropdown'; // ee_map_type_control
2801
+		$this->event_list_map_align = 'center'; // ee_map_align
2802 2802
 	}
2803 2803
 
2804 2804
 }
@@ -2960,7 +2960,7 @@  discard block
 block discarded – undo
2960 2960
 	 * @return void
2961 2961
 	 */
2962 2962
 	protected function _set_php_values() {
2963
-		$this->php->max_input_vars = ini_get( 'max_input_vars' );
2963
+		$this->php->max_input_vars = ini_get('max_input_vars');
2964 2964
 		$this->php->version = phpversion();
2965 2965
 	}
2966 2966
 
@@ -2979,10 +2979,10 @@  discard block
 block discarded – undo
2979 2979
 	 * @type string $msg         Any message to be displayed.
2980 2980
 	 *                           }
2981 2981
 	 */
2982
-	public function max_input_vars_limit_check( $input_count = 0 ) {
2983
-		if ( ! empty( $this->php->max_input_vars )
2984
-		     && ( $input_count >= $this->php->max_input_vars )
2985
-		     && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9 )
2982
+	public function max_input_vars_limit_check($input_count = 0) {
2983
+		if ( ! empty($this->php->max_input_vars)
2984
+		     && ($input_count >= $this->php->max_input_vars)
2985
+		     && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
2986 2986
 		) {
2987 2987
 			return sprintf(
2988 2988
 				__(
@@ -3078,7 +3078,7 @@  discard block
 block discarded – undo
3078 3078
 	 */
3079 3079
 	public function __construct() {
3080 3080
 		$this->payment_settings = array();
3081
-		$this->active_gateways = array( 'Invoice' => false );
3081
+		$this->active_gateways = array('Invoice' => false);
3082 3082
 	}
3083 3083
 }
3084 3084
 
Please login to merge, or discard this patch.
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	public static function reset( $hard_reset = false, $reinstantiate = true ) {
157 157
 		if ( self::$_instance instanceof EE_Config ) {
158
-            if ($hard_reset) {
159
-                self::$_instance->_addon_option_names = array();
160
-                self::$_instance->_initialize_config();
161
-                self::$_instance->update_espresso_config();
162
-            }
163
-            self::$_instance->update_addon_option_names();
158
+			if ($hard_reset) {
159
+				self::$_instance->_addon_option_names = array();
160
+				self::$_instance->_initialize_config();
161
+				self::$_instance->update_espresso_config();
162
+			}
163
+			self::$_instance->update_addon_option_names();
164 164
 		}
165 165
 		self::$_instance = null;
166 166
 		//we don't need to reset the static properties imo because those should
@@ -2211,7 +2211,7 @@  discard block
 block discarded – undo
2211 2211
 		$table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true );
2212 2212
 		// get country code from organization settings or use default
2213 2213
 		$ORG_CNT = isset( EE_Registry::instance()->CFG->organization )
2214
-		           && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2214
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2215 2215
 			? EE_Registry::instance()->CFG->organization->CNT_ISO
2216 2216
 			: '';
2217 2217
 		// but override if requested
@@ -2521,12 +2521,12 @@  discard block
 block discarded – undo
2521 2521
 	public $help_tour_activation;
2522 2522
 
2523 2523
 	/**
2524
-     * adds extra layer of encoding to session data to prevent serialization errors
2525
-     * but is incompatible with some server configuration errors
2526
-     * if you get "500 internal server errors" during registration, try turning this on
2527
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2528
-     *
2529
-     * @var boolean $encode_session_data
2524
+	 * adds extra layer of encoding to session data to prevent serialization errors
2525
+	 * but is incompatible with some server configuration errors
2526
+	 * if you get "500 internal server errors" during registration, try turning this on
2527
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2528
+	 *
2529
+	 * @var boolean $encode_session_data
2530 2530
 	 */
2531 2531
 	private $encode_session_data = false;
2532 2532
 
@@ -2591,21 +2591,21 @@  discard block
 block discarded – undo
2591 2591
 
2592 2592
 
2593 2593
 
2594
-    /**
2595
-     * @return boolean
2596
-     */
2597
-    public function encode_session_data() {
2598
-        return filter_var( $this->encode_session_data, FILTER_VALIDATE_BOOLEAN );
2599
-    }
2594
+	/**
2595
+	 * @return boolean
2596
+	 */
2597
+	public function encode_session_data() {
2598
+		return filter_var( $this->encode_session_data, FILTER_VALIDATE_BOOLEAN );
2599
+	}
2600 2600
 
2601 2601
 
2602 2602
 
2603
-    /**
2604
-     * @param boolean $encode_session_data
2605
-     */
2606
-    public function set_encode_session_data( $encode_session_data ) {
2607
-        $this->encode_session_data = filter_var( $encode_session_data, FILTER_VALIDATE_BOOLEAN );
2608
-    }
2603
+	/**
2604
+	 * @param boolean $encode_session_data
2605
+	 */
2606
+	public function set_encode_session_data( $encode_session_data ) {
2607
+		$this->encode_session_data = filter_var( $encode_session_data, FILTER_VALIDATE_BOOLEAN );
2608
+	}
2609 2609
 
2610 2610
 
2611 2611
 
@@ -2649,13 +2649,13 @@  discard block
 block discarded – undo
2649 2649
 	public $current_espresso_theme;
2650 2650
 
2651 2651
 	/**
2652
-	* @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2653
-	*/
2652
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2653
+	 */
2654 2654
 	public $EED_Ticket_Selector;
2655 2655
 
2656 2656
 	/**
2657
-	* @var EE_Event_Single_Config $EED_Event_Single
2658
-	*/
2657
+	 * @var EE_Event_Single_Config $EED_Event_Single
2658
+	 */
2659 2659
 	public $EED_Event_Single;
2660 2660
 
2661 2661
 	/**
@@ -2896,16 +2896,16 @@  discard block
 block discarded – undo
2896 2896
  */
2897 2897
 class EE_Ticket_Selector_Config extends EE_Config_Base {
2898 2898
 
2899
-    /**
2900
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2901
-     */
2902
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2899
+	/**
2900
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2901
+	 */
2902
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2903 2903
 
2904
-    /**
2905
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2906
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2907
-     */
2908
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2904
+	/**
2905
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2906
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2907
+	 */
2908
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2909 2909
 
2910 2910
 	/**
2911 2911
 	 * @var boolean $show_ticket_sale_columns
@@ -2944,7 +2944,7 @@  discard block
 block discarded – undo
2944 2944
 	 *    class constructor
2945 2945
 	 */
2946 2946
 	public function __construct() {
2947
-        $this->show_ticket_sale_columns = true;
2947
+		$this->show_ticket_sale_columns = true;
2948 2948
 		$this->show_ticket_details = true;
2949 2949
 		$this->show_expired_tickets = true;
2950 2950
 		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
@@ -2953,91 +2953,91 @@  discard block
 block discarded – undo
2953 2953
 
2954 2954
 
2955 2955
 
2956
-    /**
2957
-     * returns true if a datetime selector should be displayed
2958
-     *
2959
-     * @param array $datetimes
2960
-     * @return bool
2961
-     */
2962
-    public function showDatetimeSelector(array $datetimes)
2963
-    {
2964
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
2965
-        return ! (
2966
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
2967
-           || (
2968
-               $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
2969
-               && count($datetimes) < $this->getDatetimeSelectorThreshold()
2970
-           )
2971
-        );
2972
-    }
2973
-
2974
-
2975
-    /**
2976
-     * @return string
2977
-     */
2978
-    public function getShowDatetimeSelector()
2979
-    {
2980
-        return $this->show_datetime_selector;
2981
-    }
2956
+	/**
2957
+	 * returns true if a datetime selector should be displayed
2958
+	 *
2959
+	 * @param array $datetimes
2960
+	 * @return bool
2961
+	 */
2962
+	public function showDatetimeSelector(array $datetimes)
2963
+	{
2964
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
2965
+		return ! (
2966
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
2967
+		   || (
2968
+			   $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
2969
+			   && count($datetimes) < $this->getDatetimeSelectorThreshold()
2970
+		   )
2971
+		);
2972
+	}
2982 2973
 
2983 2974
 
2975
+	/**
2976
+	 * @return string
2977
+	 */
2978
+	public function getShowDatetimeSelector()
2979
+	{
2980
+		return $this->show_datetime_selector;
2981
+	}
2984 2982
 
2985
-    /**
2986
-     * @param bool $keys_only
2987
-     * @return array
2988
-     */
2989
-    public function getShowDatetimeSelectorOptions($keys_only = true)
2990
-    {
2991
-        return $keys_only
2992
-            ? array(
2993
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
2994
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
2995
-            )
2996
-            : array(
2997
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
2998
-                    'Do not show datetime selector', 'event_espresso'
2999
-                ),
3000
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__(
3001
-                    'Maybe show datetime selector', 'event_espresso'
3002
-                ),
3003
-            );
3004
-    }
3005
-
3006
-
3007
-
3008
-    /**
3009
-     * @param string $show_datetime_selector
3010
-     */
3011
-    public function setShowDatetimeSelector($show_datetime_selector)
3012
-    {
3013
-        $this->show_datetime_selector = in_array(
3014
-            $show_datetime_selector,
3015
-            $this->getShowDatetimeSelectorOptions()
3016
-        )
3017
-            ? $show_datetime_selector
3018
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3019
-    }
3020 2983
 
3021 2984
 
2985
+	/**
2986
+	 * @param bool $keys_only
2987
+	 * @return array
2988
+	 */
2989
+	public function getShowDatetimeSelectorOptions($keys_only = true)
2990
+	{
2991
+		return $keys_only
2992
+			? array(
2993
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
2994
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
2995
+			)
2996
+			: array(
2997
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
2998
+					'Do not show datetime selector', 'event_espresso'
2999
+				),
3000
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__(
3001
+					'Maybe show datetime selector', 'event_espresso'
3002
+				),
3003
+			);
3004
+	}
3022 3005
 
3023
-    /**
3024
-     * @return int
3025
-     */
3026
-    public function getDatetimeSelectorThreshold()
3027
-    {
3028
-        return $this->datetime_selector_threshold;
3029
-    }
3030 3006
 
3031 3007
 
3008
+	/**
3009
+	 * @param string $show_datetime_selector
3010
+	 */
3011
+	public function setShowDatetimeSelector($show_datetime_selector)
3012
+	{
3013
+		$this->show_datetime_selector = in_array(
3014
+			$show_datetime_selector,
3015
+			$this->getShowDatetimeSelectorOptions()
3016
+		)
3017
+			? $show_datetime_selector
3018
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3019
+	}
3032 3020
 
3033
-    /**
3034
-     * @param int $datetime_selector_threshold
3035
-     */
3036
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3037
-    {
3038
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3039
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3040
-    }
3021
+
3022
+
3023
+	/**
3024
+	 * @return int
3025
+	 */
3026
+	public function getDatetimeSelectorThreshold()
3027
+	{
3028
+		return $this->datetime_selector_threshold;
3029
+	}
3030
+
3031
+
3032
+
3033
+	/**
3034
+	 * @param int $datetime_selector_threshold
3035
+	 */
3036
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3037
+	{
3038
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3039
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3040
+	}
3041 3041
 
3042 3042
 
3043 3043
 }
@@ -3100,8 +3100,8 @@  discard block
 block discarded – undo
3100 3100
 	 */
3101 3101
 	public function max_input_vars_limit_check( $input_count = 0 ) {
3102 3102
 		if ( ! empty( $this->php->max_input_vars )
3103
-		     && ( $input_count >= $this->php->max_input_vars )
3104
-		     && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9 )
3103
+			 && ( $input_count >= $this->php->max_input_vars )
3104
+			 && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9 )
3105 3105
 		) {
3106 3106
 			return sprintf(
3107 3107
 				__(
@@ -3145,22 +3145,22 @@  discard block
 block discarded – undo
3145 3145
 class EE_Tax_Config extends EE_Config_Base
3146 3146
 {
3147 3147
 
3148
-    /*
3148
+	/*
3149 3149
      * flag to indicate whether or not to display ticket prices with the taxes included
3150 3150
      *
3151 3151
      * @var boolean $prices_displayed_including_taxes
3152 3152
      */
3153
-    public $prices_displayed_including_taxes;
3153
+	public $prices_displayed_including_taxes;
3154 3154
 
3155 3155
 
3156 3156
 
3157
-    /**
3158
-     *    class constructor
3159
-     */
3160
-    public function __construct()
3161
-    {
3162
-        $this->prices_displayed_including_taxes = true;
3163
-    }
3157
+	/**
3158
+	 *    class constructor
3159
+	 */
3160
+	public function __construct()
3161
+	{
3162
+		$this->prices_displayed_including_taxes = true;
3163
+	}
3164 3164
 }
3165 3165
 
3166 3166
 
Please login to merge, or discard this patch.
core/helpers/EEH_File.helper.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -325,8 +325,8 @@
 block discarded – undo
325 325
 		//eg if given "/var/something/somewhere/", we want to get "somewhere"'s
326 326
 		//parent folder, "/var/something/"
327 327
 		$ds = strlen($file_or_folder_path) > 1
328
-            ? strrpos($file_or_folder_path, DS, -2)
329
-            : strlen($file_or_folder_path);
328
+			? strrpos($file_or_folder_path, DS, -2)
329
+			: strlen($file_or_folder_path);
330 330
 		return substr($file_or_folder_path, 0, $ds + 1);
331 331
 	}
332 332
 
Please login to merge, or discard this patch.
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
  * @ version		 	4.0
13 13
  *
14 14
  */
15
-require_once( EE_HELPERS . 'EEH_Base.helper.php' );
16
-require_once( EE_INTERFACES . 'EEI_Interfaces.php' );
15
+require_once(EE_HELPERS.'EEH_Base.helper.php');
16
+require_once(EE_INTERFACES.'EEI_Interfaces.php');
17 17
 /**
18 18
  *
19 19
  * Class EEH_File
@@ -52,30 +52,30 @@  discard block
 block discarded – undo
52 52
 	 * @throws EE_Error if filesystem credentials are required
53 53
 	 * @return WP_Filesystem_Base
54 54
 	 */
55
-	private static function _get_wp_filesystem( $filepath = null) {
56
-		if( apply_filters(
55
+	private static function _get_wp_filesystem($filepath = null) {
56
+		if (apply_filters(
57 57
 				'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct',
58
-				$filepath && EEH_File::is_in_uploads_folder( $filepath ),
59
-				$filepath ) ) {
60
-			if( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct ) {
61
-				require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
58
+				$filepath && EEH_File::is_in_uploads_folder($filepath),
59
+				$filepath )) {
60
+			if ( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) {
61
+				require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php');
62 62
 				$method = 'direct';
63
-				$wp_filesystem_direct_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method );
63
+				$wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method);
64 64
 				//check constants defined, just like in wp-admin/includes/file.php's WP_Filesystem()
65
-				if ( ! defined('FS_CHMOD_DIR') ) {
66
-					define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) );
65
+				if ( ! defined('FS_CHMOD_DIR')) {
66
+					define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755));
67 67
 				}
68
-				if ( ! defined('FS_CHMOD_FILE') ) {
69
-					define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) );
68
+				if ( ! defined('FS_CHMOD_FILE')) {
69
+					define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644));
70 70
 				}
71
-				require_once( $wp_filesystem_direct_file );
72
-				EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct( array() );
71
+				require_once($wp_filesystem_direct_file);
72
+				EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array());
73 73
 			}
74 74
 			return EEH_File::$_wp_filesystem_direct;
75 75
 		}
76 76
 		global $wp_filesystem;
77 77
 		// no filesystem setup ???
78
-		if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) {
78
+		if ( ! $wp_filesystem instanceof WP_Filesystem_Base) {
79 79
 			// if some eager beaver's just trying to get in there too early...
80 80
 			// let them do it, because we are one of those eager beavers! :P
81 81
 			/**
@@ -88,34 +88,34 @@  discard block
 block discarded – undo
88 88
 			 * and there may be troubles if the WP files are owned by a different user
89 89
 			 * than the server user. But both of these issues should exist in 4.4 and earlier too
90 90
 			 */
91
-			if ( FALSE && ! did_action( 'wp_loaded' )) {
91
+			if (FALSE && ! did_action('wp_loaded')) {
92 92
 				$msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso');
93
-				if ( WP_DEBUG ) {
94
-					$msg .= '<br />' .  __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
93
+				if (WP_DEBUG) {
94
+					$msg .= '<br />'.__('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
95 95
 				}
96
-				throw new EE_Error( $msg );
96
+				throw new EE_Error($msg);
97 97
 			} else {
98 98
 				// should be loaded if we are past the wp_loaded hook...
99
-				if ( ! function_exists( 'WP_Filesystem' )) {
100
-					require_once( ABSPATH . 'wp-admin/includes/file.php' );
101
-					require_once( ABSPATH . 'wp-admin/includes/template.php' );
99
+				if ( ! function_exists('WP_Filesystem')) {
100
+					require_once(ABSPATH.'wp-admin/includes/file.php');
101
+					require_once(ABSPATH.'wp-admin/includes/template.php');
102 102
 				}
103 103
 				// turn on output buffering so that we can capture the credentials form
104 104
 				ob_start();
105
-				$credentials = request_filesystem_credentials( '' );
105
+				$credentials = request_filesystem_credentials('');
106 106
 				// store credentials form for the time being
107 107
 				EEH_File::$_credentials_form = ob_get_clean();
108 108
 				// basically check for direct or previously configured access
109
-				if ( ! WP_Filesystem( $credentials ) ) {
109
+				if ( ! WP_Filesystem($credentials)) {
110 110
 					// if credentials do NOT exist
111
-					if ( $credentials === FALSE ) {
112
-						add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 );
113
-						throw new EE_Error( __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
114
-					} elseif( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
115
-						add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 );
111
+					if ($credentials === FALSE) {
112
+						add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
113
+						throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
114
+					} elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
115
+						add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
116 116
 						throw new EE_Error(
117 117
 								sprintf(
118
-										__( 'WP Filesystem Error: $1%s', 'event_espresso' ),
118
+										__('WP Filesystem Error: $1%s', 'event_espresso'),
119 119
 										$wp_filesystem->errors->get_error_message() ) );
120 120
 					}
121 121
 				}
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 * display_request_filesystem_credentials_form
129 129
 	 */
130 130
 	public static function display_request_filesystem_credentials_form() {
131
-		if ( ! empty( EEH_File::$_credentials_form )) {
132
-			echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>';
131
+		if ( ! empty(EEH_File::$_credentials_form)) {
132
+			echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>';
133 133
 		}
134 134
 	}
135 135
 
@@ -147,29 +147,29 @@  discard block
 block discarded – undo
147 147
 	 * @throws EE_Error if filesystem credentials are required
148 148
 	 * @return bool
149 149
 	 */
150
-	public static function verify_filepath_and_permissions( $full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '' ) {
150
+	public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '') {
151 151
 		// load WP_Filesystem and set file permissions
152
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
153
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
154
-		if ( ! $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) )) {
155
-			$file_name = ! empty( $type_of_file ) ? $file_name . ' ' . $type_of_file : $file_name;
156
-			$file_name .= ! empty( $file_ext ) ? ' file' : ' folder';
152
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
153
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
154
+		if ( ! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
155
+			$file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name;
156
+			$file_name .= ! empty($file_ext) ? ' file' : ' folder';
157 157
 			$msg = sprintf(
158
-				__( 'The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso' ),
158
+				__('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'),
159 159
 				$file_name,
160 160
 				'<br />'
161 161
 			);
162
-			if ( EEH_File::exists( $full_file_path )) {
163
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, $type_of_file );
162
+			if (EEH_File::exists($full_file_path)) {
163
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file);
164 164
 			} else {
165 165
 				// no file permissions means the file was not found
166 166
 				$msg .= sprintf(
167
-					__( 'Please ensure the following path is correct: "%s".', 'event_espresso' ),
167
+					__('Please ensure the following path is correct: "%s".', 'event_espresso'),
168 168
 					$full_file_path
169 169
 				);
170 170
 			}
171
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
172
-				throw new EE_Error( $msg . '||' . $msg );
171
+			if (defined('WP_DEBUG') && WP_DEBUG) {
172
+				throw new EE_Error($msg.'||'.$msg);
173 173
 			}
174 174
 			return FALSE;
175 175
 		}
@@ -187,24 +187,24 @@  discard block
 block discarded – undo
187 187
 	 * @throws EE_Error if filesystem credentials are required
188 188
 	 * @return string
189 189
 	 */
190
-	private static function _permissions_error_for_unreadable_filepath( $full_file_path = '', $type_of_file = '' ){
190
+	private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '') {
191 191
 		// load WP_Filesystem and set file permissions
192
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
192
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
193 193
 		// check file permissions
194
-		$perms = $wp_filesystem->getchmod( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) );
195
-		if ( $perms ) {
194
+		$perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
195
+		if ($perms) {
196 196
 			// file permissions exist, but way be set incorrectly
197
-			$type_of_file = ! empty( $type_of_file ) ? $type_of_file . ' ' : '';
198
-			$type_of_file .= ! empty( $type_of_file ) ? 'file' : 'folder';
197
+			$type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : '';
198
+			$type_of_file .= ! empty($type_of_file) ? 'file' : 'folder';
199 199
 			return sprintf(
200
-				__( 'File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso' ),
200
+				__('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'),
201 201
 				$type_of_file,
202 202
 				$perms
203 203
 			);
204 204
 		} else {
205 205
 			// file exists but file permissions could not be read ?!?!
206 206
 			return sprintf(
207
-				__( 'Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso' ),
207
+				__('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'),
208 208
 				$full_file_path
209 209
 			);
210 210
 		}
@@ -222,35 +222,35 @@  discard block
 block discarded – undo
222 222
 	 * can't write to it
223 223
 	 * @return bool false if folder isn't writable; true if it exists and is writeable,
224 224
 	 */
225
-	public static function ensure_folder_exists_and_is_writable( $folder = '' ){
226
-		if ( empty( $folder )) {
225
+	public static function ensure_folder_exists_and_is_writable($folder = '') {
226
+		if (empty($folder)) {
227 227
 			return false;
228 228
 		}
229 229
 		// remove ending DS
230
-		$folder = EEH_File::standardise_directory_separators( rtrim( $folder, '/\\' ));
231
-		$parent_folder = EEH_File::get_parent_folder( $folder );
230
+		$folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\'));
231
+		$parent_folder = EEH_File::get_parent_folder($folder);
232 232
 		// add DS to folder
233
-		$folder = EEH_File::end_with_directory_separator( $folder );
234
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $folder );
235
-		if ( ! $wp_filesystem->is_dir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) {
233
+		$folder = EEH_File::end_with_directory_separator($folder);
234
+		$wp_filesystem = EEH_File::_get_wp_filesystem($folder);
235
+		if ( ! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
236 236
 			//ok so it doesn't exist. Does its parent? Can we write to it?
237
-			if(	! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) {
237
+			if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
238 238
 				return false;
239 239
 			}
240
-			if ( ! EEH_File::verify_is_writable( $parent_folder, 'folder' )) {
240
+			if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) {
241 241
 				return false;
242 242
 			} else {
243
-				if ( ! $wp_filesystem->mkdir( EEH_File::convert_local_filepath_to_remote_filepath(  $folder ) ) ) {
244
-					if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
245
-						$msg = sprintf( __( '"%s" could not be created.', 'event_espresso' ), $folder );
246
-						$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $folder );
247
-						throw new EE_Error( $msg );
243
+				if ( ! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
244
+					if (defined('WP_DEBUG') && WP_DEBUG) {
245
+						$msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder);
246
+						$msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder);
247
+						throw new EE_Error($msg);
248 248
 					}
249 249
 					return false;
250 250
 				}
251
-				EEH_File::add_index_file( $folder );
251
+				EEH_File::add_index_file($folder);
252 252
 			}
253
-		} elseif ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
253
+		} elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) {
254 254
 			return false;
255 255
 		}
256 256
 		return true;
@@ -265,15 +265,15 @@  discard block
 block discarded – undo
265 265
 	 * @throws EE_Error if filesystem credentials are required
266 266
 	 * @return bool
267 267
 	 */
268
-	public static function verify_is_writable( $full_path = '', $file_or_folder = 'folder' ){
268
+	public static function verify_is_writable($full_path = '', $file_or_folder = 'folder') {
269 269
 		// load WP_Filesystem and set file permissions
270
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_path );
271
-		$full_path = EEH_File::standardise_directory_separators( $full_path );
272
-		if ( ! $wp_filesystem->is_writable( EEH_File::convert_local_filepath_to_remote_filepath( $full_path ) ) ) {
273
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
274
-				$msg = sprintf( __( 'The "%1$s" %2$s is not writable.', 'event_espresso' ), $full_path, $file_or_folder );
275
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_path );
276
-				throw new EE_Error( $msg );
270
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_path);
271
+		$full_path = EEH_File::standardise_directory_separators($full_path);
272
+		if ( ! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) {
273
+			if (defined('WP_DEBUG') && WP_DEBUG) {
274
+				$msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder);
275
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path);
276
+				throw new EE_Error($msg);
277 277
 			}
278 278
 			return FALSE;
279 279
 		}
@@ -290,25 +290,25 @@  discard block
 block discarded – undo
290 290
 	 * @throws EE_Error if filesystem credentials are required
291 291
 	 * @return bool
292 292
 	 */
293
-	public static function ensure_file_exists_and_is_writable( $full_file_path = '' ) {
293
+	public static function ensure_file_exists_and_is_writable($full_file_path = '') {
294 294
 		// load WP_Filesystem and set file permissions
295
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
296
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
297
-		$parent_folder = EEH_File::get_parent_folder( $full_file_path );
298
-		if ( ! EEH_File::exists( $full_file_path )) {
299
-			if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) {
295
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
296
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
297
+		$parent_folder = EEH_File::get_parent_folder($full_file_path);
298
+		if ( ! EEH_File::exists($full_file_path)) {
299
+			if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
300 300
 				return false;
301 301
 			}
302
-			if ( ! $wp_filesystem->touch( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) {
303
-				if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
304
-					$msg = sprintf( __( 'The "%s" file could not be created.', 'event_espresso' ), $full_file_path );
305
-					$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path );
306
-					throw new EE_Error( $msg );
302
+			if ( ! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
303
+				if (defined('WP_DEBUG') && WP_DEBUG) {
304
+					$msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path);
305
+					$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
306
+					throw new EE_Error($msg);
307 307
 				}
308 308
 				return false;
309 309
 			}
310 310
 		}
311
-		if ( ! EEH_File::verify_is_writable( $full_file_path, 'file' )) {
311
+		if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) {
312 312
 			return false;
313 313
 		}
314 314
 		return true;
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 * @param string $file_or_folder_path
321 321
 	 * @return string parent folder, ENDING with a directory separator
322 322
 	 */
323
-	public static function get_parent_folder( $file_or_folder_path ) {
323
+	public static function get_parent_folder($file_or_folder_path) {
324 324
 		//find the last DS, ignoring a DS on the very end
325 325
 		//eg if given "/var/something/somewhere/", we want to get "somewhere"'s
326 326
 		//parent folder, "/var/something/"
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
 	 * @throws EE_Error if filesystem credentials are required
343 343
 	 * @return string
344 344
 	 */
345
-	public static function get_file_contents( $full_file_path = '' ){
346
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
347
-		if ( EEH_File::verify_filepath_and_permissions( $full_file_path, EEH_File::get_filename_from_filepath( $full_file_path ) , EEH_File::get_file_extension( $full_file_path ))) {
345
+	public static function get_file_contents($full_file_path = '') {
346
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
347
+		if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) {
348 348
 			// load WP_Filesystem and set file permissions
349
-			$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
350
-			return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) );
349
+			$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
350
+			return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
351 351
 		}
352 352
 		return '';
353 353
 	}
@@ -362,26 +362,26 @@  discard block
 block discarded – undo
362 362
 	 * @throws EE_Error if filesystem credentials are required
363 363
 	 * @return bool
364 364
 	 */
365
-	public static function write_to_file( $full_file_path = '', $file_contents = '', $file_type = '' ){
366
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
367
-		$file_type = ! empty( $file_type ) ? rtrim( $file_type, ' ' ) . ' ' : '';
368
-		$folder = EEH_File::remove_filename_from_filepath( $full_file_path );
369
-		if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
370
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
371
-				$msg = sprintf( __( 'The %1$sfile located at "%2$s" is not writable.', 'event_espresso' ), $file_type, $full_file_path );
372
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path );
373
-				throw new EE_Error( $msg );
365
+	public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '') {
366
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
367
+		$file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : '';
368
+		$folder = EEH_File::remove_filename_from_filepath($full_file_path);
369
+		if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
370
+			if (defined('WP_DEBUG') && WP_DEBUG) {
371
+				$msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path);
372
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
373
+				throw new EE_Error($msg);
374 374
 			}
375 375
 			return FALSE;
376 376
 		}
377 377
 		// load WP_Filesystem and set file permissions
378
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
378
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
379 379
 		// write the file
380
-		if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ), $file_contents )) {
381
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
382
-				$msg = sprintf( __( 'The %1$sfile located at "%2$s" could not be written to.', 'event_espresso' ), $file_type, $full_file_path );
383
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, 'f' );
384
-				throw new EE_Error( $msg );
380
+		if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) {
381
+			if (defined('WP_DEBUG') && WP_DEBUG) {
382
+				$msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path);
383
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f');
384
+				throw new EE_Error($msg);
385 385
 			}
386 386
 			return FALSE;
387 387
 		}
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
 	 * @throws EE_Error if filesystem credentials are required
398 398
 	 * @return boolean
399 399
 	 */
400
-	public static function delete( $filepath, $recursive = false, $type = false ) {
400
+	public static function delete($filepath, $recursive = false, $type = false) {
401 401
 		$wp_filesystem = EEH_File::_get_wp_filesystem();
402
-		return $wp_filesystem->delete( $filepath, $recursive, $type ) ? TRUE : FALSE;
402
+		return $wp_filesystem->delete($filepath, $recursive, $type) ? TRUE : FALSE;
403 403
 	}
404 404
 
405 405
 
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
 	 * @throws EE_Error if filesystem credentials are required
412 412
 	 * @return bool
413 413
 	 */
414
-	public static function exists( $full_file_path = '' ) {
415
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
416
-		return $wp_filesystem->exists( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ? TRUE : FALSE;
414
+	public static function exists($full_file_path = '') {
415
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
416
+		return $wp_filesystem->exists(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)) ? TRUE : FALSE;
417 417
 	}
418 418
 
419 419
 
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
 	 * @throws EE_Error if filesystem credentials are required
427 427
 	 * @return bool
428 428
 	 */
429
-	public static function is_readable( $full_file_path = '' ) {
430
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
431
-		if( $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath(  $full_file_path ) ) ) {
429
+	public static function is_readable($full_file_path = '') {
430
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
431
+		if ($wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
432 432
 			return true;
433 433
 		} else {
434 434
 			return false;
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
 	 * @param string $full_file_path
445 445
 	 * @return string
446 446
 	 */
447
-	public static function remove_filename_from_filepath( $full_file_path = '' ) {
448
-		return pathinfo( $full_file_path, PATHINFO_DIRNAME );
447
+	public static function remove_filename_from_filepath($full_file_path = '') {
448
+		return pathinfo($full_file_path, PATHINFO_DIRNAME);
449 449
 	}
450 450
 
451 451
 
@@ -455,8 +455,8 @@  discard block
 block discarded – undo
455 455
 	 * @param string $full_file_path
456 456
 	 * @return string
457 457
 	 */
458
-	public static function get_filename_from_filepath( $full_file_path = '' ) {
459
-		return pathinfo( $full_file_path, PATHINFO_BASENAME );
458
+	public static function get_filename_from_filepath($full_file_path = '') {
459
+		return pathinfo($full_file_path, PATHINFO_BASENAME);
460 460
 	}
461 461
 
462 462
 
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
 	 * @param string $full_file_path
467 467
 	 * @return string
468 468
 	 */
469
-	public static function get_file_extension( $full_file_path = '' ) {
470
-		return pathinfo( $full_file_path, PATHINFO_EXTENSION );
469
+	public static function get_file_extension($full_file_path = '') {
470
+		return pathinfo($full_file_path, PATHINFO_EXTENSION);
471 471
 	}
472 472
 
473 473
 
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
 	 * @throws EE_Error if filesystem credentials are required
479 479
 	 * @return bool
480 480
 	 */
481
-	public static function add_htaccess_deny_from_all( $folder = '' ) {
482
-		$folder = EEH_File::standardise_and_end_with_directory_separator( $folder );
483
-		if ( ! EEH_File::exists( $folder . '.htaccess' ) ) {
484
-			if ( ! EEH_File::write_to_file( $folder . '.htaccess', 'deny from all', '.htaccess' )) {
481
+	public static function add_htaccess_deny_from_all($folder = '') {
482
+		$folder = EEH_File::standardise_and_end_with_directory_separator($folder);
483
+		if ( ! EEH_File::exists($folder.'.htaccess')) {
484
+			if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) {
485 485
 				return FALSE;
486 486
 			}
487 487
 		}
@@ -495,10 +495,10 @@  discard block
 block discarded – undo
495 495
 	 * @throws EE_Error if filesystem credentials are required
496 496
 	 * @return boolean
497 497
 	 */
498
-	public static function add_index_file( $folder ) {
499
-		$folder = EEH_File::standardise_and_end_with_directory_separator( $folder );
500
-		if ( ! EEH_File::exists( $folder . 'index.php' ) ) {
501
-			if ( ! EEH_File::write_to_file( $folder . 'index.php', 'You are not permitted to read from this folder', '.php' )) {
498
+	public static function add_index_file($folder) {
499
+		$folder = EEH_File::standardise_and_end_with_directory_separator($folder);
500
+		if ( ! EEH_File::exists($folder.'index.php')) {
501
+			if ( ! EEH_File::write_to_file($folder.'index.php', 'You are not permitted to read from this folder', '.php')) {
502 502
 				return false;
503 503
 			}
504 504
 		}
@@ -513,11 +513,11 @@  discard block
 block discarded – undo
513 513
 	 * @param string $file_path
514 514
 	 * @return string
515 515
 	 */
516
-	public static function get_classname_from_filepath_with_standard_filename( $file_path ){
516
+	public static function get_classname_from_filepath_with_standard_filename($file_path) {
517 517
 		//extract file from path
518
-		$filename = basename( $file_path );
518
+		$filename = basename($file_path);
519 519
 		//now remove the first period and everything after
520
-		$pos_of_first_period = strpos( $filename,'.' );
520
+		$pos_of_first_period = strpos($filename, '.');
521 521
 		return substr($filename, 0, $pos_of_first_period);
522 522
 	}
523 523
 
@@ -529,8 +529,8 @@  discard block
 block discarded – undo
529 529
 	 * @param string $file_path
530 530
 	 * @return string
531 531
 	 */
532
-	public static function standardise_directory_separators( $file_path ){
533
-		return str_replace( array( '\\', '/' ), DS, $file_path );
532
+	public static function standardise_directory_separators($file_path) {
533
+		return str_replace(array('\\', '/'), DS, $file_path);
534 534
 	}
535 535
 
536 536
 
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
 	 * @param string $file_path
542 542
 	 * @return string
543 543
 	 */
544
-	public static function end_with_directory_separator( $file_path ){
545
-		return rtrim( $file_path, '/\\' ) . DS;
544
+	public static function end_with_directory_separator($file_path) {
545
+		return rtrim($file_path, '/\\').DS;
546 546
 	}
547 547
 
548 548
 
@@ -552,8 +552,8 @@  discard block
 block discarded – undo
552 552
 	 * @param $file_path
553 553
 	 * @return string
554 554
 	 */
555
-	public static function standardise_and_end_with_directory_separator( $file_path ){
556
-		return self::end_with_directory_separator( self::standardise_directory_separators( $file_path ));
555
+	public static function standardise_and_end_with_directory_separator($file_path) {
556
+		return self::end_with_directory_separator(self::standardise_directory_separators($file_path));
557 557
 	}
558 558
 
559 559
 
@@ -570,21 +570,21 @@  discard block
 block discarded – undo
570 570
 	 *		if $index_numerically == FALSE (Default) keys are what the class names SHOULD be;
571 571
 	 *		 and values are their filepaths
572 572
 	 */
573
-	public static function get_contents_of_folders( $folder_paths = array(), $index_numerically = FALSE ){
573
+	public static function get_contents_of_folders($folder_paths = array(), $index_numerically = FALSE) {
574 574
 		$class_to_folder_path = array();
575
-		foreach( $folder_paths as $folder_path ){
576
-			$folder_path = self::standardise_and_end_with_directory_separator( $folder_path );
575
+		foreach ($folder_paths as $folder_path) {
576
+			$folder_path = self::standardise_and_end_with_directory_separator($folder_path);
577 577
 			// load WP_Filesystem and set file permissions
578
-			$files_in_folder = glob( $folder_path . '*' );
578
+			$files_in_folder = glob($folder_path.'*');
579 579
 			$class_to_folder_path = array();
580
-			if ( $files_in_folder ) {
581
-				foreach( $files_in_folder as $file_path ){
580
+			if ($files_in_folder) {
581
+				foreach ($files_in_folder as $file_path) {
582 582
 					//only add files, not folders
583
-					if ( ! is_dir( $file_path )) {
584
-						if ( $index_numerically ) {
583
+					if ( ! is_dir($file_path)) {
584
+						if ($index_numerically) {
585 585
 							$class_to_folder_path[] = $file_path;
586 586
 						} else {
587
-							$classname = self::get_classname_from_filepath_with_standard_filename( $file_path );
587
+							$classname = self::get_classname_from_filepath_with_standard_filename($file_path);
588 588
 							$class_to_folder_path[$classname] = $file_path;
589 589
 						}
590 590
 					}
@@ -604,39 +604,39 @@  discard block
 block discarded – undo
604 604
 	 * @throws EE_Error if filesystem credentials are required
605 605
 	 * @return boolean success
606 606
 	 */
607
-	public static function copy( $source_file, $destination_file, $overwrite = FALSE ){
608
-		$full_source_path = EEH_File::standardise_directory_separators( $source_file );
609
-		if( ! EEH_File::exists( $full_source_path ) ){
610
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
611
-				$msg = sprintf( __( 'The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso' ), $full_source_path );
612
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path );
613
-				throw new EE_Error( $msg );
607
+	public static function copy($source_file, $destination_file, $overwrite = FALSE) {
608
+		$full_source_path = EEH_File::standardise_directory_separators($source_file);
609
+		if ( ! EEH_File::exists($full_source_path)) {
610
+			if (defined('WP_DEBUG') && WP_DEBUG) {
611
+				$msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path);
612
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path);
613
+				throw new EE_Error($msg);
614 614
 			}
615 615
 			return FALSE;
616 616
 		}
617 617
 
618
-		$full_dest_path = EEH_File::standardise_directory_separators( $destination_file );
619
-		$folder = EEH_File::remove_filename_from_filepath( $full_dest_path );
620
-		if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
621
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
622
-				$msg = sprintf( __( 'The file located at "%2$s" is not writable.', 'event_espresso' ), $full_dest_path );
623
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_dest_path );
624
-				throw new EE_Error( $msg );
618
+		$full_dest_path = EEH_File::standardise_directory_separators($destination_file);
619
+		$folder = EEH_File::remove_filename_from_filepath($full_dest_path);
620
+		if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
621
+			if (defined('WP_DEBUG') && WP_DEBUG) {
622
+				$msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path);
623
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path);
624
+				throw new EE_Error($msg);
625 625
 			}
626 626
 			return FALSE;
627 627
 		}
628 628
 
629 629
 		// load WP_Filesystem and set file permissions
630
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $destination_file );
630
+		$wp_filesystem = EEH_File::_get_wp_filesystem($destination_file);
631 631
 		// write the file
632 632
 		if ( ! $wp_filesystem->copy(
633
-						EEH_File::convert_local_filepath_to_remote_filepath( $full_source_path ),
634
-						EEH_File::convert_local_filepath_to_remote_filepath( $full_dest_path ),
633
+						EEH_File::convert_local_filepath_to_remote_filepath($full_source_path),
634
+						EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path),
635 635
 						$overwrite )) {
636
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
637
-				$msg = sprintf( __( 'Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso' ), $full_source_path );
638
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path, 'f' );
639
-				throw new EE_Error( $msg );
636
+			if (defined('WP_DEBUG') && WP_DEBUG) {
637
+				$msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path);
638
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f');
639
+				throw new EE_Error($msg);
640 640
 			}
641 641
 			return FALSE;
642 642
 		}
@@ -648,9 +648,9 @@  discard block
 block discarded – undo
648 648
 	 * @param string $filepath
649 649
 	 * @return boolean
650 650
 	 */
651
-	public static function is_in_uploads_folder( $filepath ) {
651
+	public static function is_in_uploads_folder($filepath) {
652 652
 		$uploads = wp_upload_dir();
653
-		return strpos( $filepath, $uploads[ 'basedir' ] ) === 0 ? true : false;
653
+		return strpos($filepath, $uploads['basedir']) === 0 ? true : false;
654 654
 	}
655 655
 
656 656
 	/**
@@ -665,9 +665,9 @@  discard block
 block discarded – undo
665 665
 	 * @return string the remote filepath (eg the filepath the filesystem method, eg
666 666
 	 * ftp or ssh, will use to access the folder
667 667
 	 */
668
-	public static function convert_local_filepath_to_remote_filepath( $local_filepath ) {
669
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $local_filepath );
670
-		return str_replace( WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath );
668
+	public static function convert_local_filepath_to_remote_filepath($local_filepath) {
669
+		$wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath);
670
+		return str_replace(WP_CONTENT_DIR.DS, $wp_filesystem->wp_content_dir(), $local_filepath);
671 671
 	}
672 672
 }
673 673
 // End of file EEH_File.helper.php
Please login to merge, or discard this patch.
core/services/assets/Registry.php 2 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -16,164 +16,164 @@
 block discarded – undo
16 16
 class Registry
17 17
 {
18 18
 
19
-    /**
20
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
21
-     * @var array
22
-     */
23
-    protected $jsdata = array();
24
-
25
-
26
-    /**
27
-     * Registry constructor.
28
-     * Hooking into WP actions for script registry.
29
-     */
30
-    public function __construct()
31
-    {
32
-        add_action('wp_enqueue_scripts', array($this, 'scripts'), 100);
33
-        add_action('admin_enqueue_scripts', array($this, 'scripts'), 100);
34
-    }
35
-
36
-
37
-    /**
38
-     * Callback for the WP script actions.
39
-     * Used to register globally accessible core scripts.
40
-     * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
41
-     */
42
-    public function scripts()
43
-    {
44
-        wp_register_script(
45
-            'eejs-core',
46
-            EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
47
-            array(),
48
-            espresso_version(),
49
-            true
50
-        );
51
-        wp_localize_script('eejs-core', 'eejs', array('data'=>$this->jsdata));
52
-    }
53
-
54
-
55
-    /**
56
-     * Used to add data to eejs.data object.
57
-     *
58
-     * Note:  Overriding existing data is not allowed.
59
-     *
60
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
61
-     * If the data you add is something like this:
62
-     *
63
-     * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
64
-     *
65
-     * It will be exposed in the page source as:
66
-     *
67
-     * eejs.data.my_plugin_data.foo == gar
68
-     *
69
-     * @param string $key          Key used to access your data
70
-     * @param string|array $value  Value to attach to key
71
-     * @throws \InvalidArgumentException
72
-     */
73
-    public function addData($key, $value)
74
-    {
75
-        if ($this->verifyDataNotExisting($key)) {
76
-            $this->jsdata[$key] = $value;
77
-        }
78
-    }
79
-
80
-
81
-    /**
82
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
83
-     * elements in an array.
84
-     *
85
-     * When you use this method, the value you include will be appended to the end of an array on $key.
86
-     *
87
-     * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript object
88
-     * like this,
89
-     *
90
-     * eejs.data.test = [
91
-     *     my_data,
92
-     * ]
93
-     *
94
-     * If there has already been a scalar value attached to the data object given key, then
95
-     * this will throw an exception.
96
-     *
97
-     * @param string $key          Key to attach data to.
98
-     * @param string|array $value  Value being registered.
99
-     * @throws InvalidArgumentException
100
-     */
101
-    public function pushData($key, $value)
102
-    {
103
-        if (isset($this->jsdata[$key])
104
-            && ! is_array($this->jsdata[$key])
105
-        ) {
106
-            throw new invalidArgumentException(
107
-                sprintf(
108
-                    __(
109
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
19
+	/**
20
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
21
+	 * @var array
22
+	 */
23
+	protected $jsdata = array();
24
+
25
+
26
+	/**
27
+	 * Registry constructor.
28
+	 * Hooking into WP actions for script registry.
29
+	 */
30
+	public function __construct()
31
+	{
32
+		add_action('wp_enqueue_scripts', array($this, 'scripts'), 100);
33
+		add_action('admin_enqueue_scripts', array($this, 'scripts'), 100);
34
+	}
35
+
36
+
37
+	/**
38
+	 * Callback for the WP script actions.
39
+	 * Used to register globally accessible core scripts.
40
+	 * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
41
+	 */
42
+	public function scripts()
43
+	{
44
+		wp_register_script(
45
+			'eejs-core',
46
+			EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
47
+			array(),
48
+			espresso_version(),
49
+			true
50
+		);
51
+		wp_localize_script('eejs-core', 'eejs', array('data'=>$this->jsdata));
52
+	}
53
+
54
+
55
+	/**
56
+	 * Used to add data to eejs.data object.
57
+	 *
58
+	 * Note:  Overriding existing data is not allowed.
59
+	 *
60
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
61
+	 * If the data you add is something like this:
62
+	 *
63
+	 * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
64
+	 *
65
+	 * It will be exposed in the page source as:
66
+	 *
67
+	 * eejs.data.my_plugin_data.foo == gar
68
+	 *
69
+	 * @param string $key          Key used to access your data
70
+	 * @param string|array $value  Value to attach to key
71
+	 * @throws \InvalidArgumentException
72
+	 */
73
+	public function addData($key, $value)
74
+	{
75
+		if ($this->verifyDataNotExisting($key)) {
76
+			$this->jsdata[$key] = $value;
77
+		}
78
+	}
79
+
80
+
81
+	/**
82
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
83
+	 * elements in an array.
84
+	 *
85
+	 * When you use this method, the value you include will be appended to the end of an array on $key.
86
+	 *
87
+	 * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript object
88
+	 * like this,
89
+	 *
90
+	 * eejs.data.test = [
91
+	 *     my_data,
92
+	 * ]
93
+	 *
94
+	 * If there has already been a scalar value attached to the data object given key, then
95
+	 * this will throw an exception.
96
+	 *
97
+	 * @param string $key          Key to attach data to.
98
+	 * @param string|array $value  Value being registered.
99
+	 * @throws InvalidArgumentException
100
+	 */
101
+	public function pushData($key, $value)
102
+	{
103
+		if (isset($this->jsdata[$key])
104
+			&& ! is_array($this->jsdata[$key])
105
+		) {
106
+			throw new invalidArgumentException(
107
+				sprintf(
108
+					__(
109
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
110 110
                          push values to this data element when it is an array.',
111
-                        'event_espresso'
112
-                    ),
113
-                    $key,
114
-                    __METHOD__
115
-                )
116
-            );
117
-        }
118
-
119
-        $this->jsdata[$key][] = $value;
120
-    }
121
-
122
-
123
-    /**
124
-     * Retrieve registered data.
125
-     *
126
-     * @param string $key           Name of key to attach data to.
127
-     * @return mixed                If there is no for the given key, then false is returned.
128
-     */
129
-    public function getData($key)
130
-    {
131
-        return isset($this->jsdata[$key])
132
-            ? $this->jsdata[$key]
133
-            : false;
134
-    }
135
-
136
-
137
-
138
-
139
-    /**
140
-     * Verifies whether the given data exists already on the jsdata array.
141
-     *
142
-     * Overriding data is not allowed.
143
-     *
144
-     * @param string       $key          Index for data.
145
-     * @return bool        If valid then return true.
146
-     * @throws InvalidArgumentException if data already exists.
147
-     */
148
-    protected function verifyDataNotExisting($key)
149
-    {
150
-        if (isset($this->jsdata[$key])) {
151
-            if (is_array($this->jsdata[$key])) {
152
-                throw new InvalidArgumentException(
153
-                    sprintf(
154
-                        __(
155
-                            'The value for %1$s already exists in the Registry::eejs object.
111
+						'event_espresso'
112
+					),
113
+					$key,
114
+					__METHOD__
115
+				)
116
+			);
117
+		}
118
+
119
+		$this->jsdata[$key][] = $value;
120
+	}
121
+
122
+
123
+	/**
124
+	 * Retrieve registered data.
125
+	 *
126
+	 * @param string $key           Name of key to attach data to.
127
+	 * @return mixed                If there is no for the given key, then false is returned.
128
+	 */
129
+	public function getData($key)
130
+	{
131
+		return isset($this->jsdata[$key])
132
+			? $this->jsdata[$key]
133
+			: false;
134
+	}
135
+
136
+
137
+
138
+
139
+	/**
140
+	 * Verifies whether the given data exists already on the jsdata array.
141
+	 *
142
+	 * Overriding data is not allowed.
143
+	 *
144
+	 * @param string       $key          Index for data.
145
+	 * @return bool        If valid then return true.
146
+	 * @throws InvalidArgumentException if data already exists.
147
+	 */
148
+	protected function verifyDataNotExisting($key)
149
+	{
150
+		if (isset($this->jsdata[$key])) {
151
+			if (is_array($this->jsdata[$key])) {
152
+				throw new InvalidArgumentException(
153
+					sprintf(
154
+						__(
155
+							'The value for %1$s already exists in the Registry::eejs object.
156 156
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
157 157
                             %2$s method to push your value to the array.',
158
-                            'event_espresso'
159
-                        ),
160
-                        $key,
161
-                        'pushData()'
162
-                    )
163
-                );
164
-            } else {
165
-                throw new InvalidArgumentException(
166
-                    sprintf(
167
-                        __(
168
-                            'The value for %1$s already exists in the Registry::eejs object. Overrides are not
158
+							'event_espresso'
159
+						),
160
+						$key,
161
+						'pushData()'
162
+					)
163
+				);
164
+			} else {
165
+				throw new InvalidArgumentException(
166
+					sprintf(
167
+						__(
168
+							'The value for %1$s already exists in the Registry::eejs object. Overrides are not
169 169
                             allowed.  Consider attaching your value to a different key',
170
-                            'event_espresso'
171
-                        ),
172
-                        $key
173
-                    )
174
-                );
175
-            }
176
-        }
177
-        return true;
178
-    }
170
+							'event_espresso'
171
+						),
172
+						$key
173
+					)
174
+				);
175
+			}
176
+		}
177
+		return true;
178
+	}
179 179
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
     {
44 44
         wp_register_script(
45 45
             'eejs-core',
46
-            EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
46
+            EE_PLUGIN_DIR_URL.'core/services/assets/core_assets/eejs-core.js',
47 47
             array(),
48 48
             espresso_version(),
49 49
             true
Please login to merge, or discard this patch.
core/helpers/EEH_DTT_Helper.helper.php 2 patches
Indentation   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 		}
118 118
 		// better have a valid timezone string by now, but if not, sigh... loop thru  the timezone_abbreviations_list()...
119 119
 		$timezone_string = $timezone_string !== false
120
-            ? $timezone_string
121
-            : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list( $gmt_offset );
120
+			? $timezone_string
121
+			: EEH_DTT_Helper::get_timezone_string_from_abbreviations_list( $gmt_offset );
122 122
 		return $timezone_string;
123 123
 	}
124 124
 
@@ -819,7 +819,6 @@  discard block
 block discarded – undo
819 819
 
820 820
 
821 821
 	/**
822
-
823 822
 	 *
824 823
 	 * 	 If the the first date starts at midnight on one day, and the next date ends at midnight on the
825 824
 	 * 	 very next day then this method will return true.
Please login to merge, or discard this patch.
Spacing   +142 added lines, -143 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 	 * @return string
54 54
 	 * @throws \EE_Error
55 55
 	 */
56
-	public static function get_valid_timezone_string( $timezone_string = '' ) {
56
+	public static function get_valid_timezone_string($timezone_string = '') {
57 57
 		// if passed a value, then use that, else get WP option
58
-		$timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' );
58
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
59 59
 		// value from above exists, use that, else get timezone string from gmt_offset
60
-		$timezone_string = ! empty( $timezone_string ) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset();
61
-		EEH_DTT_Helper::validate_timezone( $timezone_string );
60
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset();
61
+		EEH_DTT_Helper::validate_timezone($timezone_string);
62 62
 		return $timezone_string;
63 63
 	}
64 64
 
@@ -74,18 +74,18 @@  discard block
 block discarded – undo
74 74
 	 * @return bool
75 75
 	 * @throws \EE_Error
76 76
 	 */
77
-	public static function validate_timezone( $timezone_string, $throw_error = true ) {
77
+	public static function validate_timezone($timezone_string, $throw_error = true) {
78 78
 		// easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it
79 79
 		try {
80
-			new DateTimeZone( $timezone_string );
81
-		} catch ( Exception $e ) {
80
+			new DateTimeZone($timezone_string);
81
+		} catch (Exception $e) {
82 82
 			// sometimes we take exception to exceptions
83
-			if ( ! $throw_error ) {
83
+			if ( ! $throw_error) {
84 84
 				return false;
85 85
 			}
86 86
 			throw new EE_Error(
87 87
 				sprintf(
88
-					__( 'The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ),
88
+					__('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'),
89 89
 					$timezone_string,
90 90
 					'<a href="http://www.php.net/manual/en/timezones.php">',
91 91
 					'</a>'
@@ -104,21 +104,21 @@  discard block
 block discarded – undo
104 104
 	 * @param string $gmt_offset
105 105
 	 * @return string
106 106
 	 */
107
-	public static function get_timezone_string_from_gmt_offset( $gmt_offset = '' ) {
107
+	public static function get_timezone_string_from_gmt_offset($gmt_offset = '') {
108 108
 		$timezone_string = 'UTC';
109
-		$gmt_offset = ! empty( $gmt_offset ) ? $gmt_offset : get_option( 'gmt_offset' );
110
-		if ( $gmt_offset !== '' ) {
109
+		$gmt_offset = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset');
110
+		if ($gmt_offset !== '') {
111 111
 			// convert GMT offset to seconds
112 112
 			$gmt_offset = $gmt_offset * HOUR_IN_SECONDS;
113 113
 			// account for WP offsets that aren't valid UTC
114
-			$gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets( $gmt_offset );
114
+			$gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset);
115 115
 			// although we don't know the TZ abbreviation, we know the UTC offset
116
-			$timezone_string = timezone_name_from_abbr( null, $gmt_offset );
116
+			$timezone_string = timezone_name_from_abbr(null, $gmt_offset);
117 117
 		}
118 118
 		// better have a valid timezone string by now, but if not, sigh... loop thru  the timezone_abbreviations_list()...
119 119
 		$timezone_string = $timezone_string !== false
120 120
             ? $timezone_string
121
-            : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list( $gmt_offset );
121
+            : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset);
122 122
 		return $timezone_string;
123 123
 	}
124 124
 
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
 	 * @return int seconds offset
130 130
 	 */
131 131
 	public static function get_site_timezone_gmt_offset() {
132
-		$timezone_string = get_option( 'timezone_string' );
133
-		if ( $timezone_string ) {
132
+		$timezone_string = get_option('timezone_string');
133
+		if ($timezone_string) {
134 134
 			try {
135
-				$timezone = new DateTimeZone( $timezone_string );
136
-				return $timezone->getOffset( new DateTime() ); //in WordPress DateTime defaults to UTC
137
-			} catch( Exception $e ){}
135
+				$timezone = new DateTimeZone($timezone_string);
136
+				return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC
137
+			} catch (Exception $e) {}
138 138
 		}
139
-		$offset = get_option( 'gmt_offset' );
140
-		return (int) ( $offset * HOUR_IN_SECONDS );
139
+		$offset = get_option('gmt_offset');
140
+		return (int) ($offset * HOUR_IN_SECONDS);
141 141
 	}
142 142
 
143 143
 
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
 	 * @param int $gmt_offset
150 150
 	 * @return int
151 151
 	 */
152
-	public static function adjust_invalid_gmt_offsets( $gmt_offset = 0 ) {
152
+	public static function adjust_invalid_gmt_offsets($gmt_offset = 0) {
153 153
 		//make sure $gmt_offset is int
154 154
 		$gmt_offset = (int) $gmt_offset;
155
-		switch ( $gmt_offset ) {
155
+		switch ($gmt_offset) {
156 156
 
157 157
 			//			case -30600 :
158 158
 			//				$gmt_offset = -28800;
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
 	 * @return string
205 205
 	 * @throws \EE_Error
206 206
 	 */
207
-	public static function get_timezone_string_from_abbreviations_list( $gmt_offset = 0 ) {
207
+	public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0) {
208 208
 		$abbreviations = timezone_abbreviations_list();
209
-		foreach ( $abbreviations as $abbreviation ) {
210
-			foreach ( $abbreviation as $city ) {
211
-				if ( $city['offset'] === $gmt_offset && $city['dst'] === FALSE ) {
209
+		foreach ($abbreviations as $abbreviation) {
210
+			foreach ($abbreviation as $city) {
211
+				if ($city['offset'] === $gmt_offset && $city['dst'] === FALSE) {
212 212
 					// check if the timezone is valid but don't throw any errors if it isn't
213
-					if ( EEH_DTT_Helper::validate_timezone( $city['timezone_id'], false ) ) {
213
+					if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) {
214 214
 						return $city['timezone_id'];
215 215
 					}
216 216
 				}
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		}
219 219
 		throw new EE_Error(
220 220
 			sprintf(
221
-				__( 'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ),
221
+				__('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'),
222 222
 				$gmt_offset,
223 223
 				'<a href="http://www.php.net/manual/en/timezones.php">',
224 224
 				'</a>'
@@ -232,23 +232,23 @@  discard block
 block discarded – undo
232 232
 	 * @access public
233 233
 	 * @param string $timezone_string
234 234
 	 */
235
-	public static function timezone_select_input( $timezone_string = '' ) {
235
+	public static function timezone_select_input($timezone_string = '') {
236 236
 		// get WP date time format
237
-		$datetime_format = get_option('date_format') . ' '  . get_option('time_format');
237
+		$datetime_format = get_option('date_format').' '.get_option('time_format');
238 238
 		// if passed a value, then use that, else get WP option
239
-		$timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' );
239
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
240 240
 		// check if the timezone is valid but don't throw any errors if it isn't
241
-		$timezone_string = EEH_DTT_Helper::validate_timezone( $timezone_string, false );
241
+		$timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false);
242 242
 		$gmt_offset = get_option('gmt_offset');
243 243
 
244 244
 		$check_zone_info = true;
245
-		if ( empty( $timezone_string )) {
245
+		if (empty($timezone_string)) {
246 246
 			// Create a UTC+- zone if no timezone string exists
247 247
 			$check_zone_info = false;
248
-			if ( $gmt_offset > 0 ) {
249
-				$timezone_string = 'UTC+' . $gmt_offset;
250
-			} elseif ( $gmt_offset < 0 ) {
251
-				$timezone_string = 'UTC' . $gmt_offset;
248
+			if ($gmt_offset > 0) {
249
+				$timezone_string = 'UTC+'.$gmt_offset;
250
+			} elseif ($gmt_offset < 0) {
251
+				$timezone_string = 'UTC'.$gmt_offset;
252 252
 			} else {
253 253
 				$timezone_string = 'UTC';
254 254
 			}
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 					__('%1$sUTC%2$s time is %3$s'),
271 271
 					'<abbr title="Coordinated Universal Time">',
272 272
 					'</abbr>',
273
-					'<code>' . date_i18n( $datetime_format , false, true ) . '</code>'
273
+					'<code>'.date_i18n($datetime_format, false, true).'</code>'
274 274
 				);
275 275
 				?></span>
276
-			<?php if ( ! empty( $timezone_string ) || ! empty( $gmt_offset )) : ?>
277
-				<br /><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n( $datetime_format ) . '</code>' ); ?></span>
276
+			<?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?>
277
+				<br /><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span>
278 278
 		<?php endif; ?>
279 279
 
280 280
 				<?php if ($check_zone_info && $timezone_string) : ?>
@@ -306,10 +306,9 @@  discard block
 block discarded – undo
306 306
 
307 307
 						if ($found) {
308 308
 							$message = $tr['isdst'] ?
309
-											__(' Daylight saving time begins on: %s.' ) :
310
-											__(' Standard time begins  on: %s.');
309
+											__(' Daylight saving time begins on: %s.') : __(' Standard time begins  on: %s.');
311 310
 							// Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
312
-							printf( $message, '<code >' . date_i18n( $datetime_format, $tr['ts'] + ( $tz_offset - $tr['offset'] ) ). '</code >' );
311
+							printf($message, '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >');
313 312
 						} else {
314 313
 							_e('This timezone does not observe daylight saving time.');
315 314
 						}
@@ -339,14 +338,14 @@  discard block
 block discarded – undo
339 338
 	 *
340 339
 	 * @return int      $unix_timestamp with the offset applied for the given timezone.
341 340
 	 */
342
-	public static function get_timestamp_with_offset( $unix_timestamp = 0, $timezone_string = '' ) {
341
+	public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') {
343 342
 		$unix_timestamp = $unix_timestamp === 0 ? time() : (int) $unix_timestamp;
344
-		$timezone_string = self::get_valid_timezone_string( $timezone_string );
345
-		$TimeZone = new DateTimeZone( $timezone_string );
343
+		$timezone_string = self::get_valid_timezone_string($timezone_string);
344
+		$TimeZone = new DateTimeZone($timezone_string);
346 345
 
347
-		$DateTime = new DateTime( '@' . $unix_timestamp, $TimeZone );
348
-		$offset = timezone_offset_get( $TimeZone, $DateTime );
349
-		return (int)$DateTime->format( 'U' ) + (int)$offset;
346
+		$DateTime = new DateTime('@'.$unix_timestamp, $TimeZone);
347
+		$offset = timezone_offset_get($TimeZone, $DateTime);
348
+		return (int) $DateTime->format('U') + (int) $offset;
350 349
 	}
351 350
 
352 351
 
@@ -361,17 +360,17 @@  discard block
 block discarded – undo
361 360
 	 * @param  string					$datetime_field_name 	the datetime fieldname to be manipulated
362 361
 	 * @return 	EE_Base_Class
363 362
 	 */
364
-	protected static function _set_date_time_field( EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name ) {
363
+	protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name) {
365 364
 		// grab current datetime format
366 365
 		$current_format = $obj->get_format();
367 366
 		// set new full timestamp format
368
-		$obj->set_date_format( EE_Datetime_Field::mysql_date_format );
369
-		$obj->set_time_format( EE_Datetime_Field::mysql_time_format );
367
+		$obj->set_date_format(EE_Datetime_Field::mysql_date_format);
368
+		$obj->set_time_format(EE_Datetime_Field::mysql_time_format);
370 369
 		// set the new date value using a full timestamp format so that no data is lost
371
-		$obj->set( $datetime_field_name, $DateTime->format( EE_Datetime_Field::mysql_timestamp_format ) );
370
+		$obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
372 371
 		// reset datetime formats
373
-		$obj->set_date_format( $current_format[0] );
374
-		$obj->set_time_format( $current_format[1] );
372
+		$obj->set_date_format($current_format[0]);
373
+		$obj->set_time_format($current_format[1]);
375 374
 		return $obj;
376 375
 	}
377 376
 
@@ -388,11 +387,11 @@  discard block
 block discarded – undo
388 387
 	 * @param  integer 	$value    what you want to increment the time by
389 388
 	 * @return EE_Base_Class		   return the EE_Base_Class object so right away you can do something with it (chaining)
390 389
 	 */
391
-	public static function date_time_add( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) {
390
+	public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) {
392 391
 		//get the raw UTC date.
393
-		$DateTime = $obj->get_DateTime_object( $datetime_field_name );
394
-		$DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value );
395
-		return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name );
392
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
393
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
394
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
396 395
 	}
397 396
 
398 397
 
@@ -407,11 +406,11 @@  discard block
 block discarded – undo
407 406
 	 * @param int            $value
408 407
 	 * @return \EE_Base_Class
409 408
 	 */
410
-	public static function date_time_subtract( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) {
409
+	public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) {
411 410
 		//get the raw UTC date
412
-		$DateTime = $obj->get_DateTime_object( $datetime_field_name );
413
-		$DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value, '-' );
414
-		return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name );
411
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
412
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
413
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
415 414
 	}
416 415
 
417 416
 
@@ -424,44 +423,44 @@  discard block
 block discarded – undo
424 423
 	 * @return \DateTime return whatever type came in.
425 424
 	 * @throws \EE_Error
426 425
 	 */
427
-	protected static function _modify_datetime_object( DateTime $DateTime, $period = 'years', $value = 1, $operand = '+' ) {
428
-		if ( ! $DateTime instanceof DateTime ) {
426
+	protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') {
427
+		if ( ! $DateTime instanceof DateTime) {
429 428
 			throw new EE_Error(
430 429
 				sprintf(
431
-					__( 'Expected a PHP DateTime object, but instead received %1$s', 'event_espresso' ),
432
-					print_r( $DateTime, true )
430
+					__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
431
+					print_r($DateTime, true)
433 432
 				)
434 433
 			);
435 434
 		}
436
-		switch ( $period ) {
435
+		switch ($period) {
437 436
 			case 'years' :
438
-				$value = 'P' . $value . 'Y';
437
+				$value = 'P'.$value.'Y';
439 438
 				break;
440 439
 			case 'months' :
441
-				$value = 'P' . $value . 'M';
440
+				$value = 'P'.$value.'M';
442 441
 				break;
443 442
 			case 'weeks' :
444
-				$value = 'P' . $value . 'W';
443
+				$value = 'P'.$value.'W';
445 444
 				break;
446 445
 			case 'days' :
447
-				$value = 'P' . $value . 'D';
446
+				$value = 'P'.$value.'D';
448 447
 				break;
449 448
 			case 'hours' :
450
-				$value = 'PT' . $value . 'H';
449
+				$value = 'PT'.$value.'H';
451 450
 				break;
452 451
 			case 'minutes' :
453
-				$value = 'PT' . $value . 'M';
452
+				$value = 'PT'.$value.'M';
454 453
 				break;
455 454
 			case 'seconds' :
456
-				$value = 'PT' . $value . 'S';
455
+				$value = 'PT'.$value.'S';
457 456
 				break;
458 457
 		}
459
-		switch ( $operand ) {
458
+		switch ($operand) {
460 459
 			case '+':
461
-				$DateTime->add( new DateInterval( $value ) );
460
+				$DateTime->add(new DateInterval($value));
462 461
 				break;
463 462
 			case '-':
464
-				$DateTime->sub( new DateInterval( $value ) );
463
+				$DateTime->sub(new DateInterval($value));
465 464
 				break;
466 465
 		}
467 466
 		return $DateTime;
@@ -477,16 +476,16 @@  discard block
 block discarded – undo
477 476
 	 * @return \DateTime return whatever type came in.
478 477
 	 * @throws \EE_Error
479 478
 	 */
480
-	protected static function _modify_timestamp( $timestamp, $period = 'years', $value = 1, $operand = '+' ) {
481
-		if ( ! preg_match( EE_Datetime_Field::unix_timestamp_regex, $timestamp ) ) {
479
+	protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') {
480
+		if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
482 481
 			throw new EE_Error(
483 482
 				sprintf(
484
-					__( 'Expected a Unix timestamp, but instead received %1$s', 'event_espresso' ),
485
-					print_r( $timestamp, true )
483
+					__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
484
+					print_r($timestamp, true)
486 485
 				)
487 486
 			);
488 487
 		}
489
-		switch ( $period ) {
488
+		switch ($period) {
490 489
 			case 'years' :
491 490
 				$value = YEAR_IN_SECONDS * $value;
492 491
 				break;
@@ -506,9 +505,9 @@  discard block
 block discarded – undo
506 505
 				$value = MINUTE_IN_SECONDS * $value;
507 506
 				break;
508 507
 		}
509
-		switch ( $operand ) {
508
+		switch ($operand) {
510 509
 			case '+':
511
-				$timestamp  += $value;
510
+				$timestamp += $value;
512 511
 				break;
513 512
 			case '-':
514 513
 				$timestamp -= $value;
@@ -528,11 +527,11 @@  discard block
 block discarded – undo
528 527
 	 * @param  string  $operand What operand you wish to use for the calculation
529 528
 	 * @return mixed string|DateTime          return whatever type came in.
530 529
 	 */
531
-	public static function calc_date( $DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+' ) {
532
-		if ( $DateTime_or_timestamp instanceof DateTime ) {
533
-			return EEH_DTT_Helper::_modify_datetime_object( $DateTime_or_timestamp, $period, $value, $operand );
534
-		} else if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp )) {
535
-			return EEH_DTT_Helper::_modify_timestamp( $DateTime_or_timestamp, $period, $value, $operand );
530
+	public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') {
531
+		if ($DateTime_or_timestamp instanceof DateTime) {
532
+			return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand);
533
+		} else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
534
+			return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand);
536 535
 		} else {
537 536
 			//error
538 537
 			return $DateTime_or_timestamp;
@@ -562,24 +561,24 @@  discard block
 block discarded – undo
562 561
 	 * 			'moment' => //date and time format.
563 562
 	 * 		)
564 563
 	 */
565
-	public static function convert_php_to_js_and_moment_date_formats( $date_format_string = null, $time_format_string = null ) {
566
-		if ( $date_format_string === null ) {
567
-			$date_format_string = get_option( 'date_format' );
564
+	public static function convert_php_to_js_and_moment_date_formats($date_format_string = null, $time_format_string = null) {
565
+		if ($date_format_string === null) {
566
+			$date_format_string = get_option('date_format');
568 567
 		}
569 568
 
570
-		if ( $time_format_string === null ) {
571
-			$time_format_string = get_option( 'time_format' );
569
+		if ($time_format_string === null) {
570
+			$time_format_string = get_option('time_format');
572 571
 		}
573 572
 
574
-		$date_format = self::_php_to_js_moment_converter( $date_format_string );
575
-		$time_format = self::_php_to_js_moment_converter( $time_format_string );
573
+		$date_format = self::_php_to_js_moment_converter($date_format_string);
574
+		$time_format = self::_php_to_js_moment_converter($time_format_string);
576 575
 
577 576
 		return array(
578 577
 			'js' => array(
579 578
 				'date' => $date_format['js'],
580 579
 				'time' => $time_format['js']
581 580
 				),
582
-			'moment' => $date_format['moment'] . ' ' . $time_format['moment' ]
581
+			'moment' => $date_format['moment'].' '.$time_format['moment']
583 582
 			);
584 583
 	}
585 584
 
@@ -593,7 +592,7 @@  discard block
 block discarded – undo
593 592
 	 *
594 593
 	 * @return array js and moment formats.
595 594
 	 */
596
-	protected static function _php_to_js_moment_converter( $format_string ) {
595
+	protected static function _php_to_js_moment_converter($format_string) {
597 596
 		/**
598 597
 		 * This is a map of symbols for formats.
599 598
 		 * The index is the php symbol, the equivalent values are in the array.
@@ -750,15 +749,15 @@  discard block
 block discarded – undo
750 749
 		$jquery_ui_format = "";
751 750
 		$moment_format = "";
752 751
 		$escaping = false;
753
-		for ( $i = 0; $i < strlen($format_string); $i++ ) {
752
+		for ($i = 0; $i < strlen($format_string); $i++) {
754 753
 			$char = $format_string[$i];
755
-			if ( $char === '\\' )  { // PHP date format escaping character
754
+			if ($char === '\\') { // PHP date format escaping character
756 755
 				$i++;
757
-				if ( $escaping ) {
756
+				if ($escaping) {
758 757
 					$jquery_ui_format .= $format_string[$i];
759 758
 					$moment_format .= $format_string[$i];
760 759
 				} else {
761
-					$jquery_ui_format .= '\'' . $format_string[$i];
760
+					$jquery_ui_format .= '\''.$format_string[$i];
762 761
 					$moment_format .= $format_string[$i];
763 762
 				}
764 763
 				$escaping = true;
@@ -777,7 +776,7 @@  discard block
 block discarded – undo
777 776
 				}
778 777
 			}
779 778
 		}
780
-		return array( 'js' => $jquery_ui_format, 'moment' => $moment_format );
779
+		return array('js' => $jquery_ui_format, 'moment' => $moment_format);
781 780
 	}
782 781
 
783 782
 
@@ -792,25 +791,25 @@  discard block
 block discarded – undo
792 791
 	 *                           		errors is returned.  So for client code calling, check for is_array() to
793 792
 	 *                           		indicate failed validations.
794 793
 	 */
795
-	public static function validate_format_string( $format_string ) {
794
+	public static function validate_format_string($format_string) {
796 795
 		$error_msg = array();
797 796
 		//time format checks
798
-		switch ( true ) {
799
-			case   strpos( $format_string, 'h' )  !== false  :
800
-			case   strpos( $format_string, 'g' ) !== false :
797
+		switch (true) {
798
+			case   strpos($format_string, 'h') !== false  :
799
+			case   strpos($format_string, 'g') !== false :
801 800
 				/**
802 801
 				 * if the time string has a lowercase 'h' which == 12 hour time format and there
803 802
 				 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
804 803
 				 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
805 804
 				 */
806
-				if ( strpos( strtoupper( $format_string ), 'A' )  === false ) {
807
-					$error_msg[] = __('There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso' );
805
+				if (strpos(strtoupper($format_string), 'A') === false) {
806
+					$error_msg[] = __('There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso');
808 807
 				}
809 808
 				break;
810 809
 
811 810
 		}
812 811
 
813
-		return empty( $error_msg ) ? true : $error_msg;
812
+		return empty($error_msg) ? true : $error_msg;
814 813
 	}
815 814
 
816 815
 
@@ -832,11 +831,11 @@  discard block
 block discarded – undo
832 831
 	 * @param mixed $date_2
833 832
 	 * @return bool
834 833
 	 */
835
-	public static function dates_represent_one_24_hour_date( $date_1, $date_2 ) {
834
+	public static function dates_represent_one_24_hour_date($date_1, $date_2) {
836 835
 
837 836
 		if (
838
-			( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime ) ||
839
-			( $date_1->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' || $date_2->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' )
837
+			( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) ||
838
+			($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00')
840 839
 		) {
841 840
 			return false;
842 841
 		}
@@ -853,11 +852,11 @@  discard block
 block discarded – undo
853 852
 	 * @param string $field_for_interval  The Database field that is the interval is applied to in the query.
854 853
 	 * @return string
855 854
 	 */
856
-	public static function get_sql_query_interval_for_offset( $timezone_string, $field_for_interval ) {
855
+	public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval) {
857 856
 		try {
858 857
 			/** need to account for timezone offset on the selects */
859
-			$DateTimeZone = new DateTimeZone( $timezone_string );
860
-		} catch ( Exception $e ) {
858
+			$DateTimeZone = new DateTimeZone($timezone_string);
859
+		} catch (Exception $e) {
861 860
 			$DateTimeZone = null;
862 861
 		}
863 862
 
@@ -865,10 +864,10 @@  discard block
 block discarded – undo
865 864
 		 * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
866 865
 		 * Hence we do the calc for DateTimeZone::getOffset.
867 866
 		 */
868
-		$offset = $DateTimeZone instanceof DateTimeZone ? ( $DateTimeZone->getOffset( new DateTime('now') ) ) / HOUR_IN_SECONDS : get_option( 'gmt_offset' );
867
+		$offset = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset');
869 868
 		$query_interval = $offset < 0
870
-			? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset*-1 . ' HOUR)'
871
-			: 'DATE_ADD(' . $field_for_interval .', INTERVAL ' . $offset . ' HOUR)';
869
+			? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)'
870
+			: 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)';
872 871
 		return $query_interval;
873 872
 	}
874 873
 
@@ -880,47 +879,47 @@  discard block
 block discarded – undo
880 879
 	 * @return string
881 880
 	 */
882 881
 	public static function get_timezone_string_for_display() {
883
-		$pretty_timezone = apply_filters( 'FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '' );
884
-		if( ! empty( $pretty_timezone ) ) {
885
-			return esc_html( $pretty_timezone );
882
+		$pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
883
+		if ( ! empty($pretty_timezone)) {
884
+			return esc_html($pretty_timezone);
886 885
 		}
887
-		$timezone_string = get_option( 'timezone_string' );
888
-		if( $timezone_string ) {
886
+		$timezone_string = get_option('timezone_string');
887
+		if ($timezone_string) {
889 888
 			static $mo_loaded = false;
890 889
 			// Load translations for continents and cities just like wp_timezone_choice does
891
-			if ( ! $mo_loaded ) {
890
+			if ( ! $mo_loaded) {
892 891
 				$locale = get_locale();
893
-				$mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
894
-				load_textdomain( 'continents-cities', $mofile );
892
+				$mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo';
893
+				load_textdomain('continents-cities', $mofile);
895 894
 				$mo_loaded = true;
896 895
 			}
897 896
 			//well that was easy.
898
-			$parts = explode('/', $timezone_string );
897
+			$parts = explode('/', $timezone_string);
899 898
 			//remove the continent
900
-			unset( $parts[0] );
899
+			unset($parts[0]);
901 900
 			$t_parts = array();
902
-			foreach( $parts as $part ) {
903
-				$t_parts[] = translate( str_replace( '_', ' ', $part ), 'continents-cities' );
901
+			foreach ($parts as $part) {
902
+				$t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
904 903
 			}
905
-			return implode( ' - ', $t_parts );
904
+			return implode(' - ', $t_parts);
906 905
 		}
907 906
 		//they haven't set the timezone string, so let's return a string like "UTC+1"
908
-		$gmt_offset = get_option( 'gmt_offset' );
909
-		if( intval( $gmt_offset ) >= 0 ) {
907
+		$gmt_offset = get_option('gmt_offset');
908
+		if (intval($gmt_offset) >= 0) {
910 909
 			$prefix = '+';
911 910
 		} else {
912 911
 			$prefix = '';
913 912
 		}
914
-		$parts = explode( '.', (string) $gmt_offset );
915
-		if( count( $parts ) === 1 ) {
913
+		$parts = explode('.', (string) $gmt_offset);
914
+		if (count($parts) === 1) {
916 915
 			$parts[1] = '00';
917 916
 		} else {
918 917
 			//convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
919 918
 			//to minutes, eg 30 or 15, respectively
920
-			$hour_fraction = (float)( '0.' . $parts[1] );
921
-			$parts[1] = (string)$hour_fraction * 60;
919
+			$hour_fraction = (float) ('0.'.$parts[1]);
920
+			$parts[1] = (string) $hour_fraction * 60;
922 921
 		}
923
-		return sprintf( __( 'UTC%1$s', 'event_espresso' ), $prefix . implode( ':', $parts ) );
922
+		return sprintf(__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts));
924 923
 	}
925 924
 
926 925
 
Please login to merge, or discard this patch.
core/libraries/rest_api/Model_Data_Translator.php 2 patches
Indentation   +481 added lines, -481 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace EventEspresso\core\libraries\rest_api;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -26,485 +26,485 @@  discard block
 block discarded – undo
26 26
 class Model_Data_Translator
27 27
 {
28 28
 
29
-    /**
30
-     * We used to use -1 for infinity in the rest api, but that's ambiguous for
31
-     * fields that COULD contain -1; so we use null
32
-     */
33
-    const ee_inf_in_rest = null;
34
-
35
-
36
-
37
-    /**
38
-     * Prepares a possible array of input values from JSON for use by the models
39
-     *
40
-     * @param \EE_Model_Field_Base $field_obj
41
-     * @param mixed                $original_value_maybe_array
42
-     * @param string               $requested_version
43
-     * @param string               $timezone_string treat values as being in this timezone
44
-     * @return mixed
45
-     * @throws \DomainException
46
-     */
47
-    public static function prepare_field_values_from_json(
48
-        $field_obj,
49
-        $original_value_maybe_array,
50
-        $requested_version,
51
-        $timezone_string = 'UTC'
52
-    ) {
53
-        if (is_array($original_value_maybe_array)) {
54
-            $new_value_maybe_array = array();
55
-            foreach ($original_value_maybe_array as $array_key => $array_item) {
56
-                $new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_from_json(
57
-                    $field_obj,
58
-                    $array_item,
59
-                    $requested_version,
60
-                    $timezone_string
61
-                );
62
-            }
63
-        } else {
64
-            $new_value_maybe_array = Model_Data_Translator::prepare_field_value_from_json(
65
-                $field_obj,
66
-                $original_value_maybe_array,
67
-                $requested_version,
68
-                $timezone_string
69
-            );
70
-        }
71
-        return $new_value_maybe_array;
72
-    }
73
-
74
-
75
-
76
-    /**
77
-     * Prepares an array of field values FOR use in JSON/REST API
78
-     *
79
-     * @param \EE_Model_Field_Base $field_obj
80
-     * @param mixed                $original_value_maybe_array
81
-     * @param string               $request_version (eg 4.8.36)
82
-     * @return array
83
-     */
84
-    public static function prepare_field_values_for_json($field_obj, $original_value_maybe_array, $request_version)
85
-    {
86
-        if (is_array($original_value_maybe_array)) {
87
-            $new_value_maybe_array = array();
88
-            foreach ($original_value_maybe_array as $array_key => $array_item) {
89
-                $new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_for_json(
90
-                    $field_obj,
91
-                    $array_item,
92
-                    $request_version
93
-                );
94
-            }
95
-        } else {
96
-            $new_value_maybe_array = Model_Data_Translator::prepare_field_value_for_json(
97
-                $field_obj,
98
-                $original_value_maybe_array,
99
-                $request_version
100
-            );
101
-        }
102
-        return $new_value_maybe_array;
103
-    }
104
-
105
-
106
-
107
-    /**
108
-     * Prepares incoming data from the json or $_REQUEST parameters for the models'
109
-     * "$query_params".
110
-     *
111
-     * @param \EE_Model_Field_Base $field_obj
112
-     * @param mixed                $original_value
113
-     * @param string               $requested_version
114
-     * @param string               $timezone_string treat values as being in this timezone
115
-     * @return mixed
116
-     * @throws \DomainException
117
-     */
118
-    public static function prepare_field_value_from_json(
119
-        $field_obj,
120
-        $original_value,
121
-        $requested_version,
122
-        $timezone_string = 'UTC' // UTC
123
-    )
124
-    {
125
-        $timezone_string = $timezone_string !== '' ? $timezone_string : get_option('timezone_string', '');
126
-        $new_value = null;
127
-        if ($field_obj instanceof \EE_Infinite_Integer_Field
128
-            && in_array($original_value, array(null, ''), true)
129
-        ) {
130
-            $new_value = EE_INF;
131
-        } elseif ($field_obj instanceof \EE_Datetime_Field) {
132
-            list($offset_sign, $offset_secs) = Model_Data_Translator::parse_timezone_offset(
133
-                $field_obj->get_timezone_offset(
134
-                    new \DateTimeZone($timezone_string)
135
-                )
136
-            );
137
-            $offset_string =
138
-                str_pad(
139
-                    floor($offset_secs / HOUR_IN_SECONDS),
140
-                    2,
141
-                    '0',
142
-                    STR_PAD_LEFT
143
-                )
144
-                . ':'
145
-                . str_pad(
146
-                    ($offset_secs % HOUR_IN_SECONDS) / MINUTE_IN_SECONDS,
147
-                    2,
148
-                    '0',
149
-                    STR_PAD_LEFT
150
-                );
151
-            $new_value = rest_parse_date($original_value . $offset_sign . $offset_string);
152
-        } else {
153
-            $new_value = $original_value;
154
-        }
155
-        return $new_value;
156
-    }
157
-
158
-
159
-
160
-    /**
161
-     * determines what's going on with them timezone strings
162
-     *
163
-     * @param int $timezone_offset
164
-     * @return array
165
-     */
166
-    private static function parse_timezone_offset($timezone_offset)
167
-    {
168
-        $first_char = substr((string)$timezone_offset, 0, 1);
169
-        if ($first_char === '+' || $first_char === '-') {
170
-            $offset_sign = $first_char;
171
-            $offset_secs = substr((string)$timezone_offset, 1);
172
-        } else {
173
-            $offset_sign = '+';
174
-            $offset_secs = $timezone_offset;
175
-        }
176
-        return array($offset_sign, $offset_secs);
177
-    }
178
-
179
-
180
-
181
-    /**
182
-     * Prepares a field's value for display in the API
183
-     *
184
-     * @param \EE_Model_Field_Base $field_obj
185
-     * @param mixed                $original_value
186
-     * @param string               $requested_version
187
-     * @return mixed
188
-     */
189
-    public static function prepare_field_value_for_json($field_obj, $original_value, $requested_version)
190
-    {
191
-        if ($original_value === EE_INF) {
192
-            $new_value = Model_Data_Translator::ee_inf_in_rest;
193
-        } elseif ($field_obj instanceof \EE_Datetime_Field) {
194
-            if ($original_value instanceof \DateTime) {
195
-                $new_value = $original_value->format('Y-m-d H:i:s');
196
-            } elseif (is_int($original_value)) {
197
-                $new_value = date('Y-m-d H:i:s', $original_value);
198
-            } else {
199
-                $new_value = $original_value;
200
-            }
201
-            $new_value = mysql_to_rfc3339($new_value);
202
-        } else {
203
-            $new_value = $original_value;
204
-        }
205
-        return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api',
206
-            $new_value,
207
-            $field_obj,
208
-            $original_value,
209
-            $requested_version
210
-        );
211
-    }
212
-
213
-
214
-
215
-    /**
216
-     * Prepares condition-query-parameters (like what's in where and having) from
217
-     * the format expected in the API to use in the models
218
-     *
219
-     * @param array     $inputted_query_params_of_this_type
220
-     * @param \EEM_Base $model
221
-     * @param string    $requested_version
222
-     * @return array
223
-     * @throws \DomainException
224
-     * @throws \EE_Error
225
-     */
226
-    public static function prepare_conditions_query_params_for_models(
227
-        $inputted_query_params_of_this_type,
228
-        \EEM_Base $model,
229
-        $requested_version
230
-    ) {
231
-        $query_param_for_models = array();
232
-        foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) {
233
-            $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key);
234
-            $field = Model_Data_Translator::deduce_field_from_query_param(
235
-                $query_param_sans_stars,
236
-                $model
237
-            );
238
-            //double-check is it a *_gmt field?
239
-            if ( ! $field instanceof \EE_Model_Field_Base
240
-                 && Model_Data_Translator::is_gmt_date_field_name($query_param_sans_stars)
241
-            ) {
242
-                //yep, take off '_gmt', and find the field
243
-                $query_param_key = Model_Data_Translator::remove_gmt_from_field_name($query_param_sans_stars);
244
-                $field = Model_Data_Translator::deduce_field_from_query_param(
245
-                    $query_param_key,
246
-                    $model
247
-                );
248
-                $timezone = 'UTC';
249
-            } else {
250
-                //so it's not a GMT field. Set the timezone on the model to the default
251
-                $timezone = \EEH_DTT_Helper::get_valid_timezone_string();
252
-            }
253
-            if ($field instanceof \EE_Model_Field_Base) {
254
-                //did they specify an operator?
255
-                if (is_array($query_param_value)) {
256
-                    $op = $query_param_value[0];
257
-                    $translated_value = array($op);
258
-                    if (isset($query_param_value[1])) {
259
-                        $value = $query_param_value[1];
260
-                        $translated_value[1] = Model_Data_Translator::prepare_field_values_from_json($field, $value,
261
-                            $requested_version, $timezone);
262
-                    }
263
-                } else {
264
-                    $translated_value = Model_Data_Translator::prepare_field_value_from_json($field, $query_param_value,
265
-                        $requested_version, $timezone);
266
-                }
267
-                $query_param_for_models[$query_param_key] = $translated_value;
268
-            } else {
269
-                //so it's not for a field, assume it's a logic query param key
270
-                $query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_models($query_param_value,
271
-                    $model, $requested_version);
272
-            }
273
-        }
274
-        return $query_param_for_models;
275
-    }
276
-
277
-
278
-
279
-    /**
280
-     * Mostly checks if the last 4 characters are "_gmt", indicating its a
281
-     * gmt date field name
282
-     *
283
-     * @param string $field_name
284
-     * @return boolean
285
-     */
286
-    public static function is_gmt_date_field_name($field_name)
287
-    {
288
-        return substr(
289
-                   Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($field_name),
290
-                   -4,
291
-                   4
292
-               ) === '_gmt';
293
-    }
294
-
295
-
296
-
297
-    /**
298
-     * Removes the last "_gmt" part of a field name (and if there is no "_gmt" at the end, leave it alone)
299
-     *
300
-     * @param string $field_name
301
-     * @return string
302
-     */
303
-    public static function remove_gmt_from_field_name($field_name)
304
-    {
305
-        if ( ! Model_Data_Translator::is_gmt_date_field_name($field_name)) {
306
-            return $field_name;
307
-        }
308
-        $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($field_name);
309
-        $query_param_sans_gmt_and_sans_stars = substr(
310
-            $query_param_sans_stars,
311
-            0,
312
-            strrpos(
313
-                $field_name,
314
-                '_gmt'
315
-            )
316
-        );
317
-        return str_replace($query_param_sans_stars, $query_param_sans_gmt_and_sans_stars, $field_name);
318
-    }
319
-
320
-
321
-
322
-    /**
323
-     * Takes a field name from the REST API and prepares it for the model querying
324
-     *
325
-     * @param string $field_name
326
-     * @return string
327
-     */
328
-    public static function prepare_field_name_from_json($field_name)
329
-    {
330
-        if (Model_Data_Translator::is_gmt_date_field_name($field_name)) {
331
-            return Model_Data_Translator::remove_gmt_from_field_name($field_name);
332
-        }
333
-        return $field_name;
334
-    }
335
-
336
-
337
-
338
-    /**
339
-     * Takes array of field names from REST API and prepares for models
340
-     *
341
-     * @param array $field_names
342
-     * @return array of field names (possibly include model prefixes)
343
-     */
344
-    public static function prepare_field_names_from_json(array $field_names)
345
-    {
346
-        $new_array = array();
347
-        foreach ($field_names as $key => $field_name) {
348
-            $new_array[$key] = Model_Data_Translator::prepare_field_name_from_json($field_name);
349
-        }
350
-        return $new_array;
351
-    }
352
-
353
-
354
-
355
-    /**
356
-     * Takes array where array keys are field names (possibly with model path prefixes)
357
-     * from the REST API and prepares them for model querying
358
-     *
359
-     * @param array $field_names_as_keys
360
-     * @return array
361
-     */
362
-    public static function prepare_field_names_in_array_keys_from_json(array $field_names_as_keys)
363
-    {
364
-        $new_array = array();
365
-        foreach ($field_names_as_keys as $field_name => $value) {
366
-            $new_array[Model_Data_Translator::prepare_field_name_from_json($field_name)] = $value;
367
-        }
368
-        return $new_array;
369
-    }
370
-
371
-
372
-
373
-    /**
374
-     * Prepares an array of model query params for use in the REST API
375
-     *
376
-     * @param array     $model_query_params
377
-     * @param \EEM_Base $model
378
-     * @param string    $requested_version eg "4.8.36". If null is provided, defaults to the latest release of the EE4
379
-     *                                     REST API
380
-     * @return array which can be passed into the EE4 REST API when querying a model resource
381
-     * @throws \EE_Error
382
-     */
383
-    public static function prepare_query_params_for_rest_api(
384
-        array $model_query_params,
385
-        \EEM_Base $model,
386
-        $requested_version = null
387
-    ) {
388
-        if ($requested_version === null) {
389
-            $requested_version = \EED_Core_Rest_Api::latest_rest_api_version();
390
-        }
391
-        $rest_query_params = $model_query_params;
392
-        if (isset($model_query_params[0])) {
393
-            $rest_query_params['where'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api(
394
-                $model_query_params[0],
395
-                $model,
396
-                $requested_version
397
-            );
398
-            unset($rest_query_params[0]);
399
-        }
400
-        if (isset($model_query_params['having'])) {
401
-            $rest_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api(
402
-                $model_query_params['having'],
403
-                $model,
404
-                $requested_version
405
-            );
406
-        }
407
-        return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api',
408
-            $rest_query_params, $model_query_params, $model, $requested_version);
409
-    }
410
-
411
-
412
-
413
-    /**
414
-     * Prepares all the sub-conditions query parameters (eg having or where conditions) for use in the rest api
415
-     *
416
-     * @param array     $inputted_query_params_of_this_type eg like the "where" or "having" conditions query params
417
-     *                                                      passed into EEM_Base::get_all()
418
-     * @param \EEM_Base $model
419
-     * @param string    $requested_version                  eg "4.8.36"
420
-     * @return array ready for use in the rest api query params
421
-     * @throws \EE_Error
422
-     */
423
-    public static function prepare_conditions_query_params_for_rest_api(
424
-        $inputted_query_params_of_this_type,
425
-        \EEM_Base $model,
426
-        $requested_version
427
-    ) {
428
-        $query_param_for_models = array();
429
-        foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) {
430
-            $field = Model_Data_Translator::deduce_field_from_query_param(
431
-                Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key),
432
-                $model
433
-            );
434
-            if ($field instanceof \EE_Model_Field_Base) {
435
-                //did they specify an operator?
436
-                if (is_array($query_param_value)) {
437
-                    $op = $query_param_value[0];
438
-                    $translated_value = array($op);
439
-                    if (isset($query_param_value[1])) {
440
-                        $value = $query_param_value[1];
441
-                        $translated_value[1] = Model_Data_Translator::prepare_field_values_for_json($field, $value,
442
-                            $requested_version);
443
-                    }
444
-                } else {
445
-                    $translated_value = Model_Data_Translator::prepare_field_value_for_json($field, $query_param_value,
446
-                        $requested_version);
447
-                }
448
-                $query_param_for_models[$query_param_key] = $translated_value;
449
-            } else {
450
-                //so it's not for a field, assume it's a logic query param key
451
-                $query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api($query_param_value,
452
-                    $model, $requested_version);
453
-            }
454
-        }
455
-        return $query_param_for_models;
456
-    }
457
-
458
-
459
-
460
-    /**
461
-     * @param $condition_query_param_key
462
-     * @return string
463
-     */
464
-    public static function remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key)
465
-    {
466
-        $pos_of_star = strpos($condition_query_param_key, '*');
467
-        if ($pos_of_star === false) {
468
-            return $condition_query_param_key;
469
-        } else {
470
-            $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
471
-            return $condition_query_param_sans_star;
472
-        }
473
-    }
474
-
475
-
476
-
477
-    /**
478
-     * Takes the input parameter and finds the model field that it indicates.
479
-     *
480
-     * @param string    $query_param_name like Registration.Transaction.TXN_ID, Event.Datetime.start_time, or REG_ID
481
-     * @param \EEM_Base $model
482
-     * @return \EE_Model_Field_Base
483
-     * @throws \EE_Error
484
-     */
485
-    public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model)
486
-    {
487
-        //ok, now proceed with deducing which part is the model's name, and which is the field's name
488
-        //which will help us find the database table and column
489
-        $query_param_parts = explode('.', $query_param_name);
490
-        if (empty($query_param_parts)) {
491
-            throw new \EE_Error(sprintf(__('_extract_column_name is empty when trying to extract column and table name from %s',
492
-                'event_espresso'), $query_param_name));
493
-        }
494
-        $number_of_parts = count($query_param_parts);
495
-        $last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
496
-        if ($number_of_parts === 1) {
497
-            $field_name = $last_query_param_part;
498
-        } else {// $number_of_parts >= 2
499
-            //the last part is the column name, and there are only 2parts. therefore...
500
-            $field_name = $last_query_param_part;
501
-            $model = \EE_Registry::instance()->load_model($query_param_parts[$number_of_parts - 2]);
502
-        }
503
-        try {
504
-            return $model->field_settings_for($field_name);
505
-        } catch (\EE_Error $e) {
506
-            return null;
507
-        }
508
-    }
29
+	/**
30
+	 * We used to use -1 for infinity in the rest api, but that's ambiguous for
31
+	 * fields that COULD contain -1; so we use null
32
+	 */
33
+	const ee_inf_in_rest = null;
34
+
35
+
36
+
37
+	/**
38
+	 * Prepares a possible array of input values from JSON for use by the models
39
+	 *
40
+	 * @param \EE_Model_Field_Base $field_obj
41
+	 * @param mixed                $original_value_maybe_array
42
+	 * @param string               $requested_version
43
+	 * @param string               $timezone_string treat values as being in this timezone
44
+	 * @return mixed
45
+	 * @throws \DomainException
46
+	 */
47
+	public static function prepare_field_values_from_json(
48
+		$field_obj,
49
+		$original_value_maybe_array,
50
+		$requested_version,
51
+		$timezone_string = 'UTC'
52
+	) {
53
+		if (is_array($original_value_maybe_array)) {
54
+			$new_value_maybe_array = array();
55
+			foreach ($original_value_maybe_array as $array_key => $array_item) {
56
+				$new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_from_json(
57
+					$field_obj,
58
+					$array_item,
59
+					$requested_version,
60
+					$timezone_string
61
+				);
62
+			}
63
+		} else {
64
+			$new_value_maybe_array = Model_Data_Translator::prepare_field_value_from_json(
65
+				$field_obj,
66
+				$original_value_maybe_array,
67
+				$requested_version,
68
+				$timezone_string
69
+			);
70
+		}
71
+		return $new_value_maybe_array;
72
+	}
73
+
74
+
75
+
76
+	/**
77
+	 * Prepares an array of field values FOR use in JSON/REST API
78
+	 *
79
+	 * @param \EE_Model_Field_Base $field_obj
80
+	 * @param mixed                $original_value_maybe_array
81
+	 * @param string               $request_version (eg 4.8.36)
82
+	 * @return array
83
+	 */
84
+	public static function prepare_field_values_for_json($field_obj, $original_value_maybe_array, $request_version)
85
+	{
86
+		if (is_array($original_value_maybe_array)) {
87
+			$new_value_maybe_array = array();
88
+			foreach ($original_value_maybe_array as $array_key => $array_item) {
89
+				$new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_for_json(
90
+					$field_obj,
91
+					$array_item,
92
+					$request_version
93
+				);
94
+			}
95
+		} else {
96
+			$new_value_maybe_array = Model_Data_Translator::prepare_field_value_for_json(
97
+				$field_obj,
98
+				$original_value_maybe_array,
99
+				$request_version
100
+			);
101
+		}
102
+		return $new_value_maybe_array;
103
+	}
104
+
105
+
106
+
107
+	/**
108
+	 * Prepares incoming data from the json or $_REQUEST parameters for the models'
109
+	 * "$query_params".
110
+	 *
111
+	 * @param \EE_Model_Field_Base $field_obj
112
+	 * @param mixed                $original_value
113
+	 * @param string               $requested_version
114
+	 * @param string               $timezone_string treat values as being in this timezone
115
+	 * @return mixed
116
+	 * @throws \DomainException
117
+	 */
118
+	public static function prepare_field_value_from_json(
119
+		$field_obj,
120
+		$original_value,
121
+		$requested_version,
122
+		$timezone_string = 'UTC' // UTC
123
+	)
124
+	{
125
+		$timezone_string = $timezone_string !== '' ? $timezone_string : get_option('timezone_string', '');
126
+		$new_value = null;
127
+		if ($field_obj instanceof \EE_Infinite_Integer_Field
128
+			&& in_array($original_value, array(null, ''), true)
129
+		) {
130
+			$new_value = EE_INF;
131
+		} elseif ($field_obj instanceof \EE_Datetime_Field) {
132
+			list($offset_sign, $offset_secs) = Model_Data_Translator::parse_timezone_offset(
133
+				$field_obj->get_timezone_offset(
134
+					new \DateTimeZone($timezone_string)
135
+				)
136
+			);
137
+			$offset_string =
138
+				str_pad(
139
+					floor($offset_secs / HOUR_IN_SECONDS),
140
+					2,
141
+					'0',
142
+					STR_PAD_LEFT
143
+				)
144
+				. ':'
145
+				. str_pad(
146
+					($offset_secs % HOUR_IN_SECONDS) / MINUTE_IN_SECONDS,
147
+					2,
148
+					'0',
149
+					STR_PAD_LEFT
150
+				);
151
+			$new_value = rest_parse_date($original_value . $offset_sign . $offset_string);
152
+		} else {
153
+			$new_value = $original_value;
154
+		}
155
+		return $new_value;
156
+	}
157
+
158
+
159
+
160
+	/**
161
+	 * determines what's going on with them timezone strings
162
+	 *
163
+	 * @param int $timezone_offset
164
+	 * @return array
165
+	 */
166
+	private static function parse_timezone_offset($timezone_offset)
167
+	{
168
+		$first_char = substr((string)$timezone_offset, 0, 1);
169
+		if ($first_char === '+' || $first_char === '-') {
170
+			$offset_sign = $first_char;
171
+			$offset_secs = substr((string)$timezone_offset, 1);
172
+		} else {
173
+			$offset_sign = '+';
174
+			$offset_secs = $timezone_offset;
175
+		}
176
+		return array($offset_sign, $offset_secs);
177
+	}
178
+
179
+
180
+
181
+	/**
182
+	 * Prepares a field's value for display in the API
183
+	 *
184
+	 * @param \EE_Model_Field_Base $field_obj
185
+	 * @param mixed                $original_value
186
+	 * @param string               $requested_version
187
+	 * @return mixed
188
+	 */
189
+	public static function prepare_field_value_for_json($field_obj, $original_value, $requested_version)
190
+	{
191
+		if ($original_value === EE_INF) {
192
+			$new_value = Model_Data_Translator::ee_inf_in_rest;
193
+		} elseif ($field_obj instanceof \EE_Datetime_Field) {
194
+			if ($original_value instanceof \DateTime) {
195
+				$new_value = $original_value->format('Y-m-d H:i:s');
196
+			} elseif (is_int($original_value)) {
197
+				$new_value = date('Y-m-d H:i:s', $original_value);
198
+			} else {
199
+				$new_value = $original_value;
200
+			}
201
+			$new_value = mysql_to_rfc3339($new_value);
202
+		} else {
203
+			$new_value = $original_value;
204
+		}
205
+		return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api',
206
+			$new_value,
207
+			$field_obj,
208
+			$original_value,
209
+			$requested_version
210
+		);
211
+	}
212
+
213
+
214
+
215
+	/**
216
+	 * Prepares condition-query-parameters (like what's in where and having) from
217
+	 * the format expected in the API to use in the models
218
+	 *
219
+	 * @param array     $inputted_query_params_of_this_type
220
+	 * @param \EEM_Base $model
221
+	 * @param string    $requested_version
222
+	 * @return array
223
+	 * @throws \DomainException
224
+	 * @throws \EE_Error
225
+	 */
226
+	public static function prepare_conditions_query_params_for_models(
227
+		$inputted_query_params_of_this_type,
228
+		\EEM_Base $model,
229
+		$requested_version
230
+	) {
231
+		$query_param_for_models = array();
232
+		foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) {
233
+			$query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key);
234
+			$field = Model_Data_Translator::deduce_field_from_query_param(
235
+				$query_param_sans_stars,
236
+				$model
237
+			);
238
+			//double-check is it a *_gmt field?
239
+			if ( ! $field instanceof \EE_Model_Field_Base
240
+				 && Model_Data_Translator::is_gmt_date_field_name($query_param_sans_stars)
241
+			) {
242
+				//yep, take off '_gmt', and find the field
243
+				$query_param_key = Model_Data_Translator::remove_gmt_from_field_name($query_param_sans_stars);
244
+				$field = Model_Data_Translator::deduce_field_from_query_param(
245
+					$query_param_key,
246
+					$model
247
+				);
248
+				$timezone = 'UTC';
249
+			} else {
250
+				//so it's not a GMT field. Set the timezone on the model to the default
251
+				$timezone = \EEH_DTT_Helper::get_valid_timezone_string();
252
+			}
253
+			if ($field instanceof \EE_Model_Field_Base) {
254
+				//did they specify an operator?
255
+				if (is_array($query_param_value)) {
256
+					$op = $query_param_value[0];
257
+					$translated_value = array($op);
258
+					if (isset($query_param_value[1])) {
259
+						$value = $query_param_value[1];
260
+						$translated_value[1] = Model_Data_Translator::prepare_field_values_from_json($field, $value,
261
+							$requested_version, $timezone);
262
+					}
263
+				} else {
264
+					$translated_value = Model_Data_Translator::prepare_field_value_from_json($field, $query_param_value,
265
+						$requested_version, $timezone);
266
+				}
267
+				$query_param_for_models[$query_param_key] = $translated_value;
268
+			} else {
269
+				//so it's not for a field, assume it's a logic query param key
270
+				$query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_models($query_param_value,
271
+					$model, $requested_version);
272
+			}
273
+		}
274
+		return $query_param_for_models;
275
+	}
276
+
277
+
278
+
279
+	/**
280
+	 * Mostly checks if the last 4 characters are "_gmt", indicating its a
281
+	 * gmt date field name
282
+	 *
283
+	 * @param string $field_name
284
+	 * @return boolean
285
+	 */
286
+	public static function is_gmt_date_field_name($field_name)
287
+	{
288
+		return substr(
289
+				   Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($field_name),
290
+				   -4,
291
+				   4
292
+			   ) === '_gmt';
293
+	}
294
+
295
+
296
+
297
+	/**
298
+	 * Removes the last "_gmt" part of a field name (and if there is no "_gmt" at the end, leave it alone)
299
+	 *
300
+	 * @param string $field_name
301
+	 * @return string
302
+	 */
303
+	public static function remove_gmt_from_field_name($field_name)
304
+	{
305
+		if ( ! Model_Data_Translator::is_gmt_date_field_name($field_name)) {
306
+			return $field_name;
307
+		}
308
+		$query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($field_name);
309
+		$query_param_sans_gmt_and_sans_stars = substr(
310
+			$query_param_sans_stars,
311
+			0,
312
+			strrpos(
313
+				$field_name,
314
+				'_gmt'
315
+			)
316
+		);
317
+		return str_replace($query_param_sans_stars, $query_param_sans_gmt_and_sans_stars, $field_name);
318
+	}
319
+
320
+
321
+
322
+	/**
323
+	 * Takes a field name from the REST API and prepares it for the model querying
324
+	 *
325
+	 * @param string $field_name
326
+	 * @return string
327
+	 */
328
+	public static function prepare_field_name_from_json($field_name)
329
+	{
330
+		if (Model_Data_Translator::is_gmt_date_field_name($field_name)) {
331
+			return Model_Data_Translator::remove_gmt_from_field_name($field_name);
332
+		}
333
+		return $field_name;
334
+	}
335
+
336
+
337
+
338
+	/**
339
+	 * Takes array of field names from REST API and prepares for models
340
+	 *
341
+	 * @param array $field_names
342
+	 * @return array of field names (possibly include model prefixes)
343
+	 */
344
+	public static function prepare_field_names_from_json(array $field_names)
345
+	{
346
+		$new_array = array();
347
+		foreach ($field_names as $key => $field_name) {
348
+			$new_array[$key] = Model_Data_Translator::prepare_field_name_from_json($field_name);
349
+		}
350
+		return $new_array;
351
+	}
352
+
353
+
354
+
355
+	/**
356
+	 * Takes array where array keys are field names (possibly with model path prefixes)
357
+	 * from the REST API and prepares them for model querying
358
+	 *
359
+	 * @param array $field_names_as_keys
360
+	 * @return array
361
+	 */
362
+	public static function prepare_field_names_in_array_keys_from_json(array $field_names_as_keys)
363
+	{
364
+		$new_array = array();
365
+		foreach ($field_names_as_keys as $field_name => $value) {
366
+			$new_array[Model_Data_Translator::prepare_field_name_from_json($field_name)] = $value;
367
+		}
368
+		return $new_array;
369
+	}
370
+
371
+
372
+
373
+	/**
374
+	 * Prepares an array of model query params for use in the REST API
375
+	 *
376
+	 * @param array     $model_query_params
377
+	 * @param \EEM_Base $model
378
+	 * @param string    $requested_version eg "4.8.36". If null is provided, defaults to the latest release of the EE4
379
+	 *                                     REST API
380
+	 * @return array which can be passed into the EE4 REST API when querying a model resource
381
+	 * @throws \EE_Error
382
+	 */
383
+	public static function prepare_query_params_for_rest_api(
384
+		array $model_query_params,
385
+		\EEM_Base $model,
386
+		$requested_version = null
387
+	) {
388
+		if ($requested_version === null) {
389
+			$requested_version = \EED_Core_Rest_Api::latest_rest_api_version();
390
+		}
391
+		$rest_query_params = $model_query_params;
392
+		if (isset($model_query_params[0])) {
393
+			$rest_query_params['where'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api(
394
+				$model_query_params[0],
395
+				$model,
396
+				$requested_version
397
+			);
398
+			unset($rest_query_params[0]);
399
+		}
400
+		if (isset($model_query_params['having'])) {
401
+			$rest_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api(
402
+				$model_query_params['having'],
403
+				$model,
404
+				$requested_version
405
+			);
406
+		}
407
+		return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api',
408
+			$rest_query_params, $model_query_params, $model, $requested_version);
409
+	}
410
+
411
+
412
+
413
+	/**
414
+	 * Prepares all the sub-conditions query parameters (eg having or where conditions) for use in the rest api
415
+	 *
416
+	 * @param array     $inputted_query_params_of_this_type eg like the "where" or "having" conditions query params
417
+	 *                                                      passed into EEM_Base::get_all()
418
+	 * @param \EEM_Base $model
419
+	 * @param string    $requested_version                  eg "4.8.36"
420
+	 * @return array ready for use in the rest api query params
421
+	 * @throws \EE_Error
422
+	 */
423
+	public static function prepare_conditions_query_params_for_rest_api(
424
+		$inputted_query_params_of_this_type,
425
+		\EEM_Base $model,
426
+		$requested_version
427
+	) {
428
+		$query_param_for_models = array();
429
+		foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) {
430
+			$field = Model_Data_Translator::deduce_field_from_query_param(
431
+				Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key),
432
+				$model
433
+			);
434
+			if ($field instanceof \EE_Model_Field_Base) {
435
+				//did they specify an operator?
436
+				if (is_array($query_param_value)) {
437
+					$op = $query_param_value[0];
438
+					$translated_value = array($op);
439
+					if (isset($query_param_value[1])) {
440
+						$value = $query_param_value[1];
441
+						$translated_value[1] = Model_Data_Translator::prepare_field_values_for_json($field, $value,
442
+							$requested_version);
443
+					}
444
+				} else {
445
+					$translated_value = Model_Data_Translator::prepare_field_value_for_json($field, $query_param_value,
446
+						$requested_version);
447
+				}
448
+				$query_param_for_models[$query_param_key] = $translated_value;
449
+			} else {
450
+				//so it's not for a field, assume it's a logic query param key
451
+				$query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api($query_param_value,
452
+					$model, $requested_version);
453
+			}
454
+		}
455
+		return $query_param_for_models;
456
+	}
457
+
458
+
459
+
460
+	/**
461
+	 * @param $condition_query_param_key
462
+	 * @return string
463
+	 */
464
+	public static function remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key)
465
+	{
466
+		$pos_of_star = strpos($condition_query_param_key, '*');
467
+		if ($pos_of_star === false) {
468
+			return $condition_query_param_key;
469
+		} else {
470
+			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
471
+			return $condition_query_param_sans_star;
472
+		}
473
+	}
474
+
475
+
476
+
477
+	/**
478
+	 * Takes the input parameter and finds the model field that it indicates.
479
+	 *
480
+	 * @param string    $query_param_name like Registration.Transaction.TXN_ID, Event.Datetime.start_time, or REG_ID
481
+	 * @param \EEM_Base $model
482
+	 * @return \EE_Model_Field_Base
483
+	 * @throws \EE_Error
484
+	 */
485
+	public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model)
486
+	{
487
+		//ok, now proceed with deducing which part is the model's name, and which is the field's name
488
+		//which will help us find the database table and column
489
+		$query_param_parts = explode('.', $query_param_name);
490
+		if (empty($query_param_parts)) {
491
+			throw new \EE_Error(sprintf(__('_extract_column_name is empty when trying to extract column and table name from %s',
492
+				'event_espresso'), $query_param_name));
493
+		}
494
+		$number_of_parts = count($query_param_parts);
495
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
496
+		if ($number_of_parts === 1) {
497
+			$field_name = $last_query_param_part;
498
+		} else {// $number_of_parts >= 2
499
+			//the last part is the column name, and there are only 2parts. therefore...
500
+			$field_name = $last_query_param_part;
501
+			$model = \EE_Registry::instance()->load_model($query_param_parts[$number_of_parts - 2]);
502
+		}
503
+		try {
504
+			return $model->field_settings_for($field_name);
505
+		} catch (\EE_Error $e) {
506
+			return null;
507
+		}
508
+	}
509 509
 
510 510
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
                     '0',
149 149
                     STR_PAD_LEFT
150 150
                 );
151
-            $new_value = rest_parse_date($original_value . $offset_sign . $offset_string);
151
+            $new_value = rest_parse_date($original_value.$offset_sign.$offset_string);
152 152
         } else {
153 153
             $new_value = $original_value;
154 154
         }
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
      */
166 166
     private static function parse_timezone_offset($timezone_offset)
167 167
     {
168
-        $first_char = substr((string)$timezone_offset, 0, 1);
168
+        $first_char = substr((string) $timezone_offset, 0, 1);
169 169
         if ($first_char === '+' || $first_char === '-') {
170 170
             $offset_sign = $first_char;
171
-            $offset_secs = substr((string)$timezone_offset, 1);
171
+            $offset_secs = substr((string) $timezone_offset, 1);
172 172
         } else {
173 173
             $offset_sign = '+';
174 174
             $offset_secs = $timezone_offset;
Please login to merge, or discard this patch.
core/admin/EE_Admin.core.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 
168 168
 
169 169
 	/**
170
-	* init- should fire after shortcode, module,  addon, other plugin (default priority), and even EE_Front_Controller's init phases have run
171
-	*
172
-	* @access public
173
-	* @return void
174
-	*/
170
+	 * init- should fire after shortcode, module,  addon, other plugin (default priority), and even EE_Front_Controller's init phases have run
171
+	 *
172
+	 * @access public
173
+	 * @return void
174
+	 */
175 175
 	public function init() {
176 176
 		//only enable most of the EE_Admin IF we're not in full maintenance mode
177 177
 		if ( EE_Maintenance_Mode::instance()->models_can_query() ){
@@ -456,11 +456,11 @@  discard block
 block discarded – undo
456 456
 
457 457
 
458 458
 	/**
459
-	* admin_init
460
-	*
461
-	* @access public
462
-	* @return void
463
-	*/
459
+	 * admin_init
460
+	 *
461
+	 * @access public
462
+	 * @return void
463
+	 */
464 464
 	public function admin_init() {
465 465
 
466 466
 		/**
@@ -612,24 +612,24 @@  discard block
 block discarded – undo
612 612
 
613 613
 
614 614
 	/**
615
-	* 	dismiss_persistent_admin_notice
616
-	*
617
-	*	@access 	public
618
-	* 	@return 		void
619
-	*/
615
+	 * 	dismiss_persistent_admin_notice
616
+	 *
617
+	 *	@access 	public
618
+	 * 	@return 		void
619
+	 */
620 620
 	public function dismiss_ee_nag_notice_callback() {
621 621
 		EE_Error::dismiss_persistent_admin_notice();
622 622
 	}
623 623
 
624 624
 
625 625
 
626
-    /**
627
-     * @param array $elements
628
-     * @return array
629
-     * @throws \EE_Error
630
-     */
626
+	/**
627
+	 * @param array $elements
628
+	 * @return array
629
+	 * @throws \EE_Error
630
+	 */
631 631
 	public function dashboard_glance_items($elements) {
632
-        $elements = is_array($elements) ? $elements : array($elements);
632
+		$elements = is_array($elements) ? $elements : array($elements);
633 633
 		$events = EEM_Event::instance()->count();
634 634
 		$items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') );
635 635
 		$items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) );
Please login to merge, or discard this patch.
Spacing   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public static function instance() {
42 42
 		// check if class object is instantiated
43
-		if (  ! self::$_instance instanceof EE_Admin ) {
43
+		if ( ! self::$_instance instanceof EE_Admin) {
44 44
 			self::$_instance = new self();
45 45
 		}
46 46
 		return self::$_instance;
@@ -57,30 +57,30 @@  discard block
 block discarded – undo
57 57
 		// define global EE_Admin constants
58 58
 		$this->_define_all_constants();
59 59
 		// set autoloaders for our admin page classes based on included path information
60
-		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_ADMIN );
60
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
61 61
 		// admin hooks
62
-		add_filter( 'plugin_action_links', array( $this, 'filter_plugin_actions' ), 10, 2 );
62
+		add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
63 63
 		// load EE_Request_Handler early
64
-		add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'get_request' ));
65
-		add_action( 'AHEE__EE_System__initialize_last', array( $this, 'init' ));
64
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
65
+		add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
66 66
 		// post shortcode tracking
67 67
 		add_action(
68 68
 			'AHEE__EE_System__initialize_last',
69
-			array( 'EventEspresso\core\admin\PostShortcodeTracking', 'set_hooks_admin' )
69
+			array('EventEspresso\core\admin\PostShortcodeTracking', 'set_hooks_admin')
70 70
 		);
71
-		add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'route_admin_request' ), 100, 2 );
72
-		add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 100 );
73
-		add_action( 'admin_init', array( $this, 'admin_init' ), 100 );
74
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ), 20 );
75
-		add_action( 'admin_notices', array( $this, 'display_admin_notices' ), 10 );
76
-		add_action( 'network_admin_notices', array( $this, 'display_admin_notices' ), 10 );
77
-		add_filter( 'pre_update_option', array( $this, 'check_for_invalid_datetime_formats' ), 100, 2 );
78
-		add_filter('admin_footer_text', array( $this, 'espresso_admin_footer' ));
71
+		add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
72
+		add_action('wp_loaded', array($this, 'wp_loaded'), 100);
73
+		add_action('admin_init', array($this, 'admin_init'), 100);
74
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
75
+		add_action('admin_notices', array($this, 'display_admin_notices'), 10);
76
+		add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
77
+		add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
78
+		add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
79 79
 
80 80
 		//reset Environment config (we only do this on admin page loads);
81 81
 		EE_Registry::instance()->CFG->environment->recheck_values();
82 82
 
83
-		do_action( 'AHEE__EE_Admin__loaded' );
83
+		do_action('AHEE__EE_Admin__loaded');
84 84
 	}
85 85
 
86 86
 
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 	 * @return void
96 96
 	 */
97 97
 	private function _define_all_constants() {
98
-		define( 'EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/' );
99
-		define( 'EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/' );
100
-		define( 'EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS );
101
-		define( 'WP_ADMIN_PATH', ABSPATH . 'wp-admin/' );
102
-		define( 'WP_AJAX_URL', admin_url( 'admin-ajax.php' ));
98
+		define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/');
99
+		define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/');
100
+		define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS);
101
+		define('WP_ADMIN_PATH', ABSPATH.'wp-admin/');
102
+		define('WP_AJAX_URL', admin_url('admin-ajax.php'));
103 103
 	}
104 104
 
105 105
 
@@ -112,23 +112,23 @@  discard block
 block discarded – undo
112 112
 	 * @param 	string 	$plugin
113 113
 	 * @return 	array
114 114
 	 */
115
-	public function filter_plugin_actions( $links, $plugin ) {
115
+	public function filter_plugin_actions($links, $plugin) {
116 116
 		// set $main_file in stone
117 117
 		static $main_file;
118 118
 		// if $main_file is not set yet
119
-		if ( ! $main_file ) {
120
-			$main_file = plugin_basename( EVENT_ESPRESSO_MAIN_FILE );
119
+		if ( ! $main_file) {
120
+			$main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
121 121
 		}
122
-		 if ( $plugin === $main_file ) {
122
+		 if ($plugin === $main_file) {
123 123
 		 	// compare current plugin to this one
124
-			if ( EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance ) {
125
-				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode.  Click this link to learn why.">' . __('Maintenance Mode Active', 'event_espresso' ) . '</a>';
126
-				array_unshift( $links, $maintenance_link );
124
+			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
125
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode.  Click this link to learn why.">'.__('Maintenance Mode Active', 'event_espresso').'</a>';
126
+				array_unshift($links, $maintenance_link);
127 127
 			} else {
128
-				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __( 'Settings', 'event_espresso' ) . '</a>';
129
-				$events_link = '<a href="admin.php?page=espresso_events">' . __( 'Events', 'event_espresso' ) . '</a>';
128
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings', 'event_espresso').'</a>';
129
+				$events_link = '<a href="admin.php?page=espresso_events">'.__('Events', 'event_espresso').'</a>';
130 130
 				// add before other links
131
-				array_unshift( $links, $org_settings_link, $events_link );
131
+				array_unshift($links, $org_settings_link, $events_link);
132 132
 			}
133 133
 		}
134 134
 		return $links;
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
 	 *	@return void
144 144
 	 */
145 145
 	public function get_request() {
146
-		EE_Registry::instance()->load_core( 'Request_Handler' );
147
-		EE_Registry::instance()->load_core( 'CPT_Strategy' );
146
+		EE_Registry::instance()->load_core('Request_Handler');
147
+		EE_Registry::instance()->load_core('CPT_Strategy');
148 148
 	}
149 149
 
150 150
 
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
 	 * @param array $admin_page_folder_names
157 157
 	 * @return array
158 158
 	 */
159
-	public function hide_admin_pages_except_maintenance_mode( $admin_page_folder_names = array() ){
159
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) {
160 160
 		return array(
161
-			'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
162
-			'about' => EE_ADMIN_PAGES . 'about' . DS,
163
-			'support' => EE_ADMIN_PAGES . 'support' . DS
161
+			'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS,
162
+			'about' => EE_ADMIN_PAGES.'about'.DS,
163
+			'support' => EE_ADMIN_PAGES.'support'.DS
164 164
 		);
165 165
 	}
166 166
 
@@ -174,31 +174,31 @@  discard block
 block discarded – undo
174 174
 	*/
175 175
 	public function init() {
176 176
 		//only enable most of the EE_Admin IF we're not in full maintenance mode
177
-		if ( EE_Maintenance_Mode::instance()->models_can_query() ){
177
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
178 178
 			//ok so we want to enable the entire admin
179
-			add_action( 'wp_ajax_dismiss_ee_nag_notice', array( $this, 'dismiss_ee_nag_notice_callback' ));
180
-			add_action( 'admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 );
181
-			add_action( 'network_admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 );
179
+			add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback'));
180
+			add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9);
181
+			add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9);
182 182
 			//at a glance dashboard widget
183
-			add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items' ), 10 );
183
+			add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
184 184
 			//filter for get_edit_post_link used on comments for custom post types
185
-			add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link' ), 10, 2 );
185
+			add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
186 186
 		}
187 187
 		// run the admin page factory but ONLY if we are doing an ee admin ajax request
188
-		if ( !defined('DOING_AJAX') || EE_ADMIN_AJAX ) {
188
+		if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
189 189
 			try {
190 190
 				//this loads the controller for the admin pages which will setup routing etc
191
-				EE_Registry::instance()->load_core( 'Admin_Page_Loader' );
192
-			} catch ( EE_Error $e ) {
191
+				EE_Registry::instance()->load_core('Admin_Page_Loader');
192
+			} catch (EE_Error $e) {
193 193
 				$e->get_error();
194 194
 			}
195 195
 		}
196
-		add_filter( 'content_save_pre', array( $this, 'its_eSpresso' ), 10, 1 );
196
+		add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
197 197
 		//make sure our CPTs and custom taxonomy metaboxes get shown for first time users
198
-		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes' ), 10 );
199
-		add_action('admin_head', array( $this, 'register_custom_nav_menu_boxes' ), 10 );
198
+		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
199
+		add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
200 200
 		//exclude EE critical pages from all nav menus and wp_list_pages
201
-		add_filter('nav_menu_meta_box_object', array( $this, 'remove_pages_from_nav_menu'), 10 );
201
+		add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
202 202
 	}
203 203
 
204 204
 
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 	 * @param  object $post_type WP post type object
212 212
 	 * @return object            WP post type object
213 213
 	 */
214
-	public function remove_pages_from_nav_menu( $post_type ) {
214
+	public function remove_pages_from_nav_menu($post_type) {
215 215
 		//if this isn't the "pages" post type let's get out
216
-		if ( $post_type->name !== 'page' ) {
216
+		if ($post_type->name !== 'page') {
217 217
 			return $post_type;
218 218
 		}
219 219
 		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
@@ -233,28 +233,28 @@  discard block
 block discarded – undo
233 233
 	 */
234 234
 	public function enable_hidden_ee_nav_menu_metaboxes() {
235 235
 		global $wp_meta_boxes, $pagenow;
236
-		if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php' ) {
236
+		if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
237 237
 			return;
238 238
 		}
239 239
 		$user = wp_get_current_user();
240 240
 		//has this been done yet?
241
-		if ( get_user_option( 'ee_nav_menu_initialized', $user->ID ) ) {
241
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
242 242
 			return;
243 243
 		}
244 244
 
245
-		$hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus', $user->ID );
246
-		$initial_meta_boxes = apply_filters( 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array( 'nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page' ) );
245
+		$hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID);
246
+		$initial_meta_boxes = apply_filters('FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array('nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page'));
247 247
 
248
-		if ( is_array( $hidden_meta_boxes ) ) {
249
-			foreach ( $hidden_meta_boxes as $key => $meta_box_id ) {
250
-				if ( in_array( $meta_box_id, $initial_meta_boxes ) ) {
251
-					unset( $hidden_meta_boxes[ $key ] );
248
+		if (is_array($hidden_meta_boxes)) {
249
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
250
+				if (in_array($meta_box_id, $initial_meta_boxes)) {
251
+					unset($hidden_meta_boxes[$key]);
252 252
 				}
253 253
 			}
254 254
 		}
255 255
 
256
-		update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
257
-		update_user_option( $user->ID, 'ee_nav_menu_initialized', 1, true );
256
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
257
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
258 258
 	}
259 259
 
260 260
 
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 * @return void
274 274
 	 */
275 275
 	public function register_custom_nav_menu_boxes() {
276
-		add_meta_box( 'add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array( $this, 'ee_cpt_archive_pages' ), 'nav-menus', 'side', 'core' );
276
+		add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core');
277 277
 	}
278 278
 
279 279
 
@@ -289,16 +289,16 @@  discard block
 block discarded – undo
289 289
 	 *
290 290
 	 * @return string  the (maybe) modified link
291 291
 	 */
292
-	public function modify_edit_post_link( $link, $id ) {
293
-		if ( ! $post = get_post( $id ) ){
292
+	public function modify_edit_post_link($link, $id) {
293
+		if ( ! $post = get_post($id)) {
294 294
 			return $link;
295 295
 		}
296
-		if ( $post->post_type === 'espresso_attendees' ) {
296
+		if ($post->post_type === 'espresso_attendees') {
297 297
 			$query_args = array(
298 298
 				'action' => 'edit_attendee',
299 299
 				'post' => $id
300 300
 			);
301
-			return EEH_URL::add_query_args_and_nonce( $query_args, admin_url('admin.php?page=espresso_registrations') );
301
+			return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations'));
302 302
 		}
303 303
 		return $link;
304 304
 	}
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 		global $nav_menu_selected_id;
311 311
 
312 312
 		$db_fields = false;
313
-		$walker = new Walker_Nav_Menu_Checklist( $db_fields );
313
+		$walker = new Walker_Nav_Menu_Checklist($db_fields);
314 314
 		$current_tab = 'event-archives';
315 315
 
316 316
 		/*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
@@ -329,9 +329,9 @@  discard block
 block discarded – undo
329 329
 		?>
330 330
 		<div id="posttype-extra-nav-menu-pages" class="posttypediv">
331 331
 			<ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
332
-				<li <?php echo ( 'event-archives' === $current_tab ? ' class="tabs"' : '' ); ?>>
333
-					<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args)));} ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
334
-						<?php _e( 'Event Archive Pages', 'event_espresso' ); ?>
332
+				<li <?php echo ('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>>
333
+					<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ($nav_menu_selected_id) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
334
+						<?php _e('Event Archive Pages', 'event_espresso'); ?>
335 335
 					</a>
336 336
 				</li>
337 337
 			<?php /* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs.
@@ -349,13 +349,13 @@  discard block
 block discarded – undo
349 349
  			<?php */ ?>
350 350
 
351 351
 			<div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php
352
-			echo ( 'event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
352
+			echo ('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
353 353
 			?>">
354 354
 				<ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">
355 355
 					<?php
356 356
 					$pages = $this->_get_extra_nav_menu_pages_items();
357 357
 					$args['walker'] = $walker;
358
-					echo walk_nav_menu_tree( array_map( array( $this, '_setup_extra_nav_menu_pages_items' ), $pages), 0, (object) $args );
358
+					echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args);
359 359
 					?>
360 360
 				</ul>
361 361
 			</div><!-- /.tabs-panel -->
@@ -363,18 +363,18 @@  discard block
 block discarded – undo
363 363
 			<p class="button-controls">
364 364
 				<span class="list-controls">
365 365
 					<a href="<?php
366
-						echo esc_url( add_query_arg(
366
+						echo esc_url(add_query_arg(
367 367
 							array(
368 368
 								'extra-nav-menu-pages-tab' => 'event-archives',
369 369
 								'selectall' => 1,
370 370
 							),
371
-							remove_query_arg( $removed_args )
371
+							remove_query_arg($removed_args)
372 372
 						));
373 373
 					?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a>
374 374
 				</span>
375 375
 
376 376
 				<span class="add-to-menu">
377
-					<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( __( 'Add to Menu' ) ); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e( 'submit-posttype-extra-nav-menu-pages' ); ?>" />
377
+					<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e(__('Add to Menu')); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e('submit-posttype-extra-nav-menu-pages'); ?>" />
378 378
 					<span class="spinner"></span>
379 379
 				</span>
380 380
 			</p>
@@ -395,10 +395,10 @@  discard block
 block discarded – undo
395 395
 	private function _get_extra_nav_menu_pages_items() {
396 396
 		$menuitems[] = array(
397 397
 			'title' => __('Event List', 'event_espresso'),
398
-			'url' => get_post_type_archive_link( 'espresso_events' ),
398
+			'url' => get_post_type_archive_link('espresso_events'),
399 399
 			'description' => __('Archive page for all events.', 'event_espresso')
400 400
 		);
401
-		return apply_filters( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems );
401
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
402 402
 	}
403 403
 
404 404
 
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 * @param $menu_item_values
411 411
 	 * @return stdClass
412 412
 	 */
413
-	private function _setup_extra_nav_menu_pages_items( $menu_item_values ) {
413
+	private function _setup_extra_nav_menu_pages_items($menu_item_values) {
414 414
 		$menu_item = new stdClass();
415 415
 		$keys = array(
416 416
 			'ID' => 0,
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
 			'xfn' => ''
431 431
 		);
432 432
 
433
-		foreach ( $keys as $key => $value) {
434
-			$menu_item->{$key} = isset( $menu_item_values[ $key]) ? $menu_item_values[ $key] : $value;
433
+		foreach ($keys as $key => $value) {
434
+			$menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
435 435
 		}
436 436
 		return $menu_item;
437 437
 	}
@@ -470,9 +470,9 @@  discard block
 block discarded – undo
470 470
 		 * - check if doing post processing of one of EE CPTs
471 471
 		 * - instantiate the corresponding EE CPT model for the post_type being processed.
472 472
 		 */
473
-		if ( isset( $_POST['action'], $_POST['post_type'] ) && $_POST['action'] === 'editpost' ) {
474
-			EE_Registry::instance()->load_core( 'Register_CPTs' );
475
-			EE_Register_CPTs::instantiate_cpt_models( $_POST['post_type'] );
473
+		if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
474
+			EE_Registry::instance()->load_core('Register_CPTs');
475
+			EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']);
476 476
 		}
477 477
 
478 478
 
@@ -481,8 +481,8 @@  discard block
 block discarded – undo
481 481
 		 * 'options-reading.php' core WordPress admin settings page.  This is for user-proofing.
482 482
 		 */
483 483
 		global $pagenow;
484
-		if ( $pagenow === 'options-reading.php' ) {
485
-			add_filter( 'wp_dropdown_pages', array( $this, 'modify_dropdown_pages' ) );
484
+		if ($pagenow === 'options-reading.php') {
485
+			add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
486 486
 		}
487 487
 
488 488
 	}
@@ -494,25 +494,25 @@  discard block
 block discarded – undo
494 494
 	 * @param string $output  Current output.
495 495
 	 * @return string
496 496
 	 */
497
-	public function modify_dropdown_pages( $output ) {
497
+	public function modify_dropdown_pages($output) {
498 498
 		//get critical pages
499 499
 		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
500 500
 
501 501
 		//split current output by line break for easier parsing.
502
-		$split_output = explode( "\n", $output );
502
+		$split_output = explode("\n", $output);
503 503
 
504 504
 		//loop through to remove any critical pages from the array.
505
-		foreach ( $critical_pages as $page_id ) {
506
-			$needle = 'value="' . $page_id . '"';
507
-			foreach( $split_output as $key => $haystack ) {
508
-				if( strpos( $haystack, $needle ) !== false ) {
509
-					unset( $split_output[$key] );
505
+		foreach ($critical_pages as $page_id) {
506
+			$needle = 'value="'.$page_id.'"';
507
+			foreach ($split_output as $key => $haystack) {
508
+				if (strpos($haystack, $needle) !== false) {
509
+					unset($split_output[$key]);
510 510
 				}
511 511
 			}
512 512
 		}
513 513
 
514 514
 		//replace output with the new contents
515
-		return implode( "\n", $split_output );
515
+		return implode("\n", $split_output);
516 516
 	}
517 517
 
518 518
 
@@ -526,36 +526,36 @@  discard block
 block discarded – undo
526 526
 	public function enqueue_admin_scripts() {
527 527
 		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
528 528
 		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script calls.
529
-		wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
529
+		wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
530 530
 		// register cookie script for future dependencies
531
-		wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE );
531
+		wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE);
532 532
 		// jquery_validate loading is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via:  add_filter( 'FHEE_load_jquery_validate', '__return_true' );
533
-		if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) {
533
+		if (apply_filters('FHEE_load_jquery_validate', FALSE)) {
534 534
 			// register jQuery Validate
535
-			wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE);
535
+			wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE);
536 536
 		}
537 537
 		//joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again vai: add_filter('FHEE_load_joyride', '__return_true' );
538
-		if ( apply_filters( 'FHEE_load_joyride', FALSE ) ) {
538
+		if (apply_filters('FHEE_load_joyride', FALSE)) {
539 539
 			//joyride style
540
-			wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
541
-			wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION );
542
-			wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1', TRUE );
540
+			wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1');
541
+			wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION);
542
+			wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1', TRUE);
543 543
 			//joyride JS
544
-			wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE );
544
+			wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE);
545 545
 			// wanna go for a joyride?
546 546
 			wp_enqueue_style('ee-joyride-css');
547 547
 			wp_enqueue_script('jquery-joyride');
548 548
 		}
549 549
 		//qtip is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtips', '__return_true' );
550
-		if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) {
550
+		if (apply_filters('FHEE_load_qtip', FALSE)) {
551 551
 			EEH_Qtip_Loader::instance()->register_and_enqueue();
552 552
 		}
553 553
 		//accounting.js library
554 554
 		// @link http://josscrowcroft.github.io/accounting.js/
555
-		if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) {
556
-			wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE );
557
-			wp_register_script( 'ee-accounting-core', EE_THIRD_PARTY_URL . 'accounting/accounting.js', array('underscore'), '0.3.2', TRUE );
558
-			wp_enqueue_script( 'ee-accounting' );
555
+		if (apply_filters('FHEE_load_accounting_js', FALSE)) {
556
+			wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE);
557
+			wp_register_script('ee-accounting-core', EE_THIRD_PARTY_URL.'accounting/accounting.js', array('underscore'), '0.3.2', TRUE);
558
+			wp_enqueue_script('ee-accounting');
559 559
 			// array of settings to get converted to JSON array via wp_localize_script
560 560
 			$currency_config = array(
561 561
 				'currency' => array(
@@ -602,11 +602,11 @@  discard block
 block discarded – undo
602 602
 	public function get_persistent_admin_notices() {
603 603
 		// http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30
604 604
 		$args = array(
605
-			'page' => EE_Registry::instance()->REQ->is_set( 'page' ) ? EE_Registry::instance()->REQ->get( 'page' ) : '',
606
-			'action' => EE_Registry::instance()->REQ->is_set( 'action' ) ? EE_Registry::instance()->REQ->get( 'action' ) : '',
605
+			'page' => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '',
606
+			'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '',
607 607
 		);
608
-		$return_url = EE_Admin_Page::add_query_args_and_nonce( $args, EE_ADMIN_URL );
609
-		echo EE_Error::get_persistent_admin_notices( $return_url );
608
+		$return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL);
609
+		echo EE_Error::get_persistent_admin_notices($return_url);
610 610
 	}
611 611
 
612 612
 
@@ -631,24 +631,24 @@  discard block
 block discarded – undo
631 631
 	public function dashboard_glance_items($elements) {
632 632
         $elements = is_array($elements) ? $elements : array($elements);
633 633
 		$events = EEM_Event::instance()->count();
634
-		$items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') );
635
-		$items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) );
634
+		$items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'), admin_url('admin.php'));
635
+		$items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events));
636 636
 		$items['events']['title'] = __('Click to view all Events', 'event_espresso');
637 637
 		$registrations = EEM_Registration::instance()->count(
638 638
 			array(
639 639
 				array(
640
-					'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete )
640
+					'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)
641 641
 				)
642 642
 			)
643 643
 		);
644
-		$items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_registrations' ), admin_url('admin.php') );
645
-		$items['registrations']['text'] = sprintf( _n( '%s Registration', '%s Registrations', $registrations ), number_format_i18n($registrations) );
644
+		$items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'), admin_url('admin.php'));
645
+		$items['registrations']['text'] = sprintf(_n('%s Registration', '%s Registrations', $registrations), number_format_i18n($registrations));
646 646
 		$items['registrations']['title'] = __('Click to view all registrations', 'event_espresso');
647 647
 
648
-		$items = (array) apply_filters( 'FHEE__EE_Admin__dashboard_glance_items__items', $items );
648
+		$items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
649 649
 
650
-		foreach ( $items as $type => $item_properties ) {
651
-			$elements[] = sprintf( '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text'] );
650
+		foreach ($items as $type => $item_properties) {
651
+			$elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text']);
652 652
 		}
653 653
 		return $elements;
654 654
 	}
@@ -665,31 +665,31 @@  discard block
 block discarded – undo
665 665
 	 * @throws EE_Error
666 666
 	 * @return    string
667 667
 	 */
668
-	public function check_for_invalid_datetime_formats( $value, $option ) {
668
+	public function check_for_invalid_datetime_formats($value, $option) {
669 669
 		// check for date_format or time_format
670
-		switch ( $option ) {
670
+		switch ($option) {
671 671
 			case 'date_format' :
672
-				$date_time_format = $value . ' ' . get_option('time_format');
672
+				$date_time_format = $value.' '.get_option('time_format');
673 673
 				break;
674 674
 			case 'time_format' :
675
-				$date_time_format = get_option('date_format') . ' ' . $value;
675
+				$date_time_format = get_option('date_format').' '.$value;
676 676
 				break;
677 677
 			default :
678 678
 				$date_time_format = FALSE;
679 679
 		}
680 680
 		// do we have a date_time format to check ?
681
-		if ( $date_time_format ) {
682
-			$error_msg = EEH_DTT_Helper::validate_format_string( $date_time_format );
681
+		if ($date_time_format) {
682
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
683 683
 
684
-			if ( is_array( $error_msg ) ) {
685
-				$msg = '<p>' . sprintf( __( 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso' ), date( $date_time_format ) , $date_time_format  ) . '</p><p><ul>';
684
+			if (is_array($error_msg)) {
685
+				$msg = '<p>'.sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso'), date($date_time_format), $date_time_format).'</p><p><ul>';
686 686
 
687 687
 
688
-				foreach ( $error_msg as $error ) {
689
-					$msg .= '<li>' . $error . '</li>';
688
+				foreach ($error_msg as $error) {
689
+					$msg .= '<li>'.$error.'</li>';
690 690
 				}
691 691
 
692
-				$msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>';
692
+				$msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>';
693 693
 
694 694
 				// trigger WP settings error
695 695
 				add_settings_error(
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 				);
700 700
 
701 701
 				// set format to something valid
702
-				switch ( $option ) {
702
+				switch ($option) {
703 703
 					case 'date_format' :
704 704
 						$value = 'F j, Y';
705 705
 						break;
@@ -721,8 +721,8 @@  discard block
 block discarded – undo
721 721
 	 * @param $content
722 722
 	 * @return    string
723 723
 	 */
724
-	public function its_eSpresso( $content ) {
725
-		return str_replace( '[EXPRESSO_', '[ESPRESSO_', $content );
724
+	public function its_eSpresso($content) {
725
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
726 726
 	}
727 727
 
728 728
 
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 	 *  @return 	string
735 735
 	 */
736 736
 	public function espresso_admin_footer() {
737
-		return \EEH_Template::powered_by_event_espresso( 'aln-cntr', '', array( 'utm_content' => 'admin_footer' ));
737
+		return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
738 738
 	}
739 739
 
740 740
 
@@ -753,12 +753,12 @@  discard block
 block discarded – undo
753 753
 	 * @param array $config
754 754
 	 * @return void
755 755
 	 */
756
-	public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) {
757
-		EE_Error::doing_it_wrong( __METHOD__, sprintf( __('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3' );
758
-		if ( class_exists( 'EE_Register_Admin_Page' ) ) {
756
+	public static function register_ee_admin_page($page_basename, $page_path, $config = array()) {
757
+		EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3');
758
+		if (class_exists('EE_Register_Admin_Page')) {
759 759
 			$config['page_path'] = $page_path;
760 760
 		}
761
-		EE_Register_Admin_Page::register( $page_basename, $config );
761
+		EE_Register_Admin_Page::register($page_basename, $config);
762 762
 
763 763
 	}
764 764
 
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 	 * @param  \WP_Post $post
772 772
 	 * @return void
773 773
 	 */
774
-	public static function parse_post_content_on_save( $post_ID, $post ) {
774
+	public static function parse_post_content_on_save($post_ID, $post) {
775 775
 		EE_Error::doing_it_wrong(
776 776
 			__METHOD__,
777 777
 			__(
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 			),
781 781
 			'4.8.41'
782 782
 		);
783
-		EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save( $post_ID, $post );
783
+		EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save($post_ID, $post);
784 784
 	}
785 785
 
786 786
 
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 	 * @param  $value
794 794
 	 * @return void
795 795
 	 */
796
-	public function reset_page_for_posts_on_change( $option, $old_value, $value ) {
796
+	public function reset_page_for_posts_on_change($option, $old_value, $value) {
797 797
 		EE_Error::doing_it_wrong(
798 798
 			__METHOD__,
799 799
 			__(
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
 			),
803 803
 			'4.8.41'
804 804
 		);
805
-		EventEspresso\core\admin\PostShortcodeTracking::reset_page_for_posts_on_change( $option, $old_value, $value );
805
+		EventEspresso\core\admin\PostShortcodeTracking::reset_page_for_posts_on_change($option, $old_value, $value);
806 806
 	}
807 807
 
808 808
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Field_With_Model_Name.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
      * Returns the name of the model(s) pointed to
36 36
      *
37 37
      * @deprecated since version 4.6.7
38
-     * @return mixed string or array of strings
38
+     * @return string string or array of strings
39 39
      */
40 40
     function get_model_name_pointed_to()
41 41
     {
Please login to merge, or discard this patch.
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -8,83 +8,83 @@
 block discarded – undo
8 8
  */
9 9
 abstract class EE_Field_With_Model_Name extends EE_Model_Field_Base
10 10
 {
11
-    /**
12
-     * Usually the name of a single model. However, as in the case for custom post types,
13
-     * it can actually be an array of models
14
-     *
15
-     * @var string or array
16
-     */
17
-    protected $_model_name_pointed_to;
11
+	/**
12
+	 * Usually the name of a single model. However, as in the case for custom post types,
13
+	 * it can actually be an array of models
14
+	 *
15
+	 * @var string or array
16
+	 */
17
+	protected $_model_name_pointed_to;
18 18
 
19
-    /**
20
-     * @param string  $table_column  name fo column for field
21
-     * @param string  $nicename      should eb internationalized with __('blah','event_espresso')
22
-     * @param boolean $nullable
23
-     * @param mixed   $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul
24
-     *                               dbe a string
25
-     * @param string  $model_name    eg 'Event','Answer','Term', etc. Basically its the model class's name without the
26
-     *                               "EEM_"
27
-     */
28
-    function __construct($table_column, $nicename, $nullable, $default_value, $model_name)
29
-    {
30
-        $this->_model_name_pointed_to = $model_name;
31
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
32
-    }
19
+	/**
20
+	 * @param string  $table_column  name fo column for field
21
+	 * @param string  $nicename      should eb internationalized with __('blah','event_espresso')
22
+	 * @param boolean $nullable
23
+	 * @param mixed   $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul
24
+	 *                               dbe a string
25
+	 * @param string  $model_name    eg 'Event','Answer','Term', etc. Basically its the model class's name without the
26
+	 *                               "EEM_"
27
+	 */
28
+	function __construct($table_column, $nicename, $nullable, $default_value, $model_name)
29
+	{
30
+		$this->_model_name_pointed_to = $model_name;
31
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
32
+	}
33 33
 
34
-    /**
35
-     * Returns the name of the model(s) pointed to
36
-     *
37
-     * @deprecated since version 4.6.7
38
-     * @return mixed string or array of strings
39
-     */
40
-    function get_model_name_pointed_to()
41
-    {
42
-        EE_Error::doing_it_wrong('get_model_name_pointed_to',
43
-            __('This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array',
44
-                'event_espresso'), '4.6.7');
45
-        return $this->_model_name_pointed_to;
46
-    }
34
+	/**
35
+	 * Returns the name of the model(s) pointed to
36
+	 *
37
+	 * @deprecated since version 4.6.7
38
+	 * @return mixed string or array of strings
39
+	 */
40
+	function get_model_name_pointed_to()
41
+	{
42
+		EE_Error::doing_it_wrong('get_model_name_pointed_to',
43
+			__('This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array',
44
+				'event_espresso'), '4.6.7');
45
+		return $this->_model_name_pointed_to;
46
+	}
47 47
 
48
-    /**
49
-     * Gets the model names pointed to by this field, always as an array
50
-     * (even if there's only one)
51
-     *
52
-     * @return array of model names pointed to by this field
53
-     */
54
-    function get_model_names_pointed_to()
55
-    {
56
-        if (is_array($this->_model_name_pointed_to)) {
57
-            return $this->_model_name_pointed_to;
58
-        } else {
59
-            return array($this->_model_name_pointed_to);
60
-        }
61
-    }
48
+	/**
49
+	 * Gets the model names pointed to by this field, always as an array
50
+	 * (even if there's only one)
51
+	 *
52
+	 * @return array of model names pointed to by this field
53
+	 */
54
+	function get_model_names_pointed_to()
55
+	{
56
+		if (is_array($this->_model_name_pointed_to)) {
57
+			return $this->_model_name_pointed_to;
58
+		} else {
59
+			return array($this->_model_name_pointed_to);
60
+		}
61
+	}
62 62
 
63
-    /**
64
-     * Returns the model's classname (eg EE_Event instead of just Event)
65
-     *
66
-     * @return array
67
-     */
68
-    function get_model_class_names_pointed_to()
69
-    {
70
-        $model_names = array();
71
-        if (is_array($this->_model_name_pointed_to)) {
72
-            foreach ($this->_model_name_pointed_to as $model_name) {
73
-                $model_names[] = "EE_" . $model_name;
74
-            }
75
-        } else {
76
-            $model_names = array("EE_" . $this->_model_name_pointed_to);
77
-        }
78
-        return $model_names;
79
-    }
63
+	/**
64
+	 * Returns the model's classname (eg EE_Event instead of just Event)
65
+	 *
66
+	 * @return array
67
+	 */
68
+	function get_model_class_names_pointed_to()
69
+	{
70
+		$model_names = array();
71
+		if (is_array($this->_model_name_pointed_to)) {
72
+			foreach ($this->_model_name_pointed_to as $model_name) {
73
+				$model_names[] = "EE_" . $model_name;
74
+			}
75
+		} else {
76
+			$model_names = array("EE_" . $this->_model_name_pointed_to);
77
+		}
78
+		return $model_names;
79
+	}
80 80
 
81
-    function is_model_obj_of_type_pointed_to($model_obj_or_ID)
82
-    {
83
-        foreach ($this->get_model_class_names_pointed_to() as $model_obj_classname) {
84
-            if ($model_obj_or_ID instanceof $model_obj_classname) {
85
-                return true;
86
-            }
87
-        }
88
-        return false;
89
-    }
81
+	function is_model_obj_of_type_pointed_to($model_obj_or_ID)
82
+	{
83
+		foreach ($this->get_model_class_names_pointed_to() as $model_obj_classname) {
84
+			if ($model_obj_or_ID instanceof $model_obj_classname) {
85
+				return true;
86
+			}
87
+		}
88
+		return false;
89
+	}
90 90
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,10 +70,10 @@
 block discarded – undo
70 70
         $model_names = array();
71 71
         if (is_array($this->_model_name_pointed_to)) {
72 72
             foreach ($this->_model_name_pointed_to as $model_name) {
73
-                $model_names[] = "EE_" . $model_name;
73
+                $model_names[] = "EE_".$model_name;
74 74
             }
75 75
         } else {
76
-            $model_names = array("EE_" . $this->_model_name_pointed_to);
76
+            $model_names = array("EE_".$this->_model_name_pointed_to);
77 77
         }
78 78
         return $model_names;
79 79
     }
Please login to merge, or discard this patch.