Completed
Branch FEAT-7553-PayPal-Express-PM (ff03cf)
by
unknown
77:21 queued 61:39
created
core/helpers/EEH_Template.helper.php 1 patch
Spacing   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 
17 17
 
18
-if ( ! function_exists( 'espresso_get_template_part' )) {
18
+if ( ! function_exists('espresso_get_template_part')) {
19 19
 	/**
20 20
 	 * espresso_get_template_part
21 21
 	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
 	 * @param string $name The name of the specialised template.
26 26
 	 * @return string        the html output for the formatted money value
27 27
 	 */
28
-	function espresso_get_template_part( $slug = NULL, $name = NULL ) {
29
-		EEH_Template::get_template_part( $slug, $name );
28
+	function espresso_get_template_part($slug = NULL, $name = NULL) {
29
+		EEH_Template::get_template_part($slug, $name);
30 30
 	}
31 31
 }
32 32
 
33 33
 
34 34
 
35
-if ( ! function_exists( 'espresso_get_object_css_class' )) {
35
+if ( ! function_exists('espresso_get_object_css_class')) {
36 36
 	/**
37 37
 	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
38 38
 	 *
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @param  string $suffix added to the end of the generated class
43 43
 	 * @return string
44 44
 	 */
45
-	function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) {
46
-		return EEH_Template::get_object_css_class( $object, $prefix, $suffix );
45
+	function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') {
46
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
47 47
 	}
48 48
 }
49 49
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 * 	@return boolean
71 71
 	 */
72 72
 	public static function is_espresso_theme() {
73
-		return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE;
73
+		return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE;
74 74
 	}
75 75
 
76 76
 	/**
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	 * 	@return void
80 80
 	 */
81 81
 	public static function load_espresso_theme_functions() {
82
-		if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) {
83
-			if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) {
84
-				require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' );
82
+		if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
83
+			if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) {
84
+				require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php');
85 85
 			}
86 86
 		}
87 87
 	}
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 	 * 	@return array
94 94
 	 */
