Completed
Branch BUG-10878-event-spaces-remaini... (62f9c8)
by
unknown
151:41 queued 139:39
created
core/db_classes/EE_Change_Log.class.php 2 patches
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -13,216 +13,216 @@
 block discarded – undo
13 13
 class EE_Change_Log extends EE_Base_Class
14 14
 {
15 15
 
16
-    /**
17
-     * @param array  $props_n_values          incoming values
18
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
19
-     *                                        used.)
20
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
21
-     *                                        date_format and the second value is the time format
22
-     * @return EE_Change_Log
23
-     * @throws EE_Error
24
-     */
25
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
26
-    {
27
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
28
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
29
-    }
30
-
31
-
32
-    /**
33
-     * @param array  $props_n_values  incoming values from the database
34
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
35
-     *                                the website will be used.
36
-     * @return EE_Change_Log
37
-     */
38
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
39
-    {
40
-        return new self($props_n_values, true, $timezone);
41
-    }
42
-
43
-    /**
44
-     * Gets message
45
-     *
46
-     * @return mixed
47
-     * @throws EE_Error
48
-     */
49
-    public function message()
50
-    {
51
-        return $this->get('LOG_message');
52
-    }
53
-
54
-    /**
55
-     * Sets message
56
-     *
57
-     * @param mixed $message
58
-     * @throws EE_Error
59
-     */
60
-    public function set_message($message)
61
-    {
62
-        $this->set('LOG_message', $message);
63
-    }
64
-
65
-    /**
66
-     * Gets time
67
-     *
68
-     * @return string
69
-     * @throws EE_Error
70
-     */
71
-    public function time()
72
-    {
73
-        return $this->get('LOG_time');
74
-    }
75
-
76
-    /**
77
-     * Sets time
78
-     *
79
-     * @param string $time
80
-     * @throws EE_Error
81
-     */
82
-    public function set_time($time)
83
-    {
84
-        $this->set('LOG_time', $time);
85
-    }
86
-
87
-    /**
88
-     * Gets log_type
89
-     *
90
-     * @return string
91
-     * @throws EE_Error
92
-     */
93
-    public function log_type()
94
-    {
95
-        return $this->get('LOG_type');
96
-    }
97
-
98
-
99
-    /**
100
-     * Return the localized log type label.
101
-     * @return string
102
-     * @throws EE_Error
103
-     */
104
-    public function log_type_label()
105
-    {
106
-        return EEM_Change_Log::get_pretty_label_for_type($this->log_type());
107
-    }
108
-
109
-    /**
110
-     * Sets log_type
111
-     *
112
-     * @param string $log_type
113
-     * @throws EE_Error
114
-     */
115
-    public function set_log_type($log_type)
116
-    {
117
-        $this->set('LOG_type', $log_type);
118
-    }
119
-
120
-    /**
121
-     * Gets type of the model object related to this log
122
-     *
123
-     * @return string
124
-     * @throws EE_Error
125
-     */
126
-    public function OBJ_type()
127
-    {
128
-        return $this->get('OBJ_type');
129
-    }
130
-
131
-    /**
132
-     * Sets type
133
-     *
134
-     * @param string $type
135
-     * @throws EE_Error
136
-     */
137
-    public function set_OBJ_type($type)
138
-    {
139
-        $this->set('OBJ_type', $type);
140
-    }
141
-
142
-    /**
143
-     * Gets OBJ_ID (the ID of the item related to this log)
144
-     *
145
-     * @return mixed
146
-     * @throws EE_Error
147
-     */
148
-    public function OBJ_ID()
149
-    {
150
-        return $this->get('OBJ_ID');
151
-    }
152
-
153
-    /**
154
-     * Sets OBJ_ID
155
-     *
156
-     * @param mixed $OBJ_ID
157
-     * @throws EE_Error
158
-     */
159
-    public function set_OBJ_ID($OBJ_ID)
160
-    {
161
-        $this->set('OBJ_ID', $OBJ_ID);
162
-    }
163
-
164
-    /**
165
-     * Gets wp_user
166
-     *
167
-     * @return int
168
-     * @throws EE_Error
169
-     */
170
-    public function wp_user()
171
-    {
172
-        return $this->get('LOG_wp_user');
173
-    }
174
-
175
-    /**
176
-     * Sets wp_user
177
-     *
178
-     * @param int $wp_user_id
179
-     * @throws EE_Error
180
-     */
181
-    public function set_wp_user($wp_user_id)
182
-    {
183
-        $this->set('LOG_wp_user', $wp_user_id);
184
-    }
185
-
186
-    /**
187
-     * Gets the model object attached to this log
188
-     *
189
-     * @return EE_Base_Class
190
-     * @throws EE_Error
191
-     */
192
-    public function object()
193
-    {
194
-        $model_name_of_related_obj = $this->OBJ_type();
195
-        $is_model_name             = EE_Registry::instance()->is_model_name($model_name_of_related_obj);
196
-        if (! $is_model_name) {
197
-            return null;
198
-        } else {
199
-            return $this->get_first_related($model_name_of_related_obj);
200
-        }
201
-    }
202
-
203
-    /**
204
-     * Shorthand for setting the OBJ_ID and OBJ_type. Slightly handier than using
205
-     * _add_relation_to because you don't have to specify what type of model you're
206
-     * associating it with
207
-     *
208
-     * @param EE_Base_Class $object
209
-     * @param boolean       $save
210
-     * @return bool if $save=true, NULL is $save=false
211
-     * @throws EE_Error
212
-     */
213
-    public function set_object($object, $save = true)
214
-    {
215
-        if ($object instanceof EE_Base_Class) {
216
-            $this->set_OBJ_type($object->get_model()->get_this_model_name());
217
-            $this->set_OBJ_ID($object->ID());
218
-        } else {
219
-            $this->set_OBJ_type(null);
220
-            $this->set_OBJ_ID(null);
221
-        }
222
-        if ($save) {
223
-            return $this->save();
224
-        } else {
225
-            return null;
226
-        }
227
-    }
16
+	/**
17
+	 * @param array  $props_n_values          incoming values
18
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
19
+	 *                                        used.)
20
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
21
+	 *                                        date_format and the second value is the time format
22
+	 * @return EE_Change_Log
23
+	 * @throws EE_Error
24
+	 */
25
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
26
+	{
27
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
28
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
29
+	}
30
+
31
+
32
+	/**
33
+	 * @param array  $props_n_values  incoming values from the database
34
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
35
+	 *                                the website will be used.
36
+	 * @return EE_Change_Log
37
+	 */
38
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
39
+	{
40
+		return new self($props_n_values, true, $timezone);
41
+	}
42
+
43
+	/**
44
+	 * Gets message
45
+	 *
46
+	 * @return mixed
47
+	 * @throws EE_Error
48
+	 */
49
+	public function message()
50
+	{
51
+		return $this->get('LOG_message');
52
+	}
53
+
54
+	/**
55
+	 * Sets message
56
+	 *
57
+	 * @param mixed $message
58
+	 * @throws EE_Error
59
+	 */
60
+	public function set_message($message)
61
+	{
62
+		$this->set('LOG_message', $message);
63
+	}
64
+
65
+	/**
66
+	 * Gets time
67
+	 *
68
+	 * @return string
69
+	 * @throws EE_Error
70
+	 */
71
+	public function time()
72
+	{
73
+		return $this->get('LOG_time');
74
+	}
75
+
76
+	/**
77
+	 * Sets time
78
+	 *
79
+	 * @param string $time
80
+	 * @throws EE_Error
81
+	 */
82
+	public function set_time($time)
83
+	{
84
+		$this->set('LOG_time', $time);
85
+	}
86
+
87
+	/**
88
+	 * Gets log_type
89
+	 *
90
+	 * @return string
91
+	 * @throws EE_Error
92
+	 */
93
+	public function log_type()
94
+	{
95
+		return $this->get('LOG_type');
96
+	}
97
+
98
+
99
+	/**
100
+	 * Return the localized log type label.
101
+	 * @return string
102
+	 * @throws EE_Error
103
+	 */
104
+	public function log_type_label()
105
+	{
106
+		return EEM_Change_Log::get_pretty_label_for_type($this->log_type());
107
+	}
108
+
109
+	/**
110
+	 * Sets log_type
111
+	 *
112
+	 * @param string $log_type
113
+	 * @throws EE_Error
114
+	 */
115
+	public function set_log_type($log_type)
116
+	{
117
+		$this->set('LOG_type', $log_type);
118
+	}
119
+
120
+	/**
121
+	 * Gets type of the model object related to this log
122
+	 *
123
+	 * @return string
124
+	 * @throws EE_Error
125
+	 */
126
+	public function OBJ_type()
127
+	{
128
+		return $this->get('OBJ_type');
129
+	}
130
+
131
+	/**
132
+	 * Sets type
133
+	 *
134
+	 * @param string $type
135
+	 * @throws EE_Error
136
+	 */
137
+	public function set_OBJ_type($type)
138
+	{
139
+		$this->set('OBJ_type', $type);
140
+	}
141
+
142
+	/**
143
+	 * Gets OBJ_ID (the ID of the item related to this log)
144
+	 *
145
+	 * @return mixed
146
+	 * @throws EE_Error
147
+	 */
148
+	public function OBJ_ID()
149
+	{
150
+		return $this->get('OBJ_ID');
151
+	}
152
+
153
+	/**
154
+	 * Sets OBJ_ID
155
+	 *
156
+	 * @param mixed $OBJ_ID
157
+	 * @throws EE_Error
158
+	 */
159
+	public function set_OBJ_ID($OBJ_ID)
160
+	{
161
+		$this->set('OBJ_ID', $OBJ_ID);
162
+	}
163
+
164
+	/**
165
+	 * Gets wp_user
166
+	 *
167
+	 * @return int
168
+	 * @throws EE_Error
169
+	 */
170
+	public function wp_user()
171
+	{
172
+		return $this->get('LOG_wp_user');
173
+	}
174
+
175
+	/**
176
+	 * Sets wp_user
177
+	 *
178
+	 * @param int $wp_user_id
179
+	 * @throws EE_Error
180
+	 */
181
+	public function set_wp_user($wp_user_id)
182
+	{
183
+		$this->set('LOG_wp_user', $wp_user_id);
184
+	}
185
+
186
+	/**
187
+	 * Gets the model object attached to this log
188
+	 *
189
+	 * @return EE_Base_Class
190
+	 * @throws EE_Error
191
+	 */
192
+	public function object()
193
+	{
194
+		$model_name_of_related_obj = $this->OBJ_type();
195
+		$is_model_name             = EE_Registry::instance()->is_model_name($model_name_of_related_obj);
196
+		if (! $is_model_name) {
197
+			return null;
198
+		} else {
199
+			return $this->get_first_related($model_name_of_related_obj);
200
+		}
201
+	}
202
+
203
+	/**
204
+	 * Shorthand for setting the OBJ_ID and OBJ_type. Slightly handier than using
205
+	 * _add_relation_to because you don't have to specify what type of model you're
206
+	 * associating it with
207
+	 *
208
+	 * @param EE_Base_Class $object
209
+	 * @param boolean       $save
210
+	 * @return bool if $save=true, NULL is $save=false
211
+	 * @throws EE_Error
212
+	 */
213
+	public function set_object($object, $save = true)
214
+	{
215
+		if ($object instanceof EE_Base_Class) {
216
+			$this->set_OBJ_type($object->get_model()->get_this_model_name());
217
+			$this->set_OBJ_ID($object->ID());
218
+		} else {
219
+			$this->set_OBJ_type(null);
220
+			$this->set_OBJ_ID(null);
221
+		}
222
+		if ($save) {
223
+			return $this->save();
224
+		} else {
225
+			return null;
226
+		}
227
+	}
228 228
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -193,7 +193,7 @@
 block discarded – undo
193 193
     {
194 194
         $model_name_of_related_obj = $this->OBJ_type();
195 195
         $is_model_name             = EE_Registry::instance()->is_model_name($model_name_of_related_obj);
196
-        if (! $is_model_name) {
196
+        if ( ! $is_model_name) {
197 197
             return null;
198 198
         } else {
199 199
             return $this->get_first_related($model_name_of_related_obj);
Please login to merge, or discard this patch.
core/EE_Registry.core.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -270,7 +270,7 @@
 block discarded – undo
270 270
 
271 271
 
272 272
     /**
273
-     * @param $module
273
+     * @param string $module
274 274
      * @throws EE_Error
275 275
      * @throws ReflectionException
276 276
      */
Please login to merge, or discard this patch.
Indentation   +1459 added lines, -1459 removed lines patch added patch discarded remove patch
@@ -20,1465 +20,1465 @@
 block discarded – undo
20 20
 class EE_Registry implements ResettableInterface
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Registry $_instance
25
-     */
26
-    private static $_instance;
27
-
28
-    /**
29
-     * @var EE_Dependency_Map $_dependency_map
30
-     */
31
-    protected $_dependency_map;
32
-
33
-    /**
34
-     * @var array $_class_abbreviations
35
-     */
36
-    protected $_class_abbreviations = array();
37
-
38
-    /**
39
-     * @var CommandBusInterface $BUS
40
-     */
41
-    public $BUS;
42
-
43
-    /**
44
-     * @var EE_Cart $CART
45
-     */
46
-    public $CART;
47
-
48
-    /**
49
-     * @var EE_Config $CFG
50
-     */
51
-    public $CFG;
52
-
53
-    /**
54
-     * @var EE_Network_Config $NET_CFG
55
-     */
56
-    public $NET_CFG;
57
-
58
-    /**
59
-     * StdClass object for storing library classes in
60
-     *
61
-     * @var StdClass $LIB
62
-     */
63
-    public $LIB;
64
-
65
-    /**
66
-     * @var EE_Request_Handler $REQ
67
-     */
68
-    public $REQ;
69
-
70
-    /**
71
-     * @var EE_Session $SSN
72
-     */
73
-    public $SSN;
74
-
75
-    /**
76
-     * @since 4.5.0
77
-     * @var EE_Capabilities $CAP
78
-     */
79
-    public $CAP;
80
-
81
-    /**
82
-     * @since 4.9.0
83
-     * @var EE_Message_Resource_Manager $MRM
84
-     */
85
-    public $MRM;
86
-
87
-
88
-    /**
89
-     * @var Registry $AssetsRegistry
90
-     */
91
-    public $AssetsRegistry;
92
-
93
-    /**
94
-     * StdClass object for holding addons which have registered themselves to work with EE core
95
-     *
96
-     * @var EE_Addon[] $addons
97
-     */
98
-    public $addons;
99
-
100
-    /**
101
-     * keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
102
-     *
103
-     * @var EEM_Base[] $models
104
-     */
105
-    public $models = array();
106
-
107
-    /**
108
-     * @var EED_Module[] $modules
109
-     */
110
-    public $modules;
111
-
112
-    /**
113
-     * @var EES_Shortcode[] $shortcodes
114
-     */
115
-    public $shortcodes;
116
-
117
-    /**
118
-     * @var WP_Widget[] $widgets
119
-     */
120
-    public $widgets;
121
-
122
-    /**
123
-     * this is an array of all implemented model names (i.e. not the parent abstract models, or models
124
-     * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
125
-     * Keys are model "short names" (eg "Event") as used in model relations, and values are
126
-     * classnames (eg "EEM_Event")
127
-     *
128
-     * @var array $non_abstract_db_models
129
-     */
130
-    public $non_abstract_db_models = array();
131
-
132
-
133
-    /**
134
-     * internationalization for JS strings
135
-     *    usage:   EE_Registry::i18n_js_strings['string_key'] = esc_html__( 'string to translate.', 'event_espresso' );
136
-     *    in js file:  var translatedString = eei18n.string_key;
137
-     *
138
-     * @var array $i18n_js_strings
139
-     */
140
-    public static $i18n_js_strings = array();
141
-
142
-
143
-    /**
144
-     * $main_file - path to espresso.php
145
-     *
146
-     * @var array $main_file
147
-     */
148
-    public $main_file;
149
-
150
-    /**
151
-     * array of ReflectionClass objects where the key is the class name
152
-     *
153
-     * @var ReflectionClass[] $_reflectors
154
-     */
155
-    public $_reflectors;
156
-
157
-    /**
158
-     * boolean flag to indicate whether or not to load/save dependencies from/to the cache
159
-     *
160
-     * @var boolean $_cache_on
161
-     */
162
-    protected $_cache_on = true;
163
-
164
-
165
-
166
-    /**
167
-     * @singleton method used to instantiate class object
168
-     * @param  EE_Dependency_Map $dependency_map
169
-     * @return EE_Registry instance
170
-     */
171
-    public static function instance(EE_Dependency_Map $dependency_map = null)
172
-    {
173
-        // check if class object is instantiated
174
-        if (! self::$_instance instanceof EE_Registry) {
175
-            self::$_instance = new self($dependency_map);
176
-        }
177
-        return self::$_instance;
178
-    }
179
-
180
-
181
-
182
-    /**
183
-     * protected constructor to prevent direct creation
184
-     *
185
-     * @Constructor
186
-     * @param  EE_Dependency_Map $dependency_map
187
-     */
188
-    protected function __construct(EE_Dependency_Map $dependency_map)
189
-    {
190
-        $this->_dependency_map = $dependency_map;
191
-        $this->LIB = new stdClass();
192
-        $this->addons = new stdClass();
193
-        $this->modules = new stdClass();
194
-        $this->shortcodes = new stdClass();
195
-        $this->widgets = new stdClass();
196
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
197
-    }
198
-
199
-
200
-
201
-    /**
202
-     * initialize
203
-     *
204
-     * @throws EE_Error
205
-     * @throws ReflectionException
206
-     */
207
-    public function initialize()
208
-    {
209
-        $this->_class_abbreviations = apply_filters(
210
-            'FHEE__EE_Registry____construct___class_abbreviations',
211
-            array(
212
-                'EE_Config'                                       => 'CFG',
213
-                'EE_Session'                                      => 'SSN',
214
-                'EE_Capabilities'                                 => 'CAP',
215
-                'EE_Cart'                                         => 'CART',
216
-                'EE_Network_Config'                               => 'NET_CFG',
217
-                'EE_Request_Handler'                              => 'REQ',
218
-                'EE_Message_Resource_Manager'                     => 'MRM',
219
-                'EventEspresso\core\services\commands\CommandBus' => 'BUS',
220
-                'EventEspresso\core\services\assets\Registry'     => 'AssetsRegistry',
221
-            )
222
-        );
223
-        $this->load_core('Base', array(), true);
224
-        // add our request and response objects to the cache
225
-        $request_loader = $this->_dependency_map->class_loader('EE_Request');
226
-        $this->_set_cached_class(
227
-            $request_loader(),
228
-            'EE_Request'
229
-        );
230
-        $response_loader = $this->_dependency_map->class_loader('EE_Response');
231
-        $this->_set_cached_class(
232
-            $response_loader(),
233
-            'EE_Response'
234
-        );
235
-        add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
236
-    }
237
-
238
-
239
-
240
-    /**
241
-     * @return void
242
-     */
243
-    public function init()
244
-    {
245
-        // Get current page protocol
246
-        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
247
-        // Output admin-ajax.php URL with same protocol as current page
248
-        self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
249
-        self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
250
-    }
251
-
252
-
253
-
254
-    /**
255
-     * localize_i18n_js_strings
256
-     *
257
-     * @return string
258
-     */
259
-    public static function localize_i18n_js_strings()
260
-    {
261
-        $i18n_js_strings = (array)self::$i18n_js_strings;
262
-        foreach ($i18n_js_strings as $key => $value) {
263
-            if (is_scalar($value)) {
264
-                $i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
265
-            }
266
-        }
267
-        return '/* <![CDATA[ */ var eei18n = ' . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
268
-    }
269
-
270
-
271
-
272
-    /**
273
-     * @param $module
274
-     * @throws EE_Error
275
-     * @throws ReflectionException
276
-     */
277
-    public function add_module($module)
278
-    {
279
-        if ($module instanceof EED_Module) {
280
-            $module_class = get_class($module);
281
-            $this->modules->{$module_class} = $module;
282
-        } else {
283
-            if (! class_exists('EE_Module_Request_Router')) {
284
-                $this->load_core('Module_Request_Router');
285
-            }
286
-            EE_Module_Request_Router::module_factory($module);
287
-        }
288
-    }
289
-
290
-
291
-
292
-    /**
293
-     * @param string $module_name
294
-     * @return mixed EED_Module | NULL
295
-     */
296
-    public function get_module($module_name = '')
297
-    {
298
-        return isset($this->modules->{$module_name})
299
-            ? $this->modules->{$module_name}
300
-            : null;
301
-    }
302
-
303
-
304
-
305
-    /**
306
-     * loads core classes - must be singletons
307
-     *
308
-     * @param string $class_name - simple class name ie: session
309
-     * @param mixed  $arguments
310
-     * @param bool   $load_only
311
-     * @return mixed
312
-     * @throws EE_Error
313
-     * @throws ReflectionException
314
-     */
315
-    public function load_core($class_name, $arguments = array(), $load_only = false)
316
-    {
317
-        $core_paths = apply_filters(
318
-            'FHEE__EE_Registry__load_core__core_paths',
319
-            array(
320
-                EE_CORE,
321
-                EE_ADMIN,
322
-                EE_CPTS,
323
-                EE_CORE . 'data_migration_scripts' . DS,
324
-                EE_CORE . 'request_stack' . DS,
325
-                EE_CORE . 'middleware' . DS,
326
-            )
327
-        );
328
-        // retrieve instantiated class
329
-        return $this->_load(
330
-            $core_paths,
331
-            'EE_',
332
-            $class_name,
333
-            'core',
334
-            $arguments,
335
-            false,
336
-            true,
337
-            $load_only
338
-        );
339
-    }
340
-
341
-
342
-
343
-    /**
344
-     * loads service classes
345
-     *
346
-     * @param string $class_name - simple class name ie: session
347
-     * @param mixed  $arguments
348
-     * @param bool   $load_only
349
-     * @return mixed
350
-     * @throws EE_Error
351
-     * @throws ReflectionException
352
-     */
353
-    public function load_service($class_name, $arguments = array(), $load_only = false)
354
-    {
355
-        $service_paths = apply_filters(
356
-            'FHEE__EE_Registry__load_service__service_paths',
357
-            array(
358
-                EE_CORE . 'services' . DS,
359
-            )
360
-        );
361
-        // retrieve instantiated class
362
-        return $this->_load(
363
-            $service_paths,
364
-            'EE_',
365
-            $class_name,
366
-            'class',
367
-            $arguments,
368
-            false,
369
-            true,
370
-            $load_only
371
-        );
372
-    }
373
-
374
-
375
-
376
-    /**
377
-     * loads data_migration_scripts
378
-     *
379
-     * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
380
-     * @param mixed  $arguments
381
-     * @return EE_Data_Migration_Script_Base|mixed
382
-     * @throws EE_Error
383
-     * @throws ReflectionException
384
-     */
385
-    public function load_dms($class_name, $arguments = array())
386
-    {
387
-        // retrieve instantiated class
388
-        return $this->_load(
389
-            EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(),
390
-            'EE_DMS_',
391
-            $class_name,
392
-            'dms',
393
-            $arguments,
394
-            false,
395
-            false
396
-        );
397
-    }
398
-
399
-
400
-
401
-    /**
402
-     * loads object creating classes - must be singletons
403
-     *
404
-     * @param string $class_name - simple class name ie: attendee
405
-     * @param mixed  $arguments  - an array of arguments to pass to the class
406
-     * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to
407
-     *                           instantiate
408
-     * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then
409
-     *                           set this to FALSE (ie. when instantiating model objects from client in a loop)
410
-     * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate
411
-     *                           (default)
412
-     * @return EE_Base_Class | bool
413
-     * @throws EE_Error
414
-     * @throws ReflectionException
415
-     */
416
-    public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
417
-    {
418
-        $paths = apply_filters(
419
-            'FHEE__EE_Registry__load_class__paths', array(
420
-            EE_CORE,
421
-            EE_CLASSES,
422
-            EE_BUSINESS,
423
-        )
424
-        );
425
-        // retrieve instantiated class
426
-        return $this->_load(
427
-            $paths,
428
-            'EE_',
429
-            $class_name,
430
-            'class',
431
-            $arguments,
432
-            $from_db,
433
-            $cache,
434
-            $load_only
435
-        );
436
-    }
437
-
438
-
439
-
440
-    /**
441
-     * loads helper classes - must be singletons
442
-     *
443
-     * @param string $class_name - simple class name ie: price
444
-     * @param mixed  $arguments
445
-     * @param bool   $load_only
446
-     * @return EEH_Base | bool
447
-     * @throws EE_Error
448
-     * @throws ReflectionException
449
-     */
450
-    public function load_helper($class_name, $arguments = array(), $load_only = true)
451
-    {
452
-        // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
453
-        $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
454
-        // retrieve instantiated class
455
-        return $this->_load(
456
-            $helper_paths,
457
-            'EEH_',
458
-            $class_name,
459
-            'helper',
460
-            $arguments,
461
-            false,
462
-            true,
463
-            $load_only
464
-        );
465
-    }
466
-
467
-
468
-
469
-    /**
470
-     * loads core classes - must be singletons
471
-     *
472
-     * @param string $class_name - simple class name ie: session
473
-     * @param mixed  $arguments
474
-     * @param bool   $load_only
475
-     * @param bool   $cache      whether to cache the object or not.
476
-     * @return mixed
477
-     * @throws EE_Error
478
-     * @throws ReflectionException
479
-     */
480
-    public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
481
-    {
482
-        $paths = array(
483
-            EE_LIBRARIES,
484
-            EE_LIBRARIES . 'messages' . DS,
485
-            EE_LIBRARIES . 'shortcodes' . DS,
486
-            EE_LIBRARIES . 'qtips' . DS,
487
-            EE_LIBRARIES . 'payment_methods' . DS,
488
-        );
489
-        // retrieve instantiated class
490
-        return $this->_load(
491
-            $paths,
492
-            'EE_',
493
-            $class_name,
494
-            'lib',
495
-            $arguments,
496
-            false,
497
-            $cache,
498
-            $load_only
499
-        );
500
-    }
501
-
502
-
503
-
504
-    /**
505
-     * loads model classes - must be singletons
506
-     *
507
-     * @param string $class_name - simple class name ie: price
508
-     * @param mixed  $arguments
509
-     * @param bool   $load_only
510
-     * @return EEM_Base | bool
511
-     * @throws EE_Error
512
-     * @throws ReflectionException
513
-     */
514
-    public function load_model($class_name, $arguments = array(), $load_only = false)
515
-    {
516
-        $paths = apply_filters(
517
-            'FHEE__EE_Registry__load_model__paths', array(
518
-            EE_MODELS,
519
-            EE_CORE,
520
-        )
521
-        );
522
-        // retrieve instantiated class
523
-        return $this->_load(
524
-            $paths,
525
-            'EEM_',
526
-            $class_name,
527
-            'model',
528
-            $arguments,
529
-            false,
530
-            true,
531
-            $load_only
532
-        );
533
-    }
534
-
535
-
536
-
537
-    /**
538
-     * loads model classes - must be singletons
539
-     *
540
-     * @param string $class_name - simple class name ie: price
541
-     * @param mixed  $arguments
542
-     * @param bool   $load_only
543
-     * @return mixed | bool
544
-     * @throws EE_Error
545
-     * @throws ReflectionException
546
-     */
547
-    public function load_model_class($class_name, $arguments = array(), $load_only = true)
548
-    {
549
-        $paths = array(
550
-            EE_MODELS . 'fields' . DS,
551
-            EE_MODELS . 'helpers' . DS,
552
-            EE_MODELS . 'relations' . DS,
553
-            EE_MODELS . 'strategies' . DS,
554
-        );
555
-        // retrieve instantiated class
556
-        return $this->_load(
557
-            $paths,
558
-            'EE_',
559
-            $class_name,
560
-            '',
561
-            $arguments,
562
-            false,
563
-            true,
564
-            $load_only
565
-        );
566
-    }
567
-
568
-
569
-
570
-    /**
571
-     * Determines if $model_name is the name of an actual EE model.
572
-     *
573
-     * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
574
-     * @return boolean
575
-     */
576
-    public function is_model_name($model_name)
577
-    {
578
-        return isset($this->models[$model_name]);
579
-    }
580
-
581
-
582
-
583
-    /**
584
-     * generic class loader
585
-     *
586
-     * @param string $path_to_file - directory path to file location, not including filename
587
-     * @param string $file_name    - file name  ie:  my_file.php, including extension
588
-     * @param string $type         - file type - core? class? helper? model?
589
-     * @param mixed  $arguments
590
-     * @param bool   $load_only
591
-     * @return mixed
592
-     * @throws EE_Error
593
-     * @throws ReflectionException
594
-     */
595
-    public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
596
-    {
597
-        // retrieve instantiated class
598
-        return $this->_load(
599
-            $path_to_file,
600
-            '',
601
-            $file_name,
602
-            $type,
603
-            $arguments,
604
-            false,
605
-            true,
606
-            $load_only
607
-        );
608
-    }
609
-
610
-
611
-
612
-    /**
613
-     * @param string $path_to_file - directory path to file location, not including filename
614
-     * @param string $class_name   - full class name  ie:  My_Class
615
-     * @param string $type         - file type - core? class? helper? model?
616
-     * @param mixed  $arguments
617
-     * @param bool   $load_only
618
-     * @return bool|EE_Addon|object
619
-     * @throws EE_Error
620
-     * @throws ReflectionException
621
-     */
622
-    public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
623
-    {
624
-        // retrieve instantiated class
625
-        return $this->_load(
626
-            $path_to_file,
627
-            'addon',
628
-            $class_name,
629
-            $type,
630
-            $arguments,
631
-            false,
632
-            true,
633
-            $load_only
634
-        );
635
-    }
636
-
637
-
638
-
639
-    /**
640
-     * instantiates, caches, and automatically resolves dependencies
641
-     * for classes that use a Fully Qualified Class Name.
642
-     * if the class is not capable of being loaded using PSR-4 autoloading,
643
-     * then you need to use one of the existing load_*() methods
644
-     * which can resolve the classname and filepath from the passed arguments
645
-     *
646
-     * @param bool|string $class_name   Fully Qualified Class Name
647
-     * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
648
-     * @param bool        $cache        whether to cache the instantiated object for reuse
649
-     * @param bool        $from_db      some classes are instantiated from the db
650
-     *                                  and thus call a different method to instantiate
651
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
652
-     * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
653
-     * @return bool|null|object null = failure to load or instantiate class object.
654
-     *                                  object = class loaded and instantiated successfully.
655
-     *                                  bool = fail or success when $load_only is true
656
-     * @throws EE_Error
657
-     * @throws ReflectionException
658
-     */
659
-    public function create(
660
-        $class_name = false,
661
-        $arguments = array(),
662
-        $cache = false,
663
-        $from_db = false,
664
-        $load_only = false,
665
-        $addon = false
666
-    ) {
667
-        $class_name = ltrim($class_name, '\\');
668
-        $class_name = $this->_dependency_map->get_alias($class_name);
669
-        if (! class_exists($class_name)) {
670
-            // maybe the class is registered with a preceding \
671
-            $class_name = strpos($class_name, '\\') !== 0
672
-                ? '\\' . $class_name
673
-                : $class_name;
674
-            // still doesn't exist ?
675
-            if (! class_exists($class_name)) {
676
-                return null;
677
-            }
678
-        }
679
-        // if we're only loading the class and it already exists, then let's just return true immediately
680
-        if ($load_only) {
681
-            return true;
682
-        }
683
-        $addon = $addon
684
-            ? 'addon'
685
-            : '';
686
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
687
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
688
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
689
-        if ($this->_cache_on && $cache && ! $load_only) {
690
-            // return object if it's already cached
691
-            $cached_class = $this->_get_cached_class($class_name, $addon);
692
-            if ($cached_class !== null) {
693
-                return $cached_class;
694
-            }
695
-        }
696
-        // instantiate the requested object
697
-        $class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
698
-        if ($this->_cache_on && $cache) {
699
-            // save it for later... kinda like gum  { : $
700
-            $this->_set_cached_class($class_obj, $class_name, $addon, $from_db);
701
-        }
702
-        $this->_cache_on = true;
703
-        return $class_obj;
704
-    }
705
-
706
-
707
-
708
-    /**
709
-     * instantiates, caches, and injects dependencies for classes
710
-     *
711
-     * @param array       $file_paths   an array of paths to folders to look in
712
-     * @param string      $class_prefix EE  or EEM or... ???
713
-     * @param bool|string $class_name   $class name
714
-     * @param string      $type         file type - core? class? helper? model?
715
-     * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
716
-     * @param bool        $from_db      some classes are instantiated from the db
717
-     *                                  and thus call a different method to instantiate
718
-     * @param bool        $cache        whether to cache the instantiated object for reuse
719
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
720
-     * @return bool|null|object null = failure to load or instantiate class object.
721
-     *                                  object = class loaded and instantiated successfully.
722
-     *                                  bool = fail or success when $load_only is true
723
-     * @throws EE_Error
724
-     * @throws ReflectionException
725
-     */
726
-    protected function _load(
727
-        $file_paths = array(),
728
-        $class_prefix = 'EE_',
729
-        $class_name = false,
730
-        $type = 'class',
731
-        $arguments = array(),
732
-        $from_db = false,
733
-        $cache = true,
734
-        $load_only = false
735
-    ) {
736
-        $class_name = ltrim($class_name, '\\');
737
-        // strip php file extension
738
-        $class_name = str_replace('.php', '', trim($class_name));
739
-        // does the class have a prefix ?
740
-        if (! empty($class_prefix) && $class_prefix !== 'addon') {
741
-            // make sure $class_prefix is uppercase
742
-            $class_prefix = strtoupper(trim($class_prefix));
743
-            // add class prefix ONCE!!!
744
-            $class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
745
-        }
746
-        $class_name = $this->_dependency_map->get_alias($class_name);
747
-        $class_exists = class_exists($class_name);
748
-        // if we're only loading the class and it already exists, then let's just return true immediately
749
-        if ($load_only && $class_exists) {
750
-            return true;
751
-        }
752
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
753
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
754
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
755
-        if ($this->_cache_on && $cache && ! $load_only) {
756
-            // return object if it's already cached
757
-            $cached_class = $this->_get_cached_class($class_name, $class_prefix);
758
-            if ($cached_class !== null) {
759
-                return $cached_class;
760
-            }
761
-        }
762
-        // if the class doesn't already exist.. then we need to try and find the file and load it
763
-        if (! $class_exists) {
764
-            // get full path to file
765
-            $path = $this->_resolve_path($class_name, $type, $file_paths);
766
-            // load the file
767
-            $loaded = $this->_require_file($path, $class_name, $type, $file_paths);
768
-            // if loading failed, or we are only loading a file but NOT instantiating an object
769
-            if (! $loaded || $load_only) {
770
-                // return boolean if only loading, or null if an object was expected
771
-                return $load_only
772
-                    ? $loaded
773
-                    : null;
774
-            }
775
-        }
776
-        // instantiate the requested object
777
-        $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
778
-        if ($this->_cache_on && $cache) {
779
-            // save it for later... kinda like gum  { : $
780
-            $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
781
-        }
782
-        $this->_cache_on = true;
783
-        return $class_obj;
784
-    }
785
-
786
-
787
-
788
-    /**
789
-     * attempts to find a cached version of the requested class
790
-     * by looking in the following places:
791
-     *        $this->{$class_abbreviation}            ie:    $this->CART
792
-     *        $this->{$class_name}                        ie:    $this->Some_Class
793
-     *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
794
-     *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
795
-     *
796
-     * @param string $class_name
797
-     * @param string $class_prefix
798
-     * @return mixed
799
-     */
800
-    protected function _get_cached_class($class_name, $class_prefix = '')
801
-    {
802
-        if ($class_name === 'EE_Registry') {
803
-            return $this;
804
-        }
805
-        // have to specify something, but not anything that will conflict
806
-        $class_abbreviation = isset($this->_class_abbreviations[$class_name])
807
-            ? $this->_class_abbreviations[$class_name]
808
-            : 'FANCY_BATMAN_PANTS';
809
-        $class_name = str_replace('\\', '_', $class_name);
810
-        // check if class has already been loaded, and return it if it has been
811
-        if (isset($this->{$class_abbreviation})) {
812
-            return $this->{$class_abbreviation};
813
-        }
814
-        if (isset ($this->{$class_name})) {
815
-            return $this->{$class_name};
816
-        }
817
-        if (isset ($this->LIB->{$class_name})) {
818
-            return $this->LIB->{$class_name};
819
-        }
820
-        if ($class_prefix === 'addon' && isset ($this->addons->{$class_name})) {
821
-            return $this->addons->{$class_name};
822
-        }
823
-        return null;
824
-    }
825
-
826
-
827
-
828
-    /**
829
-     * removes a cached version of the requested class
830
-     *
831
-     * @param string  $class_name
832
-     * @param boolean $addon
833
-     * @return boolean
834
-     */
835
-    public function clear_cached_class($class_name, $addon = false)
836
-    {
837
-        // have to specify something, but not anything that will conflict
838
-        $class_abbreviation = isset($this->_class_abbreviations[$class_name])
839
-            ? $this->_class_abbreviations[$class_name]
840
-            : 'FANCY_BATMAN_PANTS';
841
-        $class_name = str_replace('\\', '_', $class_name);
842
-        // check if class has already been loaded, and return it if it has been
843
-        if (isset($this->{$class_abbreviation})) {
844
-            $this->{$class_abbreviation} = null;
845
-            return true;
846
-        }
847
-        if (isset($this->{$class_name})) {
848
-            $this->{$class_name} = null;
849
-            return true;
850
-        }
851
-        if (isset($this->LIB->{$class_name})) {
852
-            unset($this->LIB->{$class_name});
853
-            return true;
854
-        }
855
-        if ($addon && isset($this->addons->{$class_name})) {
856
-            unset($this->addons->{$class_name});
857
-            return true;
858
-        }
859
-        return false;
860
-    }
861
-
862
-
863
-
864
-    /**
865
-     * attempts to find a full valid filepath for the requested class.
866
-     * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
867
-     * then returns that path if the target file has been found and is readable
868
-     *
869
-     * @param string $class_name
870
-     * @param string $type
871
-     * @param array  $file_paths
872
-     * @return string | bool
873
-     */
874
-    protected function _resolve_path($class_name, $type = '', $file_paths = array())
875
-    {
876
-        // make sure $file_paths is an array
877
-        $file_paths = is_array($file_paths)
878
-            ? $file_paths
879
-            : array($file_paths);
880
-        // cycle thru paths
881
-        foreach ($file_paths as $key => $file_path) {
882
-            // convert all separators to proper DS, if no filepath, then use EE_CLASSES
883
-            $file_path = $file_path
884
-                ? str_replace(array('/', '\\'), DS, $file_path)
885
-                : EE_CLASSES;
886
-            // prep file type
887
-            $type = ! empty($type)
888
-                ? trim($type, '.') . '.'
889
-                : '';
890
-            // build full file path
891
-            $file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
892
-            //does the file exist and can be read ?
893
-            if (is_readable($file_paths[$key])) {
894
-                return $file_paths[$key];
895
-            }
896
-        }
897
-        return false;
898
-    }
899
-
900
-
901
-
902
-    /**
903
-     * basically just performs a require_once()
904
-     * but with some error handling
905
-     *
906
-     * @param  string $path
907
-     * @param  string $class_name
908
-     * @param  string $type
909
-     * @param  array  $file_paths
910
-     * @return bool
911
-     * @throws EE_Error
912
-     * @throws ReflectionException
913
-     */
914
-    protected function _require_file($path, $class_name, $type = '', $file_paths = array())
915
-    {
916
-        // don't give up! you gotta...
917
-        try {
918
-            //does the file exist and can it be read ?
919
-            if (! $path) {
920
-                // so sorry, can't find the file
921
-                throw new EE_Error (
922
-                    sprintf(
923
-                        esc_html__(
924
-                            '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',
925
-                            'event_espresso'
926
-                        ),
927
-                        trim($type, '.'),
928
-                        $class_name,
929
-                        '<br />' . implode(',<br />', $file_paths)
930
-                    )
931
-                );
932
-            }
933
-            // get the file
934
-            require_once($path);
935
-            // if the class isn't already declared somewhere
936
-            if (class_exists($class_name, false) === false) {
937
-                // so sorry, not a class
938
-                throw new EE_Error(
939
-                    sprintf(
940
-                        esc_html__('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
941
-                        $type,
942
-                        $path,
943
-                        $class_name
944
-                    )
945
-                );
946
-            }
947
-        } catch (EE_Error $e) {
948
-            $e->get_error();
949
-            return false;
950
-        }
951
-        return true;
952
-    }
953
-
954
-
955
-
956
-    /**
957
-     * _create_object
958
-     * Attempts to instantiate the requested class via any of the
959
-     * commonly used instantiation methods employed throughout EE.
960
-     * The priority for instantiation is as follows:
961
-     *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
962
-     *        - model objects via their 'new_instance_from_db' method
963
-     *        - model objects via their 'new_instance' method
964
-     *        - "singleton" classes" via their 'instance' method
965
-     *    - standard instantiable classes via their __constructor
966
-     * Prior to instantiation, if the classname exists in the dependency_map,
967
-     * then the constructor for the requested class will be examined to determine
968
-     * if any dependencies exist, and if they can be injected.
969
-     * If so, then those classes will be added to the array of arguments passed to the constructor
970
-     *
971
-     * @param string $class_name
972
-     * @param array  $arguments
973
-     * @param string $type
974
-     * @param bool   $from_db
975
-     * @return null|object
976
-     * @throws EE_Error
977
-     * @throws ReflectionException
978
-     */
979
-    protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
980
-    {
981
-        $class_obj = null;
982
-        $instantiation_mode = '0) none';
983
-        // don't give up! you gotta...
984
-        try {
985
-            // create reflection
986
-            $reflector = $this->get_ReflectionClass($class_name);
987
-            // make sure arguments are an array
988
-            $arguments = is_array($arguments)
989
-                ? $arguments
990
-                : array($arguments);
991
-            // and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
992
-            // else wrap it in an additional array so that it doesn't get split into multiple parameters
993
-            $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
994
-                ? $arguments
995
-                : array($arguments);
996
-            // attempt to inject dependencies ?
997
-            if ($this->_dependency_map->has($class_name)) {
998
-                $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
999
-            }
1000
-            // instantiate the class if possible
1001
-            if ($reflector->isAbstract()) {
1002
-                // nothing to instantiate, loading file was enough
1003
-                // does not throw an exception so $instantiation_mode is unused
1004
-                // $instantiation_mode = "1) no constructor abstract class";
1005
-                $class_obj = true;
1006
-            } else if (empty($arguments) && $reflector->getConstructor() === null && $reflector->isInstantiable()) {
1007
-                // no constructor = static methods only... nothing to instantiate, loading file was enough
1008
-                $instantiation_mode = '2) no constructor but instantiable';
1009
-                $class_obj = $reflector->newInstance();
1010
-            } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
1011
-                $instantiation_mode = '3) new_instance_from_db()';
1012
-                $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
1013
-            } else if (method_exists($class_name, 'new_instance')) {
1014
-                $instantiation_mode = '4) new_instance()';
1015
-                $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
1016
-            } else if (method_exists($class_name, 'instance')) {
1017
-                $instantiation_mode = '5) instance()';
1018
-                $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
1019
-            } else if ($reflector->isInstantiable()) {
1020
-                $instantiation_mode = '6) constructor';
1021
-                $class_obj = $reflector->newInstanceArgs($arguments);
1022
-            } else {
1023
-                // heh ? something's not right !
1024
-                throw new EE_Error(
1025
-                    sprintf(
1026
-                        esc_html__('The %s file %s could not be instantiated.', 'event_espresso'),
1027
-                        $type,
1028
-                        $class_name
1029
-                    )
1030
-                );
1031
-            }
1032
-        } catch (Exception $e) {
1033
-            if (! $e instanceof EE_Error) {
1034
-                $e = new EE_Error(
1035
-                    sprintf(
1036
-                        esc_html__(
1037
-                            'The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s',
1038
-                            'event_espresso'
1039
-                        ),
1040
-                        $class_name,
1041
-                        '<br />',
1042
-                        $e->getMessage(),
1043
-                        $instantiation_mode
1044
-                    )
1045
-                );
1046
-            }
1047
-            $e->get_error();
1048
-        }
1049
-        return $class_obj;
1050
-    }
1051
-
1052
-
1053
-
1054
-    /**
1055
-     * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
1056
-     * @param array $array
1057
-     * @return bool
1058
-     */
1059
-    protected function _array_is_numerically_and_sequentially_indexed(array $array)
1060
-    {
1061
-        return ! empty($array)
1062
-            ? array_keys($array) === range(0, count($array) - 1)
1063
-            : true;
1064
-    }
1065
-
1066
-
1067
-
1068
-    /**
1069
-     * getReflectionClass
1070
-     * checks if a ReflectionClass object has already been generated for a class
1071
-     * and returns that instead of creating a new one
1072
-     *
1073
-     * @param string $class_name
1074
-     * @return ReflectionClass
1075
-     * @throws ReflectionException
1076
-     */
1077
-    public function get_ReflectionClass($class_name)
1078
-    {
1079
-        if (
1080
-            ! isset($this->_reflectors[$class_name])
1081
-            || ! $this->_reflectors[$class_name] instanceof ReflectionClass
1082
-        ) {
1083
-            $this->_reflectors[$class_name] = new ReflectionClass($class_name);
1084
-        }
1085
-        return $this->_reflectors[$class_name];
1086
-    }
1087
-
1088
-
1089
-
1090
-    /**
1091
-     * _resolve_dependencies
1092
-     * examines the constructor for the requested class to determine
1093
-     * if any dependencies exist, and if they can be injected.
1094
-     * If so, then those classes will be added to the array of arguments passed to the constructor
1095
-     * PLZ NOTE: this is achieved by type hinting the constructor params
1096
-     * For example:
1097
-     *        if attempting to load a class "Foo" with the following constructor:
1098
-     *        __construct( Bar $bar_class, Fighter $grohl_class )
1099
-     *        then $bar_class and $grohl_class will be added to the $arguments array,
1100
-     *        but only IF they are NOT already present in the incoming arguments array,
1101
-     *        and the correct classes can be loaded
1102
-     *
1103
-     * @param ReflectionClass $reflector
1104
-     * @param string          $class_name
1105
-     * @param array           $arguments
1106
-     * @return array
1107
-     * @throws EE_Error
1108
-     * @throws ReflectionException
1109
-     */
1110
-    protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array())
1111
-    {
1112
-        // let's examine the constructor
1113
-        $constructor = $reflector->getConstructor();
1114
-        // whu? huh? nothing?
1115
-        if (! $constructor) {
1116
-            return $arguments;
1117
-        }
1118
-        // get constructor parameters
1119
-        $params = $constructor->getParameters();
1120
-        // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
1121
-        $argument_keys = array_keys($arguments);
1122
-        // now loop thru all of the constructors expected parameters
1123
-        foreach ($params as $index => $param) {
1124
-            // is this a dependency for a specific class ?
1125
-            $param_class = $param->getClass()
1126
-                ? $param->getClass()->name
1127
-                : null;
1128
-            // BUT WAIT !!! This class may be an alias for something else (or getting replaced at runtime)
1129
-            $param_class = $this->_dependency_map->has_alias($param_class, $class_name)
1130
-                ? $this->_dependency_map->get_alias($param_class, $class_name)
1131
-                : $param_class;
1132
-            if (
1133
-                // param is not even a class
1134
-                empty($param_class)
1135
-                // and something already exists in the incoming arguments for this param
1136
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
1137
-            ) {
1138
-                // so let's skip this argument and move on to the next
1139
-                continue;
1140
-            }
1141
-            if (
1142
-                // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
1143
-                ! empty($param_class)
1144
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
1145
-                && $arguments[$argument_keys[$index]] instanceof $param_class
1146
-            ) {
1147
-                // skip this argument and move on to the next
1148
-                continue;
1149
-            }
1150
-            if (
1151
-                // parameter is type hinted as a class, and should be injected
1152
-                ! empty($param_class)
1153
-                && $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1154
-            ) {
1155
-                $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index);
1156
-            } else {
1157
-                try {
1158
-                    $arguments[$index] = $param->getDefaultValue();
1159
-                } catch (ReflectionException $e) {
1160
-                    throw new ReflectionException(
1161
-                        sprintf(
1162
-                            esc_html__('%1$s for parameter "$%2$s"', 'event_espresso'),
1163
-                            $e->getMessage(),
1164
-                            $param->getName()
1165
-                        )
1166
-                    );
1167
-                }
1168
-            }
1169
-        }
1170
-        return $arguments;
1171
-    }
1172
-
1173
-
1174
-
1175
-    /**
1176
-     * @param string $class_name
1177
-     * @param string $param_class
1178
-     * @param array  $arguments
1179
-     * @param mixed  $index
1180
-     * @return array
1181
-     * @throws EE_Error
1182
-     * @throws ReflectionException
1183
-     */
1184
-    protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1185
-    {
1186
-        $dependency = null;
1187
-        // should dependency be loaded from cache ?
1188
-        $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class)
1189
-                    !== EE_Dependency_Map::load_new_object;
1190
-        // we might have a dependency...
1191
-        // let's MAYBE try and find it in our cache if that's what's been requested
1192
-        $cached_class = $cache_on
1193
-            ? $this->_get_cached_class($param_class)
1194
-            : null;
1195
-        // and grab it if it exists
1196
-        if ($cached_class instanceof $param_class) {
1197
-            $dependency = $cached_class;
1198
-        } else if ($param_class !== $class_name) {
1199
-            // obtain the loader method from the dependency map
1200
-            $loader = $this->_dependency_map->class_loader($param_class);
1201
-            // is loader a custom closure ?
1202
-            if ($loader instanceof Closure) {
1203
-                $dependency = $loader();
1204
-            } else {
1205
-                // set the cache on property for the recursive loading call
1206
-                $this->_cache_on = $cache_on;
1207
-                // if not, then let's try and load it via the registry
1208
-                if ($loader && method_exists($this, $loader)) {
1209
-                    $dependency = $this->{$loader}($param_class);
1210
-                } else {
1211
-                    $dependency = $this->create($param_class, array(), $cache_on);
1212
-                }
1213
-            }
1214
-        }
1215
-        // did we successfully find the correct dependency ?
1216
-        if ($dependency instanceof $param_class) {
1217
-            // then let's inject it into the incoming array of arguments at the correct location
1218
-            if (isset($argument_keys[$index])) {
1219
-                $arguments[$argument_keys[$index]] = $dependency;
1220
-            } else {
1221
-                $arguments[$index] = $dependency;
1222
-            }
1223
-        }
1224
-        return $arguments;
1225
-    }
1226
-
1227
-
1228
-
1229
-    /**
1230
-     * _set_cached_class
1231
-     * attempts to cache the instantiated class locally
1232
-     * in one of the following places, in the following order:
1233
-     *        $this->{class_abbreviation}   ie:    $this->CART
1234
-     *        $this->{$class_name}          ie:    $this->Some_Class
1235
-     *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1236
-     *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1237
-     *
1238
-     * @param object $class_obj
1239
-     * @param string $class_name
1240
-     * @param string $class_prefix
1241
-     * @param bool   $from_db
1242
-     * @return void
1243
-     */
1244
-    protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false)
1245
-    {
1246
-        if ($class_name === 'EE_Registry' || empty($class_obj)) {
1247
-            return;
1248
-        }
1249
-        // return newly instantiated class
1250
-        if (isset($this->_class_abbreviations[$class_name])) {
1251
-            $class_abbreviation = $this->_class_abbreviations[$class_name];
1252
-            $this->{$class_abbreviation} = $class_obj;
1253
-            return;
1254
-        }
1255
-        $class_name = str_replace('\\', '_', $class_name);
1256
-        if (property_exists($this, $class_name)) {
1257
-            $this->{$class_name} = $class_obj;
1258
-            return;
1259
-        }
1260
-        if ($class_prefix === 'addon') {
1261
-            $this->addons->{$class_name} = $class_obj;
1262
-            return;
1263
-        }
1264
-        if (! $from_db) {
1265
-            $this->LIB->{$class_name} = $class_obj;
1266
-        }
1267
-    }
1268
-
1269
-
1270
-
1271
-    /**
1272
-     * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1273
-     *
1274
-     * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1275
-     *                          in the EE_Dependency_Map::$_class_loaders array,
1276
-     *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1277
-     * @param array  $arguments
1278
-     * @return object
1279
-     */
1280
-    public static function factory($classname, $arguments = array())
1281
-    {
1282
-        $loader = self::instance()->_dependency_map->class_loader($classname);
1283
-        if ($loader instanceof Closure) {
1284
-            return $loader($arguments);
1285
-        }
1286
-        if (method_exists(self::instance(), $loader)) {
1287
-            return self::instance()->{$loader}($classname, $arguments);
1288
-        }
1289
-        return null;
1290
-    }
1291
-
1292
-
1293
-
1294
-    /**
1295
-     * Gets the addon by its name/slug (not classname. For that, just
1296
-     * use the classname as the property name on EE_Config::instance()->addons)
1297
-     *
1298
-     * @param string $name
1299
-     * @return EE_Addon
1300
-     */
1301
-    public function get_addon_by_name($name)
1302
-    {
1303
-        foreach ($this->addons as $addon) {
1304
-            if ($addon->name() === $name) {
1305
-                return $addon;
1306
-            }
1307
-        }
1308
-        return null;
1309
-    }
1310
-
1311
-
1312
-
1313
-    /**
1314
-     * Gets an array of all the registered addons, where the keys are their names. (ie, what each returns for their
1315
-     * name() function) They're already available on EE_Config::instance()->addons as properties, where each property's
1316
-     * name is the addon's classname. So if you just want to get the addon by classname, use
1317
-     * EE_Config::instance()->addons->{classname}
1318
-     *
1319
-     * @return EE_Addon[] where the KEYS are the addon's name()
1320
-     */
1321
-    public function get_addons_by_name()
1322
-    {
1323
-        $addons = array();
1324
-        foreach ($this->addons as $addon) {
1325
-            $addons[$addon->name()] = $addon;
1326
-        }
1327
-        return $addons;
1328
-    }
1329
-
1330
-
1331
-
1332
-    /**
1333
-     * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1334
-     * a stale copy of it around
1335
-     *
1336
-     * @param string $model_name
1337
-     * @return \EEM_Base
1338
-     * @throws \EE_Error
1339
-     */
1340
-    public function reset_model($model_name)
1341
-    {
1342
-        $model_class_name = strpos($model_name, 'EEM_') !== 0
1343
-            ? "EEM_{$model_name}"
1344
-            : $model_name;
1345
-        if (! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1346
-            return null;
1347
-        }
1348
-        //get that model reset it and make sure we nuke the old reference to it
1349
-        if ($this->LIB->{$model_class_name} instanceof $model_class_name
1350
-            && is_callable(
1351
-                array($model_class_name, 'reset')
1352
-            )) {
1353
-            $this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1354
-        } else {
1355
-            throw new EE_Error(sprintf(esc_html__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1356
-        }
1357
-        return $this->LIB->{$model_class_name};
1358
-    }
1359
-
1360
-
1361
-
1362
-    /**
1363
-     * Resets the registry.
1364
-     * The criteria for what gets reset is based on what can be shared between sites on the same request when
1365
-     * switch_to_blog is used in a multisite install.  Here is a list of things that are NOT reset.
1366
-     * - $_dependency_map
1367
-     * - $_class_abbreviations
1368
-     * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1369
-     * - $REQ:  Still on the same request so no need to change.
1370
-     * - $CAP: There is no site specific state in the EE_Capability class.
1371
-     * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only
1372
-     * one Session can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1373
-     * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1374
-     *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1375
-     *             switch or on the restore.
1376
-     * - $modules
1377
-     * - $shortcodes
1378
-     * - $widgets
1379
-     *
1380
-     * @param boolean $hard             whether to reset data in the database too, or just refresh
1381
-     *                                  the Registry to its state at the beginning of the request
1382
-     * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1383
-     *                                  or just reset without re-instantiating (handy to set to FALSE if you're not
1384
-     *                                  sure if you CAN currently reinstantiate the singletons at the moment)
1385
-     * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so
1386
-     *                                  client
1387
-     *                                  code instead can just change the model context to a different blog id if
1388
-     *                                  necessary
1389
-     * @return EE_Registry
1390
-     * @throws EE_Error
1391
-     * @throws ReflectionException
1392
-     */
1393
-    public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1394
-    {
1395
-        $instance = self::instance();
1396
-        $instance->_cache_on = true;
1397
-        // reset some "special" classes
1398
-        EEH_Activation::reset();
1399
-        $instance->CFG = EE_Config::reset($hard, $reinstantiate);
1400
-        $instance->CART = null;
1401
-        $instance->MRM = null;
1402
-        $instance->AssetsRegistry = $instance->create('EventEspresso\core\services\assets\Registry');
1403
-        //messages reset
1404
-        EED_Messages::reset();
1405
-        //handle of objects cached on LIB
1406
-        foreach (array('LIB', 'modules') as $cache) {
1407
-            foreach ($instance->{$cache} as $class_name => $class) {
1408
-                if (self::_reset_and_unset_object($class, $reset_models)) {
1409
-                    unset($instance->{$cache}->{$class_name});
1410
-                }
1411
-            }
1412
-        }
1413
-        return $instance;
1414
-    }
1415
-
1416
-
1417
-
1418
-    /**
1419
-     * if passed object implements ResettableInterface, then call it's reset() method
1420
-     * if passed object implements InterminableInterface, then return false,
1421
-     * to indicate that it should NOT be cleared from the Registry cache
1422
-     *
1423
-     * @param      $object
1424
-     * @param bool $reset_models
1425
-     * @return bool returns true if cached object should be unset
1426
-     */
1427
-    private static function _reset_and_unset_object($object, $reset_models)
1428
-    {
1429
-        if (! is_object($object)) {
1430
-            // don't unset anything that's not an object
1431
-            return false;
1432
-        }
1433
-        if ($object instanceof EED_Module) {
1434
-            $object::reset();
1435
-            // don't unset modules
1436
-            return false;
1437
-        }
1438
-        if ($object instanceof ResettableInterface) {
1439
-            if ($object instanceof EEM_Base) {
1440
-                if ($reset_models) {
1441
-                    $object->reset();
1442
-                    return true;
1443
-                }
1444
-                return false;
1445
-            }
1446
-            $object->reset();
1447
-            return true;
1448
-        }
1449
-        if (! $object instanceof InterminableInterface) {
1450
-            return true;
1451
-        }
1452
-        return false;
1453
-    }
1454
-
1455
-
1456
-
1457
-    /**
1458
-     * Gets all the custom post type models defined
1459
-     *
1460
-     * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1461
-     */
1462
-    public function cpt_models()
1463
-    {
1464
-        $cpt_models = array();
1465
-        foreach ($this->non_abstract_db_models as $short_name => $classname) {
1466
-            if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1467
-                $cpt_models[$short_name] = $classname;
1468
-            }
1469
-        }
1470
-        return $cpt_models;
1471
-    }
1472
-
1473
-
1474
-
1475
-    /**
1476
-     * @return \EE_Config
1477
-     */
1478
-    public static function CFG()
1479
-    {
1480
-        return self::instance()->CFG;
1481
-    }
23
+	/**
24
+	 * @var EE_Registry $_instance
25
+	 */
26
+	private static $_instance;
27
+
28
+	/**
29
+	 * @var EE_Dependency_Map $_dependency_map
30
+	 */
31
+	protected $_dependency_map;
32
+
33
+	/**
34
+	 * @var array $_class_abbreviations
35
+	 */
36
+	protected $_class_abbreviations = array();
37
+
38
+	/**
39
+	 * @var CommandBusInterface $BUS
40
+	 */
41
+	public $BUS;
42
+
43
+	/**
44
+	 * @var EE_Cart $CART
45
+	 */
46
+	public $CART;
47
+
48
+	/**
49
+	 * @var EE_Config $CFG
50
+	 */
51
+	public $CFG;
52
+
53
+	/**
54
+	 * @var EE_Network_Config $NET_CFG
55
+	 */
56
+	public $NET_CFG;
57
+
58
+	/**
59
+	 * StdClass object for storing library classes in
60
+	 *
61
+	 * @var StdClass $LIB
62
+	 */
63
+	public $LIB;
64
+
65
+	/**
66
+	 * @var EE_Request_Handler $REQ
67
+	 */
68
+	public $REQ;
69
+
70
+	/**
71
+	 * @var EE_Session $SSN
72
+	 */
73
+	public $SSN;
74
+
75
+	/**
76
+	 * @since 4.5.0
77
+	 * @var EE_Capabilities $CAP
78
+	 */
79
+	public $CAP;
80
+
81
+	/**
82
+	 * @since 4.9.0
83
+	 * @var EE_Message_Resource_Manager $MRM
84
+	 */
85
+	public $MRM;
86
+
87
+
88
+	/**
89
+	 * @var Registry $AssetsRegistry
90
+	 */
91
+	public $AssetsRegistry;
92
+
93
+	/**
94
+	 * StdClass object for holding addons which have registered themselves to work with EE core
95
+	 *
96
+	 * @var EE_Addon[] $addons
97
+	 */
98
+	public $addons;
99
+
100
+	/**
101
+	 * keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
102
+	 *
103
+	 * @var EEM_Base[] $models
104
+	 */
105
+	public $models = array();
106
+
107
+	/**
108
+	 * @var EED_Module[] $modules
109
+	 */
110
+	public $modules;
111
+
112
+	/**
113
+	 * @var EES_Shortcode[] $shortcodes
114
+	 */
115
+	public $shortcodes;
116
+
117
+	/**
118
+	 * @var WP_Widget[] $widgets
119
+	 */
120
+	public $widgets;
121
+
122
+	/**
123
+	 * this is an array of all implemented model names (i.e. not the parent abstract models, or models
124
+	 * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
125
+	 * Keys are model "short names" (eg "Event") as used in model relations, and values are
126
+	 * classnames (eg "EEM_Event")
127
+	 *
128
+	 * @var array $non_abstract_db_models
129
+	 */
130
+	public $non_abstract_db_models = array();
131
+
132
+
133
+	/**
134
+	 * internationalization for JS strings
135
+	 *    usage:   EE_Registry::i18n_js_strings['string_key'] = esc_html__( 'string to translate.', 'event_espresso' );
136
+	 *    in js file:  var translatedString = eei18n.string_key;
137
+	 *
138
+	 * @var array $i18n_js_strings
139
+	 */
140
+	public static $i18n_js_strings = array();
141
+
142
+
143
+	/**
144
+	 * $main_file - path to espresso.php
145
+	 *
146
+	 * @var array $main_file
147
+	 */
148
+	public $main_file;
149
+
150
+	/**
151
+	 * array of ReflectionClass objects where the key is the class name
152
+	 *
153
+	 * @var ReflectionClass[] $_reflectors
154
+	 */
155
+	public $_reflectors;
156
+
157
+	/**
158
+	 * boolean flag to indicate whether or not to load/save dependencies from/to the cache
159
+	 *
160
+	 * @var boolean $_cache_on
161
+	 */
162
+	protected $_cache_on = true;
163
+
164
+
165
+
166
+	/**
167
+	 * @singleton method used to instantiate class object
168
+	 * @param  EE_Dependency_Map $dependency_map
169
+	 * @return EE_Registry instance
170
+	 */
171
+	public static function instance(EE_Dependency_Map $dependency_map = null)
172
+	{
173
+		// check if class object is instantiated
174
+		if (! self::$_instance instanceof EE_Registry) {
175
+			self::$_instance = new self($dependency_map);
176
+		}
177
+		return self::$_instance;
178
+	}
179
+
180
+
181
+
182
+	/**
183
+	 * protected constructor to prevent direct creation
184
+	 *
185
+	 * @Constructor
186
+	 * @param  EE_Dependency_Map $dependency_map
187
+	 */
188
+	protected function __construct(EE_Dependency_Map $dependency_map)
189
+	{
190
+		$this->_dependency_map = $dependency_map;
191
+		$this->LIB = new stdClass();
192
+		$this->addons = new stdClass();
193
+		$this->modules = new stdClass();
194
+		$this->shortcodes = new stdClass();
195
+		$this->widgets = new stdClass();
196
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
197
+	}
198
+
199
+
200
+
201
+	/**
202
+	 * initialize
203
+	 *
204
+	 * @throws EE_Error
205
+	 * @throws ReflectionException
206
+	 */
207
+	public function initialize()
208
+	{
209
+		$this->_class_abbreviations = apply_filters(
210
+			'FHEE__EE_Registry____construct___class_abbreviations',
211
+			array(
212
+				'EE_Config'                                       => 'CFG',
213
+				'EE_Session'                                      => 'SSN',
214
+				'EE_Capabilities'                                 => 'CAP',
215
+				'EE_Cart'                                         => 'CART',
216
+				'EE_Network_Config'                               => 'NET_CFG',
217
+				'EE_Request_Handler'                              => 'REQ',
218
+				'EE_Message_Resource_Manager'                     => 'MRM',
219
+				'EventEspresso\core\services\commands\CommandBus' => 'BUS',
220
+				'EventEspresso\core\services\assets\Registry'     => 'AssetsRegistry',
221
+			)
222
+		);
223
+		$this->load_core('Base', array(), true);
224
+		// add our request and response objects to the cache
225
+		$request_loader = $this->_dependency_map->class_loader('EE_Request');
226
+		$this->_set_cached_class(
227
+			$request_loader(),
228
+			'EE_Request'
229
+		);
230
+		$response_loader = $this->_dependency_map->class_loader('EE_Response');
231
+		$this->_set_cached_class(
232
+			$response_loader(),
233
+			'EE_Response'
234
+		);
235
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
236
+	}
237
+
238
+
239
+
240
+	/**
241
+	 * @return void
242
+	 */
243
+	public function init()
244
+	{
245
+		// Get current page protocol
246
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
247
+		// Output admin-ajax.php URL with same protocol as current page
248
+		self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
249
+		self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
250
+	}
251
+
252
+
253
+
254
+	/**
255
+	 * localize_i18n_js_strings
256
+	 *
257
+	 * @return string
258
+	 */
259
+	public static function localize_i18n_js_strings()
260
+	{
261
+		$i18n_js_strings = (array)self::$i18n_js_strings;
262
+		foreach ($i18n_js_strings as $key => $value) {
263
+			if (is_scalar($value)) {
264
+				$i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
265
+			}
266
+		}
267
+		return '/* <![CDATA[ */ var eei18n = ' . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
268
+	}
269
+
270
+
271
+
272
+	/**
273
+	 * @param $module
274
+	 * @throws EE_Error
275
+	 * @throws ReflectionException
276
+	 */
277
+	public function add_module($module)
278
+	{
279
+		if ($module instanceof EED_Module) {
280
+			$module_class = get_class($module);
281
+			$this->modules->{$module_class} = $module;
282
+		} else {
283
+			if (! class_exists('EE_Module_Request_Router')) {
284
+				$this->load_core('Module_Request_Router');
285
+			}
286
+			EE_Module_Request_Router::module_factory($module);
287
+		}
288
+	}
289
+
290
+
291
+
292
+	/**
293
+	 * @param string $module_name
294
+	 * @return mixed EED_Module | NULL
295
+	 */
296
+	public function get_module($module_name = '')
297
+	{
298
+		return isset($this->modules->{$module_name})
299
+			? $this->modules->{$module_name}
300
+			: null;
301
+	}
302
+
303
+
304
+
305
+	/**
306
+	 * loads core classes - must be singletons
307
+	 *
308
+	 * @param string $class_name - simple class name ie: session
309
+	 * @param mixed  $arguments
310
+	 * @param bool   $load_only
311
+	 * @return mixed
312
+	 * @throws EE_Error
313
+	 * @throws ReflectionException
314
+	 */
315
+	public function load_core($class_name, $arguments = array(), $load_only = false)
316
+	{
317
+		$core_paths = apply_filters(
318
+			'FHEE__EE_Registry__load_core__core_paths',
319
+			array(
320
+				EE_CORE,
321
+				EE_ADMIN,
322
+				EE_CPTS,
323
+				EE_CORE . 'data_migration_scripts' . DS,
324
+				EE_CORE . 'request_stack' . DS,
325
+				EE_CORE . 'middleware' . DS,
326
+			)
327
+		);
328
+		// retrieve instantiated class
329
+		return $this->_load(
330
+			$core_paths,
331
+			'EE_',
332
+			$class_name,
333
+			'core',
334
+			$arguments,
335
+			false,
336
+			true,
337
+			$load_only
338
+		);
339
+	}
340
+
341
+
342
+
343
+	/**
344
+	 * loads service classes
345
+	 *
346
+	 * @param string $class_name - simple class name ie: session
347
+	 * @param mixed  $arguments
348
+	 * @param bool   $load_only
349
+	 * @return mixed
350
+	 * @throws EE_Error
351
+	 * @throws ReflectionException
352
+	 */
353
+	public function load_service($class_name, $arguments = array(), $load_only = false)
354
+	{
355
+		$service_paths = apply_filters(
356
+			'FHEE__EE_Registry__load_service__service_paths',
357
+			array(
358
+				EE_CORE . 'services' . DS,
359
+			)
360
+		);
361
+		// retrieve instantiated class
362
+		return $this->_load(
363
+			$service_paths,
364
+			'EE_',
365
+			$class_name,
366
+			'class',
367
+			$arguments,
368
+			false,
369
+			true,
370
+			$load_only
371
+		);
372
+	}
373
+
374
+
375
+
376
+	/**
377
+	 * loads data_migration_scripts
378
+	 *
379
+	 * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
380
+	 * @param mixed  $arguments
381
+	 * @return EE_Data_Migration_Script_Base|mixed
382
+	 * @throws EE_Error
383
+	 * @throws ReflectionException
384
+	 */
385
+	public function load_dms($class_name, $arguments = array())
386
+	{
387
+		// retrieve instantiated class
388
+		return $this->_load(
389
+			EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(),
390
+			'EE_DMS_',
391
+			$class_name,
392
+			'dms',
393
+			$arguments,
394
+			false,
395
+			false
396
+		);
397
+	}
398
+
399
+
400
+
401
+	/**
402
+	 * loads object creating classes - must be singletons
403
+	 *
404
+	 * @param string $class_name - simple class name ie: attendee
405
+	 * @param mixed  $arguments  - an array of arguments to pass to the class
406
+	 * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to
407
+	 *                           instantiate
408
+	 * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then
409
+	 *                           set this to FALSE (ie. when instantiating model objects from client in a loop)
410
+	 * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate
411
+	 *                           (default)
412
+	 * @return EE_Base_Class | bool
413
+	 * @throws EE_Error
414
+	 * @throws ReflectionException
415
+	 */
416
+	public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
417
+	{
418
+		$paths = apply_filters(
419
+			'FHEE__EE_Registry__load_class__paths', array(
420
+			EE_CORE,
421
+			EE_CLASSES,
422
+			EE_BUSINESS,
423
+		)
424
+		);
425
+		// retrieve instantiated class
426
+		return $this->_load(
427
+			$paths,
428
+			'EE_',
429
+			$class_name,
430
+			'class',
431
+			$arguments,
432
+			$from_db,
433
+			$cache,
434
+			$load_only
435
+		);
436
+	}
437
+
438
+
439
+
440
+	/**
441
+	 * loads helper classes - must be singletons
442
+	 *
443
+	 * @param string $class_name - simple class name ie: price
444
+	 * @param mixed  $arguments
445
+	 * @param bool   $load_only
446
+	 * @return EEH_Base | bool
447
+	 * @throws EE_Error
448
+	 * @throws ReflectionException
449
+	 */
450
+	public function load_helper($class_name, $arguments = array(), $load_only = true)
451
+	{
452
+		// todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
453
+		$helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
454
+		// retrieve instantiated class
455
+		return $this->_load(
456
+			$helper_paths,
457
+			'EEH_',
458
+			$class_name,
459
+			'helper',
460
+			$arguments,
461
+			false,
462
+			true,
463
+			$load_only
464
+		);
465
+	}
466
+
467
+
468
+
469
+	/**
470
+	 * loads core classes - must be singletons
471
+	 *
472
+	 * @param string $class_name - simple class name ie: session
473
+	 * @param mixed  $arguments
474
+	 * @param bool   $load_only
475
+	 * @param bool   $cache      whether to cache the object or not.
476
+	 * @return mixed
477
+	 * @throws EE_Error
478
+	 * @throws ReflectionException
479
+	 */
480
+	public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
481
+	{
482
+		$paths = array(
483
+			EE_LIBRARIES,
484
+			EE_LIBRARIES . 'messages' . DS,
485
+			EE_LIBRARIES . 'shortcodes' . DS,
486
+			EE_LIBRARIES . 'qtips' . DS,
487
+			EE_LIBRARIES . 'payment_methods' . DS,
488
+		);
489
+		// retrieve instantiated class
490
+		return $this->_load(
491
+			$paths,
492
+			'EE_',
493
+			$class_name,
494
+			'lib',
495
+			$arguments,
496
+			false,
497
+			$cache,
498
+			$load_only
499
+		);
500
+	}
501
+
502
+
503
+
504
+	/**
505
+	 * loads model classes - must be singletons
506
+	 *
507
+	 * @param string $class_name - simple class name ie: price
508
+	 * @param mixed  $arguments
509
+	 * @param bool   $load_only
510
+	 * @return EEM_Base | bool
511
+	 * @throws EE_Error
512
+	 * @throws ReflectionException
513
+	 */
514
+	public function load_model($class_name, $arguments = array(), $load_only = false)
515
+	{
516
+		$paths = apply_filters(
517
+			'FHEE__EE_Registry__load_model__paths', array(
518
+			EE_MODELS,
519
+			EE_CORE,
520
+		)
521
+		);
522
+		// retrieve instantiated class
523
+		return $this->_load(
524
+			$paths,
525
+			'EEM_',
526
+			$class_name,
527
+			'model',
528
+			$arguments,
529
+			false,
530
+			true,
531
+			$load_only
532
+		);
533
+	}
534
+
535
+
536
+
537
+	/**
538
+	 * loads model classes - must be singletons
539
+	 *
540
+	 * @param string $class_name - simple class name ie: price
541
+	 * @param mixed  $arguments
542
+	 * @param bool   $load_only
543
+	 * @return mixed | bool
544
+	 * @throws EE_Error
545
+	 * @throws ReflectionException
546
+	 */
547
+	public function load_model_class($class_name, $arguments = array(), $load_only = true)
548
+	{
549
+		$paths = array(
550
+			EE_MODELS . 'fields' . DS,
551
+			EE_MODELS . 'helpers' . DS,
552
+			EE_MODELS . 'relations' . DS,
553
+			EE_MODELS . 'strategies' . DS,
554
+		);
555
+		// retrieve instantiated class
556
+		return $this->_load(
557
+			$paths,
558
+			'EE_',
559
+			$class_name,
560
+			'',
561
+			$arguments,
562
+			false,
563
+			true,
564
+			$load_only
565
+		);
566
+	}
567
+
568
+
569
+
570
+	/**
571
+	 * Determines if $model_name is the name of an actual EE model.
572
+	 *
573
+	 * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
574
+	 * @return boolean
575
+	 */
576
+	public function is_model_name($model_name)
577
+	{
578
+		return isset($this->models[$model_name]);
579
+	}
580
+
581
+
582
+
583
+	/**
584
+	 * generic class loader
585
+	 *
586
+	 * @param string $path_to_file - directory path to file location, not including filename
587
+	 * @param string $file_name    - file name  ie:  my_file.php, including extension
588
+	 * @param string $type         - file type - core? class? helper? model?
589
+	 * @param mixed  $arguments
590
+	 * @param bool   $load_only
591
+	 * @return mixed
592
+	 * @throws EE_Error
593
+	 * @throws ReflectionException
594
+	 */
595
+	public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
596
+	{
597
+		// retrieve instantiated class
598
+		return $this->_load(
599
+			$path_to_file,
600
+			'',
601
+			$file_name,
602
+			$type,
603
+			$arguments,
604
+			false,
605
+			true,
606
+			$load_only
607
+		);
608
+	}
609
+
610
+
611
+
612
+	/**
613
+	 * @param string $path_to_file - directory path to file location, not including filename
614
+	 * @param string $class_name   - full class name  ie:  My_Class
615
+	 * @param string $type         - file type - core? class? helper? model?
616
+	 * @param mixed  $arguments
617
+	 * @param bool   $load_only
618
+	 * @return bool|EE_Addon|object
619
+	 * @throws EE_Error
620
+	 * @throws ReflectionException
621
+	 */
622
+	public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
623
+	{
624
+		// retrieve instantiated class
625
+		return $this->_load(
626
+			$path_to_file,
627
+			'addon',
628
+			$class_name,
629
+			$type,
630
+			$arguments,
631
+			false,
632
+			true,
633
+			$load_only
634
+		);
635
+	}
636
+
637
+
638
+
639
+	/**
640
+	 * instantiates, caches, and automatically resolves dependencies
641
+	 * for classes that use a Fully Qualified Class Name.
642
+	 * if the class is not capable of being loaded using PSR-4 autoloading,
643
+	 * then you need to use one of the existing load_*() methods
644
+	 * which can resolve the classname and filepath from the passed arguments
645
+	 *
646
+	 * @param bool|string $class_name   Fully Qualified Class Name
647
+	 * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
648
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
649
+	 * @param bool        $from_db      some classes are instantiated from the db
650
+	 *                                  and thus call a different method to instantiate
651
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
652
+	 * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
653
+	 * @return bool|null|object null = failure to load or instantiate class object.
654
+	 *                                  object = class loaded and instantiated successfully.
655
+	 *                                  bool = fail or success when $load_only is true
656
+	 * @throws EE_Error
657
+	 * @throws ReflectionException
658
+	 */
659
+	public function create(
660
+		$class_name = false,
661
+		$arguments = array(),
662
+		$cache = false,
663
+		$from_db = false,
664
+		$load_only = false,
665
+		$addon = false
666
+	) {
667
+		$class_name = ltrim($class_name, '\\');
668
+		$class_name = $this->_dependency_map->get_alias($class_name);
669
+		if (! class_exists($class_name)) {
670
+			// maybe the class is registered with a preceding \
671
+			$class_name = strpos($class_name, '\\') !== 0
672
+				? '\\' . $class_name
673
+				: $class_name;
674
+			// still doesn't exist ?
675
+			if (! class_exists($class_name)) {
676
+				return null;
677
+			}
678
+		}
679
+		// if we're only loading the class and it already exists, then let's just return true immediately
680
+		if ($load_only) {
681
+			return true;
682
+		}
683
+		$addon = $addon
684
+			? 'addon'
685
+			: '';
686
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
687
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
688
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
689
+		if ($this->_cache_on && $cache && ! $load_only) {
690
+			// return object if it's already cached
691
+			$cached_class = $this->_get_cached_class($class_name, $addon);
692
+			if ($cached_class !== null) {
693
+				return $cached_class;
694
+			}
695
+		}
696
+		// instantiate the requested object
697
+		$class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
698
+		if ($this->_cache_on && $cache) {
699
+			// save it for later... kinda like gum  { : $
700
+			$this->_set_cached_class($class_obj, $class_name, $addon, $from_db);
701
+		}
702
+		$this->_cache_on = true;
703
+		return $class_obj;
704
+	}
705
+
706
+
707
+
708
+	/**
709
+	 * instantiates, caches, and injects dependencies for classes
710
+	 *
711
+	 * @param array       $file_paths   an array of paths to folders to look in
712
+	 * @param string      $class_prefix EE  or EEM or... ???
713
+	 * @param bool|string $class_name   $class name
714
+	 * @param string      $type         file type - core? class? helper? model?
715
+	 * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
716
+	 * @param bool        $from_db      some classes are instantiated from the db
717
+	 *                                  and thus call a different method to instantiate
718
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
719
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
720
+	 * @return bool|null|object null = failure to load or instantiate class object.
721
+	 *                                  object = class loaded and instantiated successfully.
722
+	 *                                  bool = fail or success when $load_only is true
723
+	 * @throws EE_Error
724
+	 * @throws ReflectionException
725
+	 */
726
+	protected function _load(
727
+		$file_paths = array(),
728
+		$class_prefix = 'EE_',
729
+		$class_name = false,
730
+		$type = 'class',
731
+		$arguments = array(),
732
+		$from_db = false,
733
+		$cache = true,
734
+		$load_only = false
735
+	) {
736
+		$class_name = ltrim($class_name, '\\');
737
+		// strip php file extension
738
+		$class_name = str_replace('.php', '', trim($class_name));
739
+		// does the class have a prefix ?
740
+		if (! empty($class_prefix) && $class_prefix !== 'addon') {
741
+			// make sure $class_prefix is uppercase
742
+			$class_prefix = strtoupper(trim($class_prefix));
743
+			// add class prefix ONCE!!!
744
+			$class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
745
+		}
746
+		$class_name = $this->_dependency_map->get_alias($class_name);
747
+		$class_exists = class_exists($class_name);
748
+		// if we're only loading the class and it already exists, then let's just return true immediately
749
+		if ($load_only && $class_exists) {
750
+			return true;
751
+		}
752
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
753
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
754
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
755
+		if ($this->_cache_on && $cache && ! $load_only) {
756
+			// return object if it's already cached
757
+			$cached_class = $this->_get_cached_class($class_name, $class_prefix);
758
+			if ($cached_class !== null) {
759
+				return $cached_class;
760
+			}
761
+		}
762
+		// if the class doesn't already exist.. then we need to try and find the file and load it
763
+		if (! $class_exists) {
764
+			// get full path to file
765
+			$path = $this->_resolve_path($class_name, $type, $file_paths);
766
+			// load the file
767
+			$loaded = $this->_require_file($path, $class_name, $type, $file_paths);
768
+			// if loading failed, or we are only loading a file but NOT instantiating an object
769
+			if (! $loaded || $load_only) {
770
+				// return boolean if only loading, or null if an object was expected
771
+				return $load_only
772
+					? $loaded
773
+					: null;
774
+			}
775
+		}
776
+		// instantiate the requested object
777
+		$class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
778
+		if ($this->_cache_on && $cache) {
779
+			// save it for later... kinda like gum  { : $
780
+			$this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
781
+		}
782
+		$this->_cache_on = true;
783
+		return $class_obj;
784
+	}
785
+
786
+
787
+
788
+	/**
789
+	 * attempts to find a cached version of the requested class
790
+	 * by looking in the following places:
791
+	 *        $this->{$class_abbreviation}            ie:    $this->CART
792
+	 *        $this->{$class_name}                        ie:    $this->Some_Class
793
+	 *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
794
+	 *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
795
+	 *
796
+	 * @param string $class_name
797
+	 * @param string $class_prefix
798
+	 * @return mixed
799
+	 */
800
+	protected function _get_cached_class($class_name, $class_prefix = '')
801
+	{
802
+		if ($class_name === 'EE_Registry') {
803
+			return $this;
804
+		}
805
+		// have to specify something, but not anything that will conflict
806
+		$class_abbreviation = isset($this->_class_abbreviations[$class_name])
807
+			? $this->_class_abbreviations[$class_name]
808
+			: 'FANCY_BATMAN_PANTS';
809
+		$class_name = str_replace('\\', '_', $class_name);
810
+		// check if class has already been loaded, and return it if it has been
811
+		if (isset($this->{$class_abbreviation})) {
812
+			return $this->{$class_abbreviation};
813
+		}
814
+		if (isset ($this->{$class_name})) {
815
+			return $this->{$class_name};
816
+		}
817
+		if (isset ($this->LIB->{$class_name})) {
818
+			return $this->LIB->{$class_name};
819
+		}
820
+		if ($class_prefix === 'addon' && isset ($this->addons->{$class_name})) {
821
+			return $this->addons->{$class_name};
822
+		}
823
+		return null;
824
+	}
825
+
826
+
827
+
828
+	/**
829
+	 * removes a cached version of the requested class
830
+	 *
831
+	 * @param string  $class_name
832
+	 * @param boolean $addon
833
+	 * @return boolean
834
+	 */
835
+	public function clear_cached_class($class_name, $addon = false)
836
+	{
837
+		// have to specify something, but not anything that will conflict
838
+		$class_abbreviation = isset($this->_class_abbreviations[$class_name])
839
+			? $this->_class_abbreviations[$class_name]
840
+			: 'FANCY_BATMAN_PANTS';
841
+		$class_name = str_replace('\\', '_', $class_name);
842
+		// check if class has already been loaded, and return it if it has been
843
+		if (isset($this->{$class_abbreviation})) {
844
+			$this->{$class_abbreviation} = null;
845
+			return true;
846
+		}
847
+		if (isset($this->{$class_name})) {
848
+			$this->{$class_name} = null;
849
+			return true;
850
+		}
851
+		if (isset($this->LIB->{$class_name})) {
852
+			unset($this->LIB->{$class_name});
853
+			return true;
854
+		}
855
+		if ($addon && isset($this->addons->{$class_name})) {
856
+			unset($this->addons->{$class_name});
857
+			return true;
858
+		}
859
+		return false;
860
+	}
861
+
862
+
863
+
864
+	/**
865
+	 * attempts to find a full valid filepath for the requested class.
866
+	 * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
867
+	 * then returns that path if the target file has been found and is readable
868
+	 *
869
+	 * @param string $class_name
870
+	 * @param string $type
871
+	 * @param array  $file_paths
872
+	 * @return string | bool
873
+	 */
874
+	protected function _resolve_path($class_name, $type = '', $file_paths = array())
875
+	{
876
+		// make sure $file_paths is an array
877
+		$file_paths = is_array($file_paths)
878
+			? $file_paths
879
+			: array($file_paths);
880
+		// cycle thru paths
881
+		foreach ($file_paths as $key => $file_path) {
882
+			// convert all separators to proper DS, if no filepath, then use EE_CLASSES
883
+			$file_path = $file_path
884
+				? str_replace(array('/', '\\'), DS, $file_path)
885
+				: EE_CLASSES;
886
+			// prep file type
887
+			$type = ! empty($type)
888
+				? trim($type, '.') . '.'
889
+				: '';
890
+			// build full file path
891
+			$file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
892
+			//does the file exist and can be read ?
893
+			if (is_readable($file_paths[$key])) {
894
+				return $file_paths[$key];
895
+			}
896
+		}
897
+		return false;
898
+	}
899
+
900
+
901
+
902
+	/**
903
+	 * basically just performs a require_once()
904
+	 * but with some error handling
905
+	 *
906
+	 * @param  string $path
907
+	 * @param  string $class_name
908
+	 * @param  string $type
909
+	 * @param  array  $file_paths
910
+	 * @return bool
911
+	 * @throws EE_Error
912
+	 * @throws ReflectionException
913
+	 */
914
+	protected function _require_file($path, $class_name, $type = '', $file_paths = array())
915
+	{
916
+		// don't give up! you gotta...
917
+		try {
918
+			//does the file exist and can it be read ?
919
+			if (! $path) {
920
+				// so sorry, can't find the file
921
+				throw new EE_Error (
922
+					sprintf(
923
+						esc_html__(
924
+							'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',
925
+							'event_espresso'
926
+						),
927
+						trim($type, '.'),
928
+						$class_name,
929
+						'<br />' . implode(',<br />', $file_paths)
930
+					)
931
+				);
932
+			}
933
+			// get the file
934
+			require_once($path);
935
+			// if the class isn't already declared somewhere
936
+			if (class_exists($class_name, false) === false) {
937
+				// so sorry, not a class
938
+				throw new EE_Error(
939
+					sprintf(
940
+						esc_html__('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
941
+						$type,
942
+						$path,
943
+						$class_name
944
+					)
945
+				);
946
+			}
947
+		} catch (EE_Error $e) {
948
+			$e->get_error();
949
+			return false;
950
+		}
951
+		return true;
952
+	}
953
+
954
+
955
+
956
+	/**
957
+	 * _create_object
958
+	 * Attempts to instantiate the requested class via any of the
959
+	 * commonly used instantiation methods employed throughout EE.
960
+	 * The priority for instantiation is as follows:
961
+	 *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
962
+	 *        - model objects via their 'new_instance_from_db' method
963
+	 *        - model objects via their 'new_instance' method
964
+	 *        - "singleton" classes" via their 'instance' method
965
+	 *    - standard instantiable classes via their __constructor
966
+	 * Prior to instantiation, if the classname exists in the dependency_map,
967
+	 * then the constructor for the requested class will be examined to determine
968
+	 * if any dependencies exist, and if they can be injected.
969
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
970
+	 *
971
+	 * @param string $class_name
972
+	 * @param array  $arguments
973
+	 * @param string $type
974
+	 * @param bool   $from_db
975
+	 * @return null|object
976
+	 * @throws EE_Error
977
+	 * @throws ReflectionException
978
+	 */
979
+	protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
980
+	{
981
+		$class_obj = null;
982
+		$instantiation_mode = '0) none';
983
+		// don't give up! you gotta...
984
+		try {
985
+			// create reflection
986
+			$reflector = $this->get_ReflectionClass($class_name);
987
+			// make sure arguments are an array
988
+			$arguments = is_array($arguments)
989
+				? $arguments
990
+				: array($arguments);
991
+			// and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
992
+			// else wrap it in an additional array so that it doesn't get split into multiple parameters
993
+			$arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
994
+				? $arguments
995
+				: array($arguments);
996
+			// attempt to inject dependencies ?
997
+			if ($this->_dependency_map->has($class_name)) {
998
+				$arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
999
+			}
1000
+			// instantiate the class if possible
1001
+			if ($reflector->isAbstract()) {
1002
+				// nothing to instantiate, loading file was enough
1003
+				// does not throw an exception so $instantiation_mode is unused
1004
+				// $instantiation_mode = "1) no constructor abstract class";
1005
+				$class_obj = true;
1006
+			} else if (empty($arguments) && $reflector->getConstructor() === null && $reflector->isInstantiable()) {
1007
+				// no constructor = static methods only... nothing to instantiate, loading file was enough
1008
+				$instantiation_mode = '2) no constructor but instantiable';
1009
+				$class_obj = $reflector->newInstance();
1010
+			} else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
1011
+				$instantiation_mode = '3) new_instance_from_db()';
1012
+				$class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
1013
+			} else if (method_exists($class_name, 'new_instance')) {
1014
+				$instantiation_mode = '4) new_instance()';
1015
+				$class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
1016
+			} else if (method_exists($class_name, 'instance')) {
1017
+				$instantiation_mode = '5) instance()';
1018
+				$class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
1019
+			} else if ($reflector->isInstantiable()) {
1020
+				$instantiation_mode = '6) constructor';
1021
+				$class_obj = $reflector->newInstanceArgs($arguments);
1022
+			} else {
1023
+				// heh ? something's not right !
1024
+				throw new EE_Error(
1025
+					sprintf(
1026
+						esc_html__('The %s file %s could not be instantiated.', 'event_espresso'),
1027
+						$type,
1028
+						$class_name
1029
+					)
1030
+				);
1031
+			}
1032
+		} catch (Exception $e) {
1033
+			if (! $e instanceof EE_Error) {
1034
+				$e = new EE_Error(
1035
+					sprintf(
1036
+						esc_html__(
1037
+							'The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s',
1038
+							'event_espresso'
1039
+						),
1040
+						$class_name,
1041
+						'<br />',
1042
+						$e->getMessage(),
1043
+						$instantiation_mode
1044
+					)
1045
+				);
1046
+			}
1047
+			$e->get_error();
1048
+		}
1049
+		return $class_obj;
1050
+	}
1051
+
1052
+
1053
+
1054
+	/**
1055
+	 * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
1056
+	 * @param array $array
1057
+	 * @return bool
1058
+	 */
1059
+	protected function _array_is_numerically_and_sequentially_indexed(array $array)
1060
+	{
1061
+		return ! empty($array)
1062
+			? array_keys($array) === range(0, count($array) - 1)
1063
+			: true;
1064
+	}
1065
+
1066
+
1067
+
1068
+	/**
1069
+	 * getReflectionClass
1070
+	 * checks if a ReflectionClass object has already been generated for a class
1071
+	 * and returns that instead of creating a new one
1072
+	 *
1073
+	 * @param string $class_name
1074
+	 * @return ReflectionClass
1075
+	 * @throws ReflectionException
1076
+	 */
1077
+	public function get_ReflectionClass($class_name)
1078
+	{
1079
+		if (
1080
+			! isset($this->_reflectors[$class_name])
1081
+			|| ! $this->_reflectors[$class_name] instanceof ReflectionClass
1082
+		) {
1083
+			$this->_reflectors[$class_name] = new ReflectionClass($class_name);
1084
+		}
1085
+		return $this->_reflectors[$class_name];
1086
+	}
1087
+
1088
+
1089
+
1090
+	/**
1091
+	 * _resolve_dependencies
1092
+	 * examines the constructor for the requested class to determine
1093
+	 * if any dependencies exist, and if they can be injected.
1094
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
1095
+	 * PLZ NOTE: this is achieved by type hinting the constructor params
1096
+	 * For example:
1097
+	 *        if attempting to load a class "Foo" with the following constructor:
1098
+	 *        __construct( Bar $bar_class, Fighter $grohl_class )
1099
+	 *        then $bar_class and $grohl_class will be added to the $arguments array,
1100
+	 *        but only IF they are NOT already present in the incoming arguments array,
1101
+	 *        and the correct classes can be loaded
1102
+	 *
1103
+	 * @param ReflectionClass $reflector
1104
+	 * @param string          $class_name
1105
+	 * @param array           $arguments
1106
+	 * @return array
1107
+	 * @throws EE_Error
1108
+	 * @throws ReflectionException
1109
+	 */
1110
+	protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array())
1111
+	{
1112
+		// let's examine the constructor
1113
+		$constructor = $reflector->getConstructor();
1114
+		// whu? huh? nothing?
1115
+		if (! $constructor) {
1116
+			return $arguments;
1117
+		}
1118
+		// get constructor parameters
1119
+		$params = $constructor->getParameters();
1120
+		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
1121
+		$argument_keys = array_keys($arguments);
1122
+		// now loop thru all of the constructors expected parameters
1123
+		foreach ($params as $index => $param) {
1124
+			// is this a dependency for a specific class ?
1125
+			$param_class = $param->getClass()
1126
+				? $param->getClass()->name
1127
+				: null;
1128
+			// BUT WAIT !!! This class may be an alias for something else (or getting replaced at runtime)
1129
+			$param_class = $this->_dependency_map->has_alias($param_class, $class_name)
1130
+				? $this->_dependency_map->get_alias($param_class, $class_name)
1131
+				: $param_class;
1132
+			if (
1133
+				// param is not even a class
1134
+				empty($param_class)
1135
+				// and something already exists in the incoming arguments for this param
1136
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
1137
+			) {
1138
+				// so let's skip this argument and move on to the next
1139
+				continue;
1140
+			}
1141
+			if (
1142
+				// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
1143
+				! empty($param_class)
1144
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
1145
+				&& $arguments[$argument_keys[$index]] instanceof $param_class
1146
+			) {
1147
+				// skip this argument and move on to the next
1148
+				continue;
1149
+			}
1150
+			if (
1151
+				// parameter is type hinted as a class, and should be injected
1152
+				! empty($param_class)
1153
+				&& $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1154
+			) {
1155
+				$arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index);
1156
+			} else {
1157
+				try {
1158
+					$arguments[$index] = $param->getDefaultValue();
1159
+				} catch (ReflectionException $e) {
1160
+					throw new ReflectionException(
1161
+						sprintf(
1162
+							esc_html__('%1$s for parameter "$%2$s"', 'event_espresso'),
1163
+							$e->getMessage(),
1164
+							$param->getName()
1165
+						)
1166
+					);
1167
+				}
1168
+			}
1169
+		}
1170
+		return $arguments;
1171
+	}
1172
+
1173
+
1174
+
1175
+	/**
1176
+	 * @param string $class_name
1177
+	 * @param string $param_class
1178
+	 * @param array  $arguments
1179
+	 * @param mixed  $index
1180
+	 * @return array
1181
+	 * @throws EE_Error
1182
+	 * @throws ReflectionException
1183
+	 */
1184
+	protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1185
+	{
1186
+		$dependency = null;
1187
+		// should dependency be loaded from cache ?
1188
+		$cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class)
1189
+					!== EE_Dependency_Map::load_new_object;
1190
+		// we might have a dependency...
1191
+		// let's MAYBE try and find it in our cache if that's what's been requested
1192
+		$cached_class = $cache_on
1193
+			? $this->_get_cached_class($param_class)
1194
+			: null;
1195
+		// and grab it if it exists
1196
+		if ($cached_class instanceof $param_class) {
1197
+			$dependency = $cached_class;
1198
+		} else if ($param_class !== $class_name) {
1199
+			// obtain the loader method from the dependency map
1200
+			$loader = $this->_dependency_map->class_loader($param_class);
1201
+			// is loader a custom closure ?
1202
+			if ($loader instanceof Closure) {
1203
+				$dependency = $loader();
1204
+			} else {
1205
+				// set the cache on property for the recursive loading call
1206
+				$this->_cache_on = $cache_on;
1207
+				// if not, then let's try and load it via the registry
1208
+				if ($loader && method_exists($this, $loader)) {
1209
+					$dependency = $this->{$loader}($param_class);
1210
+				} else {
1211
+					$dependency = $this->create($param_class, array(), $cache_on);
1212
+				}
1213
+			}
1214
+		}
1215
+		// did we successfully find the correct dependency ?
1216
+		if ($dependency instanceof $param_class) {
1217
+			// then let's inject it into the incoming array of arguments at the correct location
1218
+			if (isset($argument_keys[$index])) {
1219
+				$arguments[$argument_keys[$index]] = $dependency;
1220
+			} else {
1221
+				$arguments[$index] = $dependency;
1222
+			}
1223
+		}
1224
+		return $arguments;
1225
+	}
1226
+
1227
+
1228
+
1229
+	/**
1230
+	 * _set_cached_class
1231
+	 * attempts to cache the instantiated class locally
1232
+	 * in one of the following places, in the following order:
1233
+	 *        $this->{class_abbreviation}   ie:    $this->CART
1234
+	 *        $this->{$class_name}          ie:    $this->Some_Class
1235
+	 *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1236
+	 *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1237
+	 *
1238
+	 * @param object $class_obj
1239
+	 * @param string $class_name
1240
+	 * @param string $class_prefix
1241
+	 * @param bool   $from_db
1242
+	 * @return void
1243
+	 */
1244
+	protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false)
1245
+	{
1246
+		if ($class_name === 'EE_Registry' || empty($class_obj)) {
1247
+			return;
1248
+		}
1249
+		// return newly instantiated class
1250
+		if (isset($this->_class_abbreviations[$class_name])) {
1251
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
1252
+			$this->{$class_abbreviation} = $class_obj;
1253
+			return;
1254
+		}
1255
+		$class_name = str_replace('\\', '_', $class_name);
1256
+		if (property_exists($this, $class_name)) {
1257
+			$this->{$class_name} = $class_obj;
1258
+			return;
1259
+		}
1260
+		if ($class_prefix === 'addon') {
1261
+			$this->addons->{$class_name} = $class_obj;
1262
+			return;
1263
+		}
1264
+		if (! $from_db) {
1265
+			$this->LIB->{$class_name} = $class_obj;
1266
+		}
1267
+	}
1268
+
1269
+
1270
+
1271
+	/**
1272
+	 * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1273
+	 *
1274
+	 * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1275
+	 *                          in the EE_Dependency_Map::$_class_loaders array,
1276
+	 *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1277
+	 * @param array  $arguments
1278
+	 * @return object
1279
+	 */
1280
+	public static function factory($classname, $arguments = array())
1281
+	{
1282
+		$loader = self::instance()->_dependency_map->class_loader($classname);
1283
+		if ($loader instanceof Closure) {
1284
+			return $loader($arguments);
1285
+		}
1286
+		if (method_exists(self::instance(), $loader)) {
1287
+			return self::instance()->{$loader}($classname, $arguments);
1288
+		}
1289
+		return null;
1290
+	}
1291
+
1292
+
1293
+
1294
+	/**
1295
+	 * Gets the addon by its name/slug (not classname. For that, just
1296
+	 * use the classname as the property name on EE_Config::instance()->addons)
1297
+	 *
1298
+	 * @param string $name
1299
+	 * @return EE_Addon
1300
+	 */
1301
+	public function get_addon_by_name($name)
1302
+	{
1303
+		foreach ($this->addons as $addon) {
1304
+			if ($addon->name() === $name) {
1305
+				return $addon;
1306
+			}
1307
+		}
1308
+		return null;
1309
+	}
1310
+
1311
+
1312
+
1313
+	/**
1314
+	 * Gets an array of all the registered addons, where the keys are their names. (ie, what each returns for their
1315
+	 * name() function) They're already available on EE_Config::instance()->addons as properties, where each property's
1316
+	 * name is the addon's classname. So if you just want to get the addon by classname, use
1317
+	 * EE_Config::instance()->addons->{classname}
1318
+	 *
1319
+	 * @return EE_Addon[] where the KEYS are the addon's name()
1320
+	 */
1321
+	public function get_addons_by_name()
1322
+	{
1323
+		$addons = array();
1324
+		foreach ($this->addons as $addon) {
1325
+			$addons[$addon->name()] = $addon;
1326
+		}
1327
+		return $addons;
1328
+	}
1329
+
1330
+
1331
+
1332
+	/**
1333
+	 * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1334
+	 * a stale copy of it around
1335
+	 *
1336
+	 * @param string $model_name
1337
+	 * @return \EEM_Base
1338
+	 * @throws \EE_Error
1339
+	 */
1340
+	public function reset_model($model_name)
1341
+	{
1342
+		$model_class_name = strpos($model_name, 'EEM_') !== 0
1343
+			? "EEM_{$model_name}"
1344
+			: $model_name;
1345
+		if (! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1346
+			return null;
1347
+		}
1348
+		//get that model reset it and make sure we nuke the old reference to it
1349
+		if ($this->LIB->{$model_class_name} instanceof $model_class_name
1350
+			&& is_callable(
1351
+				array($model_class_name, 'reset')
1352
+			)) {
1353
+			$this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1354
+		} else {
1355
+			throw new EE_Error(sprintf(esc_html__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1356
+		}
1357
+		return $this->LIB->{$model_class_name};
1358
+	}
1359
+
1360
+
1361
+
1362
+	/**
1363
+	 * Resets the registry.
1364
+	 * The criteria for what gets reset is based on what can be shared between sites on the same request when
1365
+	 * switch_to_blog is used in a multisite install.  Here is a list of things that are NOT reset.
1366
+	 * - $_dependency_map
1367
+	 * - $_class_abbreviations
1368
+	 * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1369
+	 * - $REQ:  Still on the same request so no need to change.
1370
+	 * - $CAP: There is no site specific state in the EE_Capability class.
1371
+	 * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only
1372
+	 * one Session can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1373
+	 * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1374
+	 *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1375
+	 *             switch or on the restore.
1376
+	 * - $modules
1377
+	 * - $shortcodes
1378
+	 * - $widgets
1379
+	 *
1380
+	 * @param boolean $hard             whether to reset data in the database too, or just refresh
1381
+	 *                                  the Registry to its state at the beginning of the request
1382
+	 * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1383
+	 *                                  or just reset without re-instantiating (handy to set to FALSE if you're not
1384
+	 *                                  sure if you CAN currently reinstantiate the singletons at the moment)
1385
+	 * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so
1386
+	 *                                  client
1387
+	 *                                  code instead can just change the model context to a different blog id if
1388
+	 *                                  necessary
1389
+	 * @return EE_Registry
1390
+	 * @throws EE_Error
1391
+	 * @throws ReflectionException
1392
+	 */
1393
+	public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1394
+	{
1395
+		$instance = self::instance();
1396
+		$instance->_cache_on = true;
1397
+		// reset some "special" classes
1398
+		EEH_Activation::reset();
1399
+		$instance->CFG = EE_Config::reset($hard, $reinstantiate);
1400
+		$instance->CART = null;
1401
+		$instance->MRM = null;
1402
+		$instance->AssetsRegistry = $instance->create('EventEspresso\core\services\assets\Registry');
1403
+		//messages reset
1404
+		EED_Messages::reset();
1405
+		//handle of objects cached on LIB
1406
+		foreach (array('LIB', 'modules') as $cache) {
1407
+			foreach ($instance->{$cache} as $class_name => $class) {
1408
+				if (self::_reset_and_unset_object($class, $reset_models)) {
1409
+					unset($instance->{$cache}->{$class_name});
1410
+				}
1411
+			}
1412
+		}
1413
+		return $instance;
1414
+	}
1415
+
1416
+
1417
+
1418
+	/**
1419
+	 * if passed object implements ResettableInterface, then call it's reset() method
1420
+	 * if passed object implements InterminableInterface, then return false,
1421
+	 * to indicate that it should NOT be cleared from the Registry cache
1422
+	 *
1423
+	 * @param      $object
1424
+	 * @param bool $reset_models
1425
+	 * @return bool returns true if cached object should be unset
1426
+	 */
1427
+	private static function _reset_and_unset_object($object, $reset_models)
1428
+	{
1429
+		if (! is_object($object)) {
1430
+			// don't unset anything that's not an object
1431
+			return false;
1432
+		}
1433
+		if ($object instanceof EED_Module) {
1434
+			$object::reset();
1435
+			// don't unset modules
1436
+			return false;
1437
+		}
1438
+		if ($object instanceof ResettableInterface) {
1439
+			if ($object instanceof EEM_Base) {
1440
+				if ($reset_models) {
1441
+					$object->reset();
1442
+					return true;
1443
+				}
1444
+				return false;
1445
+			}
1446
+			$object->reset();
1447
+			return true;
1448
+		}
1449
+		if (! $object instanceof InterminableInterface) {
1450
+			return true;
1451
+		}
1452
+		return false;
1453
+	}
1454
+
1455
+
1456
+
1457
+	/**
1458
+	 * Gets all the custom post type models defined
1459
+	 *
1460
+	 * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1461
+	 */
1462
+	public function cpt_models()
1463
+	{
1464
+		$cpt_models = array();
1465
+		foreach ($this->non_abstract_db_models as $short_name => $classname) {
1466
+			if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1467
+				$cpt_models[$short_name] = $classname;
1468
+			}
1469
+		}
1470
+		return $cpt_models;
1471
+	}
1472
+
1473
+
1474
+
1475
+	/**
1476
+	 * @return \EE_Config
1477
+	 */
1478
+	public static function CFG()
1479
+	{
1480
+		return self::instance()->CFG;
1481
+	}
1482 1482
 
1483 1483
 
1484 1484
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     public static function instance(EE_Dependency_Map $dependency_map = null)
172 172
     {
173 173
         // check if class object is instantiated
174
-        if (! self::$_instance instanceof EE_Registry) {
174
+        if ( ! self::$_instance instanceof EE_Registry) {
175 175
             self::$_instance = new self($dependency_map);
176 176
         }
177 177
         return self::$_instance;
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
      */
259 259
     public static function localize_i18n_js_strings()
260 260
     {
261
-        $i18n_js_strings = (array)self::$i18n_js_strings;
261
+        $i18n_js_strings = (array) self::$i18n_js_strings;
262 262
         foreach ($i18n_js_strings as $key => $value) {
263 263
             if (is_scalar($value)) {
264
-                $i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
264
+                $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
265 265
             }
266 266
         }
267
-        return '/* <![CDATA[ */ var eei18n = ' . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
267
+        return '/* <![CDATA[ */ var eei18n = '.wp_json_encode($i18n_js_strings).'; /* ]]> */';
268 268
     }
269 269
 
270 270
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
             $module_class = get_class($module);
281 281
             $this->modules->{$module_class} = $module;
282 282
         } else {
283
-            if (! class_exists('EE_Module_Request_Router')) {
283
+            if ( ! class_exists('EE_Module_Request_Router')) {
284 284
                 $this->load_core('Module_Request_Router');
285 285
             }
286 286
             EE_Module_Request_Router::module_factory($module);
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
                 EE_CORE,
321 321
                 EE_ADMIN,
322 322
                 EE_CPTS,
323
-                EE_CORE . 'data_migration_scripts' . DS,
324
-                EE_CORE . 'request_stack' . DS,
325
-                EE_CORE . 'middleware' . DS,
323
+                EE_CORE.'data_migration_scripts'.DS,
324
+                EE_CORE.'request_stack'.DS,
325
+                EE_CORE.'middleware'.DS,
326 326
             )
327 327
         );
328 328
         // retrieve instantiated class
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         $service_paths = apply_filters(
356 356
             'FHEE__EE_Registry__load_service__service_paths',
357 357
             array(
358
-                EE_CORE . 'services' . DS,
358
+                EE_CORE.'services'.DS,
359 359
             )
360 360
         );
361 361
         // retrieve instantiated class
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
     {
482 482
         $paths = array(
483 483
             EE_LIBRARIES,
484
-            EE_LIBRARIES . 'messages' . DS,
485
-            EE_LIBRARIES . 'shortcodes' . DS,
486
-            EE_LIBRARIES . 'qtips' . DS,
487
-            EE_LIBRARIES . 'payment_methods' . DS,
484
+            EE_LIBRARIES.'messages'.DS,
485
+            EE_LIBRARIES.'shortcodes'.DS,
486
+            EE_LIBRARIES.'qtips'.DS,
487
+            EE_LIBRARIES.'payment_methods'.DS,
488 488
         );
489 489
         // retrieve instantiated class
490 490
         return $this->_load(
@@ -547,10 +547,10 @@  discard block
 block discarded – undo
547 547
     public function load_model_class($class_name, $arguments = array(), $load_only = true)
548 548
     {
549 549
         $paths = array(
550
-            EE_MODELS . 'fields' . DS,
551
-            EE_MODELS . 'helpers' . DS,
552
-            EE_MODELS . 'relations' . DS,
553
-            EE_MODELS . 'strategies' . DS,
550
+            EE_MODELS.'fields'.DS,
551
+            EE_MODELS.'helpers'.DS,
552
+            EE_MODELS.'relations'.DS,
553
+            EE_MODELS.'strategies'.DS,
554 554
         );
555 555
         // retrieve instantiated class
556 556
         return $this->_load(
@@ -666,13 +666,13 @@  discard block
 block discarded – undo
666 666
     ) {
667 667
         $class_name = ltrim($class_name, '\\');
668 668
         $class_name = $this->_dependency_map->get_alias($class_name);
669
-        if (! class_exists($class_name)) {
669
+        if ( ! class_exists($class_name)) {
670 670
             // maybe the class is registered with a preceding \
671 671
             $class_name = strpos($class_name, '\\') !== 0
672
-                ? '\\' . $class_name
672
+                ? '\\'.$class_name
673 673
                 : $class_name;
674 674
             // still doesn't exist ?
675
-            if (! class_exists($class_name)) {
675
+            if ( ! class_exists($class_name)) {
676 676
                 return null;
677 677
             }
678 678
         }
@@ -737,11 +737,11 @@  discard block
 block discarded – undo
737 737
         // strip php file extension
738 738
         $class_name = str_replace('.php', '', trim($class_name));
739 739
         // does the class have a prefix ?
740
-        if (! empty($class_prefix) && $class_prefix !== 'addon') {
740
+        if ( ! empty($class_prefix) && $class_prefix !== 'addon') {
741 741
             // make sure $class_prefix is uppercase
742 742
             $class_prefix = strtoupper(trim($class_prefix));
743 743
             // add class prefix ONCE!!!
744
-            $class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
744
+            $class_name = $class_prefix.str_replace($class_prefix, '', $class_name);
745 745
         }
746 746
         $class_name = $this->_dependency_map->get_alias($class_name);
747 747
         $class_exists = class_exists($class_name);
@@ -760,13 +760,13 @@  discard block
 block discarded – undo
760 760
             }
761 761
         }
762 762
         // if the class doesn't already exist.. then we need to try and find the file and load it
763
-        if (! $class_exists) {
763
+        if ( ! $class_exists) {
764 764
             // get full path to file
765 765
             $path = $this->_resolve_path($class_name, $type, $file_paths);
766 766
             // load the file
767 767
             $loaded = $this->_require_file($path, $class_name, $type, $file_paths);
768 768
             // if loading failed, or we are only loading a file but NOT instantiating an object
769
-            if (! $loaded || $load_only) {
769
+            if ( ! $loaded || $load_only) {
770 770
                 // return boolean if only loading, or null if an object was expected
771 771
                 return $load_only
772 772
                     ? $loaded
@@ -885,10 +885,10 @@  discard block
 block discarded – undo
885 885
                 : EE_CLASSES;
886 886
             // prep file type
887 887
             $type = ! empty($type)
888
-                ? trim($type, '.') . '.'
888
+                ? trim($type, '.').'.'
889 889
                 : '';
890 890
             // build full file path
891
-            $file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
891
+            $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php';
892 892
             //does the file exist and can be read ?
893 893
             if (is_readable($file_paths[$key])) {
894 894
                 return $file_paths[$key];
@@ -916,9 +916,9 @@  discard block
 block discarded – undo
916 916
         // don't give up! you gotta...
917 917
         try {
918 918
             //does the file exist and can it be read ?
919
-            if (! $path) {
919
+            if ( ! $path) {
920 920
                 // so sorry, can't find the file
921
-                throw new EE_Error (
921
+                throw new EE_Error(
922 922
                     sprintf(
923 923
                         esc_html__(
924 924
                             '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',
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
                         ),
927 927
                         trim($type, '.'),
928 928
                         $class_name,
929
-                        '<br />' . implode(',<br />', $file_paths)
929
+                        '<br />'.implode(',<br />', $file_paths)
930 930
                     )
931 931
                 );
932 932
             }
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
                 );
1031 1031
             }
1032 1032
         } catch (Exception $e) {
1033
-            if (! $e instanceof EE_Error) {
1033
+            if ( ! $e instanceof EE_Error) {
1034 1034
                 $e = new EE_Error(
1035 1035
                     sprintf(
1036 1036
                         esc_html__(
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
         // let's examine the constructor
1113 1113
         $constructor = $reflector->getConstructor();
1114 1114
         // whu? huh? nothing?
1115
-        if (! $constructor) {
1115
+        if ( ! $constructor) {
1116 1116
             return $arguments;
1117 1117
         }
1118 1118
         // get constructor parameters
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
             $this->addons->{$class_name} = $class_obj;
1262 1262
             return;
1263 1263
         }
1264
-        if (! $from_db) {
1264
+        if ( ! $from_db) {
1265 1265
             $this->LIB->{$class_name} = $class_obj;
1266 1266
         }
1267 1267
     }
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
         $model_class_name = strpos($model_name, 'EEM_') !== 0
1343 1343
             ? "EEM_{$model_name}"
1344 1344
             : $model_name;
1345
-        if (! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1345
+        if ( ! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1346 1346
             return null;
1347 1347
         }
1348 1348
         //get that model reset it and make sure we nuke the old reference to it
@@ -1426,7 +1426,7 @@  discard block
 block discarded – undo
1426 1426
      */
1427 1427
     private static function _reset_and_unset_object($object, $reset_models)
1428 1428
     {
1429
-        if (! is_object($object)) {
1429
+        if ( ! is_object($object)) {
1430 1430
             // don't unset anything that's not an object
1431 1431
             return false;
1432 1432
         }
@@ -1446,7 +1446,7 @@  discard block
 block discarded – undo
1446 1446
             $object->reset();
1447 1447
             return true;
1448 1448
         }
1449
-        if (! $object instanceof InterminableInterface) {
1449
+        if ( ! $object instanceof InterminableInterface) {
1450 1450
             return true;
1451 1451
         }
1452 1452
         return false;
Please login to merge, or discard this patch.
core/admin/EE_Admin.core.php 2 patches
Indentation   +733 added lines, -733 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\interfaces\InterminableInterface;
4 4
 
5 5
 if (! defined('EVENT_ESPRESSO_VERSION')) {
6
-    exit('No direct script access allowed');
6
+	exit('No direct script access allowed');
7 7
 }
8 8
 
9 9
 /**
@@ -26,336 +26,336 @@  discard block
 block discarded – undo
26 26
 final class EE_Admin implements InterminableInterface
27 27
 {
28 28
 
29
-    /**
30
-     * @access private
31
-     * @var EE_Admin $_instance
32
-     */
33
-    private static $_instance;
34
-
35
-
36
-    /**
37
-     *@ singleton method used to instantiate class object
38
-     *@ access public
39
-     *@ return class instance
40
-     *
41
-     * @throws \EE_Error
42
-     */
43
-    public static function instance()
44
-    {
45
-        // check if class object is instantiated
46
-        if (! self::$_instance instanceof EE_Admin) {
47
-            self::$_instance = new self();
48
-        }
49
-        return self::$_instance;
50
-    }
51
-
52
-
53
-    /**
54
-     * @return EE_Admin
55
-     */
56
-    public static function reset()
57
-    {
58
-        self::$_instance = null;
59
-        return self::instance();
60
-    }
61
-
62
-
63
-    /**
64
-     * class constructor
65
-     *
66
-     * @throws \EE_Error
67
-     */
68
-    protected function __construct()
69
-    {
70
-        // define global EE_Admin constants
71
-        $this->_define_all_constants();
72
-        // set autoloaders for our admin page classes based on included path information
73
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
74
-        // admin hooks
75
-        add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
76
-        // load EE_Request_Handler early
77
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
78
-        add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
79
-        add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
80
-        add_action('wp_loaded', array($this, 'wp_loaded'), 100);
81
-        add_action('admin_init', array($this, 'admin_init'), 100);
82
-        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
83
-        add_action('admin_notices', array($this, 'display_admin_notices'), 10);
84
-        add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
85
-        add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
86
-        add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
87
-
88
-        //reset Environment config (we only do this on admin page loads);
89
-        EE_Registry::instance()->CFG->environment->recheck_values();
90
-
91
-        do_action('AHEE__EE_Admin__loaded');
92
-    }
93
-
94
-
95
-    /**
96
-     * _define_all_constants
97
-     * define constants that are set globally for all admin pages
98
-     *
99
-     * @access private
100
-     * @return void
101
-     */
102
-    private function _define_all_constants()
103
-    {
104
-        if (! defined('EE_ADMIN_URL')) {
105
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
106
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
107
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
108
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
109
-            define('WP_AJAX_URL', admin_url('admin-ajax.php'));
110
-        }
111
-    }
112
-
113
-
114
-    /**
115
-     *    filter_plugin_actions - adds links to the Plugins page listing
116
-     *
117
-     * @access    public
118
-     * @param    array  $links
119
-     * @param    string $plugin
120
-     * @return    array
121
-     */
122
-    public function filter_plugin_actions($links, $plugin)
123
-    {
124
-        // set $main_file in stone
125
-        static $main_file;
126
-        // if $main_file is not set yet
127
-        if (! $main_file) {
128
-            $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
129
-        }
130
-        if ($plugin === $main_file) {
131
-            // compare current plugin to this one
132
-            if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
133
-                $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',
134
-                        'event_espresso') . '</a>';
135
-                array_unshift($links, $maintenance_link);
136
-            } else {
137
-                $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __('Settings',
138
-                        'event_espresso') . '</a>';
139
-                $events_link       = '<a href="admin.php?page=espresso_events">' . __('Events',
140
-                        'event_espresso') . '</a>';
141
-                // add before other links
142
-                array_unshift($links, $org_settings_link, $events_link);
143
-            }
144
-        }
145
-        return $links;
146
-    }
147
-
148
-
149
-    /**
150
-     *    _get_request
151
-     *
152
-     * @access public
153
-     * @return void
154
-     */
155
-    public function get_request()
156
-    {
157
-        EE_Registry::instance()->load_core('Request_Handler');
158
-        EE_Registry::instance()->load_core('CPT_Strategy');
159
-    }
160
-
161
-
162
-    /**
163
-     *    hide_admin_pages_except_maintenance_mode
164
-     *
165
-     * @access public
166
-     * @param array $admin_page_folder_names
167
-     * @return array
168
-     */
169
-    public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
170
-    {
171
-        return array(
172
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
173
-            'about'       => EE_ADMIN_PAGES . 'about' . DS,
174
-            'support'     => EE_ADMIN_PAGES . 'support' . DS,
175
-        );
176
-    }
177
-
178
-
179
-    /**
180
-     * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
181
-     * EE_Front_Controller's init phases have run
182
-     *
183
-     * @access public
184
-     * @return void
185
-     */
186
-    public function init()
187
-    {
188
-        //only enable most of the EE_Admin IF we're not in full maintenance mode
189
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
190
-            //ok so we want to enable the entire admin
191
-            add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback'));
192
-            add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9);
193
-            add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9);
194
-            //at a glance dashboard widget
195
-            add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
196
-            //filter for get_edit_post_link used on comments for custom post types
197
-            add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
198
-        }
199
-        // run the admin page factory but ONLY if we are doing an ee admin ajax request
200
-        if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
201
-            try {
202
-                //this loads the controller for the admin pages which will setup routing etc
203
-                EE_Registry::instance()->load_core('Admin_Page_Loader');
204
-            } catch (EE_Error $e) {
205
-                $e->get_error();
206
-            }
207
-        }
208
-        add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
209
-        //make sure our CPTs and custom taxonomy metaboxes get shown for first time users
210
-        add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
211
-        add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
212
-        //exclude EE critical pages from all nav menus and wp_list_pages
213
-        add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
214
-    }
215
-
216
-
217
-    /**
218
-     * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
219
-     * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
220
-     * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
221
-     * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
222
-     * normal property on the post_type object.  It's found ONLY in this particular context.
223
-     *
224
-     * @param  object $post_type WP post type object
225
-     * @return object            WP post type object
226
-     */
227
-    public function remove_pages_from_nav_menu($post_type)
228
-    {
229
-        //if this isn't the "pages" post type let's get out
230
-        if ($post_type->name !== 'page') {
231
-            return $post_type;
232
-        }
233
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
234
-
235
-        $post_type->_default_query = array(
236
-            'post__not_in' => $critical_pages,
237
-        );
238
-        return $post_type;
239
-    }
240
-
241
-
242
-    /**
243
-     * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
244
-     * metaboxes get shown as well
245
-     *
246
-     * @access public
247
-     * @return void
248
-     */
249
-    public function enable_hidden_ee_nav_menu_metaboxes()
250
-    {
251
-        global $wp_meta_boxes, $pagenow;
252
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
253
-            return;
254
-        }
255
-        $user = wp_get_current_user();
256
-        //has this been done yet?
257
-        if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
258
-            return;
259
-        }
260
-
261
-        $hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
262
-        $initial_meta_boxes = apply_filters('FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
263
-            array(
264
-                'nav-menu-theme-locations',
265
-                'add-page',
266
-                'add-custom-links',
267
-                'add-category',
268
-                'add-espresso_events',
269
-                'add-espresso_venues',
270
-                'add-espresso_event_categories',
271
-                'add-espresso_venue_categories',
272
-                'add-post-type-post',
273
-                'add-post-type-page',
274
-            ));
275
-
276
-        if (is_array($hidden_meta_boxes)) {
277
-            foreach ($hidden_meta_boxes as $key => $meta_box_id) {
278
-                if (in_array($meta_box_id, $initial_meta_boxes)) {
279
-                    unset($hidden_meta_boxes[$key]);
280
-                }
281
-            }
282
-        }
283
-
284
-        update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
285
-        update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
286
-    }
287
-
288
-
289
-    /**
290
-     * This method simply registers custom nav menu boxes for "nav_menus.php route"
291
-     * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
292
-     *
293
-     * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
294
-     *         addons etc.
295
-     * @access public
296
-     * @return void
297
-     */
298
-    public function register_custom_nav_menu_boxes()
299
-    {
300
-        add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'),
301
-            array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core');
302
-    }
303
-
304
-
305
-    /**
306
-     * Use this to edit the post link for our cpts so that the edit link points to the correct page.
307
-     *
308
-     * @since   4.3.0
309
-     * @param string $link the original link generated by wp
310
-     * @param int    $id   post id
311
-     * @return string  the (maybe) modified link
312
-     */
313
-    public function modify_edit_post_link($link, $id)
314
-    {
315
-        if (! $post = get_post($id)) {
316
-            return $link;
317
-        }
318
-        if ($post->post_type === 'espresso_attendees') {
319
-            $query_args = array(
320
-                'action' => 'edit_attendee',
321
-                'post'   => $id,
322
-            );
323
-            return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations'));
324
-        }
325
-        return $link;
326
-    }
327
-
328
-
329
-    public function ee_cpt_archive_pages()
330
-    {
331
-        global $nav_menu_selected_id;
332
-
333
-        $db_fields   = false;
334
-        $walker      = new Walker_Nav_Menu_Checklist($db_fields);
335
-        $current_tab = 'event-archives';
336
-
337
-        /*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
29
+	/**
30
+	 * @access private
31
+	 * @var EE_Admin $_instance
32
+	 */
33
+	private static $_instance;
34
+
35
+
36
+	/**
37
+	 *@ singleton method used to instantiate class object
38
+	 *@ access public
39
+	 *@ return class instance
40
+	 *
41
+	 * @throws \EE_Error
42
+	 */
43
+	public static function instance()
44
+	{
45
+		// check if class object is instantiated
46
+		if (! self::$_instance instanceof EE_Admin) {
47
+			self::$_instance = new self();
48
+		}
49
+		return self::$_instance;
50
+	}
51
+
52
+
53
+	/**
54
+	 * @return EE_Admin
55
+	 */
56
+	public static function reset()
57
+	{
58
+		self::$_instance = null;
59
+		return self::instance();
60
+	}
61
+
62
+
63
+	/**
64
+	 * class constructor
65
+	 *
66
+	 * @throws \EE_Error
67
+	 */
68
+	protected function __construct()
69
+	{
70
+		// define global EE_Admin constants
71
+		$this->_define_all_constants();
72
+		// set autoloaders for our admin page classes based on included path information
73
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
74
+		// admin hooks
75
+		add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
76
+		// load EE_Request_Handler early
77
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
78
+		add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
79
+		add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
80
+		add_action('wp_loaded', array($this, 'wp_loaded'), 100);
81
+		add_action('admin_init', array($this, 'admin_init'), 100);
82
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
83
+		add_action('admin_notices', array($this, 'display_admin_notices'), 10);
84
+		add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
85
+		add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
86
+		add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
87
+
88
+		//reset Environment config (we only do this on admin page loads);
89
+		EE_Registry::instance()->CFG->environment->recheck_values();
90
+
91
+		do_action('AHEE__EE_Admin__loaded');
92
+	}
93
+
94
+
95
+	/**
96
+	 * _define_all_constants
97
+	 * define constants that are set globally for all admin pages
98
+	 *
99
+	 * @access private
100
+	 * @return void
101
+	 */
102
+	private function _define_all_constants()
103
+	{
104
+		if (! defined('EE_ADMIN_URL')) {
105
+			define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
106
+			define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
107
+			define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
108
+			define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
109
+			define('WP_AJAX_URL', admin_url('admin-ajax.php'));
110
+		}
111
+	}
112
+
113
+
114
+	/**
115
+	 *    filter_plugin_actions - adds links to the Plugins page listing
116
+	 *
117
+	 * @access    public
118
+	 * @param    array  $links
119
+	 * @param    string $plugin
120
+	 * @return    array
121
+	 */
122
+	public function filter_plugin_actions($links, $plugin)
123
+	{
124
+		// set $main_file in stone
125
+		static $main_file;
126
+		// if $main_file is not set yet
127
+		if (! $main_file) {
128
+			$main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
129
+		}
130
+		if ($plugin === $main_file) {
131
+			// compare current plugin to this one
132
+			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
133
+				$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',
134
+						'event_espresso') . '</a>';
135
+				array_unshift($links, $maintenance_link);
136
+			} else {
137
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __('Settings',
138
+						'event_espresso') . '</a>';
139
+				$events_link       = '<a href="admin.php?page=espresso_events">' . __('Events',
140
+						'event_espresso') . '</a>';
141
+				// add before other links
142
+				array_unshift($links, $org_settings_link, $events_link);
143
+			}
144
+		}
145
+		return $links;
146
+	}
147
+
148
+
149
+	/**
150
+	 *    _get_request
151
+	 *
152
+	 * @access public
153
+	 * @return void
154
+	 */
155
+	public function get_request()
156
+	{
157
+		EE_Registry::instance()->load_core('Request_Handler');
158
+		EE_Registry::instance()->load_core('CPT_Strategy');
159
+	}
160
+
161
+
162
+	/**
163
+	 *    hide_admin_pages_except_maintenance_mode
164
+	 *
165
+	 * @access public
166
+	 * @param array $admin_page_folder_names
167
+	 * @return array
168
+	 */
169
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
170
+	{
171
+		return array(
172
+			'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
173
+			'about'       => EE_ADMIN_PAGES . 'about' . DS,
174
+			'support'     => EE_ADMIN_PAGES . 'support' . DS,
175
+		);
176
+	}
177
+
178
+
179
+	/**
180
+	 * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
181
+	 * EE_Front_Controller's init phases have run
182
+	 *
183
+	 * @access public
184
+	 * @return void
185
+	 */
186
+	public function init()
187
+	{
188
+		//only enable most of the EE_Admin IF we're not in full maintenance mode
189
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
190
+			//ok so we want to enable the entire admin
191
+			add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback'));
192
+			add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9);
193
+			add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9);
194
+			//at a glance dashboard widget
195
+			add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
196
+			//filter for get_edit_post_link used on comments for custom post types
197
+			add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
198
+		}
199
+		// run the admin page factory but ONLY if we are doing an ee admin ajax request
200
+		if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
201
+			try {
202
+				//this loads the controller for the admin pages which will setup routing etc
203
+				EE_Registry::instance()->load_core('Admin_Page_Loader');
204
+			} catch (EE_Error $e) {
205
+				$e->get_error();
206
+			}
207
+		}
208
+		add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
209
+		//make sure our CPTs and custom taxonomy metaboxes get shown for first time users
210
+		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
211
+		add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
212
+		//exclude EE critical pages from all nav menus and wp_list_pages
213
+		add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
214
+	}
215
+
216
+
217
+	/**
218
+	 * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
219
+	 * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
220
+	 * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
221
+	 * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
222
+	 * normal property on the post_type object.  It's found ONLY in this particular context.
223
+	 *
224
+	 * @param  object $post_type WP post type object
225
+	 * @return object            WP post type object
226
+	 */
227
+	public function remove_pages_from_nav_menu($post_type)
228
+	{
229
+		//if this isn't the "pages" post type let's get out
230
+		if ($post_type->name !== 'page') {
231
+			return $post_type;
232
+		}
233
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
234
+
235
+		$post_type->_default_query = array(
236
+			'post__not_in' => $critical_pages,
237
+		);
238
+		return $post_type;
239
+	}
240
+
241
+
242
+	/**
243
+	 * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
244
+	 * metaboxes get shown as well
245
+	 *
246
+	 * @access public
247
+	 * @return void
248
+	 */
249
+	public function enable_hidden_ee_nav_menu_metaboxes()
250
+	{
251
+		global $wp_meta_boxes, $pagenow;
252
+		if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
253
+			return;
254
+		}
255
+		$user = wp_get_current_user();
256
+		//has this been done yet?
257
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
258
+			return;
259
+		}
260
+
261
+		$hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
262
+		$initial_meta_boxes = apply_filters('FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
263
+			array(
264
+				'nav-menu-theme-locations',
265
+				'add-page',
266
+				'add-custom-links',
267
+				'add-category',
268
+				'add-espresso_events',
269
+				'add-espresso_venues',
270
+				'add-espresso_event_categories',
271
+				'add-espresso_venue_categories',
272
+				'add-post-type-post',
273
+				'add-post-type-page',
274
+			));
275
+
276
+		if (is_array($hidden_meta_boxes)) {
277
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
278
+				if (in_array($meta_box_id, $initial_meta_boxes)) {
279
+					unset($hidden_meta_boxes[$key]);
280
+				}
281
+			}
282
+		}
283
+
284
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
285
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
286
+	}
287
+
288
+
289
+	/**
290
+	 * This method simply registers custom nav menu boxes for "nav_menus.php route"
291
+	 * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
292
+	 *
293
+	 * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
294
+	 *         addons etc.
295
+	 * @access public
296
+	 * @return void
297
+	 */
298
+	public function register_custom_nav_menu_boxes()
299
+	{
300
+		add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'),
301
+			array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core');
302
+	}
303
+
304
+
305
+	/**
306
+	 * Use this to edit the post link for our cpts so that the edit link points to the correct page.
307
+	 *
308
+	 * @since   4.3.0
309
+	 * @param string $link the original link generated by wp
310
+	 * @param int    $id   post id
311
+	 * @return string  the (maybe) modified link
312
+	 */
313
+	public function modify_edit_post_link($link, $id)
314
+	{
315
+		if (! $post = get_post($id)) {
316
+			return $link;
317
+		}
318
+		if ($post->post_type === 'espresso_attendees') {
319
+			$query_args = array(
320
+				'action' => 'edit_attendee',
321
+				'post'   => $id,
322
+			);
323
+			return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations'));
324
+		}
325
+		return $link;
326
+	}
327
+
328
+
329
+	public function ee_cpt_archive_pages()
330
+	{
331
+		global $nav_menu_selected_id;
332
+
333
+		$db_fields   = false;
334
+		$walker      = new Walker_Nav_Menu_Checklist($db_fields);
335
+		$current_tab = 'event-archives';
336
+
337
+		/*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
338 338
             $current_tab = 'search';
339 339
         }/**/
340 340
 
341
-        $removed_args = array(
342
-            'action',
343
-            'customlink-tab',
344
-            'edit-menu-item',
345
-            'menu-item',
346
-            'page-tab',
347
-            '_wpnonce',
348
-        );
341
+		$removed_args = array(
342
+			'action',
343
+			'customlink-tab',
344
+			'edit-menu-item',
345
+			'menu-item',
346
+			'page-tab',
347
+			'_wpnonce',
348
+		);
349 349
 
350
-        ?>
350
+		?>
351 351
         <div id="posttype-extra-nav-menu-pages" class="posttypediv">
352 352
             <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
353 353
                 <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>>
354 354
                     <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives"
355 355
                        href="<?php if ($nav_menu_selected_id) {
356
-                           echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives',
357
-                               remove_query_arg($removed_args)));
358
-                       } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
356
+						   echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives',
357
+							   remove_query_arg($removed_args)));
358
+					   } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
359 359
                         <?php _e('Event Archive Pages', 'event_espresso'); ?>
