Completed
Branch FET-8266-max-input-length (b8274a)
by
unknown
469:17 queued 453:21
created
admin_pages/registration_form/Registration_Form_Admin_Page.core.php 1 patch
Spacing   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 
59 59
 
60 60
 
61
-	public function __construct( $routing = TRUE ) {
62
-		require_once( EE_MODELS . 'EEM_Question.model.php' );
63
-		require_once( EE_MODELS . 'EEM_Question_Group.model.php' );
64
-		$this->_question_model=  EEM_Question::instance();
65
-		$this->_question_group_model=EEM_Question_Group::instance();
66
-		parent::__construct( $routing );
61
+	public function __construct($routing = TRUE) {
62
+		require_once(EE_MODELS.'EEM_Question.model.php');
63
+		require_once(EE_MODELS.'EEM_Question_Group.model.php');
64
+		$this->_question_model = EEM_Question::instance();
65
+		$this->_question_group_model = EEM_Question_Group::instance();
66
+		parent::__construct($routing);
67 67
 	}
68 68
 
69 69
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 
99 99
 	protected function _set_page_routes() {
100
-		$qst_id = ! empty( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0;
100
+		$qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
101 101
 		$this->_page_routes = array(
102 102
 			'default' => array(
103 103
 				'func' => '_questions_overview_list_table',
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 			'update_question' => array(
120 120
 				'func' => '_insert_or_update_question',
121
-				'args' => array('new_question' => FALSE ),
121
+				'args' => array('new_question' => FALSE),
122 122
 				'capability' => 'ee_edit_question',
123 123
 				'obj_id' => $qst_id,
124 124
 				'noheader' => TRUE,
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 						'filename' => 'registration_form_questions_overview_views_bulk_actions_search'
154 154
 						)
155 155
 					),
156
-				'help_tour' => array( 'Registration_Form_Questions_Overview_Help_Tour'),
156
+				'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'),
157 157
 				'require_nonce' => FALSE,
158 158
 				'qtips' => array(
159 159
 					'EE_Registration_Form_Tips'
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 						'filename' => 'registration_form_question_groups'
173 173
 						),
174 174
 					),
175
-				'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'),
175
+				'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'),
176 176
 				'require_nonce' => FALSE
177 177
 				),
178 178
 
@@ -181,16 +181,16 @@  discard block
 block discarded – undo
181 181
 					'label' => __('Edit Question', 'event_espresso'),
182 182
 					'order' => 15,
183 183
 					'persistent' => FALSE,
184
-					'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id'] ), $this->_current_page_view_url )  : $this->_admin_base_url
184
+					'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), $this->_current_page_view_url) : $this->_admin_base_url
185 185
 					),
186
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
186
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
187 187
 				'help_tabs' => array(
188 188
 					'registration_form_edit_question_group_help_tab' => array(
189 189
 						'title' => __('Edit Question', 'event_espresso'),
190 190
 						'filename' => 'registration_form_edit_question'
191 191
 						),
192 192
 					),
193
-                'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'),
193
+                'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'),
194 194
 				'require_nonce' => FALSE
195 195
 				),
196 196
 			);
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	//none of the below group are currently used for Event Categories
219 219
 	protected function _add_feature_pointers() {}
220 220
 	public function load_scripts_styles() {
221
-		wp_register_style( 'espresso_registration', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION );
221
+		wp_register_style('espresso_registration', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION);
222 222
 		wp_enqueue_style('espresso_registration');
223 223
 	}
224 224
 	public function admin_init() {}
@@ -234,20 +234,20 @@  discard block
 block discarded – undo
234 234
 
235 235
 	public function load_scripts_styles_add_question() {
236 236
 		$this->load_scripts_styles_forms();
237
-		wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE );
238
-		wp_enqueue_script( 'espresso_registration_form_single' );
237
+		wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE);
238
+		wp_enqueue_script('espresso_registration_form_single');
239 239
 	}
240 240
 	public function load_scripts_styles_edit_question() {
241 241
 		$this->load_scripts_styles_forms();
242
-		wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE );
243
-		wp_enqueue_script( 'espresso_registration_form_single' );
242
+		wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE);
243
+		wp_enqueue_script('espresso_registration_form_single');
244 244
 	}
245 245
 
246 246
 
247 247
 
248 248
 
249 249
 	public function recaptcha_info_help_tab() {
250
-		$template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php';
250
+		$template = REGISTRATION_FORM_TEMPLATE_PATH.'recaptcha_info_help_tab.template.php';
251 251
 		EEH_Template::display_template($template, array());
252 252
 	}
253 253
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 				)
280 280
 		);
281 281
 
