Completed
Branch BUG-8698-ticket-sellouts (01ee02)
by
unknown
125:34 queued 107:52
created
core/helpers/EEH_File.helper.php 2 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -595,8 +595,6 @@
 block discarded – undo
595 595
 	 * converts it into a "remote" filepath (the filepath the currently-in-use 
596 596
 	 * $wp_filesystem needs to use access the folder or file).
597 597
 	 * See http://wordpress.stackexchange.com/questions/124900/using-wp-filesystem-in-plugins
598
-	 * @param WP_Filesystem_Base $wp_filesystem we aren't initially sure which one
599
-	 * is in use, so you need to provide it
600 598
 	 * @param string $local_filepath the filepath to the folder/file locally
601 599
 	 * @return string the remote filepath (eg the filepath the filesystem method, eg 
602 600
 	 * ftp or ssh, will use to access the folder
Please login to merge, or discard this patch.
Spacing   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -27,30 +27,30 @@  discard block
 block discarded – undo
27 27
 	 * @throws EE_Error
28 28
 	 * @return WP_Filesystem_Base
29 29
 	 */
30
-	private static function _get_wp_filesystem( $filepath = null) {
31
-		if( apply_filters( 
30
+	private static function _get_wp_filesystem($filepath = null) {
31
+		if (apply_filters( 
32 32
 				'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct', 
33
-				$filepath && EEH_File::is_in_uploads_folder( $filepath ), 
34
-				$filepath ) ) {
35
-			if( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct ) {
36
-				require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
33
+				$filepath && EEH_File::is_in_uploads_folder($filepath), 
34
+				$filepath )) {
35
+			if ( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) {
36
+				require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php');
37 37
 				$method = 'direct';
38
-				$wp_filesystem_direct_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method );
38
+				$wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method);
39 39
 				//check constants defined, just like in wp-admin/includes/file.php's WP_Filesystem()
40
-				if ( ! defined('FS_CHMOD_DIR') ) {
41
-					define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) );
40
+				if ( ! defined('FS_CHMOD_DIR')) {
41
+					define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755));
42 42
 				}
43
-				if ( ! defined('FS_CHMOD_FILE') ) {
44
-					define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) );
43
+				if ( ! defined('FS_CHMOD_FILE')) {
44
+					define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644));
45 45
 				}
46
-				require_once( $wp_filesystem_direct_file );
47
-				EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct( array() );
46
+				require_once($wp_filesystem_direct_file);
47
+				EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array());
48 48
 			}
49 49
 			return EEH_File::$_wp_filesystem_direct;
50 50
 		}
51 51
 		global $wp_filesystem;
52 52
 		// no filesystem setup ???
