Completed
Branch BUG-9623-config-log (c144cd)
by
unknown
110:09 queued 92:18
created
core/libraries/messages/EE_Messages_Generator.lib.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -458,8 +458,8 @@  discard block
 block discarded – undo
458 458
 		//if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because that means this
459 459
 		//context is turned off) EXCEPT if we're previewing
460 460
 		if ( empty( $templates['to'][ $context ] )
461
-		     && ! $this->_generation_queue->get_message_repository()->is_preview()
462
-		     && ! $this->_current_messenger->allow_empty_to_field() ) {
461
+			 && ! $this->_generation_queue->get_message_repository()->is_preview()
462
+			 && ! $this->_current_messenger->allow_empty_to_field() ) {
463 463
 			//we silently exit here and do NOT record a fail because the message is "turned off" by having no "to" field.
464 464
 			return false;
465 465
 		}
@@ -575,9 +575,9 @@  discard block
 block discarded – undo
575 575
 		 * Check if there is any generation data, but only if this is not for a preview.
576 576
 		 */
577 577
 		if ( ! $this->_generation_queue->get_message_repository()->get_generation_data()
578
-		     && (
579
-			     ! $this->_generation_queue->get_message_repository()->is_preview()
580
-			     && $this->_generation_queue->get_message_repository()->get_data_handler() !== 'EE_Messages_Preview_incoming_data' )
578
+			 && (
579
+				 ! $this->_generation_queue->get_message_repository()->is_preview()
580
+				 && $this->_generation_queue->get_message_repository()->get_data_handler() !== 'EE_Messages_Preview_incoming_data' )
581 581
 		) {
582 582
 			$this->_error_msg[] = __( 'There is no generation data for this message. Unable to generate.' );
583 583
 		}
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); }
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
 
3 3
 /**
4 4
  * This class is used for generating EE_Message objects with given info.
@@ -116,17 +116,17 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @return EE_Messages_Queue  The new queue for holding generated EE_Message objects.
118 118
 	 */