282
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) {
282
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) {
283 283
 			$this->_views['trash'] = array(
284 284
 				'slug' => 'trash',
285 285
 				'label' => __('Trash', 'event_espresso'),
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	protected function _questions_groups_preview() {
299 299
 		$this->_admin_page_title = __('Question Groups (Preview)', 'event_espresso');
300
-		$this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__( 'Preview Question Groups Overview List Table screenshot', 'event_espresso' ) . '" />';
301
-		$this->_template_args['preview_text'] = '<strong>'.__( 'Question Groups is a feature that is only available in the Caffeinated version of Event Espresso.  With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso' ).'</strong>';
302
-		$this->display_admin_caf_preview_page( 'question_groups_tab' );
300
+		$this->_template_args['preview_img'] = '<img src="'.REGISTRATION_FORM_ASSETS_URL.'caf_reg_form_preview.jpg" alt="'.esc_attr__('Preview Question Groups Overview List Table screenshot', 'event_espresso').'" />';
301
+		$this->_template_args['preview_text'] = '<strong>'.__('Question Groups is a feature that is only available in the Caffeinated version of Event Espresso.  With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso').'</strong>';
302
+		$this->display_admin_caf_preview_page('question_groups_tab');
303 303
 	}
304 304
 
305 305
 
@@ -310,58 +310,58 @@  discard block
 block discarded – undo
310 310
 	 * @param \EEM_Base $model
311 311
 	 * @return array where each key is the name of a model's field/db column, and each value is its value.
312 312
 	 */
313
-	protected function _set_column_values_for(EEM_Base $model){
314
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
315
-		$set_column_values=array();
313
+	protected function _set_column_values_for(EEM_Base $model) {
314
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
315
+		$set_column_values = array();
316 316
 
317 317
 		//some initial checks for proper values.
318 318
 		//if QST_admin_only, then no matter what QST_required is we disable.
319
-		if ( !empty( $this->_req_data['QST_admin_only'] ) ) {
319
+		if ( ! empty($this->_req_data['QST_admin_only'])) {
320 320
 			$this->_req_data['QST_required'] = 0;
321 321
 		}
322
-		foreach($model->field_settings() as $fieldName=>$settings){
322
+		foreach ($model->field_settings() as $fieldName=>$settings) {
323 323
 			// basically if QSG_identifier is empty or not set
324
-			if ( $fieldName == 'QSG_identifier' && ( isset( $this->_req_data['QSG_identifier'] ) && empty( $this->_req_data['QSG_identifier'] ) )) {
325
-				$QSG_name = isset( $this->_req_data['QSG_name'] ) ? $this->_req_data['QSG_name'] : '' ;
326
-				$set_column_values[$fieldName] = sanitize_title($QSG_name ) . '-' . uniqid();
324
+			if ($fieldName == 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) {
325
+				$QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : '';
326
+				$set_column_values[$fieldName] = sanitize_title($QSG_name).'-'.uniqid();
327 327
 //				dd($set_column_values);
328 328
 			}
329 329
 			//if the admin label is blank, use a slug version of the question text
330
-			else if ( $fieldName == 'QST_admin_label' && ( isset( $this->_req_data['QST_admin_label'] ) && empty( $this->_req_data['QST_admin_label'] )  )) {
331
-				$QST_text = isset( $this->_req_data['QST_display_text'] ) ? $this->_req_data['QST_display_text'] : '' ;
332
-				$set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text,10));
330
+			else if ($fieldName == 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) {
331
+				$QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : '';
332
+				$set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10));
333 333
 			}
334 334
 
335 335
 
336
-			else if ( $fieldName == 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) {
336
+			else if ($fieldName == 'QST_admin_only' && ( ! isset($this->_req_data['QST_admin_only']))) {
337 337
 				$set_column_values[$fieldName] = 0;
338 338
 			}
339 339
 
340
-			else if ( $fieldName == 'QST_max' ) {
340
+			else if ($fieldName == 'QST_max') {
341 341
 				$qst_system = EEM_Question::instance()->get_var(
342 342
 					array(
343 343
 						array(
344
-							'QST_ID' => isset( $this->_req_data[ 'QST_ID' ] ) ? $this->_req_data[ 'QST_ID' ] : 0
344
+							'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0
345 345
 						)
346 346
 					),
347 347
 					'QST_system' );
348
-				$max_max = EEM_Question::instance()->absolute_max_for_system_question( $qst_system );
349
-				if( empty( $this->_req_data[ 'QST_max' ] ) ||
350
-					 $this->_req_data[ 'QST_max' ] > $max_max ) {
351
-					$set_column_values[ $fieldName ] = $max_max;
348
+				$max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system);
349
+				if (empty($this->_req_data['QST_max']) ||
350
+					 $this->_req_data['QST_max'] > $max_max) {
351
+					$set_column_values[$fieldName] = $max_max;
352 352
 				}
353 353
 			}
354 354
 
355 355
 
356 356
 			//only add a property to the array if it's not null (otherwise the model should just use the default value)
357
-			if(
358
-				! isset( $set_column_values[ $fieldName ] ) &&
359
-				isset($this->_req_data[$fieldName] ) ){
360
-				$set_column_values[$fieldName]=$this->_req_data[$fieldName];
357
+			if (
358
+				! isset($set_column_values[$fieldName]) &&
359
+				isset($this->_req_data[$fieldName]) ) {
360
+				$set_column_values[$fieldName] = $this->_req_data[$fieldName];
361 361
 			}
362 362
 
363 363
 		}
364
-		return $set_column_values;//validation fo this data to be performed by the model before insertion.
364
+		return $set_column_values; //validation fo this data to be performed by the model before insertion.
365 365
 	}
366 366
 
367 367
 
@@ -379,30 +379,30 @@  discard block
 block discarded – undo
379 379
 	/**
380 380
 	 * @param string $action
381 381
 	 */
382
-	protected function _edit_question( $action= 'add' ) {
383
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
384
-		$ID=isset( $this->_req_data['QST_ID'] ) && ! empty( $this->_req_data['QST_ID'] ) ? absint( $this->_req_data['QST_ID'] ) : FALSE;
382
+	protected function _edit_question($action = 'add') {
383
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
384
+		$ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : FALSE;
385 385
 
386
-		$this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action ));
386
+		$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
387 387
 		// add PRC_ID to title if editing
388
-		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
389
-		if($ID){
390
-			$question=$this->_question_model->get_one_by_ID($ID);
391
-			$additional_hidden_fields=array('QST_ID'=>array('type'=>'hidden','value'=>$ID));
388
+		$this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title;
389
+		if ($ID) {
390
+			$question = $this->_question_model->get_one_by_ID($ID);
391
+			$additional_hidden_fields = array('QST_ID'=>array('type'=>'hidden', 'value'=>$ID));
392 392
 			$this->_set_add_edit_form_tags('update_question', $additional_hidden_fields);
393
-		}else{
394
-			$question= EE_Question::new_instance();
393
+		} else {
394
+			$question = EE_Question::new_instance();
395 395
 			$question->set_order_to_latest();
396 396
 			$this->_set_add_edit_form_tags('insert_question');
397 397
 		}
398
-		$question_types = $question->has_answers() ?  $this->_question_model->question_types_in_same_category( $question->type() ) : $this->_question_model->allowed_question_types();
399
-		$this->_template_args['QST_ID']=$ID;
400
-		$this->_template_args['question']=$question;
401
-		$this->_template_args['question_types']= $question_types;
402
-		$this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( $question->system_ID() );
398
+		$question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types();
399
+		$this->_template_args['QST_ID'] = $ID;
400
+		$this->_template_args['question'] = $question;
401
+		$this->_template_args['question_types'] = $question_types;
402
+		$this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question($question->system_ID());
403 403
 
404
-		$this->_set_publish_post_box_vars( 'id', $ID );
405
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', $this->_template_args, TRUE );
404
+		$this->_set_publish_post_box_vars('id', $ID);
405
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'questions_main_meta_box.template.php', $this->_template_args, TRUE);
406 406
 
407 407
 		// the details template wrapper
408 408
 		$this->display_admin_page_with_sidebar();
@@ -414,58 +414,58 @@  discard block
 block discarded – undo
414 414
 	 * @param bool|true $new_question
415 415
 	 * @throws \EE_Error
416 416
 	 */
417
-	protected function _insert_or_update_question( $new_question = TRUE) {
418
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
419
-		$set_column_values=$this->_set_column_values_for($this->_question_model);
420
-		if($new_question){
421
-			$ID=$this->_question_model->insert($set_column_values);
417
+	protected function _insert_or_update_question($new_question = TRUE) {
418
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
419
+		$set_column_values = $this->_set_column_values_for($this->_question_model);
420
+		if ($new_question) {
421
+			$ID = $this->_question_model->insert($set_column_values);
422 422
 			$success = $ID ? true : false;
423 423
 			$action_desc = 'added';
424
-		}else{
425
-			$ID=absint($this->_req_data['QST_ID']);
426
-			$pk=$this->_question_model->primary_key_name();
427
-			$wheres=array($pk=>$ID);
424
+		} else {
425
+			$ID = absint($this->_req_data['QST_ID']);
426
+			$pk = $this->_question_model->primary_key_name();
427
+			$wheres = array($pk=>$ID);
428 428
 			unset($set_column_values[$pk]);
429
-			$success= $this->_question_model->update($set_column_values,array($wheres));
430
-			$action_desc='updated';
429
+			$success = $this->_question_model->update($set_column_values, array($wheres));
430
+			$action_desc = 'updated';
431 431
 		}
432 432
 
433
-		if ($ID){
433
+		if ($ID) {
434 434
 			//save the related options
435 435
 			//trash removed options, save old ones
436 436
 			//get list of all options
437 437
 			/** @type EE_Question $question */
438
-			$question=$this->_question_model->get_one_by_ID($ID);
439
-			$options=$question->options();
440
-			if(! empty($options)){
441
-				foreach($options as $option_ID=>$option){
442
-					$option_req_index=$this->_get_option_req_data_index($option_ID);
443
-					if($option_req_index!==FALSE){
438
+			$question = $this->_question_model->get_one_by_ID($ID);
439
+			$options = $question->options();
440
+			if ( ! empty($options)) {
441
+				foreach ($options as $option_ID=>$option) {
442
+					$option_req_index = $this->_get_option_req_data_index($option_ID);
443
+					if ($option_req_index !== FALSE) {
444 444
 						$option->save($this->_req_data['question_options'][$option_req_index]);
445
-					}else{
445
+					} else {
446 446
 						//not found, remove it
447 447
 						$option->delete();
448 448
 					}
449 449
 				}
450 450
 			}
451 451
 			//save new related options
452
-			foreach($this->_req_data['question_options'] as $index=>$option_req_data){
453
-				if( empty($option_req_data['QSO_ID'] ) && (  ( isset( $option_req_data['QSO_value'] ) && $option_req_data['QSO_value'] !== '' ) || ! empty( $option_req_data['QSO_desc'] ) ) ) {//no ID! save it!
454
-					if( ! isset( $option_req_data['QSO_value'] ) || $option_req_data['QSO_value'] === ''  ){
455
-						$option_req_data['QSO_value']=$option_req_data['QSO_desc'];
452
+			foreach ($this->_req_data['question_options'] as $index=>$option_req_data) {
453
+				if (empty($option_req_data['QSO_ID']) && ((isset($option_req_data['QSO_value']) && $option_req_data['QSO_value'] !== '') || ! empty($option_req_data['QSO_desc']))) {//no ID! save it!
454
+					if ( ! isset($option_req_data['QSO_value']) || $option_req_data['QSO_value'] === '') {
455
+						$option_req_data['QSO_value'] = $option_req_data['QSO_desc'];
456 456
 					}
457
-					$new_option=EE_Question_Option::new_instance( array( 'QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID()));
457
+					$new_option = EE_Question_Option::new_instance(array('QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID()));
458 458
 					$new_option->save();
459 459
 				}
460 460
 			}
461 461
 		}
462
-		$query_args = array( 'action' => 'edit_question', 'QST_ID' => $ID );
463
-		if ( $success !== FALSE ) {
464
-			$msg = $new_question ? sprintf( __('The %s has been created', 'event_espresso'), $this->_question_model->item_name() ) : sprintf( __('The %s has been updated', 'event_espresso' ), $this->_question_model->item_name() );
465
-			EE_Error::add_success( $msg );
462
+		$query_args = array('action' => 'edit_question', 'QST_ID' => $ID);
463
+		if ($success !== FALSE) {
464
+			$msg = $new_question ? sprintf(__('The %s has been created', 'event_espresso'), $this->_question_model->item_name()) : sprintf(__('The %s has been updated', 'event_espresso'), $this->_question_model->item_name());
465
+			EE_Error::add_success($msg);
466 466
 		}
467 467
 
468
-		$this->_redirect_after_action( FALSE, '', $action_desc, $query_args, TRUE);
468
+		$this->_redirect_after_action(FALSE, '', $action_desc, $query_args, TRUE);
469 469
 	}
470 470
 
471 471
 
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
 	 * @param int $ID of the question option to find
479 479
 	 * @return int index in question_options array if successful, FALSE if unsuccessful
480 480
 	 */
481
-	protected function _get_option_req_data_index($ID){
482
-		$req_data_for_question_options=$this->_req_data['question_options'];
483
-		foreach($req_data_for_question_options as $num=>$option_data){
484
-			if(array_key_exists('QSO_ID',$option_data) && intval($option_data['QSO_ID'])==$ID){
481
+	protected function _get_option_req_data_index($ID) {
482
+		$req_data_for_question_options = $this->_req_data['question_options'];
483
+		foreach ($req_data_for_question_options as $num=>$option_data) {
484
+			if (array_key_exists('QSO_ID', $option_data) && intval($option_data['QSO_ID']) == $ID) {
485 485
 				return $num;
486 486
 			}
487 487
 		}
@@ -503,25 +503,25 @@  discard block
 block discarded – undo
503 503
 	 * @param int      $current_page
504 504
 	 * @return array lik EEM_Base::get_all's $query_params parameter
505 505
 	 */
506
-	protected function get_query_params($model, $per_page=10,$current_page=10){
506
+	protected function get_query_params($model, $per_page = 10, $current_page = 10) {
507 507
 		$query_params = array();
508
-		$offset=($current_page-1)*$per_page;
509
-		$query_params['limit']=array($offset,$per_page);
510
-		$order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC';
508
+		$offset = ($current_page - 1) * $per_page;
509
+		$query_params['limit'] = array($offset, $per_page);
510
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
511 511
 		$orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order';
512 512
 		$field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby'];
513
-		$query_params['order_by']=array( $field_to_order_by => $order );
514
-		$search_string = array_key_exists('s',$this->_req_data) ? $this->_req_data['s'] : null;
515
-		if(! empty($search_string)){
516
-			if($model instanceof EEM_Question_Group){
517
-				$query_params[0]=array(
513
+		$query_params['order_by'] = array($field_to_order_by => $order);
514
+		$search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null;
515
+		if ( ! empty($search_string)) {
516
+			if ($model instanceof EEM_Question_Group) {
517
+				$query_params[0] = array(
518 518
 					'OR'=>array(
519
-						'QSG_name'=>array('LIKE',"%$search_string%"),
520
-						'QSG_desc'=>array('LIKE',"%$search_string%"))
519
+						'QSG_name'=>array('LIKE', "%$search_string%"),
520
+						'QSG_desc'=>array('LIKE', "%$search_string%"))
521 521
 					);
522
-			}else{
523
-				$query_params[0]=array(
524
-					'QST_display_text'=>array('LIKE',"%$search_string%")
522
+			} else {
523
+				$query_params[0] = array(
524
+					'QST_display_text'=>array('LIKE', "%$search_string%")
525 525
 					);
526 526
 			}
527 527
 		}
@@ -569,13 +569,13 @@  discard block
 block discarded – undo
569 569
 	 * @param bool|false $count
570 570
 	 * @return \EE_Soft_Delete_Base_Class[]|int
571 571
 	 */
572
-	public function get_questions( $per_page=10, $current_page = 1, $count = FALSE ) {
572
+	public function get_questions($per_page = 10, $current_page = 1, $count = FALSE) {
573 573
 		$QST = EEM_Question::instance();
574 574
 		$query_params = $this->get_query_params($QST, $per_page, $current_page);
575
-		if ($count){
576
-			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
575
+		if ($count) {
576
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
577 577
 			$results = $QST->count($where);
578
-		}else{
578
+		} else {
579 579
 			$results = $QST->get_all($query_params);
580 580
 		}
581 581
 		return $results;
@@ -590,10 +590,10 @@  discard block
 block discarded – undo
590 590
 	 * @param bool|false $count
591 591
 	 * @return \EE_Soft_Delete_Base_Class[]|int
592 592
 	 */
593
-	public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) {
594
-		$query_params =$this->get_query_params( EEM_Question::instance(), $per_page, $current_page);
595
-		$where        = isset( $query_params[0] ) ? array($query_params[0]) : array();
596
-		$questions    =$count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params);
593
+	public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) {
594
+		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
595
+		$where        = isset($query_params[0]) ? array($query_params[0]) : array();
596
+		$questions    = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params);
597 597
 		return $questions;
598 598
 	}
599 599
 
@@ -605,11 +605,11 @@  discard block
 block discarded – undo
605 605
 	 * @param bool|false $count
606 606
 	 * @return \EE_Soft_Delete_Base_Class[]
607 607
 	 */
608
-	public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) {
608
+	public function get_question_groups($per_page, $current_page = 1, $count = FALSE) {
609 609
 		/** @type EEM_Question_Group $questionGroupModel */
610
-		$questionGroupModel=EEM_Question_Group::instance();
611
-		$query_params=$this->get_query_params( $questionGroupModel, $per_page, $current_page );
612
-		$questionGroups=$questionGroupModel->get_all($query_params);//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
610
+		$questionGroupModel = EEM_Question_Group::instance();
611
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
612
+		$questionGroups = $questionGroupModel->get_all($query_params); //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
613 613
 		return $questionGroups;
614 614
 	}
615 615
 
@@ -626,36 +626,36 @@  discard block
 block discarded – undo
626 626
 
627 627
 		$this->_template_args['values'] = $this->_yes_no_values;
628 628
 
629
-		$this->_template_args['use_captcha'] = isset( EE_Registry::instance()->CFG->registration->use_captcha ) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE;
630
-		$this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"': '';
629
+		$this->_template_args['use_captcha'] = isset(EE_Registry::instance()->CFG->registration->use_captcha) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE;
630
+		$this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"' : '';
631 631
 
632
-		$this->_template_args['recaptcha_publickey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) : '';
633
-		$this->_template_args['recaptcha_privatekey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) : '';
634
-		$this->_template_args['recaptcha_width'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_width ) ? absint( EE_Registry::instance()->CFG->registration->recaptcha_width ) : 500;
632
+		$this->_template_args['recaptcha_publickey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_publickey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_publickey) : '';
633
+		$this->_template_args['recaptcha_privatekey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) : '';
634
+		$this->_template_args['recaptcha_width'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_width) ? absint(EE_Registry::instance()->CFG->registration->recaptcha_width) : 500;
635 635
 
636 636
 		$this->_template_args['recaptcha_theme_options'] = array(
637
-				array('id'  => 'red','text'=> __('Red', 'event_espresso')),
638
-				array('id'  => 'white','text'=> __('White', 'event_espresso')),
639
-				array('id'  => 'blackglass','text'=> __('Blackglass', 'event_espresso')),
640
-				array('id'  => 'clean','text'=> __('Clean', 'event_espresso'))
637
+				array('id'  => 'red', 'text'=> __('Red', 'event_espresso')),
638
+				array('id'  => 'white', 'text'=> __('White', 'event_espresso')),
639
+				array('id'  => 'blackglass', 'text'=> __('Blackglass', 'event_espresso')),
640
+				array('id'  => 'clean', 'text'=> __('Clean', 'event_espresso'))
641 641
 			);
642
-		$this->_template_args['recaptcha_theme'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_theme ) ? EE_Registry::instance()->CFG->registration->get_pretty( 'recaptcha_theme' ) : 'clean';
642
+		$this->_template_args['recaptcha_theme'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_theme) ? EE_Registry::instance()->CFG->registration->get_pretty('recaptcha_theme') : 'clean';
643 643
 
644 644
 		$this->_template_args['recaptcha_language_options'] = array(
645
-				array('id'  => 'en','text'=> __('English', 'event_espresso')),
646
-				array('id'  => 'es','text'=> __('Spanish', 'event_espresso')),
647
-				array('id'  => 'nl','text'=> __('Dutch', 'event_espresso')),
648
-				array('id'  => 'fr','text'=> __('French', 'event_espresso')),
649
-				array('id'  => 'de','text'=> __('German', 'event_espresso')),
650
-				array('id'  => 'pt','text'=> __('Portuguese', 'event_espresso')),
651
-				array('id'  => 'ru','text'=> __('Russian', 'event_espresso')),
652
-				array('id'  => 'tr','text'=> __('Turkish', 'event_espresso'))
645
+				array('id'  => 'en', 'text'=> __('English', 'event_espresso')),
646
+				array('id'  => 'es', 'text'=> __('Spanish', 'event_espresso')),
647
+				array('id'  => 'nl', 'text'=> __('Dutch', 'event_espresso')),
648
+				array('id'  => 'fr', 'text'=> __('French', 'event_espresso')),
649
+				array('id'  => 'de', 'text'=> __('German', 'event_espresso')),
650
+				array('id'  => 'pt', 'text'=> __('Portuguese', 'event_espresso')),
651
+				array('id'  => 'ru', 'text'=> __('Russian', 'event_espresso')),
652
+				array('id'  => 'tr', 'text'=> __('Turkish', 'event_espresso'))
653 653
 			);
654
-		$this->_template_args['recaptcha_language'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_language ) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en';
654
+		$this->_template_args['recaptcha_language'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_language) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en';
655 655
 
656
-		$this->_set_add_edit_form_tags( 'update_reg_form_settings' );
657
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
658
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'reg_form_settings.template.php', $this->_template_args, TRUE );
656
+		$this->_set_add_edit_form_tags('update_reg_form_settings');
657
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
658
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'reg_form_settings.template.php', $this->_template_args, TRUE);
659 659
 		$this->display_admin_page_with_sidebar();
660 660
 	}
661 661
 
Please login to merge, or discard this patch.
registration_form/templates/questions_main_meta_box.template.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 		<tbody>
22 22
 			<tr>
23 23
 				<th>
24
-					<label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info');?>
24
+					<label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info'); ?>
25 25
 				</th>
26 26
 				<td>
27 27
 					<input type="text" class="regular-text" id="QST_display_text" name="QST_display_text" value="<?php $question->f('QST_display_text')?>"/>
@@ -31,23 +31,23 @@  discard block
 block discarded – undo
31 31
 
32 32
 			<tr>
33 33
 				<th>
34
-					<label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info');?>
34
+					<label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info'); ?>
35 35
 				</th>
36 36
 				<td>
37 37
 					<?php
38
-						$disabled = ! empty( $QST_system ) ? ' disabled="disabled"' : '';
39
-						$id =  ! empty( $QST_system ) ? '_disabled' : '';
38
+						$disabled = ! empty($QST_system) ? ' disabled="disabled"' : '';
39
+						$id = ! empty($QST_system) ? '_disabled' : '';
40 40
 					?>
41 41
 					<input type="text" class="regular-text" id="QST_admin_label<?php echo $id?>" name="QST_admin_label<?php echo $id?>" value="<?php $question->f('QST_admin_label')?>"<?php echo $disabled?>/>
42 42
 					<input class="QST_order" type="hidden" id="QST_order<?php echo $id; ?>" name = "QST_order<?php echo $id; ?>" value="<?php echo $question->get('QST_order'); ?>" />
43
-					<?php if ( ! empty( $QST_system )) { ?>
43
+					<?php if ( ! empty($QST_system)) { ?>
44 44
 						<input type="hidden"  id="QST_admin_label" name="QST_admin_label" value="<?php echo $question->admin_label()?>"/>
45 45
 					<?php } ?>
46 46
 					<br/>
47 47
 					<p class="description">
48
-					<?php if ( ! empty( $QST_system )) { ?>
48
+					<?php if ( ! empty($QST_system)) { ?>
49 49
 					<span class="description" style="color:#D54E21;">
50
-						<?php _e('System question! This field cannot be changed.','event_espresso')?>
50
+						<?php _e('System question! This field cannot be changed.', 'event_espresso')?>
51 51
 					</span>
52 52
 					<?php } ?>
53 53
 
@@ -57,21 +57,21 @@  discard block
 block discarded – undo
57 57
 
58 58
 			<tr>
59 59
 				<th>
60
-					<label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info');?>
60
+					<label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info'); ?>
61 61
 				</th>
62 62
 				<td>
63 63
 					<?php
64
-						$disabled = ! empty( $QST_system ) ? ' disabled="disabled"' : '';
65
-						$id =  ! empty( $QST_system ) ? '_disabled' : '';
64
+						$disabled = ! empty($QST_system) ? ' disabled="disabled"' : '';
65
+						$id = ! empty($QST_system) ? '_disabled' : '';
66 66
 						$admin_only = $question->get('QST_admin_only');
67
-						$checked = !empty( $admin_only ) ? ' checked="checked"' : '';
67
+						$checked = ! empty($admin_only) ? ' checked="checked"' : '';
68 68
 					?>
69 69
 					<input class="QST_admin_only" type="checkbox" id="QST_admin_only<?php echo $id; ?>" name = "QST_admin_only<?php echo $id; ?>" value="1"<?php echo $disabled; echo $checked; ?>/>
70 70
 					<br/>
71 71
 					<p class="description">
72
-					<?php if ( ! empty( $QST_system )) { ?>
72
+					<?php if ( ! empty($QST_system)) { ?>
73 73
 					<span class="description" style="color:#D54E21;">
74
-						<?php _e('System question! This field cannot be changed.','event_espresso')?>
74
+						<?php _e('System question! This field cannot be changed.', 'event_espresso')?>
75 75
 					</span>
76 76
 					<?php } ?>
77 77
 
@@ -81,21 +81,21 @@  discard block
 block discarded – undo
81 81
 
82 82
 			<tr>
83 83
 				<th>
84
-					<label for="QST_type"><?php echo $fields['QST_type']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info');?>
84
+					<label for="QST_type"><?php echo $fields['QST_type']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info'); ?>
85 85
 				</th>
86 86
 				<td>
87 87
 					<?php
88
-						$disabled = ! empty( $QST_system ) ? ' disabled="disabled"' : '';
89
-						$id =  ! empty( $QST_system ) ? '_disabled' : '';
90
-						echo EEH_Form_Fields::select_input( 'QST_type' . $id, $question_types, $question->type(), 'id="QST_type' . $id . '"' . $disabled );
91
-						if( ! empty( $QST_system ) ) { ?>
88
+						$disabled = ! empty($QST_system) ? ' disabled="disabled"' : '';
89
+						$id = ! empty($QST_system) ? '_disabled' : '';
90
+						echo EEH_Form_Fields::select_input('QST_type'.$id, $question_types, $question->type(), 'id="QST_type'.$id.'"'.$disabled);
91
+						if ( ! empty($QST_system)) { ?>
92 92
 							<input type="hidden"  id="QST_type" name="QST_type" value="<?php echo $question->type()?>"/>
93 93
 						<?php
94
-							$explanatory_text = __('System question! This field cannot be changed.','event_espresso');
95
-						}else{
96
-							$explanatory_text = __('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.','event_espresso');
94
+							$explanatory_text = __('System question! This field cannot be changed.', 'event_espresso');
95
+						} else {
96
+							$explanatory_text = __('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.', 'event_espresso');
97 97
 						}
98
-						if ( ! empty( $QST_system ) || $has_answers ) { ?>
98
+						if ( ! empty($QST_system) || $has_answers) { ?>
99 99
 							<p><span class="description" style="color:#D54E21;">
100 100
 								<?php echo $explanatory_text; ?>
101 101
 							</span></p>
@@ -108,22 +108,22 @@  discard block
 block discarded – undo
108 108
 			<tr id="text_input_question_options">
109 109
 				<th>
110 110
 					<label>
111
-						<?php _e( 'Maximum Allowed Response Size', 'event_espresso' );?>
111
+						<?php _e('Maximum Allowed Response Size', 'event_espresso'); ?>
112 112
 					</label>
113 113
 				</th>
114 114
 				<td>
115
-					<input id="QST_max" name="QST_max" type="number" <?php echo $max_max == EE_INF ? '' : "max='$max_max'";?> value="<?php $question->f( 'QST_max' );?>" min="1">
115
+					<input id="QST_max" name="QST_max" type="number" <?php echo $max_max == EE_INF ? '' : "max='$max_max'"; ?> value="<?php $question->f('QST_max'); ?>" min="1">
116 116
 					<p>
117 117
 						<span class="description">
118
-							<?php _e( 'Maximum number of characters allowed when answering this question', 'event_espresso' );?>
118
+							<?php _e('Maximum number of characters allowed when answering this question', 'event_espresso'); ?>
119 119
 						</span>
120 120
 					</p>
121
-					<?php if ( $QST_system ) { ?>
121
+					<?php if ($QST_system) { ?>
122 122
 					<p>
123 123
 						<span class="description" style="color:#D54E21;">
124 124
 							<?php printf(
125
-									__( 'System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso' ),
126
-									$max_max );?>
125
+									__('System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso'),
126
+									$max_max ); ?>
127 127
 						</span>
128 128
 					</p>
129 129
 					<?php } ?>
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 			<tr id="question_options">
133 133
 				<th>
134 134
 					<label>
135
-						<?php _e('Answer Options','event_espresso')?>
135
+						<?php _e('Answer Options', 'event_espresso')?>
136 136
 					</label>
137 137
 				</th>
138 138
 				<td>
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
 						<thead>
142 142
 							<tr>
143 143
 								<th class="option-value-header">
144
-									<?php _e('Value','event_espresso')?>
144
+									<?php _e('Value', 'event_espresso')?>
145 145
 								</th>
146 146
 								<th class="option-desc-header">
147
-									<?php _e('Description (optional, only shown on registration form)','event_espresso')?>
147
+									<?php _e('Description (optional, only shown on registration form)', 'event_espresso')?>
148 148
 								</th>
149 149
 								<th>
150 150
 								</th>
@@ -167,17 +167,17 @@  discard block
 block discarded – undo
167 167
 							</tr>
168 168
 
169 169
 							<?php
170
-							$count=0;
170
+							$count = 0;
171 171
 							$question_options = $question->options();
172
-							if ( ! empty( $question_options )) {
173
-								foreach( $question_options as $option_id => $option ) {
174
-									$disabled =  $has_answers || $option->get('QSO_system') ? ' disabled="disabled"'  : '';
172
+							if ( ! empty($question_options)) {
173
+								foreach ($question_options as $option_id => $option) {
174
+									$disabled = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : '';
175 175
 							?>
176 176
 								<tr class="question-option ee-options-sortable">
177 177
 									<td class="option-value-cell">
178 178
 										<input type="hidden" class="QSO_order" name="question_options[<?php echo $count; ?>][QSO_order]" value="<?php echo $count; ?>">
179 179
 										<input type="text" class="option-value regular-text" name="question_options[<?php echo $count?>][QSO_value]" value="<?php  $option->f('QSO_value')?>"<?php echo $disabled; ?>>
180
-										<?php if ( $has_answers ) : ?>
180
+										<?php if ($has_answers) : ?>
181 181
 											<input type="hidden" name="question_options[<?php echo $count; ?>][QSO_value]" value="<?php echo $option->f('QSO_value'); ?>" >
182 182
 										<?php endif; ?>
183 183
 									</td>
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 										<input type="text" class="option-desc regular-text" name="question_options[<?php echo $count?>][QSO_desc]" value="<?php $option->f('QSO_desc')?>">
186 186
 									</td>
187 187
 									<td>
188
-										<?php if ( ! $option->system() ) { ?>
188
+										<?php if ( ! $option->system()) { ?>
189 189
 											<span class="dashicons clickable dashicons-post-trash ee-icon-size-18 remove-option remove-item"></span>
190 190
 										<?php } ?>
191 191
 										<span class="dashicons dashicons-image-flip-vertical sortable-drag-handle ee-icon-size-18"></span>
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
 					</table>
225 225
 
226 226
 					<a id="new-question-option" class="button" style="margin:0 0 1em 3px;">
227
-						<?php _e('Add Another Answer Option','event_espresso')?>
227
+						<?php _e('Add Another Answer Option', 'event_espresso')?>
228 228
 					</a><br/>
229 229
 
230 230
 					<p class="description">
231
-						<?php _e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.','event_espresso')?>
231
+						<?php _e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.', 'event_espresso')?>
232 232
 					</p>
233
-					<?php if ( $has_answers ) : ?>
233
+					<?php if ($has_answers) : ?>
234 234
 					<p class="description" style="color:#D54E21;">
235 235
 							<?php _e('Answer values that are uneditable are this way because there are registrations in the database that have answers for this question.  If you need to correct a mistake, or edit an existing option value, then trash the existing one and create a new option with the changes.  This will ensure that the existing registrations that chose the original answer will preserve that answer.', 'event_espresso'); ?>
236 236
 					</p>
@@ -241,32 +241,32 @@  discard block
 block discarded – undo
241 241
 
242 242
 			<tr>
243 243
 				<th>
244
-					<label for="QST_required"><?php echo $fields['QST_required']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info');?>
244
+					<label for="QST_required"><?php echo $fields['QST_required']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info'); ?>
245 245
 				</th>
246 246
 				<td>
247 247
 					<?php
248
-					$system_required = array( 'fname', 'email' );
249
-					$disabled = in_array( $QST_system, $system_required ) ? ' disabled="disabled"' : '';
248
+					$system_required = array('fname', 'email');
249
+					$disabled = in_array($QST_system, $system_required) ? ' disabled="disabled"' : '';
250 250
 					$required_on = $question->get('QST_admin_only');
251 251
 					$show_required_msg = $required_on ? '' : ' display:none;';
252
-					$disabled = $required_on || ! empty( $disabled ) ? ' disabled="disabled"' : '';
253
-					$id =  ! empty( $disabled ) && in_array( $QST_system, $system_required) ? '_disabled' : '';
254
-					$requiredOptions=array(
255
-						array('text'=>'Optional','id'=>0),
256
-						array('text'=>'Required','id'=>1)
252
+					$disabled = $required_on || ! empty($disabled) ? ' disabled="disabled"' : '';
253
+					$id = ! empty($disabled) && in_array($QST_system, $system_required) ? '_disabled' : '';
254
+					$requiredOptions = array(
255
+						array('text'=>'Optional', 'id'=>0),
256
+						array('text'=>'Required', 'id'=>1)
257 257
 					);
258
-					echo EEH_Form_Fields::select_input('QST_required' . $id, $requiredOptions, $question->required(), 'id="QST_required' . $id . '"' . $disabled );
258
+					echo EEH_Form_Fields::select_input('QST_required'.$id, $requiredOptions, $question->required(), 'id="QST_required'.$id.'"'.$disabled);
259 259
 					?>
260 260
 						<p><span id="required_toggled_on" class="description" style="color:#D54E21;<?php echo $show_required_msg; ?>">
261
-						<?php _e('Required is set to optional, and this field is disabled, because the question is Admin-Only.','event_espresso')?>
261
+						<?php _e('Required is set to optional, and this field is disabled, because the question is Admin-Only.', 'event_espresso')?>
262 262
 						</span></p>
263 263
 						<p><span id="required_toggled_off" class="description" style="color:#D54E21; display: none;">
264
-							<?php _e('Required option field is no longer disabled because the question is not Admin-Only','event_espresso')?>
264
+							<?php _e('Required option field is no longer disabled because the question is not Admin-Only', 'event_espresso')?>
265 265
 						</span></p>
266
-					<?php if ( ! empty( $disabled ) && in_array( $QST_system, $system_required ) ) { ?>
266
+					<?php if ( ! empty($disabled) && in_array($QST_system, $system_required)) { ?>
267 267
 						<input type="hidden"  id="QST_required" name="QST_required" value="1"/>
268 268
 						<p><span class="description" style="color:#D54E21;">
269
-						<?php _e('System question! This field cannot be changed.','event_espresso')?>
269
+						<?php _e('System question! This field cannot be changed.', 'event_espresso')?>
270 270
 					</span></p>
271 271
 					<?php } ?>
272 272
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 			<tr>
277 277
 				<th>
278
-					<label for="QST_required_text"><?php _e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info');?>
278
+					<label for="QST_required_text"><?php _e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info'); ?>
279 279
 				</th>
280 280
 				<td>
281 281
 					<input type="text" class="regular-text" id="QST_required_text" name="QST_required_text" value="<?php  $question->f('QST_required_text')?>"/>
Please login to merge, or discard this patch.
core/db_models/EEM_Question.model.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' );
25
-require_once( EE_CLASSES . 'EE_Question.class.php');
24
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
25
+require_once(EE_CLASSES.'EE_Question.class.php');
26 26
 
27 27
 class EEM_Question extends EEM_Soft_Delete_Base {
28 28
 
@@ -69,21 +69,21 @@  discard block
 block discarded – undo
69 69
 	// private instance of the Attendee object
70 70
 	protected static $_instance = NULL;
71 71
 
72
-	protected function __construct( $timezone = NULL ) {
73
-		$this->singular_item = __('Question','event_espresso');
74
-		$this->plural_item = __('Questions','event_espresso');
75
-		$this->_allowed_question_types=apply_filters(
72
+	protected function __construct($timezone = NULL) {
73
+		$this->singular_item = __('Question', 'event_espresso');
74
+		$this->plural_item = __('Questions', 'event_espresso');
75
+		$this->_allowed_question_types = apply_filters(
76 76
 			'FHEE__EEM_Question__construct__allowed_question_types',
77 77
 			array(
78
-				EEM_Question::QST_type_text =>__('Text','event_espresso'),
79
-				EEM_Question::QST_type_textarea =>__('Textarea','event_espresso'),
80
-				EEM_Question::QST_type_checkbox =>__('Checkboxes','event_espresso'),
81
-				EEM_Question::QST_type_radio =>__('Radio Buttons','event_espresso'),
82
-				EEM_Question::QST_type_dropdown =>__('Dropdown','event_espresso'),
83
-				EEM_Question::QST_type_state =>__('State/Province Dropdown','event_espresso'),
84
-				EEM_Question::QST_type_country =>__('Country Dropdown','event_espresso'),
85
-				EEM_Question::QST_type_date =>__('Date Picker','event_espresso'),
86
-				EEM_Question::QST_type_html_textarea => __( 'HTML Textarea', 'event_espresso' ),
78
+				EEM_Question::QST_type_text =>__('Text', 'event_espresso'),
79
+				EEM_Question::QST_type_textarea =>__('Textarea', 'event_espresso'),
80
+				EEM_Question::QST_type_checkbox =>__('Checkboxes', 'event_espresso'),
81
+				EEM_Question::QST_type_radio =>__('Radio Buttons', 'event_espresso'),
82
+				EEM_Question::QST_type_dropdown =>__('Dropdown', 'event_espresso'),
83
+				EEM_Question::QST_type_state =>__('State/Province Dropdown', 'event_espresso'),
84
+				EEM_Question::QST_type_country =>__('Country Dropdown', 'event_espresso'),
85
+				EEM_Question::QST_type_date =>__('Date Picker', 'event_espresso'),
86
+				EEM_Question::QST_type_html_textarea => __('HTML Textarea', 'event_espresso'),
87 87
 			)
88 88
 		);
89 89
 		$this->_question_type_categories = apply_filters(
@@ -102,22 +102,22 @@  discard block
 block discarded – undo
102 102
 		);
103 103
 
104 104
 		$this->_tables = array(
105
-			'Question'=>new EE_Primary_Table('esp_question','QST_ID')
105
+			'Question'=>new EE_Primary_Table('esp_question', 'QST_ID')
106 106
 		);
107 107
 		$this->_fields = array(
108 108
 			'Question'=>array(
109
-				'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID','event_espresso')),
110
-				'QST_display_text'=>new EE_Full_HTML_Field('QST_display_text', __('Question Text','event_espresso'), true, ''),
111
-				'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)','event_espresso'), true, ''),
112
-				'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question','event_espresso'), TRUE, NULL ),
113
-				'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type','event_espresso'),false, 'TEXT',$this->_allowed_question_types),
114
-				'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?','event_espresso'), false, false),
115
-				'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided','event_espresso'), true, ''),
116
-				'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order','event_espresso'), false, 0),
117
-				'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?','event_espresso'), false, false),
118
-				'QST_max' => new EE_Infinite_Integer_Field( 'QST_max', __( 'Max Size', 'event_espresso'	), false, EE_INF ),
119
-				'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID','event_espresso'), false ),
120
-				'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted','event_espresso'), false, false)
109
+				'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso')),
110
+				'QST_display_text'=>new EE_Full_HTML_Field('QST_display_text', __('Question Text', 'event_espresso'), true, ''),
111
+				'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)', 'event_espresso'), true, ''),
112
+				'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question', 'event_espresso'), TRUE, NULL),
113
+				'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type', 'event_espresso'), false, 'TEXT', $this->_allowed_question_types),
114
+				'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?', 'event_espresso'), false, false),
115
+				'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided', 'event_espresso'), true, ''),
116
+				'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order', 'event_espresso'), false, 0),
117
+				'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?', 'event_espresso'), false, false),
118
+				'QST_max' => new EE_Infinite_Integer_Field('QST_max', __('Max Size', 'event_espresso'), false, EE_INF),
119
+				'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID', 'event_espresso'), false),
120
+				'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted', 'event_espresso'), false, false)
121 121
 			)
122 122
 		);
123 123
 		$this->_model_relations = array(
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
 			'Question_Group_Question'=>new EE_Has_Many_Relation()
130 130
 		);
131 131
 		//this model is generally available for reading
132
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
133
-		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QST_system');
134
-		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QST_system');
135
-		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QST_system');
136
-		parent::__construct( $timezone );
132
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
133
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QST_system');
134
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QST_system');
135
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QST_system');
136
+		parent::__construct($timezone);
137 137
 	}
138 138
 
139 139
 	/**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * but they can be extended
142 142
 	 * @return string[]
143 143
 	 */
144
-	public function allowed_question_types(){
144
+	public function allowed_question_types() {
145 145
 		return $this->_allowed_question_types;
146 146
 	}
147 147
 	/**
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
 	 * @param string $question_type one of EEM_Question::allowed_question_types(
150 150
 	 * @return string[] like EEM_Question::allowed_question_types()
151 151
 	 */
152
-	public function question_types_in_same_category( $question_type ) {
153
-		$question_types = array( $question_type );
154
-		foreach( $this->_question_type_categories as $category => $question_types_in_category ) {
155
-			if( in_array( $question_type, $question_types_in_category ) ) {
152
+	public function question_types_in_same_category($question_type) {
153
+		$question_types = array($question_type);
154
+		foreach ($this->_question_type_categories as $category => $question_types_in_category) {
155
+			if (in_array($question_type, $question_types_in_category)) {
156 156
 				$question_types = $question_types_in_category;
157 157
 				break;
158 158
 			}
159 159
 		}
160 160
 
161
-		return array_intersect_key( $this->allowed_question_types(), array_flip( $question_types ) );
161
+		return array_intersect_key($this->allowed_question_types(), array_flip($question_types));
162 162
 	}
163 163
 
164 164
 	/**
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 	 * @param string $category one of the top-level keys of EEM_Question::question_type_categories()
168 168
 	 * @return boolean
169 169
 	 */
170
-	public function question_type_is_in_category( $question_type, $category ) {
171
-		if( ! isset( $this->_question_type_categories[ $category ] ) ) {
170
+	public function question_type_is_in_category($question_type, $category) {
171
+		if ( ! isset($this->_question_type_categories[$category])) {
172 172
 			return false;
173 173
 		}
174
-		return in_array( $question_type, $this->_question_type_categories[ $category ] );
174
+		return in_array($question_type, $this->_question_type_categories[$category]);
175 175
 	}
176 176
 
177 177
 	/**
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 * @param string $system_question_group_id QSG_system
189 189
 	 * @return array of system question names (QST_system)
190 190
 	 */
191
-	public function allowed_system_questions_in_system_question_group( $system_question_group_id ) {
191
+	public function allowed_system_questions_in_system_question_group($system_question_group_id) {
192 192
 		$question_system_ids = array();
193
-		switch( $system_question_group_id ) {
193
+		switch ($system_question_group_id) {
194 194
 			case EEM_Question_Group::system_personal:
195 195
 				$question_system_ids = array(
196 196
 					EEM_Attendee::system_question_fname,
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 				);
212 212
 				break;
213 213
 		}
214
-		return apply_filters( 'FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id );
214
+		return apply_filters('FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id);
215 215
 	}
216 216
 
217 217
 	/**
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
 	 * @param string $system_question_group_id QSG_system
221 221
 	 * @return array of system question names (QST_system)
222 222
 	 */
223
-	public function required_system_questions_in_system_question_group( $system_question_group_id ) {
223
+	public function required_system_questions_in_system_question_group($system_question_group_id) {
224 224
 		$question_system_ids = null;
225
-		switch( $system_question_group_id ) {
225
+		switch ($system_question_group_id) {
226 226
 			case EEM_Question_Group::system_personal:
227
-				$question_system_ids =  array(
227
+				$question_system_ids = array(
228 228
 					EEM_Attendee::system_question_fname,
229 229
 					EEM_Attendee::system_question_email,
230 230
 				);
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			default:
233 233
 				$question_system_ids = array();
234 234
 		}
235
-		return apply_filters( 'FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id );
235
+		return apply_filters('FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id);
236 236
 	}
237 237
 
238 238
 
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 	 * @param $QST_system
244 244
 	 * @return int of QST_ID for the question that corresponds to that QST_system
245 245
 	 */
246
-	public function get_Question_ID_from_system_string( $QST_system ){
247
-		 return $this->get_var( array( array( 'QST_system' => $QST_system ) ) );
246
+	public function get_Question_ID_from_system_string($QST_system) {
247
+		 return $this->get_var(array(array('QST_system' => $QST_system)));
248 248
 	}
249 249
 
250 250
 
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 	 */
257 257
 	public function get_latest_question_order() {
258 258
 		$columns_to_select = array(
259
-			'max_order' => array("MAX(QST_order)","%d")
259
+			'max_order' => array("MAX(QST_order)", "%d")
260 260
 		);
261
-		$max = $this->_get_all_wpdb_results( array(), ARRAY_A, $columns_to_select );
261
+		$max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
262 262
 		return $max[0]['max_order'];
263 263
 	}
264 264
 
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
 	 * @param string $system_question_value
289 289
 	 * @return int|float
290 290
 	 */
291
-	public function absolute_max_for_system_question( $system_question_value ) {
291
+	public function absolute_max_for_system_question($system_question_value) {
292 292
 		$maxes = $this->system_question_maxes();
293
-		if( isset( $maxes[ $system_question_value ] ) ) {
294
-			return $maxes[ $system_question_value ];
293
+		if (isset($maxes[$system_question_value])) {
294
+			return $maxes[$system_question_value];
295 295
 		} else {
296 296
 			return EE_INF;
297 297
 		}
Please login to merge, or discard this patch.
core/helpers/EEH_Activation.helper.php 1 patch
Spacing   +367 added lines, -367 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 * @param $table_name
58 58
 	 * @return string
59 59
 	 */
60
-	public static function ensure_table_name_has_prefix( $table_name ) {
60
+	public static function ensure_table_name_has_prefix($table_name) {
61 61
 		global $wpdb;
62
-		return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name;
62
+		return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name;
63 63
 	}
64 64
 
65 65
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * be called on plugin activation and reactivation
86 86
 	 * @return boolean success, whether the database and folders are setup properly
87 87
 	 */
88
-	public static function initialize_db_and_folders(){
88
+	public static function initialize_db_and_folders() {
89 89
 		$good_filesystem = EEH_Activation::create_upload_directories();
90 90
 		$good_db = EEH_Activation::create_database_tables();
91 91
 		return $good_filesystem && $good_db;
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	 * upon activation of a new plugin, reactivation, and at the end
100 100
 	 * of running migration scripts
101 101
 	 */
102
-	public static function initialize_db_content(){
102
+	public static function initialize_db_content() {
103 103
 		//let's avoid doing all this logic repeatedly, especially when addons are requesting it
104
-		if( EEH_Activation::$_initialized_db_content_already_in_this_request ) {
104
+		if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
105 105
 			return;
106 106
 		}
107 107
 		EEH_Activation::$_initialized_db_content_already_in_this_request = true;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		EEH_Activation::remove_cron_tasks();
119 119
 		EEH_Activation::create_cron_tasks();
120 120
 		//also, check for CAF default db content
121
-		do_action( 'AHEE__EEH_Activation__initialize_db_content' );
121
+		do_action('AHEE__EEH_Activation__initialize_db_content');
122 122
 		//also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
123 123
 		//which users really won't care about on initial activation
124 124
 		EE_Error::overwrite_success();
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @return array
138 138
 	 * @throws \EE_Error
139 139
 	 */
140
-	public static function get_cron_tasks( $which_to_include ) {
140
+	public static function get_cron_tasks($which_to_include) {
141 141
 		$cron_tasks = apply_filters(
142 142
 			'FHEE__EEH_Activation__get_cron_tasks',
143 143
 			array(
@@ -146,17 +146,17 @@  discard block
 block discarded – undo
146 146
 				'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
147 147
 			)
148 148
 		);
149
-		if( $which_to_include === 'all' ) {
149
+		if ($which_to_include === 'all') {
150 150
 			//leave as-is
151
-		}elseif( $which_to_include === 'old' ) {
152
-			$cron_tasks = array_filter( $cron_tasks, function ( $value ) {
151
+		}elseif ($which_to_include === 'old') {
152
+			$cron_tasks = array_filter($cron_tasks, function($value) {
153 153
 				return $value === EEH_Activation::cron_task_no_longer_in_use;
154 154
 			});
155
-		}elseif( $which_to_include === 'current' ) {
156
-			$cron_tasks = array_filter( $cron_tasks );
157
-		}elseif( WP_DEBUG ) {
158
-			throw new EE_Error( sprintf( __( 'Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso' ), $which_to_include ) );
159
-		}else{
155
+		}elseif ($which_to_include === 'current') {
156
+			$cron_tasks = array_filter($cron_tasks);
157
+		}elseif (WP_DEBUG) {
158
+			throw new EE_Error(sprintf(__('Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso'), $which_to_include));
159
+		} else {
160 160
 			//leave as-is
161 161
 		}
162 162
 		return $cron_tasks;
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public static function create_cron_tasks() {
169 169
 
170
-		foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) {
171
-			if( ! wp_next_scheduled( $hook_name ) ) {
172
-				wp_schedule_event( time(), $frequency, $hook_name );
170
+		foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
171
+			if ( ! wp_next_scheduled($hook_name)) {
172
+				wp_schedule_event(time(), $frequency, $hook_name);
173 173
 			}
174 174
 		}
175 175
 
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 	 * Remove the currently-existing and now-removed cron tasks.
180 180
 	 * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
181 181
 	 */
182
-	public static function remove_cron_tasks( $remove_all = true ) {
182
+	public static function remove_cron_tasks($remove_all = true) {
183 183
 		$cron_tasks_to_remove = $remove_all ? 'all' : 'old';
184 184
 		$crons = _get_cron_array();
185
-		$crons = is_array( $crons ) ? $crons : array();
185
+		$crons = is_array($crons) ? $crons : array();
186 186
 		/* reminder that $crons looks like: top-level keys are timestamps,
187 187
 		 * and their values are arrays.
188 188
 		 * The 2nd level arrays have keys with each of the cron task hooknames to run at that time
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 		 *					...
201 201
 		 *      ...
202 202
 		 */
203
-		foreach( EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ) as $hook_name => $frequency ) {
204
-			foreach( $crons as $timestamp => $hooks_to_fire_at_time ) {
205
-				if ( array_key_exists( $hook_name, $hooks_to_fire_at_time ) )  {
206
-					unset( $crons[ $timestamp ][ $hook_name ] );
203
+		foreach (EEH_Activation::get_cron_tasks($cron_tasks_to_remove) as $hook_name => $frequency) {
204
+			foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
205
+				if (array_key_exists($hook_name, $hooks_to_fire_at_time)) {
206
+					unset($crons[$timestamp][$hook_name]);
207 207
 				}
208 208
 			}
209 209
 		}
210
-		_set_cron_array( $crons );
210
+		_set_cron_array($crons);
211 211
 	}
212 212
 
213 213
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	public static function CPT_initialization() {
224 224
 		// register Custom Post Types
225
-		EE_Registry::instance()->load_core( 'Register_CPTs' );
225
+		EE_Registry::instance()->load_core('Register_CPTs');
226 226
 		flush_rewrite_rules();
227 227
 	}
228 228
 
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 	 * 	@return void
241 241
 	 */
242 242
 	public static function reset_and_update_config() {
243
-		do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) );
244
-		add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 );
243
+		do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
244
+		add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3);
245 245
 		//EE_Config::reset();
246 246
 	}
247 247
 
@@ -254,23 +254,23 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	public static function load_calendar_config() {
256 256
 		// grab array of all plugin folders and loop thru it
257
-		$plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR );
258
-		if ( empty( $plugins ) ) {
257
+		$plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR);
258
+		if (empty($plugins)) {
259 259
 			return;
260 260
 		}
261
-		foreach ( $plugins as $plugin_path ) {
261
+		foreach ($plugins as $plugin_path) {
262 262
 			// grab plugin folder name from path
263
-			$plugin = basename( $plugin_path );
263
+			$plugin = basename($plugin_path);
264 264
 			// drill down to Espresso plugins
265
-			if ( strpos( $plugin, 'espresso' ) !== FALSE || strpos( $plugin, 'Espresso' ) !== FALSE || strpos( $plugin, 'ee4' ) !== FALSE || strpos( $plugin, 'EE4' ) !== FALSE ) {
265
+			if (strpos($plugin, 'espresso') !== FALSE || strpos($plugin, 'Espresso') !== FALSE || strpos($plugin, 'ee4') !== FALSE || strpos($plugin, 'EE4') !== FALSE) {
266 266
 				// then to calendar related plugins
267
-				if ( strpos( $plugin, 'calendar' ) !== FALSE ) {
267
+				if (strpos($plugin, 'calendar') !== FALSE) {
268 268
 					// this is what we are looking for
269
-					$calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
269
+					$calendar_config = $plugin_path.DS.'EE_Calendar_Config.php';
270 270
 					// does it exist in this folder ?
271
-					if ( is_readable( $calendar_config )) {
271
+					if (is_readable($calendar_config)) {
272 272
 						// YEAH! let's load it
273
-						require_once( $calendar_config );
273
+						require_once($calendar_config);
274 274
 					}
275 275
 				}
276 276
 			}
@@ -287,21 +287,21 @@  discard block
 block discarded – undo
287 287
 	 * @param \EE_Config $EE_Config
288 288
 	 * @return \stdClass
289 289
 	 */
290
-	public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) {
291
-		$convert_from_array = array( 'addons' );
290
+	public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) {
291
+		$convert_from_array = array('addons');
292 292
 		// in case old settings were saved as an array
293
-		if ( is_array( $settings ) && in_array( $config, $convert_from_array )) {
293
+		if (is_array($settings) && in_array($config, $convert_from_array)) {
294 294
 			// convert existing settings to an object
295 295
 			$config_array = $settings;
296 296
 			$settings = new stdClass();
297
-			foreach ( $config_array as $key => $value ){
298
-				if ( $key == 'calendar' && class_exists( 'EE_Calendar_Config' )) {
299
-					$EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value );
297
+			foreach ($config_array as $key => $value) {
298
+				if ($key == 'calendar' && class_exists('EE_Calendar_Config')) {
299
+					$EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
300 300
 				} else {
301 301
 					$settings->$key = $value;
302 302
 				}
303 303
 			}
304
-			add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' );
304
+			add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
305 305
 		}
306 306
 		return $settings;
307 307
 	}
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 	 */
318 318
 	public static function deactivate_event_espresso() {
319 319
 		// check permissions
320
-		if ( current_user_can( 'activate_plugins' )) {
321
-			deactivate_plugins( EE_PLUGIN_BASENAME, TRUE );
320
+		if (current_user_can('activate_plugins')) {
321
+			deactivate_plugins(EE_PLUGIN_BASENAME, TRUE);
322 322
 		}
323 323
 	}
324 324
 
@@ -340,79 +340,79 @@  discard block
 block discarded – undo
340 340
 		$critical_pages = array(
341 341
 			array(
342 342
 				'id' =>'reg_page_id',
343
-				'name' => __( 'Registration Checkout', 'event_espresso' ),
343
+				'name' => __('Registration Checkout', 'event_espresso'),
344 344
 				'post' => NULL,
345 345
 				'code' => 'ESPRESSO_CHECKOUT'
346 346
 			),
347 347
 			array(
348 348
 				'id' => 'txn_page_id',
349
-				'name' => __( 'Transactions', 'event_espresso' ),
349
+				'name' => __('Transactions', 'event_espresso'),
350 350
 				'post' => NULL,
351 351
 				'code' => 'ESPRESSO_TXN_PAGE'
352 352
 			),
353 353
 			array(
354 354
 				'id' => 'thank_you_page_id',
355
-				'name' => __( 'Thank You', 'event_espresso' ),
355
+				'name' => __('Thank You', 'event_espresso'),
356 356
 				'post' => NULL,
357 357
 				'code' => 'ESPRESSO_THANK_YOU'
358 358
 			),
359 359
 			array(
360 360
 				'id' => 'cancel_page_id',
361
-				'name' => __( 'Registration Cancelled', 'event_espresso' ),
361
+				'name' => __('Registration Cancelled', 'event_espresso'),
362 362
 				'post' => NULL,
363 363
 				'code' => 'ESPRESSO_CANCELLED'
364 364
 			),
365 365
 		);
366 366
 
367
-		foreach ( $critical_pages as $critical_page ) {
367
+		foreach ($critical_pages as $critical_page) {
368 368
 			// is critical page ID set in config ?
369
-			if ( EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE ) {
369
+			if (EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE) {
370 370
 				// attempt to find post by ID
371
-				$critical_page['post'] = get_post( EE_Registry::instance()->CFG->core->$critical_page['id'] );
371
+				$critical_page['post'] = get_post(EE_Registry::instance()->CFG->core->$critical_page['id']);
372 372
 			}
373 373
 			// no dice?
374
-			if ( $critical_page['post'] == NULL ) {
374
+			if ($critical_page['post'] == NULL) {
375 375
 				// attempt to find post by title
376
-				$critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] );
376
+				$critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
377 377
 				// still nothing?
378
-				if ( $critical_page['post'] == NULL ) {
379
-					$critical_page = EEH_Activation::create_critical_page( $critical_page );
378
+				if ($critical_page['post'] == NULL) {
379
+					$critical_page = EEH_Activation::create_critical_page($critical_page);
380 380
 					// REALLY? Still nothing ??!?!?
381
-					if ( $critical_page['post'] == NULL ) {
382
-						$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
383
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
381
+					if ($critical_page['post'] == NULL) {
382
+						$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
383
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
384 384
 						break;
385 385
 					}
386 386
 				}
387 387
 			}
388 388
 			// track post_shortcodes
389
-			if ( $critical_page['post'] ) {
390
-				EEH_Activation::_track_critical_page_post_shortcodes( $critical_page );
389
+			if ($critical_page['post']) {
390
+				EEH_Activation::_track_critical_page_post_shortcodes($critical_page);
391 391
 			}
392 392
 			// check that Post ID matches critical page ID in config
393
-			if ( isset( $critical_page['post']->ID ) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id'] ) {
393
+			if (isset($critical_page['post']->ID) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id']) {
394 394
 				//update Config with post ID
395 395
 				EE_Registry::instance()->CFG->core->$critical_page['id'] = $critical_page['post']->ID;
396
-				if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) {
397
-					$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
398
-					EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
396
+				if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
397
+					$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
398
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
399 399
 				}
400 400
 			}
401 401
 
402
-			$critical_page_problem =  ! isset( $critical_page['post']->post_status ) || $critical_page['post']->post_status != 'publish' || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE ? TRUE : $critical_page_problem;
402
+			$critical_page_problem = ! isset($critical_page['post']->post_status) || $critical_page['post']->post_status != 'publish' || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE ? TRUE : $critical_page_problem;
403 403
 
404 404
 		}
405 405
 
406
-		if ( $critical_page_problem ) {
406
+		if ($critical_page_problem) {
407 407
 			$msg = sprintf(
408
-				__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ),
409
-				'<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>'
408
+				__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'),
409
+				'<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>'
410 410
 			);
411
-			EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg );
411
+			EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
412 412
 		}
413 413
 
414
-		if ( EE_Error::has_notices() ) {
415
-			EE_Error::get_notices( FALSE, TRUE, TRUE );
414
+		if (EE_Error::has_notices()) {
415
+			EE_Error::get_notices(FALSE, TRUE, TRUE);
416 416
 		}
417 417
 
418 418
 	}
@@ -425,13 +425,13 @@  discard block
 block discarded – undo
425 425
 	 * parameter to the shortcode
426 426
 	 * @return WP_Post or NULl
427 427
 	 */
428
-	public static function get_page_by_ee_shortcode($ee_shortcode){
428
+	public static function get_page_by_ee_shortcode($ee_shortcode) {
429 429
 		global $wpdb;
430 430
 		$shortcode_and_opening_bracket = '['.$ee_shortcode;
431 431
 		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
432
-		if($post_id){
432
+		if ($post_id) {
433 433
 			return get_post($post_id);
434
-		}else{
434
+		} else {
435 435
 			return NULL;
436 436
 		}
437 437
 
@@ -448,32 +448,32 @@  discard block
 block discarded – undo
448 448
 	 * @param array $critical_page
449 449
 	 * @return array
450 450
 	 */
451
-	public static function create_critical_page( $critical_page ) {
451
+	public static function create_critical_page($critical_page) {
452 452
 
453 453
 		$post_args = array(
454 454
 			'post_title' => $critical_page['name'],
455 455
 			'post_status' => 'publish',
456 456
 			'post_type' => 'page',
457 457
 			'comment_status' => 'closed',
458
-			'post_content' => '[' . $critical_page['code'] . ']'
458
+			'post_content' => '['.$critical_page['code'].']'
459 459
 		);
460 460
 
461
-		$post_id = wp_insert_post( $post_args );
462
-		if ( ! $post_id ) {
461
+		$post_id = wp_insert_post($post_args);
462
+		if ( ! $post_id) {
463 463
 			$msg = sprintf(
464
-				__( 'The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso' ),
464
+				__('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
465 465
 				$critical_page['name']
466 466
 			);
467
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
467
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
468 468
 			return $critical_page;
469 469
 		}
470 470
 		// get newly created post's details
471
-		if ( ! $critical_page['post'] = get_post( $post_id )) {
471
+		if ( ! $critical_page['post'] = get_post($post_id)) {
472 472
 			$msg = sprintf(
473
-				__( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ),
473
+				__('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
474 474
 				$critical_page['name']
475 475
 			);
476
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
476
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
477 477
 		}
478 478
 
479 479
 		return $critical_page;
@@ -492,34 +492,34 @@  discard block
 block discarded – undo
492 492
 	 * @param array $critical_page
493 493
 	 * @return void
494 494
 	 */
495
-	private static function _track_critical_page_post_shortcodes( $critical_page = array() ) {
495
+	private static function _track_critical_page_post_shortcodes($critical_page = array()) {
496 496
 		// check the goods
497
-		if ( ! $critical_page['post'] instanceof WP_Post ) {
497
+		if ( ! $critical_page['post'] instanceof WP_Post) {
498 498
 			$msg = sprintf(
499
-				__( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ),
499
+				__('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'),
500 500
 				$critical_page['name']
501 501
 			);
502
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
502
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
503 503
 			return;
504 504
 		}
505 505
 		// map shortcode to post
506
-		EE_Registry::instance()->CFG->core->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID;
506
+		EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID;
507 507
 		// and make sure it's NOT added to the WP "Posts Page"
508 508
 		// name of the WP Posts Page
509 509
 		$posts_page = EE_Registry::instance()->CFG->get_page_for_posts();
510
-		if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ] )) {
511
-			unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ][ $critical_page['code'] ] );
510
+		if (isset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page])) {
511
+			unset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page][$critical_page['code']]);
512 512
 		}
513
-		if ( $posts_page != 'posts' && isset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'] )) {
514
-			unset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'][ $critical_page['code'] ] );
513
+		if ($posts_page != 'posts' && isset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'])) {
514
+			unset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'][$critical_page['code']]);
515 515
 		}
516 516
 		// update post_shortcode CFG
517
-		if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) {
517
+		if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
518 518
 			$msg = sprintf(
519
-				__( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ),
519
+				__('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'),
520 520
 				$critical_page['name']
521 521
 			);
522
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
522
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
523 523
 		}
524 524
 	}
525 525
 
@@ -537,24 +537,24 @@  discard block
 block discarded – undo
537 537
 	public static function get_default_creator_id() {
538 538
 		global $wpdb;
539 539
 
540
-		if ( ! empty( self::$_default_creator_id ) ) {
540
+		if ( ! empty(self::$_default_creator_id)) {
541 541
 			return self::$_default_creator_id;
542 542
 		}/**/
543 543
 
544
-		$role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' );
544
+		$role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
545 545
 
546 546
 		//let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
547
-		$pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check );
548
-		if ( $pre_filtered_id !== false ) {
547
+		$pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check);
548
+		if ($pre_filtered_id !== false) {
549 549
 			return (int) $pre_filtered_id;
550 550
 		}
551 551
 
552
-		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' );
553
-		$query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' );
554
-		$user_id = $wpdb->get_var( $query );
555
-		 $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id );
556
-		 if ( $user_id && intval( $user_id ) ) {
557
-		 	self::$_default_creator_id =  intval( $user_id );
552
+		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities');
553
+		$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%');
554
+		$user_id = $wpdb->get_var($query);
555
+		 $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
556
+		 if ($user_id && intval($user_id)) {
557
+		 	self::$_default_creator_id = intval($user_id);
558 558
 		 	return self::$_default_creator_id;
559 559
 		 } else {
560 560
 		 	return NULL;
@@ -581,29 +581,29 @@  discard block
 block discarded – undo
581 581
 	 * 	@return void
582 582
 	 * @throws EE_Error if there are database errors
583 583
 	 */
584
-	public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) {
585
-		if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){
584
+	public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) {
585
+		if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) {
586 586
 			return;
587 587
 		}
588
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
589
-		if ( ! function_exists( 'dbDelta' )) {
590
-			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
588
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
589
+		if ( ! function_exists('dbDelta')) {
590
+			require_once(ABSPATH.'wp-admin/includes/upgrade.php');
591 591
 		}
592 592
 		/** @var WPDB $wpdb */
593 593
 		global $wpdb;
594
-		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
594
+		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
595 595
 		// do we need to first delete an existing version of this table ?
596
-		if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){
596
+		if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) {
597 597
 			// ok, delete the table... but ONLY if it's empty
598
-			$deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name );
598
+			$deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
599 599
 			// table is NOT empty, are you SURE you want to delete this table ???
600
-			if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){
601
-				EEH_Activation::delete_unused_db_table( $wp_table_name );
602
-			} else if ( ! $deleted_safely ) {
600
+			if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
601
+				EEH_Activation::delete_unused_db_table($wp_table_name);
602
+			} else if ( ! $deleted_safely) {
603 603
 				// so we should be more cautious rather than just dropping tables so easily
604 604
 				EE_Error::add_persistent_admin_notice(
605
-						'bad_table_' . $wp_table_name . '_detected',
606
-						sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ),
605
+						'bad_table_'.$wp_table_name.'_detected',
606
+						sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'),
607 607
 								$wp_table_name,
608 608
 								"<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>",
609 609
 								'<b>wp-config.php</b>',
@@ -612,25 +612,25 @@  discard block
 block discarded – undo
612 612
 			}
613 613
 		}
614 614
 		// does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns )
615
-		if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) {
615
+		if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) {
616 616
 			$SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;";
617 617
 			//get $wpdb to echo errors, but buffer them. This way at least WE know an error
618 618
 			//happened. And then we can choose to tell the end user
619
-			$old_show_errors_policy = $wpdb->show_errors( TRUE );
620
-			$old_error_suppression_policy = $wpdb->suppress_errors( FALSE );
619
+			$old_show_errors_policy = $wpdb->show_errors(TRUE);
620
+			$old_error_suppression_policy = $wpdb->suppress_errors(FALSE);
621 621
 			ob_start();
622
-			dbDelta( $SQL );
622
+			dbDelta($SQL);
623 623
 			$output = ob_get_contents();
624 624
 			ob_end_clean();
625
-			$wpdb->show_errors( $old_show_errors_policy );
626
-			$wpdb->suppress_errors( $old_error_suppression_policy );
627
-			if( ! empty( $output ) ){
628
-				throw new EE_Error( $output	);
625
+			$wpdb->show_errors($old_show_errors_policy);
626
+			$wpdb->suppress_errors($old_error_suppression_policy);
627
+			if ( ! empty($output)) {
628
+				throw new EE_Error($output);
629 629
 			}
630 630
 		} else {
631 631
 			throw new EE_Error(
632 632
 				sprintf(
633
-					__( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ),
633
+					__('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'),
634 634
 					'<br />',
635 635
 					$sql
636 636
 				)
@@ -652,15 +652,15 @@  discard block
 block discarded – undo
652 652
 	 * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be 'VARCHAR(10)'
653 653
 	 * @return bool|int
654 654
 	 */
655
-	public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){
656
-		if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){
655
+	public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') {
656
+		if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) {
657 657
 			return FALSE;
658 658
 		}
659 659
 		global $wpdb;
660
-		$full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
660
+		$full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
661 661
 		$fields = self::get_fields_on_table($table_name);
662
-		if (!in_array($column_name, $fields)){
663
-			$alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info";
662
+		if ( ! in_array($column_name, $fields)) {
663
+			$alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info";
664 664
 			//echo "alter query:$alter_query";
665 665
 			return $wpdb->query($alter_query);
666 666
 		}
@@ -679,15 +679,15 @@  discard block
 block discarded – undo
679 679
 	 * 	@param string $table_name, without prefixed $wpdb->prefix
680 680
 	 * 	@return array of database column names
681 681
 	 */
682
-	public static function get_fields_on_table( $table_name = NULL ) {
682
+	public static function get_fields_on_table($table_name = NULL) {
683 683
 		global $wpdb;
684
-		$table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
685
-		if ( ! empty( $table_name )) {
684
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
685
+		if ( ! empty($table_name)) {
686 686
 			$columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name ");
687 687
 			if ($columns !== FALSE) {
688 688
 				$field_array = array();
689
-				foreach($columns as $column ){
690
-					$field_array[] = $column->Field;;
689
+				foreach ($columns as $column) {
690
+					$field_array[] = $column->Field; ;
691 691
 				}
692 692
 				return $field_array;
693 693
 			}
@@ -705,12 +705,12 @@  discard block
 block discarded – undo
705 705
 	 * @param string $table_name
706 706
 	 * @return bool
707 707
 	 */
708
-	public static function db_table_is_empty( $table_name ) {
708
+	public static function db_table_is_empty($table_name) {
709 709
 		global $wpdb;
710
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
711
-		if ( EEH_Activation::table_exists( $table_name ) ) {
712
-			$count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
713
-			return absint( $count ) === 0 ? true : false;
710
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
711
+		if (EEH_Activation::table_exists($table_name)) {
712
+			$count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
713
+			return absint($count) === 0 ? true : false;
714 714
 		}
715 715
 		return false;
716 716
 	}
@@ -725,9 +725,9 @@  discard block
 block discarded – undo
725 725
 	 * @param string $table_name
726 726
 	 * @return bool | int
727 727
 	 */
728
-	public static function delete_db_table_if_empty( $table_name ) {
729
-		if ( EEH_Activation::db_table_is_empty( $table_name ) ) {
730
-			return EEH_Activation::delete_unused_db_table( $table_name );
728
+	public static function delete_db_table_if_empty($table_name) {
729
+		if (EEH_Activation::db_table_is_empty($table_name)) {
730
+			return EEH_Activation::delete_unused_db_table($table_name);
731 731
 		}
732 732
 		return false;
733 733
 	}
@@ -742,11 +742,11 @@  discard block
 block discarded – undo
742 742
 	 * @param string $table_name
743 743
 	 * @return bool | int
744 744
 	 */
745
-	public static function delete_unused_db_table( $table_name ) {
745
+	public static function delete_unused_db_table($table_name) {
746 746
 		global $wpdb;
747
-		if ( EEH_Activation::table_exists( $table_name ) ) {
748
-			$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
749
-			return $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
747
+		if (EEH_Activation::table_exists($table_name)) {
748
+			$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
749
+			return $wpdb->query("DROP TABLE IF EXISTS $table_name");
750 750
 		}
751 751
 		return false;
752 752
 	}
@@ -762,18 +762,18 @@  discard block
 block discarded – undo
762 762
 	 * @param string $index_name
763 763
 	 * @return bool | int
764 764
 	 */
765
-	public static function drop_index( $table_name, $index_name ) {
766
-		if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){
765
+	public static function drop_index($table_name, $index_name) {
766
+		if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) {
767 767
 			return FALSE;
768 768
 		}
769 769
 		global $wpdb;
770
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
770
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
771 771
 		$index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'";
772 772
 		if (
773
-			$wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name
774
-			&& $wpdb->get_var( $index_exists_query ) == $table_name //using get_var with the $index_exists_query returns the table's name
773
+			$wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name
774
+			&& $wpdb->get_var($index_exists_query) == $table_name //using get_var with the $index_exists_query returns the table's name
775 775
 		) {
776
-			return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" );
776
+			return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name");
777 777
 		}
778 778
 		return TRUE;
779 779
 	}
@@ -789,27 +789,27 @@  discard block
 block discarded – undo
789 789
 	 * @return boolean success (whether database is setup properly or not)
790 790
 	 */
791 791
 	public static function create_database_tables() {
792
-		EE_Registry::instance()->load_core( 'Data_Migration_Manager' );
792
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
793 793
 		//find the migration script that sets the database to be compatible with the code
794 794
 		$dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
795
-		if( $dms_name ){
796
-			$current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name );
797
-			$current_data_migration_script->set_migrating( false );
795
+		if ($dms_name) {
796
+			$current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
797
+			$current_data_migration_script->set_migrating(false);
798 798
 			$current_data_migration_script->schema_changes_before_migration();
799 799
 			$current_data_migration_script->schema_changes_after_migration();
800
-			if( $current_data_migration_script->get_errors() ){
801
-				if( WP_DEBUG ){
802
-					foreach( $current_data_migration_script->get_errors() as $error ){
803
-						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ );
800
+			if ($current_data_migration_script->get_errors()) {
801
+				if (WP_DEBUG) {
802
+					foreach ($current_data_migration_script->get_errors() as $error) {
803
+						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
804 804
 					}
805
-				}else{
806
-					EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) );
805
+				} else {
806
+					EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso'));
807 807
 				}
808 808
 				return false;
809 809
 			}
810 810
 			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
811
-		}else{
812
-			EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
811
+		} else {
812
+			EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
813 813
 			return false;
814 814
 		}
815 815
 		return true;
@@ -829,27 +829,27 @@  discard block
 block discarded – undo
829 829
 	public static function initialize_system_questions() {
830 830
 		// QUESTION GROUPS
831 831
 		global $wpdb;
832
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' );
832
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group');
833 833
 		$SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
834 834
 		// what we have
835
-		$question_groups = $wpdb->get_col( $SQL );
835
+		$question_groups = $wpdb->get_col($SQL);
836 836
 		// check the response
837
-		$question_groups = is_array( $question_groups ) ? $question_groups : array();
837
+		$question_groups = is_array($question_groups) ? $question_groups : array();
838 838
 		// what we should have
839
-		$QSG_systems = array( 1, 2 );
839
+		$QSG_systems = array(1, 2);
840 840
 		// loop thru what we should have and compare to what we have
841
-		foreach ( $QSG_systems as $QSG_system ) {
841
+		foreach ($QSG_systems as $QSG_system) {
842 842
 			// reset values array
843 843
 			$QSG_values = array();
844 844
 			// if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
845
-			if ( ! in_array( "$QSG_system", $question_groups )) {
845
+			if ( ! in_array("$QSG_system", $question_groups)) {
846 846
 				// add it
847
-				switch ( $QSG_system ) {
847
+				switch ($QSG_system) {
848 848
 
849 849
 					case 1:
850 850
 							$QSG_values = array(
851
-									'QSG_name' => __( 'Personal Information', 'event_espresso' ),
852
-									'QSG_identifier' => 'personal-information-' . time(),
851
+									'QSG_name' => __('Personal Information', 'event_espresso'),
852
+									'QSG_identifier' => 'personal-information-'.time(),
853 853
 									'QSG_desc' => '',
854 854
 									'QSG_order' => 1,
855 855
 									'QSG_show_group_name' => 1,
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
 
862 862
 					case 2:
863 863
 							$QSG_values = array(
864
-									'QSG_name' => __( 'Address Information','event_espresso' ),
865
-									'QSG_identifier' => 'address-information-' . time(),
864
+									'QSG_name' => __('Address Information', 'event_espresso'),
865
+									'QSG_identifier' => 'address-information-'.time(),
866 866
 									'QSG_desc' => '',
867 867
 									'QSG_order' => 2,
868 868
 									'QSG_show_group_name' => 1,
@@ -874,14 +874,14 @@  discard block
 block discarded – undo
874 874
 
875 875
 				}
876 876
 				// make sure we have some values before inserting them
877
-				if ( ! empty( $QSG_values )) {
877
+				if ( ! empty($QSG_values)) {
878 878
 					// insert system question
879 879
 					$wpdb->insert(
880 880
 						$table_name,
881 881
 						$QSG_values,
882
-						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' )
882
+						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
883 883
 					);
884
-					$QSG_IDs[ $QSG_system ] = $wpdb->insert_id;
884
+					$QSG_IDs[$QSG_system] = $wpdb->insert_id;
885 885
 				}
886 886
 			}
887 887
 		}
@@ -890,10 +890,10 @@  discard block
 block discarded – undo
890 890
 
891 891
 		// QUESTIONS
892 892
 		global $wpdb;
893
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' );
893
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question');
894 894
 		$SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
895 895
 		// what we have
896
-		$questions = $wpdb->get_col( $SQL );
896
+		$questions = $wpdb->get_col($SQL);
897 897
 		// what we should have
898 898
 		$QST_systems = array(
899 899
 			'fname',
@@ -910,25 +910,25 @@  discard block
 block discarded – undo
910 910
 		$order_for_group_1 = 1;
911 911
 		$order_for_group_2 = 1;
912 912
 		// loop thru what we should have and compare to what we have
913
-		foreach ( $QST_systems as $QST_system ) {
913
+		foreach ($QST_systems as $QST_system) {
914 914
 			// reset values array
915 915
 			$QST_values = array();
916 916
 			// if we don't have what we should have
917
-			if ( ! in_array( $QST_system, $questions )) {
917
+			if ( ! in_array($QST_system, $questions)) {
918 918
 				// add it
919
-				switch ( $QST_system ) {
919
+				switch ($QST_system) {
920 920
 
921 921
 					case 'fname':
922 922
 							$QST_values = array(
923
-									'QST_display_text' => __( 'First Name', 'event_espresso' ),
924
-									'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ),
923
+									'QST_display_text' => __('First Name', 'event_espresso'),
924
+									'QST_admin_label' => __('First Name - System Question', 'event_espresso'),
925 925
 									'QST_system' => 'fname',
926 926
 									'QST_type' => 'TEXT',
927 927
 									'QST_required' => 1,
928
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
928
+									'QST_required_text' => __('This field is required', 'event_espresso'),
929 929
 									'QST_order' => 1,
930 930
 									'QST_admin_only' => 0,
931
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
931
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
932 932
 									'QST_wp_user' => self::get_default_creator_id(),
933 933
 									'QST_deleted' => 0
934 934
 								);
@@ -936,15 +936,15 @@  discard block
 block discarded – undo
936 936
 
937 937
 					case 'lname':
938 938
 							$QST_values = array(
939
-									'QST_display_text' => __( 'Last Name', 'event_espresso' ),
940
-									'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ),
939
+									'QST_display_text' => __('Last Name', 'event_espresso'),
940
+									'QST_admin_label' => __('Last Name - System Question', 'event_espresso'),
941 941
 									'QST_system' => 'lname',
942 942
 									'QST_type' => 'TEXT',
943 943
 									'QST_required' => 1,
944
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
944
+									'QST_required_text' => __('This field is required', 'event_espresso'),
945 945
 									'QST_order' => 2,
946 946
 									'QST_admin_only' => 0,
947
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
947
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
948 948
 									'QST_wp_user' => self::get_default_creator_id(),
949 949
 									'QST_deleted' => 0
950 950
 								);
@@ -952,15 +952,15 @@  discard block
 block discarded – undo
952 952
 
953 953
 					case 'email':
954 954
 							$QST_values = array(
955
-									'QST_display_text' => __( 'Email Address', 'event_espresso' ),
956
-									'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ),
955
+									'QST_display_text' => __('Email Address', 'event_espresso'),
956
+									'QST_admin_label' => __('Email Address - System Question', 'event_espresso'),
957 957
 									'QST_system' => 'email',
958 958
 									'QST_type' => 'TEXT',
959 959
 									'QST_required' => 1,
960
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
960
+									'QST_required_text' => __('This field is required', 'event_espresso'),
961 961
 									'QST_order' => 3,
962 962
 									'QST_admin_only' => 0,
963
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
963
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
964 964
 									'QST_wp_user' => self::get_default_creator_id(),
965 965
 									'QST_deleted' => 0
966 966
 								);
@@ -968,15 +968,15 @@  discard block
 block discarded – undo
968 968
 
969 969
 					case 'address':
970 970
 							$QST_values = array(
971
-									'QST_display_text' => __( 'Address', 'event_espresso' ),
972
-									'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ),
971
+									'QST_display_text' => __('Address', 'event_espresso'),
972
+									'QST_admin_label' => __('Address - System Question', 'event_espresso'),
973 973
 									'QST_system' => 'address',
974 974
 									'QST_type' => 'TEXT',
975 975
 									'QST_required' => 0,
976
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
976
+									'QST_required_text' => __('This field is required', 'event_espresso'),
977 977
 									'QST_order' => 4,
978 978
 									'QST_admin_only' => 0,
979
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
979
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
980 980
 									'QST_wp_user' => self::get_default_creator_id(),
981 981
 									'QST_deleted' => 0
982 982
 								);
@@ -984,15 +984,15 @@  discard block
 block discarded – undo
984 984
 
985 985
 					case 'address2':
986 986
 							$QST_values = array(
987
-									'QST_display_text' => __( 'Address2', 'event_espresso' ),
988
-									'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ),
987
+									'QST_display_text' => __('Address2', 'event_espresso'),
988
+									'QST_admin_label' => __('Address2 - System Question', 'event_espresso'),
989 989
 									'QST_system' => 'address2',
990 990
 									'QST_type' => 'TEXT',
991 991
 									'QST_required' => 0,
992
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
992
+									'QST_required_text' => __('This field is required', 'event_espresso'),
993 993
 									'QST_order' => 5,
994 994
 									'QST_admin_only' => 0,
995
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
995
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
996 996
 									'QST_wp_user' => self::get_default_creator_id(),
997 997
 									'QST_deleted' => 0
998 998
 								);
@@ -1000,15 +1000,15 @@  discard block
 block discarded – undo
1000 1000
 
1001 1001
 					case 'city':
1002 1002
 							$QST_values = array(
1003
-									'QST_display_text' => __( 'City', 'event_espresso' ),
1004
-									'QST_admin_label' => __( 'City - System Question', 'event_espresso' ),
1003
+									'QST_display_text' => __('City', 'event_espresso'),
1004
+									'QST_admin_label' => __('City - System Question', 'event_espresso'),
1005 1005
 									'QST_system' => 'city',
1006 1006
 									'QST_type' => 'TEXT',
1007 1007
 									'QST_required' => 0,
1008
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1008
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1009 1009
 									'QST_order' => 6,
1010 1010
 									'QST_admin_only' => 0,
1011
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1011
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1012 1012
 									'QST_wp_user' => self::get_default_creator_id(),
1013 1013
 									'QST_deleted' => 0
1014 1014
 								);
@@ -1016,12 +1016,12 @@  discard block
 block discarded – undo
1016 1016
 
1017 1017
 					case 'state':
1018 1018
 							$QST_values = array(
1019
-									'QST_display_text' => __( 'State/Province', 'event_espresso' ),
1020
-									'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ),
1019
+									'QST_display_text' => __('State/Province', 'event_espresso'),
1020
+									'QST_admin_label' => __('State/Province - System Question', 'event_espresso'),
1021 1021
 									'QST_system' => 'state',
1022 1022
 									'QST_type' => 'STATE',
1023 1023
 									'QST_required' => 0,
1024
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1024
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1025 1025
 									'QST_order' => 7,
1026 1026
 									'QST_admin_only' => 0,
1027 1027
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1031,12 +1031,12 @@  discard block
 block discarded – undo
1031 1031
 
1032 1032
 					case 'country' :
1033 1033
 							$QST_values = array(
1034
-									'QST_display_text' => __( 'Country', 'event_espresso' ),
1035
-									'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ),
1034
+									'QST_display_text' => __('Country', 'event_espresso'),
1035
+									'QST_admin_label' => __('Country - System Question', 'event_espresso'),
1036 1036
 									'QST_system' => 'country',
1037 1037
 									'QST_type' => 'COUNTRY',
1038 1038
 									'QST_required' => 0,
1039
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1039
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1040 1040
 									'QST_order' => 8,
1041 1041
 									'QST_admin_only' => 0,
1042 1042
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1046,15 +1046,15 @@  discard block
 block discarded – undo
1046 1046
 
1047 1047
 					case 'zip':
1048 1048
 							$QST_values = array(
1049
-									'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ),
1050
-									'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ),
1049
+									'QST_display_text' => __('Zip/Postal Code', 'event_espresso'),
1050
+									'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'),
1051 1051
 									'QST_system' => 'zip',
1052 1052
 									'QST_type' => 'TEXT',
1053 1053
 									'QST_required' => 0,
1054
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1054
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1055 1055
 									'QST_order' => 9,
1056 1056
 									'QST_admin_only' => 0,
1057
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1057
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1058 1058
 									'QST_wp_user' => self::get_default_creator_id(),
1059 1059
 									'QST_deleted' => 0
1060 1060
 								);
@@ -1062,49 +1062,49 @@  discard block
 block discarded – undo
1062 1062
 
1063 1063
 					case 'phone':
1064 1064
 							$QST_values = array(
1065
-									'QST_display_text' => __( 'Phone Number', 'event_espresso' ),
1066
-									'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ),
1065
+									'QST_display_text' => __('Phone Number', 'event_espresso'),
1066
+									'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'),
1067 1067
 									'QST_system' => 'phone',
1068 1068
 									'QST_type' => 'TEXT',
1069 1069
 									'QST_required' => 0,
1070
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1070
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1071 1071
 									'QST_order' => 10,
1072 1072
 									'QST_admin_only' => 0,
1073
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1073
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1074 1074
 									'QST_wp_user' => self::get_default_creator_id(),
1075 1075
 									'QST_deleted' => 0
1076 1076
 								);
1077 1077
 						break;
1078 1078
 
1079 1079
 				}
1080
-				if ( ! empty( $QST_values )) {
1080
+				if ( ! empty($QST_values)) {
1081 1081
 					// insert system question
1082 1082
 					$wpdb->insert(
1083 1083
 						$table_name,
1084 1084
 						$QST_values,
1085
-						array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' )
1085
+						array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1086 1086
 					);
1087 1087
 					$QST_ID = $wpdb->insert_id;
1088 1088
 
1089 1089
 					// QUESTION GROUP QUESTIONS
1090
-					if(  in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) {
1090
+					if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1091 1091
 						$system_question_we_want = EEM_Question_Group::system_personal;
1092 1092
 					} else {
1093 1093
 						$system_question_we_want = EEM_Question_Group::system_address;
1094 1094
 					}
1095
-					if( isset( $QSG_IDs[ $system_question_we_want ] ) ) {
1096
-						$QSG_ID = $QSG_IDs[ $system_question_we_want ];
1095
+					if (isset($QSG_IDs[$system_question_we_want])) {
1096
+						$QSG_ID = $QSG_IDs[$system_question_we_want];
1097 1097
 					} else {
1098
-						$id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) );
1099
-						if( is_array( $id_col ) ) {
1100
-							$QSG_ID = reset( $id_col );
1098
+						$id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want)));
1099
+						if (is_array($id_col)) {
1100
+							$QSG_ID = reset($id_col);
1101 1101
 						} else {
1102 1102
 							//ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1103 1103
                                                         EE_Log::instance()->log( 
1104 1104
                                                                 __FILE__, 
1105 1105
                                                                 __FUNCTION__, 
1106 1106
                                                                 sprintf( 
1107
-                                                                        __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), 
1107
+                                                                        __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), 
1108 1108
                                                                         $QST_ID ), 
1109 1109
                                                                 'error' );
1110 1110
                                                         continue;
@@ -1113,9 +1113,9 @@  discard block
 block discarded – undo
1113 1113
                                         
1114 1114
 					// add system questions to groups
1115 1115
 					$wpdb->insert(
1116
-						EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ),
1117
-						array( 'QSG_ID' => $QSG_ID , 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID==1)? $order_for_group_1++ : $order_for_group_2++ ),
1118
-						array( '%d', '%d','%d' )
1116
+						EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'),
1117
+						array('QSG_ID' => $QSG_ID, 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID == 1) ? $order_for_group_1++ : $order_for_group_2++),
1118
+						array('%d', '%d', '%d')
1119 1119
 					);
1120 1120
 				}
1121 1121
 			}
@@ -1127,11 +1127,11 @@  discard block
 block discarded – undo
1127 1127
 	 * Makes sure the default payment method (Invoice) is active.
1128 1128
 	 * This used to be done automatically as part of constructing the old gateways config
1129 1129
 	 */
1130
-	public static function insert_default_payment_methods(){
1131
-		if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){
1132
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
1133
-			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
1134
-		}else{
1130
+	public static function insert_default_payment_methods() {
1131
+		if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1132
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
1133
+			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1134
+		} else {
1135 1135
 			EEM_Payment_Method::instance()->verify_button_urls();
1136 1136
 		}
1137 1137
 	}
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 
1148 1148
 		global $wpdb;
1149 1149
 
1150
-		if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) {
1150
+		if (EEH_Activation::table_exists(EEM_Status::instance()->table())) {
1151 1151
 
1152 1152
 			$table_name = EEM_Status::instance()->table();
1153 1153
 
@@ -1213,38 +1213,38 @@  discard block
 block discarded – undo
1213 1213
 	 * 	@return boolean success of verifying upload directories exist
1214 1214
 	 */
1215 1215
 	public static function create_upload_directories() {
1216
-		EE_Registry::instance()->load_helper( 'File' );
1216
+		EE_Registry::instance()->load_helper('File');
1217 1217
 		// Create the required folders
1218 1218
 		$folders = array(
1219 1219
 				EVENT_ESPRESSO_TEMPLATE_DIR,
1220 1220
 				EVENT_ESPRESSO_GATEWAY_DIR,
1221
-				EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1222
-				EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1223
-				EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/'
1221
+				EVENT_ESPRESSO_UPLOAD_DIR.'logs/',
1222
+				EVENT_ESPRESSO_UPLOAD_DIR.'css/',
1223
+				EVENT_ESPRESSO_UPLOAD_DIR.'tickets/'
1224 1224
 		);
1225
-		foreach ( $folders as $folder ) {
1225
+		foreach ($folders as $folder) {
1226 1226
 			try {
1227
-				EEH_File::ensure_folder_exists_and_is_writable( $folder );
1228
-				@ chmod( $folder, 0755 );
1229
-			} catch( EE_Error $e ){
1227
+				EEH_File::ensure_folder_exists_and_is_writable($folder);
1228
+				@ chmod($folder, 0755);
1229
+			} catch (EE_Error $e) {
1230 1230
 				EE_Error::add_error(
1231 1231
 					sprintf(
1232
-						__(  'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ),
1232
+						__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1233 1233
 						$folder,
1234
-						'<br />' . $e->getMessage()
1234
+						'<br />'.$e->getMessage()
1235 1235
 					),
1236 1236
 					__FILE__, __FUNCTION__, __LINE__
1237 1237
 				);
1238 1238
 				//indicate we'll need to fix this later
1239
-				update_option( EEH_Activation::upload_directories_incomplete_option_name, true );
1239
+				update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1240 1240
 				return FALSE;
1241 1241
 			}
1242 1242
 		}
1243 1243
 		//just add the .htaccess file to the logs directory to begin with. Even if logging
1244 1244
 		//is disabled, there might be activation errors recorded in there
1245
-		EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' );
1245
+		EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/');
1246 1246
 		//remember EE's folders are all good
1247
-		delete_option( EEH_Activation::upload_directories_incomplete_option_name );
1247
+		delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1248 1248
 		return TRUE;
1249 1249
 	}
1250 1250
 	
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
 	 * @return boolean
1258 1258
 	 */
1259 1259
 	public static function upload_directories_incomplete() {
1260
-		return get_option( EEH_Activation::upload_directories_incomplete_option_name, false );
1260
+		return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1261 1261
 	}
1262 1262
 
1263 1263
 
@@ -1276,16 +1276,16 @@  discard block
 block discarded – undo
1276 1276
 		$installed_messengers = $default_messengers = array();
1277 1277
 
1278 1278
 		//include our helper
1279
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
1279
+		EE_Registry::instance()->load_helper('MSG_Template');
1280 1280
 
1281 1281
 		//get all installed messenger objects
1282 1282
 		$installed = EEH_MSG_Template::get_installed_message_objects();
1283 1283
 
1284 1284
 		//let's setup the $installed messengers in an array AND the messengers that are set to be activated on install.
1285
-		foreach ( $installed['messengers'] as $msgr ) {
1286
-			if ( $msgr instanceof EE_messenger ) {
1285
+		foreach ($installed['messengers'] as $msgr) {
1286
+			if ($msgr instanceof EE_messenger) {
1287 1287
 				$installed_messengers[$msgr->name] = $msgr;
1288
-				if ( $msgr->activate_on_install ) {
1288
+				if ($msgr->activate_on_install) {
1289 1289
 					$default_messengers[] = $msgr->name;
1290 1290
 				}
1291 1291
 			}
@@ -1295,36 +1295,36 @@  discard block
 block discarded – undo
1295 1295
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
1296 1296
 
1297 1297
 		//things that have already been activated before
1298
-		$has_activated = get_option( 'ee_has_activated_messenger' );
1298
+		$has_activated = get_option('ee_has_activated_messenger');
1299 1299
 
1300 1300
 		//do an initial loop to determine if we need to continue
1301 1301
 		$def_ms = array();
1302
-		foreach ( $default_messengers as $msgr ) {
1303
-			if ( isset($active_messengers[$msgr] ) || isset( $has_activated[$msgr] ) ) continue;
1302
+		foreach ($default_messengers as $msgr) {
1303
+			if (isset($active_messengers[$msgr]) || isset($has_activated[$msgr])) continue;
1304 1304
 			$def_ms[] = $msgr;
1305 1305
 		}
1306 1306
 
1307 1307
 		//setup the $installed_mts in an array
1308
-		foreach ( $installed['message_types'] as $imt ) {
1309
-			if ( $imt instanceof EE_message_type ) {
1308
+		foreach ($installed['message_types'] as $imt) {
1309
+			if ($imt instanceof EE_message_type) {
1310 1310
 				$installed_mts[$imt->name] = $imt;
1311 1311
 			}
1312 1312
 		}
1313 1313
 
1314 1314
 		//loop through default array for default messengers (if present)
1315
-		if ( ! empty( $def_ms ) ) {
1316
-			foreach ( $def_ms as $messenger ) {
1315
+		if ( ! empty($def_ms)) {
1316
+			foreach ($def_ms as $messenger) {
1317 1317
 				//all is good so let's setup the default stuff. We need to use the given messenger object (if exists) to get the default message type for the messenger.
1318
-				if ( ! isset( $installed_messengers[$messenger] )) {
1318
+				if ( ! isset($installed_messengers[$messenger])) {
1319 1319
 					continue;
1320 1320
 				}
1321 1321
 				/** @var EE_messenger[] $installed_messengers  */
1322 1322
 				$default_mts = $installed_messengers[$messenger]->get_default_message_types();
1323 1323
 				$active_messengers[$messenger]['obj'] = $installed_messengers[$messenger];
1324
-				foreach ( $default_mts as $index => $mt ) {
1324
+				foreach ($default_mts as $index => $mt) {
1325 1325
 					//is there an installed_mt matching the default string?  If not then nothing to do here.
1326
-					if ( ! isset( $installed_mts[$mt] ) ) {
1327
-						unset( $default_mts[$index] );
1326
+					if ( ! isset($installed_mts[$mt])) {
1327
+						unset($default_mts[$index]);
1328 1328
 						continue;
1329 1329
 					}
1330 1330
 
@@ -1333,41 +1333,41 @@  discard block
 block discarded – undo
1333 1333
 					/** @var EE_message_type[] $installed_mts */
1334 1334
 					$settings_fields = $installed_mts[$mt]->get_admin_settings_fields();
1335 1335
 					$settings = array();
1336
-					if ( is_array( $settings_fields ) ) {
1337
-						foreach ( $settings_fields as $field => $values ) {
1338
-							if ( isset( $values['default'] ) ) {
1336
+					if (is_array($settings_fields)) {
1337
+						foreach ($settings_fields as $field => $values) {
1338
+							if (isset($values['default'])) {
1339 1339
 								$settings[$field] = $values['default'];
1340 1340
 							}
1341 1341
 						}
1342 1342
 					}
1343 1343
 
1344
-					$active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings;
1344
+					$active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings;
1345 1345
 					$has_activated[$messenger][] = $mt;
1346 1346
 				}
1347 1347
 
1348 1348
 				//setup any initial settings for the messenger
1349 1349
 				$msgr_settings = $installed_messengers[$messenger]->get_admin_settings_fields();
1350 1350
 
1351
-				if ( !empty( $msgr_settings ) ) {
1352
-					foreach ( $msgr_settings as $field => $value ) {
1351
+				if ( ! empty($msgr_settings)) {
1352
+					foreach ($msgr_settings as $field => $value) {
1353 1353
 						$active_messengers[$messenger]['settings'][$field] = $value;
1354 1354
 					}
1355 1355
 				}
1356 1356
 
1357 1357
 				//now let's save the settings for this messenger! Must do now because the validator checks the db for active messengers to validate.
1358
-				EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1358
+				EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1359 1359
 
1360 1360
 				//let's generate all the templates but only if the messenger has default_mts (otherwise its just activated).
1361
-				if ( !empty( $default_mts ) ) {
1362
-					$success = EEH_MSG_Template::generate_new_templates( $messenger, $default_mts, '', TRUE );
1361
+				if ( ! empty($default_mts)) {
1362
+					$success = EEH_MSG_Template::generate_new_templates($messenger, $default_mts, '', TRUE);
1363 1363
 				}
1364 1364
 			}
1365 1365
 		} //end check for empty( $def_ms )
1366 1366
 
1367 1367
 		//still need to see if there are any message types to activate for active messengers
1368
-		foreach ( $active_messengers as $messenger => $settings ) {
1368
+		foreach ($active_messengers as $messenger => $settings) {
1369 1369
 			$msg_obj = $settings['obj'];
1370
-			if ( ! $msg_obj instanceof EE_messenger ) {
1370
+			if ( ! $msg_obj instanceof EE_messenger) {
1371 1371
 				continue;
1372 1372
 			}
1373 1373
 
@@ -1375,45 +1375,45 @@  discard block
 block discarded – undo
1375 1375
 			$new_default_mts = array();
1376 1376
 
1377 1377
 			//loop through each default mt reported by the messenger and make sure its set in its active db entry.
1378
-			foreach( $all_default_mts as $index => $mt ) {
1378
+			foreach ($all_default_mts as $index => $mt) {
1379 1379
 				//already active? already has generated templates? || has already been activated before (we dont' want to reactivate things users intentionally deactivated).
1380
-				if ( ( isset( $has_activated[$messenger] ) && in_array($mt, $has_activated[$messenger]) ) || isset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] ) ||  EEH_MSG_Template::already_generated( $messenger, $mt, 0, FALSE ) ) {
1380
+				if ((isset($has_activated[$messenger]) && in_array($mt, $has_activated[$messenger])) || isset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]) || EEH_MSG_Template::already_generated($messenger, $mt, 0, FALSE)) {
1381 1381
 					continue;
1382 1382
 				}
1383 1383
 
1384 1384
 				//is there an installed_mt matching the default string?  If not then nothing to do here.
1385
-				if ( ! isset( $installed_mts[$mt] ) ) {
1386
-					unset( $all_default_mts[$mt] );
1385
+				if ( ! isset($installed_mts[$mt])) {
1386
+					unset($all_default_mts[$mt]);
1387 1387
 					continue;
1388 1388
 				}
1389 1389
 
1390 1390
 				$settings_fields = $installed_mts[$mt]->get_admin_settings_fields();
1391 1391
 				$settings = array();
1392
-				if ( is_array( $settings_fields ) ) {
1393
-					foreach ( $settings_fields as $field => $values ) {
1394
-						if ( isset( $values['default'] ) ) {
1392
+				if (is_array($settings_fields)) {
1393
+					foreach ($settings_fields as $field => $values) {
1394
+						if (isset($values['default'])) {
1395 1395
 							$settings[$field] = $values['default'];
1396 1396
 						}
1397 1397
 					}
1398 1398
 				}
1399 1399
 
1400
-				$active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings;
1400
+				$active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings;
1401 1401
 				$new_default_mts[] = $mt;
1402 1402
 				$has_activated[$messenger][] = $mt;
1403 1403
 			}
1404 1404
 
1405 1405
 
1406
-			if ( ! empty( $new_default_mts ) ) {
1407
-				$success = EEH_MSG_Template::generate_new_templates( $messenger, $new_default_mts, '', TRUE );
1406
+			if ( ! empty($new_default_mts)) {
1407
+				$success = EEH_MSG_Template::generate_new_templates($messenger, $new_default_mts, '', TRUE);
1408 1408
 			}
1409 1409
 
1410 1410
 		}
1411 1411
 
1412 1412
 		//now let's save the settings for this messenger!
1413
-		EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1413
+		EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1414 1414
 
1415 1415
 		//update $has_activated record
1416
-		update_option( 'ee_has_activated_messenger', $has_activated );
1416
+		update_option('ee_has_activated_messenger', $has_activated);
1417 1417
 
1418 1418
 		//that's it!
1419 1419
 		return $success;
@@ -1433,47 +1433,47 @@  discard block
 block discarded – undo
1433 1433
 	 */
1434 1434
 	public static function validate_messages_system() {
1435 1435
 		//include our helper
1436
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
1436
+		EE_Registry::instance()->load_helper('MSG_Template');
1437 1437
 
1438 1438
 		//get active and installed  messengers/message types.
1439 1439
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
1440 1440
 		$installed = EEH_MSG_Template::get_installed_message_objects();
1441 1441
 		$installed_messengers = $installed_mts = array();
1442 1442
 		//set up the arrays so they can be handled easier.
1443
-		foreach( $installed['messengers'] as $im ) {
1444
-			if ( $im instanceof EE_messenger ) {
1443
+		foreach ($installed['messengers'] as $im) {
1444
+			if ($im instanceof EE_messenger) {
1445 1445
 				$installed_messengers[$im->name] = $im;
1446 1446
 			}
1447 1447
 		}
1448
-		foreach( $installed['message_types'] as $imt ) {
1449
-			if ( $imt instanceof EE_message_type ) {
1448
+		foreach ($installed['message_types'] as $imt) {
1449
+			if ($imt instanceof EE_message_type) {
1450 1450
 				$installed_mts[$imt->name] = $imt;
1451 1451
 			}
1452 1452
 		}
1453 1453
 
1454 1454
 		//now let's loop through the active array and validate
1455
-		foreach( $active_messengers as $messenger => $active_details ) {
1455
+		foreach ($active_messengers as $messenger => $active_details) {
1456 1456
 			//first let's see if this messenger is installed.
1457
-			if ( ! isset( $installed_messengers[$messenger] ) ) {
1457
+			if ( ! isset($installed_messengers[$messenger])) {
1458 1458
 				//not set so let's just remove from actives and make sure templates are inactive.
1459
-				unset( $active_messengers[$messenger] );
1460
-				EEH_MSG_Template::update_to_inactive( $messenger );
1459
+				unset($active_messengers[$messenger]);
1460
+				EEH_MSG_Template::update_to_inactive($messenger);
1461 1461
 				continue;
1462 1462
 			}
1463 1463
 
1464 1464
 			//messenger is active, so let's just make sure that any active message types not installed are deactivated.
1465
-			$mts = ! empty( $active_details['settings'][$messenger . '-message_types'] ) ? $active_details['settings'][$messenger . '-message_types'] : array();
1466
-			foreach ( $mts as $mt_name => $mt ) {
1467
-				if ( ! isset( $installed_mts[$mt_name] )  ) {
1468
-					unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] );
1469
-					EEH_MSG_Template::update_to_inactive( $messenger, $mt_name );
1465
+			$mts = ! empty($active_details['settings'][$messenger.'-message_types']) ? $active_details['settings'][$messenger.'-message_types'] : array();
1466
+			foreach ($mts as $mt_name => $mt) {
1467
+				if ( ! isset($installed_mts[$mt_name])) {
1468
+					unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt_name]);
1469
+					EEH_MSG_Template::update_to_inactive($messenger, $mt_name);
1470 1470
 				}
1471 1471
 			}
1472 1472
 		}
1473 1473
 
1474 1474
 		//all done! let's update the active_messengers.
1475
-		EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1476
-		do_action( 'AHEE__EEH_Activation__validate_messages_system' );
1475
+		EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1476
+		do_action('AHEE__EEH_Activation__validate_messages_system');
1477 1477
 		return;
1478 1478
 	}
1479 1479
 
@@ -1487,12 +1487,12 @@  discard block
 block discarded – undo
1487 1487
 	 * 	@static
1488 1488
 	 * 	@return void
1489 1489
 	 */
1490
-	public static function create_no_ticket_prices_array(){
1490
+	public static function create_no_ticket_prices_array() {
1491 1491
 		// this creates an array for tracking events that have no active ticket prices created
1492 1492
 		// this allows us to warn admins of the situation so that it can be corrected
1493
-		$espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE );
1494
-		if ( ! $espresso_no_ticket_prices ) {
1495
-			add_option( 'ee_no_ticket_prices', array(), '', FALSE );
1493
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE);
1494
+		if ( ! $espresso_no_ticket_prices) {
1495
+			add_option('ee_no_ticket_prices', array(), '', FALSE);
1496 1496
 		}
1497 1497
 	}
1498 1498
 
@@ -1514,24 +1514,24 @@  discard block
 block discarded – undo
1514 1514
 	 * Finds all our EE4 custom post types, and deletes them and their associated data (like post meta or term relations)/
1515 1515
 	 * @global wpdb $wpdb
1516 1516
 	 */
1517
-	public static function delete_all_espresso_cpt_data(){
1517
+	public static function delete_all_espresso_cpt_data() {
1518 1518
 		global $wpdb;
1519 1519
 		//get all the CPT post_types
1520 1520
 		$ee_post_types = array();
1521
-		foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){
1522
-			if ( method_exists( $model_name, 'instance' )) {
1523
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1524
-				if ( $model_obj instanceof EEM_CPT_Base ) {
1525
-					$ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type());
1521
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1522
+			if (method_exists($model_name, 'instance')) {
1523
+				$model_obj = call_user_func(array($model_name, 'instance'));
1524
+				if ($model_obj instanceof EEM_CPT_Base) {
1525
+					$ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1526 1526
 				}
1527 1527
 			}
1528 1528
 		}
1529 1529
 		//get all our CPTs
1530
-		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")";
1530
+		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")";
1531 1531
 		$cpt_ids = $wpdb->get_col($query);
1532 1532
 		//delete each post meta and term relations too
1533
-		foreach($cpt_ids as $post_id){
1534
-			wp_delete_post($post_id,true);
1533
+		foreach ($cpt_ids as $post_id) {
1534
+			wp_delete_post($post_id, true);
1535 1535
 		}
1536 1536
 	}
1537 1537
 
@@ -1545,18 +1545,18 @@  discard block
 block discarded – undo
1545 1545
 	 * @param bool $remove_all
1546 1546
 	 * @return void
1547 1547
 	 */
1548
-	public static function delete_all_espresso_tables_and_data( $remove_all = true ) {
1548
+	public static function delete_all_espresso_tables_and_data($remove_all = true) {
1549 1549
 		global $wpdb;
1550 1550
 		$undeleted_tables = array();
1551 1551
 
1552 1552
 		// load registry
1553
-		foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){
1554
-			if ( method_exists( $model_name, 'instance' )) {
1555
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1556
-				if ( $model_obj instanceof EEM_Base ) {
1557
-					foreach ( $model_obj->get_tables() as $table ) {
1558
-						if ( strpos( $table->get_table_name(), 'esp_' )) {
1559
-							switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) {
1553
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1554
+			if (method_exists($model_name, 'instance')) {
1555
+				$model_obj = call_user_func(array($model_name, 'instance'));
1556
+				if ($model_obj instanceof EEM_Base) {
1557
+					foreach ($model_obj->get_tables() as $table) {
1558
+						if (strpos($table->get_table_name(), 'esp_')) {
1559
+							switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) {
1560 1560
 								case false :
1561 1561
 									$undeleted_tables[] = $table->get_table_name();
1562 1562
 								break;
@@ -1581,8 +1581,8 @@  discard block
 block discarded – undo
1581 1581
 			'esp_promotion_rule',
1582 1582
 			'esp_rule'
1583 1583
 		);
1584
-		foreach( $tables_without_models as $table ){
1585
-			EEH_Activation::delete_db_table_if_empty( $table );
1584
+		foreach ($tables_without_models as $table) {
1585
+			EEH_Activation::delete_db_table_if_empty($table);
1586 1586
 		}
1587 1587
 
1588 1588
 
@@ -1619,58 +1619,58 @@  discard block
 block discarded – undo
1619 1619
 			'ee_pers_admin_notices' => true,
1620 1620
 			'ee_upload_directories_incomplete' => true,
1621 1621
 		);
1622
-		if( is_main_site() ) {
1623
-			$wp_options_to_delete[ 'ee_network_config' ] = true;
1622
+		if (is_main_site()) {
1623
+			$wp_options_to_delete['ee_network_config'] = true;
1624 1624
 		}
1625 1625
 
1626 1626
 		$undeleted_options = array();
1627
-		foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) {
1627
+		foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1628 1628
 
1629
-			if( $no_wildcard ){
1630
-				if( ! delete_option( $option_name ) ){
1629
+			if ($no_wildcard) {
1630
+				if ( ! delete_option($option_name)) {
1631 1631
 					$undeleted_options[] = $option_name;
1632 1632
 				}
1633
-			}else{
1634
-				$option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" );
1635
-				foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){
1636
-					if( ! delete_option( $option_name_from_wildcard ) ){
1633
+			} else {
1634
+				$option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1635
+				foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1636
+					if ( ! delete_option($option_name_from_wildcard)) {
1637 1637
 						$undeleted_options[] = $option_name_from_wildcard;
1638 1638
 					}
1639 1639
 				}
1640 1640
 			}
1641 1641
 		}
1642 1642
                 //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1643
-                remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 );
1643
+                remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1644 1644
 
1645
-		if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) {
1645
+		if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1646 1646
 			$db_update_sans_ee4 = array();
1647
-			foreach($espresso_db_update as $version => $times_activated){
1648
-				if( $version[0] =='3'){//if its NON EE4
1647
+			foreach ($espresso_db_update as $version => $times_activated) {
1648
+				if ($version[0] == '3') {//if its NON EE4
1649 1649
 					$db_update_sans_ee4[$version] = $times_activated;
1650 1650
 				}
1651 1651
 			}
1652
-			update_option( 'espresso_db_update', $db_update_sans_ee4 );
1652
+			update_option('espresso_db_update', $db_update_sans_ee4);
1653 1653
 		}
1654 1654
 
1655 1655
 		$errors = '';
1656
-		if ( ! empty( $undeleted_tables )) {
1656
+		if ( ! empty($undeleted_tables)) {
1657 1657
 			$errors .= sprintf(
1658
-				__( 'The following tables could not be deleted: %s%s', 'event_espresso' ),
1658
+				__('The following tables could not be deleted: %s%s', 'event_espresso'),
1659 1659
 				'<br/>',
1660
-				implode( ',<br/>', $undeleted_tables )
1660
+				implode(',<br/>', $undeleted_tables)
1661 1661
 			);
1662 1662
 		}
1663
-		if ( ! empty( $undeleted_options )) {
1664
-			$errors .= ! empty( $undeleted_tables ) ? '<br/>' : '';
1663
+		if ( ! empty($undeleted_options)) {
1664
+			$errors .= ! empty($undeleted_tables) ? '<br/>' : '';
1665 1665
 			$errors .= sprintf(
1666
-				__( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ),
1666
+				__('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1667 1667
 				'<br/>',
1668
-				implode( ',<br/>', $undeleted_options )
1668
+				implode(',<br/>', $undeleted_options)
1669 1669
 			);
1670 1670
 
1671 1671
 		}
1672
-		if ( $errors != '' ) {
1673
-			EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ );
1672
+		if ($errors != '') {
1673
+			EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1674 1674
 		}
1675 1675
 	}
1676 1676
 
@@ -1680,23 +1680,23 @@  discard block
 block discarded – undo
1680 1680
 	 * @param string $table_name with or without $wpdb->prefix
1681 1681
 	 * @return boolean
1682 1682
 	 */
1683
-	public static function table_exists( $table_name ){
1683
+	public static function table_exists($table_name) {
1684 1684
 		global $wpdb, $EZSQL_ERROR;
1685
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
1685
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
1686 1686
 		//ignore if this causes an sql error
1687 1687
 		$old_error = $wpdb->last_error;
1688 1688
 		$old_suppress_errors = $wpdb->suppress_errors();
1689
-		$old_show_errors_value = $wpdb->show_errors( FALSE );
1689
+		$old_show_errors_value = $wpdb->show_errors(FALSE);
1690 1690
 		$ezsql_error_cache = $EZSQL_ERROR;
1691
-		$wpdb->get_results( "SELECT * from $table_name LIMIT 1");
1692
-		$wpdb->show_errors( $old_show_errors_value );
1693
-		$wpdb->suppress_errors( $old_suppress_errors );
1691
+		$wpdb->get_results("SELECT * from $table_name LIMIT 1");
1692
+		$wpdb->show_errors($old_show_errors_value);
1693
+		$wpdb->suppress_errors($old_suppress_errors);
1694 1694
 		$new_error = $wpdb->last_error;
1695 1695
 		$wpdb->last_error = $old_error;
1696 1696
 		$EZSQL_ERROR = $ezsql_error_cache;
1697
-		if( empty( $new_error ) ){
1697
+		if (empty($new_error)) {
1698 1698
 			return TRUE;
1699
-		}else{
1699
+		} else {
1700 1700
 			return FALSE;
1701 1701
 		}
1702 1702
 	}
@@ -1704,7 +1704,7 @@  discard block
 block discarded – undo
1704 1704
 	/**
1705 1705
 	 * Resets the cache on EEH_Activation
1706 1706
 	 */
1707
-	public static function reset(){
1707
+	public static function reset() {
1708 1708
 		self::$_default_creator_id = NULL;
1709 1709
 		self::$_initialized_db_content_already_in_this_request = false;
1710 1710
 	}
Please login to merge, or discard this patch.
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 1 patch
Spacing   +261 added lines, -262 removed lines patch added patch discarded remove patch
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
 	 * @param    EE_Checkout $checkout
38 38
 	 * @return    \EE_SPCO_Reg_Step_Attendee_Information
39 39
 	 */
40
-	public function __construct( EE_Checkout $checkout ) {
40
+	public function __construct(EE_Checkout $checkout) {
41 41
 		$this->_slug = 'attendee_information';
42 42
 		$this->_name = __('Attendee Information', 'event_espresso');
43
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
43
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php';
44 44
 		$this->checkout = $checkout;
45 45
 		$this->_reset_success_message();
46
-		$this->set_instructions( __('Please answer the following registration questions before proceeding.', 'event_espresso'));
46
+		$this->set_instructions(__('Please answer the following registration questions before proceeding.', 'event_espresso'));
47 47
 	}
48 48
 
49 49
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso');
53 53
 		EE_Registry::$i18n_js_strings['required_multi_field'] = __(' is a required question. Please enter a value for at least one of the options.', 'event_espresso');
54 54
 		EE_Registry::$i18n_js_strings['answer_required_questions'] = __('Please answer all required questions correctly before proceeding.', 'event_espresso');
55
-		EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( __('The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', 'event_espresso'), '<br/>' );
55
+		EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf(__('The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', 'event_espresso'), '<br/>');
56 56
 		EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = __('An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', 'event_espresso');
57 57
 		EE_Registry::$i18n_js_strings['enter_valid_email'] = __('You must enter a valid email address.', 'event_espresso');
58 58
 		EE_Registry::$i18n_js_strings['valid_email_and_questions'] = __('You must enter a valid email address and answer all other required questions before you can proceed.', 'event_espresso');
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		EEH_Autoloader::register_line_item_display_autoloaders();
86 86
 		$Line_Item_Display = new EE_Line_Item_Display();
87 87
 		// calculate taxes
88
-		$Line_Item_Display->display_line_item( $this->checkout->cart->get_grand_total(), array( 'set_tax_rate' => true ) );
88
+		$Line_Item_Display->display_line_item($this->checkout->cart->get_grand_total(), array('set_tax_rate' => true));
89 89
 		EE_Registry::instance()->load_helper('Line_Item');
90 90
 		/** @var $subsections EE_Form_Section_Proper[] */
91 91
 		$subsections = array(
@@ -97,33 +97,33 @@  discard block
 block discarded – undo
97 97
 			'ticket_count' 	=> array()
98 98
 		);
99 99
 		// grab the saved registrations from the transaction
100
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
101
-		if ( $registrations ) {
102
-			foreach ( $registrations as $registration ) {
103
-				if ( $registration instanceof EE_Registration ) {
100
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
101
+		if ($registrations) {
102
+			foreach ($registrations as $registration) {
103
+				if ($registration instanceof EE_Registration) {
104 104
 					// can this registration be processed during this visit ?
105
-					if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) {
106
-						$subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form( $registration );
107
-						if ( ! $this->checkout->admin_request ) {
108
-							$template_args['registrations'][ $registration->reg_url_link() ] = $registration;
109
-							$template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( $template_args['ticket_count'][ $registration->ticket()->ID() ] ) ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 : 1;
110
-							$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( $this->checkout->cart->get_grand_total(), 'Ticket', array( $registration->ticket()->ID() ) );
111
-							$ticket_line_item = is_array( $ticket_line_item ) ? reset( $ticket_line_item ) : $ticket_line_item;
112
-							$template_args['ticket_line_item'][ $registration->ticket()->ID() ] = $Line_Item_Display->display_line_item( $ticket_line_item );
105
+					if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
106
+						$subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
107
+						if ( ! $this->checkout->admin_request) {
108
+							$template_args['registrations'][$registration->reg_url_link()] = $registration;
109
+							$template_args['ticket_count'][$registration->ticket()->ID()] = isset($template_args['ticket_count'][$registration->ticket()->ID()]) ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 : 1;
110
+							$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs($this->checkout->cart->get_grand_total(), 'Ticket', array($registration->ticket()->ID()));
111
+							$ticket_line_item = is_array($ticket_line_item) ? reset($ticket_line_item) : $ticket_line_item;
112
+							$template_args['ticket_line_item'][$registration->ticket()->ID()] = $Line_Item_Display->display_line_item($ticket_line_item);
113 113
 						}
114
-						if ( $registration->is_primary_registrant() ) {
114
+						if ($registration->is_primary_registrant()) {
115 115
 							$primary_registrant = $registration->reg_url_link();
116 116
 						}
117 117
 					}
118 118
 				}
119 119
 			}
120 120
 			// print_copy_info ?
121
-			if ( $primary_registrant && count( $registrations ) > 1 && ! $this->checkout->admin_request ) {
121
+			if ($primary_registrant && count($registrations) > 1 && ! $this->checkout->admin_request) {
122 122
 				// TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info
123 123
 				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info ? $this->_copy_attendee_info_form() : $this->_auto_copy_attendee_info();
124 124
 				// generate hidden input
125
-				if ( isset( $subsections[ $primary_registrant ] ) && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper ) {
126
-					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
125
+				if (isset($subsections[$primary_registrant]) && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper) {
126
+					$subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false);
127 127
 				}
128 128
 			}
129 129
 
@@ -135,8 +135,7 @@  discard block
 block discarded – undo
135 135
 				'html_id' 					=> $this->reg_form_name(),
136 136
 				'subsections' 			=> $subsections,
137 137
 				'layout_strategy'		=> $this->checkout->admin_request ?
138
-					new EE_Div_Per_Section_Layout() :
139
-					new EE_Template_Layout(
138
+					new EE_Div_Per_Section_Layout() : new EE_Template_Layout(
140 139
 						array(
141 140
 							'layout_template_file' 	=> $this->_template, // layout_template
142 141
 							'template_args' 				=> $template_args
@@ -153,61 +152,61 @@  discard block
 block discarded – undo
153 152
 	 * @param EE_Registration $registration
154 153
 	 * @return EE_Form_Section_Proper
155 154
 	 */
156
-	private function _registrations_reg_form( EE_Registration $registration ) {
157
-		EE_Registry::instance()->load_helper( 'Template' );
155
+	private function _registrations_reg_form(EE_Registration $registration) {
156
+		EE_Registry::instance()->load_helper('Template');
158 157
 		static $attendee_nmbr = 1;
159 158
 		// array of params to pass to parent constructor
160 159
 		$form_args = array(
161
-			'html_id' 				=> 'ee-registration-' . $registration->reg_url_link(),
160
+			'html_id' 				=> 'ee-registration-'.$registration->reg_url_link(),
162 161
 			'html_class' 		=> 'ee-reg-form-attendee-dv',
163 162
 			'html_style' 		=> $this->checkout->admin_request ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' : '',
164 163
 			'subsections' 		=> array(),
165 164
 			'layout_strategy' => new EE_Fieldset_Section_Layout(
166 165
 				array(
167 166
 					'legend_class' 	=> 'spco-attendee-lgnd smaller-text lt-grey-text',
168
-					'legend_text' 	=> sprintf( __( 'Attendee %d', 'event_espresso' ), $attendee_nmbr )
167
+					'legend_text' 	=> sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr)
169 168
 				)
170 169
 			)
171 170
 		);
172 171
 		// verify that registration has valid event
173
-		if ( $registration->event() instanceof EE_Event ) {
172
+		if ($registration->event() instanceof EE_Event) {
174 173
 			$query_params = array(
175 174
 				array(
176 175
 					'Event.EVT_ID' => $registration->event()->ID(),
177 176
 					'Event_Question_Group.EQG_primary' => $registration->count() == 1 ? TRUE : FALSE
178 177
 				),
179
-				'order_by'=>array( 'QSG_order'=>'ASC' )
178
+				'order_by'=>array('QSG_order'=>'ASC')
180 179
 			);
181
-			$question_groups = $registration->event()->question_groups( $query_params );
182
-			if ( $question_groups ) {
183
-				foreach ( $question_groups as $question_group ) {
184
-					if ( $question_group instanceof EE_Question_Group ) {
185
-						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( $registration, $question_group );
180
+			$question_groups = $registration->event()->question_groups($query_params);
181
+			if ($question_groups) {
182
+				foreach ($question_groups as $question_group) {
183
+					if ($question_group instanceof EE_Question_Group) {
184
+						$form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form($registration, $question_group);
186 185
 						// add hidden input
187
-						$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( $registration );
186
+						$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input($registration);
188 187
 					}
189 188
 				}
190 189
 				// if we have question groups for additional attendees, then display the copy options
191 190
 				$this->_print_copy_info = $attendee_nmbr > 1 ? TRUE : $this->_print_copy_info;
192 191
 			} else {
193
-				$form_args['subsections'][ 'attendee_info_not_required_' . $registration->reg_url_link() ] = new EE_Form_Section_HTML(
192
+				$form_args['subsections']['attendee_info_not_required_'.$registration->reg_url_link()] = new EE_Form_Section_HTML(
194 193
 					EEH_Template::locate_template(
195
-						SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_not_required.template.php',
196
-						apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__attendee_info_not_required_template_args', array()),
194
+						SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_not_required.template.php',
195
+						apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__attendee_info_not_required_template_args', array()),
197 196
 						TRUE,
198 197
 						TRUE
199 198
 					)
200 199
 				);
201 200
 				// add hidden input
202
-				$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( $registration, FALSE );
201
+				$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input($registration, FALSE);
203 202
 			}
204 203
 		}
205
-		if ( $registration->is_primary_registrant() ) {
204
+		if ($registration->is_primary_registrant()) {
206 205
 			// generate hidden input
207
-			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( $registration );
206
+			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration);
208 207
 		}
209 208
 		$attendee_nmbr++;
210
-		return new EE_Form_Section_Proper( $form_args );
209
+		return new EE_Form_Section_Proper($form_args);
211 210
 	}
212 211
 
213 212
 
@@ -220,11 +219,11 @@  discard block
 block discarded – undo
220 219
 	 * @param bool  $additional_attendee_reg_info
221 220
 	 * @return    EE_Form_Input_Base
222 221
 	 */
223
-	private function _additional_attendee_reg_info_input( EE_Registration $registration, $additional_attendee_reg_info = TRUE ){
222
+	private function _additional_attendee_reg_info_input(EE_Registration $registration, $additional_attendee_reg_info = TRUE) {
224 223
 		// generate hidden input
225 224
 		return new EE_Hidden_Input(
226 225
 			array(
227
-				'html_id' 				=> 'additional-attendee-reg-info-' . $registration->reg_url_link(),
226
+				'html_id' 				=> 'additional-attendee-reg-info-'.$registration->reg_url_link(),
228 227
 				'default'				=> $additional_attendee_reg_info
229 228
 			)
230 229
 		);
@@ -237,22 +236,22 @@  discard block
 block discarded – undo
237 236
 	 * @param EE_Question_Group $question_group
238 237
 	 * @return EE_Form_Section_Proper
239 238
 	 */
240
-	private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){
239
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) {
241 240
 		// array of params to pass to parent constructor
242 241
 		$form_args = array(
243
-			'html_id' 					=> 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
242
+			'html_id' 					=> 'ee-reg-form-qstn-grp-'.$question_group->identifier(),
244 243
 			'html_class' 			=> $this->checkout->admin_request ? 'form-table ee-reg-form-qstn-grp-dv' : 'ee-reg-form-qstn-grp-dv',
245
-			'html_label_id' 		=> 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
244
+			'html_label_id' 		=> 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl',
246 245
 			'subsections' 			=> array(
247
-				'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group )
246
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group)
248 247
 			),
249 248
 			'layout_strategy' 	=> $this->checkout->admin_request ? new EE_Admin_Two_Column_Layout() : new EE_Div_Per_Section_Layout()
250 249
 		);
251 250
 		// where params
252
-		$query_params = array( 'QST_deleted' => 0 );
251
+		$query_params = array('QST_deleted' => 0);
253 252
 		// don't load admin only questions on the frontend
254
-		if ( ! $this->checkout->admin_request ) {
255
-			$query_params['QST_admin_only'] = array( '!=', TRUE );
253
+		if ( ! $this->checkout->admin_request) {
254
+			$query_params['QST_admin_only'] = array('!=', TRUE);
256 255
 		}
257 256
 		$questions = $question_group->get_many_related(
258 257
 			'Question',
@@ -264,21 +263,21 @@  discard block
 block discarded – undo
264 263
 			)
265 264
 		);
266 265
 		// filter for additional content before questions
267
-		$form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML( apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '', $registration, $question_group, $this ));
266
+		$form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML(apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '', $registration, $question_group, $this));
268 267
 		// loop thru questions
269
-		foreach ( $questions as $question ) {
270
-			if( $question instanceof EE_Question ){
268
+		foreach ($questions as $question) {
269
+			if ($question instanceof EE_Question) {
271 270
 				$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
272
-				$form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question );
271
+				$form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
273 272
 			}
274 273
 		}
275
-		$form_args['subsections'] = apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', $form_args['subsections'], $registration, $question_group, $this );
274
+		$form_args['subsections'] = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', $form_args['subsections'], $registration, $question_group, $this);
276 275
 
277 276
 		// filter for additional content after questions
278
-		$form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML( apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '', $registration, $question_group, $this ));
277
+		$form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML(apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '', $registration, $question_group, $this));
279 278
 //		d( $form_args );
280
-		$question_group_reg_form = new EE_Form_Section_Proper( $form_args );
281
-		return apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', $question_group_reg_form, $registration, $question_group, $this );
279
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
280
+		return apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', $question_group_reg_form, $registration, $question_group, $this);
282 281
 	}
283 282
 
284 283
 
@@ -288,12 +287,12 @@  discard block
 block discarded – undo
288 287
 	 * @param EE_Question_Group $question_group
289 288
 	 * @return 	EE_Form_Section_HTML
290 289
 	 */
291
-	private function _question_group_header( EE_Question_Group $question_group ){
290
+	private function _question_group_header(EE_Question_Group $question_group) {
292 291
 		$html = '';
293 292
 		// group_name
294
-		if ( $question_group->show_group_name() && $question_group->name() != '' ) {
293
+		if ($question_group->show_group_name() && $question_group->name() != '') {
295 294
 			EE_Registry::instance()->load_helper('HTML');
296
-			if ( $this->checkout->admin_request ) {
295
+			if ($this->checkout->admin_request) {
297 296
 				$html .= EEH_HTML::br();
298 297
 				$html .= EEH_HTML::h3(
299 298
 					$question_group->name(),
@@ -307,7 +306,7 @@  discard block
 block discarded – undo
307 306
 			}
308 307
 		}
309 308
 		// group_desc
310
-		if ( $question_group->show_group_desc() && $question_group->desc() != '' ) {
309
+		if ($question_group->show_group_desc() && $question_group->desc() != '') {
311 310
 			$html .= EEH_HTML::p(
312 311
 				$question_group->desc(),
313 312
 				'',
@@ -315,7 +314,7 @@  discard block
 block discarded – undo
315 314
 			);
316 315
 
317 316
 		}
318
-		return new EE_Form_Section_HTML( $html );
317
+		return new EE_Form_Section_HTML($html);
319 318
 	}
320 319
 
321 320
 
@@ -324,14 +323,14 @@  discard block
 block discarded – undo
324 323
 	 * @access public
325 324
 	 * @return 	EE_Form_Section_Proper
326 325
 	 */
327
-	private function _copy_attendee_info_form(){
326
+	private function _copy_attendee_info_form() {
328 327
 		// array of params to pass to parent constructor
329 328
 		return new EE_Form_Section_Proper(
330 329
 			array(
331 330
 				'subsections' 			=> $this->_copy_attendee_info_inputs(),
332 331
 				'layout_strategy' 	=> new EE_Template_Layout(
333 332
 					array(
334
-						'layout_template_file' 			=> SPCO_REG_STEPS_PATH . $this->_slug . DS . 'copy_attendee_info.template.php', // layout_template
333
+						'layout_template_file' 			=> SPCO_REG_STEPS_PATH.$this->_slug.DS.'copy_attendee_info.template.php', // layout_template
335 334
 						'begin_template_file' 			=> NULL,
336 335
 						'input_template_file' 				=> NULL,
337 336
 						'subsection_template_file' 	=> NULL,
@@ -353,8 +352,8 @@  discard block
 block discarded – undo
353 352
 	private function _auto_copy_attendee_info() {
354 353
 		return new EE_Form_Section_HTML(
355 354
 			EEH_Template::locate_template(
356
-				SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
357
-				apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', array()),
355
+				SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php',
356
+				apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', array()),
358 357
 				TRUE,
359 358
 				TRUE
360 359
 			)
@@ -373,25 +372,25 @@  discard block
 block discarded – undo
373 372
 		$copy_attendee_info_inputs = array();
374 373
 		$prev_ticket = NULL;
375 374
 		// grab the saved registrations from the transaction
376
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
377
-		foreach ( $registrations as $registration ) {
375
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
376
+		foreach ($registrations as $registration) {
378 377
 			// for all  attendees other than the primary attendee
379
-			if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) {
378
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
380 379
 				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
381
-				if ( $registration->ticket()->ID() !== $prev_ticket ) {
380
+				if ($registration->ticket()->ID() !== $prev_ticket) {
382 381
 					$item_name = $registration->ticket()->name();
383
-					$item_name .= $registration->ticket()->description() != '' ? ' - ' . $registration->ticket()->description() : '';
384
-					$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML(
385
-						'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
382
+					$item_name .= $registration->ticket()->description() != '' ? ' - '.$registration->ticket()->description() : '';
383
+					$copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML(
384
+						'<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>'
386 385
 					);
387 386
 					$prev_ticket = $registration->ticket()->ID();
388 387
 				}
389 388
 
390
-				$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new
389
+				$copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new
391 390
 				EE_Checkbox_Multi_Input(
392
-					array( $registration->ID() => sprintf( __('Attendee #%s', 'event_espresso'), $registration->count() )),
391
+					array($registration->ID() => sprintf(__('Attendee #%s', 'event_espresso'), $registration->count())),
393 392
 					array(
394
-						'html_id' 								=> 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
393
+						'html_id' 								=> 'spco-copy-attendee-chk-'.$registration->reg_url_link(),
395 394
 						'html_class' 						=> 'spco-copy-attendee-chk ee-do-not-validate',
396 395
 						'display_html_label_text' 	=> FALSE
397 396
 					)
@@ -410,7 +409,7 @@  discard block
 block discarded – undo
410 409
 	 * @param EE_Registration $registration
411 410
 	 * @return    EE_Form_Input_Base
412 411
 	 */
413
-	private function _additional_primary_registrant_inputs( EE_Registration $registration ){
412
+	private function _additional_primary_registrant_inputs(EE_Registration $registration) {
414 413
 		// generate hidden input
415 414
 		return new EE_Hidden_Input(
416 415
 			array(
@@ -428,31 +427,31 @@  discard block
 block discarded – undo
428 427
 	 * @param EE_Question     $question
429 428
 	 * @return 	EE_Form_Input_Base
430 429
 	 */
431
-	public function reg_form_question( EE_Registration $registration, EE_Question $question ){
430
+	public function reg_form_question(EE_Registration $registration, EE_Question $question) {
432 431
 
433 432
 		// if this question was for an attendee detail, then check for that answer
434
-		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( $registration, $question->system_ID() );
433
+		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value($registration, $question->system_ID());
435 434
 		$answer = $answer_value === null
436
-				? EEM_Answer::instance()->get_one( array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() )	) )
435
+				? EEM_Answer::instance()->get_one(array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())))
437 436
 				: null;
438 437
 		// if NOT returning to edit an existing registration OR if this question is for an attendee property OR we still don't have an EE_Answer object
439
-		if( ! $registration->reg_url_link() || $answer_value || ! $answer instanceof EE_Answer ) {
438
+		if ( ! $registration->reg_url_link() || $answer_value || ! $answer instanceof EE_Answer) {
440 439
 			// create an EE_Answer object for storing everything in
441
-			$answer = EE_Answer::new_instance ( array(
440
+			$answer = EE_Answer::new_instance(array(
442 441
 				'QST_ID'=> $question->ID(),
443 442
 				'REG_ID'=> $registration->ID()
444 443
 			));
445 444
 		}
446 445
 		// verify instance
447
-		if( $answer instanceof EE_Answer ){
448
-			if ( ! empty( $answer_value )) {
449
-				$answer->set( 'ANS_value', $answer_value );
446
+		if ($answer instanceof EE_Answer) {
447
+			if ( ! empty($answer_value)) {
448
+				$answer->set('ANS_value', $answer_value);
450 449
 			}
451
-			$answer->cache( 'Question', $question );
452
-			$answer_cache_id =$question->system_ID() != NULL ? $question->system_ID() . '-' . $registration->reg_url_link() : $question->ID() . '-' . $registration->reg_url_link();
453
-			$registration->cache( 'Answer', $answer, $answer_cache_id );
450
+			$answer->cache('Question', $question);
451
+			$answer_cache_id = $question->system_ID() != NULL ? $question->system_ID().'-'.$registration->reg_url_link() : $question->ID().'-'.$registration->reg_url_link();
452
+			$registration->cache('Answer', $answer, $answer_cache_id);
454 453
 		}
455
-		return $this->_generate_question_input( $registration, $question, $answer );
454
+		return $this->_generate_question_input($registration, $question, $answer);
456 455
 
457 456
 	}
458 457
 
@@ -464,7 +463,7 @@  discard block
 block discarded – undo
464 463
 	 * @param mixed EE_Answer|NULL      $answer
465 464
 	 * @return EE_Form_Input_Base
466 465
 	 */
467
-	private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){
466
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) {
468 467
 		//		d( $registration );
469 468
 		//		d( $question );
470 469
 		//		d( $answer );
@@ -487,29 +486,29 @@  discard block
 block discarded – undo
487 486
 		$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
488 487
 
489 488
 		$input_constructor_args = array(
490
-			'html_name' 			=> 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
491
-			'html_id' 					=> 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
492
-			'html_class' 			=> 'ee-reg-qstn ee-reg-qstn-' . $identifier,
489
+			'html_name' 			=> 'ee_reg_qstn['.$registration->ID().']['.$identifier.']',
490
+			'html_id' 					=> 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
491
+			'html_class' 			=> 'ee-reg-qstn ee-reg-qstn-'.$identifier,
493 492
 			'required' 				=> $question->required() ? TRUE : FALSE,
494
-			'html_label_id'		=> 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
493
+			'html_label_id'		=> 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
495 494
 			'html_label_class'	=> 'ee-reg-qstn',
496 495
 			'html_label_text'		=> $question->display_text(),
497 496
 			'required_validation_error_message' => $question->required_text()
498 497
 		);
499 498
 		// has this question been answered ?
500
-		if ( $answer instanceof EE_Answer ) {
501
-			if ( $answer->ID() ) {
502
-				$input_constructor_args['html_name'] 		.= '[' . $answer->ID() . ']';
503
-				$input_constructor_args['html_id'] 				.= '-' . $answer->ID();
504
-				$input_constructor_args['html_label_id'] 	.= '-' . $answer->ID();
499
+		if ($answer instanceof EE_Answer) {
500
+			if ($answer->ID()) {
501
+				$input_constructor_args['html_name'] 		.= '['.$answer->ID().']';
502
+				$input_constructor_args['html_id'] 				.= '-'.$answer->ID();
503
+				$input_constructor_args['html_label_id'] .= '-'.$answer->ID();
505 504
 			}
506 505
 			$input_constructor_args['default'] = $answer->value();
507 506
 		}
508 507
 		//add "-lbl" to the end of the label id
509
-		$input_constructor_args['html_label_id'] 	.= '-lbl';
510
-		$max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question( $question->system_ID() );
511
-		if( EEM_Question::instance()->question_type_is_in_category(  $question->type(), 'text' ) ) {
512
-			$input_constructor_args[ 'validation_strategies' ][] = new EE_Max_Length_Validation_Strategy( 
508
+		$input_constructor_args['html_label_id'] .= '-lbl';
509
+		$max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($question->system_ID());
510
+		if (EEM_Question::instance()->question_type_is_in_category($question->type(), 'text')) {
511
+			$input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy( 
513 512
 				null, 
514 513
 				min( 
515 514
 					$max_max_for_question, 
@@ -517,83 +516,83 @@  discard block
 block discarded – undo
517 516
 				) 
518 517
 			);
519 518
 		}
520
-		$input_constructor_args = apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args',
519
+		$input_constructor_args = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args',
521 520
 				$input_constructor_args,
522 521
 				$registration,
523 522
 				$question,
524 523
 				$answer
525 524
 				);
526 525
 
527
-		$this->_required_questions[ $identifier ] = $question->required() ? true : false;
526
+		$this->_required_questions[$identifier] = $question->required() ? true : false;
528 527
 
529
-		switch ( $question->type() ) {
528
+		switch ($question->type()) {
530 529
 			// Text
531 530
 			case EEM_Question::QST_type_text :
532
-				if( $identifier == 'email' ){
533
-					return new EE_Email_Input( $input_constructor_args );
534
-				}else{
535
-					return new EE_Text_Input( $input_constructor_args );
531
+				if ($identifier == 'email') {
532
+					return new EE_Email_Input($input_constructor_args);
533
+				} else {
534
+					return new EE_Text_Input($input_constructor_args);
536 535
 				}
537 536
 				break;
538 537
 			// Textarea
539 538
 			case EEM_Question::QST_type_textarea :
540
-				return new EE_Text_Area_Input( $input_constructor_args );
539
+				return new EE_Text_Area_Input($input_constructor_args);
541 540
 				break;
542 541
 			// Radio Buttons
543 542
 			case EEM_Question::QST_type_radio :
544
-				return new EE_Radio_Button_Input( $question->options(), $input_constructor_args );
543
+				return new EE_Radio_Button_Input($question->options(), $input_constructor_args);
545 544
 				break;
546 545
 			// Dropdown
547 546
 			case EEM_Question::QST_type_dropdown :
548
-				return new EE_Select_Input( $question->options(), $input_constructor_args );
547
+				return new EE_Select_Input($question->options(), $input_constructor_args);
549 548
 				break;
550 549
 			// State Dropdown
551 550
 			case EEM_Question::QST_type_state :
552
-				$state_options = array( '' => array( '' => ''));
551
+				$state_options = array('' => array('' => ''));
553 552
 				$states = $this->checkout->action == 'process_reg_step' ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_active_states();
554
-				if ( ! empty( $states )) {
555
-					foreach( $states as $state ){
556
-						if ( $state instanceof EE_State ) {
557
-							$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
553
+				if ( ! empty($states)) {
554
+					foreach ($states as $state) {
555
+						if ($state instanceof EE_State) {
556
+							$state_options[$state->country()->name()][$state->ID()] = $state->name();
558 557
 						}
559 558
 					}
560 559
 				}
561
-				$state_options = apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', $state_options, $this, $registration, $question, $answer );
562
-				return new EE_State_Select_Input( $state_options, $input_constructor_args );
560
+				$state_options = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', $state_options, $this, $registration, $question, $answer);
561
+				return new EE_State_Select_Input($state_options, $input_constructor_args);
563 562
 				break;
564 563
 			// Country Dropdown
565 564
 			case EEM_Question::QST_type_country :
566
-				$country_options = array( '' => '' );
565
+				$country_options = array('' => '');
567 566
 				// get possibly cached list of countries
568 567
 				$countries = $this->checkout->action == 'process_reg_step' ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries();
569
-				if ( ! empty( $countries )) {
570
-					foreach( $countries as $country ){
571
-						if ( $country instanceof EE_Country ) {
572
-							$country_options[ $country->ID() ] = $country->name();
568
+				if ( ! empty($countries)) {
569
+					foreach ($countries as $country) {
570
+						if ($country instanceof EE_Country) {
571
+							$country_options[$country->ID()] = $country->name();
573 572
 						}
574 573
 					}
575 574
 				}
576
-				$country_options = apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', $country_options, $this, $registration, $question, $answer );
577
-				return new EE_Country_Select_Input( $country_options, $input_constructor_args );
575
+				$country_options = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', $country_options, $this, $registration, $question, $answer);
576
+				return new EE_Country_Select_Input($country_options, $input_constructor_args);
578 577
 				break;
579 578
 			// Checkboxes
580 579
 			case EEM_Question::QST_type_checkbox :
581
-				return new EE_Checkbox_Multi_Input( $question->options(), $input_constructor_args );
580
+				return new EE_Checkbox_Multi_Input($question->options(), $input_constructor_args);
582 581
 				break;
583 582
 			// Date
584 583
 			case EEM_Question::QST_type_date :
585
-				return new EE_Datepicker_Input( $input_constructor_args );
584
+				return new EE_Datepicker_Input($input_constructor_args);
586 585
 				break;
587 586
 			case EEM_Question::QST_type_html_textarea :
588
-				$input_constructor_args[ 'validation_strategies' ][] = new EE_Simple_HTML_Validation_Strategy();
589
-				$input =  new EE_Text_Area_Input( $input_constructor_args );
590
-				$input->remove_validation_strategy( 'EE_Plaintext_Validation_Strategy' );
587
+				$input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy();
588
+				$input = new EE_Text_Area_Input($input_constructor_args);
589
+				$input->remove_validation_strategy('EE_Plaintext_Validation_Strategy');
591 590
 				return $input;
592 591
 			// fallback
593 592
 			default :
594
-				$default_input = apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default', null, $question->type(), $question, $input_constructor_args );
595
-				if( ! $default_input ){
596
-					$default_input = new EE_Text_Input( $input_constructor_args );
593
+				$default_input = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default', null, $question->type(), $question, $input_constructor_args);
594
+				if ( ! $default_input) {
595
+					$default_input = new EE_Text_Input($input_constructor_args);
597 596
 				}
598 597
 				return $default_input;
599 598
 		}
@@ -618,65 +617,65 @@  discard block
 block discarded – undo
618 617
 	 */
619 618
 	public function process_reg_step() {
620 619
 
621
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
620
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
622 621
 		// grab validated data from form
623 622
 		$valid_data = $this->checkout->current_step->valid_data();
624 623
 		//EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
625 624
 		//EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
626 625
 		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
627
-		if ( empty( $valid_data ))  {
628
-			EE_Error::add_error( __('No valid question responses were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
626
+		if (empty($valid_data)) {
627
+			EE_Error::add_error(__('No valid question responses were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
629 628
 			return FALSE;
630 629
 		}
631 630
 		//EEH_Debug_Tools::printr( $this->checkout->transaction, '$this->checkout->transaction', __FILE__, __LINE__ );
632
-		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) {
633
-			EE_Error::add_error( __( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
631
+		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
632
+			EE_Error::add_error(__('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
634 633
 			return FALSE;
635 634
 		}
636 635
 		// get cached registrations
637
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
636
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
638 637
 		// verify we got the goods
639
-		if ( empty( $registrations )) {
640
-			EE_Error::add_error( __( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
638
+		if (empty($registrations)) {
639
+			EE_Error::add_error(__('Your form data could not be applied to any valid registrations.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
641 640
 			return FALSE;
642 641
 		}
643 642
 		// extract attendee info from form data and save to model objects
644
-		$registrations_processed = $this->_process_registrations( $registrations, $valid_data );
643
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
645 644
 		// if first pass thru SPCO, then let's check processed registrations against the total number of tickets in the cart
646
-		if ( $registrations_processed === FALSE ) {
645
+		if ($registrations_processed === FALSE) {
647 646
 			// but return immediately if the previous step exited early due to errors
648 647
 			return FALSE;
649
-		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) {
648
+		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
650 649
 			// generate a correctly translated string for all possible singular/plural combinations
651
-			if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) {
650
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
652 651
 				$error_msg = sprintf(
653
-					__( 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', 'event_espresso' ),
652
+					__('There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', 'event_espresso'),
654 653
 					$this->checkout->total_ticket_count,
655 654
 					$registrations_processed
656 655
 				);
657
-			} else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) {
656
+			} else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
658 657
 				$error_msg = sprintf(
659
-					__( 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', 'event_espresso' ),
658
+					__('There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', 'event_espresso'),
660 659
 					$this->checkout->total_ticket_count,
661 660
 					$registrations_processed
662 661
 				);
663 662
 			} else {
664 663
 				$error_msg = sprintf(
665
-					__( 'There was a total of %1$d tickets in the Event Queue, but %2$ds registrations were processed', 'event_espresso' ),
664
+					__('There was a total of %1$d tickets in the Event Queue, but %2$ds registrations were processed', 'event_espresso'),
666 665
 					$this->checkout->total_ticket_count,
667 666
 					$registrations_processed
668 667
 				);
669 668
 
670 669
 			}
671
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
670
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
672 671
 			return FALSE;
673 672
 		}
674 673
 		// mark this reg step as completed
675 674
 		$this->set_completed();
676
-		$this->_set_success_message( __('The Attendee Information Step has been successfully completed.', 'event_espresso' ));
675
+		$this->_set_success_message(__('The Attendee Information Step has been successfully completed.', 'event_espresso'));
677 676
 		//do action in case a plugin wants to do something with the data submitted in step 1.
678 677
 		//passes EE_Single_Page_Checkout, and it's posted data
679
-		do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data );
678
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
680 679
 		return TRUE;
681 680
 
682 681
 	}
@@ -690,9 +689,9 @@  discard block
 block discarded – undo
690 689
 	 * @param array             $valid_data
691 690
 	 * @return boolean | int
692 691
 	 */
693
-	private function _process_registrations( $registrations = array(), $valid_data = array() ) {
692
+	private function _process_registrations($registrations = array(), $valid_data = array()) {
694 693
 		// load resources and set some defaults
695
-		EE_Registry::instance()->load_model( 'Attendee' );
694
+		EE_Registry::instance()->load_model('Attendee');
696 695
 		// holder for primary registrant attendee object
697 696
 		$this->checkout->primary_attendee_obj = NULL;
698 697
 		// array for tracking reg form data for the primary registrant
@@ -709,19 +708,19 @@  discard block
 block discarded – undo
709 708
 		// attendee counter
710 709
 		$att_nmbr = 0;
711 710
 		// grab the saved registrations from the transaction
712
-		foreach ( $registrations  as $registration ) {
711
+		foreach ($registrations  as $registration) {
713 712
 			// verify EE_Registration object
714
-			if ( ! $registration instanceof EE_Registration ) {
715
-				EE_Error::add_error( __( 'An invalid Registration object was discovered when attempting to process your registration information.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
713
+			if ( ! $registration instanceof EE_Registration) {
714
+				EE_Error::add_error(__('An invalid Registration object was discovered when attempting to process your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
716 715
 				return FALSE;
717 716
 			}
718 717
 			$reg_url_link = $registration->reg_url_link();
719 718
 			// reg_url_link exists ?
720
-			if ( $reg_url_link ) {
719
+			if ($reg_url_link) {
721 720
 				// should this registration be processed during this visit ?
722
-				if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) {
721
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
723 722
 					// if NOT revisiting, then let's save the registration now, so that we have a REG_ID to use when generating other objects
724
-					if ( ! $this->checkout->revisit ) {
723
+					if ( ! $this->checkout->revisit) {
725 724
 						$registration->save();
726 725
 					}
727 726
 
@@ -732,41 +731,41 @@  discard block
 block discarded – undo
732 731
 					 * @var bool   if TRUE is returned by the plugin then the
733 732
 					 *      		registration processing is halted.
734 733
 					 */
735
-					if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', FALSE, $att_nmbr, $registration, $registrations, $valid_data, $this ) ) {
734
+					if (apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', FALSE, $att_nmbr, $registration, $registrations, $valid_data, $this)) {
736 735
 						return FALSE;
737 736
 					}
738 737
 
739 738
 					// Houston, we have a registration!
740 739
 					$att_nmbr++;
741
-					$this->_attendee_data[ $reg_url_link ] = array();
740
+					$this->_attendee_data[$reg_url_link] = array();
742 741
 					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
743
-					if ( isset( $valid_data[ $reg_url_link ] )) {
742
+					if (isset($valid_data[$reg_url_link])) {
744 743
 						// do we need to copy basic info from primary attendee ?
745
-						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 ? TRUE : FALSE;
744
+						$copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info']) && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0 ? TRUE : FALSE;
746 745
 						// filter form input data for this registration
747
-						$valid_data[ $reg_url_link ] = apply_filters( 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', $valid_data[ $reg_url_link ] );
746
+						$valid_data[$reg_url_link] = apply_filters('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', $valid_data[$reg_url_link]);
748 747
 						//EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ );
749
-						if ( isset( $valid_data['primary_attendee'] )) {
750
-							$primary_registrant['line_item_id'] =  ! empty( $valid_data['primary_attendee'] ) ? $valid_data['primary_attendee'] : FALSE;
751
-							unset( $valid_data['primary_attendee'] );
748
+						if (isset($valid_data['primary_attendee'])) {
749
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) ? $valid_data['primary_attendee'] : FALSE;
750
+							unset($valid_data['primary_attendee']);
752 751
 						}
753 752
 						// now loop through our array of valid post data && process attendee reg forms
754
-						foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) {
755
-							if ( ! in_array( $form_section, $non_input_form_sections )) {
756
-								foreach ( $form_inputs as $form_input => $input_value ) {
753
+						foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
754
+							if ( ! in_array($form_section, $non_input_form_sections)) {
755
+								foreach ($form_inputs as $form_input => $input_value) {
757 756
 									// check for critical inputs
758
-									if ( ! $this->_verify_critical_attendee_details_are_set_and_validate_email( $form_input, $input_value )) {
757
+									if ( ! $this->_verify_critical_attendee_details_are_set_and_validate_email($form_input, $input_value)) {
759 758
 										return FALSE;
760 759
 									}
761 760
 									// store a bit of data about the primary attendee
762
-									if ( $att_nmbr == 1 && $reg_url_link == $primary_registrant['line_item_id'] && ! empty( $input_value )) {
763
-										$primary_registrant[ $form_input ] = $input_value;
764
-									} else if ( $copy_primary && isset( $primary_registrant[ $form_input ] ) && $input_value == NULL ) {
765
-										$input_value = $primary_registrant[ $form_input ];
761
+									if ($att_nmbr == 1 && $reg_url_link == $primary_registrant['line_item_id'] && ! empty($input_value)) {
762
+										$primary_registrant[$form_input] = $input_value;
763
+									} else if ($copy_primary && isset($primary_registrant[$form_input]) && $input_value == NULL) {
764
+										$input_value = $primary_registrant[$form_input];
766 765
 									}
767 766
 									// now attempt to save the input data
768
-									if ( ! $this->_save_registration_form_input( $registration, $form_input, $input_value ))  {
769
-										EE_Error::add_error( sprintf( __( 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', 'event_espresso' ), $form_input, $input_value ), __FILE__, __FUNCTION__, __LINE__ );
767
+									if ( ! $this->_save_registration_form_input($registration, $form_input, $input_value)) {
768
+										EE_Error::add_error(sprintf(__('Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', 'event_espresso'), $form_input, $input_value), __FILE__, __FUNCTION__, __LINE__);
770 769
 										return FALSE;
771 770
 									}
772 771
 								}
@@ -775,51 +774,51 @@  discard block
 block discarded – undo
775 774
 					}
776 775
 					//EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ );
777 776
 					// this registration does not require additional attendee information ?
778
-					if ( $copy_primary && $att_nmbr > 1 && $this->checkout->primary_attendee_obj instanceof EE_Attendee ) {
777
+					if ($copy_primary && $att_nmbr > 1 && $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
779 778
 						// just copy the primary registrant
780 779
 						$attendee = $this->checkout->primary_attendee_obj;
781 780
 					} else {
782 781
 						// have we met before?
783
-						$attendee = $this->_find_existing_attendee( $registration, $this->_attendee_data[ $reg_url_link ] );
782
+						$attendee = $this->_find_existing_attendee($registration, $this->_attendee_data[$reg_url_link]);
784 783
 						// did we find an already existing record for this attendee ?
785
-						if ( $attendee instanceof EE_Attendee ) {
786
-							$attendee = $this->_update_existing_attendee_data( $attendee, $this->_attendee_data[ $reg_url_link ] );
784
+						if ($attendee instanceof EE_Attendee) {
785
+							$attendee = $this->_update_existing_attendee_data($attendee, $this->_attendee_data[$reg_url_link]);
787 786
 						} else {
788 787
 							// ensure critical details are set for additional attendees
789
-							$this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 ? $this->_copy_critical_attendee_details_from_primary_registrant( $this->_attendee_data[ $reg_url_link ] ) : $this->_attendee_data[ $reg_url_link ];
790
-							$attendee = $this->_create_new_attendee( $registration, $this->_attendee_data[ $reg_url_link ] );
788
+							$this->_attendee_data[$reg_url_link] = $att_nmbr > 1 ? $this->_copy_critical_attendee_details_from_primary_registrant($this->_attendee_data[$reg_url_link]) : $this->_attendee_data[$reg_url_link];
789
+							$attendee = $this->_create_new_attendee($registration, $this->_attendee_data[$reg_url_link]);
791 790
 						}
792 791
 						// who's #1 ?
793
-						if ( $att_nmbr == 1 ) {
792
+						if ($att_nmbr == 1) {
794 793
 							$this->checkout->primary_attendee_obj = $attendee;
795 794
 						}
796 795
 					}
797 796
 					//EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
798 797
 					// add relation to registration, set attendee ID, and cache attendee
799
-					$this->_associate_attendee_with_registration( $registration, $attendee );
800
-					if ( ! $registration->attendee() instanceof EE_Attendee ) {
801
-						EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ );
798
+					$this->_associate_attendee_with_registration($registration, $attendee);
799
+					if ( ! $registration->attendee() instanceof EE_Attendee) {
800
+						EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__);
802 801
 						return FALSE;
803 802
 					}
804 803
 					/** @type EE_Registration_Processor $registration_processor */
805
-					$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
804
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
806 805
 					// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
807
-					$registration_processor->toggle_incomplete_registration_status_to_default( $registration, FALSE );
806
+					$registration_processor->toggle_incomplete_registration_status_to_default($registration, FALSE);
808 807
 					/** @type EE_Transaction_Processor $transaction_processor */
809
-					$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
808
+					$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
810 809
 					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
811
-					$transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction );
810
+					$transaction_processor->toggle_failed_transaction_status($this->checkout->transaction);
812 811
 					// if we've gotten this far, then let's save what we have
813 812
 					$registration->save();
814 813
 					// add relation between TXN and registration
815
-					$this->_associate_registration_with_transaction( $registration );
814
+					$this->_associate_registration_with_transaction($registration);
816 815
 
817 816
 				} // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) {
818 817
 
819
-			}  else {
820
-				EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
818
+			} else {
819
+				EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
821 820
 				// remove malformed data
822
-				unset( $valid_data[ $reg_url_link ] );
821
+				unset($valid_data[$reg_url_link]);
823 822
 				return FALSE;
824 823
 			}
825 824
 
@@ -837,22 +836,22 @@  discard block
 block discarded – undo
837 836
 	 * @param string           	$input_value
838 837
 	 * @return boolean
839 838
 	 */
840
-	private function _save_registration_form_input( EE_Registration $registration, $form_input = '', $input_value = '' ) {
839
+	private function _save_registration_form_input(EE_Registration $registration, $form_input = '', $input_value = '') {
841 840
 		//echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '()</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span>    <b style="font-size:10px;">  ' . __LINE__ . ' </b></h3>';
842 841
 		//EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ );
843 842
 		// allow for plugins to hook in and do their own processing of the form input.
844 843
 		// For plugins to bypass normal processing here, they just need to return a boolean value.
845
-		if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', FALSE, $registration, $form_input, $input_value, $this ) ) {
844
+		if (apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', FALSE, $registration, $form_input, $input_value, $this)) {
846 845
 			return TRUE;
847 846
 		}
848 847
 
849 848
 		// grab related answer objects
850 849
 		$answers = $registration->answers();
851 850
 		// $answer_cache_id is the key used to find the EE_Answer we want
852
-		$answer_cache_id = $this->checkout->reg_url_link ? $form_input : $form_input . '-' . $registration->reg_url_link();
853
-		$answer_is_obj = isset( $answers[ $answer_cache_id ] ) && $answers[ $answer_cache_id ] instanceof EE_Answer ? TRUE : FALSE;
851
+		$answer_cache_id = $this->checkout->reg_url_link ? $form_input : $form_input.'-'.$registration->reg_url_link();
852
+		$answer_is_obj = isset($answers[$answer_cache_id]) && $answers[$answer_cache_id] instanceof EE_Answer ? TRUE : FALSE;
854 853
 		//rename form_inputs if they are EE_Attendee properties
855
-		switch( (string)$form_input ) {
854
+		switch ((string) $form_input) {
856 855
 
857 856
 			case 'state' :
858 857
 			case 'STA_ID' :
@@ -867,33 +866,33 @@  discard block
 block discarded – undo
867 866
 				break;
868 867
 
869 868
 			default :
870
-				$ATT_input = 'ATT_' . $form_input;
869
+				$ATT_input = 'ATT_'.$form_input;
871 870
 				//EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
872
-				$attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? TRUE : FALSE;
873
-				$form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
871
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? TRUE : FALSE;
872
+				$form_input = $attendee_property ? 'ATT_'.$form_input : $form_input;
874 873
 		}
875 874
 		//EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
876 875
 		//EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
877 876
 		//EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
878 877
 		//EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
879 878
 		// if this form input has a corresponding attendee property
880
-		if ( $attendee_property ) {
881
-			$this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
882
-			if (  $answer_is_obj ) {
879
+		if ($attendee_property) {
880
+			$this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
881
+			if ($answer_is_obj) {
883 882
 				// and delete the corresponding answer since we won't be storing this data in that object
884
-				$registration->_remove_relation_to( $answers[ $answer_cache_id ], 'Answer' );
885
-				$answers[ $answer_cache_id ]->delete_permanently();
883
+				$registration->_remove_relation_to($answers[$answer_cache_id], 'Answer');
884
+				$answers[$answer_cache_id]->delete_permanently();
886 885
 			}
887 886
 			return TRUE;
888
-		} elseif ( $answer_is_obj ) {
887
+		} elseif ($answer_is_obj) {
889 888
 			// save this data to the answer object
890
-			$answers[ $answer_cache_id ]->set_value( $input_value );
891
-			$result = $answers[ $answer_cache_id ]->save();
889
+			$answers[$answer_cache_id]->set_value($input_value);
890
+			$result = $answers[$answer_cache_id]->save();
892 891
 			return $result !== false ? true : false;
893 892
 		} else {
894
-			foreach ( $answers as $answer ) {
895
-				if ( $answer instanceof EE_Answer && $answer->question_ID() == $answer_cache_id ) {
896
-					$answer->set_value( $input_value );
893
+			foreach ($answers as $answer) {
894
+				if ($answer instanceof EE_Answer && $answer->question_ID() == $answer_cache_id) {
895
+					$answer->set_value($input_value);
897 896
 					$result = $answer->save();
898 897
 					return $result !== false ? true : false;
899 898
 				}
@@ -911,33 +910,33 @@  discard block
 block discarded – undo
911 910
 	 * @param string $input_value
912 911
 	 * @return boolean
913 912
 	 */
914
-	private function _verify_critical_attendee_details_are_set_and_validate_email( $form_input = '', $input_value = '' ) {
915
-		if ( empty( $input_value )) {
913
+	private function _verify_critical_attendee_details_are_set_and_validate_email($form_input = '', $input_value = '') {
914
+		if (empty($input_value)) {
916 915
 			// if the form input isn't marked as being required, then just return
917
-			if ( ! isset( $this->_required_questions[ $form_input ]  ) || ! $this->_required_questions[ $form_input ] ) {
916
+			if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
918 917
 				return true;
919 918
 			}
920
-			switch( $form_input ) {
919
+			switch ($form_input) {
921 920
 				case 'fname' :
922
-					EE_Error::add_error( __( 'First Name is a required value.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
921
+					EE_Error::add_error(__('First Name is a required value.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
923 922
 					return FALSE;
924 923
 					break;
925 924
 				case 'lname' :
926
-					EE_Error::add_error( __( 'Last Name is a required value.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
925
+					EE_Error::add_error(__('Last Name is a required value.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
927 926
 					return FALSE;
928 927
 					break;
929 928
 				case 'email' :
930
-					EE_Error::add_error( __( 'Email Address is a required value.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
929
+					EE_Error::add_error(__('Email Address is a required value.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
931 930
 					return FALSE;
932 931
 					break;
933 932
 			}
934
-		} else if ( $form_input === 'email' ) {
933
+		} else if ($form_input === 'email') {
935 934
 			// clean the email address
936
-			$valid_email = sanitize_email( $input_value );
935
+			$valid_email = sanitize_email($input_value);
937 936
 			// check if it matches
938
-			if ( $input_value != $valid_email ) {
937
+			if ($input_value != $valid_email) {
939 938
 				// whoops!!!
940
-				EE_Error::add_error( __( 'Please enter a valid email address.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
939
+				EE_Error::add_error(__('Please enter a valid email address.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
941 940
 				return FALSE;
942 941
 			}
943 942
 		}
@@ -965,14 +964,14 @@  discard block
 block discarded – undo
965 964
 	 * @param array           $attendee_data
966 965
 	 * @return boolean
967 966
 	 */
968
-	private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) {
967
+	private function _find_existing_attendee(EE_Registration $registration, $attendee_data = array()) {
969 968
 		// does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
970
-		$ATT_fname = isset( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_fname'] ) ? $attendee_data['ATT_fname'] : '';
971
-		$ATT_lname = isset( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_lname'] ) ? $attendee_data['ATT_lname'] : '';
972
-		$ATT_email = isset( $attendee_data['ATT_email'] ) && ! empty( $attendee_data['ATT_email'] ) ? $attendee_data['ATT_email'] : '';
969
+		$ATT_fname = isset($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_fname']) ? $attendee_data['ATT_fname'] : '';
970
+		$ATT_lname = isset($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_lname']) ? $attendee_data['ATT_lname'] : '';
971
+		$ATT_email = isset($attendee_data['ATT_email']) && ! empty($attendee_data['ATT_email']) ? $attendee_data['ATT_email'] : '';
973 972
 		// but only if those have values
974
-		if ( $ATT_fname && $ATT_lname && $ATT_email ) {
975
-			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array(
973
+		if ($ATT_fname && $ATT_lname && $ATT_email) {
974
+			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array(
976 975
 				'ATT_fname' => $ATT_fname,
977 976
 				'ATT_lname' => $ATT_lname,
978 977
 				'ATT_email' => $ATT_email
@@ -980,7 +979,7 @@  discard block
 block discarded – undo
980 979
 		} else {
981 980
 			$existing_attendee = NULL;
982 981
 		}
983
-		return apply_filters( 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', $existing_attendee, $registration, $attendee_data );
982
+		return apply_filters('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', $existing_attendee, $registration, $attendee_data);
984 983
 	}
985 984
 
986 985
 
@@ -992,13 +991,13 @@  discard block
 block discarded – undo
992 991
 	 * @param array           $attendee_data
993 992
 	 * @return \EE_Attendee
994 993
 	 */
995
-	private function _update_existing_attendee_data( EE_Attendee $existing_attendee, $attendee_data = array() ) {
994
+	private function _update_existing_attendee_data(EE_Attendee $existing_attendee, $attendee_data = array()) {
996 995
 		// first remove fname, lname, and email from attendee data
997
-		$dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
996
+		$dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email');
998 997
 		// now loop thru what's left and add to attendee CPT
999
-		foreach ( $attendee_data as $property_name => $property_value ) {
1000
-			if ( ! in_array( $property_name, $dont_set ) && EEM_Attendee::instance()->has_field( $property_name )) {
1001
-				$existing_attendee->set( $property_name, $property_value );
998
+		foreach ($attendee_data as $property_name => $property_value) {
999
+			if ( ! in_array($property_name, $dont_set) && EEM_Attendee::instance()->has_field($property_name)) {
1000
+				$existing_attendee->set($property_name, $property_value);
1002 1001
 			}
1003 1002
 		}
1004 1003
 		// better save that now
@@ -1015,11 +1014,11 @@  discard block
 block discarded – undo
1015 1014
 	 * @param EE_Attendee     $attendee
1016 1015
 	 * @return void
1017 1016
 	 */
1018
-	private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) {
1017
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) {
1019 1018
 		// add relation to attendee
1020
-		$registration->_add_relation_to( $attendee, 'Attendee' );
1021
-		$registration->set_attendee_id( $attendee->ID() );
1022
-		$registration->update_cache_after_object_save( 'Attendee', $attendee );
1019
+		$registration->_add_relation_to($attendee, 'Attendee');
1020
+		$registration->set_attendee_id($attendee->ID());
1021
+		$registration->update_cache_after_object_save('Attendee', $attendee);
1023 1022
 	}
1024 1023
 
1025 1024
 
@@ -1030,10 +1029,10 @@  discard block
 block discarded – undo
1030 1029
 	 * @param EE_Registration $registration
1031 1030
 	 * @return void
1032 1031
 	 */
1033
-	private function _associate_registration_with_transaction( EE_Registration $registration ) {
1032
+	private function _associate_registration_with_transaction(EE_Registration $registration) {
1034 1033
 		// add relation to attendee
1035
-		$this->checkout->transaction->_add_relation_to( $registration, 'Registration' );
1036
-		$this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration );
1034
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1035
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1037 1036
 	}
1038 1037
 
1039 1038
 
@@ -1045,17 +1044,17 @@  discard block
 block discarded – undo
1045 1044
 	 * @param array $attendee_data
1046 1045
 	 * @return array
1047 1046
 	 */
1048
-	private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) {
1047
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) {
1049 1048
 		// bare minimum critical details include first name, last name, email address
1050
-		$critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1049
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1051 1050
 		// add address info to critical details?
1052
-		if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', FALSE )) {
1053
-			$address_details = array( 'ATT_address', 'ATT_address2', 'ATT_city', 'STA_ID', 'CNT_ISO', 'ATT_zip', 'ATT_phone' );
1054
-			$critical_attendee_details = array_merge( $critical_attendee_details, $address_details );
1051
+		if (apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', FALSE)) {
1052
+			$address_details = array('ATT_address', 'ATT_address2', 'ATT_city', 'STA_ID', 'CNT_ISO', 'ATT_zip', 'ATT_phone');
1053
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1055 1054
 		}
1056
-		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1057
-			if ( ! isset( $attendee_data[ $critical_attendee_detail ] ) || empty( $attendee_data[ $critical_attendee_detail ] )) {
1058
-				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( $critical_attendee_detail );
1055
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1056
+			if ( ! isset($attendee_data[$critical_attendee_detail]) || empty($attendee_data[$critical_attendee_detail])) {
1057
+				$attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get($critical_attendee_detail);
1059 1058
 			}
1060 1059
 		}
1061 1060
 		return $attendee_data;
@@ -1070,11 +1069,11 @@  discard block
 block discarded – undo
1070 1069
 	 * @param array           $attendee_data
1071 1070
 	 * @return \EE_Attendee
1072 1071
 	 */
1073
-	private function _create_new_attendee( EE_Registration $registration, $attendee_data = array() ) {
1072
+	private function _create_new_attendee(EE_Registration $registration, $attendee_data = array()) {
1074 1073
 		// create new attendee object
1075
-		$new_attendee = EE_Attendee::new_instance( $attendee_data );
1074
+		$new_attendee = EE_Attendee::new_instance($attendee_data);
1076 1075
 		// set author to event creator
1077
-		$new_attendee->set( 'ATT_author', $registration->event()->wp_user() );
1076
+		$new_attendee->set('ATT_author', $registration->event()->wp_user());
1078 1077
 		$new_attendee->save();
1079 1078
 		return $new_attendee;
1080 1079
 	}
@@ -1090,7 +1089,7 @@  discard block
 block discarded – undo
1090 1089
 	 */
1091 1090
 	public function update_reg_step() {
1092 1091
 		// save everything
1093
-		if ( $this->process_reg_step() ) {
1092
+		if ($this->process_reg_step()) {
1094 1093
 			$this->checkout->redirect = TRUE;
1095 1094
 			$this->checkout->redirect_url = add_query_arg(
1096 1095
 				array(
@@ -1099,7 +1098,7 @@  discard block
 block discarded – undo
1099 1098
 				),
1100 1099
 				$this->checkout->thank_you_page_url
1101 1100
 			);
1102
-			$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1101
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1103 1102
 			return TRUE;
1104 1103
 		}
1105 1104
 		return FALSE;
Please login to merge, or discard this patch.