Completed
Branch BUG-8957-add-countries (d46858)
by
unknown
31:05 queued 15:34
created
core/EE_Data_Migration_Manager.core.php 1 patch
Spacing   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * to indicate it successfully migrate some data, and has nothing left to do; or EE_Data_Migration_Manager::status_fatal_error to indicate
25 25
  * an error occurred which means the ajax script should probably stop executing.
26 26
  */
27
-class EE_Data_Migration_Manager{
27
+class EE_Data_Migration_Manager {
28 28
 
29 29
 	/**
30 30
 	 *
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * of this EE installation. Keys should be the name of the version the script upgraded to
82 82
 	 * @var EE_Data_Migration_Script_Base[]
83 83
 	 */
84
-	private $_data_migrations_ran =null;
84
+	private $_data_migrations_ran = null;
85 85
 	/**
86 86
 	 * The last ran script. It's nice to store this somewhere accessible, as its easiest
87 87
 	 * to know which was the last run by which is the newest wp option; but in most of the code
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public static function instance() {
143 143
 		// check if class object is instantiated
144
-		if ( ! self::$_instance instanceof EE_Data_Migration_Manager ) {
144
+		if ( ! self::$_instance instanceof EE_Data_Migration_Manager) {
145 145
 			self::$_instance = new self();
146 146
 		}
147 147
 		return self::$_instance;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * all new usages of the singleton should be made with Classname::instance()) and returns it
152 152
 	 * @return EE_Data_Migration_Manager
153 153
 	 */
154
-	public static function reset(){
154
+	public static function reset() {
155 155
 		self::$_instance = NULL;
156 156
 		return self::instance();
157 157
 	}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	/**
162 162
 	 * constructor
163 163
 	 */
164
-	private function __construct(){
164
+	private function __construct() {
165 165
 		$this->stati_that_indicate_to_continue_migrations = array(
166 166
 			self::status_continue,
167 167
 			self::status_completed
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
 		);
181 181
 		//make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class
182 182
 		//to be defined, because right now it doesn't get autoloaded on its own
183
-		EE_Registry::instance()->load_core( 'Data_Migration_Class_Base', array(), TRUE );
184
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Base', array(), TRUE );
185
-		EE_Registry::instance()->load_core( 'DMS_Unknown_1_0_0', array(), TRUE );
186
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage', array(), TRUE );
187
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage_Table', array(), TRUE );
188
-		$this->_table_manager = EE_Registry::instance()->create( 'TableManager', array(), true );
189
-		$this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true );
183
+		EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), TRUE);
184
+		EE_Registry::instance()->load_core('Data_Migration_Script_Base', array(), TRUE);
185
+		EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), TRUE);
186
+		EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), TRUE);
187
+		EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), TRUE);
188
+		$this->_table_manager = EE_Registry::instance()->create('TableManager', array(), true);
189
+		$this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
190 190
 	}
191 191
 
192 192
 
@@ -199,21 +199,21 @@  discard block
 block discarded – undo
199 199
 	 * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set)
200 200
 	 * @return array where the first item is the plugin slug (eg 'Core','Calendar',etc) and the 2nd is the version of that plugin (eg '4.1.0')
201 201
 	 */
202
-	private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name){
202
+	private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name) {
203 203
 		$plugin_slug_and_version_string = str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_name);
204 204
 		//check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style)
205
-		$parts = explode(".",$plugin_slug_and_version_string);
205
+		$parts = explode(".", $plugin_slug_and_version_string);
206 206
 
207
-		if(count($parts) == 4){
207
+		if (count($parts) == 4) {
208 208
 			//it's 4.2-style.eg Core.4.1.0
209
-			$plugin_slug = $parts[0];//eg Core
209
+			$plugin_slug = $parts[0]; //eg Core
210 210
 			$version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0
211
-		}else{
211
+		} else {
212 212
 			//it's 4.1-style: eg 4.1.0
213 213
 			$plugin_slug = 'Core';
214
-			$version_string = $plugin_slug_and_version_string;//eg 4.1.0
214
+			$version_string = $plugin_slug_and_version_string; //eg 4.1.0
215 215
 		}
216
-		return array($plugin_slug,$version_string);
216
+		return array($plugin_slug, $version_string);
217 217
 	}
218 218
 
219 219
 	/**
@@ -224,21 +224,21 @@  discard block
 block discarded – undo
224 224
 	 * @return EE_Data_Migration_Script_Base
225 225
 	 * @throws EE_Error
226 226
 	 */
227
-	private function _get_dms_class_from_wp_option($dms_option_name,$dms_option_value){
227
+	private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value) {
228 228
 		$data_migration_data = maybe_unserialize($dms_option_value);
229
-		if(isset($data_migration_data['class']) && class_exists($data_migration_data['class'])){
229
+		if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) {
230 230
 			$class = new $data_migration_data['class'];
231
-			if($class instanceof EE_Data_Migration_Script_Base){
231
+			if ($class instanceof EE_Data_Migration_Script_Base) {
232 232
 				$class->instantiate_from_array_of_properties($data_migration_data);
233 233
 				return $class;
234
-			}else{
234
+			} else {
235 235
 				//huh, so its an object but not a data migration script?? that shouldn't happen
236 236
 				//just leave it as an array (which will probably just get ignored)
237
-				throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class']));
237
+				throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'), $data_migration_data['class']));
238 238
 			}
239
-		}else{
239
+		} else {
240 240
 			//so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists
241
-			throw new EE_Error(sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name));
241
+			throw new EE_Error(sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name));
242 242
 		}
243 243
 	}
244 244
 	/**
@@ -246,34 +246,34 @@  discard block
 block discarded – undo
246 246
 	 * the last ran which hasn't finished yet
247 247
 	 * @return array where each element should be an array of EE_Data_Migration_Script_Base (but also has a few legacy arrays in there - which should probably be ignored)
248 248
 	 */