53
-		if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) {
53
+		if ( ! $wp_filesystem instanceof WP_Filesystem_Base) {
54 54
 			// if some eager beaver's just trying to get in there too early...
55 55
 			// let them do it, because we are one of those eager beavers! :P
56 56
 			/**
@@ -63,34 +63,34 @@  discard block
 block discarded – undo
63 63
 			 * and there may be troubles if the WP files are owned by a different user
64 64
 			 * than the server user. But both of these issues should exist in 4.4 and earlier too
65 65
 			 */
66
-			if ( FALSE && ! did_action( 'wp_loaded' )) {
66
+			if (FALSE && ! did_action('wp_loaded')) {
67 67
 				$msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso');
68
-				if ( WP_DEBUG ) {
69
-					$msg .= '<br />' .  __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
68
+				if (WP_DEBUG) {
69
+					$msg .= '<br />'.__('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
70 70
 				}
71
-				throw new EE_Error( $msg );
71
+				throw new EE_Error($msg);
72 72
 			} else {
73 73
 				// should be loaded if we are past the wp_loaded hook...
74
-				if ( ! function_exists( 'WP_Filesystem' )) {
75
-					require_once( ABSPATH . 'wp-admin/includes/file.php' );
76
-					require_once( ABSPATH . 'wp-admin/includes/template.php' );
74
+				if ( ! function_exists('WP_Filesystem')) {
75
+					require_once(ABSPATH.'wp-admin/includes/file.php');
76
+					require_once(ABSPATH.'wp-admin/includes/template.php');
77 77
 				}
78 78
 				// turn on output buffering so that we can capture the credentials form
79 79
 				ob_start();
80
-				$credentials = request_filesystem_credentials( '' );
80
+				$credentials = request_filesystem_credentials('');
81 81
 				// store credentials form for the time being
82 82
 				EEH_File::$_credentials_form = ob_get_clean();
83 83
 				// basically check for direct or previously configured access
84
-				if ( ! WP_Filesystem( $credentials ) ) {
84
+				if ( ! WP_Filesystem($credentials)) {
85 85
 					// if credentials do NOT exist
86
-					if ( $credentials === FALSE ) {
87
-						add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 );
88
-						throw new EE_Error( __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
89
-					} elseif( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {						
90
-						add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 );
86
+					if ($credentials === FALSE) {
87
+						add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
88
+						throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
89
+					} elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {						
90
+						add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
91 91
 						throw new EE_Error( 
92 92
 								sprintf( 
93
-										__( 'WP Filesystem Error: $1%s', 'event_espresso' ), 
93
+										__('WP Filesystem Error: $1%s', 'event_espresso'), 
94 94
 										$wp_filesystem->errors->get_error_message() ) );
95 95
 					}
96 96
 				}
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	 * display_request_filesystem_credentials_form
104 104
 	 */
105 105
 	public static function display_request_filesystem_credentials_form() {
106
-		if ( ! empty( EEH_File::$_credentials_form )) {
107
-			echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>';
106
+		if ( ! empty(EEH_File::$_credentials_form)) {
107
+			echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>';
108 108
 		}
109 109
 	}
110 110
 
@@ -122,29 +122,29 @@  discard block
 block discarded – undo
122 122
 	 * @throws EE_Error
123 123
 	 * @return bool
124 124
 	 */
125
-	public static function verify_filepath_and_permissions( $full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '' ) {
125
+	public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '') {
126 126
 		// load WP_Filesystem and set file permissions
127
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
128
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
129
-		if ( ! $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) )) {
130
-			$file_name = ! empty( $type_of_file ) ? $file_name . ' ' . $type_of_file : $file_name;
131
-			$file_name .= ! empty( $file_ext ) ? ' file' : ' folder';
127
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
128
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
129
+		if ( ! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
130
+			$file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name;
131
+			$file_name .= ! empty($file_ext) ? ' file' : ' folder';
132 132
 			$msg = sprintf(
133
-				__( 'The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso' ),
133
+				__('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'),
134 134
 				$file_name,
135 135
 				'<br />'
136 136
 			);
137
-			if ( EEH_File::exists( $full_file_path )) {
138
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, $type_of_file );
137
+			if (EEH_File::exists($full_file_path)) {
138
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file);
139 139
 			} else {
140 140
 				// no file permissions means the file was not found
141 141
 				$msg .= sprintf(
142
-					__( 'Please ensure the following path is correct: "%s".', 'event_espresso' ),
142
+					__('Please ensure the following path is correct: "%s".', 'event_espresso'),
143 143
 					$full_file_path
144 144
 				);
145 145
 			}
146
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
147
-				throw new EE_Error( $msg . '||' . $msg );
146
+			if (defined('WP_DEBUG') && WP_DEBUG) {
147
+				throw new EE_Error($msg.'||'.$msg);
148 148
 			}
149 149
 			return FALSE;
150 150
 		}
@@ -161,24 +161,24 @@  discard block
 block discarded – undo
161 161
 	 * @param string $type_of_file - general type of file (ie: "module"), this is only used to improve error messages
162 162
 	 * @return string
163 163
 	 */
164
-	private static function _permissions_error_for_unreadable_filepath( $full_file_path = '', $type_of_file = '' ){
164
+	private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '') {
165 165
 		// load WP_Filesystem and set file permissions
166
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
166
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
167 167
 		// check file permissions
168
-		$perms = $wp_filesystem->getchmod( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) );
169
-		if ( $perms ) {
168
+		$perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
169
+		if ($perms) {
170 170
 			// file permissions exist, but way be set incorrectly
171
-			$type_of_file = ! empty( $type_of_file ) ? $type_of_file . ' ' : '';
172
-			$type_of_file .= ! empty( $type_of_file ) ? 'file' : 'folder';
171
+			$type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : '';
172
+			$type_of_file .= ! empty($type_of_file) ? 'file' : 'folder';
173 173
 			return sprintf(
174
-				__( 'File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso' ),
174
+				__('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'),
175 175
 				$type_of_file,
176 176
 				$perms
177 177
 			);
178 178
 		} else {
179 179
 			// file exists but file permissions could not be read ?!?!
180 180
 			return sprintf(
181
-				__( 'Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso' ),
181
+				__('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'),
182 182
 				$full_file_path
183 183
 			);
184 184
 		}
@@ -196,35 +196,35 @@  discard block
 block discarded – undo
196 196
 	 * can't write to it
197 197
 	 * @return bool false if folder isn't writable; true if it exists and is writeable,
198 198
 	 */
199
-	public static function ensure_folder_exists_and_is_writable( $folder = '' ){
200
-		if ( empty( $folder )) {
199
+	public static function ensure_folder_exists_and_is_writable($folder = '') {
200
+		if (empty($folder)) {
201 201
 			return false;
202 202
 		}
203 203
 		// remove ending DS
204
-		$folder = EEH_File::standardise_directory_separators( rtrim( $folder, '/\\' ));
205
-		$parent_folder = EEH_File::get_parent_folder( $folder );
204
+		$folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\'));
205
+		$parent_folder = EEH_File::get_parent_folder($folder);
206 206
 		// add DS to folder
207
-		$folder = EEH_File::end_with_directory_separator( $folder );
208
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $folder );
209
-		if ( ! $wp_filesystem->is_dir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) {
207
+		$folder = EEH_File::end_with_directory_separator($folder);
208
+		$wp_filesystem = EEH_File::_get_wp_filesystem($folder);
209
+		if ( ! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
210 210
 			//ok so it doesn't exist. Does its parent? Can we write to it?
211
-			if(	! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) {
211
+			if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
212 212
 				return false;
213 213
 			}
214
-			if ( ! EEH_File::verify_is_writable( $parent_folder, 'folder' )) {
214
+			if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) {
215 215
 				return false;
216 216
 			} else {
217
-				if ( ! $wp_filesystem->mkdir( EEH_File::convert_local_filepath_to_remote_filepath(  $folder ) ) ) {
218
-					if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
219
-						$msg = sprintf( __( '"%s" could not be created.', 'event_espresso' ), $folder );
220
-						$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $folder );
221
-						throw new EE_Error( $msg );
217
+				if ( ! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
218
+					if (defined('WP_DEBUG') && WP_DEBUG) {
219
+						$msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder);
220
+						$msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder);
221
+						throw new EE_Error($msg);
222 222
 					}
223 223
 					return false;
224 224
 				}
225
-				EEH_File::add_htaccess_deny_from_all( $folder );
225
+				EEH_File::add_htaccess_deny_from_all($folder);
226 226
 			}
227
-		} elseif ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
227
+		} elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) {
228 228
 			return false;
229 229
 		}
230 230
 		return true;
@@ -239,15 +239,15 @@  discard block
 block discarded – undo
239 239
 	 * @throws EE_Error
240 240
 	 * @return bool
241 241
 	 */
242
-	public static function verify_is_writable( $full_path = '', $file_or_folder = 'folder' ){
242
+	public static function verify_is_writable($full_path = '', $file_or_folder = 'folder') {
243 243
 		// load WP_Filesystem and set file permissions
244
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_path );
245
-		$full_path = EEH_File::standardise_directory_separators( $full_path );
246
-		if ( ! $wp_filesystem->is_writable( EEH_File::convert_local_filepath_to_remote_filepath( $full_path ) ) ) {
247
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
248
-				$msg = sprintf( __( 'The "%1$s" %2$s is not writable.', 'event_espresso' ), $full_path, $file_or_folder );
249
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_path );
250
-				throw new EE_Error( $msg );
244
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_path);
245
+		$full_path = EEH_File::standardise_directory_separators($full_path);
246
+		if ( ! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) {
247
+			if (defined('WP_DEBUG') && WP_DEBUG) {
248
+				$msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder);
249
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path);
250
+				throw new EE_Error($msg);
251 251
 			}
252 252
 			return FALSE;
253 253
 		}
@@ -264,25 +264,25 @@  discard block
 block discarded – undo
264 264
 	 * @throws EE_Error
265 265
 	 * @return bool
266 266
 	 */
267
-	public static function ensure_file_exists_and_is_writable( $full_file_path = '' ) {
267
+	public static function ensure_file_exists_and_is_writable($full_file_path = '') {
268 268
 		// load WP_Filesystem and set file permissions
269
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
270
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
271
-		$parent_folder = EEH_File::get_parent_folder( $full_file_path );
272
-		if ( ! EEH_File::exists( $full_file_path )) {
273
-			if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) {
269
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
270
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
271
+		$parent_folder = EEH_File::get_parent_folder($full_file_path);
272
+		if ( ! EEH_File::exists($full_file_path)) {
273
+			if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
274 274
 				return false;
275 275
 			}
276
-			if ( ! $wp_filesystem->touch( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) {
277
-				if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
278
-					$msg = sprintf( __( 'The "%s" file could not be created.', 'event_espresso' ), $full_file_path );
279
-					$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path );
280
-					throw new EE_Error( $msg );
276
+			if ( ! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
277
+				if (defined('WP_DEBUG') && WP_DEBUG) {
278
+					$msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path);
279
+					$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
280
+					throw new EE_Error($msg);
281 281
 				}
282 282
 				return false;
283 283
 			}
284 284
 		}
285
-		if ( ! EEH_File::verify_is_writable( $full_file_path, 'file' )) {
285
+		if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) {
286 286
 			return false;
287 287
 		}
288 288
 		return true;
@@ -294,15 +294,15 @@  discard block
 block discarded – undo
294 294
 	 * @param string $file_or_folder_path
295 295
 	 * @return string parent folder, ENDING with a directory separator
296 296
 	 */
297
-	public static function get_parent_folder( $file_or_folder_path ) {
297
+	public static function get_parent_folder($file_or_folder_path) {
298 298
 		//find the last DS, ignoring a DS on the very end
299 299
 		//eg if given "/var/something/somewhere/", we want to get "somewhere"'s
300 300
 		//parent folder, "/var/something/"
301
-		$ds = strrpos( $file_or_folder_path, DS, -2 );
302
-		return substr( $file_or_folder_path, 0, $ds + 1 );
301
+		$ds = strrpos($file_or_folder_path, DS, -2);
302
+		return substr($file_or_folder_path, 0, $ds + 1);
303 303
 	}
304 304
 	
305
-	public static function ensure_folder_exists_recursively( $folder ) {
305
+	public static function ensure_folder_exists_recursively($folder) {
306 306
 		
307 307
 	}
308 308
 
@@ -313,12 +313,12 @@  discard block
 block discarded – undo
313 313
 	 * @param string $full_file_path
314 314
 	 * @return string
315 315
 	 */
316
-	public static function get_file_contents( $full_file_path = '' ){
317
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
318
-		if ( EEH_File::verify_filepath_and_permissions( $full_file_path, EEH_File::get_filename_from_filepath( $full_file_path ) , EEH_File::get_file_extension( $full_file_path ))) {
316
+	public static function get_file_contents($full_file_path = '') {
317
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
318
+		if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) {
319 319
 			// load WP_Filesystem and set file permissions
320
-			$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
321
-			return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) );
320
+			$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
321
+			return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
322 322
 		}
323 323
 		return '';
324 324
 	}
@@ -333,26 +333,26 @@  discard block
 block discarded – undo
333 333
 	 * @throws EE_Error
334 334
 	 * @return bool
335 335
 	 */
336
-	public static function write_to_file( $full_file_path = '', $file_contents = '', $file_type = '' ){
337
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
338
-		$file_type = ! empty( $file_type ) ? rtrim( $file_type, ' ' ) . ' ' : '';
339
-		$folder = EEH_File::remove_filename_from_filepath( $full_file_path );
340
-		if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
341
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
342
-				$msg = sprintf( __( 'The %1$sfile located at "%2$s" is not writable.', 'event_espresso' ), $file_type, $full_file_path );
343
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path );
344
-				throw new EE_Error( $msg );
336
+	public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '') {
337
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
338
+		$file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : '';
339
+		$folder = EEH_File::remove_filename_from_filepath($full_file_path);
340
+		if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
341
+			if (defined('WP_DEBUG') && WP_DEBUG) {
342
+				$msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path);
343
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
344
+				throw new EE_Error($msg);
345 345
 			}
346 346
 			return FALSE;
347 347
 		}
348 348
 		// load WP_Filesystem and set file permissions
349
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
349
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
350 350
 		// write the file
351
-		if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ), $file_contents )) {
352
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
353
-				$msg = sprintf( __( 'The %1$sfile located at "%2$s" could not be written to.', 'event_espresso' ), $file_type, $full_file_path );
354
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, 'f' );
355
-				throw new EE_Error( $msg );
351
+		if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) {
352
+			if (defined('WP_DEBUG') && WP_DEBUG) {
353
+				$msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path);
354
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f');
355
+				throw new EE_Error($msg);
356 356
 			}
357 357
 			return FALSE;
358 358
 		}
@@ -368,9 +368,9 @@  discard block
 block discarded – undo
368 368
 	 * @param string $full_file_path
369 369
 	 * @return bool
370 370
 	 */
371
-	public static function exists( $full_file_path = '' ) {
372
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
373
-		return $wp_filesystem->exists( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ? TRUE : FALSE;
371
+	public static function exists($full_file_path = '') {
372
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
373
+		return $wp_filesystem->exists(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)) ? TRUE : FALSE;
374 374
 	}
375 375
 
376 376
 
@@ -382,9 +382,9 @@  discard block
 block discarded – undo
382 382
 	 * @param string $full_file_path
383 383
 	 * @return bool
384 384
 	 */
385
-	public static function is_readable( $full_file_path = '' ) {
386
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
387
-		if( $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath(  $full_file_path ) ) ) {
385
+	public static function is_readable($full_file_path = '') {
386
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
387
+		if ($wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
388 388
 			return true;
389 389
 		} else {
390 390
 			return false;
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
 	 * @param string $full_file_path
401 401
 	 * @return string
402 402
 	 */
403
-	public static function remove_filename_from_filepath( $full_file_path = '' ) {
404
-		return pathinfo( $full_file_path, PATHINFO_DIRNAME );
403
+	public static function remove_filename_from_filepath($full_file_path = '') {
404
+		return pathinfo($full_file_path, PATHINFO_DIRNAME);
405 405
 	}
406 406
 
407 407
 
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
 	 * @param string $full_file_path
412 412
 	 * @return string
413 413
 	 */
414
-	public static function get_filename_from_filepath( $full_file_path = '' ) {
415
-		return pathinfo( $full_file_path, PATHINFO_BASENAME );
414
+	public static function get_filename_from_filepath($full_file_path = '') {
415
+		return pathinfo($full_file_path, PATHINFO_BASENAME);
416 416
 	}
417 417
 
418 418
 
@@ -422,8 +422,8 @@  discard block
 block discarded – undo
422 422
 	 * @param string $full_file_path
423 423
 	 * @return string
424 424
 	 */
425
-	public static function get_file_extension( $full_file_path = '' ) {
426
-		return pathinfo( $full_file_path, PATHINFO_EXTENSION );
425
+	public static function get_file_extension($full_file_path = '') {
426
+		return pathinfo($full_file_path, PATHINFO_EXTENSION);
427 427
 	}
428 428
 
429 429
 
@@ -434,15 +434,15 @@  discard block
 block discarded – undo
434 434
 	 * @param string $folder
435 435
 	 * @return bool
436 436
 	 */
437
-	public static function add_htaccess_deny_from_all( $folder = '' ) {
438
-		$folder = EEH_File::standardise_and_end_with_directory_separator( $folder );
439
-		if ( ! EEH_File::exists( $folder . '.htaccess' ) ) {
440
-			if ( ! EEH_File::write_to_file( $folder . '.htaccess', 'deny from all', '.htaccess' )) {
437
+	public static function add_htaccess_deny_from_all($folder = '') {
438
+		$folder = EEH_File::standardise_and_end_with_directory_separator($folder);
439
+		if ( ! EEH_File::exists($folder.'.htaccess')) {
440
+			if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) {
441 441
 				return FALSE;
442 442
 			}
443 443
 		}
444
-		if ( ! EEH_File::exists( $folder . 'index.html' ) ) {
445
-			if ( ! EEH_File::write_to_file( $folder . 'index.html', 'cheating huh?', '.html' )) {
444
+		if ( ! EEH_File::exists($folder.'index.html')) {
445
+			if ( ! EEH_File::write_to_file($folder.'index.html', 'cheating huh?', '.html')) {
446 446
 				return FALSE;
447 447
 			}
448 448
 		}
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
 	 * @param string $file_path
458 458
 	 * @return string
459 459
 	 */
460
-	public static function get_classname_from_filepath_with_standard_filename( $file_path ){
460
+	public static function get_classname_from_filepath_with_standard_filename($file_path) {
461 461
 		//extract file from path
462
-		$filename = basename( $file_path );
462
+		$filename = basename($file_path);
463 463
 		//now remove the first period and everything after
464
-		$pos_of_first_period = strpos( $filename,'.' );
464
+		$pos_of_first_period = strpos($filename, '.');
465 465
 		return substr($filename, 0, $pos_of_first_period);
466 466
 	}
467 467
 
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
 	 * @param string $file_path
474 474
 	 * @return string
475 475
 	 */
476
-	public static function standardise_directory_separators( $file_path ){
477
-		return str_replace( array( '\\', '/' ), DS, $file_path );
476
+	public static function standardise_directory_separators($file_path) {
477
+		return str_replace(array('\\', '/'), DS, $file_path);
478 478
 	}
479 479
 
480 480
 
@@ -485,8 +485,8 @@  discard block
 block discarded – undo
485 485
 	 * @param string $file_path
486 486
 	 * @return string
487 487
 	 */
488
-	public static function end_with_directory_separator( $file_path ){
489
-		return rtrim( $file_path, '/\\' ) . DS;
488
+	public static function end_with_directory_separator($file_path) {
489
+		return rtrim($file_path, '/\\').DS;
490 490
 	}
491 491
 
492 492
 
@@ -496,8 +496,8 @@  discard block
 block discarded – undo
496 496
 	 * @param $file_path
497 497
 	 * @return string
498 498
 	 */
499
-	public static function standardise_and_end_with_directory_separator( $file_path ){
500
-		return self::end_with_directory_separator( self::standardise_directory_separators( $file_path ));
499
+	public static function standardise_and_end_with_directory_separator($file_path) {
500
+		return self::end_with_directory_separator(self::standardise_directory_separators($file_path));
501 501
 	}
502 502
 
503 503
 
@@ -514,21 +514,21 @@  discard block
 block discarded – undo
514 514
 	 *		if $index_numerically == FALSE (Default) keys are what the class names SHOULD be;
515 515
 	 *		 and values are their filepaths
516 516
 	 */
517
-	public static function get_contents_of_folders( $folder_paths = array(), $index_numerically = FALSE ){
517
+	public static function get_contents_of_folders($folder_paths = array(), $index_numerically = FALSE) {
518 518
 		$class_to_folder_path = array();
519
-		foreach( $folder_paths as $folder_path ){
520
-			$folder_path = self::standardise_and_end_with_directory_separator( $folder_path );
519
+		foreach ($folder_paths as $folder_path) {
520
+			$folder_path = self::standardise_and_end_with_directory_separator($folder_path);
521 521
 			// load WP_Filesystem and set file permissions
522
-			$files_in_folder = glob( $folder_path . '*' );
522
+			$files_in_folder = glob($folder_path.'*');
523 523
 			$class_to_folder_path = array();
524
-			if ( $files_in_folder ) {
525
-				foreach( $files_in_folder as $file_path ){
524
+			if ($files_in_folder) {
525
+				foreach ($files_in_folder as $file_path) {
526 526
 					//only add files, not folders
527
-					if ( ! is_dir( $file_path )) {
528
-						if ( $index_numerically ) {
527
+					if ( ! is_dir($file_path)) {
528
+						if ($index_numerically) {
529 529
 							$class_to_folder_path[] = $file_path;
530 530
 						} else {
531
-							$classname = self::get_classname_from_filepath_with_standard_filename( $file_path );
531
+							$classname = self::get_classname_from_filepath_with_standard_filename($file_path);
532 532
 							$class_to_folder_path[$classname] = $file_path;
533 533
 						}
534 534
 					}
@@ -548,39 +548,39 @@  discard block
 block discarded – undo
548 548
 	 * @return boolean success
549 549
 	 * @throws EE_Error
550 550
 	 */
551
-	public static function copy( $source_file, $destination_file, $overwrite = FALSE ){
552
-		$full_source_path = EEH_File::standardise_directory_separators( $source_file );
553
-		if( ! EEH_File::exists( $full_source_path ) ){
554
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
555
-				$msg = sprintf( __( 'The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso' ), $full_source_path );
556
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path );
557
-				throw new EE_Error( $msg );
551
+	public static function copy($source_file, $destination_file, $overwrite = FALSE) {
552
+		$full_source_path = EEH_File::standardise_directory_separators($source_file);
553
+		if ( ! EEH_File::exists($full_source_path)) {
554
+			if (defined('WP_DEBUG') && WP_DEBUG) {
555
+				$msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path);
556
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path);
557
+				throw new EE_Error($msg);
558 558
 			}
559 559
 			return FALSE;
560 560
 		}
561 561
 
562
-		$full_dest_path = EEH_File::standardise_directory_separators( $destination_file );
563
-		$folder = EEH_File::remove_filename_from_filepath( $full_dest_path );
564
-		if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
565
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
566
-				$msg = sprintf( __( 'The file located at "%2$s" is not writable.', 'event_espresso' ), $full_dest_path );
567
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_dest_path );
568
-				throw new EE_Error( $msg );
562
+		$full_dest_path = EEH_File::standardise_directory_separators($destination_file);
563
+		$folder = EEH_File::remove_filename_from_filepath($full_dest_path);
564
+		if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
565
+			if (defined('WP_DEBUG') && WP_DEBUG) {
566
+				$msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path);
567
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path);
568
+				throw new EE_Error($msg);
569 569
 			}
570 570
 			return FALSE;
571 571
 		}
572 572
 
573 573
 		// load WP_Filesystem and set file permissions
574
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $destination_file );
574
+		$wp_filesystem = EEH_File::_get_wp_filesystem($destination_file);
575 575
 		// write the file
576 576
 		if ( ! $wp_filesystem->copy( 
577
-						EEH_File::convert_local_filepath_to_remote_filepath( $full_source_path ), 
578
-						EEH_File::convert_local_filepath_to_remote_filepath( $full_dest_path ), 
577
+						EEH_File::convert_local_filepath_to_remote_filepath($full_source_path), 
578
+						EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path), 
579 579
 						$overwrite )) {
580
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
581
-				$msg = sprintf( __( 'Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso' ), $full_source_path );
582
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path, 'f' );
583
-				throw new EE_Error( $msg );
580
+			if (defined('WP_DEBUG') && WP_DEBUG) {
581
+				$msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path);
582
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f');
583
+				throw new EE_Error($msg);
584 584
 			}
585 585
 			return FALSE;
586 586
 		}
@@ -592,9 +592,9 @@  discard block
 block discarded – undo
592 592
 	 * @param string $filepath
593 593
 	 * @return boolean
594 594
 	 */
595
-	public static function is_in_uploads_folder( $filepath ) {
595
+	public static function is_in_uploads_folder($filepath) {
596 596
 		$uploads = wp_upload_dir();
597
-		return strpos( $filepath, $uploads[ 'basedir' ] ) === 0 ? true : false;
597
+		return strpos($filepath, $uploads['basedir']) === 0 ? true : false;
598 598
 	}
599 599
 	
600 600
 	/**
@@ -608,9 +608,9 @@  discard block
 block discarded – undo
608 608
 	 * @return string the remote filepath (eg the filepath the filesystem method, eg 
609 609
 	 * ftp or ssh, will use to access the folder
610 610
 	 */
611
-	public static function convert_local_filepath_to_remote_filepath( $local_filepath ) {
612
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $local_filepath );
613
-		return str_replace( WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath );
611
+	public static function convert_local_filepath_to_remote_filepath($local_filepath) {
612
+		$wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath);
613
+		return str_replace(WP_CONTENT_DIR.DS, $wp_filesystem->wp_content_dir(), $local_filepath);
614 614
 	}
615 615
 }
616 616
 // End of file EEH_File.helper.php
Please login to merge, or discard this patch.
admin/extend/general_settings/Extend_General_Settings_Admin_Page.core.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -32,30 +32,30 @@  discard block
 block discarded – undo
32 32
 
33 33
 
34 34
 
35
-	public function __construct( $routing = TRUE ) {
36
-		parent::__construct( $routing );
37
-		define( 'GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'general_settings/templates/' );
35
+	public function __construct($routing = TRUE) {
36
+		parent::__construct($routing);
37
+		define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'general_settings/templates/');
38 38
 	}
39 39
 
40 40
 
41 41
 
42 42
 	protected function _extend_page_config() {
43 43
 
44
-		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'general_settings';
44
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'general_settings';
45 45
 
46 46
 		//filters and action hooks here
47
-		add_action('AHEE__admin_option_settings__template__before', array( $this, 'use_venue_and_staff_manager_settings'), 10 );
48
-		add_action( 'AHEE__admin_option_settings__template__before', array( $this, 'debug_logging_options' ), 9 );
49
-		add_filter( 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', array( $this, 'update_debug_logging_options' ), 10, 1 );
47
+		add_action('AHEE__admin_option_settings__template__before', array($this, 'use_venue_and_staff_manager_settings'), 10);
48
+		add_action('AHEE__admin_option_settings__template__before', array($this, 'debug_logging_options'), 9);
49
+		add_filter('FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', array($this, 'update_debug_logging_options'), 10, 1);
50 50
 
51 51
 	}
52 52
 
53 53
 
54 54
 
55
-	public function use_venue_and_staff_manager_settings( $template_args ) {
56
-		$_args['use_personnel_manager_select'] = EEH_Form_Fields::select_input('use_personnel_manager', $template_args['values'], $template_args['use_personnel_manager'] );
57
-		$template = GEN_SET_CAF_TEMPLATE_PATH . 'use_venue_and_staff_manager_settings.template.php';
58
-		EEH_Template::display_template( $template, $_args );
55
+	public function use_venue_and_staff_manager_settings($template_args) {
56
+		$_args['use_personnel_manager_select'] = EEH_Form_Fields::select_input('use_personnel_manager', $template_args['values'], $template_args['use_personnel_manager']);
57
+		$template = GEN_SET_CAF_TEMPLATE_PATH.'use_venue_and_staff_manager_settings.template.php';
58
+		EEH_Template::display_template($template, $_args);
59 59
 	}
60 60
 
61 61
 
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
 	 * @param array $template_args
69 69
 	 * @return void
70 70
 	 */
71
-	public function debug_logging_options( $template_args = array() ) {
71
+	public function debug_logging_options($template_args = array()) {
72 72
 		$template_args['use_full_logging'] = EE_Registry::instance()->CFG->admin->use_full_logging;
73
-		$template_args['use_remote_logging'] = isset( EE_Registry::instance()->CFG->admin->use_remote_logging ) ? absint( EE_Registry::instance()->CFG->admin->use_remote_logging ) : FALSE;
74
-		$template_args['remote_logging_url'] = isset( EE_Registry::instance()->CFG->admin->remote_logging_url ) && ! empty( EE_Registry::instance()->CFG->admin->remote_logging_url ) ? stripslashes( EE_Registry::instance()->CFG->admin->remote_logging_url ) : '';
75
-		$template = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php';
76
-		EEH_Template::display_template( $template, $template_args );
73
+		$template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint(EE_Registry::instance()->CFG->admin->use_remote_logging) : FALSE;
74
+		$template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url) && ! empty(EE_Registry::instance()->CFG->admin->remote_logging_url) ? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : '';
75
+		$template = GEN_SET_CAF_TEMPLATE_PATH.'debug_log_settings.template.php';
76
+		EEH_Template::display_template($template, $template_args);
77 77
 	}
78 78
 
79 79
 
@@ -84,17 +84,17 @@  discard block
 block discarded – undo
84 84
 	 * @param array $admin_options
85 85
 	 * @return array
86 86
 	 */
87
-	public function update_debug_logging_options( $admin_options = array() ) {
88
-		$use_full_logging = isset( $this->_req_data['use_full_logging'] ) ? (bool)absint( $this->_req_data['use_full_logging'] ) : $admin_options->use_full_logging;
87
+	public function update_debug_logging_options($admin_options = array()) {
88
+		$use_full_logging = isset($this->_req_data['use_full_logging']) ? (bool) absint($this->_req_data['use_full_logging']) : $admin_options->use_full_logging;
89 89
 		$admin_options->use_full_logging = $use_full_logging;
90 90
 		
91
-		if ( $use_full_logging === FALSE ) {
92
-			EE_Error::get_notices( FALSE );
91
+		if ($use_full_logging === FALSE) {
92
+			EE_Error::get_notices(FALSE);
93 93
 			EE_Error::reset_notices();
94 94
 		}
95 95
 
96
-		$admin_options->use_remote_logging = isset( $this->_req_data['use_remote_logging'] ) ? absint( $this->_req_data['use_remote_logging'] ) : $admin_options->use_remote_logging;
97
-		$admin_options->remote_logging_url = isset( $this->_req_data['remote_logging_url'] ) ? esc_url_raw( $this->_req_data['remote_logging_url'] ) : $admin_options->remote_logging_url;
96
+		$admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint($this->_req_data['use_remote_logging']) : $admin_options->use_remote_logging;
97
+		$admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw($this->_req_data['remote_logging_url']) : $admin_options->remote_logging_url;
98 98
 		return $admin_options;
99 99
 	}
100 100
 
Please login to merge, or discard this patch.
core/EE_Error.core.php 1 patch
Spacing   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2 2
 // if you're a dev and want to receive all errors via email add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE );
3
-if ( defined( 'WP_DEBUG' ) && WP_DEBUG === TRUE && defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS === TRUE ) {
4
-	set_error_handler( array( 'EE_Error', 'error_handler' ));
5
-	register_shutdown_function( array( 'EE_Error', 'fatal_error_handler' ));
3
+if (defined('WP_DEBUG') && WP_DEBUG === TRUE && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === TRUE) {
4
+	set_error_handler(array('EE_Error', 'error_handler'));
5
+	register_shutdown_function(array('EE_Error', 'fatal_error_handler'));
6 6
 }
7 7
 /**
8 8
  *
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	* 	@access	private
65 65
     *	@var boolean
66 66
 	*/
67
-	private static $_espresso_notices = array( 'success' => FALSE, 'errors' => FALSE, 'attention' => FALSE );
67
+	private static $_espresso_notices = array('success' => FALSE, 'errors' => FALSE, 'attention' => FALSE);
68 68
 
69 69
 
70 70
 
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 	*	@access public
76 76
 	*	@echo string
77 77
 	*/
78
-	function __construct( $message, $code = 0, Exception $previous = NULL ) {
79
-		if ( version_compare( phpversion(), '5.3.0', '<' )) {
80
-			parent::__construct( $message, $code );
78
+	function __construct($message, $code = 0, Exception $previous = NULL) {
79
+		if (version_compare(phpversion(), '5.3.0', '<')) {
80
+			parent::__construct($message, $code);
81 81
 		} else {
82
-			parent::__construct( $message, $code, $previous );
82
+			parent::__construct($message, $code, $previous);
83 83
 		}
84 84
 	}
85 85
 
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 	 * @param $line
95 95
 	 * @return void
96 96
 	 */
97
-	public static function error_handler( $code, $message, $file, $line ) {
98
-		$type = EE_Error::error_type( $code );
97
+	public static function error_handler($code, $message, $file, $line) {
98
+		$type = EE_Error::error_type($code);
99 99
 		$site = site_url();
100
-		switch ( $site ) {
100
+		switch ($site) {
101 101
 			case 'http://ee4.eventespresso.com/' :
102 102
 			case 'http://ee4decaf.eventespresso.com/' :
103 103
 			case 'http://ee4hf.eventespresso.com/' :
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
 				$to = '[email protected]';
111 111
 				break;
112 112
 			default :
113
-				$to = get_option( 'admin_email' );
113
+				$to = get_option('admin_email');
114 114
 		}
115
-		$subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
116
-		$msg = EE_Error::_format_error( $type, $message, $file, $line );
117
-		if ( function_exists( 'wp_mail' )) {
118
-			add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' ));
119
-			wp_mail( $to, $subject, $msg );
115
+		$subject = $type.' '.$message.' in '.EVENT_ESPRESSO_VERSION.' on '.site_url();
116
+		$msg = EE_Error::_format_error($type, $message, $file, $line);
117
+		if (function_exists('wp_mail')) {
118
+			add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
119
+			wp_mail($to, $subject, $msg);
120 120
 		}
121 121
 		echo '<div id="message" class="espresso-notices error"><p>';
122
-		echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
122
+		echo $type.': '.$message.'<br />'.$file.' line '.$line;
123 123
 		echo '<br /></p></div>';
124 124
 	}
125 125
 
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	 * @param $code
133 133
 	 * @return string
134 134
 	 */
135
-	public static function error_type( $code ) {
136
-		switch( $code ) {
135
+	public static function error_type($code) {
136
+		switch ($code) {
137 137
 			case E_ERROR: // 1 //
138 138
 			return 'E_ERROR';
139 139
 			case E_WARNING: // 2 //
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 	*/
180 180
 	public static function fatal_error_handler() {
181 181
 		$last_error = error_get_last();
182
-		if ( $last_error['type'] === E_ERROR ) {
183
-			EE_Error::error_handler( E_ERROR, $last_error['message'], $last_error['file'], $last_error['line'] );
182
+		if ($last_error['type'] === E_ERROR) {
183
+			EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
184 184
 		}
185 185
 	}
186 186
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * @param $line
196 196
 	 * @return string
197 197
 	 */
198
-	private static function _format_error( $code, $message, $file, $line ) {
198
+	private static function _format_error($code, $message, $file, $line) {
199 199
 		$html  = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>";
200 200
 		$html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>";
201 201
 		$html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>";
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	 * @param $content_type
214 214
 	 * @return string
215 215
 	 */
216
-	public static function set_content_type( $content_type ) {
216
+	public static function set_content_type($content_type) {
217 217
 		return 'text/html';
218 218
 	}
219 219
 
@@ -227,24 +227,24 @@  discard block
 block discarded – undo
227 227
 	*/
228 228
     public function get_error() {
229 229
 
230
-		if( apply_filters( 'FHEE__EE_Error__get_error__show_normal_exceptions', FALSE ) ){
230
+		if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', FALSE)) {
231 231
 			throw $this;
232 232
 		}
233 233
 		// get separate user and developer messages if they exist
234
-		$msg = explode( '||', $this->getMessage() );
234
+		$msg = explode('||', $this->getMessage());
235 235
 		$user_msg = $msg[0];
236
-		$dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0];
236
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
237 237
 		$msg = WP_DEBUG ? $dev_msg : $user_msg;
238 238
 
239 239
 		// add details to _all_exceptions array
240 240
 		$x_time = time();
241
-		self::$_all_exceptions[ $x_time ]['name'] 	= get_class( $this );
242
-		self::$_all_exceptions[ $x_time ]['file'] 		= $this->getFile();
243
-		self::$_all_exceptions[ $x_time ]['line'] 		= $this->getLine();
244
-		self::$_all_exceptions[ $x_time ]['msg'] 	= $msg;
245
-		self::$_all_exceptions[ $x_time ]['code'] 	= $this->getCode();
246
-		self::$_all_exceptions[ $x_time ]['trace'] 	= $this->getTrace();
247
-		self::$_all_exceptions[ $x_time ]['string'] 	= $this->getTraceAsString();
241
+		self::$_all_exceptions[$x_time]['name'] = get_class($this);
242
+		self::$_all_exceptions[$x_time]['file'] 		= $this->getFile();
243
+		self::$_all_exceptions[$x_time]['line'] 		= $this->getLine();
244
+		self::$_all_exceptions[$x_time]['msg'] = $msg;
245
+		self::$_all_exceptions[$x_time]['code'] = $this->getCode();
246
+		self::$_all_exceptions[$x_time]['trace'] 	= $this->getTrace();
247
+		self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString();
248 248
 		self::$_error_count++;
249 249
 
250 250
 		//add_action( 'shutdown', array( $this, 'display_errors' ));
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	*	@access public
260 260
 	*	@return boolean
261 261
 	*/
262
-    public static function has_error(){
262
+    public static function has_error() {
263 263
 		return self::$_error_count ? TRUE : FALSE;
264 264
 	}
265 265
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	*	@access public
271 271
 	*	@echo string
272 272
 	*/
273
-    public function display_errors(){
273
+    public function display_errors() {
274 274
 
275 275
 		$trace_details = '';
276 276
 
@@ -331,18 +331,18 @@  discard block
 block discarded – undo
331 331
 </style>
332 332
 <div id="ee-error-message" class="error">';
333 333
 
334
-		if ( ! WP_DEBUG ) {
334
+		if ( ! WP_DEBUG) {
335 335
 			$output .= '
336 336
 	<p>';
337 337
 		}
338 338
 
339 339
 		// cycle thru errors
340
-		foreach ( self::$_all_exceptions as $time => $ex ) {
340
+		foreach (self::$_all_exceptions as $time => $ex) {
341 341
 
342 342
 			// process trace info
343
-			if ( empty( $ex['trace'] )) {
343
+			if (empty($ex['trace'])) {
344 344
 
345
-	            $trace_details .= __( 'Sorry, but no trace information was available for this exception.', 'event_espresso' );
345
+	            $trace_details .= __('Sorry, but no trace information was available for this exception.', 'event_espresso');
346 346
 
347 347
 			} else {
348 348
 
@@ -357,50 +357,50 @@  discard block
 block discarded – undo
357 357
 					<th scope="col" align="left">Method( arguments )</th>
358 358
 				</tr>';
359 359
 
360
-				$last_on_stack = count( $ex['trace'] ) - 1;
360
+				$last_on_stack = count($ex['trace']) - 1;
361 361
 				// reverse array so that stack is in proper chronological order
362
-				$sorted_trace = array_reverse( $ex['trace'] );
362
+				$sorted_trace = array_reverse($ex['trace']);
363 363
 
364
-				foreach ( $sorted_trace as $nmbr => $trace ) {
364
+				foreach ($sorted_trace as $nmbr => $trace) {
365 365
 
366
-					$file = isset( $trace['file'] ) ? $trace['file'] : '' ;
367
-					$class = isset( $trace['class'] ) ? $trace['class'] : '';
368
-					$type = isset( $trace['type'] ) ? $trace['type'] : '';
369
-					$function = isset( $trace['function'] ) ? $trace['function'] : '';
370
-					$args = isset( $trace['args'] ) ? $this->_convert_args_to_string( $trace['args'] ) : '';
371
-					$line = isset( $trace['line'] ) ? $trace['line'] : '';
366
+					$file = isset($trace['file']) ? $trace['file'] : '';
367
+					$class = isset($trace['class']) ? $trace['class'] : '';
368
+					$type = isset($trace['type']) ? $trace['type'] : '';
369
+					$function = isset($trace['function']) ? $trace['function'] : '';
370
+					$args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
371
+					$line = isset($trace['line']) ? $trace['line'] : '';
372 372
 					$zebra = $nmbr % 2 ? ' odd' : '';
373 373
 
374
-					if ( empty( $file ) && ! empty( $class )) {
375
-						$a = new ReflectionClass( $class );
374
+					if (empty($file) && ! empty($class)) {
375
+						$a = new ReflectionClass($class);
376 376
 						$file = $a->getFileName();
377
-						if ( empty( $line ) && ! empty( $function )) {
378
-							$b = new ReflectionMethod( $class, $function );
377
+						if (empty($line) && ! empty($function)) {
378
+							$b = new ReflectionMethod($class, $function);
379 379
 							$line = $b->getStartLine();
380 380
 						}
381 381
 					}
382 382
 
383
-					if ( $nmbr == $last_on_stack ) {
383
+					if ($nmbr == $last_on_stack) {
384 384
 						$file = $ex['file'] != '' ? $ex['file'] : $file;
385 385
 						$line = $ex['line'] != '' ? $ex['line'] : $line;
386
-						$error_code = self::generate_error_code ( $file, $trace['function'], $line );
386
+						$error_code = self::generate_error_code($file, $trace['function'], $line);
387 387
 					}
388 388
 
389
-					$nmbr_dsply = ! empty( $nmbr ) ? $nmbr : '&nbsp;';
390
-					$line_dsply = ! empty( $line ) ? $line : '&nbsp;';
391
-					$file_dsply = ! empty( $file ) ? $file : '&nbsp;';
392
-					$class_dsply = ! empty( $class ) ? $class : '&nbsp;';
393
-					$type_dsply = ! empty( $type ) ? $type : '&nbsp;';
394
-					$function_dsply = ! empty( $function ) ? $function : '&nbsp;';
395
-					$args_dsply = ! empty( $args ) ? '( ' . $args . ' )' : '';
389
+					$nmbr_dsply = ! empty($nmbr) ? $nmbr : '&nbsp;';
390
+					$line_dsply = ! empty($line) ? $line : '&nbsp;';
391
+					$file_dsply = ! empty($file) ? $file : '&nbsp;';
392
+					$class_dsply = ! empty($class) ? $class : '&nbsp;';
393
+					$type_dsply = ! empty($type) ? $type : '&nbsp;';
394
+					$function_dsply = ! empty($function) ? $function : '&nbsp;';
395
+					$args_dsply = ! empty($args) ? '( '.$args.' )' : '';
396 396
 
397 397
 		              $trace_details .= '
398 398
 					<tr>
399
-						<td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td>
400
-						<td align="right" class="' . $zebra . '">' . $line_dsply . '</td>
401
-						<td align="left" class="' . $zebra . '">' . $file_dsply . '</td>
402
-						<td align="left" class="' . $zebra . '">' . $class_dsply . '</td>
403
-						<td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td>
399
+						<td align="right" class="' . $zebra.'">'.$nmbr_dsply.'</td>
400
+						<td align="right" class="' . $zebra.'">'.$line_dsply.'</td>
401
+						<td align="left" class="' . $zebra.'">'.$file_dsply.'</td>
402
+						<td align="left" class="' . $zebra.'">'.$class_dsply.'</td>
403
+						<td align="left" class="' . $zebra.'">'.$type_dsply.$function_dsply.$args_dsply.'</td>
404 404
 					</tr>';
405 405
 
406 406
 
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
 			$ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
416 416
 
417 417
 			// add generic non-identifying messages for non-privileged uesrs
418
-			if ( ! WP_DEBUG ) {
418
+			if ( ! WP_DEBUG) {
419 419
 
420
-				$output .= '<span class="ee-error-user-msg-spn">' . trim( $ex['msg'] )  . '</span> &nbsp; <sup>' . $ex['code'] . '</sup><br />';
420
+				$output .= '<span class="ee-error-user-msg-spn">'.trim($ex['msg']).'</span> &nbsp; <sup>'.$ex['code'].'</sup><br />';
421 421
 
422 422
 			} else {
423 423
 
@@ -425,24 +425,24 @@  discard block
 block discarded – undo
425 425
 				$output .= '
426 426
 		<div class="ee-error-dev-msg-dv">
427 427
 			<p class="ee-error-dev-msg-pg">
428
-				<strong class="ee-error-dev-msg-str">An ' . $ex['name'] . ' exception was thrown!</strong>  &nbsp; <span>code: ' . $ex['code'] . '</span><br />
429
-				<span class="big-text">"' . trim( $ex['msg'] ) . '"</span><br/>
430
-				<a id="display-ee-error-trace-' . self::$_error_count . $time . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' . self::$_error_count . $time . '">
431
-					' . __( 'click to view backtrace and class/method details', 'event_espresso' ) . '
428
+				<strong class="ee-error-dev-msg-str">An ' . $ex['name'].' exception was thrown!</strong>  &nbsp; <span>code: '.$ex['code'].'</span><br />
429
+				<span class="big-text">"' . trim($ex['msg']).'"</span><br/>
430
+				<a id="display-ee-error-trace-' . self::$_error_count.$time.'" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'.self::$_error_count.$time.'">
431
+					' . __('click to view backtrace and class/method details', 'event_espresso').'
432 432
 				</a><br />
433 433
 				<span class="small-text lt-grey-text">'.$ex['file'].' &nbsp; ( line no: '.$ex['line'].' )</span>
434 434
 			</p>
435
-			<div id="ee-error-trace-' . self::$_error_count . $time . '-dv" class="ee-error-trace-dv" style="display: none;">
435
+			<div id="ee-error-trace-' . self::$_error_count.$time.'-dv" class="ee-error-trace-dv" style="display: none;">
436 436
 				' . $trace_details;
437 437
 
438
-				if ( ! empty( $class )) {
438
+				if ( ! empty($class)) {
439 439
 					$output .= '
440 440
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;">
441 441
 					<div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;">
442 442
 						<h3>Class Details</h3>';
443
-						$a = new ReflectionClass( $class );
443
+						$a = new ReflectionClass($class);
444 444
 						$output .= '
445
-						<pre>' . $a . '</pre>
445
+						<pre>' . $a.'</pre>
446 446
 					</div>
447 447
 				</div>';
448 448
 				}
@@ -454,14 +454,14 @@  discard block
 block discarded – undo
454 454
 
455 455
 			}
456 456
 
457
-			$this->write_to_error_log( $time, $ex );
457
+			$this->write_to_error_log($time, $ex);
458 458
 
459 459
 		}
460 460
 
461 461
 		// remove last linebreak
462
-		$output = substr( $output, 0, ( count( $output ) - 7 ));
462
+		$output = substr($output, 0, (count($output) - 7));
463 463
 
464
-		if ( ! WP_DEBUG ) {
464
+		if ( ! WP_DEBUG) {
465 465
 			$output .= '
466 466
 	</p>';
467 467
 		}
@@ -469,10 +469,10 @@  discard block
 block discarded – undo
469 469
 		$output .= '
470 470
 </div>';
471 471
 
472
-		$output .= self::_print_scripts( TRUE );
472
+		$output .= self::_print_scripts(TRUE);
473 473
 
474
-		if ( defined( 'DOING_AJAX' )) {
475
-			echo json_encode( array( 'error' => $output ));
474
+		if (defined('DOING_AJAX')) {
475
+			echo json_encode(array('error' => $output));
476 476
 			exit();
477 477
 		}
478 478
 
@@ -492,29 +492,29 @@  discard block
 block discarded – undo
492 492
 	*	@ param array $arguments
493 493
 	*	@ return string
494 494
 	*/
495
-	private function _convert_args_to_string ( $arguments = array(), $array = FALSE ) {
495
+	private function _convert_args_to_string($arguments = array(), $array = FALSE) {
496 496
 
497 497
 		$arg_string = '';
498
-		if ( ! empty( $arguments )) {
498
+		if ( ! empty($arguments)) {
499 499
 
500 500
 			$args = array();
501 501
 
502
-			foreach ( $arguments as $arg ) {
502
+			foreach ($arguments as $arg) {
503 503
 
504
-				if ( ! empty( $arg )) {
504
+				if ( ! empty($arg)) {
505 505
 
506
-					if ( is_string( $arg )) {
507
-						$args[] = " '" . $arg . "'";
508
-					} elseif ( is_array( $arg )) {
509
-						$args[] = 'ARRAY(' . $this->_convert_args_to_string( $arg, TRUE );
510
-					} elseif ( is_null( $arg )) {
506
+					if (is_string($arg)) {
507
+						$args[] = " '".$arg."'";
508
+					} elseif (is_array($arg)) {
509
+						$args[] = 'ARRAY('.$this->_convert_args_to_string($arg, TRUE);
510
+					} elseif (is_null($arg)) {
511 511
 						$args[] = ' NULL';
512
-					} elseif ( is_bool( $arg )) {
513
-						$args[] = ( $arg ) ? ' TRUE' : ' FALSE';
514
-					} elseif ( is_object( $arg )) {
515
-						$args[] = ' OBJECT ' . get_class( $arg );
516
-					} elseif ( is_resource( $arg )) {
517
-						$args[] = get_resource_type( $arg );
512
+					} elseif (is_bool($arg)) {
513
+						$args[] = ($arg) ? ' TRUE' : ' FALSE';
514
+					} elseif (is_object($arg)) {
515
+						$args[] = ' OBJECT '.get_class($arg);
516
+					} elseif (is_resource($arg)) {
517
+						$args[] = get_resource_type($arg);
518 518
 					} else {
519 519
 						$args[] = $arg;
520 520
 					}
@@ -522,9 +522,9 @@  discard block
 block discarded – undo
522 522
 				}
523 523
 
524 524
 			}
525
-			$arg_string = implode( ', ', $args );
525
+			$arg_string = implode(', ', $args);
526 526
 		}
527
-		if ( $array ) {
527
+		if ($array) {
528 528
 			$arg_string .= ' )';
529 529
 		}
530 530
 		return $arg_string;
@@ -544,8 +544,8 @@  discard block
 block discarded – undo
544 544
 	* 	@param		string		$line	the line number where the error occurred - just use __LINE__
545 545
 	* 	@return 		void
546 546
 	*/
547
-	public static function add_error( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) {
548
-		self::_add_notice ( 'errors', $msg, $file, $func, $line );
547
+	public static function add_error($msg = NULL, $file = NULL, $func = NULL, $line = NULL) {
548
+		self::_add_notice('errors', $msg, $file, $func, $line);
549 549
 		self::$_error_count++;
550 550
 	}
551 551
 
@@ -563,8 +563,8 @@  discard block
 block discarded – undo
563 563
 	* 	@param		string		$line	the line number where the error occurred - just use __LINE__
564 564
 	* 	@return 		void
565 565
 	*/
566
-	public static function add_success( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) {
567
-		self::_add_notice ( 'success', $msg, $file, $func, $line );
566
+	public static function add_success($msg = NULL, $file = NULL, $func = NULL, $line = NULL) {
567
+		self::_add_notice('success', $msg, $file, $func, $line);
568 568
 	}
569 569
 
570 570
 
@@ -581,8 +581,8 @@  discard block
 block discarded – undo
581 581
 	* 	@param		string		$line	the line number where the error occurred - just use __LINE__
582 582
 	* 	@return 		void
583 583
 	*/
584
-	public static function add_attention( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) {
585
-		self::_add_notice ( 'attention', $msg, $file, $func, $line );
584
+	public static function add_attention($msg = NULL, $file = NULL, $func = NULL, $line = NULL) {
585
+		self::_add_notice('attention', $msg, $file, $func, $line);
586 586
 	}
587 587
 
588 588
 
@@ -600,12 +600,12 @@  discard block
 block discarded – undo
600 600
 	* 	@param		string		$line	the line number where the error occurred - just use __LINE__
601 601
 	* 	@return 		void
602 602
 	*/
603
-	private static function _add_notice( $type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) {
604
-		if ( empty( $msg )) {
603
+	private static function _add_notice($type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL) {
604
+		if (empty($msg)) {
605 605
 			EE_Error::doing_it_wrong(
606
-				'EE_Error::add_' . $type . '()',
606
+				'EE_Error::add_'.$type.'()',
607 607
 				sprintf(
608
-					__( 'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso' ),
608
+					__('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso'),
609 609
 					$type,
610 610
 					$file,
611 611
 					$line
@@ -613,27 +613,27 @@  discard block
 block discarded – undo
613 613
 				EVENT_ESPRESSO_VERSION
614 614
 			);
615 615
 		}
616
-		if ( $type == 'errors' && ( empty( $file ) || empty( $func ) || empty( $line ))) {
616
+		if ($type == 'errors' && (empty($file) || empty($func) || empty($line))) {
617 617
 			EE_Error::doing_it_wrong(
618 618
 				'EE_Error::add_error()',
619
-				__('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso' ),
619
+				__('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso'),
620 620
 				EVENT_ESPRESSO_VERSION
621 621
 			);
622 622
 		}
623 623
 		// get separate user and developer messages if they exist
624
-		$msg = explode( '||', $msg );
624
+		$msg = explode('||', $msg);
625 625
 		$user_msg = $msg[0];
626
-		$dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0];
626
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
627 627
 		$msg = WP_DEBUG ? $dev_msg : $user_msg;
628 628
 		// add notice if message exists
629
-		if ( ! empty( $msg )) {
629
+		if ( ! empty($msg)) {
630 630
 			// get error code, but only on error
631
-			if ( WP_DEBUG && $type == 'errors' ) {
632
-				$msg .= '<br/><span class="tiny-text">' . EE_Error::generate_error_code( $file, $func, $line ) . '</span>';
631
+			if (WP_DEBUG && $type == 'errors') {
632
+				$msg .= '<br/><span class="tiny-text">'.EE_Error::generate_error_code($file, $func, $line).'</span>';
633 633
 			}
634 634
 			// add notice
635
-			self::$_espresso_notices[ $type ][] = $msg;
636
-			add_action( 'wp_footer', array( 'EE_Error', 'enqueue_error_scripts' ), 1 );
635
+			self::$_espresso_notices[$type][] = $msg;
636
+			add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
637 637
 		}
638 638
 
639 639
 	}
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 	*	@access private
688 688
 	*	@return void
689 689
 	*/
690
-	public static function reset_notices(){
690
+	public static function reset_notices() {
691 691
     	self::$_espresso_notices['success'] = FALSE;
692 692
     	self::$_espresso_notices['attention'] = FALSE;
693 693
     	self::$_espresso_notices['errors'] = FALSE;
@@ -700,14 +700,14 @@  discard block
 block discarded – undo
700 700
 	*	@access public
701 701
 	*	@return int
702 702
 	*/
703
-    public static function has_notices(){
703
+    public static function has_notices() {
704 704
 		$has_notices = 0;
705 705
 		// check for success messages
706
-		$has_notices = self::$_espresso_notices['success'] && ! empty(  self::$_espresso_notices['success'] ) ? 3 : $has_notices;
706
+		$has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 : $has_notices;
707 707
 		// check for attention messages
708
-		$has_notices = self::$_espresso_notices['attention'] && ! empty(  self::$_espresso_notices['attention'] ) ? 2 : $has_notices;
708
+		$has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 : $has_notices;
709 709
 		// check for error messages
710
-		$has_notices = self::$_espresso_notices['errors'] && ! empty(  self::$_espresso_notices['errors'] ) ? 1 : $has_notices;
710
+		$has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 : $has_notices;
711 711
 		return $has_notices;
712 712
 	}
713 713
 
@@ -722,8 +722,8 @@  discard block
 block discarded – undo
722 722
 	* 	@param		boolean		$remove_empty		whether or not to unset empty messages
723 723
 	* 	@return 		array
724 724
 	*/
725
-	public static function get_notices( $format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE ) {
726
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
725
+	public static function get_notices($format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE) {
726
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
727 727
 
728 728
 		$success_messages = '';
729 729
 		$attention_messages = '';
@@ -733,44 +733,44 @@  discard block
 block discarded – undo
733 733
 		// EEH_Debug_Tools::printr( self::$_espresso_notices, 'espresso_notices  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
734 734
 
735 735
 		// either save notices to the db
736
-		if ( $save_to_transient ) {
737
-			update_option( 'ee_notices', self::$_espresso_notices );
736
+		if ($save_to_transient) {
737
+			update_option('ee_notices', self::$_espresso_notices);
738 738
 			return;
739 739
 		}
740 740
 		// grab any notices that have been previously saved
741
-		if ( $notices = get_option( 'ee_notices', FALSE )) {
742
-			foreach ( $notices as $type => $notice ) {
743
-				if ( is_array( $notice ) && ! empty( $notice )) {
741
+		if ($notices = get_option('ee_notices', FALSE)) {
742
+			foreach ($notices as $type => $notice) {
743
+				if (is_array($notice) && ! empty($notice)) {
744 744
 					// make sure that existsing notice type is an array
745
-					self::$_espresso_notices[ $type ] =  is_array( self::$_espresso_notices[ $type ] ) && ! empty( self::$_espresso_notices[ $type ] ) ? self::$_espresso_notices[ $type ] : array();
745
+					self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) && ! empty(self::$_espresso_notices[$type]) ? self::$_espresso_notices[$type] : array();
746 746
 					// merge stored notices with any newly created ones
747
-					self::$_espresso_notices[ $type ] = array_merge( self::$_espresso_notices[ $type ], $notice );
747
+					self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice);
748 748
 					$print_scripts = TRUE;
749 749
 				}
750 750
 			}
751 751
 			// now clear any stored notices
752
-			update_option( 'ee_notices', FALSE );
752
+			update_option('ee_notices', FALSE);
753 753
 		}
754 754
 
755 755
 		// check for success messages
756
-		if ( self::$_espresso_notices['success'] && ! empty(  self::$_espresso_notices['success'] )) {
756
+		if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
757 757
 			// combine messages
758
-			$success_messages .= implode( self::$_espresso_notices['success'], '<br />' );
758
+			$success_messages .= implode(self::$_espresso_notices['success'], '<br />');
759 759
 			$print_scripts = TRUE;
760 760
 		}
761 761
 
762 762
 		// check for attention messages
763
-		if ( self::$_espresso_notices['attention'] && ! empty(  self::$_espresso_notices['attention'] ) ) {
763
+		if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
764 764
 			// combine messages
765
-			$attention_messages .= implode( self::$_espresso_notices['attention'], '<br />' );
765
+			$attention_messages .= implode(self::$_espresso_notices['attention'], '<br />');
766 766
 			$print_scripts = TRUE;
767 767
 		}
768 768
 
769 769
 		// check for error messages
770
-		if ( self::$_espresso_notices['errors'] && ! empty(  self::$_espresso_notices['errors'] ) ) {
771
-			$error_messages .= count( self::$_espresso_notices['errors'] ) > 1 ? __( 'The following errors have occurred:<br />', 'event_espresso' ) : __( 'An error has occurred:<br />', 'event_espresso' );
770
+		if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
771
+			$error_messages .= count(self::$_espresso_notices['errors']) > 1 ? __('The following errors have occurred:<br />', 'event_espresso') : __('An error has occurred:<br />', 'event_espresso');
772 772
 			// combine messages
773
-			$error_messages .= implode( self::$_espresso_notices['errors'], '<br />' );
773
+			$error_messages .= implode(self::$_espresso_notices['errors'], '<br />');
774 774
 			$print_scripts = TRUE;
775 775
 		}
776 776
 
@@ -784,21 +784,21 @@  discard block
 block discarded – undo
784 784
 				$css_id = is_admin() ? 'message' : 'espresso-notices-success';
785 785
 				$css_class = is_admin() ? 'updated fade' : 'success fade-away';
786 786
 				//showMessage( $success_messages );
787
-				$notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $success_messages . '</p>' . $close . '</div>';
787
+				$notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$success_messages.'</p>'.$close.'</div>';
788 788
 			}
789 789
 
790 790
 			if ($attention_messages != '') {
791 791
 				$css_id = is_admin() ? 'message' : 'espresso-notices-attention';
792 792
 				$css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
793 793
 				//showMessage( $error_messages, TRUE );
794
-				$notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $attention_messages . '</p>' . $close . '</div>';
794
+				$notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$attention_messages.'</p>'.$close.'</div>';
795 795
 			}
796 796
 
797 797
 			if ($error_messages != '') {
798 798
 				$css_id = is_admin() ? 'message' : 'espresso-notices-error';
799 799
 				$css_class = is_admin() ? 'error' : 'error fade-away';
800 800
 				//showMessage( $error_messages, TRUE );
801
-				$notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $error_messages . '</p>' . $close . '</div>';
801
+				$notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$error_messages.'</p>'.$close.'</div>';
802 802
 			}
803 803
 
804 804
 			$notices .= '</div>';
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 					'errors' => $error_messages
812 812
 			);
813 813
 
814
-			if ( $remove_empty ) {
814
+			if ($remove_empty) {
815 815
 				// remove empty notices
816 816
 				foreach ($notices as $type => $notice) {
817 817
 					if (empty($notice)) {
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 			}
822 822
 		}
823 823
 
824
-		if ( $print_scripts ) {
824
+		if ($print_scripts) {
825 825
 			self::_print_scripts();
826 826
 		}
827 827
 
@@ -841,17 +841,17 @@  discard block
 block discarded – undo
841 841
 	* 	@param bool $force_update allows one to enforce the reappearance of a persistent message.
842 842
 	* 	@return 		void
843 843
 	*/
844
-	public static function add_persistent_admin_notice( $pan_name = '', $pan_message, $force_update = FALSE ) {
845
-		if ( ! empty( $pan_name ) && ! empty( $pan_message )) {
846
-			$persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() );
844
+	public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = FALSE) {
845
+		if ( ! empty($pan_name) && ! empty($pan_message)) {
846
+			$persistent_admin_notices = get_option('ee_pers_admin_notices', array());
847 847
 			//maybe initialize persistent_admin_notices
848
-			if ( empty( $persistent_admin_notices )) {
849
-				add_option( 'ee_pers_admin_notices', array(), '', 'no' );
848
+			if (empty($persistent_admin_notices)) {
849
+				add_option('ee_pers_admin_notices', array(), '', 'no');
850 850
 			}
851
-			$pan_name = sanitize_key( $pan_name );
852
-			if ( ! array_key_exists( $pan_name, $persistent_admin_notices ) || $force_update ) {
853
-				$persistent_admin_notices[ $pan_name ] = $pan_message;
854
-				update_option( 'ee_pers_admin_notices', $persistent_admin_notices );
851
+			$pan_name = sanitize_key($pan_name);
852
+			if ( ! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) {
853
+				$persistent_admin_notices[$pan_name] = $pan_message;
854
+				update_option('ee_pers_admin_notices', $persistent_admin_notices);
855 855
 			}
856 856
 		}
857 857
 	}
@@ -867,34 +867,34 @@  discard block
 block discarded – undo
867 867
 	 * @param bool          $return_immediately
868 868
 	 * @return        void
869 869
 	 */
870
-	public static function dismiss_persistent_admin_notice( $pan_name = '', $purge = FALSE, $return_immediately = FALSE ) {
871
-		$pan_name = EE_Registry::instance()->REQ->is_set( 'ee_nag_notice' ) ? EE_Registry::instance()->REQ->get( 'ee_nag_notice' ) : $pan_name;
872
-		if ( ! empty( $pan_name )) {
873
-			$persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() );
870
+	public static function dismiss_persistent_admin_notice($pan_name = '', $purge = FALSE, $return_immediately = FALSE) {
871
+		$pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name;
872
+		if ( ! empty($pan_name)) {
873
+			$persistent_admin_notices = get_option('ee_pers_admin_notices', array());
874 874
 			// check if notice we wish to dismiss is actually in the $persistent_admin_notices array
875
-			if ( is_array( $persistent_admin_notices ) && isset( $persistent_admin_notices[ $pan_name ] )) {
875
+			if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) {
876 876
 				// completely delete nag notice, or just NULL message so that it can NOT be added again ?
877
-				if ( $purge ) {
878
-					unset( $persistent_admin_notices[ $pan_name ] );
877
+				if ($purge) {
878
+					unset($persistent_admin_notices[$pan_name]);
879 879
 				} else {
880
-					$persistent_admin_notices[ $pan_name ] = NULL;
880
+					$persistent_admin_notices[$pan_name] = NULL;
881 881
 				}
882
-				if ( update_option( 'ee_pers_admin_notices', $persistent_admin_notices ) === FALSE ) {
883
-					EE_Error::add_error( sprintf( __( 'The persistent admin notice for "%s" could not be deleted.', 'event_espresso' ), $pan_name ), __FILE__, __FUNCTION__, __LINE__ );
882
+				if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === FALSE) {
883
+					EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__);
884 884
 				}
885 885
 			}
886 886
 		}
887
-		if ( $return_immediately ) {
887
+		if ($return_immediately) {
888 888
 			return;
889
-		} else if ( EE_Registry::instance()->REQ->ajax ) {
889
+		} else if (EE_Registry::instance()->REQ->ajax) {
890 890
 			// grab any notices and concatenate into string
891
-			echo json_encode( array( 'errors' => implode( '<br />', EE_Error::get_notices( FALSE ))));
891
+			echo json_encode(array('errors' => implode('<br />', EE_Error::get_notices(FALSE))));
892 892
 			exit();
893 893
 		} else {
894 894
 			// save errors to a transient to be displayed on next request (after redirect)
895
-			EE_Error::get_notices( FALSE, TRUE );
896
-			$return_url = EE_Registry::instance()->REQ->is_set( 'return_url' ) ? EE_Registry::instance()->REQ->get( 'return_url' ) : '';
897
-			wp_safe_redirect( urldecode( $return_url ));
895
+			EE_Error::get_notices(FALSE, TRUE);
896
+			$return_url = EE_Registry::instance()->REQ->is_set('return_url') ? EE_Registry::instance()->REQ->get('return_url') : '';
897
+			wp_safe_redirect(urldecode($return_url));
898 898
 		}
899 899
 	}
900 900
 
@@ -909,20 +909,20 @@  discard block
 block discarded – undo
909 909
 	* 	@param		string	$return_url	URL to go back to aftger nag notice is dismissed
910 910
 	 *  	@return 		string
911 911
 	 */
912
-	public static function display_persistent_admin_notices( $pan_name = '', $pan_message = '', $return_url = '' ) {
913
-		if ( ! empty( $pan_name ) && ! empty( $pan_message )) {
912
+	public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') {
913
+		if ( ! empty($pan_name) && ! empty($pan_message)) {
914 914
 			$args = array(
915 915
 				'nag_notice' => $pan_name,
916
-				'return_url' => urlencode( $return_url ),
916
+				'return_url' => urlencode($return_url),
917 917
 				'ajax_url' => WP_AJAX_URL,
918
-				'unknown_error' => __( 'An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso' )
918
+				'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso')
919 919
 			);
920
-			wp_localize_script( 'espresso_core', 'ee_dismiss', $args );
920
+			wp_localize_script('espresso_core', 'ee_dismiss', $args);
921 921
 			return '
922
-			<div id="' . $pan_name . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;">
923
-				<p>' . $pan_message . '</p>
924
-				<a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name . '">
925
-					<span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__( 'Dismiss', 'event_espresso' ) .'
922
+			<div id="' . $pan_name.'" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;">
923
+				<p>' . $pan_message.'</p>
924
+				<a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name.'">
925
+					<span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__('Dismiss', 'event_espresso').'
926 926
 				</a>
927 927
 				<div style="clear:both;"></div>
928 928
 			</div>';
@@ -938,17 +938,17 @@  discard block
 block discarded – undo
938 938
 	 * @param string $return_url
939 939
 	 * @return    array
940 940
 	 */
941
-	public static function get_persistent_admin_notices( $return_url = '' ) {
941
+	public static function get_persistent_admin_notices($return_url = '') {
942 942
 		$notices = '';
943 943
 		// check for persistent admin notices
944
-		if ( $persistent_admin_notices = get_option( 'ee_pers_admin_notices', FALSE )) {
944
+		if ($persistent_admin_notices = get_option('ee_pers_admin_notices', FALSE)) {
945 945
 			// load scripts
946
-			wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE );
947
-			wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE );
948
-			wp_enqueue_script( 'ee_error_js' );
946
+			wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
947
+			wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE);
948
+			wp_enqueue_script('ee_error_js');
949 949
 			// and display notices
950
-			foreach( $persistent_admin_notices as $pan_name => $pan_message ) {
951
-				$notices .= self::display_persistent_admin_notices( $pan_name, $pan_message, $return_url );
950
+			foreach ($persistent_admin_notices as $pan_name => $pan_message) {
951
+				$notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url);
952 952
 			}
953 953
 		}
954 954
 		return $notices;
@@ -963,26 +963,26 @@  discard block
 block discarded – undo
963 963
 	 * @param 	bool $force_print
964 964
 	 * @return 	void
965 965
 	 */
966
-	private static function _print_scripts( $force_print = FALSE ) {
967
-		if (( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' )) && ! $force_print ) {
968
-			if ( wp_script_is( 'ee_error_js', 'enqueued' )) {
966
+	private static function _print_scripts($force_print = FALSE) {
967
+		if ((did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts')) && ! $force_print) {
968
+			if (wp_script_is('ee_error_js', 'enqueued')) {
969 969
 				return;
970
-			} else if ( wp_script_is( 'ee_error_js', 'registered' )) {
971
-				add_filter( 'FHEE_load_css', '__return_true' );
972
-				add_filter( 'FHEE_load_js', '__return_true' );
973
-				wp_enqueue_script( 'ee_error_js' );
974
-				wp_localize_script( 'ee_error_js','ee_settings', array( 'wp_debug'=>WP_DEBUG ));
970
+			} else if (wp_script_is('ee_error_js', 'registered')) {
971
+				add_filter('FHEE_load_css', '__return_true');
972
+				add_filter('FHEE_load_js', '__return_true');
973
+				wp_enqueue_script('ee_error_js');
974
+				wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug'=>WP_DEBUG));
975 975
 			}
976 976
 		} else {
977 977
 			return '
978 978
 <script>
979 979
 /* <![CDATA[ */
980
-var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
980
+var ee_settings = {"wp_debug":"' . WP_DEBUG.'"};
981 981
 /* ]]> */
982 982
 </script>
983
-<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script>
984
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
985
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
983
+<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script>
984
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
985
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
986 986
 ';
987 987
 
988 988
 		}
@@ -1016,11 +1016,11 @@  discard block
 block discarded – undo
1016 1016
 	*	@ param string $line
1017 1017
 	*	@ return string
1018 1018
 	*/
1019
-	public static function generate_error_code ( $file = '', $func = '', $line = '' ) {
1020
-		$file = explode( '.', basename( $file ));
1021
-		$error_code = ! empty( $file[0] ) ? $file[0] : '';
1022
-		$error_code .= ! empty( $func ) ? ' - ' . $func : '';
1023
-		$error_code .= ! empty( $line ) ? ' - ' . $line : '';
1019
+	public static function generate_error_code($file = '', $func = '', $line = '') {
1020
+		$file = explode('.', basename($file));
1021
+		$error_code = ! empty($file[0]) ? $file[0] : '';
1022
+		$error_code .= ! empty($func) ? ' - '.$func : '';
1023
+		$error_code .= ! empty($line) ? ' - '.$line : '';
1024 1024
 		return $error_code;
1025 1025
 	}
1026 1026
 
@@ -1036,36 +1036,36 @@  discard block
 block discarded – undo
1036 1036
 	*	@ param object $ex
1037 1037
 	*	@ return void
1038 1038
 	*/
1039
-	public function write_to_error_log ( $time = FALSE, $ex = FALSE, $clear = FALSE ) {
1039
+	public function write_to_error_log($time = FALSE, $ex = FALSE, $clear = FALSE) {
1040 1040
 
1041
-		if ( ! $ex ) {
1041
+		if ( ! $ex) {
1042 1042
 			return;
1043 1043
 		}
1044 1044
 
1045
-		if ( ! $time ) {
1045
+		if ( ! $time) {
1046 1046
 			$time = time();
1047 1047
 		}
1048 1048
 
1049
-		$exception_log = '----------------------------------------------------------------------------------------' . PHP_EOL;
1050
-		$exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . ']  Exception Details' . PHP_EOL;
1051
-		$exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
1052
-		$exception_log .= 'Code: '. $ex['code'] . PHP_EOL;
1053
-		$exception_log .= 'File: '. $ex['file'] . PHP_EOL;
1054
-		$exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
1055
-		$exception_log .= 'Stack trace: ' . PHP_EOL;
1056
-		$exception_log .= $ex['string'] . PHP_EOL;
1057
-		$exception_log .= '----------------------------------------------------------------------------------------' . PHP_EOL;
1058
-
1059
-		EE_Registry::instance()->load_helper( 'File' );
1049
+		$exception_log = '----------------------------------------------------------------------------------------'.PHP_EOL;
1050
+		$exception_log .= '['.date('Y-m-d H:i:s', $time).']  Exception Details'.PHP_EOL;
1051
+		$exception_log .= 'Message: '.$ex['msg'].PHP_EOL;
1052
+		$exception_log .= 'Code: '.$ex['code'].PHP_EOL;
1053
+		$exception_log .= 'File: '.$ex['file'].PHP_EOL;
1054
+		$exception_log .= 'Line No: '.$ex['line'].PHP_EOL;
1055
+		$exception_log .= 'Stack trace: '.PHP_EOL;
1056
+		$exception_log .= $ex['string'].PHP_EOL;
1057
+		$exception_log .= '----------------------------------------------------------------------------------------'.PHP_EOL;
1058
+
1059
+		EE_Registry::instance()->load_helper('File');
1060 1060
 		try {
1061
-			EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file );
1062
-			if ( ! $clear ) {
1061
+			EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file);
1062
+			if ( ! $clear) {
1063 1063
 				//get existing log file and append new log info
1064
-				$exception_log = EEH_File::get_file_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ) . $exception_log;
1064
+				$exception_log = EEH_File::get_file_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file).$exception_log;
1065 1065
 			}
1066
-			EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, $exception_log );
1067
-		} catch( EE_Error $e ){
1068
-			EE_Error::add_error( sprintf( __(  'Event Espresso error logging could not be setup because: %s', 'event_espresso' ), $e->getMessage() ));
1066
+			EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file, $exception_log);
1067
+		} catch (EE_Error $e) {
1068
+			EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', 'event_espresso'), $e->getMessage()));
1069 1069
 			return;
1070 1070
 		}
1071 1071
 
@@ -1089,10 +1089,10 @@  discard block
 block discarded – undo
1089 1089
 	 * @param int     $error_type
1090 1090
 	 * @return void
1091 1091
 	 */
1092
-	public static function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) {
1093
-		if ( defined('WP_DEBUG') && WP_DEBUG ) {
1092
+	public static function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) {
1093
+		if (defined('WP_DEBUG') && WP_DEBUG) {
1094 1094
 			EE_Registry::instance()->load_helper('Debug_Tools');
1095
-			EEH_Debug_Tools::instance()->doing_it_wrong( $function, $message, $version, $error_type );
1095
+			EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $error_type);
1096 1096
 		}
1097 1097
 	}
1098 1098
 
@@ -1112,13 +1112,13 @@  discard block
 block discarded – undo
1112 1112
  */
1113 1113
 function espresso_error_enqueue_scripts() {
1114 1114
 	// js for error handling
1115
-	wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE );
1116
-	wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE );
1115
+	wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE);
1116
+	wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE);
1117 1117
 }
1118
-if ( is_admin() ) {
1119
-	add_action( 'admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 );
1118
+if (is_admin()) {
1119
+	add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1120 1120
 } else {
1121
-	add_action( 'wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 );
1121
+	add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1122 1122
 }
1123 1123
 
1124 1124
 
Please login to merge, or discard this patch.
core/EE_Log.core.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2 2
 /**
3 3
  *
4 4
  * Class EE_Log
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @return EE_Log
63 63
 	 */
64 64
 	public static function instance() {
65
-		if ( ! self::$_instance instanceof EE_Log ) {
65
+		if ( ! self::$_instance instanceof EE_Log) {
66 66
 			self::$_instance = new self();
67 67
 		}
68 68
 		return self::$_instance;
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	private function __construct() {
76 76
 
77
-		if ( ! EE_Registry::instance()->CFG->admin->use_full_logging && ! EE_Registry::instance()->CFG->admin->use_remote_logging ) {
77
+		if ( ! EE_Registry::instance()->CFG->admin->use_full_logging && ! EE_Registry::instance()->CFG->admin->use_remote_logging) {
78 78
 			return;
79 79
 		}
80 80
 
81
-		$this->_logs_folder = EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS;
81
+		$this->_logs_folder = EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS;
82 82
 		$this->_log_file = EE_Registry::instance()->CFG->admin->log_file_name();
83 83
 		$this->_log = '';
84 84
 		$this->_debug_file = EE_Registry::instance()->CFG->admin->debug_file_name();
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 		$this->_remote_logging_url = EE_Registry::instance()->CFG->admin->remote_logging_url;
87 87
 		$this->_remote_log = '';
88 88
 
89
-		add_action( 'admin_init', array( $this, 'verify_filesystem' ), -10 );
90
-		add_action( 'AHEE_log', array( $this, 'log' ), 10, 4 );
91
-		if ( EE_Registry::instance()->CFG->admin->use_full_logging ) {
92
-			add_action( 'shutdown', array( $this, 'write_log' ), 9999 );
89
+		add_action('admin_init', array($this, 'verify_filesystem'), -10);
90
+		add_action('AHEE_log', array($this, 'log'), 10, 4);
91
+		if (EE_Registry::instance()->CFG->admin->use_full_logging) {
92
+			add_action('shutdown', array($this, 'write_log'), 9999);
93 93
 			// if WP_DEBUG
94
-			add_action( 'shutdown', array( $this, 'write_debug' ), 9999 );
94
+			add_action('shutdown', array($this, 'write_debug'), 9999);
95 95
 		}
96
-		if ( EE_Registry::instance()->CFG->admin->use_remote_logging ) {
97
-			add_action( 'shutdown', array( $this, 'send_log' ), 9999 );
96
+		if (EE_Registry::instance()->CFG->admin->use_remote_logging) {
97
+			add_action('shutdown', array($this, 'send_log'), 9999);
98 98
 		}
99 99
 
100 100
 	}
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function verify_filesystem() {
110 110
 		try {
111
-			EE_Registry::instance()->load_helper( 'File' );
112
-			EEH_File::ensure_file_exists_and_is_writable( $this->_logs_folder . $this->_log_file );
113
-			EEH_File::ensure_file_exists_and_is_writable( $this->_logs_folder . $this->_debug_file );
114
-		} catch( EE_Error $e ){
115
-			EE_Error::add_error( sprintf( __(  'Event Espresso logging could not be setup because: %s', 'event_espresso' ), ' &nbsp; &nbsp; ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ );
111
+			EE_Registry::instance()->load_helper('File');
112
+			EEH_File::ensure_file_exists_and_is_writable($this->_logs_folder.$this->_log_file);
113
+			EEH_File::ensure_file_exists_and_is_writable($this->_logs_folder.$this->_debug_file);
114
+		} catch (EE_Error $e) {
115
+			EE_Error::add_error(sprintf(__('Event Espresso logging could not be setup because: %s', 'event_espresso'), ' &nbsp; &nbsp; '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
116 116
 			return;
117 117
 		}
118 118
 	}
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
 	 * @param string $type
130 130
 	 * @return string
131 131
 	 */
132
-	private function _format_message( $file = '', $function = '', $message = '', $type = '' ) {
133
-		$msg = '----------------------------------------------------------------------------------------' . PHP_EOL;
134
-		$msg .= '[' . current_time( 'mysql' ) . '] ';
135
-		$msg .= ! empty( $file ) ? basename( $file ) : '';
136
-		$msg .= ! empty( $file ) && ! empty( $function ) ? ' -> ' : '';
137
-		$msg .= ! empty( $function ) ? $function . '()' : '';
132
+	private function _format_message($file = '', $function = '', $message = '', $type = '') {
133
+		$msg = '----------------------------------------------------------------------------------------'.PHP_EOL;
134
+		$msg .= '['.current_time('mysql').'] ';
135
+		$msg .= ! empty($file) ? basename($file) : '';
136
+		$msg .= ! empty($file) && ! empty($function) ? ' -> ' : '';
137
+		$msg .= ! empty($function) ? $function.'()' : '';
138 138
 		$msg .= PHP_EOL;
139
-		$type = ! empty( $type ) ? $type : 'log message';
140
-		$msg .= ! empty( $message ) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : '';
139
+		$type = ! empty($type) ? $type : 'log message';
140
+		$msg .= ! empty($message) ? "\t".'['.$type.'] '.$message.PHP_EOL : '';
141 141
 		return $msg;
142 142
 	}
143 143
 
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	 * @param string $message
153 153
 	 * @param string $type
154 154
 	 */
155
-	public function log( $file = '', $function = '', $message = '', $type = '' ) {
156
-		$this->_log .= $this->_format_message( $file, $function, $message, $type );
155
+	public function log($file = '', $function = '', $message = '', $type = '') {
156
+		$this->_log .= $this->_format_message($file, $function, $message, $type);
157 157
 	}
158 158
 
159 159
 
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 	public function write_log() {
166 166
 		try {
167 167
 			//get existing log file and append new log info
168
-			$this->_log = EEH_File::get_file_contents( $this->_logs_folder . $this->_log_file ) . $this->_log;
169
-			EEH_File::write_to_file( $this->_logs_folder . $this->_log_file, $this->_log, 'Event Espresso Log' );
170
-		} catch( EE_Error $e ){
171
-			EE_Error::add_error( sprintf( __(  'Could not write to the Event Espresso log file because: %s', 'event_espresso' ), ' &nbsp; &nbsp; ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ );
168
+			$this->_log = EEH_File::get_file_contents($this->_logs_folder.$this->_log_file).$this->_log;
169
+			EEH_File::write_to_file($this->_logs_folder.$this->_log_file, $this->_log, 'Event Espresso Log');
170
+		} catch (EE_Error $e) {
171
+			EE_Error::add_error(sprintf(__('Could not write to the Event Espresso log file because: %s', 'event_espresso'), ' &nbsp; &nbsp; '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
172 172
 			return;
173 173
 		}
174 174
 	}
@@ -181,31 +181,31 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	public function send_log() {
183 183
 
184
-		if ( empty( $this->_remote_logging_url )) {
184
+		if (empty($this->_remote_logging_url)) {
185 185
 			return;
186 186
 		}
187 187
 
188
-		$data = 'domain=' . $_SERVER['HTTP_HOST'];
189
-		$data .= '&ip=' . $_SERVER['SERVER_ADDR'];
190
-		$data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE'];
191
-		$data .= '&time=' . time();
192
-		$data .= '&remote_log=' . $this->_log;
193
-		$data .= '&request_array=' . json_encode( $_REQUEST );
188
+		$data = 'domain='.$_SERVER['HTTP_HOST'];
189
+		$data .= '&ip='.$_SERVER['SERVER_ADDR'];
190
+		$data .= '&server_type='.$_SERVER['SERVER_SOFTWARE'];
191
+		$data .= '&time='.time();
192
+		$data .= '&remote_log='.$this->_log;
193
+		$data .= '&request_array='.json_encode($_REQUEST);
194 194
 		$data .= '&action=save';
195 195
 
196
-		if ( defined( 'EELOGGING_PASS' )) {
197
-			$data .= '&pass=' . EELOGGING_PASS;
196
+		if (defined('EELOGGING_PASS')) {
197
+			$data .= '&pass='.EELOGGING_PASS;
198 198
 		}
199
-		if ( defined( 'EELOGGING_KEY' )) {
200
-			$data .= '&key=' . EELOGGING_KEY;
199
+		if (defined('EELOGGING_KEY')) {
200
+			$data .= '&key='.EELOGGING_KEY;
201 201
 		}
202 202
 
203
-		$c = curl_init( $this->_remote_logging_url );
204
-		curl_setopt( $c, CURLOPT_POST, TRUE );
205
-		curl_setopt( $c, CURLOPT_POSTFIELDS, $data );
206
-		curl_setopt( $c, CURLOPT_RETURNTRANSFER, TRUE );
207
-		curl_exec( $c );
208
-		curl_close( $c );
203
+		$c = curl_init($this->_remote_logging_url);
204
+		curl_setopt($c, CURLOPT_POST, TRUE);
205
+		curl_setopt($c, CURLOPT_POSTFIELDS, $data);
206
+		curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE);
207
+		curl_exec($c);
208
+		curl_close($c);
209 209
 	}
210 210
 
211 211
 
@@ -216,18 +216,18 @@  discard block
 block discarded – undo
216 216
 	 * previous entries are overwritten
217 217
 	 */
218 218
 	public function write_debug() {
219
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
219
+		if (defined('WP_DEBUG') && WP_DEBUG) {
220 220
 			$this->_debug_log = '';
221
-			foreach ( $_GET as $key => $value ) {
222
-				$this->_debug_log .= '$_GET["' . $key . '"] = "' . serialize($value) . '"' . PHP_EOL;
221
+			foreach ($_GET as $key => $value) {
222
+				$this->_debug_log .= '$_GET["'.$key.'"] = "'.serialize($value).'"'.PHP_EOL;
223 223
 			}
224
-			foreach ( $_POST as $key => $value ) {
225
-				$this->_debug_log .= '$_POST["' . $key . '"] = "' . serialize($value) . '"' . PHP_EOL;
224
+			foreach ($_POST as $key => $value) {
225
+				$this->_debug_log .= '$_POST["'.$key.'"] = "'.serialize($value).'"'.PHP_EOL;
226 226
 			}
227 227
 			try {
228
-				EEH_File::write_to_file( $this->_logs_folder . $this->_debug_file, $this->_debug_log, 'Event Espresso Debug Log' );
229
-			} catch( EE_Error $e ){
230
-				EE_Error::add_error( sprintf( __(  'Could not write to the Event Espresso debug log file because: %s', 'event_espresso' ), ' &nbsp; &nbsp; ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ );
228
+				EEH_File::write_to_file($this->_logs_folder.$this->_debug_file, $this->_debug_log, 'Event Espresso Debug Log');
229
+			} catch (EE_Error $e) {
230
+				EE_Error::add_error(sprintf(__('Could not write to the Event Espresso debug log file because: %s', 'event_espresso'), ' &nbsp; &nbsp; '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
231 231
 				return;
232 232
 			}
233 233
 		}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 * __clone
240 240
 	 */
241 241
 	public function __clone() {
242
-		trigger_error( __( 'Clone is not allowed.', 'event_espresso' ), E_USER_ERROR );
242
+		trigger_error(__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR);
243 243
 	}
244 244
 
245 245
 
Please login to merge, or discard this patch.
core/helpers/EEH_Activation.helper.php 1 patch
Spacing   +358 added lines, -358 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 * @param $table_name
58 58
 	 * @return string
59 59
 	 */
60
-	public static function ensure_table_name_has_prefix( $table_name ) {
60
+	public static function ensure_table_name_has_prefix($table_name) {
61 61
 		global $wpdb;
62
-		return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name;
62
+		return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name;
63 63
 	}
64 64
 
65 65
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * be called on plugin activation and reactivation
86 86
 	 * @return boolean success, whether the database and folders are setup properly
87 87
 	 */
88
-	public static function initialize_db_and_folders(){
88
+	public static function initialize_db_and_folders() {
89 89
 		$good_filesystem = EEH_Activation::create_upload_directories();
90 90
 		$good_db = EEH_Activation::create_database_tables();
91 91
 		return $good_filesystem && $good_db;
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	 * upon activation of a new plugin, reactivation, and at the end
100 100
 	 * of running migration scripts
101 101
 	 */
102
-	public static function initialize_db_content(){
102
+	public static function initialize_db_content() {
103 103
 		//let's avoid doing all this logic repeatedly, especially when addons are requesting it
104
-		if( EEH_Activation::$_initialized_db_content_already_in_this_request ) {
104
+		if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
105 105
 			return;
106 106
 		}
107 107
 		EEH_Activation::$_initialized_db_content_already_in_this_request = true;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		EEH_Activation::remove_cron_tasks();
119 119
 		EEH_Activation::create_cron_tasks();
120 120
 		//also, check for CAF default db content
121
-		do_action( 'AHEE__EEH_Activation__initialize_db_content' );
121
+		do_action('AHEE__EEH_Activation__initialize_db_content');
122 122
 		//also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
123 123
 		//which users really won't care about on initial activation
124 124
 		EE_Error::overwrite_success();
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @return array
138 138
 	 * @throws \EE_Error
139 139
 	 */
140
-	public static function get_cron_tasks( $which_to_include ) {
140
+	public static function get_cron_tasks($which_to_include) {
141 141
 		$cron_tasks = apply_filters(
142 142
 			'FHEE__EEH_Activation__get_cron_tasks',
143 143
 			array(
@@ -146,17 +146,17 @@  discard block
 block discarded – undo
146 146
 				'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
147 147
 			)
148 148
 		);
149
-		if( $which_to_include === 'all' ) {
149
+		if ($which_to_include === 'all') {
150 150
 			//leave as-is
151
-		}elseif( $which_to_include === 'old' ) {
152
-			$cron_tasks = array_filter( $cron_tasks, function ( $value ) {
151
+		}elseif ($which_to_include === 'old') {
152
+			$cron_tasks = array_filter($cron_tasks, function($value) {
153 153
 				return $value === EEH_Activation::cron_task_no_longer_in_use;
154 154
 			});
155
-		}elseif( $which_to_include === 'current' ) {
156
-			$cron_tasks = array_filter( $cron_tasks );
157
-		}elseif( WP_DEBUG ) {
158
-			throw new EE_Error( sprintf( __( 'Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso' ), $which_to_include ) );
159
-		}else{
155
+		}elseif ($which_to_include === 'current') {
156
+			$cron_tasks = array_filter($cron_tasks);
157
+		}elseif (WP_DEBUG) {
158
+			throw new EE_Error(sprintf(__('Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso'), $which_to_include));
159
+		} else {
160 160
 			//leave as-is
161 161
 		}
162 162
 		return $cron_tasks;
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public static function create_cron_tasks() {
169 169
 
170
-		foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) {
171
-			if( ! wp_next_scheduled( $hook_name ) ) {
172
-				wp_schedule_event( time(), $frequency, $hook_name );
170
+		foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
171
+			if ( ! wp_next_scheduled($hook_name)) {
172
+				wp_schedule_event(time(), $frequency, $hook_name);
173 173
 			}
174 174
 		}
175 175
 
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 	 * Remove the currently-existing and now-removed cron tasks.
180 180
 	 * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
181 181
 	 */
182
-	public static function remove_cron_tasks( $remove_all = true ) {
182
+	public static function remove_cron_tasks($remove_all = true) {
183 183
 		$cron_tasks_to_remove = $remove_all ? 'all' : 'old';
184 184
 		$crons = _get_cron_array();
185
-		$crons = is_array( $crons ) ? $crons : array();
185
+		$crons = is_array($crons) ? $crons : array();
186 186
 		/* reminder that $crons looks like: top-level keys are timestamps,
187 187
 		 * and their values are arrays.
188 188
 		 * The 2nd level arrays have keys with each of the cron task hooknames to run at that time
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 		 *					...
201 201
 		 *      ...
202 202
 		 */
203
-		foreach( EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ) as $hook_name => $frequency ) {
204
-			foreach( $crons as $timestamp => $hooks_to_fire_at_time ) {
205
-				if ( array_key_exists( $hook_name, $hooks_to_fire_at_time ) )  {
206
-					unset( $crons[ $timestamp ][ $hook_name ] );
203
+		foreach (EEH_Activation::get_cron_tasks($cron_tasks_to_remove) as $hook_name => $frequency) {
204
+			foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
205
+				if (array_key_exists($hook_name, $hooks_to_fire_at_time)) {
206
+					unset($crons[$timestamp][$hook_name]);
207 207
 				}
208 208
 			}
209 209
 		}
210
-		_set_cron_array( $crons );
210
+		_set_cron_array($crons);
211 211
 	}
212 212
 
213 213
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	public static function CPT_initialization() {
224 224
 		// register Custom Post Types
225
-		EE_Registry::instance()->load_core( 'Register_CPTs' );
225
+		EE_Registry::instance()->load_core('Register_CPTs');
226 226
 		flush_rewrite_rules();
227 227
 	}
228 228
 
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 	 * 	@return void
241 241
 	 */
242 242
 	public static function reset_and_update_config() {
243
-		do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) );
244
-		add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 );
243
+		do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
244
+		add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3);
245 245
 		//EE_Config::reset();
246 246
 	}
247 247
 
@@ -254,23 +254,23 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	public static function load_calendar_config() {
256 256
 		// grab array of all plugin folders and loop thru it
257
-		$plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR );
258
-		if ( empty( $plugins ) ) {
257
+		$plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR);
258
+		if (empty($plugins)) {
259 259
 			return;
260 260
 		}
261
-		foreach ( $plugins as $plugin_path ) {
261
+		foreach ($plugins as $plugin_path) {
262 262
 			// grab plugin folder name from path
263
-			$plugin = basename( $plugin_path );
263
+			$plugin = basename($plugin_path);
264 264
 			// drill down to Espresso plugins
265
-			if ( strpos( $plugin, 'espresso' ) !== FALSE || strpos( $plugin, 'Espresso' ) !== FALSE || strpos( $plugin, 'ee4' ) !== FALSE || strpos( $plugin, 'EE4' ) !== FALSE ) {
265
+			if (strpos($plugin, 'espresso') !== FALSE || strpos($plugin, 'Espresso') !== FALSE || strpos($plugin, 'ee4') !== FALSE || strpos($plugin, 'EE4') !== FALSE) {
266 266
 				// then to calendar related plugins
267
-				if ( strpos( $plugin, 'calendar' ) !== FALSE ) {
267
+				if (strpos($plugin, 'calendar') !== FALSE) {
268 268
 					// this is what we are looking for
269
-					$calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
269
+					$calendar_config = $plugin_path.DS.'EE_Calendar_Config.php';
270 270
 					// does it exist in this folder ?
271
-					if ( is_readable( $calendar_config )) {
271
+					if (is_readable($calendar_config)) {
272 272
 						// YEAH! let's load it
273
-						require_once( $calendar_config );
273
+						require_once($calendar_config);
274 274
 					}
275 275
 				}
276 276
 			}
@@ -287,21 +287,21 @@  discard block
 block discarded – undo
287 287
 	 * @param \EE_Config $EE_Config
288 288
 	 * @return \stdClass
289 289
 	 */
290
-	public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) {
291
-		$convert_from_array = array( 'addons' );
290
+	public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) {
291
+		$convert_from_array = array('addons');
292 292
 		// in case old settings were saved as an array
293
-		if ( is_array( $settings ) && in_array( $config, $convert_from_array )) {
293
+		if (is_array($settings) && in_array($config, $convert_from_array)) {
294 294
 			// convert existing settings to an object
295 295
 			$config_array = $settings;
296 296
 			$settings = new stdClass();
297
-			foreach ( $config_array as $key => $value ){
298
-				if ( $key == 'calendar' && class_exists( 'EE_Calendar_Config' )) {
299
-					$EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value );
297
+			foreach ($config_array as $key => $value) {
298
+				if ($key == 'calendar' && class_exists('EE_Calendar_Config')) {
299
+					$EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
300 300
 				} else {
301 301
 					$settings->$key = $value;
302 302
 				}
303 303
 			}
304
-			add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' );
304
+			add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
305 305
 		}
306 306
 		return $settings;
307 307
 	}
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 	 */
318 318
 	public static function deactivate_event_espresso() {
319 319
 		// check permissions
320
-		if ( current_user_can( 'activate_plugins' )) {
321
-			deactivate_plugins( EE_PLUGIN_BASENAME, TRUE );
320
+		if (current_user_can('activate_plugins')) {
321
+			deactivate_plugins(EE_PLUGIN_BASENAME, TRUE);
322 322
 		}
323 323
 	}
324 324
 
@@ -340,79 +340,79 @@  discard block
 block discarded – undo
340 340
 		$critical_pages = array(
341 341
 			array(
342 342
 				'id' =>'reg_page_id',
343
-				'name' => __( 'Registration Checkout', 'event_espresso' ),
343
+				'name' => __('Registration Checkout', 'event_espresso'),
344 344
 				'post' => NULL,
345 345
 				'code' => 'ESPRESSO_CHECKOUT'
346 346
 			),
347 347
 			array(
348 348
 				'id' => 'txn_page_id',
349
-				'name' => __( 'Transactions', 'event_espresso' ),
349
+				'name' => __('Transactions', 'event_espresso'),
350 350
 				'post' => NULL,
351 351
 				'code' => 'ESPRESSO_TXN_PAGE'
352 352
 			),
353 353
 			array(
354 354
 				'id' => 'thank_you_page_id',
355
-				'name' => __( 'Thank You', 'event_espresso' ),
355
+				'name' => __('Thank You', 'event_espresso'),
356 356
 				'post' => NULL,
357 357
 				'code' => 'ESPRESSO_THANK_YOU'
358 358
 			),
359 359
 			array(
360 360
 				'id' => 'cancel_page_id',
361
-				'name' => __( 'Registration Cancelled', 'event_espresso' ),
361
+				'name' => __('Registration Cancelled', 'event_espresso'),
362 362
 				'post' => NULL,
363 363
 				'code' => 'ESPRESSO_CANCELLED'
364 364
 			),
365 365
 		);
366 366
 
367
-		foreach ( $critical_pages as $critical_page ) {
367
+		foreach ($critical_pages as $critical_page) {
368 368
 			// is critical page ID set in config ?
369
-			if ( EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE ) {
369
+			if (EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE) {
370 370
 				// attempt to find post by ID
371
-				$critical_page['post'] = get_post( EE_Registry::instance()->CFG->core->$critical_page['id'] );
371
+				$critical_page['post'] = get_post(EE_Registry::instance()->CFG->core->$critical_page['id']);
372 372
 			}
373 373
 			// no dice?
374
-			if ( $critical_page['post'] == NULL ) {
374
+			if ($critical_page['post'] == NULL) {
375 375
 				// attempt to find post by title
376
-				$critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] );
376
+				$critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
377 377
 				// still nothing?
378
-				if ( $critical_page['post'] == NULL ) {
379
-					$critical_page = EEH_Activation::create_critical_page( $critical_page );
378
+				if ($critical_page['post'] == NULL) {
379
+					$critical_page = EEH_Activation::create_critical_page($critical_page);
380 380
 					// REALLY? Still nothing ??!?!?
381
-					if ( $critical_page['post'] == NULL ) {
382
-						$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
383
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
381
+					if ($critical_page['post'] == NULL) {
382
+						$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
383
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
384 384
 						break;
385 385
 					}
386 386
 				}
387 387
 			}
388 388
 			// track post_shortcodes
389
-			if ( $critical_page['post'] ) {
390
-				EEH_Activation::_track_critical_page_post_shortcodes( $critical_page );
389
+			if ($critical_page['post']) {
390
+				EEH_Activation::_track_critical_page_post_shortcodes($critical_page);
391 391
 			}
392 392
 			// check that Post ID matches critical page ID in config
393
-			if ( isset( $critical_page['post']->ID ) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id'] ) {
393
+			if (isset($critical_page['post']->ID) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id']) {
394 394
 				//update Config with post ID
395 395
 				EE_Registry::instance()->CFG->core->$critical_page['id'] = $critical_page['post']->ID;
396
-				if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) {
397
-					$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
398
-					EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
396
+				if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
397
+					$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
398
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
399 399
 				}
400 400
 			}
401 401
 
402
-			$critical_page_problem =  ! isset( $critical_page['post']->post_status ) || $critical_page['post']->post_status != 'publish' || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE ? TRUE : $critical_page_problem;
402
+			$critical_page_problem = ! isset($critical_page['post']->post_status) || $critical_page['post']->post_status != 'publish' || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE ? TRUE : $critical_page_problem;
403 403
 
404 404
 		}
405 405
 
406
-		if ( $critical_page_problem ) {
406
+		if ($critical_page_problem) {
407 407
 			$msg = sprintf(
408
-				__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ),
409
-				'<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>'
408
+				__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'),
409
+				'<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>'
410 410
 			);
411
-			EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg );
411
+			EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
412 412
 		}
413 413
 
414
-		if ( EE_Error::has_notices() ) {
415
-			EE_Error::get_notices( FALSE, TRUE, TRUE );
414
+		if (EE_Error::has_notices()) {
415
+			EE_Error::get_notices(FALSE, TRUE, TRUE);
416 416
 		}
417 417
 
418 418
 	}
@@ -425,13 +425,13 @@  discard block
 block discarded – undo
425 425
 	 * parameter to the shortcode
426 426
 	 * @return WP_Post or NULl
427 427
 	 */
428
-	public static function get_page_by_ee_shortcode($ee_shortcode){
428
+	public static function get_page_by_ee_shortcode($ee_shortcode) {
429 429
 		global $wpdb;
430 430
 		$shortcode_and_opening_bracket = '['.$ee_shortcode;
431 431
 		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
432
-		if($post_id){
432
+		if ($post_id) {
433 433
 			return get_post($post_id);
434
-		}else{
434
+		} else {
435 435
 			return NULL;
436 436
 		}
437 437
 
@@ -448,32 +448,32 @@  discard block
 block discarded – undo
448 448
 	 * @param array $critical_page
449 449
 	 * @return array
450 450
 	 */
451
-	public static function create_critical_page( $critical_page ) {
451
+	public static function create_critical_page($critical_page) {
452 452
 
453 453
 		$post_args = array(
454 454
 			'post_title' => $critical_page['name'],
455 455
 			'post_status' => 'publish',
456 456
 			'post_type' => 'page',
457 457
 			'comment_status' => 'closed',
458
-			'post_content' => '[' . $critical_page['code'] . ']'
458
+			'post_content' => '['.$critical_page['code'].']'
459 459
 		);
460 460
 
461
-		$post_id = wp_insert_post( $post_args );
462
-		if ( ! $post_id ) {
461
+		$post_id = wp_insert_post($post_args);
462
+		if ( ! $post_id) {
463 463
 			$msg = sprintf(
464
-				__( 'The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso' ),
464
+				__('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
465 465
 				$critical_page['name']
466 466
 			);
467
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
467
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
468 468
 			return $critical_page;
469 469
 		}
470 470
 		// get newly created post's details
471
-		if ( ! $critical_page['post'] = get_post( $post_id )) {
471
+		if ( ! $critical_page['post'] = get_post($post_id)) {
472 472
 			$msg = sprintf(
473
-				__( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ),
473
+				__('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
474 474
 				$critical_page['name']
475 475
 			);
476
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
476
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
477 477
 		}
478 478
 
479 479
 		return $critical_page;
@@ -492,34 +492,34 @@  discard block
 block discarded – undo
492 492
 	 * @param array $critical_page
493 493
 	 * @return void
494 494
 	 */
495
-	private static function _track_critical_page_post_shortcodes( $critical_page = array() ) {
495
+	private static function _track_critical_page_post_shortcodes($critical_page = array()) {
496 496
 		// check the goods
497
-		if ( ! $critical_page['post'] instanceof WP_Post ) {
497
+		if ( ! $critical_page['post'] instanceof WP_Post) {
498 498
 			$msg = sprintf(
499
-				__( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ),
499
+				__('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'),
500 500
 				$critical_page['name']
501 501
 			);
502
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
502
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
503 503
 			return;
504 504
 		}
505 505
 		// map shortcode to post
506
-		EE_Registry::instance()->CFG->core->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID;
506
+		EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID;
507 507
 		// and make sure it's NOT added to the WP "Posts Page"
508 508
 		// name of the WP Posts Page
509 509
 		$posts_page = EE_Registry::instance()->CFG->get_page_for_posts();
510
-		if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ] )) {
511
-			unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ][ $critical_page['code'] ] );
510
+		if (isset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page])) {
511
+			unset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page][$critical_page['code']]);
512 512
 		}
513
-		if ( $posts_page != 'posts' && isset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'] )) {
514
-			unset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'][ $critical_page['code'] ] );
513
+		if ($posts_page != 'posts' && isset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'])) {
514
+			unset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'][$critical_page['code']]);
515 515
 		}
516 516
 		// update post_shortcode CFG
517
-		if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) {
517
+		if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
518 518
 			$msg = sprintf(
519
-				__( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ),
519
+				__('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'),
520 520
 				$critical_page['name']
521 521
 			);
522
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
522
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
523 523
 		}
524 524
 	}
525 525
 
@@ -537,24 +537,24 @@  discard block
 block discarded – undo
537 537
 	public static function get_default_creator_id() {
538 538
 		global $wpdb;
539 539
 
540
-		if ( ! empty( self::$_default_creator_id ) ) {
540
+		if ( ! empty(self::$_default_creator_id)) {
541 541
 			return self::$_default_creator_id;
542 542
 		}/**/
543 543
 
544
-		$role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' );
544
+		$role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
545 545
 
546 546
 		//let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
547
-		$pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check );
548
-		if ( $pre_filtered_id !== false ) {
547
+		$pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check);
548
+		if ($pre_filtered_id !== false) {
549 549
 			return (int) $pre_filtered_id;
550 550
 		}
551 551
 
552
-		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' );
553
-		$query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' );
554
-		$user_id = $wpdb->get_var( $query );
555
-		 $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id );
556
-		 if ( $user_id && intval( $user_id ) ) {
557
-		 	self::$_default_creator_id =  intval( $user_id );
552
+		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities');
553
+		$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%');
554
+		$user_id = $wpdb->get_var($query);
555
+		 $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
556
+		 if ($user_id && intval($user_id)) {
557
+		 	self::$_default_creator_id = intval($user_id);
558 558
 		 	return self::$_default_creator_id;
559 559
 		 } else {
560 560
 		 	return NULL;
@@ -581,29 +581,29 @@  discard block
 block discarded – undo
581 581
 	 * 	@return void
582 582
 	 * @throws EE_Error if there are database errors
583 583
 	 */
584
-	public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) {
585
-		if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){
584
+	public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) {
585
+		if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) {
586 586
 			return;
587 587
 		}
588
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
589
-		if ( ! function_exists( 'dbDelta' )) {
590
-			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
588
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
589
+		if ( ! function_exists('dbDelta')) {
590
+			require_once(ABSPATH.'wp-admin/includes/upgrade.php');
591 591
 		}
592 592
 		/** @var WPDB $wpdb */
593 593
 		global $wpdb;
594
-		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
594
+		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
595 595
 		// do we need to first delete an existing version of this table ?
596
-		if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){
596
+		if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) {
597 597
 			// ok, delete the table... but ONLY if it's empty
598
-			$deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name );
598
+			$deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
599 599
 			// table is NOT empty, are you SURE you want to delete this table ???
600
-			if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){
601
-				EEH_Activation::delete_unused_db_table( $wp_table_name );
602
-			} else if ( ! $deleted_safely ) {
600
+			if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
601
+				EEH_Activation::delete_unused_db_table($wp_table_name);
602
+			} else if ( ! $deleted_safely) {
603 603
 				// so we should be more cautious rather than just dropping tables so easily
604 604
 				EE_Error::add_persistent_admin_notice(
605
-						'bad_table_' . $wp_table_name . '_detected',
606
-						sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ),
605
+						'bad_table_'.$wp_table_name.'_detected',
606
+						sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'),
607 607
 								$wp_table_name,
608 608
 								"<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>",
609 609
 								'<b>wp-config.php</b>',
@@ -612,25 +612,25 @@  discard block
 block discarded – undo
612 612
 			}
613 613
 		}
614 614
 		// does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns )
615
-		if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) {
615
+		if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) {
616 616
 			$SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;";
617 617
 			//get $wpdb to echo errors, but buffer them. This way at least WE know an error
618 618
 			//happened. And then we can choose to tell the end user
619
-			$old_show_errors_policy = $wpdb->show_errors( TRUE );
620
-			$old_error_suppression_policy = $wpdb->suppress_errors( FALSE );
619
+			$old_show_errors_policy = $wpdb->show_errors(TRUE);
620
+			$old_error_suppression_policy = $wpdb->suppress_errors(FALSE);
621 621
 			ob_start();
622
-			dbDelta( $SQL );
622
+			dbDelta($SQL);
623 623
 			$output = ob_get_contents();
624 624
 			ob_end_clean();
625
-			$wpdb->show_errors( $old_show_errors_policy );
626
-			$wpdb->suppress_errors( $old_error_suppression_policy );
627
-			if( ! empty( $output ) ){
628
-				throw new EE_Error( $output	);
625
+			$wpdb->show_errors($old_show_errors_policy);
626
+			$wpdb->suppress_errors($old_error_suppression_policy);
627
+			if ( ! empty($output)) {
628
+				throw new EE_Error($output);
629 629
 			}
630 630
 		} else {
631 631
 			throw new EE_Error(
632 632
 				sprintf(
633
-					__( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ),
633
+					__('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'),
634 634
 					'<br />',
635 635
 					$sql
636 636
 				)
@@ -652,15 +652,15 @@  discard block
 block discarded – undo
652 652
 	 * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be 'VARCHAR(10)'
653 653
 	 * @return bool|int
654 654
 	 */
655
-	public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){
656
-		if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){
655
+	public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') {
656
+		if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) {
657 657
 			return FALSE;
658 658
 		}
659 659
 		global $wpdb;
660
-		$full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
660
+		$full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
661 661
 		$fields = self::get_fields_on_table($table_name);
662
-		if (!in_array($column_name, $fields)){
663
-			$alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info";
662
+		if ( ! in_array($column_name, $fields)) {
663
+			$alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info";
664 664
 			//echo "alter query:$alter_query";
665 665
 			return $wpdb->query($alter_query);
666 666
 		}
@@ -679,15 +679,15 @@  discard block
 block discarded – undo
679 679
 	 * 	@param string $table_name, without prefixed $wpdb->prefix
680 680
 	 * 	@return array of database column names
681 681
 	 */
682
-	public static function get_fields_on_table( $table_name = NULL ) {
682
+	public static function get_fields_on_table($table_name = NULL) {
683 683
 		global $wpdb;
684
-		$table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
685
-		if ( ! empty( $table_name )) {
684
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
685
+		if ( ! empty($table_name)) {
686 686
 			$columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name ");
687 687
 			if ($columns !== FALSE) {
688 688
 				$field_array = array();
689
-				foreach($columns as $column ){
690
-					$field_array[] = $column->Field;;
689
+				foreach ($columns as $column) {
690
+					$field_array[] = $column->Field; ;
691 691
 				}
692 692
 				return $field_array;
693 693
 			}
@@ -705,12 +705,12 @@  discard block
 block discarded – undo
705 705
 	 * @param string $table_name
706 706
 	 * @return bool
707 707
 	 */
708
-	public static function db_table_is_empty( $table_name ) {
708
+	public static function db_table_is_empty($table_name) {
709 709
 		global $wpdb;
710
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
711
-		if ( EEH_Activation::table_exists( $table_name ) ) {
712
-			$count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
713
-			return absint( $count ) === 0 ? true : false;
710
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
711
+		if (EEH_Activation::table_exists($table_name)) {
712
+			$count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
713
+			return absint($count) === 0 ? true : false;
714 714
 		}
715 715
 		return false;
716 716
 	}
@@ -725,9 +725,9 @@  discard block
 block discarded – undo
725 725
 	 * @param string $table_name
726 726
 	 * @return bool | int
727 727
 	 */
728
-	public static function delete_db_table_if_empty( $table_name ) {
729
-		if ( EEH_Activation::db_table_is_empty( $table_name ) ) {
730
-			return EEH_Activation::delete_unused_db_table( $table_name );
728
+	public static function delete_db_table_if_empty($table_name) {
729
+		if (EEH_Activation::db_table_is_empty($table_name)) {
730
+			return EEH_Activation::delete_unused_db_table($table_name);
731 731
 		}
732 732
 		return false;
733 733
 	}
@@ -742,11 +742,11 @@  discard block
 block discarded – undo
742 742
 	 * @param string $table_name
743 743
 	 * @return bool | int
744 744
 	 */
745
-	public static function delete_unused_db_table( $table_name ) {
745
+	public static function delete_unused_db_table($table_name) {
746 746
 		global $wpdb;
747
-		if ( EEH_Activation::table_exists( $table_name ) ) {
748
-			$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
749
-			return $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
747
+		if (EEH_Activation::table_exists($table_name)) {
748
+			$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
749
+			return $wpdb->query("DROP TABLE IF EXISTS $table_name");
750 750
 		}
751 751
 		return false;
752 752
 	}
@@ -762,18 +762,18 @@  discard block
 block discarded – undo
762 762
 	 * @param string $index_name
763 763
 	 * @return bool | int
764 764
 	 */
765
-	public static function drop_index( $table_name, $index_name ) {
766
-		if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){
765
+	public static function drop_index($table_name, $index_name) {
766
+		if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) {
767 767
 			return FALSE;
768 768
 		}
769 769
 		global $wpdb;
770
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
770
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
771 771
 		$index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'";
772 772
 		if (
773
-			$wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name
774
-			&& $wpdb->get_var( $index_exists_query ) == $table_name //using get_var with the $index_exists_query returns the table's name
773
+			$wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name
774
+			&& $wpdb->get_var($index_exists_query) == $table_name //using get_var with the $index_exists_query returns the table's name
775 775
 		) {
776
-			return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" );
776
+			return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name");
777 777
 		}
778 778
 		return TRUE;
779 779
 	}
@@ -789,27 +789,27 @@  discard block
 block discarded – undo
789 789
 	 * @return boolean success (whether database is setup properly or not)
790 790
 	 */
791 791
 	public static function create_database_tables() {
792
-		EE_Registry::instance()->load_core( 'Data_Migration_Manager' );
792
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
793 793
 		//find the migration script that sets the database to be compatible with the code
794 794
 		$dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
795
-		if( $dms_name ){
796
-			$current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name );
797
-			$current_data_migration_script->set_migrating( false );
795
+		if ($dms_name) {
796
+			$current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
797
+			$current_data_migration_script->set_migrating(false);
798 798
 			$current_data_migration_script->schema_changes_before_migration();
799 799
 			$current_data_migration_script->schema_changes_after_migration();
800
-			if( $current_data_migration_script->get_errors() ){
801
-				if( WP_DEBUG ){
802
-					foreach( $current_data_migration_script->get_errors() as $error ){
803
-						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ );
800
+			if ($current_data_migration_script->get_errors()) {
801
+				if (WP_DEBUG) {
802
+					foreach ($current_data_migration_script->get_errors() as $error) {
803
+						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
804 804
 					}
805
-				}else{
806
-					EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) );
805
+				} else {
806
+					EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso'));
807 807
 				}
808 808
 				return false;
809 809
 			}
810 810
 			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
811
-		}else{
812
-			EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
811
+		} else {
812
+			EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
813 813
 			return false;
814 814
 		}
815 815
 		return true;
@@ -829,27 +829,27 @@  discard block
 block discarded – undo
829 829
 	public static function initialize_system_questions() {
830 830
 		// QUESTION GROUPS
831 831
 		global $wpdb;
832
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' );
832
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group');
833 833
 		$SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
834 834
 		// what we have
835
-		$question_groups = $wpdb->get_col( $SQL );
835
+		$question_groups = $wpdb->get_col($SQL);
836 836
 		// check the response
837
-		$question_groups = is_array( $question_groups ) ? $question_groups : array();
837
+		$question_groups = is_array($question_groups) ? $question_groups : array();
838 838
 		// what we should have
839
-		$QSG_systems = array( 1, 2 );
839
+		$QSG_systems = array(1, 2);
840 840
 		// loop thru what we should have and compare to what we have
841
-		foreach ( $QSG_systems as $QSG_system ) {
841
+		foreach ($QSG_systems as $QSG_system) {
842 842
 			// reset values array
843 843
 			$QSG_values = array();
844 844
 			// if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
845
-			if ( ! in_array( "$QSG_system", $question_groups )) {
845
+			if ( ! in_array("$QSG_system", $question_groups)) {
846 846
 				// add it
847
-				switch ( $QSG_system ) {
847
+				switch ($QSG_system) {
848 848
 
849 849
 					case 1:
850 850
 							$QSG_values = array(
851
-									'QSG_name' => __( 'Personal Information', 'event_espresso' ),
852
-									'QSG_identifier' => 'personal-information-' . time(),
851
+									'QSG_name' => __('Personal Information', 'event_espresso'),
852
+									'QSG_identifier' => 'personal-information-'.time(),
853 853
 									'QSG_desc' => '',
854 854
 									'QSG_order' => 1,
855 855
 									'QSG_show_group_name' => 1,
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
 
862 862
 					case 2:
863 863
 							$QSG_values = array(
864
-									'QSG_name' => __( 'Address Information','event_espresso' ),
865
-									'QSG_identifier' => 'address-information-' . time(),
864
+									'QSG_name' => __('Address Information', 'event_espresso'),
865
+									'QSG_identifier' => 'address-information-'.time(),
866 866
 									'QSG_desc' => '',
867 867
 									'QSG_order' => 2,
868 868
 									'QSG_show_group_name' => 1,
@@ -874,14 +874,14 @@  discard block
 block discarded – undo
874 874
 
875 875
 				}
876 876
 				// make sure we have some values before inserting them
877
-				if ( ! empty( $QSG_values )) {
877
+				if ( ! empty($QSG_values)) {
878 878
 					// insert system question
879 879
 					$wpdb->insert(
880 880
 						$table_name,
881 881
 						$QSG_values,
882
-						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' )
882
+						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
883 883
 					);
884
-					$QSG_IDs[ $QSG_system ] = $wpdb->insert_id;
884
+					$QSG_IDs[$QSG_system] = $wpdb->insert_id;
885 885
 				}
886 886
 			}
887 887
 		}
@@ -890,10 +890,10 @@  discard block
 block discarded – undo
890 890
 
891 891
 		// QUESTIONS
892 892
 		global $wpdb;
893
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' );
893
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question');
894 894
 		$SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
895 895
 		// what we have
896
-		$questions = $wpdb->get_col( $SQL );
896
+		$questions = $wpdb->get_col($SQL);
897 897
 		// what we should have
898 898
 		$QST_systems = array(
899 899
 			'fname',
@@ -910,22 +910,22 @@  discard block
 block discarded – undo
910 910
 		$order_for_group_1 = 1;
911 911
 		$order_for_group_2 = 1;
912 912
 		// loop thru what we should have and compare to what we have
913
-		foreach ( $QST_systems as $QST_system ) {
913
+		foreach ($QST_systems as $QST_system) {
914 914
 			// reset values array
915 915
 			$QST_values = array();
916 916
 			// if we don't have what we should have
917
-			if ( ! in_array( $QST_system, $questions )) {
917
+			if ( ! in_array($QST_system, $questions)) {
918 918
 				// add it
919
-				switch ( $QST_system ) {
919
+				switch ($QST_system) {
920 920
 
921 921
 					case 'fname':
922 922
 							$QST_values = array(
923
-									'QST_display_text' => __( 'First Name', 'event_espresso' ),
924
-									'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ),
923
+									'QST_display_text' => __('First Name', 'event_espresso'),
924
+									'QST_admin_label' => __('First Name - System Question', 'event_espresso'),
925 925
 									'QST_system' => 'fname',
926 926
 									'QST_type' => 'TEXT',
927 927
 									'QST_required' => 1,
928
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
928
+									'QST_required_text' => __('This field is required', 'event_espresso'),
929 929
 									'QST_order' => 1,
930 930
 									'QST_admin_only' => 0,
931 931
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -935,12 +935,12 @@  discard block
 block discarded – undo
935 935
 
936 936
 					case 'lname':
937 937
 							$QST_values = array(
938
-									'QST_display_text' => __( 'Last Name', 'event_espresso' ),
939
-									'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ),
938
+									'QST_display_text' => __('Last Name', 'event_espresso'),
939
+									'QST_admin_label' => __('Last Name - System Question', 'event_espresso'),
940 940
 									'QST_system' => 'lname',
941 941
 									'QST_type' => 'TEXT',
942 942
 									'QST_required' => 1,
943
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
943
+									'QST_required_text' => __('This field is required', 'event_espresso'),
944 944
 									'QST_order' => 2,
945 945
 									'QST_admin_only' => 0,
946 946
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -950,12 +950,12 @@  discard block
 block discarded – undo
950 950
 
951 951
 					case 'email':
952 952
 							$QST_values = array(
953
-									'QST_display_text' => __( 'Email Address', 'event_espresso' ),
954
-									'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ),
953
+									'QST_display_text' => __('Email Address', 'event_espresso'),
954
+									'QST_admin_label' => __('Email Address - System Question', 'event_espresso'),
955 955
 									'QST_system' => 'email',
956 956
 									'QST_type' => 'TEXT',
957 957
 									'QST_required' => 1,
958
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
958
+									'QST_required_text' => __('This field is required', 'event_espresso'),
959 959
 									'QST_order' => 3,
960 960
 									'QST_admin_only' => 0,
961 961
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -965,12 +965,12 @@  discard block
 block discarded – undo
965 965
 
966 966
 					case 'address':
967 967
 							$QST_values = array(
968
-									'QST_display_text' => __( 'Address', 'event_espresso' ),
969
-									'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ),
968
+									'QST_display_text' => __('Address', 'event_espresso'),
969
+									'QST_admin_label' => __('Address - System Question', 'event_espresso'),
970 970
 									'QST_system' => 'address',
971 971
 									'QST_type' => 'TEXT',
972 972
 									'QST_required' => 0,
973
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
973
+									'QST_required_text' => __('This field is required', 'event_espresso'),
974 974
 									'QST_order' => 4,
975 975
 									'QST_admin_only' => 0,
976 976
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -980,12 +980,12 @@  discard block
 block discarded – undo
980 980
 
981 981
 					case 'address2':
982 982
 							$QST_values = array(
983
-									'QST_display_text' => __( 'Address2', 'event_espresso' ),
984
-									'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ),
983
+									'QST_display_text' => __('Address2', 'event_espresso'),
984
+									'QST_admin_label' => __('Address2 - System Question', 'event_espresso'),
985 985
 									'QST_system' => 'address2',
986 986
 									'QST_type' => 'TEXT',
987 987
 									'QST_required' => 0,
988
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
988
+									'QST_required_text' => __('This field is required', 'event_espresso'),
989 989
 									'QST_order' => 5,
990 990
 									'QST_admin_only' => 0,
991 991
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -995,12 +995,12 @@  discard block
 block discarded – undo
995 995
 
996 996
 					case 'city':
997 997
 							$QST_values = array(
998
-									'QST_display_text' => __( 'City', 'event_espresso' ),
999
-									'QST_admin_label' => __( 'City - System Question', 'event_espresso' ),
998
+									'QST_display_text' => __('City', 'event_espresso'),
999
+									'QST_admin_label' => __('City - System Question', 'event_espresso'),
1000 1000
 									'QST_system' => 'city',
1001 1001
 									'QST_type' => 'TEXT',
1002 1002
 									'QST_required' => 0,
1003
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1003
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1004 1004
 									'QST_order' => 6,
1005 1005
 									'QST_admin_only' => 0,
1006 1006
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1010,12 +1010,12 @@  discard block
 block discarded – undo
1010 1010
 
1011 1011
 					case 'state':
1012 1012
 							$QST_values = array(
1013
-									'QST_display_text' => __( 'State/Province', 'event_espresso' ),
1014
-									'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ),
1013
+									'QST_display_text' => __('State/Province', 'event_espresso'),
1014
+									'QST_admin_label' => __('State/Province - System Question', 'event_espresso'),
1015 1015
 									'QST_system' => 'state',
1016 1016
 									'QST_type' => 'STATE',
1017 1017
 									'QST_required' => 0,
1018
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1018
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1019 1019
 									'QST_order' => 7,
1020 1020
 									'QST_admin_only' => 0,
1021 1021
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1025,12 +1025,12 @@  discard block
 block discarded – undo
1025 1025
 
1026 1026
 					case 'country' :
1027 1027
 							$QST_values = array(
1028
-									'QST_display_text' => __( 'Country', 'event_espresso' ),
1029
-									'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ),
1028
+									'QST_display_text' => __('Country', 'event_espresso'),
1029
+									'QST_admin_label' => __('Country - System Question', 'event_espresso'),
1030 1030
 									'QST_system' => 'country',
1031 1031
 									'QST_type' => 'COUNTRY',
1032 1032
 									'QST_required' => 0,
1033
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1033
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1034 1034
 									'QST_order' => 8,
1035 1035
 									'QST_admin_only' => 0,
1036 1036
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1040,12 +1040,12 @@  discard block
 block discarded – undo
1040 1040
 
1041 1041
 					case 'zip':
1042 1042
 							$QST_values = array(
1043
-									'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ),
1044
-									'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ),
1043
+									'QST_display_text' => __('Zip/Postal Code', 'event_espresso'),
1044
+									'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'),
1045 1045
 									'QST_system' => 'zip',
1046 1046
 									'QST_type' => 'TEXT',
1047 1047
 									'QST_required' => 0,
1048
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1048
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1049 1049
 									'QST_order' => 9,
1050 1050
 									'QST_admin_only' => 0,
1051 1051
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1055,12 +1055,12 @@  discard block
 block discarded – undo
1055 1055
 
1056 1056
 					case 'phone':
1057 1057
 							$QST_values = array(
1058
-									'QST_display_text' => __( 'Phone Number', 'event_espresso' ),
1059
-									'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ),
1058
+									'QST_display_text' => __('Phone Number', 'event_espresso'),
1059
+									'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'),
1060 1060
 									'QST_system' => 'phone',
1061 1061
 									'QST_type' => 'TEXT',
1062 1062
 									'QST_required' => 0,
1063
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1063
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1064 1064
 									'QST_order' => 10,
1065 1065
 									'QST_admin_only' => 0,
1066 1066
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1069,34 +1069,34 @@  discard block
 block discarded – undo
1069 1069
 						break;
1070 1070
 
1071 1071
 				}
1072
-				if ( ! empty( $QST_values )) {
1072
+				if ( ! empty($QST_values)) {
1073 1073
 					// insert system question
1074 1074
 					$wpdb->insert(
1075 1075
 						$table_name,
1076 1076
 						$QST_values,
1077
-						array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' )
1077
+						array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1078 1078
 					);
1079 1079
 					$QST_ID = $wpdb->insert_id;
1080 1080
 
1081 1081
 					// QUESTION GROUP QUESTIONS
1082
-					if(  in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) {
1082
+					if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1083 1083
 						$system_question_we_want = EEM_Question_Group::system_personal;
1084 1084
 					} else {
1085 1085
 						$system_question_we_want = EEM_Question_Group::system_address;
1086 1086
 					}
1087
-					if( isset( $QSG_IDs[ $system_question_we_want ] ) ) {
1088
-						$QSG_ID = $QSG_IDs[ $system_question_we_want ];
1087
+					if (isset($QSG_IDs[$system_question_we_want])) {
1088
+						$QSG_ID = $QSG_IDs[$system_question_we_want];
1089 1089
 					} else {
1090
-						$id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) );
1091
-						if( is_array( $id_col ) ) {
1092
-							$QSG_ID = reset( $id_col );
1090
+						$id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want)));
1091
+						if (is_array($id_col)) {
1092
+							$QSG_ID = reset($id_col);
1093 1093
 						} else {
1094 1094
 							//ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1095 1095
                                                         EE_Log::instance()->log( 
1096 1096
                                                                 __FILE__, 
1097 1097
                                                                 __FUNCTION__, 
1098 1098
                                                                 sprintf( 
1099
-                                                                        __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), 
1099
+                                                                        __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), 
1100 1100
                                                                         $QST_ID ), 
1101 1101
                                                                 'error' );
1102 1102
                                                         continue;
@@ -1105,9 +1105,9 @@  discard block
 block discarded – undo
1105 1105
                                         
1106 1106
 					// add system questions to groups
1107 1107
 					$wpdb->insert(
1108
-						EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ),
1109
-						array( 'QSG_ID' => $QSG_ID , 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID==1)? $order_for_group_1++ : $order_for_group_2++ ),
1110
-						array( '%d', '%d','%d' )
1108
+						EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'),
1109
+						array('QSG_ID' => $QSG_ID, 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID == 1) ? $order_for_group_1++ : $order_for_group_2++),
1110
+						array('%d', '%d', '%d')
1111 1111
 					);
1112 1112
 				}
1113 1113
 			}
@@ -1119,11 +1119,11 @@  discard block
 block discarded – undo
1119 1119
 	 * Makes sure the default payment method (Invoice) is active.
1120 1120
 	 * This used to be done automatically as part of constructing the old gateways config
1121 1121
 	 */
1122
-	public static function insert_default_payment_methods(){
1123
-		if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){
1124
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
1125
-			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
1126
-		}else{
1122
+	public static function insert_default_payment_methods() {
1123
+		if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1124
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
1125
+			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1126
+		} else {
1127 1127
 			EEM_Payment_Method::instance()->verify_button_urls();
1128 1128
 		}
1129 1129
 	}
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 
1140 1140
 		global $wpdb;
1141 1141
 
1142
-		if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) {
1142
+		if (EEH_Activation::table_exists(EEM_Status::instance()->table())) {
1143 1143
 
1144 1144
 			$table_name = EEM_Status::instance()->table();
1145 1145
 
@@ -1205,35 +1205,35 @@  discard block
 block discarded – undo
1205 1205
 	 * 	@return boolean success of verifying upload directories exist
1206 1206
 	 */
1207 1207
 	public static function create_upload_directories() {
1208
-		EE_Registry::instance()->load_helper( 'File' );
1208
+		EE_Registry::instance()->load_helper('File');
1209 1209
 		// Create the required folders
1210 1210
 		$folders = array(
1211 1211
 				EVENT_ESPRESSO_TEMPLATE_DIR,
1212 1212
 				EVENT_ESPRESSO_GATEWAY_DIR,
1213
-				EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1214
-				EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1215
-				EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/'
1213
+				EVENT_ESPRESSO_UPLOAD_DIR.'logs/',
1214
+				EVENT_ESPRESSO_UPLOAD_DIR.'css/',
1215
+				EVENT_ESPRESSO_UPLOAD_DIR.'tickets/'
1216 1216
 		);
1217
-		foreach ( $folders as $folder ) {
1217
+		foreach ($folders as $folder) {
1218 1218
 			try {
1219
-				EEH_File::ensure_folder_exists_and_is_writable( $folder );
1220
-				@ chmod( $folder, 0755 );
1221
-			} catch( EE_Error $e ){
1219
+				EEH_File::ensure_folder_exists_and_is_writable($folder);
1220
+				@ chmod($folder, 0755);
1221
+			} catch (EE_Error $e) {
1222 1222
 				EE_Error::add_error(
1223 1223
 					sprintf(
1224
-						__(  'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ),
1224
+						__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1225 1225
 						$folder,
1226
-						'<br />' . $e->getMessage()
1226
+						'<br />'.$e->getMessage()
1227 1227
 					),
1228 1228
 					__FILE__, __FUNCTION__, __LINE__
1229 1229
 				);
1230 1230
 				//indicate we'll need to fix this later
1231
-				update_option( EEH_Activation::upload_directories_incomplete_option_name, true );
1231
+				update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1232 1232
 				return FALSE;
1233 1233
 			}
1234 1234
 		}
1235 1235
 		//remember EE's folders are all good
1236
-		delete_option( EEH_Activation::upload_directories_incomplete_option_name );
1236
+		delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1237 1237
 		return TRUE;
1238 1238
 	}
1239 1239
 	
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 	 * @return boolean
1247 1247
 	 */
1248 1248
 	public static function upload_directories_incomplete() {
1249
-		return get_option( EEH_Activation::upload_directories_incomplete_option_name, false );
1249
+		return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1250 1250
 	}
1251 1251
 
1252 1252
 
@@ -1265,16 +1265,16 @@  discard block
 block discarded – undo
1265 1265
 		$installed_messengers = $default_messengers = array();
1266 1266
 
1267 1267
 		//include our helper
1268
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
1268
+		EE_Registry::instance()->load_helper('MSG_Template');
1269 1269
 
1270 1270
 		//get all installed messenger objects
1271 1271
 		$installed = EEH_MSG_Template::get_installed_message_objects();
1272 1272
 
1273 1273
 		//let's setup the $installed messengers in an array AND the messengers that are set to be activated on install.
1274
-		foreach ( $installed['messengers'] as $msgr ) {
1275
-			if ( $msgr instanceof EE_messenger ) {
1274
+		foreach ($installed['messengers'] as $msgr) {
1275
+			if ($msgr instanceof EE_messenger) {
1276 1276
 				$installed_messengers[$msgr->name] = $msgr;
1277
-				if ( $msgr->activate_on_install ) {
1277
+				if ($msgr->activate_on_install) {
1278 1278
 					$default_messengers[] = $msgr->name;
1279 1279
 				}
1280 1280
 			}
@@ -1284,36 +1284,36 @@  discard block
 block discarded – undo
1284 1284
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
1285 1285
 
1286 1286
 		//things that have already been activated before
1287
-		$has_activated = get_option( 'ee_has_activated_messenger' );
1287
+		$has_activated = get_option('ee_has_activated_messenger');
1288 1288
 
1289 1289
 		//do an initial loop to determine if we need to continue
1290 1290
 		$def_ms = array();
1291
-		foreach ( $default_messengers as $msgr ) {
1292
-			if ( isset($active_messengers[$msgr] ) || isset( $has_activated[$msgr] ) ) continue;
1291
+		foreach ($default_messengers as $msgr) {
1292
+			if (isset($active_messengers[$msgr]) || isset($has_activated[$msgr])) continue;
1293 1293
 			$def_ms[] = $msgr;
1294 1294
 		}
1295 1295
 
1296 1296
 		//setup the $installed_mts in an array
1297
-		foreach ( $installed['message_types'] as $imt ) {
1298
-			if ( $imt instanceof EE_message_type ) {
1297
+		foreach ($installed['message_types'] as $imt) {
1298
+			if ($imt instanceof EE_message_type) {
1299 1299
 				$installed_mts[$imt->name] = $imt;
1300 1300
 			}
1301 1301
 		}
1302 1302
 
1303 1303
 		//loop through default array for default messengers (if present)
1304
-		if ( ! empty( $def_ms ) ) {
1305
-			foreach ( $def_ms as $messenger ) {
1304
+		if ( ! empty($def_ms)) {
1305
+			foreach ($def_ms as $messenger) {
1306 1306
 				//all is good so let's setup the default stuff. We need to use the given messenger object (if exists) to get the default message type for the messenger.
1307
-				if ( ! isset( $installed_messengers[$messenger] )) {
1307
+				if ( ! isset($installed_messengers[$messenger])) {
1308 1308
 					continue;
1309 1309
 				}
1310 1310
 				/** @var EE_messenger[] $installed_messengers  */
1311 1311
 				$default_mts = $installed_messengers[$messenger]->get_default_message_types();
1312 1312
 				$active_messengers[$messenger]['obj'] = $installed_messengers[$messenger];
1313
-				foreach ( $default_mts as $index => $mt ) {
1313
+				foreach ($default_mts as $index => $mt) {
1314 1314
 					//is there an installed_mt matching the default string?  If not then nothing to do here.
1315
-					if ( ! isset( $installed_mts[$mt] ) ) {
1316
-						unset( $default_mts[$index] );
1315
+					if ( ! isset($installed_mts[$mt])) {
1316
+						unset($default_mts[$index]);
1317 1317
 						continue;
1318 1318
 					}
1319 1319
 
@@ -1322,41 +1322,41 @@  discard block
 block discarded – undo
1322 1322
 					/** @var EE_message_type[] $installed_mts */
1323 1323
 					$settings_fields = $installed_mts[$mt]->get_admin_settings_fields();
1324 1324
 					$settings = array();
1325
-					if ( is_array( $settings_fields ) ) {
1326
-						foreach ( $settings_fields as $field => $values ) {
1327
-							if ( isset( $values['default'] ) ) {
1325
+					if (is_array($settings_fields)) {
1326
+						foreach ($settings_fields as $field => $values) {
1327
+							if (isset($values['default'])) {
1328 1328
 								$settings[$field] = $values['default'];
1329 1329
 							}
1330 1330
 						}
1331 1331
 					}
1332 1332
 
1333
-					$active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings;
1333
+					$active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings;
1334 1334
 					$has_activated[$messenger][] = $mt;
1335 1335
 				}
1336 1336
 
1337 1337
 				//setup any initial settings for the messenger
1338 1338
 				$msgr_settings = $installed_messengers[$messenger]->get_admin_settings_fields();
1339 1339
 
1340
-				if ( !empty( $msgr_settings ) ) {
1341
-					foreach ( $msgr_settings as $field => $value ) {
1340
+				if ( ! empty($msgr_settings)) {
1341
+					foreach ($msgr_settings as $field => $value) {
1342 1342
 						$active_messengers[$messenger]['settings'][$field] = $value;
1343 1343
 					}
1344 1344
 				}
1345 1345
 
1346 1346
 				//now let's save the settings for this messenger! Must do now because the validator checks the db for active messengers to validate.
1347
-				EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1347
+				EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1348 1348
 
1349 1349
 				//let's generate all the templates but only if the messenger has default_mts (otherwise its just activated).
1350
-				if ( !empty( $default_mts ) ) {
1351
-					$success = EEH_MSG_Template::generate_new_templates( $messenger, $default_mts, '', TRUE );
1350
+				if ( ! empty($default_mts)) {
1351
+					$success = EEH_MSG_Template::generate_new_templates($messenger, $default_mts, '', TRUE);
1352 1352
 				}
1353 1353
 			}
1354 1354
 		} //end check for empty( $def_ms )
1355 1355
 
1356 1356
 		//still need to see if there are any message types to activate for active messengers
1357
-		foreach ( $active_messengers as $messenger => $settings ) {
1357
+		foreach ($active_messengers as $messenger => $settings) {
1358 1358
 			$msg_obj = $settings['obj'];
1359
-			if ( ! $msg_obj instanceof EE_messenger ) {
1359
+			if ( ! $msg_obj instanceof EE_messenger) {
1360 1360
 				continue;
1361 1361
 			}
1362 1362
 
@@ -1364,45 +1364,45 @@  discard block
 block discarded – undo
1364 1364
 			$new_default_mts = array();
1365 1365
 
1366 1366
 			//loop through each default mt reported by the messenger and make sure its set in its active db entry.
1367
-			foreach( $all_default_mts as $index => $mt ) {
1367
+			foreach ($all_default_mts as $index => $mt) {
1368 1368
 				//already active? already has generated templates? || has already been activated before (we dont' want to reactivate things users intentionally deactivated).
1369
-				if ( ( isset( $has_activated[$messenger] ) && in_array($mt, $has_activated[$messenger]) ) || isset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] ) ||  EEH_MSG_Template::already_generated( $messenger, $mt, 0, FALSE ) ) {
1369
+				if ((isset($has_activated[$messenger]) && in_array($mt, $has_activated[$messenger])) || isset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]) || EEH_MSG_Template::already_generated($messenger, $mt, 0, FALSE)) {
1370 1370
 					continue;
1371 1371
 				}
1372 1372
 
1373 1373
 				//is there an installed_mt matching the default string?  If not then nothing to do here.
1374
-				if ( ! isset( $installed_mts[$mt] ) ) {
1375
-					unset( $all_default_mts[$mt] );
1374
+				if ( ! isset($installed_mts[$mt])) {
1375
+					unset($all_default_mts[$mt]);
1376 1376
 					continue;
1377 1377
 				}
1378 1378
 
1379 1379
 				$settings_fields = $installed_mts[$mt]->get_admin_settings_fields();
1380 1380
 				$settings = array();
1381
-				if ( is_array( $settings_fields ) ) {
1382
-					foreach ( $settings_fields as $field => $values ) {
1383
-						if ( isset( $values['default'] ) ) {
1381
+				if (is_array($settings_fields)) {
1382
+					foreach ($settings_fields as $field => $values) {
1383
+						if (isset($values['default'])) {
1384 1384
 							$settings[$field] = $values['default'];
1385 1385
 						}
1386 1386
 					}
1387 1387
 				}
1388 1388
 
1389
-				$active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings;
1389
+				$active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings;
1390 1390
 				$new_default_mts[] = $mt;
1391 1391
 				$has_activated[$messenger][] = $mt;
1392 1392
 			}
1393 1393
 
1394 1394
 
1395
-			if ( ! empty( $new_default_mts ) ) {
1396
-				$success = EEH_MSG_Template::generate_new_templates( $messenger, $new_default_mts, '', TRUE );
1395
+			if ( ! empty($new_default_mts)) {
1396
+				$success = EEH_MSG_Template::generate_new_templates($messenger, $new_default_mts, '', TRUE);
1397 1397
 			}
1398 1398
 
1399 1399
 		}
1400 1400
 
1401 1401
 		//now let's save the settings for this messenger!
1402
-		EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1402
+		EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1403 1403
 
1404 1404
 		//update $has_activated record
1405
-		update_option( 'ee_has_activated_messenger', $has_activated );
1405
+		update_option('ee_has_activated_messenger', $has_activated);
1406 1406
 
1407 1407
 		//that's it!
1408 1408
 		return $success;
@@ -1422,47 +1422,47 @@  discard block
 block discarded – undo
1422 1422
 	 */
1423 1423
 	public static function validate_messages_system() {
1424 1424
 		//include our helper
1425
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
1425
+		EE_Registry::instance()->load_helper('MSG_Template');
1426 1426
 
1427 1427
 		//get active and installed  messengers/message types.
1428 1428
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
1429 1429
 		$installed = EEH_MSG_Template::get_installed_message_objects();
1430 1430
 		$installed_messengers = $installed_mts = array();
1431 1431
 		//set up the arrays so they can be handled easier.
1432
-		foreach( $installed['messengers'] as $im ) {
1433
-			if ( $im instanceof EE_messenger ) {
1432
+		foreach ($installed['messengers'] as $im) {
1433
+			if ($im instanceof EE_messenger) {
1434 1434
 				$installed_messengers[$im->name] = $im;
1435 1435
 			}
1436 1436
 		}
1437
-		foreach( $installed['message_types'] as $imt ) {
1438
-			if ( $imt instanceof EE_message_type ) {
1437
+		foreach ($installed['message_types'] as $imt) {
1438
+			if ($imt instanceof EE_message_type) {
1439 1439
 				$installed_mts[$imt->name] = $imt;
1440 1440
 			}
1441 1441
 		}
1442 1442
 
1443 1443
 		//now let's loop through the active array and validate
1444
-		foreach( $active_messengers as $messenger => $active_details ) {
1444
+		foreach ($active_messengers as $messenger => $active_details) {
1445 1445
 			//first let's see if this messenger is installed.
1446
-			if ( ! isset( $installed_messengers[$messenger] ) ) {
1446
+			if ( ! isset($installed_messengers[$messenger])) {
1447 1447
 				//not set so let's just remove from actives and make sure templates are inactive.
1448
-				unset( $active_messengers[$messenger] );
1449
-				EEH_MSG_Template::update_to_inactive( $messenger );
1448
+				unset($active_messengers[$messenger]);
1449
+				EEH_MSG_Template::update_to_inactive($messenger);
1450 1450
 				continue;
1451 1451
 			}
1452 1452
 
1453 1453
 			//messenger is active, so let's just make sure that any active message types not installed are deactivated.
1454
-			$mts = ! empty( $active_details['settings'][$messenger . '-message_types'] ) ? $active_details['settings'][$messenger . '-message_types'] : array();
1455
-			foreach ( $mts as $mt_name => $mt ) {
1456
-				if ( ! isset( $installed_mts[$mt_name] )  ) {
1457
-					unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] );
1458
-					EEH_MSG_Template::update_to_inactive( $messenger, $mt_name );
1454
+			$mts = ! empty($active_details['settings'][$messenger.'-message_types']) ? $active_details['settings'][$messenger.'-message_types'] : array();
1455
+			foreach ($mts as $mt_name => $mt) {
1456
+				if ( ! isset($installed_mts[$mt_name])) {
1457
+					unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt_name]);
1458
+					EEH_MSG_Template::update_to_inactive($messenger, $mt_name);
1459 1459
 				}
1460 1460
 			}
1461 1461
 		}
1462 1462
 
1463 1463
 		//all done! let's update the active_messengers.
1464
-		EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1465
-		do_action( 'AHEE__EEH_Activation__validate_messages_system' );
1464
+		EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1465
+		do_action('AHEE__EEH_Activation__validate_messages_system');
1466 1466
 		return;
1467 1467
 	}
1468 1468
 
@@ -1476,12 +1476,12 @@  discard block
 block discarded – undo
1476 1476
 	 * 	@static
1477 1477
 	 * 	@return void
1478 1478
 	 */
1479
-	public static function create_no_ticket_prices_array(){
1479
+	public static function create_no_ticket_prices_array() {
1480 1480
 		// this creates an array for tracking events that have no active ticket prices created
1481 1481
 		// this allows us to warn admins of the situation so that it can be corrected
1482
-		$espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE );
1483
-		if ( ! $espresso_no_ticket_prices ) {
1484
-			add_option( 'ee_no_ticket_prices', array(), '', FALSE );
1482
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE);
1483
+		if ( ! $espresso_no_ticket_prices) {
1484
+			add_option('ee_no_ticket_prices', array(), '', FALSE);
1485 1485
 		}
1486 1486
 	}
1487 1487
 
@@ -1503,24 +1503,24 @@  discard block
 block discarded – undo
1503 1503
 	 * Finds all our EE4 custom post types, and deletes them and their associated data (like post meta or term relations)/
1504 1504
 	 * @global wpdb $wpdb
1505 1505
 	 */
1506
-	public static function delete_all_espresso_cpt_data(){
1506
+	public static function delete_all_espresso_cpt_data() {
1507 1507
 		global $wpdb;
1508 1508
 		//get all the CPT post_types
1509 1509
 		$ee_post_types = array();
1510
-		foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){
1511
-			if ( method_exists( $model_name, 'instance' )) {
1512
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1513
-				if ( $model_obj instanceof EEM_CPT_Base ) {
1514
-					$ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type());
1510
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1511
+			if (method_exists($model_name, 'instance')) {
1512
+				$model_obj = call_user_func(array($model_name, 'instance'));
1513
+				if ($model_obj instanceof EEM_CPT_Base) {
1514
+					$ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1515 1515
 				}
1516 1516
 			}
1517 1517
 		}
1518 1518
 		//get all our CPTs
1519
-		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")";
1519
+		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")";
1520 1520
 		$cpt_ids = $wpdb->get_col($query);
1521 1521
 		//delete each post meta and term relations too
1522
-		foreach($cpt_ids as $post_id){
1523
-			wp_delete_post($post_id,true);
1522
+		foreach ($cpt_ids as $post_id) {
1523
+			wp_delete_post($post_id, true);
1524 1524
 		}
1525 1525
 	}
1526 1526
 
@@ -1534,18 +1534,18 @@  discard block
 block discarded – undo
1534 1534
 	 * @param bool $remove_all
1535 1535
 	 * @return void
1536 1536
 	 */
1537
-	public static function delete_all_espresso_tables_and_data( $remove_all = true ) {
1537
+	public static function delete_all_espresso_tables_and_data($remove_all = true) {
1538 1538
 		global $wpdb;
1539 1539
 		$undeleted_tables = array();
1540 1540
 
1541 1541
 		// load registry
1542
-		foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){
1543
-			if ( method_exists( $model_name, 'instance' )) {
1544
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1545
-				if ( $model_obj instanceof EEM_Base ) {
1546
-					foreach ( $model_obj->get_tables() as $table ) {
1547
-						if ( strpos( $table->get_table_name(), 'esp_' )) {
1548
-							switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) {
1542
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1543
+			if (method_exists($model_name, 'instance')) {
1544
+				$model_obj = call_user_func(array($model_name, 'instance'));
1545
+				if ($model_obj instanceof EEM_Base) {
1546
+					foreach ($model_obj->get_tables() as $table) {
1547
+						if (strpos($table->get_table_name(), 'esp_')) {
1548
+							switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) {
1549 1549
 								case false :
1550 1550
 									$undeleted_tables[] = $table->get_table_name();
1551 1551
 								break;
@@ -1570,8 +1570,8 @@  discard block
 block discarded – undo
1570 1570
 			'esp_promotion_rule',
1571 1571
 			'esp_rule'
1572 1572
 		);
1573
-		foreach( $tables_without_models as $table ){
1574
-			EEH_Activation::delete_db_table_if_empty( $table );
1573
+		foreach ($tables_without_models as $table) {
1574
+			EEH_Activation::delete_db_table_if_empty($table);
1575 1575
 		}
1576 1576
 
1577 1577
 
@@ -1608,58 +1608,58 @@  discard block
 block discarded – undo
1608 1608
 			'ee_pers_admin_notices' => true,
1609 1609
 			'ee_upload_directories_incomplete' => true,
1610 1610
 		);
1611
-		if( is_main_site() ) {
1612
-			$wp_options_to_delete[ 'ee_network_config' ] = true;
1611
+		if (is_main_site()) {
1612
+			$wp_options_to_delete['ee_network_config'] = true;
1613 1613
 		}
1614 1614
 
1615 1615
 		$undeleted_options = array();
1616
-		foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) {
1616
+		foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1617 1617
 
1618
-			if( $no_wildcard ){
1619
-				if( ! delete_option( $option_name ) ){
1618
+			if ($no_wildcard) {
1619
+				if ( ! delete_option($option_name)) {
1620 1620
 					$undeleted_options[] = $option_name;
1621 1621
 				}
1622
-			}else{
1623
-				$option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" );
1624
-				foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){
1625
-					if( ! delete_option( $option_name_from_wildcard ) ){
1622
+			} else {
1623
+				$option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1624
+				foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1625
+					if ( ! delete_option($option_name_from_wildcard)) {
1626 1626
 						$undeleted_options[] = $option_name_from_wildcard;
1627 1627
 					}
1628 1628
 				}
1629 1629
 			}
1630 1630
 		}
1631 1631
                 //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1632
-                remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 );
1632
+                remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1633 1633
 
1634
-		if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) {
1634
+		if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1635 1635
 			$db_update_sans_ee4 = array();
1636
-			foreach($espresso_db_update as $version => $times_activated){
1637
-				if( $version[0] =='3'){//if its NON EE4
1636
+			foreach ($espresso_db_update as $version => $times_activated) {
1637
+				if ($version[0] == '3') {//if its NON EE4
1638 1638
 					$db_update_sans_ee4[$version] = $times_activated;
1639 1639
 				}
1640 1640
 			}
1641
-			update_option( 'espresso_db_update', $db_update_sans_ee4 );
1641
+			update_option('espresso_db_update', $db_update_sans_ee4);
1642 1642
 		}
1643 1643
 
1644 1644
 		$errors = '';
1645
-		if ( ! empty( $undeleted_tables )) {
1645
+		if ( ! empty($undeleted_tables)) {
1646 1646
 			$errors .= sprintf(
1647
-				__( 'The following tables could not be deleted: %s%s', 'event_espresso' ),
1647
+				__('The following tables could not be deleted: %s%s', 'event_espresso'),
1648 1648
 				'<br/>',
1649
-				implode( ',<br/>', $undeleted_tables )
1649
+				implode(',<br/>', $undeleted_tables)
1650 1650
 			);
1651 1651
 		}
1652
-		if ( ! empty( $undeleted_options )) {
1653
-			$errors .= ! empty( $undeleted_tables ) ? '<br/>' : '';
1652
+		if ( ! empty($undeleted_options)) {
1653
+			$errors .= ! empty($undeleted_tables) ? '<br/>' : '';
1654 1654
 			$errors .= sprintf(
1655
-				__( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ),
1655
+				__('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1656 1656
 				'<br/>',
1657
-				implode( ',<br/>', $undeleted_options )
1657
+				implode(',<br/>', $undeleted_options)
1658 1658
 			);
1659 1659
 
1660 1660
 		}
1661
-		if ( $errors != '' ) {
1662
-			EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ );
1661
+		if ($errors != '') {
1662
+			EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1663 1663
 		}
1664 1664
 	}
1665 1665
 
@@ -1669,23 +1669,23 @@  discard block
 block discarded – undo
1669 1669
 	 * @param string $table_name with or without $wpdb->prefix
1670 1670
 	 * @return boolean
1671 1671
 	 */
1672
-	public static function table_exists( $table_name ){
1672
+	public static function table_exists($table_name) {
1673 1673
 		global $wpdb, $EZSQL_ERROR;
1674
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
1674
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
1675 1675
 		//ignore if this causes an sql error
1676 1676
 		$old_error = $wpdb->last_error;
1677 1677
 		$old_suppress_errors = $wpdb->suppress_errors();
1678
-		$old_show_errors_value = $wpdb->show_errors( FALSE );
1678
+		$old_show_errors_value = $wpdb->show_errors(FALSE);
1679 1679
 		$ezsql_error_cache = $EZSQL_ERROR;
1680
-		$wpdb->get_results( "SELECT * from $table_name LIMIT 1");
1681
-		$wpdb->show_errors( $old_show_errors_value );
1682
-		$wpdb->suppress_errors( $old_suppress_errors );
1680
+		$wpdb->get_results("SELECT * from $table_name LIMIT 1");
1681
+		$wpdb->show_errors($old_show_errors_value);
1682
+		$wpdb->suppress_errors($old_suppress_errors);
1683 1683
 		$new_error = $wpdb->last_error;
1684 1684
 		$wpdb->last_error = $old_error;
1685 1685
 		$EZSQL_ERROR = $ezsql_error_cache;
1686
-		if( empty( $new_error ) ){
1686
+		if (empty($new_error)) {
1687 1687
 			return TRUE;
1688
-		}else{
1688
+		} else {
1689 1689
 			return FALSE;
1690 1690
 		}
1691 1691
 	}
@@ -1693,7 +1693,7 @@  discard block
 block discarded – undo
1693 1693
 	/**
1694 1694
 	 * Resets the cache on EEH_Activation
1695 1695
 	 */
1696
-	public static function reset(){
1696
+	public static function reset() {
1697 1697
 		self::$_default_creator_id = NULL;
1698 1698
 		self::$_initialized_db_content_already_in_this_request = false;
1699 1699
 	}
Please login to merge, or discard this patch.
registrations/templates/attendee_registrations_main_meta_box.template.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -5,42 +5,42 @@
 block discarded – undo
5 5
 		<table class="admin-primary-mbox-tbl">
6 6
 			<thead>
7 7
 				<tr>
8
-					<th class="jst-left"><?php _e( 'Event Name', 'event_espresso' );?></th>
9
-					<th class="jst-left"><?php _e( 'REG ID', 'event_espresso' );?></th>
10
-					<th class="jst-left"><?php _e( 'TXN ID', 'event_espresso' );?></th>
11
-					<th class="jst-left"><?php _e( 'Reg Code', 'event_espresso' );?></th>
12
-					<th class="jst-rght"><?php _e( 'Ticket Price', 'event_espresso' );?></th>
8
+					<th class="jst-left"><?php _e('Event Name', 'event_espresso'); ?></th>
9
+					<th class="jst-left"><?php _e('REG ID', 'event_espresso'); ?></th>
10
+					<th class="jst-left"><?php _e('TXN ID', 'event_espresso'); ?></th>
11
+					<th class="jst-left"><?php _e('Reg Code', 'event_espresso'); ?></th>
12
+					<th class="jst-rght"><?php _e('Ticket Price', 'event_espresso'); ?></th>
13 13
 				</tr>
14 14
 			</thead>
15 15
 			<tbody>
16
-			<?php foreach( $registrations as $registration ) : ?>
16
+			<?php foreach ($registrations as $registration) : ?>
17 17
 				<tr>
18 18
 					<td class="jst-left">
19 19
 					<?php
20
-						$event_url = add_query_arg( array( 'action' => 'edit', 'post' => $registration->event_ID() ), admin_url( 'admin.php?page=espresso_events' ));
21
-						echo EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $registration->event_ID() ) ?  '<a href="'. $event_url .'"  title="'. esc_attr__( 'Edit Event', 'event_espresso' ) .'">' . $registration->event_name() . '</a>' : $registration->event_name();
20
+						$event_url = add_query_arg(array('action' => 'edit', 'post' => $registration->event_ID()), admin_url('admin.php?page=espresso_events'));
21
+						echo EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $registration->event_ID()) ? '<a href="'.$event_url.'"  title="'.esc_attr__('Edit Event', 'event_espresso').'">'.$registration->event_name().'</a>' : $registration->event_name();
22 22
 					?>
23 23
 					</td>
24 24
 					<td class="jst-left">
25 25
 					<?php
26
-							$reg_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$registration->ID() ), REG_ADMIN_URL );
27
-							echo EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $registration->ID() ) ? '
28
-							<a href="'.$reg_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' . 
29
-								sprintf( __( 'View Registration ', 'event_espresso'), $registration->ID() ) .
26
+							$reg_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$registration->ID()), REG_ADMIN_URL);
27
+							echo EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $registration->ID()) ? '
28
+							<a href="'.$reg_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'. 
29
+								sprintf(__('View Registration ', 'event_espresso'), $registration->ID()).
30 30
 							'</a>' : '';
31 31
 					?>
32 32
 					</td>
33 33
 					<td class="jst-left">
34 34
 					<?php
35
-						$txn_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$registration->transaction_ID() ), TXN_ADMIN_URL );
36
-						echo EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction' ) ? '
37
-						<a href="'.$txn_url.'" title="' . esc_attr__( 'View Transaction Details', 'event_espresso' ) . '">
38
-							View Transaction ' . $registration->transaction_ID() . '
35
+						$txn_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$registration->transaction_ID()), TXN_ADMIN_URL);
36
+						echo EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '
37
+						<a href="'.$txn_url.'" title="'.esc_attr__('View Transaction Details', 'event_espresso').'">
38
+							View Transaction ' . $registration->transaction_ID().'
39 39
 						</a>' : '';
40 40
 					?>
41 41
 					</td>
42
-					<td class="jst-left"><?php echo $registration->reg_code();?></td>
43
-					<td class="jst-rght"><?php echo EEH_Template::format_currency( $registration->final_price() );?></td>
42
+					<td class="jst-left"><?php echo $registration->reg_code(); ?></td>
43
+					<td class="jst-rght"><?php echo EEH_Template::format_currency($registration->final_price()); ?></td>
44 44
 				</tr>
45 45
 			<?php endforeach; ?>
46 46
 			</tbody>
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/help_tabs/import_page.help_tab.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,18 +2,18 @@
 block discarded – undo
2 2
 <p>
3 3
 <?php _e('The importer can be used to import event information into Event Espresso using a CSV file.', 'event_espresso'); ?>
4 4
 </p>
5
-<h3><?php _e("Importing from other Event Espresso 4 Sites", 'event_espresso');?></h3>
5
+<h3><?php _e("Importing from other Event Espresso 4 Sites", 'event_espresso'); ?></h3>
6 6
 <p>
7 7
 <?php _e('To import Event Espresso data from another Event Espresso 4 install, export a CSV file from the admin Events overview page, or anywhere you can generate a CSV export file from. Then upload that file here (regardless of what type of information was exported).', 'event_espresso'); ?>
8 8
 </p>
9 9
 <p>
10 10
 <?php _e('Note: its possible that data from the other site have the same IDs as data in this site. The importer recognizes that this data is from a different database and inserts new items for each item in the CSV file, regardless of whether its ID matches that of an item in this site\'s database or not. However, the importer also remembers the mapping from the old site\'s database to this site\'s database, and on subsequent CSV importers from that site, the data in this database will be updated instead of re-inserting new items.', 'event_espresso'); ?>
11 11
 </p>
12
-<h3><?php _e("Importing from this Site", 'event_espresso');?></h3>
13
-<p><?php _e("You may want to export data from this site, modify it (or modify the database), and re-import it. When this is done, the importer recognizes that the data is from this site\'s database and updates the records (instead of inserting new items like it would have, had the CSV data been from a different site).", 'event_espresso');?></p>
12
+<h3><?php _e("Importing from this Site", 'event_espresso'); ?></h3>
13
+<p><?php _e("You may want to export data from this site, modify it (or modify the database), and re-import it. When this is done, the importer recognizes that the data is from this site\'s database and updates the records (instead of inserting new items like it would have, had the CSV data been from a different site).", 'event_espresso'); ?></p>
14 14
 
15
-	<h3><?php _e("Notes about Generating your own CSV Import Files", "event_espresso");?></h3>
16
-	<p><?php _e("If you think you could save time entering data into a CSV file, you can use the sample import file below. Note that creating your own CSV file is more complicated than in Event Espresso 3.1 because of the more advanced data structure, and so we recommend creating/editing your events using the normal web-interface.", "event_espresso");?></p>
17
-	<p><?php _e("The export file is just an export of an event, or if you do not have any events in your system, it will only contain column headers. Do not change those column headers. Add as many rows as you like. ", "event_espresso");?></p>
18
-	<p><?php _e("In the ID columns (columns ending in '_ID'), you should enter 'temporary IDs', which are unique numbers/words that identify that item, which can be used later when you want to refer to that item. (For example, if you assign an event's EVT_ID to be a temporary id of 'my-event-1', then use that same phrase 'my-event-1' to refer to that event in the Datetime model's EVT_ID column)", "event_espresso");?></p>
19
-	<p><?php _e("Also note, you do NOT have to enter info in for each model. (You can, for example, only enter in Term_Taxonomies and Term model data)", "event_espresso");?></p>
20 15
\ No newline at end of file
16
+	<h3><?php _e("Notes about Generating your own CSV Import Files", "event_espresso"); ?></h3>
17
+	<p><?php _e("If you think you could save time entering data into a CSV file, you can use the sample import file below. Note that creating your own CSV file is more complicated than in Event Espresso 3.1 because of the more advanced data structure, and so we recommend creating/editing your events using the normal web-interface.", "event_espresso"); ?></p>
18
+	<p><?php _e("The export file is just an export of an event, or if you do not have any events in your system, it will only contain column headers. Do not change those column headers. Add as many rows as you like. ", "event_espresso"); ?></p>
19
+	<p><?php _e("In the ID columns (columns ending in '_ID'), you should enter 'temporary IDs', which are unique numbers/words that identify that item, which can be used later when you want to refer to that item. (For example, if you assign an event's EVT_ID to be a temporary id of 'my-event-1', then use that same phrase 'my-event-1' to refer to that event in the Datetime model's EVT_ID column)", "event_espresso"); ?></p>
20
+	<p><?php _e("Also note, you do NOT have to enter info in for each model. (You can, for example, only enter in Term_Taxonomies and Term model data)", "event_espresso"); ?></p>
21 21
\ No newline at end of file
Please login to merge, or discard this patch.
core/admin/EE_Admin_Hooks.core.php 1 patch
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * constructor
210 210
 	 * @param EE_Admin_Page $admin_page the calling admin_page_object
211 211
 	 */
212
-	public function __construct( EE_Admin_Page $adminpage ) {
212
+	public function __construct(EE_Admin_Page $adminpage) {
213 213
 
214 214
 		$this->_adminpage_obj = $adminpage;
215 215
 		$this->_req_data = array_merge($_GET, $_POST);
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 		$this->_set_hooks_properties();
218 218
 
219 219
 		//first let's verify we're on the right page
220
-		if ( !isset( $this->_req_data['page'] ) || ( isset( $this->_req_data['page'] ) && $this->_adminpage_obj->page_slug != $this->_req_data['page'] ) )
220
+		if ( ! isset($this->_req_data['page']) || (isset($this->_req_data['page']) && $this->_adminpage_obj->page_slug != $this->_req_data['page']))
221 221
 			return; //get out nothing more to be done here.
222 222
 
223 223
 		//allow for extends to modify properties
224
-		if ( method_exists( $this, '_extend_properties' ) )
224
+		if (method_exists($this, '_extend_properties'))
225 225
 			$this->_extend_properties();
226 226
 
227 227
 		$this->_set_page_object();
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
 		$this->_load_custom_methods();
230 230
 		$this->_load_routed_hooks();
231 231
 
232
-		add_action( 'admin_enqueue_scripts', array($this, 'enqueue_scripts_styles' ) );
233
-		add_action( 'admin_enqueue_scripts', array($this, 'add_metaboxes'), 20 );
234
-		add_action( 'admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15 );
232
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
233
+		add_action('admin_enqueue_scripts', array($this, 'add_metaboxes'), 20);
234
+		add_action('admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15);
235 235
 
236 236
 		$this->_ajax_hooks();
237 237
 
@@ -272,15 +272,15 @@  discard block
 block discarded – undo
272 272
 	 */
273 273
 	public function enqueue_scripts_styles() {
274 274
 
275
-		if ( !empty( $this->_scripts_styles ) ) {
275
+		if ( ! empty($this->_scripts_styles)) {
276 276
 			//first let's do all the registrations
277
-			if ( !isset($this->_scripts_styles['registers'] ) ) {
277
+			if ( ! isset($this->_scripts_styles['registers'])) {
278 278
 				$msg[] = __('There is no "registers" index in the <code>$this->_scripts_styles</code> property.', 'event_espresso');
279
-				$msg[] = sprintf ( __('Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child', 'event_espresso'), '<strong>' . $this->caller . '</strong>' );
280
-				throw new EE_Error( implode( '||', $msg ) );
279
+				$msg[] = sprintf(__('Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child', 'event_espresso'), '<strong>'.$this->caller.'</strong>');
280
+				throw new EE_Error(implode('||', $msg));
281 281
 			}
282 282
 
283
-			foreach( $this->_scripts_styles['registers'] as $ref => $details ) {
283
+			foreach ($this->_scripts_styles['registers'] as $ref => $details) {
284 284
 				$defaults = array(
285 285
 					'type' => 'js',
286 286
 					'url' => '',
@@ -289,48 +289,48 @@  discard block
 block discarded – undo
289 289
 					'footer' => TRUE
290 290
 					);
291 291
 				$details = wp_parse_args($details, $defaults);
292
-				extract( $details );
292
+				extract($details);
293 293
 
294 294
 				//let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do
295 295
 				$this->_scripts_styles['registers'][$ref]['type'] = $type;
296 296
 
297 297
 				//let's make sure we're not missing any REQUIRED parameters
298
-				if ( empty($url) ) {
299
-					$msg[] = sprintf( __('Missing the url for the requested %s', 'event_espresso'), $type == 'js' ? 'script' : 'stylesheet' );
300
-					$msg[] = sprintf( __('Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref', 'event_espresso'), '<strong>' . $this->caller . '</strong>', $ref );
301
-					throw new EE_Error( implode( '||', $msg ) );
298
+				if (empty($url)) {
299
+					$msg[] = sprintf(__('Missing the url for the requested %s', 'event_espresso'), $type == 'js' ? 'script' : 'stylesheet');
300
+					$msg[] = sprintf(__('Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref', 'event_espresso'), '<strong>'.$this->caller.'</strong>', $ref);
301
+					throw new EE_Error(implode('||', $msg));
302 302
 				}
303 303
 				//made it here so let's do the appropriate registration
304
-				$type == 'js' ? wp_register_script( $ref, $url, $depends, $version, $footer ) : wp_register_style( $ref, $url, $depends, $version );
304
+				$type == 'js' ? wp_register_script($ref, $url, $depends, $version, $footer) : wp_register_style($ref, $url, $depends, $version);
305 305
 			}
306 306
 
307 307
 			//k now lets do the enqueues
308
-			if( !isset( $this->_scripts_styles['enqueues'] ) )
309
-				return;  //not sure if we should throw an error here or not.
310
-			foreach( $this->_scripts_styles['enqueues'] as $ref => $routes ) {
308
+			if ( ! isset($this->_scripts_styles['enqueues']))
309
+				return; //not sure if we should throw an error here or not.
310
+			foreach ($this->_scripts_styles['enqueues'] as $ref => $routes) {
311 311
 				//make sure $routes is an array
312 312
 				$routes = (array) $routes;
313 313
 
314
-				if ( in_array($this->_current_route, $routes ) ) {
314
+				if (in_array($this->_current_route, $routes)) {
315 315
 					$this->_scripts_styles['registers'][$ref]['type'] == 'js' ? wp_enqueue_script($ref) : wp_enqueue_style($ref);
316 316
 					//if we have a localization for the script let's do that too.
317
-					if ( isset( $this->_scripts_styles['localize'][$ref] ) ) {
318
-						foreach ( $this->_scripts_styles['localize'][$ref] as $object_name => $indexes ) {
319
-							wp_localize_script($ref, $object_name , $this->_scripts_styles['localize'][$ref][$object_name] );
317
+					if (isset($this->_scripts_styles['localize'][$ref])) {
318
+						foreach ($this->_scripts_styles['localize'][$ref] as $object_name => $indexes) {
319
+							wp_localize_script($ref, $object_name, $this->_scripts_styles['localize'][$ref][$object_name]);
320 320
 						}
321 321
 					}
322 322
 				}
323 323
 			}
324 324
 
325 325
 			//let's do the deregisters
326
-			if ( !isset( $this->_scripts_styles['deregisters'] ) )
326
+			if ( ! isset($this->_scripts_styles['deregisters']))
327 327
 				return;
328
-			foreach ( $this->_scripts_styles['deregisters'] as $ref => $details ) {
328
+			foreach ($this->_scripts_styles['deregisters'] as $ref => $details) {
329 329
 				$defaults = array(
330 330
 					'type' => 'js'
331 331
 					);
332
-				$details = wp_parse_args( $details, $defaults );
333
-				extract( $details );
332
+				$details = wp_parse_args($details, $defaults);
333
+				extract($details);
334 334
 
335 335
 				$type == 'js' ? wp_deregister_script($ref) : wp_deregister_style($ref);
336 336
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 	 */
350 350
 	private function _set_defaults() {
351 351
 		$this->_ajax_func = $this->_init_func = $this->_metaboxes = $this->_scripts = $this->_styles = $this->_wp_action_filters_priority = array();
352
-		$this->_current_route = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'default';
352
+		$this->_current_route = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'default';
353 353
 		$this->caller = get_class($this);
354 354
 		$this->_extend = stripos($this->caller, 'Extend') ? TRUE : FALSE;
355 355
 	}
@@ -364,34 +364,34 @@  discard block
 block discarded – undo
364 364
 	 */
365 365
 	protected function _set_page_object() {
366 366
 		//first make sure $this->_name is set
367
-		if ( empty( $this->_name ) ) {
367
+		if (empty($this->_name)) {
368 368
 			$msg[] = __('We can\'t load the page object', 'event_espresso');
369
-			$msg[] = sprintf( __("This is because the %s child class has not set the '_name' property", 'event_espresso'), $this->caller );
370
-			throw new EE_Error( implode( '||', $msg ) );
369
+			$msg[] = sprintf(__("This is because the %s child class has not set the '_name' property", 'event_espresso'), $this->caller);
370
+			throw new EE_Error(implode('||', $msg));
371 371
 		}
372 372
 
373
-		$ref = str_replace('_' , ' ', $this->_name); //take the_message -> the message
374
-		$ref = str_replace(' ', '_', ucwords($ref) ) . '_Admin_Page'; //take the message -> The_Message
373
+		$ref = str_replace('_', ' ', $this->_name); //take the_message -> the message
374
+		$ref = str_replace(' ', '_', ucwords($ref)).'_Admin_Page'; //take the message -> The_Message
375 375
 
376 376
 		//first default file (if exists)
377
-		$decaf_file = EE_ADMIN_PAGES . $this->_name . DS . $ref . '.core.php';
378
-		if ( is_readable( $decaf_file ) )
379
-		require_once( $decaf_file );
377
+		$decaf_file = EE_ADMIN_PAGES.$this->_name.DS.$ref.'.core.php';
378
+		if (is_readable($decaf_file))
379
+		require_once($decaf_file);
380 380
 
381 381
 		//now we have to do require for extended file (if needed)
382
-		if ( $this->_extend ) {
383
-			require_once( EE_CORE_CAF_ADMIN_EXTEND . $this->_name . DS . 'Extend_' . $ref . '.core.php' );
382
+		if ($this->_extend) {
383
+			require_once(EE_CORE_CAF_ADMIN_EXTEND.$this->_name.DS.'Extend_'.$ref.'.core.php');
384 384
 		}
385 385
 
386 386
 
387 387
 		//if we've got an extended class we use that!
388
-		$ref = $this->_extend ? 'Extend_' . $ref : $ref;
388
+		$ref = $this->_extend ? 'Extend_'.$ref : $ref;
389 389
 
390 390
 		//let's make sure the class exists
391
-		if ( !class_exists( $ref ) ) {
391
+		if ( ! class_exists($ref)) {
392 392
 			$msg[] = __('We can\'t load the page object', 'event_espresso');
393
-			$msg[] = sprintf( __('The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class', 'event_espresso'), $ref );
394
-			throw new EE_Error( implode( '||', $msg ) );
393
+			$msg[] = sprintf(__('The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class', 'event_espresso'), $ref);
394
+			throw new EE_Error(implode('||', $msg));
395 395
 		}
396 396
 
397 397
 		$a = new ReflectionClass($ref);
@@ -416,27 +416,27 @@  discard block
 block discarded – undo
416 416
 		$method_callback = $this->_current_route == 'default' ? 'default_callback' : $this->_current_route;
417 417
 
418 418
 		//these run before the Admin_Page route executes.
419
-		if ( method_exists( $this, $method_callback ) ) {
420
-			call_user_func( array( $this, $method_callback) );
419
+		if (method_exists($this, $method_callback)) {
420
+			call_user_func(array($this, $method_callback));
421 421
 		}
422 422
 
423 423
 
424 424
 		//these run via the _redirect_after_action method in EE_Admin_Page which usually happens after non_UI methods in EE_Admin_Page classes.  There are two redirect actions, the first fires before $query_args might be manipulated by "save and close" actions and the seond fires right before the actual redirect happens.
425 425
 		//first the actions
426 426
 		//note that these action hooks will have the $query_args value available.
427
-		$admin_class_name = get_class( $this->_adminpage_obj );
427
+		$admin_class_name = get_class($this->_adminpage_obj);
428 428
 
429
-		if ( method_exists( $this, '_redirect_action_early_' . $this->_current_route ) ) {
430
-			add_action( 'AHEE__' . $admin_class_name . '___redirect_after_action__before_redirect_modification_' . $this->_current_route, array( $this, '_redirect_action_early_' . $this->_current_route ), 10 );
429
+		if (method_exists($this, '_redirect_action_early_'.$this->_current_route)) {
430
+			add_action('AHEE__'.$admin_class_name.'___redirect_after_action__before_redirect_modification_'.$this->_current_route, array($this, '_redirect_action_early_'.$this->_current_route), 10);
431 431
 		}
432 432
 
433
-		if ( method_exists( $this, '_redirect_action_' . $this->_current_route ) ) {
434
-			add_action( 'AHEE_redirect_' . $admin_class_name . $this->_current_route, array( $this, '_redirect_action_' . $this->_current_route ), 10 );
433
+		if (method_exists($this, '_redirect_action_'.$this->_current_route)) {
434
+			add_action('AHEE_redirect_'.$admin_class_name.$this->_current_route, array($this, '_redirect_action_'.$this->_current_route), 10);
435 435
 		}
436 436
 
437 437
 		//let's hook into the _redirect itself and allow for changing where the user goes after redirect.  This will have $query_args and $redirect_url available.
438
-		if ( method_exists( $this, '_redirect_filter_' . $this->_current_route ) ) {
439
-			add_filter( 'FHEE_redirect_' . $admin_class_name . $this->_current_route, array( $this, '_redirect_filter_' . $this->_current_route ), 10, 2 );
438
+		if (method_exists($this, '_redirect_filter_'.$this->_current_route)) {
439
+			add_filter('FHEE_redirect_'.$admin_class_name.$this->_current_route, array($this, '_redirect_filter_'.$this->_current_route), 10, 2);
440 440
 		}
441 441
 
442 442
 	}
@@ -459,12 +459,12 @@  discard block
 block discarded – undo
459 459
 				'argnum' => 1,
460 460
 				'priority' => 10
461 461
 				),
462
-			'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array(
462
+			'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug.'_'.$this->_current_route => array(
463 463
 				'type' => 'filter',
464 464
 				'argnum' => 1,
465 465
 				'priority' => 10
466 466
 				),
467
-			'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug => array(
467
+			'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug => array(
468 468
 				'type' => 'filter',
469 469
 				'argnum' => 1,
470 470
 				'priority' => 10
@@ -483,14 +483,14 @@  discard block
 block discarded – undo
483 483
 
484 484
 
485 485
 
486
-		foreach ( $hook_filter_array as $hook => $args ) {
487
-			if ( method_exists( $this, $this->_current_route . '_' . $hook ) ) {
488
-				if ( isset( $this->_wp_action_filters_priority[$hook] ) )
486
+		foreach ($hook_filter_array as $hook => $args) {
487
+			if (method_exists($this, $this->_current_route.'_'.$hook)) {
488
+				if (isset($this->_wp_action_filters_priority[$hook]))
489 489
 					$args['priority'] = $this->_wp_action_filters_priority[$hook];
490
-				if ( $args['type'] == 'action' )
491
-					add_action( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] );
490
+				if ($args['type'] == 'action')
491
+					add_action($hook, array($this, $this->_current_route.'_'.$hook), $args['priority'], $args['argnum']);
492 492
 				else
493
-					add_filter( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] );
493
+					add_filter($hook, array($this, $this->_current_route.'_'.$hook), $args['priority'], $args['argnum']);
494 494
 			}
495 495
 		}
496 496
 
@@ -503,18 +503,18 @@  discard block
 block discarded – undo
503 503
 	 */
504 504
 	private function _ajax_hooks() {
505 505
 
506
-		if ( empty( $this->_ajax_func) )
506
+		if (empty($this->_ajax_func))
507 507
 			return; //get out there's nothing to take care of.
508 508
 
509
-		foreach ( $this->_ajax_func as $action => $method ) {
509
+		foreach ($this->_ajax_func as $action => $method) {
510 510
 			//make sure method exists
511
-			if ( !method_exists($this, $method) ) {
512
-				$msg[] = __('There is no corresponding method for the hook labeled in the _ajax_func array', 'event_espresso') . '<br />';
513
-				$msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $method, $this->caller );
514
-				throw new EE_Error( implode('||', $msg ) );
511
+			if ( ! method_exists($this, $method)) {
512
+				$msg[] = __('There is no corresponding method for the hook labeled in the _ajax_func array', 'event_espresso').'<br />';
513
+				$msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $method, $this->caller);
514
+				throw new EE_Error(implode('||', $msg));
515 515
 			}
516 516
 
517
-			add_action('wp_ajax_' . $action, array( $this, $method ) );
517
+			add_action('wp_ajax_'.$action, array($this, $method));
518 518
 		}
519 519
 
520 520
 	}
@@ -527,21 +527,21 @@  discard block
 block discarded – undo
527 527
 	 * @return void
528 528
 	 */
529 529
 	protected function _init_hooks() {
530
-		if ( empty( $this->_init_func) )
530
+		if (empty($this->_init_func))
531 531
 			return; //get out there's nothing to take care of.
532 532
 
533 533
 		//We need to determine what page_route we are on!
534
-		$current_route = isset ( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'default';
534
+		$current_route = isset ($_REQUEST['action']) ? $_REQUEST['action'] : 'default';
535 535
 
536
-		foreach ( $this->_init_func as $route => $method ) {
536
+		foreach ($this->_init_func as $route => $method) {
537 537
 			//make sure method exists
538
-			if ( !method_exists($this, $method) ) {
539
-				$msg[] = __('There is no corresponding method for the hook labeled in the _init_func array', 'event_espresso') . '<br />';
540
-				$msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $method, $this->caller );
541
-				throw new EE_Error( implode('||', $msg ) );
538
+			if ( ! method_exists($this, $method)) {
539
+				$msg[] = __('There is no corresponding method for the hook labeled in the _init_func array', 'event_espresso').'<br />';
540
+				$msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $method, $this->caller);
541
+				throw new EE_Error(implode('||', $msg));
542 542
 			}
543
-			if ( $route == $this->_current_route )
544
-				add_action('admin_init', array( $this, $method ) );
543
+			if ($route == $this->_current_route)
544
+				add_action('admin_init', array($this, $method));
545 545
 		}
546 546
 
547 547
 	}
@@ -556,28 +556,28 @@  discard block
 block discarded – undo
556 556
 	 * @return void
557 557
 	 */
558 558
 	public function add_metaboxes() {
559
-		if ( empty( $this->_metaboxes ) )
559
+		if (empty($this->_metaboxes))
560 560
 			return; //get out we don't have any metaboxes to set for this connection
561 561
 
562
-		$this->_handle_metabox_array( $this->_metaboxes );
562
+		$this->_handle_metabox_array($this->_metaboxes);
563 563
 
564 564
 	}
565 565
 
566 566
 
567 567
 
568
-	private function _handle_metabox_array( $boxes, $add = TRUE ) {
568
+	private function _handle_metabox_array($boxes, $add = TRUE) {
569 569
 
570
-		foreach ( $boxes as $box ) {
571
-			if ( !isset($box['page_route']) )
570
+		foreach ($boxes as $box) {
571
+			if ( ! isset($box['page_route']))
572 572
 				continue; //we dont' have a valid array
573 573
 
574 574
 			//let's make sure $box['page_route'] is an array so the "foreach" will work.
575 575
 			$box['page_route'] = (array) $box['page_route'];
576 576
 
577
-			foreach ( $box['page_route'] as $route ) {
578
-				if ( $route != $this->_current_route )
577
+			foreach ($box['page_route'] as $route) {
578
+				if ($route != $this->_current_route)
579 579
 					continue; //get out we only add metaboxes for set route.
580
-				if ( $add )
580
+				if ($add)
581 581
 					$this->_add_metabox($box);
582 582
 				else
583 583
 					$this->_remove_metabox($box);
@@ -595,10 +595,10 @@  discard block
 block discarded – undo
595 595
 	 */
596 596
 	public function remove_metaboxes() {
597 597
 
598
-		if ( empty( $this->_remove_metaboxes ) )
598
+		if (empty($this->_remove_metaboxes))
599 599
 			return; //get out there are no metaboxes to remove
600 600
 
601
-		$this->_handle_metabox_array( $this->_remove_metaboxes, FALSE );
601
+		$this->_handle_metabox_array($this->_remove_metaboxes, FALSE);
602 602
 	}
603 603
 
604 604
 
@@ -608,53 +608,53 @@  discard block
 block discarded – undo
608 608
 	 * @access private
609 609
 	 * @param array $args an array of args that have been set for this metabox by the child class
610 610
 	 */
611
-	private function _add_metabox( $args ) {
611
+	private function _add_metabox($args) {
612 612
 		$current_screen = get_current_screen();
613
-		$screen_id = is_object( $current_screen ) ? $current_screen->id : NULL;
614
-		$func = isset( $args['func'] ) ? $args['func'] : 'some_invalid_callback';
613
+		$screen_id = is_object($current_screen) ? $current_screen->id : NULL;
614
+		$func = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
615 615
 
616 616
 		//set defaults
617 617
 		$defaults = array(
618 618
 			'func' => $func,
619
-			'id' => $this->caller . '_' . $func . '_metabox',
619
+			'id' => $this->caller.'_'.$func.'_metabox',
620 620
 			'priority' => 'default',
621 621
 			'label' => $this->caller,
622 622
 			'context' => 'advanced',
623 623
 			'callback_args' => array(),
624
-			'page' => isset( $args['page'] ) ? $args['page'] : $screen_id
624
+			'page' => isset($args['page']) ? $args['page'] : $screen_id
625 625
 			);
626 626
 
627
-		$args = wp_parse_args( $args, $defaults );
627
+		$args = wp_parse_args($args, $defaults);
628 628
 		extract($args);
629 629
 
630 630
 
631 631
 		//make sure method exists
632
-		if ( !method_exists($this, $func) ) {
633
-			$msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />';
634
-			$msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $func, $this->caller );
635
-			throw new EE_Error( implode('||', $msg ) );
632
+		if ( ! method_exists($this, $func)) {
633
+			$msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso').'<br />';
634
+			$msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $func, $this->caller);
635
+			throw new EE_Error(implode('||', $msg));
636 636
 		}
637 637
 
638 638
 		//everything checks out so lets add the metabox
639
-		add_meta_box( $id, $label, array( $this, $func ), $page, $context, $priority, $callback_args);
639
+		add_meta_box($id, $label, array($this, $func), $page, $context, $priority, $callback_args);
640 640
 	}
641 641
 
642 642
 
643 643
 
644
-	private function _remove_metabox( $args ) {
644
+	private function _remove_metabox($args) {
645 645
 		$current_screen = get_current_screen();
646
-		$screen_id = is_object( $current_screen ) ? $current_screen->id : NULL;
647
-		$func = isset( $args['func'] ) ? $args['func'] : 'some_invalid_callback';
646
+		$screen_id = is_object($current_screen) ? $current_screen->id : NULL;
647
+		$func = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
648 648
 
649 649
 		//set defaults
650 650
 		$defaults = array(
651
-			'id' => isset( $args['id'] ) ? $args['id'] : $this->_current_route . '_' . $this->caller . '_' . $func . '_metabox',
651
+			'id' => isset($args['id']) ? $args['id'] : $this->_current_route.'_'.$this->caller.'_'.$func.'_metabox',
652 652
 			'context' => 'default',
653
-			'screen' => isset( $args['screen'] ) ? $args['screen'] : $screen_id
653
+			'screen' => isset($args['screen']) ? $args['screen'] : $screen_id
654 654
 		);
655 655
 
656
-		$args = wp_parse_args( $args, $defaults );
657
-		extract( $args );
656
+		$args = wp_parse_args($args, $defaults);
657
+		extract($args);
658 658
 
659 659
 		//everything checks out so lets remove the box!
660 660
 		remove_meta_box($id, $screen, $context);
Please login to merge, or discard this patch.
core/business/EE_Transaction_Processor.class.php 1 patch
Spacing   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
-EE_Registry::instance()->load_class( 'Processor_Base' );
2
+EE_Registry::instance()->load_class('Processor_Base');
3 3
 
4 4
 /**
5 5
  * Class EE_Transaction_Processor
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 	 * @param array $registration_query_params
51 51
 	 *@return EE_Transaction_Processor instance
52 52
 	 */
53
-	public static function instance( $registration_query_params = array() ) {
53
+	public static function instance($registration_query_params = array()) {
54 54
 		// check if class object is instantiated
55
-		if ( ! self::$_instance instanceof EE_Transaction_Processor ) {
56
-			self::$_instance = new self( $registration_query_params );
55
+		if ( ! self::$_instance instanceof EE_Transaction_Processor) {
56
+			self::$_instance = new self($registration_query_params);
57 57
 		}
58 58
 		return self::$_instance;
59 59
 	}
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 	 * @param array $registration_query_params
65 65
 	 * @return EE_Transaction_Processor
66 66
 	 */
67
-	private function __construct( $registration_query_params = array() ) {
67
+	private function __construct($registration_query_params = array()) {
68 68
 		// make sure some query params are set for retrieving registrations
69
-		$this->_set_registration_query_params( $registration_query_params );
69
+		$this->_set_registration_query_params($registration_query_params);
70 70
 	}
71 71
 
72 72
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	 * @access private
76 76
 	 * @param array $registration_query_params
77 77
 	 */
78
-	private function _set_registration_query_params( $registration_query_params ) {
79
-		$this->_registration_query_params = ! empty( $registration_query_params ) ? $registration_query_params : array( 'order_by' => array( 'REG_count' => 'ASC' ));
78
+	private function _set_registration_query_params($registration_query_params) {
79
+		$this->_registration_query_params = ! empty($registration_query_params) ? $registration_query_params : array('order_by' => array('REG_count' => 'ASC'));
80 80
 	}
81 81
 
82 82
 
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
 	/**
94 94
 	 * @param string $old_txn_status
95 95
 	 */
96
-	public function set_old_txn_status( $old_txn_status ) {
96
+	public function set_old_txn_status($old_txn_status) {
97 97
 		// only set the first time
98
-		if ( $this->_old_txn_status === null ) {
98
+		if ($this->_old_txn_status === null) {
99 99
 			$this->_old_txn_status = $old_txn_status;
100 100
 		}
101 101
 	}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	/**
115 115
 	 * @param string $new_txn_status
116 116
 	 */
117
-	public function set_new_txn_status( $new_txn_status ) {
117
+	public function set_new_txn_status($new_txn_status) {
118 118
 		$this->_new_txn_status = $new_txn_status;
119 119
 	}
120 120
 
@@ -145,17 +145,17 @@  discard block
 block discarded – undo
145 145
 	 * @param bool   $check_all
146 146
 	 * @return boolean | int
147 147
 	 */
148
-	private function _reg_steps_completed( EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE ) {
148
+	private function _reg_steps_completed(EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE) {
149 149
 		$reg_steps = $transaction->reg_steps();
150
-		if ( ! is_array( $reg_steps ) || empty( $reg_steps )) {
150
+		if ( ! is_array($reg_steps) || empty($reg_steps)) {
151 151
 			return false;
152 152
 		}
153 153
 		// loop thru reg steps array)
154
-		foreach ( $reg_steps as $slug => $reg_step_completed ) {
154
+		foreach ($reg_steps as $slug => $reg_step_completed) {
155 155
 			// if NOT checking ALL steps (only checking one step)
156
-			if ( ! $check_all ) {
156
+			if ( ! $check_all) {
157 157
 				// and this is the one
158
-				if ( $slug == $reg_step_slug ) {
158
+				if ($slug == $reg_step_slug) {
159 159
 					return $reg_step_completed;
160 160
 				} else {
161 161
 					// skip to next reg step in loop
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 				}
164 164
 			}
165 165
 			// if any reg step is NOT completed (ignoring any specific steps), then just leave
166
-			if ( $reg_step_completed !== true && $slug != $reg_step_slug ) {
166
+			if ($reg_step_completed !== true && $slug != $reg_step_slug) {
167 167
 				return false;
168
-			} else if ( $slug == $reg_step_slug ) {
168
+			} else if ($slug == $reg_step_slug) {
169 169
 				// if we reach this point, then we are testing either:
170 170
 				// all_reg_steps_completed_except() or
171 171
 				// all_reg_steps_completed_except_final_step(),
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 	 * @param EE_Transaction $transaction
191 191
 	 * @return boolean
192 192
 	 */
193
-	public function all_reg_steps_completed( EE_Transaction $transaction ) {
194
-		return $this->_reg_steps_completed( $transaction );
193
+	public function all_reg_steps_completed(EE_Transaction $transaction) {
194
+		return $this->_reg_steps_completed($transaction);
195 195
 	}
196 196
 
197 197
 
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 * @param string $exception
209 209
 	 * @return boolean
210 210
 	 */
211
-	public function all_reg_steps_completed_except( EE_Transaction $transaction, $exception = '' ) {
212
-		return $this->_reg_steps_completed( $transaction, $exception );
211
+	public function all_reg_steps_completed_except(EE_Transaction $transaction, $exception = '') {
212
+		return $this->_reg_steps_completed($transaction, $exception);
213 213
 	}
214 214
 
215 215
 
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 	 * @param EE_Transaction $transaction
226 226
 	 * @return boolean
227 227
 	 */
228
-	public function all_reg_steps_completed_except_final_step( EE_Transaction $transaction ) {
229
-		return $this->_reg_steps_completed( $transaction, 'finalize_registration' );
228
+	public function all_reg_steps_completed_except_final_step(EE_Transaction $transaction) {
229
+		return $this->_reg_steps_completed($transaction, 'finalize_registration');
230 230
 	}
231 231
 
232 232
 
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 	 * @param string $reg_step_slug
244 244
 	 * @return boolean | int
245 245
 	 */
246
-	public function reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) {
247
-		return $this->_reg_steps_completed( $transaction, $reg_step_slug, FALSE );
246
+	public function reg_step_completed(EE_Transaction $transaction, $reg_step_slug) {
247
+		return $this->_reg_steps_completed($transaction, $reg_step_slug, FALSE);
248 248
 	}
249 249
 
250 250
 
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 	 * @param EE_Transaction $transaction
261 261
 	 * @return boolean | int
262 262
 	 */
263
-	public function final_reg_step_completed( EE_Transaction $transaction ) {
264
-		return $this->_reg_steps_completed( $transaction, 'finalize_registration', FALSE );
263
+	public function final_reg_step_completed(EE_Transaction $transaction) {
264
+		return $this->_reg_steps_completed($transaction, 'finalize_registration', FALSE);
265 265
 	}
266 266
 
267 267
 
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 	 * @param string          $reg_step_slug
276 276
 	 * @return boolean
277 277
 	 */
278
-	public function set_reg_step_initiated( EE_Transaction $transaction, $reg_step_slug ) {
278
+	public function set_reg_step_initiated(EE_Transaction $transaction, $reg_step_slug) {
279 279
 		$current_time = time();
280
-		return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, $current_time );
280
+		return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, $current_time);
281 281
 	}
282 282
 
283 283
 
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
 	 * @param string          $reg_step_slug
292 292
 	 * @return boolean
293 293
 	 */
294
-	public function set_reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) {
295
-		return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, TRUE );
294
+	public function set_reg_step_completed(EE_Transaction $transaction, $reg_step_slug) {
295
+		return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, TRUE);
296 296
 	}
297 297
 
298 298
 
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
 	 * @param string          $reg_step_slug
307 307
 	 * @return boolean
308 308
 	 */
309
-	public function set_reg_step_not_completed( EE_Transaction $transaction, $reg_step_slug ) {
310
-		return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, FALSE );
309
+	public function set_reg_step_not_completed(EE_Transaction $transaction, $reg_step_slug) {
310
+		return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, FALSE);
311 311
 	}
312 312
 
313 313
 
@@ -323,36 +323,36 @@  discard block
 block discarded – undo
323 323
 	 * @param boolean | int $status
324 324
 	 * @return boolean
325 325
 	 */
326
-	private function _set_reg_step_completed_status( EE_Transaction $transaction, $reg_step_slug, $status ) {
326
+	private function _set_reg_step_completed_status(EE_Transaction $transaction, $reg_step_slug, $status) {
327 327
 		// validate status
328
-		$status = is_bool( $status ) || is_numeric( $status ) ? $status : false;
328
+		$status = is_bool($status) || is_numeric($status) ? $status : false;
329 329
 		// get reg steps array
330 330
 		$txn_reg_steps = $transaction->reg_steps();
331 331
 		// if reg step does NOT exist
332
-		if ( ! isset( $txn_reg_steps[ $reg_step_slug ] )) {
332
+		if ( ! isset($txn_reg_steps[$reg_step_slug])) {
333 333
 			return false;
334 334
 		}
335 335
 		// if  we're trying to complete a step that is already completed
336
-		if ( $txn_reg_steps[ $reg_step_slug ] === true ) {
336
+		if ($txn_reg_steps[$reg_step_slug] === true) {
337 337
 			return true;
338 338
 		}
339 339
 		// if  we're trying to complete a step that hasn't even started
340
-		if ( $status === true && $txn_reg_steps[ $reg_step_slug ] === false ) {
340
+		if ($status === true && $txn_reg_steps[$reg_step_slug] === false) {
341 341
 			return false;
342 342
 		}
343 343
 		// if current status value matches the incoming value (no change)
344
-		if ( $txn_reg_steps[ $reg_step_slug ] === $status ) {
344
+		if ($txn_reg_steps[$reg_step_slug] === $status) {
345 345
 			// this will happen in cases where multiple AJAX requests occur during the same step
346 346
 			return true;
347 347
 		}
348 348
 		// if we're trying to set a start time
349
-		if ( is_numeric( $status ) && is_numeric( $txn_reg_steps[ $reg_step_slug ] )) {
349
+		if (is_numeric($status) && is_numeric($txn_reg_steps[$reg_step_slug])) {
350 350
 			// skip the update below, but don't return FALSE so that errors won't be displayed
351 351
 			return true;
352 352
 		}
353 353
 		// update completed status
354
-		$txn_reg_steps[ $reg_step_slug ] = $status;
355
-		$transaction->set_reg_steps( $txn_reg_steps );
354
+		$txn_reg_steps[$reg_step_slug] = $status;
355
+		$transaction->set_reg_steps($txn_reg_steps);
356 356
 		$transaction->save();
357 357
 		// DEBUG LOG
358 358
 		//$this->log(
@@ -378,11 +378,11 @@  discard block
 block discarded – undo
378 378
 	 * @param string $reg_step_slug
379 379
 	 * @return void
380 380
 	 */
381
-	public function remove_reg_step( EE_Transaction $transaction, $reg_step_slug ) {
381
+	public function remove_reg_step(EE_Transaction $transaction, $reg_step_slug) {
382 382
 		// get reg steps array
383 383
 		$txn_reg_steps = $transaction->reg_steps();
384
-		unset( $txn_reg_steps[ $reg_step_slug ] );
385
-		$transaction->set_reg_steps( $txn_reg_steps );
384
+		unset($txn_reg_steps[$reg_step_slug]);
385
+		$transaction->set_reg_steps($txn_reg_steps);
386 386
 	}
387 387
 
388 388
 
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
 	 * @param EE_Transaction $transaction
397 397
 	 * 	@return 	boolean
398 398
 	 */
399
-	public function toggle_failed_transaction_status( EE_Transaction $transaction ) {
399
+	public function toggle_failed_transaction_status(EE_Transaction $transaction) {
400 400
 		// set incoming TXN_Status
401
-		$this->set_old_txn_status( $transaction->status_ID() );
401
+		$this->set_old_txn_status($transaction->status_ID());
402 402
 		// if TXN status is still set as "failed"...
403
-		if ( $transaction->status_ID() == EEM_Transaction::failed_status_code ) {
403
+		if ($transaction->status_ID() == EEM_Transaction::failed_status_code) {
404 404
 			// set incoming TXN_Status
405
-			$this->set_new_txn_status( EEM_Transaction::abandoned_status_code );
406
-			$transaction->set_status( EEM_Transaction::abandoned_status_code );
405
+			$this->set_new_txn_status(EEM_Transaction::abandoned_status_code);
406
+			$transaction->set_status(EEM_Transaction::abandoned_status_code);
407 407
 			return TRUE;
408 408
 		}
409 409
 		return FALSE;
@@ -419,20 +419,20 @@  discard block
 block discarded – undo
419 419
 	 * @param EE_Transaction $transaction
420 420
 	 * 	@return 	boolean
421 421
 	 */
422
-	public function toggle_abandoned_transaction_status( EE_Transaction $transaction ) {
422
+	public function toggle_abandoned_transaction_status(EE_Transaction $transaction) {
423 423
 		// set incoming TXN_Status
424
-		$this->set_old_txn_status( $transaction->status_ID() );
424
+		$this->set_old_txn_status($transaction->status_ID());
425 425
 		// if TXN status has not been updated already due to a payment, and is still set as "failed" or "abandoned"...
426
-		if ( $transaction->status_ID() == EEM_Transaction::failed_status_code || $transaction->status_ID() == EEM_Transaction::abandoned_status_code ) {
427
-			$this->set_new_txn_status( EEM_Transaction::incomplete_status_code );
426
+		if ($transaction->status_ID() == EEM_Transaction::failed_status_code || $transaction->status_ID() == EEM_Transaction::abandoned_status_code) {
427
+			$this->set_new_txn_status(EEM_Transaction::incomplete_status_code);
428 428
 			// if a contact record for the primary registrant has been created
429
-			if ( $transaction->primary_registration() instanceof EE_Registration && $transaction->primary_registration()->attendee() instanceof EE_Attendee ) {
430
-				$transaction->set_status( EEM_Transaction::incomplete_status_code );
431
-				$this->set_new_txn_status( EEM_Transaction::incomplete_status_code );
429
+			if ($transaction->primary_registration() instanceof EE_Registration && $transaction->primary_registration()->attendee() instanceof EE_Attendee) {
430
+				$transaction->set_status(EEM_Transaction::incomplete_status_code);
431
+				$this->set_new_txn_status(EEM_Transaction::incomplete_status_code);
432 432
 			} else {
433 433
 				// no contact record? yer abandoned!
434
-				$transaction->set_status( EEM_Transaction::abandoned_status_code );
435
-				$this->set_new_txn_status( EEM_Transaction::abandoned_status_code );
434
+				$transaction->set_status(EEM_Transaction::abandoned_status_code);
435
+				$this->set_new_txn_status(EEM_Transaction::abandoned_status_code);
436 436
 			}
437 437
 			return TRUE;
438 438
 		}
@@ -450,16 +450,16 @@  discard block
 block discarded – undo
450 450
 	 * @param array 	$registration_query_params - array of query WHERE params to use when retrieving cached registrations from a transaction
451 451
 	 * 	@return 	boolean
452 452
 	 */
453
-	public function manually_update_registration_statuses( EE_Transaction $transaction, $new_reg_status = '', $registration_query_params = array() ) {
454
-		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor( 'manually_update_registration_status', $transaction, $registration_query_params, $new_reg_status );
453
+	public function manually_update_registration_statuses(EE_Transaction $transaction, $new_reg_status = '', $registration_query_params = array()) {
454
+		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor('manually_update_registration_status', $transaction, $registration_query_params, $new_reg_status);
455 455
 		// send messages
456 456
 		/** @type EE_Registration_Processor $registration_processor */
457
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
457
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
458 458
 		$registration_processor->trigger_registration_update_notifications(
459 459
 			$transaction->primary_registration(),
460
-			array( 'manually_updated' 	=> true )
460
+			array('manually_updated' 	=> true)
461 461
 		);
462
-		do_action( 'AHEE__EE_Transaction_Processor__manually_update_registration_statuses', $transaction, $status_updates );
462
+		do_action('AHEE__EE_Transaction_Processor__manually_update_registration_statuses', $transaction, $status_updates);
463 463
 		return $status_updates;
464 464
 	}
465 465
 
@@ -473,9 +473,9 @@  discard block
 block discarded – undo
473 473
 	 * @param array 	$registration_query_params - array of query WHERE params to use when retrieving cached registrations from a transaction
474 474
 	 * 	@return 	boolean
475 475
 	 */
476
-	public function toggle_registration_statuses_for_default_approved_events( EE_Transaction $transaction, $registration_query_params = array() ) {
477
-		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor( 'toggle_registration_status_for_default_approved_events', $transaction, $registration_query_params );
478
-		do_action( 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events', $transaction, $status_updates );
476
+	public function toggle_registration_statuses_for_default_approved_events(EE_Transaction $transaction, $registration_query_params = array()) {
477
+		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor('toggle_registration_status_for_default_approved_events', $transaction, $registration_query_params);
478
+		do_action('AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events', $transaction, $status_updates);
479 479
 		return $status_updates;
480 480
 	}
481 481
 
@@ -489,9 +489,9 @@  discard block
 block discarded – undo
489 489
 	 * @param array 	$registration_query_params - array of query WHERE params to use when retrieving cached registrations from a transaction
490 490
 	 * 	@return 	boolean
491 491
 	 */
492
-	public function toggle_registration_statuses_if_no_monies_owing( EE_Transaction $transaction, $registration_query_params = array() ) {
493
-		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor( 'toggle_registration_status_if_no_monies_owing', $transaction, $registration_query_params );
494
-		do_action( 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing', $transaction, $status_updates );
492
+	public function toggle_registration_statuses_if_no_monies_owing(EE_Transaction $transaction, $registration_query_params = array()) {
493
+		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor('toggle_registration_status_if_no_monies_owing', $transaction, $registration_query_params);
494
+		do_action('AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing', $transaction, $status_updates);
495 495
 		return $status_updates;
496 496
 	}
497 497
 
@@ -507,17 +507,17 @@  discard block
 block discarded – undo
507 507
 	 * @throws \EE_Error
508 508
 	 * @return array
509 509
 	 */
510
-	public function update_transaction_and_registrations_after_checkout_or_payment( EE_Transaction $transaction, $payment = NULL, $registration_query_params = array() ) {
510
+	public function update_transaction_and_registrations_after_checkout_or_payment(EE_Transaction $transaction, $payment = NULL, $registration_query_params = array()) {
511 511
 		// set incoming TXN_Status, and consider it new since old status should have been set
512
-		$this->set_new_txn_status( $transaction->status_ID() );
513
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()' );
512
+		$this->set_new_txn_status($transaction->status_ID());
513
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()');
514 514
 		// make sure some query params are set for retrieving registrations
515
-		$this->_set_registration_query_params( $registration_query_params );
515
+		$this->_set_registration_query_params($registration_query_params);
516 516
 		// get final reg step status
517
-		$finalized = $this->final_reg_step_completed( $transaction );
517
+		$finalized = $this->final_reg_step_completed($transaction);
518 518
 		// if the 'finalize_registration' step has been initiated (has a timestamp) but has not yet been fully completed (TRUE)
519
-		if ( is_numeric( $finalized ) && $finalized !== true ) {
520
-			$this->set_reg_step_completed( $transaction, 'finalize_registration' );
519
+		if (is_numeric($finalized) && $finalized !== true) {
520
+			$this->set_reg_step_completed($transaction, 'finalize_registration');
521 521
 			$finalized = true;
522 522
 		}
523 523
 		$transaction->save();
@@ -540,13 +540,13 @@  discard block
 block discarded – undo
540 540
 
541 541
 		// send messages
542 542
 		/** @type EE_Registration_Processor $registration_processor */
543
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
543
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
544 544
 		$registration_processor->trigger_registration_update_notifications(
545 545
 			$transaction->primary_registration(),
546 546
 			$update_params
547 547
 		);
548 548
 
549
-		do_action( 'AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment', $transaction, $update_params );
549
+		do_action('AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment', $transaction, $update_params);
550 550
 		return $update_params;
551 551
 	}
552 552
 
@@ -564,23 +564,23 @@  discard block
 block discarded – undo
564 564
 	 * @throws \EE_Error
565 565
 	 * @return boolean
566 566
 	 */
567
-	private function _call_method_on_registrations_via_Registration_Processor( $method_name,  EE_Transaction $transaction, $registration_query_params = array(), $additional_param = NULL ) {
567
+	private function _call_method_on_registrations_via_Registration_Processor($method_name, EE_Transaction $transaction, $registration_query_params = array(), $additional_param = NULL) {
568 568
 		$response = FALSE;
569 569
 		/** @type EE_Registration_Processor $registration_processor */
570
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
570
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
571 571
 		// check that method exists
572
-		if ( ! method_exists( $registration_processor, $method_name )) {
573
-			throw new EE_Error( __( 'Method does not exist.', 'event_espresso' ));
572
+		if ( ! method_exists($registration_processor, $method_name)) {
573
+			throw new EE_Error(__('Method does not exist.', 'event_espresso'));
574 574
 		}
575 575
 		// make sure some query params are set for retrieving registrations
576
-		$this->_set_registration_query_params( $registration_query_params );
576
+		$this->_set_registration_query_params($registration_query_params);
577 577
 		// loop through cached registrations
578
-		foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) {
579
-			if ( $registration instanceof EE_Registration ) {
580
-				if ( $additional_param ) {
581
-					$response = $registration_processor->$method_name( $registration, $additional_param ) ? TRUE : $response;
578
+		foreach ($transaction->registrations($this->_registration_query_params) as $registration) {
579
+			if ($registration instanceof EE_Registration) {
580
+				if ($additional_param) {
581
+					$response = $registration_processor->$method_name($registration, $additional_param) ? TRUE : $response;
582 582
 				} else {
583
-					$response = $registration_processor->$method_name( $registration ) ? TRUE : $response;
583
+					$response = $registration_processor->$method_name($registration) ? TRUE : $response;
584 584
 				}
585 585
 			}
586 586
 		}
@@ -605,46 +605,46 @@  discard block
 block discarded – undo
605 605
 	public function set_transaction_payment_method_based_on_registration_statuses(
606 606
 		EE_Registration $edited_registration
607 607
 	) {
608
-		if ( $edited_registration instanceof EE_Registration ) {
608
+		if ($edited_registration instanceof EE_Registration) {
609 609
 			$transaction = $edited_registration->transaction();
610
-			if ( $transaction instanceof EE_Transaction ) {
610
+			if ($transaction instanceof EE_Transaction) {
611 611
 				$all_not_approved = true;
612
-				foreach ( $transaction->registrations() as $registration ) {
613
-					if ( $registration instanceof EE_Registration ) {
612
+				foreach ($transaction->registrations() as $registration) {
613
+					if ($registration instanceof EE_Registration) {
614 614
 						// if any REG != "Not Approved" then toggle to false
615 615
 						$all_not_approved = $registration->is_not_approved() ? $all_not_approved : false;
616 616
 					}
617 617
 				}
618 618
 				// if ALL Registrations are "Not Approved"
619
-				if ( $all_not_approved ) {
620
-					$transaction->set_payment_method_ID( null );
619
+				if ($all_not_approved) {
620
+					$transaction->set_payment_method_ID(null);
621 621
 					$transaction->save();
622 622
 				} else {
623
-					$available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart );
624
-					if ( ! empty( $available_payment_methods ) ) {
623
+					$available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart);
624
+					if ( ! empty($available_payment_methods)) {
625 625
 						$PMD_ID = 0;
626
-						foreach ( $available_payment_methods as $available_payment_method ) {
627
-							if ( $available_payment_method instanceof EE_Payment_Method && $available_payment_method->open_by_default() ) {
626
+						foreach ($available_payment_methods as $available_payment_method) {
627
+							if ($available_payment_method instanceof EE_Payment_Method && $available_payment_method->open_by_default()) {
628 628
 								$PMD_ID = $available_payment_method->ID();
629 629
 								break;
630 630
 							}
631 631
 						}
632
-						if ( ! $PMD_ID ) {
633
-							$first_payment_method = reset( $available_payment_methods );
634
-							if ( $first_payment_method instanceof EE_Payment_Method ) {
632
+						if ( ! $PMD_ID) {
633
+							$first_payment_method = reset($available_payment_methods);
634
+							if ($first_payment_method instanceof EE_Payment_Method) {
635 635
 								$PMD_ID = $first_payment_method->ID();
636 636
 							} else {
637 637
 								EE_Error::add_error(
638
-									__( 'A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso' ),
638
+									__('A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso'),
639 639
 									__FILE__, __LINE__, __FUNCTION__
640 640
 								);
641 641
 							}
642 642
 						}
643
-						$transaction->set_payment_method_ID( $PMD_ID );
643
+						$transaction->set_payment_method_ID($PMD_ID);
644 644
 						$transaction->save();
645 645
 					} else {
646 646
 						EE_Error::add_error(
647
-							__( 'Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso' ),
647
+							__('Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso'),
648 648
 							__FILE__, __LINE__, __FUNCTION__
649 649
 						);
650 650
 					}
Please login to merge, or discard this patch.