360 360
                     </a>
361 361
                 </li>
@@ -374,29 +374,29 @@  discard block
 block discarded – undo
374 374
  			<?php */ ?>
375 375
 
376 376
                 <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php
377
-                echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
378
-                ?>">
377
+				echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
378
+				?>">
379 379
                     <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">
380 380
                         <?php
381
-                        $pages          = $this->_get_extra_nav_menu_pages_items();
382
-                        $args['walker'] = $walker;
383
-                        echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0,
384
-                            (object)$args);
385
-                        ?>
381
+						$pages          = $this->_get_extra_nav_menu_pages_items();
382
+						$args['walker'] = $walker;
383
+						echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0,
384
+							(object)$args);
385
+						?>
386 386
                     </ul>
387 387
                 </div><!-- /.tabs-panel -->
388 388
 
389 389
                 <p class="button-controls">
390 390
 				<span class="list-controls">
391 391
 					<a href="<?php
392
-                    echo esc_url(add_query_arg(
393
-                        array(
394
-                            'extra-nav-menu-pages-tab' => 'event-archives',
395
-                            'selectall'                => 1,
396
-                        ),
397
-                        remove_query_arg($removed_args)
398
-                    ));
399
-                    ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a>
392
+					echo esc_url(add_query_arg(
393
+						array(
394
+							'extra-nav-menu-pages-tab' => 'event-archives',
395
+							'selectall'                => 1,
396
+						),
397
+						remove_query_arg($removed_args)
398
+					));
399
+					?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a>
400 400
 				</span>