95 95
 	public static function get_espresso_themes() {
96
-		if ( empty( EEH_Template::$_espresso_themes )) {
97
-			$espresso_themes =  glob( EE_PUBLIC . '*', GLOB_ONLYDIR );
98
-			if ( empty( $espresso_themes ) ) {
96
+		if (empty(EEH_Template::$_espresso_themes)) {
97
+			$espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
98
+			if (empty($espresso_themes)) {
99 99
 				return array();
100 100
 			}
101
-			if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) {
102
-			    unset( $espresso_themes[ $key ] );
101
+			if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) {
102
+			    unset($espresso_themes[$key]);
103 103
 			}
104 104
 			EEH_Template::$_espresso_themes = array();
105
-			foreach ( $espresso_themes as $espresso_theme ) {
106
-				EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme;
105
+			foreach ($espresso_themes as $espresso_theme) {
106
+				EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
107 107
 			}
108 108
 		}
109 109
 		return EEH_Template::$_espresso_themes;
@@ -122,16 +122,16 @@  discard block
 block discarded – undo
122 122
 	 * @param bool   $return_string
123 123
 	 * @return string        the html output for the formatted money value
124 124
 	 */
125
-	public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE  ) {
126
-		do_action( "get_template_part_{$slug}-{$name}", $slug, $name );
125
+	public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) {
126
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
127 127
 		$templates = array();
128 128
 		$name = (string) $name;
129
-		if ( $name != '' ) {
129
+		if ($name != '') {
130 130
 			$templates[] = "{$slug}-{$name}.php";
131 131
 		}
132 132
 		// allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
133
-		if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) {
134
-			EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string );
133
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) {
134
+			EEH_Template::locate_template($templates, $template_args, TRUE, $return_string);
135 135
 		}
136 136
 	}
137 137
 
@@ -182,26 +182,26 @@  discard block
 block discarded – undo
182 182
 	 * 				Used in places where you don't actually load the template, you just want to know if there's a custom version of it.
183 183
 	 * @return mixed
184 184
 	 */
185
-	public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) {
185
+	public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) {
186 186
 		// first use WP locate_template to check for template in the current theme folder
187
-		$template_path = locate_template( $templates );
187
+		$template_path = locate_template($templates);
188 188
 
189
-		if ( $check_if_custom && !empty( $template_path ) )
189
+		if ($check_if_custom && ! empty($template_path))
190 190
 			return TRUE;
191 191
 
192 192
 		// not in the theme
193
-		if ( empty( $template_path )) {
193
+		if (empty($template_path)) {
194 194
 			// not even a template to look for ?
195
-			if ( empty( $templates )) {
195
+			if (empty($templates)) {
196 196
 				// get post_type
197
-				$post_type = EE_Registry::instance()->REQ->get( 'post_type' );
197
+				$post_type = EE_Registry::instance()->REQ->get('post_type');
198 198
 				// get array of EE Custom Post Types
199 199
 				$EE_CPTs = EE_Register_CPTs::get_CPTs();
200 200
 				// build template name based on request
201
-				if ( isset( $EE_CPTs[ $post_type ] )) {
202
-					$archive_or_single =  is_archive() ? 'archive' : '';
203
-					$archive_or_single =  is_single() ? 'single' : $archive_or_single;
204
-					$templates = $archive_or_single . '-' . $post_type . '.php';
201
+				if (isset($EE_CPTs[$post_type])) {
202
+					$archive_or_single = is_archive() ? 'archive' : '';
203
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
204
+					$templates = $archive_or_single.'-'.$post_type.'.php';
205 205
 				}
206 206
 			}
207 207
 			// currently active EE template theme
@@ -210,81 +210,81 @@  discard block
 block discarded – undo
210 210
 			// array of paths to folders that may contain templates
211 211
 			$template_folder_paths = array(
212 212
 				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
213
-				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
213
+				EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
214 214
 				// then in the root of the /wp-content/uploads/espresso/templates/ folder
215 215
 				EVENT_ESPRESSO_TEMPLATE_DIR
216 216
 			);
217 217
 
218 218
 			//add core plugin folders for checking only if we're not $check_if_custom
219
-			if ( ! $check_if_custom ) {
219
+			if ( ! $check_if_custom) {
220 220
 				$core_paths = array(
221 221
 					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
222
-					EE_PUBLIC . $current_theme,
222
+					EE_PUBLIC.$current_theme,
223 223
 					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
224
-					EE_TEMPLATES . $current_theme,
224
+					EE_TEMPLATES.$current_theme,
225 225
 					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
226 226
 					EE_PLUGIN_DIR_PATH
227 227
 					);
228
-				$template_folder_paths = array_merge( $template_folder_paths, $core_paths );
228
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
229 229
 			}
230 230
 
231 231
 			// now filter that array
232
-			$template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths );
233
-			$templates = is_array( $templates ) ? $templates : array( $templates );
234
-			$template_folder_paths = is_array( $template_folder_paths ) ? $template_folder_paths : array( $template_folder_paths );
232
+			$template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths);
233
+			$templates = is_array($templates) ? $templates : array($templates);
234
+			$template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths);
235 235
 			// array to hold all possible template paths
236 236
 			$full_template_paths = array();
237 237
 
238 238
 			// loop through $templates
239
-			foreach ( $templates as $template ) {
239
+			foreach ($templates as $template) {
240 240
 				// normalize directory separators
241
-				$template = EEH_File::standardise_directory_separators( $template );
242
-				$file_name = basename( $template );
243
-				$template_path_minus_file_name = substr( $template, 0, ( strlen( $file_name ) * -1 ) );
241
+				$template = EEH_File::standardise_directory_separators($template);
242
+				$file_name = basename($template);
243
+				$template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
244 244
 				// while looping through all template folder paths
245
-				foreach ( $template_folder_paths as $template_folder_path ) {
245
+				foreach ($template_folder_paths as $template_folder_path) {
246 246
 					// normalize directory separators
247
-					$template_folder_path = EEH_File::standardise_directory_separators( $template_folder_path );
247
+					$template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
248 248
 					// determine if any common base path exists between the two paths
249 249
 					$common_base_path = EEH_Template::_find_common_base_path(
250
-						array( $template_folder_path, $template_path_minus_file_name )
250
+						array($template_folder_path, $template_path_minus_file_name)
251 251
 					);
252
-					if ( $common_base_path !== '' ) {
252
+					if ($common_base_path !== '') {
253 253
 						// both paths have a common base, so just tack the filename onto our search path
254
-						$resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $file_name;
254
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name;
255 255
 					} else {
256 256
 						// no common base path, so let's just concatenate
257
-						$resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $template;
257
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template;
258 258
 					}
259 259
 					// build up our template locations array by adding our resolved paths
260 260
 					$full_template_paths[] = $resolved_path;
261 261
 				}
262 262
 				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
263
-				array_unshift( $full_template_paths, $template );
263
+				array_unshift($full_template_paths, $template);
264 264
 				// path to the directory of the current theme: /wp-content/themes/(current WP theme)/
265
-				array_unshift( $full_template_paths, get_stylesheet_directory() . DS . $file_name );
265
+				array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name);
266 266
 			}
267 267
 			// filter final array of full template paths
268
-			$full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name );
268
+			$full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name);
269 269
 			// now loop through our final array of template location paths and check each location
270
-			foreach ( (array)$full_template_paths as $full_template_path ) {
271
-				if ( is_readable( $full_template_path )) {
272
-					$template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path );
270
+			foreach ((array) $full_template_paths as $full_template_path) {
271
+				if (is_readable($full_template_path)) {
272
+					$template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
273 273
 					// hook that can be used to display the full template path that will be used
274
-					do_action( 'AHEE__EEH_Template__locate_template__full_template_path', $template_path );
274
+					do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
275 275
 					break;
276 276
 				}
277 277
 			}
278 278
 		}
279 279
 		// if we got it and you want to see it...
280
-		if ( $template_path && $load && ! $check_if_custom  ) {
281
-			if ( $return_string ) {
282
-				return EEH_Template::display_template( $template_path, $template_args, TRUE );
280
+		if ($template_path && $load && ! $check_if_custom) {
281
+			if ($return_string) {
282
+				return EEH_Template::display_template($template_path, $template_args, TRUE);
283 283
 			} else {
284
-				EEH_Template::display_template( $template_path, $template_args, FALSE );
284
+				EEH_Template::display_template($template_path, $template_args, FALSE);
285 285
 			}
286 286
 		}
287
-		return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path;
287
+		return $check_if_custom && ! empty($template_path) ? TRUE : $template_path;
288 288
 	}
289 289
 
290 290
 
@@ -297,21 +297,21 @@  discard block
 block discarded – undo
297 297
 	 * @param array $paths
298 298
 	 * @return string
299 299
 	 */
300
-	protected static function _find_common_base_path( $paths ) {
300
+	protected static function _find_common_base_path($paths) {
301 301
 		$last_offset = 0;
302 302
 		$common_base_path = '';
303
-		while ( ( $index = strpos( $paths[ 0 ], DS, $last_offset ) ) !== false ) {
303
+		while (($index = strpos($paths[0], DS, $last_offset)) !== false) {
304 304
 			$dir_length = $index - $last_offset + 1;
305
-			$directory = substr( $paths[ 0 ], $last_offset, $dir_length );
306
-			foreach ( $paths as $path ) {
307
-				if ( substr( $path, $last_offset, $dir_length ) != $directory ) {
305
+			$directory = substr($paths[0], $last_offset, $dir_length);
306
+			foreach ($paths as $path) {
307
+				if (substr($path, $last_offset, $dir_length) != $directory) {
308 308
 					return $common_base_path;
309 309
 				}
310 310
 			}
311 311
 			$common_base_path .= $directory;
312 312
 			$last_offset = $index + 1;
313 313
 		}
314
-		return substr( $common_base_path, 0, -1 );
314
+		return substr($common_base_path, 0, -1);
315 315
 	}
316 316
 
317 317
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	 * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
324 324
 	 * @return mixed string
325 325
 	 */
326
-	public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) {
326
+	public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) {
327 327
 
328 328
 		/**
329 329
 		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
@@ -334,26 +334,26 @@  discard block
 block discarded – undo
334 334
 		 *
335 335
 		 * @since 4.6.0
336 336
 		 */
337
-		$template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path );
338
-		$template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args );
337
+		$template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
338
+		$template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
339 339
 
340 340
 		// you gimme nuttin - YOU GET NUTTIN !!
341
-		if ( ! $template_path || ! is_readable( $template_path )) {
341
+		if ( ! $template_path || ! is_readable($template_path)) {
342 342
 			return '';
343 343
 		}
344 344
 		// if $template_args are not in an array, then make it so
345
-		if ( ! is_array( $template_args ) && ! is_object( $template_args )) {
346
-			$template_args = array( $template_args );
345
+		if ( ! is_array($template_args) && ! is_object($template_args)) {
346
+			$template_args = array($template_args);
347 347
 		}
348
-		extract( (array) $template_args);
348
+		extract((array) $template_args);
349 349
 
350
-		if ( $return_string ) {
350
+		if ($return_string) {
351 351
 			// because we want to return a string, we are going to capture the output
352 352
 			ob_start();
353
-			include( $template_path );
353
+			include($template_path);
354 354
 			return ob_get_clean();
355 355
 		} else {
356
-			include( $template_path );
356
+			include($template_path);
357 357
 		}
358 358
 		return '';
359 359
 	}
@@ -371,27 +371,27 @@  discard block
 block discarded – undo
371 371
 	 * @param  string $suffix added to the end of the generated class
372 372
 	 * @return string
373 373
 	 */
374
-	public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) {
374
+	public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') {
375 375
 		// in the beginning...
376
-		$prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : '';
376
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
377 377
 		// da muddle
378 378
 		$class = '';
379 379
 		// the end
380
-		$suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : '';
380
+		$suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
381 381
 		// is the passed object an EE object ?
382
-		if ( $object instanceof EE_Base_Class ) {
382
+		if ($object instanceof EE_Base_Class) {
383 383
 			// grab the exact type of object
384
-			$obj_class = get_class( $object );
384
+			$obj_class = get_class($object);
385 385
 			// depending on the type of object...
386
-			switch ( $obj_class ) {
386
+			switch ($obj_class) {
387 387
 				// no specifics just yet...
388 388
 				default :
389
-					$class = strtolower( str_replace( '_', '-', $obj_class ));
390
-					$class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : '';
389
+					$class = strtolower(str_replace('_', '-', $obj_class));
390
+					$class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
391 391
 
392 392
 			}
393 393
 		}
394
-		return $prefix . $class . $suffix;
394
+		return $prefix.$class.$suffix;
395 395
 	}
396 396
 
397 397
 
@@ -407,54 +407,54 @@  discard block
 block discarded – undo
407 407
 	 * @param string      $cur_code_span_class
408 408
 	 * @return string        the html output for the formatted money value
409 409
 	 */
410
-	public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) {
410
+	public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') {
411 411
 		// ensure amount was received
412
-		if ( is_null( $amount ) ) {
413
-			$msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' );
414
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
412
+		if (is_null($amount)) {
413
+			$msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso');
414
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
415 415
 			return '';
416 416
 		}
417 417
 		//ensure amount is float
418
-		$amount = apply_filters( 'FHEE__EEH_Template__format_currency__raw_amount', (float) $amount );
419
-		$CNT_ISO = apply_filters( 'FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount );
418
+		$amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
419
+		$CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
420 420
 		// filter raw amount (allows 0.00 to be changed to "free" for example)
421
-		$amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw );
421
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
422 422
 		// still a number or was amount converted to a string like "free" ?
423
-		if ( is_float( $amount_formatted )) {
423
+		if (is_float($amount_formatted)) {
424 424
 			// was a country ISO code passed ? if so generate currency config object for that country
425
-			$mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL;
425
+			$mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL;
426 426
 			// verify results
427
-			if ( ! $mny instanceof EE_Currency_Config ) {
427
+			if ( ! $mny instanceof EE_Currency_Config) {
428 428
 				// set default config country currency settings
429 429
 				$mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config();
430 430
 			}
431 431
 			// format float
432
-			$amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds );
432
+			$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
433 433
 			// add formatting ?
434
-			if ( ! $return_raw ) {
434
+			if ( ! $return_raw) {
435 435
 				// add currency sign
436
-				if( $mny->sign_b4 ){
437
-					if( $amount >= 0 ){
438
-						$amount_formatted = $mny->sign . $amount_formatted;
439
-					}else{
440
-						$amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted );
436
+				if ($mny->sign_b4) {
437
+					if ($amount >= 0) {
438
+						$amount_formatted = $mny->sign.$amount_formatted;
439
+					} else {
440
+						$amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
441 441
 					}
442 442
 
443
-				}else{
444
-					$amount_formatted =  $amount_formatted . $mny->sign;
443
+				} else {
444
+					$amount_formatted = $amount_formatted.$mny->sign;
445 445
 				}
446 446
 
447 447
 				// filter to allow global setting of display_code
448
-				$display_code = apply_filters( 'FHEE__EEH_Template__format_currency__display_code', $display_code );
448
+				$display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code);
449 449
 
450 450
 				// add currency code ?
451
-				$amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
451
+				$amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted;
452 452
 			}
453 453
 			// filter results
454
-			$amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw );
454
+			$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw);
455 455
 		}
456 456
 		// clean up vars
457
-		unset( $mny );
457
+		unset($mny);
458 458
 		// return formatted currency amount
459 459
 		return $amount_formatted;
460 460
 	}
@@ -469,11 +469,11 @@  discard block
 block discarded – undo
469 469
 	 * @param  string  $schema    'UPPER', 'lower', or 'Sentence'
470 470
 	 * @return string             The localized label for the status id.
471 471
 	 */
472
-	public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) {
472
+	public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') {
473 473
 		/** @type EEM_Status $EEM_Status */
474
-		$EEM_Status = EE_Registry::instance()->load_model( 'Status' );
475
-		$status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema );
476
-		return $status[ $status_id ];
474
+		$EEM_Status = EE_Registry::instance()->load_model('Status');
475
+		$status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema);
476
+		return $status[$status_id];
477 477
 	}
478 478
 
479 479
 
@@ -488,21 +488,21 @@  discard block
 block discarded – undo
488 488
 	 * @param string  $title
489 489
 	 * @return string the html output for the button
490 490
 	 */
491
-	public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '', $title = '' ) {
491
+	public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') {
492 492
 		$icon_html = '';
493
-		if ( ! empty( $icon ) ) {
494
-			$dashicons = preg_split( "(ee-icon |dashicons )", $icon );
495
-			$dashicons = array_filter( $dashicons );
496
-			$count = count( $dashicons );
493
+		if ( ! empty($icon)) {
494
+			$dashicons = preg_split("(ee-icon |dashicons )", $icon);
495
+			$dashicons = array_filter($dashicons);
496
+			$count = count($dashicons);
497 497
 			$icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
498
-			foreach ( $dashicons as $dashicon ) {
499
-				$type = strpos( $dashicon, 'ee-icon' ) !== false ? 'ee-icon ' : 'dashicons ';
500
-				$icon_html .= '<span class="' . $type . $dashicon . '"></span>';
498
+			foreach ($dashicons as $dashicon) {
499
+				$type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
500
+				$icon_html .= '<span class="'.$type.$dashicon.'"></span>';
501 501
 			}
502 502
 			$icon_html .= $count > 1 ? '</span>' : '';
503 503
 		}
504
-		$label = ! empty( $icon ) ? $icon_html . $label : $label;
505
-		$button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
504
+		$label = ! empty($icon) ? $icon_html.$label : $label;
505
+		$button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'" title="'.$title.'">'.$label.'</a>';
506 506
 		return $button;
507 507
 	}
508 508
 
@@ -519,21 +519,21 @@  discard block
 block discarded – undo
519 519
 	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
520 520
 	 * @return string              generated link
521 521
 	 */
522
-	public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) {
522
+	public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) {
523 523
 
524
-		if ( ! $page )
525
-			$page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page;
524
+		if ( ! $page)
525
+			$page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
526 526
 
527
-		if ( ! $action )
528
-			$action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action;
527
+		if ( ! $action)
528
+			$action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
529 529
 
530 530
 		$action = empty($action) ? 'default' : $action;
531 531
 
532 532
 
533
-		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
534
-		$icon = !$icon_style ? ' dashicons-editor-help' : $icon_style;
535
-		$help_text = !$help_text ? '' : $help_text;
536
-		return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>';
533
+		$help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
534
+		$icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
535
+		$help_text = ! $help_text ? '' : $help_text;
536
+		return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>';
537 537
 	}
538 538
 
539 539
 
@@ -545,31 +545,31 @@  discard block
 block discarded – undo
545 545
 	 * @param EE_Help_Tour
546 546
 	 * @return string         html
547 547
 	 */
548
-	public static function help_tour_stops_generator( EE_Help_Tour $tour ) {
548
+	public static function help_tour_stops_generator(EE_Help_Tour $tour) {
549 549
 		$id = $tour->get_slug();
550 550
 		$stops = $tour->get_stops();
551 551
 
552
-		$content = '<ol style="display:none" id="' . $id . '">';
552
+		$content = '<ol style="display:none" id="'.$id.'">';
553 553
 
554
-		foreach ( $stops as $stop ) {
555
-			$data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : '';
556
-			$data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : '';
554
+		foreach ($stops as $stop) {
555
+			$data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : '';
556
+			$data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : '';
557 557
 
558 558
 			//if container is set to modal then let's make sure we set the options accordingly
559
-			if ( empty( $data_id ) && empty( $data_class ) ) {
559
+			if (empty($data_id) && empty($data_class)) {
560 560
 				$stop['options']['modal'] = true;
561 561
 				$stop['options']['expose'] = true;
562 562
 			}
563 563
 
564
-			$custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : '';
565
-			$button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : '';
564
+			$custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : '';
565
+			$button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : '';
566 566
 			$inner_content = isset($stop['content']) ? $stop['content'] : '';
567 567
 
568 568
 			//options
569
-			if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) {
569
+			if (isset($stop['options']) && is_array($stop['options'])) {
570 570
 				$options = ' data-options="';
571
-				foreach ( $stop['options'] as $option => $value ) {
572
-					$options .= $option . ':' . $value . ';';
571
+				foreach ($stop['options'] as $option => $value) {
572
+					$options .= $option.':'.$value.';';
573 573
 				}
574 574
 				$options .= '"';
575 575
 			} else {
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 			}
578 578
 
579 579
 			//let's put all together
580
-			$content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
580
+			$content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>';
581 581
 		}
582 582
 
583 583
 		$content .= '</ol>';
@@ -598,31 +598,31 @@  discard block
 block discarded – undo
598 598
 	 * @throws EE_Error
599 599
 	 * @return string               html structure for status.
600 600
 	 */
601
-	public static function status_legend( $status_array, $active_status = '' ) {
602
-		if ( !is_array( $status_array ) )
603
-			throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') );
601
+	public static function status_legend($status_array, $active_status = '') {
602
+		if ( ! is_array($status_array))
603
+			throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso'));
604 604
 
605 605
 		$setup_array = array();
606
-		foreach ( $status_array as $item => $status ) {
606
+		foreach ($status_array as $item => $status) {
607 607
 			$setup_array[$item] = array(
608
-					'class' => 'ee-status-legend ee-status-legend-' . $status,
609
-					'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ),
608
+					'class' => 'ee-status-legend ee-status-legend-'.$status,
609
+					'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'),
610 610
 					'status' => $status
611 611
 				);
612 612
 		}
613 613
 
614
-		$content = '<div class="ee-list-table-legend-container">' . "\n";
615
-		$content .= '<h3>' . __('Status Legend', 'event_espresso') . '</h3>' . "\n";
616
-		$content .= '<dl class="ee-list-table-legend">' . "\n\t";
617
-		foreach ( $setup_array as $item => $details ) {
614
+		$content = '<div class="ee-list-table-legend-container">'."\n";
615
+		$content .= '<h3>'.__('Status Legend', 'event_espresso').'</h3>'."\n";
616
+		$content .= '<dl class="ee-list-table-legend">'."\n\t";
617
+		foreach ($setup_array as $item => $details) {
618 618
 			$active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
619
-			$content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
620
-			$content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
621
-			$content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
622
-			$content .= '</dt>' . "\n";
619
+			$content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t";
620
+			$content .= '<span class="'.$details['class'].'"></span>'."\n\t\t";
621
+			$content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t";
622
+			$content .= '</dt>'."\n";
623 623
 		}
624
-		$content .= '</dl>' . "\n";
625
-		$content .= '</div>' . "\n";
624
+		$content .= '</dl>'."\n";
625
+		$content .= '</div>'."\n";
626 626
 		return $content;
627 627
 	}
628 628
 
@@ -635,8 +635,8 @@  discard block
 block discarded – undo
635 635
 	 * @return string
636 636
 	 */
637 637
 	public static function layout_array_as_table($data) {
638
-	if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) {
639
-		$data = (array)$data;
638
+	if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
639
+		$data = (array) $data;
640 640
 	}
641 641
 	ob_start();
642 642
 	if (is_array($data)) {
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
 						?>
650 650
 						<tr>
651 651
 							<td>
652
-								<?php echo $data_key;?>
652
+								<?php echo $data_key; ?>
653 653
 							</td>
654 654
 							<td>
655
-								<?php echo self::layout_array_as_table($data_values);?>
655
+								<?php echo self::layout_array_as_table($data_values); ?>
656 656
 							</td>
657 657
 						</tr>
658 658
 						<?php
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 			<ul>
667 667
 				<?php
668 668
 				foreach ($data as $datum) {
669
-					echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>";
669
+					echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>";
670 670
 				}?>
671 671
 			</ul>
672 672
 			<?php
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
 	 *
697 697
 	 * @return string
698 698
 	 */
699
-	public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) {
700
-		echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label );
699
+	public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) {
700
+		echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label);
701 701
 	}
702 702
 
703 703
 
@@ -721,13 +721,13 @@  discard block
 block discarded – undo
721 721
 	 *                                 )
722 722
 	 * @return  string
723 723
 	 */
724
-	public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) {
724
+	public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) {
725 725
 		$page_links = array();
726 726
 		$disable_first = $disable_last = '';
727 727
 		$total_items = (int) $total_items;
728 728
 		$per_page = (int) $per_page;
729 729
 		$current = (int) $current;
730
-		$paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name );
730
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
731 731
 
732 732
 		//filter items_label
733 733
 		$items_label = apply_filters(
@@ -735,68 +735,68 @@  discard block
 block discarded – undo
735 735
 			$items_label
736 736
 		);
737 737
 
738
-		if ( empty( $items_label )
739
-		     || ! is_array( $items_label )
740
-		     || ! isset( $items_label['single'] )
741
-		     || ! isset( $items_label['plural'] ) ) {
738
+		if (empty($items_label)
739
+		     || ! is_array($items_label)
740
+		     || ! isset($items_label['single'])
741
+		     || ! isset($items_label['plural'])) {
742 742
 			$items_label = array(
743
-				'single' => __( '1 item', 'event_espresso' ),
744
-				'plural' => __( '%s items', 'event_espresso' )
743
+				'single' => __('1 item', 'event_espresso'),
744
+				'plural' => __('%s items', 'event_espresso')
745 745
 			);
746 746
 		} else {
747 747
 			$items_label = array(
748
-				'single' => '1 ' . esc_html( $items_label['single'] ),
749
-				'plural' => '%s ' . esc_html( $items_label['plural'] )
748
+				'single' => '1 '.esc_html($items_label['single']),
749
+				'plural' => '%s '.esc_html($items_label['plural'])
750 750
 			);
751 751
 		}
752 752
 
753
-		$total_pages = ceil( $total_items / $per_page );
753
+		$total_pages = ceil($total_items / $per_page);
754 754
 
755
-		if ( $total_pages <= 1 )
755
+		if ($total_pages <= 1)
756 756
 			return '';
757 757
 
758
-		$item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single'];
758
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
759 759
 
760
-		$output = '<span class="displaying-num">' . $item_label . '</span>';
760
+		$output = '<span class="displaying-num">'.$item_label.'</span>';
761 761
 
762
-		if ( $current === 1 ) {
762
+		if ($current === 1) {
763 763
 			$disable_first = ' disabled';
764 764
 		}
765
-		if ( $current == $total_pages ) {
765
+		if ($current == $total_pages) {
766 766
 			$disable_last = ' disabled';
767 767
 		}
768 768
 
769
-		$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
770
-			'first-page' . $disable_first,
771
-			esc_attr__( 'Go to the first page' ),
772
-			esc_url( remove_query_arg( $paged_arg_name, $url ) ),
769
+		$page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
770
+			'first-page'.$disable_first,
771
+			esc_attr__('Go to the first page'),
772
+			esc_url(remove_query_arg($paged_arg_name, $url)),
773 773
 			'&laquo;'
774 774
 		);
775 775
 
776 776
 		$page_links[] = sprintf(
777 777
 			'<a class="%s" title="%s" href="%s">%s</a>',
778
-			'prev-page' . $disable_first,
779
-			esc_attr__( 'Go to the previous page' ),
780
-			esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ),
778
+			'prev-page'.$disable_first,
779
+			esc_attr__('Go to the previous page'),
780
+			esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
781 781
 			'&lsaquo;'
782 782
 		);
783 783
 
784
-		if ( ! $show_num_field ) {
784
+		if ( ! $show_num_field) {
785 785
 			$html_current_page = $current;
786 786
 		} else {
787
-			$html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
788
-				esc_attr__( 'Current page' ),
787
+			$html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
788
+				esc_attr__('Current page'),
789 789
 				$current,
790
-				strlen( $total_pages )
790
+				strlen($total_pages)
791 791
 			);
792 792
 		}
793 793
 
794 794
 		$html_total_pages = sprintf(
795 795
 			'<span class="total-pages">%s</span>',
796
-			number_format_i18n( $total_pages )
796
+			number_format_i18n($total_pages)
797 797
 		);
798 798
 		$page_links[] = sprintf(
799
-			_x( '%3$s%1$s of %2$s%4$s', 'paging' ),
799
+			_x('%3$s%1$s of %2$s%4$s', 'paging'),
800 800
 			$html_current_page,
801 801
 			$html_total_pages,
802 802
 			'<span class="paging-input">',
@@ -805,29 +805,29 @@  discard block
 block discarded – undo
805 805
 
806 806
 		$page_links[] = sprintf(
807 807
 			'<a class="%s" title="%s" href="%s">%s</a>',
808
-			'next-page' . $disable_last,
809
-			esc_attr__( 'Go to the next page' ),
810
-			esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ),
808
+			'next-page'.$disable_last,
809
+			esc_attr__('Go to the next page'),
810
+			esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
811 811
 			'&rsaquo;'
812 812
 		);
813 813
 
814 814
 		$page_links[] = sprintf(
815 815
 			'<a class="%s" title="%s" href="%s">%s</a>',
816
-			'last-page' . $disable_last,
817
-			esc_attr__( 'Go to the last page' ),
818
-			esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ),
816
+			'last-page'.$disable_last,
817
+			esc_attr__('Go to the last page'),
818
+			esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
819 819
 			'&raquo;'
820 820
 		);
821 821
 
822
-		$output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>';
822
+		$output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
823 823
 		// set page class
824
-		if ( $total_pages ) {
824
+		if ($total_pages) {
825 825
 			$page_class = $total_pages < 2 ? ' one-page' : '';
826 826
 		} else {
827 827
 			$page_class = ' no-pages';
828 828
 		}
829 829
 
830
-		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
830
+		return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
831 831
 	}
832 832
 
833 833
 
@@ -837,8 +837,8 @@  discard block
 block discarded – undo
837 837
 	 * @param string $wrap_id
838 838
 	 * @return string
839 839
 	 */
840
-	public static function powered_by_event_espresso( $wrap_class = '', $wrap_id = '' ) {
841
-		$admin = is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX );
840
+	public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '') {
841
+		$admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
842 842
 		if (
843 843
 			! $admin &&
844 844
 			! apply_filters(
@@ -848,17 +848,17 @@  discard block
 block discarded – undo
848 848
 		) {
849 849
 			return '';
850 850
 		}
851
-		$attributes = ! empty( $wrap_id ) ? " id=\"{$wrap_id}\"" : '';
851
+		$attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
852 852
 		$wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
853
-		$attributes .= ! empty( $wrap_class )
853
+		$attributes .= ! empty($wrap_class)
854 854
 			? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
855 855
 			: ' class="powered-by-event-espresso-credit"';
856 856
 		$powered_by = $admin ? EVENT_ESPRESSO_POWERED_BY : 'Event Espresso';
857 857
 		$url = add_query_arg(
858
-			array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id() ),
858
+			array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id()),
859 859
 			'https://eventespresso.com/'
860 860
 		);
861
-		$url = apply_filters( 'FHEE__EEH_Template__powered_by_event_espresso__url', $url );
861
+		$url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
862 862
 		return (string) apply_filters(
863 863
 			'FHEE__EEH_Template__powered_by_event_espresso__html',
864 864
 			sprintf(
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 //add_filter( 'FHEE__EEH_Template__format_currency__amount', 'convert_zero_to_free', 10, 2 );
889 889
 
890 890
 
891
-if ( ! function_exists( 'espresso_pagination' ) ) {
891
+if ( ! function_exists('espresso_pagination')) {
892 892
 	/**
893 893
 	 *    espresso_pagination
894 894
 	 *
@@ -900,21 +900,21 @@  discard block
 block discarded – undo
900 900
 		$big = 999999999; // need an unlikely integer
901 901
 		$pagination = paginate_links(
902 902
 		array(
903
-		'base'         => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
903
+		'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
904 904
 		'format'       => '?paged=%#%',
905
-		'current'      => max( 1, get_query_var( 'paged' ) ),
905
+		'current'      => max(1, get_query_var('paged')),
906 906
 		'total'        => $wp_query->max_num_pages,
907 907
 		'show_all'     => true,
908 908
 		'end_size'     => 10,
909 909
 		'mid_size'     => 6,
910 910
 		'prev_next'    => true,
911
-		'prev_text'    => __( '&lsaquo; PREV', 'event_espresso' ),
912
-		'next_text'    => __( 'NEXT &rsaquo;', 'event_espresso' ),
911
+		'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
912
+		'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
913 913
 		'type'         => 'plain',
914 914
 		'add_args'     => false,
915 915
 		'add_fragment' => ''
916 916
 		)
917 917
 		);
918
-		echo ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : '';
918
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : '';
919 919
 	}
920 920
 }
921 921
\ No newline at end of file
Please login to merge, or discard this patch.
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_DMS_Core_4_7_0.dms.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 // (all other times it gets resurrected from a wordpress option)
18 18
 $stages = glob(EE_CORE.'data_migration_scripts/4_7_0_stages/*');
19 19
 $class_to_filepath = array();
20
-foreach($stages as $filepath){
20
+foreach ($stages as $filepath) {
21 21
 	$matches = array();
22
-	preg_match('~4_7_0_stages/(.*).dmsstage.php~',$filepath,$matches);
22
+	preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches);
23 23
 	$class_to_filepath[$matches[1]] = $filepath;
24 24
 }
25 25
 //give addons a chance to autoload their stages too
26
-$class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages',$class_to_filepath);
26
+$class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages', $class_to_filepath);
27 27
 EEH_Autoloader::register_autoloader($class_to_filepath);
28 28
 
29 29
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  * @since                4.7.0
40 40
  *
41 41
  */
42
-class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base{
42
+class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base {
43 43
 
44 44
 	/**
45 45
 	 * return EE_DMS_Core_4_7_0
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
 	 * @param TableManager  $table_manager
48 48
 	 * @param TableAnalysis $table_analysis
49 49
 	 */
50
-	public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) {
50
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) {
51 51
 		$this->_pretty_name = __("Data Migration to Event Espresso 4.7.0.p", "event_espresso");
52 52
 		$this->_priority = 10;
53 53
 		$this->_migration_stages = array(
54 54
 			new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(),
55 55
 			new EE_DMS_4_7_0_Registration_Payments(),
56 56
 		);
57
-		parent::__construct( $table_manager, $table_analysis );
57
+		parent::__construct($table_manager, $table_analysis);
58 58
 	}
59 59
 
60 60
 
@@ -66,15 +66,15 @@  discard block
 block discarded – undo
66 66
 	public function can_migrate_from_version($version_array) {
67 67
 		$version_string = $version_array['Core'];
68 68
 		if (
69
-			( $version_string <= '4.7.0' && $version_string >= '4.6.0' )
69
+			($version_string <= '4.7.0' && $version_string >= '4.6.0')
70 70
 			||
71
-			( $version_string >= '4.7.0' &&
72
-					! $this->_get_table_analysis()->tableExists( 'esp_registration_payment' ) &&
73
-					$this->_get_table_analysis()->tableExists( 'esp_registration' ) ) ) {
71
+			($version_string >= '4.7.0' &&
72
+					! $this->_get_table_analysis()->tableExists('esp_registration_payment') &&
73
+					$this->_get_table_analysis()->tableExists('esp_registration')) ) {
74 74
 			return true;
75
-		} elseif ( ! $version_string ) {
75
+		} elseif ( ! $version_string) {
76 76
 			//no version string provided... this must be pre 4.3
77
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
77
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
78 78
 		} else {
79 79
 			return false;
80 80
 		}
@@ -96,16 +96,16 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function schema_changes_before_migration() {
98 98
 		//relies on 4.1's EEH_Activation::create_table
99
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
100
-		$table_name='esp_answer';
101
-		$sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
99
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
100
+		$table_name = 'esp_answer';
101
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
102 102
 					REG_ID INT UNSIGNED NOT NULL,
103 103
 					QST_ID INT UNSIGNED NOT NULL,
104 104
 					ANS_value TEXT NOT NULL,
105 105
 					PRIMARY KEY  (ANS_ID),
106 106
 					KEY REG_ID (REG_ID),
107 107
 					KEY QST_ID (QST_ID)";
108
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
108
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
109 109
 
110 110
 		$table_name = 'esp_attendee_meta';
111 111
 		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
146 146
 					  CNT_active TINYINT(1) DEFAULT '0',
147 147
 					  PRIMARY KEY  (CNT_ISO)";
148
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
148
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
149 149
 
150 150
 		$table_name = 'esp_currency';
151 151
 		$sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL,
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 				CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2',
156 156
 				CUR_active TINYINT(1) DEFAULT '0',
157 157
 				PRIMARY KEY  (CUR_code)";
158
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
158
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
159 159
 
160 160
 
161 161
 		$table_name = 'esp_currency_payment_method';
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 						KEY EVT_ID (EVT_ID),
186 186
 						KEY DTT_is_primary (DTT_is_primary)";
187 187
 
188
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
188
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
189 189
 
190 190
 		$table_name = 'esp_event_meta';
191 191
 		$sql = "
@@ -204,44 +204,44 @@  discard block
 block discarded – undo
204 204
 			EVT_donations TINYINT(1) NULL,
205 205
 			PRIMARY KEY  (EVTM_ID),
206 206
 			KEY EVT_ID (EVT_ID)";
207
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
207
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
208 208
 
209 209
 
210 210
 
211
-		$table_name='esp_event_question_group';
212
-		$sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
211
+		$table_name = 'esp_event_question_group';
212
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
213 213
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
214 214
 					QSG_ID INT UNSIGNED NOT NULL,
215 215
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
216 216
 					PRIMARY KEY  (EQG_ID),
217 217
 					KEY EVT_ID (EVT_ID),
218 218
 					KEY QSG_ID (QSG_ID)";
219
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
219
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
220 220
 
221 221
 
222 222
 
223
-		$table_name='esp_event_venue';
224
-		$sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
223
+		$table_name = 'esp_event_venue';
224
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
225 225
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
226 226
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
227 227
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
228 228
 				PRIMARY KEY  (EVV_ID)";
229
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
229
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
230 230
 
231 231
 
232 232
 
233
-		$table_name='esp_extra_meta';
234
-		$sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
233
+		$table_name = 'esp_extra_meta';
234
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
235 235
 				OBJ_ID INT(11) DEFAULT NULL,
236 236
 				EXM_type VARCHAR(45) DEFAULT NULL,
237 237
 				EXM_key VARCHAR(45) DEFAULT NULL,
238 238
 				EXM_value TEXT,
239 239
 				PRIMARY KEY  (EXM_ID),
240 240
 				KEY EXM_type (EXM_type, OBJ_ID, EXM_key(45))";
241
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
241
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
242 242
 
243
-		$table_name='esp_line_item';
244
-		$sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
243
+		$table_name = 'esp_line_item';
244
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
245 245
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
246 246
 				TXN_ID INT(11) DEFAULT NULL,
247 247
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 				PRIMARY KEY  (LIN_ID),
260 260
 				KEY LIN_code (LIN_code(191)),
261 261
 				KEY TXN_ID (TXN_ID)";
262
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB' );
262
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
263 263
 
264 264
 		$table_name = 'esp_log';
265 265
 		$sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT,
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 					MTP_is_active TINYINT(1) NOT NULL DEFAULT '1',
300 300
 					PRIMARY KEY  (GRP_ID),
301 301
 					KEY MTP_user_id (MTP_user_id)";
302
-		$this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB');
302
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
303 303
 
304 304
 		$table_name = 'esp_event_message_template';
305 305
 		$sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 					PRIMARY KEY  (EMT_ID),
309 309
 					KEY EVT_ID (EVT_ID),
310 310
 					KEY GRP_ID (GRP_ID)";
311
-		$this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB');
311
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
312 312
 
313 313
 
314 314
 		$table_name = 'esp_payment';
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
 					  PRIMARY KEY  (TTM_ID)";
382 382
 		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
383 383
 
384
-		$table_name='esp_question';
385
-		$sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
384
+		$table_name = 'esp_question';
385
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
386 386
 					QST_display_text TEXT NOT NULL,
387 387
 					QST_admin_label VARCHAR(255) NOT NULL,
388 388
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -395,22 +395,22 @@  discard block
 block discarded – undo
395 395
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
396 396
 					PRIMARY KEY  (QST_ID),
397 397
 					KEY QST_order (QST_order)';
398
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
398
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
399 399
 
400
-		$table_name='esp_question_group_question';
401
-		$sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
400
+		$table_name = 'esp_question_group_question';
401
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
402 402
 					QSG_ID INT UNSIGNED NOT NULL,
403 403
 					QST_ID INT UNSIGNED NOT NULL,
404 404
 					QGQ_order INT UNSIGNED NOT NULL DEFAULT 0,
405 405
 					PRIMARY KEY  (QGQ_ID),
406 406
 					KEY QST_ID (QST_ID),
407 407
 					KEY QSG_ID_order (QSG_ID, QGQ_order)";
408
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
408
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
409 409
 
410 410
 
411 411
 
412
-		$table_name='esp_question_option';
413
-		$sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
412
+		$table_name = 'esp_question_option';
413
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
414 414
 					QSO_value VARCHAR(255) NOT NULL,
415 415
 					QSO_desc TEXT NOT NULL,
416 416
 					QST_ID INT UNSIGNED NOT NULL,
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 					PRIMARY KEY  (QSO_ID),
420 420
 					KEY QST_ID (QST_ID),
421 421
 					KEY QSO_order (QSO_order)";
422
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
422
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
423 423
 
424 424
 
425 425
 
@@ -465,8 +465,8 @@  discard block
 block discarded – undo
465 465
 
466 466
 
467 467
 
468
-		$table_name='esp_checkin';
469
-		$sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
468
+		$table_name = 'esp_checkin';
469
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
470 470
 					REG_ID INT(10) UNSIGNED NOT NULL,
471 471
 					DTT_ID INT(10) UNSIGNED NOT NULL,
472 472
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 					  PRC_parent INT(10) UNSIGNED DEFAULT 0,
562 562
 					  PRIMARY KEY  (PRC_ID),
563 563
 					  KEY PRT_ID (PRT_ID)";
564
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
564
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
565 565
 
566 566
 		$table_name = "esp_price_type";
567 567
 		$sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -599,10 +599,10 @@  discard block
 block discarded – undo
599 599
 					  TKT_deleted TINYINT(1) NOT NULL DEFAULT '0',
600 600
 					  PRIMARY KEY  (TKT_ID),
601 601
 					  KEY TKT_start_date (TKT_start_date)";
602
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
602
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
603 603
 
604 604
 		$table_name = 'esp_question_group';
605
-		$sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
605
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
606 606
 					QSG_name VARCHAR(255) NOT NULL,
607 607
 					QSG_identifier VARCHAR(100) NOT NULL,
608 608
 					QSG_desc TEXT NULL,
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 					PRIMARY KEY  (QSG_ID),
616 616
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
617 617
 					KEY QSG_order (QSG_order)';
618
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
618
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
619 619
 
620 620
 		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
621 621
 		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 		return true;
648 648
 	}
649 649
 
650
-	public function migration_page_hooks(){
650
+	public function migration_page_hooks() {
651 651
 
652 652
 	}
653 653
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_1_0.dms.php 1 patch
Spacing   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
 //(all other times it gets resurrected from a wordpress option)
12 12
 $stages = glob(EE_CORE.'data_migration_scripts/4_1_0_stages/*');
13 13
 $class_to_filepath = array();
14
-if ( ! empty( $stages ) ) {
15
-	foreach($stages as $filepath){
14
+if ( ! empty($stages)) {
15
+	foreach ($stages as $filepath) {
16 16
 		$matches = array();
17
-		preg_match('~4_1_0_stages/(.*).dmsstage.php~',$filepath,$matches);
17
+		preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18 18
 		$class_to_filepath[$matches[1]] = $filepath;
19 19
 	}
20 20
 }
21 21
 //give addons a chance to autoload their stages too
22
-$class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages',$class_to_filepath);
22
+$class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages', $class_to_filepath);
23 23
 EEH_Autoloader::register_autoloader($class_to_filepath);
24 24
 
25 25
 /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
  * --a function named update_espresso_config() which saves the EE_Config object to the database
38 38
  * --...and all its subclasses... really, you're best off copying the whole thing when 4.1 is released into this file and wrapping its declaration in if( ! class_exists()){...}
39 39
  */
40
-class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base{
40
+class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base {
41 41
 
42 42
 
43 43
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @param TableManager  $table_manager
48 48
 	 * @param TableAnalysis $table_analysis
49 49
 	 */
50
-	public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) {
50
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) {
51 51
 		$this->_pretty_name = __("Data Migration to Event Espresso 4.1.0P", "event_espresso");
52 52
 		$this->_priority = 10;
53 53
 		$this->_migration_stages = array(
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 			new EE_DMS_4_1_0_answers(),
70 70
 			new EE_DMS_4_1_0_checkins(),
71 71
 		);
72
-		parent::__construct( $table_manager, $table_analysis );
72
+		parent::__construct($table_manager, $table_analysis);
73 73
 	}
74 74
 	/**
75 75
 	 * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
@@ -77,27 +77,27 @@  discard block
 block discarded – undo
77 77
 	 * @global wpdb $wpdb
78 78
 	 * @return boolean
79 79
 	 */
80
-	private function _checkin_table_exists(){
80
+	private function _checkin_table_exists() {
81 81
 		global $wpdb;
82 82
 		$results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'");
83
-		if($results){
83
+		if ($results) {
84 84
 			return true;
85
-		}else{
85
+		} else {
86 86
 			return false;
87 87
 		}
88 88
 	}
89 89
 
90 90
 	public function can_migrate_from_version($version_array) {
91 91
 		$version_string = $version_array['Core'];
92
-		if($version_string < '4.0.0' && $version_string > '3.1.26' ){
92
+		if ($version_string < '4.0.0' && $version_string > '3.1.26') {
93 93
 //			echo "$version_string can be migrated fro";
94 94
 			return true;
95
-		}elseif( ! $version_string ){
95
+		}elseif ( ! $version_string) {
96 96
 //			echo "no version string provided: $version_string";
97 97
 			//no version string provided... this must be pre 4.1
98 98
 			//because since 4.1 we're
99
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
100
-		}else{
99
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
100
+		} else {
101 101
 //			echo "$version_string doesnt apply";
102 102
 			return false;
103 103
 		}
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
 	}
108 108
 	public function schema_changes_before_migration() {
109 109
 		//relies on 4.1's EEH_Activation::create_table
110
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
110
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
111 111
 
112
-		$table_name='esp_answer';
113
-		$sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
112
+		$table_name = 'esp_answer';
113
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
114 114
 					REG_ID INT UNSIGNED NOT NULL,
115 115
 					QST_ID INT UNSIGNED NOT NULL,
116 116
 					ANS_value TEXT NOT NULL,
117 117
 					PRIMARY KEY  (ANS_ID)";
118
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
118
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
119 119
 
120 120
 		$table_name = 'esp_attendee_meta';
121 121
 		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
156 156
 					  CNT_active TINYINT(1) DEFAULT '0',
157 157
 					  PRIMARY KEY  (CNT_ISO)";
158
-		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
158
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
159 159
 
160 160
 
161 161
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 
178 178
 
179
-		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
179
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
180 180
 		$table_name = 'esp_event_meta';
181 181
 		$sql = "
182 182
 			EVTM_ID INT NOT NULL AUTO_INCREMENT,
@@ -193,41 +193,41 @@  discard block
 block discarded – undo
193 193
 			EVT_external_URL VARCHAR(200) NULL,
194 194
 			EVT_donations TINYINT(1) NULL,
195 195
 			PRIMARY KEY  (EVTM_ID)";
196
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
196
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
197 197
 
198 198
 
199 199
 
200
-		$table_name='esp_event_question_group';
201
-		$sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
200
+		$table_name = 'esp_event_question_group';
201
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
202 202
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
203 203
 					QSG_ID INT UNSIGNED NOT NULL,
204 204
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
205 205
 					PRIMARY KEY  (EQG_ID)";
206
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
206
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
207 207
 
208 208
 
209 209
 
210
-		$table_name='esp_event_venue';
211
-		$sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
210
+		$table_name = 'esp_event_venue';
211
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
212 212
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
213 213
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
214 214
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
215 215
 				PRIMARY KEY  (EVV_ID)";
216
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
216
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
217 217
 
218 218
 
219 219
 
220
-		$table_name='esp_extra_meta';
221
-		$sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
220
+		$table_name = 'esp_extra_meta';
221
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
222 222
 				OBJ_ID INT(11) DEFAULT NULL,
223 223
 				EXM_type VARCHAR(45) DEFAULT NULL,
224 224
 				EXM_key VARCHAR(45) DEFAULT NULL,
225 225
 				EXM_value TEXT,
226 226
 				PRIMARY KEY  (EXM_ID)";
227
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
227
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
228 228
 
229
-		$table_name='esp_line_item';
230
-		$sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
229
+		$table_name = 'esp_line_item';
230
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
231 231
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
232 232
 				TXN_ID INT(11) DEFAULT NULL,
233 233
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 				OBJ_ID INT(11) DEFAULT NULL,
244 244
 				OBJ_type VARCHAR(45)DEFAULT NULL,
245 245
 				PRIMARY KEY  (LIN_ID)";
246
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB' );
246
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247 247
 
248 248
 		$table_name = 'esp_message_template';
249 249
 		$sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 					PRIMARY KEY  (GRP_ID),
271 271
 					KEY EVT_ID (EVT_ID),
272 272
 					KEY MTP_user_id (MTP_user_id)";
273
-		$this->_table_is_new_in_this_version( $table_name, $sql, 'ENGINE=InnoDB');
273
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
274 274
 
275 275
 
276 276
 
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 
379 379
 
380 380
 
381
-		$table_name='esp_question';
382
-		$sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
381
+		$table_name = 'esp_question';
382
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
383 383
 					QST_display_text TEXT NOT NULL,
384 384
 					QST_admin_label VARCHAR(255) NOT NULL,
385 385
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -391,12 +391,12 @@  discard block
 block discarded – undo
391 391
 					QST_wp_user BIGINT UNSIGNED NULL,
392 392
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
393 393
 					PRIMARY KEY  (QST_ID)';
394
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
394
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
395 395
 
396
-		$this->_get_table_manager()->dropIndex( 'esp_question_group', 'QSG_identifier_UNIQUE' );
396
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
397 397
 
398 398
 		$table_name = 'esp_question_group';
399
-		$sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
399
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
400 400
 					QSG_name VARCHAR(255) NOT NULL,
401 401
 					QSG_identifier VARCHAR(100) NOT NULL,
402 402
 					QSG_desc TEXT NULL,
@@ -407,27 +407,27 @@  discard block
 block discarded – undo
407 407
 					QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
408 408
 					PRIMARY KEY  (QSG_ID),
409 409
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
410
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
410
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
411 411
 
412 412
 
413 413
 
414
-		$table_name='esp_question_group_question';
415
-		$sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
414
+		$table_name = 'esp_question_group_question';
415
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
416 416
 					QSG_ID INT UNSIGNED NOT NULL,
417 417
 					QST_ID INT UNSIGNED NOT NULL,
418 418
 					PRIMARY KEY  (QGQ_ID) ";
419
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
419
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
420 420
 
421 421
 
422 422
 
423
-		$table_name='esp_question_option';
424
-		$sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
423
+		$table_name = 'esp_question_option';
424
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
425 425
 					QSO_value VARCHAR(255) NOT NULL,
426 426
 					QSO_desc TEXT NOT NULL,
427 427
 					QST_ID INT UNSIGNED NOT NULL,
428 428
 					QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
429 429
 					PRIMARY KEY  (QSO_ID)";
430
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
430
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
431 431
 
432 432
 
433 433
 
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
 
461 461
 
462 462
 
463
-		$table_name='esp_checkin';
464
-		$sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
463
+		$table_name = 'esp_checkin';
464
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
465 465
 					REG_ID INT(10) UNSIGNED NOT NULL,
466 466
 					DTT_ID INT(10) UNSIGNED NOT NULL,
467 467
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -568,12 +568,12 @@  discard block
 block discarded – undo
568 568
 
569 569
 		global $wpdb;
570 570
 		$state_table = $wpdb->prefix."esp_state";
571
-		if ( $this->_get_table_analysis()->tableExists( $state_table ) ) {
571
+		if ($this->_get_table_analysis()->tableExists($state_table)) {
572 572
 
573
-			$SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
573
+			$SQL = "SELECT COUNT('STA_ID') FROM ".$state_table;
574 574
 			$states = $wpdb->get_var($SQL);
575
-			if ( ! $states ) {
576
-				$SQL = "INSERT INTO " . $state_table . "
575
+			if ( ! $states) {
576
+				$SQL = "INSERT INTO ".$state_table."
577 577
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
578 578
 				(1, 'US', 'AK', 'Alaska', 1),
579 579
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -660,12 +660,12 @@  discard block
 block discarded – undo
660 660
 
661 661
 		global $wpdb;
662 662
 		$country_table = $wpdb->prefix."esp_country";
663
-		if ( $this->_get_table_analysis()->tableExists( $country_table ) ) {
663
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
664 664
 
665
-			$SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
665
+			$SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table;
666 666
 			$countries = $wpdb->get_var($SQL);
667
-			if ( ! $countries ) {
668
-				$SQL = "INSERT INTO " . $country_table . "
667
+			if ( ! $countries) {
668
+				$SQL = "INSERT INTO ".$country_table."
669 669
 				(CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES
670 670
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
671 671
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -912,20 +912,20 @@  discard block
 block discarded – undo
912 912
 		global $wpdb;
913 913
 		$price_type_table = $wpdb->prefix."esp_price_type";
914 914
 
915
-		if ( $this->_get_table_analysis()->tableExists( $price_type_table ) ) {
915
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
916 916
 
917
-			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
918
-			$price_types_exist = $wpdb->get_var( $SQL );
917
+			$SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table;
918
+			$price_types_exist = $wpdb->get_var($SQL);
919 919
 
920
-			if ( ! $price_types_exist ) {
920
+			if ( ! $price_types_exist) {
921 921
 				$SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
922
-							(1, '" . __('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
923
-							(2, '" . __('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
924
-							(3, '" . __('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
925
-							(4, '" . __('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
926
-							(5, '" . __('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
927
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL );
928
-				$wpdb->query( $SQL );
922
+							(1, '".__('Base Price', 'event_espresso')."', 1,  0, 0, 0),
923
+							(2, '" . __('Percent Discount', 'event_espresso')."', 2,  1, 20, 0),
924
+							(3, '" . __('Fixed Discount', 'event_espresso')."', 2,  0, 30, 0),
925
+							(4, '" . __('Percent Surcharge', 'event_espresso')."', 3,  1, 40, 0),
926
+							(5, '" . __('Fixed Surcharge', 'event_espresso')."', 3,  0, 50, 0);";
927
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
928
+				$wpdb->query($SQL);
929 929
 			}
930 930
 		}
931 931
 	}
@@ -945,16 +945,16 @@  discard block
 block discarded – undo
945 945
 		global $wpdb;
946 946
 		$price_table = $wpdb->prefix."esp_price";
947 947
 
948
-		if ( $this->_get_table_analysis()->tableExists(  $price_table ) ) {
948
+		if ($this->_get_table_analysis()->tableExists($price_table)) {
949 949
 
950
-			$SQL = 'SELECT COUNT(PRC_ID) FROM ' .$price_table;
951
-			$prices_exist = $wpdb->get_var( $SQL );
950
+			$SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table;
951
+			$prices_exist = $wpdb->get_var($SQL);
952 952
 
953
-			if ( ! $prices_exist ) {
953
+			if ( ! $prices_exist) {
954 954
 				$SQL = "INSERT INTO $price_table
955 955
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES
956 956
 							(1, 1, '0.00', 'Free Admission', '', 1, NULL, 0, 0, 0);";
957
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL );
957
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
958 958
 				$wpdb->query($SQL);
959 959
 			}
960 960
 		}
@@ -971,34 +971,34 @@  discard block
 block discarded – undo
971 971
 
972 972
 		global $wpdb;
973 973
 		$ticket_table = $wpdb->prefix."esp_ticket";
974
-		if ( $this->_get_table_analysis()->tableExists( $ticket_table ) ) {
974
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
975 975
 
976
-			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
976
+			$SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
977 977
 			$tickets_exist = $wpdb->get_var($SQL);
978 978
 
979
-			if ( ! $tickets_exist ) {
979
+			if ( ! $tickets_exist) {
980 980
 				$SQL = "INSERT INTO $ticket_table
981 981
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES
982
-					( 1, 0, '" . __("Free Ticket", "event_espresso") . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
983
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL );
982
+					( 1, 0, '".__("Free Ticket", "event_espresso")."', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
983
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
984 984
 				$wpdb->query($SQL);
985 985
 			}
986 986
 		}
987 987
 		$ticket_price_table = $wpdb->prefix."esp_ticket_price";
988 988
 
989
-		if ( $this->_get_table_analysis()->tableExists( $ticket_price_table ) ) {
989
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
990 990
 
991
-			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
991
+			$SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
992 992
 			$ticket_prc_exist = $wpdb->get_var($SQL);
993 993
 
994
-			if ( ! $ticket_prc_exist ) {
994
+			if ( ! $ticket_prc_exist) {
995 995
 
996 996
 				$SQL = "INSERT INTO $ticket_price_table
997 997
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
998 998
 				( 1, 1, 1 )
999 999
 				";
1000 1000
 
1001
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL );
1001
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
1002 1002
 				$wpdb->query($SQL);
1003 1003
 			}
1004 1004
 		}
@@ -1011,20 +1011,20 @@  discard block
 block discarded – undo
1011 1011
 	 * @param string $country_name
1012 1012
 	 * @return array where keys are columns, values are column values
1013 1013
 	 */
1014
-	public function get_or_create_country($country_name){
1015
-		if( ! $country_name ){
1014
+	public function get_or_create_country($country_name) {
1015
+		if ( ! $country_name) {
1016 1016
 			throw new EE_Error(__("Could not get a country because country name is blank", "event_espresso"));
1017 1017
 		}
1018 1018
 		global $wpdb;
1019 1019
 		$country_table = $wpdb->prefix."esp_country";
1020
-		if(is_int($country_name)){
1020
+		if (is_int($country_name)) {
1021 1021
 			$country_name = $this->get_iso_from_3_1_country_id($country_name);
1022 1022
 		}
1023 1023
 		$country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
1024 1024
 			CNT_ISO LIKE %s OR
1025 1025
 			CNT_ISO3 LIKE %s OR
1026
-			CNT_name LIKE %s LIMIT 1",$country_name,$country_name,$country_name),ARRAY_A);
1027
-		if( ! $country ){
1026
+			CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A);
1027
+		if ( ! $country) {
1028 1028
 			//insert a new one then
1029 1029
 			$cols_n_values = array(
1030 1030
 				'CNT_ISO'=> $this->_find_available_country_iso(2),
@@ -1044,26 +1044,26 @@  discard block
 block discarded – undo
1044 1044
 				'CNT_active'=>true
1045 1045
 			);
1046 1046
 			$data_types = array(
1047
-				'%s',//CNT_ISO
1048
-				'%s',//CNT_ISO3
1049
-				'%d',//RGN_ID
1050
-				'%s',//CNT_name
1051
-				'%s',//CNT_cur_code
1052
-				'%s',//CNT_cur_single
1053
-				'%s',//CNT_cur_plural
1054
-				'%s',//CNT_cur_sign
1055
-				'%d',//CNT_cur_sign_b4
1056
-				'%d',//CNT_cur_dec_plc
1057
-				'%s',//CNT_cur_dec_mrk
1058
-				'%s',//CNT_cur_thsnds
1059
-				'%s',//CNT_tel_code
1060
-				'%d',//CNT_is_EU
1061
-				'%d',//CNT_active
1047
+				'%s', //CNT_ISO
1048
+				'%s', //CNT_ISO3
1049
+				'%d', //RGN_ID
1050
+				'%s', //CNT_name
1051
+				'%s', //CNT_cur_code
1052
+				'%s', //CNT_cur_single
1053
+				'%s', //CNT_cur_plural
1054
+				'%s', //CNT_cur_sign
1055
+				'%d', //CNT_cur_sign_b4
1056
+				'%d', //CNT_cur_dec_plc
1057
+				'%s', //CNT_cur_dec_mrk
1058
+				'%s', //CNT_cur_thsnds
1059
+				'%s', //CNT_tel_code
1060
+				'%d', //CNT_is_EU
1061
+				'%d', //CNT_active
1062 1062
 			);
1063 1063
 			$success = $wpdb->insert($country_table,
1064 1064
 					$cols_n_values,
1065 1065
 					$data_types);
1066
-			if( ! $success){
1066
+			if ( ! $success) {
1067 1067
 				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('country_id'=>$country_name), $country_table, $cols_n_values, $data_types));
1068 1068
 			}
1069 1069
 			$country = $cols_n_values;
@@ -1075,13 +1075,13 @@  discard block
 block discarded – undo
1075 1075
 	 * @global type $wpdb
1076 1076
 	 * @return string
1077 1077
 	 */
1078
-	private function _find_available_country_iso($num_letters = 2){
1078
+	private function _find_available_country_iso($num_letters = 2) {
1079 1079
 		global $wpdb;
1080 1080
 		$country_table = $wpdb->prefix."esp_country";
1081
-		do{
1081
+		do {
1082 1082
 			$current_iso = strtoupper(wp_generate_password($num_letters, false));
1083
-			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s",$current_iso));
1084
-		}while(intval($country_with_that_iso));
1083
+			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s", $current_iso));
1084
+		}while (intval($country_with_that_iso));
1085 1085
 		return $current_iso;
1086 1086
 	}
1087 1087
 
@@ -1092,14 +1092,14 @@  discard block
 block discarded – undo
1092 1092
 	 * @param string $state_name
1093 1093
 	 * @return array where keys are columns, values are column values
1094 1094
 	 */
1095
-	public function get_or_create_state($state_name,$country_name = ''){
1096
-		if( ! $state_name ){
1095
+	public function get_or_create_state($state_name, $country_name = '') {
1096
+		if ( ! $state_name) {
1097 1097
 			throw new EE_Error(__("Could not get-or-create state because no state name was provided", "event_espresso"));
1098 1098
 		}
1099
-		try{
1099
+		try {
1100 1100
 			$country = $this->get_or_create_country($country_name);
1101 1101
 			$country_iso = $country['CNT_ISO'];
1102
-		}catch(EE_Error $e){
1102
+		} catch (EE_Error $e) {
1103 1103
 			$country_iso = $this->get_default_country_iso();
1104 1104
 		}
1105 1105
 		global $wpdb;
@@ -1107,24 +1107,24 @@  discard block
 block discarded – undo
1107 1107
 		$state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1108 1108
 			(STA_abbrev LIKE %s OR
1109 1109
 			STA_name LIKE %s) AND
1110
-			CNT_ISO LIKE %s LIMIT 1",$state_name,$state_name,$country_iso),ARRAY_A);
1111
-		if ( ! $state){
1110
+			CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A);
1111
+		if ( ! $state) {
1112 1112
 			//insert a new one then
1113 1113
 			$cols_n_values = array(
1114 1114
 				'CNT_ISO'=>$country_iso,
1115
-				'STA_abbrev'=>substr($state_name,0,6),
1115
+				'STA_abbrev'=>substr($state_name, 0, 6),
1116 1116
 				'STA_name'=>$state_name,
1117 1117
 				'STA_active'=>true
1118 1118
 			);
1119 1119
 			$data_types = array(
1120
-				'%s',//CNT_ISO
1121
-				'%s',//STA_abbrev
1122
-				'%s',//STA_name
1123
-				'%d',//STA_active
1120
+				'%s', //CNT_ISO
1121
+				'%s', //STA_abbrev
1122
+				'%s', //STA_name
1123
+				'%d', //STA_active
1124 1124
 			);
1125
-			$success = $wpdb->insert($state_table,$cols_n_values,$data_types);
1126
-			if ( ! $success ){
1127
-				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name,'country_id'=>$country_name), $state_table, $cols_n_values, $data_types));
1125
+			$success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1126
+			if ( ! $success) {
1127
+				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name, 'country_id'=>$country_name), $state_table, $cols_n_values, $data_types));
1128 1128
 			}
1129 1129
 			$state = $cols_n_values;
1130 1130
 			$state['STA_ID'] = $wpdb->insert_id;
@@ -1137,21 +1137,21 @@  discard block
 block discarded – undo
1137 1137
 	 * @param type $timeString
1138 1138
 	 * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes with leading zeros)
1139 1139
 	 */
1140
-	public function convertTimeFromAMPM($timeString){
1140
+	public function convertTimeFromAMPM($timeString) {
1141 1141
 		$matches = array();
1142
-		preg_match("~(\\d*):(\\d*)~",$timeString,$matches);
1143
-		if( ! $matches || count($matches)<3){
1142
+		preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1143
+		if ( ! $matches || count($matches) < 3) {
1144 1144
 			$hour = '00';
1145 1145
 			$minutes = '00';
1146
-		}else{
1146
+		} else {
1147 1147
 			$hour = intval($matches[1]);
1148 1148
 			$minutes = $matches[2];
1149 1149
 		}
1150
-		if(strpos($timeString, 'PM') || strpos($timeString, 'pm')){
1150
+		if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1151 1151
 			$hour = intval($hour) + 12;
1152 1152
 		}
1153
-		$hour = str_pad( "$hour", 2, '0',STR_PAD_LEFT);
1154
-		$minutes = str_pad( "$minutes", 2, '0',STR_PAD_LEFT);
1153
+		$hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1154
+		$minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1155 1155
 		return "$hour:$minutes";
1156 1156
 	}
1157 1157
 
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 	 * @param int $country_id
1161 1161
 	 * @return string the country's ISO3 code
1162 1162
 	 */
1163
-	public function get_iso_from_3_1_country_id($country_id){
1163
+	public function get_iso_from_3_1_country_id($country_id) {
1164 1164
 		$old_countries = array(
1165 1165
 			array(64, 'United States', 'US', 'USA', 1),
1166 1166
 			array(15, 'Australia', 'AU', 'AUS', 1),
@@ -1386,9 +1386,9 @@  discard block
 block discarded – undo
1386 1386
 			array(226, 'Zimbabwe', 'ZW', 'ZWE', 1));
1387 1387
 
1388 1388
 		$country_iso = 'US';
1389
-		foreach($old_countries as $country_array){
1389
+		foreach ($old_countries as $country_array) {
1390 1390
 			//note: index 0 is the 3.1 country ID
1391
-			if($country_array[0] == $country_id){
1391
+			if ($country_array[0] == $country_id) {
1392 1392
 				//note: index 2 is the ISO
1393 1393
 				$country_iso = $country_array[2];
1394 1394
 				break;
@@ -1401,8 +1401,8 @@  discard block
 block discarded – undo
1401 1401
 	 * Gets the ISO3 for the
1402 1402
 	 * @return string
1403 1403
 	 */
1404
-	public function get_default_country_iso(){
1405
-		$old_org_options= get_option('events_organization_settings');
1404
+	public function get_default_country_iso() {
1405
+		$old_org_options = get_option('events_organization_settings');
1406 1406
 		$iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1407 1407
 		return $iso;
1408 1408
 	}
@@ -1414,13 +1414,13 @@  discard block
 block discarded – undo
1414 1414
 	 * the event's DEFAULT payment status, or the attendee's payment status) required pre-approval.
1415 1415
 	 * @return string STS_ID for use in 4.1
1416 1416
 	 */
1417
-	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false){
1417
+	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false) {
1418 1418
 
1419 1419
 		//EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1420
-		if($this_thing_required_pre_approval){
1420
+		if ($this_thing_required_pre_approval) {
1421 1421
 				return 'RNA';
1422
-		}else{
1423
-				$mapping = $default_reg_stati_conversions=array(
1422
+		} else {
1423
+				$mapping = $default_reg_stati_conversions = array(
1424 1424
 			'Completed'=>'RAP',
1425 1425
 			''=>'RPP',
1426 1426
 			'Incomplete'=>'RPP',
@@ -1450,22 +1450,22 @@  discard block
 block discarded – undo
1450 1450
 	 * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1451 1451
 	 * @return boolean whether or not we had to do the big job of creating an image attachment
1452 1452
 	 */
1453
-	public function convert_image_url_to_attachment_and_attach_to_post($guid,$new_cpt_id,  EE_Data_Migration_Script_Stage $migration_stage){
1453
+	public function convert_image_url_to_attachment_and_attach_to_post($guid, $new_cpt_id, EE_Data_Migration_Script_Stage $migration_stage) {
1454 1454
 		$created_attachment_post = false;
1455 1455
 		$guid = $this->_get_original_guid($guid);
1456
-		if($guid){
1456
+		if ($guid) {
1457 1457
 			//check for an existing attachment post with this guid
1458 1458
 			$attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1459
-			if( ! $attachment_post_id){
1459
+			if ( ! $attachment_post_id) {
1460 1460
 				//post thumbnail with that GUID doesn't exist, we should create one
1461 1461
 				$attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1462 1462
 				$created_attachment_post = true;
1463 1463
 			}
1464 1464
 			//double-check we actually have an attachment post
1465
-			if( $attachment_post_id){
1466
-				update_post_meta($new_cpt_id,'_thumbnail_id',$attachment_post_id);
1467
-			}else{
1468
-				$migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"),$guid,$new_cpt_id,$attachment_post_id));
1465
+			if ($attachment_post_id) {
1466
+				update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1467
+			} else {
1468
+				$migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"), $guid, $new_cpt_id, $attachment_post_id));
1469 1469
 			}
1470 1470
 		}
1471 1471
 		return $created_attachment_post;
@@ -1479,13 +1479,13 @@  discard block
 block discarded – undo
1479 1479
 	 * @param string $guid_in_old_event
1480 1480
 	 * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1481 1481
 	 */
1482
-	private function _get_original_guid($guid_in_old_event){
1483
-		$original_guid = preg_replace('~-\d*x\d*\.~','.',$guid_in_old_event,1);
1482
+	private function _get_original_guid($guid_in_old_event) {
1483
+		$original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1484 1484
 		//do a head request to verify the file exists
1485 1485
 		$head_response = wp_remote_head($original_guid);
1486
-		if( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK'){
1486
+		if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1487 1487
 			return $original_guid;
1488
-		}else{
1488
+		} else {
1489 1489
 			return $guid_in_old_event;
1490 1490
 		}
1491 1491
 	}
@@ -1497,32 +1497,32 @@  discard block
 block discarded – undo
1497 1497
 	 * @param EE_Data_Migration_Script_Stage $migration_stage
1498 1498
 	 * @return int
1499 1499
 	 */
1500
-	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage){
1501
-		if ( ! $guid){
1500
+	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage) {
1501
+		if ( ! $guid) {
1502 1502
 			$migration_stage->add_error(sprintf(__("Cannot create image attachment for a blank GUID!", "event_espresso")));
1503 1503
 			return 0;
1504 1504
 		}
1505
-		$wp_filetype = wp_check_filetype(basename($guid), null );
1505
+		$wp_filetype = wp_check_filetype(basename($guid), null);
1506 1506
 		$wp_upload_dir = wp_upload_dir();
1507 1507
 		//if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1508
-		if(strpos($guid,$wp_upload_dir['url']) === FALSE){
1508
+		if (strpos($guid, $wp_upload_dir['url']) === FALSE) {
1509 1509
 			//image is located remotely. download it and place it in the uploads directory
1510
-			if( ! is_readable($guid)){
1511
-				$migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"),$guid));
1510
+			if ( ! is_readable($guid)) {
1511
+				$migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"), $guid));
1512 1512
 				return 0;
1513 1513
 			}
1514
-			$contents= file_get_contents($guid);
1515
-			if($contents === FALSE){
1516
-				$migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"),$guid));
1514
+			$contents = file_get_contents($guid);
1515
+			if ($contents === FALSE) {
1516
+				$migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"), $guid));
1517 1517
 				return false;
1518 1518
 			}
1519
-			$local_filepath  = $wp_upload_dir['path'].DS.basename($guid);
1519
+			$local_filepath = $wp_upload_dir['path'].DS.basename($guid);
1520 1520
 			$savefile = fopen($local_filepath, 'w');
1521 1521
 			fwrite($savefile, $contents);
1522 1522
 			fclose($savefile);
1523
-			$guid = str_replace($wp_upload_dir['path'],$wp_upload_dir['url'],$local_filepath);
1524
-		}else{
1525
-			$local_filepath = str_replace($wp_upload_dir['url'],$wp_upload_dir['path'],$guid);
1523
+			$guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1524
+		} else {
1525
+			$local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1526 1526
 		}
1527 1527
 
1528 1528
 		$attachment = array(
@@ -1532,24 +1532,24 @@  discard block
 block discarded – undo
1532 1532
 		   'post_content' => '',
1533 1533
 		   'post_status' => 'inherit'
1534 1534
 		);
1535
-		$attach_id = wp_insert_attachment( $attachment, $guid );
1536
-		if( ! $attach_id ){
1537
-			$migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"),$guid,$this->_json_encode($attachment)));
1535
+		$attach_id = wp_insert_attachment($attachment, $guid);
1536
+		if ( ! $attach_id) {
1537
+			$migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"), $guid, $this->_json_encode($attachment)));
1538 1538
 			return $attach_id;
1539 1539
 		}
1540 1540
 
1541 1541
 		// you must first include the image.php file
1542 1542
 		// for the function wp_generate_attachment_metadata() to work
1543
-		require_once(ABSPATH . 'wp-admin/includes/image.php');
1543
+		require_once(ABSPATH.'wp-admin/includes/image.php');
1544 1544
 
1545
-		$attach_data = wp_generate_attachment_metadata( $attach_id, $local_filepath );
1546
-		if( ! $attach_data){
1547
-			$migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"),$attach_id,$local_filepath,$guid));
1545
+		$attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1546
+		if ( ! $attach_data) {
1547
+			$migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"), $attach_id, $local_filepath, $guid));
1548 1548
 			return $attach_id;
1549 1549
 		}
1550
-		$metadata_save_result = wp_update_attachment_metadata( $attach_id, $attach_data );
1551
-		if( ! $metadata_save_result ){
1552
-			$migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"),$attach_id,$this->_json_encode($attach_data)));
1550
+		$metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1551
+		if ( ! $metadata_save_result) {
1552
+			$migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"), $attach_id, $this->_json_encode($attach_data)));
1553 1553
 		}
1554 1554
 		return $attach_id;
1555 1555
 	}
@@ -1561,9 +1561,9 @@  discard block
 block discarded – undo
1561 1561
 	 * @param string $guid
1562 1562
 	 * @return int
1563 1563
 	 */
1564
-	private function _get_image_attachment_id_by_GUID($guid){
1564
+	private function _get_image_attachment_id_by_GUID($guid) {
1565 1565
 		global $wpdb;
1566
-		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1",$guid));
1566
+		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1567 1567
 		return $attachment_id;
1568 1568
 	}
1569 1569
 	/**
@@ -1575,20 +1575,20 @@  discard block
 block discarded – undo
1575 1575
 	 * @param string $timezone
1576 1576
 	 * @return string
1577 1577
 	 */
1578
-	public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string,$timezone = null){
1578
+	public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string, $timezone = null) {
1579 1579
 		$original_tz = $timezone;
1580
-		if( ! $timezone){
1580
+		if ( ! $timezone) {
1581 1581
 			$timezone = $this->_get_wp_timezone();
1582 1582
 		}
1583
-		if( ! $timezone){
1584
-			$stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"),$original_tz,$row_of_data));
1583
+		if ( ! $timezone) {
1584
+			$stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"), $original_tz, $row_of_data));
1585 1585
 			$timezone = 'UTC';
1586 1586
 		}
1587
-		try{
1588
-			$date_obj = new DateTime( $DATETIME_string, new DateTimeZone( $timezone ) );
1587
+		try {
1588
+			$date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1589 1589
 			$date_obj->setTimezone(new DateTimeZone('UTC'));
1590
-		}catch(Exception $e){
1591
-			$stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"),$DATETIME_string,$timezone));
1590
+		} catch (Exception $e) {
1591
+			$stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"), $DATETIME_string, $timezone));
1592 1592
 			$date_obj = new DateTime();
1593 1593
 		}
1594 1594
 
@@ -1599,14 +1599,14 @@  discard block
 block discarded – undo
1599 1599
 	 * Gets the DEFAULT timezone string from wordpress (even if they set a gmt offset)
1600 1600
 	 * @return string
1601 1601
 	 */
1602
-	private function _get_wp_timezone(){
1603
-		$timezone = empty( $timezone ) ? get_option('timezone_string') : $timezone;
1602
+	private function _get_wp_timezone() {
1603
+		$timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1604 1604
 
1605 1605
 		//if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1606
-		if ( empty( $timezone ) ) {
1606
+		if (empty($timezone)) {
1607 1607
 			//let's get a the WordPress UTC offset
1608 1608
 			$offset = get_option('gmt_offset');
1609
-			$timezone = $this->timezone_convert_to_string_from_offset( $offset );
1609
+			$timezone = $this->timezone_convert_to_string_from_offset($offset);
1610 1610
 		}
1611 1611
 		return $timezone;
1612 1612
 	}
@@ -1615,11 +1615,11 @@  discard block
 block discarded – undo
1615 1615
 	 * @param int $offset
1616 1616
 	 * @return boolean
1617 1617
 	 */
1618
-	private function timezone_convert_to_string_from_offset($offset){
1618
+	private function timezone_convert_to_string_from_offset($offset) {
1619 1619
 		//shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable
1620 1620
 		$offset *= 3600; // convert hour offset to seconds
1621 1621
         $abbrarray = timezone_abbreviations_list();
1622
-        foreach ($abbrarray as $abbr){
1622
+        foreach ($abbrarray as $abbr) {
1623 1623
                 foreach ($abbr as $city)
1624 1624
                 {
1625 1625
                         if ($city['offset'] == $offset)
@@ -1633,32 +1633,32 @@  discard block
 block discarded – undo
1633 1633
         return FALSE;
1634 1634
 	}
1635 1635
 
1636
-	public function migration_page_hooks(){
1637
-		add_filter('FHEE__ee_migration_page__header',array($this,'_migrate_page_hook_simplify_version_strings'),10,3);
1638
-		add_filter('FHEE__ee_migration_page__p_after_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1639
-		add_filter('FHEE__ee_migration_page__option_1_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,3);
1640
-		add_filter('FHEE__ee_migration_page__option_1_button_text',array($this,'_migrate_page_hook_simplify_version_strings'),10,3);
1641
-		add_action('AHEE__ee_migration_page__option_1_extra_details',array($this,'_migration_page_hook_option_1_extra_details'),10,3);
1642
-		add_filter('FHEE__ee_migration_page__option_2_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,4);
1643
-		add_filter('FHEE__ee_migration_page__option_2_button_text',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1644
-		add_filter('FHEE__ee_migration_page__option_2_details',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1645
-		add_action('AHEE__ee_migration_page__after_migration_options_table',array($this,'_migration_page_hook_after_migration_options_table'));
1646
-		add_filter('FHEE__ee_migration_page__done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1647
-		add_filter('FHEE__ee_migration_page__p_after_done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1636
+	public function migration_page_hooks() {
1637
+		add_filter('FHEE__ee_migration_page__header', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3);
1638
+		add_filter('FHEE__ee_migration_page__p_after_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1639
+		add_filter('FHEE__ee_migration_page__option_1_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3);
1640
+		add_filter('FHEE__ee_migration_page__option_1_button_text', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3);
1641
+		add_action('AHEE__ee_migration_page__option_1_extra_details', array($this, '_migration_page_hook_option_1_extra_details'), 10, 3);
1642
+		add_filter('FHEE__ee_migration_page__option_2_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 4);
1643
+		add_filter('FHEE__ee_migration_page__option_2_button_text', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1644
+		add_filter('FHEE__ee_migration_page__option_2_details', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1645
+		add_action('AHEE__ee_migration_page__after_migration_options_table', array($this, '_migration_page_hook_after_migration_options_table'));
1646
+		add_filter('FHEE__ee_migration_page__done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1647
+		add_filter('FHEE__ee_migration_page__p_after_done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1648 1648
 	}
1649 1649
 
1650
-	public function _migrate_page_hook_simplify_version_strings($old_content,$current_db_state,$next_db_state,$ultimate_db_state = NULL){
1651
-		return str_replace(array($current_db_state,$next_db_state,$ultimate_db_state),array(__('EE3','event_espresso'),__('EE4','event_espresso'),  __("EE4", 'event_espresso')),$old_content);
1650
+	public function _migrate_page_hook_simplify_version_strings($old_content, $current_db_state, $next_db_state, $ultimate_db_state = NULL) {
1651
+		return str_replace(array($current_db_state, $next_db_state, $ultimate_db_state), array(__('EE3', 'event_espresso'), __('EE4', 'event_espresso'), __("EE4", 'event_espresso')), $old_content);
1652 1652
 	}
1653
-	public function _migration_page_hook_simplify_next_db_state($old_content,$next_db_state){
1654
-		return str_replace($next_db_state,  __("EE4", 'event_espresso'),$old_content);
1653
+	public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state) {
1654
+		return str_replace($next_db_state, __("EE4", 'event_espresso'), $old_content);
1655 1655
 	}
1656
-	public function _migration_page_hook_option_1_extra_details(){
1657
-		?><p><?php	printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso"));?></p><?php
1656
+	public function _migration_page_hook_option_1_extra_details() {
1657
+		?><p><?php	printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso")); ?></p><?php
1658 1658
 	}
1659
-	public function _migration_page_hook_after_migration_options_table(){
1659
+	public function _migration_page_hook_after_migration_options_table() {
1660 1660
 		?><p class="ee-attention">
1661
-				<strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso");?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso");	?>
1661
+				<strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso"); ?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso"); ?>
1662 1662
 			</p><?php
1663 1663
 	}
1664 1664
 }
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/data_migration_scripts/EE_DMS_Core_4_5_0.dms.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
 //(all other times it gets resurrected from a wordpress option)
16 16
 $stages = glob(EE_CORE.'data_migration_scripts/4_5_0_stages/*');
17 17
 $class_to_filepath = array();
18
-foreach($stages as $filepath){
18
+foreach ($stages as $filepath) {
19 19
 	$matches = array();
20
-	preg_match('~4_5_0_stages/(.*).dmsstage.php~',$filepath,$matches);
20
+	preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21 21
 	$class_to_filepath[$matches[1]] = $filepath;
22 22
 }
23 23
 //give addons a chance to autoload their stages too
24
-$class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages',$class_to_filepath);
24
+$class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages', $class_to_filepath);
25 25
 EEH_Autoloader::register_autoloader($class_to_filepath);
26 26
 
27
-class EE_DMS_Core_4_5_0 extends EE_Data_Migration_Script_Base{
27
+class EE_DMS_Core_4_5_0 extends EE_Data_Migration_Script_Base {
28 28
 
29 29
 
30 30
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param TableManager  $table_manager
35 35
 	 * @param TableAnalysis $table_analysis
36 36
 	 */
37
-	public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) {
37
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) {
38 38
 		$this->_pretty_name = __("Data Migration to Event Espresso 4.5.0.P", "event_espresso");
39 39
 		$this->_priority = 10;
40 40
 		$this->_migration_stages = array(
@@ -44,21 +44,21 @@  discard block
 block discarded – undo
44 44
 			new EE_DMS_4_5_0_update_wp_user_for_question_groups(),
45 45
 			new EE_DMS_4_5_0_invoice_settings(),
46 46
 			);
47
-		parent::__construct( $table_manager, $table_analysis );
47
+		parent::__construct($table_manager, $table_analysis);
48 48
 	}
49 49
 
50 50
 
51 51
 
52 52
 	public function can_migrate_from_version($version_array) {
53 53
 		$version_string = $version_array['Core'];
54
-		if($version_string <= '4.5.0' && $version_string >= '4.3.0' ){
54
+		if ($version_string <= '4.5.0' && $version_string >= '4.3.0') {
55 55
 //			echo "$version_string can be migrated from";
56 56
 			return true;
57
-		}elseif( ! $version_string ){
57
+		}elseif ( ! $version_string) {
58 58
 //			echo "no version string provided: $version_string";
59 59
 			//no version string provided... this must be pre 4.3
60
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
61
-		}else{
60
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
61
+		} else {
62 62
 //			echo "$version_string doesnt apply";
63 63
 			return false;
64 64
 		}
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 	}
69 69
 	public function schema_changes_before_migration() {
70 70
 		//relies on 4.1's EEH_Activation::create_table
71
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
72
-		$table_name='esp_answer';
73
-		$sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
71
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
72
+		$table_name = 'esp_answer';
73
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
74 74
 					REG_ID INT UNSIGNED NOT NULL,
75 75
 					QST_ID INT UNSIGNED NOT NULL,
76 76
 					ANS_value TEXT NOT NULL,
77 77
 					PRIMARY KEY  (ANS_ID)";
78
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
78
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
79 79
 
80 80
 		$table_name = 'esp_attendee_meta';
81 81
 		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
115 115
 					  CNT_active TINYINT(1) DEFAULT '0',
116 116
 					  PRIMARY KEY  (CNT_ISO)";
117
-		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' );
117
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
118 118
 
119 119
 		$table_name = 'esp_datetime';
120 120
 		$sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 
136 136
 
137 137
 
138
-		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' );
138
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
139 139
 		$table_name = 'esp_event_meta';
140 140
 		$sql = "
141 141
 			EVTM_ID INT NOT NULL AUTO_INCREMENT,
@@ -152,41 +152,41 @@  discard block
 block discarded – undo
152 152
 			EVT_external_URL VARCHAR(200) NULL,
153 153
 			EVT_donations TINYINT(1) NULL,
154 154
 			PRIMARY KEY  (EVTM_ID)";
155
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
155
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
156 156
 
157 157
 
158 158
 
159
-		$table_name='esp_event_question_group';
160
-		$sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
159
+		$table_name = 'esp_event_question_group';
160
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
161 161
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
162 162
 					QSG_ID INT UNSIGNED NOT NULL,
163 163
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
164 164
 					PRIMARY KEY  (EQG_ID)";
165
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
165
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
166 166
 
167 167
 
168 168
 
169
-		$table_name='esp_event_venue';
170
-		$sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
169
+		$table_name = 'esp_event_venue';
170
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
171 171
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
172 172
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
173 173
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
174 174
 				PRIMARY KEY  (EVV_ID)";
175
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
175
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
176 176
 
177 177
 
178 178
 
179
-		$table_name='esp_extra_meta';
180
-		$sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
179
+		$table_name = 'esp_extra_meta';
180
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
181 181
 				OBJ_ID INT(11) DEFAULT NULL,
182 182
 				EXM_type VARCHAR(45) DEFAULT NULL,
183 183
 				EXM_key VARCHAR(45) DEFAULT NULL,
184 184
 				EXM_value TEXT,
185 185
 				PRIMARY KEY  (EXM_ID)";
186
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
186
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
187 187
 
188
-		$table_name='esp_line_item';
189
-		$sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
188
+		$table_name = 'esp_line_item';
189
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
190 190
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
191 191
 				TXN_ID INT(11) DEFAULT NULL,
192 192
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 				OBJ_ID INT(11) DEFAULT NULL,
203 203
 				OBJ_type VARCHAR(45)DEFAULT NULL,
204 204
 				PRIMARY KEY  (LIN_ID)";
205
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB' );
205
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
206 206
 
207 207
 		$table_name = 'esp_message_template';
208 208
 		$sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 					KEY GRP_ID (GRP_ID)";
215 215
 		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
216 216
 
217
-		$this->_get_table_manager()->dropIndex( 'esp_message_template_group', 'EVT_ID' );
217
+		$this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
218 218
 
219 219
 		$table_name = 'esp_message_template_group';
220 220
 		$sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 					MTP_is_active TINYINT(1) NOT NULL DEFAULT '1',
230 230
 					PRIMARY KEY  (GRP_ID),
231 231
 					KEY MTP_user_id (MTP_user_id)";
232
-		$this->_table_should_exist_previously( $table_name, $sql, 'ENGINE=InnoDB');
232
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
233 233
 
234 234
 		$table_name = 'esp_event_message_template';
235 235
 		$sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 					PRIMARY KEY  (EMT_ID),
239 239
 					KEY EVT_ID (EVT_ID),
240 240
 					KEY GRP_ID (GRP_ID)";
241
-		$this->_table_should_exist_previously( $table_name, $sql, 'ENGINE=InnoDB');
241
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
242 242
 
243 243
 
244 244
 		$table_name = 'esp_payment';
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 					  PRIMARY KEY  (TTM_ID)";
289 289
 		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
290 290
 
291
-		$table_name='esp_question';
292
-		$sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
291
+		$table_name = 'esp_question';
292
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
293 293
 					QST_display_text TEXT NOT NULL,
294 294
 					QST_admin_label VARCHAR(255) NOT NULL,
295 295
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -301,27 +301,27 @@  discard block
 block discarded – undo
301 301
 					QST_wp_user BIGINT UNSIGNED NULL,
302 302
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
303 303
 					PRIMARY KEY  (QST_ID)';
304
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
304
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
305 305
 
306
-		$table_name='esp_question_group_question';
307
-		$sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
306
+		$table_name = 'esp_question_group_question';
307
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
308 308
 					QSG_ID INT UNSIGNED NOT NULL,
309 309
 					QST_ID INT UNSIGNED NOT NULL,
310 310
 					QGQ_order INT UNSIGNED NOT NULL DEFAULT 0,
311 311
 					PRIMARY KEY  (QGQ_ID) ";
312
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
312
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
313 313
 
314 314
 
315 315
 
316
-		$table_name='esp_question_option';
317
-		$sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
316
+		$table_name = 'esp_question_option';
317
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
318 318
 					QSO_value VARCHAR(255) NOT NULL,
319 319
 					QSO_desc TEXT NOT NULL,
320 320
 					QST_ID INT UNSIGNED NOT NULL,
321 321
 					QSO_order INT UNSIGNED NOT NULL DEFAULT 0,
322 322
 					QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
323 323
 					PRIMARY KEY  (QSO_ID)";
324
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
324
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
325 325
 
326 326
 
327 327
 
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 
355 355
 
356 356
 
357
-		$table_name='esp_checkin';
358
-		$sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
357
+		$table_name = 'esp_checkin';
358
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
359 359
 					REG_ID INT(10) UNSIGNED NOT NULL,
360 360
 					DTT_ID INT(10) UNSIGNED NOT NULL,
361 361
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 					  PRC_wp_user BIGINT UNSIGNED NULL,
444 444
 					  PRC_parent INT(10) UNSIGNED DEFAULT 0,
445 445
 					  PRIMARY KEY  (PRC_ID)";
446
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
446
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
447 447
 
448 448
 		$table_name = "esp_price_type";
449 449
 		$sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -480,12 +480,12 @@  discard block
 block discarded – undo
480 480
 					  TKT_parent INT(10) UNSIGNED DEFAULT '0',
481 481
 					  TKT_deleted TINYINT(1) NOT NULL DEFAULT '0',
482 482
 					  PRIMARY KEY  (TKT_ID)";
483
-		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' );
483
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
484 484
 
485
-		$this->_get_table_manager()->dropIndex( 'esp_question_group', 'QSG_identifier_UNIQUE' );
485
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
486 486
 
487 487
 		$table_name = 'esp_question_group';
488
-		$sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
488
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
489 489
 					QSG_name VARCHAR(255) NOT NULL,
490 490
 					QSG_identifier VARCHAR(100) NOT NULL,
491 491
 					QSG_desc TEXT NULL,
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 					QSG_wp_user BIGINT UNSIGNED NULL,
498 498
 					PRIMARY KEY  (QSG_ID),
499 499
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
500
-		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' );
500
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
501 501
 
502 502
 		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
503 503
 
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 		return true;
522 522
 	}
523 523
 
524
-	public function migration_page_hooks(){
524
+	public function migration_page_hooks() {
525 525
 
526 526
 	}
527 527
 
@@ -535,21 +535,21 @@  discard block
 block discarded – undo
535 535
 		global $wpdb;
536 536
 		$price_type_table = $wpdb->prefix."esp_price_type";
537 537
 
538
-		if ( $this->_get_table_analysis()->tableExists( $price_type_table ) ) {
538
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
539 539
 
540
-			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
541
-			$price_types_exist = $wpdb->get_var( $SQL );
540
+			$SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table;
541
+			$price_types_exist = $wpdb->get_var($SQL);
542 542
 
543
-			if ( ! $price_types_exist ) {
543
+			if ( ! $price_types_exist) {
544 544
 				$user_id = EEH_Activation::get_default_creator_id();
545 545
 				$SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES
546
-							(1, '" . __('Base Price', 'event_espresso') . "', 1,  0, 0, $user_id, 0),
547
-							(2, '" . __('Percent Discount', 'event_espresso') . "', 2,  1, 20, $user_id, 0),
548
-							(3, '" . __('Dollar Discount', 'event_espresso') . "', 2,  0, 30, $user_id, 0),
549
-							(4, '" . __('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, $user_id,  0),
550
-							(5, '" . __('Dollar Surcharge', 'event_espresso') . "', 3,  0, 50, $user_id, 0);";
551
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL );
552
-				$wpdb->query( $SQL );
546
+							(1, '".__('Base Price', 'event_espresso')."', 1,  0, 0, $user_id, 0),
547
+							(2, '".__('Percent Discount', 'event_espresso')."', 2,  1, 20, $user_id, 0),
548
+							(3, '".__('Dollar Discount', 'event_espresso')."', 2,  0, 30, $user_id, 0),
549
+							(4, '".__('Percent Surcharge', 'event_espresso')."', 3,  1, 40, $user_id,  0),
550
+							(5, '".__('Dollar Surcharge', 'event_espresso')."', 3,  0, 50, $user_id, 0);";
551
+				$SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL);
552
+				$wpdb->query($SQL);
553 553
 			}
554 554
 		}
555 555
 	}
@@ -569,17 +569,17 @@  discard block
 block discarded – undo
569 569
 		global $wpdb;
570 570
 		$price_table = $wpdb->prefix."esp_price";
571 571
 
572
-		if ( $this->_get_table_analysis()->tableExists( $price_table ) ) {
572
+		if ($this->_get_table_analysis()->tableExists($price_table)) {
573 573
 
574
-			$SQL = 'SELECT COUNT(PRC_ID) FROM ' .$price_table;
575
-			$prices_exist = $wpdb->get_var( $SQL );
574
+			$SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table;
575
+			$prices_exist = $wpdb->get_var($SQL);
576 576
 
577
-			if ( ! $prices_exist ) {
577
+			if ( ! $prices_exist) {
578 578
 				$user_id = EEH_Activation::get_default_creator_id();
579 579
 				$SQL = "INSERT INTO $price_table
580 580
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_wp_user, PRC_order, PRC_deleted, PRC_parent ) VALUES
581 581
 							(1, 1, '0.00', 'Free Admission', '', 1, NULL, $user_id, 0, 0, 0);";
582
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL );
582
+				$SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL);
583 583
 				$wpdb->query($SQL);
584 584
 			}
585 585
 		}
@@ -597,35 +597,35 @@  discard block
 block discarded – undo
597 597
 
598 598
 		global $wpdb;
599 599
 		$ticket_table = $wpdb->prefix."esp_ticket";
600
-		if ( $this->_get_table_analysis()->tableExists( $ticket_table ) ) {
600
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
601 601
 
602
-			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
602
+			$SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
603 603
 			$tickets_exist = $wpdb->get_var($SQL);
604 604
 
605
-			if ( ! $tickets_exist ) {
605
+			if ( ! $tickets_exist) {
606 606
 				$user_id = EEH_Activation::get_default_creator_id();
607 607
 				$SQL = "INSERT INTO $ticket_table
608 608
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_wp_user, TKT_deleted ) VALUES
609
-					( 1, 0, '" . __("Free Ticket", "event_espresso") . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);";
610
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL );
609
+					( 1, 0, '".__("Free Ticket", "event_espresso")."', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);";
610
+				$SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL);
611 611
 				$wpdb->query($SQL);
612 612
 			}
613 613
 		}
614 614
 		$ticket_price_table = $wpdb->prefix."esp_ticket_price";
615 615
 
616
-		if ( $this->_get_table_analysis()->tableExists( $ticket_price_table ) ) {
616
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
617 617
 
618
-			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
618
+			$SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
619 619
 			$ticket_prc_exist = $wpdb->get_var($SQL);
620 620
 
621
-			if ( ! $ticket_prc_exist ) {
621
+			if ( ! $ticket_prc_exist) {
622 622
 
623 623
 				$SQL = "INSERT INTO $ticket_price_table
624 624
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
625 625
 				( 1, 1, 1 )
626 626
 				";
627 627
 
628
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL );
628
+				$SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL);
629 629
 				$wpdb->query($SQL);
630 630
 			}
631 631
 		}
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_2_0.dms.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
 //(all other times it gets resurrected from a wordpress option)
15 15
 $stages = glob(EE_CORE.'data_migration_scripts/4_2_0_stages/*');
16 16
 $class_to_filepath = array();
17
-if ( ! empty( $stages ) ) {
18
-	foreach($stages as $filepath){
17
+if ( ! empty($stages)) {
18
+	foreach ($stages as $filepath) {
19 19
 		$matches = array();
20
-		preg_match('~4_2_0_stages/(.*).dmsstage.php~',$filepath,$matches);
20
+		preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21 21
 		$class_to_filepath[$matches[1]] = $filepath;
22 22
 	}
23 23
 }
24 24
 //give addons a chance to autoload their stages too
25
-$class_to_filepath = apply_filters('FHEE__EE_DMS_4_2_0__autoloaded_stages',$class_to_filepath);
25
+$class_to_filepath = apply_filters('FHEE__EE_DMS_4_2_0__autoloaded_stages', $class_to_filepath);
26 26
 EEH_Autoloader::register_autoloader($class_to_filepath);
27 27
 
28
-class EE_DMS_Core_4_2_0 extends EE_Data_Migration_Script_Base{
28
+class EE_DMS_Core_4_2_0 extends EE_Data_Migration_Script_Base {
29 29
 
30 30
 
31 31
 
@@ -35,26 +35,26 @@  discard block
 block discarded – undo
35 35
 	 * @param TableManager  $table_manager
36 36
 	 * @param TableAnalysis $table_analysis
37 37
 	 */
38
-	public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) {
38
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) {
39 39
 		$this->_pretty_name = __("Data Migration to Event Espresso 4.2.0.P", "event_espresso");
40 40
 		$this->_priority = 10;
41 41
 		$this->_migration_stages = array(
42 42
 			new EE_DMS_4_2_0_question_group_questions(),
43 43
 			new EE_DMS_4_2_0_datetime_fields(),
44 44
 		);
45
-		parent::__construct( $table_manager, $table_analysis );
45
+		parent::__construct($table_manager, $table_analysis);
46 46
 	}
47 47
 	public function can_migrate_from_version($version_array) {
48 48
 		$version_string = $version_array['Core'];
49
-		if($version_string <= '4.2.0' && $version_string >= '4.1.0' ){
49
+		if ($version_string <= '4.2.0' && $version_string >= '4.1.0') {
50 50
 //			echo "$version_string can be migrated fro";
51 51
 			return true;
52
-		}elseif( ! $version_string ){
52
+		}elseif ( ! $version_string) {
53 53
 //			echo "no version string provided: $version_string";
54 54
 			//no version string provided... this must be pre 4.1
55 55
 			//because since 4.1 we're
56
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
57
-		}else{
56
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
57
+		} else {
58 58
 //			echo "$version_string doesnt apply";
59 59
 			return false;
60 60
 		}
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
 	}
65 65
 	public function schema_changes_before_migration() {
66 66
 		//relies on 4.1's EEH_Activation::create_table
67
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
68
-		$table_name='esp_answer';
69
-		$sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
67
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
68
+		$table_name = 'esp_answer';
69
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
70 70
 					REG_ID INT UNSIGNED NOT NULL,
71 71
 					QST_ID INT UNSIGNED NOT NULL,
72 72
 					ANS_value TEXT NOT NULL,
73 73
 					PRIMARY KEY  (ANS_ID)";
74
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
74
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
75 75
 
76 76
 		$table_name = 'esp_attendee_meta';
77 77
 		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
112 112
 					  CNT_active TINYINT(1) DEFAULT '0',
113 113
 					  PRIMARY KEY  (CNT_ISO)";
114
-		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' );
114
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
115 115
 
116 116
 
117 117
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 
136 136
 
137
-		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' );
137
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
138 138
 		$table_name = 'esp_event_meta';
139 139
 		$sql = "
140 140
 			EVTM_ID INT NOT NULL AUTO_INCREMENT,
@@ -151,41 +151,41 @@  discard block
 block discarded – undo
151 151
 			EVT_external_URL VARCHAR(200) NULL,
152 152
 			EVT_donations TINYINT(1) NULL,
153 153
 			PRIMARY KEY  (EVTM_ID)";
154
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
154
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
155 155
 
156 156
 
157 157
 
158
-		$table_name='esp_event_question_group';
159
-		$sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
158
+		$table_name = 'esp_event_question_group';
159
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
160 160
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
161 161
 					QSG_ID INT UNSIGNED NOT NULL,
162 162
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
163 163
 					PRIMARY KEY  (EQG_ID)";
164
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
164
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
165 165
 
166 166
 
167 167
 
168
-		$table_name='esp_event_venue';
169
-		$sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
168
+		$table_name = 'esp_event_venue';
169
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
170 170
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
171 171
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
172 172
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
173 173
 				PRIMARY KEY  (EVV_ID)";
174
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
174
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
175 175
 
176 176
 
177 177
 
178
-		$table_name='esp_extra_meta';
179
-		$sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
178
+		$table_name = 'esp_extra_meta';
179
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
180 180
 				OBJ_ID INT(11) DEFAULT NULL,
181 181
 				EXM_type VARCHAR(45) DEFAULT NULL,
182 182
 				EXM_key VARCHAR(45) DEFAULT NULL,
183 183
 				EXM_value TEXT,
184 184
 				PRIMARY KEY  (EXM_ID)";
185
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
185
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
186 186
 
187
-		$table_name='esp_line_item';
188
-		$sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
187
+		$table_name = 'esp_line_item';
188
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
189 189
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
190 190
 				TXN_ID INT(11) DEFAULT NULL,
191 191
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 				OBJ_ID INT(11) DEFAULT NULL,
202 202
 				OBJ_type VARCHAR(45)DEFAULT NULL,
203 203
 				PRIMARY KEY  (LIN_ID)";
204
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB' );
204
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
205 205
 
206 206
 		$table_name = 'esp_message_template';
207 207
 		$sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 					PRIMARY KEY  (GRP_ID),
229 229
 					KEY EVT_ID (EVT_ID),
230 230
 					KEY MTP_user_id (MTP_user_id)";
231
-		$this->_table_should_exist_previously( $table_name, $sql, 'ENGINE=InnoDB');
231
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
232 232
 
233 233
 
234 234
 
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 
337 337
 
338 338
 
339
-		$table_name='esp_question';
340
-		$sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
339
+		$table_name = 'esp_question';
340
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
341 341
 					QST_display_text TEXT NOT NULL,
342 342
 					QST_admin_label VARCHAR(255) NOT NULL,
343 343
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -349,12 +349,12 @@  discard block
 block discarded – undo
349 349
 					QST_wp_user BIGINT UNSIGNED NULL,
350 350
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
351 351
 					PRIMARY KEY  (QST_ID)';
352
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
352
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
353 353
 
354
-		$this->_get_table_manager()->dropIndex( 'esp_question_group', 'QSG_identifier_UNIQUE' );
354
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
355 355
 
356 356
 		$table_name = 'esp_question_group';
357
-		$sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
357
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
358 358
 					QSG_name VARCHAR(255) NOT NULL,
359 359
 					QSG_identifier VARCHAR(100) NOT NULL,
360 360
 					QSG_desc TEXT NULL,
@@ -365,28 +365,28 @@  discard block
 block discarded – undo
365 365
 					QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
366 366
 					PRIMARY KEY  (QSG_ID),
367 367
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
368
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
368
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
369 369
 
370 370
 
371 371
 
372
-		$table_name='esp_question_group_question';
373
-		$sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
372
+		$table_name = 'esp_question_group_question';
373
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
374 374
 					QSG_ID INT UNSIGNED NOT NULL,
375 375
 					QST_ID INT UNSIGNED NOT NULL,
376 376
 					QGQ_order INT UNSIGNED NOT NULL DEFAULT 0,
377 377
 					PRIMARY KEY  (QGQ_ID) ";
378
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
378
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
379 379
 
380 380
 
381 381
 
382
-		$table_name='esp_question_option';
383
-		$sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
382
+		$table_name = 'esp_question_option';
383
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
384 384
 					QSO_value VARCHAR(255) NOT NULL,
385 385
 					QSO_desc TEXT NOT NULL,
386 386
 					QST_ID INT UNSIGNED NOT NULL,
387 387
 					QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
388 388
 					PRIMARY KEY  (QSO_ID)";
389
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
389
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
390 390
 
391 391
 
392 392
 
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 
420 420
 
421 421
 
422
-		$table_name='esp_checkin';
423
-		$sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
422
+		$table_name = 'esp_checkin';
423
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
424 424
 					REG_ID INT(10) UNSIGNED NOT NULL,
425 425
 					DTT_ID INT(10) UNSIGNED NOT NULL,
426 426
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
495 495
 
496 496
 
497
-		$script_with_defaults = EE_Registry::instance()->load_dms( 'Core_4_1_0' );
497
+		$script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
498 498
 		//setting up the DEFAULT stats and countries is also essential for the data migrations to run
499 499
 		//(because many need to convert old string states to foreign keys into the states table)
500 500
 		$script_with_defaults->insert_default_states();
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 		return true;
517 517
 	}
518 518
 
519
-	public function migration_page_hooks(){
519
+	public function migration_page_hooks() {
520 520
 
521 521
 	}
522 522
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_6_0.dms.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 //(all other times it gets resurrected from a wordpress option)
14 14
 $stages = glob(EE_CORE.'data_migration_scripts/4_6_0_stages/*');
15 15
 $class_to_filepath = array();
16
-foreach($stages as $filepath){
16
+foreach ($stages as $filepath) {
17 17
 	$matches = array();
18
-	preg_match('~4_6_0_stages/(.*).dmsstage.php~',$filepath,$matches);
18
+	preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19 19
 	$class_to_filepath[$matches[1]] = $filepath;
20 20
 }
21 21
 //give addons a chance to autoload their stages too
22
-$class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages',$class_to_filepath);
22
+$class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath);
23 23
 EEH_Autoloader::register_autoloader($class_to_filepath);
24 24
 
25 25
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
  * @since                4.6.0
36 36
  *
37 37
  */
38
-class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base{
38
+class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base {
39 39
 
40 40
 	/**
41 41
 	 * return EE_DMS_Core_4_6_0
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @param TableManager  $table_manager
44 44
 	 * @param TableAnalysis $table_analysis
45 45
 	 */
46
-	public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) {
46
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) {
47 47
 		$this->_pretty_name = __("Data Migration to Event Espresso 4.6.0.P", "event_espresso");
48 48
 		$this->_priority = 10;
49 49
 		$this->_migration_stages = array(
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 			new EE_DMS_4_6_0_payments(),
58 58
 			new EE_DMS_4_6_0_invoice_settings()
59 59
 		);
60
-		parent::__construct( $table_manager, $table_analysis );
60
+		parent::__construct($table_manager, $table_analysis);
61 61
 	}
62 62
 
63 63
 
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function can_migrate_from_version($version_array) {
70 70
 		$version_string = $version_array['Core'];
71
-		if($version_string <= '4.6.0' && $version_string >= '4.5.0' ){
71
+		if ($version_string <= '4.6.0' && $version_string >= '4.5.0') {
72 72
 //			echo "$version_string can be migrated from";
73 73
 			return true;
74
-		}elseif( ! $version_string ){
74
+		}elseif ( ! $version_string) {
75 75
 //			echo "no version string provided: $version_string";
76 76
 			//no version string provided... this must be pre 4.3
77
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
78
-		}else{
77
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
78
+		} else {
79 79
 //			echo "$version_string doesnt apply";
80 80
 			return false;
81 81
 		}
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function schema_changes_before_migration() {
99 99
 		//relies on 4.1's EEH_Activation::create_table
100
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
101
-		$table_name='esp_answer';
102
-		$sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
100
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
101
+		$table_name = 'esp_answer';
102
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
103 103
 					REG_ID INT UNSIGNED NOT NULL,
104 104
 					QST_ID INT UNSIGNED NOT NULL,
105 105
 					ANS_value TEXT NOT NULL,
106 106
 					PRIMARY KEY  (ANS_ID)";
107
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
107
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
108 108
 
109 109
 		$table_name = 'esp_attendee_meta';
110 110
 		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
144 144
 					  CNT_active TINYINT(1) DEFAULT '0',
145 145
 					  PRIMARY KEY  (CNT_ISO)";
146
-		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' );
146
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
147 147
 
148 148
 		$table_name = 'esp_currency';
149 149
 		$sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL,
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 				CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2',
154 154
 				CUR_active TINYINT(1) DEFAULT '0',
155 155
 				PRIMARY KEY  (CUR_code)";
156
-		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
156
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
157 157
 
158 158
 
159 159
 		$table_name = 'esp_currency_payment_method';
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
 
185 185
 
186
-		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' );
186
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
187 187
 		$table_name = 'esp_event_meta';
188 188
 		$sql = "
189 189
 			EVTM_ID INT NOT NULL AUTO_INCREMENT,
@@ -200,41 +200,41 @@  discard block
 block discarded – undo
200 200
 			EVT_external_URL VARCHAR(200) NULL,
201 201
 			EVT_donations TINYINT(1) NULL,
202 202
 			PRIMARY KEY  (EVTM_ID)";
203
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
203
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
204 204
 
205 205
 
206 206
 
207
-		$table_name='esp_event_question_group';
208
-		$sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
207
+		$table_name = 'esp_event_question_group';
208
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
209 209
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
210 210
 					QSG_ID INT UNSIGNED NOT NULL,
211 211
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
212 212
 					PRIMARY KEY  (EQG_ID)";
213
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
213
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
214 214
 
215 215
 
216 216
 
217
-		$table_name='esp_event_venue';
218
-		$sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
217
+		$table_name = 'esp_event_venue';
218
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
219 219
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
220 220
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
221 221
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
222 222
 				PRIMARY KEY  (EVV_ID)";
223
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
223
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
224 224
 
225 225
 
226 226
 
227
-		$table_name='esp_extra_meta';
228
-		$sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
227
+		$table_name = 'esp_extra_meta';
228
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
229 229
 				OBJ_ID INT(11) DEFAULT NULL,
230 230
 				EXM_type VARCHAR(45) DEFAULT NULL,
231 231
 				EXM_key VARCHAR(45) DEFAULT NULL,
232 232
 				EXM_value TEXT,
233 233
 				PRIMARY KEY  (EXM_ID)";
234
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
234
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
235 235
 
236
-		$table_name='esp_line_item';
237
-		$sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
236
+		$table_name = 'esp_line_item';
237
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
238 238
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
239 239
 				TXN_ID INT(11) DEFAULT NULL,
240 240
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 				OBJ_ID INT(11) DEFAULT NULL,
251 251
 				OBJ_type VARCHAR(45)DEFAULT NULL,
252 252
 				PRIMARY KEY  (LIN_ID)";
253
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB' );
253
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
254 254
 
255 255
 		$table_name = 'esp_log';
256 256
 		$sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT,
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 					KEY GRP_ID (GRP_ID)";
274 274
 		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
275 275
 
276
-		$this->_get_table_manager()->dropIndex( 'esp_message_template_group', 'EVT_ID' );
276
+		$this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
277 277
 
278 278
 		$table_name = 'esp_message_template_group';
279 279
 		$sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 					MTP_is_active TINYINT(1) NOT NULL DEFAULT '1',
289 289
 					PRIMARY KEY  (GRP_ID),
290 290
 					KEY MTP_user_id (MTP_user_id)";
291
-		$this->_table_should_exist_previously( $table_name, $sql, 'ENGINE=InnoDB');
291
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
292 292
 
293 293
 		$table_name = 'esp_event_message_template';
294 294
 		$sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 					PRIMARY KEY  (EMT_ID),
298 298
 					KEY EVT_ID (EVT_ID),
299 299
 					KEY GRP_ID (GRP_ID)";
300
-		$this->_table_should_exist_previously( $table_name, $sql, 'ENGINE=InnoDB');
300
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
301 301
 
302 302
 
303 303
 		$table_name = 'esp_payment';
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 					  PRIMARY KEY  (TTM_ID)";
366 366
 		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
367 367
 
368
-		$table_name='esp_question';
369
-		$sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
368
+		$table_name = 'esp_question';
369
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
370 370
 					QST_display_text TEXT NOT NULL,
371 371
 					QST_admin_label VARCHAR(255) NOT NULL,
372 372
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -378,27 +378,27 @@  discard block
 block discarded – undo
378 378
 					QST_wp_user BIGINT UNSIGNED NULL,
379 379
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
380 380
 					PRIMARY KEY  (QST_ID)';
381
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
381
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
382 382
 
383
-		$table_name='esp_question_group_question';
384
-		$sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
383
+		$table_name = 'esp_question_group_question';
384
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
385 385
 					QSG_ID INT UNSIGNED NOT NULL,
386 386
 					QST_ID INT UNSIGNED NOT NULL,
387 387
 					QGQ_order INT UNSIGNED NOT NULL DEFAULT 0,
388 388
 					PRIMARY KEY  (QGQ_ID) ";
389
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
389
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
390 390
 
391 391
 
392 392
 
393
-		$table_name='esp_question_option';
394
-		$sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
393
+		$table_name = 'esp_question_option';
394
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
395 395
 					QSO_value VARCHAR(255) NOT NULL,
396 396
 					QSO_desc TEXT NOT NULL,
397 397
 					QST_ID INT UNSIGNED NOT NULL,
398 398
 					QSO_order INT UNSIGNED NOT NULL DEFAULT 0,
399 399
 					QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
400 400
 					PRIMARY KEY  (QSO_ID)";
401
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
401
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
402 402
 
403 403
 
404 404
 
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 
432 432
 
433 433
 
434
-		$table_name='esp_checkin';
435
-		$sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
434
+		$table_name = 'esp_checkin';
435
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
436 436
 					REG_ID INT(10) UNSIGNED NOT NULL,
437 437
 					DTT_ID INT(10) UNSIGNED NOT NULL,
438 438
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 					  PRC_wp_user BIGINT UNSIGNED NULL,
522 522
 					  PRC_parent INT(10) UNSIGNED DEFAULT 0,
523 523
 					  PRIMARY KEY  (PRC_ID)";
524
-		$this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB');
524
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
525 525
 
526 526
 		$table_name = "esp_price_type";
527 527
 		$sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -558,12 +558,12 @@  discard block
 block discarded – undo
558 558
 					  TKT_parent INT(10) UNSIGNED DEFAULT '0',
559 559
 					  TKT_deleted TINYINT(1) NOT NULL DEFAULT '0',
560 560
 					  PRIMARY KEY  (TKT_ID)";
561
-		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' );
561
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
562 562
 
563
-		$this->_get_table_manager()->dropIndex( 'esp_question_group', 'QSG_identifier_UNIQUE' );
563
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
564 564
 
565 565
 		$table_name = 'esp_question_group';
566
-		$sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
566
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
567 567
 					QSG_name VARCHAR(255) NOT NULL,
568 568
 					QSG_identifier VARCHAR(100) NOT NULL,
569 569
 					QSG_desc TEXT NULL,
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 					QSG_wp_user BIGINT UNSIGNED NULL,
576 576
 					PRIMARY KEY  (QSG_ID),
577 577
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
578
-		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' );
578
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
579 579
 
580 580
 		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
581 581
 		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
@@ -603,15 +603,15 @@  discard block
 block discarded – undo
603 603
 		return true;
604 604
 	}
605 605
 
606
-	public function migration_page_hooks(){
606
+	public function migration_page_hooks() {
607 607
 
608 608
 	}
609 609
 
610
-	public function add_default_admin_only_payments(){
610
+	public function add_default_admin_only_payments() {
611 611
 		global $wpdb;
612 612
 		$table_name = $wpdb->prefix."esp_payment_method";
613 613
 		$user_id = EEH_Activation::get_default_creator_id();
614
-		if ( $this->_get_table_analysis()->tableExists( $table_name ) ) {
614
+		if ($this->_get_table_analysis()->tableExists($table_name)) {
615 615
 
616 616
 			$SQL = "SELECT COUNT( * ) FROM $table_name";
617 617
 			$existing_payment_methods = $wpdb->get_var($SQL);
@@ -632,11 +632,11 @@  discard block
 block discarded – undo
632 632
 			//so admins can record payments for them from the admin page
633 633
 
634 634
 
635
-			foreach($default_admin_only_payment_methods as $nicename => $description){
635
+			foreach ($default_admin_only_payment_methods as $nicename => $description) {
636 636
 				$slug = sanitize_key($nicename);
637 637
 			//check that such a payment method exists
638
-				$exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s",$slug));
639
-				if( ! $exists){
638
+				$exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug));
639
+				if ( ! $exists) {
640 640
 					$values = array(
641 641
 								'PMD_type'=>'Admin_Only',
642 642
 								'PMD_name'=>$nicename,
@@ -650,17 +650,17 @@  discard block
 block discarded – undo
650 650
 							$table_name,
651 651
 							$values,
652 652
 							array(
653
-								'%s',//PMD_type
654
-								'%s',//PMD_name
655
-								'%s',//PMD_admin_name
656
-								'%s',//PMD_admin_desc
657
-								'%s',//PMD_slug
658
-								'%d',//PMD_wp_user
659
-								'%s',//PMD_scope
653
+								'%s', //PMD_type
654
+								'%s', //PMD_name
655
+								'%s', //PMD_admin_name
656
+								'%s', //PMD_admin_desc
657
+								'%s', //PMD_slug
658
+								'%d', //PMD_wp_user
659
+								'%s', //PMD_scope
660 660
 							)
661 661
 							);
662
-					if( ! $success ){
663
-						$this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", "event_espresso"),$this->_json_encode($values)));
662
+					if ( ! $success) {
663
+						$this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", "event_espresso"), $this->_json_encode($values)));
664 664
 					}
665 665
 				}
666 666
 			}
@@ -678,11 +678,11 @@  discard block
 block discarded – undo
678 678
 
679 679
 		global $wpdb;
680 680
 		$currency_table = $wpdb->prefix."esp_currency";
681
-		if ( $this->_get_table_analysis()->tableExists( $currency_table ) ) {
681
+		if ($this->_get_table_analysis()->tableExists($currency_table)) {
682 682
 
683 683
 			$SQL = "SELECT COUNT('CUR_code') FROM $currency_table";
684 684
 			$countries = $wpdb->get_var($SQL);
685
-			if ( ! $countries ) {
685
+			if ( ! $countries) {
686 686
 				$SQL = "INSERT INTO $currency_table
687 687
 				( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES
688 688
 				( 'EUR',  'Euro',  'Euros',  '€',  2,1),
Please login to merge, or discard this patch.