Completed
Branch BUG-9042-ics-organizer-email (0077fa)
by
unknown
26:47 queued 15:14
created
core/EE_Maintenance_Mode.core.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public static function instance() {
75 75
 		// check if class object is instantiated
76
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Maintenance_Mode )) {
76
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Maintenance_Mode)) {
77 77
 			self::$_instance = new self();
78 78
 		}
79 79
 		return self::$_instance;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * Resets maintenance mode (mostly just re-checks whether or not we should be in maintenance mode)
84 84
 	 * @return EE_Maintenance_Mode
85 85
 	 */
86
-	public static function reset(){
86
+	public static function reset() {
87 87
 		self::instance()->set_maintenance_mode_if_db_old();
88 88
 		return self::instance();
89 89
 	}
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	private function __construct() {
100 100
 		// if M-Mode level 2 is engaged, we still need basic assets loaded
101
-		add_action( 'wp_enqueue_scripts', array( $this, 'load_assets_required_for_m_mode' ));
101
+		add_action('wp_enqueue_scripts', array($this, 'load_assets_required_for_m_mode'));
102 102
 		// shut 'er down down for maintenance ?
103
-		add_filter( 'the_content', array( $this, 'the_content' ), 2 );
103
+		add_filter('the_content', array($this, 'the_content'), 2);
104 104
 		// add powered by EE msg
105
-		add_action( 'shutdown', array( $this, 'display_maintenance_mode_notice' ), 10 );
105
+		add_action('shutdown', array($this, 'display_maintenance_mode_notice'), 10);
106 106
 	}
107 107
 
108 108
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	 * retrieves the maintenance mode option value from the db
113 113
 	 * @return int
114 114
 	 */
115
-	public function real_level(){
116
-		return get_option( self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance );
115
+	public function real_level() {
116
+		return get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance);
117 117
 	}
118 118
 
119 119
 	/**
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * thinks their tables are present and up-to-date).
122 122
 	 * @return boolean
123 123
 	 */
124
-	public function models_can_query(){
124
+	public function models_can_query() {
125 125
 		return $this->real_level() != EE_Maintenance_Mode::level_2_complete_maintenance;
126 126
 	}
127 127
 
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 	 * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode
135 135
 	 * @return int
136 136
 	 */
137
-	public function level(){
137
+	public function level() {
138 138
 		$real_maintenance_mode_level = $this->real_level();
139 139
 		//if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend
140
-		if( ( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests
140
+		if (( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests
141 141
 			current_user_can('administrator') && //when the user is an admin
142
-			$real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance){//and we're in level 1
142
+			$real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance) {//and we're in level 1
143 143
 			$maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance;
144
-		}else{
144
+		} else {
145 145
 			$maintenance_mode_level = $real_maintenance_mode_level;
146 146
 		}
147 147
 		return $maintenance_mode_level;
@@ -151,17 +151,17 @@  discard block
 block discarded – undo
151 151
 	 * Determines if we need to put EE in maintenance mode because the database needs updating
152 152
 	 * @return boolean true if DB is old and maintenance mode was triggered; false otherwise
153 153
 	 */
154
-	public function set_maintenance_mode_if_db_old(){
155
-		EE_Registry::instance()->load_core( 'Data_Migration_Manager' );
156
-		if( EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()){
154
+	public function set_maintenance_mode_if_db_old() {
155
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
156
+		if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
157 157
 			update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance);
158 158
 			return true;
159
-		}elseif( $this->level() == self::level_2_complete_maintenance ){
159
+		}elseif ($this->level() == self::level_2_complete_maintenance) {
160 160
 			//we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run
161 161
 			//then we shouldn't be in mm2. (Maybe an addon got deactivated?)
162
-			update_option( self::option_name_maintenance_mode, self::level_0_not_in_maintenance );
162
+			update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance);
163 163
 			return false;
164
-		}else{
164
+		} else {
165 165
 			return false;
166 166
 		}
167 167
 	}
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 * @param int $level
172 172
 	 * @return void
173 173
 	 */
174
-	public function set_maintenance_level($level){
175
-		do_action( 'AHEE__EE_Maintenance_Mode__set_maintenance_level', $level );
174
+	public function set_maintenance_level($level) {
175
+		do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level);
176 176
 		update_option(self::option_name_maintenance_mode, intval($level));
177 177
 	}
178 178
 
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 *  @return 	string
200 200
 	 */
201 201
 	public function load_assets_required_for_m_mode() {
202
-		if ( $this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is( 'espresso_core', 'enqueued' )) {
203
-			wp_register_style( 'espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION );
202
+		if ($this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is('espresso_core', 'enqueued')) {
203
+			wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION);
204 204
 			wp_enqueue_style('espresso_default');
205
-			wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE );
206
-			wp_enqueue_script( 'espresso_core' );
205
+			wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
206
+			wp_enqueue_script('espresso_core');
207 207
 		}
208 208
 	}
209 209
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 */
222 222
 	public static function template_include() {
223 223
 		// shut 'er down down for maintenance ? then don't use any of our templates for our endpoints
224
-		return get_template_directory() . '/index.php';
224
+		return get_template_directory().'/index.php';
225 225
 	}
226 226
 
227 227
 
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
 	 * @param    string $the_content
236 236
 	 * @return    string
237 237
 	 */
238
-	public function the_content( $the_content ) {
238
+	public function the_content($the_content) {
239 239
 		// check if M-mode is engaged and for EE shortcode
240
-		if ( $this->level() && strpos( $the_content, '[ESPRESSO_' ) !== false ) {
240
+		if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) {
241 241
 			// this can eventually be moved to a template, or edited via admin. But for now...
242 242
 			$the_content = sprintf(
243
-				__( '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso' ),
243
+				__('%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso'),
244 244
 				'<h3>',
245 245
 				'</h3><p>',
246 246
 				'</p>'
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
 		// check if M-mode is engaged and for EE shortcode
265 265
 		if (
266 266
 			$this->real_level() &&
267
-			current_user_can( 'administrator' ) &&
267
+			current_user_can('administrator') &&
268 268
 			! is_admin() &&
269
-			! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
269
+			! (defined('DOING_AJAX') && DOING_AJAX)
270 270
 			&& EE_Registry::instance()->REQ->is_espresso_page()
271 271
 		) {
272 272
 			printf(
273
-				__( '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso' ),
273
+				__('%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso'),
274 274
 				'<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="',
275 275
 				'"><span class="dashicons dashicons-no"></span></a><p>',
276
-				' &raquo; <a href="' . add_query_arg( array( 'page' => 'espresso_maintenance_settings' ), admin_url( 'admin.php' )) . '">',
276
+				' &raquo; <a href="'.add_query_arg(array('page' => 'espresso_maintenance_settings'), admin_url('admin.php')).'">',
277 277
 				'</a></p></div>'
278 278
 			);
279 279
 		}
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
 	 *		@ return void
292 292
 	 */
293 293
 	final function __destruct() {}
294
-	final function __call($a,$b) {}
294
+	final function __call($a, $b) {}
295 295
 	final function __get($a) {}
296
-	final function __set($a,$b) {}
296
+	final function __set($a, $b) {}
297 297
 	final function __isset($a) {}
298 298
 	final function __unset($a) {}
299 299
 	final function __sleep() {
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	final function __invoke() {}
305 305
 	final static function __set_state() {}
306 306
 	final function __clone() {}
307
-	final static function __callStatic($a,$b) {}
307
+	final static function __callStatic($a, $b) {}
308 308
 
309 309
 }
310 310
 // End of file EE_Maintenance_Mode.core.php
Please login to merge, or discard this patch.
core/services/container/CoffeeShop.php 1 patch
Indentation   +497 added lines, -497 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use OutOfBoundsException;
14 14
 
15 15
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
16
-    exit('No direct script access allowed');
16
+	exit('No direct script access allowed');
17 17
 }
18 18
 
19 19
 
@@ -32,502 +32,502 @@  discard block
 block discarded – undo
32 32
 {
33 33
 
34 34
 
35
-    /**
36
-     * This was the best coffee related name I could think of to represent class name "aliases"
37
-     * So classes can be found via an alias identifier,
38
-     * that is revealed when it is run through... the filters... eh? get it?
39
-     *
40
-     * @var array $filters
41
-     */
42
-    private $filters = array();
43
-
44
-    /**
45
-     * These are the classes that will actually build the objects (to order of course)
46
-     *
47
-     * @var array $coffee_makers
48
-     */
49
-    private $coffee_makers = array();
50
-
51
-    /**
52
-     * where the instantiated "singleton" objects are stored
53
-     *
54
-     * @var CollectionInterface $carafe
55
-     */
56
-    private $carafe;
57
-
58
-    /**
59
-     * collection of Recipes that instruct us how to brew objects
60
-     *
61
-     * @var CollectionInterface $recipes
62
-     */
63
-    private $recipes;
64
-
65
-    /**
66
-     * collection of closures for brewing objects
67
-     *
68
-     * @var CollectionInterface $reservoir
69
-     */
70
-    private $reservoir;
71
-
72
-
73
-
74
-    /**
75
-     * CoffeeShop constructor
76
-     */
77
-    public function __construct()
78
-    {
79
-        // array for storing class aliases
80
-        $this->filters = array();
81
-        // create collection for storing shared services
82
-        $this->carafe = new LooseCollection( '' );
83
-        // create collection for storing recipes that tell how to build services and entities
84
-        $this->recipes = new Collection('EventEspresso\core\services\container\RecipeInterface');
85
-        // create collection for storing closures for constructing new entities
86
-        $this->reservoir = new Collection('Closure');
87
-        // create collection for storing the generators that build our services and entity closures
88
-        $this->coffee_makers = new Collection('EventEspresso\core\services\container\CoffeeMakerInterface');
89
-    }
90
-
91
-
92
-
93
-    /**
94
-     * Returns true if the container can return an entry for the given identifier.
95
-     * Returns false otherwise.
96
-     * `has($identifier)` returning true does not mean that `get($identifier)` will not throw an exception.
97
-     * It does however mean that `get($identifier)` will not throw a `ServiceNotFoundException`.
98
-     *
99
-     * @param string $identifier  Identifier of the entry to look for.
100
-     *                            Typically a Fully Qualified Class Name
101
-     * @return boolean
102
-     */
103
-    public function has($identifier)
104
-    {
105
-        $identifier = $this->filterIdentifier($identifier);
106
-        return $this->carafe->has($identifier);
107
-    }
108
-
109
-
110
-
111
-    /**
112
-     * finds a previously brewed (SHARED) service and returns it
113
-     *
114
-     * @param  string $identifier Identifier for the entity class to be constructed.
115
-     *                            Typically a Fully Qualified Class Name
116
-     * @return mixed
117
-     * @throws ServiceNotFoundException No service was found for this identifier.
118
-     */
119
-    public function get($identifier)
120
-    {
121
-        $identifier = $this->filterIdentifier($identifier);
122
-        if ($this->carafe->has($identifier)) {
123
-            return $this->carafe->get($identifier);
124
-        }
125
-        throw new ServiceNotFoundException($identifier);
126
-    }
127
-
128
-
129
-
130
-    /**
131
-     * returns an instance of the requested entity type using the supplied arguments.
132
-     * If a shared service is requested and an instance is already in the carafe, then it will be returned.
133
-     * If it is not already in the carafe, then the service will be constructed, added to the carafe, and returned
134
-     * If the request is for a new entity and a closure exists in the reservoir for creating it,
135
-     * then a new entity will be instantiated from the closure and returned.
136
-     * If a closure does not exist, then one will be built and added to the reservoir
137
-     * before instantiating the requested entity.
138
-     *
139
-     * @param  string $identifier Identifier for the entity class to be constructed.
140
-     *                            Typically a Fully Qualified Class Name
141
-     * @param array   $arguments  an array of arguments to be passed to the entity constructor
142
-     * @param string  $type
143
-     * @return mixed
144
-     * @throws ServiceNotFoundException No service was found for this identifier.
145
-     */
146
-    public function brew($identifier, $arguments = array(), $type = '')
147
-    {
148
-        // resolve any class aliases that may exist
149
-        $identifier = $this->filterIdentifier($identifier);
150
-        try {
151
-            // is a shared service being requested?
152
-            if (empty($type) || $type === CoffeeMaker::BREW_SHARED) {
153
-                // if a shared service was requested and an instance is in the carafe, then return it
154
-                return $this->get($identifier);
155
-            }
156
-        } catch (ServiceNotFoundException $e) {
157
-            // if not then we'll just catch the ServiceNotFoundException but not do anything just yet,
158
-            // and instead, attempt to build whatever was requested
159
-        }
160
-        $brewed = false;
161
-        // if the reservoir doesn't have a closure already for the requested identifier,
162
-        // then neither a shared service nor a closure for making entities has been built yet
163
-        if ( ! $this->reservoir->has($identifier)) {
164
-            // so let's brew something up and add it to the proper collection
165
-            $brewed = $this->makeCoffee($identifier, $arguments, $type);
166
-        }
167
-        // was the brewed item a callable factory function ?
168
-        if (is_callable($brewed)) {
169
-            // then instantiate a new entity from the cached closure
170
-            $entity = $brewed($arguments);
171
-        } else if ($brewed) {
172
-            // requested object was a shared entity, so attempt to get it from the carafe again
173
-            // because if it wasn't there before, then it should have just been brewed and added,
174
-            // but if it still isn't there, then this time
175
-            // the thrown ServiceNotFoundException will not be caught
176
-            $entity = $this->get($identifier);
177
-        } else {
178
-            // if identifier is for a non-shared entity,
179
-            // then either a cached closure already existed, or was just brewed
180
-            $closure = $this->reservoir->get($identifier);
181
-            $entity = $closure($arguments);
182
-        }
183
-        return $entity;
184
-    }
185
-
186
-
187
-
188
-    /**
189
-     * @param CoffeeMakerInterface $coffee_maker
190
-     * @param string               $type
191
-     * @return bool
192
-     */
193
-    public function addCoffeeMaker(CoffeeMakerInterface $coffee_maker, $type)
194
-    {
195
-        $type = CoffeeMaker::validateType($type);
196
-        return $this->coffee_makers->add($coffee_maker, $type);
197
-    }
198
-
199
-
200
-
201
-    /**
202
-     * @param string   $identifier
203
-     * @param callable $closure
204
-     * @return callable|null
205
-     */
206
-    public function addClosure($identifier, $closure)
207
-    {
208
-        if ( ! is_callable($closure)) {
209
-            throw new InvalidDataTypeException('$closure', $closure, 'Closure');
210
-        }
211
-        $identifier = $this->processIdentifier($identifier);
212
-        if ($this->reservoir->add($closure, $identifier)) {
213
-            return $closure;
214
-        }
215
-        return null;
216
-    }
217
-
218
-
219
-
220
-    /**
221
-     * @param string   $identifier
222
-     * @return boolean
223
-     */
224
-    public function removeClosure($identifier)
225
-    {
226
-        $identifier = $this->processIdentifier($identifier);
227
-        if ($this->reservoir->has($identifier)) {
228
-            $this->reservoir->remove($this->reservoir->get($identifier));
229
-            if ( ! $this->reservoir->has($identifier)) {
230
-                return true;
231
-            }
232
-        }
233
-        return false;
234
-    }
235
-
236
-
237
-
238
-    /**
239
-     * @param  string $identifier Identifier for the entity class that the service applies to
240
-     *                            Typically a Fully Qualified Class Name
241
-     * @param mixed  $service
242
-     * @return bool
243
-     */
244
-    public function addService($identifier, $service)
245
-    {
246
-        $identifier = $this->processIdentifier($identifier);
247
-        $service = $this->validateService($identifier, $service);
248
-        return $this->carafe->add($service, $identifier);
249
-    }
250
-
251
-
252
-
253
-    /**
254
-     * @param string $identifier
255
-     * @return boolean
256
-     */
257
-    public function removeService($identifier)
258
-    {
259
-        $identifier = $this->processIdentifier($identifier);
260
-        if ($this->carafe->has($identifier)) {
261
-            $this->carafe->remove($this->carafe->get($identifier));
262
-            if ( ! $this->carafe->has($identifier)) {
263
-                return true;
264
-            }
265
-        }
266
-        return false;
267
-    }
268
-
269
-
270
-
271
-    /**
272
-     * Adds instructions on how to brew objects
273
-     *
274
-     * @param RecipeInterface $recipe
275
-     * @return mixed
276
-     */
277
-    public function addRecipe(RecipeInterface $recipe)
278
-    {
279
-        $this->addAliases($recipe->identifier(), $recipe->filters());
280
-        $identifier = $this->processIdentifier($recipe->identifier());
281
-        return $this->recipes->add($recipe, $identifier);
282
-    }
283
-
284
-
285
-
286
-    /**
287
-     * @param string $identifier The Recipe's identifier
288
-     * @return boolean
289
-     */
290
-    public function removeRecipe($identifier)
291
-    {
292
-        $identifier = $this->processIdentifier($identifier);
293
-        if ($this->recipes->has($identifier)) {
294
-            $this->recipes->remove(
295
-                $this->recipes->get($identifier)
296
-            );
297
-            if ( ! $this->recipes->has($identifier)) {
298
-                return true;
299
-            }
300
-        }
301
-        return false;
302
-    }
303
-
304
-
305
-
306
-    /**
307
-     * Get instructions on how to brew objects
308
-     *
309
-     * @param  string $identifier Identifier for the entity class that the recipe applies to
310
-     *                            Typically a Fully Qualified Class Name
311
-     * @param string $type
312
-     * @return RecipeInterface
313
-     */
314
-    public function getRecipe($identifier, $type = '')
315
-    {
316
-        $identifier = $this->processIdentifier($identifier);
317
-        if ($this->recipes->has($identifier)) {
318
-            return $this->recipes->get($identifier);
319
-        }
320
-        $default_recipes = $this->getDefaultRecipes();
321
-        $matches = array();
322
-        foreach ($default_recipes as $wildcard => $default_recipe) {
323
-            // is the wildcard recipe prefix in the identifier ?
324
-            if (strpos($identifier, $wildcard) !== false) {
325
-                // track matches and use the number of wildcard characters matched for the key
326
-                $matches[strlen($wildcard)] = $default_recipe;
327
-            }
328
-        }
329
-        if (count($matches) > 0) {
330
-            // sort our recipes by the number of wildcard characters matched
331
-            ksort($matches);
332
-            // then grab the last recipe form the list, since it had the most matching characters
333
-            $match = array_pop($matches);
334
-            // since we are using a default recipe, we need to set it's identifier and fqcn
335
-            return $this->copyDefaultRecipe($match, $identifier, $type);
336
-        }
337
-        if ($this->recipes->has(Recipe::DEFAULT_ID)) {
338
-            // since we are using a default recipe, we need to set it's identifier and fqcn
339
-            return $this->copyDefaultRecipe($this->recipes->get(Recipe::DEFAULT_ID), $identifier, $type);
340
-        }
341
-        throw new OutOfBoundsException(
342
-            sprintf(
343
-                __('Could not brew coffee because no recipes were found for class "%1$s".', 'event_espresso'),
344
-                $identifier
345
-            )
346
-        );
347
-    }
348
-
349
-
350
-
351
-    /**
352
-     * adds class name aliases to list of filters
353
-     *
354
-     * @param  string $identifier Identifier for the entity class that the alias applies to
355
-     *                            Typically a Fully Qualified Class Name
356
-     * @param  array  $aliases
357
-     * @return void
358
-     * @throws InvalidIdentifierException
359
-     */
360
-    public function addAliases($identifier, $aliases)
361
-    {
362
-        if (empty($aliases)) {
363
-            return;
364
-        }
365
-        $identifier = $this->processIdentifier($identifier);
366
-        foreach ((array)$aliases as $alias) {
367
-            $this->filters[$this->processIdentifier($alias)] = $identifier;
368
-        }
369
-    }
370
-
371
-
372
-
373
-    /**
374
-     * Adds a service to one of the internal collections
375
-     *
376
-     * @param        $identifier
377
-     * @param array  $arguments
378
-     * @param string $type
379
-     * @return mixed
380
-     * @throws ServiceExistsException
381
-     */
382
-    private function makeCoffee($identifier, $arguments = array(), $type = '')
383
-    {
384
-        if ((empty($type) || $type === CoffeeMaker::BREW_SHARED) && $this->has($identifier)) {
385
-            throw new ServiceExistsException($identifier);
386
-        }
387
-        $identifier = $this->filterIdentifier($identifier);
388
-        $recipe = $this->getRecipe($identifier, $type);
389
-        $type = ! empty($type) ? $type : $recipe->type();
390
-        $coffee_maker = $this->getCoffeeMaker($type);
391
-        return $coffee_maker->brew($recipe, $arguments);
392
-    }
393
-
394
-
395
-
396
-    /**
397
-     * filters alias identifiers to find the real class name
398
-     *
399
-     * @param  string $identifier Identifier for the entity class that the filter applies to
400
-     *                            Typically a Fully Qualified Class Name
401
-     * @return string
402
-     * @throws InvalidIdentifierException
403
-     */
404
-    private function filterIdentifier($identifier)
405
-    {
406
-        $identifier = $this->processIdentifier($identifier);
407
-        return isset($this->filters[$identifier]) && ! empty($this->filters[$identifier])
408
-            ? $this->filters[$identifier]
409
-            : $identifier;
410
-    }
411
-
412
-
413
-
414
-    /**
415
-     * verifies and standardizes identifiers
416
-     *
417
-     * @param  string $identifier Identifier for the entity class
418
-     *                            Typically a Fully Qualified Class Name
419
-     * @return string
420
-     * @throws InvalidIdentifierException
421
-     */
422
-    private function processIdentifier($identifier)
423
-    {
424
-        if ( ! is_string($identifier)) {
425
-            throw new InvalidIdentifierException(
426
-                is_object($identifier) ? get_class($identifier) : gettype($identifier),
427
-                '\Fully\Qualified\ClassName'
428
-            );
429
-        }
430
-        return ltrim($identifier, '\\');
431
-    }
432
-
433
-
434
-
435
-    /**
436
-     * @param string $type
437
-     * @return CoffeeMakerInterface
438
-     * @throws InvalidDataTypeException
439
-     * @throws InvalidClassException
440
-     */
441
-    private function getCoffeeMaker($type)
442
-    {
443
-        if ( ! $this->coffee_makers->has($type)) {
444
-            throw new OutOfBoundsException(
445
-                __('The requested coffee maker is either missing or invalid.', 'event_espresso')
446
-            );
447
-        }
448
-        return $this->coffee_makers->get($type);
449
-    }
450
-
451
-
452
-
453
-    /**
454
-     * Retrieves all recipes that use a wildcard "*" in their identifier
455
-     * This allows recipes to be set up for handling
456
-     * legacy classes that do not support PSR-4 autoloading.
457
-     * for example:
458
-     * using "EEM_*" for a recipe identifier would target all legacy models like EEM_Attendee
459
-     *
460
-     * @return array
461
-     */
462
-    private function getDefaultRecipes()
463
-    {
464
-        $default_recipes = array();
465
-        $this->recipes->rewind();
466
-        while ($this->recipes->valid()) {
467
-            $identifier = $this->recipes->getInfo();
468
-            // does this recipe use a wildcard ? (but is NOT the global default)
469
-            if ($identifier !== Recipe::DEFAULT_ID && strpos($identifier, '*') !== false) {
470
-                // strip the wildcard and use identifier as key
471
-                $default_recipes[str_replace('*', '', $identifier)] = $this->recipes->current();
472
-            }
473
-            $this->recipes->next();
474
-        }
475
-        return $default_recipes;
476
-    }
477
-
478
-
479
-
480
-    /**
481
-     * clones a default recipe and then copies details
482
-     * from the incoming request to it so that it can be used
483
-     *
484
-     * @param RecipeInterface $default_recipe
485
-     * @param string          $identifier
486
-     * @param string          $type
487
-     * @return RecipeInterface
488
-     */
489
-    private function copyDefaultRecipe(RecipeInterface $default_recipe, $identifier, $type = '')
490
-    {
491
-        $recipe = clone $default_recipe;
492
-        if ( ! empty($type)) {
493
-            $recipe->setType($type);
494
-        }
495
-        // is this the base default recipe ?
496
-        if ($default_recipe->identifier() === Recipe::DEFAULT_ID) {
497
-            $recipe->setIdentifier($identifier);
498
-            $recipe->setFqcn($identifier);
499
-            return $recipe;
500
-        }
501
-        $recipe->setIdentifier($identifier);
502
-        foreach ($default_recipe->paths() as $path) {
503
-            $path = str_replace('*', $identifier, $path);
504
-            if (is_readable($path)) {
505
-                $recipe->setPaths($path);
506
-            }
507
-        }
508
-        $recipe->setFqcn($identifier);
509
-        return $recipe;
510
-    }
511
-
512
-
513
-
514
-    /**
515
-     * @param  string $identifier Identifier for the entity class that the service applies to
516
-     *                            Typically a Fully Qualified Class Name
517
-     * @param mixed  $service
518
-     * @return object
519
-     * @throws InvalidServiceException
520
-     */
521
-    private function validateService($identifier, $service)
522
-    {
523
-        if ( ! is_object($service)) {
524
-            throw new InvalidServiceException(
525
-                $identifier,
526
-                $service
527
-            );
528
-        }
529
-        return $service;
530
-    }
35
+	/**
36
+	 * This was the best coffee related name I could think of to represent class name "aliases"
37
+	 * So classes can be found via an alias identifier,
38
+	 * that is revealed when it is run through... the filters... eh? get it?
39
+	 *
40
+	 * @var array $filters
41
+	 */
42
+	private $filters = array();
43
+
44
+	/**
45
+	 * These are the classes that will actually build the objects (to order of course)
46
+	 *
47
+	 * @var array $coffee_makers
48
+	 */
49
+	private $coffee_makers = array();
50
+
51
+	/**
52
+	 * where the instantiated "singleton" objects are stored
53
+	 *
54
+	 * @var CollectionInterface $carafe
55
+	 */
56
+	private $carafe;
57
+
58
+	/**
59
+	 * collection of Recipes that instruct us how to brew objects
60
+	 *
61
+	 * @var CollectionInterface $recipes
62
+	 */
63
+	private $recipes;
64
+
65
+	/**
66
+	 * collection of closures for brewing objects
67
+	 *
68
+	 * @var CollectionInterface $reservoir
69
+	 */
70
+	private $reservoir;
71
+
72
+
73
+
74
+	/**
75
+	 * CoffeeShop constructor
76
+	 */
77
+	public function __construct()
78
+	{
79
+		// array for storing class aliases
80
+		$this->filters = array();
81
+		// create collection for storing shared services
82
+		$this->carafe = new LooseCollection( '' );
83
+		// create collection for storing recipes that tell how to build services and entities
84
+		$this->recipes = new Collection('EventEspresso\core\services\container\RecipeInterface');
85
+		// create collection for storing closures for constructing new entities
86
+		$this->reservoir = new Collection('Closure');
87
+		// create collection for storing the generators that build our services and entity closures
88
+		$this->coffee_makers = new Collection('EventEspresso\core\services\container\CoffeeMakerInterface');
89
+	}
90
+
91
+
92
+
93
+	/**
94
+	 * Returns true if the container can return an entry for the given identifier.
95
+	 * Returns false otherwise.
96
+	 * `has($identifier)` returning true does not mean that `get($identifier)` will not throw an exception.
97
+	 * It does however mean that `get($identifier)` will not throw a `ServiceNotFoundException`.
98
+	 *
99
+	 * @param string $identifier  Identifier of the entry to look for.
100
+	 *                            Typically a Fully Qualified Class Name
101
+	 * @return boolean
102
+	 */
103
+	public function has($identifier)
104
+	{
105
+		$identifier = $this->filterIdentifier($identifier);
106
+		return $this->carafe->has($identifier);
107
+	}
108
+
109
+
110
+
111
+	/**
112
+	 * finds a previously brewed (SHARED) service and returns it
113
+	 *
114
+	 * @param  string $identifier Identifier for the entity class to be constructed.
115
+	 *                            Typically a Fully Qualified Class Name
116
+	 * @return mixed
117
+	 * @throws ServiceNotFoundException No service was found for this identifier.
118
+	 */
119
+	public function get($identifier)
120
+	{
121
+		$identifier = $this->filterIdentifier($identifier);
122
+		if ($this->carafe->has($identifier)) {
123
+			return $this->carafe->get($identifier);
124
+		}
125
+		throw new ServiceNotFoundException($identifier);
126
+	}
127
+
128
+
129
+
130
+	/**
131
+	 * returns an instance of the requested entity type using the supplied arguments.
132
+	 * If a shared service is requested and an instance is already in the carafe, then it will be returned.
133
+	 * If it is not already in the carafe, then the service will be constructed, added to the carafe, and returned
134
+	 * If the request is for a new entity and a closure exists in the reservoir for creating it,
135
+	 * then a new entity will be instantiated from the closure and returned.
136
+	 * If a closure does not exist, then one will be built and added to the reservoir
137
+	 * before instantiating the requested entity.
138
+	 *
139
+	 * @param  string $identifier Identifier for the entity class to be constructed.
140
+	 *                            Typically a Fully Qualified Class Name
141
+	 * @param array   $arguments  an array of arguments to be passed to the entity constructor
142
+	 * @param string  $type
143
+	 * @return mixed
144
+	 * @throws ServiceNotFoundException No service was found for this identifier.
145
+	 */
146
+	public function brew($identifier, $arguments = array(), $type = '')
147
+	{
148
+		// resolve any class aliases that may exist
149
+		$identifier = $this->filterIdentifier($identifier);
150
+		try {
151
+			// is a shared service being requested?
152
+			if (empty($type) || $type === CoffeeMaker::BREW_SHARED) {
153
+				// if a shared service was requested and an instance is in the carafe, then return it
154
+				return $this->get($identifier);
155
+			}
156
+		} catch (ServiceNotFoundException $e) {
157
+			// if not then we'll just catch the ServiceNotFoundException but not do anything just yet,
158
+			// and instead, attempt to build whatever was requested
159
+		}
160
+		$brewed = false;
161
+		// if the reservoir doesn't have a closure already for the requested identifier,
162
+		// then neither a shared service nor a closure for making entities has been built yet
163
+		if ( ! $this->reservoir->has($identifier)) {
164
+			// so let's brew something up and add it to the proper collection
165
+			$brewed = $this->makeCoffee($identifier, $arguments, $type);
166
+		}
167
+		// was the brewed item a callable factory function ?
168
+		if (is_callable($brewed)) {
169
+			// then instantiate a new entity from the cached closure
170
+			$entity = $brewed($arguments);
171
+		} else if ($brewed) {
172
+			// requested object was a shared entity, so attempt to get it from the carafe again
173
+			// because if it wasn't there before, then it should have just been brewed and added,
174
+			// but if it still isn't there, then this time
175
+			// the thrown ServiceNotFoundException will not be caught
176
+			$entity = $this->get($identifier);
177
+		} else {
178
+			// if identifier is for a non-shared entity,
179
+			// then either a cached closure already existed, or was just brewed
180
+			$closure = $this->reservoir->get($identifier);
181
+			$entity = $closure($arguments);
182
+		}
183
+		return $entity;
184
+	}
185
+
186
+
187
+
188
+	/**
189
+	 * @param CoffeeMakerInterface $coffee_maker
190
+	 * @param string               $type
191
+	 * @return bool
192
+	 */
193
+	public function addCoffeeMaker(CoffeeMakerInterface $coffee_maker, $type)
194
+	{
195
+		$type = CoffeeMaker::validateType($type);
196
+		return $this->coffee_makers->add($coffee_maker, $type);
197
+	}
198
+
199
+
200
+
201
+	/**
202
+	 * @param string   $identifier
203
+	 * @param callable $closure
204
+	 * @return callable|null
205
+	 */
206
+	public function addClosure($identifier, $closure)
207
+	{
208
+		if ( ! is_callable($closure)) {
209
+			throw new InvalidDataTypeException('$closure', $closure, 'Closure');
210
+		}
211
+		$identifier = $this->processIdentifier($identifier);
212
+		if ($this->reservoir->add($closure, $identifier)) {
213
+			return $closure;
214
+		}
215
+		return null;
216
+	}
217
+
218
+
219
+
220
+	/**
221
+	 * @param string   $identifier
222
+	 * @return boolean
223
+	 */
224
+	public function removeClosure($identifier)
225
+	{
226
+		$identifier = $this->processIdentifier($identifier);
227
+		if ($this->reservoir->has($identifier)) {
228
+			$this->reservoir->remove($this->reservoir->get($identifier));
229
+			if ( ! $this->reservoir->has($identifier)) {
230
+				return true;
231
+			}
232
+		}
233
+		return false;
234
+	}
235
+
236
+
237
+
238
+	/**
239
+	 * @param  string $identifier Identifier for the entity class that the service applies to
240
+	 *                            Typically a Fully Qualified Class Name
241
+	 * @param mixed  $service
242
+	 * @return bool
243
+	 */
244
+	public function addService($identifier, $service)
245
+	{
246
+		$identifier = $this->processIdentifier($identifier);
247
+		$service = $this->validateService($identifier, $service);
248
+		return $this->carafe->add($service, $identifier);
249
+	}
250
+
251
+
252
+
253
+	/**
254
+	 * @param string $identifier
255
+	 * @return boolean
256
+	 */
257
+	public function removeService($identifier)
258
+	{
259
+		$identifier = $this->processIdentifier($identifier);
260
+		if ($this->carafe->has($identifier)) {
261
+			$this->carafe->remove($this->carafe->get($identifier));
262
+			if ( ! $this->carafe->has($identifier)) {
263
+				return true;
264
+			}
265
+		}
266
+		return false;
267
+	}
268
+
269
+
270
+
271
+	/**
272
+	 * Adds instructions on how to brew objects
273
+	 *
274
+	 * @param RecipeInterface $recipe
275
+	 * @return mixed
276
+	 */
277
+	public function addRecipe(RecipeInterface $recipe)
278
+	{
279
+		$this->addAliases($recipe->identifier(), $recipe->filters());
280
+		$identifier = $this->processIdentifier($recipe->identifier());
281
+		return $this->recipes->add($recipe, $identifier);
282
+	}
283
+
284
+
285
+
286
+	/**
287
+	 * @param string $identifier The Recipe's identifier
288
+	 * @return boolean
289
+	 */
290
+	public function removeRecipe($identifier)
291
+	{
292
+		$identifier = $this->processIdentifier($identifier);
293
+		if ($this->recipes->has($identifier)) {
294
+			$this->recipes->remove(
295
+				$this->recipes->get($identifier)
296
+			);
297
+			if ( ! $this->recipes->has($identifier)) {
298
+				return true;
299
+			}
300
+		}
301
+		return false;
302
+	}
303
+
304
+
305
+
306
+	/**
307
+	 * Get instructions on how to brew objects
308
+	 *
309
+	 * @param  string $identifier Identifier for the entity class that the recipe applies to
310
+	 *                            Typically a Fully Qualified Class Name
311
+	 * @param string $type
312
+	 * @return RecipeInterface
313
+	 */
314
+	public function getRecipe($identifier, $type = '')
315
+	{
316
+		$identifier = $this->processIdentifier($identifier);
317
+		if ($this->recipes->has($identifier)) {
318
+			return $this->recipes->get($identifier);
319
+		}
320
+		$default_recipes = $this->getDefaultRecipes();
321
+		$matches = array();
322
+		foreach ($default_recipes as $wildcard => $default_recipe) {
323
+			// is the wildcard recipe prefix in the identifier ?
324
+			if (strpos($identifier, $wildcard) !== false) {
325
+				// track matches and use the number of wildcard characters matched for the key
326
+				$matches[strlen($wildcard)] = $default_recipe;
327
+			}
328
+		}
329
+		if (count($matches) > 0) {
330
+			// sort our recipes by the number of wildcard characters matched
331
+			ksort($matches);
332
+			// then grab the last recipe form the list, since it had the most matching characters
333
+			$match = array_pop($matches);
334
+			// since we are using a default recipe, we need to set it's identifier and fqcn
335
+			return $this->copyDefaultRecipe($match, $identifier, $type);
336
+		}
337
+		if ($this->recipes->has(Recipe::DEFAULT_ID)) {
338
+			// since we are using a default recipe, we need to set it's identifier and fqcn
339
+			return $this->copyDefaultRecipe($this->recipes->get(Recipe::DEFAULT_ID), $identifier, $type);
340
+		}
341
+		throw new OutOfBoundsException(
342
+			sprintf(
343
+				__('Could not brew coffee because no recipes were found for class "%1$s".', 'event_espresso'),
344
+				$identifier
345
+			)
346
+		);
347
+	}
348
+
349
+
350
+
351
+	/**
352
+	 * adds class name aliases to list of filters
353
+	 *
354
+	 * @param  string $identifier Identifier for the entity class that the alias applies to
355
+	 *                            Typically a Fully Qualified Class Name
356
+	 * @param  array  $aliases
357
+	 * @return void
358
+	 * @throws InvalidIdentifierException
359
+	 */
360
+	public function addAliases($identifier, $aliases)
361
+	{
362
+		if (empty($aliases)) {
363
+			return;
364
+		}
365
+		$identifier = $this->processIdentifier($identifier);
366
+		foreach ((array)$aliases as $alias) {
367
+			$this->filters[$this->processIdentifier($alias)] = $identifier;
368
+		}
369
+	}
370
+
371
+
372
+
373
+	/**
374
+	 * Adds a service to one of the internal collections
375
+	 *
376
+	 * @param        $identifier
377
+	 * @param array  $arguments
378
+	 * @param string $type
379
+	 * @return mixed
380
+	 * @throws ServiceExistsException
381
+	 */
382
+	private function makeCoffee($identifier, $arguments = array(), $type = '')
383
+	{
384
+		if ((empty($type) || $type === CoffeeMaker::BREW_SHARED) && $this->has($identifier)) {
385
+			throw new ServiceExistsException($identifier);
386
+		}
387
+		$identifier = $this->filterIdentifier($identifier);
388
+		$recipe = $this->getRecipe($identifier, $type);
389
+		$type = ! empty($type) ? $type : $recipe->type();
390
+		$coffee_maker = $this->getCoffeeMaker($type);
391
+		return $coffee_maker->brew($recipe, $arguments);
392
+	}
393
+
394
+
395
+
396
+	/**
397
+	 * filters alias identifiers to find the real class name
398
+	 *
399
+	 * @param  string $identifier Identifier for the entity class that the filter applies to
400
+	 *                            Typically a Fully Qualified Class Name
401
+	 * @return string
402
+	 * @throws InvalidIdentifierException
403
+	 */
404
+	private function filterIdentifier($identifier)
405
+	{
406
+		$identifier = $this->processIdentifier($identifier);
407
+		return isset($this->filters[$identifier]) && ! empty($this->filters[$identifier])
408
+			? $this->filters[$identifier]
409
+			: $identifier;
410
+	}
411
+
412
+
413
+
414
+	/**
415
+	 * verifies and standardizes identifiers
416
+	 *
417
+	 * @param  string $identifier Identifier for the entity class
418
+	 *                            Typically a Fully Qualified Class Name
419
+	 * @return string
420
+	 * @throws InvalidIdentifierException
421
+	 */
422
+	private function processIdentifier($identifier)
423
+	{
424
+		if ( ! is_string($identifier)) {
425
+			throw new InvalidIdentifierException(
426
+				is_object($identifier) ? get_class($identifier) : gettype($identifier),
427
+				'\Fully\Qualified\ClassName'
428
+			);
429
+		}
430
+		return ltrim($identifier, '\\');
431
+	}
432
+
433
+
434
+
435
+	/**
436
+	 * @param string $type
437
+	 * @return CoffeeMakerInterface
438
+	 * @throws InvalidDataTypeException
439
+	 * @throws InvalidClassException
440
+	 */
441
+	private function getCoffeeMaker($type)
442
+	{
443
+		if ( ! $this->coffee_makers->has($type)) {
444
+			throw new OutOfBoundsException(
445
+				__('The requested coffee maker is either missing or invalid.', 'event_espresso')
446
+			);
447
+		}
448
+		return $this->coffee_makers->get($type);
449
+	}
450
+
451
+
452
+
453
+	/**
454
+	 * Retrieves all recipes that use a wildcard "*" in their identifier
455
+	 * This allows recipes to be set up for handling
456
+	 * legacy classes that do not support PSR-4 autoloading.
457
+	 * for example:
458
+	 * using "EEM_*" for a recipe identifier would target all legacy models like EEM_Attendee
459
+	 *
460
+	 * @return array
461
+	 */
462
+	private function getDefaultRecipes()
463
+	{
464
+		$default_recipes = array();
465
+		$this->recipes->rewind();
466
+		while ($this->recipes->valid()) {
467
+			$identifier = $this->recipes->getInfo();
468
+			// does this recipe use a wildcard ? (but is NOT the global default)
469
+			if ($identifier !== Recipe::DEFAULT_ID && strpos($identifier, '*') !== false) {
470
+				// strip the wildcard and use identifier as key
471
+				$default_recipes[str_replace('*', '', $identifier)] = $this->recipes->current();
472
+			}
473
+			$this->recipes->next();
474
+		}
475
+		return $default_recipes;
476
+	}
477
+
478
+
479
+
480
+	/**
481
+	 * clones a default recipe and then copies details
482
+	 * from the incoming request to it so that it can be used
483
+	 *
484
+	 * @param RecipeInterface $default_recipe
485
+	 * @param string          $identifier
486
+	 * @param string          $type
487
+	 * @return RecipeInterface
488
+	 */
489
+	private function copyDefaultRecipe(RecipeInterface $default_recipe, $identifier, $type = '')
490
+	{
491
+		$recipe = clone $default_recipe;
492
+		if ( ! empty($type)) {
493
+			$recipe->setType($type);
494
+		}
495
+		// is this the base default recipe ?
496
+		if ($default_recipe->identifier() === Recipe::DEFAULT_ID) {
497
+			$recipe->setIdentifier($identifier);
498
+			$recipe->setFqcn($identifier);
499
+			return $recipe;
500
+		}
501
+		$recipe->setIdentifier($identifier);
502
+		foreach ($default_recipe->paths() as $path) {
503
+			$path = str_replace('*', $identifier, $path);
504
+			if (is_readable($path)) {
505
+				$recipe->setPaths($path);
506
+			}
507
+		}
508
+		$recipe->setFqcn($identifier);
509
+		return $recipe;
510
+	}
511
+
512
+
513
+
514
+	/**
515
+	 * @param  string $identifier Identifier for the entity class that the service applies to
516
+	 *                            Typically a Fully Qualified Class Name
517
+	 * @param mixed  $service
518
+	 * @return object
519
+	 * @throws InvalidServiceException
520
+	 */
521
+	private function validateService($identifier, $service)
522
+	{
523
+		if ( ! is_object($service)) {
524
+			throw new InvalidServiceException(
525
+				$identifier,
526
+				$service
527
+			);
528
+		}
529
+		return $service;
530
+	}
531 531
 
532 532
 }
533 533
 // End of file CoffeeShop.php
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 1 patch
Indentation   +1406 added lines, -1406 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -31,1533 +31,1533 @@  discard block
 block discarded – undo
31 31
 class espresso_events_Pricing_Hooks extends EE_Admin_Hooks
32 32
 {
33 33
     
34
-    /**
35
-     * This property is just used to hold the status of whether an event is currently being
36
-     * created (true) or edited (false)
37
-     * @access protected
38
-     * @var bool
39
-     */
40
-    protected $_is_creating_event;
34
+	/**
35
+	 * This property is just used to hold the status of whether an event is currently being
36
+	 * created (true) or edited (false)
37
+	 * @access protected
38
+	 * @var bool
39
+	 */
40
+	protected $_is_creating_event;
41 41
     
42 42
     
43
-    /**
44
-     * Used to contain the format strings for date and time that will be used for php date and
45
-     * time.
46
-     *
47
-     * Is set in the _set_hooks_properties() method.
48
-     *
49
-     * @var array
50
-     */
51
-    protected $_date_format_strings;
43
+	/**
44
+	 * Used to contain the format strings for date and time that will be used for php date and
45
+	 * time.
46
+	 *
47
+	 * Is set in the _set_hooks_properties() method.
48
+	 *
49
+	 * @var array
50
+	 */
51
+	protected $_date_format_strings;
52 52
     
53 53
     
54
-    protected function _set_hooks_properties()
55
-    {
56
-        $this->_name = 'pricing';
57
-        
58
-        //capability check
59
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices',
60
-            'advanced_ticket_datetime_metabox')
61
-        ) {
62
-            return;
63
-        }
64
-        
65
-        
66
-        //if we were going to add our own metaboxes we'd use the below.
67
-        $this->_metaboxes = array(
68
-            0 => array(
69
-                'page_route' => array('edit', 'create_new'),
70
-                'func'       => 'pricing_metabox',
71
-                'label'      => __('Event Tickets & Datetimes', 'event_espresso'),
72
-                'priority'   => 'high',
73
-                'context'    => 'normal'
74
-            ),
75
-        
76
-        );/**/
77
-        
78
-        $this->_remove_metaboxes = array(
79
-            0 => array(
80
-                'page_route' => array('edit', 'create_new'),
81
-                'id'         => 'espresso_event_editor_tickets',
82
-                'context'    => 'normal'
83
-            )
84
-        );
85
-        
86
-        /**
87
-         * Format strings for date and time.  Defaults are existing behaviour from 4.1.
88
-         * Note, that if you return null as the value for 'date', and 'time' in the array, then
89
-         * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
90
-         *
91
-         * @since 4.6.7
92
-         *
93
-         * @var array  Expected an array returned with 'date' and 'time' keys.
94
-         */
95
-        $this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
96
-            array(
97
-                'date' => 'Y-m-d',
98
-                'time' => 'h:i a'
99
-            ));
100
-        
101
-        //validate
102
-        $this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null;
103
-        $this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null;
104
-        
105
-        //validate format strings
106
-        $format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']);
107
-        if (is_array($format_validation)) {
108
-            $msg = '<p>' . sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:',
109
-                    'event_espresso'),
110
-                    $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']) . '</p><ul>';
111
-            foreach ($format_validation as $error) {
112
-                $msg .= '<li>' . $error . '</li>';
113
-            }
114
-            $msg .= '</ul></p><p>' . sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
115
-                    'event_espresso'), '<span style="color:#D54E21;">', '</span>') . '</p>';
116
-            EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
117
-            $this->_date_format_strings = array(
118
-                'date' => 'Y-m-d',
119
-                'time' => 'h:i a'
120
-            );
121
-        }
122
-        
123
-        
124
-        $this->_scripts_styles = array(
125
-            'registers'   => array(
126
-                'ee-tickets-datetimes-css' => array(
127
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
128
-                    'type' => 'css'
129
-                ),
130
-                'ee-dtt-ticket-metabox'    => array(
131
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
132
-                    'depends' => array('ee-datepicker', 'ee-dialog', 'underscore')
133
-                )
134
-            ),
135
-            'deregisters' => array(
136
-                'event-editor-css'       => array('type' => 'css'),
137
-                'event-datetime-metabox' => array('type' => 'js')
138
-            ),
139
-            'enqueues'    => array(
140
-                'ee-tickets-datetimes-css' => array('edit', 'create_new'),
141
-                'ee-dtt-ticket-metabox'    => array('edit', 'create_new')
142
-            ),
143
-            'localize'    => array(
144
-                'ee-dtt-ticket-metabox' => array(
145
-                    'DTT_TRASH_BLOCK'       => array(
146
-                        'main_warning'            => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
147
-                            'event_espresso'),
148
-                        'after_warning'           => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
149
-                            'event_espresso'),
150
-                        'cancel_button'           => '<button class="button-secondary ee-modal-cancel">' . __('Cancel',
151
-                                'event_espresso') . '</button>',
152
-                        'close_button'            => '<button class="button-secondary ee-modal-cancel">' . __('Close',
153
-                                'event_espresso') . '</button>',
154
-                        'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
155
-                            'event_espresso'),
156
-                        'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
157
-                            'event_espresso'),
158
-                        'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss',
159
-                                'event_espresso') . '</button>'
160
-                    ),
161
-                    'DTT_ERROR_MSG'         => array(
162
-                        'no_ticket_name' => __('General Admission', 'event_espresso'),
163
-                        'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss',
164
-                                'event_espresso') . '</button></div>'
165
-                    ),
166
-                    'DTT_OVERSELL_WARNING'  => array(
167
-                        'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
168
-                            'event_espresso'),
169
-                        'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
170
-                            'event_espresso')
171
-                    ),
172
-                    'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'],
173
-                        $this->_date_format_strings['time']),
174
-                    'DTT_START_OF_WEEK'     => array('dayValue' => (int)get_option('start_of_week'))
175
-                )
176
-            )
177
-        );
178
-        
179
-        
180
-        add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
181
-            array($this, 'autosave_handling'), 10);
182
-        add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
183
-            array($this, 'caf_updates'), 10);
184
-    }
54
+	protected function _set_hooks_properties()
55
+	{
56
+		$this->_name = 'pricing';
57
+        
58
+		//capability check
59
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices',
60
+			'advanced_ticket_datetime_metabox')
61
+		) {
62
+			return;
63
+		}
64
+        
65
+        
66
+		//if we were going to add our own metaboxes we'd use the below.
67
+		$this->_metaboxes = array(
68
+			0 => array(
69
+				'page_route' => array('edit', 'create_new'),
70
+				'func'       => 'pricing_metabox',
71
+				'label'      => __('Event Tickets & Datetimes', 'event_espresso'),
72
+				'priority'   => 'high',
73
+				'context'    => 'normal'
74
+			),
75
+        
76
+		);/**/
77
+        
78
+		$this->_remove_metaboxes = array(
79
+			0 => array(
80
+				'page_route' => array('edit', 'create_new'),
81
+				'id'         => 'espresso_event_editor_tickets',
82
+				'context'    => 'normal'
83
+			)
84
+		);
85
+        
86
+		/**
87
+		 * Format strings for date and time.  Defaults are existing behaviour from 4.1.
88
+		 * Note, that if you return null as the value for 'date', and 'time' in the array, then
89
+		 * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
90
+		 *
91
+		 * @since 4.6.7
92
+		 *
93
+		 * @var array  Expected an array returned with 'date' and 'time' keys.
94
+		 */
95
+		$this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
96
+			array(
97
+				'date' => 'Y-m-d',
98
+				'time' => 'h:i a'
99
+			));
100
+        
101
+		//validate
102
+		$this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null;
103
+		$this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null;
104
+        
105
+		//validate format strings
106
+		$format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']);
107
+		if (is_array($format_validation)) {
108
+			$msg = '<p>' . sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:',
109
+					'event_espresso'),
110
+					$this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']) . '</p><ul>';
111
+			foreach ($format_validation as $error) {
112
+				$msg .= '<li>' . $error . '</li>';
113
+			}
114
+			$msg .= '</ul></p><p>' . sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
115
+					'event_espresso'), '<span style="color:#D54E21;">', '</span>') . '</p>';
116
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
117
+			$this->_date_format_strings = array(
118
+				'date' => 'Y-m-d',
119
+				'time' => 'h:i a'
120
+			);
121
+		}
122
+        
123
+        
124
+		$this->_scripts_styles = array(
125
+			'registers'   => array(
126
+				'ee-tickets-datetimes-css' => array(
127
+					'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
128
+					'type' => 'css'
129
+				),
130
+				'ee-dtt-ticket-metabox'    => array(
131
+					'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
132
+					'depends' => array('ee-datepicker', 'ee-dialog', 'underscore')
133
+				)
134
+			),
135
+			'deregisters' => array(
136
+				'event-editor-css'       => array('type' => 'css'),
137
+				'event-datetime-metabox' => array('type' => 'js')
138
+			),
139
+			'enqueues'    => array(
140
+				'ee-tickets-datetimes-css' => array('edit', 'create_new'),
141
+				'ee-dtt-ticket-metabox'    => array('edit', 'create_new')
142
+			),
143
+			'localize'    => array(
144
+				'ee-dtt-ticket-metabox' => array(
145
+					'DTT_TRASH_BLOCK'       => array(
146
+						'main_warning'            => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
147
+							'event_espresso'),
148
+						'after_warning'           => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
149
+							'event_espresso'),
150
+						'cancel_button'           => '<button class="button-secondary ee-modal-cancel">' . __('Cancel',
151
+								'event_espresso') . '</button>',
152
+						'close_button'            => '<button class="button-secondary ee-modal-cancel">' . __('Close',
153
+								'event_espresso') . '</button>',
154
+						'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
155
+							'event_espresso'),
156
+						'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
157
+							'event_espresso'),
158
+						'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss',
159
+								'event_espresso') . '</button>'
160
+					),
161
+					'DTT_ERROR_MSG'         => array(
162
+						'no_ticket_name' => __('General Admission', 'event_espresso'),
163
+						'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss',
164
+								'event_espresso') . '</button></div>'
165
+					),
166
+					'DTT_OVERSELL_WARNING'  => array(
167
+						'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
168
+							'event_espresso'),
169
+						'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
170
+							'event_espresso')
171
+					),
172
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'],
173
+						$this->_date_format_strings['time']),
174
+					'DTT_START_OF_WEEK'     => array('dayValue' => (int)get_option('start_of_week'))
175
+				)
176
+			)
177
+		);
178
+        
179
+        
180
+		add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
181
+			array($this, 'autosave_handling'), 10);
182
+		add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
183
+			array($this, 'caf_updates'), 10);
184
+	}
185 185
     
186 186
     
187
-    public function caf_updates($update_callbacks)
188
-    {
189
-        foreach ($update_callbacks as $key => $callback) {
190
-            if ($callback[1] == '_default_tickets_update') {
191
-                unset($update_callbacks[$key]);
192
-            }
193
-        }
194
-        
195
-        $update_callbacks[] = array($this, 'dtt_and_tickets_caf_update');
196
-        
197
-        return $update_callbacks;
198
-    }
187
+	public function caf_updates($update_callbacks)
188
+	{
189
+		foreach ($update_callbacks as $key => $callback) {
190
+			if ($callback[1] == '_default_tickets_update') {
191
+				unset($update_callbacks[$key]);
192
+			}
193
+		}
194
+        
195
+		$update_callbacks[] = array($this, 'dtt_and_tickets_caf_update');
196
+        
197
+		return $update_callbacks;
198
+	}
199 199
     
200 200
     
201
-    /**
202
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
203
-     *
204
-     * @param  EE_Event $evtobj The Event object we're attaching data to
205
-     * @param  array    $data   The request data from the form
206
-     *
207
-     * @return bool             success or fail
208
-     */
209
-    public function dtt_and_tickets_caf_update($evtobj, $data)
210
-    {
211
-        //first we need to start with datetimes cause they are the "root" items attached to events.
212
-        $saved_dtts = $this->_update_dtts($evtobj, $data);
213
-        //next tackle the tickets (and prices?)
214
-        $this->_update_tkts($evtobj, $saved_dtts, $data);
215
-    }
201
+	/**
202
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
203
+	 *
204
+	 * @param  EE_Event $evtobj The Event object we're attaching data to
205
+	 * @param  array    $data   The request data from the form
206
+	 *
207
+	 * @return bool             success or fail
208
+	 */
209
+	public function dtt_and_tickets_caf_update($evtobj, $data)
210
+	{
211
+		//first we need to start with datetimes cause they are the "root" items attached to events.
212
+		$saved_dtts = $this->_update_dtts($evtobj, $data);
213
+		//next tackle the tickets (and prices?)
214
+		$this->_update_tkts($evtobj, $saved_dtts, $data);
215
+	}
216 216
     
217 217
     
218
-    /**
219
-     * update event_datetimes
220
-     *
221
-     * @param  EE_Event $evt_obj Event being updated
222
-     * @param  array    $data    the request data from the form
223
-     *
224
-     * @return EE_Datetime[]
225
-     */
226
-    protected function _update_dtts($evt_obj, $data)
227
-    {
228
-        $timezone       = isset($data['timezone_string']) ? $data['timezone_string'] : null;
229
-        $saved_dtt_ids  = array();
230
-        $saved_dtt_objs = array();
231
-        
232
-        foreach ($data['edit_event_datetimes'] as $row => $dtt) {
233
-            //trim all values to ensure any excess whitespace is removed.
234
-            $dtt                = array_map(
235
-                function ($datetime_data) {
236
-                    return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
237
-                },
238
-                $dtt
239
-            );
240
-            $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
241
-            $datetime_values    = array(
242
-                'DTT_ID'          => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
243
-                'DTT_name'        => ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '',
244
-                'DTT_description' => ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '',
245
-                'DTT_EVT_start'   => $dtt['DTT_EVT_start'],
246
-                'DTT_EVT_end'     => $dtt['DTT_EVT_end'],
247
-                'DTT_reg_limit'   => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
248
-                'DTT_order'       => ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'],
249
-            );
218
+	/**
219
+	 * update event_datetimes
220
+	 *
221
+	 * @param  EE_Event $evt_obj Event being updated
222
+	 * @param  array    $data    the request data from the form
223
+	 *
224
+	 * @return EE_Datetime[]
225
+	 */
226
+	protected function _update_dtts($evt_obj, $data)
227
+	{
228
+		$timezone       = isset($data['timezone_string']) ? $data['timezone_string'] : null;
229
+		$saved_dtt_ids  = array();
230
+		$saved_dtt_objs = array();
231
+        
232
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
233
+			//trim all values to ensure any excess whitespace is removed.
234
+			$dtt                = array_map(
235
+				function ($datetime_data) {
236
+					return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
237
+				},
238
+				$dtt
239
+			);
240
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
241
+			$datetime_values    = array(
242
+				'DTT_ID'          => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
243
+				'DTT_name'        => ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '',
244
+				'DTT_description' => ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '',
245
+				'DTT_EVT_start'   => $dtt['DTT_EVT_start'],
246
+				'DTT_EVT_end'     => $dtt['DTT_EVT_end'],
247
+				'DTT_reg_limit'   => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
248
+				'DTT_order'       => ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'],
249
+			);
250 250
             
251
-            //if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
251
+			//if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
252 252
             
253
-            if ( ! empty($dtt['DTT_ID'])) {
254
-                $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']);
253
+			if ( ! empty($dtt['DTT_ID'])) {
254
+				$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']);
255 255
                 
256
-                //set date and time format according to what is set in this class.
257
-                $DTM->set_date_format($this->_date_format_strings['date']);
258
-                $DTM->set_time_format($this->_date_format_strings['time']);
256
+				//set date and time format according to what is set in this class.
257
+				$DTM->set_date_format($this->_date_format_strings['date']);
258
+				$DTM->set_time_format($this->_date_format_strings['time']);
259 259
                 
260
-                foreach ($datetime_values as $field => $value) {
261
-                    $DTM->set($field, $value);
262
-                }
260
+				foreach ($datetime_values as $field => $value) {
261
+					$DTM->set($field, $value);
262
+				}
263 263
                 
264
-                // make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.
265
-                // We need to do this so we dont' TRASH the parent DTT.(save the ID for both key and value to avoid duplications)
266
-                $saved_dtt_ids[$DTM->ID()] = $DTM->ID();
264
+				// make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.
265
+				// We need to do this so we dont' TRASH the parent DTT.(save the ID for both key and value to avoid duplications)
266
+				$saved_dtt_ids[$DTM->ID()] = $DTM->ID();
267 267
                 
268
-            } else {
269
-                $DTM = EE_Registry::instance()->load_class(
270
-                    'Datetime',
271
-                    array(
272
-                        $datetime_values,
273
-                        $timezone,
274
-                        array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
275
-                    ),
276
-                    false,
277
-                    false
278
-                );
268
+			} else {
269
+				$DTM = EE_Registry::instance()->load_class(
270
+					'Datetime',
271
+					array(
272
+						$datetime_values,
273
+						$timezone,
274
+						array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
275
+					),
276
+					false,
277
+					false
278
+				);
279 279
                 
280
-                foreach ($datetime_values as $field => $value) {
281
-                    $DTM->set($field, $value);
282
-                }
283
-            }
280
+				foreach ($datetime_values as $field => $value) {
281
+					$DTM->set($field, $value);
282
+				}
283
+			}
284 284
             
285 285
             
286
-            $DTM->save();
287
-            $DTM = $evt_obj->_add_relation_to($DTM, 'Datetime');
288
-            $evt_obj->save();
286
+			$DTM->save();
287
+			$DTM = $evt_obj->_add_relation_to($DTM, 'Datetime');
288
+			$evt_obj->save();
289 289
             
290
-            //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
291
-            if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) {
292
-                $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start'));
293
-                $DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days');
294
-                $DTM->save();
295
-            }
290
+			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
291
+			if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) {
292
+				$DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start'));
293
+				$DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days');
294
+				$DTM->save();
295
+			}
296 296
             
297
-            //	now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
298
-            // because it is possible there was a new one created for the autosave.
299
-            // (save the ID for both key and value to avoid duplications)
300
-            $saved_dtt_ids[$DTM->ID()] = $DTM->ID();
301
-            $saved_dtt_objs[$row]      = $DTM;
297
+			//	now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
298
+			// because it is possible there was a new one created for the autosave.
299
+			// (save the ID for both key and value to avoid duplications)
300
+			$saved_dtt_ids[$DTM->ID()] = $DTM->ID();
301
+			$saved_dtt_objs[$row]      = $DTM;
302 302
             
303
-            //todo if ANY of these updates fail then we want the appropriate global error message.
304
-        }
305
-        
306
-        //now we need to REMOVE any dtts that got deleted.  Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point.
307
-        $old_datetimes = explode(',', $data['datetime_IDs']);
308
-        $old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes;
309
-        
310
-        if (is_array($old_datetimes)) {
311
-            $dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
312
-            foreach ($dtts_to_delete as $id) {
313
-                $id = absint($id);
314
-                if (empty($id)) {
315
-                    continue;
316
-                }
303
+			//todo if ANY of these updates fail then we want the appropriate global error message.
304
+		}
305
+        
306
+		//now we need to REMOVE any dtts that got deleted.  Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point.
307
+		$old_datetimes = explode(',', $data['datetime_IDs']);
308
+		$old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes;
309
+        
310
+		if (is_array($old_datetimes)) {
311
+			$dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
312
+			foreach ($dtts_to_delete as $id) {
313
+				$id = absint($id);
314
+				if (empty($id)) {
315
+					continue;
316
+				}
317 317
                 
318
-                $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
318
+				$dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
319 319
                 
320
-                //remove tkt relationships.
321
-                $related_tickets = $dtt_to_remove->get_many_related('Ticket');
322
-                foreach ($related_tickets as $tkt) {
323
-                    $dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
324
-                }
320
+				//remove tkt relationships.
321
+				$related_tickets = $dtt_to_remove->get_many_related('Ticket');
322
+				foreach ($related_tickets as $tkt) {
323
+					$dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
324
+				}
325 325
                 
326
-                $evt_obj->_remove_relation_to($id, 'Datetime');
327
-                $dtt_to_remove->refresh_cache_of_related_objects();
326
+				$evt_obj->_remove_relation_to($id, 'Datetime');
327
+				$dtt_to_remove->refresh_cache_of_related_objects();
328 328
                 
329
-            }
330
-        }
329
+			}
330
+		}
331 331
         
332
-        return $saved_dtt_objs;
333
-    }
332
+		return $saved_dtt_objs;
333
+	}
334 334
     
335 335
     
336
-    /**
337
-     * update tickets
338
-     *
339
-     * @param  EE_Event      $evtobj     Event object being updated
340
-     * @param  EE_Datetime[] $saved_dtts an array of datetime ids being updated
341
-     * @param  array         $data       incoming request data
342
-     *
343
-     * @return EE_Ticket[]
344
-     */
345
-    protected function _update_tkts($evtobj, $saved_dtts, $data)
346
-    {
347
-        
348
-        $new_tkt     = null;
349
-        $new_default = null;
350
-        //stripslashes because WP filtered the $_POST ($data) array to add slashes
351
-        $data          = stripslashes_deep($data);
352
-        $timezone      = isset($data['timezone_string']) ? $data['timezone_string'] : null;
353
-        $saved_tickets = $dtts_on_existing = array();
354
-        $old_tickets   = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
355
-        
356
-        //load money helper
357
-        
358
-        foreach ($data['edit_tickets'] as $row => $tkt) {
336
+	/**
337
+	 * update tickets
338
+	 *
339
+	 * @param  EE_Event      $evtobj     Event object being updated
340
+	 * @param  EE_Datetime[] $saved_dtts an array of datetime ids being updated
341
+	 * @param  array         $data       incoming request data
342
+	 *
343
+	 * @return EE_Ticket[]
344
+	 */
345
+	protected function _update_tkts($evtobj, $saved_dtts, $data)
346
+	{
347
+        
348
+		$new_tkt     = null;
349
+		$new_default = null;
350
+		//stripslashes because WP filtered the $_POST ($data) array to add slashes
351
+		$data          = stripslashes_deep($data);
352
+		$timezone      = isset($data['timezone_string']) ? $data['timezone_string'] : null;
353
+		$saved_tickets = $dtts_on_existing = array();
354
+		$old_tickets   = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
355
+        
356
+		//load money helper
357
+        
358
+		foreach ($data['edit_tickets'] as $row => $tkt) {
359 359
             
360
-            $update_prices = $create_new_TKT = false;
360
+			$update_prices = $create_new_TKT = false;
361 361
             
362
-            //figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session.
362
+			//figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session.
363 363
             
364
-            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
365
-            $tkt_dtt_rows          = explode(',', $data['ticket_datetime_rows'][$row]);
366
-            $dtts_added            = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
367
-            $dtts_removed          = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
364
+			$starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
365
+			$tkt_dtt_rows          = explode(',', $data['ticket_datetime_rows'][$row]);
366
+			$dtts_added            = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
367
+			$dtts_removed          = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
368 368
             
369
-            // trim inputs to ensure any excess whitespace is removed.
370
-            $tkt = array_map(
371
-                function ($ticket_data) {
372
-                    return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
373
-                },
374
-                $tkt
375
-            );
369
+			// trim inputs to ensure any excess whitespace is removed.
370
+			$tkt = array_map(
371
+				function ($ticket_data) {
372
+					return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
373
+				},
374
+				$tkt
375
+			);
376 376
             
377
-            //note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models.
378
-            //note incoming ['TKT_price'] value is already in standard notation (via js).
379
-            $ticket_price = isset($tkt['TKT_price']) ? round((float)$tkt['TKT_price'], 3) : 0;
377
+			//note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models.
378
+			//note incoming ['TKT_price'] value is already in standard notation (via js).
379
+			$ticket_price = isset($tkt['TKT_price']) ? round((float)$tkt['TKT_price'], 3) : 0;
380 380
             
381
-            //note incoming base price needs converted from localized value.
382
-            $base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0;
383
-            //if ticket price == 0 and $base_price != 0 then ticket price == base_price
384
-            $ticket_price  = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price;
385
-            $base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0;
381
+			//note incoming base price needs converted from localized value.
382
+			$base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0;
383
+			//if ticket price == 0 and $base_price != 0 then ticket price == base_price
384
+			$ticket_price  = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price;
385
+			$base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0;
386 386
             
387
-            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array();
387
+			$price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array();
388 388
             
389
-            $now = null;
390
-            if (empty($tkt['TKT_start_date'])) {
391
-                //lets' use now in the set timezone.
392
-                $now                   = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
393
-                $tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']);
394
-            }
389
+			$now = null;
390
+			if (empty($tkt['TKT_start_date'])) {
391
+				//lets' use now in the set timezone.
392
+				$now                   = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
393
+				$tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']);
394
+			}
395 395
             
396
-            if (empty($tkt['TKT_end_date'])) {
397
-                /**
398
-                 * set the TKT_end_date to the first datetime attached to the ticket.
399
-                 */
400
-                $first_dtt           = $saved_dtts[reset($tkt_dtt_rows)];
401
-                $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time']);
402
-            }
396
+			if (empty($tkt['TKT_end_date'])) {
397
+				/**
398
+				 * set the TKT_end_date to the first datetime attached to the ticket.
399
+				 */
400
+				$first_dtt           = $saved_dtts[reset($tkt_dtt_rows)];
401
+				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time']);
402
+			}
403 403
             
404
-            $TKT_values = array(
405
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
406
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
407
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
408
-                'TKT_description' => ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description',
409
-                    'event_espresso') ? $tkt['TKT_description'] : '',
410
-                'TKT_start_date'  => $tkt['TKT_start_date'],
411
-                'TKT_end_date'    => $tkt['TKT_end_date'],
412
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
413
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
414
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
415
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
416
-                'TKT_row'         => $row,
417
-                'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0,
418
-                'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
419
-                'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
420
-                'TKT_price'       => $ticket_price
421
-            );
404
+			$TKT_values = array(
405
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
406
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
407
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
408
+				'TKT_description' => ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description',
409
+					'event_espresso') ? $tkt['TKT_description'] : '',
410
+				'TKT_start_date'  => $tkt['TKT_start_date'],
411
+				'TKT_end_date'    => $tkt['TKT_end_date'],
412
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
413
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
414
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
415
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
416
+				'TKT_row'         => $row,
417
+				'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0,
418
+				'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
419
+				'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
420
+				'TKT_price'       => $ticket_price
421
+			);
422 422
             
423 423
             
424
-            //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
425
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
426
-                $TKT_values['TKT_ID']         = 0;
427
-                $TKT_values['TKT_is_default'] = 0;
428
-                $update_prices                = true;
429
-            }
424
+			//if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
425
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
426
+				$TKT_values['TKT_ID']         = 0;
427
+				$TKT_values['TKT_is_default'] = 0;
428
+				$update_prices                = true;
429
+			}
430 430
             
431
-            // if we have a TKT_ID then we need to get that existing TKT_obj and update it
432
-            // we actually do our saves ahead of doing any add_relations to
433
-            // because its entirely possible that this ticket wasn't removed or added to any datetime in the session
434
-            // but DID have it's items modified.
435
-            // keep in mind that if the TKT has been sold (and we have changed pricing information),
436
-            // then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
437
-            if (absint($TKT_values['TKT_ID'])) {
438
-                $TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']);
439
-                if ($TKT instanceof EE_Ticket) {
431
+			// if we have a TKT_ID then we need to get that existing TKT_obj and update it
432
+			// we actually do our saves ahead of doing any add_relations to
433
+			// because its entirely possible that this ticket wasn't removed or added to any datetime in the session
434
+			// but DID have it's items modified.
435
+			// keep in mind that if the TKT has been sold (and we have changed pricing information),
436
+			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
437
+			if (absint($TKT_values['TKT_ID'])) {
438
+				$TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']);
439
+				if ($TKT instanceof EE_Ticket) {
440 440
                     
441
-                    $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
442
-                    // are there any registrations using this ticket ?
443
-                    $tickets_sold = $TKT->count_related(
444
-                        'Registration',
445
-                        array(
446
-                            array(
447
-                                'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))
448
-                            )
449
-                        )
450
-                    );
451
-                    //set ticket formats
452
-                    $TKT->set_date_format($this->_date_format_strings['date']);
453
-                    $TKT->set_time_format($this->_date_format_strings['time']);
441
+					$TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
442
+					// are there any registrations using this ticket ?
443
+					$tickets_sold = $TKT->count_related(
444
+						'Registration',
445
+						array(
446
+							array(
447
+								'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))
448
+							)
449
+						)
450
+					);
451
+					//set ticket formats
452
+					$TKT->set_date_format($this->_date_format_strings['date']);
453
+					$TKT->set_time_format($this->_date_format_strings['time']);
454 454
                     
455
-                    // let's just check the total price for the existing ticket
456
-                    // and determine if it matches the new total price.
457
-                    // if they are different then we create a new ticket (if tkts sold)
458
-                    // if they aren't different then we go ahead and modify existing ticket.
459
-                    $create_new_TKT = $tickets_sold > 0 && $ticket_price != $TKT->price() && ! $TKT->deleted()
460
-                        ? true : false;
455
+					// let's just check the total price for the existing ticket
456
+					// and determine if it matches the new total price.
457
+					// if they are different then we create a new ticket (if tkts sold)
458
+					// if they aren't different then we go ahead and modify existing ticket.
459
+					$create_new_TKT = $tickets_sold > 0 && $ticket_price != $TKT->price() && ! $TKT->deleted()
460
+						? true : false;
461 461
                     
462
-                    //set new values
463
-                    foreach ($TKT_values as $field => $value) {
464
-                        if ($field === 'TKT_qty') {
465
-                            $TKT->set_qty($value);
466
-                        } else {
467
-                            $TKT->set($field, $value);
468
-                        }
469
-                    }
462
+					//set new values
463
+					foreach ($TKT_values as $field => $value) {
464
+						if ($field === 'TKT_qty') {
465
+							$TKT->set_qty($value);
466
+						} else {
467
+							$TKT->set($field, $value);
468
+						}
469
+					}
470 470
                     
471
-                    //if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
472
-                    if ($create_new_TKT) {
473
-                        $new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price,
474
-                            $base_price_id);
475
-                    }
476
-                }
471
+					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
472
+					if ($create_new_TKT) {
473
+						$new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price,
474
+							$base_price_id);
475
+					}
476
+				}
477 477
                 
478
-            } else {
479
-                // no TKT_id so a new TKT
480
-                $TKT = EE_Ticket::new_instance(
481
-                    $TKT_values,
482
-                    $timezone,
483
-                    array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
484
-                );
485
-                if ($TKT instanceof EE_Ticket) {
486
-                    // make sure ticket has an ID of setting relations won't work
487
-                    $TKT->save();
488
-                    $TKT           = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
489
-                    $update_prices = true;
490
-                }
491
-            }
492
-            //make sure any current values have been saved.
493
-            //$TKT->save();
478
+			} else {
479
+				// no TKT_id so a new TKT
480
+				$TKT = EE_Ticket::new_instance(
481
+					$TKT_values,
482
+					$timezone,
483
+					array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
484
+				);
485
+				if ($TKT instanceof EE_Ticket) {
486
+					// make sure ticket has an ID of setting relations won't work
487
+					$TKT->save();
488
+					$TKT           = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
489
+					$update_prices = true;
490
+				}
491
+			}
492
+			//make sure any current values have been saved.
493
+			//$TKT->save();
494 494
             
495
-            //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
496
-            if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
497
-                $TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
498
-                $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
499
-            }
495
+			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
496
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
497
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
498
+				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
499
+			}
500 500
             
501
-            //let's make sure the base price is handled
502
-            $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price,
503
-                $base_price_id) : $TKT;
501
+			//let's make sure the base price is handled
502
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price,
503
+				$base_price_id) : $TKT;
504 504
             
505
-            //add/update price_modifiers
506
-            $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT;
505
+			//add/update price_modifiers
506
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT;
507 507
             
508
-            //need to make sue that the TKT_price is accurate after saving the prices.
509
-            $TKT->ensure_TKT_Price_correct();
508
+			//need to make sue that the TKT_price is accurate after saving the prices.
509
+			$TKT->ensure_TKT_Price_correct();
510 510
             
511
-            //handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
512
-            if ( ! defined('DOING_AUTOSAVE')) {
513
-                if ( ! empty($tkt['TKT_is_default_selector'])) {
514
-                    $update_prices = true;
515
-                    $new_default   = clone $TKT;
516
-                    $new_default->set('TKT_ID', 0);
517
-                    $new_default->set('TKT_is_default', 1);
518
-                    $new_default->set('TKT_row', 1);
519
-                    $new_default->set('TKT_price', $ticket_price);
520
-                    //remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object)
521
-                    $new_default->_remove_relations('Datetime');
522
-                    //todo we need to add the current attached prices as new prices to the new default ticket.
523
-                    $new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices);
524
-                    //don't forget the base price!
525
-                    $new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price,
526
-                        $base_price_id);
527
-                    $new_default->save();
528
-                    do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default,
529
-                        $row, $TKT, $data);
530
-                }
531
-            }
511
+			//handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
512
+			if ( ! defined('DOING_AUTOSAVE')) {
513
+				if ( ! empty($tkt['TKT_is_default_selector'])) {
514
+					$update_prices = true;
515
+					$new_default   = clone $TKT;
516
+					$new_default->set('TKT_ID', 0);
517
+					$new_default->set('TKT_is_default', 1);
518
+					$new_default->set('TKT_row', 1);
519
+					$new_default->set('TKT_price', $ticket_price);
520
+					//remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object)
521
+					$new_default->_remove_relations('Datetime');
522
+					//todo we need to add the current attached prices as new prices to the new default ticket.
523
+					$new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices);
524
+					//don't forget the base price!
525
+					$new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price,
526
+						$base_price_id);
527
+					$new_default->save();
528
+					do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default,
529
+						$row, $TKT, $data);
530
+				}
531
+			}
532 532
             
533 533
             
534
-            //DO ALL dtt relationships for both current tickets and any archived tickets for the given dtt that are related to the current ticket. TODO... not sure exactly how we're going to do this considering we don't know what current ticket the archived tickets are related to (and TKT_parent is used for autosaves so that's not a field we can reliably use).
534
+			//DO ALL dtt relationships for both current tickets and any archived tickets for the given dtt that are related to the current ticket. TODO... not sure exactly how we're going to do this considering we don't know what current ticket the archived tickets are related to (and TKT_parent is used for autosaves so that's not a field we can reliably use).
535 535
             
536 536
             
537
-            //let's assign any tickets that have been setup to the saved_tickets tracker
538
-            //save existing TKT
539
-            $TKT->save();
540
-            if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
541
-                //save new TKT
542
-                $new_tkt->save();
543
-                //add new ticket to array
544
-                $saved_tickets[$new_tkt->ID()] = $new_tkt;
537
+			//let's assign any tickets that have been setup to the saved_tickets tracker
538
+			//save existing TKT
539
+			$TKT->save();
540
+			if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
541
+				//save new TKT
542
+				$new_tkt->save();
543
+				//add new ticket to array
544
+				$saved_tickets[$new_tkt->ID()] = $new_tkt;
545 545
                 
546
-                do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data);
546
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data);
547 547
                 
548
-            } else {
549
-                //add tkt to saved tkts
550
-                $saved_tickets[$TKT->ID()] = $TKT;
548
+			} else {
549
+				//add tkt to saved tkts
550
+				$saved_tickets[$TKT->ID()] = $TKT;
551 551
                 
552
-                do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data);
553
-            }
552
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data);
553
+			}
554 554
             
555
-        }
556
-        
557
-        // now we need to handle tickets actually "deleted permanently".
558
-        // There are cases where we'd want this to happen
559
-        // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
560
-        // Or a draft event was saved and in the process of editing a ticket is trashed.
561
-        // No sense in keeping all the related data in the db!
562
-        $old_tickets     = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
563
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
564
-        
565
-        foreach ($tickets_removed as $id) {
566
-            $id = absint($id);
555
+		}
556
+        
557
+		// now we need to handle tickets actually "deleted permanently".
558
+		// There are cases where we'd want this to happen
559
+		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
560
+		// Or a draft event was saved and in the process of editing a ticket is trashed.
561
+		// No sense in keeping all the related data in the db!
562
+		$old_tickets     = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
563
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
564
+        
565
+		foreach ($tickets_removed as $id) {
566
+			$id = absint($id);
567 567
             
568
-            //get the ticket for this id
569
-            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
568
+			//get the ticket for this id
569
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
570 570
             
571
-            //if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
572
-            if ($tkt_to_remove->get('TKT_is_default')) {
573
-                continue;
574
-            }
571
+			//if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
572
+			if ($tkt_to_remove->get('TKT_is_default')) {
573
+				continue;
574
+			}
575 575
             
576
-            // if this tkt has any registrations attached so then we just ARCHIVE
577
-            // because we don't actually permanently delete these tickets.
578
-            if ($tkt_to_remove->count_related('Registration') > 0) {
579
-                $tkt_to_remove->delete();
580
-                continue;
581
-            }
576
+			// if this tkt has any registrations attached so then we just ARCHIVE
577
+			// because we don't actually permanently delete these tickets.
578
+			if ($tkt_to_remove->count_related('Registration') > 0) {
579
+				$tkt_to_remove->delete();
580
+				continue;
581
+			}
582 582
             
583
-            // need to get all the related datetimes on this ticket and remove from every single one of them
584
-            // (remember this process can ONLY kick off if there are NO tkts_sold)
585
-            $dtts = $tkt_to_remove->get_many_related('Datetime');
583
+			// need to get all the related datetimes on this ticket and remove from every single one of them
584
+			// (remember this process can ONLY kick off if there are NO tkts_sold)
585
+			$dtts = $tkt_to_remove->get_many_related('Datetime');
586 586
             
587
-            foreach ($dtts as $dtt) {
588
-                $tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
589
-            }
587
+			foreach ($dtts as $dtt) {
588
+				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
589
+			}
590 590
             
591
-            // need to do the same for prices (except these prices can also be deleted because again,
592
-            // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
593
-            $tkt_to_remove->delete_related_permanently('Price');
591
+			// need to do the same for prices (except these prices can also be deleted because again,
592
+			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
593
+			$tkt_to_remove->delete_related_permanently('Price');
594 594
             
595
-            do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
595
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
596 596
             
597
-            // finally let's delete this ticket
598
-            // (which should not be blocked at this point b/c we've removed all our relationships)
599
-            $tkt_to_remove->delete_permanently();
600
-        }
597
+			// finally let's delete this ticket
598
+			// (which should not be blocked at this point b/c we've removed all our relationships)
599
+			$tkt_to_remove->delete_permanently();
600
+		}
601 601
         
602
-        return $saved_tickets;
603
-    }
602
+		return $saved_tickets;
603
+	}
604 604
     
605 605
     
606
-    /**
607
-     *
608
-     * @access  protected
609
-     *
610
-     * @param \EE_Ticket     $ticket
611
-     * @param \EE_Datetime[] $saved_datetimes
612
-     * @param \EE_Datetime[] $added_datetimes
613
-     * @param \EE_Datetime[] $removed_datetimes
614
-     *
615
-     * @return \EE_Ticket
616
-     * @throws \EE_Error
617
-     */
618
-    protected function _update_ticket_datetimes(
619
-        EE_Ticket $ticket,
620
-        $saved_datetimes = array(),
621
-        $added_datetimes = array(),
622
-        $removed_datetimes = array()
623
-    ) {
624
-        
625
-        // to start we have to add the ticket to all the datetimes its supposed to be with,
626
-        // and removing the ticket from datetimes it got removed from.
627
-        
628
-        // first let's add datetimes
629
-        if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
630
-            foreach ($added_datetimes as $row_id) {
631
-                $row_id = (int)$row_id;
632
-                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
633
-                    $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
634
-                    // Is this an existing ticket (has an ID) and does it have any sold?
635
-                    // If so, then we need to add that to the DTT sold because this DTT is getting added.
636
-                    if ($ticket->ID() && $ticket->sold() > 0) {
637
-                        $saved_datetimes[$row_id]->increase_sold($ticket->sold());
638
-                        $saved_datetimes[$row_id]->save();
639
-                    }
640
-                }
641
-            }
642
-        }
643
-        // then remove datetimes
644
-        if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
645
-            foreach ($removed_datetimes as $row_id) {
646
-                $row_id = (int)$row_id;
647
-                // its entirely possible that a datetime got deleted (instead of just removed from relationship.
648
-                // So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
649
-                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
650
-                    $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
651
-                    // Is this an existing ticket (has an ID) and does it have any sold?
652
-                    // If so, then we need to remove it's sold from the DTT_sold.
653
-                    if ($ticket->ID() && $ticket->sold() > 0) {
654
-                        $saved_datetimes[$row_id]->decrease_sold($ticket->sold());
655
-                        $saved_datetimes[$row_id]->save();
656
-                    }
657
-                }
658
-            }
659
-        }
660
-        // cap ticket qty by datetime reg limits
661
-        $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
662
-        
663
-        return $ticket;
664
-    }
606
+	/**
607
+	 *
608
+	 * @access  protected
609
+	 *
610
+	 * @param \EE_Ticket     $ticket
611
+	 * @param \EE_Datetime[] $saved_datetimes
612
+	 * @param \EE_Datetime[] $added_datetimes
613
+	 * @param \EE_Datetime[] $removed_datetimes
614
+	 *
615
+	 * @return \EE_Ticket
616
+	 * @throws \EE_Error
617
+	 */
618
+	protected function _update_ticket_datetimes(
619
+		EE_Ticket $ticket,
620
+		$saved_datetimes = array(),
621
+		$added_datetimes = array(),
622
+		$removed_datetimes = array()
623
+	) {
624
+        
625
+		// to start we have to add the ticket to all the datetimes its supposed to be with,
626
+		// and removing the ticket from datetimes it got removed from.
627
+        
628
+		// first let's add datetimes
629
+		if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
630
+			foreach ($added_datetimes as $row_id) {
631
+				$row_id = (int)$row_id;
632
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
633
+					$ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
634
+					// Is this an existing ticket (has an ID) and does it have any sold?
635
+					// If so, then we need to add that to the DTT sold because this DTT is getting added.
636
+					if ($ticket->ID() && $ticket->sold() > 0) {
637
+						$saved_datetimes[$row_id]->increase_sold($ticket->sold());
638
+						$saved_datetimes[$row_id]->save();
639
+					}
640
+				}
641
+			}
642
+		}
643
+		// then remove datetimes
644
+		if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
645
+			foreach ($removed_datetimes as $row_id) {
646
+				$row_id = (int)$row_id;
647
+				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
648
+				// So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
649
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
650
+					$ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
651
+					// Is this an existing ticket (has an ID) and does it have any sold?
652
+					// If so, then we need to remove it's sold from the DTT_sold.
653
+					if ($ticket->ID() && $ticket->sold() > 0) {
654
+						$saved_datetimes[$row_id]->decrease_sold($ticket->sold());
655
+						$saved_datetimes[$row_id]->save();
656
+					}
657
+				}
658
+			}
659
+		}
660
+		// cap ticket qty by datetime reg limits
661
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
662
+        
663
+		return $ticket;
664
+	}
665 665
     
666 666
     
667
-    /**
668
-     *
669
-     * @access  protected
670
-     *
671
-     * @param \EE_Ticket $ticket
672
-     * @param array      $price_rows
673
-     * @param int        $ticket_price
674
-     * @param int        $base_price
675
-     * @param int        $base_price_id
676
-     *
677
-     * @return \EE_Ticket
678
-     * @throws \EE_Error
679
-     */
680
-    protected function _duplicate_ticket(
681
-        EE_Ticket $ticket,
682
-        $price_rows = array(),
683
-        $ticket_price = 0,
684
-        $base_price = 0,
685
-        $base_price_id = 0
686
-    ) {
687
-        
688
-        // create new ticket that's a copy of the existing
689
-        // except a new id of course (and not archived)
690
-        // AND has the new TKT_price associated with it.
691
-        $new_ticket = clone $ticket;
692
-        $new_ticket->set('TKT_ID', 0);
693
-        $new_ticket->set('TKT_deleted', 0);
694
-        $new_ticket->set('TKT_price', $ticket_price);
695
-        $new_ticket->set('TKT_sold', 0);
696
-        // let's get a new ID for this ticket
697
-        $new_ticket->save();
698
-        // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
699
-        $datetimes_on_existing = $ticket->get_many_related('Datetime');
700
-        $new_ticket            = $this->_update_ticket_datetimes(
701
-            $new_ticket,
702
-            $datetimes_on_existing,
703
-            array_keys($datetimes_on_existing)
704
-        );
705
-        
706
-        // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
707
-        // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
708
-        // available.
709
-        if ($ticket->sold() > 0) {
710
-            $new_qty = $ticket->qty() - $ticket->sold();
711
-            $new_ticket->set_qty($new_qty);
712
-        }
713
-        //now we update the prices just for this ticket
714
-        $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
715
-        //and we update the base price
716
-        $new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id);
717
-        
718
-        return $new_ticket;
719
-    }
667
+	/**
668
+	 *
669
+	 * @access  protected
670
+	 *
671
+	 * @param \EE_Ticket $ticket
672
+	 * @param array      $price_rows
673
+	 * @param int        $ticket_price
674
+	 * @param int        $base_price
675
+	 * @param int        $base_price_id
676
+	 *
677
+	 * @return \EE_Ticket
678
+	 * @throws \EE_Error
679
+	 */
680
+	protected function _duplicate_ticket(
681
+		EE_Ticket $ticket,
682
+		$price_rows = array(),
683
+		$ticket_price = 0,
684
+		$base_price = 0,
685
+		$base_price_id = 0
686
+	) {
687
+        
688
+		// create new ticket that's a copy of the existing
689
+		// except a new id of course (and not archived)
690
+		// AND has the new TKT_price associated with it.
691
+		$new_ticket = clone $ticket;
692
+		$new_ticket->set('TKT_ID', 0);
693
+		$new_ticket->set('TKT_deleted', 0);
694
+		$new_ticket->set('TKT_price', $ticket_price);
695
+		$new_ticket->set('TKT_sold', 0);
696
+		// let's get a new ID for this ticket
697
+		$new_ticket->save();
698
+		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
699
+		$datetimes_on_existing = $ticket->get_many_related('Datetime');
700
+		$new_ticket            = $this->_update_ticket_datetimes(
701
+			$new_ticket,
702
+			$datetimes_on_existing,
703
+			array_keys($datetimes_on_existing)
704
+		);
705
+        
706
+		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
707
+		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
708
+		// available.
709
+		if ($ticket->sold() > 0) {
710
+			$new_qty = $ticket->qty() - $ticket->sold();
711
+			$new_ticket->set_qty($new_qty);
712
+		}
713
+		//now we update the prices just for this ticket
714
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
715
+		//and we update the base price
716
+		$new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id);
717
+        
718
+		return $new_ticket;
719
+	}
720 720
     
721 721
     
722
-    /**
723
-     * This attaches a list of given prices to a ticket.
724
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
725
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
726
-     * price info and prices are automatically "archived" via the ticket.
727
-     *
728
-     * @access  private
729
-     *
730
-     * @param array     $prices        Array of prices from the form.
731
-     * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
732
-     * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
733
-     * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
734
-     * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
735
-     *
736
-     * @return EE_Ticket
737
-     */
738
-    protected function _add_prices_to_ticket(
739
-        $prices = array(),
740
-        EE_Ticket $ticket,
741
-        $new_prices = false,
742
-        $base_price = false,
743
-        $base_price_id = false
744
-    ) {
745
-        
746
-        //let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session.
747
-        $current_prices_on_ticket = $base_price !== false ? $ticket->base_price(true) : $ticket->price_modifiers();
748
-        
749
-        $updated_prices = array();
750
-        
751
-        // if $base_price ! FALSE then updating a base price.
752
-        if ($base_price !== false) {
753
-            $prices[1] = array(
754
-                'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
755
-                'PRT_ID'     => 1,
756
-                'PRC_amount' => $base_price,
757
-                'PRC_name'   => $ticket->get('TKT_name'),
758
-                'PRC_desc'   => $ticket->get('TKT_description')
759
-            );
760
-        }
761
-        
762
-        //possibly need to save tkt
763
-        if ( ! $ticket->ID()) {
764
-            $ticket->save();
765
-        }
766
-        
767
-        foreach ($prices as $row => $prc) {
768
-            $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
769
-            if (empty($prt_id)) {
770
-                continue;
771
-            } //prices MUST have a price type id.
772
-            $PRC_values = array(
773
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
774
-                'PRT_ID'         => $prt_id,
775
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
776
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
777
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
778
-                'PRC_is_default' => false,
779
-                //make sure we set PRC_is_default to false for all ticket saves from event_editor
780
-                'PRC_order'      => $row
781
-            );
782
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
783
-                $PRC_values['PRC_ID'] = 0;
784
-                $PRC                  = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
785
-            } else {
786
-                $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
787
-                //update this price with new values
788
-                foreach ($PRC_values as $field => $newprc) {
789
-                    $PRC->set($field, $newprc);
790
-                }
791
-            }
792
-            $PRC->save();
793
-            $prcid                  = $PRC->ID();
794
-            $updated_prices[$prcid] = $PRC;
795
-            $ticket->_add_relation_to($PRC, 'Price');
796
-        }
797
-        
798
-        //now let's remove any prices that got removed from the ticket
799
-        if ( ! empty ($current_prices_on_ticket)) {
800
-            $current          = array_keys($current_prices_on_ticket);
801
-            $updated          = array_keys($updated_prices);
802
-            $prices_to_remove = array_diff($current, $updated);
803
-            if ( ! empty($prices_to_remove)) {
804
-                foreach ($prices_to_remove as $prc_id) {
805
-                    $p = $current_prices_on_ticket[$prc_id];
806
-                    $ticket->_remove_relation_to($p, 'Price');
722
+	/**
723
+	 * This attaches a list of given prices to a ticket.
724
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
725
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
726
+	 * price info and prices are automatically "archived" via the ticket.
727
+	 *
728
+	 * @access  private
729
+	 *
730
+	 * @param array     $prices        Array of prices from the form.
731
+	 * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
732
+	 * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
733
+	 * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
734
+	 * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
735
+	 *
736
+	 * @return EE_Ticket
737
+	 */
738
+	protected function _add_prices_to_ticket(
739
+		$prices = array(),
740
+		EE_Ticket $ticket,
741
+		$new_prices = false,
742
+		$base_price = false,
743
+		$base_price_id = false
744
+	) {
745
+        
746
+		//let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session.
747
+		$current_prices_on_ticket = $base_price !== false ? $ticket->base_price(true) : $ticket->price_modifiers();
748
+        
749
+		$updated_prices = array();
750
+        
751
+		// if $base_price ! FALSE then updating a base price.
752
+		if ($base_price !== false) {
753
+			$prices[1] = array(
754
+				'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
755
+				'PRT_ID'     => 1,
756
+				'PRC_amount' => $base_price,
757
+				'PRC_name'   => $ticket->get('TKT_name'),
758
+				'PRC_desc'   => $ticket->get('TKT_description')
759
+			);
760
+		}
761
+        
762
+		//possibly need to save tkt
763
+		if ( ! $ticket->ID()) {
764
+			$ticket->save();
765
+		}
766
+        
767
+		foreach ($prices as $row => $prc) {
768
+			$prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
769
+			if (empty($prt_id)) {
770
+				continue;
771
+			} //prices MUST have a price type id.
772
+			$PRC_values = array(
773
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
774
+				'PRT_ID'         => $prt_id,
775
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
776
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
777
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
778
+				'PRC_is_default' => false,
779
+				//make sure we set PRC_is_default to false for all ticket saves from event_editor
780
+				'PRC_order'      => $row
781
+			);
782
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
783
+				$PRC_values['PRC_ID'] = 0;
784
+				$PRC                  = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
785
+			} else {
786
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
787
+				//update this price with new values
788
+				foreach ($PRC_values as $field => $newprc) {
789
+					$PRC->set($field, $newprc);
790
+				}
791
+			}
792
+			$PRC->save();
793
+			$prcid                  = $PRC->ID();
794
+			$updated_prices[$prcid] = $PRC;
795
+			$ticket->_add_relation_to($PRC, 'Price');
796
+		}
797
+        
798
+		//now let's remove any prices that got removed from the ticket
799
+		if ( ! empty ($current_prices_on_ticket)) {
800
+			$current          = array_keys($current_prices_on_ticket);
801
+			$updated          = array_keys($updated_prices);
802
+			$prices_to_remove = array_diff($current, $updated);
803
+			if ( ! empty($prices_to_remove)) {
804
+				foreach ($prices_to_remove as $prc_id) {
805
+					$p = $current_prices_on_ticket[$prc_id];
806
+					$ticket->_remove_relation_to($p, 'Price');
807 807
                     
808
-                    //delete permanently the price
809
-                    $p->delete_permanently();
810
-                }
811
-            }
812
-        }
813
-        
814
-        return $ticket;
815
-    }
808
+					//delete permanently the price
809
+					$p->delete_permanently();
810
+				}
811
+			}
812
+		}
813
+        
814
+		return $ticket;
815
+	}
816 816
     
817 817
     
818
-    public function autosave_handling($event_admin_obj)
819
-    {
820
-        return $event_admin_obj; //doing nothing for the moment.
821
-        //todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method)
822
-        
823
-        /**
824
-         * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
825
-         *
826
-         * 1. TKT_is_default_selector (visible)
827
-         * 2. TKT_is_default (hidden)
828
-         *
829
-         * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want this ticket to be saved as a default.
830
-         *
831
-         * The tricky part is, on an initial display on create or edit (or after manually updating), the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true if this is a create.  However, after an autosave, users will want some sort of indicator that the TKT HAS been saved as a default.. in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
832
-         * On Autosave:
833
-         * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements, then set the TKT_is_default to false.
834
-         * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
835
-         * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
836
-         */
837
-    }
818
+	public function autosave_handling($event_admin_obj)
819
+	{
820
+		return $event_admin_obj; //doing nothing for the moment.
821
+		//todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method)
822
+        
823
+		/**
824
+		 * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
825
+		 *
826
+		 * 1. TKT_is_default_selector (visible)
827
+		 * 2. TKT_is_default (hidden)
828
+		 *
829
+		 * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want this ticket to be saved as a default.
830
+		 *
831
+		 * The tricky part is, on an initial display on create or edit (or after manually updating), the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true if this is a create.  However, after an autosave, users will want some sort of indicator that the TKT HAS been saved as a default.. in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
832
+		 * On Autosave:
833
+		 * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements, then set the TKT_is_default to false.
834
+		 * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
835
+		 * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
836
+		 */
837
+	}
838 838
     
839 839
     
840
-    public function pricing_metabox()
841
-    {
842
-        $existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
843
-        
844
-        $evtobj = $this->_adminpage_obj->get_cpt_model_obj();
845
-        
846
-        //set is_creating_event property.
847
-        $evtID                    = $evtobj->ID();
848
-        $this->_is_creating_event = absint($evtID) != 0 ? false : true;
849
-        
850
-        //default main template args
851
-        $main_template_args = array(
852
-            'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab',
853
-                $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), false, false),
854
-            //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
855
-            'existing_datetime_ids'    => '',
856
-            'total_dtt_rows'           => 1,
857
-            'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link('add_new_dtt_info',
858
-                $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), false, false),
859
-            //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
860
-            'datetime_rows'            => '',
861
-            'show_tickets_container'   => '',
862
-            //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
863
-            'ticket_rows'              => '',
864
-            'existing_ticket_ids'      => '',
865
-            'total_ticket_rows'        => 1,
866
-            'ticket_js_structure'      => '',
867
-            'ee_collapsible_status'    => ' ee-collapsible-open'
868
-            //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
869
-        );
870
-        
871
-        $timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : null;
872
-        
873
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
874
-        
875
-        /**
876
-         * 1. Start with retrieving Datetimes
877
-         * 2. For each datetime get related tickets
878
-         * 3. For each ticket get related prices
879
-         */
880
-        
881
-        $DTM   = EE_Registry::instance()->load_model('Datetime', array($timezone));
882
-        $times = $DTM->get_all_event_dates($evtID);
883
-        
884
-        
885
-        $main_template_args['total_dtt_rows'] = count($times);
886
-        
887
-        /** @see https://events.codebasehq.com/projects/event-espresso/tickets/9486 for why we are counting $dttrow and then setting that on the Datetime object */
888
-        $dttrow = 1;
889
-        foreach ($times as $time) {
890
-            $dttid = $time->get('DTT_ID');
891
-            $time->set('DTT_order', $dttrow);
892
-            $existing_datetime_ids[] = $dttid;
840
+	public function pricing_metabox()
841
+	{
842
+		$existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
843
+        
844
+		$evtobj = $this->_adminpage_obj->get_cpt_model_obj();
845
+        
846
+		//set is_creating_event property.
847
+		$evtID                    = $evtobj->ID();
848
+		$this->_is_creating_event = absint($evtID) != 0 ? false : true;
849
+        
850
+		//default main template args
851
+		$main_template_args = array(
852
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab',
853
+				$this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), false, false),
854
+			//todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
855
+			'existing_datetime_ids'    => '',
856
+			'total_dtt_rows'           => 1,
857
+			'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link('add_new_dtt_info',
858
+				$this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), false, false),
859
+			//todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
860
+			'datetime_rows'            => '',
861
+			'show_tickets_container'   => '',
862
+			//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
863
+			'ticket_rows'              => '',
864
+			'existing_ticket_ids'      => '',
865
+			'total_ticket_rows'        => 1,
866
+			'ticket_js_structure'      => '',
867
+			'ee_collapsible_status'    => ' ee-collapsible-open'
868
+			//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
869
+		);
870
+        
871
+		$timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : null;
872
+        
873
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
874
+        
875
+		/**
876
+		 * 1. Start with retrieving Datetimes
877
+		 * 2. For each datetime get related tickets
878
+		 * 3. For each ticket get related prices
879
+		 */
880
+        
881
+		$DTM   = EE_Registry::instance()->load_model('Datetime', array($timezone));
882
+		$times = $DTM->get_all_event_dates($evtID);
883
+        
884
+        
885
+		$main_template_args['total_dtt_rows'] = count($times);
886
+        
887
+		/** @see https://events.codebasehq.com/projects/event-espresso/tickets/9486 for why we are counting $dttrow and then setting that on the Datetime object */
888
+		$dttrow = 1;
889
+		foreach ($times as $time) {
890
+			$dttid = $time->get('DTT_ID');
891
+			$time->set('DTT_order', $dttrow);
892
+			$existing_datetime_ids[] = $dttid;
893 893
             
894
-            //tickets attached
895
-            $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(
896
-                array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
897
-                'default_where_conditions' => 'none',
898
-                'order_by'                 => array('TKT_order' => 'ASC')
899
-            )) : array();
894
+			//tickets attached
895
+			$related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(
896
+				array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
897
+				'default_where_conditions' => 'none',
898
+				'order_by'                 => array('TKT_order' => 'ASC')
899
+			)) : array();
900 900
             
901
-            //if there are no related tickets this is likely a new event OR autodraft
902
-            // event so we need to generate the default tickets because dtts
903
-            // ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
904
-            // datetime on the event.
905
-            if (empty ($related_tickets) && count($times) < 2) {
906
-                $related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
901
+			//if there are no related tickets this is likely a new event OR autodraft
902
+			// event so we need to generate the default tickets because dtts
903
+			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
904
+			// datetime on the event.
905
+			if (empty ($related_tickets) && count($times) < 2) {
906
+				$related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
907 907
                 
908
-                //this should be ordered by TKT_ID, so let's grab the first default ticket (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
909
-                $default_prices = EEM_Price::instance()->get_all_default_prices();
908
+				//this should be ordered by TKT_ID, so let's grab the first default ticket (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
909
+				$default_prices = EEM_Price::instance()->get_all_default_prices();
910 910
                 
911
-                $main_default_ticket = reset($related_tickets);
912
-                if ($main_default_ticket instanceof EE_Ticket) {
913
-                    foreach ($default_prices as $default_price) {
914
-                        if ($default_price->is_base_price()) {
915
-                            continue;
916
-                        }
917
-                        $main_default_ticket->cache('Price', $default_price);
918
-                    }
919
-                }
920
-            }
911
+				$main_default_ticket = reset($related_tickets);
912
+				if ($main_default_ticket instanceof EE_Ticket) {
913
+					foreach ($default_prices as $default_price) {
914
+						if ($default_price->is_base_price()) {
915
+							continue;
916
+						}
917
+						$main_default_ticket->cache('Price', $default_price);
918
+					}
919
+				}
920
+			}
921 921
             
922 922
             
923
-            //we can't actually setup rows in this loop yet cause we don't know all the unique tickets for this event yet (tickets are linked through all datetimes). So we're going to temporarily cache some of that information.
923
+			//we can't actually setup rows in this loop yet cause we don't know all the unique tickets for this event yet (tickets are linked through all datetimes). So we're going to temporarily cache some of that information.
924 924
             
925
-            //loop through and setup the ticket rows and make sure the order is set.
926
-            foreach ($related_tickets as $ticket) {
927
-                $tktid  = $ticket->get('TKT_ID');
928
-                $tktrow = $ticket->get('TKT_row');
929
-                //we only want unique tickets in our final display!!
930
-                if ( ! in_array($tktid, $existing_ticket_ids)) {
931
-                    $existing_ticket_ids[] = $tktid;
932
-                    $all_tickets[]         = $ticket;
933
-                }
925
+			//loop through and setup the ticket rows and make sure the order is set.
926
+			foreach ($related_tickets as $ticket) {
927
+				$tktid  = $ticket->get('TKT_ID');
928
+				$tktrow = $ticket->get('TKT_row');
929
+				//we only want unique tickets in our final display!!
930
+				if ( ! in_array($tktid, $existing_ticket_ids)) {
931
+					$existing_ticket_ids[] = $tktid;
932
+					$all_tickets[]         = $ticket;
933
+				}
934 934
                 
935
-                //temporary cache of this ticket info for this datetime for later processing of datetime rows.
936
-                $datetime_tickets[$dttid][] = $tktrow;
935
+				//temporary cache of this ticket info for this datetime for later processing of datetime rows.
936
+				$datetime_tickets[$dttid][] = $tktrow;
937 937
                 
938
-                //temporary cache of this datetime info for this ticket for later processing of ticket rows.
939
-                if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid])) {
940
-                    $ticket_datetimes[$tktid][] = $dttrow;
941
-                }
942
-            }
943
-            $dttrow++;
944
-        }
945
-        
946
-        $main_template_args['total_ticket_rows']     = count($existing_ticket_ids);
947
-        $main_template_args['existing_ticket_ids']   = implode(',', $existing_ticket_ids);
948
-        $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
949
-        
950
-        //sort $all_tickets by order
951
-        usort($all_tickets, function ($a, $b) {
952
-            $a_order = (int)$a->get('TKT_order');
953
-            $b_order = (int)$b->get('TKT_order');
954
-            if ($a_order == $b_order) {
955
-                return 0;
956
-            }
938
+				//temporary cache of this datetime info for this ticket for later processing of ticket rows.
939
+				if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid])) {
940
+					$ticket_datetimes[$tktid][] = $dttrow;
941
+				}
942
+			}
943
+			$dttrow++;
944
+		}
945
+        
946
+		$main_template_args['total_ticket_rows']     = count($existing_ticket_ids);
947
+		$main_template_args['existing_ticket_ids']   = implode(',', $existing_ticket_ids);
948
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
949
+        
950
+		//sort $all_tickets by order
951
+		usort($all_tickets, function ($a, $b) {
952
+			$a_order = (int)$a->get('TKT_order');
953
+			$b_order = (int)$b->get('TKT_order');
954
+			if ($a_order == $b_order) {
955
+				return 0;
956
+			}
957 957
             
958
-            return ($a_order < $b_order) ? -1 : 1;
959
-        });
960
-        
961
-        //k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again.
962
-        $dttrow = 1;
963
-        foreach ($times as $time) {
964
-            $main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets,
965
-                $all_tickets, false, $times);
966
-            $dttrow++;
967
-        }
968
-        
969
-        //then loop through all tickets for the ticket rows.
970
-        $tktrow = 1;
971
-        foreach ($all_tickets as $ticket) {
972
-            $main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times,
973
-                false, $all_tickets);
974
-            $tktrow++;
975
-        }
976
-        
977
-        $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets);
978
-        $template                                  = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php';
979
-        EEH_Template::display_template($template, $main_template_args);
980
-        
981
-        return;
982
-    }
958
+			return ($a_order < $b_order) ? -1 : 1;
959
+		});
960
+        
961
+		//k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again.
962
+		$dttrow = 1;
963
+		foreach ($times as $time) {
964
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets,
965
+				$all_tickets, false, $times);
966
+			$dttrow++;
967
+		}
968
+        
969
+		//then loop through all tickets for the ticket rows.
970
+		$tktrow = 1;
971
+		foreach ($all_tickets as $ticket) {
972
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times,
973
+				false, $all_tickets);
974
+			$tktrow++;
975
+		}
976
+        
977
+		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets);
978
+		$template                                  = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php';
979
+		EEH_Template::display_template($template, $main_template_args);
980
+        
981
+		return;
982
+	}
983 983
     
984 984
     
985
-    protected function _get_datetime_row(
986
-        $dttrow,
987
-        EE_Datetime $dtt,
988
-        $datetime_tickets,
989
-        $all_tickets,
990
-        $default = false,
991
-        $all_dtts = array()
992
-    ) {
993
-        
994
-        $dtt_display_template_args = array(
995
-            'dtt_edit_row'             => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts),
996
-            'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets,
997
-                $all_tickets, $default),
998
-            'dtt_row'                  => $default ? 'DTTNUM' : $dttrow
999
-        );
1000
-        $template                  = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php';
1001
-        
1002
-        return EEH_Template::display_template($template, $dtt_display_template_args, true);
1003
-    }
985
+	protected function _get_datetime_row(
986
+		$dttrow,
987
+		EE_Datetime $dtt,
988
+		$datetime_tickets,
989
+		$all_tickets,
990
+		$default = false,
991
+		$all_dtts = array()
992
+	) {
993
+        
994
+		$dtt_display_template_args = array(
995
+			'dtt_edit_row'             => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts),
996
+			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets,
997
+				$all_tickets, $default),
998
+			'dtt_row'                  => $default ? 'DTTNUM' : $dttrow
999
+		);
1000
+		$template                  = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php';
1001
+        
1002
+		return EEH_Template::display_template($template, $dtt_display_template_args, true);
1003
+	}
1004 1004
     
1005 1005
     
1006
-    /**
1007
-     * This method is used to generate a dtt fields  edit row.
1008
-     * The same row is used to generate a row with valid DTT objects and the default row that is used as the
1009
-     * skeleton by the js.
1010
-     *
1011
-     * @param int           $dttrow                         The row number for the row being generated.
1012
-     * @param               mixed                           EE_Datetime|null $dtt      If not default row being
1013
-     *                                                                       generated, this must be a EE_Datetime
1014
-     *                                                                       object.
1015
-     * @param bool          $default                        Whether a default row is being generated or not.
1016
-     * @param EE_Datetime[] $all_dtts                       This is the array of all datetimes used in the editor.
1017
-     *
1018
-     * @return string Generated edit row.
1019
-     */
1020
-    protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts)
1021
-    {
1022
-        
1023
-        // if the incoming $dtt object is NOT an instance of EE_Datetime then force default to true.
1024
-        $default = ! $dtt instanceof EE_Datetime ? true : false;
1025
-        
1026
-        $template_args = array(
1027
-            'dtt_row'              => $default ? 'DTTNUM' : $dttrow,
1028
-            'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1029
-            'edit_dtt_expanded'    => '',
1030
-            //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
1031
-            'DTT_ID'               => $default ? '' : $dtt->ID(),
1032
-            'DTT_name'             => $default ? '' : $dtt->name(),
1033
-            'DTT_description'      => $default ? '' : $dtt->description(),
1034
-            'DTT_EVT_start'        => $default ? '' : $dtt->start_date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1035
-            'DTT_EVT_end'          => $default ? '' : $dtt->end_date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1036
-            'DTT_reg_limit'        => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'),
1037
-            'DTT_order'            => $default ? 'DTTNUM' : $dttrow,
1038
-            'dtt_sold'             => $default ? '0' : $dtt->get('DTT_sold'),
1039
-            'clone_icon'           => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
1040
-            'trash_icon'           => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable',
1041
-            'reg_list_url'         => $default || ! $dtt->event() instanceof \EE_Event
1042
-                ? ''
1043
-                : EE_Admin_Page::add_query_args_and_nonce(
1044
-                    array('event_id' => $dtt->event()->ID(), 'datetime_id' => $dtt->ID()),
1045
-                    REG_ADMIN_URL
1046
-                )
1047
-        );
1048
-        
1049
-        $template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
1050
-        
1051
-        //allow filtering of template args at this point.
1052
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1053
-            $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event);
1054
-        
1055
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php';
1056
-        
1057
-        return EEH_Template::display_template($template, $template_args, true);
1058
-    }
1006
+	/**
1007
+	 * This method is used to generate a dtt fields  edit row.
1008
+	 * The same row is used to generate a row with valid DTT objects and the default row that is used as the
1009
+	 * skeleton by the js.
1010
+	 *
1011
+	 * @param int           $dttrow                         The row number for the row being generated.
1012
+	 * @param               mixed                           EE_Datetime|null $dtt      If not default row being
1013
+	 *                                                                       generated, this must be a EE_Datetime
1014
+	 *                                                                       object.
1015
+	 * @param bool          $default                        Whether a default row is being generated or not.
1016
+	 * @param EE_Datetime[] $all_dtts                       This is the array of all datetimes used in the editor.
1017
+	 *
1018
+	 * @return string Generated edit row.
1019
+	 */
1020
+	protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts)
1021
+	{
1022
+        
1023
+		// if the incoming $dtt object is NOT an instance of EE_Datetime then force default to true.
1024
+		$default = ! $dtt instanceof EE_Datetime ? true : false;
1025
+        
1026
+		$template_args = array(
1027
+			'dtt_row'              => $default ? 'DTTNUM' : $dttrow,
1028
+			'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1029
+			'edit_dtt_expanded'    => '',
1030
+			//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
1031
+			'DTT_ID'               => $default ? '' : $dtt->ID(),
1032
+			'DTT_name'             => $default ? '' : $dtt->name(),
1033
+			'DTT_description'      => $default ? '' : $dtt->description(),
1034
+			'DTT_EVT_start'        => $default ? '' : $dtt->start_date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1035
+			'DTT_EVT_end'          => $default ? '' : $dtt->end_date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1036
+			'DTT_reg_limit'        => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'),
1037
+			'DTT_order'            => $default ? 'DTTNUM' : $dttrow,
1038
+			'dtt_sold'             => $default ? '0' : $dtt->get('DTT_sold'),
1039
+			'clone_icon'           => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
1040
+			'trash_icon'           => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable',
1041
+			'reg_list_url'         => $default || ! $dtt->event() instanceof \EE_Event
1042
+				? ''
1043
+				: EE_Admin_Page::add_query_args_and_nonce(
1044
+					array('event_id' => $dtt->event()->ID(), 'datetime_id' => $dtt->ID()),
1045
+					REG_ADMIN_URL
1046
+				)
1047
+		);
1048
+        
1049
+		$template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
1050
+        
1051
+		//allow filtering of template args at this point.
1052
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1053
+			$template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event);
1054
+        
1055
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php';
1056
+        
1057
+		return EEH_Template::display_template($template, $template_args, true);
1058
+	}
1059 1059
     
1060 1060
     
1061
-    protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default)
1062
-    {
1063
-        
1064
-        $template_args = array(
1065
-            'dtt_row'                           => $default ? 'DTTNUM' : $dttrow,
1066
-            'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1067
-            'DTT_description'                   => $default ? '' : $dtt->description(),
1068
-            'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1069
-            'show_tickets_row'                  => ' style="display:none;"',
1070
-            //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '',
1071
-            'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime',
1072
-                $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), false, false),
1073
-            //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1074
-            'DTT_ID'                            => $default ? '' : $dtt->ID()
1075
-        );
1076
-        
1077
-        //need to setup the list items (but only if this isnt' a default skeleton setup)
1078
-        if ( ! $default) {
1079
-            $tktrow = 1;
1080
-            foreach ($all_tickets as $ticket) {
1081
-                $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow,
1082
-                    $dtt, $ticket, $datetime_tickets, $default);
1083
-                $tktrow++;
1084
-            }
1085
-        }
1086
-        
1087
-        //filter template args at this point
1088
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1089
-            $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event);
1090
-        
1091
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php';
1092
-        
1093
-        return EEH_Template::display_template($template, $template_args, true);
1094
-    }
1061
+	protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default)
1062
+	{
1063
+        
1064
+		$template_args = array(
1065
+			'dtt_row'                           => $default ? 'DTTNUM' : $dttrow,
1066
+			'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1067
+			'DTT_description'                   => $default ? '' : $dtt->description(),
1068
+			'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1069
+			'show_tickets_row'                  => ' style="display:none;"',
1070
+			//$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '',
1071
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime',
1072
+				$this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), false, false),
1073
+			//todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1074
+			'DTT_ID'                            => $default ? '' : $dtt->ID()
1075
+		);
1076
+        
1077
+		//need to setup the list items (but only if this isnt' a default skeleton setup)
1078
+		if ( ! $default) {
1079
+			$tktrow = 1;
1080
+			foreach ($all_tickets as $ticket) {
1081
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow,
1082
+					$dtt, $ticket, $datetime_tickets, $default);
1083
+				$tktrow++;
1084
+			}
1085
+		}
1086
+        
1087
+		//filter template args at this point
1088
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1089
+			$template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event);
1090
+        
1091
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php';
1092
+        
1093
+		return EEH_Template::display_template($template, $template_args, true);
1094
+	}
1095 1095
     
1096 1096
     
1097
-    protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default)
1098
-    {
1099
-        $tktid    = ! empty($ticket) ? $ticket->ID() : 0;
1100
-        $dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array();
1101
-        
1102
-        $displayrow    = ! empty($ticket) ? $ticket->get('TKT_row') : 0;
1103
-        $template_args = array(
1104
-            'dtt_row'                 => $default ? 'DTTNUM' : $dttrow,
1105
-            'tkt_row'                 => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1106
-            'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '',
1107
-            'ticket_selected'         => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '',
1108
-            'TKT_name'                => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'),
1109
-            'tkt_status_class'        => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(),
1110
-        );
1111
-        
1112
-        //filter template args
1113
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1114
-            $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event);
1115
-        
1116
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php';
1117
-        
1118
-        return EEH_Template::display_template($template, $template_args, true);
1119
-    }
1097
+	protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default)
1098
+	{
1099
+		$tktid    = ! empty($ticket) ? $ticket->ID() : 0;
1100
+		$dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array();
1101
+        
1102
+		$displayrow    = ! empty($ticket) ? $ticket->get('TKT_row') : 0;
1103
+		$template_args = array(
1104
+			'dtt_row'                 => $default ? 'DTTNUM' : $dttrow,
1105
+			'tkt_row'                 => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1106
+			'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '',
1107
+			'ticket_selected'         => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '',
1108
+			'TKT_name'                => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'),
1109
+			'tkt_status_class'        => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(),
1110
+		);
1111
+        
1112
+		//filter template args
1113
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1114
+			$template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event);
1115
+        
1116
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php';
1117
+        
1118
+		return EEH_Template::display_template($template, $template_args, true);
1119
+	}
1120 1120
     
1121 1121
     
1122
-    /**
1123
-     * This generates the ticket row for tickets.
1124
-     * This same method is used to generate both the actual rows and the js skeleton row (when default ==
1125
-     * true)
1126
-     *
1127
-     * @param int           $tktrow                          Represents the row number being generated.
1128
-     * @param               mixed                            null|EE_Ticket $ticket           If default then this will
1129
-     *                                                                      be null.
1130
-     * @param EE_Datetime[] $ticket_datetimes                Either an array of all datetimes on all tickets indexed by
1131
-     *                                                       each ticket or empty for  default
1132
-     * @param EE_Datetime[] $all_dtts                        All Datetimes on the event or empty for default.
1133
-     * @param bool          $default                         Whether default row being generated or not.
1134
-     * @param EE_Ticket[]   $all_tickets                     This is an array of all tickets attached to the event (or
1135
-     *                                                       empty in the case of defaults)
1136
-     *
1137
-     * @return [type] [description]
1138
-     */
1139
-    protected function _get_ticket_row(
1140
-        $tktrow,
1141
-        $ticket,
1142
-        $ticket_datetimes,
1143
-        $all_dtts,
1144
-        $default = false,
1145
-        $all_tickets = array()
1146
-    ) {
1147
-        
1148
-        //if $ticket is not an instance of EE_Ticket then force default to true.
1149
-        $default = ! $ticket instanceof EE_Ticket ? true : false;
1150
-        
1151
-        $prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price',
1152
-            array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array();
1153
-        
1154
-        //if there is only one price (which would be the base price) or NO prices and this ticket is a default ticket, let's just make sure there are no cached default prices on
1155
-        //the object.  This is done by not including any query_params.
1156
-        if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1157
-            $prices = $ticket->get_many_related('Price');
1158
-        }
1159
-        
1160
-        // check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket).  This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1161
-        $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? true : false;
1162
-        
1163
-        $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1164
-        
1165
-        $ticket_subtotal  = $default ? 0 : $ticket->get_ticket_subtotal();
1166
-        $base_price       = $default ? null : $ticket->base_price();
1167
-        $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1168
-        
1169
-        //breaking out complicated condition for ticket_status
1170
-        if ($default) {
1171
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1172
-        } else {
1173
-            $ticket_status_class = $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status();
1174
-        }
1175
-        
1176
-        //breaking out complicated condition for TKT_taxable
1177
-        if ($default) {
1178
-            $TKT_taxable = '';
1179
-        } else {
1180
-            $TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : '';
1181
-        }
1122
+	/**
1123
+	 * This generates the ticket row for tickets.
1124
+	 * This same method is used to generate both the actual rows and the js skeleton row (when default ==
1125
+	 * true)
1126
+	 *
1127
+	 * @param int           $tktrow                          Represents the row number being generated.
1128
+	 * @param               mixed                            null|EE_Ticket $ticket           If default then this will
1129
+	 *                                                                      be null.
1130
+	 * @param EE_Datetime[] $ticket_datetimes                Either an array of all datetimes on all tickets indexed by
1131
+	 *                                                       each ticket or empty for  default
1132
+	 * @param EE_Datetime[] $all_dtts                        All Datetimes on the event or empty for default.
1133
+	 * @param bool          $default                         Whether default row being generated or not.
1134
+	 * @param EE_Ticket[]   $all_tickets                     This is an array of all tickets attached to the event (or
1135
+	 *                                                       empty in the case of defaults)
1136
+	 *
1137
+	 * @return [type] [description]
1138
+	 */
1139
+	protected function _get_ticket_row(
1140
+		$tktrow,
1141
+		$ticket,
1142
+		$ticket_datetimes,
1143
+		$all_dtts,
1144
+		$default = false,
1145
+		$all_tickets = array()
1146
+	) {
1147
+        
1148
+		//if $ticket is not an instance of EE_Ticket then force default to true.
1149
+		$default = ! $ticket instanceof EE_Ticket ? true : false;
1150
+        
1151
+		$prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price',
1152
+			array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array();
1153
+        
1154
+		//if there is only one price (which would be the base price) or NO prices and this ticket is a default ticket, let's just make sure there are no cached default prices on
1155
+		//the object.  This is done by not including any query_params.
1156
+		if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1157
+			$prices = $ticket->get_many_related('Price');
1158
+		}
1159
+        
1160
+		// check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket).  This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1161
+		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? true : false;
1162
+        
1163
+		$tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1164
+        
1165
+		$ticket_subtotal  = $default ? 0 : $ticket->get_ticket_subtotal();
1166
+		$base_price       = $default ? null : $ticket->base_price();
1167
+		$count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1168
+        
1169
+		//breaking out complicated condition for ticket_status
1170
+		if ($default) {
1171
+			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1172
+		} else {
1173
+			$ticket_status_class = $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status();
1174
+		}
1175
+        
1176
+		//breaking out complicated condition for TKT_taxable
1177
+		if ($default) {
1178
+			$TKT_taxable = '';
1179
+		} else {
1180
+			$TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : '';
1181
+		}
1182 1182
 
1183 1183
         
1184
-        $template_args = array(
1185
-            'tkt_row'                       => $default ? 'TICKETNUM' : $tktrow,
1186
-            'TKT_order'                     => $default ? 'TICKETNUM' : $tktrow,
1187
-            //on initial page load this will always be the correct order.
1188
-            'tkt_status_class'              => $ticket_status_class,
1189
-            'display_edit_tkt_row'          => ' style="display:none;"',
1190
-            'edit_tkt_expanded'             => '',
1191
-            'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1192
-            'TKT_name'                      => $default ? '' : $ticket->get('TKT_name'),
1193
-            'TKT_start_date'                => $default ? '' : $ticket->get_date('TKT_start_date',
1194
-                $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1195
-            'TKT_end_date'                  => $default ? '' : $ticket->get_date('TKT_end_date',
1196
-                $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1197
-            'TKT_status'                    => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, false,
1198
-                'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, false,
1199
-                'sentence') : $ticket->ticket_status(true),
1200
-            'TKT_price'                     => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(),
1201
-                false, false),
1202
-            'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1203
-            'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1204
-            'TKT_qty'                       => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'),
1205
-            'TKT_qty_for_input'             => $default ? '' : $ticket->get_pretty('TKT_qty', 'input'),
1206
-            'TKT_uses'                      => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'),
1207
-            'TKT_min'                       => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')),
1208
-            'TKT_max'                       => $default ? '' : $ticket->get_pretty('TKT_max', 'input'),
1209
-            'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1210
-            'TKT_registrations'             => $default ? 0 : $ticket->count_registrations(array(
1211
-                array(
1212
-                    'STS_ID' => array(
1213
-                        '!=',
1214
-                        EEM_Registration::status_id_incomplete
1215
-                    )
1216
-                )
1217
-            )),
1218
-            'TKT_ID'                        => $default ? 0 : $ticket->get('TKT_ID'),
1219
-            'TKT_description'               => $default ? '' : $ticket->get('TKT_description'),
1220
-            'TKT_is_default'                => $default ? 0 : $ticket->get('TKT_is_default'),
1221
-            'TKT_required'                  => $default ? 0 : $ticket->required(),
1222
-            'TKT_is_default_selector'       => '',
1223
-            'ticket_price_rows'             => '',
1224
-            'TKT_base_price'                => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount',
1225
-                'localized_float'),
1226
-            'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1227
-            'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"',
1228
-            'show_price_mod_button'         => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '',
1229
-            'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1230
-            'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1231
-            'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts),
1232
-            'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_dtts),
1233
-            'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1234
-            'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1235
-            'TKT_taxable'                   => $TKT_taxable,
1236
-            'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"',
1237
-            'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1238
-            'TKT_subtotal_amount_display'   => EEH_Template::format_currency($ticket_subtotal, false, false),
1239
-            'TKT_subtotal_amount'           => $ticket_subtotal,
1240
-            'tax_rows'                      => $this->_get_tax_rows($tktrow, $ticket),
1241
-            'disabled'                      => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? true : false,
1242
-            'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '',
1243
-            'trash_icon'                    => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable',
1244
-            'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable'
1245
-        );
1246
-        
1247
-        $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1248
-        
1249
-        //handle rows that should NOT be empty
1250
-        if (empty($template_args['TKT_start_date'])) {
1251
-            //if empty then the start date will be now.
1252
-            $template_args['TKT_start_date']   = date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'],
1253
-                current_time('timestamp'));
1254
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1255
-        }
1256
-        
1257
-        if (empty($template_args['TKT_end_date'])) {
1184
+		$template_args = array(
1185
+			'tkt_row'                       => $default ? 'TICKETNUM' : $tktrow,
1186
+			'TKT_order'                     => $default ? 'TICKETNUM' : $tktrow,
1187
+			//on initial page load this will always be the correct order.
1188
+			'tkt_status_class'              => $ticket_status_class,
1189
+			'display_edit_tkt_row'          => ' style="display:none;"',
1190
+			'edit_tkt_expanded'             => '',
1191
+			'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1192
+			'TKT_name'                      => $default ? '' : $ticket->get('TKT_name'),
1193
+			'TKT_start_date'                => $default ? '' : $ticket->get_date('TKT_start_date',
1194
+				$this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1195
+			'TKT_end_date'                  => $default ? '' : $ticket->get_date('TKT_end_date',
1196
+				$this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1197
+			'TKT_status'                    => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, false,
1198
+				'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, false,
1199
+				'sentence') : $ticket->ticket_status(true),
1200
+			'TKT_price'                     => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(),
1201
+				false, false),
1202
+			'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1203
+			'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1204
+			'TKT_qty'                       => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'),
1205
+			'TKT_qty_for_input'             => $default ? '' : $ticket->get_pretty('TKT_qty', 'input'),
1206
+			'TKT_uses'                      => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'),
1207
+			'TKT_min'                       => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')),
1208
+			'TKT_max'                       => $default ? '' : $ticket->get_pretty('TKT_max', 'input'),
1209
+			'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1210
+			'TKT_registrations'             => $default ? 0 : $ticket->count_registrations(array(
1211
+				array(
1212
+					'STS_ID' => array(
1213
+						'!=',
1214
+						EEM_Registration::status_id_incomplete
1215
+					)
1216
+				)
1217
+			)),
1218
+			'TKT_ID'                        => $default ? 0 : $ticket->get('TKT_ID'),
1219
+			'TKT_description'               => $default ? '' : $ticket->get('TKT_description'),
1220
+			'TKT_is_default'                => $default ? 0 : $ticket->get('TKT_is_default'),
1221
+			'TKT_required'                  => $default ? 0 : $ticket->required(),
1222
+			'TKT_is_default_selector'       => '',
1223
+			'ticket_price_rows'             => '',
1224
+			'TKT_base_price'                => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount',
1225
+				'localized_float'),
1226
+			'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1227
+			'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"',
1228
+			'show_price_mod_button'         => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '',
1229
+			'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1230
+			'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1231
+			'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts),
1232
+			'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_dtts),
1233
+			'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1234
+			'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1235
+			'TKT_taxable'                   => $TKT_taxable,
1236
+			'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"',
1237
+			'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1238
+			'TKT_subtotal_amount_display'   => EEH_Template::format_currency($ticket_subtotal, false, false),
1239
+			'TKT_subtotal_amount'           => $ticket_subtotal,
1240
+			'tax_rows'                      => $this->_get_tax_rows($tktrow, $ticket),
1241
+			'disabled'                      => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? true : false,
1242
+			'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '',
1243
+			'trash_icon'                    => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable',
1244
+			'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable'
1245
+		);
1246
+        
1247
+		$template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1248
+        
1249
+		//handle rows that should NOT be empty
1250
+		if (empty($template_args['TKT_start_date'])) {
1251
+			//if empty then the start date will be now.
1252
+			$template_args['TKT_start_date']   = date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'],
1253
+				current_time('timestamp'));
1254
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1255
+		}
1256
+        
1257
+		if (empty($template_args['TKT_end_date'])) {
1258 1258
             
1259
-            //get the earliest datetime (if present);
1260
-            $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime',
1261
-                array('order_by' => array('DTT_EVT_start' => 'ASC'))) : null;
1259
+			//get the earliest datetime (if present);
1260
+			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime',
1261
+				array('order_by' => array('DTT_EVT_start' => 'ASC'))) : null;
1262 1262
             
1263
-            if ( ! empty($earliest_dtt)) {
1264
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start',
1265
-                    $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']);
1266
-            } else {
1267
-                //default so let's just use what's been set for the default date-time which is 30 days from now.
1268
-                $template_args['TKT_end_date'] = date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'],
1269
-                    mktime(24, 0, 0, date("m"), date("d") + 29, date("Y")));
1270
-            }
1271
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1272
-        }
1273
-        
1274
-        //generate ticket_datetime items
1275
-        if ( ! $default) {
1276
-            $dttrow = 1;
1277
-            foreach ($all_dtts as $dtt) {
1278
-                $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt,
1279
-                    $ticket, $ticket_datetimes, $default);
1280
-                $dttrow++;
1281
-            }
1282
-        }
1283
-        
1284
-        $prcrow = 1;
1285
-        foreach ($prices as $price) {
1286
-            if ($price->is_base_price()) {
1287
-                $prcrow++;
1288
-                continue;
1289
-            }
1290
-            $show_trash  = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? false : true;
1291
-            $show_create = count($prices) > 1 && count($prices) !== $prcrow ? false : true;
1292
-            $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default,
1293
-                $ticket, $show_trash, $show_create);
1294
-            $prcrow++;
1295
-        }
1296
-        
1297
-        //filter $template_args
1298
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1299
-            $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets,
1300
-            $this->_is_creating_event);
1301
-        
1302
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php';
1303
-        
1304
-        return EEH_Template::display_template($template, $template_args, true);
1305
-    }
1263
+			if ( ! empty($earliest_dtt)) {
1264
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start',
1265
+					$this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']);
1266
+			} else {
1267
+				//default so let's just use what's been set for the default date-time which is 30 days from now.
1268
+				$template_args['TKT_end_date'] = date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'],
1269
+					mktime(24, 0, 0, date("m"), date("d") + 29, date("Y")));
1270
+			}
1271
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1272
+		}
1273
+        
1274
+		//generate ticket_datetime items
1275
+		if ( ! $default) {
1276
+			$dttrow = 1;
1277
+			foreach ($all_dtts as $dtt) {
1278
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt,
1279
+					$ticket, $ticket_datetimes, $default);
1280
+				$dttrow++;
1281
+			}
1282
+		}
1283
+        
1284
+		$prcrow = 1;
1285
+		foreach ($prices as $price) {
1286
+			if ($price->is_base_price()) {
1287
+				$prcrow++;
1288
+				continue;
1289
+			}
1290
+			$show_trash  = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? false : true;
1291
+			$show_create = count($prices) > 1 && count($prices) !== $prcrow ? false : true;
1292
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default,
1293
+				$ticket, $show_trash, $show_create);
1294
+			$prcrow++;
1295
+		}
1296
+        
1297
+		//filter $template_args
1298
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1299
+			$template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets,
1300
+			$this->_is_creating_event);
1301
+        
1302
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php';
1303
+        
1304
+		return EEH_Template::display_template($template, $template_args, true);
1305
+	}
1306 1306
     
1307 1307
     
1308
-    protected function _get_tax_rows($tktrow, $ticket)
1309
-    {
1310
-        $tax_rows      = '';
1311
-        $template      = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php';
1312
-        $template_args = array();
1313
-        $taxes         = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1314
-        foreach ($taxes as $tax) {
1315
-            $tax_added     = $this->_get_tax_added($tax, $ticket);
1316
-            $template_args = array(
1317
-                'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1318
-                'tax_id'            => $tax->ID(),
1319
-                'tkt_row'           => $tktrow,
1320
-                'tax_label'         => $tax->get('PRC_name'),
1321
-                'tax_added'         => $tax_added,
1322
-                'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1323
-                'tax_amount'        => $tax->get('PRC_amount')
1324
-            );
1325
-            $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1326
-                $template_args, $tktrow, $ticket, $this->_is_creating_event);
1327
-            $tax_rows .= EEH_Template::display_template($template, $template_args, true);
1328
-        }
1329
-        
1330
-        
1331
-        return $tax_rows;
1332
-    }
1308
+	protected function _get_tax_rows($tktrow, $ticket)
1309
+	{
1310
+		$tax_rows      = '';
1311
+		$template      = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php';
1312
+		$template_args = array();
1313
+		$taxes         = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1314
+		foreach ($taxes as $tax) {
1315
+			$tax_added     = $this->_get_tax_added($tax, $ticket);
1316
+			$template_args = array(
1317
+				'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1318
+				'tax_id'            => $tax->ID(),
1319
+				'tkt_row'           => $tktrow,
1320
+				'tax_label'         => $tax->get('PRC_name'),
1321
+				'tax_added'         => $tax_added,
1322
+				'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1323
+				'tax_amount'        => $tax->get('PRC_amount')
1324
+			);
1325
+			$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1326
+				$template_args, $tktrow, $ticket, $this->_is_creating_event);
1327
+			$tax_rows .= EEH_Template::display_template($template, $template_args, true);
1328
+		}
1329
+        
1330
+        
1331
+		return $tax_rows;
1332
+	}
1333 1333
     
1334 1334
     
1335
-    protected function _get_tax_added(EE_Price $tax, $ticket)
1336
-    {
1337
-        $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1335
+	protected function _get_tax_added(EE_Price $tax, $ticket)
1336
+	{
1337
+		$subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1338 1338
         
1339
-        return $subtotal * $tax->get('PRC_amount') / 100;
1340
-    }
1339
+		return $subtotal * $tax->get('PRC_amount') / 100;
1340
+	}
1341 1341
     
1342 1342
     
1343
-    protected function _get_ticket_price_row(
1344
-        $tktrow,
1345
-        $prcrow,
1346
-        $price,
1347
-        $default,
1348
-        $ticket,
1349
-        $show_trash = true,
1350
-        $show_create = true
1351
-    ) {
1352
-        $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? true : false;
1353
-        $template_args = array(
1354
-            'tkt_row'               => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1355
-            'PRC_order'             => $default && empty($price) ? 'PRICENUM' : $prcrow,
1356
-            'edit_prices_name'      => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices',
1357
-            'price_type_selector'   => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow,
1358
-                $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled),
1359
-            'PRC_ID'                => $default && empty($price) ? 0 : $price->ID(),
1360
-            'PRC_is_default'        => $default && empty($price) ? 0 : $price->get('PRC_is_default'),
1361
-            'PRC_name'              => $default && empty($price) ? '' : $price->get('PRC_name'),
1362
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1363
-            'show_plus_or_minus'    => $default && empty($price) ? '' : ' style="display:none;"',
1364
-            'show_plus'             => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1365
-            'show_minus'            => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1366
-            'show_currency_symbol'  => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''),
1367
-            'PRC_amount'            => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount',
1368
-                'localized_float'),
1369
-            'show_percentage'       => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'),
1370
-            'show_trash_icon'       => $show_trash ? '' : ' style="display:none;"',
1371
-            'show_create_button'    => $show_create ? '' : ' style="display:none;"',
1372
-            'PRC_desc'              => $default && empty($price) ? '' : $price->get('PRC_desc'),
1373
-            'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted') ? true : false
1374
-        );
1375
-        
1376
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1377
-            $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create,
1378
-            $this->_is_creating_event);
1379
-        
1380
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php';
1381
-        
1382
-        return EEH_Template::display_template($template, $template_args, true);
1383
-    }
1343
+	protected function _get_ticket_price_row(
1344
+		$tktrow,
1345
+		$prcrow,
1346
+		$price,
1347
+		$default,
1348
+		$ticket,
1349
+		$show_trash = true,
1350
+		$show_create = true
1351
+	) {
1352
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? true : false;
1353
+		$template_args = array(
1354
+			'tkt_row'               => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1355
+			'PRC_order'             => $default && empty($price) ? 'PRICENUM' : $prcrow,
1356
+			'edit_prices_name'      => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices',
1357
+			'price_type_selector'   => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow,
1358
+				$price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled),
1359
+			'PRC_ID'                => $default && empty($price) ? 0 : $price->ID(),
1360
+			'PRC_is_default'        => $default && empty($price) ? 0 : $price->get('PRC_is_default'),
1361
+			'PRC_name'              => $default && empty($price) ? '' : $price->get('PRC_name'),
1362
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1363
+			'show_plus_or_minus'    => $default && empty($price) ? '' : ' style="display:none;"',
1364
+			'show_plus'             => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1365
+			'show_minus'            => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1366
+			'show_currency_symbol'  => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''),
1367
+			'PRC_amount'            => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount',
1368
+				'localized_float'),
1369
+			'show_percentage'       => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'),
1370
+			'show_trash_icon'       => $show_trash ? '' : ' style="display:none;"',
1371
+			'show_create_button'    => $show_create ? '' : ' style="display:none;"',
1372
+			'PRC_desc'              => $default && empty($price) ? '' : $price->get('PRC_desc'),
1373
+			'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted') ? true : false
1374
+		);
1375
+        
1376
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1377
+			$template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create,
1378
+			$this->_is_creating_event);
1379
+        
1380
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php';
1381
+        
1382
+		return EEH_Template::display_template($template, $template_args, true);
1383
+	}
1384 1384
     
1385 1385
     
1386
-    protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = false)
1387
-    {
1388
-        if ($price->is_base_price()) {
1389
-            return $this->_get_base_price_template($tktrow, $prcrow, $price, $default);
1390
-        } else {
1391
-            return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled);
1392
-        }
1393
-        
1394
-    }
1386
+	protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = false)
1387
+	{
1388
+		if ($price->is_base_price()) {
1389
+			return $this->_get_base_price_template($tktrow, $prcrow, $price, $default);
1390
+		} else {
1391
+			return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled);
1392
+		}
1393
+        
1394
+	}
1395 1395
     
1396 1396
     
1397
-    protected function _get_base_price_template($tktrow, $prcrow, $price, $default)
1398
-    {
1399
-        $template_args = array(
1400
-            'tkt_row'                   => $default ? 'TICKETNUM' : $tktrow,
1401
-            'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $prcrow,
1402
-            'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1403
-            'PRT_name'                  => __('Price', 'event_espresso'),
1404
-            'price_selected_operator'   => '+',
1405
-            'price_selected_is_percent' => 0
1406
-        );
1407
-        $template      = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php';
1408
-        
1409
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1410
-            $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event);
1411
-        
1412
-        return EEH_Template::display_template($template, $template_args, true);
1413
-    }
1397
+	protected function _get_base_price_template($tktrow, $prcrow, $price, $default)
1398
+	{
1399
+		$template_args = array(
1400
+			'tkt_row'                   => $default ? 'TICKETNUM' : $tktrow,
1401
+			'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $prcrow,
1402
+			'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1403
+			'PRT_name'                  => __('Price', 'event_espresso'),
1404
+			'price_selected_operator'   => '+',
1405
+			'price_selected_is_percent' => 0
1406
+		);
1407
+		$template      = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php';
1408
+        
1409
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1410
+			$template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event);
1411
+        
1412
+		return EEH_Template::display_template($template, $template_args, true);
1413
+	}
1414 1414
     
1415 1415
     
1416
-    protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = false)
1417
-    {
1418
-        $select_name                = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]';
1419
-        $price_types                = EE_Registry::instance()->load_model('Price_Type')->get_all(array(
1420
-            array(
1421
-                'OR' => array(
1422
-                    'PBT_ID'  => '2',
1423
-                    'PBT_ID*' => '3'
1424
-                )
1425
-            )
1426
-        ));
1427
-        $price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php';
1428
-        $all_price_types            = $default && empty($price) ? array(
1429
-            array(
1430
-                'id'   => 0,
1431
-                'text' => __('Select Modifier', 'event_espresso')
1432
-            )
1433
-        ) : array();
1434
-        $selected_price_type_id     = $default && empty($price) ? 0 : $price->type();
1435
-        $price_option_spans         = '';
1436
-        //setup pricetypes for selector
1437
-        foreach ($price_types as $price_type) {
1438
-            $all_price_types[] = array(
1439
-                'id'   => $price_type->ID(),
1440
-                'text' => $price_type->get('PRT_name'),
1441
-            );
1416
+	protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = false)
1417
+	{
1418
+		$select_name                = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]';
1419
+		$price_types                = EE_Registry::instance()->load_model('Price_Type')->get_all(array(
1420
+			array(
1421
+				'OR' => array(
1422
+					'PBT_ID'  => '2',
1423
+					'PBT_ID*' => '3'
1424
+				)
1425
+			)
1426
+		));
1427
+		$price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php';
1428
+		$all_price_types            = $default && empty($price) ? array(
1429
+			array(
1430
+				'id'   => 0,
1431
+				'text' => __('Select Modifier', 'event_espresso')
1432
+			)
1433
+		) : array();
1434
+		$selected_price_type_id     = $default && empty($price) ? 0 : $price->type();
1435
+		$price_option_spans         = '';
1436
+		//setup pricetypes for selector
1437
+		foreach ($price_types as $price_type) {
1438
+			$all_price_types[] = array(
1439
+				'id'   => $price_type->ID(),
1440
+				'text' => $price_type->get('PRT_name'),
1441
+			);
1442 1442
             
1443
-            //while we're in the loop let's setup the option spans used by js
1444
-            $spanargs = array(
1445
-                'PRT_ID'         => $price_type->ID(),
1446
-                'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1447
-                'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0
1448
-            );
1449
-            $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, true);
1450
-        }
1451
-        
1452
-        $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"';
1453
-        $main_name     = $select_name;
1454
-        $select_name   = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name;
1455
-        
1456
-        $template_args = array(
1457
-            'tkt_row'                   => $default ? 'TICKETNUM' : $tktrow,
1458
-            'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $prcrow,
1459
-            'price_modifier_selector'   => EEH_Form_Fields::select_input($select_name, $all_price_types,
1460
-                $selected_price_type_id, $select_params, 'edit-price-PRT_ID'),
1461
-            'main_name'                 => $main_name,
1462
-            'selected_price_type_id'    => $selected_price_type_id,
1463
-            'price_option_spans'        => $price_option_spans,
1464
-            'price_selected_operator'   => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'),
1465
-            'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0),
1466
-            'disabled'                  => $disabled
1467
-        );
1468
-        
1469
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
1470
-            $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event);
1471
-        
1472
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php';
1473
-        
1474
-        return EEH_Template::display_template($template, $template_args, true);
1475
-    }
1443
+			//while we're in the loop let's setup the option spans used by js
1444
+			$spanargs = array(
1445
+				'PRT_ID'         => $price_type->ID(),
1446
+				'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1447
+				'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0
1448
+			);
1449
+			$price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, true);
1450
+		}
1451
+        
1452
+		$select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"';
1453
+		$main_name     = $select_name;
1454
+		$select_name   = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name;
1455
+        
1456
+		$template_args = array(
1457
+			'tkt_row'                   => $default ? 'TICKETNUM' : $tktrow,
1458
+			'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $prcrow,
1459
+			'price_modifier_selector'   => EEH_Form_Fields::select_input($select_name, $all_price_types,
1460
+				$selected_price_type_id, $select_params, 'edit-price-PRT_ID'),
1461
+			'main_name'                 => $main_name,
1462
+			'selected_price_type_id'    => $selected_price_type_id,
1463
+			'price_option_spans'        => $price_option_spans,
1464
+			'price_selected_operator'   => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'),
1465
+			'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0),
1466
+			'disabled'                  => $disabled
1467
+		);
1468
+        
1469
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
1470
+			$template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event);
1471
+        
1472
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php';
1473
+        
1474
+		return EEH_Template::display_template($template, $template_args, true);
1475
+	}
1476 1476
     
1477 1477
     
1478
-    protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default)
1479
-    {
1480
-        $tkt_dtts      = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1481
-        $template_args = array(
1482
-            'dtt_row'                  => $default && ! $dtt instanceof EE_Datetime ? 'DTTNUM' : $dttrow,
1483
-            'tkt_row'                  => $default ? 'TICKETNUM' : $tktrow,
1484
-            'ticket_datetime_selected' => in_array($dttrow, $tkt_dtts) ? ' ticket-selected' : '',
1485
-            'ticket_datetime_checked'  => in_array($dttrow, $tkt_dtts) ? ' checked="checked"' : '',
1486
-            'DTT_name'                 => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(true),
1487
-            'tkt_status_class'         => '',
1488
-        );
1489
-        
1490
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
1491
-            $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event);
1492
-        $template      = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1493
-        
1494
-        return EEH_Template::display_template($template, $template_args, true);
1495
-    }
1478
+	protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default)
1479
+	{
1480
+		$tkt_dtts      = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1481
+		$template_args = array(
1482
+			'dtt_row'                  => $default && ! $dtt instanceof EE_Datetime ? 'DTTNUM' : $dttrow,
1483
+			'tkt_row'                  => $default ? 'TICKETNUM' : $tktrow,
1484
+			'ticket_datetime_selected' => in_array($dttrow, $tkt_dtts) ? ' ticket-selected' : '',
1485
+			'ticket_datetime_checked'  => in_array($dttrow, $tkt_dtts) ? ' checked="checked"' : '',
1486
+			'DTT_name'                 => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(true),
1487
+			'tkt_status_class'         => '',
1488
+		);
1489
+        
1490
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
1491
+			$template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event);
1492
+		$template      = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1493
+        
1494
+		return EEH_Template::display_template($template, $template_args, true);
1495
+	}
1496 1496
     
1497 1497
     
1498
-    protected function _get_ticket_js_structure($all_dtts, $all_tickets)
1499
-    {
1500
-        $template_args = array(
1501
-            'default_datetime_edit_row'                => $this->_get_dtt_edit_row('DTTNUM', null, true, $all_dtts),
1502
-            'default_ticket_row'                       => $this->_get_ticket_row('TICKETNUM', null, array(), array(),
1503
-                true),
1504
-            'default_price_row'                        => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', null,
1505
-                true, null),
1506
-            'default_price_rows'                       => '',
1507
-            'default_base_price_amount'                => 0,
1508
-            'default_base_price_name'                  => '',
1509
-            'default_base_price_description'           => '',
1510
-            'default_price_modifier_selector_row'      => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM',
1511
-                null, true),
1512
-            'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row('DTTNUM', null, array(),
1513
-                array(), true),
1514
-            'existing_available_datetime_tickets_list' => '',
1515
-            'existing_available_ticket_datetimes_list' => '',
1516
-            'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM',
1517
-                null, null, array(), true),
1518
-            'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM',
1519
-                null, null, array(), true)
1520
-        );
1521
-        
1522
-        $tktrow = 1;
1523
-        foreach ($all_tickets as $ticket) {
1524
-            $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM',
1525
-                $tktrow, null, $ticket, array(), true);
1526
-            $tktrow++;
1527
-        }
1528
-        
1529
-        
1530
-        $dttrow = 1;
1531
-        foreach ($all_dtts as $dtt) {
1532
-            $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow,
1533
-                'TICKETNUM', $dtt, null, array(), true);
1534
-            $dttrow++;
1535
-        }
1536
-        
1537
-        $default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices();
1538
-        $prcrow         = 1;
1539
-        foreach ($default_prices as $price) {
1540
-            if ($price->is_base_price()) {
1541
-                $template_args['default_base_price_amount']      = $price->get_pretty('PRC_amount', 'localized_float');
1542
-                $template_args['default_base_price_name']        = $price->get('PRC_name');
1543
-                $template_args['default_base_price_description'] = $price->get('PRC_desc');
1544
-                $prcrow++;
1545
-                continue;
1546
-            }
1547
-            $show_trash  = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? false : true;
1548
-            $show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? false : true;
1549
-            $template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, true,
1550
-                null, $show_trash, $show_create);
1551
-            $prcrow++;
1552
-        }
1553
-        
1554
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
1555
-            $template_args, $all_dtts, $all_tickets, $this->_is_creating_event);
1556
-        
1557
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php';
1558
-        
1559
-        return EEH_Template::display_template($template, $template_args, true);
1560
-    }
1498
+	protected function _get_ticket_js_structure($all_dtts, $all_tickets)
1499
+	{
1500
+		$template_args = array(
1501
+			'default_datetime_edit_row'                => $this->_get_dtt_edit_row('DTTNUM', null, true, $all_dtts),
1502
+			'default_ticket_row'                       => $this->_get_ticket_row('TICKETNUM', null, array(), array(),
1503
+				true),
1504
+			'default_price_row'                        => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', null,
1505
+				true, null),
1506
+			'default_price_rows'                       => '',
1507
+			'default_base_price_amount'                => 0,
1508
+			'default_base_price_name'                  => '',
1509
+			'default_base_price_description'           => '',
1510
+			'default_price_modifier_selector_row'      => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM',
1511
+				null, true),
1512
+			'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row('DTTNUM', null, array(),
1513
+				array(), true),
1514
+			'existing_available_datetime_tickets_list' => '',
1515
+			'existing_available_ticket_datetimes_list' => '',
1516
+			'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM',
1517
+				null, null, array(), true),
1518
+			'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM',
1519
+				null, null, array(), true)
1520
+		);
1521
+        
1522
+		$tktrow = 1;
1523
+		foreach ($all_tickets as $ticket) {
1524
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM',
1525
+				$tktrow, null, $ticket, array(), true);
1526
+			$tktrow++;
1527
+		}
1528
+        
1529
+        
1530
+		$dttrow = 1;
1531
+		foreach ($all_dtts as $dtt) {
1532
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow,
1533
+				'TICKETNUM', $dtt, null, array(), true);
1534
+			$dttrow++;
1535
+		}
1536
+        
1537
+		$default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices();
1538
+		$prcrow         = 1;
1539
+		foreach ($default_prices as $price) {
1540
+			if ($price->is_base_price()) {
1541
+				$template_args['default_base_price_amount']      = $price->get_pretty('PRC_amount', 'localized_float');
1542
+				$template_args['default_base_price_name']        = $price->get('PRC_name');
1543
+				$template_args['default_base_price_description'] = $price->get('PRC_desc');
1544
+				$prcrow++;
1545
+				continue;
1546
+			}
1547
+			$show_trash  = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? false : true;
1548
+			$show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? false : true;
1549
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, true,
1550
+				null, $show_trash, $show_create);
1551
+			$prcrow++;
1552
+		}
1553
+        
1554
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
1555
+			$template_args, $all_dtts, $all_tickets, $this->_is_creating_event);
1556
+        
1557
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php';
1558
+        
1559
+		return EEH_Template::display_template($template, $template_args, true);
1560
+	}
1561 1561
     
1562 1562
     
1563 1563
 } //end class espresso_events_Pricing_Hooks
Please login to merge, or discard this patch.
core/EE_Registry.core.php 1 patch
Indentation   +1336 added lines, -1336 removed lines patch added patch discarded remove patch
@@ -16,1372 +16,1372 @@
 block discarded – undo
16 16
 class EE_Registry
17 17
 {
18 18
 
19
-    /**
20
-     *    EE_Registry Object
21
-     *
22
-     * @var EE_Registry $_instance
23
-     * @access    private
24
-     */
25
-    private static $_instance = null;
26
-
27
-    /**
28
-     * @var EE_Dependency_Map $_dependency_map
29
-     * @access    protected
30
-     */
31
-    protected $_dependency_map = null;
32
-
33
-    /**
34
-     * @var array $_class_abbreviations
35
-     * @access    protected
36
-     */
37
-    protected $_class_abbreviations = array();
38
-
39
-    /**
40
-     * @access public
41
-     * @var \EventEspresso\core\services\commands\CommandBusInterface $BUS
42
-     */
43
-    public $BUS;
44
-
45
-    /**
46
-     *    EE_Cart Object
47
-     *
48
-     * @access    public
49
-     * @var    EE_Cart $CART
50
-     */
51
-    public $CART = null;
52
-
53
-    /**
54
-     *    EE_Config Object
55
-     *
56
-     * @access    public
57
-     * @var    EE_Config $CFG
58
-     */
59
-    public $CFG = null;
60
-
61
-    /**
62
-     * EE_Network_Config Object
63
-     *
64
-     * @access public
65
-     * @var EE_Network_Config $NET_CFG
66
-     */
67
-    public $NET_CFG = null;
68
-
69
-    /**
70
-     *    StdClass object for storing library classes in
71
-     *
72
-     * @public LIB
73
-     * @var StdClass $LIB
74
-     */
75
-    public $LIB = null;
76
-
77
-    /**
78
-     *    EE_Request_Handler Object
79
-     *
80
-     * @access    public
81
-     * @var    EE_Request_Handler $REQ
82
-     */
83
-    public $REQ = null;
84
-
85
-    /**
86
-     *    EE_Session Object
87
-     *
88
-     * @access    public
89
-     * @var    EE_Session $SSN
90
-     */
91
-    public $SSN = null;
92
-
93
-    /**
94
-     * holds the ee capabilities object.
95
-     *
96
-     * @since 4.5.0
97
-     * @var EE_Capabilities
98
-     */
99
-    public $CAP = null;
100
-
101
-    /**
102
-     * holds the EE_Message_Resource_Manager object.
103
-     *
104
-     * @since 4.9.0
105
-     * @var EE_Message_Resource_Manager
106
-     */
107
-    public $MRM = null;
108
-
109
-
110
-    /**
111
-     * Holds the Assets Registry instance
112
-     * @var Registry
113
-     */
114
-    public $AssetsRegistry = null;
115
-
116
-    /**
117
-     *    $addons - StdClass object for holding addons which have registered themselves to work with EE core
118
-     *
119
-     * @access    public
120
-     * @var    EE_Addon[]
121
-     */
122
-    public $addons = null;
123
-
124
-    /**
125
-     *    $models
126
-     * @access    public
127
-     * @var    EEM_Base[] $models keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
128
-     */
129
-    public $models = array();
130
-
131
-    /**
132
-     *    $modules
133
-     * @access    public
134
-     * @var    EED_Module[] $modules
135
-     */
136
-    public $modules = null;
137
-
138
-    /**
139
-     *    $shortcodes
140
-     * @access    public
141
-     * @var    EES_Shortcode[] $shortcodes
142
-     */
143
-    public $shortcodes = null;
144
-
145
-    /**
146
-     *    $widgets
147
-     * @access    public
148
-     * @var    WP_Widget[] $widgets
149
-     */
150
-    public $widgets = null;
151
-
152
-    /**
153
-     * $non_abstract_db_models
154
-     * @access public
155
-     * @var array this is an array of all implemented model names (i.e. not the parent abstract models, or models
156
-     * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
157
-     * Keys are model "short names" (eg "Event") as used in model relations, and values are
158
-     * classnames (eg "EEM_Event")
159
-     */
160
-    public $non_abstract_db_models = array();
161
-
162
-
163
-    /**
164
-     *    $i18n_js_strings - internationalization for JS strings
165
-     *    usage:   EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' );
166
-     *    in js file:  var translatedString = eei18n.string_key;
167
-     *
168
-     * @access    public
169
-     * @var    array
170
-     */
171
-    public static $i18n_js_strings = array();
172
-
173
-
174
-    /**
175
-     *    $main_file - path to espresso.php
176
-     *
177
-     * @access    public
178
-     * @var    array
179
-     */
180
-    public $main_file;
181
-
182
-    /**
183
-     * array of ReflectionClass objects where the key is the class name
184
-     *
185
-     * @access    public
186
-     * @var ReflectionClass[]
187
-     */
188
-    public $_reflectors;
189
-
190
-    /**
191
-     * boolean flag to indicate whether or not to load/save dependencies from/to the cache
192
-     *
193
-     * @access    protected
194
-     * @var boolean $_cache_on
195
-     */
196
-    protected $_cache_on = true;
197
-
198
-
199
-
200
-    /**
201
-     * @singleton method used to instantiate class object
202
-     * @access    public
203
-     * @param  \EE_Dependency_Map $dependency_map
204
-     * @return \EE_Registry instance
205
-     */
206
-    public static function instance(\EE_Dependency_Map $dependency_map = null)
207
-    {
208
-        // check if class object is instantiated
209
-        if ( ! self::$_instance instanceof EE_Registry) {
210
-            self::$_instance = new EE_Registry($dependency_map);
211
-        }
212
-        return self::$_instance;
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     *protected constructor to prevent direct creation
219
-     *
220
-     * @Constructor
221
-     * @access protected
222
-     * @param  \EE_Dependency_Map $dependency_map
223
-     * @return \EE_Registry
224
-     */
225
-    protected function __construct(\EE_Dependency_Map $dependency_map)
226
-    {
227
-        $this->_dependency_map = $dependency_map;
228
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
229
-    }
230
-
231
-
232
-
233
-    /**
234
-     * initialize
235
-     */
236
-    public function initialize()
237
-    {
238
-        $this->_class_abbreviations = apply_filters(
239
-            'FHEE__EE_Registry____construct___class_abbreviations',
240
-            array(
241
-                'EE_Config'                                       => 'CFG',
242
-                'EE_Session'                                      => 'SSN',
243
-                'EE_Capabilities'                                 => 'CAP',
244
-                'EE_Cart'                                         => 'CART',
245
-                'EE_Network_Config'                               => 'NET_CFG',
246
-                'EE_Request_Handler'                              => 'REQ',
247
-                'EE_Message_Resource_Manager'                     => 'MRM',
248
-                'EventEspresso\core\services\commands\CommandBus' => 'BUS',
249
-            )
250
-        );
251
-        // class library
252
-        $this->LIB = new stdClass();
253
-        $this->addons = new stdClass();
254
-        $this->modules = new stdClass();
255
-        $this->shortcodes = new stdClass();
256
-        $this->widgets = new stdClass();
257
-        $this->load_core('Base', array(), true);
258
-        // add our request and response objects to the cache
259
-        $request_loader = $this->_dependency_map->class_loader('EE_Request');
260
-        $this->_set_cached_class(
261
-            $request_loader(),
262
-            'EE_Request'
263
-        );
264
-        $response_loader = $this->_dependency_map->class_loader('EE_Response');
265
-        $this->_set_cached_class(
266
-            $response_loader(),
267
-            'EE_Response'
268
-        );
269
-        add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
270
-    }
271
-
272
-
273
-
274
-    /**
275
-     *    init
276
-     *
277
-     * @access    public
278
-     * @return    void
279
-     */
280
-    public function init()
281
-    {
282
-        $this->AssetsRegistry = new Registry();
283
-        // Get current page protocol
284
-        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
285
-        // Output admin-ajax.php URL with same protocol as current page
286
-        self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
287
-        self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
288
-    }
289
-
290
-
291
-
292
-    /**
293
-     * localize_i18n_js_strings
294
-     *
295
-     * @return string
296
-     */
297
-    public static function localize_i18n_js_strings()
298
-    {
299
-        $i18n_js_strings = (array)EE_Registry::$i18n_js_strings;
300
-        foreach ($i18n_js_strings as $key => $value) {
301
-            if (is_scalar($value)) {
302
-                $i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
303
-            }
304
-        }
305
-        return "/* <![CDATA[ */ var eei18n = " . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
306
-    }
307
-
308
-
309
-
310
-    /**
311
-     * @param mixed string | EED_Module $module
312
-     */
313
-    public function add_module($module)
314
-    {
315
-        if ($module instanceof EED_Module) {
316
-            $module_class = get_class($module);
317
-            $this->modules->{$module_class} = $module;
318
-        } else {
319
-            if ( ! class_exists('EE_Module_Request_Router')) {
320
-                $this->load_core('Module_Request_Router');
321
-            }
322
-            $this->modules->{$module} = EE_Module_Request_Router::module_factory($module);
323
-        }
324
-    }
325
-
326
-
327
-
328
-    /**
329
-     * @param string $module_name
330
-     * @return mixed EED_Module | NULL
331
-     */
332
-    public function get_module($module_name = '')
333
-    {
334
-        return isset($this->modules->{$module_name}) ? $this->modules->{$module_name} : null;
335
-    }
336
-
337
-
338
-
339
-    /**
340
-     *    loads core classes - must be singletons
341
-     *
342
-     * @access    public
343
-     * @param string $class_name - simple class name ie: session
344
-     * @param mixed  $arguments
345
-     * @param bool   $load_only
346
-     * @return mixed
347
-     */
348
-    public function load_core($class_name, $arguments = array(), $load_only = false)
349
-    {
350
-        $core_paths = apply_filters(
351
-            'FHEE__EE_Registry__load_core__core_paths',
352
-            array(
353
-                EE_CORE,
354
-                EE_ADMIN,
355
-                EE_CPTS,
356
-                EE_CORE . 'data_migration_scripts' . DS,
357
-                EE_CORE . 'request_stack' . DS,
358
-                EE_CORE . 'middleware' . DS,
359
-            )
360
-        );
361
-        // retrieve instantiated class
362
-        return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only);
363
-    }
364
-
365
-
366
-
367
-    /**
368
-     *    loads service classes
369
-     *
370
-     * @access    public
371
-     * @param string $class_name - simple class name ie: session
372
-     * @param mixed  $arguments
373
-     * @param bool   $load_only
374
-     * @return mixed
375
-     */
376
-    public function load_service($class_name, $arguments = array(), $load_only = false)
377
-    {
378
-        $service_paths = apply_filters(
379
-            'FHEE__EE_Registry__load_service__service_paths',
380
-            array(
381
-                EE_CORE . 'services' . DS,
382
-            )
383
-        );
384
-        // retrieve instantiated class
385
-        return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only);
386
-    }
387
-
388
-
389
-
390
-    /**
391
-     *    loads data_migration_scripts
392
-     *
393
-     * @access    public
394
-     * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
395
-     * @param mixed  $arguments
396
-     * @return EE_Data_Migration_Script_Base|mixed
397
-     */
398
-    public function load_dms($class_name, $arguments = array())
399
-    {
400
-        // retrieve instantiated class
401
-        return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false);
402
-    }
403
-
404
-
405
-
406
-    /**
407
-     *    loads object creating classes - must be singletons
408
-     *
409
-     * @param string $class_name - simple class name ie: attendee
410
-     * @param mixed  $arguments  - an array of arguments to pass to the class
411
-     * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to instantiate
412
-     * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then set this to FALSE (ie. when instantiating model objects from client in a loop)
413
-     * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate (default)
414
-     * @return EE_Base_Class | bool
415
-     */
416
-    public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
417
-    {
418
-        $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array(
419
-            EE_CORE,
420
-            EE_CLASSES,
421
-            EE_BUSINESS,
422
-        ));
423
-        // retrieve instantiated class
424
-        return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only);
425
-    }
426
-
427
-
428
-
429
-    /**
430
-     *    loads helper classes - must be singletons
431
-     *
432
-     * @param string $class_name - simple class name ie: price
433
-     * @param mixed  $arguments
434
-     * @param bool   $load_only
435
-     * @return EEH_Base | bool
436
-     */
437
-    public function load_helper($class_name, $arguments = array(), $load_only = true)
438
-    {
439
-        // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
440
-        $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
441
-        // retrieve instantiated class
442
-        return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only);
443
-    }
444
-
445
-
446
-
447
-    /**
448
-     *    loads core classes - must be singletons
449
-     *
450
-     * @access    public
451
-     * @param string $class_name - simple class name ie: session
452
-     * @param mixed  $arguments
453
-     * @param bool   $load_only
454
-     * @param bool   $cache      whether to cache the object or not.
455
-     * @return mixed
456
-     */
457
-    public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
458
-    {
459
-        $paths = array(
460
-            EE_LIBRARIES,
461
-            EE_LIBRARIES . 'messages' . DS,
462
-            EE_LIBRARIES . 'shortcodes' . DS,
463
-            EE_LIBRARIES . 'qtips' . DS,
464
-            EE_LIBRARIES . 'payment_methods' . DS,
465
-        );
466
-        // retrieve instantiated class
467
-        return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only);
468
-    }
469
-
470
-
471
-
472
-    /**
473
-     *    loads model classes - must be singletons
474
-     *
475
-     * @param string $class_name - simple class name ie: price
476
-     * @param mixed  $arguments
477
-     * @param bool   $load_only
478
-     * @return EEM_Base | bool
479
-     */
480
-    public function load_model($class_name, $arguments = array(), $load_only = false)
481
-    {
482
-        $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array(
483
-            EE_MODELS,
484
-            EE_CORE,
485
-        ));
486
-        // retrieve instantiated class
487
-        return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only);
488
-    }
489
-
490
-
491
-
492
-    /**
493
-     *    loads model classes - must be singletons
494
-     *
495
-     * @param string $class_name - simple class name ie: price
496
-     * @param mixed  $arguments
497
-     * @param bool   $load_only
498
-     * @return mixed | bool
499
-     */
500
-    public function load_model_class($class_name, $arguments = array(), $load_only = true)
501
-    {
502
-        $paths = array(
503
-            EE_MODELS . 'fields' . DS,
504
-            EE_MODELS . 'helpers' . DS,
505
-            EE_MODELS . 'relations' . DS,
506
-            EE_MODELS . 'strategies' . DS,
507
-        );
508
-        // retrieve instantiated class
509
-        return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only);
510
-    }
511
-
512
-
513
-
514
-    /**
515
-     * Determines if $model_name is the name of an actual EE model.
516
-     *
517
-     * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
518
-     * @return boolean
519
-     */
520
-    public function is_model_name($model_name)
521
-    {
522
-        return isset($this->models[$model_name]) ? true : false;
523
-    }
524
-
525
-
526
-
527
-    /**
528
-     *    generic class loader
529
-     *
530
-     * @param string $path_to_file - directory path to file location, not including filename
531
-     * @param string $file_name    - file name  ie:  my_file.php, including extension
532
-     * @param string $type         - file type - core? class? helper? model?
533
-     * @param mixed  $arguments
534
-     * @param bool   $load_only
535
-     * @return mixed
536
-     */
537
-    public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
538
-    {
539
-        // retrieve instantiated class
540
-        return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only);
541
-    }
542
-
543
-
544
-
545
-    /**
546
-     *    load_addon
547
-     *
548
-     * @param string $path_to_file - directory path to file location, not including filename
549
-     * @param string $class_name   - full class name  ie:  My_Class
550
-     * @param string $type         - file type - core? class? helper? model?
551
-     * @param mixed  $arguments
552
-     * @param bool   $load_only
553
-     * @return EE_Addon
554
-     */
555
-    public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
556
-    {
557
-        // retrieve instantiated class
558
-        return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only);
559
-    }
560
-
561
-
562
-
563
-    /**
564
-     * instantiates, caches, and automatically resolves dependencies
565
-     * for classes that use a Fully Qualified Class Name.
566
-     * if the class is not capable of being loaded using PSR-4 autoloading,
567
-     * then you need to use one of the existing load_*() methods
568
-     * which can resolve the classname and filepath from the passed arguments
569
-     *
570
-     * @param bool|string $class_name   Fully Qualified Class Name
571
-     * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
572
-     * @param bool        $cache        whether to cache the instantiated object for reuse
573
-     * @param bool        $from_db      some classes are instantiated from the db
574
-     *                                  and thus call a different method to instantiate
575
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
576
-     * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
577
-     * @return mixed                    null = failure to load or instantiate class object.
578
-     *                                  object = class loaded and instantiated successfully.
579
-     *                                  bool = fail or success when $load_only is true
580
-     */
581
-    public function create(
582
-        $class_name = false,
583
-        $arguments = array(),
584
-        $cache = false,
585
-        $from_db = false,
586
-        $load_only = false,
587
-        $addon = false
588
-    ) {
589
-        $class_name = $this->_dependency_map->get_alias($class_name);
590
-        if ( ! class_exists($class_name)) {
591
-            // maybe the class is registered with a preceding \
592
-            $class_name = strpos($class_name, '\\') !== 0 ? '\\' . $class_name : $class_name;
593
-            // still doesn't exist ?
594
-            if ( ! class_exists($class_name)) {
595
-                return null;
596
-            }
597
-        }
598
-        // if we're only loading the class and it already exists, then let's just return true immediately
599
-        if ($load_only) {
600
-            return true;
601
-        }
602
-        $addon = $addon ? 'addon' : '';
603
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
604
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
605
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
606
-        if ($this->_cache_on && $cache && ! $load_only) {
607
-            // return object if it's already cached
608
-            $cached_class = $this->_get_cached_class($class_name, $addon);
609
-            if ($cached_class !== null) {
610
-                return $cached_class;
611
-            }
612
-        }
613
-        // instantiate the requested object
614
-        $class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
615
-        if ($this->_cache_on && $cache) {
616
-            // save it for later... kinda like gum  { : $
617
-            $this->_set_cached_class($class_obj, $class_name, $addon, $from_db);
618
-        }
619
-        $this->_cache_on = true;
620
-        return $class_obj;
621
-    }
622
-
623
-
624
-
625
-    /**
626
-     * instantiates, caches, and injects dependencies for classes
627
-     *
628
-     * @param array       $file_paths   an array of paths to folders to look in
629
-     * @param string      $class_prefix EE  or EEM or... ???
630
-     * @param bool|string $class_name   $class name
631
-     * @param string      $type         file type - core? class? helper? model?
632
-     * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
633
-     * @param bool        $from_db      some classes are instantiated from the db
634
-     *                                  and thus call a different method to instantiate
635
-     * @param bool        $cache        whether to cache the instantiated object for reuse
636
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
637
-     * @return null|object|bool         null = failure to load or instantiate class object.
638
-     *                                  object = class loaded and instantiated successfully.
639
-     *                                  bool = fail or success when $load_only is true
640
-     */
641
-    protected function _load(
642
-        $file_paths = array(),
643
-        $class_prefix = 'EE_',
644
-        $class_name = false,
645
-        $type = 'class',
646
-        $arguments = array(),
647
-        $from_db = false,
648
-        $cache = true,
649
-        $load_only = false
650
-    ) {
651
-        // strip php file extension
652
-        $class_name = str_replace('.php', '', trim($class_name));
653
-        // does the class have a prefix ?
654
-        if ( ! empty($class_prefix) && $class_prefix != 'addon') {
655
-            // make sure $class_prefix is uppercase
656
-            $class_prefix = strtoupper(trim($class_prefix));
657
-            // add class prefix ONCE!!!
658
-            $class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
659
-        }
660
-        $class_name = $this->_dependency_map->get_alias($class_name);
661
-        $class_exists = class_exists($class_name);
662
-        // if we're only loading the class and it already exists, then let's just return true immediately
663
-        if ($load_only && $class_exists) {
664
-            return true;
665
-        }
666
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
667
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
668
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
669
-        if ($this->_cache_on && $cache && ! $load_only) {
670
-            // return object if it's already cached
671
-            $cached_class = $this->_get_cached_class($class_name, $class_prefix);
672
-            if ($cached_class !== null) {
673
-                return $cached_class;
674
-            }
675
-        }
676
-        // if the class doesn't already exist.. then we need to try and find the file and load it
677
-        if ( ! $class_exists) {
678
-            // get full path to file
679
-            $path = $this->_resolve_path($class_name, $type, $file_paths);
680
-            // load the file
681
-            $loaded = $this->_require_file($path, $class_name, $type, $file_paths);
682
-            // if loading failed, or we are only loading a file but NOT instantiating an object
683
-            if ( ! $loaded || $load_only) {
684
-                // return boolean if only loading, or null if an object was expected
685
-                return $load_only ? $loaded : null;
686
-            }
687
-        }
688
-        // instantiate the requested object
689
-        $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
690
-        if ($this->_cache_on && $cache) {
691
-            // save it for later... kinda like gum  { : $
692
-            $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
693
-        }
694
-        $this->_cache_on = true;
695
-        return $class_obj;
696
-    }
697
-
698
-
699
-
700
-    /**
701
-     * _get_cached_class
702
-     * attempts to find a cached version of the requested class
703
-     * by looking in the following places:
704
-     *        $this->{$class_abbreviation}            ie:    $this->CART
705
-     *        $this->{$class_name}                        ie:    $this->Some_Class
706
-     *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
707
-     *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
708
-     *
709
-     * @access protected
710
-     * @param string $class_name
711
-     * @param string $class_prefix
712
-     * @return mixed
713
-     */
714
-    protected function _get_cached_class($class_name, $class_prefix = '')
715
-    {
716
-        if (isset($this->_class_abbreviations[$class_name])) {
717
-            $class_abbreviation = $this->_class_abbreviations[$class_name];
718
-        } else {
719
-            // have to specify something, but not anything that will conflict
720
-            $class_abbreviation = 'FANCY_BATMAN_PANTS';
721
-        }
722
-        // check if class has already been loaded, and return it if it has been
723
-        if (isset($this->{$class_abbreviation}) && ! is_null($this->{$class_abbreviation})) {
724
-            return $this->{$class_abbreviation};
725
-        } else if (isset ($this->{$class_name})) {
726
-            return $this->{$class_name};
727
-        } else if (isset ($this->LIB->{$class_name})) {
728
-            return $this->LIB->{$class_name};
729
-        } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name})) {
730
-            return $this->addons->{$class_name};
731
-        }
732
-        return null;
733
-    }
734
-
735
-
736
-
737
-    /**
738
-     * _resolve_path
739
-     * attempts to find a full valid filepath for the requested class.
740
-     * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
741
-     * then returns that path if the target file has been found and is readable
742
-     *
743
-     * @access protected
744
-     * @param string $class_name
745
-     * @param string $type
746
-     * @param array  $file_paths
747
-     * @return string | bool
748
-     */
749
-    protected function _resolve_path($class_name, $type = '', $file_paths = array())
750
-    {
751
-        // make sure $file_paths is an array
752
-        $file_paths = is_array($file_paths) ? $file_paths : array($file_paths);
753
-        // cycle thru paths
754
-        foreach ($file_paths as $key => $file_path) {
755
-            // convert all separators to proper DS, if no filepath, then use EE_CLASSES
756
-            $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES;
757
-            // prep file type
758
-            $type = ! empty($type) ? trim($type, '.') . '.' : '';
759
-            // build full file path
760
-            $file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
761
-            //does the file exist and can be read ?
762
-            if (is_readable($file_paths[$key])) {
763
-                return $file_paths[$key];
764
-            }
765
-        }
766
-        return false;
767
-    }
768
-
769
-
770
-
771
-    /**
772
-     * _require_file
773
-     * basically just performs a require_once()
774
-     * but with some error handling
775
-     *
776
-     * @access protected
777
-     * @param  string $path
778
-     * @param  string $class_name
779
-     * @param  string $type
780
-     * @param  array  $file_paths
781
-     * @return boolean
782
-     * @throws \EE_Error
783
-     */
784
-    protected function _require_file($path, $class_name, $type = '', $file_paths = array())
785
-    {
786
-        // don't give up! you gotta...
787
-        try {
788
-            //does the file exist and can it be read ?
789
-            if ( ! $path) {
790
-                // so sorry, can't find the file
791
-                throw new EE_Error (
792
-                    sprintf(
793
-                        __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'),
794
-                        trim($type, '.'),
795
-                        $class_name,
796
-                        '<br />' . implode(',<br />', $file_paths)
797
-                    )
798
-                );
799
-            }
800
-            // get the file
801
-            require_once($path);
802
-            // if the class isn't already declared somewhere
803
-            if (class_exists($class_name, false) === false) {
804
-                // so sorry, not a class
805
-                throw new EE_Error(
806
-                    sprintf(
807
-                        __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
808
-                        $type,
809
-                        $path,
810
-                        $class_name
811
-                    )
812
-                );
813
-            }
814
-        } catch (EE_Error $e) {
815
-            $e->get_error();
816
-            return false;
817
-        }
818
-        return true;
819
-    }
820
-
821
-
822
-
823
-    /**
824
-     * _create_object
825
-     * Attempts to instantiate the requested class via any of the
826
-     * commonly used instantiation methods employed throughout EE.
827
-     * The priority for instantiation is as follows:
828
-     *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
829
-     *        - model objects via their 'new_instance_from_db' method
830
-     *        - model objects via their 'new_instance' method
831
-     *        - "singleton" classes" via their 'instance' method
832
-     *    - standard instantiable classes via their __constructor
833
-     * Prior to instantiation, if the classname exists in the dependency_map,
834
-     * then the constructor for the requested class will be examined to determine
835
-     * if any dependencies exist, and if they can be injected.
836
-     * If so, then those classes will be added to the array of arguments passed to the constructor
837
-     *
838
-     * @access protected
839
-     * @param string $class_name
840
-     * @param array  $arguments
841
-     * @param string $type
842
-     * @param bool   $from_db
843
-     * @return null | object
844
-     * @throws \EE_Error
845
-     */
846
-    protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
847
-    {
848
-        $class_obj = null;
849
-        $instantiation_mode = '0) none';
850
-        // don't give up! you gotta...
851
-        try {
852
-            // create reflection
853
-            $reflector = $this->get_ReflectionClass($class_name);
854
-            // make sure arguments are an array
855
-            $arguments = is_array($arguments) ? $arguments : array($arguments);
856
-            // and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
857
-            // else wrap it in an additional array so that it doesn't get split into multiple parameters
858
-            $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
859
-                ? $arguments
860
-                : array($arguments);
861
-            // attempt to inject dependencies ?
862
-            if ($this->_dependency_map->has($class_name)) {
863
-                $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
864
-            }
865
-            // instantiate the class if possible
866
-            if ($reflector->isAbstract()) {
867
-                // nothing to instantiate, loading file was enough
868
-                // does not throw an exception so $instantiation_mode is unused
869
-                // $instantiation_mode = "1) no constructor abstract class";
870
-                $class_obj = true;
871
-            } else if ($reflector->getConstructor() === null && $reflector->isInstantiable() && empty($arguments)) {
872
-                // no constructor = static methods only... nothing to instantiate, loading file was enough
873
-                $instantiation_mode = "2) no constructor but instantiable";
874
-                $class_obj = $reflector->newInstance();
875
-            } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
876
-                $instantiation_mode = "3) new_instance_from_db()";
877
-                $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
878
-            } else if (method_exists($class_name, 'new_instance')) {
879
-                $instantiation_mode = "4) new_instance()";
880
-                $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
881
-            } else if (method_exists($class_name, 'instance')) {
882
-                $instantiation_mode = "5) instance()";
883
-                $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
884
-            } else if ($reflector->isInstantiable()) {
885
-                $instantiation_mode = "6) constructor";
886
-                $class_obj = $reflector->newInstanceArgs($arguments);
887
-            } else {
888
-                // heh ? something's not right !
889
-                throw new EE_Error(
890
-                    sprintf(
891
-                        __('The %s file %s could not be instantiated.', 'event_espresso'),
892
-                        $type,
893
-                        $class_name
894
-                    )
895
-                );
896
-            }
897
-        } catch (Exception $e) {
898
-            if ( ! $e instanceof EE_Error) {
899
-                $e = new EE_Error(
900
-                    sprintf(
901
-                        __('The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso'),
902
-                        $class_name,
903
-                        '<br />',
904
-                        $e->getMessage(),
905
-                        $instantiation_mode
906
-                    )
907
-                );
908
-            }
909
-            $e->get_error();
910
-        }
911
-        return $class_obj;
912
-    }
913
-
914
-
915
-
916
-    /**
917
-     * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
918
-     * @param array $array
919
-     * @return bool
920
-     */
921
-    protected function _array_is_numerically_and_sequentially_indexed(array $array)
922
-    {
923
-        return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
924
-    }
925
-
926
-
927
-
928
-    /**
929
-     * getReflectionClass
930
-     * checks if a ReflectionClass object has already been generated for a class
931
-     * and returns that instead of creating a new one
932
-     *
933
-     * @access public
934
-     * @param string $class_name
935
-     * @return ReflectionClass
936
-     */
937
-    public function get_ReflectionClass($class_name)
938
-    {
939
-        if (
940
-            ! isset($this->_reflectors[$class_name])
941
-            || ! $this->_reflectors[$class_name] instanceof ReflectionClass
942
-        ) {
943
-            $this->_reflectors[$class_name] = new ReflectionClass($class_name);
944
-        }
945
-        return $this->_reflectors[$class_name];
946
-    }
947
-
948
-
949
-
950
-    /**
951
-     * _resolve_dependencies
952
-     * examines the constructor for the requested class to determine
953
-     * if any dependencies exist, and if they can be injected.
954
-     * If so, then those classes will be added to the array of arguments passed to the constructor
955
-     * PLZ NOTE: this is achieved by type hinting the constructor params
956
-     * For example:
957
-     *        if attempting to load a class "Foo" with the following constructor:
958
-     *        __construct( Bar $bar_class, Fighter $grohl_class )
959
-     *        then $bar_class and $grohl_class will be added to the $arguments array,
960
-     *        but only IF they are NOT already present in the incoming arguments array,
961
-     *        and the correct classes can be loaded
962
-     *
963
-     * @access protected
964
-     * @param ReflectionClass $reflector
965
-     * @param string          $class_name
966
-     * @param array           $arguments
967
-     * @return array
968
-     * @throws \ReflectionException
969
-     */
970
-    protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array())
971
-    {
972
-        // let's examine the constructor
973
-        $constructor = $reflector->getConstructor();
974
-        // whu? huh? nothing?
975
-        if ( ! $constructor) {
976
-            return $arguments;
977
-        }
978
-        // get constructor parameters
979
-        $params = $constructor->getParameters();
980
-        // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
981
-        $argument_keys = array_keys($arguments);
982
-        // now loop thru all of the constructors expected parameters
983
-        foreach ($params as $index => $param) {
984
-            // is this a dependency for a specific class ?
985
-            $param_class = $param->getClass() ? $param->getClass()->name : null;
986
-            if (
987
-                // param is not even a class
988
-                empty($param_class)
989
-                // and something already exists in the incoming arguments for this param
990
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
991
-            ) {
992
-                // so let's skip this argument and move on to the next
993
-                continue;
994
-            } else if (
995
-                // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
996
-                ! empty($param_class)
997
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
998
-                && $arguments[$argument_keys[$index]] instanceof $param_class
999
-            ) {
1000
-                // skip this argument and move on to the next
1001
-                continue;
1002
-            } else if (
1003
-                // parameter is type hinted as a class, and should be injected
1004
-                ! empty($param_class)
1005
-                && $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1006
-            ) {
1007
-                $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index);
1008
-            } else {
1009
-                try {
1010
-                    $arguments[$index] = $param->getDefaultValue();
1011
-                } catch (ReflectionException $e) {
1012
-                    throw new ReflectionException(
1013
-                        sprintf(
1014
-                            __('%1$s for parameter "$%2$s"', 'event_espresso'),
1015
-                            $e->getMessage(),
1016
-                            $param->getName()
1017
-                        )
1018
-                    );
1019
-                }
1020
-            }
1021
-        }
1022
-        return $arguments;
1023
-    }
1024
-
1025
-
1026
-
1027
-    /**
1028
-     * @access protected
1029
-     * @param string $class_name
1030
-     * @param string $param_class
1031
-     * @param array  $arguments
1032
-     * @param mixed  $index
1033
-     * @return array
1034
-     */
1035
-    protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1036
-    {
1037
-        $dependency = null;
1038
-        // should dependency be loaded from cache ?
1039
-        $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class)
1040
-                    !== EE_Dependency_Map::load_new_object
1041
-            ? true
1042
-            : false;
1043
-        // we might have a dependency...
1044
-        // let's MAYBE try and find it in our cache if that's what's been requested
1045
-        $cached_class = $cache_on ? $this->_get_cached_class($param_class) : null;
1046
-        // and grab it if it exists
1047
-        if ($cached_class instanceof $param_class) {
1048
-            $dependency = $cached_class;
1049
-        } else if ($param_class != $class_name) {
1050
-            // obtain the loader method from the dependency map
1051
-            $loader = $this->_dependency_map->class_loader($param_class);
1052
-            // is loader a custom closure ?
1053
-            if ($loader instanceof Closure) {
1054
-                $dependency = $loader();
1055
-            } else {
1056
-                // set the cache on property for the recursive loading call
1057
-                $this->_cache_on = $cache_on;
1058
-                // if not, then let's try and load it via the registry
1059
-                if (method_exists($this, $loader)) {
1060
-                    $dependency = $this->{$loader}($param_class);
1061
-                } else {
1062
-                    $dependency = $this->create($param_class, array(), $cache_on);
1063
-                }
1064
-            }
1065
-        }
1066
-        // did we successfully find the correct dependency ?
1067
-        if ($dependency instanceof $param_class) {
1068
-            // then let's inject it into the incoming array of arguments at the correct location
1069
-            if (isset($argument_keys[$index])) {
1070
-                $arguments[$argument_keys[$index]] = $dependency;
1071
-            } else {
1072
-                $arguments[$index] = $dependency;
1073
-            }
1074
-        }
1075
-        return $arguments;
1076
-    }
1077
-
1078
-
1079
-
1080
-    /**
1081
-     * _set_cached_class
1082
-     * attempts to cache the instantiated class locally
1083
-     * in one of the following places, in the following order:
1084
-     *        $this->{class_abbreviation}   ie:    $this->CART
1085
-     *        $this->{$class_name}          ie:    $this->Some_Class
1086
-     *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1087
-     *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1088
-     *
1089
-     * @access protected
1090
-     * @param object $class_obj
1091
-     * @param string $class_name
1092
-     * @param string $class_prefix
1093
-     * @param bool   $from_db
1094
-     * @return void
1095
-     */
1096
-    protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false)
1097
-    {
1098
-        if (empty($class_obj)) {
1099
-            return;
1100
-        }
1101
-        // return newly instantiated class
1102
-        if (isset($this->_class_abbreviations[$class_name])) {
1103
-            $class_abbreviation = $this->_class_abbreviations[$class_name];
1104
-            $this->{$class_abbreviation} = $class_obj;
1105
-        } else if (property_exists($this, $class_name)) {
1106
-            $this->{$class_name} = $class_obj;
1107
-        } else if ($class_prefix == 'addon') {
1108
-            $this->addons->{$class_name} = $class_obj;
1109
-        } else if ( ! $from_db) {
1110
-            $this->LIB->{$class_name} = $class_obj;
1111
-        }
1112
-    }
1113
-
1114
-
1115
-
1116
-    /**
1117
-     * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1118
-     *
1119
-     * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1120
-     *                          in the EE_Dependency_Map::$_class_loaders array,
1121
-     *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1122
-     * @param array  $arguments
1123
-     * @return object
1124
-     */
1125
-    public static function factory($classname, $arguments = array())
1126
-    {
1127
-        $loader = self::instance()->_dependency_map->class_loader($classname);
1128
-        if ($loader instanceof Closure) {
1129
-            return $loader($arguments);
1130
-        } else if (method_exists(EE_Registry::instance(), $loader)) {
1131
-            return EE_Registry::instance()->{$loader}($classname, $arguments);
1132
-        }
1133
-        return null;
1134
-    }
1135
-
1136
-
1137
-
1138
-    /**
1139
-     * Gets the addon by its name/slug (not classname. For that, just
1140
-     * use the classname as the property name on EE_Config::instance()->addons)
1141
-     *
1142
-     * @param string $name
1143
-     * @return EE_Addon
1144
-     */
1145
-    public function get_addon_by_name($name)
1146
-    {
1147
-        foreach ($this->addons as $addon) {
1148
-            if ($addon->name() == $name) {
1149
-                return $addon;
1150
-            }
1151
-        }
1152
-        return null;
1153
-    }
1154
-
1155
-
1156
-
1157
-    /**
1158
-     * Gets an array of all the registered addons, where the keys are their names. (ie, what each returns for their name() function) They're already available on EE_Config::instance()->addons as properties, where each property's name is
1159
-     * the addon's classname. So if you just want to get the addon by classname, use EE_Config::instance()->addons->{classname}
1160
-     *
1161
-     * @return EE_Addon[] where the KEYS are the addon's name()
1162
-     */
1163
-    public function get_addons_by_name()
1164
-    {
1165
-        $addons = array();
1166
-        foreach ($this->addons as $addon) {
1167
-            $addons[$addon->name()] = $addon;
1168
-        }
1169
-        return $addons;
1170
-    }
1171
-
1172
-
1173
-
1174
-    /**
1175
-     * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1176
-     * a stale copy of it around
1177
-     *
1178
-     * @param string $model_name
1179
-     * @return \EEM_Base
1180
-     * @throws \EE_Error
1181
-     */
1182
-    public function reset_model($model_name)
1183
-    {
1184
-        $model_class_name = strpos($model_name, 'EEM_') !== 0 ? "EEM_{$model_name}" : $model_name;
1185
-        if ( ! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1186
-            return null;
1187
-        }
1188
-        //get that model reset it and make sure we nuke the old reference to it
1189
-        if ($this->LIB->{$model_class_name} instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) {
1190
-            $this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1191
-        } else {
1192
-            throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1193
-        }
1194
-        return $this->LIB->{$model_class_name};
1195
-    }
1196
-
1197
-
1198
-
1199
-    /**
1200
-     * Resets the registry.
1201
-     * The criteria for what gets reset is based on what can be shared between sites on the same request when switch_to_blog
1202
-     * is used in a multisite install.  Here is a list of things that are NOT reset.
1203
-     * - $_dependency_map
1204
-     * - $_class_abbreviations
1205
-     * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1206
-     * - $REQ:  Still on the same request so no need to change.
1207
-     * - $CAP: There is no site specific state in the EE_Capability class.
1208
-     * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only one Session
1209
-     *         can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1210
-     * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1211
-     *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1212
-     *             switch or on the restore.
1213
-     * - $modules
1214
-     * - $shortcodes
1215
-     * - $widgets
1216
-     *
1217
-     * @param boolean $hard             whether to reset data in the database too, or just refresh
1218
-     *                                  the Registry to its state at the beginning of the request
1219
-     * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1220
-     *                                  or just reset without re-instantiating (handy to set to FALSE if you're not sure if you CAN
1221
-     *                                  currently reinstantiate the singletons at the moment)
1222
-     * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so client
1223
-     *                                  code instead can just change the model context to a different blog id if necessary
1224
-     * @return EE_Registry
1225
-     */
1226
-    public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1227
-    {
1228
-        $instance = self::instance();
1229
-        EEH_Activation::reset();
1230
-        //properties that get reset
1231
-        $instance->_cache_on = true;
1232
-        $instance->CFG = EE_Config::reset($hard, $reinstantiate);
1233
-        $instance->CART = null;
1234
-        $instance->MRM = null;
1235
-        $instance->AssetsRegistry = new Registry();
1236
-        //messages reset
1237
-        EED_Messages::reset();
1238
-        if ($reset_models) {
1239
-            foreach (array_keys($instance->non_abstract_db_models) as $model_name) {
1240
-                $instance->reset_model($model_name);
1241
-            }
1242
-        }
1243
-        $instance->LIB = new stdClass();
1244
-        return $instance;
1245
-    }
1246
-
1247
-
1248
-
1249
-    /**
1250
-     * @override magic methods
1251
-     * @return void
1252
-     */
1253
-    final function __destruct()
1254
-    {
1255
-    }
1256
-
1257
-
1258
-
1259
-    /**
1260
-     * @param $a
1261
-     * @param $b
1262
-     */
1263
-    final function __call($a, $b)
1264
-    {
1265
-    }
1266
-
1267
-
1268
-
1269
-    /**
1270
-     * @param $a
1271
-     */
1272
-    final function __get($a)
1273
-    {
1274
-    }
1275
-
1276
-
1277
-
1278
-    /**
1279
-     * @param $a
1280
-     * @param $b
1281
-     */
1282
-    final function __set($a, $b)
1283
-    {
1284
-    }
1285
-
1286
-
1287
-
1288
-    /**
1289
-     * @param $a
1290
-     */
1291
-    final function __isset($a)
1292
-    {
1293
-    }
19
+	/**
20
+	 *    EE_Registry Object
21
+	 *
22
+	 * @var EE_Registry $_instance
23
+	 * @access    private
24
+	 */
25
+	private static $_instance = null;
26
+
27
+	/**
28
+	 * @var EE_Dependency_Map $_dependency_map
29
+	 * @access    protected
30
+	 */
31
+	protected $_dependency_map = null;
32
+
33
+	/**
34
+	 * @var array $_class_abbreviations
35
+	 * @access    protected
36
+	 */
37
+	protected $_class_abbreviations = array();
38
+
39
+	/**
40
+	 * @access public
41
+	 * @var \EventEspresso\core\services\commands\CommandBusInterface $BUS
42
+	 */
43
+	public $BUS;
44
+
45
+	/**
46
+	 *    EE_Cart Object
47
+	 *
48
+	 * @access    public
49
+	 * @var    EE_Cart $CART
50
+	 */
51
+	public $CART = null;
52
+
53
+	/**
54
+	 *    EE_Config Object
55
+	 *
56
+	 * @access    public
57
+	 * @var    EE_Config $CFG
58
+	 */
59
+	public $CFG = null;
60
+
61
+	/**
62
+	 * EE_Network_Config Object
63
+	 *
64
+	 * @access public
65
+	 * @var EE_Network_Config $NET_CFG
66
+	 */
67
+	public $NET_CFG = null;
68
+
69
+	/**
70
+	 *    StdClass object for storing library classes in
71
+	 *
72
+	 * @public LIB
73
+	 * @var StdClass $LIB
74
+	 */
75
+	public $LIB = null;
76
+
77
+	/**
78
+	 *    EE_Request_Handler Object
79
+	 *
80
+	 * @access    public
81
+	 * @var    EE_Request_Handler $REQ
82
+	 */
83
+	public $REQ = null;
84
+
85
+	/**
86
+	 *    EE_Session Object
87
+	 *
88
+	 * @access    public
89
+	 * @var    EE_Session $SSN
90
+	 */
91
+	public $SSN = null;
92
+
93
+	/**
94
+	 * holds the ee capabilities object.
95
+	 *
96
+	 * @since 4.5.0
97
+	 * @var EE_Capabilities
98
+	 */
99
+	public $CAP = null;
100
+
101
+	/**
102
+	 * holds the EE_Message_Resource_Manager object.
103
+	 *
104
+	 * @since 4.9.0
105
+	 * @var EE_Message_Resource_Manager
106
+	 */
107
+	public $MRM = null;
108
+
109
+
110
+	/**
111
+	 * Holds the Assets Registry instance
112
+	 * @var Registry
113
+	 */
114
+	public $AssetsRegistry = null;
115
+
116
+	/**
117
+	 *    $addons - StdClass object for holding addons which have registered themselves to work with EE core
118
+	 *
119
+	 * @access    public
120
+	 * @var    EE_Addon[]
121
+	 */
122
+	public $addons = null;
123
+
124
+	/**
125
+	 *    $models
126
+	 * @access    public
127
+	 * @var    EEM_Base[] $models keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
128
+	 */
129
+	public $models = array();
130
+
131
+	/**
132
+	 *    $modules
133
+	 * @access    public
134
+	 * @var    EED_Module[] $modules
135
+	 */
136
+	public $modules = null;
137
+
138
+	/**
139
+	 *    $shortcodes
140
+	 * @access    public
141
+	 * @var    EES_Shortcode[] $shortcodes
142
+	 */
143
+	public $shortcodes = null;
144
+
145
+	/**
146
+	 *    $widgets
147
+	 * @access    public
148
+	 * @var    WP_Widget[] $widgets
149
+	 */
150
+	public $widgets = null;
151
+
152
+	/**
153
+	 * $non_abstract_db_models
154
+	 * @access public
155
+	 * @var array this is an array of all implemented model names (i.e. not the parent abstract models, or models
156
+	 * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
157
+	 * Keys are model "short names" (eg "Event") as used in model relations, and values are
158
+	 * classnames (eg "EEM_Event")
159
+	 */
160
+	public $non_abstract_db_models = array();
161
+
162
+
163
+	/**
164
+	 *    $i18n_js_strings - internationalization for JS strings
165
+	 *    usage:   EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' );
166
+	 *    in js file:  var translatedString = eei18n.string_key;
167
+	 *
168
+	 * @access    public
169
+	 * @var    array
170
+	 */
171
+	public static $i18n_js_strings = array();
172
+
173
+
174
+	/**
175
+	 *    $main_file - path to espresso.php
176
+	 *
177
+	 * @access    public
178
+	 * @var    array
179
+	 */
180
+	public $main_file;
181
+
182
+	/**
183
+	 * array of ReflectionClass objects where the key is the class name
184
+	 *
185
+	 * @access    public
186
+	 * @var ReflectionClass[]
187
+	 */
188
+	public $_reflectors;
189
+
190
+	/**
191
+	 * boolean flag to indicate whether or not to load/save dependencies from/to the cache
192
+	 *
193
+	 * @access    protected
194
+	 * @var boolean $_cache_on
195
+	 */
196
+	protected $_cache_on = true;
197
+
198
+
199
+
200
+	/**
201
+	 * @singleton method used to instantiate class object
202
+	 * @access    public
203
+	 * @param  \EE_Dependency_Map $dependency_map
204
+	 * @return \EE_Registry instance
205
+	 */
206
+	public static function instance(\EE_Dependency_Map $dependency_map = null)
207
+	{
208
+		// check if class object is instantiated
209
+		if ( ! self::$_instance instanceof EE_Registry) {
210
+			self::$_instance = new EE_Registry($dependency_map);
211
+		}
212
+		return self::$_instance;
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 *protected constructor to prevent direct creation
219
+	 *
220
+	 * @Constructor
221
+	 * @access protected
222
+	 * @param  \EE_Dependency_Map $dependency_map
223
+	 * @return \EE_Registry
224
+	 */
225
+	protected function __construct(\EE_Dependency_Map $dependency_map)
226
+	{
227
+		$this->_dependency_map = $dependency_map;
228
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
229
+	}
230
+
231
+
232
+
233
+	/**
234
+	 * initialize
235
+	 */
236
+	public function initialize()
237
+	{
238
+		$this->_class_abbreviations = apply_filters(
239
+			'FHEE__EE_Registry____construct___class_abbreviations',
240
+			array(
241
+				'EE_Config'                                       => 'CFG',
242
+				'EE_Session'                                      => 'SSN',
243
+				'EE_Capabilities'                                 => 'CAP',
244
+				'EE_Cart'                                         => 'CART',
245
+				'EE_Network_Config'                               => 'NET_CFG',
246
+				'EE_Request_Handler'                              => 'REQ',
247
+				'EE_Message_Resource_Manager'                     => 'MRM',
248
+				'EventEspresso\core\services\commands\CommandBus' => 'BUS',
249
+			)
250
+		);
251
+		// class library
252
+		$this->LIB = new stdClass();
253
+		$this->addons = new stdClass();
254
+		$this->modules = new stdClass();
255
+		$this->shortcodes = new stdClass();
256
+		$this->widgets = new stdClass();
257
+		$this->load_core('Base', array(), true);
258
+		// add our request and response objects to the cache
259
+		$request_loader = $this->_dependency_map->class_loader('EE_Request');
260
+		$this->_set_cached_class(
261
+			$request_loader(),
262
+			'EE_Request'
263
+		);
264
+		$response_loader = $this->_dependency_map->class_loader('EE_Response');
265
+		$this->_set_cached_class(
266
+			$response_loader(),
267
+			'EE_Response'
268
+		);
269
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
270
+	}
271
+
272
+
273
+
274
+	/**
275
+	 *    init
276
+	 *
277
+	 * @access    public
278
+	 * @return    void
279
+	 */
280
+	public function init()
281
+	{
282
+		$this->AssetsRegistry = new Registry();
283
+		// Get current page protocol
284
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
285
+		// Output admin-ajax.php URL with same protocol as current page
286
+		self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
287
+		self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
288
+	}
289
+
290
+
291
+
292
+	/**
293
+	 * localize_i18n_js_strings
294
+	 *
295
+	 * @return string
296
+	 */
297
+	public static function localize_i18n_js_strings()
298
+	{
299
+		$i18n_js_strings = (array)EE_Registry::$i18n_js_strings;
300
+		foreach ($i18n_js_strings as $key => $value) {
301
+			if (is_scalar($value)) {
302
+				$i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
303
+			}
304
+		}
305
+		return "/* <![CDATA[ */ var eei18n = " . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
306
+	}
307
+
308
+
309
+
310
+	/**
311
+	 * @param mixed string | EED_Module $module
312
+	 */
313
+	public function add_module($module)
314
+	{
315
+		if ($module instanceof EED_Module) {
316
+			$module_class = get_class($module);
317
+			$this->modules->{$module_class} = $module;
318
+		} else {
319
+			if ( ! class_exists('EE_Module_Request_Router')) {
320
+				$this->load_core('Module_Request_Router');
321
+			}
322
+			$this->modules->{$module} = EE_Module_Request_Router::module_factory($module);
323
+		}
324
+	}
325
+
326
+
327
+
328
+	/**
329
+	 * @param string $module_name
330
+	 * @return mixed EED_Module | NULL
331
+	 */
332
+	public function get_module($module_name = '')
333
+	{
334
+		return isset($this->modules->{$module_name}) ? $this->modules->{$module_name} : null;
335
+	}
336
+
337
+
338
+
339
+	/**
340
+	 *    loads core classes - must be singletons
341
+	 *
342
+	 * @access    public
343
+	 * @param string $class_name - simple class name ie: session
344
+	 * @param mixed  $arguments
345
+	 * @param bool   $load_only
346
+	 * @return mixed
347
+	 */
348
+	public function load_core($class_name, $arguments = array(), $load_only = false)
349
+	{
350
+		$core_paths = apply_filters(
351
+			'FHEE__EE_Registry__load_core__core_paths',
352
+			array(
353
+				EE_CORE,
354
+				EE_ADMIN,
355
+				EE_CPTS,
356
+				EE_CORE . 'data_migration_scripts' . DS,
357
+				EE_CORE . 'request_stack' . DS,
358
+				EE_CORE . 'middleware' . DS,
359
+			)
360
+		);
361
+		// retrieve instantiated class
362
+		return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only);
363
+	}
364
+
365
+
366
+
367
+	/**
368
+	 *    loads service classes
369
+	 *
370
+	 * @access    public
371
+	 * @param string $class_name - simple class name ie: session
372
+	 * @param mixed  $arguments
373
+	 * @param bool   $load_only
374
+	 * @return mixed
375
+	 */
376
+	public function load_service($class_name, $arguments = array(), $load_only = false)
377
+	{
378
+		$service_paths = apply_filters(
379
+			'FHEE__EE_Registry__load_service__service_paths',
380
+			array(
381
+				EE_CORE . 'services' . DS,
382
+			)
383
+		);
384
+		// retrieve instantiated class
385
+		return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only);
386
+	}
387
+
388
+
389
+
390
+	/**
391
+	 *    loads data_migration_scripts
392
+	 *
393
+	 * @access    public
394
+	 * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
395
+	 * @param mixed  $arguments
396
+	 * @return EE_Data_Migration_Script_Base|mixed
397
+	 */
398
+	public function load_dms($class_name, $arguments = array())
399
+	{
400
+		// retrieve instantiated class
401
+		return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false);
402
+	}
403
+
404
+
405
+
406
+	/**
407
+	 *    loads object creating classes - must be singletons
408
+	 *
409
+	 * @param string $class_name - simple class name ie: attendee
410
+	 * @param mixed  $arguments  - an array of arguments to pass to the class
411
+	 * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to instantiate
412
+	 * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then set this to FALSE (ie. when instantiating model objects from client in a loop)
413
+	 * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate (default)
414
+	 * @return EE_Base_Class | bool
415
+	 */
416
+	public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
417
+	{
418
+		$paths = apply_filters('FHEE__EE_Registry__load_class__paths', array(
419
+			EE_CORE,
420
+			EE_CLASSES,
421
+			EE_BUSINESS,
422
+		));
423
+		// retrieve instantiated class
424
+		return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only);
425
+	}
426
+
427
+
428
+
429
+	/**
430
+	 *    loads helper classes - must be singletons
431
+	 *
432
+	 * @param string $class_name - simple class name ie: price
433
+	 * @param mixed  $arguments
434
+	 * @param bool   $load_only
435
+	 * @return EEH_Base | bool
436
+	 */
437
+	public function load_helper($class_name, $arguments = array(), $load_only = true)
438
+	{
439
+		// todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
440
+		$helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
441
+		// retrieve instantiated class
442
+		return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only);
443
+	}
444
+
445
+
446
+
447
+	/**
448
+	 *    loads core classes - must be singletons
449
+	 *
450
+	 * @access    public
451
+	 * @param string $class_name - simple class name ie: session
452
+	 * @param mixed  $arguments
453
+	 * @param bool   $load_only
454
+	 * @param bool   $cache      whether to cache the object or not.
455
+	 * @return mixed
456
+	 */
457
+	public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
458
+	{
459
+		$paths = array(
460
+			EE_LIBRARIES,
461
+			EE_LIBRARIES . 'messages' . DS,
462
+			EE_LIBRARIES . 'shortcodes' . DS,
463
+			EE_LIBRARIES . 'qtips' . DS,
464
+			EE_LIBRARIES . 'payment_methods' . DS,
465
+		);
466
+		// retrieve instantiated class
467
+		return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only);
468
+	}
469
+
470
+
471
+
472
+	/**
473
+	 *    loads model classes - must be singletons
474
+	 *
475
+	 * @param string $class_name - simple class name ie: price
476
+	 * @param mixed  $arguments
477
+	 * @param bool   $load_only
478
+	 * @return EEM_Base | bool
479
+	 */
480
+	public function load_model($class_name, $arguments = array(), $load_only = false)
481
+	{
482
+		$paths = apply_filters('FHEE__EE_Registry__load_model__paths', array(
483
+			EE_MODELS,
484
+			EE_CORE,
485
+		));
486
+		// retrieve instantiated class
487
+		return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only);
488
+	}
489
+
490
+
491
+
492
+	/**
493
+	 *    loads model classes - must be singletons
494
+	 *
495
+	 * @param string $class_name - simple class name ie: price
496
+	 * @param mixed  $arguments
497
+	 * @param bool   $load_only
498
+	 * @return mixed | bool
499
+	 */
500
+	public function load_model_class($class_name, $arguments = array(), $load_only = true)
501
+	{
502
+		$paths = array(
503
+			EE_MODELS . 'fields' . DS,
504
+			EE_MODELS . 'helpers' . DS,
505
+			EE_MODELS . 'relations' . DS,
506
+			EE_MODELS . 'strategies' . DS,
507
+		);
508
+		// retrieve instantiated class
509
+		return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only);
510
+	}
511
+
512
+
513
+
514
+	/**
515
+	 * Determines if $model_name is the name of an actual EE model.
516
+	 *
517
+	 * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
518
+	 * @return boolean
519
+	 */
520
+	public function is_model_name($model_name)
521
+	{
522
+		return isset($this->models[$model_name]) ? true : false;
523
+	}
524
+
525
+
526
+
527
+	/**
528
+	 *    generic class loader
529
+	 *
530
+	 * @param string $path_to_file - directory path to file location, not including filename
531
+	 * @param string $file_name    - file name  ie:  my_file.php, including extension
532
+	 * @param string $type         - file type - core? class? helper? model?
533
+	 * @param mixed  $arguments
534
+	 * @param bool   $load_only
535
+	 * @return mixed
536
+	 */
537
+	public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
538
+	{
539
+		// retrieve instantiated class
540
+		return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only);
541
+	}
542
+
543
+
544
+
545
+	/**
546
+	 *    load_addon
547
+	 *
548
+	 * @param string $path_to_file - directory path to file location, not including filename
549
+	 * @param string $class_name   - full class name  ie:  My_Class
550
+	 * @param string $type         - file type - core? class? helper? model?
551
+	 * @param mixed  $arguments
552
+	 * @param bool   $load_only
553
+	 * @return EE_Addon
554
+	 */
555
+	public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
556
+	{
557
+		// retrieve instantiated class
558
+		return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only);
559
+	}
560
+
561
+
562
+
563
+	/**
564
+	 * instantiates, caches, and automatically resolves dependencies
565
+	 * for classes that use a Fully Qualified Class Name.
566
+	 * if the class is not capable of being loaded using PSR-4 autoloading,
567
+	 * then you need to use one of the existing load_*() methods
568
+	 * which can resolve the classname and filepath from the passed arguments
569
+	 *
570
+	 * @param bool|string $class_name   Fully Qualified Class Name
571
+	 * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
572
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
573
+	 * @param bool        $from_db      some classes are instantiated from the db
574
+	 *                                  and thus call a different method to instantiate
575
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
576
+	 * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
577
+	 * @return mixed                    null = failure to load or instantiate class object.
578
+	 *                                  object = class loaded and instantiated successfully.
579
+	 *                                  bool = fail or success when $load_only is true
580
+	 */
581
+	public function create(
582
+		$class_name = false,
583
+		$arguments = array(),
584
+		$cache = false,
585
+		$from_db = false,
586
+		$load_only = false,
587
+		$addon = false
588
+	) {
589
+		$class_name = $this->_dependency_map->get_alias($class_name);
590
+		if ( ! class_exists($class_name)) {
591
+			// maybe the class is registered with a preceding \
592
+			$class_name = strpos($class_name, '\\') !== 0 ? '\\' . $class_name : $class_name;
593
+			// still doesn't exist ?
594
+			if ( ! class_exists($class_name)) {
595
+				return null;
596
+			}
597
+		}
598
+		// if we're only loading the class and it already exists, then let's just return true immediately
599
+		if ($load_only) {
600
+			return true;
601
+		}
602
+		$addon = $addon ? 'addon' : '';
603
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
604
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
605
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
606
+		if ($this->_cache_on && $cache && ! $load_only) {
607
+			// return object if it's already cached
608
+			$cached_class = $this->_get_cached_class($class_name, $addon);
609
+			if ($cached_class !== null) {
610
+				return $cached_class;
611
+			}
612
+		}
613
+		// instantiate the requested object
614
+		$class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
615
+		if ($this->_cache_on && $cache) {
616
+			// save it for later... kinda like gum  { : $
617
+			$this->_set_cached_class($class_obj, $class_name, $addon, $from_db);
618
+		}
619
+		$this->_cache_on = true;
620
+		return $class_obj;
621
+	}
622
+
623
+
624
+
625
+	/**
626
+	 * instantiates, caches, and injects dependencies for classes
627
+	 *
628
+	 * @param array       $file_paths   an array of paths to folders to look in
629
+	 * @param string      $class_prefix EE  or EEM or... ???
630
+	 * @param bool|string $class_name   $class name
631
+	 * @param string      $type         file type - core? class? helper? model?
632
+	 * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
633
+	 * @param bool        $from_db      some classes are instantiated from the db
634
+	 *                                  and thus call a different method to instantiate
635
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
636
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
637
+	 * @return null|object|bool         null = failure to load or instantiate class object.
638
+	 *                                  object = class loaded and instantiated successfully.
639
+	 *                                  bool = fail or success when $load_only is true
640
+	 */
641
+	protected function _load(
642
+		$file_paths = array(),
643
+		$class_prefix = 'EE_',
644
+		$class_name = false,
645
+		$type = 'class',
646
+		$arguments = array(),
647
+		$from_db = false,
648
+		$cache = true,
649
+		$load_only = false
650
+	) {
651
+		// strip php file extension
652
+		$class_name = str_replace('.php', '', trim($class_name));
653
+		// does the class have a prefix ?
654
+		if ( ! empty($class_prefix) && $class_prefix != 'addon') {
655
+			// make sure $class_prefix is uppercase
656
+			$class_prefix = strtoupper(trim($class_prefix));
657
+			// add class prefix ONCE!!!
658
+			$class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
659
+		}
660
+		$class_name = $this->_dependency_map->get_alias($class_name);
661
+		$class_exists = class_exists($class_name);
662
+		// if we're only loading the class and it already exists, then let's just return true immediately
663
+		if ($load_only && $class_exists) {
664
+			return true;
665
+		}
666
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
667
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
668
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
669
+		if ($this->_cache_on && $cache && ! $load_only) {
670
+			// return object if it's already cached
671
+			$cached_class = $this->_get_cached_class($class_name, $class_prefix);
672
+			if ($cached_class !== null) {
673
+				return $cached_class;
674
+			}
675
+		}
676
+		// if the class doesn't already exist.. then we need to try and find the file and load it
677
+		if ( ! $class_exists) {
678
+			// get full path to file
679
+			$path = $this->_resolve_path($class_name, $type, $file_paths);
680
+			// load the file
681
+			$loaded = $this->_require_file($path, $class_name, $type, $file_paths);
682
+			// if loading failed, or we are only loading a file but NOT instantiating an object
683
+			if ( ! $loaded || $load_only) {
684
+				// return boolean if only loading, or null if an object was expected
685
+				return $load_only ? $loaded : null;
686
+			}
687
+		}
688
+		// instantiate the requested object
689
+		$class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
690
+		if ($this->_cache_on && $cache) {
691
+			// save it for later... kinda like gum  { : $
692
+			$this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
693
+		}
694
+		$this->_cache_on = true;
695
+		return $class_obj;
696
+	}
697
+
698
+
699
+
700
+	/**
701
+	 * _get_cached_class
702
+	 * attempts to find a cached version of the requested class
703
+	 * by looking in the following places:
704
+	 *        $this->{$class_abbreviation}            ie:    $this->CART
705
+	 *        $this->{$class_name}                        ie:    $this->Some_Class
706
+	 *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
707
+	 *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
708
+	 *
709
+	 * @access protected
710
+	 * @param string $class_name
711
+	 * @param string $class_prefix
712
+	 * @return mixed
713
+	 */
714
+	protected function _get_cached_class($class_name, $class_prefix = '')
715
+	{
716
+		if (isset($this->_class_abbreviations[$class_name])) {
717
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
718
+		} else {
719
+			// have to specify something, but not anything that will conflict
720
+			$class_abbreviation = 'FANCY_BATMAN_PANTS';
721
+		}
722
+		// check if class has already been loaded, and return it if it has been
723
+		if (isset($this->{$class_abbreviation}) && ! is_null($this->{$class_abbreviation})) {
724
+			return $this->{$class_abbreviation};
725
+		} else if (isset ($this->{$class_name})) {
726
+			return $this->{$class_name};
727
+		} else if (isset ($this->LIB->{$class_name})) {
728
+			return $this->LIB->{$class_name};
729
+		} else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name})) {
730
+			return $this->addons->{$class_name};
731
+		}
732
+		return null;
733
+	}
734
+
735
+
736
+
737
+	/**
738
+	 * _resolve_path
739
+	 * attempts to find a full valid filepath for the requested class.
740
+	 * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
741
+	 * then returns that path if the target file has been found and is readable
742
+	 *
743
+	 * @access protected
744
+	 * @param string $class_name
745
+	 * @param string $type
746
+	 * @param array  $file_paths
747
+	 * @return string | bool
748
+	 */
749
+	protected function _resolve_path($class_name, $type = '', $file_paths = array())
750
+	{
751
+		// make sure $file_paths is an array
752
+		$file_paths = is_array($file_paths) ? $file_paths : array($file_paths);
753
+		// cycle thru paths
754
+		foreach ($file_paths as $key => $file_path) {
755
+			// convert all separators to proper DS, if no filepath, then use EE_CLASSES
756
+			$file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES;
757
+			// prep file type
758
+			$type = ! empty($type) ? trim($type, '.') . '.' : '';
759
+			// build full file path
760
+			$file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
761
+			//does the file exist and can be read ?
762
+			if (is_readable($file_paths[$key])) {
763
+				return $file_paths[$key];
764
+			}
765
+		}
766
+		return false;
767
+	}
768
+
769
+
770
+
771
+	/**
772
+	 * _require_file
773
+	 * basically just performs a require_once()
774
+	 * but with some error handling
775
+	 *
776
+	 * @access protected
777
+	 * @param  string $path
778
+	 * @param  string $class_name
779
+	 * @param  string $type
780
+	 * @param  array  $file_paths
781
+	 * @return boolean
782
+	 * @throws \EE_Error
783
+	 */
784
+	protected function _require_file($path, $class_name, $type = '', $file_paths = array())
785
+	{
786
+		// don't give up! you gotta...
787
+		try {
788
+			//does the file exist and can it be read ?
789
+			if ( ! $path) {
790
+				// so sorry, can't find the file
791
+				throw new EE_Error (
792
+					sprintf(
793
+						__('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'),
794
+						trim($type, '.'),
795
+						$class_name,
796
+						'<br />' . implode(',<br />', $file_paths)
797
+					)
798
+				);
799
+			}
800
+			// get the file
801
+			require_once($path);
802
+			// if the class isn't already declared somewhere
803
+			if (class_exists($class_name, false) === false) {
804
+				// so sorry, not a class
805
+				throw new EE_Error(
806
+					sprintf(
807
+						__('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
808
+						$type,
809
+						$path,
810
+						$class_name
811
+					)
812
+				);
813
+			}
814
+		} catch (EE_Error $e) {
815
+			$e->get_error();
816
+			return false;
817
+		}
818
+		return true;
819
+	}
820
+
821
+
822
+
823
+	/**
824
+	 * _create_object
825
+	 * Attempts to instantiate the requested class via any of the
826
+	 * commonly used instantiation methods employed throughout EE.
827
+	 * The priority for instantiation is as follows:
828
+	 *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
829
+	 *        - model objects via their 'new_instance_from_db' method
830
+	 *        - model objects via their 'new_instance' method
831
+	 *        - "singleton" classes" via their 'instance' method
832
+	 *    - standard instantiable classes via their __constructor
833
+	 * Prior to instantiation, if the classname exists in the dependency_map,
834
+	 * then the constructor for the requested class will be examined to determine
835
+	 * if any dependencies exist, and if they can be injected.
836
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
837
+	 *
838
+	 * @access protected
839
+	 * @param string $class_name
840
+	 * @param array  $arguments
841
+	 * @param string $type
842
+	 * @param bool   $from_db
843
+	 * @return null | object
844
+	 * @throws \EE_Error
845
+	 */
846
+	protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
847
+	{
848
+		$class_obj = null;
849
+		$instantiation_mode = '0) none';
850
+		// don't give up! you gotta...
851
+		try {
852
+			// create reflection
853
+			$reflector = $this->get_ReflectionClass($class_name);
854
+			// make sure arguments are an array
855
+			$arguments = is_array($arguments) ? $arguments : array($arguments);
856
+			// and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
857
+			// else wrap it in an additional array so that it doesn't get split into multiple parameters
858
+			$arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
859
+				? $arguments
860
+				: array($arguments);
861
+			// attempt to inject dependencies ?
862
+			if ($this->_dependency_map->has($class_name)) {
863
+				$arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
864
+			}
865
+			// instantiate the class if possible
866
+			if ($reflector->isAbstract()) {
867
+				// nothing to instantiate, loading file was enough
868
+				// does not throw an exception so $instantiation_mode is unused
869
+				// $instantiation_mode = "1) no constructor abstract class";
870
+				$class_obj = true;
871
+			} else if ($reflector->getConstructor() === null && $reflector->isInstantiable() && empty($arguments)) {
872
+				// no constructor = static methods only... nothing to instantiate, loading file was enough
873
+				$instantiation_mode = "2) no constructor but instantiable";
874
+				$class_obj = $reflector->newInstance();
875
+			} else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
876
+				$instantiation_mode = "3) new_instance_from_db()";
877
+				$class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
878
+			} else if (method_exists($class_name, 'new_instance')) {
879
+				$instantiation_mode = "4) new_instance()";
880
+				$class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
881
+			} else if (method_exists($class_name, 'instance')) {
882
+				$instantiation_mode = "5) instance()";
883
+				$class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
884
+			} else if ($reflector->isInstantiable()) {
885
+				$instantiation_mode = "6) constructor";
886
+				$class_obj = $reflector->newInstanceArgs($arguments);
887
+			} else {
888
+				// heh ? something's not right !
889
+				throw new EE_Error(
890
+					sprintf(
891
+						__('The %s file %s could not be instantiated.', 'event_espresso'),
892
+						$type,
893
+						$class_name
894
+					)
895
+				);
896
+			}
897
+		} catch (Exception $e) {
898
+			if ( ! $e instanceof EE_Error) {
899
+				$e = new EE_Error(
900
+					sprintf(
901
+						__('The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso'),
902
+						$class_name,
903
+						'<br />',
904
+						$e->getMessage(),
905
+						$instantiation_mode
906
+					)
907
+				);
908
+			}
909
+			$e->get_error();
910
+		}
911
+		return $class_obj;
912
+	}
913
+
914
+
915
+
916
+	/**
917
+	 * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
918
+	 * @param array $array
919
+	 * @return bool
920
+	 */
921
+	protected function _array_is_numerically_and_sequentially_indexed(array $array)
922
+	{
923
+		return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
924
+	}
925
+
926
+
927
+
928
+	/**
929
+	 * getReflectionClass
930
+	 * checks if a ReflectionClass object has already been generated for a class
931
+	 * and returns that instead of creating a new one
932
+	 *
933
+	 * @access public
934
+	 * @param string $class_name
935
+	 * @return ReflectionClass
936
+	 */
937
+	public function get_ReflectionClass($class_name)
938
+	{
939
+		if (
940
+			! isset($this->_reflectors[$class_name])
941
+			|| ! $this->_reflectors[$class_name] instanceof ReflectionClass
942
+		) {
943
+			$this->_reflectors[$class_name] = new ReflectionClass($class_name);
944
+		}
945
+		return $this->_reflectors[$class_name];
946
+	}
947
+
948
+
949
+
950
+	/**
951
+	 * _resolve_dependencies
952
+	 * examines the constructor for the requested class to determine
953
+	 * if any dependencies exist, and if they can be injected.
954
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
955
+	 * PLZ NOTE: this is achieved by type hinting the constructor params
956
+	 * For example:
957
+	 *        if attempting to load a class "Foo" with the following constructor:
958
+	 *        __construct( Bar $bar_class, Fighter $grohl_class )
959
+	 *        then $bar_class and $grohl_class will be added to the $arguments array,
960
+	 *        but only IF they are NOT already present in the incoming arguments array,
961
+	 *        and the correct classes can be loaded
962
+	 *
963
+	 * @access protected
964
+	 * @param ReflectionClass $reflector
965
+	 * @param string          $class_name
966
+	 * @param array           $arguments
967
+	 * @return array
968
+	 * @throws \ReflectionException
969
+	 */
970
+	protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array())
971
+	{
972
+		// let's examine the constructor
973
+		$constructor = $reflector->getConstructor();
974
+		// whu? huh? nothing?
975
+		if ( ! $constructor) {
976
+			return $arguments;
977
+		}
978
+		// get constructor parameters
979
+		$params = $constructor->getParameters();
980
+		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
981
+		$argument_keys = array_keys($arguments);
982
+		// now loop thru all of the constructors expected parameters
983
+		foreach ($params as $index => $param) {
984
+			// is this a dependency for a specific class ?
985
+			$param_class = $param->getClass() ? $param->getClass()->name : null;
986
+			if (
987
+				// param is not even a class
988
+				empty($param_class)
989
+				// and something already exists in the incoming arguments for this param
990
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
991
+			) {
992
+				// so let's skip this argument and move on to the next
993
+				continue;
994
+			} else if (
995
+				// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
996
+				! empty($param_class)
997
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
998
+				&& $arguments[$argument_keys[$index]] instanceof $param_class
999
+			) {
1000
+				// skip this argument and move on to the next
1001
+				continue;
1002
+			} else if (
1003
+				// parameter is type hinted as a class, and should be injected
1004
+				! empty($param_class)
1005
+				&& $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1006
+			) {
1007
+				$arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index);
1008
+			} else {
1009
+				try {
1010
+					$arguments[$index] = $param->getDefaultValue();
1011
+				} catch (ReflectionException $e) {
1012
+					throw new ReflectionException(
1013
+						sprintf(
1014
+							__('%1$s for parameter "$%2$s"', 'event_espresso'),
1015
+							$e->getMessage(),
1016
+							$param->getName()
1017
+						)
1018
+					);
1019
+				}
1020
+			}
1021
+		}
1022
+		return $arguments;
1023
+	}
1024
+
1025
+
1026
+
1027
+	/**
1028
+	 * @access protected
1029
+	 * @param string $class_name
1030
+	 * @param string $param_class
1031
+	 * @param array  $arguments
1032
+	 * @param mixed  $index
1033
+	 * @return array
1034
+	 */
1035
+	protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1036
+	{
1037
+		$dependency = null;
1038
+		// should dependency be loaded from cache ?
1039
+		$cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class)
1040
+					!== EE_Dependency_Map::load_new_object
1041
+			? true
1042
+			: false;
1043
+		// we might have a dependency...
1044
+		// let's MAYBE try and find it in our cache if that's what's been requested
1045
+		$cached_class = $cache_on ? $this->_get_cached_class($param_class) : null;
1046
+		// and grab it if it exists
1047
+		if ($cached_class instanceof $param_class) {
1048
+			$dependency = $cached_class;
1049
+		} else if ($param_class != $class_name) {
1050
+			// obtain the loader method from the dependency map
1051
+			$loader = $this->_dependency_map->class_loader($param_class);
1052
+			// is loader a custom closure ?
1053
+			if ($loader instanceof Closure) {
1054
+				$dependency = $loader();
1055
+			} else {
1056
+				// set the cache on property for the recursive loading call
1057
+				$this->_cache_on = $cache_on;
1058
+				// if not, then let's try and load it via the registry
1059
+				if (method_exists($this, $loader)) {
1060
+					$dependency = $this->{$loader}($param_class);
1061
+				} else {
1062
+					$dependency = $this->create($param_class, array(), $cache_on);
1063
+				}
1064
+			}
1065
+		}
1066
+		// did we successfully find the correct dependency ?
1067
+		if ($dependency instanceof $param_class) {
1068
+			// then let's inject it into the incoming array of arguments at the correct location
1069
+			if (isset($argument_keys[$index])) {
1070
+				$arguments[$argument_keys[$index]] = $dependency;
1071
+			} else {
1072
+				$arguments[$index] = $dependency;
1073
+			}
1074
+		}
1075
+		return $arguments;
1076
+	}
1077
+
1078
+
1079
+
1080
+	/**
1081
+	 * _set_cached_class
1082
+	 * attempts to cache the instantiated class locally
1083
+	 * in one of the following places, in the following order:
1084
+	 *        $this->{class_abbreviation}   ie:    $this->CART
1085
+	 *        $this->{$class_name}          ie:    $this->Some_Class
1086
+	 *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1087
+	 *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1088
+	 *
1089
+	 * @access protected
1090
+	 * @param object $class_obj
1091
+	 * @param string $class_name
1092
+	 * @param string $class_prefix
1093
+	 * @param bool   $from_db
1094
+	 * @return void
1095
+	 */
1096
+	protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false)
1097
+	{
1098
+		if (empty($class_obj)) {
1099
+			return;
1100
+		}
1101
+		// return newly instantiated class
1102
+		if (isset($this->_class_abbreviations[$class_name])) {
1103
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
1104
+			$this->{$class_abbreviation} = $class_obj;
1105
+		} else if (property_exists($this, $class_name)) {
1106
+			$this->{$class_name} = $class_obj;
1107
+		} else if ($class_prefix == 'addon') {
1108
+			$this->addons->{$class_name} = $class_obj;
1109
+		} else if ( ! $from_db) {
1110
+			$this->LIB->{$class_name} = $class_obj;
1111
+		}
1112
+	}
1113
+
1114
+
1115
+
1116
+	/**
1117
+	 * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1118
+	 *
1119
+	 * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1120
+	 *                          in the EE_Dependency_Map::$_class_loaders array,
1121
+	 *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1122
+	 * @param array  $arguments
1123
+	 * @return object
1124
+	 */
1125
+	public static function factory($classname, $arguments = array())
1126
+	{
1127
+		$loader = self::instance()->_dependency_map->class_loader($classname);
1128
+		if ($loader instanceof Closure) {
1129
+			return $loader($arguments);
1130
+		} else if (method_exists(EE_Registry::instance(), $loader)) {
1131
+			return EE_Registry::instance()->{$loader}($classname, $arguments);
1132
+		}
1133
+		return null;
1134
+	}
1135
+
1136
+
1137
+
1138
+	/**
1139
+	 * Gets the addon by its name/slug (not classname. For that, just
1140
+	 * use the classname as the property name on EE_Config::instance()->addons)
1141
+	 *
1142
+	 * @param string $name
1143
+	 * @return EE_Addon
1144
+	 */
1145
+	public function get_addon_by_name($name)
1146
+	{
1147
+		foreach ($this->addons as $addon) {
1148
+			if ($addon->name() == $name) {
1149
+				return $addon;
1150
+			}
1151
+		}
1152
+		return null;
1153
+	}
1154
+
1155
+
1156
+
1157
+	/**
1158
+	 * Gets an array of all the registered addons, where the keys are their names. (ie, what each returns for their name() function) They're already available on EE_Config::instance()->addons as properties, where each property's name is
1159
+	 * the addon's classname. So if you just want to get the addon by classname, use EE_Config::instance()->addons->{classname}
1160
+	 *
1161
+	 * @return EE_Addon[] where the KEYS are the addon's name()
1162
+	 */
1163
+	public function get_addons_by_name()
1164
+	{
1165
+		$addons = array();
1166
+		foreach ($this->addons as $addon) {
1167
+			$addons[$addon->name()] = $addon;
1168
+		}
1169
+		return $addons;
1170
+	}
1171
+
1172
+
1173
+
1174
+	/**
1175
+	 * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1176
+	 * a stale copy of it around
1177
+	 *
1178
+	 * @param string $model_name
1179
+	 * @return \EEM_Base
1180
+	 * @throws \EE_Error
1181
+	 */
1182
+	public function reset_model($model_name)
1183
+	{
1184
+		$model_class_name = strpos($model_name, 'EEM_') !== 0 ? "EEM_{$model_name}" : $model_name;
1185
+		if ( ! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1186
+			return null;
1187
+		}
1188
+		//get that model reset it and make sure we nuke the old reference to it
1189
+		if ($this->LIB->{$model_class_name} instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) {
1190
+			$this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1191
+		} else {
1192
+			throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1193
+		}
1194
+		return $this->LIB->{$model_class_name};
1195
+	}
1196
+
1197
+
1198
+
1199
+	/**
1200
+	 * Resets the registry.
1201
+	 * The criteria for what gets reset is based on what can be shared between sites on the same request when switch_to_blog
1202
+	 * is used in a multisite install.  Here is a list of things that are NOT reset.
1203
+	 * - $_dependency_map
1204
+	 * - $_class_abbreviations
1205
+	 * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1206
+	 * - $REQ:  Still on the same request so no need to change.
1207
+	 * - $CAP: There is no site specific state in the EE_Capability class.
1208
+	 * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only one Session
1209
+	 *         can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1210
+	 * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1211
+	 *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1212
+	 *             switch or on the restore.
1213
+	 * - $modules
1214
+	 * - $shortcodes
1215
+	 * - $widgets
1216
+	 *
1217
+	 * @param boolean $hard             whether to reset data in the database too, or just refresh
1218
+	 *                                  the Registry to its state at the beginning of the request
1219
+	 * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1220
+	 *                                  or just reset without re-instantiating (handy to set to FALSE if you're not sure if you CAN
1221
+	 *                                  currently reinstantiate the singletons at the moment)
1222
+	 * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so client
1223
+	 *                                  code instead can just change the model context to a different blog id if necessary
1224
+	 * @return EE_Registry
1225
+	 */
1226
+	public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1227
+	{
1228
+		$instance = self::instance();
1229
+		EEH_Activation::reset();
1230
+		//properties that get reset
1231
+		$instance->_cache_on = true;
1232
+		$instance->CFG = EE_Config::reset($hard, $reinstantiate);
1233
+		$instance->CART = null;
1234
+		$instance->MRM = null;
1235
+		$instance->AssetsRegistry = new Registry();
1236
+		//messages reset
1237
+		EED_Messages::reset();
1238
+		if ($reset_models) {
1239
+			foreach (array_keys($instance->non_abstract_db_models) as $model_name) {
1240
+				$instance->reset_model($model_name);
1241
+			}
1242
+		}
1243
+		$instance->LIB = new stdClass();
1244
+		return $instance;
1245
+	}
1246
+
1247
+
1248
+
1249
+	/**
1250
+	 * @override magic methods
1251
+	 * @return void
1252
+	 */
1253
+	final function __destruct()
1254
+	{
1255
+	}
1256
+
1257
+
1258
+
1259
+	/**
1260
+	 * @param $a
1261
+	 * @param $b
1262
+	 */
1263
+	final function __call($a, $b)
1264
+	{
1265
+	}
1266
+
1267
+
1268
+
1269
+	/**
1270
+	 * @param $a
1271
+	 */
1272
+	final function __get($a)
1273
+	{
1274
+	}
1275
+
1276
+
1277
+
1278
+	/**
1279
+	 * @param $a
1280
+	 * @param $b
1281
+	 */
1282
+	final function __set($a, $b)
1283
+	{
1284
+	}
1285
+
1286
+
1287
+
1288
+	/**
1289
+	 * @param $a
1290
+	 */
1291
+	final function __isset($a)
1292
+	{
1293
+	}
1294 1294
 
1295 1295
 
1296 1296
 
1297
-    /**
1298
-     * @param $a
1299
-     */
1300
-    final function __unset($a)
1301
-    {
1302
-    }
1297
+	/**
1298
+	 * @param $a
1299
+	 */
1300
+	final function __unset($a)
1301
+	{
1302
+	}
1303 1303
 
1304 1304
 
1305 1305
 
1306
-    /**
1307
-     * @return array
1308
-     */
1309
-    final function __sleep()
1310
-    {
1311
-        return array();
1312
-    }
1306
+	/**
1307
+	 * @return array
1308
+	 */
1309
+	final function __sleep()
1310
+	{
1311
+		return array();
1312
+	}
1313 1313
 
1314 1314
 
1315 1315
 
1316
-    final function __wakeup()
1317
-    {
1318
-    }
1316
+	final function __wakeup()
1317
+	{
1318
+	}
1319 1319
 
1320 1320
 
1321 1321
 
1322
-    /**
1323
-     * @return string
1324
-     */
1325
-    final function __toString()
1326
-    {
1327
-        return '';
1328
-    }
1322
+	/**
1323
+	 * @return string
1324
+	 */
1325
+	final function __toString()
1326
+	{
1327
+		return '';
1328
+	}
1329 1329
 
1330 1330
 
1331 1331
 
1332
-    final function __invoke()
1333
-    {
1334
-    }
1332
+	final function __invoke()
1333
+	{
1334
+	}
1335 1335
 
1336 1336
 
1337 1337
 
1338
-    final static function __set_state()
1339
-    {
1340
-    }
1338
+	final static function __set_state()
1339
+	{
1340
+	}
1341 1341
 
1342 1342
 
1343 1343
 
1344
-    final function __clone()
1345
-    {
1346
-    }
1344
+	final function __clone()
1345
+	{
1346
+	}
1347 1347
 
1348 1348
 
1349 1349
 
1350
-    /**
1351
-     * @param $a
1352
-     * @param $b
1353
-     */
1354
-    final static function __callStatic($a, $b)
1355
-    {
1356
-    }
1350
+	/**
1351
+	 * @param $a
1352
+	 * @param $b
1353
+	 */
1354
+	final static function __callStatic($a, $b)
1355
+	{
1356
+	}
1357 1357
 
1358 1358
 
1359 1359
 
1360
-    /**
1361
-     * Gets all the custom post type models defined
1362
-     *
1363
-     * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1364
-     */
1365
-    public function cpt_models()
1366
-    {
1367
-        $cpt_models = array();
1368
-        foreach ($this->non_abstract_db_models as $short_name => $classname) {
1369
-            if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1370
-                $cpt_models[$short_name] = $classname;
1371
-            }
1372
-        }
1373
-        return $cpt_models;
1374
-    }
1360
+	/**
1361
+	 * Gets all the custom post type models defined
1362
+	 *
1363
+	 * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1364
+	 */
1365
+	public function cpt_models()
1366
+	{
1367
+		$cpt_models = array();
1368
+		foreach ($this->non_abstract_db_models as $short_name => $classname) {
1369
+			if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1370
+				$cpt_models[$short_name] = $classname;
1371
+			}
1372
+		}
1373
+		return $cpt_models;
1374
+	}
1375 1375
 
1376 1376
 
1377 1377
 
1378
-    /**
1379
-     * @return \EE_Config
1380
-     */
1381
-    public static function CFG()
1382
-    {
1383
-        return self::instance()->CFG;
1384
-    }
1378
+	/**
1379
+	 * @return \EE_Config
1380
+	 */
1381
+	public static function CFG()
1382
+	{
1383
+		return self::instance()->CFG;
1384
+	}
1385 1385
 
1386 1386
 
1387 1387
 }
Please login to merge, or discard this patch.
core/EE_Data_Mapper.core.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
 
30 30
    /**
31
-     * instance of the EE_Data_Mapper Object
32
-     * @private _instance
33
-     */
31
+    * instance of the EE_Data_Mapper Object
32
+    * @private _instance
33
+    */
34 34
 	private static $_instance = NULL;
35 35
 
36 36
 
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 	}
83 83
 	final function __wakeup() {}
84 84
 	final function __toString() {
85
-	    return '';
86
-    }
85
+		return '';
86
+	}
87 87
 	final function __invoke() {}
88 88
 	final static function __set_state() {}
89 89
 	final function __clone() {}
Please login to merge, or discard this patch.
core/EE_Config.core.php 2 patches
Indentation   +3108 added lines, -3108 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -14,2504 +14,2504 @@  discard block
 block discarded – undo
14 14
 final class EE_Config
15 15
 {
16 16
 
17
-    const OPTION_NAME        = 'ee_config';
17
+	const OPTION_NAME        = 'ee_config';
18
+
19
+	const LOG_NAME           = 'ee_config_log';
20
+
21
+	const LOG_LENGTH         = 100;
22
+
23
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
24
+
25
+
26
+	/**
27
+	 *    instance of the EE_Config object
28
+	 *
29
+	 * @var    EE_Config $_instance
30
+	 * @access    private
31
+	 */
32
+	private static $_instance;
33
+
34
+	/**
35
+	 * @var boolean $_logging_enabled
36
+	 */
37
+	private static $_logging_enabled = false;
38
+
39
+	/**
40
+	 * An StdClass whose property names are addon slugs,
41
+	 * and values are their config classes
42
+	 *
43
+	 * @var StdClass
44
+	 */
45
+	public $addons;
46
+
47
+	/**
48
+	 * @var EE_Admin_Config
49
+	 */
50
+	public $admin;
51
+
52
+	/**
53
+	 * @var EE_Core_Config
54
+	 */
55
+	public $core;
56
+
57
+	/**
58
+	 * @var EE_Currency_Config
59
+	 */
60
+	public $currency;
61
+
62
+	/**
63
+	 * @var EE_Organization_Config
64
+	 */
65
+	public $organization;
66
+
67
+	/**
68
+	 * @var EE_Registration_Config
69
+	 */
70
+	public $registration;
71
+
72
+	/**
73
+	 * @var EE_Template_Config
74
+	 */
75
+	public $template_settings;
76
+
77
+	/**
78
+	 * Holds EE environment values.
79
+	 *
80
+	 * @var EE_Environment_Config
81
+	 */
82
+	public $environment;
83
+
84
+	/**
85
+	 * settings pertaining to Google maps
86
+	 *
87
+	 * @var EE_Map_Config
88
+	 */
89
+	public $map_settings;
90
+
91
+	/**
92
+	 * settings pertaining to Taxes
93
+	 *
94
+	 * @var EE_Tax_Config
95
+	 */
96
+	public $tax_settings;
97
+
98
+	/**
99
+	 * @deprecated
100
+	 * @var EE_Gateway_Config
101
+	 */
102
+	public $gateway;
103
+
104
+	/**
105
+	 * @var    array $_addon_option_names
106
+	 * @access    private
107
+	 */
108
+	private $_addon_option_names = array();
109
+
110
+	/**
111
+	 * @var    array $_module_route_map
112
+	 * @access    private
113
+	 */
114
+	private static $_module_route_map = array();
115
+
116
+	/**
117
+	 * @var    array $_module_forward_map
118
+	 * @access    private
119
+	 */
120
+	private static $_module_forward_map = array();
121
+
122
+	/**
123
+	 * @var    array $_module_view_map
124
+	 * @access    private
125
+	 */
126
+	private static $_module_view_map = array();
127
+
128
+
129
+
130
+	/**
131
+	 * @singleton method used to instantiate class object
132
+	 * @access    public
133
+	 * @return EE_Config instance
134
+	 */
135
+	public static function instance()
136
+	{
137
+		// check if class object is instantiated, and instantiated properly
138
+		if ( ! self::$_instance instanceof EE_Config) {
139
+			self::$_instance = new self();
140
+		}
141
+		return self::$_instance;
142
+	}
143
+
144
+
145
+
146
+	/**
147
+	 * Resets the config
148
+	 *
149
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
150
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
151
+	 *                               reflect its state in the database
152
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
153
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
154
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
155
+	 *                               site was put into maintenance mode)
156
+	 * @return EE_Config
157
+	 */
158
+	public static function reset($hard_reset = false, $reinstantiate = true)
159
+	{
160
+		if (self::$_instance instanceof EE_Config) {
161
+			if ($hard_reset) {
162
+				self::$_instance->_addon_option_names = array();
163
+				self::$_instance->_initialize_config();
164
+				self::$_instance->update_espresso_config();
165
+			}
166
+			self::$_instance->update_addon_option_names();
167
+		}
168
+		self::$_instance = null;
169
+		//we don't need to reset the static properties imo because those should
170
+		//only change when a module is added or removed. Currently we don't
171
+		//support removing a module during a request when it previously existed
172
+		if ($reinstantiate) {
173
+			return self::instance();
174
+		} else {
175
+			return null;
176
+		}
177
+	}
178
+
179
+
180
+
181
+	/**
182
+	 *    class constructor
183
+	 *
184
+	 * @access    private
185
+	 */
186
+	private function __construct()
187
+	{
188
+		do_action('AHEE__EE_Config__construct__begin', $this);
189
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
190
+		// setup empty config classes
191
+		$this->_initialize_config();
192
+		// load existing EE site settings
193
+		$this->_load_core_config();
194
+		// confirm everything loaded correctly and set filtered defaults if not
195
+		$this->_verify_config();
196
+		//  register shortcodes and modules
197
+		add_action(
198
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
199
+			array($this, 'register_shortcodes_and_modules'),
200
+			999
201
+		);
202
+		//  initialize shortcodes and modules
203
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
204
+		// register widgets
205
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
206
+		// shutdown
207
+		add_action('shutdown', array($this, 'shutdown'), 10);
208
+		// construct__end hook
209
+		do_action('AHEE__EE_Config__construct__end', $this);
210
+		// hardcoded hack
211
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
212
+	}
213
+
214
+
215
+
216
+	/**
217
+	 * @return boolean
218
+	 */
219
+	public static function logging_enabled()
220
+	{
221
+		return self::$_logging_enabled;
222
+	}
223
+
224
+
225
+
226
+	/**
227
+	 * use to get the current theme if needed from static context
228
+	 *
229
+	 * @return string current theme set.
230
+	 */
231
+	public static function get_current_theme()
232
+	{
233
+		return isset(self::$_instance->template_settings->current_espresso_theme)
234
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
235
+	}
236
+
237
+
238
+
239
+	/**
240
+	 *        _initialize_config
241
+	 *
242
+	 * @access private
243
+	 * @return void
244
+	 */
245
+	private function _initialize_config()
246
+	{
247
+		EE_Config::trim_log();
248
+		//set defaults
249
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
250
+		$this->addons = new stdClass();
251
+		// set _module_route_map
252
+		EE_Config::$_module_route_map = array();
253
+		// set _module_forward_map
254
+		EE_Config::$_module_forward_map = array();
255
+		// set _module_view_map
256
+		EE_Config::$_module_view_map = array();
257
+	}
258
+
259
+
260
+
261
+	/**
262
+	 *        load core plugin configuration
263
+	 *
264
+	 * @access private
265
+	 * @return void
266
+	 */
267
+	private function _load_core_config()
268
+	{
269
+		// load_core_config__start hook
270
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
271
+		$espresso_config = $this->get_espresso_config();
272
+		foreach ($espresso_config as $config => $settings) {
273
+			// load_core_config__start hook
274
+			$settings = apply_filters(
275
+				'FHEE__EE_Config___load_core_config__config_settings',
276
+				$settings,
277
+				$config,
278
+				$this
279
+			);
280
+			if (is_object($settings) && property_exists($this, $config)) {
281
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
282
+				//call configs populate method to ensure any defaults are set for empty values.
283
+				if (method_exists($settings, 'populate')) {
284
+					$this->{$config}->populate();
285
+				}
286
+				if (method_exists($settings, 'do_hooks')) {
287
+					$this->{$config}->do_hooks();
288
+				}
289
+			}
290
+		}
291
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
292
+			$this->update_espresso_config();
293
+		}
294
+		// load_core_config__end hook
295
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
296
+	}
297
+
298
+
299
+
300
+	/**
301
+	 *    _verify_config
302
+	 *
303
+	 * @access    protected
304
+	 * @return    void
305
+	 */
306
+	protected function _verify_config()
307
+	{
308
+		$this->core = $this->core instanceof EE_Core_Config
309
+			? $this->core
310
+			: new EE_Core_Config();
311
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
312
+		$this->organization = $this->organization instanceof EE_Organization_Config
313
+			? $this->organization
314
+			: new EE_Organization_Config();
315
+		$this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization',
316
+			$this->organization);
317
+		$this->currency = $this->currency instanceof EE_Currency_Config
318
+			? $this->currency
319
+			: new EE_Currency_Config();
320
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
321
+		$this->registration = $this->registration instanceof EE_Registration_Config
322
+			? $this->registration
323
+			: new EE_Registration_Config();
324
+		$this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration',
325
+			$this->registration);
326
+		$this->admin = $this->admin instanceof EE_Admin_Config
327
+			? $this->admin
328
+			: new EE_Admin_Config();
329
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
330
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
331
+			? $this->template_settings
332
+			: new EE_Template_Config();
333
+		$this->template_settings = apply_filters(
334
+			'FHEE__EE_Config___initialize_config__template_settings',
335
+			$this->template_settings
336
+		);
337
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
338
+			? $this->map_settings
339
+			: new EE_Map_Config();
340
+		$this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
341
+			$this->map_settings);
342
+		$this->environment = $this->environment instanceof EE_Environment_Config
343
+			? $this->environment
344
+			: new EE_Environment_Config();
345
+		$this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
346
+			$this->environment);
347
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
348
+			? $this->tax_settings
349
+			: new EE_Tax_Config();
350
+		$this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
351
+			$this->tax_settings);
352
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
353
+			? $this->gateway
354
+			: new EE_Gateway_Config();
355
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
356
+	}
357
+
358
+
359
+
360
+	/**
361
+	 *    get_espresso_config
362
+	 *
363
+	 * @access    public
364
+	 * @return    array of espresso config stuff
365
+	 */
366
+	public function get_espresso_config()
367
+	{
368
+		// grab espresso configuration
369
+		return apply_filters(
370
+			'FHEE__EE_Config__get_espresso_config__CFG',
371
+			get_option(EE_Config::OPTION_NAME, array())
372
+		);
373
+	}
374
+
375
+
376
+
377
+	/**
378
+	 *    double_check_config_comparison
379
+	 *
380
+	 * @access    public
381
+	 * @param string $option
382
+	 * @param        $old_value
383
+	 * @param        $value
384
+	 */
385
+	public function double_check_config_comparison($option = '', $old_value, $value)
386
+	{
387
+		// make sure we're checking the ee config
388
+		if ($option === EE_Config::OPTION_NAME) {
389
+			// run a loose comparison of the old value against the new value for type and properties,
390
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
391
+			if ($value != $old_value) {
392
+				// if they are NOT the same, then remove the hook,
393
+				// which means the subsequent update results will be based solely on the update query results
394
+				// the reason we do this is because, as stated above,
395
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
396
+				// this happens PRIOR to serialization and any subsequent update.
397
+				// If values are found to match their previous old value,
398
+				// then WP bails before performing any update.
399
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
400
+				// it just pulled from the db, with the one being passed to it (which will not match).
401
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
402
+				// MySQL MAY ALSO NOT perform the update because
403
+				// the string it sees in the db looks the same as the new one it has been passed!!!
404
+				// This results in the query returning an "affected rows" value of ZERO,
405
+				// which gets returned immediately by WP update_option and looks like an error.
406
+				remove_action('update_option', array($this, 'check_config_updated'));
407
+			}
408
+		}
409
+	}
410
+
411
+
412
+
413
+	/**
414
+	 *    update_espresso_config
415
+	 *
416
+	 * @access   public
417
+	 */
418
+	protected function _reset_espresso_addon_config()
419
+	{
420
+		$this->_addon_option_names = array();
421
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
422
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
423
+			$config_class = get_class($addon_config_obj);
424
+			if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
425
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
426
+			}
427
+			$this->addons->{$addon_name} = null;
428
+		}
429
+	}
430
+
431
+
432
+
433
+	/**
434
+	 *    update_espresso_config
435
+	 *
436
+	 * @access   public
437
+	 * @param   bool $add_success
438
+	 * @param   bool $add_error
439
+	 * @return   bool
440
+	 */
441
+	public function update_espresso_config($add_success = false, $add_error = true)
442
+	{
443
+		// don't allow config updates during WP heartbeats
444
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
445
+			return false;
446
+		}
447
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
448
+		//$clone = clone( self::$_instance );
449
+		//self::$_instance = NULL;
450
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
451
+		$this->_reset_espresso_addon_config();
452
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
453
+		// but BEFORE the actual update occurs
454
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
455
+		// now update "ee_config"
456
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
457
+		EE_Config::log(EE_Config::OPTION_NAME);
458
+		// if not saved... check if the hook we just added still exists;
459
+		// if it does, it means one of two things:
460
+		// 		that update_option bailed at the ( $value === $old_value ) conditional,
461
+		//		 or...
462
+		// 		the db update query returned 0 rows affected
463
+		// 		(probably because the data  value was the same from it's perspective)
464
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
465
+		// but just means no update occurred, so don't display an error to the user.
466
+		// BUT... if update_option returns FALSE, AND the hook is missing,
467
+		// then it means that something truly went wrong
468
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
469
+		// remove our action since we don't want it in the system anymore
470
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
471
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
472
+		//self::$_instance = $clone;
473
+		//unset( $clone );
474
+		// if config remains the same or was updated successfully
475
+		if ($saved) {
476
+			if ($add_success) {
477
+				EE_Error::add_success(
478
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
479
+					__FILE__,
480
+					__FUNCTION__,
481
+					__LINE__
482
+				);
483
+			}
484
+			return true;
485
+		} else {
486
+			if ($add_error) {
487
+				EE_Error::add_error(
488
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
489
+					__FILE__,
490
+					__FUNCTION__,
491
+					__LINE__
492
+				);
493
+			}
494
+			return false;
495
+		}
496
+	}
497
+
498
+
499
+
500
+	/**
501
+	 *    _verify_config_params
502
+	 *
503
+	 * @access    private
504
+	 * @param    string         $section
505
+	 * @param    string         $name
506
+	 * @param    string         $config_class
507
+	 * @param    EE_Config_Base $config_obj
508
+	 * @param    array          $tests_to_run
509
+	 * @param    bool           $display_errors
510
+	 * @return    bool    TRUE on success, FALSE on fail
511
+	 */
512
+	private function _verify_config_params(
513
+		$section = '',
514
+		$name = '',
515
+		$config_class = '',
516
+		$config_obj = null,
517
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
518
+		$display_errors = true
519
+	) {
520
+		try {
521
+			foreach ($tests_to_run as $test) {
522
+				switch ($test) {
523
+					// TEST #1 : check that section was set
524
+					case 1 :
525
+						if (empty($section)) {
526
+							if ($display_errors) {
527
+								throw new EE_Error(
528
+									sprintf(
529
+										__(
530
+											'No configuration section has been provided while attempting to save "%s".',
531
+											'event_espresso'
532
+										),
533
+										$config_class
534
+									)
535
+								);
536
+							}
537
+							return false;
538
+						}
539
+						break;
540
+					// TEST #2 : check that settings section exists
541
+					case 2 :
542
+						if ( ! isset($this->{$section})) {
543
+							if ($display_errors) {
544
+								throw new EE_Error(
545
+									sprintf(
546
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
547
+										$section
548
+									)
549
+								);
550
+							}
551
+							return false;
552
+						}
553
+						break;
554
+					// TEST #3 : check that section is the proper format
555
+					case 3 :
556
+						if (
557
+						! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
558
+						) {
559
+							if ($display_errors) {
560
+								throw new EE_Error(
561
+									sprintf(
562
+										__(
563
+											'The "%s" configuration settings have not been formatted correctly.',
564
+											'event_espresso'
565
+										),
566
+										$section
567
+									)
568
+								);
569
+							}
570
+							return false;
571
+						}
572
+						break;
573
+					// TEST #4 : check that config section name has been set
574
+					case 4 :
575
+						if (empty($name)) {
576
+							if ($display_errors) {
577
+								throw new EE_Error(
578
+									__(
579
+										'No name has been provided for the specific configuration section.',
580
+										'event_espresso'
581
+									)
582
+								);
583
+							}
584
+							return false;
585
+						}
586
+						break;
587
+					// TEST #5 : check that a config class name has been set
588
+					case 5 :
589
+						if (empty($config_class)) {
590
+							if ($display_errors) {
591
+								throw new EE_Error(
592
+									__(
593
+										'No class name has been provided for the specific configuration section.',
594
+										'event_espresso'
595
+									)
596
+								);
597
+							}
598
+							return false;
599
+						}
600
+						break;
601
+					// TEST #6 : verify config class is accessible
602
+					case 6 :
603
+						if ( ! class_exists($config_class)) {
604
+							if ($display_errors) {
605
+								throw new EE_Error(
606
+									sprintf(
607
+										__(
608
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
609
+											'event_espresso'
610
+										),
611
+										$config_class
612
+									)
613
+								);
614
+							}
615
+							return false;
616
+						}
617
+						break;
618
+					// TEST #7 : check that config has even been set
619
+					case 7 :
620
+						if ( ! isset($this->{$section}->{$name})) {
621
+							if ($display_errors) {
622
+								throw new EE_Error(
623
+									sprintf(
624
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
625
+										$section,
626
+										$name
627
+									)
628
+								);
629
+							}
630
+							return false;
631
+						} else {
632
+							// and make sure it's not serialized
633
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
634
+						}
635
+						break;
636
+					// TEST #8 : check that config is the requested type
637
+					case 8 :
638
+						if ( ! $this->{$section}->{$name} instanceof $config_class) {
639
+							if ($display_errors) {
640
+								throw new EE_Error(
641
+									sprintf(
642
+										__(
643
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
644
+											'event_espresso'
645
+										),
646
+										$section,
647
+										$name,
648
+										$config_class
649
+									)
650
+								);
651
+							}
652
+							return false;
653
+						}
654
+						break;
655
+					// TEST #9 : verify config object
656
+					case 9 :
657
+						if ( ! $config_obj instanceof EE_Config_Base) {
658
+							if ($display_errors) {
659
+								throw new EE_Error(
660
+									sprintf(
661
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
662
+										print_r($config_obj, true)
663
+									)
664
+								);
665
+							}
666
+							return false;
667
+						}
668
+						break;
669
+				}
670
+			}
671
+		} catch (EE_Error $e) {
672
+			$e->get_error();
673
+		}
674
+		// you have successfully run the gauntlet
675
+		return true;
676
+	}
677
+
678
+
679
+
680
+	/**
681
+	 *    _generate_config_option_name
682
+	 *
683
+	 * @access        protected
684
+	 * @param        string $section
685
+	 * @param        string $name
686
+	 * @return        string
687
+	 */
688
+	private function _generate_config_option_name($section = '', $name = '')
689
+	{
690
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
691
+	}
692
+
693
+
694
+
695
+	/**
696
+	 *    _set_config_class
697
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
698
+	 *
699
+	 * @access    private
700
+	 * @param    string $config_class
701
+	 * @param    string $name
702
+	 * @return    string
703
+	 */
704
+	private function _set_config_class($config_class = '', $name = '')
705
+	{
706
+		return ! empty($config_class)
707
+			? $config_class
708
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
709
+	}
710
+
711
+
712
+
713
+	/**
714
+	 *    set_config
715
+	 *
716
+	 * @access    protected
717
+	 * @param    string         $section
718
+	 * @param    string         $name
719
+	 * @param    string         $config_class
720
+	 * @param    EE_Config_Base $config_obj
721
+	 * @return    EE_Config_Base
722
+	 */
723
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
724
+	{
725
+		// ensure config class is set to something
726
+		$config_class = $this->_set_config_class($config_class, $name);
727
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
728
+		if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
729
+			return null;
730
+		}
731
+		$config_option_name = $this->_generate_config_option_name($section, $name);
732
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
733
+		if ( ! isset($this->_addon_option_names[$config_option_name])) {
734
+			$this->_addon_option_names[$config_option_name] = $config_class;
735
+			$this->update_addon_option_names();
736
+		}
737
+		// verify the incoming config object but suppress errors
738
+		if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
739
+			$config_obj = new $config_class();
740
+		}
741
+		if (get_option($config_option_name)) {
742
+			EE_Config::log($config_option_name);
743
+			update_option($config_option_name, $config_obj);
744
+			$this->{$section}->{$name} = $config_obj;
745
+			return $this->{$section}->{$name};
746
+		} else {
747
+			// create a wp-option for this config
748
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
749
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
750
+				return $this->{$section}->{$name};
751
+			} else {
752
+				EE_Error::add_error(
753
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
754
+					__FILE__,
755
+					__FUNCTION__,
756
+					__LINE__
757
+				);
758
+				return null;
759
+			}
760
+		}
761
+	}
762
+
763
+
764
+
765
+	/**
766
+	 *    update_config
767
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
768
+	 *
769
+	 * @access    public
770
+	 * @param    string                $section
771
+	 * @param    string                $name
772
+	 * @param    EE_Config_Base|string $config_obj
773
+	 * @param    bool                  $throw_errors
774
+	 * @return    bool
775
+	 */
776
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
777
+	{
778
+		// don't allow config updates during WP heartbeats
779
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
780
+			return false;
781
+		}
782
+		$config_obj = maybe_unserialize($config_obj);
783
+		// get class name of the incoming object
784
+		$config_class = get_class($config_obj);
785
+		// run tests 1-5 and 9 to verify config
786
+		if ( ! $this->_verify_config_params(
787
+			$section,
788
+			$name,
789
+			$config_class,
790
+			$config_obj,
791
+			array(1, 2, 3, 4, 7, 9)
792
+		)
793
+		) {
794
+			return false;
795
+		}
796
+		$config_option_name = $this->_generate_config_option_name($section, $name);
797
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
798
+		if ( ! isset($this->_addon_option_names[$config_option_name])) {
799
+			// save new config to db
800
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
801
+				return true;
802
+			}
803
+		} else {
804
+			// first check if the record already exists
805
+			$existing_config = get_option($config_option_name);
806
+			$config_obj = serialize($config_obj);
807
+			// just return if db record is already up to date (NOT type safe comparison)
808
+			if ($existing_config == $config_obj) {
809
+				$this->{$section}->{$name} = $config_obj;
810
+				return true;
811
+			} else if (update_option($config_option_name, $config_obj)) {
812
+				EE_Config::log($config_option_name);
813
+				// update wp-option for this config class
814
+				$this->{$section}->{$name} = $config_obj;
815
+				return true;
816
+			} elseif ($throw_errors) {
817
+				EE_Error::add_error(
818
+					sprintf(
819
+						__(
820
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
821
+							'event_espresso'
822
+						),
823
+						$config_class,
824
+						'EE_Config->' . $section . '->' . $name
825
+					),
826
+					__FILE__,
827
+					__FUNCTION__,
828
+					__LINE__
829
+				);
830
+			}
831
+		}
832
+		return false;
833
+	}
834
+
835
+
836
+
837
+	/**
838
+	 *    get_config
839
+	 *
840
+	 * @access    public
841
+	 * @param    string $section
842
+	 * @param    string $name
843
+	 * @param    string $config_class
844
+	 * @return    mixed EE_Config_Base | NULL
845
+	 */
846
+	public function get_config($section = '', $name = '', $config_class = '')
847
+	{
848
+		// ensure config class is set to something
849
+		$config_class = $this->_set_config_class($config_class, $name);
850
+		// run tests 1-4, 6 and 7 to verify that all params have been set
851
+		if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
852
+			return null;
853
+		}
854
+		// now test if the requested config object exists, but suppress errors
855
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
856
+			// config already exists, so pass it back
857
+			return $this->{$section}->{$name};
858
+		}
859
+		// load config option from db if it exists
860
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
861
+		// verify the newly retrieved config object, but suppress errors
862
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
863
+			// config is good, so set it and pass it back
864
+			$this->{$section}->{$name} = $config_obj;
865
+			return $this->{$section}->{$name};
866
+		}
867
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
868
+		$config_obj = $this->set_config($section, $name, $config_class);
869
+		// verify the newly created config object
870
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
871
+			return $this->{$section}->{$name};
872
+		} else {
873
+			EE_Error::add_error(
874
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
875
+				__FILE__,
876
+				__FUNCTION__,
877
+				__LINE__
878
+			);
879
+		}
880
+		return null;
881
+	}
882
+
883
+
884
+
885
+	/**
886
+	 *    get_config_option
887
+	 *
888
+	 * @access    public
889
+	 * @param    string $config_option_name
890
+	 * @return    mixed EE_Config_Base | FALSE
891
+	 */
892
+	public function get_config_option($config_option_name = '')
893
+	{
894
+		// retrieve the wp-option for this config class.
895
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
896
+		if (empty($config_option)) {
897
+			EE_Config::log($config_option_name . '-NOT-FOUND');
898
+		}
899
+		return $config_option;
900
+	}
901
+
902
+
903
+
904
+	/**
905
+	 * log
906
+	 *
907
+	 * @param string $config_option_name
908
+	 */
909
+	public static function log($config_option_name = '')
910
+	{
911
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
912
+			$config_log = get_option(EE_Config::LOG_NAME, array());
913
+			//copy incoming $_REQUEST and sanitize it so we can save it
914
+			$_request = $_REQUEST;
915
+			array_walk_recursive($_request, 'sanitize_text_field');
916
+			$config_log[(string)microtime(true)] = array(
917
+				'config_name' => $config_option_name,
918
+				'request'     => $_request,
919
+			);
920
+			update_option(EE_Config::LOG_NAME, $config_log);
921
+		}
922
+	}
923
+
924
+
925
+
926
+	/**
927
+	 * trim_log
928
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
929
+	 */
930
+	public static function trim_log()
931
+	{
932
+		if ( ! EE_Config::logging_enabled()) {
933
+			return;
934
+		}
935
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
936
+		$log_length = count($config_log);
937
+		if ($log_length > EE_Config::LOG_LENGTH) {
938
+			ksort($config_log);
939
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
940
+			update_option(EE_Config::LOG_NAME, $config_log);
941
+		}
942
+	}
943
+
944
+
945
+
946
+	/**
947
+	 *    get_page_for_posts
948
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
949
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
950
+	 *
951
+	 * @access    public
952
+	 * @return    string
953
+	 */
954
+	public static function get_page_for_posts()
955
+	{
956
+		$page_for_posts = get_option('page_for_posts');
957
+		if ( ! $page_for_posts) {
958
+			return 'posts';
959
+		}
960
+		/** @type WPDB $wpdb */
961
+		global $wpdb;
962
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
963
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
964
+	}
965
+
966
+
967
+
968
+	/**
969
+	 *    register_shortcodes_and_modules.
970
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
971
+	 *    In fact, this is where we give modules a chance to let core know they exist
972
+	 *    so they can help trigger maintenance mode if it's needed
973
+	 *
974
+	 * @access    public
975
+	 * @return    void
976
+	 */
977
+	public function register_shortcodes_and_modules()
978
+	{
979
+		// allow shortcodes to register with WP and to set hooks for the rest of the system
980
+		EE_Registry::instance()->shortcodes = $this->_register_shortcodes();
981
+		// allow modules to set hooks for the rest of the system
982
+		EE_Registry::instance()->modules = $this->_register_modules();
983
+	}
984
+
985
+
986
+
987
+	/**
988
+	 *    initialize_shortcodes_and_modules
989
+	 *    meaning they can start adding their hooks to get stuff done
990
+	 *
991
+	 * @access    public
992
+	 * @return    void
993
+	 */
994
+	public function initialize_shortcodes_and_modules()
995
+	{
996
+		// allow shortcodes to set hooks for the rest of the system
997
+		$this->_initialize_shortcodes();
998
+		// allow modules to set hooks for the rest of the system
999
+		$this->_initialize_modules();
1000
+	}
1001
+
1002
+
1003
+
1004
+	/**
1005
+	 *    widgets_init
1006
+	 *
1007
+	 * @access private
1008
+	 * @return void
1009
+	 */
1010
+	public function widgets_init()
1011
+	{
1012
+		//only init widgets on admin pages when not in complete maintenance, and
1013
+		//on frontend when not in any maintenance mode
1014
+		if (
1015
+			! EE_Maintenance_Mode::instance()->level()
1016
+			|| (
1017
+				is_admin()
1018
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1019
+			)
1020
+		) {
1021
+			// grab list of installed widgets
1022
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1023
+			// filter list of modules to register
1024
+			$widgets_to_register = apply_filters(
1025
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1026
+				$widgets_to_register
1027
+			);
1028
+			if ( ! empty($widgets_to_register)) {
1029
+				// cycle thru widget folders
1030
+				foreach ($widgets_to_register as $widget_path) {
1031
+					// add to list of installed widget modules
1032
+					EE_Config::register_ee_widget($widget_path);
1033
+				}
1034
+			}
1035
+			// filter list of installed modules
1036
+			EE_Registry::instance()->widgets = apply_filters(
1037
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1038
+				EE_Registry::instance()->widgets
1039
+			);
1040
+		}
1041
+	}
1042
+
1043
+
1044
+
1045
+	/**
1046
+	 *    register_ee_widget - makes core aware of this widget
1047
+	 *
1048
+	 * @access    public
1049
+	 * @param    string $widget_path - full path up to and including widget folder
1050
+	 * @return    void
1051
+	 */
1052
+	public static function register_ee_widget($widget_path = null)
1053
+	{
1054
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1055
+		$widget_ext = '.widget.php';
1056
+		// make all separators match
1057
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1058
+		// does the file path INCLUDE the actual file name as part of the path ?
1059
+		if (strpos($widget_path, $widget_ext) !== false) {
1060
+			// grab and shortcode file name from directory name and break apart at dots
1061
+			$file_name = explode('.', basename($widget_path));
1062
+			// take first segment from file name pieces and remove class prefix if it exists
1063
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1064
+			// sanitize shortcode directory name
1065
+			$widget = sanitize_key($widget);
1066
+			// now we need to rebuild the shortcode path
1067
+			$widget_path = explode(DS, $widget_path);
1068
+			// remove last segment
1069
+			array_pop($widget_path);
1070
+			// glue it back together
1071
+			$widget_path = implode(DS, $widget_path);
1072
+		} else {
1073
+			// grab and sanitize widget directory name
1074
+			$widget = sanitize_key(basename($widget_path));
1075
+		}
1076
+		// create classname from widget directory name
1077
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1078
+		// add class prefix
1079
+		$widget_class = 'EEW_' . $widget;
1080
+		// does the widget exist ?
1081
+		if ( ! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1082
+			$msg = sprintf(
1083
+				__(
1084
+					'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1085
+					'event_espresso'
1086
+				),
1087
+				$widget_class,
1088
+				$widget_path . DS . $widget_class . $widget_ext
1089
+			);
1090
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1091
+			return;
1092
+		}
1093
+		// load the widget class file
1094
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1095
+		// verify that class exists
1096
+		if ( ! class_exists($widget_class)) {
1097
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1098
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1099
+			return;
1100
+		}
1101
+		register_widget($widget_class);
1102
+		// add to array of registered widgets
1103
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1104
+	}
1105
+
1106
+
1107
+
1108
+	/**
1109
+	 *        _register_shortcodes
1110
+	 *
1111
+	 * @access private
1112
+	 * @return array
1113
+	 */
1114
+	private function _register_shortcodes()
1115
+	{
1116
+		// grab list of installed shortcodes
1117
+		$shortcodes_to_register = glob(EE_SHORTCODES . '*', GLOB_ONLYDIR);
1118
+		// filter list of modules to register
1119
+		$shortcodes_to_register = apply_filters(
1120
+			'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
1121
+			$shortcodes_to_register
1122
+		);
1123
+		if ( ! empty($shortcodes_to_register)) {
1124
+			// cycle thru shortcode folders
1125
+			foreach ($shortcodes_to_register as $shortcode_path) {
1126
+				// add to list of installed shortcode modules
1127
+				EE_Config::register_shortcode($shortcode_path);
1128
+			}
1129
+		}
1130
+		// filter list of installed modules
1131
+		return apply_filters(
1132
+			'FHEE__EE_Config___register_shortcodes__installed_shortcodes',
1133
+			EE_Registry::instance()->shortcodes
1134
+		);
1135
+	}
1136
+
1137
+
1138
+
1139
+	/**
1140
+	 *    register_shortcode - makes core aware of this shortcode
1141
+	 *
1142
+	 * @access    public
1143
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1144
+	 * @return    bool
1145
+	 */
1146
+	public static function register_shortcode($shortcode_path = null)
1147
+	{
1148
+		do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
1149
+		$shortcode_ext = '.shortcode.php';
1150
+		// make all separators match
1151
+		$shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path);
1152
+		// does the file path INCLUDE the actual file name as part of the path ?
1153
+		if (strpos($shortcode_path, $shortcode_ext) !== false) {
1154
+			// grab shortcode file name from directory name and break apart at dots
1155
+			$shortcode_file = explode('.', basename($shortcode_path));
1156
+			// take first segment from file name pieces and remove class prefix if it exists
1157
+			$shortcode = strpos($shortcode_file[0], 'EES_') === 0
1158
+				? substr($shortcode_file[0], 4)
1159
+				: $shortcode_file[0];
1160
+			// sanitize shortcode directory name
1161
+			$shortcode = sanitize_key($shortcode);
1162
+			// now we need to rebuild the shortcode path
1163
+			$shortcode_path = explode(DS, $shortcode_path);
1164
+			// remove last segment
1165
+			array_pop($shortcode_path);
1166
+			// glue it back together
1167
+			$shortcode_path = implode(DS, $shortcode_path) . DS;
1168
+		} else {
1169
+			// we need to generate the filename based off of the folder name
1170
+			// grab and sanitize shortcode directory name
1171
+			$shortcode = sanitize_key(basename($shortcode_path));
1172
+			$shortcode_path = rtrim($shortcode_path, DS) . DS;
1173
+		}
1174
+		// create classname from shortcode directory or file name
1175
+		$shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
1176
+		// add class prefix
1177
+		$shortcode_class = 'EES_' . $shortcode;
1178
+		// does the shortcode exist ?
1179
+		if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) {
1180
+			$msg = sprintf(
1181
+				__(
1182
+					'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s',
1183
+					'event_espresso'
1184
+				),
1185
+				$shortcode_class,
1186
+				$shortcode_path . DS . $shortcode_class . $shortcode_ext
1187
+			);
1188
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1189
+			return false;
1190
+		}
1191
+		// load the shortcode class file
1192
+		require_once($shortcode_path . $shortcode_class . $shortcode_ext);
1193
+		// verify that class exists
1194
+		if ( ! class_exists($shortcode_class)) {
1195
+			$msg = sprintf(
1196
+				__('The requested %s shortcode class does not exist.', 'event_espresso'),
1197
+				$shortcode_class
1198
+			);
1199
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1200
+			return false;
1201
+		}
1202
+		$shortcode = strtoupper($shortcode);
1203
+		// add to array of registered shortcodes
1204
+		EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
1205
+		return true;
1206
+	}
1207
+
1208
+
1209
+
1210
+	/**
1211
+	 *        _register_modules
1212
+	 *
1213
+	 * @access private
1214
+	 * @return array
1215
+	 */
1216
+	private function _register_modules()
1217
+	{
1218
+		// grab list of installed modules
1219
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1220
+		// filter list of modules to register
1221
+		$modules_to_register = apply_filters(
1222
+			'FHEE__EE_Config__register_modules__modules_to_register',
1223
+			$modules_to_register
1224
+		);
1225
+		if ( ! empty($modules_to_register)) {
1226
+			// loop through folders
1227
+			foreach ($modules_to_register as $module_path) {
1228
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1229
+				if (
1230
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1231
+					&& $module_path !== EE_MODULES . 'gateways'
1232
+				) {
1233
+					// add to list of installed modules
1234
+					EE_Config::register_module($module_path);
1235
+				}
1236
+			}
1237
+		}
1238
+		// filter list of installed modules
1239
+		return apply_filters(
1240
+			'FHEE__EE_Config___register_modules__installed_modules',
1241
+			EE_Registry::instance()->modules
1242
+		);
1243
+	}
1244
+
1245
+
1246
+
1247
+	/**
1248
+	 *    register_module - makes core aware of this module
1249
+	 *
1250
+	 * @access    public
1251
+	 * @param    string $module_path - full path up to and including module folder
1252
+	 * @return    bool
1253
+	 */
1254
+	public static function register_module($module_path = null)
1255
+	{
1256
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1257
+		$module_ext = '.module.php';
1258
+		// make all separators match
1259
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1260
+		// does the file path INCLUDE the actual file name as part of the path ?
1261
+		if (strpos($module_path, $module_ext) !== false) {
1262
+			// grab and shortcode file name from directory name and break apart at dots
1263
+			$module_file = explode('.', basename($module_path));
1264
+			// now we need to rebuild the shortcode path
1265
+			$module_path = explode(DS, $module_path);
1266
+			// remove last segment
1267
+			array_pop($module_path);
1268
+			// glue it back together
1269
+			$module_path = implode(DS, $module_path) . DS;
1270
+			// take first segment from file name pieces and sanitize it
1271
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1272
+			// ensure class prefix is added
1273
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1274
+		} else {
1275
+			// we need to generate the filename based off of the folder name
1276
+			// grab and sanitize module name
1277
+			$module = strtolower(basename($module_path));
1278
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1279
+			// like trailingslashit()
1280
+			$module_path = rtrim($module_path, DS) . DS;
1281
+			// create classname from module directory name
1282
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1283
+			// add class prefix
1284
+			$module_class = 'EED_' . $module;
1285
+		}
1286
+		// does the module exist ?
1287
+		if ( ! is_readable($module_path . DS . $module_class . $module_ext)) {
1288
+			$msg = sprintf(
1289
+				__(
1290
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1291
+					'event_espresso'
1292
+				),
1293
+				$module
1294
+			);
1295
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1296
+			return false;
1297
+		}
1298
+		// load the module class file
1299
+		require_once($module_path . $module_class . $module_ext);
1300
+		// verify that class exists
1301
+		if ( ! class_exists($module_class)) {
1302
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1303
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1304
+			return false;
1305
+		}
1306
+		// add to array of registered modules
1307
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1308
+		do_action(
1309
+			'AHEE__EE_Config__register_module__complete',
1310
+			$module_class,
1311
+			EE_Registry::instance()->modules->{$module_class}
1312
+		);
1313
+		return true;
1314
+	}
1315
+
1316
+
1317
+
1318
+	/**
1319
+	 *    _initialize_shortcodes
1320
+	 *    allow shortcodes to set hooks for the rest of the system
1321
+	 *
1322
+	 * @access private
1323
+	 * @return void
1324
+	 */
1325
+	private function _initialize_shortcodes()
1326
+	{
1327
+		// cycle thru shortcode folders
1328
+		foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) {
1329
+			// add class prefix
1330
+			$shortcode_class = 'EES_' . $shortcode;
1331
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1332
+			// which set hooks ?
1333
+			if (is_admin()) {
1334
+				// fire immediately
1335
+				call_user_func(array($shortcode_class, 'set_hooks_admin'));
1336
+			} else {
1337
+				// delay until other systems are online
1338
+				add_action(
1339
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1340
+					array($shortcode_class, 'set_hooks')
1341
+				);
1342
+				// convert classname to UPPERCASE and create WP shortcode.
1343
+				$shortcode_tag = strtoupper($shortcode);
1344
+				// but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor'
1345
+				if ( ! shortcode_exists($shortcode_tag)) {
1346
+					// NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes()
1347
+					add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
1348
+				}
1349
+			}
1350
+		}
1351
+	}
1352
+
1353
+
1354
+
1355
+	/**
1356
+	 *    _initialize_modules
1357
+	 *    allow modules to set hooks for the rest of the system
1358
+	 *
1359
+	 * @access private
1360
+	 * @return void
1361
+	 */
1362
+	private function _initialize_modules()
1363
+	{
1364
+		// cycle thru shortcode folders
1365
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1366
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1367
+			// which set hooks ?
1368
+			if (is_admin()) {
1369
+				// fire immediately
1370
+				call_user_func(array($module_class, 'set_hooks_admin'));
1371
+			} else {
1372
+				// delay until other systems are online
1373
+				add_action(
1374
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1375
+					array($module_class, 'set_hooks')
1376
+				);
1377
+			}
1378
+		}
1379
+	}
1380
+
1381
+
1382
+
1383
+	/**
1384
+	 *    register_route - adds module method routes to route_map
1385
+	 *
1386
+	 * @access    public
1387
+	 * @param    string $route       - "pretty" public alias for module method
1388
+	 * @param    string $module      - module name (classname without EED_ prefix)
1389
+	 * @param    string $method_name - the actual module method to be routed to
1390
+	 * @param    string $key         - url param key indicating a route is being called
1391
+	 * @return    bool
1392
+	 */
1393
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1394
+	{
1395
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1396
+		$module = str_replace('EED_', '', $module);
1397
+		$module_class = 'EED_' . $module;
1398
+		if ( ! isset(EE_Registry::instance()->modules->{$module_class})) {
1399
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1400
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1401
+			return false;
1402
+		}
1403
+		if (empty($route)) {
1404
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1405
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1406
+			return false;
1407
+		}
1408
+		if ( ! method_exists('EED_' . $module, $method_name)) {
1409
+			$msg = sprintf(
1410
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1411
+				$route
1412
+			);
1413
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1414
+			return false;
1415
+		}
1416
+		EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1417
+		return true;
1418
+	}
1419
+
1420
+
1421
+
1422
+	/**
1423
+	 *    get_route - get module method route
1424
+	 *
1425
+	 * @access    public
1426
+	 * @param    string $route - "pretty" public alias for module method
1427
+	 * @param    string $key   - url param key indicating a route is being called
1428
+	 * @return    string
1429
+	 */
1430
+	public static function get_route($route = null, $key = 'ee')
1431
+	{
1432
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1433
+		$route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1434
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1435
+			return EE_Config::$_module_route_map[$key][$route];
1436
+		}
1437
+		return null;
1438
+	}
1439
+
1440
+
1441
+
1442
+	/**
1443
+	 *    get_routes - get ALL module method routes
1444
+	 *
1445
+	 * @access    public
1446
+	 * @return    array
1447
+	 */
1448
+	public static function get_routes()
1449
+	{
1450
+		return EE_Config::$_module_route_map;
1451
+	}
1452
+
1453
+
1454
+
1455
+	/**
1456
+	 *    register_forward - allows modules to forward request to another module for further processing
1457
+	 *
1458
+	 * @access    public
1459
+	 * @param    string       $route   - "pretty" public alias for module method
1460
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1461
+	 *                                 class, allows different forwards to be served based on status
1462
+	 * @param    array|string $forward - function name or array( class, method )
1463
+	 * @param    string       $key     - url param key indicating a route is being called
1464
+	 * @return    bool
1465
+	 */
1466
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1467
+	{
1468
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1469
+		if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1470
+			$msg = sprintf(
1471
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1472
+				$route
1473
+			);
1474
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1475
+			return false;
1476
+		}
1477
+		if (empty($forward)) {
1478
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1479
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1480
+			return false;
1481
+		}
1482
+		if (is_array($forward)) {
1483
+			if ( ! isset($forward[1])) {
1484
+				$msg = sprintf(
1485
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1486
+					$route
1487
+				);
1488
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1489
+				return false;
1490
+			}
1491
+			if ( ! method_exists($forward[0], $forward[1])) {
1492
+				$msg = sprintf(
1493
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1494
+					$forward[1],
1495
+					$route
1496
+				);
1497
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1498
+				return false;
1499
+			}
1500
+		} else if ( ! function_exists($forward)) {
1501
+			$msg = sprintf(
1502
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1503
+				$forward,
1504
+				$route
1505
+			);
1506
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1507
+			return false;
1508
+		}
1509
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1510
+		return true;
1511
+	}
1512
+
1513
+
1514
+
1515
+	/**
1516
+	 *    get_forward - get forwarding route
1517
+	 *
1518
+	 * @access    public
1519
+	 * @param    string  $route  - "pretty" public alias for module method
1520
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1521
+	 *                           allows different forwards to be served based on status
1522
+	 * @param    string  $key    - url param key indicating a route is being called
1523
+	 * @return    string
1524
+	 */
1525
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1526
+	{
1527
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1528
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1529
+			return apply_filters(
1530
+				'FHEE__EE_Config__get_forward',
1531
+				EE_Config::$_module_forward_map[$key][$route][$status],
1532
+				$route,
1533
+				$status
1534
+			);
1535
+		}
1536
+		return null;
1537
+	}
1538
+
1539
+
1540
+
1541
+	/**
1542
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1543
+	 *    results
1544
+	 *
1545
+	 * @access    public
1546
+	 * @param    string  $route  - "pretty" public alias for module method
1547
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1548
+	 *                           allows different views to be served based on status
1549
+	 * @param    string  $view
1550
+	 * @param    string  $key    - url param key indicating a route is being called
1551
+	 * @return    bool
1552
+	 */
1553
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1554
+	{
1555
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1556
+		if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1557
+			$msg = sprintf(
1558
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1559
+				$route
1560
+			);
1561
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1562
+			return false;
1563
+		}
1564
+		if ( ! is_readable($view)) {
1565
+			$msg = sprintf(
1566
+				__(
1567
+					'The %s view file could not be found or is not readable due to file permissions.',
1568
+					'event_espresso'
1569
+				),
1570
+				$view
1571
+			);
1572
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1573
+			return false;
1574
+		}
1575
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1576
+		return true;
1577
+	}
1578
+
1579
+
1580
+
1581
+	/**
1582
+	 *    get_view - get view for route and status
1583
+	 *
1584
+	 * @access    public
1585
+	 * @param    string  $route  - "pretty" public alias for module method
1586
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1587
+	 *                           allows different views to be served based on status
1588
+	 * @param    string  $key    - url param key indicating a route is being called
1589
+	 * @return    string
1590
+	 */
1591
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1592
+	{
1593
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1594
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1595
+			return apply_filters(
1596
+				'FHEE__EE_Config__get_view',
1597
+				EE_Config::$_module_view_map[$key][$route][$status],
1598
+				$route,
1599
+				$status
1600
+			);
1601
+		}
1602
+		return null;
1603
+	}
1604
+
1605
+
1606
+
1607
+	public function update_addon_option_names()
1608
+	{
1609
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1610
+	}
1611
+
1612
+
1613
+
1614
+	public function shutdown()
1615
+	{
1616
+		$this->update_addon_option_names();
1617
+	}
18 1618
 
19
-    const LOG_NAME           = 'ee_config_log';
20 1619
 
21
-    const LOG_LENGTH         = 100;
22
-
23
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
24
-
25
-
26
-    /**
27
-     *    instance of the EE_Config object
28
-     *
29
-     * @var    EE_Config $_instance
30
-     * @access    private
31
-     */
32
-    private static $_instance;
33
-
34
-    /**
35
-     * @var boolean $_logging_enabled
36
-     */
37
-    private static $_logging_enabled = false;
38
-
39
-    /**
40
-     * An StdClass whose property names are addon slugs,
41
-     * and values are their config classes
42
-     *
43
-     * @var StdClass
44
-     */
45
-    public $addons;
46
-
47
-    /**
48
-     * @var EE_Admin_Config
49
-     */
50
-    public $admin;
51
-
52
-    /**
53
-     * @var EE_Core_Config
54
-     */
55
-    public $core;
56
-
57
-    /**
58
-     * @var EE_Currency_Config
59
-     */
60
-    public $currency;
61
-
62
-    /**
63
-     * @var EE_Organization_Config
64
-     */
65
-    public $organization;
66
-
67
-    /**
68
-     * @var EE_Registration_Config
69
-     */
70
-    public $registration;
71
-
72
-    /**
73
-     * @var EE_Template_Config
74
-     */
75
-    public $template_settings;
76
-
77
-    /**
78
-     * Holds EE environment values.
79
-     *
80
-     * @var EE_Environment_Config
81
-     */
82
-    public $environment;
83
-
84
-    /**
85
-     * settings pertaining to Google maps
86
-     *
87
-     * @var EE_Map_Config
88
-     */
89
-    public $map_settings;
90
-
91
-    /**
92
-     * settings pertaining to Taxes
93
-     *
94
-     * @var EE_Tax_Config
95
-     */
96
-    public $tax_settings;
97
-
98
-    /**
99
-     * @deprecated
100
-     * @var EE_Gateway_Config
101
-     */
102
-    public $gateway;
103
-
104
-    /**
105
-     * @var    array $_addon_option_names
106
-     * @access    private
107
-     */
108
-    private $_addon_option_names = array();
109
-
110
-    /**
111
-     * @var    array $_module_route_map
112
-     * @access    private
113
-     */
114
-    private static $_module_route_map = array();
115
-
116
-    /**
117
-     * @var    array $_module_forward_map
118
-     * @access    private
119
-     */
120
-    private static $_module_forward_map = array();
121
-
122
-    /**
123
-     * @var    array $_module_view_map
124
-     * @access    private
125
-     */
126
-    private static $_module_view_map = array();
127
-
128
-
129
-
130
-    /**
131
-     * @singleton method used to instantiate class object
132
-     * @access    public
133
-     * @return EE_Config instance
134
-     */
135
-    public static function instance()
136
-    {
137
-        // check if class object is instantiated, and instantiated properly
138
-        if ( ! self::$_instance instanceof EE_Config) {
139
-            self::$_instance = new self();
140
-        }
141
-        return self::$_instance;
142
-    }
143
-
144
-
145
-
146
-    /**
147
-     * Resets the config
148
-     *
149
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
150
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
151
-     *                               reflect its state in the database
152
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
153
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
154
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
155
-     *                               site was put into maintenance mode)
156
-     * @return EE_Config
157
-     */
158
-    public static function reset($hard_reset = false, $reinstantiate = true)
159
-    {
160
-        if (self::$_instance instanceof EE_Config) {
161
-            if ($hard_reset) {
162
-                self::$_instance->_addon_option_names = array();
163
-                self::$_instance->_initialize_config();
164
-                self::$_instance->update_espresso_config();
165
-            }
166
-            self::$_instance->update_addon_option_names();
167
-        }
168
-        self::$_instance = null;
169
-        //we don't need to reset the static properties imo because those should
170
-        //only change when a module is added or removed. Currently we don't
171
-        //support removing a module during a request when it previously existed
172
-        if ($reinstantiate) {
173
-            return self::instance();
174
-        } else {
175
-            return null;
176
-        }
177
-    }
178
-
179
-
180
-
181
-    /**
182
-     *    class constructor
183
-     *
184
-     * @access    private
185
-     */
186
-    private function __construct()
187
-    {
188
-        do_action('AHEE__EE_Config__construct__begin', $this);
189
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
190
-        // setup empty config classes
191
-        $this->_initialize_config();
192
-        // load existing EE site settings
193
-        $this->_load_core_config();
194
-        // confirm everything loaded correctly and set filtered defaults if not
195
-        $this->_verify_config();
196
-        //  register shortcodes and modules
197
-        add_action(
198
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
199
-            array($this, 'register_shortcodes_and_modules'),
200
-            999
201
-        );
202
-        //  initialize shortcodes and modules
203
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
204
-        // register widgets
205
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
206
-        // shutdown
207
-        add_action('shutdown', array($this, 'shutdown'), 10);
208
-        // construct__end hook
209
-        do_action('AHEE__EE_Config__construct__end', $this);
210
-        // hardcoded hack
211
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
212
-    }
213
-
214
-
215
-
216
-    /**
217
-     * @return boolean
218
-     */
219
-    public static function logging_enabled()
220
-    {
221
-        return self::$_logging_enabled;
222
-    }
223
-
224
-
225
-
226
-    /**
227
-     * use to get the current theme if needed from static context
228
-     *
229
-     * @return string current theme set.
230
-     */
231
-    public static function get_current_theme()
232
-    {
233
-        return isset(self::$_instance->template_settings->current_espresso_theme)
234
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
235
-    }
236
-
237
-
238
-
239
-    /**
240
-     *        _initialize_config
241
-     *
242
-     * @access private
243
-     * @return void
244
-     */
245
-    private function _initialize_config()
246
-    {
247
-        EE_Config::trim_log();
248
-        //set defaults
249
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
250
-        $this->addons = new stdClass();
251
-        // set _module_route_map
252
-        EE_Config::$_module_route_map = array();
253
-        // set _module_forward_map
254
-        EE_Config::$_module_forward_map = array();
255
-        // set _module_view_map
256
-        EE_Config::$_module_view_map = array();
257
-    }
258
-
259
-
260
-
261
-    /**
262
-     *        load core plugin configuration
263
-     *
264
-     * @access private
265
-     * @return void
266
-     */
267
-    private function _load_core_config()
268
-    {
269
-        // load_core_config__start hook
270
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
271
-        $espresso_config = $this->get_espresso_config();
272
-        foreach ($espresso_config as $config => $settings) {
273
-            // load_core_config__start hook
274
-            $settings = apply_filters(
275
-                'FHEE__EE_Config___load_core_config__config_settings',
276
-                $settings,
277
-                $config,
278
-                $this
279
-            );
280
-            if (is_object($settings) && property_exists($this, $config)) {
281
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
282
-                //call configs populate method to ensure any defaults are set for empty values.
283
-                if (method_exists($settings, 'populate')) {
284
-                    $this->{$config}->populate();
285
-                }
286
-                if (method_exists($settings, 'do_hooks')) {
287
-                    $this->{$config}->do_hooks();
288
-                }
289
-            }
290
-        }
291
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
292
-            $this->update_espresso_config();
293
-        }
294
-        // load_core_config__end hook
295
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
296
-    }
297
-
298
-
299
-
300
-    /**
301
-     *    _verify_config
302
-     *
303
-     * @access    protected
304
-     * @return    void
305
-     */
306
-    protected function _verify_config()
307
-    {
308
-        $this->core = $this->core instanceof EE_Core_Config
309
-            ? $this->core
310
-            : new EE_Core_Config();
311
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
312
-        $this->organization = $this->organization instanceof EE_Organization_Config
313
-            ? $this->organization
314
-            : new EE_Organization_Config();
315
-        $this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization',
316
-            $this->organization);
317
-        $this->currency = $this->currency instanceof EE_Currency_Config
318
-            ? $this->currency
319
-            : new EE_Currency_Config();
320
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
321
-        $this->registration = $this->registration instanceof EE_Registration_Config
322
-            ? $this->registration
323
-            : new EE_Registration_Config();
324
-        $this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration',
325
-            $this->registration);
326
-        $this->admin = $this->admin instanceof EE_Admin_Config
327
-            ? $this->admin
328
-            : new EE_Admin_Config();
329
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
330
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
331
-            ? $this->template_settings
332
-            : new EE_Template_Config();
333
-        $this->template_settings = apply_filters(
334
-            'FHEE__EE_Config___initialize_config__template_settings',
335
-            $this->template_settings
336
-        );
337
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
338
-            ? $this->map_settings
339
-            : new EE_Map_Config();
340
-        $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
341
-            $this->map_settings);
342
-        $this->environment = $this->environment instanceof EE_Environment_Config
343
-            ? $this->environment
344
-            : new EE_Environment_Config();
345
-        $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
346
-            $this->environment);
347
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
348
-            ? $this->tax_settings
349
-            : new EE_Tax_Config();
350
-        $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
351
-            $this->tax_settings);
352
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
353
-            ? $this->gateway
354
-            : new EE_Gateway_Config();
355
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
356
-    }
357
-
358
-
359
-
360
-    /**
361
-     *    get_espresso_config
362
-     *
363
-     * @access    public
364
-     * @return    array of espresso config stuff
365
-     */
366
-    public function get_espresso_config()
367
-    {
368
-        // grab espresso configuration
369
-        return apply_filters(
370
-            'FHEE__EE_Config__get_espresso_config__CFG',
371
-            get_option(EE_Config::OPTION_NAME, array())
372
-        );
373
-    }
374
-
375
-
376
-
377
-    /**
378
-     *    double_check_config_comparison
379
-     *
380
-     * @access    public
381
-     * @param string $option
382
-     * @param        $old_value
383
-     * @param        $value
384
-     */
385
-    public function double_check_config_comparison($option = '', $old_value, $value)
386
-    {
387
-        // make sure we're checking the ee config
388
-        if ($option === EE_Config::OPTION_NAME) {
389
-            // run a loose comparison of the old value against the new value for type and properties,
390
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
391
-            if ($value != $old_value) {
392
-                // if they are NOT the same, then remove the hook,
393
-                // which means the subsequent update results will be based solely on the update query results
394
-                // the reason we do this is because, as stated above,
395
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
396
-                // this happens PRIOR to serialization and any subsequent update.
397
-                // If values are found to match their previous old value,
398
-                // then WP bails before performing any update.
399
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
400
-                // it just pulled from the db, with the one being passed to it (which will not match).
401
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
402
-                // MySQL MAY ALSO NOT perform the update because
403
-                // the string it sees in the db looks the same as the new one it has been passed!!!
404
-                // This results in the query returning an "affected rows" value of ZERO,
405
-                // which gets returned immediately by WP update_option and looks like an error.
406
-                remove_action('update_option', array($this, 'check_config_updated'));
407
-            }
408
-        }
409
-    }
410
-
411
-
412
-
413
-    /**
414
-     *    update_espresso_config
415
-     *
416
-     * @access   public
417
-     */
418
-    protected function _reset_espresso_addon_config()
419
-    {
420
-        $this->_addon_option_names = array();
421
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
422
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
423
-            $config_class = get_class($addon_config_obj);
424
-            if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
425
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
426
-            }
427
-            $this->addons->{$addon_name} = null;
428
-        }
429
-    }
430
-
431
-
432
-
433
-    /**
434
-     *    update_espresso_config
435
-     *
436
-     * @access   public
437
-     * @param   bool $add_success
438
-     * @param   bool $add_error
439
-     * @return   bool
440
-     */
441
-    public function update_espresso_config($add_success = false, $add_error = true)
442
-    {
443
-        // don't allow config updates during WP heartbeats
444
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
445
-            return false;
446
-        }
447
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
448
-        //$clone = clone( self::$_instance );
449
-        //self::$_instance = NULL;
450
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
451
-        $this->_reset_espresso_addon_config();
452
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
453
-        // but BEFORE the actual update occurs
454
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
455
-        // now update "ee_config"
456
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
457
-        EE_Config::log(EE_Config::OPTION_NAME);
458
-        // if not saved... check if the hook we just added still exists;
459
-        // if it does, it means one of two things:
460
-        // 		that update_option bailed at the ( $value === $old_value ) conditional,
461
-        //		 or...
462
-        // 		the db update query returned 0 rows affected
463
-        // 		(probably because the data  value was the same from it's perspective)
464
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
465
-        // but just means no update occurred, so don't display an error to the user.
466
-        // BUT... if update_option returns FALSE, AND the hook is missing,
467
-        // then it means that something truly went wrong
468
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
469
-        // remove our action since we don't want it in the system anymore
470
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
471
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
472
-        //self::$_instance = $clone;
473
-        //unset( $clone );
474
-        // if config remains the same or was updated successfully
475
-        if ($saved) {
476
-            if ($add_success) {
477
-                EE_Error::add_success(
478
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
479
-                    __FILE__,
480
-                    __FUNCTION__,
481
-                    __LINE__
482
-                );
483
-            }
484
-            return true;
485
-        } else {
486
-            if ($add_error) {
487
-                EE_Error::add_error(
488
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
489
-                    __FILE__,
490
-                    __FUNCTION__,
491
-                    __LINE__
492
-                );
493
-            }
494
-            return false;
495
-        }
496
-    }
497
-
498
-
499
-
500
-    /**
501
-     *    _verify_config_params
502
-     *
503
-     * @access    private
504
-     * @param    string         $section
505
-     * @param    string         $name
506
-     * @param    string         $config_class
507
-     * @param    EE_Config_Base $config_obj
508
-     * @param    array          $tests_to_run
509
-     * @param    bool           $display_errors
510
-     * @return    bool    TRUE on success, FALSE on fail
511
-     */
512
-    private function _verify_config_params(
513
-        $section = '',
514
-        $name = '',
515
-        $config_class = '',
516
-        $config_obj = null,
517
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
518
-        $display_errors = true
519
-    ) {
520
-        try {
521
-            foreach ($tests_to_run as $test) {
522
-                switch ($test) {
523
-                    // TEST #1 : check that section was set
524
-                    case 1 :
525
-                        if (empty($section)) {
526
-                            if ($display_errors) {
527
-                                throw new EE_Error(
528
-                                    sprintf(
529
-                                        __(
530
-                                            'No configuration section has been provided while attempting to save "%s".',
531
-                                            'event_espresso'
532
-                                        ),
533
-                                        $config_class
534
-                                    )
535
-                                );
536
-                            }
537
-                            return false;
538
-                        }
539
-                        break;
540
-                    // TEST #2 : check that settings section exists
541
-                    case 2 :
542
-                        if ( ! isset($this->{$section})) {
543
-                            if ($display_errors) {
544
-                                throw new EE_Error(
545
-                                    sprintf(
546
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
547
-                                        $section
548
-                                    )
549
-                                );
550
-                            }
551
-                            return false;
552
-                        }
553
-                        break;
554
-                    // TEST #3 : check that section is the proper format
555
-                    case 3 :
556
-                        if (
557
-                        ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
558
-                        ) {
559
-                            if ($display_errors) {
560
-                                throw new EE_Error(
561
-                                    sprintf(
562
-                                        __(
563
-                                            'The "%s" configuration settings have not been formatted correctly.',
564
-                                            'event_espresso'
565
-                                        ),
566
-                                        $section
567
-                                    )
568
-                                );
569
-                            }
570
-                            return false;
571
-                        }
572
-                        break;
573
-                    // TEST #4 : check that config section name has been set
574
-                    case 4 :
575
-                        if (empty($name)) {
576
-                            if ($display_errors) {
577
-                                throw new EE_Error(
578
-                                    __(
579
-                                        'No name has been provided for the specific configuration section.',
580
-                                        'event_espresso'
581
-                                    )
582
-                                );
583
-                            }
584
-                            return false;
585
-                        }
586
-                        break;
587
-                    // TEST #5 : check that a config class name has been set
588
-                    case 5 :
589
-                        if (empty($config_class)) {
590
-                            if ($display_errors) {
591
-                                throw new EE_Error(
592
-                                    __(
593
-                                        'No class name has been provided for the specific configuration section.',
594
-                                        'event_espresso'
595
-                                    )
596
-                                );
597
-                            }
598
-                            return false;
599
-                        }
600
-                        break;
601
-                    // TEST #6 : verify config class is accessible
602
-                    case 6 :
603
-                        if ( ! class_exists($config_class)) {
604
-                            if ($display_errors) {
605
-                                throw new EE_Error(
606
-                                    sprintf(
607
-                                        __(
608
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
609
-                                            'event_espresso'
610
-                                        ),
611
-                                        $config_class
612
-                                    )
613
-                                );
614
-                            }
615
-                            return false;
616
-                        }
617
-                        break;
618
-                    // TEST #7 : check that config has even been set
619
-                    case 7 :
620
-                        if ( ! isset($this->{$section}->{$name})) {
621
-                            if ($display_errors) {
622
-                                throw new EE_Error(
623
-                                    sprintf(
624
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
625
-                                        $section,
626
-                                        $name
627
-                                    )
628
-                                );
629
-                            }
630
-                            return false;
631
-                        } else {
632
-                            // and make sure it's not serialized
633
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
634
-                        }
635
-                        break;
636
-                    // TEST #8 : check that config is the requested type
637
-                    case 8 :
638
-                        if ( ! $this->{$section}->{$name} instanceof $config_class) {
639
-                            if ($display_errors) {
640
-                                throw new EE_Error(
641
-                                    sprintf(
642
-                                        __(
643
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
644
-                                            'event_espresso'
645
-                                        ),
646
-                                        $section,
647
-                                        $name,
648
-                                        $config_class
649
-                                    )
650
-                                );
651
-                            }
652
-                            return false;
653
-                        }
654
-                        break;
655
-                    // TEST #9 : verify config object
656
-                    case 9 :
657
-                        if ( ! $config_obj instanceof EE_Config_Base) {
658
-                            if ($display_errors) {
659
-                                throw new EE_Error(
660
-                                    sprintf(
661
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
662
-                                        print_r($config_obj, true)
663
-                                    )
664
-                                );
665
-                            }
666
-                            return false;
667
-                        }
668
-                        break;
669
-                }
670
-            }
671
-        } catch (EE_Error $e) {
672
-            $e->get_error();
673
-        }
674
-        // you have successfully run the gauntlet
675
-        return true;
676
-    }
677
-
678
-
679
-
680
-    /**
681
-     *    _generate_config_option_name
682
-     *
683
-     * @access        protected
684
-     * @param        string $section
685
-     * @param        string $name
686
-     * @return        string
687
-     */
688
-    private function _generate_config_option_name($section = '', $name = '')
689
-    {
690
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
691
-    }
692
-
693
-
694
-
695
-    /**
696
-     *    _set_config_class
697
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
698
-     *
699
-     * @access    private
700
-     * @param    string $config_class
701
-     * @param    string $name
702
-     * @return    string
703
-     */
704
-    private function _set_config_class($config_class = '', $name = '')
705
-    {
706
-        return ! empty($config_class)
707
-            ? $config_class
708
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
709
-    }
710
-
711
-
712
-
713
-    /**
714
-     *    set_config
715
-     *
716
-     * @access    protected
717
-     * @param    string         $section
718
-     * @param    string         $name
719
-     * @param    string         $config_class
720
-     * @param    EE_Config_Base $config_obj
721
-     * @return    EE_Config_Base
722
-     */
723
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
724
-    {
725
-        // ensure config class is set to something
726
-        $config_class = $this->_set_config_class($config_class, $name);
727
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
728
-        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
729
-            return null;
730
-        }
731
-        $config_option_name = $this->_generate_config_option_name($section, $name);
732
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
733
-        if ( ! isset($this->_addon_option_names[$config_option_name])) {
734
-            $this->_addon_option_names[$config_option_name] = $config_class;
735
-            $this->update_addon_option_names();
736
-        }
737
-        // verify the incoming config object but suppress errors
738
-        if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
739
-            $config_obj = new $config_class();
740
-        }
741
-        if (get_option($config_option_name)) {
742
-            EE_Config::log($config_option_name);
743
-            update_option($config_option_name, $config_obj);
744
-            $this->{$section}->{$name} = $config_obj;
745
-            return $this->{$section}->{$name};
746
-        } else {
747
-            // create a wp-option for this config
748
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
749
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
750
-                return $this->{$section}->{$name};
751
-            } else {
752
-                EE_Error::add_error(
753
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
754
-                    __FILE__,
755
-                    __FUNCTION__,
756
-                    __LINE__
757
-                );
758
-                return null;
759
-            }
760
-        }
761
-    }
762
-
763
-
764
-
765
-    /**
766
-     *    update_config
767
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
768
-     *
769
-     * @access    public
770
-     * @param    string                $section
771
-     * @param    string                $name
772
-     * @param    EE_Config_Base|string $config_obj
773
-     * @param    bool                  $throw_errors
774
-     * @return    bool
775
-     */
776
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
777
-    {
778
-        // don't allow config updates during WP heartbeats
779
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
780
-            return false;
781
-        }
782
-        $config_obj = maybe_unserialize($config_obj);
783
-        // get class name of the incoming object
784
-        $config_class = get_class($config_obj);
785
-        // run tests 1-5 and 9 to verify config
786
-        if ( ! $this->_verify_config_params(
787
-            $section,
788
-            $name,
789
-            $config_class,
790
-            $config_obj,
791
-            array(1, 2, 3, 4, 7, 9)
792
-        )
793
-        ) {
794
-            return false;
795
-        }
796
-        $config_option_name = $this->_generate_config_option_name($section, $name);
797
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
798
-        if ( ! isset($this->_addon_option_names[$config_option_name])) {
799
-            // save new config to db
800
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
801
-                return true;
802
-            }
803
-        } else {
804
-            // first check if the record already exists
805
-            $existing_config = get_option($config_option_name);
806
-            $config_obj = serialize($config_obj);
807
-            // just return if db record is already up to date (NOT type safe comparison)
808
-            if ($existing_config == $config_obj) {
809
-                $this->{$section}->{$name} = $config_obj;
810
-                return true;
811
-            } else if (update_option($config_option_name, $config_obj)) {
812
-                EE_Config::log($config_option_name);
813
-                // update wp-option for this config class
814
-                $this->{$section}->{$name} = $config_obj;
815
-                return true;
816
-            } elseif ($throw_errors) {
817
-                EE_Error::add_error(
818
-                    sprintf(
819
-                        __(
820
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
821
-                            'event_espresso'
822
-                        ),
823
-                        $config_class,
824
-                        'EE_Config->' . $section . '->' . $name
825
-                    ),
826
-                    __FILE__,
827
-                    __FUNCTION__,
828
-                    __LINE__
829
-                );
830
-            }
831
-        }
832
-        return false;
833
-    }
834
-
835
-
836
-
837
-    /**
838
-     *    get_config
839
-     *
840
-     * @access    public
841
-     * @param    string $section
842
-     * @param    string $name
843
-     * @param    string $config_class
844
-     * @return    mixed EE_Config_Base | NULL
845
-     */
846
-    public function get_config($section = '', $name = '', $config_class = '')
847
-    {
848
-        // ensure config class is set to something
849
-        $config_class = $this->_set_config_class($config_class, $name);
850
-        // run tests 1-4, 6 and 7 to verify that all params have been set
851
-        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
852
-            return null;
853
-        }
854
-        // now test if the requested config object exists, but suppress errors
855
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
856
-            // config already exists, so pass it back
857
-            return $this->{$section}->{$name};
858
-        }
859
-        // load config option from db if it exists
860
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
861
-        // verify the newly retrieved config object, but suppress errors
862
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
863
-            // config is good, so set it and pass it back
864
-            $this->{$section}->{$name} = $config_obj;
865
-            return $this->{$section}->{$name};
866
-        }
867
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
868
-        $config_obj = $this->set_config($section, $name, $config_class);
869
-        // verify the newly created config object
870
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
871
-            return $this->{$section}->{$name};
872
-        } else {
873
-            EE_Error::add_error(
874
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
875
-                __FILE__,
876
-                __FUNCTION__,
877
-                __LINE__
878
-            );
879
-        }
880
-        return null;
881
-    }
882
-
883
-
884
-
885
-    /**
886
-     *    get_config_option
887
-     *
888
-     * @access    public
889
-     * @param    string $config_option_name
890
-     * @return    mixed EE_Config_Base | FALSE
891
-     */
892
-    public function get_config_option($config_option_name = '')
893
-    {
894
-        // retrieve the wp-option for this config class.
895
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
896
-        if (empty($config_option)) {
897
-            EE_Config::log($config_option_name . '-NOT-FOUND');
898
-        }
899
-        return $config_option;
900
-    }
901
-
902
-
903
-
904
-    /**
905
-     * log
906
-     *
907
-     * @param string $config_option_name
908
-     */
909
-    public static function log($config_option_name = '')
910
-    {
911
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
912
-            $config_log = get_option(EE_Config::LOG_NAME, array());
913
-            //copy incoming $_REQUEST and sanitize it so we can save it
914
-            $_request = $_REQUEST;
915
-            array_walk_recursive($_request, 'sanitize_text_field');
916
-            $config_log[(string)microtime(true)] = array(
917
-                'config_name' => $config_option_name,
918
-                'request'     => $_request,
919
-            );
920
-            update_option(EE_Config::LOG_NAME, $config_log);
921
-        }
922
-    }
923
-
924
-
925
-
926
-    /**
927
-     * trim_log
928
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
929
-     */
930
-    public static function trim_log()
931
-    {
932
-        if ( ! EE_Config::logging_enabled()) {
933
-            return;
934
-        }
935
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
936
-        $log_length = count($config_log);
937
-        if ($log_length > EE_Config::LOG_LENGTH) {
938
-            ksort($config_log);
939
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
940
-            update_option(EE_Config::LOG_NAME, $config_log);
941
-        }
942
-    }
943
-
944
-
945
-
946
-    /**
947
-     *    get_page_for_posts
948
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
949
-     *    wp-option "page_for_posts", or "posts" if no page is selected
950
-     *
951
-     * @access    public
952
-     * @return    string
953
-     */
954
-    public static function get_page_for_posts()
955
-    {
956
-        $page_for_posts = get_option('page_for_posts');
957
-        if ( ! $page_for_posts) {
958
-            return 'posts';
959
-        }
960
-        /** @type WPDB $wpdb */
961
-        global $wpdb;
962
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
963
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
964
-    }
965
-
966
-
967
-
968
-    /**
969
-     *    register_shortcodes_and_modules.
970
-     *    At this point, it's too early to tell if we're maintenance mode or not.
971
-     *    In fact, this is where we give modules a chance to let core know they exist
972
-     *    so they can help trigger maintenance mode if it's needed
973
-     *
974
-     * @access    public
975
-     * @return    void
976
-     */
977
-    public function register_shortcodes_and_modules()
978
-    {
979
-        // allow shortcodes to register with WP and to set hooks for the rest of the system
980
-        EE_Registry::instance()->shortcodes = $this->_register_shortcodes();
981
-        // allow modules to set hooks for the rest of the system
982
-        EE_Registry::instance()->modules = $this->_register_modules();
983
-    }
984
-
985
-
986
-
987
-    /**
988
-     *    initialize_shortcodes_and_modules
989
-     *    meaning they can start adding their hooks to get stuff done
990
-     *
991
-     * @access    public
992
-     * @return    void
993
-     */
994
-    public function initialize_shortcodes_and_modules()
995
-    {
996
-        // allow shortcodes to set hooks for the rest of the system
997
-        $this->_initialize_shortcodes();
998
-        // allow modules to set hooks for the rest of the system
999
-        $this->_initialize_modules();
1000
-    }
1001
-
1002
-
1003
-
1004
-    /**
1005
-     *    widgets_init
1006
-     *
1007
-     * @access private
1008
-     * @return void
1009
-     */
1010
-    public function widgets_init()
1011
-    {
1012
-        //only init widgets on admin pages when not in complete maintenance, and
1013
-        //on frontend when not in any maintenance mode
1014
-        if (
1015
-            ! EE_Maintenance_Mode::instance()->level()
1016
-            || (
1017
-                is_admin()
1018
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1019
-            )
1020
-        ) {
1021
-            // grab list of installed widgets
1022
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1023
-            // filter list of modules to register
1024
-            $widgets_to_register = apply_filters(
1025
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1026
-                $widgets_to_register
1027
-            );
1028
-            if ( ! empty($widgets_to_register)) {
1029
-                // cycle thru widget folders
1030
-                foreach ($widgets_to_register as $widget_path) {
1031
-                    // add to list of installed widget modules
1032
-                    EE_Config::register_ee_widget($widget_path);
1033
-                }
1034
-            }
1035
-            // filter list of installed modules
1036
-            EE_Registry::instance()->widgets = apply_filters(
1037
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1038
-                EE_Registry::instance()->widgets
1039
-            );
1040
-        }
1041
-    }
1042
-
1043
-
1044
-
1045
-    /**
1046
-     *    register_ee_widget - makes core aware of this widget
1047
-     *
1048
-     * @access    public
1049
-     * @param    string $widget_path - full path up to and including widget folder
1050
-     * @return    void
1051
-     */
1052
-    public static function register_ee_widget($widget_path = null)
1053
-    {
1054
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1055
-        $widget_ext = '.widget.php';
1056
-        // make all separators match
1057
-        $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1058
-        // does the file path INCLUDE the actual file name as part of the path ?
1059
-        if (strpos($widget_path, $widget_ext) !== false) {
1060
-            // grab and shortcode file name from directory name and break apart at dots
1061
-            $file_name = explode('.', basename($widget_path));
1062
-            // take first segment from file name pieces and remove class prefix if it exists
1063
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1064
-            // sanitize shortcode directory name
1065
-            $widget = sanitize_key($widget);
1066
-            // now we need to rebuild the shortcode path
1067
-            $widget_path = explode(DS, $widget_path);
1068
-            // remove last segment
1069
-            array_pop($widget_path);
1070
-            // glue it back together
1071
-            $widget_path = implode(DS, $widget_path);
1072
-        } else {
1073
-            // grab and sanitize widget directory name
1074
-            $widget = sanitize_key(basename($widget_path));
1075
-        }
1076
-        // create classname from widget directory name
1077
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1078
-        // add class prefix
1079
-        $widget_class = 'EEW_' . $widget;
1080
-        // does the widget exist ?
1081
-        if ( ! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1082
-            $msg = sprintf(
1083
-                __(
1084
-                    'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1085
-                    'event_espresso'
1086
-                ),
1087
-                $widget_class,
1088
-                $widget_path . DS . $widget_class . $widget_ext
1089
-            );
1090
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1091
-            return;
1092
-        }
1093
-        // load the widget class file
1094
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1095
-        // verify that class exists
1096
-        if ( ! class_exists($widget_class)) {
1097
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1098
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1099
-            return;
1100
-        }
1101
-        register_widget($widget_class);
1102
-        // add to array of registered widgets
1103
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1104
-    }
1105
-
1106
-
1107
-
1108
-    /**
1109
-     *        _register_shortcodes
1110
-     *
1111
-     * @access private
1112
-     * @return array
1113
-     */
1114
-    private function _register_shortcodes()
1115
-    {
1116
-        // grab list of installed shortcodes
1117
-        $shortcodes_to_register = glob(EE_SHORTCODES . '*', GLOB_ONLYDIR);
1118
-        // filter list of modules to register
1119
-        $shortcodes_to_register = apply_filters(
1120
-            'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
1121
-            $shortcodes_to_register
1122
-        );
1123
-        if ( ! empty($shortcodes_to_register)) {
1124
-            // cycle thru shortcode folders
1125
-            foreach ($shortcodes_to_register as $shortcode_path) {
1126
-                // add to list of installed shortcode modules
1127
-                EE_Config::register_shortcode($shortcode_path);
1128
-            }
1129
-        }
1130
-        // filter list of installed modules
1131
-        return apply_filters(
1132
-            'FHEE__EE_Config___register_shortcodes__installed_shortcodes',
1133
-            EE_Registry::instance()->shortcodes
1134
-        );
1135
-    }
1136
-
1137
-
1138
-
1139
-    /**
1140
-     *    register_shortcode - makes core aware of this shortcode
1141
-     *
1142
-     * @access    public
1143
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1144
-     * @return    bool
1145
-     */
1146
-    public static function register_shortcode($shortcode_path = null)
1147
-    {
1148
-        do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
1149
-        $shortcode_ext = '.shortcode.php';
1150
-        // make all separators match
1151
-        $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path);
1152
-        // does the file path INCLUDE the actual file name as part of the path ?
1153
-        if (strpos($shortcode_path, $shortcode_ext) !== false) {
1154
-            // grab shortcode file name from directory name and break apart at dots
1155
-            $shortcode_file = explode('.', basename($shortcode_path));
1156
-            // take first segment from file name pieces and remove class prefix if it exists
1157
-            $shortcode = strpos($shortcode_file[0], 'EES_') === 0
1158
-                ? substr($shortcode_file[0], 4)
1159
-                : $shortcode_file[0];
1160
-            // sanitize shortcode directory name
1161
-            $shortcode = sanitize_key($shortcode);
1162
-            // now we need to rebuild the shortcode path
1163
-            $shortcode_path = explode(DS, $shortcode_path);
1164
-            // remove last segment
1165
-            array_pop($shortcode_path);
1166
-            // glue it back together
1167
-            $shortcode_path = implode(DS, $shortcode_path) . DS;
1168
-        } else {
1169
-            // we need to generate the filename based off of the folder name
1170
-            // grab and sanitize shortcode directory name
1171
-            $shortcode = sanitize_key(basename($shortcode_path));
1172
-            $shortcode_path = rtrim($shortcode_path, DS) . DS;
1173
-        }
1174
-        // create classname from shortcode directory or file name
1175
-        $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
1176
-        // add class prefix
1177
-        $shortcode_class = 'EES_' . $shortcode;
1178
-        // does the shortcode exist ?
1179
-        if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) {
1180
-            $msg = sprintf(
1181
-                __(
1182
-                    'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s',
1183
-                    'event_espresso'
1184
-                ),
1185
-                $shortcode_class,
1186
-                $shortcode_path . DS . $shortcode_class . $shortcode_ext
1187
-            );
1188
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1189
-            return false;
1190
-        }
1191
-        // load the shortcode class file
1192
-        require_once($shortcode_path . $shortcode_class . $shortcode_ext);
1193
-        // verify that class exists
1194
-        if ( ! class_exists($shortcode_class)) {
1195
-            $msg = sprintf(
1196
-                __('The requested %s shortcode class does not exist.', 'event_espresso'),
1197
-                $shortcode_class
1198
-            );
1199
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1200
-            return false;
1201
-        }
1202
-        $shortcode = strtoupper($shortcode);
1203
-        // add to array of registered shortcodes
1204
-        EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
1205
-        return true;
1206
-    }
1207
-
1208
-
1209
-
1210
-    /**
1211
-     *        _register_modules
1212
-     *
1213
-     * @access private
1214
-     * @return array
1215
-     */
1216
-    private function _register_modules()
1217
-    {
1218
-        // grab list of installed modules
1219
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1220
-        // filter list of modules to register
1221
-        $modules_to_register = apply_filters(
1222
-            'FHEE__EE_Config__register_modules__modules_to_register',
1223
-            $modules_to_register
1224
-        );
1225
-        if ( ! empty($modules_to_register)) {
1226
-            // loop through folders
1227
-            foreach ($modules_to_register as $module_path) {
1228
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1229
-                if (
1230
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1231
-                    && $module_path !== EE_MODULES . 'gateways'
1232
-                ) {
1233
-                    // add to list of installed modules
1234
-                    EE_Config::register_module($module_path);
1235
-                }
1236
-            }
1237
-        }
1238
-        // filter list of installed modules
1239
-        return apply_filters(
1240
-            'FHEE__EE_Config___register_modules__installed_modules',
1241
-            EE_Registry::instance()->modules
1242
-        );
1243
-    }
1244
-
1245
-
1246
-
1247
-    /**
1248
-     *    register_module - makes core aware of this module
1249
-     *
1250
-     * @access    public
1251
-     * @param    string $module_path - full path up to and including module folder
1252
-     * @return    bool
1253
-     */
1254
-    public static function register_module($module_path = null)
1255
-    {
1256
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1257
-        $module_ext = '.module.php';
1258
-        // make all separators match
1259
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1260
-        // does the file path INCLUDE the actual file name as part of the path ?
1261
-        if (strpos($module_path, $module_ext) !== false) {
1262
-            // grab and shortcode file name from directory name and break apart at dots
1263
-            $module_file = explode('.', basename($module_path));
1264
-            // now we need to rebuild the shortcode path
1265
-            $module_path = explode(DS, $module_path);
1266
-            // remove last segment
1267
-            array_pop($module_path);
1268
-            // glue it back together
1269
-            $module_path = implode(DS, $module_path) . DS;
1270
-            // take first segment from file name pieces and sanitize it
1271
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1272
-            // ensure class prefix is added
1273
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1274
-        } else {
1275
-            // we need to generate the filename based off of the folder name
1276
-            // grab and sanitize module name
1277
-            $module = strtolower(basename($module_path));
1278
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1279
-            // like trailingslashit()
1280
-            $module_path = rtrim($module_path, DS) . DS;
1281
-            // create classname from module directory name
1282
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1283
-            // add class prefix
1284
-            $module_class = 'EED_' . $module;
1285
-        }
1286
-        // does the module exist ?
1287
-        if ( ! is_readable($module_path . DS . $module_class . $module_ext)) {
1288
-            $msg = sprintf(
1289
-                __(
1290
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1291
-                    'event_espresso'
1292
-                ),
1293
-                $module
1294
-            );
1295
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1296
-            return false;
1297
-        }
1298
-        // load the module class file
1299
-        require_once($module_path . $module_class . $module_ext);
1300
-        // verify that class exists
1301
-        if ( ! class_exists($module_class)) {
1302
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1303
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1304
-            return false;
1305
-        }
1306
-        // add to array of registered modules
1307
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1308
-        do_action(
1309
-            'AHEE__EE_Config__register_module__complete',
1310
-            $module_class,
1311
-            EE_Registry::instance()->modules->{$module_class}
1312
-        );
1313
-        return true;
1314
-    }
1315
-
1316
-
1317
-
1318
-    /**
1319
-     *    _initialize_shortcodes
1320
-     *    allow shortcodes to set hooks for the rest of the system
1321
-     *
1322
-     * @access private
1323
-     * @return void
1324
-     */
1325
-    private function _initialize_shortcodes()
1326
-    {
1327
-        // cycle thru shortcode folders
1328
-        foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) {
1329
-            // add class prefix
1330
-            $shortcode_class = 'EES_' . $shortcode;
1331
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1332
-            // which set hooks ?
1333
-            if (is_admin()) {
1334
-                // fire immediately
1335
-                call_user_func(array($shortcode_class, 'set_hooks_admin'));
1336
-            } else {
1337
-                // delay until other systems are online
1338
-                add_action(
1339
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1340
-                    array($shortcode_class, 'set_hooks')
1341
-                );
1342
-                // convert classname to UPPERCASE and create WP shortcode.
1343
-                $shortcode_tag = strtoupper($shortcode);
1344
-                // but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor'
1345
-                if ( ! shortcode_exists($shortcode_tag)) {
1346
-                    // NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes()
1347
-                    add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
1348
-                }
1349
-            }
1350
-        }
1351
-    }
1352
-
1353
-
1354
-
1355
-    /**
1356
-     *    _initialize_modules
1357
-     *    allow modules to set hooks for the rest of the system
1358
-     *
1359
-     * @access private
1360
-     * @return void
1361
-     */
1362
-    private function _initialize_modules()
1363
-    {
1364
-        // cycle thru shortcode folders
1365
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1366
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1367
-            // which set hooks ?
1368
-            if (is_admin()) {
1369
-                // fire immediately
1370
-                call_user_func(array($module_class, 'set_hooks_admin'));
1371
-            } else {
1372
-                // delay until other systems are online
1373
-                add_action(
1374
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1375
-                    array($module_class, 'set_hooks')
1376
-                );
1377
-            }
1378
-        }
1379
-    }
1380
-
1381
-
1382
-
1383
-    /**
1384
-     *    register_route - adds module method routes to route_map
1385
-     *
1386
-     * @access    public
1387
-     * @param    string $route       - "pretty" public alias for module method
1388
-     * @param    string $module      - module name (classname without EED_ prefix)
1389
-     * @param    string $method_name - the actual module method to be routed to
1390
-     * @param    string $key         - url param key indicating a route is being called
1391
-     * @return    bool
1392
-     */
1393
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1394
-    {
1395
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1396
-        $module = str_replace('EED_', '', $module);
1397
-        $module_class = 'EED_' . $module;
1398
-        if ( ! isset(EE_Registry::instance()->modules->{$module_class})) {
1399
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1400
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1401
-            return false;
1402
-        }
1403
-        if (empty($route)) {
1404
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1405
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1406
-            return false;
1407
-        }
1408
-        if ( ! method_exists('EED_' . $module, $method_name)) {
1409
-            $msg = sprintf(
1410
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1411
-                $route
1412
-            );
1413
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1414
-            return false;
1415
-        }
1416
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1417
-        return true;
1418
-    }
1419
-
1420
-
1421
-
1422
-    /**
1423
-     *    get_route - get module method route
1424
-     *
1425
-     * @access    public
1426
-     * @param    string $route - "pretty" public alias for module method
1427
-     * @param    string $key   - url param key indicating a route is being called
1428
-     * @return    string
1429
-     */
1430
-    public static function get_route($route = null, $key = 'ee')
1431
-    {
1432
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1433
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1434
-        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1435
-            return EE_Config::$_module_route_map[$key][$route];
1436
-        }
1437
-        return null;
1438
-    }
1439
-
1440
-
1441
-
1442
-    /**
1443
-     *    get_routes - get ALL module method routes
1444
-     *
1445
-     * @access    public
1446
-     * @return    array
1447
-     */
1448
-    public static function get_routes()
1449
-    {
1450
-        return EE_Config::$_module_route_map;
1451
-    }
1452
-
1453
-
1454
-
1455
-    /**
1456
-     *    register_forward - allows modules to forward request to another module for further processing
1457
-     *
1458
-     * @access    public
1459
-     * @param    string       $route   - "pretty" public alias for module method
1460
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1461
-     *                                 class, allows different forwards to be served based on status
1462
-     * @param    array|string $forward - function name or array( class, method )
1463
-     * @param    string       $key     - url param key indicating a route is being called
1464
-     * @return    bool
1465
-     */
1466
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1467
-    {
1468
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1469
-        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1470
-            $msg = sprintf(
1471
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1472
-                $route
1473
-            );
1474
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1475
-            return false;
1476
-        }
1477
-        if (empty($forward)) {
1478
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1479
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1480
-            return false;
1481
-        }
1482
-        if (is_array($forward)) {
1483
-            if ( ! isset($forward[1])) {
1484
-                $msg = sprintf(
1485
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1486
-                    $route
1487
-                );
1488
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1489
-                return false;
1490
-            }
1491
-            if ( ! method_exists($forward[0], $forward[1])) {
1492
-                $msg = sprintf(
1493
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1494
-                    $forward[1],
1495
-                    $route
1496
-                );
1497
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1498
-                return false;
1499
-            }
1500
-        } else if ( ! function_exists($forward)) {
1501
-            $msg = sprintf(
1502
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1503
-                $forward,
1504
-                $route
1505
-            );
1506
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1507
-            return false;
1508
-        }
1509
-        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1510
-        return true;
1511
-    }
1512
-
1513
-
1514
-
1515
-    /**
1516
-     *    get_forward - get forwarding route
1517
-     *
1518
-     * @access    public
1519
-     * @param    string  $route  - "pretty" public alias for module method
1520
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1521
-     *                           allows different forwards to be served based on status
1522
-     * @param    string  $key    - url param key indicating a route is being called
1523
-     * @return    string
1524
-     */
1525
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1526
-    {
1527
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1528
-        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1529
-            return apply_filters(
1530
-                'FHEE__EE_Config__get_forward',
1531
-                EE_Config::$_module_forward_map[$key][$route][$status],
1532
-                $route,
1533
-                $status
1534
-            );
1535
-        }
1536
-        return null;
1537
-    }
1538
-
1539
-
1540
-
1541
-    /**
1542
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1543
-     *    results
1544
-     *
1545
-     * @access    public
1546
-     * @param    string  $route  - "pretty" public alias for module method
1547
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1548
-     *                           allows different views to be served based on status
1549
-     * @param    string  $view
1550
-     * @param    string  $key    - url param key indicating a route is being called
1551
-     * @return    bool
1552
-     */
1553
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1554
-    {
1555
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1556
-        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1557
-            $msg = sprintf(
1558
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1559
-                $route
1560
-            );
1561
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1562
-            return false;
1563
-        }
1564
-        if ( ! is_readable($view)) {
1565
-            $msg = sprintf(
1566
-                __(
1567
-                    'The %s view file could not be found or is not readable due to file permissions.',
1568
-                    'event_espresso'
1569
-                ),
1570
-                $view
1571
-            );
1572
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1573
-            return false;
1574
-        }
1575
-        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1576
-        return true;
1577
-    }
1578
-
1579
-
1580
-
1581
-    /**
1582
-     *    get_view - get view for route and status
1583
-     *
1584
-     * @access    public
1585
-     * @param    string  $route  - "pretty" public alias for module method
1586
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1587
-     *                           allows different views to be served based on status
1588
-     * @param    string  $key    - url param key indicating a route is being called
1589
-     * @return    string
1590
-     */
1591
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1592
-    {
1593
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1594
-        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1595
-            return apply_filters(
1596
-                'FHEE__EE_Config__get_view',
1597
-                EE_Config::$_module_view_map[$key][$route][$status],
1598
-                $route,
1599
-                $status
1600
-            );
1601
-        }
1602
-        return null;
1603
-    }
1604
-
1605
-
1606
-
1607
-    public function update_addon_option_names()
1608
-    {
1609
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1610
-    }
1611
-
1612
-
1613
-
1614
-    public function shutdown()
1615
-    {
1616
-        $this->update_addon_option_names();
1617
-    }
1618
-
1619
-
1620
-}
1621
-
1622
-
1623
-
1624
-/**
1625
- * Base class used for config classes. These classes should generally not have
1626
- * magic functions in use, except we'll allow them to magically set and get stuff...
1627
- * basically, they should just be well-defined stdClasses
1628
- */
1629
-class EE_Config_Base
1630
-{
1631
-
1632
-    /**
1633
-     * Utility function for escaping the value of a property and returning.
1634
-     *
1635
-     * @param string $property property name (checks to see if exists).
1636
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1637
-     * @throws \EE_Error
1638
-     */
1639
-    public function get_pretty($property)
1640
-    {
1641
-        if ( ! property_exists($this, $property)) {
1642
-            throw new EE_Error(
1643
-                sprintf(
1644
-                    __(
1645
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1646
-                        'event_espresso'
1647
-                    ),
1648
-                    get_class($this),
1649
-                    $property
1650
-                )
1651
-            );
1652
-        }
1653
-        //just handling escaping of strings for now.
1654
-        if (is_string($this->{$property})) {
1655
-            return stripslashes($this->{$property});
1656
-        }
1657
-        return $this->{$property};
1658
-    }
1659
-
1660
-
1661
-
1662
-    public function populate()
1663
-    {
1664
-        //grab defaults via a new instance of this class.
1665
-        $class_name = get_class($this);
1666
-        $defaults = new $class_name;
1667
-        //loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1668
-        //default from our $defaults object.
1669
-        foreach (get_object_vars($defaults) as $property => $value) {
1670
-            if ($this->{$property} === null) {
1671
-                $this->{$property} = $value;
1672
-            }
1673
-        }
1674
-        //cleanup
1675
-        unset($defaults);
1676
-    }
1677
-
1678
-
1679
-    /**
1680
-     *        @ override magic methods
1681
-     *        @ return void
1682
-     */
1683
-    //	public function __get($a) { return apply_filters('FHEE__'.get_class($this).'__get__'.$a,$this->{$a}); }
1684
-    //	public function __set($a,$b) { return apply_filters('FHEE__'.get_class($this).'__set__'.$a, $this->{$a} = $b ); }
1685
-    /**
1686
-     *        __isset
1687
-     *
1688
-     * @param $a
1689
-     * @return bool
1690
-     */
1691
-    public function __isset($a)
1692
-    {
1693
-        return false;
1694
-    }
1695
-
1696
-
1697
-
1698
-    /**
1699
-     *        __unset
1700
-     *
1701
-     * @param $a
1702
-     * @return bool
1703
-     */
1704
-    public function __unset($a)
1705
-    {
1706
-        return false;
1707
-    }
1708
-
1709
-
1710
-
1711
-    /**
1712
-     *        __clone
1713
-     */
1714
-    public function __clone()
1715
-    {
1716
-    }
1717
-
1718
-
1719
-
1720
-    /**
1721
-     *        __wakeup
1722
-     */
1723
-    public function __wakeup()
1724
-    {
1725
-    }
1726
-
1727
-
1728
-
1729
-    /**
1730
-     *        __destruct
1731
-     */
1732
-    public function __destruct()
1733
-    {
1734
-    }
1735
-}
1736
-
1737
-
1738
-
1739
-/**
1740
- * Class for defining what's in the EE_Config relating to registration settings
1741
- */
1742
-class EE_Core_Config extends EE_Config_Base
1743
-{
1744
-
1745
-    public $current_blog_id;
1746
-
1747
-    public $ee_ueip_optin;
1748
-
1749
-    public $ee_ueip_has_notified;
1750
-
1751
-    /**
1752
-     * Not to be confused with the 4 critical page variables (See
1753
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1754
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1755
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1756
-     *
1757
-     * @var array
1758
-     */
1759
-    public $post_shortcodes;
1760
-
1761
-    public $module_route_map;
1762
-
1763
-    public $module_forward_map;
1764
-
1765
-    public $module_view_map;
1766
-
1767
-    /**
1768
-     * The next 4 vars are the IDs of critical EE pages.
1769
-     *
1770
-     * @var int
1771
-     */
1772
-    public $reg_page_id;
1773
-
1774
-    public $txn_page_id;
1775
-
1776
-    public $thank_you_page_id;
1777
-
1778
-    public $cancel_page_id;
1779
-
1780
-    /**
1781
-     * The next 4 vars are the URLs of critical EE pages.
1782
-     *
1783
-     * @var int
1784
-     */
1785
-    public $reg_page_url;
1786
-
1787
-    public $txn_page_url;
1788
-
1789
-    public $thank_you_page_url;
1790
-
1791
-    public $cancel_page_url;
1792
-
1793
-    /**
1794
-     * The next vars relate to the custom slugs for EE CPT routes
1795
-     */
1796
-    public $event_cpt_slug;
1797
-
1798
-
1799
-    /**
1800
-     * This caches the _ee_ueip_option in case this config is reset in the same
1801
-     * request across blog switches in a multisite context.
1802
-     * Avoids extra queries to the db for this option.
1803
-     *
1804
-     * @var bool
1805
-     */
1806
-    public static $ee_ueip_option;
1807
-
1808
-
1809
-
1810
-    /**
1811
-     *    class constructor
1812
-     *
1813
-     * @access    public
1814
-     */
1815
-    public function __construct()
1816
-    {
1817
-        // set default organization settings
1818
-        $this->current_blog_id = get_current_blog_id();
1819
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1820
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1821
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1822
-        $this->post_shortcodes = array();
1823
-        $this->module_route_map = array();
1824
-        $this->module_forward_map = array();
1825
-        $this->module_view_map = array();
1826
-        // critical EE page IDs
1827
-        $this->reg_page_id = 0;
1828
-        $this->txn_page_id = 0;
1829
-        $this->thank_you_page_id = 0;
1830
-        $this->cancel_page_id = 0;
1831
-        // critical EE page URLs
1832
-        $this->reg_page_url = '';
1833
-        $this->txn_page_url = '';
1834
-        $this->thank_you_page_url = '';
1835
-        $this->cancel_page_url = '';
1836
-        //cpt slugs
1837
-        $this->event_cpt_slug = __('events', 'event_espresso');
1838
-        //ueip constant check
1839
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1840
-            $this->ee_ueip_optin = false;
1841
-            $this->ee_ueip_has_notified = true;
1842
-        }
1843
-    }
1844
-
1845
-
1846
-
1847
-    /**
1848
-     * @return array
1849
-     */
1850
-    public function get_critical_pages_array()
1851
-    {
1852
-        return array(
1853
-            $this->reg_page_id,
1854
-            $this->txn_page_id,
1855
-            $this->thank_you_page_id,
1856
-            $this->cancel_page_id,
1857
-        );
1858
-    }
1859
-
1860
-
1861
-
1862
-    /**
1863
-     * @return array
1864
-     */
1865
-    public function get_critical_pages_shortcodes_array()
1866
-    {
1867
-        return array(
1868
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1869
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1870
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1871
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1872
-        );
1873
-    }
1874
-
1875
-
1876
-
1877
-    /**
1878
-     *  gets/returns URL for EE reg_page
1879
-     *
1880
-     * @access    public
1881
-     * @return    string
1882
-     */
1883
-    public function reg_page_url()
1884
-    {
1885
-        if ( ! $this->reg_page_url) {
1886
-            $this->reg_page_url = add_query_arg(
1887
-                                      array('uts' => time()),
1888
-                                      get_permalink($this->reg_page_id)
1889
-                                  ) . '#checkout';
1890
-        }
1891
-        return $this->reg_page_url;
1892
-    }
1893
-
1894
-
1895
-
1896
-    /**
1897
-     *  gets/returns URL for EE txn_page
1898
-     *
1899
-     * @param array $query_args like what gets passed to
1900
-     *                          add_query_arg() as the first argument
1901
-     * @access    public
1902
-     * @return    string
1903
-     */
1904
-    public function txn_page_url($query_args = array())
1905
-    {
1906
-        if ( ! $this->txn_page_url) {
1907
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1908
-        }
1909
-        if ($query_args) {
1910
-            return add_query_arg($query_args, $this->txn_page_url);
1911
-        } else {
1912
-            return $this->txn_page_url;
1913
-        }
1914
-    }
1915
-
1916
-
1917
-
1918
-    /**
1919
-     *  gets/returns URL for EE thank_you_page
1920
-     *
1921
-     * @param array $query_args like what gets passed to
1922
-     *                          add_query_arg() as the first argument
1923
-     * @access    public
1924
-     * @return    string
1925
-     */
1926
-    public function thank_you_page_url($query_args = array())
1927
-    {
1928
-        if ( ! $this->thank_you_page_url) {
1929
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1930
-        }
1931
-        if ($query_args) {
1932
-            return add_query_arg($query_args, $this->thank_you_page_url);
1933
-        } else {
1934
-            return $this->thank_you_page_url;
1935
-        }
1936
-    }
1937
-
1938
-
1939
-
1940
-    /**
1941
-     *  gets/returns URL for EE cancel_page
1942
-     *
1943
-     * @access    public
1944
-     * @return    string
1945
-     */
1946
-    public function cancel_page_url()
1947
-    {
1948
-        if ( ! $this->cancel_page_url) {
1949
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1950
-        }
1951
-        return $this->cancel_page_url;
1952
-    }
1953
-
1954
-
1955
-
1956
-    /**
1957
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1958
-     *
1959
-     * @since 4.7.5
1960
-     */
1961
-    protected function _reset_urls()
1962
-    {
1963
-        $this->reg_page_url = '';
1964
-        $this->txn_page_url = '';
1965
-        $this->cancel_page_url = '';
1966
-        $this->thank_you_page_url = '';
1967
-    }
1968
-
1969
-
1970
-
1971
-    /**
1972
-     * Used to return what the optin value is set for the EE User Experience Program.
1973
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1974
-     * on the main site only.
1975
-     *
1976
-     * @return mixed|void
1977
-     */
1978
-    protected function _get_main_ee_ueip_optin()
1979
-    {
1980
-        //if this is the main site then we can just bypass our direct query.
1981
-        if (is_main_site()) {
1982
-            return get_option('ee_ueip_optin', false);
1983
-        }
1984
-        //is this already cached for this request?  If so use it.
1985
-        if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1986
-            return EE_Core_Config::$ee_ueip_option;
1987
-        }
1988
-        global $wpdb;
1989
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1990
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1991
-        $option = 'ee_ueip_optin';
1992
-        //set correct table for query
1993
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1994
-        //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1995
-        //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1996
-        //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1997
-        //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1998
-        //for the purpose of caching.
1999
-        $pre = apply_filters('pre_option_' . $option, false, $option);
2000
-        if (false !== $pre) {
2001
-            EE_Core_Config::$ee_ueip_option = $pre;
2002
-            return EE_Core_Config::$ee_ueip_option;
2003
-        }
2004
-        $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
2005
-            $option));
2006
-        if (is_object($row)) {
2007
-            $value = $row->option_value;
2008
-        } else { //option does not exist so use default.
2009
-            return apply_filters('default_option_' . $option, false, $option);
2010
-        }
2011
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
2012
-        return EE_Core_Config::$ee_ueip_option;
2013
-    }
2014
-
2015
-
2016
-
2017
-    /**
2018
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
2019
-     * on the object.
2020
-     *
2021
-     * @return array
2022
-     */
2023
-    public function __sleep()
2024
-    {
2025
-        //reset all url properties
2026
-        $this->_reset_urls();
2027
-        //return what to save to db
2028
-        return array_keys(get_object_vars($this));
2029
-    }
2030
-
2031
-}
2032
-
2033
-
2034
-
2035
-/**
2036
- * Config class for storing info on the Organization
2037
- */
2038
-class EE_Organization_Config extends EE_Config_Base
2039
-{
2040
-
2041
-    /**
2042
-     * @var string $name
2043
-     * eg EE4.1
2044
-     */
2045
-    public $name;
2046
-
2047
-    /**
2048
-     * @var string $address_1
2049
-     * eg 123 Onna Road
2050
-     */
2051
-    public $address_1;
2052
-
2053
-    /**
2054
-     * @var string $address_2
2055
-     * eg PO Box 123
2056
-     */
2057
-    public $address_2;
2058
-
2059
-    /**
2060
-     * @var string $city
2061
-     * eg Inna City
2062
-     */
2063
-    public $city;
2064
-
2065
-    /**
2066
-     * @var int $STA_ID
2067
-     * eg 4
2068
-     */
2069
-    public $STA_ID;
2070
-
2071
-    /**
2072
-     * @var string $CNT_ISO
2073
-     * eg US
2074
-     */
2075
-    public $CNT_ISO;
2076
-
2077
-    /**
2078
-     * @var string $zip
2079
-     * eg 12345  or V1A 2B3
2080
-     */
2081
-    public $zip;
2082
-
2083
-    /**
2084
-     * @var string $email
2085
-     * eg [email protected]
2086
-     */
2087
-    public $email;
2088
-
2089
-
2090
-    /**
2091
-     * @var string $phone
2092
-     * eg. 111-111-1111
2093
-     */
2094
-    public $phone;
2095
-
2096
-
2097
-    /**
2098
-     * @var string $vat
2099
-     * VAT/Tax Number
2100
-     */
2101
-    public $vat;
2102
-
2103
-    /**
2104
-     * @var string $logo_url
2105
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2106
-     */
2107
-    public $logo_url;
2108
-
2109
-
2110
-    /**
2111
-     * The below are all various properties for holding links to organization social network profiles
2112
-     *
2113
-     * @var string
2114
-     */
2115
-    /**
2116
-     * facebook (facebook.com/profile.name)
2117
-     *
2118
-     * @var string
2119
-     */
2120
-    public $facebook;
2121
-
2122
-
2123
-    /**
2124
-     * twitter (twitter.com/twitter_handle)
2125
-     *
2126
-     * @var string
2127
-     */
2128
-    public $twitter;
2129
-
2130
-
2131
-    /**
2132
-     * linkedin (linkedin.com/in/profile_name)
2133
-     *
2134
-     * @var string
2135
-     */
2136
-    public $linkedin;
2137
-
2138
-
2139
-    /**
2140
-     * pinterest (www.pinterest.com/profile_name)
2141
-     *
2142
-     * @var string
2143
-     */
2144
-    public $pinterest;
2145
-
2146
-
2147
-    /**
2148
-     * google+ (google.com/+profileName)
2149
-     *
2150
-     * @var string
2151
-     */
2152
-    public $google;
2153
-
2154
-
2155
-    /**
2156
-     * instagram (instagram.com/handle)
2157
-     *
2158
-     * @var string
2159
-     */
2160
-    public $instagram;
2161
-
2162
-
2163
-
2164
-    /**
2165
-     *    class constructor
2166
-     *
2167
-     * @access    public
2168
-     */
2169
-    public function __construct()
2170
-    {
2171
-        // set default organization settings
2172
-        $this->name = get_bloginfo('name');
2173
-        $this->address_1 = '123 Onna Road';
2174
-        $this->address_2 = 'PO Box 123';
2175
-        $this->city = 'Inna City';
2176
-        $this->STA_ID = 4;
2177
-        $this->CNT_ISO = 'US';
2178
-        $this->zip = '12345';
2179
-        $this->email = get_bloginfo('admin_email');
2180
-        $this->phone = '';
2181
-        $this->vat = '123456789';
2182
-        $this->logo_url = '';
2183
-        $this->facebook = '';
2184
-        $this->twitter = '';
2185
-        $this->linkedin = '';
2186
-        $this->pinterest = '';
2187
-        $this->google = '';
2188
-        $this->instagram = '';
2189
-    }
2190
-
2191
-}
2192
-
2193
-
2194
-
2195
-/**
2196
- * Class for defining what's in the EE_Config relating to currency
2197
- */
2198
-class EE_Currency_Config extends EE_Config_Base
2199
-{
2200
-
2201
-    /**
2202
-     * @var string $code
2203
-     * eg 'US'
2204
-     */
2205
-    public $code;
2206
-
2207
-    /**
2208
-     * @var string $name
2209
-     * eg 'Dollar'
2210
-     */
2211
-    public $name;
2212
-
2213
-    /**
2214
-     * plural name
2215
-     *
2216
-     * @var string $plural
2217
-     * eg 'Dollars'
2218
-     */
2219
-    public $plural;
2220
-
2221
-    /**
2222
-     * currency sign
2223
-     *
2224
-     * @var string $sign
2225
-     * eg '$'
2226
-     */
2227
-    public $sign;
2228
-
2229
-    /**
2230
-     * Whether the currency sign should come before the number or not
2231
-     *
2232
-     * @var boolean $sign_b4
2233
-     */
2234
-    public $sign_b4;
2235
-
2236
-    /**
2237
-     * How many digits should come after the decimal place
2238
-     *
2239
-     * @var int $dec_plc
2240
-     */
2241
-    public $dec_plc;
2242
-
2243
-    /**
2244
-     * Symbol to use for decimal mark
2245
-     *
2246
-     * @var string $dec_mrk
2247
-     * eg '.'
2248
-     */
2249
-    public $dec_mrk;
2250
-
2251
-    /**
2252
-     * Symbol to use for thousands
2253
-     *
2254
-     * @var string $thsnds
2255
-     * eg ','
2256
-     */
2257
-    public $thsnds;
2258
-
2259
-
2260
-
2261
-    /**
2262
-     *    class constructor
2263
-     *
2264
-     * @access    public
2265
-     * @param string $CNT_ISO
2266
-     * @throws \EE_Error
2267
-     */
2268
-    public function __construct($CNT_ISO = '')
2269
-    {
2270
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2271
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2272
-        // get country code from organization settings or use default
2273
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2274
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2275
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2276
-            : '';
2277
-        // but override if requested
2278
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2279
-        // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2280
-        if (
2281
-            ! empty($CNT_ISO)
2282
-            && EE_Maintenance_Mode::instance()->models_can_query()
2283
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2284
-        ) {
2285
-            // retrieve the country settings from the db, just in case they have been customized
2286
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2287
-            if ($country instanceof EE_Country) {
2288
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2289
-                $this->name = $country->currency_name_single();    // Dollar
2290
-                $this->plural = $country->currency_name_plural();    // Dollars
2291
-                $this->sign = $country->currency_sign();            // currency sign: $
2292
-                $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2293
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2294
-                $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2295
-                $this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2296
-            }
2297
-        }
2298
-        // fallback to hardcoded defaults, in case the above failed
2299
-        if (empty($this->code)) {
2300
-            // set default currency settings
2301
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2302
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2303
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2304
-            $this->sign = '$';    // currency sign: $
2305
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2306
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2307
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2308
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2309
-        }
2310
-    }
2311 1620
 }
2312 1621
 
2313 1622
 
2314 1623
 
2315 1624
 /**
2316
- * Class for defining what's in the EE_Config relating to registration settings
1625
+ * Base class used for config classes. These classes should generally not have
1626
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1627
+ * basically, they should just be well-defined stdClasses
2317 1628
  */
2318
-class EE_Registration_Config extends EE_Config_Base
1629
+class EE_Config_Base
2319 1630
 {
2320 1631
 
2321
-    /**
2322
-     * Default registration status
2323
-     *
2324
-     * @var string $default_STS_ID
2325
-     * eg 'RPP'
2326
-     */
2327
-    public $default_STS_ID;
2328
-
2329
-    /**
2330
-     * level of validation to apply to email addresses
2331
-     *
2332
-     * @var string $email_validation_level
2333
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2334
-     */
2335
-    public $email_validation_level;
2336
-
2337
-    /**
2338
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2339
-     *
2340
-     * @var boolean $show_pending_payment_options
2341
-     */
2342
-    public $show_pending_payment_options;
2343
-
2344
-    /**
2345
-     * Whether to skip the registration confirmation page
2346
-     *
2347
-     * @var boolean $skip_reg_confirmation
2348
-     */
2349
-    public $skip_reg_confirmation;
2350
-
2351
-    /**
2352
-     * an array of SPCO reg steps where:
2353
-     *        the keys denotes the reg step order
2354
-     *        each element consists of an array with the following elements:
2355
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2356
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2357
-     *            "slug" => the URL param used to trigger the reg step
2358
-     *
2359
-     * @var array $reg_steps
2360
-     */
2361
-    public $reg_steps;
2362
-
2363
-    /**
2364
-     * Whether registration confirmation should be the last page of SPCO
2365
-     *
2366
-     * @var boolean $reg_confirmation_last
2367
-     */
2368
-    public $reg_confirmation_last;
2369
-
2370
-    /**
2371
-     * Whether or not to enable the EE Bot Trap
2372
-     *
2373
-     * @var boolean $use_bot_trap
2374
-     */
2375
-    public $use_bot_trap;
2376
-
2377
-    /**
2378
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2379
-     *
2380
-     * @var boolean $use_encryption
2381
-     */
2382
-    public $use_encryption;
2383
-
2384
-    /**
2385
-     * Whether or not to use ReCaptcha
2386
-     *
2387
-     * @var boolean $use_captcha
2388
-     */
2389
-    public $use_captcha;
2390
-
2391
-    /**
2392
-     * ReCaptcha Theme
2393
-     *
2394
-     * @var string $recaptcha_theme
2395
-     *    options: 'dark    ', 'light'
2396
-     */
2397
-    public $recaptcha_theme;
1632
+	/**
1633
+	 * Utility function for escaping the value of a property and returning.
1634
+	 *
1635
+	 * @param string $property property name (checks to see if exists).
1636
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1637
+	 * @throws \EE_Error
1638
+	 */
1639
+	public function get_pretty($property)
1640
+	{
1641
+		if ( ! property_exists($this, $property)) {
1642
+			throw new EE_Error(
1643
+				sprintf(
1644
+					__(
1645
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1646
+						'event_espresso'
1647
+					),
1648
+					get_class($this),
1649
+					$property
1650
+				)
1651
+			);
1652
+		}
1653
+		//just handling escaping of strings for now.
1654
+		if (is_string($this->{$property})) {
1655
+			return stripslashes($this->{$property});
1656
+		}
1657
+		return $this->{$property};
1658
+	}
1659
+
1660
+
1661
+
1662
+	public function populate()
1663
+	{
1664
+		//grab defaults via a new instance of this class.
1665
+		$class_name = get_class($this);
1666
+		$defaults = new $class_name;
1667
+		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1668
+		//default from our $defaults object.
1669
+		foreach (get_object_vars($defaults) as $property => $value) {
1670
+			if ($this->{$property} === null) {
1671
+				$this->{$property} = $value;
1672
+			}
1673
+		}
1674
+		//cleanup
1675
+		unset($defaults);
1676
+	}
1677
+
1678
+
1679
+	/**
1680
+	 *        @ override magic methods
1681
+	 *        @ return void
1682
+	 */
1683
+	//	public function __get($a) { return apply_filters('FHEE__'.get_class($this).'__get__'.$a,$this->{$a}); }
1684
+	//	public function __set($a,$b) { return apply_filters('FHEE__'.get_class($this).'__set__'.$a, $this->{$a} = $b ); }
1685
+	/**
1686
+	 *        __isset
1687
+	 *
1688
+	 * @param $a
1689
+	 * @return bool
1690
+	 */
1691
+	public function __isset($a)
1692
+	{
1693
+		return false;
1694
+	}
1695
+
1696
+
1697
+
1698
+	/**
1699
+	 *        __unset
1700
+	 *
1701
+	 * @param $a
1702
+	 * @return bool
1703
+	 */
1704
+	public function __unset($a)
1705
+	{
1706
+		return false;
1707
+	}
1708
+
1709
+
1710
+
1711
+	/**
1712
+	 *        __clone
1713
+	 */
1714
+	public function __clone()
1715
+	{
1716
+	}
1717
+
1718
+
1719
+
1720
+	/**
1721
+	 *        __wakeup
1722
+	 */
1723
+	public function __wakeup()
1724
+	{
1725
+	}
1726
+
1727
+
1728
+
1729
+	/**
1730
+	 *        __destruct
1731
+	 */
1732
+	public function __destruct()
1733
+	{
1734
+	}
1735
+}
2398 1736
 
2399
-    /**
2400
-     * ReCaptcha Type
2401
-     *
2402
-     * @var string $recaptcha_type
2403
-     *    options: 'audio', 'image'
2404
-     */
2405
-    public $recaptcha_type;
2406 1737
 
2407
-    /**
2408
-     * ReCaptcha language
2409
-     *
2410
-     * @var string $recaptcha_language
2411
-     * eg 'en'
2412
-     */
2413
-    public $recaptcha_language;
2414 1738
 
2415
-    /**
2416
-     * ReCaptcha public key
2417
-     *
2418
-     * @var string $recaptcha_publickey
2419
-     */
2420
-    public $recaptcha_publickey;
1739
+/**
1740
+ * Class for defining what's in the EE_Config relating to registration settings
1741
+ */
1742
+class EE_Core_Config extends EE_Config_Base
1743
+{
2421 1744
 
2422
-    /**
2423
-     * ReCaptcha private key
2424
-     *
2425
-     * @var string $recaptcha_privatekey
2426
-     */
2427
-    public $recaptcha_privatekey;
1745
+	public $current_blog_id;
1746
+
1747
+	public $ee_ueip_optin;
1748
+
1749
+	public $ee_ueip_has_notified;
1750
+
1751
+	/**
1752
+	 * Not to be confused with the 4 critical page variables (See
1753
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1754
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1755
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1756
+	 *
1757
+	 * @var array
1758
+	 */
1759
+	public $post_shortcodes;
1760
+
1761
+	public $module_route_map;
1762
+
1763
+	public $module_forward_map;
1764
+
1765
+	public $module_view_map;
1766
+
1767
+	/**
1768
+	 * The next 4 vars are the IDs of critical EE pages.
1769
+	 *
1770
+	 * @var int
1771
+	 */
1772
+	public $reg_page_id;
1773
+
1774
+	public $txn_page_id;
1775
+
1776
+	public $thank_you_page_id;
1777
+
1778
+	public $cancel_page_id;
1779
+
1780
+	/**
1781
+	 * The next 4 vars are the URLs of critical EE pages.
1782
+	 *
1783
+	 * @var int
1784
+	 */
1785
+	public $reg_page_url;
1786
+
1787
+	public $txn_page_url;
1788
+
1789
+	public $thank_you_page_url;
1790
+
1791
+	public $cancel_page_url;
1792
+
1793
+	/**
1794
+	 * The next vars relate to the custom slugs for EE CPT routes
1795
+	 */
1796
+	public $event_cpt_slug;
1797
+
1798
+
1799
+	/**
1800
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1801
+	 * request across blog switches in a multisite context.
1802
+	 * Avoids extra queries to the db for this option.
1803
+	 *
1804
+	 * @var bool
1805
+	 */
1806
+	public static $ee_ueip_option;
1807
+
1808
+
1809
+
1810
+	/**
1811
+	 *    class constructor
1812
+	 *
1813
+	 * @access    public
1814
+	 */
1815
+	public function __construct()
1816
+	{
1817
+		// set default organization settings
1818
+		$this->current_blog_id = get_current_blog_id();
1819
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1820
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1821
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1822
+		$this->post_shortcodes = array();
1823
+		$this->module_route_map = array();
1824
+		$this->module_forward_map = array();
1825
+		$this->module_view_map = array();
1826
+		// critical EE page IDs
1827
+		$this->reg_page_id = 0;
1828
+		$this->txn_page_id = 0;
1829
+		$this->thank_you_page_id = 0;
1830
+		$this->cancel_page_id = 0;
1831
+		// critical EE page URLs
1832
+		$this->reg_page_url = '';
1833
+		$this->txn_page_url = '';
1834
+		$this->thank_you_page_url = '';
1835
+		$this->cancel_page_url = '';
1836
+		//cpt slugs
1837
+		$this->event_cpt_slug = __('events', 'event_espresso');
1838
+		//ueip constant check
1839
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1840
+			$this->ee_ueip_optin = false;
1841
+			$this->ee_ueip_has_notified = true;
1842
+		}
1843
+	}
1844
+
1845
+
1846
+
1847
+	/**
1848
+	 * @return array
1849
+	 */
1850
+	public function get_critical_pages_array()
1851
+	{
1852
+		return array(
1853
+			$this->reg_page_id,
1854
+			$this->txn_page_id,
1855
+			$this->thank_you_page_id,
1856
+			$this->cancel_page_id,
1857
+		);
1858
+	}
1859
+
1860
+
1861
+
1862
+	/**
1863
+	 * @return array
1864
+	 */
1865
+	public function get_critical_pages_shortcodes_array()
1866
+	{
1867
+		return array(
1868
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1869
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1870
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1871
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1872
+		);
1873
+	}
1874
+
1875
+
1876
+
1877
+	/**
1878
+	 *  gets/returns URL for EE reg_page
1879
+	 *
1880
+	 * @access    public
1881
+	 * @return    string
1882
+	 */
1883
+	public function reg_page_url()
1884
+	{
1885
+		if ( ! $this->reg_page_url) {
1886
+			$this->reg_page_url = add_query_arg(
1887
+									  array('uts' => time()),
1888
+									  get_permalink($this->reg_page_id)
1889
+								  ) . '#checkout';
1890
+		}
1891
+		return $this->reg_page_url;
1892
+	}
1893
+
1894
+
1895
+
1896
+	/**
1897
+	 *  gets/returns URL for EE txn_page
1898
+	 *
1899
+	 * @param array $query_args like what gets passed to
1900
+	 *                          add_query_arg() as the first argument
1901
+	 * @access    public
1902
+	 * @return    string
1903
+	 */
1904
+	public function txn_page_url($query_args = array())
1905
+	{
1906
+		if ( ! $this->txn_page_url) {
1907
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1908
+		}
1909
+		if ($query_args) {
1910
+			return add_query_arg($query_args, $this->txn_page_url);
1911
+		} else {
1912
+			return $this->txn_page_url;
1913
+		}
1914
+	}
1915
+
1916
+
1917
+
1918
+	/**
1919
+	 *  gets/returns URL for EE thank_you_page
1920
+	 *
1921
+	 * @param array $query_args like what gets passed to
1922
+	 *                          add_query_arg() as the first argument
1923
+	 * @access    public
1924
+	 * @return    string
1925
+	 */
1926
+	public function thank_you_page_url($query_args = array())
1927
+	{
1928
+		if ( ! $this->thank_you_page_url) {
1929
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1930
+		}
1931
+		if ($query_args) {
1932
+			return add_query_arg($query_args, $this->thank_you_page_url);
1933
+		} else {
1934
+			return $this->thank_you_page_url;
1935
+		}
1936
+	}
1937
+
1938
+
1939
+
1940
+	/**
1941
+	 *  gets/returns URL for EE cancel_page
1942
+	 *
1943
+	 * @access    public
1944
+	 * @return    string
1945
+	 */
1946
+	public function cancel_page_url()
1947
+	{
1948
+		if ( ! $this->cancel_page_url) {
1949
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1950
+		}
1951
+		return $this->cancel_page_url;
1952
+	}
1953
+
1954
+
1955
+
1956
+	/**
1957
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1958
+	 *
1959
+	 * @since 4.7.5
1960
+	 */
1961
+	protected function _reset_urls()
1962
+	{
1963
+		$this->reg_page_url = '';
1964
+		$this->txn_page_url = '';
1965
+		$this->cancel_page_url = '';
1966
+		$this->thank_you_page_url = '';
1967
+	}
1968
+
1969
+
1970
+
1971
+	/**
1972
+	 * Used to return what the optin value is set for the EE User Experience Program.
1973
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1974
+	 * on the main site only.
1975
+	 *
1976
+	 * @return mixed|void
1977
+	 */
1978
+	protected function _get_main_ee_ueip_optin()
1979
+	{
1980
+		//if this is the main site then we can just bypass our direct query.
1981
+		if (is_main_site()) {
1982
+			return get_option('ee_ueip_optin', false);
1983
+		}
1984
+		//is this already cached for this request?  If so use it.
1985
+		if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1986
+			return EE_Core_Config::$ee_ueip_option;
1987
+		}
1988
+		global $wpdb;
1989
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1990
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1991
+		$option = 'ee_ueip_optin';
1992
+		//set correct table for query
1993
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1994
+		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1995
+		//get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1996
+		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1997
+		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1998
+		//for the purpose of caching.
1999
+		$pre = apply_filters('pre_option_' . $option, false, $option);
2000
+		if (false !== $pre) {
2001
+			EE_Core_Config::$ee_ueip_option = $pre;
2002
+			return EE_Core_Config::$ee_ueip_option;
2003
+		}
2004
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
2005
+			$option));
2006
+		if (is_object($row)) {
2007
+			$value = $row->option_value;
2008
+		} else { //option does not exist so use default.
2009
+			return apply_filters('default_option_' . $option, false, $option);
2010
+		}
2011
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
2012
+		return EE_Core_Config::$ee_ueip_option;
2013
+	}
2014
+
2015
+
2016
+
2017
+	/**
2018
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
2019
+	 * on the object.
2020
+	 *
2021
+	 * @return array
2022
+	 */
2023
+	public function __sleep()
2024
+	{
2025
+		//reset all url properties
2026
+		$this->_reset_urls();
2027
+		//return what to save to db
2028
+		return array_keys(get_object_vars($this));
2029
+	}
2428 2030
 
2429
-    /**
2430
-     * ReCaptcha width
2431
-     *
2432
-     * @var int $recaptcha_width
2433
-     * @deprecated
2434
-     */
2435
-    public $recaptcha_width;
2031
+}
2436 2032
 
2437
-    /**
2438
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2439
-     *
2440
-     * @var boolean $track_invalid_checkout_access
2441
-     */
2442
-    protected $track_invalid_checkout_access = true;
2443 2033
 
2444 2034
 
2035
+/**
2036
+ * Config class for storing info on the Organization
2037
+ */
2038
+class EE_Organization_Config extends EE_Config_Base
2039
+{
2445 2040
 
2446
-    /**
2447
-     *    class constructor
2448
-     *
2449
-     * @access    public
2450
-     */
2451
-    public function __construct()
2452
-    {
2453
-        // set default registration settings
2454
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2455
-        $this->email_validation_level = 'wp_default';
2456
-        $this->show_pending_payment_options = true;
2457
-        $this->skip_reg_confirmation = false;
2458
-        $this->reg_steps = array();
2459
-        $this->reg_confirmation_last = false;
2460
-        $this->use_bot_trap = true;
2461
-        $this->use_encryption = true;
2462
-        $this->use_captcha = false;
2463
-        $this->recaptcha_theme = 'light';
2464
-        $this->recaptcha_type = 'image';
2465
-        $this->recaptcha_language = 'en';
2466
-        $this->recaptcha_publickey = null;
2467
-        $this->recaptcha_privatekey = null;
2468
-        $this->recaptcha_width = 500;
2469
-    }
2470
-
2471
-
2472
-
2473
-    /**
2474
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2475
-     *
2476
-     * @since 4.8.8.rc.019
2477
-     */
2478
-    public function do_hooks()
2479
-    {
2480
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2481
-    }
2041
+	/**
2042
+	 * @var string $name
2043
+	 * eg EE4.1
2044
+	 */
2045
+	public $name;
2046
+
2047
+	/**
2048
+	 * @var string $address_1
2049
+	 * eg 123 Onna Road
2050
+	 */
2051
+	public $address_1;
2052
+
2053
+	/**
2054
+	 * @var string $address_2
2055
+	 * eg PO Box 123
2056
+	 */
2057
+	public $address_2;
2058
+
2059
+	/**
2060
+	 * @var string $city
2061
+	 * eg Inna City
2062
+	 */
2063
+	public $city;
2064
+
2065
+	/**
2066
+	 * @var int $STA_ID
2067
+	 * eg 4
2068
+	 */
2069
+	public $STA_ID;
2070
+
2071
+	/**
2072
+	 * @var string $CNT_ISO
2073
+	 * eg US
2074
+	 */
2075
+	public $CNT_ISO;
2076
+
2077
+	/**
2078
+	 * @var string $zip
2079
+	 * eg 12345  or V1A 2B3
2080
+	 */
2081
+	public $zip;
2082
+
2083
+	/**
2084
+	 * @var string $email
2085
+	 * eg [email protected]
2086
+	 */
2087
+	public $email;
2088
+
2089
+
2090
+	/**
2091
+	 * @var string $phone
2092
+	 * eg. 111-111-1111
2093
+	 */
2094
+	public $phone;
2095
+
2096
+
2097
+	/**
2098
+	 * @var string $vat
2099
+	 * VAT/Tax Number
2100
+	 */
2101
+	public $vat;
2102
+
2103
+	/**
2104
+	 * @var string $logo_url
2105
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2106
+	 */
2107
+	public $logo_url;
2108
+
2109
+
2110
+	/**
2111
+	 * The below are all various properties for holding links to organization social network profiles
2112
+	 *
2113
+	 * @var string
2114
+	 */
2115
+	/**
2116
+	 * facebook (facebook.com/profile.name)
2117
+	 *
2118
+	 * @var string
2119
+	 */
2120
+	public $facebook;
2121
+
2122
+
2123
+	/**
2124
+	 * twitter (twitter.com/twitter_handle)
2125
+	 *
2126
+	 * @var string
2127
+	 */
2128
+	public $twitter;
2129
+
2130
+
2131
+	/**
2132
+	 * linkedin (linkedin.com/in/profile_name)
2133
+	 *
2134
+	 * @var string
2135
+	 */
2136
+	public $linkedin;
2137
+
2138
+
2139
+	/**
2140
+	 * pinterest (www.pinterest.com/profile_name)
2141
+	 *
2142
+	 * @var string
2143
+	 */
2144
+	public $pinterest;
2145
+
2146
+
2147
+	/**
2148
+	 * google+ (google.com/+profileName)
2149
+	 *
2150
+	 * @var string
2151
+	 */
2152
+	public $google;
2153
+
2154
+
2155
+	/**
2156
+	 * instagram (instagram.com/handle)
2157
+	 *
2158
+	 * @var string
2159
+	 */
2160
+	public $instagram;
2161
+
2162
+
2163
+
2164
+	/**
2165
+	 *    class constructor
2166
+	 *
2167
+	 * @access    public
2168
+	 */
2169
+	public function __construct()
2170
+	{
2171
+		// set default organization settings
2172
+		$this->name = get_bloginfo('name');
2173
+		$this->address_1 = '123 Onna Road';
2174
+		$this->address_2 = 'PO Box 123';
2175
+		$this->city = 'Inna City';
2176
+		$this->STA_ID = 4;
2177
+		$this->CNT_ISO = 'US';
2178
+		$this->zip = '12345';
2179
+		$this->email = get_bloginfo('admin_email');
2180
+		$this->phone = '';
2181
+		$this->vat = '123456789';
2182
+		$this->logo_url = '';
2183
+		$this->facebook = '';
2184
+		$this->twitter = '';
2185
+		$this->linkedin = '';
2186
+		$this->pinterest = '';
2187
+		$this->google = '';
2188
+		$this->instagram = '';
2189
+	}
2482 2190
 
2191
+}
2483 2192
 
2484 2193
 
2485
-    /**
2486
-     * @return void
2487
-     */
2488
-    public function set_default_reg_status_on_EEM_Event()
2489
-    {
2490
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2491
-    }
2492 2194
 
2195
+/**
2196
+ * Class for defining what's in the EE_Config relating to currency
2197
+ */
2198
+class EE_Currency_Config extends EE_Config_Base
2199
+{
2493 2200
 
2201
+	/**
2202
+	 * @var string $code
2203
+	 * eg 'US'
2204
+	 */
2205
+	public $code;
2206
+
2207
+	/**
2208
+	 * @var string $name
2209
+	 * eg 'Dollar'
2210
+	 */
2211
+	public $name;
2212
+
2213
+	/**
2214
+	 * plural name
2215
+	 *
2216
+	 * @var string $plural
2217
+	 * eg 'Dollars'
2218
+	 */
2219
+	public $plural;
2220
+
2221
+	/**
2222
+	 * currency sign
2223
+	 *
2224
+	 * @var string $sign
2225
+	 * eg '$'
2226
+	 */
2227
+	public $sign;
2228
+
2229
+	/**
2230
+	 * Whether the currency sign should come before the number or not
2231
+	 *
2232
+	 * @var boolean $sign_b4
2233
+	 */
2234
+	public $sign_b4;
2235
+
2236
+	/**
2237
+	 * How many digits should come after the decimal place
2238
+	 *
2239
+	 * @var int $dec_plc
2240
+	 */
2241
+	public $dec_plc;
2242
+
2243
+	/**
2244
+	 * Symbol to use for decimal mark
2245
+	 *
2246
+	 * @var string $dec_mrk
2247
+	 * eg '.'
2248
+	 */
2249
+	public $dec_mrk;
2250
+
2251
+	/**
2252
+	 * Symbol to use for thousands
2253
+	 *
2254
+	 * @var string $thsnds
2255
+	 * eg ','
2256
+	 */
2257
+	public $thsnds;
2258
+
2259
+
2260
+
2261
+	/**
2262
+	 *    class constructor
2263
+	 *
2264
+	 * @access    public
2265
+	 * @param string $CNT_ISO
2266
+	 * @throws \EE_Error
2267
+	 */
2268
+	public function __construct($CNT_ISO = '')
2269
+	{
2270
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2271
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2272
+		// get country code from organization settings or use default
2273
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2274
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2275
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2276
+			: '';
2277
+		// but override if requested
2278
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2279
+		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2280
+		if (
2281
+			! empty($CNT_ISO)
2282
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2283
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2284
+		) {
2285
+			// retrieve the country settings from the db, just in case they have been customized
2286
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2287
+			if ($country instanceof EE_Country) {
2288
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2289
+				$this->name = $country->currency_name_single();    // Dollar
2290
+				$this->plural = $country->currency_name_plural();    // Dollars
2291
+				$this->sign = $country->currency_sign();            // currency sign: $
2292
+				$this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2293
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2294
+				$this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2295
+				$this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2296
+			}
2297
+		}
2298
+		// fallback to hardcoded defaults, in case the above failed
2299
+		if (empty($this->code)) {
2300
+			// set default currency settings
2301
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2302
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2303
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2304
+			$this->sign = '$';    // currency sign: $
2305
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2306
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2307
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2308
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2309
+		}
2310
+	}
2311
+}
2494 2312
 
2495
-    /**
2496
-     * @return boolean
2497
-     */
2498
-    public function track_invalid_checkout_access()
2499
-    {
2500
-        return $this->track_invalid_checkout_access;
2501
-    }
2502 2313
 
2503 2314
 
2315
+/**
2316
+ * Class for defining what's in the EE_Config relating to registration settings
2317
+ */
2318
+class EE_Registration_Config extends EE_Config_Base
2319
+{
2504 2320
 
2505
-    /**
2506
-     * @param boolean $track_invalid_checkout_access
2507
-     */
2508
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2509
-    {
2510
-        $this->track_invalid_checkout_access = filter_var(
2511
-            $track_invalid_checkout_access,
2512
-            FILTER_VALIDATE_BOOLEAN
2513
-        );
2514
-    }
2321
+	/**
2322
+	 * Default registration status
2323
+	 *
2324
+	 * @var string $default_STS_ID
2325
+	 * eg 'RPP'
2326
+	 */
2327
+	public $default_STS_ID;
2328
+
2329
+	/**
2330
+	 * level of validation to apply to email addresses
2331
+	 *
2332
+	 * @var string $email_validation_level
2333
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2334
+	 */
2335
+	public $email_validation_level;
2336
+
2337
+	/**
2338
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2339
+	 *
2340
+	 * @var boolean $show_pending_payment_options
2341
+	 */
2342
+	public $show_pending_payment_options;
2343
+
2344
+	/**
2345
+	 * Whether to skip the registration confirmation page
2346
+	 *
2347
+	 * @var boolean $skip_reg_confirmation
2348
+	 */
2349
+	public $skip_reg_confirmation;
2350
+
2351
+	/**
2352
+	 * an array of SPCO reg steps where:
2353
+	 *        the keys denotes the reg step order
2354
+	 *        each element consists of an array with the following elements:
2355
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2356
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2357
+	 *            "slug" => the URL param used to trigger the reg step
2358
+	 *
2359
+	 * @var array $reg_steps
2360
+	 */
2361
+	public $reg_steps;
2362
+
2363
+	/**
2364
+	 * Whether registration confirmation should be the last page of SPCO
2365
+	 *
2366
+	 * @var boolean $reg_confirmation_last
2367
+	 */
2368
+	public $reg_confirmation_last;
2369
+
2370
+	/**
2371
+	 * Whether or not to enable the EE Bot Trap
2372
+	 *
2373
+	 * @var boolean $use_bot_trap
2374
+	 */
2375
+	public $use_bot_trap;
2376
+
2377
+	/**
2378
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2379
+	 *
2380
+	 * @var boolean $use_encryption
2381
+	 */
2382
+	public $use_encryption;
2383
+
2384
+	/**
2385
+	 * Whether or not to use ReCaptcha
2386
+	 *
2387
+	 * @var boolean $use_captcha
2388
+	 */
2389
+	public $use_captcha;
2390
+
2391
+	/**
2392
+	 * ReCaptcha Theme
2393
+	 *
2394
+	 * @var string $recaptcha_theme
2395
+	 *    options: 'dark    ', 'light'
2396
+	 */
2397
+	public $recaptcha_theme;
2398
+
2399
+	/**
2400
+	 * ReCaptcha Type
2401
+	 *
2402
+	 * @var string $recaptcha_type
2403
+	 *    options: 'audio', 'image'
2404
+	 */
2405
+	public $recaptcha_type;
2406
+
2407
+	/**
2408
+	 * ReCaptcha language
2409
+	 *
2410
+	 * @var string $recaptcha_language
2411
+	 * eg 'en'
2412
+	 */
2413
+	public $recaptcha_language;
2414
+
2415
+	/**
2416
+	 * ReCaptcha public key
2417
+	 *
2418
+	 * @var string $recaptcha_publickey
2419
+	 */
2420
+	public $recaptcha_publickey;
2421
+
2422
+	/**
2423
+	 * ReCaptcha private key
2424
+	 *
2425
+	 * @var string $recaptcha_privatekey
2426
+	 */
2427
+	public $recaptcha_privatekey;
2428
+
2429
+	/**
2430
+	 * ReCaptcha width
2431
+	 *
2432
+	 * @var int $recaptcha_width
2433
+	 * @deprecated
2434
+	 */
2435
+	public $recaptcha_width;
2436
+
2437
+	/**
2438
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2439
+	 *
2440
+	 * @var boolean $track_invalid_checkout_access
2441
+	 */
2442
+	protected $track_invalid_checkout_access = true;
2443
+
2444
+
2445
+
2446
+	/**
2447
+	 *    class constructor
2448
+	 *
2449
+	 * @access    public
2450
+	 */
2451
+	public function __construct()
2452
+	{
2453
+		// set default registration settings
2454
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2455
+		$this->email_validation_level = 'wp_default';
2456
+		$this->show_pending_payment_options = true;
2457
+		$this->skip_reg_confirmation = false;
2458
+		$this->reg_steps = array();
2459
+		$this->reg_confirmation_last = false;
2460
+		$this->use_bot_trap = true;
2461
+		$this->use_encryption = true;
2462
+		$this->use_captcha = false;
2463
+		$this->recaptcha_theme = 'light';
2464
+		$this->recaptcha_type = 'image';
2465
+		$this->recaptcha_language = 'en';
2466
+		$this->recaptcha_publickey = null;
2467
+		$this->recaptcha_privatekey = null;
2468
+		$this->recaptcha_width = 500;
2469
+	}
2470
+
2471
+
2472
+
2473
+	/**
2474
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2475
+	 *
2476
+	 * @since 4.8.8.rc.019
2477
+	 */
2478
+	public function do_hooks()
2479
+	{
2480
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2481
+	}
2482
+
2483
+
2484
+
2485
+	/**
2486
+	 * @return void
2487
+	 */
2488
+	public function set_default_reg_status_on_EEM_Event()
2489
+	{
2490
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2491
+	}
2492
+
2493
+
2494
+
2495
+	/**
2496
+	 * @return boolean
2497
+	 */
2498
+	public function track_invalid_checkout_access()
2499
+	{
2500
+		return $this->track_invalid_checkout_access;
2501
+	}
2502
+
2503
+
2504
+
2505
+	/**
2506
+	 * @param boolean $track_invalid_checkout_access
2507
+	 */
2508
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2509
+	{
2510
+		$this->track_invalid_checkout_access = filter_var(
2511
+			$track_invalid_checkout_access,
2512
+			FILTER_VALIDATE_BOOLEAN
2513
+		);
2514
+	}
2515 2515
 
2516 2516
 
2517 2517
 }
@@ -2524,160 +2524,160 @@  discard block
 block discarded – undo
2524 2524
 class EE_Admin_Config extends EE_Config_Base
2525 2525
 {
2526 2526
 
2527
-    /**
2528
-     * @var boolean $use_personnel_manager
2529
-     */
2530
-    public $use_personnel_manager;
2531
-
2532
-    /**
2533
-     * @var boolean $use_dashboard_widget
2534
-     */
2535
-    public $use_dashboard_widget;
2536
-
2537
-    /**
2538
-     * @var int $events_in_dashboard
2539
-     */
2540
-    public $events_in_dashboard;
2541
-
2542
-    /**
2543
-     * @var boolean $use_event_timezones
2544
-     */
2545
-    public $use_event_timezones;
2546
-
2547
-    /**
2548
-     * @var boolean $use_full_logging
2549
-     */
2550
-    public $use_full_logging;
2551
-
2552
-    /**
2553
-     * @var string $log_file_name
2554
-     */
2555
-    public $log_file_name;
2556
-
2557
-    /**
2558
-     * @var string $debug_file_name
2559
-     */
2560
-    public $debug_file_name;
2561
-
2562
-    /**
2563
-     * @var boolean $use_remote_logging
2564
-     */
2565
-    public $use_remote_logging;
2566
-
2567
-    /**
2568
-     * @var string $remote_logging_url
2569
-     */
2570
-    public $remote_logging_url;
2571
-
2572
-    /**
2573
-     * @var boolean $show_reg_footer
2574
-     */
2575
-    public $show_reg_footer;
2576
-
2577
-    /**
2578
-     * @var string $affiliate_id
2579
-     */
2580
-    public $affiliate_id;
2581
-
2582
-    /**
2583
-     * help tours on or off (global setting)
2584
-     *
2585
-     * @var boolean
2586
-     */
2587
-    public $help_tour_activation;
2588
-
2589
-    /**
2590
-     * adds extra layer of encoding to session data to prevent serialization errors
2591
-     * but is incompatible with some server configuration errors
2592
-     * if you get "500 internal server errors" during registration, try turning this on
2593
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2594
-     *
2595
-     * @var boolean $encode_session_data
2596
-     */
2597
-    private $encode_session_data = false;
2598
-
2599
-
2600
-
2601
-    /**
2602
-     *    class constructor
2603
-     *
2604
-     * @access    public
2605
-     */
2606
-    public function __construct()
2607
-    {
2608
-        // set default general admin settings
2609
-        $this->use_personnel_manager = true;
2610
-        $this->use_dashboard_widget = true;
2611
-        $this->events_in_dashboard = 30;
2612
-        $this->use_event_timezones = false;
2613
-        $this->use_full_logging = false;
2614
-        $this->use_remote_logging = false;
2615
-        $this->remote_logging_url = null;
2616
-        $this->show_reg_footer = true;
2617
-        $this->affiliate_id = 'default';
2618
-        $this->help_tour_activation = true;
2619
-        $this->encode_session_data = false;
2620
-    }
2621
-
2622
-
2623
-
2624
-    /**
2625
-     * @param bool $reset
2626
-     * @return string
2627
-     */
2628
-    public function log_file_name($reset = false)
2629
-    {
2630
-        if (empty($this->log_file_name) || $reset) {
2631
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2632
-            EE_Config::instance()->update_espresso_config(false, false);
2633
-        }
2634
-        return $this->log_file_name;
2635
-    }
2636
-
2637
-
2638
-
2639
-    /**
2640
-     * @param bool $reset
2641
-     * @return string
2642
-     */
2643
-    public function debug_file_name($reset = false)
2644
-    {
2645
-        if (empty($this->debug_file_name) || $reset) {
2646
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2647
-            EE_Config::instance()->update_espresso_config(false, false);
2648
-        }
2649
-        return $this->debug_file_name;
2650
-    }
2651
-
2652
-
2653
-
2654
-    /**
2655
-     * @return string
2656
-     */
2657
-    public function affiliate_id()
2658
-    {
2659
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2660
-    }
2661
-
2662
-
2663
-
2664
-    /**
2665
-     * @return boolean
2666
-     */
2667
-    public function encode_session_data()
2668
-    {
2669
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2670
-    }
2671
-
2672
-
2673
-
2674
-    /**
2675
-     * @param boolean $encode_session_data
2676
-     */
2677
-    public function set_encode_session_data($encode_session_data)
2678
-    {
2679
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2680
-    }
2527
+	/**
2528
+	 * @var boolean $use_personnel_manager
2529
+	 */
2530
+	public $use_personnel_manager;
2531
+
2532
+	/**
2533
+	 * @var boolean $use_dashboard_widget
2534
+	 */
2535
+	public $use_dashboard_widget;
2536
+
2537
+	/**
2538
+	 * @var int $events_in_dashboard
2539
+	 */
2540
+	public $events_in_dashboard;
2541
+
2542
+	/**
2543
+	 * @var boolean $use_event_timezones
2544
+	 */
2545
+	public $use_event_timezones;
2546
+
2547
+	/**
2548
+	 * @var boolean $use_full_logging
2549
+	 */
2550
+	public $use_full_logging;
2551
+
2552
+	/**
2553
+	 * @var string $log_file_name
2554
+	 */
2555
+	public $log_file_name;
2556
+
2557
+	/**
2558
+	 * @var string $debug_file_name
2559
+	 */
2560
+	public $debug_file_name;
2561
+
2562
+	/**
2563
+	 * @var boolean $use_remote_logging
2564
+	 */
2565
+	public $use_remote_logging;
2566
+
2567
+	/**
2568
+	 * @var string $remote_logging_url
2569
+	 */
2570
+	public $remote_logging_url;
2571
+
2572
+	/**
2573
+	 * @var boolean $show_reg_footer
2574
+	 */
2575
+	public $show_reg_footer;
2576
+
2577
+	/**
2578
+	 * @var string $affiliate_id
2579
+	 */
2580
+	public $affiliate_id;
2581
+
2582
+	/**
2583
+	 * help tours on or off (global setting)
2584
+	 *
2585
+	 * @var boolean
2586
+	 */
2587
+	public $help_tour_activation;
2588
+
2589
+	/**
2590
+	 * adds extra layer of encoding to session data to prevent serialization errors
2591
+	 * but is incompatible with some server configuration errors
2592
+	 * if you get "500 internal server errors" during registration, try turning this on
2593
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2594
+	 *
2595
+	 * @var boolean $encode_session_data
2596
+	 */
2597
+	private $encode_session_data = false;
2598
+
2599
+
2600
+
2601
+	/**
2602
+	 *    class constructor
2603
+	 *
2604
+	 * @access    public
2605
+	 */
2606
+	public function __construct()
2607
+	{
2608
+		// set default general admin settings
2609
+		$this->use_personnel_manager = true;
2610
+		$this->use_dashboard_widget = true;
2611
+		$this->events_in_dashboard = 30;
2612
+		$this->use_event_timezones = false;
2613
+		$this->use_full_logging = false;
2614
+		$this->use_remote_logging = false;
2615
+		$this->remote_logging_url = null;
2616
+		$this->show_reg_footer = true;
2617
+		$this->affiliate_id = 'default';
2618
+		$this->help_tour_activation = true;
2619
+		$this->encode_session_data = false;
2620
+	}
2621
+
2622
+
2623
+
2624
+	/**
2625
+	 * @param bool $reset
2626
+	 * @return string
2627
+	 */
2628
+	public function log_file_name($reset = false)
2629
+	{
2630
+		if (empty($this->log_file_name) || $reset) {
2631
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2632
+			EE_Config::instance()->update_espresso_config(false, false);
2633
+		}
2634
+		return $this->log_file_name;
2635
+	}
2636
+
2637
+
2638
+
2639
+	/**
2640
+	 * @param bool $reset
2641
+	 * @return string
2642
+	 */
2643
+	public function debug_file_name($reset = false)
2644
+	{
2645
+		if (empty($this->debug_file_name) || $reset) {
2646
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2647
+			EE_Config::instance()->update_espresso_config(false, false);
2648
+		}
2649
+		return $this->debug_file_name;
2650
+	}
2651
+
2652
+
2653
+
2654
+	/**
2655
+	 * @return string
2656
+	 */
2657
+	public function affiliate_id()
2658
+	{
2659
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2660
+	}
2661
+
2662
+
2663
+
2664
+	/**
2665
+	 * @return boolean
2666
+	 */
2667
+	public function encode_session_data()
2668
+	{
2669
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2670
+	}
2671
+
2672
+
2673
+
2674
+	/**
2675
+	 * @param boolean $encode_session_data
2676
+	 */
2677
+	public function set_encode_session_data($encode_session_data)
2678
+	{
2679
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2680
+	}
2681 2681
 
2682 2682
 
2683 2683
 }
@@ -2690,71 +2690,71 @@  discard block
 block discarded – undo
2690 2690
 class EE_Template_Config extends EE_Config_Base
2691 2691
 {
2692 2692
 
2693
-    /**
2694
-     * @var boolean $enable_default_style
2695
-     */
2696
-    public $enable_default_style;
2697
-
2698
-    /**
2699
-     * @var string $custom_style_sheet
2700
-     */
2701
-    public $custom_style_sheet;
2702
-
2703
-    /**
2704
-     * @var boolean $display_address_in_regform
2705
-     */
2706
-    public $display_address_in_regform;
2707
-
2708
-    /**
2709
-     * @var int $display_description_on_multi_reg_page
2710
-     */
2711
-    public $display_description_on_multi_reg_page;
2712
-
2713
-    /**
2714
-     * @var boolean $use_custom_templates
2715
-     */
2716
-    public $use_custom_templates;
2717
-
2718
-    /**
2719
-     * @var string $current_espresso_theme
2720
-     */
2721
-    public $current_espresso_theme;
2722
-
2723
-    /**
2724
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2725
-     */
2726
-    public $EED_Ticket_Selector;
2727
-
2728
-    /**
2729
-     * @var EE_Event_Single_Config $EED_Event_Single
2730
-     */
2731
-    public $EED_Event_Single;
2732
-
2733
-    /**
2734
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2735
-     */
2736
-    public $EED_Events_Archive;
2737
-
2738
-
2739
-
2740
-    /**
2741
-     *    class constructor
2742
-     *
2743
-     * @access    public
2744
-     */
2745
-    public function __construct()
2746
-    {
2747
-        // set default template settings
2748
-        $this->enable_default_style = true;
2749
-        $this->custom_style_sheet = null;
2750
-        $this->display_address_in_regform = true;
2751
-        $this->display_description_on_multi_reg_page = false;
2752
-        $this->use_custom_templates = false;
2753
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2754
-        $this->EED_Event_Single = null;
2755
-        $this->EED_Events_Archive = null;
2756
-        $this->EED_Ticket_Selector = null;
2757
-    }
2693
+	/**
2694
+	 * @var boolean $enable_default_style
2695
+	 */
2696
+	public $enable_default_style;
2697
+
2698
+	/**
2699
+	 * @var string $custom_style_sheet
2700
+	 */
2701
+	public $custom_style_sheet;
2702
+
2703
+	/**
2704
+	 * @var boolean $display_address_in_regform
2705
+	 */
2706
+	public $display_address_in_regform;
2707
+
2708
+	/**
2709
+	 * @var int $display_description_on_multi_reg_page
2710
+	 */
2711
+	public $display_description_on_multi_reg_page;
2712
+
2713
+	/**
2714
+	 * @var boolean $use_custom_templates
2715
+	 */
2716
+	public $use_custom_templates;
2717
+
2718
+	/**
2719
+	 * @var string $current_espresso_theme
2720
+	 */
2721
+	public $current_espresso_theme;
2722
+
2723
+	/**
2724
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2725
+	 */
2726
+	public $EED_Ticket_Selector;
2727
+
2728
+	/**
2729
+	 * @var EE_Event_Single_Config $EED_Event_Single
2730
+	 */
2731
+	public $EED_Event_Single;
2732
+
2733
+	/**
2734
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2735
+	 */
2736
+	public $EED_Events_Archive;
2737
+
2738
+
2739
+
2740
+	/**
2741
+	 *    class constructor
2742
+	 *
2743
+	 * @access    public
2744
+	 */
2745
+	public function __construct()
2746
+	{
2747
+		// set default template settings
2748
+		$this->enable_default_style = true;
2749
+		$this->custom_style_sheet = null;
2750
+		$this->display_address_in_regform = true;
2751
+		$this->display_description_on_multi_reg_page = false;
2752
+		$this->use_custom_templates = false;
2753
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2754
+		$this->EED_Event_Single = null;
2755
+		$this->EED_Events_Archive = null;
2756
+		$this->EED_Ticket_Selector = null;
2757
+	}
2758 2758
 
2759 2759
 }
2760 2760
 
@@ -2766,115 +2766,115 @@  discard block
 block discarded – undo
2766 2766
 class EE_Map_Config extends EE_Config_Base
2767 2767
 {
2768 2768
 
2769
-    /**
2770
-     * @var boolean $use_google_maps
2771
-     */
2772
-    public $use_google_maps;
2773
-
2774
-    /**
2775
-     * @var string $api_key
2776
-     */
2777
-    public $google_map_api_key;
2778
-
2779
-    /**
2780
-     * @var int $event_details_map_width
2781
-     */
2782
-    public $event_details_map_width;
2783
-
2784
-    /**
2785
-     * @var int $event_details_map_height
2786
-     */
2787
-    public $event_details_map_height;
2788
-
2789
-    /**
2790
-     * @var int $event_details_map_zoom
2791
-     */
2792
-    public $event_details_map_zoom;
2793
-
2794
-    /**
2795
-     * @var boolean $event_details_display_nav
2796
-     */
2797
-    public $event_details_display_nav;
2798
-
2799
-    /**
2800
-     * @var boolean $event_details_nav_size
2801
-     */
2802
-    public $event_details_nav_size;
2803
-
2804
-    /**
2805
-     * @var string $event_details_control_type
2806
-     */
2807
-    public $event_details_control_type;
2808
-
2809
-    /**
2810
-     * @var string $event_details_map_align
2811
-     */
2812
-    public $event_details_map_align;
2813
-
2814
-    /**
2815
-     * @var int $event_list_map_width
2816
-     */
2817
-    public $event_list_map_width;
2818
-
2819
-    /**
2820
-     * @var int $event_list_map_height
2821
-     */
2822
-    public $event_list_map_height;
2823
-
2824
-    /**
2825
-     * @var int $event_list_map_zoom
2826
-     */
2827
-    public $event_list_map_zoom;
2828
-
2829
-    /**
2830
-     * @var boolean $event_list_display_nav
2831
-     */
2832
-    public $event_list_display_nav;
2833
-
2834
-    /**
2835
-     * @var boolean $event_list_nav_size
2836
-     */
2837
-    public $event_list_nav_size;
2838
-
2839
-    /**
2840
-     * @var string $event_list_control_type
2841
-     */
2842
-    public $event_list_control_type;
2843
-
2844
-    /**
2845
-     * @var string $event_list_map_align
2846
-     */
2847
-    public $event_list_map_align;
2848
-
2849
-
2850
-
2851
-    /**
2852
-     *    class constructor
2853
-     *
2854
-     * @access    public
2855
-     */
2856
-    public function __construct()
2857
-    {
2858
-        // set default map settings
2859
-        $this->use_google_maps = true;
2860
-        $this->google_map_api_key = '';
2861
-        // for event details pages (reg page)
2862
-        $this->event_details_map_width = 585;            // ee_map_width_single
2863
-        $this->event_details_map_height = 362;            // ee_map_height_single
2864
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2865
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2866
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2867
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2868
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2869
-        // for event list pages
2870
-        $this->event_list_map_width = 300;            // ee_map_width
2871
-        $this->event_list_map_height = 185;        // ee_map_height
2872
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2873
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2874
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2875
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2876
-        $this->event_list_map_align = 'center';            // ee_map_align
2877
-    }
2769
+	/**
2770
+	 * @var boolean $use_google_maps
2771
+	 */
2772
+	public $use_google_maps;
2773
+
2774
+	/**
2775
+	 * @var string $api_key
2776
+	 */
2777
+	public $google_map_api_key;
2778
+
2779
+	/**
2780
+	 * @var int $event_details_map_width
2781
+	 */
2782
+	public $event_details_map_width;
2783
+
2784
+	/**
2785
+	 * @var int $event_details_map_height
2786
+	 */
2787
+	public $event_details_map_height;
2788
+
2789
+	/**
2790
+	 * @var int $event_details_map_zoom
2791
+	 */
2792
+	public $event_details_map_zoom;
2793
+
2794
+	/**
2795
+	 * @var boolean $event_details_display_nav
2796
+	 */
2797
+	public $event_details_display_nav;
2798
+
2799
+	/**
2800
+	 * @var boolean $event_details_nav_size
2801
+	 */
2802
+	public $event_details_nav_size;
2803
+
2804
+	/**
2805
+	 * @var string $event_details_control_type
2806
+	 */
2807
+	public $event_details_control_type;
2808
+
2809
+	/**
2810
+	 * @var string $event_details_map_align
2811
+	 */
2812
+	public $event_details_map_align;
2813
+
2814
+	/**
2815
+	 * @var int $event_list_map_width
2816
+	 */
2817
+	public $event_list_map_width;
2818
+
2819
+	/**
2820
+	 * @var int $event_list_map_height
2821
+	 */
2822
+	public $event_list_map_height;
2823
+
2824
+	/**
2825
+	 * @var int $event_list_map_zoom
2826
+	 */
2827
+	public $event_list_map_zoom;
2828
+
2829
+	/**
2830
+	 * @var boolean $event_list_display_nav
2831
+	 */
2832
+	public $event_list_display_nav;
2833
+
2834
+	/**
2835
+	 * @var boolean $event_list_nav_size
2836
+	 */
2837
+	public $event_list_nav_size;
2838
+
2839
+	/**
2840
+	 * @var string $event_list_control_type
2841
+	 */
2842
+	public $event_list_control_type;
2843
+
2844
+	/**
2845
+	 * @var string $event_list_map_align
2846
+	 */
2847
+	public $event_list_map_align;
2848
+
2849
+
2850
+
2851
+	/**
2852
+	 *    class constructor
2853
+	 *
2854
+	 * @access    public
2855
+	 */
2856
+	public function __construct()
2857
+	{
2858
+		// set default map settings
2859
+		$this->use_google_maps = true;
2860
+		$this->google_map_api_key = '';
2861
+		// for event details pages (reg page)
2862
+		$this->event_details_map_width = 585;            // ee_map_width_single
2863
+		$this->event_details_map_height = 362;            // ee_map_height_single
2864
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2865
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2866
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2867
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2868
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2869
+		// for event list pages
2870
+		$this->event_list_map_width = 300;            // ee_map_width
2871
+		$this->event_list_map_height = 185;        // ee_map_height
2872
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2873
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2874
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2875
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2876
+		$this->event_list_map_align = 'center';            // ee_map_align
2877
+	}
2878 2878
 
2879 2879
 }
2880 2880
 
@@ -2886,47 +2886,47 @@  discard block
 block discarded – undo
2886 2886
 class EE_Events_Archive_Config extends EE_Config_Base
2887 2887
 {
2888 2888
 
2889
-    public $display_status_banner;
2889
+	public $display_status_banner;
2890 2890
 
2891
-    public $display_description;
2891
+	public $display_description;
2892 2892
 
2893
-    public $display_ticket_selector;
2893
+	public $display_ticket_selector;
2894 2894
 
2895
-    public $display_datetimes;
2895
+	public $display_datetimes;
2896 2896
 
2897
-    public $display_venue;
2897
+	public $display_venue;
2898 2898
 
2899
-    public $display_expired_events;
2899
+	public $display_expired_events;
2900 2900
 
2901
-    public $use_sortable_display_order;
2901
+	public $use_sortable_display_order;
2902 2902
 
2903
-    public $display_order_tickets;
2903
+	public $display_order_tickets;
2904 2904
 
2905
-    public $display_order_datetimes;
2905
+	public $display_order_datetimes;
2906 2906
 
2907
-    public $display_order_event;
2907
+	public $display_order_event;
2908 2908
 
2909
-    public $display_order_venue;
2909
+	public $display_order_venue;
2910 2910
 
2911 2911
 
2912 2912
 
2913
-    /**
2914
-     *    class constructor
2915
-     */
2916
-    public function __construct()
2917
-    {
2918
-        $this->display_status_banner = 0;
2919
-        $this->display_description = 1;
2920
-        $this->display_ticket_selector = 0;
2921
-        $this->display_datetimes = 1;
2922
-        $this->display_venue = 0;
2923
-        $this->display_expired_events = 0;
2924
-        $this->use_sortable_display_order = false;
2925
-        $this->display_order_tickets = 100;
2926
-        $this->display_order_datetimes = 110;
2927
-        $this->display_order_event = 120;
2928
-        $this->display_order_venue = 130;
2929
-    }
2913
+	/**
2914
+	 *    class constructor
2915
+	 */
2916
+	public function __construct()
2917
+	{
2918
+		$this->display_status_banner = 0;
2919
+		$this->display_description = 1;
2920
+		$this->display_ticket_selector = 0;
2921
+		$this->display_datetimes = 1;
2922
+		$this->display_venue = 0;
2923
+		$this->display_expired_events = 0;
2924
+		$this->use_sortable_display_order = false;
2925
+		$this->display_order_tickets = 100;
2926
+		$this->display_order_datetimes = 110;
2927
+		$this->display_order_event = 120;
2928
+		$this->display_order_venue = 130;
2929
+	}
2930 2930
 }
2931 2931
 
2932 2932
 
@@ -2937,35 +2937,35 @@  discard block
 block discarded – undo
2937 2937
 class EE_Event_Single_Config extends EE_Config_Base
2938 2938
 {
2939 2939
 
2940
-    public $display_status_banner_single;
2940
+	public $display_status_banner_single;
2941 2941
 
2942
-    public $display_venue;
2942
+	public $display_venue;
2943 2943
 
2944
-    public $use_sortable_display_order;
2944
+	public $use_sortable_display_order;
2945 2945
 
2946
-    public $display_order_tickets;
2946
+	public $display_order_tickets;
2947 2947
 
2948
-    public $display_order_datetimes;
2948
+	public $display_order_datetimes;
2949 2949
 
2950
-    public $display_order_event;
2950
+	public $display_order_event;
2951 2951
 
2952
-    public $display_order_venue;
2952
+	public $display_order_venue;
2953 2953
 
2954 2954
 
2955 2955
 
2956
-    /**
2957
-     *    class constructor
2958
-     */
2959
-    public function __construct()
2960
-    {
2961
-        $this->display_status_banner_single = 0;
2962
-        $this->display_venue = 1;
2963
-        $this->use_sortable_display_order = false;
2964
-        $this->display_order_tickets = 100;
2965
-        $this->display_order_datetimes = 110;
2966
-        $this->display_order_event = 120;
2967
-        $this->display_order_venue = 130;
2968
-    }
2956
+	/**
2957
+	 *    class constructor
2958
+	 */
2959
+	public function __construct()
2960
+	{
2961
+		$this->display_status_banner_single = 0;
2962
+		$this->display_venue = 1;
2963
+		$this->use_sortable_display_order = false;
2964
+		$this->display_order_tickets = 100;
2965
+		$this->display_order_datetimes = 110;
2966
+		$this->display_order_event = 120;
2967
+		$this->display_order_venue = 130;
2968
+	}
2969 2969
 }
2970 2970
 
2971 2971
 
@@ -2976,151 +2976,151 @@  discard block
 block discarded – undo
2976 2976
 class EE_Ticket_Selector_Config extends EE_Config_Base
2977 2977
 {
2978 2978
 
2979
-    /**
2980
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2981
-     */
2982
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2983
-
2984
-    /**
2985
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2986
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2987
-     */
2988
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2989
-
2990
-    /**
2991
-     * @var boolean $show_ticket_sale_columns
2992
-     */
2993
-    public $show_ticket_sale_columns;
2994
-
2995
-    /**
2996
-     * @var boolean $show_ticket_details
2997
-     */
2998
-    public $show_ticket_details;
2999
-
3000
-    /**
3001
-     * @var boolean $show_expired_tickets
3002
-     */
3003
-    public $show_expired_tickets;
3004
-
3005
-    /**
3006
-     * whether or not to display a dropdown box populated with event datetimes
3007
-     * that toggles which tickets are displayed for a ticket selector.
3008
-     * uses one of the *_DATETIME_SELECTOR constants defined above
3009
-     *
3010
-     * @var string $show_datetime_selector
3011
-     */
3012
-    private $show_datetime_selector = 'no_datetime_selector';
3013
-
3014
-    /**
3015
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
3016
-     *
3017
-     * @var int $datetime_selector_threshold
3018
-     */
3019
-    private $datetime_selector_threshold = 3;
3020
-
3021
-
3022
-
3023
-    /**
3024
-     *    class constructor
3025
-     */
3026
-    public function __construct()
3027
-    {
3028
-        $this->show_ticket_sale_columns = true;
3029
-        $this->show_ticket_details = true;
3030
-        $this->show_expired_tickets = true;
3031
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3032
-        $this->datetime_selector_threshold = 3;
3033
-    }
3034
-
3035
-
3036
-
3037
-    /**
3038
-     * returns true if a datetime selector should be displayed
3039
-     *
3040
-     * @param array $datetimes
3041
-     * @return bool
3042
-     */
3043
-    public function showDatetimeSelector(array $datetimes)
3044
-    {
3045
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3046
-        return ! (
3047
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3048
-            || (
3049
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3050
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3051
-            )
3052
-        );
3053
-    }
3054
-
3055
-
3056
-
3057
-    /**
3058
-     * @return string
3059
-     */
3060
-    public function getShowDatetimeSelector()
3061
-    {
3062
-        return $this->show_datetime_selector;
3063
-    }
3064
-
3065
-
3066
-
3067
-    /**
3068
-     * @param bool $keys_only
3069
-     * @return array
3070
-     */
3071
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3072
-    {
3073
-        return $keys_only
3074
-            ? array(
3075
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3076
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3077
-            )
3078
-            : array(
3079
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3080
-                    'Do not show date & time filter', 'event_espresso'
3081
-                ),
3082
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3083
-                    'Maybe show date & time filter', 'event_espresso'
3084
-                ),
3085
-            );
3086
-    }
3087
-
3088
-
3089
-
3090
-    /**
3091
-     * @param string $show_datetime_selector
3092
-     */
3093
-    public function setShowDatetimeSelector($show_datetime_selector)
3094
-    {
3095
-        $this->show_datetime_selector = in_array(
3096
-            $show_datetime_selector,
3097
-            $this->getShowDatetimeSelectorOptions(),
3098
-            true
3099
-        )
3100
-            ? $show_datetime_selector
3101
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3102
-    }
3103
-
3104
-
3105
-
3106
-    /**
3107
-     * @return int
3108
-     */
3109
-    public function getDatetimeSelectorThreshold()
3110
-    {
3111
-        return $this->datetime_selector_threshold;
3112
-    }
3113
-
3114
-
3115
-
3116
-    /**
3117
-     * @param int $datetime_selector_threshold
3118
-     */
3119
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3120
-    {
3121
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3122
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3123
-    }
2979
+	/**
2980
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2981
+	 */
2982
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2983
+
2984
+	/**
2985
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2986
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2987
+	 */
2988
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2989
+
2990
+	/**
2991
+	 * @var boolean $show_ticket_sale_columns
2992
+	 */
2993
+	public $show_ticket_sale_columns;
2994
+
2995
+	/**
2996
+	 * @var boolean $show_ticket_details
2997
+	 */
2998
+	public $show_ticket_details;
2999
+
3000
+	/**
3001
+	 * @var boolean $show_expired_tickets
3002
+	 */
3003
+	public $show_expired_tickets;
3004
+
3005
+	/**
3006
+	 * whether or not to display a dropdown box populated with event datetimes
3007
+	 * that toggles which tickets are displayed for a ticket selector.
3008
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
3009
+	 *
3010
+	 * @var string $show_datetime_selector
3011
+	 */
3012
+	private $show_datetime_selector = 'no_datetime_selector';
3013
+
3014
+	/**
3015
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
3016
+	 *
3017
+	 * @var int $datetime_selector_threshold
3018
+	 */
3019
+	private $datetime_selector_threshold = 3;
3020
+
3021
+
3022
+
3023
+	/**
3024
+	 *    class constructor
3025
+	 */
3026
+	public function __construct()
3027
+	{
3028
+		$this->show_ticket_sale_columns = true;
3029
+		$this->show_ticket_details = true;
3030
+		$this->show_expired_tickets = true;
3031
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3032
+		$this->datetime_selector_threshold = 3;
3033
+	}
3034
+
3035
+
3036
+
3037
+	/**
3038
+	 * returns true if a datetime selector should be displayed
3039
+	 *
3040
+	 * @param array $datetimes
3041
+	 * @return bool
3042
+	 */
3043
+	public function showDatetimeSelector(array $datetimes)
3044
+	{
3045
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3046
+		return ! (
3047
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3048
+			|| (
3049
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3050
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3051
+			)
3052
+		);
3053
+	}
3054
+
3055
+
3056
+
3057
+	/**
3058
+	 * @return string
3059
+	 */
3060
+	public function getShowDatetimeSelector()
3061
+	{
3062
+		return $this->show_datetime_selector;
3063
+	}
3064
+
3065
+
3066
+
3067
+	/**
3068
+	 * @param bool $keys_only
3069
+	 * @return array
3070
+	 */
3071
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3072
+	{
3073
+		return $keys_only
3074
+			? array(
3075
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3076
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3077
+			)
3078
+			: array(
3079
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3080
+					'Do not show date & time filter', 'event_espresso'
3081
+				),
3082
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3083
+					'Maybe show date & time filter', 'event_espresso'
3084
+				),
3085
+			);
3086
+	}
3087
+
3088
+
3089
+
3090
+	/**
3091
+	 * @param string $show_datetime_selector
3092
+	 */
3093
+	public function setShowDatetimeSelector($show_datetime_selector)
3094
+	{
3095
+		$this->show_datetime_selector = in_array(
3096
+			$show_datetime_selector,
3097
+			$this->getShowDatetimeSelectorOptions(),
3098
+			true
3099
+		)
3100
+			? $show_datetime_selector
3101
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3102
+	}
3103
+
3104
+
3105
+
3106
+	/**
3107
+	 * @return int
3108
+	 */
3109
+	public function getDatetimeSelectorThreshold()
3110
+	{
3111
+		return $this->datetime_selector_threshold;
3112
+	}
3113
+
3114
+
3115
+
3116
+	/**
3117
+	 * @param int $datetime_selector_threshold
3118
+	 */
3119
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3120
+	{
3121
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3122
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3123
+	}
3124 3124
 
3125 3125
 
3126 3126
 }
@@ -3137,85 +3137,85 @@  discard block
 block discarded – undo
3137 3137
 class EE_Environment_Config extends EE_Config_Base
3138 3138
 {
3139 3139
 
3140
-    /**
3141
-     * Hold any php environment variables that we want to track.
3142
-     *
3143
-     * @var stdClass;
3144
-     */
3145
-    public $php;
3146
-
3147
-
3148
-
3149
-    /**
3150
-     *    constructor
3151
-     */
3152
-    public function __construct()
3153
-    {
3154
-        $this->php = new stdClass();
3155
-        $this->_set_php_values();
3156
-    }
3157
-
3158
-
3159
-
3160
-    /**
3161
-     * This sets the php environment variables.
3162
-     *
3163
-     * @since 4.4.0
3164
-     * @return void
3165
-     */
3166
-    protected function _set_php_values()
3167
-    {
3168
-        $this->php->max_input_vars = ini_get('max_input_vars');
3169
-        $this->php->version = phpversion();
3170
-    }
3171
-
3172
-
3173
-
3174
-    /**
3175
-     * helper method for determining whether input_count is
3176
-     * reaching the potential maximum the server can handle
3177
-     * according to max_input_vars
3178
-     *
3179
-     * @param int   $input_count the count of input vars.
3180
-     * @return array {
3181
-     *                           An array that represents whether available space and if no available space the error
3182
-     *                           message.
3183
-     * @type bool   $has_space   whether more inputs can be added.
3184
-     * @type string $msg         Any message to be displayed.
3185
-     *                           }
3186
-     */
3187
-    public function max_input_vars_limit_check($input_count = 0)
3188
-    {
3189
-        if ( ! empty($this->php->max_input_vars)
3190
-             && ($input_count >= $this->php->max_input_vars)
3191
-             && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3192
-        ) {
3193
-            return sprintf(
3194
-                __(
3195
-                    'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3196
-                    'event_espresso'
3197
-                ),
3198
-                '<br>',
3199
-                $input_count,
3200
-                $this->php->max_input_vars
3201
-            );
3202
-        } else {
3203
-            return '';
3204
-        }
3205
-    }
3206
-
3207
-
3208
-
3209
-    /**
3210
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3211
-     *
3212
-     * @since 4.4.1
3213
-     * @return void
3214
-     */
3215
-    public function recheck_values()
3216
-    {
3217
-        $this->_set_php_values();
3218
-    }
3140
+	/**
3141
+	 * Hold any php environment variables that we want to track.
3142
+	 *
3143
+	 * @var stdClass;
3144
+	 */
3145
+	public $php;
3146
+
3147
+
3148
+
3149
+	/**
3150
+	 *    constructor
3151
+	 */
3152
+	public function __construct()
3153
+	{
3154
+		$this->php = new stdClass();
3155
+		$this->_set_php_values();
3156
+	}
3157
+
3158
+
3159
+
3160
+	/**
3161
+	 * This sets the php environment variables.
3162
+	 *
3163
+	 * @since 4.4.0
3164
+	 * @return void
3165
+	 */
3166
+	protected function _set_php_values()
3167
+	{
3168
+		$this->php->max_input_vars = ini_get('max_input_vars');
3169
+		$this->php->version = phpversion();
3170
+	}
3171
+
3172
+
3173
+
3174
+	/**
3175
+	 * helper method for determining whether input_count is
3176
+	 * reaching the potential maximum the server can handle
3177
+	 * according to max_input_vars
3178
+	 *
3179
+	 * @param int   $input_count the count of input vars.
3180
+	 * @return array {
3181
+	 *                           An array that represents whether available space and if no available space the error
3182
+	 *                           message.
3183
+	 * @type bool   $has_space   whether more inputs can be added.
3184
+	 * @type string $msg         Any message to be displayed.
3185
+	 *                           }
3186
+	 */
3187
+	public function max_input_vars_limit_check($input_count = 0)
3188
+	{
3189
+		if ( ! empty($this->php->max_input_vars)
3190
+			 && ($input_count >= $this->php->max_input_vars)
3191
+			 && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3192
+		) {
3193
+			return sprintf(
3194
+				__(
3195
+					'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3196
+					'event_espresso'
3197
+				),
3198
+				'<br>',
3199
+				$input_count,
3200
+				$this->php->max_input_vars
3201
+			);
3202
+		} else {
3203
+			return '';
3204
+		}
3205
+	}
3206
+
3207
+
3208
+
3209
+	/**
3210
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3211
+	 *
3212
+	 * @since 4.4.1
3213
+	 * @return void
3214
+	 */
3215
+	public function recheck_values()
3216
+	{
3217
+		$this->_set_php_values();
3218
+	}
3219 3219
 
3220 3220
 
3221 3221
 }
@@ -3232,22 +3232,22 @@  discard block
 block discarded – undo
3232 3232
 class EE_Tax_Config extends EE_Config_Base
3233 3233
 {
3234 3234
 
3235
-    /*
3235
+	/*
3236 3236
      * flag to indicate whether or not to display ticket prices with the taxes included
3237 3237
      *
3238 3238
      * @var boolean $prices_displayed_including_taxes
3239 3239
      */
3240
-    public $prices_displayed_including_taxes;
3240
+	public $prices_displayed_including_taxes;
3241 3241
 
3242 3242
 
3243 3243
 
3244
-    /**
3245
-     *    class constructor
3246
-     */
3247
-    public function __construct()
3248
-    {
3249
-        $this->prices_displayed_including_taxes = true;
3250
-    }
3244
+	/**
3245
+	 *    class constructor
3246
+	 */
3247
+	public function __construct()
3248
+	{
3249
+		$this->prices_displayed_including_taxes = true;
3250
+	}
3251 3251
 }
3252 3252
 
3253 3253
 
@@ -3260,34 +3260,34 @@  discard block
 block discarded – undo
3260 3260
 class EE_Gateway_Config extends EE_Config_Base
3261 3261
 {
3262 3262
 
3263
-    /**
3264
-     * Array with keys that are payment gateways slugs, and values are arrays
3265
-     * with any config info the gateway wants to store
3266
-     *
3267
-     * @var array
3268
-     */
3269
-    public $payment_settings;
3270
-
3271
-    /**
3272
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3273
-     * the gateway is stored in the uploads directory
3274
-     *
3275
-     * @var array
3276
-     */
3277
-    public $active_gateways;
3278
-
3279
-
3280
-
3281
-    /**
3282
-     *    class constructor
3283
-     *
3284
-     * @deprecated
3285
-     */
3286
-    public function __construct()
3287
-    {
3288
-        $this->payment_settings = array();
3289
-        $this->active_gateways = array('Invoice' => false);
3290
-    }
3263
+	/**
3264
+	 * Array with keys that are payment gateways slugs, and values are arrays
3265
+	 * with any config info the gateway wants to store
3266
+	 *
3267
+	 * @var array
3268
+	 */
3269
+	public $payment_settings;
3270
+
3271
+	/**
3272
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3273
+	 * the gateway is stored in the uploads directory
3274
+	 *
3275
+	 * @var array
3276
+	 */
3277
+	public $active_gateways;
3278
+
3279
+
3280
+
3281
+	/**
3282
+	 *    class constructor
3283
+	 *
3284
+	 * @deprecated
3285
+	 */
3286
+	public function __construct()
3287
+	{
3288
+		$this->payment_settings = array();
3289
+		$this->active_gateways = array('Invoice' => false);
3290
+	}
3291 3291
 }
3292 3292
 
3293 3293
 // End of file EE_Config.core.php
Please login to merge, or discard this patch.
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
                 $this
279 279
             );
280 280
             if (is_object($settings) && property_exists($this, $config)) {
281
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
281
+                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
282 282
                 //call configs populate method to ensure any defaults are set for empty values.
283 283
                 if (method_exists($settings, 'populate')) {
284 284
                     $this->{$config}->populate();
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
      */
688 688
     private function _generate_config_option_name($section = '', $name = '')
689 689
     {
690
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
690
+        return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
691 691
     }
692 692
 
693 693
 
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
     {
706 706
         return ! empty($config_class)
707 707
             ? $config_class
708
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
708
+            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
709 709
     }
710 710
 
711 711
 
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
                             'event_espresso'
822 822
                         ),
823 823
                         $config_class,
824
-                        'EE_Config->' . $section . '->' . $name
824
+                        'EE_Config->'.$section.'->'.$name
825 825
                     ),
826 826
                     __FILE__,
827 827
                     __FUNCTION__,
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
         // retrieve the wp-option for this config class.
895 895
         $config_option = maybe_unserialize(get_option($config_option_name, array()));
896 896
         if (empty($config_option)) {
897
-            EE_Config::log($config_option_name . '-NOT-FOUND');
897
+            EE_Config::log($config_option_name.'-NOT-FOUND');
898 898
         }
899 899
         return $config_option;
900 900
     }
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
             //copy incoming $_REQUEST and sanitize it so we can save it
914 914
             $_request = $_REQUEST;
915 915
             array_walk_recursive($_request, 'sanitize_text_field');
916
-            $config_log[(string)microtime(true)] = array(
916
+            $config_log[(string) microtime(true)] = array(
917 917
                 'config_name' => $config_option_name,
918 918
                 'request'     => $_request,
919 919
             );
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
             )
1020 1020
         ) {
1021 1021
             // grab list of installed widgets
1022
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1022
+            $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
1023 1023
             // filter list of modules to register
1024 1024
             $widgets_to_register = apply_filters(
1025 1025
                 'FHEE__EE_Config__register_widgets__widgets_to_register',
@@ -1076,31 +1076,31 @@  discard block
 block discarded – undo
1076 1076
         // create classname from widget directory name
1077 1077
         $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1078 1078
         // add class prefix
1079
-        $widget_class = 'EEW_' . $widget;
1079
+        $widget_class = 'EEW_'.$widget;
1080 1080
         // does the widget exist ?
1081
-        if ( ! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1081
+        if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) {
1082 1082
             $msg = sprintf(
1083 1083
                 __(
1084 1084
                     'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1085 1085
                     'event_espresso'
1086 1086
                 ),
1087 1087
                 $widget_class,
1088
-                $widget_path . DS . $widget_class . $widget_ext
1088
+                $widget_path.DS.$widget_class.$widget_ext
1089 1089
             );
1090
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1090
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1091 1091
             return;
1092 1092
         }
1093 1093
         // load the widget class file
1094
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1094
+        require_once($widget_path.DS.$widget_class.$widget_ext);
1095 1095
         // verify that class exists
1096 1096
         if ( ! class_exists($widget_class)) {
1097 1097
             $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1098
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1098
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1099 1099
             return;
1100 1100
         }
1101 1101
         register_widget($widget_class);
1102 1102
         // add to array of registered widgets
1103
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1103
+        EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext;
1104 1104
     }
1105 1105
 
1106 1106
 
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
     private function _register_shortcodes()
1115 1115
     {
1116 1116
         // grab list of installed shortcodes
1117
-        $shortcodes_to_register = glob(EE_SHORTCODES . '*', GLOB_ONLYDIR);
1117
+        $shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR);
1118 1118
         // filter list of modules to register
1119 1119
         $shortcodes_to_register = apply_filters(
1120 1120
             'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
@@ -1164,44 +1164,44 @@  discard block
 block discarded – undo
1164 1164
             // remove last segment
1165 1165
             array_pop($shortcode_path);
1166 1166
             // glue it back together
1167
-            $shortcode_path = implode(DS, $shortcode_path) . DS;
1167
+            $shortcode_path = implode(DS, $shortcode_path).DS;
1168 1168
         } else {
1169 1169
             // we need to generate the filename based off of the folder name
1170 1170
             // grab and sanitize shortcode directory name
1171 1171
             $shortcode = sanitize_key(basename($shortcode_path));
1172
-            $shortcode_path = rtrim($shortcode_path, DS) . DS;
1172
+            $shortcode_path = rtrim($shortcode_path, DS).DS;
1173 1173
         }
1174 1174
         // create classname from shortcode directory or file name
1175 1175
         $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
1176 1176
         // add class prefix
1177
-        $shortcode_class = 'EES_' . $shortcode;
1177
+        $shortcode_class = 'EES_'.$shortcode;
1178 1178
         // does the shortcode exist ?
1179
-        if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) {
1179
+        if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) {
1180 1180
             $msg = sprintf(
1181 1181
                 __(
1182 1182
                     'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s',
1183 1183
                     'event_espresso'
1184 1184
                 ),
1185 1185
                 $shortcode_class,
1186
-                $shortcode_path . DS . $shortcode_class . $shortcode_ext
1186
+                $shortcode_path.DS.$shortcode_class.$shortcode_ext
1187 1187
             );
1188
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1188
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1189 1189
             return false;
1190 1190
         }
1191 1191
         // load the shortcode class file
1192
-        require_once($shortcode_path . $shortcode_class . $shortcode_ext);
1192
+        require_once($shortcode_path.$shortcode_class.$shortcode_ext);
1193 1193
         // verify that class exists
1194 1194
         if ( ! class_exists($shortcode_class)) {
1195 1195
             $msg = sprintf(
1196 1196
                 __('The requested %s shortcode class does not exist.', 'event_espresso'),
1197 1197
                 $shortcode_class
1198 1198
             );
1199
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1199
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1200 1200
             return false;
1201 1201
         }
1202 1202
         $shortcode = strtoupper($shortcode);
1203 1203
         // add to array of registered shortcodes
1204
-        EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
1204
+        EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext;
1205 1205
         return true;
1206 1206
     }
1207 1207
 
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
     private function _register_modules()
1217 1217
     {
1218 1218
         // grab list of installed modules
1219
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1219
+        $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1220 1220
         // filter list of modules to register
1221 1221
         $modules_to_register = apply_filters(
1222 1222
             'FHEE__EE_Config__register_modules__modules_to_register',
@@ -1227,8 +1227,8 @@  discard block
 block discarded – undo
1227 1227
             foreach ($modules_to_register as $module_path) {
1228 1228
                 /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1229 1229
                 if (
1230
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1231
-                    && $module_path !== EE_MODULES . 'gateways'
1230
+                    $module_path !== EE_MODULES.'zzz-copy-this-module-template'
1231
+                    && $module_path !== EE_MODULES.'gateways'
1232 1232
                 ) {
1233 1233
                     // add to list of installed modules
1234 1234
                     EE_Config::register_module($module_path);
@@ -1266,25 +1266,25 @@  discard block
 block discarded – undo
1266 1266
             // remove last segment
1267 1267
             array_pop($module_path);
1268 1268
             // glue it back together
1269
-            $module_path = implode(DS, $module_path) . DS;
1269
+            $module_path = implode(DS, $module_path).DS;
1270 1270
             // take first segment from file name pieces and sanitize it
1271 1271
             $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1272 1272
             // ensure class prefix is added
1273
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1273
+            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1274 1274
         } else {
1275 1275
             // we need to generate the filename based off of the folder name
1276 1276
             // grab and sanitize module name
1277 1277
             $module = strtolower(basename($module_path));
1278 1278
             $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1279 1279
             // like trailingslashit()
1280
-            $module_path = rtrim($module_path, DS) . DS;
1280
+            $module_path = rtrim($module_path, DS).DS;
1281 1281
             // create classname from module directory name
1282 1282
             $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1283 1283
             // add class prefix
1284
-            $module_class = 'EED_' . $module;
1284
+            $module_class = 'EED_'.$module;
1285 1285
         }
1286 1286
         // does the module exist ?
1287
-        if ( ! is_readable($module_path . DS . $module_class . $module_ext)) {
1287
+        if ( ! is_readable($module_path.DS.$module_class.$module_ext)) {
1288 1288
             $msg = sprintf(
1289 1289
                 __(
1290 1290
                     'The requested %s module file could not be found or is not readable due to file permissions.',
@@ -1292,19 +1292,19 @@  discard block
 block discarded – undo
1292 1292
                 ),
1293 1293
                 $module
1294 1294
             );
1295
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1295
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1296 1296
             return false;
1297 1297
         }
1298 1298
         // load the module class file
1299
-        require_once($module_path . $module_class . $module_ext);
1299
+        require_once($module_path.$module_class.$module_ext);
1300 1300
         // verify that class exists
1301 1301
         if ( ! class_exists($module_class)) {
1302 1302
             $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1303
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1303
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1304 1304
             return false;
1305 1305
         }
1306 1306
         // add to array of registered modules
1307
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1307
+        EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1308 1308
         do_action(
1309 1309
             'AHEE__EE_Config__register_module__complete',
1310 1310
             $module_class,
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
         // cycle thru shortcode folders
1328 1328
         foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) {
1329 1329
             // add class prefix
1330
-            $shortcode_class = 'EES_' . $shortcode;
1330
+            $shortcode_class = 'EES_'.$shortcode;
1331 1331
             // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1332 1332
             // which set hooks ?
1333 1333
             if (is_admin()) {
@@ -1394,26 +1394,26 @@  discard block
 block discarded – undo
1394 1394
     {
1395 1395
         do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1396 1396
         $module = str_replace('EED_', '', $module);
1397
-        $module_class = 'EED_' . $module;
1397
+        $module_class = 'EED_'.$module;
1398 1398
         if ( ! isset(EE_Registry::instance()->modules->{$module_class})) {
1399 1399
             $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1400
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1400
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1401 1401
             return false;
1402 1402
         }
1403 1403
         if (empty($route)) {
1404 1404
             $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1405
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1405
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1406 1406
             return false;
1407 1407
         }
1408
-        if ( ! method_exists('EED_' . $module, $method_name)) {
1408
+        if ( ! method_exists('EED_'.$module, $method_name)) {
1409 1409
             $msg = sprintf(
1410 1410
                 __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1411 1411
                 $route
1412 1412
             );
1413
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1413
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1414 1414
             return false;
1415 1415
         }
1416
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1416
+        EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name);
1417 1417
         return true;
1418 1418
     }
1419 1419
 
@@ -1430,7 +1430,7 @@  discard block
 block discarded – undo
1430 1430
     public static function get_route($route = null, $key = 'ee')
1431 1431
     {
1432 1432
         do_action('AHEE__EE_Config__get_route__begin', $route);
1433
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1433
+        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1434 1434
         if (isset(EE_Config::$_module_route_map[$key][$route])) {
1435 1435
             return EE_Config::$_module_route_map[$key][$route];
1436 1436
         }
@@ -1471,12 +1471,12 @@  discard block
 block discarded – undo
1471 1471
                 __('The module route %s for this forward has not been registered.', 'event_espresso'),
1472 1472
                 $route
1473 1473
             );
1474
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1474
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1475 1475
             return false;
1476 1476
         }
1477 1477
         if (empty($forward)) {
1478 1478
             $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1479
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1479
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1480 1480
             return false;
1481 1481
         }
1482 1482
         if (is_array($forward)) {
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
                     __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1486 1486
                     $route
1487 1487
                 );
1488
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1488
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1489 1489
                 return false;
1490 1490
             }
1491 1491
             if ( ! method_exists($forward[0], $forward[1])) {
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
                     $forward[1],
1495 1495
                     $route
1496 1496
                 );
1497
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1497
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1498 1498
                 return false;
1499 1499
             }
1500 1500
         } else if ( ! function_exists($forward)) {
@@ -1503,7 +1503,7 @@  discard block
 block discarded – undo
1503 1503
                 $forward,
1504 1504
                 $route
1505 1505
             );
1506
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1506
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1507 1507
             return false;
1508 1508
         }
1509 1509
         EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
                 __('The module route %s for this view has not been registered.', 'event_espresso'),
1559 1559
                 $route
1560 1560
             );
1561
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1561
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1562 1562
             return false;
1563 1563
         }
1564 1564
         if ( ! is_readable($view)) {
@@ -1569,7 +1569,7 @@  discard block
 block discarded – undo
1569 1569
                 ),
1570 1570
                 $view
1571 1571
             );
1572
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1572
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1573 1573
             return false;
1574 1574
         }
1575 1575
         EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
@@ -1886,7 +1886,7 @@  discard block
 block discarded – undo
1886 1886
             $this->reg_page_url = add_query_arg(
1887 1887
                                       array('uts' => time()),
1888 1888
                                       get_permalink($this->reg_page_id)
1889
-                                  ) . '#checkout';
1889
+                                  ).'#checkout';
1890 1890
         }
1891 1891
         return $this->reg_page_url;
1892 1892
     }
@@ -1990,13 +1990,13 @@  discard block
 block discarded – undo
1990 1990
         $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1991 1991
         $option = 'ee_ueip_optin';
1992 1992
         //set correct table for query
1993
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1993
+        $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1994 1994
         //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1995 1995
         //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1996 1996
         //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1997 1997
         //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1998 1998
         //for the purpose of caching.
1999
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1999
+        $pre = apply_filters('pre_option_'.$option, false, $option);
2000 2000
         if (false !== $pre) {
2001 2001
             EE_Core_Config::$ee_ueip_option = $pre;
2002 2002
             return EE_Core_Config::$ee_ueip_option;
@@ -2006,9 +2006,9 @@  discard block
 block discarded – undo
2006 2006
         if (is_object($row)) {
2007 2007
             $value = $row->option_value;
2008 2008
         } else { //option does not exist so use default.
2009
-            return apply_filters('default_option_' . $option, false, $option);
2009
+            return apply_filters('default_option_'.$option, false, $option);
2010 2010
         }
2011
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
2011
+        EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
2012 2012
         return EE_Core_Config::$ee_ueip_option;
2013 2013
     }
2014 2014
 
@@ -2285,27 +2285,27 @@  discard block
 block discarded – undo
2285 2285
             // retrieve the country settings from the db, just in case they have been customized
2286 2286
             $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2287 2287
             if ($country instanceof EE_Country) {
2288
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2289
-                $this->name = $country->currency_name_single();    // Dollar
2290
-                $this->plural = $country->currency_name_plural();    // Dollars
2291
-                $this->sign = $country->currency_sign();            // currency sign: $
2292
-                $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2293
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2294
-                $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2295
-                $this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2288
+                $this->code = $country->currency_code(); // currency code: USD, CAD, EUR
2289
+                $this->name = $country->currency_name_single(); // Dollar
2290
+                $this->plural = $country->currency_name_plural(); // Dollars
2291
+                $this->sign = $country->currency_sign(); // currency sign: $
2292
+                $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE  or  FALSE$
2293
+                $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
2294
+                $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2295
+                $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2296 2296
             }
2297 2297
         }
2298 2298
         // fallback to hardcoded defaults, in case the above failed
2299 2299
         if (empty($this->code)) {
2300 2300
             // set default currency settings
2301
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2302
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2303
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2304
-            $this->sign = '$';    // currency sign: $
2305
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2306
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2307
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2308
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2301
+            $this->code = 'USD'; // currency code: USD, CAD, EUR
2302
+            $this->name = __('Dollar', 'event_espresso'); // Dollar
2303
+            $this->plural = __('Dollars', 'event_espresso'); // Dollars
2304
+            $this->sign = '$'; // currency sign: $
2305
+            $this->sign_b4 = true; // currency sign before or after: $TRUE  or  FALSE$
2306
+            $this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
2307
+            $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2308
+            $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2309 2309
         }
2310 2310
     }
2311 2311
 }
@@ -2628,7 +2628,7 @@  discard block
 block discarded – undo
2628 2628
     public function log_file_name($reset = false)
2629 2629
     {
2630 2630
         if (empty($this->log_file_name) || $reset) {
2631
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2631
+            $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt';
2632 2632
             EE_Config::instance()->update_espresso_config(false, false);
2633 2633
         }
2634 2634
         return $this->log_file_name;
@@ -2643,7 +2643,7 @@  discard block
 block discarded – undo
2643 2643
     public function debug_file_name($reset = false)
2644 2644
     {
2645 2645
         if (empty($this->debug_file_name) || $reset) {
2646
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2646
+            $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt';
2647 2647
             EE_Config::instance()->update_espresso_config(false, false);
2648 2648
         }
2649 2649
         return $this->debug_file_name;
@@ -2859,21 +2859,21 @@  discard block
 block discarded – undo
2859 2859
         $this->use_google_maps = true;
2860 2860
         $this->google_map_api_key = '';
2861 2861
         // for event details pages (reg page)
2862
-        $this->event_details_map_width = 585;            // ee_map_width_single
2863
-        $this->event_details_map_height = 362;            // ee_map_height_single
2864
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2865
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2866
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2867
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2868
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2862
+        $this->event_details_map_width = 585; // ee_map_width_single
2863
+        $this->event_details_map_height = 362; // ee_map_height_single
2864
+        $this->event_details_map_zoom = 14; // ee_map_zoom_single
2865
+        $this->event_details_display_nav = true; // ee_map_nav_display_single
2866
+        $this->event_details_nav_size = false; // ee_map_nav_size_single
2867
+        $this->event_details_control_type = 'default'; // ee_map_type_control_single
2868
+        $this->event_details_map_align = 'center'; // ee_map_align_single
2869 2869
         // for event list pages
2870
-        $this->event_list_map_width = 300;            // ee_map_width
2871
-        $this->event_list_map_height = 185;        // ee_map_height
2872
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2873
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2874
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2875
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2876
-        $this->event_list_map_align = 'center';            // ee_map_align
2870
+        $this->event_list_map_width = 300; // ee_map_width
2871
+        $this->event_list_map_height = 185; // ee_map_height
2872
+        $this->event_list_map_zoom = 12; // ee_map_zoom
2873
+        $this->event_list_display_nav = false; // ee_map_nav_display
2874
+        $this->event_list_nav_size = true; // ee_map_nav_size
2875
+        $this->event_list_control_type = 'dropdown'; // ee_map_type_control
2876
+        $this->event_list_map_align = 'center'; // ee_map_align
2877 2877
     }
2878 2878
 
2879 2879
 }
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorRowStandard.php 2 patches
Indentation   +455 added lines, -455 removed lines patch added patch discarded remove patch
@@ -16,461 +16,461 @@
 block discarded – undo
16 16
 class TicketSelectorRowStandard extends TicketSelectorRow
17 17
 {
18 18
 
19
-    /**
20
-     * @var TicketDetails $ticket_details
21
-     */
22
-    protected $ticket_details;
23
-
24
-    /**
25
-     * @var \EE_Ticket_Selector_Config $template_settings
26
-     */
27
-    protected $template_settings;
28
-
29
-    /**
30
-     * @var \EE_Tax_Config $tax_settings
31
-     */
32
-    protected $tax_settings;
33
-
34
-    /**
35
-     * @var boolean $required_ticket_sold_out
36
-     */
37
-    protected $required_ticket_sold_out;
38
-
39
-    /**
40
-     * @var boolean $prices_displayed_including_taxes
41
-     */
42
-    protected $prices_displayed_including_taxes;
43
-
44
-    /**
45
-     * @var string $event_status
46
-     */
47
-    protected $event_status;
48
-
49
-    /**
50
-     * @var int $row
51
-     */
52
-    protected $row;
53
-
54
-    /**
55
-     * @var int $cols
56
-     */
57
-    protected $cols;
58
-
59
-    /**
60
-     * @var boolean $hidden_input_qty
61
-     */
62
-    protected $hidden_input_qty;
63
-
64
-    /**
65
-     * @var string $ticket_datetime_classes
66
-     */
67
-    protected $ticket_datetime_classes;
68
-
69
-
70
-
71
-    /**
72
-     * TicketDetails constructor.
73
-     *
74
-     * @param \EE_Ticket $ticket
75
-     * @param TicketDetails              $ticket_details
76
-     * @param \EE_Ticket_Selector_Config $template_settings
77
-     * @param \EE_Tax_Config             $tax_settings
78
-     * @param int                        $max_atndz
79
-     * @param int                        $row
80
-     * @param int                        $cols
81
-     * @param boolean                    $required_ticket_sold_out
82
-     * @param string                     $event_status
83
-     * @param string                     $date_format
84
-     * @param string                     $ticket_datetime_classes
85
-     */
86
-    public function __construct(
87
-        \EE_Ticket $ticket,
88
-        TicketDetails $ticket_details,
89
-        \EE_Ticket_Selector_Config $template_settings,
90
-        \EE_Tax_Config $tax_settings,
91
-        $max_atndz,
92
-        $row,
93
-        $cols,
94
-        $required_ticket_sold_out,
95
-        $event_status,
96
-        $date_format,
97
-        $ticket_datetime_classes
98
-    ) {
99
-        $this->ticket = $ticket;
100
-        $this->ticket_details = $ticket_details;
101
-        $this->template_settings = $template_settings;
102
-        $this->tax_settings = $tax_settings;
103
-        $this->max_atndz = $max_atndz;
104
-        $this->row = $row;
105
-        $this->cols = $cols;
106
-        $this->required_ticket_sold_out = $required_ticket_sold_out;
107
-        $this->event_status = $event_status;
108
-        $this->date_format = $date_format;
109
-        $this->ticket_datetime_classes = $ticket_datetime_classes;
110
-        parent::__construct($ticket, $max_atndz, $date_format);
111
-    }
112
-
113
-
114
-
115
-    /**
116
-     * other ticket rows will need to know if a required ticket is sold out,
117
-     * so that they are not offered for sale
118
-     *
119
-     * @return boolean
120
-     */
121
-    public function getRequiredTicketSoldOut()
122
-    {
123
-        return $this->required_ticket_sold_out;
124
-    }
125
-
126
-
127
-
128
-    /**
129
-     * @return int
130
-     */
131
-    public function getCols()
132
-    {
133
-        return $this->cols;
134
-    }
135
-
136
-
137
-
138
-    /**
139
-     * getHtml
140
-     *
141
-     * @return string
142
-     * @throws \EE_Error
143
-     */
144
-    public function getHtml()
145
-    {
146
-        $min = 0;
147
-        $max = $this->ticket->max();
148
-        $remaining = $this->ticket->remaining();
149
-        if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) {
150
-            list($min, $max) = $this->setTicketMinAndMax($remaining);
151
-        } else {
152
-            // set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
153
-            $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining
154
-                ? $this->ticket->start_date()
155
-                : $this->required_ticket_sold_out;
156
-        }
157
-        list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails();
158
-        list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining);
159
-        /**
160
-         * Allow plugins to hook in and abort the generation and display of this row to do
161
-         * something else if they want.
162
-         * For an addon to abort things, all they have to do is register a filter with this hook, and
163
-         * return a value that is NOT false.  Whatever is returned gets echoed instead of the
164
-         * current row.
165
-         *
166
-         * @var string|bool
167
-         */
168
-        $ticket_selector_row_html = apply_filters(
169
-            'FHEE__ticket_selector_chart_template__do_ticket_entire_row',
170
-            false,
171
-            $this->ticket,
172
-            $max,
173
-            $min,
174
-            $this->required_ticket_sold_out,
175
-            $ticket_price,
176
-            $ticket_bundle,
177
-            $ticket_status,
178
-            $status_class
179
-        );
180
-        if ($ticket_selector_row_html !== false) {
181
-            return $ticket_selector_row_html;
182
-        }
183
-        $ticket_selector_row_html = \EEH_HTML::tr(
184
-            '', '',
185
-            "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket)
186
-        );
187
-        /**
188
-         * Allow plugins to hook in and abort the generation and display of the contents of this
189
-         * row to do something else if they want.
190
-         * For an addon to abort things, all they have to do is register a filter with this hook, and
191
-         * return a value that is NOT false.  Whatever is returned gets echoed instead of the
192
-         * current row.
193
-         *
194
-         * @var string|bool
195
-         */
196
-        $new_row_cells_content = apply_filters(
197
-            'FHEE__ticket_selector_chart_template__do_ticket_inside_row',
198
-            false,
199
-            $this->ticket,
200
-            $max,
201
-            $min,
202
-            $this->required_ticket_sold_out,
203
-            $ticket_price,
204
-            $ticket_bundle,
205
-            $ticket_status,
206
-            $status_class
207
-        );
208
-        if ($new_row_cells_content !== false) {
209
-            return $ticket_selector_row_html
210
-                   . $new_row_cells_content
211
-                   . $this->ticketQtyAndIdHiddenInputs()
212
-                   . \EEH_HTML::trx();
213
-        }
214
-        $this->hidden_input_qty = $this->max_atndz > 1 ? true : false;
215
-
216
-        $ticket_selector_row_html .= $this->ticketNameTableCell();
217
-        $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle);
218
-        $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr');
219
-        $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining);
220
-        if (empty($this->ticket_status_display)) {
221
-            if ($this->max_atndz === 1) {
222
-                // only ONE attendee is allowed to register at a time
223
-                $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister();
224
-            } else if ($max > 0) {
225
-                $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max);
226
-            }
227
-        }
228
-        $ticket_selector_row_html .= $this->ticket_status_display;
229
-        $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs();
230
-        $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols);
231
-        $ticket_selector_row_html .= \EEH_HTML::tdx();
232
-        $ticket_selector_row_html .= \EEH_HTML::trx();
233
-
234
-
235
-        $this->row++;
236
-        return $ticket_selector_row_html;
237
-    }
238
-
239
-
240
-
241
-    /**
242
-     * setTicketMinAndMax
243
-     *
244
-     * @param int $remaining
245
-     * @return array
246
-     */
247
-    protected function setTicketMinAndMax($remaining)
248
-    {
249
-        // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller
250
-        $max = min($remaining, $this->max_atndz);
251
-        // but... we also want to restrict the number of tickets by the ticket max setting,
252
-        // however, the max still can't be higher than what was just set above
253
-        $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max;
254
-        // and we also want to restrict the minimum number of tickets by the ticket min setting
255
-        $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0;
256
-        // and if the ticket is required, then make sure that min qty is at least 1
257
-        $min = $this->ticket->required() ? max($min, 1) : $min;
258
-        return array($min, $max);
259
-    }
260
-
261
-
262
-    /**
263
-     * getTicketPriceDetails
264
-     *
265
-     * @return array
266
-     */
267
-    protected function getTicketPriceDetails()
268
-    {
269
-        $ticket_price = $this->tax_settings->prices_displayed_including_taxes
270
-            ? $this->ticket->get_ticket_total_with_taxes()
271
-            : $this->ticket->get_ticket_subtotal();
272
-        $ticket_bundle = false;
273
-        $ticket_min = $this->ticket->min();
274
-        // for ticket bundles, set min and max qty the same
275
-        if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) {
276
-            $ticket_price *= $ticket_min;
277
-            $ticket_bundle = true;
278
-        }
279
-        $ticket_price = apply_filters(
280
-            'FHEE__ticket_selector_chart_template__ticket_price',
281
-            $ticket_price,
282
-            $this->ticket
283
-        );
284
-        return array($ticket_price, $ticket_bundle);
285
-    }
286
-
287
-
288
-
289
-    /**
290
-     * getTicketStatusClasses
291
-     *
292
-     * @param int $remaining
293
-     * @return array
294
-     * @throws \EE_Error
295
-     */
296
-    protected function getTicketStatusClasses($remaining = 0)
297
-    {
298
-        // if a previous required ticket with the same sale start date is sold out,
299
-        // then mark this ticket as sold out as well.
300
-        // tickets that go on sale at a later date than the required ticket  will NOT be affected
301
-        $tkt_status = $this->required_ticket_sold_out !== false
302
-                      && $this->required_ticket_sold_out === $this->ticket->start_date()
303
-            ? \EE_Ticket::sold_out
304
-            : $this->ticket->ticket_status();
305
-        $tkt_status = $this->event_status === \EE_Datetime::sold_out
306
-            ? \EE_Ticket::sold_out
307
-            : $tkt_status;
308
-        // check ticket status
309
-        switch ($tkt_status) {
310
-            // sold_out
311
-            case \EE_Ticket::sold_out :
312
-                $ticket_status = 'ticket-sales-sold-out';
313
-                $status_class = 'ticket-sales-sold-out lt-grey-text';
314
-                break;
315
-            // expired
316
-            case \EE_Ticket::expired :
317
-                $ticket_status = 'ticket-sales-expired';
318
-                $status_class = 'ticket-sales-expired lt-grey-text';
319
-                break;
320
-            // archived
321
-            case \EE_Ticket::archived :
322
-                $ticket_status = 'archived-ticket';
323
-                $status_class = 'archived-ticket hidden';
324
-                break;
325
-            // pending
326
-            case \EE_Ticket::pending :
327
-                $ticket_status = 'ticket-pending';
328
-                $status_class = 'ticket-pending';
329
-                break;
330
-            // onsale
331
-            case \EE_Ticket::onsale :
332
-            default :
333
-                $ticket_status = 'ticket-on-sale';
334
-                $status_class = 'ticket-on-sale';
335
-                break;
336
-        }
337
-        $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status);
338
-        return array($tkt_status, $ticket_status, $status_class);
339
-    }
340
-
341
-
342
-
343
-    /**
344
-     * ticketNameTableCell
345
-     *
346
-     * @return string
347
-     * @throws \EE_Error
348
-     */
349
-    protected function ticketNameTableCell()
350
-    {
351
-        $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name');
352
-        $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name'));
353
-        $html .= $this->ticket_details->getShowHideLinks();
354
-        if ($this->ticket->required()) {
355
-            $html .= \EEH_HTML::p(
356
-                    apply_filters(
357
-                            'FHEE__ticket_selector_chart_template__ticket_required_message',
358
-                            esc_html__('This ticket is required and must be purchased.', 'event_espresso')
359
-                    ),
360
-                    '', 'ticket-required-pg'
361
-            );
362
-        }
363
-        $html .= \EEH_HTML::tdx();
364
-        return $html;
365
-    }
366
-
367
-
368
-
369
-    /**
370
-     * ticketPriceTableCell
371
-     *
372
-     * @param float $ticket_price
373
-     * @param bool  $ticket_bundle
374
-     * @return string
375
-     * @throws \EE_Error
376
-     */
377
-    protected function ticketPriceTableCell($ticket_price, $ticket_bundle)
378
-    {
379
-        $html = '';
380
-        if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
381
-            $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght');
382
-            $html .= \EEH_Template::format_currency($ticket_price);
383
-            $html .= $this->ticket->taxable()
384
-                ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' )
385
-                : '';
386
-            $html .= '&nbsp;';
387
-            $html .= \EEH_HTML::span(
388
-                $ticket_bundle
389
-                    ? apply_filters(
390
-                        'FHEE__ticket_selector_chart_template__per_ticket_bundle_text',
391
-                        __(' / bundle', 'event_espresso')
392
-                    )
393
-                    : apply_filters(
394
-                        'FHEE__ticket_selector_chart_template__per_ticket_text',
395
-                        __('', 'event_espresso')
396
-                    ),
397
-                '', 'smaller-text no-bold'
398
-            );
399
-            $html .= '&nbsp;';
400
-            $html .= \EEH_HTML::tdx();
401
-            $this->cols++;
402
-        }
403
-        return $html;
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * onlyOneAttendeeCanRegister
410
-     *
411
-     * @return string
412
-     */
413
-    protected function onlyOneAttendeeCanRegister()
414
-    {
415
-        // display submit button since we have tickets available
416
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
417
-        $this->hidden_input_qty = false;
418
-        $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
419
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
420
-        $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
421
-        $html .= $this->row === 1 ? ' checked="checked"' : '';
422
-        $html .= ' title=""/>';
423
-        return $html;
424
-    }
425
-
426
-
427
-
428
-    /**
429
-     * ticketQuantitySelector
430
-     *
431
-     * @param int $min
432
-     * @param int $max
433
-     * @return string
434
-     */
435
-    protected function ticketQuantitySelector($min = 0, $max = 0)
436
-    {
437
-        // display submit button since we have tickets available
438
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
439
-        $this->hidden_input_qty = false;
440
-        $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
441
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
442
-        $html .= ' class="ticket-selector-tbl-qty-slct">';
443
-        // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
444
-        if ($min !== 0 && ! $this->ticket->required()) {
445
-            $html .= '<option value="0">&nbsp;0&nbsp;</option>';
446
-        }
447
-        // offer ticket quantities from the min to the max
448
-        for ($i = $min; $i <= $max; $i++) {
449
-            $html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
450
-        }
451
-        $html .= '</select>';
452
-        return $html;
453
-    }
454
-
455
-
456
-
457
-    /**
458
-     * getHiddenInputs
459
-     *
460
-     * @return string
461
-     * @throws \EE_Error
462
-     */
463
-    protected function ticketQtyAndIdHiddenInputs()
464
-    {
465
-        $html = '';
466
-        // depending on group reg we need to change the format for qty
467
-        if ($this->hidden_input_qty) {
468
-            $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
469
-        }
470
-        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
471
-        $html .= ' value="' . $this->ticket->ID() . '"/>';
472
-        return $html;
473
-    }
19
+	/**
20
+	 * @var TicketDetails $ticket_details
21
+	 */
22
+	protected $ticket_details;
23
+
24
+	/**
25
+	 * @var \EE_Ticket_Selector_Config $template_settings
26
+	 */
27
+	protected $template_settings;
28
+
29
+	/**
30
+	 * @var \EE_Tax_Config $tax_settings
31
+	 */
32
+	protected $tax_settings;
33
+
34
+	/**
35
+	 * @var boolean $required_ticket_sold_out
36
+	 */
37
+	protected $required_ticket_sold_out;
38
+
39
+	/**
40
+	 * @var boolean $prices_displayed_including_taxes
41
+	 */
42
+	protected $prices_displayed_including_taxes;
43
+
44
+	/**
45
+	 * @var string $event_status
46
+	 */
47
+	protected $event_status;
48
+
49
+	/**
50
+	 * @var int $row
51
+	 */
52
+	protected $row;
53
+
54
+	/**
55
+	 * @var int $cols
56
+	 */
57
+	protected $cols;
58
+
59
+	/**
60
+	 * @var boolean $hidden_input_qty
61
+	 */
62
+	protected $hidden_input_qty;
63
+
64
+	/**
65
+	 * @var string $ticket_datetime_classes
66
+	 */
67
+	protected $ticket_datetime_classes;
68
+
69
+
70
+
71
+	/**
72
+	 * TicketDetails constructor.
73
+	 *
74
+	 * @param \EE_Ticket $ticket
75
+	 * @param TicketDetails              $ticket_details
76
+	 * @param \EE_Ticket_Selector_Config $template_settings
77
+	 * @param \EE_Tax_Config             $tax_settings
78
+	 * @param int                        $max_atndz
79
+	 * @param int                        $row
80
+	 * @param int                        $cols
81
+	 * @param boolean                    $required_ticket_sold_out
82
+	 * @param string                     $event_status
83
+	 * @param string                     $date_format
84
+	 * @param string                     $ticket_datetime_classes
85
+	 */
86
+	public function __construct(
87
+		\EE_Ticket $ticket,
88
+		TicketDetails $ticket_details,
89
+		\EE_Ticket_Selector_Config $template_settings,
90
+		\EE_Tax_Config $tax_settings,
91
+		$max_atndz,
92
+		$row,
93
+		$cols,
94
+		$required_ticket_sold_out,
95
+		$event_status,
96
+		$date_format,
97
+		$ticket_datetime_classes
98
+	) {
99
+		$this->ticket = $ticket;
100
+		$this->ticket_details = $ticket_details;
101
+		$this->template_settings = $template_settings;
102
+		$this->tax_settings = $tax_settings;
103
+		$this->max_atndz = $max_atndz;
104
+		$this->row = $row;
105
+		$this->cols = $cols;
106
+		$this->required_ticket_sold_out = $required_ticket_sold_out;
107
+		$this->event_status = $event_status;
108
+		$this->date_format = $date_format;
109
+		$this->ticket_datetime_classes = $ticket_datetime_classes;
110
+		parent::__construct($ticket, $max_atndz, $date_format);
111
+	}
112
+
113
+
114
+
115
+	/**
116
+	 * other ticket rows will need to know if a required ticket is sold out,
117
+	 * so that they are not offered for sale
118
+	 *
119
+	 * @return boolean
120
+	 */
121
+	public function getRequiredTicketSoldOut()
122
+	{
123
+		return $this->required_ticket_sold_out;
124
+	}
125
+
126
+
127
+
128
+	/**
129
+	 * @return int
130
+	 */
131
+	public function getCols()
132
+	{
133
+		return $this->cols;
134
+	}
135
+
136
+
137
+
138
+	/**
139
+	 * getHtml
140
+	 *
141
+	 * @return string
142
+	 * @throws \EE_Error
143
+	 */
144
+	public function getHtml()
145
+	{
146
+		$min = 0;
147
+		$max = $this->ticket->max();
148
+		$remaining = $this->ticket->remaining();
149
+		if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) {
150
+			list($min, $max) = $this->setTicketMinAndMax($remaining);
151
+		} else {
152
+			// set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
153
+			$this->required_ticket_sold_out = $this->ticket->required() && ! $remaining
154
+				? $this->ticket->start_date()
155
+				: $this->required_ticket_sold_out;
156
+		}
157
+		list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails();
158
+		list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining);
159
+		/**
160
+		 * Allow plugins to hook in and abort the generation and display of this row to do
161
+		 * something else if they want.
162
+		 * For an addon to abort things, all they have to do is register a filter with this hook, and
163
+		 * return a value that is NOT false.  Whatever is returned gets echoed instead of the
164
+		 * current row.
165
+		 *
166
+		 * @var string|bool
167
+		 */
168
+		$ticket_selector_row_html = apply_filters(
169
+			'FHEE__ticket_selector_chart_template__do_ticket_entire_row',
170
+			false,
171
+			$this->ticket,
172
+			$max,
173
+			$min,
174
+			$this->required_ticket_sold_out,
175
+			$ticket_price,
176
+			$ticket_bundle,
177
+			$ticket_status,
178
+			$status_class
179
+		);
180
+		if ($ticket_selector_row_html !== false) {
181
+			return $ticket_selector_row_html;
182
+		}
183
+		$ticket_selector_row_html = \EEH_HTML::tr(
184
+			'', '',
185
+			"tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket)
186
+		);
187
+		/**
188
+		 * Allow plugins to hook in and abort the generation and display of the contents of this
189
+		 * row to do something else if they want.
190
+		 * For an addon to abort things, all they have to do is register a filter with this hook, and
191
+		 * return a value that is NOT false.  Whatever is returned gets echoed instead of the
192
+		 * current row.
193
+		 *
194
+		 * @var string|bool
195
+		 */
196
+		$new_row_cells_content = apply_filters(
197
+			'FHEE__ticket_selector_chart_template__do_ticket_inside_row',
198
+			false,
199
+			$this->ticket,
200
+			$max,
201
+			$min,
202
+			$this->required_ticket_sold_out,
203
+			$ticket_price,
204
+			$ticket_bundle,
205
+			$ticket_status,
206
+			$status_class
207
+		);
208
+		if ($new_row_cells_content !== false) {
209
+			return $ticket_selector_row_html
210
+				   . $new_row_cells_content
211
+				   . $this->ticketQtyAndIdHiddenInputs()
212
+				   . \EEH_HTML::trx();
213
+		}
214
+		$this->hidden_input_qty = $this->max_atndz > 1 ? true : false;
215
+
216
+		$ticket_selector_row_html .= $this->ticketNameTableCell();
217
+		$ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle);
218
+		$ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr');
219
+		$this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining);
220
+		if (empty($this->ticket_status_display)) {
221
+			if ($this->max_atndz === 1) {
222
+				// only ONE attendee is allowed to register at a time
223
+				$ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister();
224
+			} else if ($max > 0) {
225
+				$ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max);
226
+			}
227
+		}
228
+		$ticket_selector_row_html .= $this->ticket_status_display;
229
+		$ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs();
230
+		$ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols);
231
+		$ticket_selector_row_html .= \EEH_HTML::tdx();
232
+		$ticket_selector_row_html .= \EEH_HTML::trx();
233
+
234
+
235
+		$this->row++;
236
+		return $ticket_selector_row_html;
237
+	}
238
+
239
+
240
+
241
+	/**
242
+	 * setTicketMinAndMax
243
+	 *
244
+	 * @param int $remaining
245
+	 * @return array
246
+	 */
247
+	protected function setTicketMinAndMax($remaining)
248
+	{
249
+		// offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller
250
+		$max = min($remaining, $this->max_atndz);
251
+		// but... we also want to restrict the number of tickets by the ticket max setting,
252
+		// however, the max still can't be higher than what was just set above
253
+		$max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max;
254
+		// and we also want to restrict the minimum number of tickets by the ticket min setting
255
+		$min = $this->ticket->min() > 0 ? $this->ticket->min() : 0;
256
+		// and if the ticket is required, then make sure that min qty is at least 1
257
+		$min = $this->ticket->required() ? max($min, 1) : $min;
258
+		return array($min, $max);
259
+	}
260
+
261
+
262
+	/**
263
+	 * getTicketPriceDetails
264
+	 *
265
+	 * @return array
266
+	 */
267
+	protected function getTicketPriceDetails()
268
+	{
269
+		$ticket_price = $this->tax_settings->prices_displayed_including_taxes
270
+			? $this->ticket->get_ticket_total_with_taxes()
271
+			: $this->ticket->get_ticket_subtotal();
272
+		$ticket_bundle = false;
273
+		$ticket_min = $this->ticket->min();
274
+		// for ticket bundles, set min and max qty the same
275
+		if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) {
276
+			$ticket_price *= $ticket_min;
277
+			$ticket_bundle = true;
278
+		}
279
+		$ticket_price = apply_filters(
280
+			'FHEE__ticket_selector_chart_template__ticket_price',
281
+			$ticket_price,
282
+			$this->ticket
283
+		);
284
+		return array($ticket_price, $ticket_bundle);
285
+	}
286
+
287
+
288
+
289
+	/**
290
+	 * getTicketStatusClasses
291
+	 *
292
+	 * @param int $remaining
293
+	 * @return array
294
+	 * @throws \EE_Error
295
+	 */
296
+	protected function getTicketStatusClasses($remaining = 0)
297
+	{
298
+		// if a previous required ticket with the same sale start date is sold out,
299
+		// then mark this ticket as sold out as well.
300
+		// tickets that go on sale at a later date than the required ticket  will NOT be affected
301
+		$tkt_status = $this->required_ticket_sold_out !== false
302
+					  && $this->required_ticket_sold_out === $this->ticket->start_date()
303
+			? \EE_Ticket::sold_out
304
+			: $this->ticket->ticket_status();
305
+		$tkt_status = $this->event_status === \EE_Datetime::sold_out
306
+			? \EE_Ticket::sold_out
307
+			: $tkt_status;
308
+		// check ticket status
309
+		switch ($tkt_status) {
310
+			// sold_out
311
+			case \EE_Ticket::sold_out :
312
+				$ticket_status = 'ticket-sales-sold-out';
313
+				$status_class = 'ticket-sales-sold-out lt-grey-text';
314
+				break;
315
+			// expired
316
+			case \EE_Ticket::expired :
317
+				$ticket_status = 'ticket-sales-expired';
318
+				$status_class = 'ticket-sales-expired lt-grey-text';
319
+				break;
320
+			// archived
321
+			case \EE_Ticket::archived :
322
+				$ticket_status = 'archived-ticket';
323
+				$status_class = 'archived-ticket hidden';
324
+				break;
325
+			// pending
326
+			case \EE_Ticket::pending :
327
+				$ticket_status = 'ticket-pending';
328
+				$status_class = 'ticket-pending';
329
+				break;
330
+			// onsale
331
+			case \EE_Ticket::onsale :
332
+			default :
333
+				$ticket_status = 'ticket-on-sale';
334
+				$status_class = 'ticket-on-sale';
335
+				break;
336
+		}
337
+		$ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status);
338
+		return array($tkt_status, $ticket_status, $status_class);
339
+	}
340
+
341
+
342
+
343
+	/**
344
+	 * ticketNameTableCell
345
+	 *
346
+	 * @return string
347
+	 * @throws \EE_Error
348
+	 */
349
+	protected function ticketNameTableCell()
350
+	{
351
+		$html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name');
352
+		$html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name'));
353
+		$html .= $this->ticket_details->getShowHideLinks();
354
+		if ($this->ticket->required()) {
355
+			$html .= \EEH_HTML::p(
356
+					apply_filters(
357
+							'FHEE__ticket_selector_chart_template__ticket_required_message',
358
+							esc_html__('This ticket is required and must be purchased.', 'event_espresso')
359
+					),
360
+					'', 'ticket-required-pg'
361
+			);
362
+		}
363
+		$html .= \EEH_HTML::tdx();
364
+		return $html;
365
+	}
366
+
367
+
368
+
369
+	/**
370
+	 * ticketPriceTableCell
371
+	 *
372
+	 * @param float $ticket_price
373
+	 * @param bool  $ticket_bundle
374
+	 * @return string
375
+	 * @throws \EE_Error
376
+	 */
377
+	protected function ticketPriceTableCell($ticket_price, $ticket_bundle)
378
+	{
379
+		$html = '';
380
+		if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
381
+			$html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght');
382
+			$html .= \EEH_Template::format_currency($ticket_price);
383
+			$html .= $this->ticket->taxable()
384
+				? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' )
385
+				: '';
386
+			$html .= '&nbsp;';
387
+			$html .= \EEH_HTML::span(
388
+				$ticket_bundle
389
+					? apply_filters(
390
+						'FHEE__ticket_selector_chart_template__per_ticket_bundle_text',
391
+						__(' / bundle', 'event_espresso')
392
+					)
393
+					: apply_filters(
394
+						'FHEE__ticket_selector_chart_template__per_ticket_text',
395
+						__('', 'event_espresso')
396
+					),
397
+				'', 'smaller-text no-bold'
398
+			);
399
+			$html .= '&nbsp;';
400
+			$html .= \EEH_HTML::tdx();
401
+			$this->cols++;
402
+		}
403
+		return $html;
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * onlyOneAttendeeCanRegister
410
+	 *
411
+	 * @return string
412
+	 */
413
+	protected function onlyOneAttendeeCanRegister()
414
+	{
415
+		// display submit button since we have tickets available
416
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
417
+		$this->hidden_input_qty = false;
418
+		$html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
419
+		$html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
420
+		$html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
421
+		$html .= $this->row === 1 ? ' checked="checked"' : '';
422
+		$html .= ' title=""/>';
423
+		return $html;
424
+	}
425
+
426
+
427
+
428
+	/**
429
+	 * ticketQuantitySelector
430
+	 *
431
+	 * @param int $min
432
+	 * @param int $max
433
+	 * @return string
434
+	 */
435
+	protected function ticketQuantitySelector($min = 0, $max = 0)
436
+	{
437
+		// display submit button since we have tickets available
438
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
439
+		$this->hidden_input_qty = false;
440
+		$html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
441
+		$html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
442
+		$html .= ' class="ticket-selector-tbl-qty-slct">';
443
+		// this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
444
+		if ($min !== 0 && ! $this->ticket->required()) {
445
+			$html .= '<option value="0">&nbsp;0&nbsp;</option>';
446
+		}
447
+		// offer ticket quantities from the min to the max
448
+		for ($i = $min; $i <= $max; $i++) {
449
+			$html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
450
+		}
451
+		$html .= '</select>';
452
+		return $html;
453
+	}
454
+
455
+
456
+
457
+	/**
458
+	 * getHiddenInputs
459
+	 *
460
+	 * @return string
461
+	 * @throws \EE_Error
462
+	 */
463
+	protected function ticketQtyAndIdHiddenInputs()
464
+	{
465
+		$html = '';
466
+		// depending on group reg we need to change the format for qty
467
+		if ($this->hidden_input_qty) {
468
+			$html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
469
+		}
470
+		$html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
471
+		$html .= ' value="' . $this->ticket->ID() . '"/>';
472
+		return $html;
473
+	}
474 474
 
475 475
 }
476 476
 // End of file TicketSelectorRowStandard.php
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         }
183 183
         $ticket_selector_row_html = \EEH_HTML::tr(
184 184
             '', '',
185
-            "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket)
185
+            "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} ".espresso_get_object_css_class($this->ticket)
186 186
         );
187 187
         /**
188 188
          * Allow plugins to hook in and abort the generation and display of the contents of this
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght');
382 382
             $html .= \EEH_Template::format_currency($ticket_price);
383 383
             $html .= $this->ticket->taxable()
384
-                ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' )
384
+                ? \EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text')
385 385
                 : '';
386 386
             $html .= '&nbsp;';
387 387
             $html .= \EEH_HTML::span(
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
         // display submit button since we have tickets available
416 416
         add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
417 417
         $this->hidden_input_qty = false;
418
-        $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
419
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
420
-        $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
418
+        $html = '<input type="radio" name="tkt-slctr-qty-'.$this->EVT_ID.'"';
419
+        $html .= ' id="ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row.'"';
420
+        $html .= ' class="ticket-selector-tbl-qty-slct" value="'.$this->row.'-1"';
421 421
         $html .= $this->row === 1 ? ' checked="checked"' : '';
422 422
         $html .= ' title=""/>';
423 423
         return $html;
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
         // display submit button since we have tickets available
438 438
         add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
439 439
         $this->hidden_input_qty = false;
440
-        $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
441
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
440
+        $html = '<select name="tkt-slctr-qty-'.$this->EVT_ID.'[]"';
441
+        $html .= ' id="ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row.'"';
442 442
         $html .= ' class="ticket-selector-tbl-qty-slct">';
443 443
         // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
444 444
         if ($min !== 0 && ! $this->ticket->required()) {
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
         }
447 447
         // offer ticket quantities from the min to the max
448 448
         for ($i = $min; $i <= $max; $i++) {
449
-            $html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
449
+            $html .= '<option value="'.$i.'">&nbsp;'.$i.'&nbsp;</option>';
450 450
         }
451 451
         $html .= '</select>';
452 452
         return $html;
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
         $html = '';
466 466
         // depending on group reg we need to change the format for qty
467 467
         if ($this->hidden_input_qty) {
468
-            $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
468
+            $html .= '<input type="hidden" name="tkt-slctr-qty-'.$this->EVT_ID.'[]" value="0"/>';
469 469
         }
470
-        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
471
-        $html .= ' value="' . $this->ticket->ID() . '"/>';
470
+        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-'.$this->EVT_ID.'[]"';
471
+        $html .= ' value="'.$this->ticket->ID().'"/>';
472 472
         return $html;
473 473
     }
474 474
 
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.31.rc.003');
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.31.rc.003');
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
 }
Please login to merge, or discard this patch.
modules/ical/EED_Ical.module.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @return EED_Ical|EED_Module
20 20
 	 */
21 21
 	public static function instance() {
22
-		return parent::get_instance( __CLASS__ );
22
+		return parent::get_instance(__CLASS__);
23 23
 	}
24 24
 
25 25
 
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 		// create download buttons
35 35
 		add_filter(
36 36
 		    'FHEE__espresso_list_of_event_dates__datetime_html',
37
-            array( 'EED_Ical', 'generate_add_to_iCal_button' ),
37
+            array('EED_Ical', 'generate_add_to_iCal_button'),
38 38
             10,
39 39
             2
40 40
         );
41 41
 		 // process ics download request
42
-		EE_Config::register_route( 'download_ics_file', 'EED_Ical', 'download_ics_file' );
42
+		EE_Config::register_route('download_ics_file', 'EED_Ical', 'download_ics_file');
43 43
 	}
44 44
 
45 45
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param    WP $WP
63 63
 	 * @return    void
64 64
 	 */
65
-	public function run( $WP ) {}
65
+	public function run($WP) {}
66 66
 
67 67
 
68 68
 
@@ -75,35 +75,35 @@  discard block
 block discarded – undo
75 75
      * @return    string
76 76
      * @throws \EE_Error
77 77
      */
78
-	public static function generate_add_to_iCal_button( $html, $datetime ) {
78
+	public static function generate_add_to_iCal_button($html, $datetime) {
79 79
 		// first verify a proper datetime object has been received
80
-		if ( $datetime instanceof EE_Datetime ) {
80
+		if ($datetime instanceof EE_Datetime) {
81 81
 			// set whether a link or submit button is shown
82
-			$iCal_type = apply_filters( 'FHEE__EED_Ical__generate_add_to_iCal_button__iCal_type', 'submit' );
82
+			$iCal_type = apply_filters('FHEE__EED_Ical__generate_add_to_iCal_button__iCal_type', 'submit');
83 83
 			// generate a link to the route we registered in set_hooks()
84
-			$URL = add_query_arg( array( 'ee' => 'download_ics_file', 'ics_id' => $datetime->ID() ), site_url() );
84
+			$URL = add_query_arg(array('ee' => 'download_ics_file', 'ics_id' => $datetime->ID()), site_url());
85 85
 			// what type ?
86
-			switch ( $iCal_type ) {
86
+			switch ($iCal_type) {
87 87
 				// submit buttons appear as buttons and are very compatible with a theme's style
88 88
 				case 'submit' :
89
-					$html .= '<form id="download-iCal-frm-' . $datetime->ID();
90
-					$html .= '" class="download-iCal-frm" action="' . $URL . '" method="post" >';
89
+					$html .= '<form id="download-iCal-frm-'.$datetime->ID();
90
+					$html .= '" class="download-iCal-frm" action="'.$URL.'" method="post" >';
91 91
 					$html .= '<input type="submit" class="ee-ical-sbmt" value="&#xf145;" title="';
92
-					$html .= __( 'Add to iCal Calendar', 'event_espresso' ) . '"/>';
92
+					$html .= __('Add to iCal Calendar', 'event_espresso').'"/>';
93 93
 					$html .= '</form>';
94 94
 					break;
95 95
 				// buttons are just links that have been styled to appear as buttons,
96 96
                 // but may not be blend with a theme as well as submit buttons
97 97
 				case 'button' :
98
-					$html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="' . $URL;
99
-					$html .= '" title="' . __( 'Add to iCal Calendar', 'event_espresso' ) . '">';
98
+					$html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="'.$URL;
99
+					$html .= '" title="'.__('Add to iCal Calendar', 'event_espresso').'">';
100 100
 					$html .= ' <span class="dashicons dashicons-calendar"></span>';
101 101
 					$html .= '</a>';
102 102
 					break;
103 103
 				// links are just links that use the calendar dashicon
104 104
 				case 'icon' :
105
-					$html .= '<a class="ee-ical-lnk" href="' . $URL . '" title="';
106
-					$html .= __( 'Add to iCal Calendar', 'event_espresso' ) . '">';
105
+					$html .= '<a class="ee-ical-lnk" href="'.$URL.'" title="';
106
+					$html .= __('Add to iCal Calendar', 'event_espresso').'">';
107 107
 					$html .= ' <span class="dashicons dashicons-calendar"></span>';
108 108
 					$html .= '</a>';
109 109
 					break;
@@ -122,29 +122,29 @@  discard block
 block discarded – undo
122 122
      * @throws \EE_Error
123 123
      */
124 124
 	public static function download_ics_file() {
125
-		if ( EE_Registry::instance()->REQ->is_set( 'ics_id' )) {
126
-			$DTT_ID = absint( EE_Registry::instance()->REQ->get( 'ics_id' ));
127
-			$datetime = EE_Registry::instance()->load_model( 'Datetime' )->get_one_by_ID( $DTT_ID );
128
-			if ( $datetime instanceof EE_Datetime ) {
125
+		if (EE_Registry::instance()->REQ->is_set('ics_id')) {
126
+			$DTT_ID = absint(EE_Registry::instance()->REQ->get('ics_id'));
127
+			$datetime = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($DTT_ID);
128
+			if ($datetime instanceof EE_Datetime) {
129 129
 				// get related event, venues, and event categories
130 130
 				$event = $datetime->event();
131 131
 				// get related category Term object and it's name
132 132
 				$category = $event->first_event_category();
133
-				if ( $category instanceof EE_Term ) {
133
+				if ($category instanceof EE_Term) {
134 134
 					$category = $category->name();
135 135
 				}
136 136
 				$location = '';
137 137
 				// get first related venue and convert to CSV string
138
-				$venue = $event->venues(array( 'limit'=>1 ));
139
-				if ( is_array( $venue ) && ! empty( $venue )) {
140
-					$venue = array_shift( $venue );
141
-					if ( $venue instanceof EE_Venue ) {
142
-						$location = espresso_venue_raw_address( 'inline', $venue->ID(), FALSE );
138
+				$venue = $event->venues(array('limit'=>1));
139
+				if (is_array($venue) && ! empty($venue)) {
140
+					$venue = array_shift($venue);
141
+					if ($venue instanceof EE_Venue) {
142
+						$location = espresso_venue_raw_address('inline', $venue->ID(), FALSE);
143 143
 					}
144 144
 				}
145 145
 
146 146
 				//Generate filename
147
-				$filename = $event->slug() . '-' . $datetime->start_date( 'Y-m-d' ) . '.ics';
147
+				$filename = $event->slug().'-'.$datetime->start_date('Y-m-d').'.ics';
148 148
 
149 149
 				//Check the datetime status has not been cancelled and set the ics value accordingly
150 150
 				$status = $datetime->get_active_status();
@@ -153,62 +153,62 @@  discard block
 block discarded – undo
153 153
 				// Create array of ics details, escape strings, convert timestamps to ics format, etc
154 154
 				$ics_data = array(
155 155
 					'ORGANIZER_NAME' => EE_Registry::instance()->CFG->organization->name,
156
-					'UID' => md5( $event->name() . $event->ID() . $datetime->ID() ),
156
+					'UID' => md5($event->name().$event->ID().$datetime->ID()),
157 157
 					'ORGANIZER' => EE_Registry::instance()->CFG->organization->email,
158
-					'DTSTAMP' => date( EED_Ical::iCal_datetime_format ),
158
+					'DTSTAMP' => date(EED_Ical::iCal_datetime_format),
159 159
 					'LOCATION' => $location,
160 160
 					'SUMMARY' => $event->name(),
161
-					'DESCRIPTION' => wp_strip_all_tags( $event->description() ),
161
+					'DESCRIPTION' => wp_strip_all_tags($event->description()),
162 162
 					'STATUS' => $status,
163 163
 					'CATEGORIES' => $category,
164
-					'URL;VALUE=URI' => get_permalink( $event->ID() ),
165
-					'DTSTART' => date( EED_Ical::iCal_datetime_format, $datetime->start() ),
166
-					'DTEND' => date( EED_Ical::iCal_datetime_format, $datetime->end() ),
164
+					'URL;VALUE=URI' => get_permalink($event->ID()),
165
+					'DTSTART' => date(EED_Ical::iCal_datetime_format, $datetime->start()),
166
+					'DTEND' => date(EED_Ical::iCal_datetime_format, $datetime->end()),
167 167
 				);
168 168
 
169 169
 				//Filter the values used within the ics output.
170 170
 				//NOTE - all values within ics_data will be escaped automatically.
171
-				$ics_data = apply_filters( 'FHEE__EED_Ical__download_ics_file_ics_data', $ics_data, $datetime );
171
+				$ics_data = apply_filters('FHEE__EED_Ical__download_ics_file_ics_data', $ics_data, $datetime);
172 172
 
173 173
 				//Escape all ics data
174
-				foreach( $ics_data as $key => $value ) {
174
+				foreach ($ics_data as $key => $value) {
175 175
 					//Description is escaped differently from all all values
176
-					if( $key === 'DESCRIPTION' ) {
177
-						$ics_data[$key] = EED_Ical::_escape_ICal_description( wp_strip_all_tags( $value ) );
176
+					if ($key === 'DESCRIPTION') {
177
+						$ics_data[$key] = EED_Ical::_escape_ICal_description(wp_strip_all_tags($value));
178 178
 					} else {
179
-						$ics_data[$key] = EED_Ical::_escape_ICal_data( $value );
179
+						$ics_data[$key] = EED_Ical::_escape_ICal_data($value);
180 180
 					}
181 181
 				}
182 182
 
183 183
 				//Pull the organizer name from ics_data and remove it from the array.
184
-				$organizer_name = isset( $ics_data['ORGANIZER_NAME'] ) ? $ics_data['ORGANIZER_NAME'] : '';
185
-				unset( $ics_data['ORGANIZER_NAME'] );
184
+				$organizer_name = isset($ics_data['ORGANIZER_NAME']) ? $ics_data['ORGANIZER_NAME'] : '';
185
+				unset($ics_data['ORGANIZER_NAME']);
186 186
 
187 187
 				// set headers
188
-				header( 'Content-type: text/calendar; charset=utf-8' );
189
-				header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
190
-				header( 'Cache-Control: private, max-age=0, must-revalidate' );
191
-				header( 'Pragma: public' );
192
-				header( 'Content-Type: application/octet-stream' );
193
-				header( 'Content-Type: application/force-download' );
194
-				header( 'Cache-Control: no-cache, must-revalidate' );
195
-				header( 'Content-Transfer-Encoding: binary' );
196
-				header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); // past date
197
-				ini_set( 'zlib.output_compression', '0' );
188
+				header('Content-type: text/calendar; charset=utf-8');
189
+				header('Content-Disposition: attachment; filename="'.$filename.'"');
190
+				header('Cache-Control: private, max-age=0, must-revalidate');
191
+				header('Pragma: public');
192
+				header('Content-Type: application/octet-stream');
193
+				header('Content-Type: application/force-download');
194
+				header('Cache-Control: no-cache, must-revalidate');
195
+				header('Content-Transfer-Encoding: binary');
196
+				header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // past date
197
+				ini_set('zlib.output_compression', '0');
198 198
 				// echo the output
199
-				echo "BEGIN:VCALENDAR" . PHP_EOL;
200
-				echo "VERSION:2.0" . PHP_EOL;
201
-				echo "PRODID:-//{$organizer_name}//NONSGML PDA Calendar Version 1.0//EN" . PHP_EOL;
202
-				echo "CALSCALE:GREGORIAN" . PHP_EOL;
203
-				echo "BEGIN:VEVENT" . PHP_EOL;
199
+				echo "BEGIN:VCALENDAR".PHP_EOL;
200
+				echo "VERSION:2.0".PHP_EOL;
201
+				echo "PRODID:-//{$organizer_name}//NONSGML PDA Calendar Version 1.0//EN".PHP_EOL;
202
+				echo "CALSCALE:GREGORIAN".PHP_EOL;
203
+				echo "BEGIN:VEVENT".PHP_EOL;
204 204
 				
205 205
 				//Output all remaining values from ics_data.
206
-				foreach( $ics_data as $key => $value ) {
207
-					echo $key . ':' . $value . PHP_EOL;
206
+				foreach ($ics_data as $key => $value) {
207
+					echo $key.':'.$value.PHP_EOL;
208 208
 				}
209 209
 
210
-				echo "END:VEVENT" . PHP_EOL;
211
-				echo "END:VCALENDAR" . PHP_EOL;
210
+				echo "END:VEVENT".PHP_EOL;
211
+				echo "END:VCALENDAR".PHP_EOL;
212 212
 			}
213 213
 		}
214 214
 		die();
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 	 *  	@param	string $string
224 224
 	 *  	@return	string
225 225
 	 */
226
-	private static function _escape_ICal_data( $string = '' ) {
227
-		return preg_replace( '/([\,;])/', '\\\$1', $string );
226
+	private static function _escape_ICal_data($string = '') {
227
+		return preg_replace('/([\,;])/', '\\\$1', $string);
228 228
 	}
229 229
 
230 230
 	/**
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
 	 *  	@param	string $description
235 235
 	 *  	@return	string
236 236
 	 */
237
-	private static function _escape_ICal_description( $description = '' ) {
237
+	private static function _escape_ICal_description($description = '') {
238 238
 
239 239
 			//Escape special chars within the description
240
-			$description = EED_Ical::_escape_ICal_data( $description );
240
+			$description = EED_Ical::_escape_ICal_data($description);
241 241
 
242 242
 		    //Remove line breaks and output in iCal format
243
-		    $description = str_replace( array( "\r\n", "\n"), '\n', $description );
243
+		    $description = str_replace(array("\r\n", "\n"), '\n', $description);
244 244
 
245 245
 		return $description;
246 246
 	}
Please login to merge, or discard this patch.