401 401
 
402 402
                     <span class="add-to-menu">
@@ -411,402 +411,402 @@  discard block
 block discarded – undo
411 411
         </div><!-- /.posttypediv -->
412 412
 
413 413
         <?php
414
-    }
415
-
416
-
417
-    /**
418
-     * Returns an array of event archive nav items.
419
-     *
420
-     * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
421
-     *        method we use for getting the extra nav menu items
422
-     * @return array
423
-     */
424
-    private function _get_extra_nav_menu_pages_items()
425
-    {
426
-        $menuitems[] = array(
427
-            'title'       => __('Event List', 'event_espresso'),
428
-            'url'         => get_post_type_archive_link('espresso_events'),
429
-            'description' => __('Archive page for all events.', 'event_espresso'),
430
-        );
431
-        return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
432
-    }
433
-
434
-
435
-    /**
436
-     * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
437
-     * the properties and converts it to the menu item object.
438
-     *
439
-     * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
440
-     * @param $menu_item_values
441
-     * @return stdClass
442
-     */
443
-    private function _setup_extra_nav_menu_pages_items($menu_item_values)
444
-    {
445
-        $menu_item = new stdClass();
446
-        $keys      = array(
447
-            'ID'               => 0,
448
-            'db_id'            => 0,
449
-            'menu_item_parent' => 0,
450
-            'object_id'        => -1,
451
-            'post_parent'      => 0,
452
-            'type'             => 'custom',
453
-            'object'           => '',
454
-            'type_label'       => __('Extra Nav Menu Item', 'event_espresso'),
455
-            'title'            => '',
456
-            'url'              => '',
457
-            'target'           => '',
458
-            'attr_title'       => '',
459
-            'description'      => '',
460
-            'classes'          => array(),
461
-            'xfn'              => '',
462
-        );
463
-
464
-        foreach ($keys as $key => $value) {
465
-            $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
466
-        }
467
-        return $menu_item;
468
-    }
469
-
470
-
471
-    /**
472
-     * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
473
-     * EE_Admin_Page route is called.
474
-     *
475
-     * @return void
476
-     */
477
-    public function route_admin_request()
478
-    {
479
-    }
480
-
481
-
482
-    /**
483
-     * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
484
-     *
485
-     * @return void
486
-     */
487
-    public function wp_loaded()
488
-    {
489
-    }
490
-
491
-
492
-    /**
493
-     * admin_init
494
-     *
495
-     * @access public
496
-     * @return void
497
-     */
498
-    public function admin_init()
499
-    {
500
-
501
-        /**
502
-         * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
503
-         * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
504
-         * - check if doing post processing.
505
-         * - check if doing post processing of one of EE CPTs
506
-         * - instantiate the corresponding EE CPT model for the post_type being processed.
507
-         */
508
-        if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
509
-            EE_Registry::instance()->load_core('Register_CPTs');
510
-            EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']);
511
-        }
512
-
513
-
514
-        /**
515
-         * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
516
-         * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical Pages"
517
-         * tab in the EE General Settings Admin page.
518
-         * This is for user-proofing.
519
-         */
520
-        add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
521
-
522
-    }
523
-
524
-
525
-    /**
526
-     * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
527
-     *
528
-     * @param string $output Current output.
529
-     * @return string
530
-     */
531
-    public function modify_dropdown_pages($output)
532
-    {
533
-        //get critical pages
534
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
535
-
536
-        //split current output by line break for easier parsing.
537
-        $split_output = explode("\n", $output);
538
-
539
-        //loop through to remove any critical pages from the array.
540
-        foreach ($critical_pages as $page_id) {
541
-            $needle = 'value="' . $page_id . '"';
542
-            foreach ($split_output as $key => $haystack) {
543
-                if (strpos($haystack, $needle) !== false) {
544
-                    unset($split_output[$key]);
545
-                }
546
-            }
547
-        }
548
-
549
-        //replace output with the new contents
550
-        return implode("\n", $split_output);
551
-    }
552
-
553
-
554
-    /**
555
-     * enqueue all admin scripts that need loaded for admin pages
556
-     *
557
-     * @access public
558
-     * @return void
559
-     */
560
-    public function enqueue_admin_scripts()
561
-    {
562
-        // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
563
-        // Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script calls.
564
-        wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'),
565
-            EVENT_ESPRESSO_VERSION, true);
566
-        // register cookie script for future dependencies
567
-        wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1',
568
-            true);
569
-        //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' );
570
-        if (apply_filters('FHEE_load_joyride', false)) {
571
-            //joyride style
572
-            wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
573
-            wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
574
-                array('joyride-css'), EVENT_ESPRESSO_VERSION);
575
-            wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1',
576
-                true);
577
-            //joyride JS
578
-            wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
579
-                array('jquery-cookie', 'joyride-modernizr'), '2.1', true);
580
-            // wanna go for a joyride?
581
-            wp_enqueue_style('ee-joyride-css');
582
-            wp_enqueue_script('jquery-joyride');
583
-        }
584
-    }
585
-
586
-
587
-    /**
588
-     *    display_admin_notices
589
-     *
590
-     * @access    public
591
-     * @return    string
592
-     */
593
-    public function display_admin_notices()
594
-    {
595
-        echo EE_Error::get_notices();
596
-    }
597
-
598
-
599
-    /**
600
-     *    get_persistent_admin_notices
601
-     *
602
-     * @access    public
603
-     * @return        void
604
-     */
605
-    public function get_persistent_admin_notices()
606
-    {
607
-        // http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30
608
-        $args       = array(
609
-            'page'   => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '',
610
-            'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '',
611
-        );
612
-        $return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL);
613
-        echo EE_Error::get_persistent_admin_notices($return_url);
614
-    }
615
-
616
-
617
-    /**
618
-     *    dismiss_persistent_admin_notice
619
-     *
620
-     * @access    public
621
-     * @return        void
622
-     */
623
-    public function dismiss_ee_nag_notice_callback()
624
-    {
625
-        EE_Error::dismiss_persistent_admin_notice();
626
-    }
627
-
628
-
629
-    /**
630
-     * @param array $elements
631
-     * @return array
632
-     * @throws \EE_Error
633
-     */
634
-    public function dashboard_glance_items($elements)
635
-    {
636
-        $elements                        = is_array($elements) ? $elements : array($elements);
637
-        $events                          = EEM_Event::instance()->count();
638
-        $items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'),
639
-            admin_url('admin.php'));
640
-        $items['events']['text']         = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events));
641
-        $items['events']['title']        = __('Click to view all Events', 'event_espresso');
642
-        $registrations                   = EEM_Registration::instance()->count(
643
-            array(
644
-                array(
645
-                    'STS_ID' => array('!=', EEM_Registration::status_id_incomplete),
646
-                ),
647
-            )
648
-        );
649
-        $items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'),
650
-            admin_url('admin.php'));
651
-        $items['registrations']['text']  = sprintf(_n('%s Registration', '%s Registrations', $registrations),
652
-            number_format_i18n($registrations));
653
-        $items['registrations']['title'] = __('Click to view all registrations', 'event_espresso');
654
-
655
-        $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
656
-
657
-        foreach ($items as $type => $item_properties) {
658
-            $elements[] = sprintf('<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
659
-                $item_properties['url'], $item_properties['title'], $item_properties['text']);
660
-        }
661
-        return $elements;
662
-    }
663
-
664
-
665
-    /**
666
-     *    check_for_invalid_datetime_formats
667
-     *    if an admin changes their date or time format settings on the WP General Settings admin page, verify that
668
-     *    their selected format can be parsed by PHP
669
-     *
670
-     * @access    public
671
-     * @param    $value
672
-     * @param    $option
673
-     * @throws EE_Error
674
-     * @return    string
675
-     */
676
-    public function check_for_invalid_datetime_formats($value, $option)
677
-    {
678
-        // check for date_format or time_format
679
-        switch ($option) {
680
-            case 'date_format' :
681
-                $date_time_format = $value . ' ' . get_option('time_format');
682
-                break;
683
-            case 'time_format' :
684
-                $date_time_format = get_option('date_format') . ' ' . $value;
685
-                break;
686
-            default :
687
-                $date_time_format = false;
688
-        }
689
-        // do we have a date_time format to check ?
690
-        if ($date_time_format) {
691
-            $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
692
-
693
-            if (is_array($error_msg)) {
694
-                $msg = '<p>' . sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
695
-                        'event_espresso'), date($date_time_format), $date_time_format) . '</p><p><ul>';
696
-
697
-
698
-                foreach ($error_msg as $error) {
699
-                    $msg .= '<li>' . $error . '</li>';
700
-                }
701
-
702
-                $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',
703
-                        'event_espresso'), '<span style="color:#D54E21;">', '</span>') . '</p>';
704
-
705
-                // trigger WP settings error
706
-                add_settings_error(
707
-                    'date_format',
708
-                    'date_format',
709
-                    $msg
710
-                );
711
-
712
-                // set format to something valid
713
-                switch ($option) {
714
-                    case 'date_format' :
715
-                        $value = 'F j, Y';
716
-                        break;
717
-                    case 'time_format' :
718
-                        $value = 'g:i a';
719
-                        break;
720
-                }
721
-            }
722
-        }
723
-        return $value;
724
-    }
725
-
726
-
727
-    /**
728
-     *    its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
729
-     *
730
-     * @access    public
731
-     * @param $content
732
-     * @return    string
733
-     */
734
-    public function its_eSpresso($content)
735
-    {
736
-        return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
737
-    }
738
-
739
-
740
-    /**
741
-     *    espresso_admin_footer
742
-     *
743
-     * @access    public
744
-     * @return    string
745
-     */
746
-    public function espresso_admin_footer()
747
-    {
748
-        return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
749
-    }
750
-
751
-
752
-    /**
753
-     * static method for registering ee admin page.
754
-     * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
755
-     *
756
-     * @since      4.3.0
757
-     * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
758
-     * @see        EE_Register_Admin_Page::register()
759
-     * @param       $page_basename
760
-     * @param       $page_path
761
-     * @param array $config
762
-     * @return void
763
-     */
764
-    public static function register_ee_admin_page($page_basename, $page_path, $config = array())
765
-    {
766
-        EE_Error::doing_it_wrong(__METHOD__,
767
-            sprintf(__('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
768
-                'event_espresso'), $page_basename), '4.3');
769
-        if (class_exists('EE_Register_Admin_Page')) {
770
-            $config['page_path'] = $page_path;
771
-        }
772
-        EE_Register_Admin_Page::register($page_basename, $config);
773
-
774
-    }
775
-
776
-
777
-    /**
778
-     * @deprecated 4.8.41
779
-     * @access     public
780
-     * @param  int      $post_ID
781
-     * @param  \WP_Post $post
782
-     * @return void
783
-     */
784
-    public static function parse_post_content_on_save($post_ID, $post)
785
-    {
786
-        EE_Error::doing_it_wrong(
787
-            __METHOD__,
788
-            __('Usage is deprecated', 'event_espresso'),
789
-            '4.8.41'
790
-        );
791
-    }
792
-
793
-
794
-    /**
795
-     * @deprecated 4.8.41
796
-     * @access     public
797
-     * @param  $option
798
-     * @param  $old_value
799
-     * @param  $value
800
-     * @return void
801
-     */
802
-    public function reset_page_for_posts_on_change($option, $old_value, $value)
803
-    {
804
-        EE_Error::doing_it_wrong(
805
-            __METHOD__,
806
-            __('Usage is deprecated', 'event_espresso'),
807
-            '4.8.41'
808
-        );
809
-    }
414
+	}
415
+
416
+
417
+	/**
418
+	 * Returns an array of event archive nav items.
419
+	 *
420
+	 * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
421
+	 *        method we use for getting the extra nav menu items
422
+	 * @return array
423
+	 */
424
+	private function _get_extra_nav_menu_pages_items()
425
+	{
426
+		$menuitems[] = array(
427
+			'title'       => __('Event List', 'event_espresso'),
428
+			'url'         => get_post_type_archive_link('espresso_events'),
429
+			'description' => __('Archive page for all events.', 'event_espresso'),
430
+		);
431
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
432
+	}
433
+
434
+
435
+	/**
436
+	 * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
437
+	 * the properties and converts it to the menu item object.
438
+	 *
439
+	 * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
440
+	 * @param $menu_item_values
441
+	 * @return stdClass
442
+	 */
443
+	private function _setup_extra_nav_menu_pages_items($menu_item_values)
444
+	{
445
+		$menu_item = new stdClass();
446
+		$keys      = array(
447
+			'ID'               => 0,
448
+			'db_id'            => 0,
449
+			'menu_item_parent' => 0,
450
+			'object_id'        => -1,
451
+			'post_parent'      => 0,
452
+			'type'             => 'custom',
453
+			'object'           => '',
454
+			'type_label'       => __('Extra Nav Menu Item', 'event_espresso'),
455
+			'title'            => '',
456
+			'url'              => '',
457
+			'target'           => '',
458
+			'attr_title'       => '',
459
+			'description'      => '',
460
+			'classes'          => array(),
461
+			'xfn'              => '',
462
+		);
463
+
464
+		foreach ($keys as $key => $value) {
465
+			$menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
466
+		}
467
+		return $menu_item;
468
+	}
469
+
470
+
471
+	/**
472
+	 * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
473
+	 * EE_Admin_Page route is called.
474
+	 *
475
+	 * @return void
476
+	 */
477
+	public function route_admin_request()
478
+	{
479
+	}
480
+
481
+
482
+	/**
483
+	 * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
484
+	 *
485
+	 * @return void
486
+	 */
487
+	public function wp_loaded()
488
+	{
489
+	}
490
+
491
+
492
+	/**
493
+	 * admin_init
494
+	 *
495
+	 * @access public
496
+	 * @return void
497
+	 */
498
+	public function admin_init()
499
+	{
500
+
501
+		/**
502
+		 * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
503
+		 * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
504
+		 * - check if doing post processing.
505
+		 * - check if doing post processing of one of EE CPTs
506
+		 * - instantiate the corresponding EE CPT model for the post_type being processed.
507
+		 */
508
+		if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
509
+			EE_Registry::instance()->load_core('Register_CPTs');
510
+			EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']);
511
+		}
512
+
513
+
514
+		/**
515
+		 * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
516
+		 * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical Pages"
517
+		 * tab in the EE General Settings Admin page.
518
+		 * This is for user-proofing.
519
+		 */
520
+		add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
521
+
522
+	}
523
+
524
+
525
+	/**
526
+	 * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
527
+	 *
528
+	 * @param string $output Current output.
529
+	 * @return string
530
+	 */
531
+	public function modify_dropdown_pages($output)
532
+	{
533
+		//get critical pages
534
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
535
+
536
+		//split current output by line break for easier parsing.
537
+		$split_output = explode("\n", $output);
538
+
539
+		//loop through to remove any critical pages from the array.
540
+		foreach ($critical_pages as $page_id) {
541
+			$needle = 'value="' . $page_id . '"';
542
+			foreach ($split_output as $key => $haystack) {
543
+				if (strpos($haystack, $needle) !== false) {
544
+					unset($split_output[$key]);
545
+				}
546
+			}
547
+		}
548
+
549
+		//replace output with the new contents
550
+		return implode("\n", $split_output);
551
+	}
552
+
553
+
554
+	/**
555
+	 * enqueue all admin scripts that need loaded for admin pages
556
+	 *
557
+	 * @access public
558
+	 * @return void
559
+	 */
560
+	public function enqueue_admin_scripts()
561
+	{
562
+		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
563
+		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script calls.
564
+		wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'),
565
+			EVENT_ESPRESSO_VERSION, true);
566
+		// register cookie script for future dependencies
567
+		wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1',
568
+			true);
569
+		//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' );
570
+		if (apply_filters('FHEE_load_joyride', false)) {
571
+			//joyride style
572
+			wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
573
+			wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
574
+				array('joyride-css'), EVENT_ESPRESSO_VERSION);
575
+			wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1',
576
+				true);
577
+			//joyride JS
578
+			wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
579
+				array('jquery-cookie', 'joyride-modernizr'), '2.1', true);
580
+			// wanna go for a joyride?
581
+			wp_enqueue_style('ee-joyride-css');
582
+			wp_enqueue_script('jquery-joyride');
583
+		}
584
+	}
585
+
586
+
587
+	/**
588
+	 *    display_admin_notices
589
+	 *
590
+	 * @access    public
591
+	 * @return    string
592
+	 */
593
+	public function display_admin_notices()
594
+	{
595
+		echo EE_Error::get_notices();
596
+	}
597
+
598
+
599
+	/**
600
+	 *    get_persistent_admin_notices
601
+	 *
602
+	 * @access    public
603
+	 * @return        void
604
+	 */
605
+	public function get_persistent_admin_notices()
606
+	{
607
+		// http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30
608
+		$args       = array(
609
+			'page'   => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '',
610
+			'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '',
611
+		);
612
+		$return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL);
613
+		echo EE_Error::get_persistent_admin_notices($return_url);
614
+	}
615
+
616
+
617
+	/**
618
+	 *    dismiss_persistent_admin_notice
619
+	 *
620
+	 * @access    public
621
+	 * @return        void
622
+	 */
623
+	public function dismiss_ee_nag_notice_callback()
624
+	{
625
+		EE_Error::dismiss_persistent_admin_notice();
626
+	}
627
+
628
+
629
+	/**
630
+	 * @param array $elements
631
+	 * @return array
632
+	 * @throws \EE_Error
633
+	 */
634
+	public function dashboard_glance_items($elements)
635
+	{
636
+		$elements                        = is_array($elements) ? $elements : array($elements);
637
+		$events                          = EEM_Event::instance()->count();
638
+		$items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'),
639
+			admin_url('admin.php'));
640
+		$items['events']['text']         = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events));
641
+		$items['events']['title']        = __('Click to view all Events', 'event_espresso');
642
+		$registrations                   = EEM_Registration::instance()->count(
643
+			array(
644
+				array(
645
+					'STS_ID' => array('!=', EEM_Registration::status_id_incomplete),
646
+				),
647
+			)
648
+		);
649
+		$items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'),
650
+			admin_url('admin.php'));
651
+		$items['registrations']['text']  = sprintf(_n('%s Registration', '%s Registrations', $registrations),
652
+			number_format_i18n($registrations));
653
+		$items['registrations']['title'] = __('Click to view all registrations', 'event_espresso');
654
+
655
+		$items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
656
+
657
+		foreach ($items as $type => $item_properties) {
658
+			$elements[] = sprintf('<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
659
+				$item_properties['url'], $item_properties['title'], $item_properties['text']);
660
+		}
661
+		return $elements;
662
+	}
663
+
664
+
665
+	/**
666
+	 *    check_for_invalid_datetime_formats
667
+	 *    if an admin changes their date or time format settings on the WP General Settings admin page, verify that
668
+	 *    their selected format can be parsed by PHP
669
+	 *
670
+	 * @access    public
671
+	 * @param    $value
672
+	 * @param    $option
673
+	 * @throws EE_Error
674
+	 * @return    string
675
+	 */
676
+	public function check_for_invalid_datetime_formats($value, $option)
677
+	{
678
+		// check for date_format or time_format
679
+		switch ($option) {
680
+			case 'date_format' :
681
+				$date_time_format = $value . ' ' . get_option('time_format');
682
+				break;
683
+			case 'time_format' :
684
+				$date_time_format = get_option('date_format') . ' ' . $value;
685
+				break;
686
+			default :
687
+				$date_time_format = false;
688
+		}
689
+		// do we have a date_time format to check ?
690
+		if ($date_time_format) {
691
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
692
+
693
+			if (is_array($error_msg)) {
694
+				$msg = '<p>' . sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
695
+						'event_espresso'), date($date_time_format), $date_time_format) . '</p><p><ul>';
696
+
697
+
698
+				foreach ($error_msg as $error) {
699
+					$msg .= '<li>' . $error . '</li>';
700
+				}
701
+
702
+				$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',
703
+						'event_espresso'), '<span style="color:#D54E21;">', '</span>') . '</p>';
704
+
705
+				// trigger WP settings error
706
+				add_settings_error(
707
+					'date_format',
708
+					'date_format',
709
+					$msg
710
+				);
711
+
712
+				// set format to something valid
713
+				switch ($option) {
714
+					case 'date_format' :
715
+						$value = 'F j, Y';
716
+						break;
717
+					case 'time_format' :
718
+						$value = 'g:i a';
719
+						break;
720
+				}
721
+			}
722
+		}
723
+		return $value;
724
+	}
725
+
726
+
727
+	/**
728
+	 *    its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
729
+	 *
730
+	 * @access    public
731
+	 * @param $content
732
+	 * @return    string
733
+	 */
734
+	public function its_eSpresso($content)
735
+	{
736
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
737
+	}
738
+
739
+
740
+	/**
741
+	 *    espresso_admin_footer
742
+	 *
743
+	 * @access    public
744
+	 * @return    string
745
+	 */
746
+	public function espresso_admin_footer()
747
+	{
748
+		return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
749
+	}
750
+
751
+
752
+	/**
753
+	 * static method for registering ee admin page.
754
+	 * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
755
+	 *
756
+	 * @since      4.3.0
757
+	 * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
758
+	 * @see        EE_Register_Admin_Page::register()
759
+	 * @param       $page_basename
760
+	 * @param       $page_path
761
+	 * @param array $config
762
+	 * @return void
763
+	 */
764
+	public static function register_ee_admin_page($page_basename, $page_path, $config = array())
765
+	{
766
+		EE_Error::doing_it_wrong(__METHOD__,
767
+			sprintf(__('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
768
+				'event_espresso'), $page_basename), '4.3');
769
+		if (class_exists('EE_Register_Admin_Page')) {
770
+			$config['page_path'] = $page_path;
771
+		}
772
+		EE_Register_Admin_Page::register($page_basename, $config);
773
+
774
+	}
775
+
776
+
777
+	/**
778
+	 * @deprecated 4.8.41
779
+	 * @access     public
780
+	 * @param  int      $post_ID
781
+	 * @param  \WP_Post $post
782
+	 * @return void
783
+	 */
784
+	public static function parse_post_content_on_save($post_ID, $post)
785
+	{
786
+		EE_Error::doing_it_wrong(
787
+			__METHOD__,
788
+			__('Usage is deprecated', 'event_espresso'),
789
+			'4.8.41'
790
+		);
791
+	}
792
+
793
+
794
+	/**
795
+	 * @deprecated 4.8.41
796
+	 * @access     public
797
+	 * @param  $option
798
+	 * @param  $old_value
799
+	 * @param  $value
800
+	 * @return void
801
+	 */
802
+	public function reset_page_for_posts_on_change($option, $old_value, $value)
803
+	{
804
+		EE_Error::doing_it_wrong(
805
+			__METHOD__,
806
+			__('Usage is deprecated', 'event_espresso'),
807
+			'4.8.41'
808
+		);
809
+	}
810 810
 