249
-	public function get_data_migrations_ran(){
250
-		if( ! $this->_data_migrations_ran ){
249
+	public function get_data_migrations_ran() {
250
+		if ( ! $this->_data_migrations_ran) {
251 251
 			//setup autoloaders for each of the scripts in there
252 252
 			$this->get_all_data_migration_scripts_available();
253
-			$data_migrations_options = $this->get_all_migration_script_options();//get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
253
+			$data_migrations_options = $this->get_all_migration_script_options(); //get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
254 254
 
255 255
 			$data_migrations_ran = array();
256 256
 			//convert into data migration script classes where possible
257
-			foreach($data_migrations_options as $data_migration_option){
258
-				list($plugin_slug,$version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']);
257
+			foreach ($data_migrations_options as $data_migration_option) {
258
+				list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']);
259 259
 
260
-				try{
261
-					$class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'],$data_migration_option['option_value']);
260
+				try {
261
+					$class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'], $data_migration_option['option_value']);
262 262
 					$data_migrations_ran[$plugin_slug][$version_string] = $class;
263 263
 					//ok so far THIS is the 'last-ran-script'... unless we find another on next iteration
264 264
 					$this->_last_ran_script = $class;
265
-					if( ! $class->is_completed()){
265
+					if ( ! $class->is_completed()) {
266 266
 						//sometimes we also like to know which was the last incomplete script (or if there are any at all)
267 267
 						$this->_last_ran_incomplete_script = $class;
268 268
 					}
269
-				}catch(EE_Error $e){
269
+				} catch (EE_Error $e) {
270 270
 					//ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs
271 271
 					$data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']);
272 272
 				}
273 273
 			}
274 274
 			//so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays
275 275
 			$this->_data_migrations_ran = $data_migrations_ran;
276
-			 if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran) ){
276
+			 if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) {
277 277
 				$this->_data_migrations_ran = array();
278 278
 			}
279 279
 		}
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @param        $new_table
291 291
 	 * @return mixed string or int
292 292
 	 */
293
-	public function get_mapping_new_pk( $script_name, $old_table, $old_pk, $new_table){
293
+	public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table) {
294 294
 		$script = EE_Registry::instance()->load_dms($script_name);
295 295
 		$mapping = $script->get_mapping_new_pk($old_table, $old_pk, $new_table);
296 296
 		return $mapping;
@@ -301,9 +301,9 @@  discard block
 block discarded – undo
301 301
 	 * option returned in this array is the most-recently ran DMS option
302 302
 	 * @return array
303 303
 	 */
304
-	 public function get_all_migration_script_options(){
304
+	 public function get_all_migration_script_options() {
305 305
 		global $wpdb;
306
-		return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC",ARRAY_A);
306
+		return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC", ARRAY_A);
307 307
 	}
308 308
 
309 309
 	/**
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
 	 * @return array where each value is the full folder path of a folder containing data migration scripts, WITH slashes at the end of the
312 312
 	 * folder name.
313 313
 	 */
314
-	public function get_data_migration_script_folders(){
315
-		return  apply_filters( 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',array(EE_CORE.'data_migration_scripts') );
314
+	public function get_data_migration_script_folders() {
315
+		return  apply_filters('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array(EE_CORE.'data_migration_scripts'));
316 316
 	}
317 317
 
318 318
 	/**
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
 	 * }
325 325
 	 * @throws EE_Error
326 326
 	 */
327
-	public function script_migrates_to_version($migration_script_name){
327
+	public function script_migrates_to_version($migration_script_name) {
328 328
 		$dms_info = $this->parse_dms_classname($migration_script_name);
329 329
 		return array(
330
-			'slug'=> $dms_info[ 'slug' ],
331
-			'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ] );
330
+			'slug'=> $dms_info['slug'],
331
+			'version'=> $dms_info['major_version'].".".$dms_info['minor_version'].".".$dms_info['micro_version'] );
332 332
 	}
333 333
 
334 334
 	/**
@@ -337,13 +337,13 @@  discard block
 block discarded – undo
337 337
 	 * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints)
338 338
 	 * @throws EE_Error
339 339
 	 */
340
-	public function parse_dms_classname($classname){
340
+	public function parse_dms_classname($classname) {
341 341
 		$matches = array();
342
-		preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~',$classname,$matches);
343
-		if( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))){
344
-				throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"),$classname));
342
+		preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches);
343
+		if ( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) {
344
+				throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"), $classname));
345 345
 		}
346
-		return array('slug'=>$matches[1],'major_version'=>intval($matches[2]),'minor_version'=>intval($matches[3]),'micro_version'=>intval($matches[4]));
346
+		return array('slug'=>$matches[1], 'major_version'=>intval($matches[2]), 'minor_version'=>intval($matches[3]), 'micro_version'=>intval($matches[4]));
347 347
 	}
348 348
 	/**
349 349
 	 * Ensures that the option indicating the current DB version is set. This should only be
@@ -352,33 +352,33 @@  discard block
 block discarded – undo
352 352
 	 * to 4.1.x.
353 353
 	 * @return string of current db state
354 354
 	 */
355
-	public function ensure_current_database_state_is_set(){
356
-		$espresso_db_core_updates = get_option( 'espresso_db_update', array() );
355
+	public function ensure_current_database_state_is_set() {
356
+		$espresso_db_core_updates = get_option('espresso_db_update', array());
357 357
 		$db_state = get_option(EE_Data_Migration_Manager::current_database_state);
358
-		if( ! $db_state ){
358
+		if ( ! $db_state) {
359 359
 			//mark the DB as being in the state as the last version in there.
360 360
 			//this is done to trigger maintenance mode and do data migration scripts
361 361
 			//if the admin installed this version of EE over 3.1.x or 4.0.x
362 362
 			//otherwise, the normal maintenance mode code is fine
363 363
 			$previous_versions_installed = array_keys($espresso_db_core_updates);
364 364
 			$previous_version_installed = end($previous_versions_installed);
365
-			if(version_compare('4.1.0', $previous_version_installed)){
365
+			if (version_compare('4.1.0', $previous_version_installed)) {
366 366
 				//last installed version was less than 4.1
367 367
 				//so we want the data migrations to happen. SO, we're going to say the DB is at that state
368 368
 //				echo "4.1.0 is greater than $previous_version_installed! update the option";
369 369
 				$db_state = array('Core'=>$previous_version_installed);
370
-			}else{
370
+			} else {
371 371
 //					echo "4.1.0 is SMALLER than $previous_version_installed";
372 372
 					$db_state = array('Core'=>EVENT_ESPRESSO_VERSION);
373 373
 			}
374
-			update_option(EE_Data_Migration_Manager::current_database_state,$db_state);
374
+			update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
375 375
 		}
376 376
 		//in 4.1, $db_state would have only been a simple string like '4.1.0',
377 377
 		//but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's
378 378
 		//db, and possibly other keys for other addons like 'Calendar','Permissions',etc
379
-		if( ! is_array($db_state)){
379
+		if ( ! is_array($db_state)) {
380 380
 			$db_state = array('Core'=>$db_state);
381
-			update_option(EE_Data_Migration_Manager::current_database_state,$db_state);
381
+			update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
382 382
 		}
383 383
 		return $db_state;
384 384
 	}
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 	 * or they don't apply), returns an empty array
390 390
 	 * @return EE_Data_Migration_Script_Base[]
391 391
 	 */
392
-	public function check_for_applicable_data_migration_scripts(){
392
+	public function check_for_applicable_data_migration_scripts() {
393 393
 		//get the option describing what options have already run
394 394
 		$scripts_ran = $this->get_data_migrations_ran();
395 395
 		//$scripts_ran = array('4.1.0.core'=>array('monkey'=>null));
@@ -402,62 +402,62 @@  discard block
 block discarded – undo
402 402
 		$iteration = 0;
403 403
 		$next_database_state_to_consider = $current_database_state;
404 404
 		$theoretical_database_state = NULL;
405
-		do{
405
+		do {
406 406
 			//the next state after the currently-considered one will start off looking the same as the current, but we may make additions...
407 407
 			$theoretical_database_state = $next_database_state_to_consider;
408 408
 			//the next db state to consider is "what would the DB be like had we run all the scripts we found that applied last time?)
409
-			foreach($script_class_and_filepaths_available as $classname => $filepath){
409
+			foreach ($script_class_and_filepaths_available as $classname => $filepath) {
410 410
 
411 411
 				$migrates_to_version = $this->script_migrates_to_version($classname);
412
-				$script_converts_plugin_slug = $migrates_to_version[ 'slug' ];
413
-				$script_converts_to_version = $migrates_to_version[ 'version' ];
412
+				$script_converts_plugin_slug = $migrates_to_version['slug'];
413
+				$script_converts_to_version = $migrates_to_version['version'];
414 414
 				//check if this version script is DONE or not; or if it's never been ran
415
-				if(		! $scripts_ran ||
415
+				if ( ! $scripts_ran ||
416 416
 						! isset($scripts_ran[$script_converts_plugin_slug]) ||
417
-						! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])){
417
+						! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])) {
418 418
 					//we haven't ran this conversion script before
419 419
 					//now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available
420
-					$script = new $classname( $this->_get_table_manager(), $this->_get_table_analysis() );
420
+					$script = new $classname($this->_get_table_manager(), $this->_get_table_analysis());
421 421
 					/* @var $script EE_Data_Migration_Script_Base */
422 422
 					$can_migrate = $script->can_migrate_from_version($theoretical_database_state);
423
-					if($can_migrate){
423
+					if ($can_migrate) {
424 424
 						$script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script;
425 425
 						$migrates_to_version = $script->migrates_to_version();
426
-						$next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ];
426
+						$next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version'];
427 427
 						unset($script_class_and_filepaths_available[$classname]);
428 428
 					}
429
-				} elseif($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base){
429
+				} elseif ($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base) {
430 430
 					//this script has been ran, or at least started
431 431
 					$script = $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version];
432
-					if( $script->get_status() != self::status_completed){
432
+					if ($script->get_status() != self::status_completed) {
433 433
 						//this script is already underway... keep going with it
434 434
 						$script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script;
435 435
 						$migrates_to_version = $script->migrates_to_version();
436
-						$next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ];
436
+						$next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version'];
437 437
 						unset($script_class_and_filepaths_available[$classname]);
438
-					}else{
438
+					} else {
439 439
 						//it must have a status that indicates it has finished, so we don't want to try and run it again
440 440
 					}
441
-				}else{
441
+				} else {
442 442
 					//it exists but it's not  a proper data migration script
443 443
 					//maybe the script got renamed? or was simply removed from EE?
444 444
 					//either way, its certainly not runnable!
445 445
 				}
446 446
 			}
447 447
 			$iteration++;
448
-		}while( $next_database_state_to_consider != $theoretical_database_state && $iteration<6);
448
+		}while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6);
449 449
 		//ok we have all the scripts that should run, now let's make them into flat array
450 450
 		$scripts_that_should_run = array();
451
-		foreach($script_classes_that_should_run_per_iteration as $scripts_at_priority){
451
+		foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) {
452 452
 			ksort($scripts_at_priority);
453
-			foreach($scripts_at_priority as $scripts){
454
-				foreach($scripts as $script){
453
+			foreach ($scripts_at_priority as $scripts) {
454
+				foreach ($scripts as $script) {
455 455
 					$scripts_that_should_run[get_class($script)] = $script;
456 456
 				}
457 457
 			}
458 458
 		}
459 459
 
460
-		do_action( 'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run );
460
+		do_action('AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run);
461 461
 		return $scripts_that_should_run;
462 462
 	}
463 463
 
@@ -471,14 +471,14 @@  discard block
 block discarded – undo
471 471
 	 * @param bool $include_completed_scripts
472 472
 	 * @return EE_Data_Migration_Script_Base
473 473
 	 */
474
-	public function get_last_ran_script($include_completed_scripts = false){
474
+	public function get_last_ran_script($include_completed_scripts = false) {
475 475
 		//make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script
476
-		if( ! $this->_data_migrations_ran){
476
+		if ( ! $this->_data_migrations_ran) {
477 477
 			$this->get_data_migrations_ran();
478 478
 		}
479
-		if($include_completed_scripts){
479
+		if ($include_completed_scripts) {
480 480
 			return $this->_last_ran_script;
481
-		}else{
481
+		} else {
482 482
 			return $this->_last_ran_incomplete_script;
483 483
 		}
484 484
 	}
@@ -501,19 +501,19 @@  discard block
 block discarded – undo
501 501
 	 * 		@type string $message string describing what was done during this step
502 502
 	 * }
503 503
 	 */
504
-	public function migration_step( $step_size = 0 ){
504
+	public function migration_step($step_size = 0) {
505 505
 
506 506
 		//bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535
507
-		if ( class_exists( 'EE_CPT_Strategy' ) ) {
508
-			remove_action( 'pre_get_posts', array( EE_CPT_Strategy::instance(), 'pre_get_posts' ), 5 );
507
+		if (class_exists('EE_CPT_Strategy')) {
508
+			remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5);
509 509
 		}
510 510
 
511
-		try{
511
+		try {
512 512
 			$currently_executing_script = $this->get_last_ran_script();
513
-			if( ! $currently_executing_script){
513
+			if ( ! $currently_executing_script) {
514 514
 				//Find the next script that needs to execute
515 515
 				$scripts = $this->check_for_applicable_data_migration_scripts();
516
-				if( ! $scripts ){
516
+				if ( ! $scripts) {
517 517
 					//huh, no more scripts to run... apparently we're done!
518 518
 					//but dont forget to make sure initial data is there
519 519
 					//we should be good to allow them to exit maintenance mode now
@@ -534,18 +534,18 @@  discard block
 block discarded – undo
534 534
 				//and add to the array/wp option showing the scripts ran
535 535
 //				$this->_data_migrations_ran[$this->script_migrates_to_version(get_class($currently_executing_script))] = $currently_executing_script;
536 536
 				$migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script));
537
-				$plugin_slug = $migrates_to[ 'slug' ];
538
-				$version = $migrates_to[ 'version' ];
537
+				$plugin_slug = $migrates_to['slug'];
538
+				$version = $migrates_to['version'];
539 539
 				$this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script;
540 540
 			}
541 541
 			$current_script_name = get_class($currently_executing_script);
542
-		}catch(Exception $e){
542
+		} catch (Exception $e) {
543 543
 			//an exception occurred while trying to get migration scripts
544 544
 
545
-			$message =  sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() );
545
+			$message = sprintf(__("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage().'<br>', $e->getTraceAsString());
546 546
 			//record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations
547 547
 			//but that's ok-- it's just an FYI to support that we couldn't even run any data migrations
548
-			$this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"),$message));
548
+			$this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message));
549 549
 			return array(
550 550
 				'records_to_migrate'=>1,
551 551
 				'records_migrated'=>0,
@@ -555,16 +555,16 @@  discard block
 block discarded – undo
555 555
 			);
556 556
 		}
557 557
 		//ok so we definitely have a data migration script
558
-		try{
558
+		try {
559 559
 			//how big of a bite do we want to take? Allow users to easily override via their wp-config
560
-			if( ! absint( $step_size ) > 0 ){
561
-				$step_size = defined( 'EE_MIGRATION_STEP_SIZE' ) && absint( EE_MIGRATION_STEP_SIZE ) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size;
560
+			if ( ! absint($step_size) > 0) {
561
+				$step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size;
562 562
 			}
563 563
 			//do what we came to do!
564 564
 			$currently_executing_script->migration_step($step_size);
565 565
 			//can we wrap it up and verify default data?
566 566
 			$init_dbs = false;
567
-			switch($currently_executing_script->get_status()){
567
+			switch ($currently_executing_script->get_status()) {
568 568
 				case EE_Data_Migration_Manager::status_continue:
569 569
 					$response_array = array(
570 570
 						'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
@@ -576,16 +576,16 @@  discard block
 block discarded – undo
576 576
 				case EE_Data_Migration_Manager::status_completed:
577 577
 					//ok so THAT script has completed
578 578
 					$this->update_current_database_state_to($this->script_migrates_to_version($current_script_name));
579
-					$response_array =  array(
579
+					$response_array = array(
580 580
 							'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
581 581
 							'records_migrated'=>$currently_executing_script->count_records_migrated(),
582 582
 							'status'=> EE_Data_Migration_Manager::status_completed,
583 583
 							'message'=>$currently_executing_script->get_feedback_message(),
584
-							'script'=> sprintf(__("%s Completed",'event_espresso'),$currently_executing_script->pretty_name())
584
+							'script'=> sprintf(__("%s Completed", 'event_espresso'), $currently_executing_script->pretty_name())
585 585
 						);
586 586
 					//check if there are any more after this one.
587 587
 					$scripts_remaining = $this->check_for_applicable_data_migration_scripts();
588
-					if( ! $scripts_remaining ){
588
+					if ( ! $scripts_remaining) {
589 589
 						//we should be good to allow them to exit maintenance mode now
590 590
 						EE_Maintenance_Mode::instance()->set_maintenance_level(intval(EE_Maintenance_Mode::level_0_not_in_maintenance));
591 591
 						////huh, no more scripts to run... apparently we're done!
@@ -599,39 +599,39 @@  discard block
 block discarded – undo
599 599
 						'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
600 600
 						'records_migrated'=>$currently_executing_script->count_records_migrated(),
601 601
 						'status'=> $currently_executing_script->get_status(),
602
-						'message'=>  sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ",$currently_executing_script->get_errors())),
602
+						'message'=>  sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ", $currently_executing_script->get_errors())),
603 603
 						'script'=>$currently_executing_script->pretty_name()
604 604
 					);
605 605
 					break;
606 606
 			}
607
-		}catch(Exception $e){
607
+		} catch (Exception $e) {
608 608
 			//ok so some exception was thrown which killed the data migration script
609 609
 			//double-check we have a real script
610
-			if($currently_executing_script instanceof EE_Data_Migration_Script_Base){
610
+			if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) {
611 611
 				$script_name = $currently_executing_script->pretty_name();
612 612
 				$currently_executing_script->set_broken();
613 613
 				$currently_executing_script->add_error($e->getMessage());
614
-			}else{
614
+			} else {
615 615
 				$script_name = __("Error getting Migration Script", "event_espresso");
616 616
 			}
617 617
 			$response_array = array(
618 618
 				'records_to_migrate'=>1,
619 619
 				'records_migrated'=>0,
620 620
 				'status'=>self::status_fatal_error,
621
-				'message'=>  sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"),$e->getMessage()),
621
+				'message'=>  sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"), $e->getMessage()),
622 622
 				'script'=>$script_name
623 623
 			);
624 624
 		}
625 625
 		$successful_save = $this->_save_migrations_ran();
626
-		if($successful_save !== TRUE){
626
+		if ($successful_save !== TRUE) {
627 627
 			//ok so the current wp option didn't save. that's tricky, because we'd like to update it
628 628
 			//and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION!
629 629
 			//however, if we throw an exception, and return that, then the next request
630 630
 			//won't have as much info in it, and it may be able to save
631
-			throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"),$successful_save));
631
+			throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"), $successful_save));
632 632
 		}
633 633
 		//if we're all done, initialize EE plugins' default data etc.
634
-		if( $init_dbs ) {
634
+		if ($init_dbs) {
635 635
 			$this->initialize_db_for_enqueued_ee_plugins();
636 636
 		}
637 637
 		return $response_array;
@@ -649,23 +649,23 @@  discard block
 block discarded – undo
649 649
 	 * 'message'=>a string, containing any message you want to show to the user. We may decide to split this up into errors, notifications, and successes
650 650
 	 * 'script'=>a pretty name of the script currently running
651 651
 	 */
652
-	public function response_to_migration_ajax_request(){
652
+	public function response_to_migration_ajax_request() {
653 653
 //		//start output buffer just to make sure we don't mess up the json
654 654
 		ob_start();
655
-		try{
655
+		try {
656 656
 			$response = $this->migration_step();
657
-		}catch(Exception $e){
657
+		} catch (Exception $e) {
658 658
 			$response = array(
659 659
 				'records_to_migrate'=>0,
660 660
 				'records_migrated'=>0,
661 661
 				'status'=> EE_Data_Migration_Manager::status_fatal_error,
662
-				'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"),$e->getMessage()),
662
+				'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"), $e->getMessage()),
663 663
 				'script'=>'Unknown');
664 664
 			$this->add_error_to_migrations_ran($e->getMessage()."; Stack trace:".$e->getTraceAsString());
665 665
 		}
666 666
 		$warnings_etc = @ob_get_contents();
667 667
 		ob_end_clean();
668
-		$response['message'] .=$warnings_etc;
668
+		$response['message'] .= $warnings_etc;
669 669
 		return $response;
670 670
 	}
671 671
 
@@ -678,14 +678,14 @@  discard block
 block discarded – undo
678 678
 	 * }
679 679
 	 * @return void
680 680
 	 */
681
-	public function update_current_database_state_to($slug_and_version = null){
682
-		if( ! $slug_and_version ){
681
+	public function update_current_database_state_to($slug_and_version = null) {
682
+		if ( ! $slug_and_version) {
683 683
 			//no version was provided, assume it should be at the current code version
684 684
 			$slug_and_version = array('slug' => 'Core', 'version' => espresso_version());
685 685
 		}
686 686
 		$current_database_state = get_option(self::current_database_state);
687
-		$current_database_state[ $slug_and_version[ 'slug' ] ]=$slug_and_version[ 'version' ];
688
-		update_option(self::current_database_state,$current_database_state);
687
+		$current_database_state[$slug_and_version['slug']] = $slug_and_version['version'];
688
+		update_option(self::current_database_state, $current_database_state);
689 689
 	}
690 690
 
691 691
 	/**
@@ -696,20 +696,20 @@  discard block
 block discarded – undo
696 696
 	 * }
697 697
 	 * @return boolean
698 698
 	 */
699
-	public function database_needs_updating_to( $slug_and_version ) {
699
+	public function database_needs_updating_to($slug_and_version) {
700 700
 
701
-		$slug = $slug_and_version[ 'slug' ];
702
-		$version = $slug_and_version[ 'version' ];
701
+		$slug = $slug_and_version['slug'];
702
+		$version = $slug_and_version['version'];
703 703
 		$current_database_state = get_option(self::current_database_state);
704
-		if( ! isset( $current_database_state[ $slug ] ) ) {
704
+		if ( ! isset($current_database_state[$slug])) {
705 705
 			return true;
706
-		}else{
706
+		} else {
707 707
 			//just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes
708
-			$version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3);
709
-			$version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 );
708
+			$version_parts_current_db_state = array_slice(explode('.', $current_database_state[$slug]), 0, 3);
709
+			$version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3);
710 710
 			$needs_updating = false;
711
-			foreach($version_parts_current_db_state as $offset => $version_part_in_current_db_state ) {
712
-				if( $version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ] ) {
711
+			foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) {
712
+				if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[$offset]) {
713 713
 					$needs_updating = true;
714 714
 					break;
715 715
 				}
@@ -723,29 +723,29 @@  discard block
 block discarded – undo
723 723
 	 * in addons. Has the side effect of adding them for autoloading
724 724
 	 * @return array keys are expected classnames, values are their filepaths
725 725
 	 */
726
-	public function get_all_data_migration_scripts_available(){
727
-		if( ! $this->_data_migration_class_to_filepath_map){
726
+	public function get_all_data_migration_scripts_available() {
727
+		if ( ! $this->_data_migration_class_to_filepath_map) {
728 728
 			$this->_data_migration_class_to_filepath_map = array();
729
-			foreach($this->get_data_migration_script_folders() as $folder_path){
730
-				if($folder_path[count($folder_path-1)] != DS ){
731
-					$folder_path.= DS;
729
+			foreach ($this->get_data_migration_script_folders() as $folder_path) {
730
+				if ($folder_path[count($folder_path - 1)] != DS) {
731
+					$folder_path .= DS;
732 732
 				}
733
-				$files = glob( $folder_path. '*.dms.php' );
733
+				$files = glob($folder_path.'*.dms.php');
734 734
 
735
-				if ( empty( $files ) ) {
735
+				if (empty($files)) {
736 736
 					continue;
737 737
 				}
738 738
 
739
-				foreach($files as $file){
740
-					$pos_of_last_slash = strrpos($file,DS);
741
-					$classname = str_replace(".dms.php","", substr($file, $pos_of_last_slash+1));
742
-					$migrates_to = $this->script_migrates_to_version( $classname );
743
-					$slug = $migrates_to[ 'slug' ];
739
+				foreach ($files as $file) {
740
+					$pos_of_last_slash = strrpos($file, DS);
741
+					$classname = str_replace(".dms.php", "", substr($file, $pos_of_last_slash + 1));
742
+					$migrates_to = $this->script_migrates_to_version($classname);
743
+					$slug = $migrates_to['slug'];
744 744
 					//check that the slug as contained in the DMS is associated with
745 745
 					//the slug of an addon or core
746
-					if( $slug != 'Core' ){
747
-						if( ! EE_Registry::instance()->get_addon_by_name( $slug ) ) {
748
-							EE_Error::doing_it_wrong(__FUNCTION__, sprintf( __( 'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso' ),$classname,$slug,implode(",", array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ), '4.3.0.alpha.019' );
746
+					if ($slug != 'Core') {
747
+						if ( ! EE_Registry::instance()->get_addon_by_name($slug)) {
748
+							EE_Error::doing_it_wrong(__FUNCTION__, sprintf(__('The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso'), $classname, $slug, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name()))), '4.3.0.alpha.019');
749 749
 						}
750 750
 					}
751 751
 					$this->_data_migration_class_to_filepath_map[$classname] = $file;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 	 * from each addon, and check if they need updating,
766 766
 	 * @return boolean
767 767
 	 */
768
-	public function addons_need_updating(){
768
+	public function addons_need_updating() {
769 769
 		return false;
770 770
 	}
771 771
 	/**
@@ -774,25 +774,25 @@  discard block
 block discarded – undo
774 774
 	 * @param string $error_message
775 775
 	 * @throws EE_Error
776 776
 	 */
777
-	public function add_error_to_migrations_ran($error_message){
777
+	public function add_error_to_migrations_ran($error_message) {
778 778
 		//get last-ran migration script
779 779
 		global $wpdb;
780
-		$last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1",ARRAY_A);
780
+		$last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1", ARRAY_A);
781 781
 
782 782
 		$last_ran_migration_script_properties = isset($last_migration_script_option['option_value']) ? maybe_unserialize($last_migration_script_option['option_value']) : null;
783 783
 		//now, tread lightly because we're here because a FATAL non-catchable error
784 784
 		//was thrown last time when we were trying to run a data migration script
785 785
 		//so the fatal error could have happened while getting the migration script
786 786
 		//or doing running it...
787
-		$versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix,"",$last_migration_script_option['option_name']) : null;
787
+		$versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $last_migration_script_option['option_name']) : null;
788 788
 
789 789
 		//check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet
790 790
 		//because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done)
791
-		if(isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed){
791
+		if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) {
792 792
 			//ok then just add this error to its list of errors
793 793
 			$last_ran_migration_script_properties['_errors'][] = $error_message;
794 794
 			$last_ran_migration_script_properties['_status'] = self::status_fatal_error;
795
-		}else{
795
+		} else {
796 796
 			//so we don't even know which script was last running
797 797
 			//use the data migration error stub, which is designed specifically for this type of thing
798 798
 			$general_migration_error = new EE_DMS_Unknown_1_0_0();
@@ -802,39 +802,39 @@  discard block
 block discarded – undo
802 802
 			$versions_migrated_to = 'Unknown.1.0.0';
803 803
 			//now just to make sure appears as last (in case the were previously a fatal error like this)
804 804
 			//delete the old one
805
-			delete_option( self::data_migration_script_option_prefix . $versions_migrated_to );
805
+			delete_option(self::data_migration_script_option_prefix.$versions_migrated_to);
806 806
 		}
807
-		update_option(self::data_migration_script_option_prefix.$versions_migrated_to,$last_ran_migration_script_properties);
807
+		update_option(self::data_migration_script_option_prefix.$versions_migrated_to, $last_ran_migration_script_properties);
808 808
 
809 809
 	}
810 810
 	/**
811 811
 	 * saves what data migrations have ran to the database
812 812
 	 * @return mixed TRUE if successfully saved migrations ran, string if an error occurred
813 813
 	 */
814
-	protected function _save_migrations_ran(){
815
-		if($this->_data_migrations_ran == null){
814
+	protected function _save_migrations_ran() {
815
+		if ($this->_data_migrations_ran == null) {
816 816
 			$this->get_data_migrations_ran();
817 817
 		}
818 818
 		//now, we don't want to save actual classes to the DB because that's messy
819 819
 		$successful_updates = true;
820
-		foreach($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin){
821
-			foreach($migrations_ran_for_plugin as $version_string => $array_or_migration_obj){
820
+		foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) {
821
+			foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) {
822 822
 	//			echo "saving migration script to $version_string<br>";
823 823
 				$plugin_slug_for_use_in_option_name = $plugin_slug.".";
824 824
 				$option_name = self::data_migration_script_option_prefix.$plugin_slug_for_use_in_option_name.$version_string;
825 825
 				$old_option_value = get_option($option_name);
826
-				if($array_or_migration_obj instanceof EE_Data_Migration_Script_Base){
826
+				if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) {
827 827
 					$script_array_for_saving = $array_or_migration_obj->properties_as_array();
828
-					if( $old_option_value != $script_array_for_saving){
829
-						$successful_updates = update_option($option_name,$script_array_for_saving);
828
+					if ($old_option_value != $script_array_for_saving) {
829
+						$successful_updates = update_option($option_name, $script_array_for_saving);
830 830
 					}
831
-				}else{//we don't know what this array-thing is. So just save it as-is
831
+				} else {//we don't know what this array-thing is. So just save it as-is
832 832
 	//				$array_of_migrations[$version_string] = $array_or_migration_obj;
833
-					if($old_option_value != $array_or_migration_obj){
834
-						$successful_updates = update_option($option_name,$array_or_migration_obj);
833
+					if ($old_option_value != $array_or_migration_obj) {
834
+						$successful_updates = update_option($option_name, $array_or_migration_obj);
835 835
 					}
836 836
 				}
837
-				if( ! $successful_updates ){
837
+				if ( ! $successful_updates) {
838 838
 					global $wpdb;
839 839
 					return $wpdb->last_error;
840 840
 				}
@@ -858,17 +858,17 @@  discard block
 block discarded – undo
858 858
 	 * @return EE_Data_Migration_Script_Base
859 859
 	 * @throws EE_Error
860 860
 	 */
861
-	function _instantiate_script_from_properties_array($properties_array){
862
-		if( ! isset($properties_array['class'])){
863
-			throw new EE_Error(sprintf(__("Properties array  has no 'class' properties. Here's what it has: %s", "event_espresso"),implode(",",$properties_array)));
861
+	function _instantiate_script_from_properties_array($properties_array) {
862
+		if ( ! isset($properties_array['class'])) {
863
+			throw new EE_Error(sprintf(__("Properties array  has no 'class' properties. Here's what it has: %s", "event_espresso"), implode(",", $properties_array)));
864 864
 		}
865 865
 		$class_name = $properties_array['class'];
866
-		if( ! class_exists($class_name)){
867
-			throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"),$class_name));
866
+		if ( ! class_exists($class_name)) {
867
+			throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name));
868 868
 		}
869 869
 		$class = new $class_name;
870
-		if( ! $class instanceof EE_Data_Migration_Script_Base){
871
-			throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"),$class_name,get_class($class)));
870
+		if ( ! $class instanceof EE_Data_Migration_Script_Base) {
871
+			throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"), $class_name, get_class($class)));
872 872
 		}
873 873
 		$class->instantiate_from_array_of_properties($properties_array);
874 874
 		return $class;
@@ -880,25 +880,25 @@  discard block
 block discarded – undo
880 880
 	 * @param string $plugin_slug the slug for the ee plugin we are searching for. Default is 'Core'
881 881
 	 * @return string
882 882
 	 */
883
-	public function get_most_up_to_date_dms($plugin_slug = 'Core'){
883
+	public function get_most_up_to_date_dms($plugin_slug = 'Core') {
884 884
 		$class_to_filepath_map = $this->get_all_data_migration_scripts_available();
885 885
 		$most_up_to_date_dms_classname = NULL;
886
-		foreach($class_to_filepath_map as $classname => $filepath){
887
-			if($most_up_to_date_dms_classname === NULL){
886
+		foreach ($class_to_filepath_map as $classname => $filepath) {
887
+			if ($most_up_to_date_dms_classname === NULL) {
888 888
 				$migrates_to = $this->script_migrates_to_version($classname);
889
-				$this_plugin_slug = $migrates_to[ 'slug' ];
889
+				$this_plugin_slug = $migrates_to['slug'];
890 890
 //				$version_string = $migrates_to[ 'version' ];
891 891
 //				$details = $this->parse_dms_classname($classname);
892
-				if($this_plugin_slug == $plugin_slug){
892
+				if ($this_plugin_slug == $plugin_slug) {
893 893
 					//if it's for core, it wins
894 894
 					$most_up_to_date_dms_classname = $classname;
895 895
 				}
896 896
 				//if it wasn't for core, we must keep searching for one that is!
897 897
 				continue;
898
-			}else{
899
-				$champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname);
898
+			} else {
899
+				$champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname);
900 900
 				$contender_migrates_to = $this->script_migrates_to_version($classname);
901
-				if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){
901
+				if ($contender_migrates_to['slug'] == $plugin_slug && version_compare($champion_migrates_to['version'], $contender_migrates_to['version'], '<')) {
902 902
 					//so the contenders version is higher and its for Core
903 903
 					$most_up_to_date_dms_classname = $classname;
904 904
 				}
@@ -918,11 +918,11 @@  discard block
 block discarded – undo
918 918
 	 * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
919 919
 	 * @return EE_Data_Migration_Script_Base
920 920
 	 */
921
-	public function get_migration_ran( $version, $plugin_slug = 'Core' ) {
921
+	public function get_migration_ran($version, $plugin_slug = 'Core') {
922 922
 		$migrations_ran = $this->get_data_migrations_ran();
923
-		if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){
924
-			return $migrations_ran[ $plugin_slug ][ $version ];
925
-		}else{
923
+		if (isset($migrations_ran[$plugin_slug]) && isset($migrations_ran[$plugin_slug][$version])) {
924
+			return $migrations_ran[$plugin_slug][$version];
925
+		} else {
926 926
 			return NULL;
927 927
 		}
928 928
 	}
@@ -934,20 +934,20 @@  discard block
 block discarded – undo
934 934
 	 * @return bool
935 935
 	 * @throws \EE_Error
936 936
 	 */
937
-	public function reattempt(){
937
+	public function reattempt() {
938 938
 		//find if the last-ran script was borked
939 939
 		//set it as being non-borked (we shouldn't ever get DMSs that we don't recognize)
940 940
 		//add an 'error' saying that we attempted to reset
941 941
 		//does it have a stage that was borked too? if so make it no longer borked
942 942
 		//add an 'error' saying we attempted to reset
943 943
 		$last_ran_script = $this->get_last_ran_script();
944
-		if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){
944
+		if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) {
945 945
 			//if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it)
946 946
 			$last_ran_script->set_completed();
947
-		}elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) {
947
+		}elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) {
948 948
 			$last_ran_script->reattempt();
949
-		}else{
950
-			throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script, true ) ) );
949
+		} else {
950
+			throw new EE_Error(sprintf(__('Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso'), print_r($last_ran_script, true)));
951 951
 		}
952 952
 		return $this->_save_migrations_ran();
953 953
 	}
@@ -957,19 +957,19 @@  discard block
 block discarded – undo
957 957
 	 * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
958 958
 	 * @return boolean
959 959
 	 */
960
-	public function migration_has_ran( $version, $plugin_slug = 'Core' ) {
961
-		return $this->get_migration_ran( $version, $plugin_slug ) !== NULL;
960
+	public function migration_has_ran($version, $plugin_slug = 'Core') {
961
+		return $this->get_migration_ran($version, $plugin_slug) !== NULL;
962 962
 	}
963 963
 	/**
964 964
 	 * Enqueues this ee plugin to have its data initialized
965 965
 	 * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value
966 966
 	 */
967
-	public function enqueue_db_initialization_for( $plugin_slug ) {
967
+	public function enqueue_db_initialization_for($plugin_slug) {
968 968
 		$queue = $this->get_db_initialization_queue();
969
-		if( ! in_array( $plugin_slug, $queue ) ) {
969
+		if ( ! in_array($plugin_slug, $queue)) {
970 970
 			$queue[] = $plugin_slug;
971 971
 		}
972
-		update_option( self::db_init_queue_option_name, $queue );
972
+		update_option(self::db_init_queue_option_name, $queue);
973 973
 	}
974 974
 	/**
975 975
 	 * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon
@@ -979,26 +979,26 @@  discard block
 block discarded – undo
979 979
 	public function initialize_db_for_enqueued_ee_plugins() {
980 980
 //		EEH_Debug_Tools::instance()->start_timer( 'initialize_db_for_enqueued_ee_plugins' );
981 981
 		$queue = $this->get_db_initialization_queue();
982
-		foreach( $queue as $plugin_slug ) {
983
-			$most_up_to_date_dms = $this->get_most_up_to_date_dms( $plugin_slug );
984
-			if( ! $most_up_to_date_dms ) {
982
+		foreach ($queue as $plugin_slug) {
983
+			$most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug);
984
+			if ( ! $most_up_to_date_dms) {
985 985
 				//if there is NO DMS for this plugin, obviously there's no schema to verify anyways
986 986
 				$verify_db = false;
987
-			}else{
988
-				$most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms );
989
-				$verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to );
987
+			} else {
988
+				$most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms);
989
+				$verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to);
990 990
 			}
991
-			if( $plugin_slug == 'Core' ){
991
+			if ($plugin_slug == 'Core') {
992 992
 				EE_System::instance()->initialize_db_if_no_migrations_required(
993 993
 						false,
994 994
 						$verify_db
995 995
 					);
996
-			}else{
996
+			} else {
997 997
 				//just loop through the addons to make sure their database is setup
998
-				foreach( EE_Registry::instance()->addons as $addon ) {
999
-					if( $addon->name() == $plugin_slug ) {
998
+				foreach (EE_Registry::instance()->addons as $addon) {
999
+					if ($addon->name() == $plugin_slug) {
1000 1000
 
1001
-						$addon->initialize_db_if_no_migrations_required( $verify_db );
1001
+						$addon->initialize_db_if_no_migrations_required($verify_db);
1002 1002
 						break;
1003 1003
 					}
1004 1004
 				}
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 //		EEH_Debug_Tools::instance()->show_times();
1009 1009
 		//because we just initialized the DBs for the enqueued ee plugins
1010 1010
 		//we don't need to keep remembering which ones needed to be initialized
1011
-		delete_option( self::db_init_queue_option_name );
1011
+		delete_option(self::db_init_queue_option_name);
1012 1012
 	}
1013 1013
 
1014 1014
 	/**
@@ -1017,8 +1017,8 @@  discard block
 block discarded – undo
1017 1017
 	 * 'Core', or the return value of EE_Addon::name() for an addon
1018 1018
 	 * @return array
1019 1019
 	 */
1020
-	public function get_db_initialization_queue(){
1021
-		return get_option ( self::db_init_queue_option_name, array() );
1020
+	public function get_db_initialization_queue() {
1021
+		return get_option(self::db_init_queue_option_name, array());
1022 1022
 	}
1023 1023
 	
1024 1024
 	/**
@@ -1027,13 +1027,13 @@  discard block
 block discarded – undo
1027 1027
 	 * @throws \EE_Error
1028 1028
 	 */
1029 1029
 	protected function _get_table_analysis() {
1030
-		if( $this->_table_analysis instanceof TableAnalysis ) {
1030
+		if ($this->_table_analysis instanceof TableAnalysis) {
1031 1031
 			return $this->_table_analysis;
1032 1032
 		} else {
1033 1033
 			throw new \EE_Error( 
1034 1034
 				sprintf( 
1035
-					__( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), 
1036
-					get_class( $this ) 
1035
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'), 
1036
+					get_class($this) 
1037 1037
 				) 
1038 1038
 			);
1039 1039
 		}
@@ -1045,13 +1045,13 @@  discard block
 block discarded – undo
1045 1045
 	 * @throws \EE_Error
1046 1046
 	 */
1047 1047
 	protected function _get_table_manager() {
1048
-		if( $this->_table_manager instanceof TableManager ) {
1048
+		if ($this->_table_manager instanceof TableManager) {
1049 1049
 			return $this->_table_manager;
1050 1050
 		} else {
1051 1051
 			throw new \EE_Error( 
1052 1052
 				sprintf( 
1053
-					__( 'Table manager class on class %1$s is not set properly.', 'event_espresso'), 
1054
-					get_class( $this ) 
1053
+					__('Table manager class on class %1$s is not set properly.', 'event_espresso'), 
1054
+					get_class($this) 
1055 1055
 				) 
1056 1056
 			);
1057 1057
 		}
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_Data_Migration_Class_Base.core.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
 
22 22
 
23
-abstract class EE_Data_Migration_Class_Base{
23
+abstract class EE_Data_Migration_Class_Base {
24 24
 
25 25
 	/**
26 26
 	 * @var $records_to_migrate int count of all that have been migrated
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param TableManager  $table_manager
73 73
 	 * @param TableAnalysis $table_analysis
74 74
 	 */
75
-	public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ){
75
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) {
76 76
 		$this->_table_manager = $table_manager;
77 77
 		$this->_table_analysis = $table_analysis;
78 78
 		$this->set_status(EE_Data_Migration_Manager::status_continue);
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	 * @throws EE_Error
86 86
 	 * @return string
87 87
 	 */
88
-	public function pretty_name(){
89
-		if($this->_pretty_name === null){
90
-			throw new EE_Error(sprintf(__("Please give a pretty name to the migration script stage %s by assigning the property _pretty_name in the constructor", "event_espresso"),get_class($this)));
88
+	public function pretty_name() {
89
+		if ($this->_pretty_name === null) {
90
+			throw new EE_Error(sprintf(__("Please give a pretty name to the migration script stage %s by assigning the property _pretty_name in the constructor", "event_espresso"), get_class($this)));
91 91
 		}
92 92
 		return $this->_pretty_name;
93 93
 	}
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 	 *
96 96
 	 * @return int
97 97
 	 */
98
-	public function count_records_to_migrate(){
99
-		if( $this->_records_to_migrate == null){
98
+	public function count_records_to_migrate() {
99
+		if ($this->_records_to_migrate == null) {
100 100
 			$this->_records_to_migrate = $this->_count_records_to_migrate();
101 101
 		}
102 102
 		return $this->_records_to_migrate;
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	 * @return string one of EE_Data_Migration_Manager::status_* constants
117 117
 	 * @throws EE_Error
118 118
 	 */
119
-	public function get_status(){
120
-		if($this->_status === null){
121
-			throw new EE_Error(sprintf(__("Trying to get status of Migration class %s, but it has not been initialized yet. It should be set in the constructor.", "event_espresso"),get_class($this)));
119
+	public function get_status() {
120
+		if ($this->_status === null) {
121
+			throw new EE_Error(sprintf(__("Trying to get status of Migration class %s, but it has not been initialized yet. It should be set in the constructor.", "event_espresso"), get_class($this)));
122 122
 		}
123 123
 		return $this->_status;
124 124
 	}
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @param string $status
128 128
 	 * @return void
129 129
 	 */
130
-	protected function set_status($status){
130
+	protected function set_status($status) {
131 131
 		$this->_status = $status;
132 132
 	}
133 133
 	/**
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 	 * Returns the last error that occurred. If none occurred, returns null
140 140
 	 * @return string
141 141
 	 */
142
-	public function get_last_error(){
142
+	public function get_last_error() {
143 143
 		$errors = $this->get_errors();
144
-		if($errors){
144
+		if ($errors) {
145 145
 			return end($errors);
146
-		}else{
146
+		} else {
147 147
 			return null;
148 148
 		}
149 149
 	}
@@ -152,26 +152,26 @@  discard block
 block discarded – undo
152 152
 	 * @param string $error a string describing the error that will be useful for debugging. Consider including all the data that led to the error, and a stack trace etc.
153 153
 	 * @param boolean $force force the error to be added (because otherwise we have a limit). If forcing and errors are already at their limit, we will purposefully forget the first half
154 154
 	 */
155
-	public function add_error($error, $force = FALSE ){
156
-		if( ! defined( 'EE_DMS_ERROR_LIMIT' ) ){
155
+	public function add_error($error, $force = FALSE) {
156
+		if ( ! defined('EE_DMS_ERROR_LIMIT')) {
157 157
 			$limit = 50;
158
-		}else{
158
+		} else {
159 159
 			$limit = EE_DMS_ERROR_LIMIT;
160 160
 		}
161 161
 		//make sure errors is an array, see ticket #8261
162
-		if( is_string( $this->_errors ) ){
163
-			$this->_errors = array( $this->_errors );
162
+		if (is_string($this->_errors)) {
163
+			$this->_errors = array($this->_errors);
164 164
 		}
165
-		if(count($this->_errors) >= $limit ){
166
-			if( $force ){
165
+		if (count($this->_errors) >= $limit) {
166
+			if ($force) {
167 167
 				//get rid of the first half of the errors and any above the limit
168
-				$this->_errors = array_slice( $this->_errors, $limit / 2, $limit / 2 );
168
+				$this->_errors = array_slice($this->_errors, $limit / 2, $limit / 2);
169 169
 				$this->_errors[] = "Limit reached; removed first half of errors to save space";
170 170
 				$this->_errors[] = $error;
171
-			}else{
172
-				$this->_errors[ $limit ] = 'More, but limit reached...';
171
+			} else {
172
+				$this->_errors[$limit] = 'More, but limit reached...';
173 173
 			}
174
-		}else{
174
+		} else {
175 175
 			$this->_errors[] = $error;
176 176
 		}
177 177
 	}
@@ -180,57 +180,57 @@  discard block
 block discarded – undo
180 180
 	 * Indicates there was a fatal error and the migration cannot possibly continue
181 181
 	 * @return boolean
182 182
 	 */
183
-	public function is_broken(){
183
+	public function is_broken() {
184 184
 		return $this->get_status() == EE_Data_Migration_Manager::status_fatal_error;
185 185
 	}
186 186
 	/**
187 187
 	 * @deprecated since 4.6.12
188 188
 	 */
189
-	public function is_borked(){
190
-		EE_Error::doing_it_wrong('is_borked', __( 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso' ), '4.6.12');
189
+	public function is_borked() {
190
+		EE_Error::doing_it_wrong('is_borked', __('The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso'), '4.6.12');
191 191
 		return $this->is_broken();
192 192
 	}
193 193
 	/**
194 194
 	 * Sets the status to as having a fatal error
195 195
 	 */
196
-	public function set_broken(){
196
+	public function set_broken() {
197 197
 		$this->_status = EE_Data_Migration_Manager::status_fatal_error;
198 198
 	}
199 199
 	/**
200 200
 	 *
201 201
 	 * @deprecated since 4.6.12
202 202
 	 */
203
-	public function set_borked(){
204
-		EE_Error::doing_it_wrong('is_borked', __( 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso' ), '4.6.12');
203
+	public function set_borked() {
204
+		EE_Error::doing_it_wrong('is_borked', __('The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso'), '4.6.12');
205 205
 		return $this->set_broken();
206 206
 	}
207 207
 	/**
208 208
 	 * Checks if this thing believes it is completed
209 209
 	 * @return boolean
210 210
 	 */
211
-	public function is_completed(){
211
+	public function is_completed() {
212 212
 		return $this->get_status() == EE_Data_Migration_Manager::status_completed;
213 213
 	}
214 214
 	/**
215 215
 	 * Checks if the current script has more to do or not (ie, if it's status is CONTINUE)
216 216
 	 * @return boolean
217 217
 	 */
218
-	public function has_more_to_do(){
218
+	public function has_more_to_do() {
219 219
 		return $this->get_status() == EE_Data_Migration_Manager::status_continue;
220 220
 	}
221 221
 	/**
222 222
 	 * Marks that we believe this migration thing is completed
223 223
 	 */
224
-	public function set_completed(){
224
+	public function set_completed() {
225 225
 		$this->_status = EE_Data_Migration_Manager::status_completed;
226 226
 	}
227 227
 
228 228
 	/**
229 229
 	 * Marks that we think this migration class can continue to migrate
230 230
 	 */
231
-	public function reattempt(){
231
+	public function reattempt() {
232 232
 		$this->_status = EE_Data_Migration_Manager::status_continue;
233
-		$this->add_error( __( 'Reattempt migration', 'event_espresso' ), TRUE );
233
+		$this->add_error(__('Reattempt migration', 'event_espresso'), TRUE);
234 234
 	}
235 235
 
236 236
 	/**
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 	 * possible that this class is defined when it goes to sleep, but NOT available when it
240 240
 	 * awakes (eg, this class is part of an addon that is deactivated at some point).
241 241
 	 */
242
-	public function properties_as_array(){
243
-		$properties =  get_object_vars($this);
242
+	public function properties_as_array() {
243
+		$properties = get_object_vars($this);
244 244
 		$properties['class'] = get_class($this);
245 245
 		unset($properties['_migration_script']);
246 246
 		return $properties;
@@ -261,22 +261,22 @@  discard block
 block discarded – undo
261 261
 	 * @param array $data_types numerically indexed
262 262
 	 * @return string
263 263
 	 */
264
-	protected function _create_error_message_for_db_insertion($old_table, $old_row_as_array, $new_table, $new_row_as_array, $data_types){
264
+	protected function _create_error_message_for_db_insertion($old_table, $old_row_as_array, $new_table, $new_row_as_array, $data_types) {
265 265
 		global $wpdb;
266 266
 		$old_columns_and_values_for_string = array();
267
-		foreach($old_row_as_array as $column => $value){
267
+		foreach ($old_row_as_array as $column => $value) {
268 268
 			$old_columns_and_values_for_string[] = "$column => $value";
269 269
 		}
270 270
 		$new_columns_and_values_for_string = array();
271 271
 		$count = 0;
272
-		foreach($new_row_as_array as $column => $value){
272
+		foreach ($new_row_as_array as $column => $value) {
273 273
 			$new_columns_and_values_for_string[] = " $column => $value (".$data_types[$count++].")";
274 274
 		}
275 275
 		return sprintf(
276 276
 			__('Received error "%6$s" inserting row %5$s %1$s %5$s into table %2$s.%5$s Data used was %5$s %3$s %5$s from table %4%s.', "event_espresso"),
277
-			implode(", ",$new_columns_and_values_for_string),
277
+			implode(", ", $new_columns_and_values_for_string),
278 278
 			$new_table,
279
-			implode(", ",$old_columns_and_values_for_string),
279
+			implode(", ", $old_columns_and_values_for_string),
280 280
 			$old_table,
281 281
 			'<br/>',
282 282
 			$wpdb->last_error
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 	* @param array $array_of_data
292 292
 	* @return string
293 293
 	*/
294
-	protected function _json_encode($array_of_data){
294
+	protected function _json_encode($array_of_data) {
295 295
 		//we'd rather NOT serialize the transaction details
296 296
 		$fields_to_include = array();
297
-		foreach($array_of_data as $name => $value){
297
+		foreach ($array_of_data as $name => $value) {
298 298
 			$unserialized_data = @unserialize($value);
299
-			if($unserialized_data === FALSE){
299
+			if ($unserialized_data === FALSE) {
300 300
 				$fields_to_include[$name] = $value;
301 301
 			}
302 302
 		}
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
 	 * @throws EE_Error
310 310
 	 */
311 311
 	protected function _get_table_manager() {
312
-		if( $this->_table_manager instanceof TableManager ) {
312
+		if ($this->_table_manager instanceof TableManager) {
313 313
 			return $this->_table_manager;
314 314
 		} else {
315 315
 			throw new EE_Error( 
316 316
 				sprintf( 
317
-					__( 'Table manager on migration class %1$s is not set properly.', 'event_espresso'), 
318
-					get_class( $this ) 
317
+					__('Table manager on migration class %1$s is not set properly.', 'event_espresso'), 
318
+					get_class($this) 
319 319
 				) 	
320 320
 			);
321 321
 		}
@@ -327,13 +327,13 @@  discard block
 block discarded – undo
327 327
 	 * @throws EE_Error
328 328
 	 */
329 329
 	protected function _get_table_analysis() {
330
-		if( $this->_table_analysis instanceof TableAnalysis ) {
330
+		if ($this->_table_analysis instanceof TableAnalysis) {
331 331
 			return $this->_table_analysis;
332 332
 		} else {
333 333
 			throw new EE_Error( 
334 334
 				sprintf( 
335
-					__( 'Table analysis class on migration class %1$s is not set properly.', 'event_espresso'), 
336
-					get_class( $this ) 
335
+					__('Table analysis class on migration class %1$s is not set properly.', 'event_espresso'), 
336
+					get_class($this) 
337 337
 				) 
338 338
 			);
339 339
 		}
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_Data_Migration_Script_Base.core.php 1 patch
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\services\database\TableAnalysis;
3 3
 use EventEspresso\core\services\database\TableManager;
4 4
 
5
-if ( ! defined( 'EVENT_ESPRESSO_VERSION')) {
5
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
6 6
 	exit('No direct script access allowed');
7 7
 }
8 8
 
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
 	 * @param TableManager  $table_manager
125 125
 	 * @param TableAnalysis $table_analysis
126 126
 	 */
127
-	public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) {
128
-		$this->_migration_stages = (array) apply_filters('FHEE__'.get_class($this).'__construct__migration_stages',$this->_migration_stages);
129
-		foreach($this->_migration_stages as $migration_stage){
130
-			if ( $migration_stage instanceof EE_Data_Migration_Script_Stage ) {
127
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) {
128
+		$this->_migration_stages = (array) apply_filters('FHEE__'.get_class($this).'__construct__migration_stages', $this->_migration_stages);
129
+		foreach ($this->_migration_stages as $migration_stage) {
130
+			if ($migration_stage instanceof EE_Data_Migration_Script_Stage) {
131 131
 				$migration_stage->_construct_finalize($this);
132 132
 			}
133 133
 		}
134
-		parent::__construct( $table_manager, $table_analysis );
134
+		parent::__construct($table_manager, $table_analysis);
135 135
 	}
136 136
 
137 137
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 * Place to add hooks and filters for tweaking the migrations page, in order
141 141
 	 * to customize it
142 142
 	 */
143
-	public function migration_page_hooks(){
143
+	public function migration_page_hooks() {
144 144
 		//by default none are added because we normally like the default look of the migration page
145 145
 	}
146 146
 
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 	 * @param int|string $new_pk eg posts.ID
156 156
 	 * @return void
157 157
 	 */
158
-	public function set_mapping($old_table,$old_pk,$new_table,$new_pk){
158
+	public function set_mapping($old_table, $old_pk, $new_table, $new_pk) {
159 159
 		//make sure it has the needed keys
160
-		if( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])){
160
+		if ( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])) {
161 161
 			$this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table);
162 162
 		}
163 163
 		$this->_mappings[$old_table][$new_table][$old_pk] = $new_pk;
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
 	 * @param string $new_table with wpdb prefix (wp_). Eg: wp_posts
174 174
 	 * @return mixed the primary key on the new table
175 175
 	 */
176
-	public function get_mapping_new_pk($old_table,$old_pk,$new_table){
177
-		if( ! isset($this->_mappings[$old_table]) ||
178
-			! isset($this->_mappings[$old_table][$new_table])){
176
+	public function get_mapping_new_pk($old_table, $old_pk, $new_table) {
177
+		if ( ! isset($this->_mappings[$old_table]) ||
178
+			! isset($this->_mappings[$old_table][$new_table])) {
179 179
 			//try fetching the option
180 180
 			$this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table);
181 181
 		}
@@ -192,15 +192,15 @@  discard block
 block discarded – undo
192 192
 	 * @param mixed $new_pk
193 193
 	 * @return mixed
194 194
 	 */
195
-	public function get_mapping_old_pk($old_table,$new_table,$new_pk){
196
-		if( ! isset($this->_mappings[$old_table]) ||
197
-			! isset($this->_mappings[$old_table][$new_table])){
195
+	public function get_mapping_old_pk($old_table, $new_table, $new_pk) {
196
+		if ( ! isset($this->_mappings[$old_table]) ||
197
+			! isset($this->_mappings[$old_table][$new_table])) {
198 198
 			//try fetching the option
199 199
 			$this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table);
200 200
 		}
201
-		if(isset($this->_mappings[$old_table][$new_table])){
201
+		if (isset($this->_mappings[$old_table][$new_table])) {
202 202
 			$new_pk_to_old_pk = array_flip($this->_mappings[$old_table][$new_table]);
203
-			if(isset($new_pk_to_old_pk[$new_pk])){
203
+			if (isset($new_pk_to_old_pk[$new_pk])) {
204 204
 				return $new_pk_to_old_pk[$new_pk];
205 205
 			}
206 206
 		}
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 * @param string $new_table_name
216 216
 	 * @return array
217 217
 	 */
218
-	protected function _get_mapping_option($old_table_name,$new_table_name){
219
-		$option =  get_option($this->_get_mapping_option_name($old_table_name, $new_table_name),array());
218
+	protected function _get_mapping_option($old_table_name, $new_table_name) {
219
+		$option = get_option($this->_get_mapping_option_name($old_table_name, $new_table_name), array());
220 220
 		return $option;
221 221
 	}
222 222
 
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
 	 * @param array $mapping_array
230 230
 	 * @return boolean success of updating option
231 231
 	 */
232
-	protected function _set_mapping_option($old_table_name,$new_table_name,$mapping_array){
232
+	protected function _set_mapping_option($old_table_name, $new_table_name, $mapping_array) {
233 233
 //		echo "set mapping for $old_table_name $new_table_name".count($mapping_array)."<br>";
234
-		$success =  update_option($this->_get_mapping_option_name($old_table_name, $new_table_name),$mapping_array);
234
+		$success = update_option($this->_get_mapping_option_name($old_table_name, $new_table_name), $mapping_array);
235 235
 		return $success;
236 236
 	}
237 237
 
@@ -243,12 +243,12 @@  discard block
 block discarded – undo
243 243
 	 * @param string $new_table_name
244 244
 	 * @return string
245 245
 	 */
246
-	protected function _get_mapping_option_name($old_table_name,$new_table_name){
246
+	protected function _get_mapping_option_name($old_table_name, $new_table_name) {
247 247
 		global $wpdb;
248
-		$old_table_name_sans_wp = str_replace($wpdb->prefix,"",$old_table_name);
249
-		$new_table_name_sans_wp = str_replace($wpdb->prefix,"",$new_table_name);
248
+		$old_table_name_sans_wp = str_replace($wpdb->prefix, "", $old_table_name);
249
+		$new_table_name_sans_wp = str_replace($wpdb->prefix, "", $new_table_name);
250 250
 		$migrates_to = EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this));
251
-		return substr( EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix . $migrates_to [ 'slug' ] . '_' . $migrates_to[ 'version' ] . '_' . $old_table_name_sans_wp . '_' . $new_table_name_sans_wp, 0, 64 );
251
+		return substr(EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix.$migrates_to ['slug'].'_'.$migrates_to['version'].'_'.$old_table_name_sans_wp.'_'.$new_table_name_sans_wp, 0, 64);
252 252
 	}
253 253
 
254 254
 
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 	 * 99% until the function "migration_step" returns EE_Data_Migration_Script_Base::status_complete.
266 266
 	 * @return int
267 267
 	 */
268
-	protected function _count_records_to_migrate(){
268
+	protected function _count_records_to_migrate() {
269 269
 		$count = 0;
270
-		foreach($this->stages() as $stage){
271
-			$count+= $stage->count_records_to_migrate();
270
+		foreach ($this->stages() as $stage) {
271
+			$count += $stage->count_records_to_migrate();
272 272
 		}
273 273
 		return $count;
274 274
 	}
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 	 * by just setting a transient and updating it after each migration_step
281 281
 	 * @return int
282 282
 	 */
283
-	public function count_records_migrated(){
283
+	public function count_records_migrated() {
284 284
 		$count = 0;
285
-		foreach($this->stages() as $stage){
286
-			$count+= $stage->count_records_migrated();
285
+		foreach ($this->stages() as $stage) {
286
+			$count += $stage->count_records_migrated();
287 287
 		}
288 288
 		$this->_records_migrated = $count;
289 289
 		return $count;
@@ -297,24 +297,24 @@  discard block
 block discarded – undo
297 297
 	 * @throws EE_Error
298 298
 	 * @throws Exception
299 299
 	 */
300
-	public function migration_step($num_records_to_migrate_limit){
300
+	public function migration_step($num_records_to_migrate_limit) {
301 301
 		//reset the feedback message
302 302
 		$this->_feedback_message = '';
303 303
 		//if we haven't yet done the 1st schema changes, do them now. buffer any output
304 304
 		$this->_maybe_do_schema_changes(true);
305 305
 
306
-		$num_records_actually_migrated =0;
306
+		$num_records_actually_migrated = 0;
307 307
 		$records_migrated_per_stage = array();
308 308
 		//setup the 'stage' variable, which should hold the last run stage of the migration  (or none at all if nothing runs)
309 309
 		$stage = null;
310 310
 		//get the next stage that isn't complete
311
-		foreach($this->stages() as $stage){
312
-			if( $stage->get_status() == EE_Data_Migration_Manager::status_continue){
313
-				try{
311
+		foreach ($this->stages() as $stage) {
312
+			if ($stage->get_status() == EE_Data_Migration_Manager::status_continue) {
313
+				try {
314 314
 					$records_migrated_during_stage = $stage->migration_step($num_records_to_migrate_limit - $num_records_actually_migrated);
315 315
 					$num_records_actually_migrated += $records_migrated_during_stage;
316 316
 					$records_migrated_per_stage[$stage->pretty_name()] = $records_migrated_during_stage;
317
-				}catch(Exception $e){
317
+				} catch (Exception $e) {
318 318
 					//yes if we catch an exception here, we consider that migration stage borked.
319 319
 					$stage->set_status(EE_Data_Migration_Manager::status_fatal_error);
320 320
 					$this->set_status(EE_Data_Migration_Manager::status_fatal_error);
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 					throw $e;
323 323
 				}
324 324
 				//check that the migration stage didn't mark itself as having a fatal error
325
-				if($stage->is_broken()){
325
+				if ($stage->is_broken()) {
326 326
 					$this->set_broken();
327 327
 					throw new EE_Error($stage->get_last_error());
328 328
 				}
@@ -330,24 +330,24 @@  discard block
 block discarded – undo
330 330
 			//once we've migrated all the number we intended to (possibly from different stages), stop migrating
331 331
 			//or if we had a fatal error
332 332
 			//or if the current script stopped early- its not done, but it's done all it thinks we should do on this step
333
-			if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()){
333
+			if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()) {
334 334
 				break;
335 335
 			}
336 336
 		}
337 337
 		//check if we're all done this data migration...
338 338
 		//which is indicated by being done early AND the last stage claims to be done
339
-		if($stage == NULL){
339
+		if ($stage == NULL) {
340 340
 			//this migration script apparently has NO stages... which is super weird, but whatever
341 341
 			$this->set_completed();
342 342
 			$this->_maybe_do_schema_changes(false);
343
-		}else if( $num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()){
343
+		} else if ($num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()) {
344 344
 			//apparently we're done, because we couldn't migrate the number we intended to
345 345
 			$this->set_completed();
346 346
 			$this->_update_feedback_message(array_reverse($records_migrated_per_stage));
347 347
 			//do schema changes for after the migration now
348 348
 			//first double-check we haven't already done this
349 349
 			$this->_maybe_do_schema_changes(false);
350
-		}else{
350
+		} else {
351 351
 			//update feedback message, keeping in mind that we show them with the most recent at the top
352 352
 			$this->_update_feedback_message(array_reverse($records_migrated_per_stage));
353 353
 		}
@@ -361,12 +361,12 @@  discard block
 block discarded – undo
361 361
 	 * @param array $records_migrated_per_stage KEYS are pretty names for each stage; values are the count of records migrated from that stage
362 362
 	 * @return void
363 363
 	 */
364
-	private function _update_feedback_message($records_migrated_per_stage){
364
+	private function _update_feedback_message($records_migrated_per_stage) {
365 365
 		$feedback_message_array = array();
366
-		foreach($records_migrated_per_stage as $migration_stage_name => $num_records_migrated){
367
-			$feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"),$num_records_migrated,$migration_stage_name) ;
366
+		foreach ($records_migrated_per_stage as $migration_stage_name => $num_records_migrated) {
367
+			$feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"), $num_records_migrated, $migration_stage_name);
368 368
 		}
369
-		$this->_feedback_message .= implode("<br>",$feedback_message_array);
369
+		$this->_feedback_message .= implode("<br>", $feedback_message_array);
370 370
 	}
371 371
 
372 372
 
@@ -378,27 +378,27 @@  discard block
 block discarded – undo
378 378
 	 * @throws Exception
379 379
 	 * @return void
380 380
 	 */
381
-	private function _maybe_do_schema_changes($before = true){
381
+	private function _maybe_do_schema_changes($before = true) {
382 382
 		//so this property will be either _schema_changes_after_migration_ran or _schema_changes_before_migration_ran
383
-		$property_name = '_schema_changes_'. ($before ? 'before' : 'after').'_migration_ran';
384
-		if ( ! $this->{$property_name} ){
385
-			try{
383
+		$property_name = '_schema_changes_'.($before ? 'before' : 'after').'_migration_ran';
384
+		if ( ! $this->{$property_name} ) {
385
+			try {
386 386
 				ob_start();
387
-				if($before){
387
+				if ($before) {
388 388
 					$this->schema_changes_before_migration();
389
-				}else{
389
+				} else {
390 390
 					$this->schema_changes_after_migration();
391 391
 				}
392 392
 				$output = ob_get_contents();
393 393
 				ob_end_clean();
394
-			}catch(Exception $e){
394
+			} catch (Exception $e) {
395 395
 				$this->set_status(EE_Data_Migration_Manager::status_fatal_error);
396 396
 				throw $e;
397 397
 			}
398 398
 			//record that we've done these schema changes
399 399
 			$this->{$property_name} = true;
400 400
 			//if there were any warnings etc, record them as non-fatal errors
401
-			if( $output ){
401
+			if ($output) {
402 402
 				//there were some warnings
403 403
 				$this->_errors[] = $output;
404 404
 			}
@@ -425,9 +425,9 @@  discard block
 block discarded – undo
425 425
 	 * @param string $table_definition_sql
426 426
 	 * @param string $engine_string
427 427
 	 */
428
-	protected function _table_is_new_in_this_version($table_name,$table_definition_sql,$engine_string='ENGINE=InnoDB '){
428
+	protected function _table_is_new_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=InnoDB ') {
429 429
 //		EEH_Debug_Tools::instance()->start_timer( '_table_is_new_in_this_version_' . $table_name );
430
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  true ) );
430
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(true));
431 431
 //		EEH_Debug_Tools::instance()->stop_timer( '_table_is_new_in_this_version_' . $table_name  );
432 432
 	}
433 433
 
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
 	 * @param string $table_definition_sql
442 442
 	 * @param string $engine_string
443 443
 	 */
444
-	protected function _table_is_changed_in_this_version($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){
444
+	protected function _table_is_changed_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') {
445 445
 //		EEH_Debug_Tools::instance()->start_timer( '_table_is_changed_in_this_version' . $table_name );
446
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  false ) );
446
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false));
447 447
 //		EEH_Debug_Tools::instance()->stop_timer( '_table_is_changed_in_this_version' . $table_name  );
448 448
 	}
449 449
 
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	 * @param string $table_name
455 455
 	 * @return boolean
456 456
 	 */
457
-	protected function _old_table_exists( $table_name ) {
458
-		return $this->_get_table_analysis()->tableExists( $table_name );
457
+	protected function _old_table_exists($table_name) {
458
+		return $this->_get_table_analysis()->tableExists($table_name);
459 459
 	}
460 460
 
461 461
 
@@ -465,8 +465,8 @@  discard block
 block discarded – undo
465 465
 	 * @param string $table_name
466 466
 	 * @return boolean
467 467
 	 */
468
-	protected function _delete_table_if_empty( $table_name ) {
469
-		return EEH_Activation::delete_db_table_if_empty( $table_name );
468
+	protected function _delete_table_if_empty($table_name) {
469
+		return EEH_Activation::delete_db_table_if_empty($table_name);
470 470
 	}
471 471
 
472 472
 
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
 	 * @param string $table_definition_sql
486 486
 	 * @param string $engine_string
487 487
 	 */
488
-	protected function _table_should_exist_previously($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){
488
+	protected function _table_should_exist_previously($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') {
489 489
 //		EEH_Debug_Tools::instance()->start_timer( '_table_should_exist_previously' . $table_name );
490
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  false ) );
490
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false));
491 491
 //		EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name );
492 492
 	}
493 493
 
@@ -502,13 +502,13 @@  discard block
 block discarded – undo
502 502
 	 * @param string $table_definition_sql
503 503
 	 * @param string $engine_string
504 504
 	 */
505
-	protected function _table_has_not_changed_since_previous( $table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){
506
-		if( $this->_currently_migrating() ) {
505
+	protected function _table_has_not_changed_since_previous($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') {
506
+		if ($this->_currently_migrating()) {
507 507
 			//if we're doing a migration, and this table apparently already exists, then we don't need do anything right?
508 508
 //			EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name );
509 509
 			return;
510 510
 		}
511
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  false ) );
511
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false));
512 512
 	}
513 513
 
514 514
 	/**
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 	protected function _currently_migrating() {
519 519
 		//we want to know if we are currently performing a migration. We could just believe what was set on the _migrating property, but let's double-check (ie the script should apply and we should be in MM)
520 520
 		return $this->_migrating &&
521
-					$this->can_migrate_from_version( EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set() ) &&
521
+					$this->can_migrate_from_version(EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set()) &&
522 522
 					EE_Maintenance_Mode::instance()->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance;
523 523
 	}
524 524
 
@@ -529,17 +529,17 @@  discard block
 block discarded – undo
529 529
 	 * @param boolean $table_is_new
530 530
 	 * @return boolean
531 531
 	 */
532
-	protected function _pre_existing_table_should_be_dropped( $table_is_new ) {
533
-		if( $table_is_new ) {
534
-			if( $this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation  || $this->_currently_migrating() ){
532
+	protected function _pre_existing_table_should_be_dropped($table_is_new) {
533
+		if ($table_is_new) {
534
+			if ($this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation || $this->_currently_migrating()) {
535 535
 				return true;
536
-			}else{
536
+			} else {
537 537
 				return false;
538 538
 			}
539
-		}else{
540
-			if(in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(),array(EE_System::req_type_new_activation))){
539
+		} else {
540
+			if (in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(), array(EE_System::req_type_new_activation))) {
541 541
 				return true;
542
-			}else{
542
+			} else {
543 543
 				return false;
544 544
 			}
545 545
 		}
@@ -552,12 +552,12 @@  discard block
 block discarded – undo
552 552
 	 * @param string $engine_string
553 553
 	 * @param boolean $drop_pre_existing_tables
554 554
 	 */
555
-	private function _create_table_and_catch_errors( $table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE ){
556
-		try{
557
-			EEH_Activation::create_table($table_name,$table_definition_sql, $engine_string, $drop_pre_existing_tables);
558
-		}catch( EE_Error $e ) {
559
-			$message = $e->getMessage() . '<br>Stack Trace:' . $e->getTraceAsString();
560
-			$this->add_error( $message  );
555
+	private function _create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE) {
556
+		try {
557
+			EEH_Activation::create_table($table_name, $table_definition_sql, $engine_string, $drop_pre_existing_tables);
558
+		} catch (EE_Error $e) {
559
+			$message = $e->getMessage().'<br>Stack Trace:'.$e->getTraceAsString();
560
+			$this->add_error($message);
561 561
 			$this->_feedback_message .= $message;
562 562
 		}
563 563
 	}
@@ -569,15 +569,15 @@  discard block
 block discarded – undo
569 569
 	 * @return int one of EE_System::_req_type_* constants
570 570
 	 * @throws EE_Error
571 571
 	 */
572
-	private function _get_req_type_for_plugin_corresponding_to_this_dms(){
573
-		if($this->slug() == 'Core'){
572
+	private function _get_req_type_for_plugin_corresponding_to_this_dms() {
573
+		if ($this->slug() == 'Core') {
574 574
 			return EE_System::instance()->detect_req_type();
575
-		}else{//it must be for an addon
575
+		} else {//it must be for an addon
576 576
 			$addon_name = $this->slug();
577
-			if( EE_Registry::instance()->get_addon_by_name($addon_name)){
577
+			if (EE_Registry::instance()->get_addon_by_name($addon_name)) {
578 578
 				return EE_Registry::instance()->get_addon_by_name($addon_name)->detect_req_type();
579
-			}else{
580
-				throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"),$this->slug(),$addon_name,implode(",",array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ) ) ;
579
+			} else {
580
+				throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"), $this->slug(), $addon_name, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name()))));
581 581
 			}
582 582
 		}
583 583
 	}
@@ -588,13 +588,13 @@  discard block
 block discarded – undo
588 588
 	 * returns an array of strings describing errors by all the script's stages
589 589
 	 * @return array
590 590
 	 */
591
-	public function get_errors(){
591
+	public function get_errors() {
592 592
 		$all_errors = $this->_errors;
593
-		if( ! is_array($all_errors)){
593
+		if ( ! is_array($all_errors)) {
594 594
 			$all_errors = array();
595 595
 		}
596
-		foreach($this->stages() as $stage){
597
-			$all_errors = array_merge($stage->get_errors(),$all_errors);
596
+		foreach ($this->stages() as $stage) {
597
+			$all_errors = array_merge($stage->get_errors(), $all_errors);
598 598
 		}
599 599
 		return $all_errors;
600 600
 	}
@@ -605,8 +605,8 @@  discard block
 block discarded – undo
605 605
 	 * Indicates whether or not this migration script should continue
606 606
 	 * @return boolean
607 607
 	 */
608
-	public function can_continue(){
609
-		return in_array($this->get_status(),  EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script);
608
+	public function can_continue() {
609
+		return in_array($this->get_status(), EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script);
610 610
 	}
611 611
 
612 612
 
@@ -618,8 +618,8 @@  discard block
 block discarded – undo
618 618
 	 * get ordered by the indexes
619 619
 	 * @return EE_Data_Migration_Script_Stage[]
620 620
 	 */
621
-	protected function stages(){
622
-		$stages = apply_filters( 'FHEE__'.get_class($this).'__stages',$this->_migration_stages );
621
+	protected function stages() {
622
+		$stages = apply_filters('FHEE__'.get_class($this).'__stages', $this->_migration_stages);
623 623
 		ksort($stages);
624 624
 		return $stages;
625 625
 	}
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 	 * can be displayed to the user
632 632
 	 * @return string
633 633
 	 */
634
-	public function get_feedback_message(){
634
+	public function get_feedback_message() {
635 635
 		return $this->_feedback_message;
636 636
 	}
637 637
 
@@ -643,16 +643,16 @@  discard block
 block discarded – undo
643 643
 	 * possible that this class is defined when it goes to sleep, but NOT available when it
644 644
 	 * awakes (eg, this class is part of an addon that is deactivated at some point).
645 645
 	 */
646
-	public function properties_as_array(){
646
+	public function properties_as_array() {
647 647
 		$properties = parent::properties_as_array();
648 648
 		$properties['_migration_stages'] = array();
649
-		foreach($this->_migration_stages as $migration_stage_priority => $migration_stage_class){
649
+		foreach ($this->_migration_stages as $migration_stage_priority => $migration_stage_class) {
650 650
 			$properties['_migration_stages'][$migration_stage_priority] = $migration_stage_class->properties_as_array();
651 651
 		}
652 652
 		unset($properties['_mappings']);
653 653
 
654
-		foreach($this->_mappings as $old_table_name => $mapping_to_new_table){
655
-			foreach($mapping_to_new_table as $new_table_name => $mapping){
654
+		foreach ($this->_mappings as $old_table_name => $mapping_to_new_table) {
655
+			foreach ($mapping_to_new_table as $new_table_name => $mapping) {
656 656
 				$this->_set_mapping_option($old_table_name, $new_table_name, $mapping);
657 657
 			}
658 658
 		}
@@ -667,19 +667,19 @@  discard block
 block discarded – undo
667 667
 	 * @param array $array_of_properties like what's produced from properties_as_array() method
668 668
 	 * @return void
669 669
 	 */
670
-	public function instantiate_from_array_of_properties($array_of_properties){
670
+	public function instantiate_from_array_of_properties($array_of_properties) {
671 671
 		$stages_properties_arrays = $array_of_properties['_migration_stages'];
672 672
 		unset($array_of_properties['_migration_stages']);
673 673
 		unset($array_of_properties['class']);
674
-		foreach($array_of_properties as $property_name => $property_value){
674
+		foreach ($array_of_properties as $property_name => $property_value) {
675 675
 			$this->{$property_name} = $property_value;
676 676
 		}
677 677
 		//_migration_stages are already instantiated, but have only default data
678
-		foreach($this->_migration_stages as $stage){
679
-			$stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage),$stages_properties_arrays);
678
+		foreach ($this->_migration_stages as $stage) {
679
+			$stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage), $stages_properties_arrays);
680 680
 			//SO, if we found the stage data that was saved, use it. Otherwise, I guess the stage is new? (maybe added by
681 681
 			//an addon? Unlikely... not sure why it wouldn't exist, but if it doesn't just treat it like it was never started yet)
682
-			if($stage_data){
682
+			if ($stage_data) {
683 683
 				$stage->instantiate_from_array_of_properties($stage_data);
684 684
 			}
685 685
 		}
@@ -695,9 +695,9 @@  discard block
 block discarded – undo
695 695
 	 * @param array $migration_stage_data_arrays
696 696
 	 * @return null
697 697
 	 */
698
-	private function _find_migration_stage_data_with_classname($classname,$migration_stage_data_arrays){
699
-		foreach($migration_stage_data_arrays as $migration_stage_data_array){
700
-			if(isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname){
698
+	private function _find_migration_stage_data_with_classname($classname, $migration_stage_data_arrays) {
699
+		foreach ($migration_stage_data_arrays as $migration_stage_data_array) {
700
+			if (isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname) {
701 701
 				return $migration_stage_data_array;
702 702
 			}
703 703
 		}
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
 	 * @return array where the first key is the plugin's slug, the 2nd is the version of that plugin
714 714
 	 * that will be updated to. Eg array('Core','4.1.0')
715 715
 	 */
716
-	public final function migrates_to_version(){
717
-		return EE_Data_Migration_Manager::instance()->script_migrates_to_version( get_class( $this ) );
716
+	public final function migrates_to_version() {
717
+		return EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this));
718 718
 	}
719 719
 
720 720
 
@@ -726,10 +726,10 @@  discard block
 block discarded – undo
726 726
 	 * Or 'Core' for core (non-addon).
727 727
 	 * @return string
728 728
 	 */
729
-	public function slug(){
729
+	public function slug() {
730 730
 		$migrates_to_version_info = $this->migrates_to_version();
731 731
 		//the slug is the first part of the array
732
-		return $migrates_to_version_info[ 'slug' ];
732
+		return $migrates_to_version_info['slug'];
733 733
 	}
734 734
 
735 735
 
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
 	 * the database up so it can run), then you can set "A" to priority 3 or something.
744 744
 	 * @return int
745 745
 	 */
746
-	public function priority(){
746
+	public function priority() {
747 747
 		return $this->_priority;
748 748
 	}
749 749
 
@@ -756,18 +756,18 @@  discard block
 block discarded – undo
756 756
 	 * @param boolean $migrating
757 757
 	 * @return void
758 758
 	 */
759
-	public function set_migrating( $migrating = TRUE ){
759
+	public function set_migrating($migrating = TRUE) {
760 760
 		$this->_migrating = $migrating;
761 761
 	}
762 762
 
763 763
 	/**
764 764
 	 * Marks that we think this migration class can continue to migrate
765 765
 	 */
766
-	public function reattempt(){
766
+	public function reattempt() {
767 767
 		parent::reattempt();
768 768
 		//also, we want to reattempt any stages that were marked as borked
769
-		foreach( $this->stages() as $stage ) {
770
-			if( $stage->is_broken() ) {
769
+		foreach ($this->stages() as $stage) {
770
+			if ($stage->is_broken()) {
771 771
 				$stage->reattempt();
772 772
 			}
773 773
 		}
Please login to merge, or discard this patch.
core/db_models/EEM_Registration.model.php 2 patches
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -106,32 +106,32 @@  discard block
 block discarded – undo
106 106
 	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).
107 107
 	 *    Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
108 108
 	 */
109
-	protected function __construct( $timezone = null ) {
110
-		$this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true );
111
-		$this->singular_item = __('Registration','event_espresso');
112
-		$this->plural_item = __('Registrations','event_espresso');
109
+	protected function __construct($timezone = null) {
110
+		$this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
111
+		$this->singular_item = __('Registration', 'event_espresso');
112
+		$this->plural_item = __('Registrations', 'event_espresso');
113 113
 
114 114
 		$this->_tables = array(
115
-			'Registration'=>new EE_Primary_Table('esp_registration','REG_ID')
115
+			'Registration'=>new EE_Primary_Table('esp_registration', 'REG_ID')
116 116
 		);
117 117
 		$this->_fields = array(
118 118
 			'Registration'=>array(
119
-				'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID','event_espresso')),
120
-				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'),
121
-				'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID','event_espresso'), false, 0, 'Attendee'),
122
-				'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'),
123
-				'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso'), false, 0, 'Ticket'),
124
-				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'),
125
-				'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred','event_espresso'), false, EE_Datetime_Field::now, $timezone ),
126
-				'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total','event_espresso'), false, 0),
127
-				'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration','event_espresso'), false, 0),
128
-				'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration','event_espresso'), false, ''),
129
-				'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration','event_espresso'), false, ''),
130
-				'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration','event_espresso'), false, ''),
131
-				'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ','event_espresso'), true, 1),
132
-				'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group','event_espresso'), false, 1),
133
-				'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending','event_espresso'), false, false),
134
-				'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false )
119
+				'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')),
120
+				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'),
121
+				'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'),
122
+				'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'),
123
+				'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, 0, 'Ticket'),
124
+				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'),
125
+				'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone),
126
+				'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total', 'event_espresso'), false, 0),
127
+				'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration', 'event_espresso'), false, 0),
128
+				'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration', 'event_espresso'), false, ''),
129
+				'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration', 'event_espresso'), false, ''),
130
+				'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration', 'event_espresso'), false, ''),
131
+				'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ', 'event_espresso'), true, 1),
132
+				'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group', 'event_espresso'), false, 1),
133
+				'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false),
134
+				'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false)
135 135
 			)
136 136
 		);
137 137
 		$this->_model_relations = array(
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
 			'Answer'=>new EE_Has_Many_Relation(),
144 144
 			'Checkin'=>new EE_Has_Many_Relation(),
145 145
 			'Registration_Payment' => new EE_Has_Many_Relation(),
146
-			'Payment'=>new EE_HABTM_Relation( 'Registration_Payment' ),
147
-			'Message' => new EE_Has_Many_Any_Relation( false ) //allow deletes even if there are messages in the queue related
146
+			'Payment'=>new EE_HABTM_Relation('Registration_Payment'),
147
+			'Message' => new EE_Has_Many_Any_Relation(false) //allow deletes even if there are messages in the queue related
148 148
 		);
149 149
 		$this->_model_chain_to_wp_user = 'Event';
150 150
 
151
-		parent::__construct( $timezone );
151
+		parent::__construct($timezone);
152 152
 	}
153 153
 
154 154
 
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
 	 *		@param bool  $translated If true will return the values as singular localized strings
244 244
 	 *		@return array
245 245
 	 */
246
-	public static function reg_status_array( $exclude = array(), $translated = FALSE ) {
247
-		EEM_Registration::instance()->_get_registration_status_array( $exclude );
248
-		return $translated ? EEM_Status::instance()->localized_status( self::$_reg_status, FALSE, 'sentence') : self::$_reg_status;
246
+	public static function reg_status_array($exclude = array(), $translated = FALSE) {
247
+		EEM_Registration::instance()->_get_registration_status_array($exclude);
248
+		return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, FALSE, 'sentence') : self::$_reg_status;
249 249
 	}
250 250
 
251 251
 
@@ -256,18 +256,18 @@  discard block
 block discarded – undo
256 256
 	 * @param array $exclude
257 257
 	 * @return array
258 258
 	 */
259
-	private function _get_registration_status_array( $exclude = array() ) {
259
+	private function _get_registration_status_array($exclude = array()) {
260 260
 		//in the very rare circumstance that we are deleting a model's table's data
261 261
 		//and the table hasn't actually been created, this could have an error
262 262
 		/** @type WPDB $wpdb */
263 263
 		global $wpdb;
264
-		if( $this->_get_table_analysis()->tableExists( $wpdb->prefix . 'esp_status' ) ){
265
-			$SQL = 'SELECT STS_ID, STS_code FROM '. $wpdb->prefix . 'esp_status WHERE STS_type = "registration"';
266
-			$results = $wpdb->get_results( $SQL );
264
+		if ($this->_get_table_analysis()->tableExists($wpdb->prefix.'esp_status')) {
265
+			$SQL = 'SELECT STS_ID, STS_code FROM '.$wpdb->prefix.'esp_status WHERE STS_type = "registration"';
266
+			$results = $wpdb->get_results($SQL);
267 267
 			self::$_reg_status = array();
268
-			foreach ( $results as $status ) {
269
-				if ( ! in_array( $status->STS_ID, $exclude )) {
270
-					self::$_reg_status[ $status->STS_ID ] = $status->STS_code;
268
+			foreach ($results as $status) {
269
+				if ( ! in_array($status->STS_ID, $exclude)) {
270
+					self::$_reg_status[$status->STS_ID] = $status->STS_code;
271 271
 				}
272 272
 			}
273 273
 		}
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
 	 * @throws \EE_Error
281 281
 	 */
282 282
 	protected function _get_table_analysis() {
283
-		if( $this->_table_analysis instanceof TableAnalysis ) {
283
+		if ($this->_table_analysis instanceof TableAnalysis) {
284 284
 			return $this->_table_analysis;
285 285
 		} else {
286 286
 			throw new \EE_Error( 
287 287
 				sprintf( 
288
-					__( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), 
289
-					get_class( $this ) 
288
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'), 
289
+					get_class($this) 
290 290
 				) 
291 291
 			);
292 292
 		}
@@ -301,15 +301,15 @@  discard block
 block discarded – undo
301 301
 	 * @return array
302 302
 	 * @throws \EE_Error
303 303
 	 */
304
-	public function get_reg_months_and_years( $where_params ) {
304
+	public function get_reg_months_and_years($where_params) {
305 305
 		$query_params[0] = $where_params;
306 306
 		$query_params['group_by'] = array('reg_year', 'reg_month');
307
-		$query_params['order_by'] = array( 'REG_date' => 'DESC' );
307
+		$query_params['order_by'] = array('REG_date' => 'DESC');
308 308
 		$columns_to_select = array(
309 309
 			'reg_year' => array('YEAR(REG_date)', '%s'),
310 310
 			'reg_month' => array('MONTHNAME(REG_date)', '%s')
311 311
 			);
312
-		return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select );
312
+		return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
313 313
 	}
314 314
 
315 315
 
@@ -321,11 +321,11 @@  discard block
 block discarded – undo
321 321
 	* 		@param		int		$ATT_ID
322 322
 	*		@return 	EE_Registration[]
323 323
 	*/
324
-	public function get_all_registrations_for_attendee( $ATT_ID = 0 ) {
325
-		if ( ! $ATT_ID ) {
324
+	public function get_all_registrations_for_attendee($ATT_ID = 0) {
325
+		if ( ! $ATT_ID) {
326 326
 			return FALSE;
327 327
 		}
328
-		return $this->get_all( array( array( 'ATT_ID' => $ATT_ID )));
328
+		return $this->get_all(array(array('ATT_ID' => $ATT_ID)));
329 329
 	}
330 330
 
331 331
 
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	 * @param string $REG_url_link
337 337
 	 * @return EE_Registration
338 338
 	 */
339
-	public function get_registration_for_reg_url_link($REG_url_link){
340
-		if(!$REG_url_link){
339
+	public function get_registration_for_reg_url_link($REG_url_link) {
340
+		if ( ! $REG_url_link) {
341 341
 			return false;
342 342
 		}
343 343
 		return $this->get_one(array(array('REG_url_link'=>$REG_url_link)));
@@ -355,13 +355,13 @@  discard block
 block discarded – undo
355 355
 	* 		@param    int		$att_nmbr 	in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required
356 356
 	*		@return 		mixed		array on success, FALSE on fail
357 357
 	*/
358
-	public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) {
358
+	public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) {
359 359
 		return $this->get_one(array(
360 360
 			array(
361 361
 				'TXN_ID'=>$TXN_ID,
362 362
 				'ATT_ID'=>$ATT_ID
363 363
 			),
364
-			'limit'=>array( min( ( $att_nmbr-1 ), 0 ), 1 )
364
+			'limit'=>array(min(($att_nmbr - 1), 0), 1)
365 365
 		));
366 366
 	}
367 367
 
@@ -373,16 +373,16 @@  discard block
 block discarded – undo
373 373
 	 *		@param $period string which can be passed to php's strtotime function (eg "-1 month")
374 374
 	 *		@return stdClass[] with properties regDate and total
375 375
 	*/
376
-	public function get_registrations_per_day_report( $period = '-1 month' ) {
376
+	public function get_registrations_per_day_report($period = '-1 month') {
377 377
 
378
-		$sql_date = $this->convert_datetime_for_query( 'REG_date', date("Y-m-d H:i:s", strtotime($period) ), 'Y-m-d H:i:s', 'UTC' );
379
-		$where = array( 'REG_date' => array( '>=', $sql_date ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) );
378
+		$sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC');
379
+		$where = array('REG_date' => array('>=', $sql_date), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete));
380 380
 
381
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_day_report' ) ) {
381
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) {
382 382
 			$where['Event.EVT_wp_user'] = get_current_user_id();
383 383
 		}
384 384
 
385
-		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'REG_date' );
385
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date');
386 386
 
387 387
 		$results = $this->_get_all_wpdb_results(
388 388
 				array(
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 				),
393 393
 				OBJECT,
394 394
 				array(
395
-					'regDate'=>array( 'DATE(' . $query_interval . ')','%s'),
396
-					'total'=>array('count(REG_ID)','%d')
395
+					'regDate'=>array('DATE('.$query_interval.')', '%s'),
396
+					'total'=>array('count(REG_ID)', '%d')
397 397
 				));
398 398
 		return $results;
399 399
 	}
@@ -408,22 +408,22 @@  discard block
 block discarded – undo
408 408
 	 * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID
409 409
 	 *                    (i.e. RAP)
410 410
 	 */
411
-	public function get_registrations_per_day_and_per_status_report( $period = '-1 month' ) {
411
+	public function get_registrations_per_day_and_per_status_report($period = '-1 month') {
412 412
 		global $wpdb;
413
-		$registration_table = $wpdb->prefix . 'esp_registration';
413
+		$registration_table = $wpdb->prefix.'esp_registration';
414 414
 		$event_table = $wpdb->posts;
415
-		$sql_date = date("Y-m-d H:i:s", strtotime($period) );
415
+		$sql_date = date("Y-m-d H:i:s", strtotime($period));
416 416
 
417 417
 		//prepare the query interval for displaying offset
418
-		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'dates.REG_date' );
418
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date');
419 419
 
420 420
 		//inner date query
421 421
 		$inner_date_query = "SELECT DISTINCT REG_date from $registration_table ";
422 422
 		$inner_where = " WHERE";
423 423
 		//exclude events not authored by user if permissions in effect
424
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) {
424
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
425 425
 			$inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
426
-			$inner_where .= " post_author = " . get_current_user_id() . " AND";
426
+			$inner_where .= " post_author = ".get_current_user_id()." AND";
427 427
 		}
428 428
 		$inner_where .= " REG_date >= '$sql_date'";
429 429
 		$inner_date_query .= $inner_where;
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 		$select_parts = array();
436 436
 
437 437
 		//loop through registration stati to do parts for each status.
438
-		foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) {
439
-			if ( $STS_ID === EEM_Registration::status_id_incomplete ) {
438
+		foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
439
+			if ($STS_ID === EEM_Registration::status_id_incomplete) {
440 440
 				continue;
441 441
 			}
442 442
 			$select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
@@ -444,14 +444,14 @@  discard block
 block discarded – undo
444 444
 		}
445 445
 
446 446
 		//setup the selects
447
-		$select .= implode(', ', $select_parts );
447
+		$select .= implode(', ', $select_parts);
448 448
 		$select .= " FROM ($inner_date_query) AS dates LEFT JOIN ";
449 449
 
450 450
 		//setup the joins
451
-		$join .= implode( " LEFT JOIN ", $join_parts );
451
+		$join .= implode(" LEFT JOIN ", $join_parts);
452 452
 
453 453
 		//now let's put it all together
454
-		$query = $select . $join . ' GROUP BY Registration_REG_date';
454
+		$query = $select.$join.' GROUP BY Registration_REG_date';
455 455
 
456 456
 		//and execute it
457 457
 		$results = $wpdb->get_results(
@@ -472,23 +472,23 @@  discard block
 block discarded – undo
472 472
 	 * @param $period string which can be passed to php's strtotime function (eg "-1 month")
473 473
 	 *		@return stdClass[] each with properties event_name, reg_limit, and total
474 474
 	*/
475
-	public function get_registrations_per_event_report( $period = '-1 month' ) {
475
+	public function get_registrations_per_event_report($period = '-1 month') {
476 476
 
477
-		$date_sql = $this->convert_datetime_for_query( 'REG_date', date( "Y-m-d H:i:s", strtotime( $period )), 'Y-m-d H:i:s', 'UTC' );
478
-		$where = array( 'REG_date' => array( '>=', $date_sql ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) );
477
+		$date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC');
478
+		$where = array('REG_date' => array('>=', $date_sql), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete));
479 479
 
480
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) {
480
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
481 481
 			$where['Event.EVT_wp_user'] = get_current_user_id();
482 482
 		}
483 483
 		$results = $this->_get_all_wpdb_results(array(
484 484
 			$where,
485 485
 			'group_by'=>'Event.EVT_name',
486 486
 			'order_by'=>'Event.EVT_name',
487
-			'limit'=>array(0,24)),
487
+			'limit'=>array(0, 24)),
488 488
 			OBJECT,
489 489
 			array(
490
-				'event_name'=>array('Event_CPT.post_title','%s'),
491
-				'total'=>array('COUNT(REG_ID)','%s')
490
+				'event_name'=>array('Event_CPT.post_title', '%s'),
491
+				'total'=>array('COUNT(REG_ID)', '%s')
492 492
 			)
493 493
 		);
494 494
 
@@ -506,19 +506,19 @@  discard block
 block discarded – undo
506 506
 	 * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID
507 507
 	 *                    (i.e. RAP)
508 508
 	 */
509
-	public function get_registrations_per_event_and_per_status_report( $period = '-1 month' ) {
509
+	public function get_registrations_per_event_and_per_status_report($period = '-1 month') {
510 510
 		global $wpdb;
511
-		$registration_table = $wpdb->prefix . 'esp_registration';
511
+		$registration_table = $wpdb->prefix.'esp_registration';
512 512
 		$event_table = $wpdb->posts;
513
-		$sql_date = date("Y-m-d H:i:s", strtotime($period) );
513
+		$sql_date = date("Y-m-d H:i:s", strtotime($period));
514 514
 
515 515
 		//inner date query
516 516
 		$inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table ";
517 517
 		$inner_where = " WHERE";
518 518
 		//exclude events not authored by user if permissions in effect
519
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) {
519
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
520 520
 			$inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
521
-			$inner_where .= " post_author = " . get_current_user_id() . " AND";
521
+			$inner_where .= " post_author = ".get_current_user_id()." AND";
522 522
 		}
523 523
 		$inner_where .= " REG_date >= '$sql_date'";
524 524
 		$inner_date_query .= $inner_where;
@@ -530,8 +530,8 @@  discard block
 block discarded – undo
530 530
 		$select_parts = array();
531 531
 
532 532
 		//loop through registration stati to do parts for each status.
533
-		foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) {
534
-			if ( $STS_ID === EEM_Registration::status_id_incomplete ) {
533
+		foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
534
+			if ($STS_ID === EEM_Registration::status_id_incomplete) {
535 535
 				continue;
536 536
 			}
537 537
 			$select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
@@ -539,14 +539,14 @@  discard block
 block discarded – undo
539 539
 		}
540 540
 
541 541
 		//setup the selects
542
-		$select .= implode( ', ', $select_parts );
542
+		$select .= implode(', ', $select_parts);
543 543
 		$select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN ";
544 544
 
545 545
 		//setup remaining joins
546
-		$join .= implode( " LEFT JOIN ", $join_parts );
546
+		$join .= implode(" LEFT JOIN ", $join_parts);
547 547
 
548 548
 		//now put it all together
549
-		$query = $select . $join . ' GROUP BY Registration_Event';
549
+		$query = $select.$join.' GROUP BY Registration_Event';
550 550
 
551 551
 		//and execute
552 552
 		$results = $wpdb->get_results(
@@ -562,11 +562,11 @@  discard block
 block discarded – undo
562 562
 	 * @param int $TXN_ID
563 563
 	 * @return EE_Registration
564 564
 	 */
565
-	public function get_primary_registration_for_transaction_ID( $TXN_ID = 0){
566
-		if( ! $TXN_ID ){
565
+	public function get_primary_registration_for_transaction_ID($TXN_ID = 0) {
566
+		if ( ! $TXN_ID) {
567 567
 			return false;
568 568
 		}
569
-		return $this->get_one(array(array('TXN_ID'=>$TXN_ID,'REG_count'=>  EEM_Registration::PRIMARY_REGISTRANT_COUNT)));
569
+		return $this->get_one(array(array('TXN_ID'=>$TXN_ID, 'REG_count'=>  EEM_Registration::PRIMARY_REGISTRANT_COUNT)));
570 570
 	}
571 571
 
572 572
 
@@ -578,11 +578,11 @@  discard block
 block discarded – undo
578 578
 	 *		@param boolean $for_incomplete_payments
579 579
 	 *		@return int
580 580
 	 */
581
-	public function get_event_registration_count ( $EVT_ID, $for_incomplete_payments = FALSE ) {
581
+	public function get_event_registration_count($EVT_ID, $for_incomplete_payments = FALSE) {
582 582
 		// we only count approved registrations towards registration limits
583
-		$query_params = array( array( 'EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved ) );
584
-		if( $for_incomplete_payments ){
585
-			$query_params[0]['Transaction.STS_ID']=array('!=',  EEM_Transaction::complete_status_code);
583
+		$query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved));
584
+		if ($for_incomplete_payments) {
585
+			$query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code);
586 586
 		}
587 587
 
588 588
 		return $this->count($query_params);
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 		/** @type WPDB $wpdb */
599 599
 		global $wpdb;
600 600
 		return $wpdb->query(
601
-				'DELETE r FROM ' . $this->table() . ' r LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' );
601
+				'DELETE r FROM '.$this->table().' r LEFT JOIN '.EEM_Transaction::instance()->table().' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' );
602 602
 	}
603 603
 
604 604
 	/**
@@ -608,17 +608,17 @@  discard block
 block discarded – undo
608 608
 	 * @param boolean $checked_in whether to count registrations checked IN or OUT
609 609
 	 * @return int
610 610
 	 */
611
-	public function count_registrations_checked_into_datetime( $DTT_ID, $checked_in = true) {
611
+	public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) {
612 612
 		global $wpdb;
613 613
 		//subquery to get latest checkin
614 614
 		$query = $wpdb->prepare(
615 615
 			'SELECT '
616 616
 				. 'COUNT( DISTINCT checkins.REG_ID ) '
617
-			. 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN'
617
+			. 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN'
618 618
 				. '( SELECT '
619 619
 					. 'max( CHK_timestamp ) AS latest_checkin, '
620 620
 					. 'REG_ID AS REG_ID '
621
-				. 'FROM ' . EEM_Checkin::instance()->table() . ' '
621
+				. 'FROM '.EEM_Checkin::instance()->table().' '
622 622
 				. 'WHERE DTT_ID=%d '
623 623
 				. 'GROUP BY REG_ID'
624 624
 			. ') AS most_recent_checkin_per_reg '
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 			$DTT_ID,
630 630
 			$checked_in
631 631
 		);
632
-		return (int)$wpdb->get_var( $query );
632
+		return (int) $wpdb->get_var($query);
633 633
 	}
634 634
 
635 635
 	/**
@@ -639,18 +639,18 @@  discard block
 block discarded – undo
639 639
 	 * @param boolean $checked_in whether to count registrations checked IN or OUT
640 640
 	 * @return int
641 641
 	 */
642
-	public function count_registrations_checked_into_event( $EVT_ID, $checked_in = true ) {
642
+	public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) {
643 643
 		global $wpdb;
644 644
 		//subquery to get latest checkin
645 645
 		$query = $wpdb->prepare(
646 646
 			'SELECT '
647 647
 				. 'COUNT( DISTINCT checkins.REG_ID ) '
648
-			. 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN'
648
+			. 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN'
649 649
 				. '( SELECT '
650 650
 					. 'max( CHK_timestamp ) AS latest_checkin, '
651 651
 					. 'REG_ID AS REG_ID '
652
-				. 'FROM ' . EEM_Checkin::instance()->table() . ' AS c '
653
-				. 'INNER JOIN ' . EEM_Datetime::instance()->table() . ' AS d '
652
+				. 'FROM '.EEM_Checkin::instance()->table().' AS c '
653
+				. 'INNER JOIN '.EEM_Datetime::instance()->table().' AS d '
654 654
 				. 'ON c.DTT_ID=d.DTT_ID '
655 655
 				. 'WHERE d.EVT_ID=%d '
656 656
 				. 'GROUP BY REG_ID'
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 			$EVT_ID,
663 663
 			$checked_in
664 664
 		);
665
-		return (int)$wpdb->get_var( $query );
665
+		return (int) $wpdb->get_var($query);
666 666
 	}
667 667
 
668 668
 
@@ -677,15 +677,15 @@  discard block
 block discarded – undo
677 677
 	 * @param array $attendee_ids
678 678
 	 * @return EE_Registration[]
679 679
 	 */
680
-	public function get_latest_registration_for_each_of_given_contacts( $attendee_ids = array() ) {
680
+	public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array()) {
681 681
 		//first do a native wp_query to get the latest REG_ID's matching these attendees.
682 682
 		global $wpdb;
683
-		$registration_table = $wpdb->prefix . 'esp_registration';
683
+		$registration_table = $wpdb->prefix.'esp_registration';
684 684
 		$attendee_table = $wpdb->posts;
685
-		$attendee_ids = is_array( $attendee_ids )
686
-			? array_map( 'absint', $attendee_ids )
687
-			: array( (int) $attendee_ids );
688
-		$attendee_ids = implode( ',', $attendee_ids );
685
+		$attendee_ids = is_array($attendee_ids)
686
+			? array_map('absint', $attendee_ids)
687
+			: array((int) $attendee_ids);
688
+		$attendee_ids = implode(',', $attendee_ids);
689 689
 
690 690
 
691 691
 		//first we do a query to get the registration ids
@@ -710,24 +710,24 @@  discard block
 block discarded – undo
710 710
 			ARRAY_A
711 711
 		);
712 712
 
713
-		if ( empty( $registration_ids ) ) {
713
+		if (empty($registration_ids)) {
714 714
 			return array();
715 715
 		}
716 716
 
717 717
 		$ids_for_model_query = array();
718 718
 		//let's flatten the ids so they can be used in the model query.
719
-		foreach ( $registration_ids as $registration_id ) {
720
-			if ( isset( $registration_id['registration_id'] ) ) {
719
+		foreach ($registration_ids as $registration_id) {
720
+			if (isset($registration_id['registration_id'])) {
721 721
 				$ids_for_model_query[] = $registration_id['registration_id'];
722 722
 			}
723 723
 		}
724 724
 
725 725
 		//construct query
726 726
 		$_where = array(
727
-			'REG_ID' => array( 'IN', $ids_for_model_query )
727
+			'REG_ID' => array('IN', $ids_for_model_query)
728 728
 		);
729 729
 
730
-		return $this->get_all( array( $_where ) );
730
+		return $this->get_all(array($_where));
731 731
 	}
732 732
 
733 733
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
  * @subpackage plugin api, messages
6 6
  * @since           4.5.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register or deregister a new message template pack variation for the EE messages system.
Please login to merge, or discard this patch.
admin_pages/payments/Payments_Admin_Page_Init.core.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use EventEspresso\core\services\database\TableAnalysis;
3
-if (!defined('EVENT_ESPRESSO_VERSION') ){
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('NO direct script access allowed');
5 5
 }
6 6
 /**
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public function __construct() {
29 29
 		//define some page related constants
30
-		define( 'EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings' );
31
-		define( 'EE_PAYMENTS_ADMIN_URL', admin_url( 'admin.php?page=' . EE_PAYMENTS_PG_SLUG ));
32
-		define( 'EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES . 'payments' . DS );
33
-		define( 'EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN . 'templates' . DS );
34
-		define( 'EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'payments/assets/' );
35
-		$this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true );
30
+		define('EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings');
31
+		define('EE_PAYMENTS_ADMIN_URL', admin_url('admin.php?page='.EE_PAYMENTS_PG_SLUG));
32
+		define('EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES.'payments'.DS);
33
+		define('EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN.'templates'.DS);
34
+		define('EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL.'payments/assets/');
35
+		$this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
36 36
 		//check that there are active gateways on all admin page loads. but dont do it just yet
37 37
 //		echo "constructing payments admin page";die;
38
-		add_action('admin_notices',array($this,'check_payment_gateway_setup'));
38
+		add_action('admin_notices', array($this, 'check_payment_gateway_setup'));
39 39
 		parent::__construct();
40 40
 	}
41 41
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
59 59
 				'parent_slug'     => 'espresso_events',
60 60
 				'menu_slug'       => EE_PAYMENTS_PG_SLUG,
61
-				'menu_label'      => __( 'Payment Methods', 'event_espresso' ),
61
+				'menu_label'      => __('Payment Methods', 'event_espresso'),
62 62
 				'capability'      => 'ee_manage_gateways',
63 63
 				'admin_init_page' => $this,
64 64
 			)
@@ -72,25 +72,25 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @throws \EE_Error
74 74
 	 */
75
-	public function check_payment_gateway_setup(){
75
+	public function check_payment_gateway_setup() {
76 76
 		//ONLY do this check if models can query
77 77
 		//and avoid a bug where when we nuke EE4's data that this causes a fatal error
78 78
 		//because the tables are deleted just before this request runs. see https://events.codebasehq.com/projects/event-espresso/tickets/7539
79 79
 		if (
80 80
 			! EE_Maintenance_Mode::instance()->models_can_query()
81
-			|| ! $this->_get_table_analysis()->tableExists( EEM_Payment_Method::instance()->table() )
81
+			|| ! $this->_get_table_analysis()->tableExists(EEM_Payment_Method::instance()->table())
82 82
 		) {
83 83
 			return;
84 84
 		}
85 85
 
86 86
 
87 87
 		// ensure Payment_Method model is loaded
88
-		EE_Registry::instance()->load_model( 'Payment_Method' );
89
-		$actives = EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart );
90
-		if( $actives  < 1 ){
88
+		EE_Registry::instance()->load_model('Payment_Method');
89
+		$actives = EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart);
90
+		if ($actives < 1) {
91 91
 			$url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_PAYMENTS_ADMIN_URL);
92 92
 			echo '<div class="error">
93
-				 <p>'.  sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"),"<a href='$url'>","</a>").'</p>
93
+				 <p>'.  sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"), "<a href='$url'>", "</a>").'</p>
94 94
 			 </div>';
95 95
 		}
96 96
 	}
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
 	 * @throws \EE_Error
102 102
 	 */
103 103
 	protected function _get_table_analysis() {
104
-		if( $this->_table_analysis instanceof TableAnalysis ) {
104
+		if ($this->_table_analysis instanceof TableAnalysis) {
105 105
 			return $this->_table_analysis;
106 106
 		} else {
107 107
 			throw new \EE_Error( 
108 108
 				sprintf( 
109
-					__( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), 
110
-					get_class( $this ) 
109
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'), 
110
+					get_class($this) 
111 111
 				) 
112 112
 			);
113 113
 		}
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Spacing   +392 added lines, -392 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public static function instance() {
123 123
 		// check if class object is instantiated, and instantiated properly
124
-		if ( ! self::$_instance instanceof EE_Config ) {
124
+		if ( ! self::$_instance instanceof EE_Config) {
125 125
 			self::$_instance = new self();
126 126
 		}
127 127
 		return self::$_instance;
@@ -141,20 +141,20 @@  discard block
 block discarded – undo
141 141
 	 *                               site was put into maintenance mode)
142 142
 	 * @return EE_Config
143 143
 	 */
144
-	public static function reset( $hard_reset = false, $reinstantiate = true ) {
145
-		if ( $hard_reset ) {
144
+	public static function reset($hard_reset = false, $reinstantiate = true) {
145
+		if ($hard_reset) {
146 146
 			self::$_instance->_addon_option_names = array();
147 147
 			self::$_instance->_initialize_config();
148 148
 			self::$_instance->update_espresso_config();
149 149
 		}
150
-		if ( self::$_instance instanceof EE_Config ) {
150
+		if (self::$_instance instanceof EE_Config) {
151 151
 			self::$_instance->update_addon_option_names();
152 152
 		}
153 153
 		self::$_instance = null;
154 154
 		//we don't need to reset the static properties imo because those should
155 155
 		//only change when a module is added or removed. Currently we don't
156 156
 		//support removing a module during a request when it previously existed
157
-		if ( $reinstantiate ) {
157
+		if ($reinstantiate) {
158 158
 			return self::instance();
159 159
 		} else {
160 160
 			return null;
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 * @access    private
170 170
 	 */
171 171
 	private function __construct() {
172
-		do_action( 'AHEE__EE_Config__construct__begin', $this );
172
+		do_action('AHEE__EE_Config__construct__begin', $this);
173 173
 		// setup empty config classes
174 174
 		$this->_initialize_config();
175 175
 		// load existing EE site settings
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 		//  register shortcodes and modules
180 180
 		add_action(
181 181
 			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
182
-			array( $this, 'register_shortcodes_and_modules' ),
182
+			array($this, 'register_shortcodes_and_modules'),
183 183
 			999
184 184
 		);
185 185
 		//  initialize shortcodes and modules
186
-		add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'initialize_shortcodes_and_modules' ) );
186
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
187 187
 		// register widgets
188
-		add_action( 'widgets_init', array( $this, 'widgets_init' ), 10 );
188
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
189 189
 		// shutdown
190
-		add_action( 'shutdown', array( $this, 'shutdown' ), 10 );
190
+		add_action('shutdown', array($this, 'shutdown'), 10);
191 191
 		// construct__end hook
192
-		do_action( 'AHEE__EE_Config__construct__end', $this );
192
+		do_action('AHEE__EE_Config__construct__end', $this);
193 193
 		// hardcoded hack
194 194
 		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
195 195
 	}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 * @return string current theme set.
203 203
 	 */
204 204
 	public static function get_current_theme() {
205
-		return isset( self::$_instance->template_settings->current_espresso_theme )
205
+		return isset(self::$_instance->template_settings->current_espresso_theme)
206 206
 			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
207 207
 	}
208 208
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	private function _initialize_config() {
218 218
 		EE_Config::trim_log();
219 219
 		//set defaults
220
-		$this->_addon_option_names = get_option( EE_Config::ADDON_OPTION_NAMES, array() );
220
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
221 221
 		$this->addons = new stdClass();
222 222
 		// set _module_route_map
223 223
 		EE_Config::$_module_route_map = array();
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	private function _load_core_config() {
239 239
 		// load_core_config__start hook
240
-		do_action( 'AHEE__EE_Config___load_core_config__start', $this );
240
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
241 241
 		$espresso_config = $this->get_espresso_config();
242
-		foreach ( $espresso_config as $config => $settings ) {
242
+		foreach ($espresso_config as $config => $settings) {
243 243
 			// load_core_config__start hook
244 244
 			$settings = apply_filters(
245 245
 				'FHEE__EE_Config___load_core_config__config_settings',
@@ -247,22 +247,22 @@  discard block
 block discarded – undo
247 247
 				$config,
248 248
 				$this
249 249
 			);
250
-			if ( is_object( $settings ) && property_exists( $this, $config ) ) {
251
-				$this->{$config} = apply_filters( 'FHEE__EE_Config___load_core_config__' . $config, $settings );
250
+			if (is_object($settings) && property_exists($this, $config)) {
251
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
252 252
 				//call configs populate method to ensure any defaults are set for empty values.
253
-				if ( method_exists( $settings, 'populate' ) ) {
253
+				if (method_exists($settings, 'populate')) {
254 254
 					$this->{$config}->populate();
255 255
 				}
256
-				if ( method_exists( $settings, 'do_hooks' ) ) {
256
+				if (method_exists($settings, 'do_hooks')) {
257 257
 					$this->{$config}->do_hooks();
258 258
 				}
259 259
 			}
260 260
 		}
261
-		if ( apply_filters( 'FHEE__EE_Config___load_core_config__update_espresso_config', false ) ) {
261
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
262 262
 			$this->update_espresso_config();
263 263
 		}
264 264
 		// load_core_config__end hook
265
-		do_action( 'AHEE__EE_Config___load_core_config__end', $this );
265
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
266 266
 	}
267 267
 
268 268
 
@@ -277,23 +277,23 @@  discard block
 block discarded – undo
277 277
 		$this->core = $this->core instanceof EE_Core_Config
278 278
 			? $this->core
279 279
 			: new EE_Core_Config();
280
-		$this->core = apply_filters( 'FHEE__EE_Config___initialize_config__core', $this->core );
280
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
281 281
 		$this->organization = $this->organization instanceof EE_Organization_Config
282 282
 			? $this->organization
283 283
 			: new EE_Organization_Config();
284
-		$this->organization = apply_filters( 'FHEE__EE_Config___initialize_config__organization', $this->organization );
284
+		$this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', $this->organization);
285 285
 		$this->currency = $this->currency instanceof EE_Currency_Config
286 286
 			? $this->currency
287 287
 			: new EE_Currency_Config();
288
-		$this->currency = apply_filters( 'FHEE__EE_Config___initialize_config__currency', $this->currency );
288
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
289 289
 		$this->registration = $this->registration instanceof EE_Registration_Config
290 290
 			? $this->registration
291 291
 			: new EE_Registration_Config();
292
-		$this->registration = apply_filters( 'FHEE__EE_Config___initialize_config__registration', $this->registration );
292
+		$this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', $this->registration);
293 293
 		$this->admin = $this->admin instanceof EE_Admin_Config
294 294
 			? $this->admin
295 295
 			: new EE_Admin_Config();
296
-		$this->admin = apply_filters( 'FHEE__EE_Config___initialize_config__admin', $this->admin );
296
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
297 297
 		$this->template_settings = $this->template_settings instanceof EE_Template_Config
298 298
 			? $this->template_settings
299 299
 			: new EE_Template_Config();
@@ -304,15 +304,15 @@  discard block
 block discarded – undo
304 304
 		$this->map_settings = $this->map_settings instanceof EE_Map_Config
305 305
 			? $this->map_settings
306 306
 			: new EE_Map_Config();
307
-		$this->map_settings = apply_filters( 'FHEE__EE_Config___initialize_config__map_settings', $this->map_settings );
307
+		$this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', $this->map_settings);
308 308
 		$this->environment = $this->environment instanceof EE_Environment_Config
309 309
 			? $this->environment
310 310
 			: new EE_Environment_Config();
311
-		$this->environment = apply_filters( 'FHEE__EE_Config___initialize_config__environment', $this->environment );
311
+		$this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', $this->environment);
312 312
 		$this->gateway = $this->gateway instanceof EE_Gateway_Config
313 313
 			? $this->gateway
314 314
 			: new EE_Gateway_Config();
315
-		$this->gateway = apply_filters( 'FHEE__EE_Config___initialize_config__gateway', $this->gateway );
315
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
316 316
 	}
317 317
 
318 318
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 		// grab espresso configuration
328 328
 		return apply_filters(
329 329
 			'FHEE__EE_Config__get_espresso_config__CFG',
330
-			get_option( EE_Config::OPTION_NAME, array() )
330
+			get_option(EE_Config::OPTION_NAME, array())
331 331
 		);
332 332
 	}
333 333
 
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
 	 * @param        $old_value
342 342
 	 * @param        $value
343 343
 	 */
344
-	public function double_check_config_comparison( $option = '', $old_value, $value ) {
344
+	public function double_check_config_comparison($option = '', $old_value, $value) {
345 345
 		// make sure we're checking the ee config
346
-		if ( $option === EE_Config::OPTION_NAME ) {
346
+		if ($option === EE_Config::OPTION_NAME) {
347 347
 			// run a loose comparison of the old value against the new value for type and properties,
348 348
 			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
349
-			if ( $value != $old_value ) {
349
+			if ($value != $old_value) {
350 350
 				// if they are NOT the same, then remove the hook,
351 351
 				// which means the subsequent update results will be based solely on the update query results
352 352
 				// the reason we do this is because, as stated above,
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 				// the string it sees in the db looks the same as the new one it has been passed!!!
362 362
 				// This results in the query returning an "affected rows" value of ZERO,
363 363
 				// which gets returned immediately by WP update_option and looks like an error.
364
-				remove_action( 'update_option', array( $this, 'check_config_updated' ) );
364
+				remove_action('update_option', array($this, 'check_config_updated'));
365 365
 			}
366 366
 		}
367 367
 	}
@@ -375,11 +375,11 @@  discard block
 block discarded – undo
375 375
 	 */
376 376
 	protected function _reset_espresso_addon_config() {
377 377
 		$this->_addon_option_names = array();
378
-		foreach ( $this->addons as $addon_name => $addon_config_obj ) {
379
-			$addon_config_obj = maybe_unserialize( $addon_config_obj );
380
-			$config_class = get_class( $addon_config_obj );
381
-			if ( $addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class ) {
382
-				$this->update_config( 'addons', $addon_name, $addon_config_obj, false );
378
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
379
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
380
+			$config_class = get_class($addon_config_obj);
381
+			if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
382
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
383 383
 			}
384 384
 			$this->addons->{$addon_name} = null;
385 385
 		}
@@ -395,22 +395,22 @@  discard block
 block discarded – undo
395 395
 	 * @param   bool $add_error
396 396
 	 * @return   bool
397 397
 	 */
398
-	public function update_espresso_config( $add_success = false, $add_error = true ) {
398
+	public function update_espresso_config($add_success = false, $add_error = true) {
399 399
 		// don't allow config updates during WP heartbeats
400
-		if ( \EE_Registry::instance()->REQ->get( 'action', '' ) === 'heartbeat' ) {
400
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
401 401
 			return false;
402 402
 		}
403 403
 		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
404 404
 		//$clone = clone( self::$_instance );
405 405
 		//self::$_instance = NULL;
406
-		do_action( 'AHEE__EE_Config__update_espresso_config__begin', $this );
406
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
407 407
 		$this->_reset_espresso_addon_config();
408 408
 		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
409 409
 		// but BEFORE the actual update occurs
410
-		add_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1, 3 );
410
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
411 411
 		// now update "ee_config"
412
-		$saved = update_option( EE_Config::OPTION_NAME, $this );
413
-		EE_Config::log( EE_Config::OPTION_NAME );
412
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
413
+		EE_Config::log(EE_Config::OPTION_NAME);
414 414
 		// if not saved... check if the hook we just added still exists;
415 415
 		// if it does, it means one of two things:
416 416
 		// 		that update_option bailed at the ( $value === $old_value ) conditional,
@@ -421,17 +421,17 @@  discard block
 block discarded – undo
421 421
 		// but just means no update occurred, so don't display an error to the user.
422 422
 		// BUT... if update_option returns FALSE, AND the hook is missing,
423 423
 		// then it means that something truly went wrong
424
-		$saved = ! $saved ? has_action( 'update_option', array( $this, 'double_check_config_comparison' ) ) : $saved;
424
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
425 425
 		// remove our action since we don't want it in the system anymore
426
-		remove_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1 );
427
-		do_action( 'AHEE__EE_Config__update_espresso_config__end', $this, $saved );
426
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
427
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
428 428
 		//self::$_instance = $clone;
429 429
 		//unset( $clone );
430 430
 		// if config remains the same or was updated successfully
431
-		if ( $saved ) {
432
-			if ( $add_success ) {
431
+		if ($saved) {
432
+			if ($add_success) {
433 433
 				EE_Error::add_success(
434
-					__( 'The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso' ),
434
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
435 435
 					__FILE__,
436 436
 					__FUNCTION__,
437 437
 					__LINE__
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
 			}
440 440
 			return true;
441 441
 		} else {
442
-			if ( $add_error ) {
442
+			if ($add_error) {
443 443
 				EE_Error::add_error(
444
-					__( 'The Event Espresso Configuration Settings were not updated.', 'event_espresso' ),
444
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
445 445
 					__FILE__,
446 446
 					__FUNCTION__,
447 447
 					__LINE__
@@ -470,16 +470,16 @@  discard block
 block discarded – undo
470 470
 		$name = '',
471 471
 		$config_class = '',
472 472
 		$config_obj = null,
473
-		$tests_to_run = array( 1, 2, 3, 4, 5, 6, 7, 8 ),
473
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
474 474
 		$display_errors = true
475 475
 	) {
476 476
 		try {
477
-			foreach ( $tests_to_run as $test ) {
478
-				switch ( $test ) {
477
+			foreach ($tests_to_run as $test) {
478
+				switch ($test) {
479 479
 					// TEST #1 : check that section was set
480 480
 					case 1 :
481
-						if ( empty( $section ) ) {
482
-							if ( $display_errors ) {
481
+						if (empty($section)) {
482
+							if ($display_errors) {
483 483
 								throw new EE_Error(
484 484
 									sprintf(
485 485
 										__(
@@ -495,11 +495,11 @@  discard block
 block discarded – undo
495 495
 						break;
496 496
 					// TEST #2 : check that settings section exists
497 497
 					case 2 :
498
-						if ( ! isset( $this->{$section} ) ) {
499
-							if ( $display_errors ) {
498
+						if ( ! isset($this->{$section} )) {
499
+							if ($display_errors) {
500 500
 								throw new EE_Error(
501 501
 									sprintf(
502
-										__( 'The "%s" configuration section does not exist.', 'event_espresso' ),
502
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
503 503
 										$section
504 504
 									)
505 505
 								);
@@ -510,9 +510,9 @@  discard block
 block discarded – undo
510 510
 					// TEST #3 : check that section is the proper format
511 511
 					case 3 :
512 512
 						if (
513
-						! ( $this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass )
513
+						! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
514 514
 						) {
515
-							if ( $display_errors ) {
515
+							if ($display_errors) {
516 516
 								throw new EE_Error(
517 517
 									sprintf(
518 518
 										__(
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
 						break;
529 529
 					// TEST #4 : check that config section name has been set
530 530
 					case 4 :
531
-						if ( empty( $name ) ) {
532
-							if ( $display_errors ) {
531
+						if (empty($name)) {
532
+							if ($display_errors) {
533 533
 								throw new EE_Error(
534 534
 									__(
535 535
 										'No name has been provided for the specific configuration section.',
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
 						break;
543 543
 					// TEST #5 : check that a config class name has been set
544 544
 					case 5 :
545
-						if ( empty( $config_class ) ) {
546
-							if ( $display_errors ) {
545
+						if (empty($config_class)) {
546
+							if ($display_errors) {
547 547
 								throw new EE_Error(
548 548
 									__(
549 549
 										'No class name has been provided for the specific configuration section.',
@@ -556,8 +556,8 @@  discard block
 block discarded – undo
556 556
 						break;
557 557
 					// TEST #6 : verify config class is accessible
558 558
 					case 6 :
559
-						if ( ! class_exists( $config_class ) ) {
560
-							if ( $display_errors ) {
559
+						if ( ! class_exists($config_class)) {
560
+							if ($display_errors) {
561 561
 								throw new EE_Error(
562 562
 									sprintf(
563 563
 										__(
@@ -573,11 +573,11 @@  discard block
 block discarded – undo
573 573
 						break;
574 574
 					// TEST #7 : check that config has even been set
575 575
 					case 7 :
576
-						if ( ! isset( $this->{$section}->{$name} ) ) {
577
-							if ( $display_errors ) {
576
+						if ( ! isset($this->{$section}->{$name} )) {
577
+							if ($display_errors) {
578 578
 								throw new EE_Error(
579 579
 									sprintf(
580
-										__( 'No configuration has been set for "%1$s->%2$s".', 'event_espresso' ),
580
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
581 581
 										$section,
582 582
 										$name
583 583
 									)
@@ -586,13 +586,13 @@  discard block
 block discarded – undo
586 586
 							return false;
587 587
 						} else {
588 588
 							// and make sure it's not serialized
589
-							$this->{$section}->{$name} = maybe_unserialize( $this->{$section}->{$name} );
589
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name} );
590 590
 						}
591 591
 						break;
592 592
 					// TEST #8 : check that config is the requested type
593 593
 					case 8 :
594
-						if ( ! $this->{$section}->{$name} instanceof $config_class ) {
595
-							if ( $display_errors ) {
594
+						if ( ! $this->{$section}->{$name} instanceof $config_class) {
595
+							if ($display_errors) {
596 596
 								throw new EE_Error(
597 597
 									sprintf(
598 598
 										__(
@@ -610,12 +610,12 @@  discard block
 block discarded – undo
610 610
 						break;
611 611
 					// TEST #9 : verify config object
612 612
 					case 9 :
613
-						if ( ! $config_obj instanceof EE_Config_Base ) {
614
-							if ( $display_errors ) {
613
+						if ( ! $config_obj instanceof EE_Config_Base) {
614
+							if ($display_errors) {
615 615
 								throw new EE_Error(
616 616
 									sprintf(
617
-										__( 'The "%s" class is not an instance of EE_Config_Base.', 'event_espresso' ),
618
-										print_r( $config_obj, true )
617
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
618
+										print_r($config_obj, true)
619 619
 									)
620 620
 								);
621 621
 							}
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 						break;
625 625
 				}
626 626
 			}
627
-		} catch ( EE_Error $e ) {
627
+		} catch (EE_Error $e) {
628 628
 			$e->get_error();
629 629
 		}
630 630
 		// you have successfully run the gauntlet
@@ -641,8 +641,8 @@  discard block
 block discarded – undo
641 641
 	 * @param        string $name
642 642
 	 * @return        string
643 643
 	 */
644
-	private function _generate_config_option_name( $section = '', $name = '' ) {
645
-		return 'ee_config-' . strtolower( $section . '-' . str_replace( array( 'EE_', 'EED_' ), '', $name ) );
644
+	private function _generate_config_option_name($section = '', $name = '') {
645
+		return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
646 646
 	}
647 647
 
648 648
 
@@ -656,10 +656,10 @@  discard block
 block discarded – undo
656 656
 	 * @param    string $name
657 657
 	 * @return    string
658 658
 	 */
659
-	private function _set_config_class( $config_class = '', $name = '' ) {
660
-		return ! empty( $config_class )
659
+	private function _set_config_class($config_class = '', $name = '') {
660
+		return ! empty($config_class)
661 661
 			? $config_class
662
-			: str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $name ) ) ) . '_Config';
662
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
663 663
 	}
664 664
 
665 665
 
@@ -674,36 +674,36 @@  discard block
 block discarded – undo
674 674
 	 * @param    EE_Config_Base $config_obj
675 675
 	 * @return    EE_Config_Base
676 676
 	 */
677
-	public function set_config( $section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null ) {
677
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) {
678 678
 		// ensure config class is set to something
679
-		$config_class = $this->_set_config_class( $config_class, $name );
679
+		$config_class = $this->_set_config_class($config_class, $name);
680 680
 		// run tests 1-4, 6, and 7 to verify all config params are set and valid
681
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ) ) ) {
681
+		if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
682 682
 			return null;
683 683
 		}
684
-		$config_option_name = $this->_generate_config_option_name( $section, $name );
684
+		$config_option_name = $this->_generate_config_option_name($section, $name);
685 685
 		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
686
-		if ( ! isset( $this->_addon_option_names[ $config_option_name ] ) ) {
687
-			$this->_addon_option_names[ $config_option_name ] = $config_class;
686
+		if ( ! isset($this->_addon_option_names[$config_option_name])) {
687
+			$this->_addon_option_names[$config_option_name] = $config_class;
688 688
 			$this->update_addon_option_names();
689 689
 		}
690 690
 		// verify the incoming config object but suppress errors
691
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false ) ) {
691
+		if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
692 692
 			$config_obj = new $config_class();
693 693
 		}
694
-		if ( get_option( $config_option_name ) ) {
695
-			EE_Config::log( $config_option_name );
696
-			update_option( $config_option_name, $config_obj );
694
+		if (get_option($config_option_name)) {
695
+			EE_Config::log($config_option_name);
696
+			update_option($config_option_name, $config_obj);
697 697
 			$this->{$section}->{$name} = $config_obj;
698 698
 			return $this->{$section}->{$name};
699 699
 		} else {
700 700
 			// create a wp-option for this config
701
-			if ( add_option( $config_option_name, $config_obj, '', 'no' ) ) {
702
-				$this->{$section}->{$name} = maybe_unserialize( $config_obj );
701
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
702
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
703 703
 				return $this->{$section}->{$name};
704 704
 			} else {
705 705
 				EE_Error::add_error(
706
-					sprintf( __( 'The "%s" could not be saved to the database.', 'event_espresso' ), $config_class ),
706
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
707 707
 					__FILE__,
708 708
 					__FUNCTION__,
709 709
 					__LINE__
@@ -726,46 +726,46 @@  discard block
 block discarded – undo
726 726
 	 * @param    bool                  $throw_errors
727 727
 	 * @return    bool
728 728
 	 */
729
-	public function update_config( $section = '', $name = '', $config_obj = '', $throw_errors = true ) {
729
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) {
730 730
 		// don't allow config updates during WP heartbeats
731
-		if ( \EE_Registry::instance()->REQ->get( 'action', '' ) === 'heartbeat' ) {
731
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
732 732
 			return false;
733 733
 		}
734
-		$config_obj = maybe_unserialize( $config_obj );
734
+		$config_obj = maybe_unserialize($config_obj);
735 735
 		// get class name of the incoming object
736
-		$config_class = get_class( $config_obj );
736
+		$config_class = get_class($config_obj);
737 737
 		// run tests 1-5 and 9 to verify config
738 738
 		if ( ! $this->_verify_config_params(
739 739
 			$section,
740 740
 			$name,
741 741
 			$config_class,
742 742
 			$config_obj,
743
-			array( 1, 2, 3, 4, 7, 9 )
743
+			array(1, 2, 3, 4, 7, 9)
744 744
 		)
745 745
 		) {
746 746
 			return false;
747 747
 		}
748
-		$config_option_name = $this->_generate_config_option_name( $section, $name );
748
+		$config_option_name = $this->_generate_config_option_name($section, $name);
749 749
 		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
750
-		if ( ! isset( $this->_addon_option_names[ $config_option_name ] ) ) {
750
+		if ( ! isset($this->_addon_option_names[$config_option_name])) {
751 751
 			// save new config to db
752
-			if( $this->set_config( $section, $name, $config_class, $config_obj ) ) {
752
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
753 753
 				return true;
754 754
 			}
755 755
 		} else {
756 756
 			// first check if the record already exists
757
-			$existing_config = get_option( $config_option_name );
758
-			$config_obj = serialize( $config_obj );
757
+			$existing_config = get_option($config_option_name);
758
+			$config_obj = serialize($config_obj);
759 759
 			// just return if db record is already up to date (NOT type safe comparison)
760
-			if ( $existing_config == $config_obj ) {
760
+			if ($existing_config == $config_obj) {
761 761
 				$this->{$section}->{$name} = $config_obj;
762 762
 				return true;
763
-			} else if ( update_option( $config_option_name, $config_obj ) ) {
764
-				EE_Config::log( $config_option_name );
763
+			} else if (update_option($config_option_name, $config_obj)) {
764
+				EE_Config::log($config_option_name);
765 765
 				// update wp-option for this config class
766 766
 				$this->{$section}->{$name} = $config_obj;
767 767
 				return true;
768
-			} elseif ( $throw_errors ) {
768
+			} elseif ($throw_errors) {
769 769
 				EE_Error::add_error(
770 770
 					sprintf(
771 771
 						__(
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 							'event_espresso'
774 774
 						),
775 775
 						$config_class,
776
-						'EE_Config->' . $section . '->' . $name
776
+						'EE_Config->'.$section.'->'.$name
777 777
 					),
778 778
 					__FILE__,
779 779
 					__FUNCTION__,
@@ -795,34 +795,34 @@  discard block
 block discarded – undo
795 795
 	 * @param    string $config_class
796 796
 	 * @return    mixed EE_Config_Base | NULL
797 797
 	 */
798
-	public function get_config( $section = '', $name = '', $config_class = '' ) {
798
+	public function get_config($section = '', $name = '', $config_class = '') {
799 799
 		// ensure config class is set to something
800
-		$config_class = $this->_set_config_class( $config_class, $name );
800
+		$config_class = $this->_set_config_class($config_class, $name);
801 801
 		// run tests 1-4, 6 and 7 to verify that all params have been set
802
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ) ) ) {
802
+		if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
803 803
 			return null;
804 804
 		}
805 805
 		// now test if the requested config object exists, but suppress errors
806
-		if ( $this->_verify_config_params( $section, $name, $config_class, null, array( 7, 8 ), false ) ) {
806
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
807 807
 			// config already exists, so pass it back
808 808
 			return $this->{$section}->{$name};
809 809
 		}
810 810
 		// load config option from db if it exists
811
-		$config_obj = $this->get_config_option( $this->_generate_config_option_name( $section, $name ) );
811
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
812 812
 		// verify the newly retrieved config object, but suppress errors
813
-		if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false ) ) {
813
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
814 814
 			// config is good, so set it and pass it back
815 815
 			$this->{$section}->{$name} = $config_obj;
816 816
 			return $this->{$section}->{$name};
817 817
 		}
818 818
 		// oops! $config_obj is not already set and does not exist in the db, so create a new one
819
-		$config_obj = $this->set_config( $section, $name, $config_class );
819
+		$config_obj = $this->set_config($section, $name, $config_class);
820 820
 		// verify the newly created config object
821
-		if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ) ) ) {
821
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
822 822
 			return $this->{$section}->{$name};
823 823
 		} else {
824 824
 			EE_Error::add_error(
825
-				sprintf( __( 'The "%s" could not be retrieved from the database.', 'event_espresso' ), $config_class ),
825
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
826 826
 				__FILE__,
827 827
 				__FUNCTION__,
828 828
 				__LINE__
@@ -840,11 +840,11 @@  discard block
 block discarded – undo
840 840
 	 * @param    string $config_option_name
841 841
 	 * @return    mixed EE_Config_Base | FALSE
842 842
 	 */
843
-	public function get_config_option( $config_option_name = '' ) {
843
+	public function get_config_option($config_option_name = '') {
844 844
 		// retrieve the wp-option for this config class.
845
-		$config_option = maybe_unserialize( get_option( $config_option_name, array() ) );
846
-		if ( empty( $config_option ) ) {
847
-			EE_Config::log( $config_option_name . '-NOT-FOUND' );
845
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
846
+		if (empty($config_option)) {
847
+			EE_Config::log($config_option_name.'-NOT-FOUND');
848 848
 		}
849 849
 		return $config_option;
850 850
 	}
@@ -856,17 +856,17 @@  discard block
 block discarded – undo
856 856
 	 *
857 857
 	 * @param string $config_option_name
858 858
 	 */
859
-	public static function log( $config_option_name = '' ) {
860
-		if ( ! empty( $config_option_name ) ) {
861
-			$config_log = get_option( EE_Config::LOG_NAME, array() );
859
+	public static function log($config_option_name = '') {
860
+		if ( ! empty($config_option_name)) {
861
+			$config_log = get_option(EE_Config::LOG_NAME, array());
862 862
 			//copy incoming $_REQUEST and sanitize it so we can save it
863 863
 			$_request = $_REQUEST;
864
-			array_walk_recursive( $_request, 'sanitize_text_field' );
865
-			$config_log[ (string) microtime( true ) ] = array(
864
+			array_walk_recursive($_request, 'sanitize_text_field');
865
+			$config_log[(string) microtime(true)] = array(
866 866
 				'config_name' => $config_option_name,
867 867
 				'request'     => $_request,
868 868
 			);
869
-			update_option( EE_Config::LOG_NAME, $config_log );
869
+			update_option(EE_Config::LOG_NAME, $config_log);
870 870
 		}
871 871
 	}
872 872
 
@@ -877,12 +877,12 @@  discard block
 block discarded – undo
877 877
 	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
878 878
 	 */
879 879
 	public static function trim_log() {
880
-		$config_log = get_option( EE_Config::LOG_NAME, array() );
881
-		$log_length = count( $config_log );
882
-		if ( $log_length > EE_Config::LOG_LENGTH ) {
883
-			ksort( $config_log );
884
-			$config_log = array_slice( $config_log, $log_length - EE_Config::LOG_LENGTH, null, true );
885
-			update_option( EE_Config::LOG_NAME, $config_log );
880
+		$config_log = get_option(EE_Config::LOG_NAME, array());
881
+		$log_length = count($config_log);
882
+		if ($log_length > EE_Config::LOG_LENGTH) {
883
+			ksort($config_log);
884
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
885
+			update_option(EE_Config::LOG_NAME, $config_log);
886 886
 		}
887 887
 	}
888 888
 
@@ -897,14 +897,14 @@  discard block
 block discarded – undo
897 897
 	 * @return    string
898 898
 	 */
899 899
 	public static function get_page_for_posts() {
900
-		$page_for_posts = get_option( 'page_for_posts' );
901
-		if ( ! $page_for_posts ) {
900
+		$page_for_posts = get_option('page_for_posts');
901
+		if ( ! $page_for_posts) {
902 902
 			return 'posts';
903 903
 		}
904 904
 		/** @type WPDB $wpdb */
905 905
 		global $wpdb;
906 906
 		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
907
-		return $wpdb->get_var( $wpdb->prepare( $SQL, $page_for_posts ) );
907
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
908 908
 	}
909 909
 
910 910
 
@@ -960,17 +960,17 @@  discard block
 block discarded – undo
960 960
 			)
961 961
 		) {
962 962
 			// grab list of installed widgets
963
-			$widgets_to_register = glob( EE_WIDGETS . '*', GLOB_ONLYDIR );
963
+			$widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
964 964
 			// filter list of modules to register
965 965
 			$widgets_to_register = apply_filters(
966 966
 				'FHEE__EE_Config__register_widgets__widgets_to_register',
967 967
 				$widgets_to_register
968 968
 			);
969
-			if ( ! empty( $widgets_to_register ) ) {
969
+			if ( ! empty($widgets_to_register)) {
970 970
 				// cycle thru widget folders
971
-				foreach ( $widgets_to_register as $widget_path ) {
971
+				foreach ($widgets_to_register as $widget_path) {
972 972
 					// add to list of installed widget modules
973
-					EE_Config::register_ee_widget( $widget_path );
973
+					EE_Config::register_ee_widget($widget_path);
974 974
 				}
975 975
 			}
976 976
 			// filter list of installed modules
@@ -990,57 +990,57 @@  discard block
 block discarded – undo
990 990
 	 * @param    string $widget_path - full path up to and including widget folder
991 991
 	 * @return    void
992 992
 	 */
993
-	public static function register_ee_widget( $widget_path = null ) {
994
-		do_action( 'AHEE__EE_Config__register_widget__begin', $widget_path );
993
+	public static function register_ee_widget($widget_path = null) {
994
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
995 995
 		$widget_ext = '.widget.php';
996 996
 		// make all separators match
997
-		$widget_path = rtrim( str_replace( '/\\', DS, $widget_path ), DS );
997
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
998 998
 		// does the file path INCLUDE the actual file name as part of the path ?
999
-		if ( strpos( $widget_path, $widget_ext ) !== false ) {
999
+		if (strpos($widget_path, $widget_ext) !== false) {
1000 1000
 			// grab and shortcode file name from directory name and break apart at dots
1001
-			$file_name = explode( '.', basename( $widget_path ) );
1001
+			$file_name = explode('.', basename($widget_path));
1002 1002
 			// take first segment from file name pieces and remove class prefix if it exists
1003
-			$widget = strpos( $file_name[0], 'EEW_' ) === 0 ? substr( $file_name[0], 4 ) : $file_name[0];
1003
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1004 1004
 			// sanitize shortcode directory name
1005
-			$widget = sanitize_key( $widget );
1005
+			$widget = sanitize_key($widget);
1006 1006
 			// now we need to rebuild the shortcode path
1007
-			$widget_path = explode( DS, $widget_path );
1007
+			$widget_path = explode(DS, $widget_path);
1008 1008
 			// remove last segment
1009
-			array_pop( $widget_path );
1009
+			array_pop($widget_path);
1010 1010
 			// glue it back together
1011
-			$widget_path = implode( DS, $widget_path );
1011
+			$widget_path = implode(DS, $widget_path);
1012 1012
 		} else {
1013 1013
 			// grab and sanitize widget directory name
1014
-			$widget = sanitize_key( basename( $widget_path ) );
1014
+			$widget = sanitize_key(basename($widget_path));
1015 1015
 		}
1016 1016
 		// create classname from widget directory name
1017
-		$widget = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget ) ) );
1017
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1018 1018
 		// add class prefix
1019
-		$widget_class = 'EEW_' . $widget;
1019
+		$widget_class = 'EEW_'.$widget;
1020 1020
 		// does the widget exist ?
1021
-		if ( ! is_readable( $widget_path . DS . $widget_class . $widget_ext ) ) {
1021
+		if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) {
1022 1022
 			$msg = sprintf(
1023 1023
 				__(
1024 1024
 					'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',
1025 1025
 					'event_espresso'
1026 1026
 				),
1027 1027
 				$widget_class,
1028
-				$widget_path . DS . $widget_class . $widget_ext
1028
+				$widget_path.DS.$widget_class.$widget_ext
1029 1029
 			);
1030
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1030
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1031 1031
 			return;
1032 1032
 		}
1033 1033
 		// load the widget class file
1034
-		require_once( $widget_path . DS . $widget_class . $widget_ext );
1034
+		require_once($widget_path.DS.$widget_class.$widget_ext);
1035 1035
 		// verify that class exists
1036
-		if ( ! class_exists( $widget_class ) ) {
1037
-			$msg = sprintf( __( 'The requested %s widget class does not exist.', 'event_espresso' ), $widget_class );
1038
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1036
+		if ( ! class_exists($widget_class)) {
1037
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1038
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1039 1039
 			return;
1040 1040
 		}
1041
-		register_widget( $widget_class );
1041
+		register_widget($widget_class);
1042 1042
 		// add to array of registered widgets
1043
-		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1043
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext;
1044 1044
 	}
1045 1045
 
1046 1046
 
@@ -1053,17 +1053,17 @@  discard block
 block discarded – undo
1053 1053
 	 */
1054 1054
 	private function _register_shortcodes() {
1055 1055
 		// grab list of installed shortcodes
1056
-		$shortcodes_to_register = glob( EE_SHORTCODES . '*', GLOB_ONLYDIR );
1056
+		$shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR);
1057 1057
 		// filter list of modules to register
1058 1058
 		$shortcodes_to_register = apply_filters(
1059 1059
 			'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
1060 1060
 			$shortcodes_to_register
1061 1061
 		);
1062
-		if ( ! empty( $shortcodes_to_register ) ) {
1062
+		if ( ! empty($shortcodes_to_register)) {
1063 1063
 			// cycle thru shortcode folders
1064
-			foreach ( $shortcodes_to_register as $shortcode_path ) {
1064
+			foreach ($shortcodes_to_register as $shortcode_path) {
1065 1065
 				// add to list of installed shortcode modules
1066
-				EE_Config::register_shortcode( $shortcode_path );
1066
+				EE_Config::register_shortcode($shortcode_path);
1067 1067
 			}
1068 1068
 		}
1069 1069
 		// filter list of installed modules
@@ -1082,64 +1082,64 @@  discard block
 block discarded – undo
1082 1082
 	 * @param    string $shortcode_path - full path up to and including shortcode folder
1083 1083
 	 * @return    bool
1084 1084
 	 */
1085
-	public static function register_shortcode( $shortcode_path = null ) {
1086
-		do_action( 'AHEE__EE_Config__register_shortcode__begin', $shortcode_path );
1085
+	public static function register_shortcode($shortcode_path = null) {
1086
+		do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
1087 1087
 		$shortcode_ext = '.shortcode.php';
1088 1088
 		// make all separators match
1089
-		$shortcode_path = str_replace( array( '\\', '/' ), DS, $shortcode_path );
1089
+		$shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path);
1090 1090
 		// does the file path INCLUDE the actual file name as part of the path ?
1091
-		if ( strpos( $shortcode_path, $shortcode_ext ) !== false ) {
1091
+		if (strpos($shortcode_path, $shortcode_ext) !== false) {
1092 1092
 			// grab shortcode file name from directory name and break apart at dots
1093
-			$shortcode_file = explode( '.', basename( $shortcode_path ) );
1093
+			$shortcode_file = explode('.', basename($shortcode_path));
1094 1094
 			// take first segment from file name pieces and remove class prefix if it exists
1095
-			$shortcode = strpos( $shortcode_file[0], 'EES_' ) === 0
1096
-				? substr( $shortcode_file[0], 4 )
1095
+			$shortcode = strpos($shortcode_file[0], 'EES_') === 0
1096
+				? substr($shortcode_file[0], 4)
1097 1097
 				: $shortcode_file[0];
1098 1098
 			// sanitize shortcode directory name
1099
-			$shortcode = sanitize_key( $shortcode );
1099
+			$shortcode = sanitize_key($shortcode);
1100 1100
 			// now we need to rebuild the shortcode path
1101
-			$shortcode_path = explode( DS, $shortcode_path );
1101
+			$shortcode_path = explode(DS, $shortcode_path);
1102 1102
 			// remove last segment
1103
-			array_pop( $shortcode_path );
1103
+			array_pop($shortcode_path);
1104 1104
 			// glue it back together
1105
-			$shortcode_path = implode( DS, $shortcode_path ) . DS;
1105
+			$shortcode_path = implode(DS, $shortcode_path).DS;
1106 1106
 		} else {
1107 1107
 			// we need to generate the filename based off of the folder name
1108 1108
 			// grab and sanitize shortcode directory name
1109
-			$shortcode = sanitize_key( basename( $shortcode_path ) );
1110
-			$shortcode_path = rtrim( $shortcode_path, DS ) . DS;
1109
+			$shortcode = sanitize_key(basename($shortcode_path));
1110
+			$shortcode_path = rtrim($shortcode_path, DS).DS;
1111 1111
 		}
1112 1112
 		// create classname from shortcode directory or file name
1113
-		$shortcode = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $shortcode ) ) );
1113
+		$shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
1114 1114
 		// add class prefix
1115
-		$shortcode_class = 'EES_' . $shortcode;
1115
+		$shortcode_class = 'EES_'.$shortcode;
1116 1116
 		// does the shortcode exist ?
1117
-		if ( ! is_readable( $shortcode_path . DS . $shortcode_class . $shortcode_ext ) ) {
1117
+		if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) {
1118 1118
 			$msg = sprintf(
1119 1119
 				__(
1120 1120
 					'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s',
1121 1121
 					'event_espresso'
1122 1122
 				),
1123 1123
 				$shortcode_class,
1124
-				$shortcode_path . DS . $shortcode_class . $shortcode_ext
1124
+				$shortcode_path.DS.$shortcode_class.$shortcode_ext
1125 1125
 			);
1126
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1126
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1127 1127
 			return false;
1128 1128
 		}
1129 1129
 		// load the shortcode class file
1130
-		require_once( $shortcode_path . $shortcode_class . $shortcode_ext );
1130
+		require_once($shortcode_path.$shortcode_class.$shortcode_ext);
1131 1131
 		// verify that class exists
1132
-		if ( ! class_exists( $shortcode_class ) ) {
1132
+		if ( ! class_exists($shortcode_class)) {
1133 1133
 			$msg = sprintf(
1134
-				__( 'The requested %s shortcode class does not exist.', 'event_espresso' ),
1134
+				__('The requested %s shortcode class does not exist.', 'event_espresso'),
1135 1135
 				$shortcode_class
1136 1136
 			);
1137
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1137
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1138 1138
 			return false;
1139 1139
 		}
1140
-		$shortcode = strtoupper( $shortcode );
1140
+		$shortcode = strtoupper($shortcode);
1141 1141
 		// add to array of registered shortcodes
1142
-		EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
1142
+		EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext;
1143 1143
 		return true;
1144 1144
 	}
1145 1145
 
@@ -1153,22 +1153,22 @@  discard block
 block discarded – undo
1153 1153
 	 */
1154 1154
 	private function _register_modules() {
1155 1155
 		// grab list of installed modules
1156
-		$modules_to_register = glob( EE_MODULES . '*', GLOB_ONLYDIR );
1156
+		$modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1157 1157
 		// filter list of modules to register
1158 1158
 		$modules_to_register = apply_filters(
1159 1159
 			'FHEE__EE_Config__register_modules__modules_to_register',
1160 1160
 			$modules_to_register
1161 1161
 		);
1162
-		if ( ! empty( $modules_to_register ) ) {
1162
+		if ( ! empty($modules_to_register)) {
1163 1163
 			// loop through folders
1164
-			foreach ( $modules_to_register as $module_path ) {
1164
+			foreach ($modules_to_register as $module_path) {
1165 1165
 				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1166 1166
 				if (
1167
-					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1168
-					&& $module_path !== EE_MODULES . 'gateways'
1167
+					$module_path !== EE_MODULES.'zzz-copy-this-module-template'
1168
+					&& $module_path !== EE_MODULES.'gateways'
1169 1169
 				) {
1170 1170
 					// add to list of installed modules
1171
-					EE_Config::register_module( $module_path );
1171
+					EE_Config::register_module($module_path);
1172 1172
 				}
1173 1173
 			}
1174 1174
 		}
@@ -1188,39 +1188,39 @@  discard block
 block discarded – undo
1188 1188
 	 * @param    string $module_path - full path up to and including module folder
1189 1189
 	 * @return    bool
1190 1190
 	 */
1191
-	public static function register_module( $module_path = null ) {
1192
-		do_action( 'AHEE__EE_Config__register_module__begin', $module_path );
1191
+	public static function register_module($module_path = null) {
1192
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1193 1193
 		$module_ext = '.module.php';
1194 1194
 		// make all separators match
1195
-		$module_path = str_replace( array( '\\', '/' ), DS, $module_path );
1195
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1196 1196
 		// does the file path INCLUDE the actual file name as part of the path ?
1197
-		if ( strpos( $module_path, $module_ext ) !== false ) {
1197
+		if (strpos($module_path, $module_ext) !== false) {
1198 1198
 			// grab and shortcode file name from directory name and break apart at dots
1199
-			$module_file = explode( '.', basename( $module_path ) );
1199
+			$module_file = explode('.', basename($module_path));
1200 1200
 			// now we need to rebuild the shortcode path
1201
-			$module_path = explode( DS, $module_path );
1201
+			$module_path = explode(DS, $module_path);
1202 1202
 			// remove last segment
1203
-			array_pop( $module_path );
1203
+			array_pop($module_path);
1204 1204
 			// glue it back together
1205
-			$module_path = implode( DS, $module_path ) . DS;
1205
+			$module_path = implode(DS, $module_path).DS;
1206 1206
 			// take first segment from file name pieces and sanitize it
1207
-			$module = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $module_file[0] );
1207
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1208 1208
 			// ensure class prefix is added
1209
-			$module_class = strpos( $module, 'EED_' ) !== 0 ? 'EED_' . $module : $module;
1209
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1210 1210
 		} else {
1211 1211
 			// we need to generate the filename based off of the folder name
1212 1212
 			// grab and sanitize module name
1213
-			$module = strtolower( basename( $module_path ) );
1214
-			$module = preg_replace( '/[^a-z0-9_\-]/', '', $module );
1213
+			$module = strtolower(basename($module_path));
1214
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1215 1215
 			// like trailingslashit()
1216
-			$module_path = rtrim( $module_path, DS ) . DS;
1216
+			$module_path = rtrim($module_path, DS).DS;
1217 1217
 			// create classname from module directory name
1218
-			$module = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $module ) ) );
1218
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1219 1219
 			// add class prefix
1220
-			$module_class = 'EED_' . $module;
1220
+			$module_class = 'EED_'.$module;
1221 1221
 		}
1222 1222
 		// does the module exist ?
1223
-		if ( ! is_readable( $module_path . DS . $module_class . $module_ext ) ) {
1223
+		if ( ! is_readable($module_path.DS.$module_class.$module_ext)) {
1224 1224
 			$msg = sprintf(
1225 1225
 				__(
1226 1226
 					'The requested %s module file could not be found or is not readable due to file permissions.',
@@ -1228,19 +1228,19 @@  discard block
 block discarded – undo
1228 1228
 				),
1229 1229
 				$module
1230 1230
 			);
1231
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1231
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1232 1232
 			return false;
1233 1233
 		}
1234 1234
 		// load the module class file
1235
-		require_once( $module_path . $module_class . $module_ext );
1235
+		require_once($module_path.$module_class.$module_ext);
1236 1236
 		// verify that class exists
1237
-		if ( ! class_exists( $module_class ) ) {
1238
-			$msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class );
1239
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1237
+		if ( ! class_exists($module_class)) {
1238
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1239
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1240 1240
 			return false;
1241 1241
 		}
1242 1242
 		// add to array of registered modules
1243
-		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1243
+		EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1244 1244
 		do_action(
1245 1245
 			'AHEE__EE_Config__register_module__complete',
1246 1246
 			$module_class,
@@ -1260,26 +1260,26 @@  discard block
 block discarded – undo
1260 1260
 	 */
1261 1261
 	private function _initialize_shortcodes() {
1262 1262
 		// cycle thru shortcode folders
1263
-		foreach ( EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path ) {
1263
+		foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) {
1264 1264
 			// add class prefix
1265
-			$shortcode_class = 'EES_' . $shortcode;
1265
+			$shortcode_class = 'EES_'.$shortcode;
1266 1266
 			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1267 1267
 			// which set hooks ?
1268
-			if ( is_admin() ) {
1268
+			if (is_admin()) {
1269 1269
 				// fire immediately
1270
-				call_user_func( array( $shortcode_class, 'set_hooks_admin' ) );
1270
+				call_user_func(array($shortcode_class, 'set_hooks_admin'));
1271 1271
 			} else {
1272 1272
 				// delay until other systems are online
1273 1273
 				add_action(
1274 1274
 					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1275
-					array( $shortcode_class, 'set_hooks' )
1275
+					array($shortcode_class, 'set_hooks')
1276 1276
 				);
1277 1277
 				// convert classname to UPPERCASE and create WP shortcode.
1278
-				$shortcode_tag = strtoupper( $shortcode );
1278
+				$shortcode_tag = strtoupper($shortcode);
1279 1279
 				// but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor'
1280
-				if ( ! shortcode_exists( $shortcode_tag ) ) {
1280
+				if ( ! shortcode_exists($shortcode_tag)) {
1281 1281
 					// NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes()
1282
-					add_shortcode( $shortcode_tag, array( $shortcode_class, 'fallback_shortcode_processor' ) );
1282
+					add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
1283 1283
 				}
1284 1284
 			}
1285 1285
 		}
@@ -1296,17 +1296,17 @@  discard block
 block discarded – undo
1296 1296
 	 */
1297 1297
 	private function _initialize_modules() {
1298 1298
 		// cycle thru shortcode folders
1299
-		foreach ( EE_Registry::instance()->modules as $module_class => $module_path ) {
1299
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1300 1300
 			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1301 1301
 			// which set hooks ?
1302
-			if ( is_admin() ) {
1302
+			if (is_admin()) {
1303 1303
 				// fire immediately
1304
-				call_user_func( array( $module_class, 'set_hooks_admin' ) );
1304
+				call_user_func(array($module_class, 'set_hooks_admin'));
1305 1305
 			} else {
1306 1306
 				// delay until other systems are online
1307 1307
 				add_action(
1308 1308
 					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1309
-					array( $module_class, 'set_hooks' )
1309
+					array($module_class, 'set_hooks')
1310 1310
 				);
1311 1311
 			}
1312 1312
 		}
@@ -1324,29 +1324,29 @@  discard block
 block discarded – undo
1324 1324
 	 * @param    string $key         - url param key indicating a route is being called
1325 1325
 	 * @return    bool
1326 1326
 	 */
1327
-	public static function register_route( $route = null, $module = null, $method_name = null, $key = 'ee' ) {
1328
-		do_action( 'AHEE__EE_Config__register_route__begin', $route, $module, $method_name );
1329
-		$module = str_replace( 'EED_', '', $module );
1330
-		$module_class = 'EED_' . $module;
1331
-		if ( ! isset( EE_Registry::instance()->modules->{$module_class} ) ) {
1332
-			$msg = sprintf( __( 'The module %s has not been registered.', 'event_espresso' ), $module );
1333
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1327
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') {
1328
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1329
+		$module = str_replace('EED_', '', $module);
1330
+		$module_class = 'EED_'.$module;
1331
+		if ( ! isset(EE_Registry::instance()->modules->{$module_class} )) {
1332
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1333
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1334 1334
 			return false;
1335 1335
 		}
1336
-		if ( empty( $route ) ) {
1337
-			$msg = sprintf( __( 'No route has been supplied.', 'event_espresso' ), $route );
1338
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1336
+		if (empty($route)) {
1337
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1338
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1339 1339
 			return false;
1340 1340
 		}
1341
-		if ( ! method_exists( 'EED_' . $module, $method_name ) ) {
1341
+		if ( ! method_exists('EED_'.$module, $method_name)) {
1342 1342
 			$msg = sprintf(
1343
-				__( 'A valid class method for the %s route has not been supplied.', 'event_espresso' ),
1343
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1344 1344
 				$route
1345 1345
 			);
1346
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1346
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1347 1347
 			return false;
1348 1348
 		}
1349
-		EE_Config::$_module_route_map[ $key ][ $route ] = array( 'EED_' . $module, $method_name );
1349
+		EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name);
1350 1350
 		return true;
1351 1351
 	}
1352 1352
 
@@ -1360,11 +1360,11 @@  discard block
 block discarded – undo
1360 1360
 	 * @param    string $key   - url param key indicating a route is being called
1361 1361
 	 * @return    string
1362 1362
 	 */
1363
-	public static function get_route( $route = null, $key = 'ee' ) {
1364
-		do_action( 'AHEE__EE_Config__get_route__begin', $route );
1365
-		$route = (string) apply_filters( 'FHEE__EE_Config__get_route', $route );
1366
-		if ( isset( EE_Config::$_module_route_map[ $key ][ $route ] ) ) {
1367
-			return EE_Config::$_module_route_map[ $key ][ $route ];
1363
+	public static function get_route($route = null, $key = 'ee') {
1364
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1365
+		$route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1366
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1367
+			return EE_Config::$_module_route_map[$key][$route];
1368 1368
 		}
1369 1369
 		return null;
1370 1370
 	}
@@ -1394,49 +1394,49 @@  discard block
 block discarded – undo
1394 1394
 	 * @param    string       $key     - url param key indicating a route is being called
1395 1395
 	 * @return    bool
1396 1396
 	 */
1397
-	public static function register_forward( $route = null, $status = 0, $forward = null, $key = 'ee' ) {
1398
-		do_action( 'AHEE__EE_Config__register_forward', $route, $status, $forward );
1399
-		if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route ) ) {
1397
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') {
1398
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1399
+		if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1400 1400
 			$msg = sprintf(
1401
-				__( 'The module route %s for this forward has not been registered.', 'event_espresso' ),
1401
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1402 1402
 				$route
1403 1403
 			);
1404
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1404
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1405 1405
 			return false;
1406 1406
 		}
1407
-		if ( empty( $forward ) ) {
1408
-			$msg = sprintf( __( 'No forwarding route has been supplied.', 'event_espresso' ), $route );
1409
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1407
+		if (empty($forward)) {
1408
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1409
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1410 1410
 			return false;
1411 1411
 		}
1412
-		if ( is_array( $forward ) ) {
1413
-			if ( ! isset( $forward[1] ) ) {
1412
+		if (is_array($forward)) {
1413
+			if ( ! isset($forward[1])) {
1414 1414
 				$msg = sprintf(
1415
-					__( 'A class method for the %s forwarding route has not been supplied.', 'event_espresso' ),
1415
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1416 1416
 					$route
1417 1417
 				);
1418
-				EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1418
+				EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1419 1419
 				return false;
1420 1420
 			}
1421
-			if ( ! method_exists( $forward[0], $forward[1] ) ) {
1421
+			if ( ! method_exists($forward[0], $forward[1])) {
1422 1422
 				$msg = sprintf(
1423
-					__( 'The class method %s for the %s forwarding route is in invalid.', 'event_espresso' ),
1423
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1424 1424
 					$forward[1],
1425 1425
 					$route
1426 1426
 				);
1427
-				EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1427
+				EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1428 1428
 				return false;
1429 1429
 			}
1430
-		} else if ( ! function_exists( $forward ) ) {
1430
+		} else if ( ! function_exists($forward)) {
1431 1431
 			$msg = sprintf(
1432
-				__( 'The function %s for the %s forwarding route is in invalid.', 'event_espresso' ),
1432
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1433 1433
 				$forward,
1434 1434
 				$route
1435 1435
 			);
1436
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1436
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1437 1437
 			return false;
1438 1438
 		}
1439
-		EE_Config::$_module_forward_map[ $key ][ $route ][ absint( $status ) ] = $forward;
1439
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1440 1440
 		return true;
1441 1441
 	}
1442 1442
 
@@ -1452,12 +1452,12 @@  discard block
 block discarded – undo
1452 1452
 	 * @param    string  $key    - url param key indicating a route is being called
1453 1453
 	 * @return    string
1454 1454
 	 */
1455
-	public static function get_forward( $route = null, $status = 0, $key = 'ee' ) {
1456
-		do_action( 'AHEE__EE_Config__get_forward__begin', $route, $status );
1457
-		if ( isset( EE_Config::$_module_forward_map[ $key ][ $route ][ $status ] ) ) {
1455
+	public static function get_forward($route = null, $status = 0, $key = 'ee') {
1456
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1457
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1458 1458
 			return apply_filters(
1459 1459
 				'FHEE__EE_Config__get_forward',
1460
-				EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1460
+				EE_Config::$_module_forward_map[$key][$route][$status],
1461 1461
 				$route,
1462 1462
 				$status
1463 1463
 			);
@@ -1479,17 +1479,17 @@  discard block
 block discarded – undo
1479 1479
 	 * @param    string  $key    - url param key indicating a route is being called
1480 1480
 	 * @return    bool
1481 1481
 	 */
1482
-	public static function register_view( $route = null, $status = 0, $view = null, $key = 'ee' ) {
1483
-		do_action( 'AHEE__EE_Config__register_view__begin', $route, $status, $view );
1484
-		if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route ) ) {
1482
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') {
1483
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1484
+		if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1485 1485
 			$msg = sprintf(
1486
-				__( 'The module route %s for this view has not been registered.', 'event_espresso' ),
1486
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1487 1487
 				$route
1488 1488
 			);
1489
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1489
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1490 1490
 			return false;
1491 1491
 		}
1492
-		if ( ! is_readable( $view ) ) {
1492
+		if ( ! is_readable($view)) {
1493 1493
 			$msg = sprintf(
1494 1494
 				__(
1495 1495
 					'The %s view file could not be found or is not readable due to file permissions.',
@@ -1497,10 +1497,10 @@  discard block
 block discarded – undo
1497 1497
 				),
1498 1498
 				$view
1499 1499
 			);
1500
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1500
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1501 1501
 			return false;
1502 1502
 		}
1503
-		EE_Config::$_module_view_map[ $key ][ $route ][ absint( $status ) ] = $view;
1503
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1504 1504
 		return true;
1505 1505
 	}
1506 1506
 
@@ -1516,12 +1516,12 @@  discard block
 block discarded – undo
1516 1516
 	 * @param    string  $key    - url param key indicating a route is being called
1517 1517
 	 * @return    string
1518 1518
 	 */
1519
-	public static function get_view( $route = null, $status = 0, $key = 'ee' ) {
1520
-		do_action( 'AHEE__EE_Config__get_view__begin', $route, $status );
1521
-		if ( isset( EE_Config::$_module_view_map[ $key ][ $route ][ $status ] ) ) {
1519
+	public static function get_view($route = null, $status = 0, $key = 'ee') {
1520
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1521
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1522 1522
 			return apply_filters(
1523 1523
 				'FHEE__EE_Config__get_view',
1524
-				EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1524
+				EE_Config::$_module_view_map[$key][$route][$status],
1525 1525
 				$route,
1526 1526
 				$status
1527 1527
 			);
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
 
1533 1533
 
1534 1534
 	public function update_addon_option_names() {
1535
-		update_option( EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names );
1535
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1536 1536
 	}
1537 1537
 
1538 1538
 
@@ -1560,22 +1560,22 @@  discard block
 block discarded – undo
1560 1560
 	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561 1561
 	 * @throws \EE_Error
1562 1562
 	 */
1563
-	public function get_pretty( $property ) {
1564
-		if ( ! property_exists( $this, $property ) ) {
1563
+	public function get_pretty($property) {
1564
+		if ( ! property_exists($this, $property)) {
1565 1565
 			throw new EE_Error(
1566 1566
 				sprintf(
1567 1567
 					__(
1568 1568
 						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1569 1569
 						'event_espresso'
1570 1570
 					),
1571
-					get_class( $this ),
1571
+					get_class($this),
1572 1572
 					$property
1573 1573
 				)
1574 1574
 			);
1575 1575
 		}
1576 1576
 		//just handling escaping of strings for now.
1577
-		if ( is_string( $this->{$property} ) ) {
1578
-			return stripslashes( $this->{$property} );
1577
+		if (is_string($this->{$property} )) {
1578
+			return stripslashes($this->{$property} );
1579 1579
 		}
1580 1580
 		return $this->{$property};
1581 1581
 	}
@@ -1584,17 +1584,17 @@  discard block
 block discarded – undo
1584 1584
 
1585 1585
 	public function populate() {
1586 1586
 		//grab defaults via a new instance of this class.
1587
-		$class_name = get_class( $this );
1587
+		$class_name = get_class($this);
1588 1588
 		$defaults = new $class_name;
1589 1589
 		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1590 1590
 		//default from our $defaults object.
1591
-		foreach ( get_object_vars( $defaults ) as $property => $value ) {
1592
-			if ( $this->{$property} === null ) {
1591
+		foreach (get_object_vars($defaults) as $property => $value) {
1592
+			if ($this->{$property} === null) {
1593 1593
 				$this->{$property} = $value;
1594 1594
 			}
1595 1595
 		}
1596 1596
 		//cleanup
1597
-		unset( $defaults );
1597
+		unset($defaults);
1598 1598
 	}
1599 1599
 
1600 1600
 
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
 	 * @param $a
1611 1611
 	 * @return bool
1612 1612
 	 */
1613
-	public function __isset( $a ) {
1613
+	public function __isset($a) {
1614 1614
 		return false;
1615 1615
 	}
1616 1616
 
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
 	 * @param $a
1623 1623
 	 * @return bool
1624 1624
 	 */
1625
-	public function __unset( $a ) {
1625
+	public function __unset($a) {
1626 1626
 		return false;
1627 1627
 	}
1628 1628
 
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
 		$this->current_blog_id = get_current_blog_id();
1733 1733
 		$this->current_blog_id = $this->current_blog_id === NULL ? 1 : $this->current_blog_id;
1734 1734
 		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1735
-		$this->ee_ueip_has_notified = is_main_site() ? get_option( 'ee_ueip_has_notified', false ) : true;
1735
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1736 1736
 		$this->post_shortcodes = array();
1737 1737
 		$this->module_route_map = array();
1738 1738
 		$this->module_forward_map = array();
@@ -1748,9 +1748,9 @@  discard block
 block discarded – undo
1748 1748
 		$this->thank_you_page_url = '';
1749 1749
 		$this->cancel_page_url = '';
1750 1750
 		//cpt slugs
1751
-		$this->event_cpt_slug = __( 'events', 'event_espresso' );
1751
+		$this->event_cpt_slug = __('events', 'event_espresso');
1752 1752
 		//ueip constant check
1753
-		if ( defined( 'EE_DISABLE_UXIP' ) && EE_DISABLE_UXIP ) {
1753
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1754 1754
 			$this->ee_ueip_optin = false;
1755 1755
 			$this->ee_ueip_has_notified = true;
1756 1756
 		}
@@ -1793,11 +1793,11 @@  discard block
 block discarded – undo
1793 1793
 	 * @return    string
1794 1794
 	 */
1795 1795
 	public function reg_page_url() {
1796
-		if ( ! $this->reg_page_url ) {
1796
+		if ( ! $this->reg_page_url) {
1797 1797
 			$this->reg_page_url = add_query_arg(
1798
-				array( 'uts' => time() ),
1799
-				get_permalink( $this->reg_page_id )
1800
-			) . '#checkout';
1798
+				array('uts' => time()),
1799
+				get_permalink($this->reg_page_id)
1800
+			).'#checkout';
1801 1801
 		}
1802 1802
 		return $this->reg_page_url;
1803 1803
 	}
@@ -1812,12 +1812,12 @@  discard block
 block discarded – undo
1812 1812
 	 * @access    public
1813 1813
 	 * @return    string
1814 1814
 	 */
1815
-	public function txn_page_url( $query_args = array() ) {
1816
-		if ( ! $this->txn_page_url ) {
1817
-			$this->txn_page_url = get_permalink( $this->txn_page_id );
1815
+	public function txn_page_url($query_args = array()) {
1816
+		if ( ! $this->txn_page_url) {
1817
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1818 1818
 		}
1819
-		if ( $query_args ) {
1820
-			return add_query_arg( $query_args, $this->txn_page_url );
1819
+		if ($query_args) {
1820
+			return add_query_arg($query_args, $this->txn_page_url);
1821 1821
 		} else {
1822 1822
 			return $this->txn_page_url;
1823 1823
 		}
@@ -1833,12 +1833,12 @@  discard block
 block discarded – undo
1833 1833
 	 * @access    public
1834 1834
 	 * @return    string
1835 1835
 	 */
1836
-	public function thank_you_page_url( $query_args = array() ) {
1837
-		if ( ! $this->thank_you_page_url ) {
1838
-			$this->thank_you_page_url = get_permalink( $this->thank_you_page_id );
1836
+	public function thank_you_page_url($query_args = array()) {
1837
+		if ( ! $this->thank_you_page_url) {
1838
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1839 1839
 		}
1840
-		if ( $query_args ) {
1841
-			return add_query_arg( $query_args, $this->thank_you_page_url );
1840
+		if ($query_args) {
1841
+			return add_query_arg($query_args, $this->thank_you_page_url);
1842 1842
 		} else {
1843 1843
 			return $this->thank_you_page_url;
1844 1844
 		}
@@ -1853,8 +1853,8 @@  discard block
 block discarded – undo
1853 1853
 	 * @return    string
1854 1854
 	 */
1855 1855
 	public function cancel_page_url() {
1856
-		if ( ! $this->cancel_page_url ) {
1857
-			$this->cancel_page_url = get_permalink( $this->cancel_page_id );
1856
+		if ( ! $this->cancel_page_url) {
1857
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1858 1858
 		}
1859 1859
 		return $this->cancel_page_url;
1860 1860
 	}
@@ -1883,22 +1883,22 @@  discard block
 block discarded – undo
1883 1883
 	 */
1884 1884
 	protected function _get_main_ee_ueip_optin() {
1885 1885
 		//if this is the main site then we can just bypass our direct query.
1886
-		if ( is_main_site() ) {
1887
-			return get_option( 'ee_ueip_optin', false );
1886
+		if (is_main_site()) {
1887
+			return get_option('ee_ueip_optin', false);
1888 1888
 		}
1889 1889
 
1890 1890
 		//is this already cached for this request?  If so use it.
1891
-		if ( ! empty( EE_Core_Config::$ee_ueip_option ) ) {
1891
+		if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1892 1892
 			return EE_Core_Config::$ee_ueip_option;
1893 1893
 		}
1894 1894
 
1895 1895
 		global $wpdb;
1896 1896
 		$current_network_main_site = is_multisite() ? get_current_site() : null;
1897
-		$current_main_site_id = ! empty( $current_network_main_site ) ? $current_network_main_site->blog_id : 1;
1897
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1898 1898
 		$option = 'ee_ueip_optin';
1899 1899
 
1900 1900
 		//set correct table for query
1901
-		$table_name = $wpdb->get_blog_prefix( $current_main_site_id ) . 'options';
1901
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1902 1902
 
1903 1903
 
1904 1904
 		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
@@ -1906,20 +1906,20 @@  discard block
 block discarded – undo
1906 1906
 		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1907 1907
 		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1908 1908
 		//for the purpose of caching.
1909
-		$pre = apply_filters( 'pre_option_' . $option, false, $option );
1910
-		if ( false !== $pre ) {
1909
+		$pre = apply_filters('pre_option_'.$option, false, $option);
1910
+		if (false !== $pre) {
1911 1911
 			EE_Core_Config::$ee_ueip_option = $pre;
1912 1912
 			return EE_Core_Config::$ee_ueip_option;
1913 1913
 		}
1914 1914
 
1915
-		$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", $option ) );
1916
-		if ( is_object( $row ) ) {
1915
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", $option));
1916
+		if (is_object($row)) {
1917 1917
 			$value = $row->option_value;
1918 1918
 		} else { //option does not exist so use default.
1919
-			return apply_filters( 'default_option_' . $option, false, $option );
1919
+			return apply_filters('default_option_'.$option, false, $option);
1920 1920
 		}
1921 1921
 
1922
-		EE_Core_Config::$ee_ueip_option = apply_filters( 'option_' . $option, maybe_unserialize( $value ), $option );
1922
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
1923 1923
 		return EE_Core_Config::$ee_ueip_option;
1924 1924
 	}
1925 1925
 
@@ -1935,7 +1935,7 @@  discard block
 block discarded – undo
1935 1935
 		//reset all url properties
1936 1936
 		$this->_reset_urls();
1937 1937
 		//return what to save to db
1938
-		return array_keys( get_object_vars( $this ) );
1938
+		return array_keys(get_object_vars($this));
1939 1939
 	}
1940 1940
 
1941 1941
 }
@@ -2082,14 +2082,14 @@  discard block
 block discarded – undo
2082 2082
 	 */
2083 2083
 	public function __construct() {
2084 2084
 		// set default organization settings
2085
-		$this->name = get_bloginfo( 'name' );
2085
+		$this->name = get_bloginfo('name');
2086 2086
 		$this->address_1 = '123 Onna Road';
2087 2087
 		$this->address_2 = 'PO Box 123';
2088 2088
 		$this->city = 'Inna City';
2089 2089
 		$this->STA_ID = 4;
2090 2090
 		$this->CNT_ISO = 'US';
2091 2091
 		$this->zip = '12345';
2092
-		$this->email = get_bloginfo( 'admin_email' );
2092
+		$this->email = get_bloginfo('admin_email');
2093 2093
 		$this->phone = '';
2094 2094
 		$this->vat = '123456789';
2095 2095
 		$this->logo_url = '';
@@ -2177,46 +2177,46 @@  discard block
 block discarded – undo
2177 2177
 	 * @param string $CNT_ISO
2178 2178
 	 * @throws \EE_Error
2179 2179
 	 */
2180
-	public function __construct( $CNT_ISO = '' ) {
2180
+	public function __construct($CNT_ISO = '') {
2181 2181
 		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2182
-		$table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true );
2182
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2183 2183
 		// get country code from organization settings or use default
2184
-		$ORG_CNT = isset( EE_Registry::instance()->CFG->organization )
2184
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2185 2185
 		           && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2186 2186
 			? EE_Registry::instance()->CFG->organization->CNT_ISO
2187 2187
 			: '';
2188 2188
 		// but override if requested
2189
-		$CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : $ORG_CNT;
2189
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2190 2190
 		// 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
2191 2191
 		if (
2192
-			! empty( $CNT_ISO )
2192
+			! empty($CNT_ISO)
2193 2193
 			&& EE_Maintenance_Mode::instance()->models_can_query()
2194
-			&& $table_analysis->tableExists( EE_Registry::instance()->load_model( 'Country' )->table() )
2194
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2195 2195
 		) {
2196 2196
 			// retrieve the country settings from the db, just in case they have been customized
2197
-			$country = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $CNT_ISO );
2198
-			if ( $country instanceof EE_Country ) {
2199
-				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2200
-				$this->name = $country->currency_name_single();    // Dollar
2201
-				$this->plural = $country->currency_name_plural();    // Dollars
2202
-				$this->sign = $country->currency_sign();            // currency sign: $
2203
-				$this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2204
-				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2205
-				$this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2206
-				$this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2197
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2198
+			if ($country instanceof EE_Country) {
2199
+				$this->code = $country->currency_code(); // currency code: USD, CAD, EUR
2200
+				$this->name = $country->currency_name_single(); // Dollar
2201
+				$this->plural = $country->currency_name_plural(); // Dollars
2202
+				$this->sign = $country->currency_sign(); // currency sign: $
2203
+				$this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE  or  FALSE$
2204
+				$this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
2205
+				$this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2206
+				$this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2207 2207
 			}
2208 2208
 		}
2209 2209
 		// fallback to hardcoded defaults, in case the above failed
2210
-		if ( empty( $this->code ) ) {
2210
+		if (empty($this->code)) {
2211 2211
 			// set default currency settings
2212
-			$this->code = 'USD';    // currency code: USD, CAD, EUR
2213
-			$this->name = __( 'Dollar', 'event_espresso' );    // Dollar
2214
-			$this->plural = __( 'Dollars', 'event_espresso' );    // Dollars
2215
-			$this->sign = '$';    // currency sign: $
2216
-			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2217
-			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2218
-			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2219
-			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2212
+			$this->code = 'USD'; // currency code: USD, CAD, EUR
2213
+			$this->name = __('Dollar', 'event_espresso'); // Dollar
2214
+			$this->plural = __('Dollars', 'event_espresso'); // Dollars
2215
+			$this->sign = '$'; // currency sign: $
2216
+			$this->sign_b4 = true; // currency sign before or after: $TRUE  or  FALSE$
2217
+			$this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
2218
+			$this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2219
+			$this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2220 2220
 		}
2221 2221
 	}
2222 2222
 }
@@ -2378,7 +2378,7 @@  discard block
 block discarded – undo
2378 2378
 	 * @since 4.8.8.rc.019
2379 2379
 	 */
2380 2380
 	public function do_hooks() {
2381
-		add_action( 'AHEE__EE_Config___load_core_config__end', array( $this, 'set_default_reg_status_on_EEM_Event' ) );
2381
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2382 2382
 	}
2383 2383
 
2384 2384
 
@@ -2387,7 +2387,7 @@  discard block
 block discarded – undo
2387 2387
 	 * @return void
2388 2388
 	 */
2389 2389
 	public function set_default_reg_status_on_EEM_Event() {
2390
-		EEM_Event::set_default_reg_status( $this->default_STS_ID );
2390
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2391 2391
 	}
2392 2392
 
2393 2393
 
@@ -2491,10 +2491,10 @@  discard block
 block discarded – undo
2491 2491
 	 * @param bool $reset
2492 2492
 	 * @return string
2493 2493
 	 */
2494
-	public function log_file_name( $reset = false ) {
2495
-		if ( empty( $this->log_file_name ) || $reset ) {
2496
-			$this->log_file_name = sanitize_key( 'espresso_log_' . md5( uniqid( '', true ) ) ) . '.txt';
2497
-			EE_Config::instance()->update_espresso_config( false, false );
2494
+	public function log_file_name($reset = false) {
2495
+		if (empty($this->log_file_name) || $reset) {
2496
+			$this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt';
2497
+			EE_Config::instance()->update_espresso_config(false, false);
2498 2498
 		}
2499 2499
 		return $this->log_file_name;
2500 2500
 	}
@@ -2505,10 +2505,10 @@  discard block
 block discarded – undo
2505 2505
 	 * @param bool $reset
2506 2506
 	 * @return string
2507 2507
 	 */
2508
-	public function debug_file_name( $reset = false ) {
2509
-		if ( empty( $this->debug_file_name ) || $reset ) {
2510
-			$this->debug_file_name = sanitize_key( 'espresso_debug_' . md5( uniqid( '', true ) ) ) . '.txt';
2511
-			EE_Config::instance()->update_espresso_config( false, false );
2508
+	public function debug_file_name($reset = false) {
2509
+		if (empty($this->debug_file_name) || $reset) {
2510
+			$this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt';
2511
+			EE_Config::instance()->update_espresso_config(false, false);
2512 2512
 		}
2513 2513
 		return $this->debug_file_name;
2514 2514
 	}
@@ -2519,7 +2519,7 @@  discard block
 block discarded – undo
2519 2519
 	 * @return string
2520 2520
 	 */
2521 2521
 	public function affiliate_id() {
2522
-		return ! empty( $this->affiliate_id ) ? $this->affiliate_id : 'default';
2522
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2523 2523
 	}
2524 2524
 
2525 2525
 
@@ -2699,21 +2699,21 @@  discard block
 block discarded – undo
2699 2699
 		$this->use_google_maps = true;
2700 2700
 		$this->google_map_api_key = '';
2701 2701
 		// for event details pages (reg page)
2702
-		$this->event_details_map_width = 585;            // ee_map_width_single
2703
-		$this->event_details_map_height = 362;            // ee_map_height_single
2704
-		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2705
-		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2706
-		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2707
-		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2708
-		$this->event_details_map_align = 'center';            // ee_map_align_single
2702
+		$this->event_details_map_width = 585; // ee_map_width_single
2703
+		$this->event_details_map_height = 362; // ee_map_height_single
2704
+		$this->event_details_map_zoom = 14; // ee_map_zoom_single
2705
+		$this->event_details_display_nav = true; // ee_map_nav_display_single
2706
+		$this->event_details_nav_size = false; // ee_map_nav_size_single
2707
+		$this->event_details_control_type = 'default'; // ee_map_type_control_single
2708
+		$this->event_details_map_align = 'center'; // ee_map_align_single
2709 2709
 		// for event list pages
2710
-		$this->event_list_map_width = 300;            // ee_map_width
2711
-		$this->event_list_map_height = 185;        // ee_map_height
2712
-		$this->event_list_map_zoom = 12;            // ee_map_zoom
2713
-		$this->event_list_display_nav = false;        // ee_map_nav_display
2714
-		$this->event_list_nav_size = true;            // ee_map_nav_size
2715
-		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2716
-		$this->event_list_map_align = 'center';            // ee_map_align
2710
+		$this->event_list_map_width = 300; // ee_map_width
2711
+		$this->event_list_map_height = 185; // ee_map_height
2712
+		$this->event_list_map_zoom = 12; // ee_map_zoom
2713
+		$this->event_list_display_nav = false; // ee_map_nav_display
2714
+		$this->event_list_nav_size = true; // ee_map_nav_size
2715
+		$this->event_list_control_type = 'dropdown'; // ee_map_type_control
2716
+		$this->event_list_map_align = 'center'; // ee_map_align
2717 2717
 	}
2718 2718
 
2719 2719
 }
@@ -2866,7 +2866,7 @@  discard block
 block discarded – undo
2866 2866
 	 * @return void
2867 2867
 	 */
2868 2868
 	protected function _set_php_values() {
2869
-		$this->php->max_input_vars = ini_get( 'max_input_vars' );
2869
+		$this->php->max_input_vars = ini_get('max_input_vars');
2870 2870
 		$this->php->version = phpversion();
2871 2871
 	}
2872 2872
 
@@ -2885,10 +2885,10 @@  discard block
 block discarded – undo
2885 2885
 	 * @type string $msg         Any message to be displayed.
2886 2886
 	 *                           }
2887 2887
 	 */
2888
-	public function max_input_vars_limit_check( $input_count = 0 ) {
2889
-		if ( ! empty( $this->php->max_input_vars )
2890
-		     && ( $input_count >= $this->php->max_input_vars )
2891
-		     && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9 )
2888
+	public function max_input_vars_limit_check($input_count = 0) {
2889
+		if ( ! empty($this->php->max_input_vars)
2890
+		     && ($input_count >= $this->php->max_input_vars)
2891
+		     && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
2892 2892
 		) {
2893 2893
 			return sprintf(
2894 2894
 				__(
@@ -2954,7 +2954,7 @@  discard block
 block discarded – undo
2954 2954
 	 */
2955 2955
 	public function __construct() {
2956 2956
 		$this->payment_settings = array();
2957
-		$this->active_gateways = array( 'Invoice' => false );
2957
+		$this->active_gateways = array('Invoice' => false);
2958 2958
 	}
2959 2959
 }
2960 2960
 
Please login to merge, or discard this patch.
caffeinated/brewing_regular.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use EventEspresso\core\services\database\TableAnalysis;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 /**
8 8
  * the purpose of this file is to simply contain any action/filter hook callbacks etc for specific aspects of EE
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // defined some new constants related to caffeinated folder
14
-define( 'EE_CAF_URL', EE_PLUGIN_DIR_URL . 'caffeinated/' );
15
-define( 'EE_CAF_CORE', EE_CAFF_PATH . 'core' . DS );
16
-define( 'EE_CAF_LIBRARIES', EE_CAF_CORE . 'libraries' . DS );
17
-define( 'EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH . 'payment_methods' . DS );
14
+define('EE_CAF_URL', EE_PLUGIN_DIR_URL.'caffeinated/');
15
+define('EE_CAF_CORE', EE_CAFF_PATH.'core'.DS);
16
+define('EE_CAF_LIBRARIES', EE_CAF_CORE.'libraries'.DS);
17
+define('EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH.'payment_methods'.DS);
18 18
 
19 19
 
20 20
 
@@ -35,31 +35,31 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * EE_Brewing_Regular constructor.
37 37
 	 */
38
-	public function __construct( TableAnalysis $table_analysis ) {
38
+	public function __construct(TableAnalysis $table_analysis) {
39 39
 		$this->_table_analysis = $table_analysis;
40
-		if ( defined( 'EE_CAFF_PATH' ) ) {
40
+		if (defined('EE_CAFF_PATH')) {
41 41
 			// activation
42
-			add_action( 'AHEE__EEH_Activation__initialize_db_content', array( $this, 'initialize_caf_db_content' ) );
42
+			add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content'));
43 43
 			// load caff init
44
-			add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'caffeinated_init' ) );
44
+			add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init'));
45 45
 			// remove the "powered by" credit link from receipts and invoices
46
-			add_filter( 'FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false' );
46
+			add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false');
47 47
 			// add caffeinated modules
48 48
 			add_filter(
49 49
 				'FHEE__EE_Config__register_modules__modules_to_register',
50
-				array( $this, 'caffeinated_modules_to_register' )
50
+				array($this, 'caffeinated_modules_to_register')
51 51
 			);
52 52
 			// load caff scripts
53
-			add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_caffeinated_scripts' ), 10 );
54
-			add_filter( 'FHEE__EE_Registry__load_helper__helper_paths', array( $this, 'caf_helper_paths' ), 10 );
53
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10);
54
+			add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10);
55 55
 			add_filter(
56 56
 				'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
57
-				array( $this, 'caf_payment_methods' )
57
+				array($this, 'caf_payment_methods')
58 58
 			);
59 59
 			// caffeinated constructed
60
-			do_action( 'AHEE__EE_Brewing_Regular__construct__complete' );
60
+			do_action('AHEE__EE_Brewing_Regular__construct__complete');
61 61
 			//seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer
62
-			add_filter( 'FHEE__ee_show_affiliate_links', '__return_false' );
62
+			add_filter('FHEE__ee_show_affiliate_links', '__return_false');
63 63
 		}
64 64
 	}
65 65
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 * @param array $paths original helper paths array
72 72
 	 * @return array             new array of paths
73 73
 	 */
74
-	public function caf_helper_paths( $paths ) {
75
-		$paths[] = EE_CAF_CORE . 'helpers' . DS;
74
+	public function caf_helper_paths($paths) {
75
+		$paths[] = EE_CAF_CORE.'helpers'.DS;
76 76
 		return $paths;
77 77
 	}
78 78
 
@@ -89,21 +89,21 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @global wpdb $wpdb
91 91
 	 */
92
-	public function initialize_caf_db_content(){
92
+	public function initialize_caf_db_content() {
93 93
 		global $wpdb;
94 94
 		//use same method of getting creator id as the version introducing the change
95
-		$default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id',get_current_user_id());
95
+		$default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
96 96
 		$price_type_table = $wpdb->prefix."esp_price_type";
97 97
 		$price_table = $wpdb->prefix."esp_price";
98
-		if ( $this->_get_table_analysis()->tableExists( $price_type_table ) ) {
98
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
99 99
 
100
-			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';//include trashed price types
101
-			$tax_price_type_count = $wpdb->get_var( $SQL );
102
-			if ( $tax_price_type_count <= 1 ) {
100
+			$SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table.' WHERE PBT_ID=4'; //include trashed price types
101
+			$tax_price_type_count = $wpdb->get_var($SQL);
102
+			if ($tax_price_type_count <= 1) {
103 103
 				$wpdb->insert(
104 104
 					$price_type_table,
105 105
 					array(
106
-						'PRT_name'       => __( "Regional Tax", "event_espresso" ),
106
+						'PRT_name'       => __("Regional Tax", "event_espresso"),
107 107
 						'PBT_ID'         => 4,
108 108
 						'PRT_is_percent' => true,
109 109
 						'PRT_order'      => 60,
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 						'PRT_wp_user'    => $default_creator_id,
112 112
 					),
113 113
 					array(
114
-						'%s',//PRT_name
115
-						'%d',//PBT_id
116
-						'%d',//PRT_is_percent
117
-						'%d',//PRT_order
118
-						'%d',//PRT_deleted
114
+						'%s', //PRT_name
115
+						'%d', //PBT_id
116
+						'%d', //PRT_is_percent
117
+						'%d', //PRT_order
118
+						'%d', //PRT_deleted
119 119
 						'%d', //PRT_wp_user
120 120
 					)
121 121
 				);
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 				$result = $wpdb->insert(
124 124
 					$price_type_table,
125 125
 					array(
126
-						'PRT_name'       => __( "Federal Tax", "event_espresso" ),
126
+						'PRT_name'       => __("Federal Tax", "event_espresso"),
127 127
 						'PBT_ID'         => 4,
128 128
 						'PRT_is_percent' => true,
129 129
 						'PRT_order'      => 70,
@@ -131,21 +131,21 @@  discard block
 block discarded – undo
131 131
 						'PRT_wp_user'    => $default_creator_id,
132 132
 					),
133 133
 					array(
134
-						'%s',//PRT_name
135
-						'%d',//PBT_id
136
-						'%d',//PRT_is_percent
137
-						'%d',//PRT_order
138
-						'%d',//PRT_deleted
134
+						'%s', //PRT_name
135
+						'%d', //PBT_id
136
+						'%d', //PRT_is_percent
137
+						'%d', //PRT_order
138
+						'%d', //PRT_deleted
139 139
 						'%d' //PRT_wp_user
140 140
 					)
141 141
 				);
142
-				if ( $result ) {
142
+				if ($result) {
143 143
 					$wpdb->insert(
144 144
 						$price_table,
145 145
 						array(
146 146
 							'PRT_ID'         => $wpdb->insert_id,
147 147
 							'PRC_amount'     => 15.00,
148
-							'PRC_name'       => __( "Sales Tax", "event_espresso" ),
148
+							'PRC_name'       => __("Sales Tax", "event_espresso"),
149 149
 							'PRC_desc'       => '',
150 150
 							'PRC_is_default' => true,
151 151
 							'PRC_overrides'  => null,
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
 							'PRC_wp_user'    => $default_creator_id,
156 156
 						),
157 157
 						array(
158
-							'%d',//PRT_id
159
-							'%f',//PRC_amount
160
-							'%s',//PRC_name
161
-							'%s',//PRC_desc
162
-							'%d',//PRC_is_default
163
-							'%d',//PRC_overrides
164
-							'%d',//PRC_deleted
165
-							'%d',//PRC_order
166
-							'%d',//PRC_parent
158
+							'%d', //PRT_id
159
+							'%f', //PRC_amount
160
+							'%s', //PRC_name
161
+							'%s', //PRC_desc
162
+							'%d', //PRC_is_default
163
+							'%d', //PRC_overrides
164
+							'%d', //PRC_deleted
165
+							'%d', //PRC_order
166
+							'%d', //PRC_parent
167 167
 							'%d' //PRC_wp_user
168 168
 						)
169 169
 					);
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 	 * @param array $modules_to_register
182 182
 	 * @return array
183 183
 	 */
184
-	public function caffeinated_modules_to_register( $modules_to_register = array() ) {
185
-		if ( is_readable( EE_CAFF_PATH . 'modules' ) ) {
186
-			$caffeinated_modules_to_register = glob( EE_CAFF_PATH . 'modules' . DS . '*', GLOB_ONLYDIR );
187
-			if ( is_array( $caffeinated_modules_to_register ) && ! empty( $caffeinated_modules_to_register ) ) {
188
-				$modules_to_register = array_merge( $modules_to_register, $caffeinated_modules_to_register );
184
+	public function caffeinated_modules_to_register($modules_to_register = array()) {
185
+		if (is_readable(EE_CAFF_PATH.'modules')) {
186
+			$caffeinated_modules_to_register = glob(EE_CAFF_PATH.'modules'.DS.'*', GLOB_ONLYDIR);
187
+			if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
188
+				$modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
189 189
 			}
190 190
 		}
191 191
 		return $modules_to_register;
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
 
196 196
 	public function caffeinated_init() {
197 197
 		// EE_Register_CPTs hooks
198
-		add_filter( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( $this, 'filter_taxonomies' ), 10 );
199
-		add_filter( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', array( $this, 'filter_cpts' ), 10 );
200
-		add_filter( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', array( $this, 'nav_metabox_items' ), 10 );
201
-		EE_Registry::instance()->load_file( EE_CAFF_PATH, 'EE_Caf_Messages', 'class', array(), false );
198
+		add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array($this, 'filter_taxonomies'), 10);
199
+		add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array($this, 'filter_cpts'), 10);
200
+		add_filter('FHEE__EE_Admin__get_extra_nav_menu_pages_items', array($this, 'nav_metabox_items'), 10);
201
+		EE_Registry::instance()->load_file(EE_CAFF_PATH, 'EE_Caf_Messages', 'class', array(), false);
202 202
 		// caffeinated_init__complete hook
203
-		do_action( 'AHEE__EE_Brewing_Regular__caffeinated_init__complete' );
203
+		do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete');
204 204
 	}
205 205
 
206 206
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 * @param array $taxonomy_array
218 218
 	 * @return array
219 219
 	 */
220
-	public function filter_taxonomies( array $taxonomy_array ) {
220
+	public function filter_taxonomies(array $taxonomy_array) {
221 221
 		$taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true;
222 222
 		return $taxonomy_array;
223 223
 	}
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	 * @param array $cpt_array
229 229
 	 * @return mixed
230 230
 	 */
231
-	public function filter_cpts( array $cpt_array ) {
231
+	public function filter_cpts(array $cpt_array) {
232 232
 		$cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true;
233 233
 		return $cpt_array;
234 234
 	}
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
 	 * @param array $menuitems
240 240
 	 * @return array
241 241
 	 */
242
-	public function nav_metabox_items( array $menuitems ) {
242
+	public function nav_metabox_items(array $menuitems) {
243 243
 		$menuitems[] = array(
244
-			'title'       => __( 'Venue List', 'event_espresso' ),
245
-			'url'         => get_post_type_archive_link( 'espresso_venues' ),
246
-			'description' => __( 'Archive page for all venues.', 'event_espresso' ),
244
+			'title'       => __('Venue List', 'event_espresso'),
245
+			'url'         => get_post_type_archive_link('espresso_venues'),
246
+			'description' => __('Archive page for all venues.', 'event_espresso'),
247 247
 		);
248 248
 		return $menuitems;
249 249
 	}
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 	 * @param array $payment_method_paths
257 257
 	 * @return array values are folder paths to payment method folders
258 258
 	 */
259
-	public function caf_payment_methods( $payment_method_paths ) {
260
-		$caf_payment_methods_paths = glob( EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR );
261
-		$payment_method_paths = array_merge( $payment_method_paths, $caf_payment_methods_paths );
259
+	public function caf_payment_methods($payment_method_paths) {
260
+		$caf_payment_methods_paths = glob(EE_CAF_PAYMENT_METHODS.'*', GLOB_ONLYDIR);
261
+		$payment_method_paths = array_merge($payment_method_paths, $caf_payment_methods_paths);
262 262
 		return $payment_method_paths;
263 263
 	}
264 264
 	/**
@@ -267,18 +267,18 @@  discard block
 block discarded – undo
267 267
 	 * @throws \EE_Error
268 268
 	 */
269 269
 	protected function _get_table_analysis() {
270
-		if( $this->_table_analysis instanceof TableAnalysis ) {
270
+		if ($this->_table_analysis instanceof TableAnalysis) {
271 271
 			return $this->_table_analysis;
272 272
 		} else {
273 273
 			throw new \EE_Error( 
274 274
 				sprintf( 
275
-					__( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), 
276
-					get_class( $this ) 
275
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'), 
276
+					get_class($this) 
277 277
 				) 
278 278
 			);
279 279
 		}
280 280
 	}
281 281
 }
282 282
 $brewing = new EE_Brewing_Regular(
283
-	EE_Registry::instance()->create( 'TableAnalysis', array(), true )
283
+	EE_Registry::instance()->create('TableAnalysis', array(), true)
284 284
 );
Please login to merge, or discard this patch.
core/libraries/messages/data_class/EE_Messages_incoming_data.core.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 * @param mixed $data incoming data object|array.  Suggested that child classes use type hinting for expected
267 267
 	 * data object.  But here parent will be generic because we don't know what's coming in.
268 268
 	 */
269
-	public function __construct( $data ) {
269
+	public function __construct($data) {
270 270
 		$this->_data = $data;
271 271
 		$this->_setup_data();
272 272
 	}
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 *
289 289
 	 * @return mixed   The prepped data for db
290 290
 	 */
291
-	static public function convert_data_for_persistent_storage( $data ) {
291
+	static public function convert_data_for_persistent_storage($data) {
292 292
 		return $data;
293 293
 	}
294 294
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 *
305 305
 	 * @return mixed
306 306
 	 */
307
-	static public function convert_data_from_persistent_storage( $data ) {
307
+	static public function convert_data_from_persistent_storage($data) {
308 308
 		return $data;
309 309
 	}
310 310
 
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 	protected function _assemble_data() {
332 332
 		//verify that reg_objs is set
333 333
 		if (
334
-			! is_array( $this->reg_objs )
335
-			&& ! reset( $this->reg_objs ) instanceof EE_Registration
334
+			! is_array($this->reg_objs)
335
+			&& ! reset($this->reg_objs) instanceof EE_Registration
336 336
 		) {
337 337
 			throw new EE_Error(
338 338
 				__(
@@ -347,84 +347,84 @@  discard block
 block discarded – undo
347 347
 		$answers = $questions = $attendees = $line_items = $registrations = array();
348 348
 		$total_ticket_count = 0;
349 349
 
350
-		if ( ! empty( $this->reg_objs ) ) {
350
+		if ( ! empty($this->reg_objs)) {
351 351
 			$event_attendee_count = array();
352
-			foreach ( $this->reg_objs as $reg ) {
352
+			foreach ($this->reg_objs as $reg) {
353 353
 
354 354
 				if (
355
-					$this->_skip_registration_for_processing( $reg )
355
+					$this->_skip_registration_for_processing($reg)
356 356
 				) {
357 357
 					continue;
358 358
 				}
359 359
 
360 360
 				$evt_id = $reg->event_ID();
361 361
 				/** @type EE_Ticket $ticket */
362
-				$ticket = $reg->get_first_related( 'Ticket' );
362
+				$ticket = $reg->get_first_related('Ticket');
363 363
 				$relateddatetime = $ticket->datetimes();
364 364
 				$total_ticket_count++;
365
-				$tickets[ $ticket->ID() ]['ticket'] = $ticket;
366
-				$tickets[ $ticket->ID() ]['count'] = is_array( $tickets[ $ticket->ID() ] )
367
-				                                     && isset( $tickets[ $ticket->ID() ]['count'] )
368
-					? $tickets[ $ticket->ID() ]['count'] + 1
365
+				$tickets[$ticket->ID()]['ticket'] = $ticket;
366
+				$tickets[$ticket->ID()]['count'] = is_array($tickets[$ticket->ID()])
367
+				                                     && isset($tickets[$ticket->ID()]['count'])
368
+					? $tickets[$ticket->ID()]['count'] + 1
369 369
 					: 1;
370
-				$tickets[ $ticket->ID() ]['att_objs'][ $reg->attendee_ID() ] = $reg->attendee();
371
-				$tickets[ $ticket->ID() ]['dtt_objs'] = $relateddatetime;
372
-				$tickets[ $ticket->ID() ]['reg_objs'][ $reg->ID() ] = $reg;
370
+				$tickets[$ticket->ID()]['att_objs'][$reg->attendee_ID()] = $reg->attendee();
371
+				$tickets[$ticket->ID()]['dtt_objs'] = $relateddatetime;
372
+				$tickets[$ticket->ID()]['reg_objs'][$reg->ID()] = $reg;
373 373
 				$event = $reg->event();
374
-				$tickets[ $ticket->ID() ]['EE_Event'] = $event;
375
-				$evtcache[ $evt_id ] = $event;
376
-				$eventsetup[ $evt_id ]['reg_objs'][ $reg->ID() ] = $reg;
377
-				$eventsetup[ $evt_id ]['tkt_objs'][ $ticket->ID() ] = $ticket;
378
-				$eventsetup[ $evt_id ]['att_objs'][ $reg->attendee_ID() ] = $reg->attendee();
379
-				$event_attendee_count[ $evt_id ] = isset( $event_attendee_count[ $evt_id ] )
380
-					? $event_attendee_count[ $evt_id ] + 1
374
+				$tickets[$ticket->ID()]['EE_Event'] = $event;
375
+				$evtcache[$evt_id] = $event;
376
+				$eventsetup[$evt_id]['reg_objs'][$reg->ID()] = $reg;
377
+				$eventsetup[$evt_id]['tkt_objs'][$ticket->ID()] = $ticket;
378
+				$eventsetup[$evt_id]['att_objs'][$reg->attendee_ID()] = $reg->attendee();
379
+				$event_attendee_count[$evt_id] = isset($event_attendee_count[$evt_id])
380
+					? $event_attendee_count[$evt_id] + 1
381 381
 					: 0;
382
-				$attendees[ $reg->attendee_ID() ]['line_ref'][] = $evt_id;
383
-				$attendees[ $reg->attendee_ID() ]['att_obj'] = $reg->attendee();
384
-				$attendees[ $reg->attendee_ID() ]['reg_objs'][ $reg->ID() ] = $reg;
382
+				$attendees[$reg->attendee_ID()]['line_ref'][] = $evt_id;
383
+				$attendees[$reg->attendee_ID()]['att_obj'] = $reg->attendee();
384
+				$attendees[$reg->attendee_ID()]['reg_objs'][$reg->ID()] = $reg;
385 385
 				//$attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID();
386
-				$attendees[ $reg->attendee_ID() ]['attendee_email'] = $reg->attendee() instanceof EE_Attendee
386
+				$attendees[$reg->attendee_ID()]['attendee_email'] = $reg->attendee() instanceof EE_Attendee
387 387
 					? $reg->attendee()->email()
388 388
 					: '';
389
-				$attendees[ $reg->attendee_ID() ]['tkt_objs'][ $ticket->ID() ] = $ticket;
390
-				$attendees[ $reg->attendee_ID() ]['evt_objs'][ $evt_id ] = $event;
389
+				$attendees[$reg->attendee_ID()]['tkt_objs'][$ticket->ID()] = $ticket;
390
+				$attendees[$reg->attendee_ID()]['evt_objs'][$evt_id] = $event;
391 391
 
392 392
 				//registrations
393
-				$registrations[ $reg->ID() ]['tkt_obj'] = $ticket;
394
-				$registrations[ $reg->ID() ]['evt_obj'] = $event;
395
-				$registrations[ $reg->ID() ]['reg_obj'] = $reg;
396
-				$registrations[ $reg->ID() ]['att_obj'] = $reg->attendee();
393
+				$registrations[$reg->ID()]['tkt_obj'] = $ticket;
394
+				$registrations[$reg->ID()]['evt_obj'] = $event;
395
+				$registrations[$reg->ID()]['reg_obj'] = $reg;
396
+				$registrations[$reg->ID()]['att_obj'] = $reg->attendee();
397 397
 
398 398
 				//set up answer objects
399
-				$rel_ans = $reg->get_many_related( 'Answer' );
400
-				foreach ( $rel_ans as $ansid => $answer ) {
401
-					if ( ! isset( $questions[ $ansid ] ) ) {
402
-						$questions[ $ansid ] = $answer->get_first_related( 'Question' );
399
+				$rel_ans = $reg->get_many_related('Answer');
400
+				foreach ($rel_ans as $ansid => $answer) {
401
+					if ( ! isset($questions[$ansid])) {
402
+						$questions[$ansid] = $answer->get_first_related('Question');
403 403
 					}
404
-					$answers[ $ansid ] = $answer;
405
-					$registrations[ $reg->ID() ]['ans_objs'][ $ansid ] = $answer;
404
+					$answers[$ansid] = $answer;
405
+					$registrations[$reg->ID()]['ans_objs'][$ansid] = $answer;
406 406
 				}
407 407
 
408
-				foreach ( $relateddatetime as $dtt_id => $datetime ) {
409
-					$eventsetup[ $evt_id ]['dtt_objs'][ $dtt_id ] = $datetime;
410
-					$registrations[ $reg->ID() ]['dtt_objs'][ $dtt_id ] = $datetime;
408
+				foreach ($relateddatetime as $dtt_id => $datetime) {
409
+					$eventsetup[$evt_id]['dtt_objs'][$dtt_id] = $datetime;
410
+					$registrations[$reg->ID()]['dtt_objs'][$dtt_id] = $datetime;
411 411
 
412
-					if ( isset( $datetimes[ $dtt_id ] ) ) {
412
+					if (isset($datetimes[$dtt_id])) {
413 413
 						continue; //already have this info in the datetimes array.
414 414
 					}
415 415
 
416
-					$datetimes[ $dtt_id ]['tkt_objs'][] = $ticket;
417
-					$datetimes[ $dtt_id ]['datetime'] = $datetime;
418
-					$datetimes[ $dtt_id ]['evt_objs'][ $evt_id ] = $event;
419
-					$datetimes[ $dtt_id ]['reg_objs'][ $reg->ID() ] = $reg;
416
+					$datetimes[$dtt_id]['tkt_objs'][] = $ticket;
417
+					$datetimes[$dtt_id]['datetime'] = $datetime;
418
+					$datetimes[$dtt_id]['evt_objs'][$evt_id] = $event;
419
+					$datetimes[$dtt_id]['reg_objs'][$reg->ID()] = $reg;
420 420
 				}
421 421
 			}
422 422
 
423 423
 			//let's loop through the unique event=>reg items and setup data on them
424 424
 
425
-			if ( ! empty( $eventsetup ) ) {
426
-				foreach ( $eventsetup as $evt_id => $items ) {
427
-					if ( $this->txn instanceof EE_Transaction ) {
425
+			if ( ! empty($eventsetup)) {
426
+				foreach ($eventsetup as $evt_id => $items) {
427
+					if ($this->txn instanceof EE_Transaction) {
428 428
 						$ticket_line_items_for_event = EEM_Line_Item::instance()->get_all(
429 429
 							array(
430 430
 								array(
@@ -437,25 +437,25 @@  discard block
 block discarded – undo
437 437
 					} else {
438 438
 						$ticket_line_items_for_event = array();
439 439
 					}
440
-					$events[ $evt_id ] = array(
440
+					$events[$evt_id] = array(
441 441
 						'ID' => $evt_id,
442
-						'event' => $evtcache[ $evt_id ],
443
-						'name' => $evtcache[ $evt_id ] instanceof EE_Event ? $evtcache[ $evt_id ]->name() : '',
444
-						'total_attendees' => $event_attendee_count[ $evt_id ],
442
+						'event' => $evtcache[$evt_id],
443
+						'name' => $evtcache[$evt_id] instanceof EE_Event ? $evtcache[$evt_id]->name() : '',
444
+						'total_attendees' => $event_attendee_count[$evt_id],
445 445
 						'reg_objs' => $items['reg_objs'],
446 446
 						'tkt_objs' => $items['tkt_objs'],
447 447
 						'att_objs' => $items['att_objs'],
448
-						'dtt_objs' => isset( $items['dtt_objs'] ) ? $items['dtt_objs'] : array(),
448
+						'dtt_objs' => isset($items['dtt_objs']) ? $items['dtt_objs'] : array(),
449 449
 						'line_items' => $ticket_line_items_for_event,
450 450
 					);
451 451
 
452 452
 					//make sure the tickets have the line items setup for them.
453
-					foreach ( $ticket_line_items_for_event as $line_id => $line_item ) {
454
-						if ( $line_item instanceof EE_Line_Item ) {
455
-							$tickets[ $line_item->ticket()->ID() ]['line_item'] = $line_item;
456
-							$tickets[ $line_item->ticket()->ID() ]['sub_line_items'] = $line_item->children();
457
-							$line_items[ $line_item->ID() ]['children'] = $line_item->children();
458
-							$line_items[ $line_item->ID() ]['EE_Ticket'] = $line_item->ticket();
453
+					foreach ($ticket_line_items_for_event as $line_id => $line_item) {
454
+						if ($line_item instanceof EE_Line_Item) {
455
+							$tickets[$line_item->ticket()->ID()]['line_item'] = $line_item;
456
+							$tickets[$line_item->ticket()->ID()]['sub_line_items'] = $line_item->children();
457
+							$line_items[$line_item->ID()]['children'] = $line_item->children();
458
+							$line_items[$line_item->ID()]['EE_Ticket'] = $line_item->ticket();
459 459
 						}
460 460
 					}
461 461
 				}
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 		$this->total_ticket_count = $total_ticket_count;
478 478
 		$this->registrations = $registrations;
479 479
 
480
-		if ( $this->txn instanceof EE_Transaction ) {
480
+		if ($this->txn instanceof EE_Transaction) {
481 481
 			$this->tax_line_items        = $this->txn->tax_items();
482 482
 			$this->additional_line_items = $this->txn->non_ticket_line_items();
483 483
 			$this->payments              = $this->txn->payments();
@@ -487,10 +487,10 @@  discard block
 block discarded – undo
487 487
 			//let's get just the primary_attendee_data!  First we get the primary registration object.
488 488
 			$primary_reg = $this->txn->primary_registration();
489 489
 			// verify
490
-			if ( $primary_reg instanceof EE_Registration ) {
490
+			if ($primary_reg instanceof EE_Registration) {
491 491
 
492 492
 				// get attendee object
493
-				if ( $primary_reg->attendee() instanceof EE_Attendee ) {
493
+				if ($primary_reg->attendee() instanceof EE_Attendee) {
494 494
 
495 495
 					//now we can setup the primary_attendee_data array
496 496
 					$this->primary_attendee_data = array(
@@ -534,8 +534,8 @@  discard block
 block discarded – undo
534 534
 	 * @return bool  returning true means we DO want to skip processing.  returning false means we DON'T want to skip
535 535
 	 *               processing
536 536
 	 */
537
-	protected function _skip_registration_for_processing( EE_Registration $registration ) {
538
-		if ( empty( $this->filtered_reg_status ) ) {
537
+	protected function _skip_registration_for_processing(EE_Registration $registration) {
538
+		if (empty($this->filtered_reg_status)) {
539 539
 			return false;
540 540
 		}
541 541
 
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Generator.lib.php 1 patch
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); }
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
 
3 3
 /**
4 4
  * This class is used for generating EE_Message objects with given info.
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @return EE_Messages_Queue  The new queue for holding generated EE_Message objects.
118 118
 	 */
119
-	public function generate( $save = true ) {
119
+	public function generate($save = true) {
120 120
 		//iterate through the messages in the queue, generate, and add to new queue.
121 121
 		$this->_generation_queue->get_message_repository()->rewind();
122
-		while ( $this->_generation_queue->get_message_repository()->valid() ) {
122
+		while ($this->_generation_queue->get_message_repository()->valid()) {
123 123
 			//reset "current" properties
124 124
 			$this->_reset_current_properties();
125 125
 
@@ -133,18 +133,18 @@  discard block
 block discarded – undo
133 133
 			$this->_generation_queue->get_message_repository()->next();
134 134
 			$next_msg = $this->_generation_queue->get_message_repository()->current();
135 135
 			//restore pointer to current item
136
-			$this->_generation_queue->get_message_repository()->set_current( $msg );
136
+			$this->_generation_queue->get_message_repository()->set_current($msg);
137 137
 
138 138
 			//skip and delete if the current $msg is NOT incomplete (queued for generation)
139
-			if ( $msg->STS_ID() !== EEM_Message::status_incomplete ) {
139
+			if ($msg->STS_ID() !== EEM_Message::status_incomplete) {
140 140
 				//we keep this item in the db just remove from the repo.
141
-				$this->_generation_queue->get_message_repository()->remove( $msg );
141
+				$this->_generation_queue->get_message_repository()->remove($msg);
142 142
 				//next item
143
-				$this->_generation_queue->get_message_repository()->set_current( $next_msg );
143
+				$this->_generation_queue->get_message_repository()->set_current($next_msg);
144 144
 				continue;
145 145
 			}
146 146
 
147
-			if ( $this->_verify() ) {
147
+			if ($this->_verify()) {
148 148
 				//let's get generating!
149 149
 				$this->_generate();
150 150
 			}
@@ -154,32 +154,32 @@  discard block
 block discarded – undo
154 154
 				$msg->STS_ID() === EEM_Message::status_debug_only
155 155
 				&& ! EEM_Message::debug()
156 156
 			) {
157
-				do_action( 'AHEE__EE_Messages_Generator__generate__before_debug_delete', $msg, $this->_error_msg, $this->_current_messenger, $this->_current_message_type, $this->_current_data_handler );
157
+				do_action('AHEE__EE_Messages_Generator__generate__before_debug_delete', $msg, $this->_error_msg, $this->_current_messenger, $this->_current_message_type, $this->_current_data_handler);
158 158
 				$this->_generation_queue->get_message_repository()->delete();
159
-				$this->_generation_queue->get_message_repository()->set_current( $next_msg );
159
+				$this->_generation_queue->get_message_repository()->set_current($next_msg);
160 160
 				continue;
161 161
 			}
162 162
 
163 163
 			//if there are error messages then let's set the status and the error message.
164
-			if ( $this->_error_msg ) {
164
+			if ($this->_error_msg) {
165 165
 				//if the status is already debug only, then let's leave it at that.
166
-				if ( $msg->STS_ID() !== EEM_Message::status_debug_only ) {
167
-					$msg->set_STS_ID( EEM_Message::status_failed );
166
+				if ($msg->STS_ID() !== EEM_Message::status_debug_only) {
167
+					$msg->set_STS_ID(EEM_Message::status_failed);
168 168
 				}
169
-				do_action( 'AHEE__EE_Messages_Generator__generate__processing_failed_message', $msg, $this->_error_msg, $this->_current_messenger, $this->_current_message_type, $this->_current_data_handler );
169
+				do_action('AHEE__EE_Messages_Generator__generate__processing_failed_message', $msg, $this->_error_msg, $this->_current_messenger, $this->_current_message_type, $this->_current_data_handler);
170 170
 				$msg->set_error_message(
171
-					__( 'Message failed to generate for the following reasons: ' )
171
+					__('Message failed to generate for the following reasons: ')
172 172
 					. "\n"
173
-					. implode( "\n", $this->_error_msg )
173
+					. implode("\n", $this->_error_msg)
174 174
 				);
175
-				$msg->set_modified( time() );
175
+				$msg->set_modified(time());
176 176
 			} else {
177
-				do_action( 'AHEE__EE_Messages_Generator__generate__before_successful_generated_message_delete', $msg, $this->_error_msg, $this->_current_messenger, $this->_current_message_type, $this->_current_data_handler );
177
+				do_action('AHEE__EE_Messages_Generator__generate__before_successful_generated_message_delete', $msg, $this->_error_msg, $this->_current_messenger, $this->_current_message_type, $this->_current_data_handler);
178 178
 				//remove from db
179 179
 				$this->_generation_queue->get_message_repository()->delete();
180 180
 			}
181 181
 			//next item
182
-			$this->_generation_queue->get_message_repository()->set_current( $next_msg );
182
+			$this->_generation_queue->get_message_repository()->set_current($next_msg);
183 183
 		}
184 184
 
185 185
 		//generation queue is ALWAYS saved to record any errors in the generation process.
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 		 * so a EE_Extra_Meta entry could be created and attached to the EE_Message.  In those cases the save flag is
193 193
 		 * irrelevant.
194 194
 		 */
195
-		if ( $save ) {
195
+		if ($save) {
196 196
 			$this->_ready_queue->save();
197 197
 		}
198 198
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	protected function _reset_current_properties() {
211 211
 		$this->_verified = false;
212 212
 		//make sure any _data value in the current message type is reset
213
-		if ( $this->_current_message_type instanceof EE_message_type ) {
213
+		if ($this->_current_message_type instanceof EE_message_type) {
214 214
 			$this->_current_message_type->reset_data();
215 215
 		}
216 216
 		$this->_current_messenger = $this->_current_message_type = $this->_current_data_handler = null;
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	protected function _generate() {
231 231
 		//double check verification has run and that everything is ready to work with (saves us having to validate everything again).
232
-		if ( ! $this->_verified ) {
232
+		if ( ! $this->_verified) {
233 233
 			return false; //get out because we don't have a valid setup to work with.
234 234
 		}
235 235
 
@@ -239,35 +239,35 @@  discard block
 block discarded – undo
239 239
 				$this->_current_data_handler,
240 240
 				$this->_generation_queue->get_message_repository()->current()->context()
241 241
 			);
242
-		} catch ( EE_Error $e ) {
242
+		} catch (EE_Error $e) {
243 243
 			$this->_error_msg[] = $e->getMessage();
244 244
 			return false;
245 245
 		}
246 246
 
247 247
 
248 248
 		//if no addressees then get out because there is nothing to generation (possible bad data).
249
-		if ( ! $this->_valid_addressees( $addressees ) ) {
250
-			do_action( 'AHEE__EE_Messages_Generator___generate__invalid_addressees', $this->_generation_queue->get_message_repository()->current(), $addressees, $this->_current_messenger, $this->_current_message_type, $this->_current_data_handler );
251
-			$this->_generation_queue->get_message_repository()->current()->set_STS_ID( EEM_Message::status_debug_only );
252
-			$this->_error_msg[] = __( 'This is not a critical error but an informational notice. Unable to generate messages EE_Messages_Addressee objects.  There were no attendees prepared by the data handler.
253
-			  Sometimes this is because messages only get generated for certain registration statuses. For example, the ticket notice message type only goes to approved registrations.', 'event_espresso' );
249
+		if ( ! $this->_valid_addressees($addressees)) {
250
+			do_action('AHEE__EE_Messages_Generator___generate__invalid_addressees', $this->_generation_queue->get_message_repository()->current(), $addressees, $this->_current_messenger, $this->_current_message_type, $this->_current_data_handler);
251
+			$this->_generation_queue->get_message_repository()->current()->set_STS_ID(EEM_Message::status_debug_only);
252
+			$this->_error_msg[] = __('This is not a critical error but an informational notice. Unable to generate messages EE_Messages_Addressee objects.  There were no attendees prepared by the data handler.
253
+			  Sometimes this is because messages only get generated for certain registration statuses. For example, the ticket notice message type only goes to approved registrations.', 'event_espresso');
254 254
 			return false;
255 255
 		}
256 256
 
257 257
 		$message_template_group = $this->_get_message_template_group();
258 258
 
259 259
 		//in the unlikely event there is no EE_Message_Template_Group available, get out!
260
-		if ( ! $message_template_group instanceof EE_Message_Template_Group ) {
261
-			$this->_error_msg[] = __( 'Unable to get the Message Templates for the Message being generated.  No message template group accessible.', 'event_espresso' );
260
+		if ( ! $message_template_group instanceof EE_Message_Template_Group) {
261
+			$this->_error_msg[] = __('Unable to get the Message Templates for the Message being generated.  No message template group accessible.', 'event_espresso');
262 262
 			return false;
263 263
 		}
264 264
 
265 265
 		//get formatted templates for using to parse and setup EE_Message objects.
266
-		$templates = $this->_get_templates( $message_template_group );
266
+		$templates = $this->_get_templates($message_template_group);
267 267
 
268 268
 
269 269
 		//setup new EE_Message objects (and add to _ready_queue)
270
-		return $this->_assemble_messages( $addressees, $templates, $message_template_group );
270
+		return $this->_assemble_messages($addressees, $templates, $message_template_group);
271 271
 	}
272 272
 
273 273
 
@@ -285,18 +285,18 @@  discard block
 block discarded – undo
285 285
 		//so let's use that.
286 286
 		$GRP_ID = $this->_generation_queue->get_message_repository()->current()->GRP_ID();
287 287
 
288
-		if ( $GRP_ID ) {
288
+		if ($GRP_ID) {
289 289
 			//attempt to retrieve from repo first
290
-			$GRP = $this->_template_collection->get_by_ID( $GRP_ID );
291
-			if ( $GRP instanceof EE_Message_Template_Group ) {
292
-				return $GRP;  //got it!
290
+			$GRP = $this->_template_collection->get_by_ID($GRP_ID);
291
+			if ($GRP instanceof EE_Message_Template_Group) {
292
+				return $GRP; //got it!
293 293
 			}
294 294
 
295 295
 			//nope don't have it yet.  Get from DB then add to repo if its not here, then that means the current GRP_ID
296 296
 			//is not valid, so we'll continue on in the code assuming there's NO GRP_ID.
297
-			$GRP = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
298
-			if ( $GRP instanceof EE_Message_Template_Group ) {
299
-				$this->_template_collection->add( $GRP );
297
+			$GRP = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
298
+			if ($GRP instanceof EE_Message_Template_Group) {
299
+				$this->_template_collection->add($GRP);
300 300
 				return $GRP;
301 301
 			}
302 302
 		}
@@ -315,41 +315,41 @@  discard block
 block discarded – undo
315 315
 		//in vanilla EE we're assuming there's only one event.
316 316
 		//However, if there are multiple events then we'll just use the default templates instead of different
317 317
 		// templates per event (which could create problems).
318
-		if ( count( $this->_current_data_handler->events ) === 1 ) {
319
-			foreach ( $this->_current_data_handler->events as $event ) {
318
+		if (count($this->_current_data_handler->events) === 1) {
319
+			foreach ($this->_current_data_handler->events as $event) {
320 320
 				$EVT_ID = $event['ID'];
321 321
 			}
322 322
 		}
323 323
 
324 324
 		//before going any further, let's see if its in the queue
325
-		$GRP = $this->_template_collection->get_by_key( $this->_template_collection->get_key( $this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID ) );
325
+		$GRP = $this->_template_collection->get_by_key($this->_template_collection->get_key($this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID));
326 326
 
327
-		if ( $GRP instanceof EE_Message_Template_Group ) {
327
+		if ($GRP instanceof EE_Message_Template_Group) {
328 328
 			return $GRP;
329 329
 		}
330 330
 
331 331
 		//nope still no GRP?
332 332
 		//first we get the global template in case it has an override set.
333
-		$global_template_qa = array_merge( array( 'MTP_is_global' => true ), $template_qa );
334
-		$global_GRP = EEM_Message_Template_Group::instance()->get_one( array( $global_template_qa ) );
333
+		$global_template_qa = array_merge(array('MTP_is_global' => true), $template_qa);
334
+		$global_GRP = EEM_Message_Template_Group::instance()->get_one(array($global_template_qa));
335 335
 
336 336
 		//if this is an override, then we just return it.
337
-		if ( $global_GRP instanceof EE_Message_Template_Group && $global_GRP->get( 'MTP_is_override' ) ) {
338
-			$this->_template_collection->add( $global_GRP, $EVT_ID );
337
+		if ($global_GRP instanceof EE_Message_Template_Group && $global_GRP->get('MTP_is_override')) {
338
+			$this->_template_collection->add($global_GRP, $EVT_ID);
339 339
 			return $global_GRP;
340 340
 		}
341 341
 
342 342
 		//STILL here? Okay that means we want to see if there is event specific group and if there is we return it,
343 343
 		//otherwise we return the global group we retrieved.
344
-		if ( $EVT_ID ) {
344
+		if ($EVT_ID) {
345 345
 			$template_qa['Event.EVT_ID'] = $EVT_ID;
346 346
 		}
347 347
 
348
-		$GRP = EEM_Message_Template_Group::instance()->get_one( array( $template_qa ) );
348
+		$GRP = EEM_Message_Template_Group::instance()->get_one(array($template_qa));
349 349
 		$GRP = $GRP instanceof EE_Message_Template_Group ? $GRP : $global_GRP;
350 350
 
351
-		if ( $GRP instanceof EE_Message_Template_Group ) {
352
-			$this->_template_collection->add( $GRP, $EVT_ID );
351
+		if ($GRP instanceof EE_Message_Template_Group) {
352
+			$this->_template_collection->add($GRP, $EVT_ID);
353 353
 			return $GRP;
354 354
 		}
355 355
 
@@ -373,15 +373,15 @@  discard block
 block discarded – undo
373 373
 	 *                      )
374 374
 	 *                  )
375 375
 	 */
376
-	protected function _get_templates( EE_Message_Template_Group $message_template_group ) {
376
+	protected function _get_templates(EE_Message_Template_Group $message_template_group) {
377 377
 		$templates = array();
378 378
 		$context_templates = $message_template_group->context_templates();
379
-		foreach ( $context_templates as $context => $template_fields ) {
380
-			foreach ( $template_fields as $template_field => $template_obj ) {
381
-				if ( ! $template_obj instanceof EE_Message_Template ) {
379
+		foreach ($context_templates as $context => $template_fields) {
380
+			foreach ($template_fields as $template_field => $template_obj) {
381
+				if ( ! $template_obj instanceof EE_Message_Template) {
382 382
 					continue;
383 383
 				}
384
-				$templates[ $template_field ][ $context ] = $template_obj->get( 'MTP_content' );
384
+				$templates[$template_field][$context] = $template_obj->get('MTP_content');
385 385
 			}
386 386
 		}
387 387
 		return $templates;
@@ -403,21 +403,21 @@  discard block
 block discarded – undo
403 403
 	 *                get added to the queue with EEM_Message::status_idle, unsuccessfully generated messages will get added
404 404
 	 *                to the queue as EEM_Message::status_failed.  Very rarely should "false" be returned from this method.
405 405
 	 */
406
-	protected function _assemble_messages( $addressees, $templates, EE_Message_Template_Group $message_template_group ) {
406
+	protected function _assemble_messages($addressees, $templates, EE_Message_Template_Group $message_template_group) {
407 407
 
408 408
 		//if templates are empty then get out because we can't generate anything.
409
-		if ( ! $templates ) {
410
-			$this->_error_msg[] = __( 'Unable to assemble messages because there are no templates retrieved for generating the messages with', 'event_espresso' );
409
+		if ( ! $templates) {
410
+			$this->_error_msg[] = __('Unable to assemble messages because there are no templates retrieved for generating the messages with', 'event_espresso');
411 411
 			return false;
412 412
 		}
413 413
 
414 414
 		//We use this as the counter for generated messages because don't forget we may be executing this inside of a
415 415
 		//generation_queue.  So _ready_queue may have generated EE_Message objects already.
416 416
 		$generated_count = 0;
417
-		foreach ( $addressees as $context => $recipients ) {
418
-			foreach ( $recipients as $recipient ) {
419
-				$message = $this->_setup_message_object( $context, $recipient, $templates, $message_template_group );
420
-				if ( $message instanceof EE_Message ) {
417
+		foreach ($addressees as $context => $recipients) {
418
+			foreach ($recipients as $recipient) {
419
+				$message = $this->_setup_message_object($context, $recipient, $templates, $message_template_group);
420
+				if ($message instanceof EE_Message) {
421 421
 					$this->_ready_queue->add(
422 422
 						$message,
423 423
 						array(),
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 				}
429 429
 
430 430
 				//if the current MSG being generated is for a test send then we'll only use ONE message in the generation.
431
-				if ( $this->_generation_queue->get_message_repository()->is_test_send() ) {
431
+				if ($this->_generation_queue->get_message_repository()->is_test_send()) {
432 432
 					break 2;
433 433
 				}
434 434
 			}
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 	) {
458 458
 		//stuff we already know
459 459
 		$transaction_id = $recipient->txn instanceof EE_Transaction ? $recipient->txn->ID() : 0;
460
-		$transaction_id = empty( $transaction_id ) && $this->_current_data_handler->txn instanceof EE_Transaction
460
+		$transaction_id = empty($transaction_id) && $this->_current_data_handler->txn instanceof EE_Transaction
461 461
 			? $this->_current_data_handler->txn->ID()
462 462
 			: $transaction_id;
463 463
 		$message_fields = array(
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 
471 471
 		//recipient id and type should be on the EE_Messages_Addressee object but if this is empty, let's try to grab the
472 472
 		//info from the att_obj found in the EE_Messages_Addressee object.
473
-		if ( empty( $recipient->recipient_id ) || empty( $recipient->recipient_type ) ) {
473
+		if (empty($recipient->recipient_id) || empty($recipient->recipient_type)) {
474 474
 			$message_fields['MSG_recipient_ID'] = $recipient->att_obj instanceof EE_Attendee
475 475
 				? $recipient->att_obj->ID()
476 476
 				: 0;
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 			$message_fields['MSG_recipient_ID'] = $recipient->recipient_id;
480 480
 			$message_fields['MSG_recipient_type'] = $recipient->recipient_type;
481 481
 		}
482
-		$message = EE_Message_Factory::create( $message_fields );
482
+		$message = EE_Message_Factory::create($message_fields);
483 483
 
484 484
 		//grab valid shortcodes for shortcode parser
485 485
 		$mt_shortcodes = $this->_current_message_type->get_valid_shortcodes();
@@ -487,43 +487,43 @@  discard block
 block discarded – undo
487 487
 
488 488
 		//if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because that means this
489 489
 		//context is turned off) EXCEPT if we're previewing
490
-		if ( empty( $templates['to'][ $context ] )
490
+		if (empty($templates['to'][$context])
491 491
 		     && ! $this->_generation_queue->get_message_repository()->is_preview()
492
-		     && ! $this->_current_messenger->allow_empty_to_field() ) {
492
+		     && ! $this->_current_messenger->allow_empty_to_field()) {
493 493
 			//we silently exit here and do NOT record a fail because the message is "turned off" by having no "to" field.
494 494
 			return false;
495 495
 		}
496 496
 		$error_msg = array();
497
-		foreach ( $templates as $field => $field_context ) {
497
+		foreach ($templates as $field => $field_context) {
498 498
 			$error_msg = array();
499 499
 			//let's setup the valid shortcodes for the incoming context.
500
-			$valid_shortcodes = $mt_shortcodes[ $context ];
500
+			$valid_shortcodes = $mt_shortcodes[$context];
501 501
 			//merge in valid shortcodes for the field.
502
-			$shortcodes = isset($m_shortcodes[ $field ]) ? $m_shortcodes[ $field ] : $valid_shortcodes;
503
-			if ( isset( $templates[ $field ][ $context ] ) ) {
502
+			$shortcodes = isset($m_shortcodes[$field]) ? $m_shortcodes[$field] : $valid_shortcodes;
503
+			if (isset($templates[$field][$context])) {
504 504
 				//prefix field.
505
-				$column_name = 'MSG_' . $field;
505
+				$column_name = 'MSG_'.$field;
506 506
 				try {
507 507
 					$content = $this->_shortcode_parser->parse_message_template(
508
-						$templates[ $field ][ $context ],
508
+						$templates[$field][$context],
509 509
 						$recipient,
510 510
 						$shortcodes,
511 511
 						$this->_current_message_type,
512 512
 						$this->_current_messenger,
513 513
 						$message );
514
-					$message->set_field_or_extra_meta( $column_name, $content );
515
-				} catch ( EE_Error $e ) {
516
-					$error_msg[] = sprintf( __( 'There was a problem generating the content for the field %s: %s', 'event_espresso' ), $field, $e->getMessage() );
517
-					$message->set_STS_ID( EEM_Message::status_failed );
514
+					$message->set_field_or_extra_meta($column_name, $content);
515
+				} catch (EE_Error $e) {
516
+					$error_msg[] = sprintf(__('There was a problem generating the content for the field %s: %s', 'event_espresso'), $field, $e->getMessage());
517
+					$message->set_STS_ID(EEM_Message::status_failed);
518 518
 				}
519 519
 			}
520 520
 		}
521 521
 
522
-		if ( $message->STS_ID() === EEM_Message::status_failed ) {
523
-			$error_msg = __( 'There were problems generating this message:', 'event_espresso' ) . "\n" . implode( "\n", $error_msg );
524
-			$message->set_error_message( $error_msg );
522
+		if ($message->STS_ID() === EEM_Message::status_failed) {
523
+			$error_msg = __('There were problems generating this message:', 'event_espresso')."\n".implode("\n", $error_msg);
524
+			$message->set_error_message($error_msg);
525 525
 		} else {
526
-			$message->set_STS_ID( EEM_Message::status_idle );
526
+			$message->set_STS_ID(EEM_Message::status_idle);
527 527
 		}
528 528
 		return $message;
529 529
 	}
@@ -557,14 +557,14 @@  discard block
 block discarded – undo
557 557
 	 * @param array $addressees  Keys correspond to contexts for the message type and values are EE_Messages_Addressee[]
558 558
 	 * @return bool
559 559
 	 */
560
-	protected function _valid_addressees( $addressees ) {
561
-		if ( ! $addressees || ! is_array( $addressees ) ) {
560
+	protected function _valid_addressees($addressees) {
561
+		if ( ! $addressees || ! is_array($addressees)) {
562 562
 			return false;
563 563
 		}
564 564
 
565
-		foreach ( $addressees as $addressee_array ) {
566
-			foreach ( $addressee_array as $addressee ) {
567
-				if ( ! $addressee instanceof EE_Messages_Addressee ) {
565
+		foreach ($addressees as $addressee_array) {
566
+			foreach ($addressee_array as $addressee) {
567
+				if ( ! $addressee instanceof EE_Messages_Addressee) {
568 568
 					return false;
569 569
 				}
570 570
 			}
@@ -585,19 +585,19 @@  discard block
 block discarded – undo
585 585
 	protected function _validate_messenger_and_message_type() {
586 586
 
587 587
 		//first are there any existing error messages?  If so then return.
588
-		if ( $this->_error_msg ) {
588
+		if ($this->_error_msg) {
589 589
 			return false;
590 590
 		}
591 591
 		/** @type EE_Message $message */
592 592
 		$message = $this->_generation_queue->get_message_repository()->current();
593 593
 		try {
594
-			$this->_current_messenger = $message->valid_messenger( true ) ? $message->messenger_object() : null;
595
-		} catch ( Exception $e ) {
594
+			$this->_current_messenger = $message->valid_messenger(true) ? $message->messenger_object() : null;
595
+		} catch (Exception $e) {
596 596
 			$this->_error_msg[] = $e->getMessage();
597 597
 		}
598 598
 		try {
599
-			$this->_current_message_type = $message->valid_message_type( true ) ? $message->message_type_object() : null;
600
-		} catch ( Exception $e ) {
599
+			$this->_current_message_type = $message->valid_message_type(true) ? $message->message_type_object() : null;
600
+		} catch (Exception $e) {
601 601
 			$this->_error_msg[] = $e->getMessage();
602 602
 		}
603 603
 
@@ -609,10 +609,10 @@  discard block
 block discarded – undo
609 609
 			     ! $this->_generation_queue->get_message_repository()->is_preview()
610 610
 			     && $this->_generation_queue->get_message_repository()->get_data_handler() !== 'EE_Messages_Preview_incoming_data' )
611 611
 		) {
612
-			$this->_error_msg[] = __( 'There is no generation data for this message. Unable to generate.' );
612
+			$this->_error_msg[] = __('There is no generation data for this message. Unable to generate.');
613 613
 		}
614 614
 
615
-		return empty( $this->_error_msg );
615
+		return empty($this->_error_msg);
616 616
 	}
617 617
 
618 618
 
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 
630 630
 		//First, are there any existing error messages?  If so, return because if there were errors elsewhere this can't
631 631
 		//be used anyways.
632
-		if ( $this->_error_msg ) {
632
+		if ($this->_error_msg) {
633 633
 			return false;
634 634
 		}
635 635
 
@@ -638,29 +638,29 @@  discard block
 block discarded – undo
638 638
 		/** @type EE_Messages_incoming_data $data_handler_class_name - well not really... just the class name actually */
639 639
 		$data_handler_class_name = $this->_generation_queue->get_message_repository()->get_data_handler()
640 640
 			? $this->_generation_queue->get_message_repository()->get_data_handler()
641
-			: 'EE_Messages_' .  $this->_current_message_type->get_data_handler( $generation_data ) . '_incoming_data';
641
+			: 'EE_Messages_'.$this->_current_message_type->get_data_handler($generation_data).'_incoming_data';
642 642
 
643 643
 		//If this EE_Message is for a preview, then let's switch out to the preview data handler.
644
-		if ( $this->_generation_queue->get_message_repository()->is_preview() ) {
645
-			$data_handler_class_name  = 'EE_Messages_Preview_incoming_data';
644
+		if ($this->_generation_queue->get_message_repository()->is_preview()) {
645
+			$data_handler_class_name = 'EE_Messages_Preview_incoming_data';
646 646
 		}
647 647
 
648 648
 		//First get the class name for the data handler (and also verifies it exists.
649
-		if ( ! class_exists( $data_handler_class_name ) ) {
649
+		if ( ! class_exists($data_handler_class_name)) {
650 650
 			$this->_error_msg[] = sprintf(
651
-				__( 'The included data handler class name does not match any valid, accessible, "EE_Messages_incoming_data" classes.  Looking for %s.', 'event_espresso' ),
651
+				__('The included data handler class name does not match any valid, accessible, "EE_Messages_incoming_data" classes.  Looking for %s.', 'event_espresso'),
652 652
 				$data_handler_class_name
653 653
 			);
654 654
 			return false;
655 655
 		}
656 656
 
657 657
 		//convert generation_data for data_handler_instantiation.
658
-		$generation_data = $data_handler_class_name::convert_data_from_persistent_storage( $generation_data );
658
+		$generation_data = $data_handler_class_name::convert_data_from_persistent_storage($generation_data);
659 659
 
660 660
 		//note, this may set error messages as well.
661
-		$this->_set_data_handler( $generation_data, $data_handler_class_name );
661
+		$this->_set_data_handler($generation_data, $data_handler_class_name);
662 662
 
663
-		return empty( $this->_error_msg );
663
+		return empty($this->_error_msg);
664 664
 	}
665 665
 
666 666
 
@@ -677,16 +677,16 @@  discard block
 block discarded – undo
677 677
 	 *
678 678
 	 * @return void.
679 679
 	 */
680
-	protected function _set_data_handler( $generating_data, $data_handler_class_name ) {
680
+	protected function _set_data_handler($generating_data, $data_handler_class_name) {
681 681
 		//valid classname for the data handler.  Now let's setup the key for the data handler repository to see if there
682 682
 		//is already a ready data handler in the repository.
683
-		$this->_current_data_handler = $this->_data_handler_collection->get_by_key( $this->_data_handler_collection->get_key( $data_handler_class_name, $generating_data ) );
684
-		if ( ! $this->_current_data_handler instanceof EE_Messages_incoming_data ) {
683
+		$this->_current_data_handler = $this->_data_handler_collection->get_by_key($this->_data_handler_collection->get_key($data_handler_class_name, $generating_data));
684
+		if ( ! $this->_current_data_handler instanceof EE_Messages_incoming_data) {
685 685
 			//no saved data_handler in the repo so let's set one up and add it to the repo.
686 686
 			try {
687
-				$this->_current_data_handler = new $data_handler_class_name( $generating_data );
688
-				$this->_data_handler_collection->add( $this->_current_data_handler, $generating_data );
689
-			} catch( EE_Error $e ) {
687
+				$this->_current_data_handler = new $data_handler_class_name($generating_data);
688
+				$this->_data_handler_collection->add($this->_current_data_handler, $generating_data);
689
+			} catch (EE_Error $e) {
690 690
 				$this->_error_msg[] = $e->get_error();
691 691
 			}
692 692
 		}
@@ -706,13 +706,13 @@  discard block
 block discarded – undo
706 706
 	 * @param bool                   $preview Indicate whether this is being used for a preview or not.
707 707
 	 * @return mixed Prepped data for persisting to the queue.  false is returned if unable to prep data.
708 708
 	 */
709
-	protected function _prepare_data_for_queue( EE_Message_To_Generate $message_to_generate, $preview ) {
709
+	protected function _prepare_data_for_queue(EE_Message_To_Generate $message_to_generate, $preview) {
710 710
 		/** @type EE_Messages_incoming_data $data_handler - well not really... just the class name actually */
711
-		$data_handler = $message_to_generate->get_data_handler_class_name( $preview );
712
-		if ( ! $message_to_generate->valid() ) {
711
+		$data_handler = $message_to_generate->get_data_handler_class_name($preview);
712
+		if ( ! $message_to_generate->valid()) {
713 713
 			return false; //unable to get the data because the info in the EE_Message_To_Generate class is invalid.
714 714
 		}
715
-		return $data_handler::convert_data_for_persistent_storage( $message_to_generate->data() );
715
+		return $data_handler::convert_data_for_persistent_storage($message_to_generate->data());
716 716
 	}
717 717
 
718 718
 
@@ -725,26 +725,26 @@  discard block
 block discarded – undo
725 725
 	 * @param EE_Message_To_Generate $message_to_generate
726 726
 	 * @param bool                   $test_send Whether this is just a test send or not.  Typically used for previews.
727 727
 	 */
728
-	public function create_and_add_message_to_queue( EE_Message_To_Generate $message_to_generate, $test_send = false ) {
728
+	public function create_and_add_message_to_queue(EE_Message_To_Generate $message_to_generate, $test_send = false) {
729 729
 		//prep data
730
-		$data = $this->_prepare_data_for_queue( $message_to_generate, $message_to_generate->preview() );
730
+		$data = $this->_prepare_data_for_queue($message_to_generate, $message_to_generate->preview());
731 731
 
732 732
 		$message = $message_to_generate->get_EE_Message();
733 733
 
734 734
 		//is there a GRP_ID in the request?
735
-		if ( $GRP_ID = EE_Registry::instance()->REQ->get( 'GRP_ID' ) ) {
736
-			$message->set_GRP_ID( $GRP_ID );
735
+		if ($GRP_ID = EE_Registry::instance()->REQ->get('GRP_ID')) {
736
+			$message->set_GRP_ID($GRP_ID);
737 737
 		}
738 738
 
739
-		if ( $data === false ) {
740
-			$message->set_STS_ID( EEM_Message::status_failed );
741
-			$message->set_error_message( __( 'Unable to prepare data for persistence to the database.', 'event_espresso' ) );
739
+		if ($data === false) {
740
+			$message->set_STS_ID(EEM_Message::status_failed);
741
+			$message->set_error_message(__('Unable to prepare data for persistence to the database.', 'event_espresso'));
742 742
 		} else {
743 743
 			//make sure that the data handler is cached on the message as well
744 744
 			$data['data_handler_class_name'] = $message_to_generate->get_data_handler_class_name();
745 745
 		}
746 746
 
747
-		$this->_generation_queue->add( $message, $data, $message_to_generate->preview(), $test_send );
747
+		$this->_generation_queue->add($message, $data, $message_to_generate->preview(), $test_send);
748 748
 	}
749 749
 
750 750
 
Please login to merge, or discard this patch.