119
-	public function generate( $save = true ) {
119
+	public function generate($save = true) {
120 120
 		//iterate through the messages in the queue, generate, and add to new queue.
121 121
 		$this->_generation_queue->get_message_repository()->rewind();
122
-		while ( $this->_generation_queue->get_message_repository()->valid() ) {
122
+		while ($this->_generation_queue->get_message_repository()->valid()) {
123 123
 			//reset "current" properties
124 124
 			$this->_reset_current_properties();
125 125
 
126 126
 			/** @type EE_Message $msg */
127 127
 			$msg = $this->_generation_queue->get_message_repository()->current();
128 128
 
129
-			if ( $this->_verify() ) {
129
+			if ($this->_verify()) {
130 130
 				//let's get generating!
131 131
 				$this->_generate();
132 132
 			}
@@ -138,26 +138,26 @@  discard block
 block discarded – undo
138 138
 			$this->_generation_queue->get_message_repository()->next();
139 139
 			$next_msg = $this->_generation_queue->get_message_repository()->current();
140 140
 			//restore pointer to current item
141
-			$this->_generation_queue->get_message_repository()->set_current( $msg );
141
+			$this->_generation_queue->get_message_repository()->set_current($msg);
142 142
 
143 143
 			//if there are error messages then let's set the status and the error message.
144
-			if ( $this->_error_msg ) {
144
+			if ($this->_error_msg) {
145 145
 				//if the status is already debug only, then let's leave it at that.
146
-				if ( $msg->STS_ID() !== EEM_Message::status_debug_only ) {
147
-					$msg->set_STS_ID( EEM_Message::status_failed );
146
+				if ($msg->STS_ID() !== EEM_Message::status_debug_only) {
147
+					$msg->set_STS_ID(EEM_Message::status_failed);
148 148
 				}
149 149
 				$msg->set_error_message(
150
-					__( 'Message failed to generate for the following reasons: ' )
150
+					__('Message failed to generate for the following reasons: ')
151 151
 					. "\n"
152
-					. implode( "\n", $this->_error_msg )
152
+					. implode("\n", $this->_error_msg)
153 153
 				);
154
-				$msg->set_modified( time() );
154
+				$msg->set_modified(time());
155 155
 			} else {
156 156
 				//remove from db
157 157
 				$this->_generation_queue->get_message_repository()->delete();
158 158
 			}
159 159
 			//next item
160
-			$this->_generation_queue->get_message_repository()->set_current( $next_msg );
160
+			$this->_generation_queue->get_message_repository()->set_current($next_msg);
161 161
 		}
162 162
 
163 163
 		//generation queue is ALWAYS saved to record any errors in the generation process.
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		 * so a EE_Extra_Meta entry could be created and attached to the EE_Message.  In those cases the save flag is
171 171
 		 * irrelevant.
172 172
 		 */
173
-		if ( $save ) {
173
+		if ($save) {
174 174
 			$this->_ready_queue->save();
175 175
 		}
176 176
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	protected function _reset_current_properties() {
189 189
 		$this->_verified = false;
190 190
 		//make sure any _data value in the current message type is reset
191
-		if ( $this->_current_message_type instanceof EE_message_type ) {
191
+		if ($this->_current_message_type instanceof EE_message_type) {
192 192
 			$this->_current_message_type->reset_data();
193 193
 		}
194 194
 		$this->_current_messenger = $this->_current_message_type = $this->_current_data_handler = null;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	protected function _generate() {
209 209
 		//double check verification has run and that everything is ready to work with (saves us having to validate everything again).
210
-		if ( ! $this->_verified ) {
210
+		if ( ! $this->_verified) {
211 211
 			return false; //get out because we don't have a valid setup to work with.
212 212
 		}
213 213
 
@@ -217,34 +217,34 @@  discard block
 block discarded – undo
217 217
 				$this->_current_data_handler,
218 218
 				$this->_generation_queue->get_message_repository()->current()->context()
219 219
 			);
220
-		} catch ( EE_Error $e ) {
220
+		} catch (EE_Error $e) {
221 221
 			$this->_error_msg[] = $e->getMessage();
222 222
 			return false;
223 223
 		}
224 224
 
225 225
 
226 226
 		//if no addressees then get out because there is nothing to generation (possible bad data).
227
-		if ( ! $this->_valid_addressees( $addressees ) ) {
228
-			$this->_generation_queue->get_message_repository()->current()->set_STS_ID( EEM_Message::status_debug_only );
229
-			$this->_error_msg[] = __( 'This is not a critical error but an informational notice. Unable to generate messages EE_Messages_Addressee objects.  There were no attendees prepared by the data handler.
230
-			  Sometimes this is because messages only get generated for certain registration statuses. For example, the ticket notice message type only goes to approved registrations.', 'event_espresso' );
227
+		if ( ! $this->_valid_addressees($addressees)) {
228
+			$this->_generation_queue->get_message_repository()->current()->set_STS_ID(EEM_Message::status_debug_only);
229
+			$this->_error_msg[] = __('This is not a critical error but an informational notice. Unable to generate messages EE_Messages_Addressee objects.  There were no attendees prepared by the data handler.
230
+			  Sometimes this is because messages only get generated for certain registration statuses. For example, the ticket notice message type only goes to approved registrations.', 'event_espresso');
231 231
 			return false;
232 232
 		}
233 233
 
234 234
 		$message_template_group = $this->_get_message_template_group();
235 235
 
236 236
 		//in the unlikely event there is no EE_Message_Template_Group available, get out!
237
-		if ( ! $message_template_group instanceof EE_Message_Template_Group ) {
238
-			$this->_error_msg[] = __( 'Unable to get the Message Templates for the Message being generated.  No message template group accessible.', 'event_espresso' );
237
+		if ( ! $message_template_group instanceof EE_Message_Template_Group) {
238
+			$this->_error_msg[] = __('Unable to get the Message Templates for the Message being generated.  No message template group accessible.', 'event_espresso');
239 239
 			return false;
240 240
 		}
241 241
 
242 242
 		//get formatted templates for using to parse and setup EE_Message objects.
243
-		$templates = $this->_get_templates( $message_template_group );
243
+		$templates = $this->_get_templates($message_template_group);
244 244
 
245 245
 
246 246
 		//setup new EE_Message objects (and add to _ready_queue)
247
-		return $this->_assemble_messages( $addressees, $templates, $message_template_group );
247
+		return $this->_assemble_messages($addressees, $templates, $message_template_group);
248 248
 	}
249 249
 
250 250
 
@@ -262,17 +262,17 @@  discard block
 block discarded – undo
262 262
 		//so let's use that.
263 263
 		$GRP_ID = $this->_generation_queue->get_message_repository()->current()->GRP_ID();
264 264
 
265
-		if ( $GRP_ID ) {
265
+		if ($GRP_ID) {
266 266
 			//attempt to retrieve from repo first
267
-			$GRP = $this->_template_collection->get_by_ID( $GRP_ID );
268
-			if ( $GRP instanceof EE_Message_Template_Group ) {
269
-				return $GRP;  //got it!
267
+			$GRP = $this->_template_collection->get_by_ID($GRP_ID);
268
+			if ($GRP instanceof EE_Message_Template_Group) {
269
+				return $GRP; //got it!
270 270
 			}
271 271
 
272 272
 			//nope don't have it yet.  Get from DB then add to repo
273
-			$GRP = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
274
-			if ( $GRP instanceof EE_Message_Template_Group ) {
275
-				$this->_template_collection->add( $GRP );
273
+			$GRP = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
274
+			if ($GRP instanceof EE_Message_Template_Group) {
275
+				$this->_template_collection->add($GRP);
276 276
 			}
277 277
 			return $GRP;
278 278
 		}
@@ -291,41 +291,41 @@  discard block
 block discarded – undo
291 291
 		//in vanilla EE we're assuming there's only one event.
292 292
 		//However, if there are multiple events then we'll just use the default templates instead of different
293 293
 		// templates per event (which could create problems).
294
-		if ( count( $this->_current_data_handler->events ) === 1 ) {
295
-			foreach ( $this->_current_data_handler->events as $event ) {
294
+		if (count($this->_current_data_handler->events) === 1) {
295
+			foreach ($this->_current_data_handler->events as $event) {
296 296
 				$EVT_ID = $event['ID'];
297 297
 			}
298 298
 		}
299 299
 
300 300
 		//before going any further, let's see if its in the queue
301
-		$GRP = $this->_template_collection->get_by_key( $this->_template_collection->get_key( $this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID ) );
301
+		$GRP = $this->_template_collection->get_by_key($this->_template_collection->get_key($this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID));
302 302
 
303
-		if ( $GRP instanceof EE_Message_Template_Group ) {
303
+		if ($GRP instanceof EE_Message_Template_Group) {
304 304
 			return $GRP;
305 305
 		}
306 306
 
307 307
 		//nope still no GRP?
308 308
 		//first we get the global template in case it has an override set.
309
-		$global_template_qa = array_merge( array( 'MTP_is_global' => true ), $template_qa );
310
-		$global_GRP = EEM_Message_Template_Group::instance()->get_one( array( $global_template_qa ) );
309
+		$global_template_qa = array_merge(array('MTP_is_global' => true), $template_qa);
310
+		$global_GRP = EEM_Message_Template_Group::instance()->get_one(array($global_template_qa));
311 311
 
312 312
 		//if this is an override, then we just return it.
313
-		if ( $global_GRP instanceof EE_Message_Template_Group && $global_GRP->get( 'MTP_is_override' ) ) {
314
-			$this->_template_collection->add( $global_GRP, $EVT_ID );
313
+		if ($global_GRP instanceof EE_Message_Template_Group && $global_GRP->get('MTP_is_override')) {
314
+			$this->_template_collection->add($global_GRP, $EVT_ID);
315 315
 			return $global_GRP;
316 316
 		}
317 317
 
318 318
 		//STILL here? Okay that means we want to see if there is event specific group and if there is we return it,
319 319
 		//otherwise we return the global group we retrieved.
320
-		if ( $EVT_ID ) {
320
+		if ($EVT_ID) {
321 321
 			$template_qa['Event.EVT_ID'] = $EVT_ID;
322 322
 		}
323 323
 
324
-		$GRP = EEM_Message_Template_Group::instance()->get_one( array( $template_qa ) );
324
+		$GRP = EEM_Message_Template_Group::instance()->get_one(array($template_qa));
325 325
 		$GRP = $GRP instanceof EE_Message_Template_Group ? $GRP : $global_GRP;
326 326
 
327
-		if ( $GRP instanceof EE_Message_Template_Group ) {
328
-			$this->_template_collection->add( $GRP, $EVT_ID );
327
+		if ($GRP instanceof EE_Message_Template_Group) {
328
+			$this->_template_collection->add($GRP, $EVT_ID);
329 329
 			return $GRP;
330 330
 		}
331 331
 
@@ -349,15 +349,15 @@  discard block
 block discarded – undo
349 349
 	 *                      )
350 350
 	 *                  )
351 351
 	 */
352
-	protected function _get_templates( EE_Message_Template_Group $message_template_group ) {
352
+	protected function _get_templates(EE_Message_Template_Group $message_template_group) {
353 353
 		$templates = array();
354 354
 		$context_templates = $message_template_group->context_templates();
355
-		foreach ( $context_templates as $context => $template_fields ) {
356
-			foreach ( $template_fields as $template_field => $template_obj ) {
357
-				if ( ! $template_obj instanceof EE_Message_Template ) {
355
+		foreach ($context_templates as $context => $template_fields) {
356
+			foreach ($template_fields as $template_field => $template_obj) {
357
+				if ( ! $template_obj instanceof EE_Message_Template) {
358 358
 					continue;
359 359
 				}
360
-				$templates[ $template_field ][ $context ] = $template_obj->get( 'MTP_content' );
360
+				$templates[$template_field][$context] = $template_obj->get('MTP_content');
361 361
 			}
362 362
 		}
363 363
 		return $templates;
@@ -379,20 +379,20 @@  discard block
 block discarded – undo
379 379
 	 *                get added to the queue with EEM_Message::status_idle, unsuccessfully generated messages will get added
380 380
 	 *                to the queue as EEM_Message::status_failed.  Very rarely should "false" be returned from this method.
381 381
 	 */
382
-	protected function _assemble_messages( $addressees, $templates, EE_Message_Template_Group $message_template_group ) {
382
+	protected function _assemble_messages($addressees, $templates, EE_Message_Template_Group $message_template_group) {
383 383
 
384 384
 		//if templates are empty then get out because we can't generate anything.
385
-		if ( ! $templates ) {
385
+		if ( ! $templates) {
386 386
 			return false;
387 387
 		}
388 388
 
389 389
 		//We use this as the counter for generated messages because don't forget we may be executing this inside of a
390 390
 		//generation_queue.  So _ready_queue may have generated EE_Message objects already.
391 391
 		$generated_count = 0;
392
-		foreach ( $addressees as $context => $recipients ) {
393
-			foreach ( $recipients as $recipient ) {
394
-				$message = $this->_setup_message_object( $context, $recipient, $templates, $message_template_group );
395
-				if ( $message instanceof EE_Message ) {
392
+		foreach ($addressees as $context => $recipients) {
393
+			foreach ($recipients as $recipient) {
394
+				$message = $this->_setup_message_object($context, $recipient, $templates, $message_template_group);
395
+				if ($message instanceof EE_Message) {
396 396
 					$this->_ready_queue->add(
397 397
 						$message,
398 398
 						array(),
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 				}
404 404
 
405 405
 				//if the current MSG being generated is for a test send then we'll only use ONE message in the generation.
406
-				if ( $this->_generation_queue->get_message_repository()->is_test_send() ) {
406
+				if ($this->_generation_queue->get_message_repository()->is_test_send()) {
407 407
 					break 2;
408 408
 				}
409 409
 			}
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 	) {
433 433
 		//stuff we already know
434 434
 		$transaction_id = $recipient->txn instanceof EE_Transaction ? $recipient->txn->ID() : 0;
435
-		$transaction_id = empty( $transaction_id ) && $this->_current_data_handler->txn instanceof EE_Transaction
435
+		$transaction_id = empty($transaction_id) && $this->_current_data_handler->txn instanceof EE_Transaction
436 436
 			? $this->_current_data_handler->txn->ID()
437 437
 			: $transaction_id;
438 438
 		$message_fields = array(
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 
446 446
 		//recipient id and type should be on the EE_Messages_Addressee object but if this is empty, let's try to grab the
447 447
 		//info from the att_obj found in the EE_Messages_Addressee object.
448
-		if ( empty( $recipient->recipient_id ) || empty( $recipient->recipient_type ) ) {
448
+		if (empty($recipient->recipient_id) || empty($recipient->recipient_type)) {
449 449
 			$message_fields['MSG_recipient_ID'] = $recipient->att_obj instanceof EE_Attendee
450 450
 				? $recipient->att_obj->ID()
451 451
 				: 0;
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 			$message_fields['MSG_recipient_ID'] = $recipient->recipient_id;
455 455
 			$message_fields['MSG_recipient_type'] = $recipient->recipient_type;
456 456
 		}
457
-		$message = EE_Message_Factory::create( $message_fields );
457
+		$message = EE_Message_Factory::create($message_fields);
458 458
 
459 459
 		//grab valid shortcodes for shortcode parser
460 460
 		$mt_shortcodes = $this->_current_message_type->get_valid_shortcodes();
@@ -462,43 +462,43 @@  discard block
 block discarded – undo
462 462
 
463 463
 		//if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because that means this
464 464
 		//context is turned off) EXCEPT if we're previewing
465
-		if ( empty( $templates['to'][ $context ] )
465
+		if (empty($templates['to'][$context])
466 466
 		     && ! $this->_generation_queue->get_message_repository()->is_preview()
467
-		     && ! $this->_current_messenger->allow_empty_to_field() ) {
467
+		     && ! $this->_current_messenger->allow_empty_to_field()) {
468 468
 			//we silently exit here and do NOT record a fail because the message is "turned off" by having no "to" field.
469 469
 			return false;
470 470
 		}
471 471
 		$error_msg = array();
472
-		foreach ( $templates as $field => $field_context ) {
472
+		foreach ($templates as $field => $field_context) {
473 473
 			$error_msg = array();
474 474
 			//let's setup the valid shortcodes for the incoming context.
475
-			$valid_shortcodes = $mt_shortcodes[ $context ];
475
+			$valid_shortcodes = $mt_shortcodes[$context];
476 476
 			//merge in valid shortcodes for the field.
477
-			$shortcodes = isset($m_shortcodes[ $field ]) ? $m_shortcodes[ $field ] : $valid_shortcodes;
478
-			if ( isset( $templates[ $field ][ $context ] ) ) {
477
+			$shortcodes = isset($m_shortcodes[$field]) ? $m_shortcodes[$field] : $valid_shortcodes;
478
+			if (isset($templates[$field][$context])) {
479 479
 				//prefix field.
480
-				$column_name = 'MSG_' . $field;
480
+				$column_name = 'MSG_'.$field;
481 481
 				try {
482 482
 					$content = $this->_shortcode_parser->parse_message_template(
483
-						$templates[ $field ][ $context ],
483
+						$templates[$field][$context],
484 484
 						$recipient,
485 485
 						$shortcodes,
486 486
 						$this->_current_message_type,
487 487
 						$this->_current_messenger,
488 488
 						$message );
489
-					$message->set_field_or_extra_meta( $column_name, $content );
490
-				} catch ( EE_Error $e ) {
491
-					$error_msg[] = sprintf( __( 'There was a problem generating the content for the field %s: %s', 'event_espresso' ), $field, $e->getMessage() );
492
-					$message->set_STS_ID( EEM_Message::status_failed );
489
+					$message->set_field_or_extra_meta($column_name, $content);
490
+				} catch (EE_Error $e) {
491
+					$error_msg[] = sprintf(__('There was a problem generating the content for the field %s: %s', 'event_espresso'), $field, $e->getMessage());
492
+					$message->set_STS_ID(EEM_Message::status_failed);
493 493
 				}
494 494
 			}
495 495
 		}
496 496
 
497
-		if ( $message->STS_ID() === EEM_Message::status_failed ) {
498
-			$error_msg = __( 'There were problems generating this message:', 'event_espresso' ) . "\n" . implode( "\n", $error_msg );
499
-			$message->set_error_message( $error_msg );
497
+		if ($message->STS_ID() === EEM_Message::status_failed) {
498
+			$error_msg = __('There were problems generating this message:', 'event_espresso')."\n".implode("\n", $error_msg);
499
+			$message->set_error_message($error_msg);
500 500
 		} else {
501
-			$message->set_STS_ID( EEM_Message::status_idle );
501
+			$message->set_STS_ID(EEM_Message::status_idle);
502 502
 		}
503 503
 		return $message;
504 504
 	}
@@ -532,14 +532,14 @@  discard block
 block discarded – undo
532 532
 	 * @param array $addressees  Keys correspond to contexts for the message type and values are EE_Messages_Addressee[]
533 533
 	 * @return bool
534 534
 	 */
535
-	protected function _valid_addressees( $addressees ) {
536
-		if ( ! $addressees || ! is_array( $addressees ) ) {
535
+	protected function _valid_addressees($addressees) {
536
+		if ( ! $addressees || ! is_array($addressees)) {
537 537
 			return false;
538 538
 		}
539 539
 
540
-		foreach( $addressees as $addressee_array ) {
541
-			foreach ( $addressee_array as $addressee ) {
542
-				if ( ! $addressee instanceof EE_Messages_Addressee ) {
540
+		foreach ($addressees as $addressee_array) {
541
+			foreach ($addressee_array as $addressee) {
542
+				if ( ! $addressee instanceof EE_Messages_Addressee) {
543 543
 					return false;
544 544
 				}
545 545
 			}
@@ -560,19 +560,19 @@  discard block
 block discarded – undo
560 560
 	protected function _validate_messenger_and_message_type() {
561 561
 
562 562
 		//first are there any existing error messages?  If so then return.
563
-		if ( $this->_error_msg ) {
563
+		if ($this->_error_msg) {
564 564
 			return false;
565 565
 		}
566 566
 		/** @type EE_Message $message */
567 567
 		$message = $this->_generation_queue->get_message_repository()->current();
568 568
 		try {
569
-			$this->_current_messenger = $message->valid_messenger( true ) ? $message->messenger_object() : null;
570
-		} catch ( Exception $e ) {
569
+			$this->_current_messenger = $message->valid_messenger(true) ? $message->messenger_object() : null;
570
+		} catch (Exception $e) {
571 571
 			$this->_error_msg[] = $e->getMessage();
572 572
 		}
573 573
 		try {
574
-			$this->_current_message_type = $message->valid_message_type( true ) ? $message->message_type_object() : null;
575
-		} catch ( Exception $e ) {
574
+			$this->_current_message_type = $message->valid_message_type(true) ? $message->message_type_object() : null;
575
+		} catch (Exception $e) {
576 576
 			$this->_error_msg[] = $e->getMessage();
577 577
 		}
578 578
 
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
 			     ! $this->_generation_queue->get_message_repository()->is_preview()
585 585
 			     && $this->_generation_queue->get_message_repository()->get_data_handler() !== 'EE_Messages_Preview_incoming_data' )
586 586
 		) {
587
-			$this->_error_msg[] = __( 'There is no generation data for this message. Unable to generate.' );
587
+			$this->_error_msg[] = __('There is no generation data for this message. Unable to generate.');
588 588
 		}
589 589
 
590
-		return empty( $this->_error_msg );
590
+		return empty($this->_error_msg);
591 591
 	}
592 592
 
593 593
 
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 
605 605
 		//First, are there any existing error messages?  If so, return because if there were errors elsewhere this can't
606 606
 		//be used anyways.
607
-		if ( $this->_error_msg ) {
607
+		if ($this->_error_msg) {
608 608
 			return false;
609 609
 		}
610 610
 
@@ -613,29 +613,29 @@  discard block
 block discarded – undo
613 613
 		/** @type EE_Messages_incoming_data $data_handler_class_name - well not really... just the class name actually */
614 614
 		$data_handler_class_name = $this->_generation_queue->get_message_repository()->get_data_handler()
615 615
 			? $this->_generation_queue->get_message_repository()->get_data_handler()
616
-			: 'EE_Messages_' .  $this->_current_message_type->get_data_handler( $generation_data ) . '_incoming_data';
616
+			: 'EE_Messages_'.$this->_current_message_type->get_data_handler($generation_data).'_incoming_data';
617 617
 
618 618
 		//If this EE_Message is for a preview, then let's switch out to the preview data handler.
619
-		if ( $this->_generation_queue->get_message_repository()->is_preview() ) {
620
-			$data_handler_class_name  = 'EE_Messages_Preview_incoming_data';
619
+		if ($this->_generation_queue->get_message_repository()->is_preview()) {
620
+			$data_handler_class_name = 'EE_Messages_Preview_incoming_data';
621 621
 		}
622 622
 
623 623
 		//First get the class name for the data handler (and also verifies it exists.
624
-		if ( ! class_exists( $data_handler_class_name ) ) {
624
+		if ( ! class_exists($data_handler_class_name)) {
625 625
 			$this->_error_msg[] = sprintf(
626
-				__( 'The included data handler class name does not match any valid, accessible, "EE_Messages_incoming_data" classes.  Looking for %s.', 'event_espresso' ),
626
+				__('The included data handler class name does not match any valid, accessible, "EE_Messages_incoming_data" classes.  Looking for %s.', 'event_espresso'),
627 627
 				$data_handler_class_name
628 628
 			);
629 629
 			return false;
630 630
 		}
631 631
 
632 632
 		//convert generation_data for data_handler_instantiation.
633
-		$generation_data = $data_handler_class_name::convert_data_from_persistent_storage( $generation_data );
633
+		$generation_data = $data_handler_class_name::convert_data_from_persistent_storage($generation_data);
634 634
 
635 635
 		//note, this may set error messages as well.
636
-		$this->_set_data_handler( $generation_data, $data_handler_class_name );
636
+		$this->_set_data_handler($generation_data, $data_handler_class_name);
637 637
 
638
-		return empty( $this->_error_msg );
638
+		return empty($this->_error_msg);
639 639
 	}
640 640
 
641 641
 
@@ -652,16 +652,16 @@  discard block
 block discarded – undo
652 652
 	 *
653 653
 	 * @return void.
654 654
 	 */
655
-	protected function _set_data_handler( $generating_data, $data_handler_class_name ) {
655
+	protected function _set_data_handler($generating_data, $data_handler_class_name) {
656 656
 		//valid classname for the data handler.  Now let's setup the key for the data handler repository to see if there
657 657
 		//is already a ready data handler in the repository.
658
-		$this->_current_data_handler = $this->_data_handler_collection->get_by_key( $this->_data_handler_collection->get_key( $data_handler_class_name, $generating_data ) );
659
-		if ( ! $this->_current_data_handler instanceof EE_messages_incoming_data ) {
658
+		$this->_current_data_handler = $this->_data_handler_collection->get_by_key($this->_data_handler_collection->get_key($data_handler_class_name, $generating_data));
659
+		if ( ! $this->_current_data_handler instanceof EE_messages_incoming_data) {
660 660
 			//no saved data_handler in the repo so let's set one up and add it to the repo.
661 661
 			try {
662
-				$this->_current_data_handler = new $data_handler_class_name( $generating_data );
663
-				$this->_data_handler_collection->add( $this->_current_data_handler, $generating_data );
664
-			} catch( EE_Error $e ) {
662
+				$this->_current_data_handler = new $data_handler_class_name($generating_data);
663
+				$this->_data_handler_collection->add($this->_current_data_handler, $generating_data);
664
+			} catch (EE_Error $e) {
665 665
 				$this->_error_msg[] = $e->get_error();
666 666
 			}
667 667
 		}
@@ -681,13 +681,13 @@  discard block
 block discarded – undo
681 681
 	 * @param bool                   $preview Indicate whether this is being used for a preview or not.
682 682
 	 * @return mixed Prepped data for persisting to the queue.  false is returned if unable to prep data.
683 683
 	 */
684
-	protected function _prepare_data_for_queue( EE_Message_To_Generate $message_to_generate, $preview ) {
684
+	protected function _prepare_data_for_queue(EE_Message_To_Generate $message_to_generate, $preview) {
685 685
 		/** @type EE_Messages_incoming_data $data_handler - well not really... just the class name actually */
686
-		$data_handler = $message_to_generate->get_data_handler_class_name( $preview );
687
-		if ( ! $message_to_generate->valid() ) {
686
+		$data_handler = $message_to_generate->get_data_handler_class_name($preview);
687
+		if ( ! $message_to_generate->valid()) {
688 688
 			return false; //unable to get the data because the info in the EE_Message_To_Generate class is invalid.
689 689
 		}
690
-		return $data_handler::convert_data_for_persistent_storage( $message_to_generate->data() );
690
+		return $data_handler::convert_data_for_persistent_storage($message_to_generate->data());
691 691
 	}
692 692
 
693 693
 
@@ -700,26 +700,26 @@  discard block
 block discarded – undo
700 700
 	 * @param EE_Message_To_Generate $message_to_generate
701 701
 	 * @param bool                   $test_send Whether this is just a test send or not.  Typically used for previews.
702 702
 	 */
703
-	public function create_and_add_message_to_queue( EE_Message_To_Generate $message_to_generate, $test_send = false ) {
703
+	public function create_and_add_message_to_queue(EE_Message_To_Generate $message_to_generate, $test_send = false) {
704 704
 		//prep data
705
-		$data = $this->_prepare_data_for_queue( $message_to_generate, $message_to_generate->preview() );
705
+		$data = $this->_prepare_data_for_queue($message_to_generate, $message_to_generate->preview());
706 706
 
707 707
 		$message = $message_to_generate->get_EE_Message();
708 708
 
709 709
 		//is there a GRP_ID in the request?
710
-		if ( $GRP_ID = EE_Registry::instance()->REQ->get( 'GRP_ID' ) ) {
711
-			$message->set_GRP_ID( $GRP_ID );
710
+		if ($GRP_ID = EE_Registry::instance()->REQ->get('GRP_ID')) {
711
+			$message->set_GRP_ID($GRP_ID);
712 712
 		}
713 713
 
714
-		if ( $data === false ) {
715
-			$message->set_STS_ID( EEM_Message::status_failed );
716
-			$message->set_error_message( __( 'Unable to prepare data for persistence to the database.', 'event_espresso' ) );
714
+		if ($data === false) {
715
+			$message->set_STS_ID(EEM_Message::status_failed);
716
+			$message->set_error_message(__('Unable to prepare data for persistence to the database.', 'event_espresso'));
717 717
 		} else {
718 718
 			//make sure that the data handler is cached on the message as well
719 719
 			$data['data_handler_class_name'] = $message_to_generate->get_data_handler_class_name();
720 720
 		}
721 721
 
722
-		$this->_generation_queue->add( $message, $data, $message_to_generate->preview(), $test_send );
722
+		$this->_generation_queue->add($message, $data, $message_to_generate->preview(), $test_send);
723 723
 	}
724 724
 
725 725
 
Please login to merge, or discard this patch.
form_sections/strategies/display/EE_Checkbox_Display_Strategy.strategy.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -18,42 +18,42 @@
 block discarded – undo
18 18
 	 * @throws EE_Error
19 19
 	 * @return string of html to display the field
20 20
 	 */
21
-	public function display(){
21
+	public function display() {
22 22
 		$input = $this->get_input();
23 23
 		//d( $input );
24
-		$multi = count( $input->options() ) > 1 ? TRUE : FALSE;
24
+		$multi = count($input->options()) > 1 ? TRUE : FALSE;
25 25
 		$input->set_label_sizes();
26 26
 		$label_size_class = $input->get_label_size_class();
27 27
 		$html = '';
28
-		if ( ! is_array( $input->raw_value() ) && $input->raw_value() !== NULL ) {
28
+		if ( ! is_array($input->raw_value()) && $input->raw_value() !== NULL) {
29 29
 			EE_Error::doing_it_wrong(
30 30
 				'EE_Checkbox_Display_Strategy::display()',
31 31
 				sprintf(
32
-					__( 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'),
32
+					__('Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'),
33 33
 					$input->html_id(),
34
-					var_export( $input->raw_value(), true),
35
-					$input->html_name() . '[]'
34
+					var_export($input->raw_value(), true),
35
+					$input->html_name().'[]'
36 36
 				),
37 37
 				'4.8.1'
38 38
 			);
39 39
 		}
40
-		$input_raw_value = (array)$input->raw_value();
41
-		foreach( $input->options() as $value => $display_text ){
42
-			$value = $input->get_normalization_strategy()->unnormalize_one( $value );
43
-			$html_id = $multi ? $this->get_sub_input_id( $value ) : $input->html_id();
44
-			$html .= EEH_HTML::nl( 0, 'checkbox' );
45
-			$html .= '<label for="' . $html_id . '" id="' . $html_id . '-lbl" class="ee-checkbox-label-after' . $label_size_class . '">';
46
-			$html .= EEH_HTML::nl( 1, 'checkbox' );
40
+		$input_raw_value = (array) $input->raw_value();
41
+		foreach ($input->options() as $value => $display_text) {
42
+			$value = $input->get_normalization_strategy()->unnormalize_one($value);
43
+			$html_id = $multi ? $this->get_sub_input_id($value) : $input->html_id();
44
+			$html .= EEH_HTML::nl(0, 'checkbox');
45
+			$html .= '<label for="'.$html_id.'" id="'.$html_id.'-lbl" class="ee-checkbox-label-after'.$label_size_class.'">';
46
+			$html .= EEH_HTML::nl(1, 'checkbox');
47 47
 			$html .= '<input type="checkbox"';
48
-			$html .= ' name="' . $input->html_name() . '[]"';
49
-			$html .= ' id="' . $html_id . '"';
50
-			$html .= ' class="' . $input->html_class() . '"';
51
-			$html .= ' style="' . $input->html_style() . '"';
52
-			$html .= ' value="' . esc_attr( $value ) . '"';
53
-			$html .= ! empty( $input_raw_value ) && in_array( $value, $input_raw_value ) ? ' checked="checked"' : '';
48
+			$html .= ' name="'.$input->html_name().'[]"';
49
+			$html .= ' id="'.$html_id.'"';
50
+			$html .= ' class="'.$input->html_class().'"';
51
+			$html .= ' style="'.$input->html_style().'"';
52
+			$html .= ' value="'.esc_attr($value).'"';
53
+			$html .= ! empty($input_raw_value) && in_array($value, $input_raw_value) ? ' checked="checked"' : '';
54 54
 			$html .= '>&nbsp;';
55 55
 			$html .= $display_text;
56
-			$html .= EEH_HTML::nl( -1, 'checkbox' ) . '</label>';
56
+			$html .= EEH_HTML::nl( -1, 'checkbox' ).'</label>';
57 57
 		}
58 58
 		return $html;
59 59
 	}
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Form_Input_Base.input.php 2 patches
Braces   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 					$this->html_id()
244 244
 				)
245 245
 			);
246
-		}else{
246
+		} else{
247 247
 			return $this->_display_strategy;
248 248
 		}
249 249
 	}
@@ -458,14 +458,14 @@  discard block
 block discarded – undo
458 458
 			if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
459 459
 				try{
460 460
 					$validation_strategy->validate($this->normalized_value());
461
-				}catch(EE_Validation_Error $e){
461
+				} catch(EE_Validation_Error $e){
462 462
 					$this->add_validation_error($e);
463 463
 				}
464 464
 			}
465 465
 		}
466 466
 		if( $this->get_validation_errors()){
467 467
 			return false;
468
-		}else{
468
+		} else{
469 469
 			return true;
470 470
 		}
471 471
 	}
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 		if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){
829 829
 			$name_parts = $matches[ 1 ];
830 830
 			array_unshift($name_parts, $before_any_brackets);
831
-		}else{
831
+		} else{
832 832
 			$name_parts = array( $before_any_brackets );
833 833
 		}
834 834
 		// now get the value for the input
@@ -853,13 +853,13 @@  discard block
 block discarded – undo
853 853
 		if( isset( $req_data[ $first_part_to_consider ] ) ){
854 854
 			if( empty($html_name_parts ) ){
855 855
 				return $req_data[ $first_part_to_consider ];
856
-			}else{
856
+			} else{
857 857
 				return $this->_find_form_data_for_this_section_using_name_parts(
858 858
 					$html_name_parts,
859 859
 					$req_data[ $first_part_to_consider ]
860 860
 				);
861 861
 			}
862
-		}else{
862
+		} else{
863 863
 			return NULL;
864 864
 		}
865 865
 	}
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 		$checked_value = $this->find_form_data_for_this_section( $req_data );
881 881
 		if( $checked_value !== null ){
882 882
 			return TRUE;
883
-		}else{
883
+		} else{
884 884
 			return FALSE;
885 885
 		}
886 886
 	}
Please login to merge, or discard this patch.
Spacing   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage
9 9
  * @author				Mike Nelson
10 10
  */
11
-abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{
11
+abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable {
12 12
 
13 13
 	/**
14 14
 	 * the input's name attribute
@@ -143,54 +143,54 @@  discard block
 block discarded – undo
143 143
 	 *  @type EE_Validation_Strategy_Base[]  $validation_strategies
144 144
 	 * }
145 145
 	 */
146
-	public function __construct( $input_args = array() ){
147
-		$input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this );
146
+	public function __construct($input_args = array()) {
147
+		$input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this);
148 148
 		// the following properties must be cast as arrays
149
-		if ( isset( $input_args['validation_strategies'] ) ) {
150
-			foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) {
151
-				if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
152
-					$this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy;
149
+		if (isset($input_args['validation_strategies'])) {
150
+			foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
151
+				if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
152
+					$this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy;
153 153
 				}
154 154
 			}
155
-			unset( $input_args['validation_strategies'] );
155
+			unset($input_args['validation_strategies']);
156 156
 		}
157 157
 		// loop thru incoming options
158
-		foreach( $input_args as $key => $value ) {
158
+		foreach ($input_args as $key => $value) {
159 159
 			// add underscore to $key to match property names
160
-			$_key = '_' . $key;
161
-			if ( property_exists( $this, $_key )) {
160
+			$_key = '_'.$key;
161
+			if (property_exists($this, $_key)) {
162 162
 				$this->{$_key} = $value;
163 163
 			}
164 164
 		}
165 165
 		// ensure that "required" is set correctly
166 166
 		$this->set_required(
167
-			$this->_required, isset( $input_args[ 'required_validation_error_message' ] )
168
-				? $input_args[ 'required_validation_error_message' ]
167
+			$this->_required, isset($input_args['required_validation_error_message'])
168
+				? $input_args['required_validation_error_message']
169 169
 				: null
170 170
 		);
171 171
 
172 172
 		//$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE;
173 173
 
174 174
 		$this->_display_strategy->_construct_finalize($this);
175
-		foreach( $this->_validation_strategies as $validation_strategy ){
175
+		foreach ($this->_validation_strategies as $validation_strategy) {
176 176
 			$validation_strategy->_construct_finalize($this);
177 177
 		}
178 178
 
179
-		if( ! $this->_normalization_strategy){
179
+		if ( ! $this->_normalization_strategy) {
180 180
 			$this->_normalization_strategy = new EE_Text_Normalization();
181 181
 		}
182 182
 		$this->_normalization_strategy->_construct_finalize($this);
183 183
 
184 184
 		//at least we can use the normalization strategy to populate the default
185
-		if( isset( $input_args[ 'default' ] ) ) {
186
-			$this->set_default( $input_args[ 'default' ] );
185
+		if (isset($input_args['default'])) {
186
+			$this->set_default($input_args['default']);
187 187
 		}
188 188
 
189
-		if( ! $this->_sensitive_data_removal_strategy){
189
+		if ( ! $this->_sensitive_data_removal_strategy) {
190 190
 			$this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
191 191
 		}
192 192
 		$this->_sensitive_data_removal_strategy->_construct_finalize($this);
193
-		parent::__construct( $input_args );
193
+		parent::__construct($input_args);
194 194
 	}
195 195
 
196 196
 
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @throws \EE_Error
203 203
 	 */
204
-	protected function _set_default_html_name_if_empty(){
205
-		if( ! $this->_html_name){
204
+	protected function _set_default_html_name_if_empty() {
205
+		if ( ! $this->_html_name) {
206 206
 			$this->_html_name = $this->name();
207
-			if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){
208
-				$this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
207
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
208
+				$this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]";
209 209
 			}
210 210
 		}
211 211
 	}
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 	public function _construct_finalize($parent_form_section, $name) {
221 221
 		parent::_construct_finalize($parent_form_section, $name);
222 222
 		$this->_set_default_html_name_if_empty();
223
-		if( ! $this->_html_label && ! $this->_html_label_text){
224
-			$this->_html_label_text = ucwords( str_replace("_"," ",$name));
223
+		if ( ! $this->_html_label && ! $this->_html_label_text) {
224
+			$this->_html_label_text = ucwords(str_replace("_", " ", $name));
225 225
 		}
226
-		do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name );
226
+		do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name);
227 227
 	}
228 228
 
229 229
 	 /**
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 	  * @return EE_Display_Strategy_Base
232 232
 	  * @throws EE_Error
233 233
 	  */
234
-	protected function _get_display_strategy(){
235
-		if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){
234
+	protected function _get_display_strategy() {
235
+		if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
236 236
 			throw new EE_Error(
237 237
 				sprintf(
238 238
 					__(
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 					$this->html_id()
244 244
 				)
245 245
 			);
246
-		}else{
246
+		} else {
247 247
 			return $this->_display_strategy;
248 248
 		}
249 249
 	}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * Sets the display strategy.
252 252
 	 * @param EE_Display_Strategy_Base $strategy
253 253
 	 */
254
-	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){
254
+	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) {
255 255
 		$this->_display_strategy = $strategy;
256 256
 	}
257 257
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * Sets the sanitization strategy
260 260
 	 * @param EE_Normalization_Strategy_Base $strategy
261 261
 	 */
262
-	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){
262
+	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) {
263 263
 		$this->_normalization_strategy = $strategy;
264 264
 	}
265 265
 
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
 	 * Gets the display strategy for this input
286 286
 	 * @return EE_Display_Strategy_Base
287 287
 	 */
288
-	public function get_display_strategy(){
288
+	public function get_display_strategy() {
289 289
 		return $this->_display_strategy;
290 290
 	}
291 291
 	/**
292 292
 	 * Overwrites the display strategy
293 293
 	 * @param EE_Display_Strategy_Base $display_strategy
294 294
 	 */
295
-	public function set_display_strategy($display_strategy){
295
+	public function set_display_strategy($display_strategy) {
296 296
 		$this->_display_strategy = $display_strategy;
297 297
 		$this->_display_strategy->_construct_finalize($this);
298 298
 	}
@@ -300,14 +300,14 @@  discard block
 block discarded – undo
300 300
 	 * Gets the normalization strategy set on this input
301 301
 	 * @return EE_Normalization_Strategy_Base
302 302
 	 */
303
-	public function get_normalization_strategy(){
303
+	public function get_normalization_strategy() {
304 304
 		return $this->_normalization_strategy;
305 305
 	}
306 306
 	/**
307 307
 	 * Overwrites the normalization strategy
308 308
 	 * @param EE_Normalization_Strategy_Base $normalization_strategy
309 309
 	 */
310
-	public function set_normalization_strategy($normalization_strategy){
310
+	public function set_normalization_strategy($normalization_strategy) {
311 311
 		$this->_normalization_strategy = $normalization_strategy;
312 312
 		$this->_normalization_strategy->_construct_finalize($this);
313 313
 	}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * Returns all teh validation strategies which apply to this field, numerically indexed
317 317
 	 * @return EE_Validation_Strategy_Base[]
318 318
 	 */
319
-	public function get_validation_strategies(){
319
+	public function get_validation_strategies() {
320 320
 		return $this->_validation_strategies;
321 321
 	}
322 322
 
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
 	 * @param EE_Validation_Strategy_Base $validation_strategy
328 328
 	 * @return void
329 329
 	 */
330
-	protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){
331
-		$validation_strategy->_construct_finalize( $this );
330
+	protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
331
+		$validation_strategy->_construct_finalize($this);
332 332
 		$this->_validation_strategies[] = $validation_strategy;
333 333
 	}
334 334
 
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 	 * @param EE_Validation_Strategy_Base $validation_strategy
340 340
 	 * @return void
341 341
 	 */
342
-	public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) {
343
-		$this->_add_validation_strategy( $validation_strategy );
342
+	public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
343
+		$this->_add_validation_strategy($validation_strategy);
344 344
 	}
345 345
 
346 346
 
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @param string $validation_strategy_classname
352 352
 	 */
353
-	public function remove_validation_strategy( $validation_strategy_classname ) {
354
-		foreach( $this->_validation_strategies as $key => $validation_strategy ){
355
-			if(
353
+	public function remove_validation_strategy($validation_strategy_classname) {
354
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
355
+			if (
356 356
 				$validation_strategy instanceof $validation_strategy_classname
357
-				|| is_subclass_of( $validation_strategy, $validation_strategy_classname )
357
+				|| is_subclass_of($validation_strategy, $validation_strategy_classname)
358 358
 			) {
359
-				unset( $this->_validation_strategies[ $key ] );
359
+				unset($this->_validation_strategies[$key]);
360 360
 			}
361 361
 		}
362 362
 	}
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
 	 * @param array $validation_strategy_classnames
370 370
 	 * @return bool
371 371
 	 */
372
-	public function has_validation_strategy( $validation_strategy_classnames ) {
373
-		$validation_strategy_classnames = is_array( $validation_strategy_classnames )
372
+	public function has_validation_strategy($validation_strategy_classnames) {
373
+		$validation_strategy_classnames = is_array($validation_strategy_classnames)
374 374
 			? $validation_strategy_classnames
375
-			: array( $validation_strategy_classnames );
376
-		foreach( $this->_validation_strategies as $key => $validation_strategy ){
377
-			if( in_array( $key, $validation_strategy_classnames ) ) {
375
+			: array($validation_strategy_classnames);
376
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
377
+			if (in_array($key, $validation_strategy_classnames)) {
378 378
 				return true;
379 379
 			}
380 380
 		}
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 * Gets the HTML
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_html(){
390
+	public function get_html() {
391 391
 		return $this->_parent_section->get_html_for_input($this);
392 392
 	}
393 393
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 	 * @return string
402 402
 	 * @throws \EE_Error
403 403
 	 */
404
-	public function get_html_for_input(){
404
+	public function get_html_for_input() {
405 405
 		return  $this->_get_display_strategy()->display();
406 406
 	}
407 407
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 	 * @return string
412 412
 	 */
413 413
 	public function html_other_attributes() {
414
-		return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : '';
414
+		return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : '';
415 415
 	}
416 416
 
417 417
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	/**
420 420
 	 * @param string $html_other_attributes
421 421
 	 */
422
-	public function set_html_other_attributes( $html_other_attributes ) {
422
+	public function set_html_other_attributes($html_other_attributes) {
423 423
 		$this->_html_other_attributes = $html_other_attributes;
424 424
 	}
425 425
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	 * according to the form section's layout strategy
429 429
 	 * @return string
430 430
 	 */
431
-	public function get_html_for_label(){
431
+	public function get_html_for_label() {
432 432
 		return $this->_parent_section->get_layout_strategy()->display_label($this);
433 433
 	}
434 434
 	/**
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	 * according to the form section's layout strategy
437 437
 	 * @return string
438 438
 	 */
439
-	public function get_html_for_errors(){
439
+	public function get_html_for_errors() {
440 440
 		return $this->_parent_section->get_layout_strategy()->display_errors($this);
441 441
 	}
442 442
 	/**
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	 * according to the form section's layout strategy
445 445
 	 * @return string
446 446
 	 */
447
-	public function get_html_for_help(){
447
+	public function get_html_for_help() {
448 448
 		return $this->_parent_section->get_layout_strategy()->display_help_text($this);
449 449
 	}
450 450
 	/**
@@ -453,18 +453,18 @@  discard block
 block discarded – undo
453 453
 	 * @return boolean
454 454
 	 */
455 455
 	protected function _validate() {
456
-		foreach($this->_validation_strategies as $validation_strategy){
457
-			if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
458
-				try{
456
+		foreach ($this->_validation_strategies as $validation_strategy) {
457
+			if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
458
+				try {
459 459
 					$validation_strategy->validate($this->normalized_value());
460
-				}catch(EE_Validation_Error $e){
460
+				} catch (EE_Validation_Error $e) {
461 461
 					$this->add_validation_error($e);
462 462
 				}
463 463
 			}
464 464
 		}
465
-		if( $this->get_validation_errors()){
465
+		if ($this->get_validation_errors()) {
466 466
 			return false;
467
-		}else{
467
+		} else {
468 468
 			return true;
469 469
 		}
470 470
 	}
@@ -477,8 +477,8 @@  discard block
 block discarded – undo
477 477
 	 * @param string $value
478 478
 	 * @return null|string
479 479
 	 */
480
-	private function _sanitize($value){
481
-		return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL;//don't sanitize_text_field
480
+	private function _sanitize($value) {
481
+		return $value !== NULL ? stripslashes(html_entity_decode($value)) : NULL; //don't sanitize_text_field
482 482
 	}
483 483
 
484 484
 
@@ -492,24 +492,24 @@  discard block
 block discarded – undo
492 492
 	 * @return boolean whether or not there was an error
493 493
 	 * @throws \EE_Error
494 494
 	 */
495
-	protected function _normalize( $req_data ) {
495
+	protected function _normalize($req_data) {
496 496
 		//any existing validation errors don't apply so clear them
497 497
 		$this->_validation_errors = array();
498 498
 		try {
499
-			$raw_input = $this->find_form_data_for_this_section( $req_data );
499
+			$raw_input = $this->find_form_data_for_this_section($req_data);
500 500
 			//super simple sanitization for now
501
-			if ( is_array( $raw_input )) {
501
+			if (is_array($raw_input)) {
502 502
 				$this->_raw_value = array();
503
-				foreach( $raw_input as $key => $value ) {
504
-					$this->_raw_value[ $key ] = $this->_sanitize( $value );
503
+				foreach ($raw_input as $key => $value) {
504
+					$this->_raw_value[$key] = $this->_sanitize($value);
505 505
 				}
506 506
 			} else {
507
-				$this->_raw_value = $this->_sanitize( $raw_input );
507
+				$this->_raw_value = $this->_sanitize($raw_input);
508 508
 			}
509 509
 			//we want ot mostly leave the input alone in case we need to re-display it to the user
510
-			$this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() );
511
-		} catch ( EE_Validation_Error $e ) {
512
-			$this->add_validation_error( $e );
510
+			$this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value());
511
+		} catch (EE_Validation_Error $e) {
512
+			$this->add_validation_error($e);
513 513
 		}
514 514
 	}
515 515
 
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 	/**
519 519
 	 * @return string
520 520
 	 */
521
-	public function html_name(){
521
+	public function html_name() {
522 522
 		return $this->_html_name;
523 523
 	}
524 524
 
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 	/**
528 528
 	 * @return string
529 529
 	 */
530
-	public function html_label_id(){
531
-		return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl';
530
+	public function html_label_id() {
531
+		return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl';
532 532
 	}
533 533
 
534 534
 
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 	/**
537 537
 	 * @return string
538 538
 	 */
539
-	public function html_label_class(){
539
+	public function html_label_class() {
540 540
 		return $this->_html_label_class;
541 541
 	}
542 542
 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 	/**
546 546
 	 * @return string
547 547
 	 */
548
-	public function html_label_style(){
548
+	public function html_label_style() {
549 549
 		return $this->_html_label_style;
550 550
 	}
551 551
 
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 	/**
555 555
 	 * @return string
556 556
 	 */
557
-	public function html_label_text(){
557
+	public function html_label_text() {
558 558
 		return $this->_html_label_text;
559 559
 	}
560 560
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	/**
564 564
 	 * @return string
565 565
 	 */
566
-	public function html_help_text(){
566
+	public function html_help_text() {
567 567
 		return $this->_html_help_text;
568 568
 	}
569 569
 
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 	/**
573 573
 	 * @return string
574 574
 	 */
575
-	public function html_help_class(){
575
+	public function html_help_class() {
576 576
 		return $this->_html_help_class;
577 577
 	}
578 578
 
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 	/**
582 582
 	 * @return string
583 583
 	 */
584
-	public function html_help_style(){
584
+	public function html_help_style() {
585 585
 		return $this->_html_style;
586 586
 	}
587 587
 	/**
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 	 * in which case, we would have stored the malicious content to our database.
595 595
 	 * @return string
596 596
 	 */
597
-	public function raw_value(){
597
+	public function raw_value() {
598 598
 		return $this->_raw_value;
599 599
 	}
600 600
 	/**
@@ -602,15 +602,15 @@  discard block
 block discarded – undo
602 602
 	 * it escapes all html entities
603 603
 	 * @return string
604 604
 	 */
605
-	public function raw_value_in_form(){
606
-		return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8');
605
+	public function raw_value_in_form() {
606
+		return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8');
607 607
 	}
608 608
 	/**
609 609
 	 * returns the value after it's been sanitized, and then converted into it's proper type
610 610
 	 * in PHP. Eg, a string, an int, an array,
611 611
 	 * @return mixed
612 612
 	 */
613
-	public function normalized_value(){
613
+	public function normalized_value() {
614 614
 		return $this->_normalized_value;
615 615
 	}
616 616
 
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	 * the best thing to display
621 621
 	 * @return string
622 622
 	 */
623
-	public function pretty_value(){
623
+	public function pretty_value() {
624 624
 		return $this->_normalized_value;
625 625
 	}
626 626
 	/**
@@ -639,19 +639,19 @@  discard block
 block discarded – undo
639 639
 		  }</code>
640 640
 	 * @return array
641 641
 	 */
642
-	public function get_jquery_validation_rules(){
642
+	public function get_jquery_validation_rules() {
643 643
 		$jquery_validation_js = array();
644 644
 		$jquery_validation_rules = array();
645
-		foreach($this->get_validation_strategies() as $validation_strategy){
645
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
646 646
 			$jquery_validation_rules = array_replace_recursive(
647 647
 				$jquery_validation_rules,
648 648
 				$validation_strategy->get_jquery_validation_rule_array()
649 649
 			);
650 650
 		}
651 651
 
652
-		if(! empty($jquery_validation_rules)){
653
-			foreach( $this->get_display_strategy()->get_html_input_ids( true ) as $html_id_with_pound_sign ) {
654
-				$jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
652
+		if ( ! empty($jquery_validation_rules)) {
653
+			foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
654
+				$jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules;
655 655
 			}
656 656
 		}
657 657
 		return $jquery_validation_js;
@@ -663,9 +663,9 @@  discard block
 block discarded – undo
663 663
 	 * @param mixed $value
664 664
 	 * @return void
665 665
 	 */
666
-	public function set_default($value){
666
+	public function set_default($value) {
667 667
 		$this->_normalized_value = $value;
668
-		$this->_raw_value = $this->_normalization_strategy->unnormalize( $value );
668
+		$this->_raw_value = $this->_normalization_strategy->unnormalize($value);
669 669
 	}
670 670
 
671 671
 	/**
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 	 * @param string $label
674 674
 	 * @return void
675 675
 	 */
676
-	public function set_html_label_text($label){
676
+	public function set_html_label_text($label) {
677 677
 		$this->_html_label_text = $label;
678 678
 	}
679 679
 
@@ -687,13 +687,13 @@  discard block
 block discarded – undo
687 687
 	 * @param boolean $required boolean
688 688
 	 * @param null    $required_text
689 689
 	 */
690
-	public function set_required($required = true, $required_text = NULL ){
691
-		$required = filter_var( $required, FILTER_VALIDATE_BOOLEAN  );
690
+	public function set_required($required = true, $required_text = NULL) {
691
+		$required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
692 692
 		//whether $required is a string or a boolean, we want to add a required validation strategy
693
-		if ( $required ) {
694
-			$this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) );
693
+		if ($required) {
694
+			$this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text));
695 695
 		} else {
696
-			unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] );
696
+			unset($this->_validation_strategies['EE_Required_Validation_Strategy']);
697 697
 		}
698 698
 		$this->_required = $required;
699 699
 	}
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 	 * Returns whether or not this field is required
702 702
 	 * @return boolean
703 703
 	 */
704
-	public function required(){
704
+	public function required() {
705 705
 		return $this->_required;
706 706
 	}
707 707
 
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 	/**
711 711
 	 * @param string $required_css_class
712 712
 	 */
713
-	public function set_required_css_class( $required_css_class ) {
713
+	public function set_required_css_class($required_css_class) {
714 714
 		$this->_required_css_class = $required_css_class;
715 715
 	}
716 716
 
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 	 * Sets the help text, in case
730 730
 	 * @param string $text
731 731
 	 */
732
-	public function set_html_help_text($text){
732
+	public function set_html_help_text($text) {
733 733
 		$this->_html_help_text = $text;
734 734
 	}
735 735
 	/**
@@ -741,8 +741,8 @@  discard block
 block discarded – undo
741 741
 	public function clean_sensitive_data() {
742 742
 		//if we do ANY kind of sensitive data removal on this, then just clear out the raw value
743 743
 		//if we need more logic than this we'll make a strategy for it
744
-		if( $this->_sensitive_data_removal_strategy &&
745
-				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){
744
+		if ($this->_sensitive_data_removal_strategy &&
745
+				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) {
746 746
 			$this->_raw_value = NULL;
747 747
 		}
748 748
 		//and clean the normalized value according to the appropriate strategy
@@ -758,10 +758,10 @@  discard block
 block discarded – undo
758 758
 	 * @param string $button_size
759 759
 	 * @param string $other_attributes
760 760
 	 */
761
-	public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) {
761
+	public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') {
762 762
 		$button_css_attributes = 'button';
763 763
 		$button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary';
764
-		switch ( $button_size ) {
764
+		switch ($button_size) {
765 765
 			case 'xs' :
766 766
 			case 'extra-small' :
767 767
 				$button_css_attributes .= ' button-xs';
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
 			default :
783 783
 				$button_css_attributes .= '';
784 784
 		}
785
-		$this->_button_css_attributes .= ! empty( $other_attributes )
786
-			? $button_css_attributes . ' ' . $other_attributes
785
+		$this->_button_css_attributes .= ! empty($other_attributes)
786
+			? $button_css_attributes.' '.$other_attributes
787 787
 			: $button_css_attributes;
788 788
 	}
789 789
 
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 	 * @return string
794 794
 	 */
795 795
 	public function button_css_attributes() {
796
-		if ( empty( $this->_button_css_attributes )) {
796
+		if (empty($this->_button_css_attributes)) {
797 797
 			$this->set_button_css_attributes();
798 798
 		}
799 799
 		return $this->_button_css_attributes;
@@ -815,26 +815,26 @@  discard block
 block discarded – undo
815 815
 	 * @return mixed whatever the raw value of this form section is in the request data
816 816
 	 * @throws \EE_Error
817 817
 	 */
818
-	public function find_form_data_for_this_section( $req_data ){
818
+	public function find_form_data_for_this_section($req_data) {
819 819
 		// break up the html name by "[]"
820
-		if ( strpos( $this->html_name(), '[' ) !== FALSE ) {
821
-			$before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') );
820
+		if (strpos($this->html_name(), '[') !== FALSE) {
821
+			$before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '['));
822 822
 		} else {
823 823
 			$before_any_brackets = $this->html_name();
824 824
 		}
825 825
 		// grab all of the segments
826
-		preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches);
827
-		if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){
828
-			$name_parts = $matches[ 1 ];
826
+		preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches);
827
+		if (isset($matches[1]) && is_array($matches[1])) {
828
+			$name_parts = $matches[1];
829 829
 			array_unshift($name_parts, $before_any_brackets);
830
-		}else{
831
-			$name_parts = array( $before_any_brackets );
830
+		} else {
831
+			$name_parts = array($before_any_brackets);
832 832
 		}
833 833
 		// now get the value for the input
834 834
 		$value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data);
835 835
 		// check if this thing's name is at the TOP level of the request data
836
-		if( $value === null && isset( $req_data[ $this->name() ] ) ){
837
-			$value = $req_data[ $this->name() ];
836
+		if ($value === null && isset($req_data[$this->name()])) {
837
+			$value = $req_data[$this->name()];
838 838
 		}
839 839
 		return $value;
840 840
 	}
@@ -847,18 +847,18 @@  discard block
 block discarded – undo
847 847
 	 * @param array $req_data
848 848
 	 * @return array | NULL
849 849
 	 */
850
-	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){
851
-		$first_part_to_consider = array_shift( $html_name_parts );
852
-		if( isset( $req_data[ $first_part_to_consider ] ) ){
853
-			if( empty($html_name_parts ) ){
854
-				return $req_data[ $first_part_to_consider ];
855
-			}else{
850
+	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) {
851
+		$first_part_to_consider = array_shift($html_name_parts);
852
+		if (isset($req_data[$first_part_to_consider])) {
853
+			if (empty($html_name_parts)) {
854
+				return $req_data[$first_part_to_consider];
855
+			} else {
856 856
 				return $this->_find_form_data_for_this_section_using_name_parts(
857 857
 					$html_name_parts,
858
-					$req_data[ $first_part_to_consider ]
858
+					$req_data[$first_part_to_consider]
859 859
 				);
860 860
 			}
861
-		}else{
861
+		} else {
862 862
 			return NULL;
863 863
 		}
864 864
 	}
@@ -872,14 +872,14 @@  discard block
 block discarded – undo
872 872
 	 * @return boolean
873 873
 	 * @throws \EE_Error
874 874
 	 */
875
-	public function form_data_present_in($req_data = NULL){
876
-		if( $req_data === NULL ){
875
+	public function form_data_present_in($req_data = NULL) {
876
+		if ($req_data === NULL) {
877 877
 			$req_data = $_POST;
878 878
 		}
879
-		$checked_value = $this->find_form_data_for_this_section( $req_data );
880
-		if( $checked_value !== null ){
879
+		$checked_value = $this->find_form_data_for_this_section($req_data);
880
+		if ($checked_value !== null) {
881 881
 			return TRUE;
882
-		}else{
882
+		} else {
883 883
 			return FALSE;
884 884
 		}
885 885
 	}
@@ -890,8 +890,8 @@  discard block
 block discarded – undo
890 890
 	 * @param array $form_other_js_data
891 891
 	 * @return array
892 892
 	 */
893
-	public function get_other_js_data( $form_other_js_data = array() ) {
894
-		$form_other_js_data = $this->get_other_js_data_from_strategies( $form_other_js_data );
893
+	public function get_other_js_data($form_other_js_data = array()) {
894
+		$form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data);
895 895
 		return $form_other_js_data;
896 896
 	}
897 897
 
@@ -904,10 +904,10 @@  discard block
 block discarded – undo
904 904
 	 * @param array $form_other_js_data
905 905
 	 * @return array
906 906
 	 */
907
-	public function get_other_js_data_from_strategies( $form_other_js_data = array() ) {
908
-		$form_other_js_data = $this->get_display_strategy()->get_other_js_data( $form_other_js_data );
909
-		foreach( $this->get_validation_strategies() as $validation_strategy ) {
910
-			$form_other_js_data = $validation_strategy->get_other_js_data( $form_other_js_data );
907
+	public function get_other_js_data_from_strategies($form_other_js_data = array()) {
908
+		$form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data);
909
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
910
+			$form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data);
911 911
 		}
912 912
 		return $form_other_js_data;
913 913
 	}
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
 	 * Override parent because we want to give our strategies an opportunity to enqueue some js and css
917 917
 	 * @return void
918 918
 	 */
919
-	public function enqueue_js(){
919
+	public function enqueue_js() {
920 920
 		//ask our display strategy and validation strategies if they have js to enqueue
921 921
 		$this->enqueue_js_from_strategies();
922 922
 	}
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 	 */
928 928
 	public function enqueue_js_from_strategies() {
929 929
 		$this->get_display_strategy()->enqueue_js();
930
-		foreach( $this->get_validation_strategies() as $validation_strategy ) {
930
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
931 931
 			$validation_strategy->enqueue_js();
932 932
 		}
933 933
 	}
Please login to merge, or discard this patch.
form_sections/strategies/display/EE_Select2_Display_Strategy.strategy.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @since 				$VID:$
13 13
  *
14 14
  */
15
-class EE_Select2_Display_Strategy extends EE_Select_Display_Strategy{
15
+class EE_Select2_Display_Strategy extends EE_Select_Display_Strategy {
16 16
 	
17 17
 	/**
18 18
 	 * Arguments that will be passed into the select2 javascript constructor
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @param array $select2_js_args pass in the EXACT array of JS arguments you want
26 26
 	 * to pass into the select2 js/html input. See https://select2.github.io
27 27
 	 */
28
-	public function __construct( $select2_js_args = array() ) {
28
+	public function __construct($select2_js_args = array()) {
29 29
 		$this->_select2_js_args = $select2_js_args;
30 30
 		parent::__construct();
31 31
 	}
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 	 * the select2 css
36 36
 	 */
37 37
 	public function enqueue_js() {
38
-		wp_enqueue_script( 'form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true );
39
-		wp_enqueue_style( 'select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all' );
38
+		wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL.'scripts/form_section_select2_init.js', array('select2'), '1.0.0', true);
39
+		wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all');
40 40
 	}
41 41
 	
42 42
 	/**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * Sets the exact js args which will be passed into the select2 js/html input
52 52
 	 * @param array $js_args
53 53
 	 */
54
-	public function set_js_args( $js_args ) {
54
+	public function set_js_args($js_args) {
55 55
 		$this->_select2_js_args = $js_args;
56 56
 	}
57 57
 	
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 	 * @param array $other_js_data
61 61
 	 * @return array
62 62
 	 */
63
-	public function get_other_js_data( $other_js_data = array() ) {
64
-		$other_js_data = parent::get_other_js_data( $other_js_data );
65
-		if( ! isset( $other_js_data[ 'select2s' ] ) ) {
63
+	public function get_other_js_data($other_js_data = array()) {
64
+		$other_js_data = parent::get_other_js_data($other_js_data);
65
+		if ( ! isset($other_js_data['select2s'])) {
66 66
 			$other_js_data['select2s'] = array();
67 67
 		}
68
-		$other_js_data[ 'select2s' ][ $this->_input->html_id() ] = $this->get_js_args();
68
+		$other_js_data['select2s'][$this->_input->html_id()] = $this->get_js_args();
69 69
 		return $other_js_data;
70 70
 	}
71 71
 }
72 72
\ No newline at end of file
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Proper.form.php 1 patch
Spacing   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts).
8 8
  * However, you may output the form (usually by calling get_html) anywhere you like.
9 9
  */
10
-class EE_Form_Section_Proper extends EE_Form_Section_Validatable{
10
+class EE_Form_Section_Proper extends EE_Form_Section_Validatable {
11 11
 
12 12
 	/**
13 13
 	 * Subsections
@@ -69,49 +69,49 @@  discard block
 block discarded – undo
69 69
 	 *                               } @see EE_Form_Section_Validatable::__construct()
70 70
 	 * @throws \EE_Error
71 71
 	 */
72
-	public function __construct( $options_array = array() ){
73
-		$options_array = (array) apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this );
72
+	public function __construct($options_array = array()) {
73
+		$options_array = (array) apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this);
74 74
 		//call parent first, as it may be setting the name
75 75
 		parent::__construct($options_array);
76 76
 		//if they've included subsections in the constructor, add them now
77
-		if( isset( $options_array['include'] )){
77
+		if (isset($options_array['include'])) {
78 78
 			//we are going to make sure we ONLY have those subsections to include
79 79
 			//AND we are going to make sure they're in that specified order
80 80
 			$reordered_subsections = array();
81
-			foreach($options_array['include'] as $input_name){
82
-				if(isset($this->_subsections[$input_name])){
81
+			foreach ($options_array['include'] as $input_name) {
82
+				if (isset($this->_subsections[$input_name])) {
83 83
 					$reordered_subsections[$input_name] = $this->_subsections[$input_name];
84 84
 				}
85 85
 			}
86 86
 			$this->_subsections = $reordered_subsections;
87 87
 		}
88
-		if(isset($options_array['exclude'])){
88
+		if (isset($options_array['exclude'])) {
89 89
 			$exclude = $options_array['exclude'];
90 90
 			$this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
91 91
 		}
92
-		if(isset($options_array['layout_strategy'])){
92
+		if (isset($options_array['layout_strategy'])) {
93 93
 			$this->_layout_strategy = $options_array['layout_strategy'];
94 94
 		}
95
-		if( ! $this->_layout_strategy){
95
+		if ( ! $this->_layout_strategy) {
96 96
 			$this->_layout_strategy = new EE_Two_Column_Layout();
97 97
 		}
98 98
 		$this->_layout_strategy->_construct_finalize($this);
99 99
 
100 100
 		//ok so we are definitely going to want the forms JS,
101 101
 		//so enqueue it or remember to enqueue it during wp_enqueue_scripts
102
-		if( did_action( 'wp_enqueue_scripts' )
103
-			|| did_action( 'admin_enqueue_scripts' ) ) {
102
+		if (did_action('wp_enqueue_scripts')
103
+			|| did_action('admin_enqueue_scripts')) {
104 104
 			//ok so they've constructed this object after when they should have.
105 105
 			//just enqueue the generic form scripts and initialize the form immediately in the JS
106
-			\EE_Form_Section_Proper::wp_enqueue_scripts( true );
106
+			\EE_Form_Section_Proper::wp_enqueue_scripts(true);
107 107
 		} else {
108
-			add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' ));
109
-			add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' ));
108
+			add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
109
+			add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
110 110
 		}
111
-		add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 );
111
+		add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
112 112
 
113
-		if( isset( $options_array[ 'name' ] ) ) {
114
-			$this->_construct_finalize( null, $options_array[ 'name' ] );
113
+		if (isset($options_array['name'])) {
114
+			$this->_construct_finalize(null, $options_array['name']);
115 115
 		}
116 116
 	}
117 117
 
@@ -124,25 +124,25 @@  discard block
 block discarded – undo
124 124
 	 * @param string                 $name
125 125
 	 * @throws \EE_Error
126 126
 	 */
127
-	public function _construct_finalize( $parent_form_section, $name ) {
127
+	public function _construct_finalize($parent_form_section, $name) {
128 128
 		parent::_construct_finalize($parent_form_section, $name);
129 129
 		$this->_set_default_name_if_empty();
130 130
 		$this->_set_default_html_id_if_empty();
131
-		foreach( $this->_subsections as $subsection_name => $subsection ){
132
-			if ( $subsection instanceof EE_Form_Section_Base ) {
133
-				$subsection->_construct_finalize( $this, $subsection_name );
131
+		foreach ($this->_subsections as $subsection_name => $subsection) {
132
+			if ($subsection instanceof EE_Form_Section_Base) {
133
+				$subsection->_construct_finalize($this, $subsection_name);
134 134
 			} else {
135 135
 				throw new EE_Error(
136 136
 					sprintf(
137
-						__( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ),
137
+						__('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'),
138 138
 						$subsection_name,
139 139
 						get_class($this),
140
-						$subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' )
140
+						$subsection ? get_class($subsection) : __('NULL', 'event_espresso')
141 141
 					)
142 142
 				);
143 143
 			}
144 144
 		}
145
-		do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name );
145
+		do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name);
146 146
 	}
147 147
 
148 148
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * Gets the layout strategy for this form section
152 152
 	 * @return EE_Form_Section_Layout_Base
153 153
 	 */
154
-	public function get_layout_strategy(){
154
+	public function get_layout_strategy() {
155 155
 		return $this->_layout_strategy;
156 156
 	}
157 157
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @param EE_Form_Input_Base $input
164 164
 	 * @return string
165 165
 	 */
166
-	public function get_html_for_input($input){
166
+	public function get_html_for_input($input) {
167 167
 		return $this->_layout_strategy->layout_input($input);
168 168
 	}
169 169
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 * @param null $form_data
177 177
 	 * @return boolean
178 178
 	 */
179
-	public function was_submitted($form_data = NULL){
179
+	public function was_submitted($form_data = NULL) {
180 180
 		return $this->form_data_present_in($form_data);
181 181
 	}
182 182
 
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
 	 *                          (eg you validated the data then stored it in the DB) you may want to skip this step.
202 202
 	 * @return void
203 203
 	 */
204
-	public function receive_form_submission($req_data = NULL, $validate = TRUE){
205
-		$req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate );
206
-		if( $req_data === NULL){
207
-			$req_data = array_merge( $_GET, $_POST );
204
+	public function receive_form_submission($req_data = NULL, $validate = TRUE) {
205
+		$req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate);
206
+		if ($req_data === NULL) {
207
+			$req_data = array_merge($_GET, $_POST);
208 208
 		}
209
-		$req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this );
209
+		$req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this);
210 210
 		$this->_normalize($req_data);
211
-		if( $validate ){
211
+		if ($validate) {
212 212
 			$this->_validate();
213 213
 		}
214
-		do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate );
214
+		do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate);
215 215
 	}
216 216
 
217 217
 
@@ -224,12 +224,12 @@  discard block
 block discarded – undo
224 224
 	 * the value being an array formatted in teh same way
225 225
 	 * @param array $default_data
226 226
 	 */
227
-	public function populate_defaults($default_data){
228
-		foreach($this->subsections() as $subsection_name => $subsection){
229
-			if(isset($default_data[$subsection_name])){
230
-				if($subsection instanceof EE_Form_Input_Base){
227
+	public function populate_defaults($default_data) {
228
+		foreach ($this->subsections() as $subsection_name => $subsection) {
229
+			if (isset($default_data[$subsection_name])) {
230
+				if ($subsection instanceof EE_Form_Input_Base) {
231 231
 					$subsection->set_default($default_data[$subsection_name]);
232
-				}elseif($subsection instanceof EE_Form_Section_Proper){
232
+				}elseif ($subsection instanceof EE_Form_Section_Proper) {
233 233
 					$subsection->populate_defaults($default_data[$subsection_name]);
234 234
 				}
235 235
 			}
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 	 * @return EE_Form_Section_Base
252 252
 	 * @throws \EE_Error
253 253
 	 */
254
-	public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){
255
-		if( $require_construction_to_be_finalized ){
254
+	public function get_subsection($name, $require_construction_to_be_finalized = TRUE) {
255
+		if ($require_construction_to_be_finalized) {
256 256
 			$this->ensure_construct_finalized_called();
257 257
 		}
258 258
 		return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL;
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
 	 * Gets all the validatable subsections of this form section
265 265
 	 * @return EE_Form_Section_Validatable[]
266 266
 	 */
267
-	public function get_validatable_subsections(){
267
+	public function get_validatable_subsections() {
268 268
 		$validatable_subsections = array();
269
-		foreach($this->subsections() as $name=>$obj){
270
-			if($obj instanceof EE_Form_Section_Validatable){
269
+		foreach ($this->subsections() as $name=>$obj) {
270
+			if ($obj instanceof EE_Form_Section_Validatable) {
271 271
 				$validatable_subsections[$name] = $obj;
272 272
 			}
273 273
 		}
@@ -287,10 +287,10 @@  discard block
 block discarded – undo
287 287
 	 * @return EE_Form_Input_Base
288 288
 	 * @throws EE_Error
289 289
 	 */
290
-	public function get_input($name, $require_construction_to_be_finalized = TRUE ){
290
+	public function get_input($name, $require_construction_to_be_finalized = TRUE) {
291 291
 		$subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
292
-		if( ! $subsection instanceof EE_Form_Input_Base){
293
-			throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'),$name, get_class($this),$subsection ? get_class($subsection) : __("NULL", 'event_espresso')));
292
+		if ( ! $subsection instanceof EE_Form_Input_Base) {
293
+			throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'), $name, get_class($this), $subsection ? get_class($subsection) : __("NULL", 'event_espresso')));
294 294
 		}
295 295
 		return $subsection;
296 296
 	}
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 	 * @return EE_Form_Section_Proper
309 309
 	 * @throws EE_Error
310 310
 	 */
311
-	public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){
312
-		$subsection = $this->get_subsection( $name, $require_construction_to_be_finalized );
313
-		if( ! $subsection instanceof EE_Form_Section_Proper){
314
-			throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this)));
311
+	public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) {
312
+		$subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
313
+		if ( ! $subsection instanceof EE_Form_Section_Proper) {
314
+			throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this)));
315 315
 		}
316 316
 		return $subsection;
317 317
 	}
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	 * @return mixed depending on the input's type and its normalization strategy
327 327
 	 * @throws \EE_Error
328 328
 	 */
329
-	public function get_input_value($name){
329
+	public function get_input_value($name) {
330 330
 		$input = $this->get_input($name);
331 331
 		return $input->normalized_value();
332 332
 	}
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
 	 * @return boolean
340 340
 	 */
341 341
 	public function is_valid() {
342
-		if( ! $this->has_received_submission()){
342
+		if ( ! $this->has_received_submission()) {
343 343
 			throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso")));
344 344
 		}
345
-		if( ! parent::is_valid()){
345
+		if ( ! parent::is_valid()) {
346 346
 			return false;
347 347
 		}
348 348
 		//ok so no errors general to this entire form section. so let's check the subsections
349
-		foreach( $this->get_validatable_subsections() as $subsection ){
350
-			if( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '' ){
351
-				$this->set_submission_error_message( $subsection->get_validation_error_string() );
349
+		foreach ($this->get_validatable_subsections() as $subsection) {
350
+			if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '') {
351
+				$this->set_submission_error_message($subsection->get_validation_error_string());
352 352
 				return false;
353 353
 			}
354 354
 		}
@@ -361,11 +361,11 @@  discard block
 block discarded – undo
361 361
 	 * gets teh default name of this form section if none is specified
362 362
 	 * @return string
363 363
 	 */
364
-	protected function _set_default_name_if_empty(){
365
-		if( ! $this->_name ){
364
+	protected function _set_default_name_if_empty() {
365
+		if ( ! $this->_name) {
366 366
 			$classname = get_class($this);
367 367
 			$default_name = str_replace("EE_", "", $classname);
368
-			$this->_name =  $default_name;
368
+			$this->_name = $default_name;
369 369
 		}
370 370
 	}
371 371
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 *             and get_html when you are about to display the form.
381 381
 	 * @throws \EE_Error
382 382
 	 */
383
-	public function get_html_and_js(){
383
+	public function get_html_and_js() {
384 384
 		//no doing_it_wrong yet because we ourselves are still doing it wrong...
385 385
 		//and theoretically this CAN be used properly, provided its used during "wp_enqueue_scripts"
386 386
 		$this->enqueue_js();
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	 * @return string
396 396
 	 * @throws \EE_Error
397 397
 	 */
398
-	public function get_html(){
398
+	public function get_html() {
399 399
 		$this->ensure_construct_finalized_called();
400 400
 		return $this->_layout_strategy->layout_form();
401 401
 	}
@@ -408,9 +408,9 @@  discard block
 block discarded – undo
408 408
 	 * @return string
409 409
 	 * @throws \EE_Error
410 410
 	 */
411
-	public function enqueue_js(){
411
+	public function enqueue_js() {
412 412
 		$this->_enqueue_and_localize_form_js();
413
-		foreach( $this->subsections() as $subsection ) {
413
+		foreach ($this->subsections() as $subsection) {
414 414
 			$subsection->enqueue_js();
415 415
 		}
416 416
 	}
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
 	 * @param boolean $init_form_validation_automatically whether or not we want the form validation to be triggered automatically or not
428 428
 	 * @return void
429 429
 	 */
430
-	public static function wp_enqueue_scripts( $init_form_validation_automatically = true ){
431
-		add_filter( 'FHEE_load_jquery_validate', '__return_true' );
432
-		wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods' ), EVENT_ESPRESSO_VERSION, TRUE );
433
-		wp_localize_script( 'ee_form_section_validation', 'ee_form_section_validation_init', array( 'init' => $init_form_validation_automatically ? true : false ) );
430
+	public static function wp_enqueue_scripts($init_form_validation_automatically = true) {
431
+		add_filter('FHEE_load_jquery_validate', '__return_true');
432
+		wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'), EVENT_ESPRESSO_VERSION, TRUE);
433
+		wp_localize_script('ee_form_section_validation', 'ee_form_section_validation_init', array('init' => $init_form_validation_automatically ? true : false));
434 434
 	}
435 435
 
436 436
 
@@ -442,14 +442,14 @@  discard block
 block discarded – undo
442 442
 	 *
443 443
 	 * @throws \EE_Error
444 444
 	 */
445
-	public function _enqueue_and_localize_form_js(){
445
+	public function _enqueue_and_localize_form_js() {
446 446
 		$this->ensure_construct_finalized_called();
447 447
 		//actually, we don't want to localize just yet. There may be other forms on the page.
448 448
 		//so we need to add our form section data to a static variable accessible by all form sections
449 449
 		//and localize it just before the footer
450 450
 		$this->localize_validation_rules();
451
-		add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 );
452
-		add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) );
451
+		add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
452
+		add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
453 453
 	}
454 454
 
455 455
 
@@ -461,11 +461,11 @@  discard block
 block discarded – undo
461 461
 	 * @return void
462 462
 	 * @throws \EE_Error
463 463
 	 */
464
-	public function localize_validation_rules( $return_for_subsection = FALSE ){
464
+	public function localize_validation_rules($return_for_subsection = FALSE) {
465 465
 		// we only want to localize vars ONCE for the entire form, so if the form section doesn't have a parent, then it must be the top dog
466
-		if ( $return_for_subsection || ! $this->parent_section() ) {
467
-			EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
468
-				'form_section_id'=> $this->html_id( TRUE ),
466
+		if ($return_for_subsection || ! $this->parent_section()) {
467
+			EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array(
468
+				'form_section_id'=> $this->html_id(TRUE),
469 469
 				'validation_rules'=> $this->get_jquery_validation_rules(),
470 470
 				'other_data' => $this->get_other_js_data(),
471 471
 				'errors'=> $this->subsection_validation_errors_by_html_name()
@@ -481,9 +481,9 @@  discard block
 block discarded – undo
481 481
 	 * @param array $form_other_js_data
482 482
 	 * @return array
483 483
 	 */
484
-	public function get_other_js_data( $form_other_js_data = array() ) {
485
-		foreach( $this->subsections() as $subsection ) {
486
-			$form_other_js_data = $subsection->get_other_js_data( $form_other_js_data );
484
+	public function get_other_js_data($form_other_js_data = array()) {
485
+		foreach ($this->subsections() as $subsection) {
486
+			$form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
487 487
 		}
488 488
 		return $form_other_js_data;
489 489
 	}
@@ -494,12 +494,12 @@  discard block
 block discarded – undo
494 494
 	 * Keys are their form names, and values are the inputs themselves
495 495
 	 * @return EE_Form_Input_Base
496 496
 	 */
497
-	public function inputs_in_subsections(){
497
+	public function inputs_in_subsections() {
498 498
 		$inputs = array();
499
-		foreach($this->subsections() as $subsection){
500
-			if( $subsection instanceof EE_Form_Input_Base ){
501
-				$inputs[ $subsection->html_name() ] = $subsection;
502
-			}elseif($subsection instanceof EE_Form_Section_Proper ){
499
+		foreach ($this->subsections() as $subsection) {
500
+			if ($subsection instanceof EE_Form_Input_Base) {
501
+				$inputs[$subsection->html_name()] = $subsection;
502
+			}elseif ($subsection instanceof EE_Form_Section_Proper) {
503 503
 				$inputs += $subsection->inputs_in_subsections();
504 504
 			}
505 505
 		}
@@ -512,12 +512,12 @@  discard block
 block discarded – undo
512 512
 	 * and values are a string of all their validation errors
513 513
 	 * @return string[]
514 514
 	 */
515
-	public function subsection_validation_errors_by_html_name(){
515
+	public function subsection_validation_errors_by_html_name() {
516 516
 		$inputs = $this->inputs();
517 517
 		$errors = array();
518
-		foreach( $inputs as $form_input ){
519
-			if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){
520
-				$errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
518
+		foreach ($inputs as $form_input) {
519
+			if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
520
+				$errors[$form_input->html_name()] = $form_input->get_validation_error_string();
521 521
 			}
522 522
 		}
523 523
 		return $errors;
@@ -529,16 +529,16 @@  discard block
 block discarded – undo
529 529
 	 * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
530 530
 	 * Should be setup by each form during the _enqueues_and_localize_form_js
531 531
 	 */
532
-	public static function localize_script_for_all_forms(){
532
+	public static function localize_script_for_all_forms() {
533 533
 		//allow inputs and stuff to hook in their JS and stuff here
534 534
 		do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
535 535
 		EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
536
-		$email_validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level )
536
+		$email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
537 537
 			? EE_Registry::instance()->CFG->registration->email_validation_level
538 538
 			: 'wp_default';
539 539
 		EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level;
540
-		wp_enqueue_script( 'ee_form_section_validation' );
541
-		wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization );
540
+		wp_enqueue_script('ee_form_section_validation');
541
+		wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization);
542 542
 	}
543 543
 
544 544
 
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
 	/**
547 547
 	 * ensure_scripts_localized
548 548
 	 */
549
-	public function ensure_scripts_localized(){
550
-		if ( ! EE_Form_Section_Proper::$_scripts_localized ) {
549
+	public function ensure_scripts_localized() {
550
+		if ( ! EE_Form_Section_Proper::$_scripts_localized) {
551 551
 			$this->_enqueue_and_localize_form_js();
552 552
 		}
553 553
 	}
@@ -559,10 +559,10 @@  discard block
 block discarded – undo
559 559
 	 * is that the key here should be the same as the custom validation rule put in the JS file
560 560
 	 * @return array keys are custom validation rules, and values are internationalized strings
561 561
 	 */
562
-	private static function _get_localized_error_messages(){
562
+	private static function _get_localized_error_messages() {
563 563
 		return array(
564 564
 			'validUrl'=>  __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"),
565
-			'regex' => __( 'Please check your input', 'event_espresso' ),
565
+			'regex' => __('Please check your input', 'event_espresso'),
566 566
 		);
567 567
 	}
568 568
 
@@ -590,10 +590,10 @@  discard block
 block discarded – undo
590 590
 	 * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more...
591 591
 	 * @return array
592 592
 	 */
593
-	public function get_jquery_validation_rules(){
593
+	public function get_jquery_validation_rules() {
594 594
 		$jquery_validation_rules = array();
595
-		foreach($this->get_validatable_subsections() as $subsection){
596
-			$jquery_validation_rules = array_merge( $jquery_validation_rules,  $subsection->get_jquery_validation_rules() );
595
+		foreach ($this->get_validatable_subsections() as $subsection) {
596
+			$jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules());
597 597
 		}
598 598
 		return $jquery_validation_rules;
599 599
 	}
@@ -608,11 +608,11 @@  discard block
 block discarded – undo
608 608
 	protected function _normalize($req_data) {
609 609
 		$this->_received_submission = TRUE;
610 610
 		$this->_validation_errors = array();
611
-		foreach($this->get_validatable_subsections() as $subsection){
612
-			try{
611
+		foreach ($this->get_validatable_subsections() as $subsection) {
612
+			try {
613 613
 				$subsection->_normalize($req_data);
614
-			}catch( EE_Validation_Error $e ){
615
-				$subsection->add_validation_error( $e );
614
+			} catch (EE_Validation_Error $e) {
615
+				$subsection->add_validation_error($e);
616 616
 			}
617 617
 		}
618 618
 	}
@@ -626,9 +626,9 @@  discard block
 block discarded – undo
626 626
 	 * calling parent::_validate() first.
627 627
 	 */
628 628
 	protected function _validate() {
629
-		foreach($this->get_validatable_subsections() as $subsection_name => $subsection){
630
-			if(method_exists($this,'_validate_'.$subsection_name)){
631
-				call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
629
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
630
+			if (method_exists($this, '_validate_'.$subsection_name)) {
631
+				call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection));
632 632
 			}
633 633
 			$subsection->_validate();
634 634
 		}
@@ -640,13 +640,13 @@  discard block
 block discarded – undo
640 640
 	 * Gets all the validated inputs for the form section
641 641
 	 * @return array
642 642
 	 */
643
-	public function valid_data(){
643
+	public function valid_data() {
644 644
 		$inputs = array();
645
-		foreach( $this->subsections() as $subsection_name =>$subsection ){
646
-			if ( $subsection instanceof EE_Form_Section_Proper ) {
647
-				$inputs[ $subsection_name ] = $subsection->valid_data();
648
-			} else if ( $subsection instanceof EE_Form_Input_Base ){
649
-				$inputs[ $subsection_name ] = $subsection->normalized_value();
645
+		foreach ($this->subsections() as $subsection_name =>$subsection) {
646
+			if ($subsection instanceof EE_Form_Section_Proper) {
647
+				$inputs[$subsection_name] = $subsection->valid_data();
648
+			} else if ($subsection instanceof EE_Form_Input_Base) {
649
+				$inputs[$subsection_name] = $subsection->normalized_value();
650 650
 			}
651 651
 		}
652 652
 		return $inputs;
@@ -658,11 +658,11 @@  discard block
 block discarded – undo
658 658
 	 * Gets all the inputs on this form section
659 659
 	 * @return EE_Form_Input_Base[]
660 660
 	 */
661
-	public function inputs(){
661
+	public function inputs() {
662 662
 		$inputs = array();
663
-		foreach( $this->subsections() as $subsection_name =>$subsection ){
664
-			if ( $subsection instanceof EE_Form_Input_Base ){
665
-				$inputs[ $subsection_name ] = $subsection;
663
+		foreach ($this->subsections() as $subsection_name =>$subsection) {
664
+			if ($subsection instanceof EE_Form_Input_Base) {
665
+				$inputs[$subsection_name] = $subsection;
666 666
 			}
667 667
 		}
668 668
 		return $inputs;
@@ -674,10 +674,10 @@  discard block
 block discarded – undo
674 674
 	 * Gets all the subsections which are a proper form
675 675
 	 * @return EE_Form_Section_Proper[]
676 676
 	 */
677
-	public function subforms(){
677
+	public function subforms() {
678 678
 		$form_sections = array();
679
-		foreach($this->subsections() as $name=>$obj){
680
-			if($obj instanceof EE_Form_Section_Proper){
679
+		foreach ($this->subsections() as $name=>$obj) {
680
+			if ($obj instanceof EE_Form_Section_Proper) {
681 681
 				$form_sections[$name] = $obj;
682 682
 			}
683 683
 		}
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 	 * if you only want form inputs or proper form sections.
693 693
 	 * @return EE_Form_Section_Proper[]
694 694
 	 */
695
-	public function subsections(){
695
+	public function subsections() {
696 696
 		$this->ensure_construct_finalized_called();
697 697
 		return $this->_subsections;
698 698
 	}
@@ -710,8 +710,8 @@  discard block
 block discarded – undo
710 710
 	 * it can be a multidimensional array where keys are always subsection names and values are either the
711 711
 	 * input's normalized value, or an array like the top-level array
712 712
 	 */
713
-	public function input_values( $include_subform_inputs = false, $flatten = false ){
714
-		return $this->_input_values( false, $include_subform_inputs, $flatten );
713
+	public function input_values($include_subform_inputs = false, $flatten = false) {
714
+		return $this->_input_values(false, $include_subform_inputs, $flatten);
715 715
 	}
716 716
 
717 717
 	/**
@@ -727,8 +727,8 @@  discard block
 block discarded – undo
727 727
 	 * it can be a multidimensional array where keys are always subsection names and values are either the
728 728
 	 * input's normalized value, or an array like the top-level array
729 729
 	 */
730
-	public function input_pretty_values(  $include_subform_inputs = false, $flatten = false ){
731
-		return $this->_input_values( true, $include_subform_inputs, $flatten );
730
+	public function input_pretty_values($include_subform_inputs = false, $flatten = false) {
731
+		return $this->_input_values(true, $include_subform_inputs, $flatten);
732 732
 	}
733 733
 
734 734
 	/**
@@ -741,17 +741,17 @@  discard block
 block discarded – undo
741 741
 	 * it can be a multidimensional array where keys are always subsection names and values are either the
742 742
 	 * input's normalized value, or an array like the top-level array
743 743
 	 */
744
-	public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) {
744
+	public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) {
745 745
 		$input_values = array();
746
-		foreach( $this->subsections() as $subsection_name => $subsection ) {
747
-			if( $subsection instanceof EE_Form_Input_Base ) {
748
-				$input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value();
749
-			} else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) {
750
-				$subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten );
751
-				if( $flatten ) {
752
-					$input_values = array_merge( $input_values, $subform_input_values );
746
+		foreach ($this->subsections() as $subsection_name => $subsection) {
747
+			if ($subsection instanceof EE_Form_Input_Base) {
748
+				$input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value();
749
+			} else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
750
+				$subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten);
751
+				if ($flatten) {
752
+					$input_values = array_merge($input_values, $subform_input_values);
753 753
 				} else {
754
-					$input_values[ $subsection_name ] = $subform_input_values;
754
+					$input_values[$subsection_name] = $subform_input_values;
755 755
 				}
756 756
 			}
757 757
 		}
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 	 * @return boolean
768 768
 	 * @throws \EE_Error
769 769
 	 */
770
-	public function has_received_submission(){
770
+	public function has_received_submission() {
771 771
 		$this->ensure_construct_finalized_called();
772 772
 		return $this->_received_submission;
773 773
 	}
@@ -780,8 +780,8 @@  discard block
 block discarded – undo
780 780
 	 * @param array $inputs_to_exclude values are the input names
781 781
 	 * @return void
782 782
 	 */
783
-	public function exclude($inputs_to_exclude = array()){
784
-		foreach($inputs_to_exclude as $input_to_exclude_name){
783
+	public function exclude($inputs_to_exclude = array()) {
784
+		foreach ($inputs_to_exclude as $input_to_exclude_name) {
785 785
 			unset($this->_subsections[$input_to_exclude_name]);
786 786
 		}
787 787
 	}
@@ -792,8 +792,8 @@  discard block
 block discarded – undo
792 792
 	 * @param array $inputs_to_hide
793 793
 	 * @throws \EE_Error
794 794
 	 */
795
-	public function hide($inputs_to_hide= array()){
796
-		foreach($inputs_to_hide as $input_to_hide){
795
+	public function hide($inputs_to_hide = array()) {
796
+		foreach ($inputs_to_hide as $input_to_hide) {
797 797
 			$input = $this->get_input($input_to_hide);
798 798
 
799 799
 			$input->set_display_strategy(new EE_Hidden_Display_Strategy());
@@ -818,13 +818,13 @@  discard block
 block discarded – undo
818 818
 	 * @return void
819 819
 	 * @throws \EE_Error
820 820
 	 */
821
-	public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){
822
-		foreach($new_subsections as $subsection_name => $subsection){
823
-			if( ! $subsection instanceof EE_Form_Section_Base){
821
+	public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) {
822
+		foreach ($new_subsections as $subsection_name => $subsection) {
823
+			if ( ! $subsection instanceof EE_Form_Section_Base) {
824 824
 				EE_Error::add_error(
825 825
 					sprintf(
826 826
 						__("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"),
827
-						get_class( $subsection ),
827
+						get_class($subsection),
828 828
 						$subsection_name,
829 829
 						$this->name()
830 830
 					)
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 			}
834 834
 		}
835 835
 
836
-		$this->_subsections = EEH_Array::insert_into_array( $this->_subsections, $new_subsections, $subsection_name_to_target, $add_before );
836
+		$this->_subsections = EEH_Array::insert_into_array($this->_subsections, $new_subsections, $subsection_name_to_target, $add_before);
837 837
 
838 838
 		/*$subsections_before = array();
839 839
 		if( $subsection_name_to_target ){
@@ -864,8 +864,8 @@  discard block
 block discarded – undo
864 864
 				$this->_subsections = $new_subsections;
865 865
 			}
866 866
 		}*/
867
-		if( $this->_construction_finalized ){
868
-			foreach($this->_subsections as $name => $subsection){
867
+		if ($this->_construction_finalized) {
868
+			foreach ($this->_subsections as $name => $subsection) {
869 869
 				$subsection->_construct_finalize($this, $name);
870 870
 			}
871 871
 		}
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
 	/**
877 877
 	 * Just gets all validatable subsections to clean their sensitive data
878 878
 	 */
879
-	public function clean_sensitive_data(){
880
-		foreach($this->get_validatable_subsections() as $subsection){
879
+	public function clean_sensitive_data() {
880
+		foreach ($this->get_validatable_subsections() as $subsection) {
881 881
 			$subsection->clean_sensitive_data();
882 882
 		}
883 883
 	}
@@ -887,8 +887,8 @@  discard block
 block discarded – undo
887 887
 	/**
888 888
 	 * @param string $form_submission_error_message
889 889
 	 */
890
-	public function set_submission_error_message( $form_submission_error_message = '' ) {
891
-		$this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' );
890
+	public function set_submission_error_message($form_submission_error_message = '') {
891
+		$this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso');
892 892
 	}
893 893
 
894 894
 
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 	/**
906 906
 	 * @param string $form_submission_success_message
907 907
 	 */
908
-	public function set_submission_success_message( $form_submission_success_message ) {
909
-		$this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' );
908
+	public function set_submission_success_message($form_submission_success_message) {
909
+		$this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso');
910 910
 	}
911 911
 
912 912
 
@@ -929,10 +929,10 @@  discard block
 block discarded – undo
929 929
 	 * @return string
930 930
 	 * @throws \EE_Error
931 931
 	 */
932
-	public function html_name_prefix(){
933
-		if( $this->parent_section() instanceof EE_Form_Section_Proper ){
934
-			return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
935
-		}else{
932
+	public function html_name_prefix() {
933
+		if ($this->parent_section() instanceof EE_Form_Section_Proper) {
934
+			return $this->parent_section()->html_name_prefix().'['.$this->name().']';
935
+		} else {
936 936
 			return $this->name();
937 937
 		}
938 938
 	}
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 	 * @return string
948 948
 	 * @throws \EE_Error
949 949
 	 */
950
-	public function name(){
950
+	public function name() {
951 951
 		$this->ensure_construct_finalized_called();
952 952
 		return parent::name();
953 953
 	}
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 	 * @return EE_Form_Section_Proper
959 959
 	 * @throws \EE_Error
960 960
 	 */
961
-	public function parent_section(){
961
+	public function parent_section() {
962 962
 		$this->ensure_construct_finalized_called();
963 963
 		return parent::parent_section();
964 964
 	}
@@ -971,9 +971,9 @@  discard block
 block discarded – undo
971 971
 	 * @return void
972 972
 	 * @throws \EE_Error
973 973
 	 */
974
-	public function ensure_construct_finalized_called(){
975
-		if( ! $this->_construction_finalized ){
976
-			$this->_construct_finalize($this->_parent_section, $this->_name );
974
+	public function ensure_construct_finalized_called() {
975
+		if ( ! $this->_construction_finalized) {
976
+			$this->_construct_finalize($this->_parent_section, $this->_name);
977 977
 		}
978 978
 	}
979 979
 
@@ -985,17 +985,17 @@  discard block
 block discarded – undo
985 985
 	 * @param array $req_data
986 986
 	 * @return boolean
987 987
 	 */
988
-	public function form_data_present_in( $req_data = NULL ) {
989
-		if( $req_data === NULL){
988
+	public function form_data_present_in($req_data = NULL) {
989
+		if ($req_data === NULL) {
990 990
 			$req_data = $_POST;
991 991
 		}
992
-		foreach( $this->subsections() as $subsection ) {
993
-			if($subsection instanceof EE_Form_Input_Base ) {
994
-				if( $subsection->form_data_present_in( $req_data ) ) {
992
+		foreach ($this->subsections() as $subsection) {
993
+			if ($subsection instanceof EE_Form_Input_Base) {
994
+				if ($subsection->form_data_present_in($req_data)) {
995 995
 					return TRUE;
996 996
 				}
997
-			}elseif( $subsection instanceof EE_Form_Section_Proper ) {
998
-				if( $subsection->form_data_present_in( $req_data ) ) {
997
+			}elseif ($subsection instanceof EE_Form_Section_Proper) {
998
+				if ($subsection->form_data_present_in($req_data)) {
999 999
 					return TRUE;
1000 1000
 				}
1001 1001
 			}
@@ -1012,14 +1012,14 @@  discard block
 block discarded – undo
1012 1012
 	 */
1013 1013
 	public function get_validation_errors_accumulated() {
1014 1014
 		$validation_errors = $this->get_validation_errors();
1015
-		foreach($this->get_validatable_subsections() as $subsection ) {
1016
-			if( $subsection instanceof EE_Form_Section_Proper ) {
1015
+		foreach ($this->get_validatable_subsections() as $subsection) {
1016
+			if ($subsection instanceof EE_Form_Section_Proper) {
1017 1017
 				$validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1018 1018
 			} else {
1019
-				$validation_errors_on_this_subsection =  $subsection->get_validation_errors();
1019
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors();
1020 1020
 			}
1021
-			if( $validation_errors_on_this_subsection ){
1022
-				$validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection );
1021
+			if ($validation_errors_on_this_subsection) {
1022
+				$validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1023 1023
 			}
1024 1024
 		}
1025 1025
 		return $validation_errors;
@@ -1041,24 +1041,24 @@  discard block
 block discarded – undo
1041 1041
 	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1042 1042
 	 * @return EE_Form_Section_Base
1043 1043
 	 */
1044
-	public function find_section_from_path( $form_section_path ) {
1044
+	public function find_section_from_path($form_section_path) {
1045 1045
 		//check if we can find the input from purely going straight up the tree
1046
-		$input = parent::find_section_from_path( $form_section_path );
1047
-		if( $input instanceof EE_Form_Section_Base ) {
1046
+		$input = parent::find_section_from_path($form_section_path);
1047
+		if ($input instanceof EE_Form_Section_Base) {
1048 1048
 			return $input;
1049 1049
 		}
1050 1050
 
1051
-		$next_slash_pos = strpos( $form_section_path, '/' );
1052
-		if( $next_slash_pos !== false ) {
1053
-			$child_section_name = substr( $form_section_path, 0, $next_slash_pos );
1054
-			$subpath = substr( $form_section_path, $next_slash_pos + 1 );
1051
+		$next_slash_pos = strpos($form_section_path, '/');
1052
+		if ($next_slash_pos !== false) {
1053
+			$child_section_name = substr($form_section_path, 0, $next_slash_pos);
1054
+			$subpath = substr($form_section_path, $next_slash_pos + 1);
1055 1055
 		} else {
1056 1056
 			$child_section_name = $form_section_path;
1057 1057
 			$subpath = '';
1058 1058
 		}
1059
-		$child_section =  $this->get_subsection( $child_section_name );
1060
-		if ( $child_section instanceof EE_Form_Section_Base ) {
1061
-			return $child_section->find_section_from_path( $subpath );
1059
+		$child_section = $this->get_subsection($child_section_name);
1060
+		if ($child_section instanceof EE_Form_Section_Base) {
1061
+			return $child_section->find_section_from_path($subpath);
1062 1062
 		} else {
1063 1063
 			return null;
1064 1064
 		}
Please login to merge, or discard this patch.
core/db_models/helpers/EE_Table_Base.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * Base class for defining the tables that comprise models. This is used to store information
5 5
  * about the table\s alias, private key, etc.
6 6
  */
7
-abstract class EE_Table_Base{
7
+abstract class EE_Table_Base {
8 8
 
9 9
 	/**
10 10
 	 * This holds the table_name without the table prefix.
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 	 * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install,
42 42
 	 *					or whether each site on a multisite install has a copy of this table
43 43
 	 */
44
-	function __construct($table_name, $pk_column, $global = false ){
44
+	function __construct($table_name, $pk_column, $global = false) {
45 45
 		$this->_global = $global;
46 46
 		$prefix = $this->get_table_prefix();
47 47
 		//if they added the prefix, let's remove it because we delay adding the prefix until right when its needed.
48
-		if ( strpos( $table_name, $prefix ) === 0 ) {
49
-			$table_name = ltrim( $table_name, $prefix );
48
+		if (strpos($table_name, $prefix) === 0) {
49
+			$table_name = ltrim($table_name, $prefix);
50 50
 		}
51 51
 		$this->_table_name = $table_name;
52 52
 		$this->_pk_column = $pk_column;
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	public function get_table_prefix() {
65 65
 		global $wpdb;
66 66
 
67
-		if ( $this->_global ) {
67
+		if ($this->_global) {
68 68
 			$prefix = $wpdb->base_prefix;
69 69
 		} else {
70
-			$prefix = $wpdb->get_blog_prefix( EEM_Base::get_model_query_blog_id() );
70
+			$prefix = $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id());
71 71
 		}
72 72
 		return $prefix;
73 73
 	}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param string $table_alias
80 80
 	 */
81
-	function _construct_finalize_with_alias($table_alias){
81
+	function _construct_finalize_with_alias($table_alias) {
82 82
 		$this->_table_alias = $table_alias;
83 83
 	}
84 84
 
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 * Returns the fully qualified table name for the database (includes the table prefix current for the blog).
88 88
 	 * @return string
89 89
 	 */
90
-	function get_table_name(){
91
-		return $this->get_table_prefix() . $this->_table_name;
90
+	function get_table_name() {
91
+		return $this->get_table_prefix().$this->_table_name;
92 92
 	}
93 93
 
94 94
 
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 	 * @return string
101 101
 	 * @throws EE_Error
102 102
 	 */
103
-	function get_table_alias(){
104
-		if( ! $this->_table_alias){
103
+	function get_table_alias() {
104
+		if ( ! $this->_table_alias) {
105 105
 			throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?");
106 106
 		}
107 107
 		return $this->_table_alias;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return string name of column of PK
115 115
 	 */
116
-	function get_pk_column(){
116
+	function get_pk_column() {
117 117
 		return $this->_pk_column;
118 118
 	}
119 119
 
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 	 * returns a string with the table alias, a period, and the private key's column.
124 124
 	 * @return string
125 125
 	 */
126
-	function get_fully_qualified_pk_column(){
127
-		$sql =  $this->get_table_alias().".".$this->get_pk_column();
126
+	function get_fully_qualified_pk_column() {
127
+		$sql = $this->get_table_alias().".".$this->get_pk_column();
128 128
 		return $sql;
129 129
 	}
130 130
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 	 * returns the special sql for a inner select with a limit.
134 134
 	 * @return string    SQL select
135 135
 	 */
136
-	public function get_select_join_limit( $limit ) {
137
-		$limit = is_array( $limit ) ? 'LIMIT ' . implode(',', array_map( 'intval', $limit ) ) : 'LIMIT ' . (int) $limit;
138
-		$SQL = SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias;
136
+	public function get_select_join_limit($limit) {
137
+		$limit = is_array($limit) ? 'LIMIT '.implode(',', array_map('intval', $limit)) : 'LIMIT '.(int) $limit;
138
+		$SQL = SP.'(SELECT * FROM '.$this->_table_name.SP.$limit.') AS '.$this->_table_alias;
139 139
 		return $SQL;
140 140
 	}
141 141
 }
Please login to merge, or discard this patch.
modules/core_rest_api/EED_Core_Rest_Api.module.php 1 patch
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields;
3 3
 
4
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 /**
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public static function instance() {
37 37
 		self::$_field_calculator = new Calculated_Model_Fields();
38
-		return parent::get_instance( __CLASS__ );
38
+		return parent::get_instance(__CLASS__);
39 39
 	}
40 40
 
41 41
 
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 
66 66
 
67 67
 	public static function set_hooks_both() {
68
-		add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 );
69
-		add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 );
70
-		add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 );
71
-		add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) );
68
+		add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10);
69
+		add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5);
70
+		add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2);
71
+		add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index'));
72 72
 		EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change();
73 73
 	}
74 74
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * Loads all the hooks which make requests to old versions of the API
87 87
 	 * appear the same as they always did
88 88
 	 */
89
-	public static function set_hooks_for_changes(){
89
+	public static function set_hooks_for_changes() {
90 90
 		self::_set_hooks_for_changes();
91 91
 	}
92 92
 	/**
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
 	 * appear the same as they always did
95 95
 	 */
96 96
 	protected static function _set_hooks_for_changes() {
97
-		$folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false );
98
-		foreach( $folder_contents as $classname_in_namespace => $filepath ) {
97
+		$folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false);
98
+		foreach ($folder_contents as $classname_in_namespace => $filepath) {
99 99
 			//ignore the base parent class
100
-			if( $classname_in_namespace === 'Changes_In_Base' ) {
100
+			if ($classname_in_namespace === 'Changes_In_Base') {
101 101
 				continue;
102 102
 			}
103
-			$full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace;
104
-			if ( class_exists( $full_classname )) {
103
+			$full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace;
104
+			if (class_exists($full_classname)) {
105 105
 				$instance_of_class = new $full_classname;
106
-				if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) {
106
+				if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) {
107 107
 					$instance_of_class->set_hooks();
108 108
 				}
109 109
 			}
@@ -116,16 +116,16 @@  discard block
 block discarded – undo
116 116
 	 * so we actually prefer to only do it when an EE plugin is activated or upgraded
117 117
 	 */
118 118
 	public static function register_routes() {
119
-		foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) {
120
-			foreach( $relative_urls as $endpoint => $routes ) {
121
-				foreach( $routes as $route ) {
119
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
120
+			foreach ($relative_urls as $endpoint => $routes) {
121
+				foreach ($routes as $route) {
122 122
 					register_rest_route(
123 123
 						$namespace,
124 124
 						$endpoint,
125 125
 						array(
126
-							'callback' => $route[ 'callback' ],
127
-							'methods' => $route[ 'methods' ],
128
-							'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(),
126
+							'callback' => $route['callback'],
127
+							'methods' => $route['methods'],
128
+							'args' => isset($route['args']) ? $route['args'] : array(),
129 129
 						)
130 130
 					);
131 131
 				}
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 	 * next time the WP API is used
140 140
 	 */
141 141
 	public static function invalidate_cached_route_data_on_version_change() {
142
-		if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) {
142
+		if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) {
143 143
 			EED_Core_Rest_Api::invalidate_cached_route_data();
144 144
 		}
145
-		foreach( EE_Registry::instance()->addons as $addon ){
146
-			if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) {
145
+		foreach (EE_Registry::instance()->addons as $addon) {
146
+			if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) {
147 147
 				EED_Core_Rest_Api::invalidate_cached_route_data();
148 148
 			}
149 149
 		}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	public static function invalidate_cached_route_data() {
156 156
 		//delete the saved EE REST API routes
157
-		delete_option( EED_Core_Rest_Api::saved_routes_option_names );
157
+		delete_option(EED_Core_Rest_Api::saved_routes_option_names);
158 158
 	}
159 159
 
160 160
 	/**
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public static function get_ee_route_data() {
169 169
 		$ee_routes = array();
170
-		foreach( self::versions_served() as $version => $hidden_endpoints ) {
171
-			$ee_routes[  self::ee_api_namespace . $version ] = self::_get_ee_route_data_for_version( $version, $hidden_endpoints );
170
+		foreach (self::versions_served() as $version => $hidden_endpoints) {
171
+			$ee_routes[self::ee_api_namespace.$version] = self::_get_ee_route_data_for_version($version, $hidden_endpoints);
172 172
 		}
173 173
 		return $ee_routes;
174 174
 	}
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
 	 * @param boolean $hidden_endpoints
181 181
 	 * @return array
182 182
 	 */
183
-	protected static function _get_ee_route_data_for_version( $version, $hidden_endpoints = false ) {
184
-		$ee_routes = get_option( self::saved_routes_option_names . $version , null );
185
-		if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){
186
-			$ee_routes = self::_save_ee_route_data_for_version( $version, $hidden_endpoints );
183
+	protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) {
184
+		$ee_routes = get_option(self::saved_routes_option_names.$version, null);
185
+		if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) {
186
+			$ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints);
187 187
 		}
188 188
 		return $ee_routes;
189 189
 	}
@@ -193,18 +193,18 @@  discard block
 block discarded – undo
193 193
 	 * @param string $version
194 194
 	 * @param boolean $hidden_endpoints
195 195
 	 */
196
-	protected static function _save_ee_route_data_for_version( $version, $hidden_endpoints = false ) {
196
+	protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) {
197 197
 		$instance = self::instance();
198 198
 		$routes = apply_filters(
199 199
 			'EED_Core_Rest_Api__save_ee_route_data_for_version__routes',
200 200
 			array_replace_recursive(
201
-				$instance->_get_config_route_data_for_version( $version, $hidden_endpoints ),
202
-				$instance->_get_meta_route_data_for_version( $version, $hidden_endpoints ),
203
-				$instance->_get_model_route_data_for_version( $version, $hidden_endpoints ),
204
-				$instance->_get_rpc_route_data_for_version( $version, $hidden_endpoints )
201
+				$instance->_get_config_route_data_for_version($version, $hidden_endpoints),
202
+				$instance->_get_meta_route_data_for_version($version, $hidden_endpoints),
203
+				$instance->_get_model_route_data_for_version($version, $hidden_endpoints),
204
+				$instance->_get_rpc_route_data_for_version($version, $hidden_endpoints)
205 205
 			)
206 206
 		);
207
-		update_option( self::saved_routes_option_names . $version, $routes, true );
207
+		update_option(self::saved_routes_option_names.$version, $routes, true);
208 208
 		return $routes;
209 209
 	}
210 210
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 * @return void
216 216
 	 */
217 217
 	public static function save_ee_routes() {
218
-		if( EE_Maintenance_Mode::instance()->models_can_query() ){
218
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
219 219
 			$instance = self::instance();
220 220
 			$routes = apply_filters(
221 221
 				'EED_Core_Rest_Api__save_ee_routes__routes',
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 					$instance->_register_rpc_routes()
227 227
 				)
228 228
 			);
229
-			update_option( self::saved_routes_option_names, $routes, true );
229
+			update_option(self::saved_routes_option_names, $routes, true);
230 230
 		}
231 231
 	}
232 232
 
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	protected function _register_model_routes() {
239 239
 		$model_routes = array( );
240
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
241
-			$model_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint );
240
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
241
+			$model_routes[EED_Core_Rest_Api::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint);
242 242
 		}
243 243
 		return $model_routes;
244 244
 	}
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 	 * @param boolean $hidden_endpoint
250 250
 	 * @return array
251 251
 	 */
252
-	protected function _get_model_route_data_for_version( $version, $hidden_endpoint = false ) {
253
-		$model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info( $version );
252
+	protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) {
253
+		$model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version);
254 254
 		$models_to_register = apply_filters(
255 255
 			'FHEE__EED_Core_REST_API___register_model_routes',
256 256
 			$model_version_info->models_for_requested_version()
@@ -259,21 +259,21 @@  discard block
 block discarded – undo
259 259
 		unset($models_to_register['Extra_Meta']);
260 260
 		unset($models_to_register['Extra_Join']);
261 261
 		$model_routes = array();
262
-		foreach ( $models_to_register as $model_name => $model_classname ) {
263
-			$model = \EE_Registry::instance()->load_model( $model_name );
262
+		foreach ($models_to_register as $model_name => $model_classname) {
263
+			$model = \EE_Registry::instance()->load_model($model_name);
264 264
 			//yes we could just register one route for ALL models, but then they wouldn't show up in the index
265
-			$plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name );
266
-			$singular_model_route = $plural_model_route . '/(?P<id>\d+)' ;
267
-			$model_routes[ $plural_model_route ] = array(
265
+			$plural_model_route = EEH_Inflector::pluralize_and_lower($model_name);
266
+			$singular_model_route = $plural_model_route.'/(?P<id>\d+)';
267
+			$model_routes[$plural_model_route] = array(
268 268
 					array(
269 269
 						'callback' => array(
270 270
 							'EventEspresso\core\libraries\rest_api\controllers\model\Read',
271 271
 							'handle_request_get_all' ),
272 272
 						'methods' => WP_REST_Server::READABLE,
273 273
 						'hidden_endpoint' => $hidden_endpoint,
274
-						'args' => $this->_get_read_query_params( $model, $version ),
274
+						'args' => $this->_get_read_query_params($model, $version),
275 275
 						'_links' => array(
276
-							'self' => rest_url( EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route ),
276
+							'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace.$version.$singular_model_route),
277 277
 						)
278 278
 					),
279 279
 //						array(
@@ -284,14 +284,14 @@  discard block
 block discarded – undo
284 284
 //							'hidden_endpoint' => $hidden_endpoint
285 285
 //						)
286 286
 				);
287
-			$model_routes[ $singular_model_route ] = array(
287
+			$model_routes[$singular_model_route] = array(
288 288
 					array(
289 289
 						'callback' => array(
290 290
 							'EventEspresso\core\libraries\rest_api\controllers\model\Read',
291 291
 							'handle_request_get_one' ),
292 292
 						'methods' => WP_REST_Server::READABLE,
293 293
 						'hidden_endpoint' => $hidden_endpoint,
294
-						'args' => $this->_get_response_selection_query_params( $model, $version)
294
+						'args' => $this->_get_response_selection_query_params($model, $version)
295 295
 					),
296 296
 //						array(
297 297
 //							'callback' => array(
@@ -302,19 +302,19 @@  discard block
 block discarded – undo
302 302
 //							),
303 303
 			);
304 304
 			//@todo: also handle  DELETE for a single item
305
-			foreach ( $model->relation_settings() as $relation_name => $relation_obj ) {
305
+			foreach ($model->relation_settings() as $relation_name => $relation_obj) {
306 306
 				$related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name(
307 307
 					$relation_name,
308 308
 					$relation_obj
309 309
 				);
310
-				$model_routes[ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array(
310
+				$model_routes[$singular_model_route.'/'.$related_model_name_endpoint_part] = array(
311 311
 						array(
312 312
 							'callback' => array(
313 313
 								'EventEspresso\core\libraries\rest_api\controllers\model\Read',
314 314
 								'handle_request_get_related' ),
315 315
 							'methods' => WP_REST_Server::READABLE,
316 316
 							'hidden_endpoint' => $hidden_endpoint,
317
-							'args' => $this->_get_read_query_params( $relation_obj->get_other_model(), $version ),
317
+							'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version),
318 318
 						),
319 319
 //							array(
320 320
 //								'callback' => array(
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 	 */
338 338
 	protected function _register_rpc_routes() {
339 339
 		$routes = array();
340
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
341
-			$routes[ self::ee_api_namespace . $version ] = $this->_get_rpc_route_data_for_version( $version, $hidden_endpoint );
340
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
341
+			$routes[self::ee_api_namespace.$version] = $this->_get_rpc_route_data_for_version($version, $hidden_endpoint);
342 342
 		}
343 343
 		return $routes;
344 344
 	}
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
 	 * @param boolean $hidden_endpoint
350 350
 	 * @return array
351 351
 	 */
352
-	protected function _get_rpc_route_data_for_version( $version, $hidden_endpoint = false ) {
352
+	protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) {
353 353
 		$this_versions_routes = array();
354 354
 			//checkin endpoint
355
-			$this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array(
355
+			$this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array(
356 356
 				array(
357 357
 					'callback' => array(
358 358
 						'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin',
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 						'force' => array(
364 364
 							'required' => false,
365 365
 							'default' => false,
366
-							'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' )
366
+							'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso')
367 367
 						)
368 368
 					)
369 369
 				)
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 	 * @param string $version
383 383
 	 * @return array
384 384
 	 */
385
-	protected function _get_response_selection_query_params( \EEM_Base $model, $version ) {
385
+	protected function _get_response_selection_query_params(\EEM_Base $model, $version) {
386 386
 		return apply_filters(
387 387
 			'FHEE__EED_Core_Rest_Api___get_response_selection_query_params',
388 388
 			array(
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 				'calculate' => array(
394 394
 					'required' => false,
395 395
 					'default' => '',
396
-					'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model( $model )
396
+					'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model)
397 397
 				)
398 398
 			),
399 399
 			$model,
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 	 * @return array    describing the args acceptable when querying this model
412 412
 	 * @throws \EE_Error
413 413
 	 */
414
-	protected function _get_read_query_params( \EEM_Base $model, $version ) {
414
+	protected function _get_read_query_params(\EEM_Base $model, $version) {
415 415
 		$default_orderby = array();
416
-		foreach( $model->get_combined_primary_key_fields() as $key_field ) {
417
-			$default_orderby[ $key_field->get_name() ] = 'ASC';
416
+		foreach ($model->get_combined_primary_key_fields() as $key_field) {
417
+			$default_orderby[$key_field->get_name()] = 'ASC';
418 418
 		}
419 419
 		return array_merge(
420
-			$this->_get_response_selection_query_params( $model, $version ),
420
+			$this->_get_response_selection_query_params($model, $version),
421 421
 			array(
422 422
 				'where' => array(
423 423
 					'required' => false,
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	 */
455 455
 	protected function _register_config_routes() {
456 456
 		$config_routes = array();
457
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
458
-			$config_routes[ self::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version,	$hidden_endpoint );
457
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
458
+			$config_routes[self::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint);
459 459
 		}
460 460
 		return $config_routes;
461 461
 	}
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 * @param boolean $hidden_endpoint
467 467
 	 * @return array
468 468
 	 */
469
-	protected function _get_config_route_data_for_version( $version, $hidden_endpoint ) {
469
+	protected function _get_config_route_data_for_version($version, $hidden_endpoint) {
470 470
 		return array(
471 471
 			'config' => array(
472 472
 				array(
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
 	 */
488 488
 	protected function _register_meta_routes() {
489 489
 		$meta_routes = array();
490
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
491
-			$meta_routes[ self::ee_api_namespace . $version ] = $this->_get_meta_route_data_for_version( $version, $hidden_endpoint );
490
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
491
+			$meta_routes[self::ee_api_namespace.$version] = $this->_get_meta_route_data_for_version($version, $hidden_endpoint);
492 492
 		}
493 493
 		return $meta_routes;
494 494
 	}
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 	 * @param boolean $hidden_endpoint
500 500
 	 * @return array
501 501
 	 */
502
-	protected function _get_meta_route_data_for_version( $version, $hidden_endpoint = false ) {
502
+	protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) {
503 503
 		return array( 
504 504
 			'resources'  => array(
505 505
 				array(
@@ -521,13 +521,13 @@  discard block
 block discarded – undo
521 521
 	 * @param array $route_data
522 522
 	 * @return array
523 523
 	 */
524
-	public static function hide_old_endpoints( $route_data ) {
525
-		foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) {
526
-			foreach( $relative_urls as $endpoint => $routes ) {
527
-				foreach( $routes as $route ) {
528
-					if( $route[ 'hidden_endpoint' ] ) {
529
-						$full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' );
530
-						unset( $route_data[ $full_route ] );
524
+	public static function hide_old_endpoints($route_data) {
525
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
526
+			foreach ($relative_urls as $endpoint => $routes) {
527
+				foreach ($routes as $route) {
528
+					if ($route['hidden_endpoint']) {
529
+						$full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/');
530
+						unset($route_data[$full_route]);
531 531
 					}
532 532
 				}
533 533
 			}
@@ -566,8 +566,8 @@  discard block
 block discarded – undo
566 566
 	 */
567 567
 	public static function latest_rest_api_version() {
568 568
 		$versions_served = \EED_Core_Rest_Api::versions_served();
569
-		$versions_served_keys = array_keys( $versions_served );
570
-		return end( $versions_served_keys );
569
+		$versions_served_keys = array_keys($versions_served);
570
+		return end($versions_served_keys);
571 571
 	}
572 572
 
573 573
 	/**
@@ -581,32 +581,32 @@  discard block
 block discarded – undo
581 581
 	public static function versions_served() {
582 582
 		$versions_served = array();
583 583
 		$possibly_served_versions = EED_Core_Rest_Api::version_compatibilities();
584
-		$lowest_compatible_version = end( $possibly_served_versions);
585
-		reset( $possibly_served_versions );
586
-		$versions_served_historically = array_keys( $possibly_served_versions );
587
-		$latest_version = end( $versions_served_historically );
588
-		reset( $versions_served_historically );
584
+		$lowest_compatible_version = end($possibly_served_versions);
585
+		reset($possibly_served_versions);
586
+		$versions_served_historically = array_keys($possibly_served_versions);
587
+		$latest_version = end($versions_served_historically);
588
+		reset($versions_served_historically);
589 589
 		//for each version of core we have ever served:
590
-		foreach ( $versions_served_historically as $key_versioned_endpoint ) {
590
+		foreach ($versions_served_historically as $key_versioned_endpoint) {
591 591
 			//if it's not above the current core version, and it's compatible with the current version of core
592
-			if( $key_versioned_endpoint == $latest_version ) {
592
+			if ($key_versioned_endpoint == $latest_version) {
593 593
 				//don't hide the latest version in the index
594
-				$versions_served[ $key_versioned_endpoint ] = false;
595
-			} else if(
594
+				$versions_served[$key_versioned_endpoint] = false;
595
+			} else if (
596 596
 				$key_versioned_endpoint < EED_Core_Rest_Api::core_version()
597 597
 				&& $key_versioned_endpoint >= $lowest_compatible_version
598 598
 			) {
599 599
 				//include, but hide, previous versions which are still supported
600
-				$versions_served[ $key_versioned_endpoint ] = true;
601
-			} elseif(
600
+				$versions_served[$key_versioned_endpoint] = true;
601
+			} elseif (
602 602
 				apply_filters(
603 603
 					'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions',
604 604
 					false,
605 605
 					$possibly_served_versions
606 606
 				)
607
-			){
607
+			) {
608 608
 				//if a version is no longer supported, don't include it in index or list of versions served
609
-				$versions_served[ $key_versioned_endpoint ] = true;
609
+				$versions_served[$key_versioned_endpoint] = true;
610 610
 			}
611 611
 		}
612 612
 		return $versions_served;
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	 * @return string
620 620
 	 */
621 621
 	public static function core_version() {
622
-		return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) );
622
+		return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3)));
623 623
 	}
624 624
 
625 625
 	/**
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 	 * @param  WP $WP
645 645
 	 * @return    void
646 646
 	 */
647
-	public function run( $WP ) {
647
+	public function run($WP) {
648 648
 
649 649
 	}
650 650
 
Please login to merge, or discard this patch.
espresso.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'ABSPATH' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('ABSPATH')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
  *
42 42
  */
43 43
 
44
-if ( function_exists( 'espresso_version' ) ) {
44
+if (function_exists('espresso_version')) {
45 45
 
46 46
 	/**
47 47
 	 *    espresso_duplicate_plugin_error
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 	function espresso_duplicate_plugin_error() {
51 51
 		?>
52 52
 		<div class="error">
53
-			<p><?php _e( 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso' ); ?></p>
53
+			<p><?php _e('Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso'); ?></p>
54 54
 		</div>
55 55
 		<?php
56
-		espresso_deactivate_plugin( plugin_basename( __FILE__ ) );
56
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
57 57
 	}
58
-	add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 );
58
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59 59
 
60 60
 } else {
61 61
 
@@ -66,103 +66,103 @@  discard block
 block discarded – undo
66 66
 	 * @return string
67 67
 	 */
68 68
 	function espresso_version() {
69
-		return apply_filters( 'FHEE__espresso__espresso_version', '4.9.0.rc.037' );
69
+		return apply_filters('FHEE__espresso__espresso_version', '4.9.0.rc.037');
70 70
 	}
71 71
 
72 72
 	// define versions
73
-	define( 'EVENT_ESPRESSO_VERSION', espresso_version() );
74
-	define( 'EE_MIN_WP_VER_REQUIRED', '4.1' );
75
-	define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' );
76
-	define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' );
77
-	define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' );
78
-	define( 'EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - ' . EVENT_ESPRESSO_VERSION );
79
-	define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ );
73
+	define('EVENT_ESPRESSO_VERSION', espresso_version());
74
+	define('EE_MIN_WP_VER_REQUIRED', '4.1');
75
+	define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
76
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.0');
77
+	define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
78
+	define('EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - '.EVENT_ESPRESSO_VERSION);
79
+	define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
80 80
 	//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
81
-	if ( ! defined( 'DS' ) ) {
82
-		define( 'DS', '/' );
81
+	if ( ! defined('DS')) {
82
+		define('DS', '/');
83 83
 	}
84
-	if ( ! defined( 'PS' ) ) {
85
-		define( 'PS', PATH_SEPARATOR );
84
+	if ( ! defined('PS')) {
85
+		define('PS', PATH_SEPARATOR);
86 86
 	}
87
-	if ( ! defined( 'SP' ) ) {
88
-		define( 'SP', ' ' );
87
+	if ( ! defined('SP')) {
88
+		define('SP', ' ');
89 89
 	}
90
-	if ( ! defined( 'EENL' ) ) {
91
-		define( 'EENL', "\n" );
90
+	if ( ! defined('EENL')) {
91
+		define('EENL', "\n");
92 92
 	}
93
-	define( 'EE_SUPPORT_EMAIL', '[email protected]' );
93
+	define('EE_SUPPORT_EMAIL', '[email protected]');
94 94
 	// define the plugin directory and URL
95
-	define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) );
96
-	define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) );
97
-	define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) );
95
+	define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
96
+	define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
97
+	define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
98 98
 	// main root folder paths
99
-	define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS );
100
-	define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS );
101
-	define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS );
102
-	define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS );
103
-	define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS );
104
-	define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS );
105
-	define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS );
106
-	define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS );
99
+	define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS);
100
+	define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS);
101
+	define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS);
102
+	define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS);
103
+	define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS);
104
+	define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS);
105
+	define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS);
106
+	define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS);
107 107
 	// core system paths
108
-	define( 'EE_ADMIN', EE_CORE . 'admin' . DS );
109
-	define( 'EE_CPTS', EE_CORE . 'CPTs' . DS );
110
-	define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS );
111
-	define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS );
112
-	define( 'EE_BUSINESS', EE_CORE . 'business' . DS );
113
-	define( 'EE_MODELS', EE_CORE . 'db_models' . DS );
114
-	define( 'EE_HELPERS', EE_CORE . 'helpers' . DS );
115
-	define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS );
116
-	define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS );
117
-	define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS );
118
-	define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS );
119
-	define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS );
108
+	define('EE_ADMIN', EE_CORE.'admin'.DS);
109
+	define('EE_CPTS', EE_CORE.'CPTs'.DS);
110
+	define('EE_CLASSES', EE_CORE.'db_classes'.DS);
111
+	define('EE_INTERFACES', EE_CORE.'interfaces'.DS);
112
+	define('EE_BUSINESS', EE_CORE.'business'.DS);
113
+	define('EE_MODELS', EE_CORE.'db_models'.DS);
114
+	define('EE_HELPERS', EE_CORE.'helpers'.DS);
115
+	define('EE_LIBRARIES', EE_CORE.'libraries'.DS);
116
+	define('EE_TEMPLATES', EE_CORE.'templates'.DS);
117
+	define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS);
118
+	define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS);
119
+	define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS);
120 120
 	// gateways
121
-	define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS );
122
-	define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS );
121
+	define('EE_GATEWAYS', EE_MODULES.'gateways'.DS);
122
+	define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS);
123 123
 	// asset URL paths
124
-	define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS );
125
-	define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS );
126
-	define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS );
127
-	define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS );
128
-	define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' );
129
-	define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' );
124
+	define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS);
125
+	define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS);
126
+	define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS);
127
+	define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS);
128
+	define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/');
129
+	define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/');
130 130
 	// define upload paths
131 131
 	$uploads = wp_upload_dir();
132 132
 	// define the uploads directory and URL
133
-	define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS );
134
-	define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS );
133
+	define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS);
134
+	define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS);
135 135
 	// define the templates directory and URL
136
-	define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS );
137
-	define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS );
136
+	define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS);
137
+	define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS);
138 138
 	// define the gateway directory and URL
139
-	define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS );
140
-	define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS );
139
+	define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS);
140
+	define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS);
141 141
 	// languages folder/path
142
-	define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS );
143
-	define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS );
142
+	define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS);
143
+	define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS);
144 144
 	//check for dompdf fonts in uploads
145
-	if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) {
146
-		define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS );
145
+	if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) {
146
+		define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS);
147 147
 	}
148 148
 	//ajax constants
149
-	define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false );
150
-	define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false );
149
+	define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false);
150
+	define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false);
151 151
 	//just a handy constant occasionally needed for finding values representing infinity in the DB
152 152
 	//you're better to use this than its straight value (currently -1) in case you ever
153 153
 	//want to change its default value! or find when -1 means infinity
154
-	define( 'EE_INF_IN_DB', -1 );
155
-	define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX );
156
-	define( 'EE_DEBUG', false );
154
+	define('EE_INF_IN_DB', -1);
155
+	define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX);
156
+	define('EE_DEBUG', false);
157 157
 
158 158
 	/**
159 159
 	 *    espresso_plugin_activation
160 160
 	 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
161 161
 	 */
162 162
 	function espresso_plugin_activation() {
163
-		update_option( 'ee_espresso_activation', true );
163
+		update_option('ee_espresso_activation', true);
164 164
 	}
165
-	register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' );
165
+	register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
166 166
 
167 167
 
168 168
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		//	}
177 177
 		//
178 178
 	}
179
-	register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' );
179
+	register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
180 180
 
181 181
 
182 182
 
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	function espresso_load_error_handling() {
188 188
 		// load debugging tools
189
-		if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) {
190
-			require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' );
189
+		if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) {
190
+			require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php');
191 191
 			EEH_Debug_Tools::instance();
192 192
 		}
193 193
 		// load error handling
194
-		if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) {
195
-			require_once( EE_CORE . 'EE_Error.core.php' );
194
+		if (is_readable(EE_CORE.'EE_Error.core.php')) {
195
+			require_once(EE_CORE.'EE_Error.core.php');
196 196
 		} else {
197
-			wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) );
197
+			wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso'));
198 198
 		}
199 199
 	}
200 200
 
@@ -208,25 +208,25 @@  discard block
 block discarded – undo
208 208
 	 * @param    string $full_path_to_file
209 209
 	 * @throws    EE_Error
210 210
 	 */
211
-	function espresso_load_required( $classname, $full_path_to_file ) {
211
+	function espresso_load_required($classname, $full_path_to_file) {
212 212
 		static $error_handling_loaded = false;
213
-		if ( ! $error_handling_loaded ) {
213
+		if ( ! $error_handling_loaded) {
214 214
 			espresso_load_error_handling();
215 215
 			$error_handling_loaded = true;
216 216
 		}
217
-		if ( is_readable( $full_path_to_file ) ) {
218
-			require_once( $full_path_to_file );
217
+		if (is_readable($full_path_to_file)) {
218
+			require_once($full_path_to_file);
219 219
 		} else {
220
-			throw new EE_Error ( sprintf(
221
-				__( 'The %s class file could not be located or is not readable due to file permissions.', 'event_espresso' ),
220
+			throw new EE_Error(sprintf(
221
+				__('The %s class file could not be located or is not readable due to file permissions.', 'event_espresso'),
222 222
 				$classname
223
-			) );
223
+			));
224 224
 		}
225 225
 	}
226 226
 
227
-	espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' );
228
-	espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' );
229
-	espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' );
227
+	espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php');
228
+	espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php');
229
+	espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php');
230 230
 	new EE_Bootstrap();
231 231
 
232 232
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 
236 236
 
237 237
 
238
-if ( ! function_exists( 'espresso_deactivate_plugin' ) ) {
238
+if ( ! function_exists('espresso_deactivate_plugin')) {
239 239
 	/**
240 240
 	*    deactivate_plugin
241 241
 	* usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 	* @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
245 245
 	* @return    void
246 246
 	*/
247
-	function espresso_deactivate_plugin( $plugin_basename = '' ) {
248
-		if ( ! function_exists( 'deactivate_plugins' ) ) {
249
-			require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
247
+	function espresso_deactivate_plugin($plugin_basename = '') {
248
+		if ( ! function_exists('deactivate_plugins')) {
249
+			require_once(ABSPATH.'wp-admin/includes/plugin.php');
250 250
 		}
251
-		unset( $_GET[ 'activate' ] );
252
-		unset( $_REQUEST[ 'activate' ] );
253
-		deactivate_plugins( $plugin_basename );
251
+		unset($_GET['activate']);
252
+		unset($_REQUEST['activate']);
253
+		deactivate_plugins($plugin_basename);
254 254
 	}
255 255
 }
Please login to merge, or discard this patch.
core/EE_Error.core.php 1 patch
Spacing   +244 added lines, -244 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
 	
@@ -558,11 +558,11 @@  discard block
 block discarded – undo
558 558
 	 * @param string $line
559 559
 	 * @throws EE_Error
560 560
 	 */
561
-	public static function throw_exception_if_debugging( $msg = null, $file = null, $func = null, $line = null ) {
562
-		if( WP_DEBUG ) {
563
-			throw new EE_Error( $msg );
564
-		} else  {
565
-			EE_Error::add_error( $msg, $file, $func, $line );
561
+	public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null) {
562
+		if (WP_DEBUG) {
563
+			throw new EE_Error($msg);
564
+		} else {
565
+			EE_Error::add_error($msg, $file, $func, $line);
566 566
 		}
567 567
 	}
568 568
 
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 	* 	@param		string		$line	the line number where the error occurred - just use __LINE__
581 581
 	* 	@return 		void
582 582
 	*/
583
-	public static function add_success( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) {
584
-		self::_add_notice ( 'success', $msg, $file, $func, $line );
583
+	public static function add_success($msg = NULL, $file = NULL, $func = NULL, $line = NULL) {
584
+		self::_add_notice('success', $msg, $file, $func, $line);
585 585
 	}
586 586
 
587 587
 
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
 	* 	@param		string		$line	the line number where the error occurred - just use __LINE__
599 599
 	* 	@return 		void
600 600
 	*/
601
-	public static function add_attention( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) {
602
-		self::_add_notice ( 'attention', $msg, $file, $func, $line );
601
+	public static function add_attention($msg = NULL, $file = NULL, $func = NULL, $line = NULL) {
602
+		self::_add_notice('attention', $msg, $file, $func, $line);
603 603
 	}
604 604
 
605 605
 
@@ -617,12 +617,12 @@  discard block
 block discarded – undo
617 617
 	* 	@param		string		$line	the line number where the error occurred - just use __LINE__
618 618
 	* 	@return 		void
619 619
 	*/
620
-	private static function _add_notice( $type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) {
621
-		if ( empty( $msg )) {
620
+	private static function _add_notice($type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL) {
621
+		if (empty($msg)) {
622 622
 			EE_Error::doing_it_wrong(
623
-				'EE_Error::add_' . $type . '()',
623
+				'EE_Error::add_'.$type.'()',
624 624
 				sprintf(
625
-					__( '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' ),
625
+					__('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'),
626 626
 					$type,
627 627
 					$file,
628 628
 					$line
@@ -630,17 +630,17 @@  discard block
 block discarded – undo
630 630
 				EVENT_ESPRESSO_VERSION
631 631
 			);
632 632
 		}
633
-		if ( $type == 'errors' && ( empty( $file ) || empty( $func ) || empty( $line ))) {
633
+		if ($type == 'errors' && (empty($file) || empty($func) || empty($line))) {
634 634
 			EE_Error::doing_it_wrong(
635 635
 				'EE_Error::add_error()',
636
-				__('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' ),
636
+				__('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'),
637 637
 				EVENT_ESPRESSO_VERSION
638 638
 			);
639 639
 		}
640 640
 		// get separate user and developer messages if they exist
641
-		$msg = explode( '||', $msg );
641
+		$msg = explode('||', $msg);
642 642
 		$user_msg = $msg[0];
643
-		$dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0];
643
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
644 644
 		/**
645 645
 		 * Do an action so other code can be triggered when a notice is created
646 646
 		 * @param string $type can be 'errors', 'attention', or 'success'
@@ -650,22 +650,22 @@  discard block
 block discarded – undo
650 650
 		 * @param string $func function where error was generated
651 651
 		 * @param string $line line where error was generated
652 652
 		 */
653
-		do_action( 'AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line );
653
+		do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
654 654
 		$msg = WP_DEBUG ? $dev_msg : $user_msg;
655 655
 		// add notice if message exists
656
-		if ( ! empty( $msg )) {
656
+		if ( ! empty($msg)) {
657 657
 			// get error code
658
-			$notice_code = EE_Error::generate_error_code( $file, $func, $line );
659
-			if ( WP_DEBUG && $type == 'errors' ) {
660
-				$msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
658
+			$notice_code = EE_Error::generate_error_code($file, $func, $line);
659
+			if (WP_DEBUG && $type == 'errors') {
660
+				$msg .= '<br/><span class="tiny-text">'.$notice_code.'</span>';
661 661
 			}
662 662
 			// add notice. Index by code if it's not blank
663
-			if( $notice_code ) {
664
-				self::$_espresso_notices[ $type ][ $notice_code ] = $msg;
663
+			if ($notice_code) {
664
+				self::$_espresso_notices[$type][$notice_code] = $msg;
665 665
 			} else {
666
-				self::$_espresso_notices[ $type ][] = $msg;
666
+				self::$_espresso_notices[$type][] = $msg;
667 667
 			}
668
-			add_action( 'wp_footer', array( 'EE_Error', 'enqueue_error_scripts' ), 1 );
668
+			add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
669 669
 		}
670 670
 
671 671
 	}
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 	*	@access private
720 720
 	*	@return void
721 721
 	*/
722
-	public static function reset_notices(){
722
+	public static function reset_notices() {
723 723
     	self::$_espresso_notices['success'] = FALSE;
724 724
     	self::$_espresso_notices['attention'] = FALSE;
725 725
     	self::$_espresso_notices['errors'] = FALSE;
@@ -732,14 +732,14 @@  discard block
 block discarded – undo
732 732
 	*	@access public
733 733
 	*	@return int
734 734
 	*/
735
-    public static function has_notices(){
735
+    public static function has_notices() {
736 736
 		$has_notices = 0;
737 737
 		// check for success messages
738
-		$has_notices = self::$_espresso_notices['success'] && ! empty(  self::$_espresso_notices['success'] ) ? 3 : $has_notices;
738
+		$has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 : $has_notices;
739 739
 		// check for attention messages
740
-		$has_notices = self::$_espresso_notices['attention'] && ! empty(  self::$_espresso_notices['attention'] ) ? 2 : $has_notices;
740
+		$has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 : $has_notices;
741 741
 		// check for error messages
742
-		$has_notices = self::$_espresso_notices['errors'] && ! empty(  self::$_espresso_notices['errors'] ) ? 1 : $has_notices;
742
+		$has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 : $has_notices;
743 743
 		return $has_notices;
744 744
 	}
745 745
 
@@ -754,9 +754,9 @@  discard block
 block discarded – undo
754 754
 	 */
755 755
 	public static function get_vanilla_notices() {
756 756
 		return array(
757
-			'success' => isset( self::$_espresso_notices['success'] ) ? self::$_espresso_notices['success'] : array(),
758
-			'attention' => isset( self::$_espresso_notices['attention'] )  ? self::$_espresso_notices['attention'] : array(),
759
-			'errors' => isset( self::$_espresso_notices['errors'] ) ? self::$_espresso_notices['errors'] : array(),
757
+			'success' => isset(self::$_espresso_notices['success']) ? self::$_espresso_notices['success'] : array(),
758
+			'attention' => isset(self::$_espresso_notices['attention']) ? self::$_espresso_notices['attention'] : array(),
759
+			'errors' => isset(self::$_espresso_notices['errors']) ? self::$_espresso_notices['errors'] : array(),
760 760
 		);
761 761
 	}
762 762
 
@@ -772,8 +772,8 @@  discard block
 block discarded – undo
772 772
 	* 	@param		boolean		$remove_empty		whether or not to unset empty messages
773 773
 	* 	@return 		array
774 774
 	*/
775
-	public static function get_notices( $format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE ) {
776
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
775
+	public static function get_notices($format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE) {
776
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
777 777
 
778 778
 		$success_messages = '';
779 779
 		$attention_messages = '';
@@ -783,44 +783,44 @@  discard block
 block discarded – undo
783 783
 		// 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' );
784 784
 
785 785
 		// either save notices to the db
786
-		if ( $save_to_transient ) {
787
-			update_option( 'ee_notices', self::$_espresso_notices );
786
+		if ($save_to_transient) {
787
+			update_option('ee_notices', self::$_espresso_notices);
788 788
 			return;
789 789
 		}
790 790
 		// grab any notices that have been previously saved
791
-		if ( $notices = get_option( 'ee_notices', FALSE )) {
792
-			foreach ( $notices as $type => $notice ) {
793
-				if ( is_array( $notice ) && ! empty( $notice )) {
791
+		if ($notices = get_option('ee_notices', FALSE)) {
792
+			foreach ($notices as $type => $notice) {
793
+				if (is_array($notice) && ! empty($notice)) {
794 794
 					// make sure that existsing notice type is an array
795
-					self::$_espresso_notices[ $type ] =  is_array( self::$_espresso_notices[ $type ] ) && ! empty( self::$_espresso_notices[ $type ] ) ? self::$_espresso_notices[ $type ] : array();
795
+					self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) && ! empty(self::$_espresso_notices[$type]) ? self::$_espresso_notices[$type] : array();
796 796
 					// merge stored notices with any newly created ones
797
-					self::$_espresso_notices[ $type ] = array_merge( self::$_espresso_notices[ $type ], $notice );
797
+					self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice);
798 798
 					$print_scripts = TRUE;
799 799
 				}
800 800
 			}
801 801
 			// now clear any stored notices
802
-			update_option( 'ee_notices', FALSE );
802
+			update_option('ee_notices', FALSE);
803 803
 		}
804 804
 
805 805
 		// check for success messages
806
-		if ( self::$_espresso_notices['success'] && ! empty(  self::$_espresso_notices['success'] )) {
806
+		if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
807 807
 			// combine messages
808
-			$success_messages .= implode( self::$_espresso_notices['success'], '<br />' );
808
+			$success_messages .= implode(self::$_espresso_notices['success'], '<br />');
809 809
 			$print_scripts = TRUE;
810 810
 		}
811 811
 
812 812
 		// check for attention messages
813
-		if ( self::$_espresso_notices['attention'] && ! empty(  self::$_espresso_notices['attention'] ) ) {
813
+		if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
814 814
 			// combine messages
815
-			$attention_messages .= implode( self::$_espresso_notices['attention'], '<br />' );
815
+			$attention_messages .= implode(self::$_espresso_notices['attention'], '<br />');
816 816
 			$print_scripts = TRUE;
817 817
 		}
818 818
 
819 819
 		// check for error messages
820
-		if ( self::$_espresso_notices['errors'] && ! empty(  self::$_espresso_notices['errors'] ) ) {
821
-			$error_messages .= count( self::$_espresso_notices['errors'] ) > 1 ? __( 'The following errors have occurred:<br />', 'event_espresso' ) : __( 'An error has occurred:<br />', 'event_espresso' );
820
+		if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
821
+			$error_messages .= count(self::$_espresso_notices['errors']) > 1 ? __('The following errors have occurred:<br />', 'event_espresso') : __('An error has occurred:<br />', 'event_espresso');
822 822
 			// combine messages
823
-			$error_messages .= implode( self::$_espresso_notices['errors'], '<br />' );
823
+			$error_messages .= implode(self::$_espresso_notices['errors'], '<br />');
824 824
 			$print_scripts = TRUE;
825 825
 		}
826 826
 
@@ -834,21 +834,21 @@  discard block
 block discarded – undo
834 834
 				$css_id = is_admin() ? 'message' : 'espresso-notices-success';
835 835
 				$css_class = is_admin() ? 'updated fade' : 'success fade-away';
836 836
 				//showMessage( $success_messages );
837
-				$notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $success_messages . '</p>' . $close . '</div>';
837
+				$notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$success_messages.'</p>'.$close.'</div>';
838 838
 			}
839 839
 
840 840
 			if ($attention_messages != '') {
841 841
 				$css_id = is_admin() ? 'message' : 'espresso-notices-attention';
842 842
 				$css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
843 843
 				//showMessage( $error_messages, TRUE );
844
-				$notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $attention_messages . '</p>' . $close . '</div>';
844
+				$notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$attention_messages.'</p>'.$close.'</div>';
845 845
 			}
846 846
 
847 847
 			if ($error_messages != '') {
848 848
 				$css_id = is_admin() ? 'message' : 'espresso-notices-error';
849 849
 				$css_class = is_admin() ? 'error' : 'error fade-away';
850 850
 				//showMessage( $error_messages, TRUE );
851
-				$notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $error_messages . '</p>' . $close . '</div>';
851
+				$notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$error_messages.'</p>'.$close.'</div>';
852 852
 			}
853 853
 
854 854
 			$notices .= '</div>';
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 					'errors' => $error_messages
862 862
 			);
863 863
 
864
-			if ( $remove_empty ) {
864
+			if ($remove_empty) {
865 865
 				// remove empty notices
866 866
 				foreach ($notices as $type => $notice) {
867 867
 					if (empty($notice)) {
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 			}
872 872
 		}
873 873
 
874
-		if ( $print_scripts ) {
874
+		if ($print_scripts) {
875 875
 			self::_print_scripts();
876 876
 		}
877 877
 
@@ -891,17 +891,17 @@  discard block
 block discarded – undo
891 891
 	* 	@param bool $force_update allows one to enforce the reappearance of a persistent message.
892 892
 	* 	@return 		void
893 893
 	*/
894
-	public static function add_persistent_admin_notice( $pan_name = '', $pan_message, $force_update = FALSE ) {
895
-		if ( ! empty( $pan_name ) && ! empty( $pan_message )) {
896
-			$persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() );
894
+	public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = FALSE) {
895
+		if ( ! empty($pan_name) && ! empty($pan_message)) {
896
+			$persistent_admin_notices = get_option('ee_pers_admin_notices', array());
897 897
 			//maybe initialize persistent_admin_notices
898
-			if ( empty( $persistent_admin_notices )) {
899
-				add_option( 'ee_pers_admin_notices', array(), '', 'no' );
898
+			if (empty($persistent_admin_notices)) {
899
+				add_option('ee_pers_admin_notices', array(), '', 'no');
900 900
 			}
901
-			$pan_name = sanitize_key( $pan_name );
902
-			if ( ! array_key_exists( $pan_name, $persistent_admin_notices ) || $force_update ) {
903
-				$persistent_admin_notices[ $pan_name ] = $pan_message;
904
-				update_option( 'ee_pers_admin_notices', $persistent_admin_notices );
901
+			$pan_name = sanitize_key($pan_name);
902
+			if ( ! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) {
903
+				$persistent_admin_notices[$pan_name] = $pan_message;
904
+				update_option('ee_pers_admin_notices', $persistent_admin_notices);
905 905
 			}
906 906
 		}
907 907
 	}
@@ -917,34 +917,34 @@  discard block
 block discarded – undo
917 917
 	 * @param bool          $return_immediately
918 918
 	 * @return        void
919 919
 	 */
920
-	public static function dismiss_persistent_admin_notice( $pan_name = '', $purge = FALSE, $return_immediately = FALSE ) {
921
-		$pan_name = EE_Registry::instance()->REQ->is_set( 'ee_nag_notice' ) ? EE_Registry::instance()->REQ->get( 'ee_nag_notice' ) : $pan_name;
922
-		if ( ! empty( $pan_name )) {
923
-			$persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() );
920
+	public static function dismiss_persistent_admin_notice($pan_name = '', $purge = FALSE, $return_immediately = FALSE) {
921
+		$pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name;
922
+		if ( ! empty($pan_name)) {
923
+			$persistent_admin_notices = get_option('ee_pers_admin_notices', array());
924 924
 			// check if notice we wish to dismiss is actually in the $persistent_admin_notices array
925
-			if ( is_array( $persistent_admin_notices ) && isset( $persistent_admin_notices[ $pan_name ] )) {
925
+			if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) {
926 926
 				// completely delete nag notice, or just NULL message so that it can NOT be added again ?
927
-				if ( $purge ) {
928
-					unset( $persistent_admin_notices[ $pan_name ] );
927
+				if ($purge) {
928
+					unset($persistent_admin_notices[$pan_name]);
929 929
 				} else {
930
-					$persistent_admin_notices[ $pan_name ] = NULL;
930
+					$persistent_admin_notices[$pan_name] = NULL;
931 931
 				}
932
-				if ( update_option( 'ee_pers_admin_notices', $persistent_admin_notices ) === FALSE ) {
933
-					EE_Error::add_error( sprintf( __( 'The persistent admin notice for "%s" could not be deleted.', 'event_espresso' ), $pan_name ), __FILE__, __FUNCTION__, __LINE__ );
932
+				if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === FALSE) {
933
+					EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__);
934 934
 				}
935 935
 			}
936 936
 		}
937
-		if ( $return_immediately ) {
937
+		if ($return_immediately) {
938 938
 			return;
939
-		} else if ( EE_Registry::instance()->REQ->ajax ) {
939
+		} else if (EE_Registry::instance()->REQ->ajax) {
940 940
 			// grab any notices and concatenate into string
941
-			echo json_encode( array( 'errors' => implode( '<br />', EE_Error::get_notices( FALSE ))));
941
+			echo json_encode(array('errors' => implode('<br />', EE_Error::get_notices(FALSE))));
942 942
 			exit();
943 943
 		} else {
944 944
 			// save errors to a transient to be displayed on next request (after redirect)
945
-			EE_Error::get_notices( FALSE, TRUE );
946
-			$return_url = EE_Registry::instance()->REQ->is_set( 'return_url' ) ? EE_Registry::instance()->REQ->get( 'return_url' ) : '';
947
-			wp_safe_redirect( urldecode( $return_url ));
945
+			EE_Error::get_notices(FALSE, TRUE);
946
+			$return_url = EE_Registry::instance()->REQ->is_set('return_url') ? EE_Registry::instance()->REQ->get('return_url') : '';
947
+			wp_safe_redirect(urldecode($return_url));
948 948
 		}
949 949
 	}
950 950
 
@@ -959,20 +959,20 @@  discard block
 block discarded – undo
959 959
 	* 	@param		string	$return_url	URL to go back to aftger nag notice is dismissed
960 960
 	 *  	@return 		string
961 961
 	 */
962
-	public static function display_persistent_admin_notices( $pan_name = '', $pan_message = '', $return_url = '' ) {
963
-		if ( ! empty( $pan_name ) && ! empty( $pan_message )) {
962
+	public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') {
963
+		if ( ! empty($pan_name) && ! empty($pan_message)) {
964 964
 			$args = array(
965 965
 				'nag_notice' => $pan_name,
966
-				'return_url' => urlencode( $return_url ),
966
+				'return_url' => urlencode($return_url),
967 967
 				'ajax_url' => WP_AJAX_URL,
968
-				'unknown_error' => __( 'An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso' )
968
+				'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso')
969 969
 			);
970
-			wp_localize_script( 'espresso_core', 'ee_dismiss', $args );
970
+			wp_localize_script('espresso_core', 'ee_dismiss', $args);
971 971
 			return '
972
-			<div id="' . $pan_name . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;">
973
-				<p>' . $pan_message . '</p>
974
-				<a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name . '">
975
-					<span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__( 'Dismiss', 'event_espresso' ) .'
972
+			<div id="' . $pan_name.'" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;">
973
+				<p>' . $pan_message.'</p>
974
+				<a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name.'">
975
+					<span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__('Dismiss', 'event_espresso').'
976 976
 				</a>
977 977
 				<div style="clear:both;"></div>
978 978
 			</div>';
@@ -988,24 +988,24 @@  discard block
 block discarded – undo
988 988
 	 * @param string $return_url
989 989
 	 * @return    array
990 990
 	 */
991
-	public static function get_persistent_admin_notices( $return_url = '' ) {
991
+	public static function get_persistent_admin_notices($return_url = '') {
992 992
 		$notices = '';
993 993
 		// check for persistent admin notices
994 994
 		//filter the list though so plugins can notify the admin in a different way if they want
995 995
 		$persistent_admin_notices = apply_filters( 
996 996
 			'FHEE__EE_Error__get_persistent_admin_notices',
997
-			get_option( 'ee_pers_admin_notices', FALSE ),
997
+			get_option('ee_pers_admin_notices', FALSE),
998 998
 			'ee_pers_admin_notices',
999 999
 			$return_url
1000 1000
 		);
1001
-		if ( $persistent_admin_notices ) {
1001
+		if ($persistent_admin_notices) {
1002 1002
 			// load scripts
1003
-			wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE );
1004
-			wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE );
1005
-			wp_enqueue_script( 'ee_error_js' );
1003
+			wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
1004
+			wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE);
1005
+			wp_enqueue_script('ee_error_js');
1006 1006
 			// and display notices
1007
-			foreach( $persistent_admin_notices as $pan_name => $pan_message ) {
1008
-				$notices .= self::display_persistent_admin_notices( $pan_name, $pan_message, $return_url );
1007
+			foreach ($persistent_admin_notices as $pan_name => $pan_message) {
1008
+				$notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url);
1009 1009
 			}
1010 1010
 		}
1011 1011
 		return $notices;
@@ -1020,26 +1020,26 @@  discard block
 block discarded – undo
1020 1020
 	 * @param 	bool $force_print
1021 1021
 	 * @return 	void
1022 1022
 	 */
1023
-	private static function _print_scripts( $force_print = FALSE ) {
1024
-		if (( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' )) && ! $force_print ) {
1025
-			if ( wp_script_is( 'ee_error_js', 'enqueued' )) {
1023
+	private static function _print_scripts($force_print = FALSE) {
1024
+		if ((did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts')) && ! $force_print) {
1025
+			if (wp_script_is('ee_error_js', 'enqueued')) {
1026 1026
 				return;
1027
-			} else if ( wp_script_is( 'ee_error_js', 'registered' )) {
1028
-				add_filter( 'FHEE_load_css', '__return_true' );
1029
-				add_filter( 'FHEE_load_js', '__return_true' );
1030
-				wp_enqueue_script( 'ee_error_js' );
1031
-				wp_localize_script( 'ee_error_js','ee_settings', array( 'wp_debug'=>WP_DEBUG ));
1027
+			} else if (wp_script_is('ee_error_js', 'registered')) {
1028
+				add_filter('FHEE_load_css', '__return_true');
1029
+				add_filter('FHEE_load_js', '__return_true');
1030
+				wp_enqueue_script('ee_error_js');
1031
+				wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug'=>WP_DEBUG));
1032 1032
 			}
1033 1033
 		} else {
1034 1034
 			return '
1035 1035
 <script>
1036 1036
 /* <![CDATA[ */
1037
-var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
1037
+var ee_settings = {"wp_debug":"' . WP_DEBUG.'"};
1038 1038
 /* ]]> */
1039 1039
 </script>
1040
-<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script>
1041
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1042
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1040
+<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script>
1041
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
1042
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
1043 1043
 ';
1044 1044
 
1045 1045
 		}
@@ -1073,11 +1073,11 @@  discard block
 block discarded – undo
1073 1073
 	*	@ param string $line
1074 1074
 	*	@ return string
1075 1075
 	*/
1076
-	public static function generate_error_code ( $file = '', $func = '', $line = '' ) {
1077
-		$file = explode( '.', basename( $file ));
1078
-		$error_code = ! empty( $file[0] ) ? $file[0] : '';
1079
-		$error_code .= ! empty( $func ) ? ' - ' . $func : '';
1080
-		$error_code .= ! empty( $line ) ? ' - ' . $line : '';
1076
+	public static function generate_error_code($file = '', $func = '', $line = '') {
1077
+		$file = explode('.', basename($file));
1078
+		$error_code = ! empty($file[0]) ? $file[0] : '';
1079
+		$error_code .= ! empty($func) ? ' - '.$func : '';
1080
+		$error_code .= ! empty($line) ? ' - '.$line : '';
1081 1081
 		return $error_code;
1082 1082
 	}
1083 1083
 
@@ -1093,36 +1093,36 @@  discard block
 block discarded – undo
1093 1093
 	*	@ param object $ex
1094 1094
 	*	@ return void
1095 1095
 	*/
1096
-	public function write_to_error_log ( $time = FALSE, $ex = FALSE, $clear = FALSE ) {
1096
+	public function write_to_error_log($time = FALSE, $ex = FALSE, $clear = FALSE) {
1097 1097
 
1098
-		if ( ! $ex ) {
1098
+		if ( ! $ex) {
1099 1099
 			return;
1100 1100
 		}
1101 1101
 
1102
-		if ( ! $time ) {
1102
+		if ( ! $time) {
1103 1103
 			$time = time();
1104 1104
 		}
1105 1105
 
1106
-		$exception_log = '----------------------------------------------------------------------------------------' . PHP_EOL;
1107
-		$exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . ']  Exception Details' . PHP_EOL;
1108
-		$exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
1109
-		$exception_log .= 'Code: '. $ex['code'] . PHP_EOL;
1110
-		$exception_log .= 'File: '. $ex['file'] . PHP_EOL;
1111
-		$exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
1112
-		$exception_log .= 'Stack trace: ' . PHP_EOL;
1113
-		$exception_log .= $ex['string'] . PHP_EOL;
1114
-		$exception_log .= '----------------------------------------------------------------------------------------' . PHP_EOL;
1106
+		$exception_log = '----------------------------------------------------------------------------------------'.PHP_EOL;
1107
+		$exception_log .= '['.date('Y-m-d H:i:s', $time).']  Exception Details'.PHP_EOL;
1108
+		$exception_log .= 'Message: '.$ex['msg'].PHP_EOL;
1109
+		$exception_log .= 'Code: '.$ex['code'].PHP_EOL;
1110
+		$exception_log .= 'File: '.$ex['file'].PHP_EOL;
1111
+		$exception_log .= 'Line No: '.$ex['line'].PHP_EOL;
1112
+		$exception_log .= 'Stack trace: '.PHP_EOL;
1113
+		$exception_log .= $ex['string'].PHP_EOL;
1114
+		$exception_log .= '----------------------------------------------------------------------------------------'.PHP_EOL;
1115 1115
 
1116 1116
 		try {
1117
-			EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file );
1118
-			EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' ); 
1119
-			if ( ! $clear ) {
1117
+			EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file);
1118
+			EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs'); 
1119
+			if ( ! $clear) {
1120 1120
 				//get existing log file and append new log info
1121
-				$exception_log = EEH_File::get_file_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ) . $exception_log;
1121
+				$exception_log = EEH_File::get_file_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file).$exception_log;
1122 1122
 			}
1123
-			EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, $exception_log );
1124
-		} catch( EE_Error $e ){
1125
-			EE_Error::add_error( sprintf( __(  'Event Espresso error logging could not be setup because: %s', 'event_espresso' ), $e->getMessage() ));
1123
+			EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file, $exception_log);
1124
+		} catch (EE_Error $e) {
1125
+			EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', 'event_espresso'), $e->getMessage()));
1126 1126
 			return;
1127 1127
 		}
1128 1128
 
@@ -1146,9 +1146,9 @@  discard block
 block discarded – undo
1146 1146
 	 * @param int     $error_type
1147 1147
 	 * @return void
1148 1148
 	 */
1149
-	public static function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) {
1150
-		if ( defined('WP_DEBUG') && WP_DEBUG ) {
1151
-			EEH_Debug_Tools::instance()->doing_it_wrong( $function, $message, $version, $error_type );
1149
+	public static function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) {
1150
+		if (defined('WP_DEBUG') && WP_DEBUG) {
1151
+			EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $error_type);
1152 1152
 		}
1153 1153
 	}
1154 1154
 	
@@ -1180,13 +1180,13 @@  discard block
 block discarded – undo
1180 1180
  */
1181 1181
 function espresso_error_enqueue_scripts() {
1182 1182
 	// js for error handling
1183
-	wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE );
1184
-	wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE );
1183
+	wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE);
1184
+	wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE);
1185 1185
 }
1186
-if ( is_admin() ) {
1187
-	add_action( 'admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 );
1186
+if (is_admin()) {
1187
+	add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1188 1188
 } else {
1189
-	add_action( 'wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 );
1189
+	add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1190 1190
 }
1191 1191
 
1192 1192
 
Please login to merge, or discard this patch.