811 811
 }
812 812
 // End of file EE_Admin.core.php
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 use EventEspresso\core\interfaces\InterminableInterface;
4 4
 
5
-if (! defined('EVENT_ESPRESSO_VERSION')) {
5
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
6 6
     exit('No direct script access allowed');
7 7
 }
8 8
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public static function instance()
44 44
     {
45 45
         // check if class object is instantiated
46
-        if (! self::$_instance instanceof EE_Admin) {
46
+        if ( ! self::$_instance instanceof EE_Admin) {
47 47
             self::$_instance = new self();
48 48
         }
49 49
         return self::$_instance;
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
      */
102 102
     private function _define_all_constants()
103 103
     {
104
-        if (! defined('EE_ADMIN_URL')) {
105
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
106
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
107
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
108
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
104
+        if ( ! defined('EE_ADMIN_URL')) {
105
+            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/');
106
+            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/');
107
+            define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS);
108
+            define('WP_ADMIN_PATH', ABSPATH.'wp-admin/');
109 109
             define('WP_AJAX_URL', admin_url('admin-ajax.php'));
110 110
         }
111 111
     }
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
         // set $main_file in stone
125 125
         static $main_file;
126 126
         // if $main_file is not set yet
127
-        if (! $main_file) {
127
+        if ( ! $main_file) {
128 128
             $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
129 129
         }
130 130
         if ($plugin === $main_file) {
131 131
             // compare current plugin to this one
132 132
             if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
133
-                $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',
134
-                        'event_espresso') . '</a>';
133
+                $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',
134
+                        'event_espresso').'</a>';
135 135
                 array_unshift($links, $maintenance_link);
136 136
             } else {
137
-                $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __('Settings',
138
-                        'event_espresso') . '</a>';
139
-                $events_link       = '<a href="admin.php?page=espresso_events">' . __('Events',
140
-                        'event_espresso') . '</a>';
137
+                $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings',
138
+                        'event_espresso').'</a>';
139
+                $events_link       = '<a href="admin.php?page=espresso_events">'.__('Events',
140
+                        'event_espresso').'</a>';
141 141
                 // add before other links
142 142
                 array_unshift($links, $org_settings_link, $events_link);
143 143
             }
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
     public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
