Completed
Branch FET-9784-autopopulate-forms (4bc800)
by
unknown
403:32 queued 388:51
created
core/libraries/form_sections/base/EE_Form_Section_Proper.form.php 1 patch
Spacing   +199 added lines, -199 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
 	const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data';
13 13
 
@@ -71,49 +71,49 @@  discard block
 block discarded – undo
71 71
 	 *                               } @see EE_Form_Section_Validatable::__construct()
72 72
 	 * @throws \EE_Error
73 73
 	 */
74
-	public function __construct( $options_array = array() ){
75
-		$options_array = (array) apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this );
74
+	public function __construct($options_array = array()) {
75
+		$options_array = (array) apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this);
76 76
 		//call parent first, as it may be setting the name
77 77
 		parent::__construct($options_array);
78 78
 		//if they've included subsections in the constructor, add them now
79
-		if( isset( $options_array['include'] )){
79
+		if (isset($options_array['include'])) {
80 80
 			//we are going to make sure we ONLY have those subsections to include
81 81
 			//AND we are going to make sure they're in that specified order
82 82
 			$reordered_subsections = array();
83
-			foreach($options_array['include'] as $input_name){
84
-				if(isset($this->_subsections[$input_name])){
83
+			foreach ($options_array['include'] as $input_name) {
84
+				if (isset($this->_subsections[$input_name])) {
85 85
 					$reordered_subsections[$input_name] = $this->_subsections[$input_name];
86 86
 				}
87 87
 			}
88 88
 			$this->_subsections = $reordered_subsections;
89 89
 		}
90
-		if(isset($options_array['exclude'])){
90
+		if (isset($options_array['exclude'])) {
91 91
 			$exclude = $options_array['exclude'];
92 92
 			$this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
93 93
 		}
94
-		if(isset($options_array['layout_strategy'])){
94
+		if (isset($options_array['layout_strategy'])) {
95 95
 			$this->_layout_strategy = $options_array['layout_strategy'];
96 96
 		}
97
-		if( ! $this->_layout_strategy){
97
+		if ( ! $this->_layout_strategy) {
98 98
 			$this->_layout_strategy = new EE_Two_Column_Layout();
99 99
 		}
100 100
 		$this->_layout_strategy->_construct_finalize($this);
101 101
 
102 102
 		//ok so we are definitely going to want the forms JS,
103 103
 		//so enqueue it or remember to enqueue it during wp_enqueue_scripts
104
-		if( did_action( 'wp_enqueue_scripts' )
105
-			|| did_action( 'admin_enqueue_scripts' ) ) {
104
+		if (did_action('wp_enqueue_scripts')
105
+			|| did_action('admin_enqueue_scripts')) {
106 106
 			//ok so they've constructed this object after when they should have.
107 107
 			//just enqueue the generic form scripts and initialize the form immediately in the JS
108
-			\EE_Form_Section_Proper::wp_enqueue_scripts( true );
108
+			\EE_Form_Section_Proper::wp_enqueue_scripts(true);
109 109
 		} else {
110
-			add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' ));
111
-			add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' ));
110
+			add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
111
+			add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
112 112
 		}
113
-		add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 );
113
+		add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
114 114
 
115
-		if( isset( $options_array[ 'name' ] ) ) {
116
-			$this->_construct_finalize( null, $options_array[ 'name' ] );
115
+		if (isset($options_array['name'])) {
116
+			$this->_construct_finalize(null, $options_array['name']);
117 117
 		}
118 118
 	}
119 119
 
@@ -126,25 +126,25 @@  discard block
 block discarded – undo
126 126
 	 * @param string                 $name
127 127
 	 * @throws \EE_Error
128 128
 	 */
129
-	public function _construct_finalize( $parent_form_section, $name ) {
129
+	public function _construct_finalize($parent_form_section, $name) {
130 130
 		parent::_construct_finalize($parent_form_section, $name);
131 131
 		$this->_set_default_name_if_empty();
132 132
 		$this->_set_default_html_id_if_empty();
133
-		foreach( $this->_subsections as $subsection_name => $subsection ){
134
-			if ( $subsection instanceof EE_Form_Section_Base ) {
135
-				$subsection->_construct_finalize( $this, $subsection_name );
133
+		foreach ($this->_subsections as $subsection_name => $subsection) {
134
+			if ($subsection instanceof EE_Form_Section_Base) {
135
+				$subsection->_construct_finalize($this, $subsection_name);
136 136
 			} else {
137 137
 				throw new EE_Error(
138 138
 					sprintf(
139
-						__( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ),
139
+						__('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'),
140 140
 						$subsection_name,
141 141
 						get_class($this),
142
-						$subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' )
142
+						$subsection ? get_class($subsection) : __('NULL', 'event_espresso')
143 143
 					)
144 144
 				);
145 145
 			}
146 146
 		}
147
-		do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name );
147
+		do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name);
148 148
 	}
149 149
 
150 150
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * Gets the layout strategy for this form section
154 154
 	 * @return EE_Form_Section_Layout_Base
155 155
 	 */
156
-	public function get_layout_strategy(){
156
+	public function get_layout_strategy() {
157 157
 		return $this->_layout_strategy;
158 158
 	}
159 159
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @param EE_Form_Input_Base $input
166 166
 	 * @return string
167 167
 	 */
168
-	public function get_html_for_input($input){
168
+	public function get_html_for_input($input) {
169 169
 		return $this->_layout_strategy->layout_input($input);
170 170
 	}
171 171
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @param null $form_data
179 179
 	 * @return boolean
180 180
 	 */
181
-	public function was_submitted($form_data = NULL){
181
+	public function was_submitted($form_data = NULL) {
182 182
 		return $this->form_data_present_in($form_data);
183 183
 	}
184 184
 
@@ -204,19 +204,19 @@  discard block
 block discarded – undo
204 204
 	 *                             you may want to skip this step.
205 205
 	 * @param bool       $previously_submitted_data
206 206
 	 */
207
-	public function receive_form_submission( $req_data = null, $validate = true, $previously_submitted_data = false ){
208
-		$req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate );
209
-		if( $previously_submitted_data ){
207
+	public function receive_form_submission($req_data = null, $validate = true, $previously_submitted_data = false) {
208
+		$req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate);
209
+		if ($previously_submitted_data) {
210 210
 			$req_data = $this->get_submitted_form_data_from_session();
211
-		} else if( $req_data === null ){
212
-			$req_data = array_merge( $_GET, $_POST );
211
+		} else if ($req_data === null) {
212
+			$req_data = array_merge($_GET, $_POST);
213 213
 		}
214
-		$req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this );
215
-		$this->_normalize( $req_data );
216
-		if( $validate ){
214
+		$req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this);
215
+		$this->_normalize($req_data);
216
+		if ($validate) {
217 217
 			$this->_validate();
218 218
 		}
219
-		do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate );
219
+		do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate);
220 220
 	}
221 221
 
222 222
 
@@ -229,12 +229,12 @@  discard block
 block discarded – undo
229 229
 	 * the value being an array formatted in teh same way
230 230
 	 * @param array $default_data
231 231
 	 */
232
-	public function populate_defaults($default_data){
233
-		foreach($this->subsections() as $subsection_name => $subsection){
234
-			if(isset($default_data[$subsection_name])){
235
-				if($subsection instanceof EE_Form_Input_Base){
232
+	public function populate_defaults($default_data) {
233
+		foreach ($this->subsections() as $subsection_name => $subsection) {
234
+			if (isset($default_data[$subsection_name])) {
235
+				if ($subsection instanceof EE_Form_Input_Base) {
236 236
 					$subsection->set_default($default_data[$subsection_name]);
237
-				}elseif($subsection instanceof EE_Form_Section_Proper){
237
+				}elseif ($subsection instanceof EE_Form_Section_Proper) {
238 238
 					$subsection->populate_defaults($default_data[$subsection_name]);
239 239
 				}
240 240
 			}
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 	 * @return EE_Form_Section_Base
257 257
 	 * @throws \EE_Error
258 258
 	 */
259
-	public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){
260
-		if( $require_construction_to_be_finalized ){
259
+	public function get_subsection($name, $require_construction_to_be_finalized = TRUE) {
260
+		if ($require_construction_to_be_finalized) {
261 261
 			$this->ensure_construct_finalized_called();
262 262
 		}
263 263
 		return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL;
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
 	 * Gets all the validatable subsections of this form section
270 270
 	 * @return EE_Form_Section_Validatable[]
271 271
 	 */
272
-	public function get_validatable_subsections(){
272
+	public function get_validatable_subsections() {
273 273
 		$validatable_subsections = array();
274
-		foreach($this->subsections() as $name=>$obj){
275
-			if($obj instanceof EE_Form_Section_Validatable){
274
+		foreach ($this->subsections() as $name=>$obj) {
275
+			if ($obj instanceof EE_Form_Section_Validatable) {
276 276
 				$validatable_subsections[$name] = $obj;
277 277
 			}
278 278
 		}
@@ -292,9 +292,9 @@  discard block
 block discarded – undo
292 292
 	 * @return EE_Form_Input_Base
293 293
 	 * @throws EE_Error
294 294
 	 */
295
-	public function get_input($name, $require_construction_to_be_finalized = TRUE ){
295
+	public function get_input($name, $require_construction_to_be_finalized = TRUE) {
296 296
 		$subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
297
-		if( ! $subsection instanceof EE_Form_Input_Base){
297
+		if ( ! $subsection instanceof EE_Form_Input_Base) {
298 298
 			throw new EE_Error(
299 299
 				sprintf(
300 300
 					__(
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 						'event_espresso'
303 303
 					),
304 304
 					$name,
305
-					get_class( $this ),
306
-					$subsection ? get_class( $subsection ) : __( "NULL", 'event_espresso' )
305
+					get_class($this),
306
+					$subsection ? get_class($subsection) : __("NULL", 'event_espresso')
307 307
 				)
308 308
 			);
309 309
 		}
@@ -323,14 +323,14 @@  discard block
 block discarded – undo
323 323
 	 * @return EE_Form_Section_Proper
324 324
 	 * @throws EE_Error
325 325
 	 */
326
-	public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){
327
-		$subsection = $this->get_subsection( $name, $require_construction_to_be_finalized );
328
-		if( ! $subsection instanceof EE_Form_Section_Proper){
326
+	public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) {
327
+		$subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
328
+		if ( ! $subsection instanceof EE_Form_Section_Proper) {
329 329
 			throw new EE_Error(
330 330
 				sprintf(
331
-					__( "Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso' ),
331
+					__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),
332 332
 					$name,
333
-					get_class( $this )
333
+					get_class($this)
334 334
 				)
335 335
 			);
336 336
 		}
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 * @return mixed depending on the input's type and its normalization strategy
348 348
 	 * @throws \EE_Error
349 349
 	 */
350
-	public function get_input_value($name){
350
+	public function get_input_value($name) {
351 351
 		$input = $this->get_input($name);
352 352
 		return $input->normalized_value();
353 353
 	}
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 * @return boolean
361 361
 	 */
362 362
 	public function is_valid() {
363
-		if( ! $this->has_received_submission()){
363
+		if ( ! $this->has_received_submission()) {
364 364
 			throw new EE_Error(
365 365
 				sprintf(
366 366
 					__(
@@ -370,13 +370,13 @@  discard block
 block discarded – undo
370 370
 				)
371 371
 			);
372 372
 		}
373
-		if( ! parent::is_valid()){
373
+		if ( ! parent::is_valid()) {
374 374
 			return false;
375 375
 		}
376 376
 		//ok so no errors general to this entire form section. so let's check the subsections
377
-		foreach( $this->get_validatable_subsections() as $subsection ){
378
-			if( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '' ){
379
-				$this->set_submission_error_message( $subsection->get_validation_error_string() );
377
+		foreach ($this->get_validatable_subsections() as $subsection) {
378
+			if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '') {
379
+				$this->set_submission_error_message($subsection->get_validation_error_string());
380 380
 				return false;
381 381
 			}
382 382
 		}
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
 	 * gets teh default name of this form section if none is specified
390 390
 	 * @return string
391 391
 	 */
392
-	protected function _set_default_name_if_empty(){
393
-		if( ! $this->_name ){
392
+	protected function _set_default_name_if_empty() {
393
+		if ( ! $this->_name) {
394 394
 			$classname = get_class($this);
395 395
 			$default_name = str_replace("EE_", "", $classname);
396
-			$this->_name =  $default_name;
396
+			$this->_name = $default_name;
397 397
 		}
398 398
 	}
399 399
 
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 	 *             and get_html when you are about to display the form.
410 410
 	 * @throws \EE_Error
411 411
 	 */
412
-	public function get_html_and_js(){
412
+	public function get_html_and_js() {
413 413
 		//no doing_it_wrong yet because we ourselves are still doing it wrong...
414 414
 		//and theoretically this CAN be used properly, provided its used during "wp_enqueue_scripts"
415 415
 		$this->enqueue_js();
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 	 * @return string
425 425
 	 * @throws \EE_Error
426 426
 	 */
427
-	public function get_html(){
427
+	public function get_html() {
428 428
 		$this->ensure_construct_finalized_called();
429 429
 		return $this->_layout_strategy->layout_form();
430 430
 	}
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
 	 * @return string
438 438
 	 * @throws \EE_Error
439 439
 	 */
440
-	public function enqueue_js(){
440
+	public function enqueue_js() {
441 441
 		$this->_enqueue_and_localize_form_js();
442
-		foreach( $this->subsections() as $subsection ) {
442
+		foreach ($this->subsections() as $subsection) {
443 443
 			$subsection->enqueue_js();
444 444
 		}
445 445
 	}
@@ -458,19 +458,19 @@  discard block
 block discarded – undo
458 458
 	 *                                                    to be triggered automatically or not
459 459
 	 * @return void
460 460
 	 */
461
-	public static function wp_enqueue_scripts( $init_form_validation_automatically = true ){
462
-		add_filter( 'FHEE_load_jquery_validate', '__return_true' );
461
+	public static function wp_enqueue_scripts($init_form_validation_automatically = true) {
462
+		add_filter('FHEE_load_jquery_validate', '__return_true');
463 463
 		wp_register_script(
464 464
 			'ee_form_section_validation',
465
-			EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js',
466
-			array( 'jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods' ),
465
+			EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js',
466
+			array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
467 467
 			EVENT_ESPRESSO_VERSION,
468 468
 			true
469 469
 		);
470 470
 		wp_localize_script(
471 471
 			'ee_form_section_validation',
472 472
 			'ee_form_section_validation_init',
473
-			array( 'init' => $init_form_validation_automatically ? true : false )
473
+			array('init' => $init_form_validation_automatically ? true : false)
474 474
 		);
475 475
 	}
476 476
 
@@ -483,14 +483,14 @@  discard block
 block discarded – undo
483 483
 	 *
484 484
 	 * @throws \EE_Error
485 485
 	 */
486
-	public function _enqueue_and_localize_form_js(){
486
+	public function _enqueue_and_localize_form_js() {
487 487
 		$this->ensure_construct_finalized_called();
488 488
 		//actually, we don't want to localize just yet. There may be other forms on the page.
489 489
 		//so we need to add our form section data to a static variable accessible by all form sections
490 490
 		//and localize it just before the footer
491 491
 		$this->localize_validation_rules();
492
-		add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 );
493
-		add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) );
492
+		add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
493
+		add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
494 494
 	}
495 495
 
496 496
 
@@ -502,12 +502,12 @@  discard block
 block discarded – undo
502 502
 	 * @return void
503 503
 	 * @throws \EE_Error
504 504
 	 */
505
-	public function localize_validation_rules( $return_for_subsection = FALSE ){
505
+	public function localize_validation_rules($return_for_subsection = FALSE) {
506 506
 		// we only want to localize vars ONCE for the entire form,
507 507
 		// so if the form section doesn't have a parent, then it must be the top dog
508
-		if ( $return_for_subsection || ! $this->parent_section() ) {
509
-			EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
510
-				'form_section_id'=> $this->html_id( TRUE ),
508
+		if ($return_for_subsection || ! $this->parent_section()) {
509
+			EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array(
510
+				'form_section_id'=> $this->html_id(TRUE),
511 511
 				'validation_rules'=> $this->get_jquery_validation_rules(),
512 512
 				'other_data' => $this->get_other_js_data(),
513 513
 				'errors'=> $this->subsection_validation_errors_by_html_name()
@@ -523,9 +523,9 @@  discard block
 block discarded – undo
523 523
 	 * @param array $form_other_js_data
524 524
 	 * @return array
525 525
 	 */
526
-	public function get_other_js_data( $form_other_js_data = array() ) {
527
-		foreach( $this->subsections() as $subsection ) {
528
-			$form_other_js_data = $subsection->get_other_js_data( $form_other_js_data );
526
+	public function get_other_js_data($form_other_js_data = array()) {
527
+		foreach ($this->subsections() as $subsection) {
528
+			$form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
529 529
 		}
530 530
 		return $form_other_js_data;
531 531
 	}
@@ -536,12 +536,12 @@  discard block
 block discarded – undo
536 536
 	 * Keys are their form names, and values are the inputs themselves
537 537
 	 * @return EE_Form_Input_Base
538 538
 	 */
539
-	public function inputs_in_subsections(){
539
+	public function inputs_in_subsections() {
540 540
 		$inputs = array();
541
-		foreach($this->subsections() as $subsection){
542
-			if( $subsection instanceof EE_Form_Input_Base ){
543
-				$inputs[ $subsection->html_name() ] = $subsection;
544
-			}elseif($subsection instanceof EE_Form_Section_Proper ){
541
+		foreach ($this->subsections() as $subsection) {
542
+			if ($subsection instanceof EE_Form_Input_Base) {
543
+				$inputs[$subsection->html_name()] = $subsection;
544
+			}elseif ($subsection instanceof EE_Form_Section_Proper) {
545 545
 				$inputs += $subsection->inputs_in_subsections();
546 546
 			}
547 547
 		}
@@ -554,12 +554,12 @@  discard block
 block discarded – undo
554 554
 	 * and values are a string of all their validation errors
555 555
 	 * @return string[]
556 556
 	 */
557
-	public function subsection_validation_errors_by_html_name(){
557
+	public function subsection_validation_errors_by_html_name() {
558 558
 		$inputs = $this->inputs();
559 559
 		$errors = array();
560
-		foreach( $inputs as $form_input ){
561
-			if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){
562
-				$errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
560
+		foreach ($inputs as $form_input) {
561
+			if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
562
+				$errors[$form_input->html_name()] = $form_input->get_validation_error_string();
563 563
 			}
564 564
 		}
565 565
 		return $errors;
@@ -571,15 +571,15 @@  discard block
 block discarded – undo
571 571
 	 * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
572 572
 	 * Should be setup by each form during the _enqueues_and_localize_form_js
573 573
 	 */
574
-	public static function localize_script_for_all_forms(){
574
+	public static function localize_script_for_all_forms() {
575 575
 		//allow inputs and stuff to hook in their JS and stuff here
576
-		do_action( 'AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin' );
576
+		do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
577 577
 		EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
578
-		$email_validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level )
578
+		$email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
579 579
 			? EE_Registry::instance()->CFG->registration->email_validation_level
580 580
 			: 'wp_default';
581 581
 		EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level;
582
-		wp_enqueue_script( 'ee_form_section_validation' );
582
+		wp_enqueue_script('ee_form_section_validation');
583 583
 		wp_localize_script(
584 584
 			'ee_form_section_validation',
585 585
 			'ee_form_section_vars',
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
 	/**
593 593
 	 * ensure_scripts_localized
594 594
 	 */
595
-	public function ensure_scripts_localized(){
596
-		if ( ! EE_Form_Section_Proper::$_scripts_localized ) {
595
+	public function ensure_scripts_localized() {
596
+		if ( ! EE_Form_Section_Proper::$_scripts_localized) {
597 597
 			$this->_enqueue_and_localize_form_js();
598 598
 		}
599 599
 	}
@@ -605,10 +605,10 @@  discard block
 block discarded – undo
605 605
 	 * is that the key here should be the same as the custom validation rule put in the JS file
606 606
 	 * @return array keys are custom validation rules, and values are internationalized strings
607 607
 	 */
608
-	private static function _get_localized_error_messages(){
608
+	private static function _get_localized_error_messages() {
609 609
 		return array(
610 610
 			'validUrl'=>  __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"),
611
-			'regex' => __( 'Please check your input', 'event_espresso' ),
611
+			'regex' => __('Please check your input', 'event_espresso'),
612 612
 		);
613 613
 	}
614 614
 
@@ -638,9 +638,9 @@  discard block
 block discarded – undo
638 638
 	 *
639 639
 	 * @return array
640 640
 	 */
641
-	public function get_jquery_validation_rules(){
641
+	public function get_jquery_validation_rules() {
642 642
 		$jquery_validation_rules = array();
643
-		foreach($this->get_validatable_subsections() as $subsection){
643
+		foreach ($this->get_validatable_subsections() as $subsection) {
644 644
 			$jquery_validation_rules = array_merge(
645 645
 				$jquery_validation_rules,
646 646
 				$subsection->get_jquery_validation_rules()
@@ -659,11 +659,11 @@  discard block
 block discarded – undo
659 659
 	protected function _normalize($req_data) {
660 660
 		$this->_received_submission = TRUE;
661 661
 		$this->_validation_errors = array();
662
-		foreach($this->get_validatable_subsections() as $subsection){
663
-			try{
662
+		foreach ($this->get_validatable_subsections() as $subsection) {
663
+			try {
664 664
 				$subsection->_normalize($req_data);
665
-			}catch( EE_Validation_Error $e ){
666
-				$subsection->add_validation_error( $e );
665
+			} catch (EE_Validation_Error $e) {
666
+				$subsection->add_validation_error($e);
667 667
 			}
668 668
 		}
669 669
 	}
@@ -681,13 +681,13 @@  discard block
 block discarded – undo
681 681
 	 */
682 682
 	protected function _validate() {
683 683
 		$this->flush_submitted_form_data_from_session();
684
-		foreach($this->get_validatable_subsections() as $subsection_name => $subsection){
685
-			if(method_exists($this,'_validate_'.$subsection_name)){
686
-				call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
684
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
685
+			if (method_exists($this, '_validate_'.$subsection_name)) {
686
+				call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection));
687 687
 			}
688 688
 			$subsection->_validate();
689 689
 		}
690
-		if ( $this->is_valid() ) {
690
+		if ($this->is_valid()) {
691 691
 			$this->store_submitted_form_data_in_session();
692 692
 		}
693 693
 	}
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	 */
703 703
 	protected function store_submitted_form_data_in_session() {
704 704
 		return EE_Session::instance()->set_session_data(
705
-			array( \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values() )
705
+			array(\EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values())
706 706
 		);
707 707
 	}
708 708
 
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 	 */
717 717
 	protected function get_submitted_form_data_from_session() {
718 718
 		return EE_Session::instance()->get_session_data(
719
-			array( \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY )
719
+			array(\EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
720 720
 		);
721 721
 	}
722 722
 
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 	 */
730 730
 	protected function flush_submitted_form_data_from_session() {
731 731
 		return EE_Session::instance()->reset_data(
732
-			array( \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY )
732
+			array(\EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
733 733
 		);
734 734
 	}
735 735
 
@@ -739,13 +739,13 @@  discard block
 block discarded – undo
739 739
 	 * Gets all the validated inputs for the form section
740 740
 	 * @return array
741 741
 	 */
742
-	public function valid_data(){
742
+	public function valid_data() {
743 743
 		$inputs = array();
744
-		foreach( $this->subsections() as $subsection_name =>$subsection ){
745
-			if ( $subsection instanceof EE_Form_Section_Proper ) {
746
-				$inputs[ $subsection_name ] = $subsection->valid_data();
747
-			} else if ( $subsection instanceof EE_Form_Input_Base ){
748
-				$inputs[ $subsection_name ] = $subsection->normalized_value();
744
+		foreach ($this->subsections() as $subsection_name =>$subsection) {
745
+			if ($subsection instanceof EE_Form_Section_Proper) {
746
+				$inputs[$subsection_name] = $subsection->valid_data();
747
+			} else if ($subsection instanceof EE_Form_Input_Base) {
748
+				$inputs[$subsection_name] = $subsection->normalized_value();
749 749
 			}
750 750
 		}
751 751
 		return $inputs;
@@ -757,11 +757,11 @@  discard block
 block discarded – undo
757 757
 	 * Gets all the inputs on this form section
758 758
 	 * @return EE_Form_Input_Base[]
759 759
 	 */
760
-	public function inputs(){
760
+	public function inputs() {
761 761
 		$inputs = array();
762
-		foreach( $this->subsections() as $subsection_name =>$subsection ){
763
-			if ( $subsection instanceof EE_Form_Input_Base ){
764
-				$inputs[ $subsection_name ] = $subsection;
762
+		foreach ($this->subsections() as $subsection_name =>$subsection) {
763
+			if ($subsection instanceof EE_Form_Input_Base) {
764
+				$inputs[$subsection_name] = $subsection;
765 765
 			}
766 766
 		}
767 767
 		return $inputs;
@@ -773,10 +773,10 @@  discard block
 block discarded – undo
773 773
 	 * Gets all the subsections which are a proper form
774 774
 	 * @return EE_Form_Section_Proper[]
775 775
 	 */
776
-	public function subforms(){
776
+	public function subforms() {
777 777
 		$form_sections = array();
778
-		foreach($this->subsections() as $name=>$obj){
779
-			if($obj instanceof EE_Form_Section_Proper){
778
+		foreach ($this->subsections() as $name=>$obj) {
779
+			if ($obj instanceof EE_Form_Section_Proper) {
780 780
 				$form_sections[$name] = $obj;
781 781
 			}
782 782
 		}
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 	 * if you only want form inputs or proper form sections.
792 792
 	 * @return EE_Form_Section_Proper[]
793 793
 	 */
794
-	public function subsections(){
794
+	public function subsections() {
795 795
 		$this->ensure_construct_finalized_called();
796 796
 		return $this->_subsections;
797 797
 	}
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
 	 *                                        where keys are always subsection names and values are either
814 814
 	 *                                        the input's normalized value, or an array like the top-level array
815 815
 	 */
816
-	public function input_values( $include_subform_inputs = false, $flatten = false ){
817
-		return $this->_input_values( false, $include_subform_inputs, $flatten );
816
+	public function input_values($include_subform_inputs = false, $flatten = false) {
817
+		return $this->_input_values(false, $include_subform_inputs, $flatten);
818 818
 	}
819 819
 
820 820
 	/**
@@ -834,8 +834,8 @@  discard block
 block discarded – undo
834 834
 	 *                                        where keys are always subsection names and values are either
835 835
 	 *                                        the input's normalized value, or an array like the top-level array
836 836
 	 */
837
-	public function input_pretty_values(  $include_subform_inputs = false, $flatten = false ){
838
-		return $this->_input_values( true, $include_subform_inputs, $flatten );
837
+	public function input_pretty_values($include_subform_inputs = false, $flatten = false) {
838
+		return $this->_input_values(true, $include_subform_inputs, $flatten);
839 839
 	}
840 840
 
841 841
 	/**
@@ -853,19 +853,19 @@  discard block
 block discarded – undo
853 853
 	 *                                        where keys are always subsection names and values are either
854 854
 	 *                                        the input's normalized value, or an array like the top-level array
855 855
 	 */
856
-	public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) {
856
+	public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) {
857 857
 		$input_values = array();
858
-		foreach( $this->subsections() as $subsection_name => $subsection ) {
859
-			if( $subsection instanceof EE_Form_Input_Base ) {
860
-				$input_values[ $subsection_name ] = $pretty
858
+		foreach ($this->subsections() as $subsection_name => $subsection) {
859
+			if ($subsection instanceof EE_Form_Input_Base) {
860
+				$input_values[$subsection_name] = $pretty
861 861
 					? $subsection->pretty_value()
862 862
 					: $subsection->normalized_value();
863
-			} else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) {
864
-				$subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten );
865
-				if( $flatten ) {
866
-					$input_values = array_merge( $input_values, $subform_input_values );
863
+			} else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
864
+				$subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten);
865
+				if ($flatten) {
866
+					$input_values = array_merge($input_values, $subform_input_values);
867 867
 				} else {
868
-					$input_values[ $subsection_name ] = $subform_input_values;
868
+					$input_values[$subsection_name] = $subform_input_values;
869 869
 				}
870 870
 			}
871 871
 		}
@@ -888,17 +888,17 @@  discard block
 block discarded – undo
888 888
 	 *                                   where keys are always subsection names and values are either
889 889
 	 *                                   the input's normalized value, or an array like the top-level array
890 890
 	 */
891
-	public function submitted_values( $include_subforms = false, $flatten = false ) {
891
+	public function submitted_values($include_subforms = false, $flatten = false) {
892 892
 		$submitted_values = array();
893
-		foreach( $this->subsections() as $subsection_name => $subsection ) {
894
-			if( $subsection instanceof EE_Form_Input_Base ) {
895
-				$submitted_values[ $subsection_name ] = $subsection->raw_value();
896
-			} else if( $subsection instanceof EE_Form_Section_Proper && $include_subforms ) {
897
-				$subform_input_values = $subsection->_input_values( $include_subforms, $flatten );
898
-				if( $flatten ) {
899
-					$submitted_values = array_merge( $submitted_values, $subform_input_values );
893
+		foreach ($this->subsections() as $subsection_name => $subsection) {
894
+			if ($subsection instanceof EE_Form_Input_Base) {
895
+				$submitted_values[$subsection_name] = $subsection->raw_value();
896
+			} else if ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
897
+				$subform_input_values = $subsection->_input_values($include_subforms, $flatten);
898
+				if ($flatten) {
899
+					$submitted_values = array_merge($submitted_values, $subform_input_values);
900 900
 				} else {
901
-					$submitted_values[ $subsection_name ] = $subform_input_values;
901
+					$submitted_values[$subsection_name] = $subform_input_values;
902 902
 				}
903 903
 			}
904 904
 		}
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 	 * @return boolean
915 915
 	 * @throws \EE_Error
916 916
 	 */
917
-	public function has_received_submission(){
917
+	public function has_received_submission() {
918 918
 		$this->ensure_construct_finalized_called();
919 919
 		return $this->_received_submission;
920 920
 	}
@@ -927,8 +927,8 @@  discard block
 block discarded – undo
927 927
 	 * @param array $inputs_to_exclude values are the input names
928 928
 	 * @return void
929 929
 	 */
930
-	public function exclude($inputs_to_exclude = array()){
931
-		foreach($inputs_to_exclude as $input_to_exclude_name){
930
+	public function exclude($inputs_to_exclude = array()) {
931
+		foreach ($inputs_to_exclude as $input_to_exclude_name) {
932 932
 			unset($this->_subsections[$input_to_exclude_name]);
933 933
 		}
934 934
 	}
@@ -939,8 +939,8 @@  discard block
 block discarded – undo
939 939
 	 * @param array $inputs_to_hide
940 940
 	 * @throws \EE_Error
941 941
 	 */
942
-	public function hide($inputs_to_hide= array()){
943
-		foreach($inputs_to_hide as $input_to_hide){
942
+	public function hide($inputs_to_hide = array()) {
943
+		foreach ($inputs_to_hide as $input_to_hide) {
944 944
 			$input = $this->get_input($input_to_hide);
945 945
 
946 946
 			$input->set_display_strategy(new EE_Hidden_Display_Strategy());
@@ -970,16 +970,16 @@  discard block
 block discarded – undo
970 970
 	 * @return void
971 971
 	 * @throws \EE_Error
972 972
 	 */
973
-	public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){
974
-		foreach($new_subsections as $subsection_name => $subsection){
975
-			if( ! $subsection instanceof EE_Form_Section_Base){
973
+	public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) {
974
+		foreach ($new_subsections as $subsection_name => $subsection) {
975
+			if ( ! $subsection instanceof EE_Form_Section_Base) {
976 976
 				EE_Error::add_error(
977 977
 					sprintf(
978 978
 						__(
979 979
 							"Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.",
980 980
 							"event_espresso"
981 981
 						),
982
-						get_class( $subsection ),
982
+						get_class($subsection),
983 983
 						$subsection_name,
984 984
 						$this->name()
985 985
 					)
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 		);
996 996
 
997 997
 
998
-		if( $this->_construction_finalized ){
999
-			foreach($this->_subsections as $name => $subsection){
998
+		if ($this->_construction_finalized) {
999
+			foreach ($this->_subsections as $name => $subsection) {
1000 1000
 				$subsection->_construct_finalize($this, $name);
1001 1001
 			}
1002 1002
 		}
@@ -1007,8 +1007,8 @@  discard block
 block discarded – undo
1007 1007
 	/**
1008 1008
 	 * Just gets all validatable subsections to clean their sensitive data
1009 1009
 	 */
1010
-	public function clean_sensitive_data(){
1011
-		foreach($this->get_validatable_subsections() as $subsection){
1010
+	public function clean_sensitive_data() {
1011
+		foreach ($this->get_validatable_subsections() as $subsection) {
1012 1012
 			$subsection->clean_sensitive_data();
1013 1013
 		}
1014 1014
 	}
@@ -1018,10 +1018,10 @@  discard block
 block discarded – undo
1018 1018
 	/**
1019 1019
 	 * @param string $form_submission_error_message
1020 1020
 	 */
1021
-	public function set_submission_error_message( $form_submission_error_message = '' ) {
1022
-		$this->_form_submission_error_message .= ! empty( $form_submission_error_message )
1021
+	public function set_submission_error_message($form_submission_error_message = '') {
1022
+		$this->_form_submission_error_message .= ! empty($form_submission_error_message)
1023 1023
 			? $form_submission_error_message
1024
-			: __( 'Form submission failed due to errors', 'event_espresso' );
1024
+			: __('Form submission failed due to errors', 'event_espresso');
1025 1025
 	}
1026 1026
 
1027 1027
 
@@ -1038,10 +1038,10 @@  discard block
 block discarded – undo
1038 1038
 	/**
1039 1039
 	 * @param string $form_submission_success_message
1040 1040
 	 */
1041
-	public function set_submission_success_message( $form_submission_success_message ) {
1042
-		$this->_form_submission_success_message .= ! empty( $form_submission_success_message )
1041
+	public function set_submission_success_message($form_submission_success_message) {
1042
+		$this->_form_submission_success_message .= ! empty($form_submission_success_message)
1043 1043
 			? $form_submission_success_message
1044
-			: __( 'Form submitted successfully', 'event_espresso' );
1044
+			: __('Form submitted successfully', 'event_espresso');
1045 1045
 	}
1046 1046
 
1047 1047
 
@@ -1064,10 +1064,10 @@  discard block
 block discarded – undo
1064 1064
 	 * @return string
1065 1065
 	 * @throws \EE_Error
1066 1066
 	 */
1067
-	public function html_name_prefix(){
1068
-		if( $this->parent_section() instanceof EE_Form_Section_Proper ){
1069
-			return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1070
-		}else{
1067
+	public function html_name_prefix() {
1068
+		if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1069
+			return $this->parent_section()->html_name_prefix().'['.$this->name().']';
1070
+		} else {
1071 1071
 			return $this->name();
1072 1072
 		}
1073 1073
 	}
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 	 * @return string
1083 1083
 	 * @throws \EE_Error
1084 1084
 	 */
1085
-	public function name(){
1085
+	public function name() {
1086 1086
 		$this->ensure_construct_finalized_called();
1087 1087
 		return parent::name();
1088 1088
 	}
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
 	 * @return EE_Form_Section_Proper
1094 1094
 	 * @throws \EE_Error
1095 1095
 	 */
1096
-	public function parent_section(){
1096
+	public function parent_section() {
1097 1097
 		$this->ensure_construct_finalized_called();
1098 1098
 		return parent::parent_section();
1099 1099
 	}
@@ -1106,9 +1106,9 @@  discard block
 block discarded – undo
1106 1106
 	 * @return void
1107 1107
 	 * @throws \EE_Error
1108 1108
 	 */
1109
-	public function ensure_construct_finalized_called(){
1110
-		if( ! $this->_construction_finalized ){
1111
-			$this->_construct_finalize($this->_parent_section, $this->_name );
1109
+	public function ensure_construct_finalized_called() {
1110
+		if ( ! $this->_construction_finalized) {
1111
+			$this->_construct_finalize($this->_parent_section, $this->_name);
1112 1112
 		}
1113 1113
 	}
1114 1114
 
@@ -1120,17 +1120,17 @@  discard block
 block discarded – undo
1120 1120
 	 * @param array $req_data
1121 1121
 	 * @return boolean
1122 1122
 	 */
1123
-	public function form_data_present_in( $req_data = NULL ) {
1124
-		if( $req_data === NULL){
1123
+	public function form_data_present_in($req_data = NULL) {
1124
+		if ($req_data === NULL) {
1125 1125
 			$req_data = $_POST;
1126 1126
 		}
1127
-		foreach( $this->subsections() as $subsection ) {
1128
-			if($subsection instanceof EE_Form_Input_Base ) {
1129
-				if( $subsection->form_data_present_in( $req_data ) ) {
1127
+		foreach ($this->subsections() as $subsection) {
1128
+			if ($subsection instanceof EE_Form_Input_Base) {
1129
+				if ($subsection->form_data_present_in($req_data)) {
1130 1130
 					return TRUE;
1131 1131
 				}
1132
-			}elseif( $subsection instanceof EE_Form_Section_Proper ) {
1133
-				if( $subsection->form_data_present_in( $req_data ) ) {
1132
+			}elseif ($subsection instanceof EE_Form_Section_Proper) {
1133
+				if ($subsection->form_data_present_in($req_data)) {
1134 1134
 					return TRUE;
1135 1135
 				}
1136 1136
 			}
@@ -1147,14 +1147,14 @@  discard block
 block discarded – undo
1147 1147
 	 */
1148 1148
 	public function get_validation_errors_accumulated() {
1149 1149
 		$validation_errors = $this->get_validation_errors();
1150
-		foreach($this->get_validatable_subsections() as $subsection ) {
1151
-			if( $subsection instanceof EE_Form_Section_Proper ) {
1150
+		foreach ($this->get_validatable_subsections() as $subsection) {
1151
+			if ($subsection instanceof EE_Form_Section_Proper) {
1152 1152
 				$validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1153 1153
 			} else {
1154
-				$validation_errors_on_this_subsection =  $subsection->get_validation_errors();
1154
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors();
1155 1155
 			}
1156
-			if( $validation_errors_on_this_subsection ){
1157
-				$validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection );
1156
+			if ($validation_errors_on_this_subsection) {
1157
+				$validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1158 1158
 			}
1159 1159
 		}
1160 1160
 		return $validation_errors;
@@ -1176,24 +1176,24 @@  discard block
 block discarded – undo
1176 1176
 	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1177 1177
 	 * @return EE_Form_Section_Base
1178 1178
 	 */
1179
-	public function find_section_from_path( $form_section_path ) {
1179
+	public function find_section_from_path($form_section_path) {
1180 1180
 		//check if we can find the input from purely going straight up the tree
1181
-		$input = parent::find_section_from_path( $form_section_path );
1182
-		if( $input instanceof EE_Form_Section_Base ) {
1181
+		$input = parent::find_section_from_path($form_section_path);
1182
+		if ($input instanceof EE_Form_Section_Base) {
1183 1183
 			return $input;
1184 1184
 		}
1185 1185
 
1186
-		$next_slash_pos = strpos( $form_section_path, '/' );
1187
-		if( $next_slash_pos !== false ) {
1188
-			$child_section_name = substr( $form_section_path, 0, $next_slash_pos );
1189
-			$subpath = substr( $form_section_path, $next_slash_pos + 1 );
1186
+		$next_slash_pos = strpos($form_section_path, '/');
1187
+		if ($next_slash_pos !== false) {
1188
+			$child_section_name = substr($form_section_path, 0, $next_slash_pos);
1189
+			$subpath = substr($form_section_path, $next_slash_pos + 1);
1190 1190
 		} else {
1191 1191
 			$child_section_name = $form_section_path;
1192 1192
 			$subpath = '';
1193 1193
 		}
1194
-		$child_section =  $this->get_subsection( $child_section_name );
1195
-		if ( $child_section instanceof EE_Form_Section_Base ) {
1196
-			return $child_section->find_section_from_path( $subpath );
1194
+		$child_section = $this->get_subsection($child_section_name);
1195
+		if ($child_section instanceof EE_Form_Section_Base) {
1196
+			return $child_section->find_section_from_path($subpath);
1197 1197
 		} else {
1198 1198
 			return null;
1199 1199
 		}
Please login to merge, or discard this patch.