170 170
     {
171 171
         return array(
172
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
173
-            'about'       => EE_ADMIN_PAGES . 'about' . DS,
174
-            'support'     => EE_ADMIN_PAGES . 'support' . DS,
172
+            'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS,
173
+            'about'       => EE_ADMIN_PAGES.'about'.DS,
174
+            'support'     => EE_ADMIN_PAGES.'support'.DS,
175 175
         );
176 176
     }
177 177
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
198 198
         }
199 199
         // run the admin page factory but ONLY if we are doing an ee admin ajax request
200
-        if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
200
+        if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
201 201
             try {
202 202
                 //this loads the controller for the admin pages which will setup routing etc
203 203
                 EE_Registry::instance()->load_core('Admin_Page_Loader');
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
     public function enable_hidden_ee_nav_menu_metaboxes()
250 250
     {
251 251
         global $wp_meta_boxes, $pagenow;
252
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
252
+        if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
253 253
             return;
254 254
         }
255 255
         $user = wp_get_current_user();
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
      */
313 313
     public function modify_edit_post_link($link, $id)
314 314
     {
315
-        if (! $post = get_post($id)) {
315
+        if ( ! $post = get_post($id)) {
316 316
             return $link;
317 317
         }
318 318
         if ($post->post_type === 'espresso_attendees') {
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
                         $pages          = $this->_get_extra_nav_menu_pages_items();
382 382
                         $args['walker'] = $walker;
383 383
                         echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0,
384
-                            (object)$args);
384
+                            (object) $args);
385 385
                         ?>
386 386
                     </ul>
387 387
                 </div><!-- /.tabs-panel -->
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 
539 539
         //loop through to remove any critical pages from the array.
540 540
         foreach ($critical_pages as $page_id) {
541
-            $needle = 'value="' . $page_id . '"';
541
+            $needle = 'value="'.$page_id.'"';
542 542
             foreach ($split_output as $key => $haystack) {
543 543
                 if (strpos($haystack, $needle) !== false) {
544 544
                     unset($split_output[$key]);
@@ -561,21 +561,21 @@  discard block
 block discarded – undo
561 561
     {
562 562
         // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
563 563
         // Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script calls.
564
-        wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'),
564
+        wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'),
565 565
             EVENT_ESPRESSO_VERSION, true);
566 566
         // register cookie script for future dependencies
567
-        wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1',
567
+        wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1',
568 568
             true);
569 569
         //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' );
570 570
         if (apply_filters('FHEE_load_joyride', false)) {
571 571
             //joyride style
572
-            wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
573
-            wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
572
+            wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1');
573
+            wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css',
574 574
                 array('joyride-css'), EVENT_ESPRESSO_VERSION);
575
-            wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1',
575
+            wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1',
576 576
                 true);
577 577
             //joyride JS
578
-            wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
578
+            wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js',
579 579
                 array('jquery-cookie', 'joyride-modernizr'), '2.1', true);
580 580
             // wanna go for a joyride?
581 581
             wp_enqueue_style('ee-joyride-css');
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
     public function get_persistent_admin_notices()
606 606
     {
607 607
         // http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30
608
-        $args       = array(
608
+        $args = array(
609 609
             'page'   => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '',
610 610
             'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '',
611 611
         );
@@ -652,10 +652,10 @@  discard block
 block discarded – undo
652 652
             number_format_i18n($registrations));
653 653
         $items['registrations']['title'] = __('Click to view all registrations', 'event_espresso');
654 654
 
655
-        $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
655
+        $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
656 656
 
657 657
         foreach ($items as $type => $item_properties) {
658
-            $elements[] = sprintf('<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
658
+            $elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>',
659 659
                 $item_properties['url'], $item_properties['title'], $item_properties['text']);
660 660
         }
661 661
         return $elements;
@@ -678,10 +678,10 @@  discard block
 block discarded – undo
678 678
         // check for date_format or time_format
679 679
         switch ($option) {
680 680
             case 'date_format' :
681
-                $date_time_format = $value . ' ' . get_option('time_format');
681
+                $date_time_format = $value.' '.get_option('time_format');
682 682
                 break;
683 683
             case 'time_format' :
684
-                $date_time_format = get_option('date_format') . ' ' . $value;
684
+                $date_time_format = get_option('date_format').' '.$value;
685 685
                 break;
686 686
             default :
687 687
                 $date_time_format = false;
@@ -691,16 +691,16 @@  discard block
 block discarded – undo
691 691
             $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
692 692
 
693 693
             if (is_array($error_msg)) {
694
-                $msg = '<p>' . sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
695
-                        'event_espresso'), date($date_time_format), $date_time_format) . '</p><p><ul>';
694
+                $msg = '<p>'.sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
695
+                        'event_espresso'), date($date_time_format), $date_time_format).'</p><p><ul>';
696 696
 
697 697
 
698 698
                 foreach ($error_msg as $error) {
699
-                    $msg .= '<li>' . $error . '</li>';
699
+                    $msg .= '<li>'.$error.'</li>';
700 700
                 }
701 701
 
702
-                $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',
703
-                        'event_espresso'), '<span style="color:#D54E21;">', '</span>') . '</p>';
702
+                $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',
703
+                        'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>';
704 704
 
705 705
                 // trigger WP settings error
706 706
                 add_settings_error(
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.46.rc.015');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.46.rc.015');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.