@@ -11,13 +11,13 @@ discard block |
||
11 | 11 | //(all other times it gets resurrected from a wordpress option) |
12 | 12 | $stages = glob(EE_CORE.'data_migration_scripts/4_9_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | -foreach($stages as $filepath){ |
|
14 | +foreach ($stages as $filepath) { |
|
15 | 15 | $matches = array(); |
16 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~',$filepath,$matches); |
|
16 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | 17 | $class_to_filepath[$matches[1]] = $filepath; |
18 | 18 | } |
19 | 19 | //give addons a chance to autoload their stages too |
20 | -$class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages',$class_to_filepath); |
|
20 | +$class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
|
21 | 21 | EEH_Autoloader::register_autoloader($class_to_filepath); |
22 | 22 | |
23 | 23 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @since 4.6.0 |
34 | 34 | * |
35 | 35 | */ |
36 | -class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base{ |
|
36 | +class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base { |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * return EE_DMS_Core_4_9_0 |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | * @param TableManager $table_manager |
42 | 42 | * @param TableAnalysis $table_analysis |
43 | 43 | */ |
44 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
44 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
45 | 45 | $this->_pretty_name = __("Data Migration to Event Espresso 4.9.0.P", "event_espresso"); |
46 | 46 | $this->_priority = 10; |
47 | 47 | $this->_migration_stages = array( |
48 | 48 | new EE_DMS_4_9_0_Email_System_Question(), |
49 | 49 | new EE_DMS_4_9_0_Answers_With_No_Registration(), |
50 | 50 | ); |
51 | - parent::__construct( $table_manager, $table_analysis ); |
|
51 | + parent::__construct($table_manager, $table_analysis); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function can_migrate_from_version($version_array) { |
62 | 62 | $version_string = $version_array['Core']; |
63 | - if ( version_compare( $version_string, '4.9.0', '<=' ) && version_compare( $version_string, '4.8.0', '>=' ) ) { |
|
63 | + if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
64 | 64 | // echo "$version_string can be migrated from"; |
65 | 65 | return true; |
66 | - } elseif( ! $version_string ){ |
|
66 | + } elseif ( ! $version_string) { |
|
67 | 67 | // echo "no version string provided: $version_string"; |
68 | 68 | //no version string provided... this must be pre 4.3 |
69 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
70 | - }else{ |
|
69 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
70 | + } else { |
|
71 | 71 | // echo "$version_string doesnt apply"; |
72 | 72 | return false; |
73 | 73 | } |
@@ -88,18 +88,18 @@ discard block |
||
88 | 88 | * @return bool |
89 | 89 | */ |
90 | 90 | public function schema_changes_before_migration() { |
91 | - require_once( EE_HELPERS . 'EEH_Activation.helper.php' ); |
|
92 | - $now_in_mysql = current_time( 'mysql', true ); |
|
91 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
92 | + $now_in_mysql = current_time('mysql', true); |
|
93 | 93 | |
94 | - $table_name='esp_answer'; |
|
95 | - $sql=" ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
94 | + $table_name = 'esp_answer'; |
|
95 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
96 | 96 | REG_ID int(10) unsigned NOT NULL, |
97 | 97 | QST_ID int(10) unsigned NOT NULL, |
98 | 98 | ANS_value text NOT NULL, |
99 | 99 | PRIMARY KEY (ANS_ID), |
100 | 100 | KEY REG_ID (REG_ID), |
101 | 101 | KEY QST_ID (QST_ID)"; |
102 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
102 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
103 | 103 | |
104 | 104 | $table_name = 'esp_attendee_meta'; |
105 | 105 | $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | KEY ATT_fname (ATT_fname)"; |
122 | 122 | $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
123 | 123 | |
124 | - $table_name='esp_checkin'; |
|
124 | + $table_name = 'esp_checkin'; |
|
125 | 125 | $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
126 | 126 | REG_ID int(10) unsigned NOT NULL, |
127 | 127 | DTT_ID int(10) unsigned NOT NULL, |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | CNT_is_EU tinyint(1) DEFAULT '0', |
150 | 150 | CNT_active tinyint(1) DEFAULT '0', |
151 | 151 | PRIMARY KEY (CNT_ISO)"; |
152 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
152 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
153 | 153 | |
154 | 154 | $table_name = 'esp_currency'; |
155 | 155 | $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2', |
160 | 160 | CUR_active tinyint(1) DEFAULT '0', |
161 | 161 | PRIMARY KEY (CUR_code)"; |
162 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
162 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
163 | 163 | |
164 | 164 | |
165 | 165 | $table_name = 'esp_currency_payment_method'; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | KEY DTT_EVT_start (DTT_EVT_start), |
188 | 188 | KEY EVT_ID (EVT_ID), |
189 | 189 | KEY DTT_is_primary (DTT_is_primary)"; |
190 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
190 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | 191 | |
192 | 192 | $table_name = "esp_datetime_ticket"; |
193 | 193 | $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | PRIMARY KEY (EMT_ID), |
206 | 206 | KEY EVT_ID (EVT_ID), |
207 | 207 | KEY GRP_ID (GRP_ID)"; |
208 | - $this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB'); |
|
208 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
209 | 209 | |
210 | 210 | $table_name = 'esp_event_meta'; |
211 | 211 | $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | EVT_donations tinyint(1) NULL, |
224 | 224 | PRIMARY KEY (EVTM_ID), |
225 | 225 | KEY EVT_ID (EVT_ID)"; |
226 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
226 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
227 | 227 | |
228 | - $table_name='esp_event_question_group'; |
|
228 | + $table_name = 'esp_event_question_group'; |
|
229 | 229 | $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
230 | 230 | EVT_ID bigint(20) unsigned NOT NULL, |
231 | 231 | QSG_ID int(10) unsigned NOT NULL, |
@@ -233,17 +233,17 @@ discard block |
||
233 | 233 | PRIMARY KEY (EQG_ID), |
234 | 234 | KEY EVT_ID (EVT_ID), |
235 | 235 | KEY QSG_ID (QSG_ID)"; |
236 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
236 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
237 | 237 | |
238 | - $table_name='esp_event_venue'; |
|
238 | + $table_name = 'esp_event_venue'; |
|
239 | 239 | $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
240 | 240 | EVT_ID bigint(20) unsigned NOT NULL, |
241 | 241 | VNU_ID bigint(20) unsigned NOT NULL, |
242 | 242 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
243 | 243 | PRIMARY KEY (EVV_ID)"; |
244 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
244 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
245 | 245 | |
246 | - $table_name='esp_extra_meta'; |
|
246 | + $table_name = 'esp_extra_meta'; |
|
247 | 247 | $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
248 | 248 | OBJ_ID int(11) DEFAULT NULL, |
249 | 249 | EXM_type varchar(45) DEFAULT NULL, |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | EXM_value text, |
252 | 252 | PRIMARY KEY (EXM_ID), |
253 | 253 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
254 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
254 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
255 | 255 | |
256 | 256 | $table_name = 'esp_extra_join'; |
257 | 257 | $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
265 | 265 | $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
266 | 266 | |
267 | - $table_name='esp_line_item'; |
|
267 | + $table_name = 'esp_line_item'; |
|
268 | 268 | $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
269 | 269 | LIN_code varchar(245) NOT NULL DEFAULT '', |
270 | 270 | TXN_ID int(11) DEFAULT NULL, |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | PRIMARY KEY (LIN_ID), |
285 | 285 | KEY LIN_code (LIN_code(191)), |
286 | 286 | KEY TXN_ID (TXN_ID)"; |
287 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB' ); |
|
287 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
288 | 288 | |
289 | 289 | $table_name = 'esp_log'; |
290 | 290 | $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | KEY STS_ID (STS_ID), |
334 | 334 | KEY MSG_created (MSG_created), |
335 | 335 | KEY MSG_modified (MSG_modified)"; |
336 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
336 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
337 | 337 | |
338 | 338 | $table_name = 'esp_message_template'; |
339 | 339 | $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
359 | 359 | PRIMARY KEY (GRP_ID), |
360 | 360 | KEY MTP_user_id (MTP_user_id)"; |
361 | - $this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB'); |
|
361 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
362 | 362 | |
363 | 363 | $table_name = 'esp_payment'; |
364 | 364 | $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | PRIMARY KEY (TTM_ID)"; |
417 | 417 | $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
418 | 418 | |
419 | - $table_name='esp_question'; |
|
419 | + $table_name = 'esp_question'; |
|
420 | 420 | $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
421 | 421 | QST_display_text text NOT NULL, |
422 | 422 | QST_admin_label varchar(255) NOT NULL, |
@@ -431,9 +431,9 @@ discard block |
||
431 | 431 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
432 | 432 | PRIMARY KEY (QST_ID), |
433 | 433 | KEY QST_order (QST_order)'; |
434 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
434 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
435 | 435 | |
436 | - $table_name='esp_question_group_question'; |
|
436 | + $table_name = 'esp_question_group_question'; |
|
437 | 437 | $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
438 | 438 | QSG_ID int(10) unsigned NOT NULL, |
439 | 439 | QST_ID int(10) unsigned NOT NULL, |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | PRIMARY KEY (QGQ_ID), |
442 | 442 | KEY QST_ID (QST_ID), |
443 | 443 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
444 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
444 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
445 | 445 | |
446 | - $table_name='esp_question_option'; |
|
446 | + $table_name = 'esp_question_option'; |
|
447 | 447 | $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
448 | 448 | QSO_value varchar(255) NOT NULL, |
449 | 449 | QSO_desc text NOT NULL, |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | PRIMARY KEY (QSO_ID), |
455 | 455 | KEY QST_ID (QST_ID), |
456 | 456 | KEY QSO_order (QSO_order)"; |
457 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
457 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
458 | 458 | |
459 | 459 | $table_name = 'esp_registration'; |
460 | 460 | $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | PRC_parent int(10) unsigned DEFAULT 0, |
568 | 568 | PRIMARY KEY (PRC_ID), |
569 | 569 | KEY PRT_ID (PRT_ID)"; |
570 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
570 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
571 | 571 | |
572 | 572 | $table_name = "esp_price_type"; |
573 | 573 | $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
605 | 605 | PRIMARY KEY (TKT_ID), |
606 | 606 | KEY TKT_start_date (TKT_start_date)"; |
607 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
607 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
608 | 608 | |
609 | 609 | $table_name = 'esp_question_group'; |
610 | 610 | $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | PRIMARY KEY (QSG_ID), |
621 | 621 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
622 | 622 | KEY QSG_order (QSG_order)'; |
623 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
623 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
624 | 624 | |
625 | 625 | /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
626 | 626 | $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
@@ -654,5 +654,5 @@ discard block |
||
654 | 654 | return true; |
655 | 655 | } |
656 | 656 | |
657 | - public function migration_page_hooks(){} |
|
657 | + public function migration_page_hooks() {} |
|
658 | 658 | } |
659 | 659 | \ No newline at end of file |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | //(all other times it gets resurrected from a wordpress option) |
14 | 14 | $stages = glob(EE_CORE.'data_migration_scripts/4_3_0_stages/*'); |
15 | 15 | $class_to_filepath = array(); |
16 | -if ( ! empty( $stages ) ) { |
|
17 | - foreach($stages as $filepath){ |
|
16 | +if ( ! empty($stages)) { |
|
17 | + foreach ($stages as $filepath) { |
|
18 | 18 | $matches = array(); |
19 | - preg_match('~4_3_0_stages/(.*).dmsstage.php~',$filepath,$matches); |
|
19 | + preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
20 | 20 | $class_to_filepath[$matches[1]] = $filepath; |
21 | 21 | } |
22 | 22 | } |
23 | 23 | //give addons a chance to autoload their stages too |
24 | -$class_to_filepath = apply_filters('FHEE__EE_DMS_4_3_0__autoloaded_stages',$class_to_filepath); |
|
24 | +$class_to_filepath = apply_filters('FHEE__EE_DMS_4_3_0__autoloaded_stages', $class_to_filepath); |
|
25 | 25 | EEH_Autoloader::register_autoloader($class_to_filepath); |
26 | 26 | |
27 | -class EE_DMS_Core_4_3_0 extends EE_Data_Migration_Script_Base{ |
|
27 | +class EE_DMS_Core_4_3_0 extends EE_Data_Migration_Script_Base { |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param TableManager $table_manager |
35 | 35 | * @param TableAnalysis $table_analysis |
36 | 36 | */ |
37 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
37 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
38 | 38 | $this->_pretty_name = __("Data Migration to Event Espresso 4.3.0.P", "event_espresso"); |
39 | 39 | $this->_priority = 10; |
40 | 40 | $this->_migration_stages = array( |
@@ -42,18 +42,18 @@ discard block |
||
42 | 42 | new EE_DMS_4_3_0_event_message_templates(), |
43 | 43 | new EE_DMS_4_3_0_critical_page_shortcode_tracking() |
44 | 44 | ); |
45 | - parent::__construct( $table_manager, $table_analysis ); |
|
45 | + parent::__construct($table_manager, $table_analysis); |
|
46 | 46 | } |
47 | 47 | public function can_migrate_from_version($version_array) { |
48 | 48 | $version_string = $version_array['Core']; |
49 | - if ( version_compare( $version_string, '4.3.0', '<=' ) && version_compare( $version_string, '4.2.0', '>=' ) ) { |
|
49 | + if (version_compare($version_string, '4.3.0', '<=') && version_compare($version_string, '4.2.0', '>=')) { |
|
50 | 50 | // echo "$version_string can be migrated fro"; |
51 | 51 | return true; |
52 | - }elseif( ! $version_string ){ |
|
52 | + }elseif ( ! $version_string) { |
|
53 | 53 | // echo "no version string provided: $version_string"; |
54 | 54 | //no version string provided... this must be pre 4.2 |
55 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
56 | - }else{ |
|
55 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
56 | + } else { |
|
57 | 57 | // echo "$version_string doesnt apply"; |
58 | 58 | return false; |
59 | 59 | } |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | } |
64 | 64 | public function schema_changes_before_migration() { |
65 | 65 | //relies on 4.1's EEH_Activation::create_table |
66 | - require_once( EE_HELPERS . 'EEH_Activation.helper.php' ); |
|
67 | - $table_name='esp_answer'; |
|
68 | - $sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
66 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
67 | + $table_name = 'esp_answer'; |
|
68 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
69 | 69 | REG_ID INT UNSIGNED NOT NULL, |
70 | 70 | QST_ID INT UNSIGNED NOT NULL, |
71 | 71 | ANS_value TEXT NOT NULL, |
72 | 72 | PRIMARY KEY (ANS_ID)"; |
73 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
73 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
74 | 74 | |
75 | 75 | $table_name = 'esp_attendee_meta'; |
76 | 76 | $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | CNT_is_EU TINYINT(1) DEFAULT '0', |
110 | 110 | CNT_active TINYINT(1) DEFAULT '0', |
111 | 111 | PRIMARY KEY (CNT_ISO)"; |
112 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
112 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
113 | 113 | |
114 | 114 | |
115 | 115 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | |
134 | 134 | |
135 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
135 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
136 | 136 | $table_name = 'esp_event_meta'; |
137 | 137 | $sql = " |
138 | 138 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
@@ -149,41 +149,41 @@ discard block |
||
149 | 149 | EVT_external_URL VARCHAR(200) NULL, |
150 | 150 | EVT_donations TINYINT(1) NULL, |
151 | 151 | PRIMARY KEY (EVTM_ID)"; |
152 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
152 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
153 | 153 | |
154 | 154 | |
155 | 155 | |
156 | - $table_name='esp_event_question_group'; |
|
157 | - $sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
156 | + $table_name = 'esp_event_question_group'; |
|
157 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
158 | 158 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
159 | 159 | QSG_ID INT UNSIGNED NOT NULL, |
160 | 160 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
161 | 161 | PRIMARY KEY (EQG_ID)"; |
162 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
162 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
163 | 163 | |
164 | 164 | |
165 | 165 | |
166 | - $table_name='esp_event_venue'; |
|
167 | - $sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
166 | + $table_name = 'esp_event_venue'; |
|
167 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
168 | 168 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
169 | 169 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
170 | 170 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
171 | 171 | PRIMARY KEY (EVV_ID)"; |
172 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
172 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
173 | 173 | |
174 | 174 | |
175 | 175 | |
176 | - $table_name='esp_extra_meta'; |
|
177 | - $sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
176 | + $table_name = 'esp_extra_meta'; |
|
177 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
178 | 178 | OBJ_ID INT(11) DEFAULT NULL, |
179 | 179 | EXM_type VARCHAR(45) DEFAULT NULL, |
180 | 180 | EXM_key VARCHAR(45) DEFAULT NULL, |
181 | 181 | EXM_value TEXT, |
182 | 182 | PRIMARY KEY (EXM_ID)"; |
183 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
183 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
184 | 184 | |
185 | - $table_name='esp_line_item'; |
|
186 | - $sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
185 | + $table_name = 'esp_line_item'; |
|
186 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
187 | 187 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
188 | 188 | TXN_ID INT(11) DEFAULT NULL, |
189 | 189 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | OBJ_ID INT(11) DEFAULT NULL, |
200 | 200 | OBJ_type VARCHAR(45)DEFAULT NULL, |
201 | 201 | PRIMARY KEY (LIN_ID)"; |
202 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB' ); |
|
202 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
203 | 203 | |
204 | 204 | $table_name = 'esp_message_template'; |
205 | 205 | $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | KEY GRP_ID (GRP_ID)"; |
212 | 212 | $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
213 | 213 | |
214 | - $this->_get_table_manager()->dropIndex( 'esp_message_template_group', 'EVT_ID' ); |
|
214 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
215 | 215 | |
216 | 216 | $table_name = 'esp_message_template_group'; |
217 | 217 | $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
227 | 227 | PRIMARY KEY (GRP_ID), |
228 | 228 | KEY MTP_user_id (MTP_user_id)"; |
229 | - $this->_table_should_exist_previously( $table_name, $sql, 'ENGINE=InnoDB'); |
|
229 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
230 | 230 | |
231 | 231 | $table_name = 'esp_event_message_template'; |
232 | 232 | $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | PRIMARY KEY (EMT_ID), |
236 | 236 | KEY EVT_ID (EVT_ID), |
237 | 237 | KEY GRP_ID (GRP_ID)"; |
238 | - $this->_table_is_new_in_this_version( $table_name, $sql, 'ENGINE=InnoDB'); |
|
238 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
239 | 239 | |
240 | 240 | |
241 | 241 | |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | |
345 | 345 | |
346 | 346 | |
347 | - $table_name='esp_question'; |
|
348 | - $sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
347 | + $table_name = 'esp_question'; |
|
348 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
349 | 349 | QST_display_text TEXT NOT NULL, |
350 | 350 | QST_admin_label VARCHAR(255) NOT NULL, |
351 | 351 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -357,12 +357,12 @@ discard block |
||
357 | 357 | QST_wp_user BIGINT UNSIGNED NULL, |
358 | 358 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
359 | 359 | PRIMARY KEY (QST_ID)'; |
360 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
360 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
361 | 361 | |
362 | - $this->_get_table_manager()->dropIndex( 'esp_question_group', 'QSG_identifier_UNIQUE' ); |
|
362 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
363 | 363 | |
364 | 364 | $table_name = 'esp_question_group'; |
365 | - $sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
365 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
366 | 366 | QSG_name VARCHAR(255) NOT NULL, |
367 | 367 | QSG_identifier VARCHAR(100) NOT NULL, |
368 | 368 | QSG_desc TEXT NULL, |
@@ -373,29 +373,29 @@ discard block |
||
373 | 373 | QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
374 | 374 | PRIMARY KEY (QSG_ID), |
375 | 375 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
376 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
376 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
377 | 377 | |
378 | 378 | |
379 | 379 | |
380 | - $table_name='esp_question_group_question'; |
|
381 | - $sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
380 | + $table_name = 'esp_question_group_question'; |
|
381 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
382 | 382 | QSG_ID INT UNSIGNED NOT NULL, |
383 | 383 | QST_ID INT UNSIGNED NOT NULL, |
384 | 384 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
385 | 385 | PRIMARY KEY (QGQ_ID) "; |
386 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
386 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
387 | 387 | |
388 | 388 | |
389 | 389 | |
390 | - $table_name='esp_question_option'; |
|
391 | - $sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
390 | + $table_name = 'esp_question_option'; |
|
391 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
392 | 392 | QSO_value VARCHAR(255) NOT NULL, |
393 | 393 | QSO_desc TEXT NOT NULL, |
394 | 394 | QST_ID INT UNSIGNED NOT NULL, |
395 | 395 | QSO_order INT UNSIGNED NOT NULL DEFAULT 0, |
396 | 396 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
397 | 397 | PRIMARY KEY (QSO_ID)"; |
398 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
398 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
399 | 399 | |
400 | 400 | |
401 | 401 | |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | |
429 | 429 | |
430 | 430 | |
431 | - $table_name='esp_checkin'; |
|
432 | - $sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
431 | + $table_name = 'esp_checkin'; |
|
432 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
433 | 433 | REG_ID INT(10) UNSIGNED NOT NULL, |
434 | 434 | DTT_ID INT(10) UNSIGNED NOT NULL, |
435 | 435 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
504 | 504 | |
505 | 505 | |
506 | - $script_with_defaults = EE_Registry::instance()->load_dms( 'Core_4_1_0' ); |
|
506 | + $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
507 | 507 | //setting up the DEFAULT stats and countries is also essential for the data migrations to run |
508 | 508 | //(because many need to convert old string states to foreign keys into the states table) |
509 | 509 | $script_with_defaults->insert_default_states(); |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | return true; |
526 | 526 | } |
527 | 527 | |
528 | - public function migration_page_hooks(){ |
|
528 | + public function migration_page_hooks() { |
|
529 | 529 | |
530 | 530 | } |
531 | 531 | |
@@ -541,34 +541,34 @@ discard block |
||
541 | 541 | |
542 | 542 | global $wpdb; |
543 | 543 | $ticket_table = $wpdb->prefix."esp_ticket"; |
544 | - if ( $this->_get_table_analysis()->tableExists( $ticket_table ) ) { |
|
544 | + if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
545 | 545 | |
546 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
546 | + $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table; |
|
547 | 547 | $tickets_exist = $wpdb->get_var($SQL); |
548 | 548 | |
549 | - if ( ! $tickets_exist ) { |
|
549 | + if ( ! $tickets_exist) { |
|
550 | 550 | $SQL = "INSERT INTO $ticket_table |
551 | 551 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES |
552 | - ( 1, 0, '" . __("Free Ticket", "event_espresso") . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
553 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL ); |
|
552 | + ( 1, 0, '".__("Free Ticket", "event_espresso")."', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
553 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
554 | 554 | $wpdb->query($SQL); |
555 | 555 | } |
556 | 556 | } |
557 | 557 | $ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
558 | 558 | |
559 | - if ( $this->_get_table_analysis()->tableExists( $ticket_price_table ) ) { |
|
559 | + if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
560 | 560 | |
561 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
561 | + $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table; |
|
562 | 562 | $ticket_prc_exist = $wpdb->get_var($SQL); |
563 | 563 | |
564 | - if ( ! $ticket_prc_exist ) { |
|
564 | + if ( ! $ticket_prc_exist) { |
|
565 | 565 | |
566 | 566 | $SQL = "INSERT INTO $ticket_price_table |
567 | 567 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
568 | 568 | ( 1, 1, 1 ) |
569 | 569 | "; |
570 | 570 | |
571 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL ); |
|
571 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
572 | 572 | $wpdb->query($SQL); |
573 | 573 | } |
574 | 574 | } |
@@ -15,16 +15,16 @@ discard block |
||
15 | 15 | //(all other times it gets resurrected from a wordpress option) |
16 | 16 | $stages = glob(EE_CORE.'data_migration_scripts/4_5_0_stages/*'); |
17 | 17 | $class_to_filepath = array(); |
18 | -foreach($stages as $filepath){ |
|
18 | +foreach ($stages as $filepath) { |
|
19 | 19 | $matches = array(); |
20 | - preg_match('~4_5_0_stages/(.*).dmsstage.php~',$filepath,$matches); |
|
20 | + preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
21 | 21 | $class_to_filepath[$matches[1]] = $filepath; |
22 | 22 | } |
23 | 23 | //give addons a chance to autoload their stages too |
24 | -$class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages',$class_to_filepath); |
|
24 | +$class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages', $class_to_filepath); |
|
25 | 25 | EEH_Autoloader::register_autoloader($class_to_filepath); |
26 | 26 | |
27 | -class EE_DMS_Core_4_5_0 extends EE_Data_Migration_Script_Base{ |
|
27 | +class EE_DMS_Core_4_5_0 extends EE_Data_Migration_Script_Base { |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param TableManager $table_manager |
35 | 35 | * @param TableAnalysis $table_analysis |
36 | 36 | */ |
37 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
37 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
38 | 38 | $this->_pretty_name = __("Data Migration to Event Espresso 4.5.0.P", "event_espresso"); |
39 | 39 | $this->_priority = 10; |
40 | 40 | $this->_migration_stages = array( |
@@ -44,21 +44,21 @@ discard block |
||
44 | 44 | new EE_DMS_4_5_0_update_wp_user_for_question_groups(), |
45 | 45 | new EE_DMS_4_5_0_invoice_settings(), |
46 | 46 | ); |
47 | - parent::__construct( $table_manager, $table_analysis ); |
|
47 | + parent::__construct($table_manager, $table_analysis); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
51 | 51 | |
52 | 52 | public function can_migrate_from_version($version_array) { |
53 | 53 | $version_string = $version_array['Core']; |
54 | - if ( version_compare( $version_string, '4.5.0', '<=' ) && version_compare( $version_string, '4.3.0', '>=' ) ) { |
|
54 | + if (version_compare($version_string, '4.5.0', '<=') && version_compare($version_string, '4.3.0', '>=')) { |
|
55 | 55 | // echo "$version_string can be migrated from"; |
56 | 56 | return true; |
57 | - }elseif( ! $version_string ){ |
|
57 | + }elseif ( ! $version_string) { |
|
58 | 58 | // echo "no version string provided: $version_string"; |
59 | 59 | //no version string provided... this must be pre 4.3 |
60 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
61 | - }else{ |
|
60 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
61 | + } else { |
|
62 | 62 | // echo "$version_string doesnt apply"; |
63 | 63 | return false; |
64 | 64 | } |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | } |
69 | 69 | public function schema_changes_before_migration() { |
70 | 70 | //relies on 4.1's EEH_Activation::create_table |
71 | - require_once( EE_HELPERS . 'EEH_Activation.helper.php' ); |
|
72 | - $table_name='esp_answer'; |
|
73 | - $sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
71 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
72 | + $table_name = 'esp_answer'; |
|
73 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
74 | 74 | REG_ID INT UNSIGNED NOT NULL, |
75 | 75 | QST_ID INT UNSIGNED NOT NULL, |
76 | 76 | ANS_value TEXT NOT NULL, |
77 | 77 | PRIMARY KEY (ANS_ID)"; |
78 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
78 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
79 | 79 | |
80 | 80 | $table_name = 'esp_attendee_meta'; |
81 | 81 | $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | CNT_is_EU TINYINT(1) DEFAULT '0', |
115 | 115 | CNT_active TINYINT(1) DEFAULT '0', |
116 | 116 | PRIMARY KEY (CNT_ISO)"; |
117 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
117 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
118 | 118 | |
119 | 119 | $table_name = 'esp_datetime'; |
120 | 120 | $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | |
137 | 137 | |
138 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
138 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
139 | 139 | $table_name = 'esp_event_meta'; |
140 | 140 | $sql = " |
141 | 141 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
@@ -152,41 +152,41 @@ discard block |
||
152 | 152 | EVT_external_URL VARCHAR(200) NULL, |
153 | 153 | EVT_donations TINYINT(1) NULL, |
154 | 154 | PRIMARY KEY (EVTM_ID)"; |
155 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
155 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
156 | 156 | |
157 | 157 | |
158 | 158 | |
159 | - $table_name='esp_event_question_group'; |
|
160 | - $sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
159 | + $table_name = 'esp_event_question_group'; |
|
160 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
161 | 161 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
162 | 162 | QSG_ID INT UNSIGNED NOT NULL, |
163 | 163 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
164 | 164 | PRIMARY KEY (EQG_ID)"; |
165 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
165 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | |
169 | - $table_name='esp_event_venue'; |
|
170 | - $sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
169 | + $table_name = 'esp_event_venue'; |
|
170 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
171 | 171 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
172 | 172 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
173 | 173 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
174 | 174 | PRIMARY KEY (EVV_ID)"; |
175 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
175 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
176 | 176 | |
177 | 177 | |
178 | 178 | |
179 | - $table_name='esp_extra_meta'; |
|
180 | - $sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
179 | + $table_name = 'esp_extra_meta'; |
|
180 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
181 | 181 | OBJ_ID INT(11) DEFAULT NULL, |
182 | 182 | EXM_type VARCHAR(45) DEFAULT NULL, |
183 | 183 | EXM_key VARCHAR(45) DEFAULT NULL, |
184 | 184 | EXM_value TEXT, |
185 | 185 | PRIMARY KEY (EXM_ID)"; |
186 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
186 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
187 | 187 | |
188 | - $table_name='esp_line_item'; |
|
189 | - $sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
188 | + $table_name = 'esp_line_item'; |
|
189 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
190 | 190 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
191 | 191 | TXN_ID INT(11) DEFAULT NULL, |
192 | 192 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | OBJ_ID INT(11) DEFAULT NULL, |
203 | 203 | OBJ_type VARCHAR(45)DEFAULT NULL, |
204 | 204 | PRIMARY KEY (LIN_ID)"; |
205 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB' ); |
|
205 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
206 | 206 | |
207 | 207 | $table_name = 'esp_message_template'; |
208 | 208 | $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | KEY GRP_ID (GRP_ID)"; |
215 | 215 | $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
216 | 216 | |
217 | - $this->_get_table_manager()->dropIndex( 'esp_message_template_group', 'EVT_ID' ); |
|
217 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
218 | 218 | |
219 | 219 | $table_name = 'esp_message_template_group'; |
220 | 220 | $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
230 | 230 | PRIMARY KEY (GRP_ID), |
231 | 231 | KEY MTP_user_id (MTP_user_id)"; |
232 | - $this->_table_should_exist_previously( $table_name, $sql, 'ENGINE=InnoDB'); |
|
232 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
233 | 233 | |
234 | 234 | $table_name = 'esp_event_message_template'; |
235 | 235 | $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | PRIMARY KEY (EMT_ID), |
239 | 239 | KEY EVT_ID (EVT_ID), |
240 | 240 | KEY GRP_ID (GRP_ID)"; |
241 | - $this->_table_should_exist_previously( $table_name, $sql, 'ENGINE=InnoDB'); |
|
241 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
242 | 242 | |
243 | 243 | |
244 | 244 | $table_name = 'esp_payment'; |
@@ -288,8 +288,8 @@ discard block |
||
288 | 288 | PRIMARY KEY (TTM_ID)"; |
289 | 289 | $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
290 | 290 | |
291 | - $table_name='esp_question'; |
|
292 | - $sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
291 | + $table_name = 'esp_question'; |
|
292 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
293 | 293 | QST_display_text TEXT NOT NULL, |
294 | 294 | QST_admin_label VARCHAR(255) NOT NULL, |
295 | 295 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -301,27 +301,27 @@ discard block |
||
301 | 301 | QST_wp_user BIGINT UNSIGNED NULL, |
302 | 302 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
303 | 303 | PRIMARY KEY (QST_ID)'; |
304 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
304 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
305 | 305 | |
306 | - $table_name='esp_question_group_question'; |
|
307 | - $sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
306 | + $table_name = 'esp_question_group_question'; |
|
307 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
308 | 308 | QSG_ID INT UNSIGNED NOT NULL, |
309 | 309 | QST_ID INT UNSIGNED NOT NULL, |
310 | 310 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
311 | 311 | PRIMARY KEY (QGQ_ID) "; |
312 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
312 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
313 | 313 | |
314 | 314 | |
315 | 315 | |
316 | - $table_name='esp_question_option'; |
|
317 | - $sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
316 | + $table_name = 'esp_question_option'; |
|
317 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
318 | 318 | QSO_value VARCHAR(255) NOT NULL, |
319 | 319 | QSO_desc TEXT NOT NULL, |
320 | 320 | QST_ID INT UNSIGNED NOT NULL, |
321 | 321 | QSO_order INT UNSIGNED NOT NULL DEFAULT 0, |
322 | 322 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
323 | 323 | PRIMARY KEY (QSO_ID)"; |
324 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
324 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
325 | 325 | |
326 | 326 | |
327 | 327 | |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | |
355 | 355 | |
356 | 356 | |
357 | - $table_name='esp_checkin'; |
|
358 | - $sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
357 | + $table_name = 'esp_checkin'; |
|
358 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
359 | 359 | REG_ID INT(10) UNSIGNED NOT NULL, |
360 | 360 | DTT_ID INT(10) UNSIGNED NOT NULL, |
361 | 361 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | PRC_wp_user BIGINT UNSIGNED NULL, |
444 | 444 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
445 | 445 | PRIMARY KEY (PRC_ID)"; |
446 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
446 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
447 | 447 | |
448 | 448 | $table_name = "esp_price_type"; |
449 | 449 | $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -480,12 +480,12 @@ discard block |
||
480 | 480 | TKT_parent INT(10) UNSIGNED DEFAULT '0', |
481 | 481 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
482 | 482 | PRIMARY KEY (TKT_ID)"; |
483 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
483 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
484 | 484 | |
485 | - $this->_get_table_manager()->dropIndex( 'esp_question_group', 'QSG_identifier_UNIQUE' ); |
|
485 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
486 | 486 | |
487 | 487 | $table_name = 'esp_question_group'; |
488 | - $sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
488 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
489 | 489 | QSG_name VARCHAR(255) NOT NULL, |
490 | 490 | QSG_identifier VARCHAR(100) NOT NULL, |
491 | 491 | QSG_desc TEXT NULL, |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | QSG_wp_user BIGINT UNSIGNED NULL, |
498 | 498 | PRIMARY KEY (QSG_ID), |
499 | 499 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
500 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
500 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
501 | 501 | |
502 | 502 | $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
503 | 503 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | return true; |
522 | 522 | } |
523 | 523 | |
524 | - public function migration_page_hooks(){ |
|
524 | + public function migration_page_hooks() { |
|
525 | 525 | |
526 | 526 | } |
527 | 527 | |
@@ -535,21 +535,21 @@ discard block |
||
535 | 535 | global $wpdb; |
536 | 536 | $price_type_table = $wpdb->prefix."esp_price_type"; |
537 | 537 | |
538 | - if ( $this->_get_table_analysis()->tableExists( $price_type_table ) ) { |
|
538 | + if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
539 | 539 | |
540 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
541 | - $price_types_exist = $wpdb->get_var( $SQL ); |
|
540 | + $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table; |
|
541 | + $price_types_exist = $wpdb->get_var($SQL); |
|
542 | 542 | |
543 | - if ( ! $price_types_exist ) { |
|
543 | + if ( ! $price_types_exist) { |
|
544 | 544 | $user_id = EEH_Activation::get_default_creator_id(); |
545 | 545 | $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES |
546 | - (1, '" . __('Base Price', 'event_espresso') . "', 1, 0, 0, $user_id, 0), |
|
547 | - (2, '" . __('Percent Discount', 'event_espresso') . "', 2, 1, 20, $user_id, 0), |
|
548 | - (3, '" . __('Dollar Discount', 'event_espresso') . "', 2, 0, 30, $user_id, 0), |
|
549 | - (4, '" . __('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, $user_id, 0), |
|
550 | - (5, '" . __('Dollar Surcharge', 'event_espresso') . "', 3, 0, 50, $user_id, 0);"; |
|
551 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL ); |
|
552 | - $wpdb->query( $SQL ); |
|
546 | + (1, '".__('Base Price', 'event_espresso')."', 1, 0, 0, $user_id, 0), |
|
547 | + (2, '".__('Percent Discount', 'event_espresso')."', 2, 1, 20, $user_id, 0), |
|
548 | + (3, '".__('Dollar Discount', 'event_espresso')."', 2, 0, 30, $user_id, 0), |
|
549 | + (4, '".__('Percent Surcharge', 'event_espresso')."', 3, 1, 40, $user_id, 0), |
|
550 | + (5, '".__('Dollar Surcharge', 'event_espresso')."', 3, 0, 50, $user_id, 0);"; |
|
551 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL); |
|
552 | + $wpdb->query($SQL); |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | } |
@@ -569,17 +569,17 @@ discard block |
||
569 | 569 | global $wpdb; |
570 | 570 | $price_table = $wpdb->prefix."esp_price"; |
571 | 571 | |
572 | - if ( $this->_get_table_analysis()->tableExists( $price_table ) ) { |
|
572 | + if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
573 | 573 | |
574 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' .$price_table; |
|
575 | - $prices_exist = $wpdb->get_var( $SQL ); |
|
574 | + $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table; |
|
575 | + $prices_exist = $wpdb->get_var($SQL); |
|
576 | 576 | |
577 | - if ( ! $prices_exist ) { |
|
577 | + if ( ! $prices_exist) { |
|
578 | 578 | $user_id = EEH_Activation::get_default_creator_id(); |
579 | 579 | $SQL = "INSERT INTO $price_table |
580 | 580 | (PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc, PRC_is_default, PRC_overrides, PRC_wp_user, PRC_order, PRC_deleted, PRC_parent ) VALUES |
581 | 581 | (1, 1, '0.00', 'Free Admission', '', 1, NULL, $user_id, 0, 0, 0);"; |
582 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL ); |
|
582 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL); |
|
583 | 583 | $wpdb->query($SQL); |
584 | 584 | } |
585 | 585 | } |
@@ -597,35 +597,35 @@ discard block |
||
597 | 597 | |
598 | 598 | global $wpdb; |
599 | 599 | $ticket_table = $wpdb->prefix."esp_ticket"; |
600 | - if ( $this->_get_table_analysis()->tableExists( $ticket_table ) ) { |
|
600 | + if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
601 | 601 | |
602 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
602 | + $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table; |
|
603 | 603 | $tickets_exist = $wpdb->get_var($SQL); |
604 | 604 | |
605 | - if ( ! $tickets_exist ) { |
|
605 | + if ( ! $tickets_exist) { |
|
606 | 606 | $user_id = EEH_Activation::get_default_creator_id(); |
607 | 607 | $SQL = "INSERT INTO $ticket_table |
608 | 608 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_wp_user, TKT_deleted ) VALUES |
609 | - ( 1, 0, '" . __("Free Ticket", "event_espresso") . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);"; |
|
610 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL ); |
|
609 | + ( 1, 0, '".__("Free Ticket", "event_espresso")."', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);"; |
|
610 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL); |
|
611 | 611 | $wpdb->query($SQL); |
612 | 612 | } |
613 | 613 | } |
614 | 614 | $ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
615 | 615 | |
616 | - if ( $this->_get_table_analysis()->tableExists( $ticket_price_table ) ) { |
|
616 | + if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
617 | 617 | |
618 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
618 | + $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table; |
|
619 | 619 | $ticket_prc_exist = $wpdb->get_var($SQL); |
620 | 620 | |
621 | - if ( ! $ticket_prc_exist ) { |
|
621 | + if ( ! $ticket_prc_exist) { |
|
622 | 622 | |
623 | 623 | $SQL = "INSERT INTO $ticket_price_table |
624 | 624 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
625 | 625 | ( 1, 1, 1 ) |
626 | 626 | "; |
627 | 627 | |
628 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL ); |
|
628 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
629 | 629 | $wpdb->query($SQL); |
630 | 630 | } |
631 | 631 | } |
@@ -11,15 +11,15 @@ discard block |
||
11 | 11 | //(all other times it gets resurrected from a wordpress option) |
12 | 12 | $stages = glob(EE_CORE.'data_migration_scripts/4_1_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | -if ( ! empty( $stages ) ) { |
|
15 | - foreach($stages as $filepath){ |
|
14 | +if ( ! empty($stages)) { |
|
15 | + foreach ($stages as $filepath) { |
|
16 | 16 | $matches = array(); |
17 | - preg_match('~4_1_0_stages/(.*).dmsstage.php~',$filepath,$matches); |
|
17 | + preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
18 | 18 | $class_to_filepath[$matches[1]] = $filepath; |
19 | 19 | } |
20 | 20 | } |
21 | 21 | //give addons a chance to autoload their stages too |
22 | -$class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages',$class_to_filepath); |
|
22 | +$class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages', $class_to_filepath); |
|
23 | 23 | EEH_Autoloader::register_autoloader($class_to_filepath); |
24 | 24 | |
25 | 25 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * --a function named update_espresso_config() which saves the EE_Config object to the database |
38 | 38 | * --...and all its subclasses... really, you're best off copying the whole thing when 4.1 is released into this file and wrapping its declaration in if( ! class_exists()){...} |
39 | 39 | */ |
40 | -class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base{ |
|
40 | +class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base { |
|
41 | 41 | |
42 | 42 | |
43 | 43 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param TableManager $table_manager |
48 | 48 | * @param TableAnalysis $table_analysis |
49 | 49 | */ |
50 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
50 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
51 | 51 | $this->_pretty_name = __("Data Migration to Event Espresso 4.1.0P", "event_espresso"); |
52 | 52 | $this->_priority = 10; |
53 | 53 | $this->_migration_stages = array( |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | new EE_DMS_4_1_0_answers(), |
70 | 70 | new EE_DMS_4_1_0_checkins(), |
71 | 71 | ); |
72 | - parent::__construct( $table_manager, $table_analysis ); |
|
72 | + parent::__construct($table_manager, $table_analysis); |
|
73 | 73 | } |
74 | 74 | /** |
75 | 75 | * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins |
@@ -77,27 +77,27 @@ discard block |
||
77 | 77 | * @global wpdb $wpdb |
78 | 78 | * @return boolean |
79 | 79 | */ |
80 | - private function _checkin_table_exists(){ |
|
80 | + private function _checkin_table_exists() { |
|
81 | 81 | global $wpdb; |
82 | 82 | $results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'"); |
83 | - if($results){ |
|
83 | + if ($results) { |
|
84 | 84 | return true; |
85 | - }else{ |
|
85 | + } else { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | 90 | public function can_migrate_from_version($version_array) { |
91 | 91 | $version_string = $version_array['Core']; |
92 | - if ( version_compare( $version_string, '4.0.0', '<=' ) && version_compare( $version_string, '3.1.26', '>=' ) ) { |
|
92 | + if (version_compare($version_string, '4.0.0', '<=') && version_compare($version_string, '3.1.26', '>=')) { |
|
93 | 93 | // echo "$version_string can be migrated fro"; |
94 | 94 | return true; |
95 | - }elseif( ! $version_string ){ |
|
95 | + }elseif ( ! $version_string) { |
|
96 | 96 | // echo "no version string provided: $version_string"; |
97 | 97 | //no version string provided... this must be pre 4.1 |
98 | 98 | //because since 4.1 we're |
99 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
100 | - }else{ |
|
99 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
100 | + } else { |
|
101 | 101 | // echo "$version_string doesnt apply"; |
102 | 102 | return false; |
103 | 103 | } |
@@ -107,15 +107,15 @@ discard block |
||
107 | 107 | } |
108 | 108 | public function schema_changes_before_migration() { |
109 | 109 | //relies on 4.1's EEH_Activation::create_table |
110 | - require_once( EE_HELPERS . 'EEH_Activation.helper.php' ); |
|
110 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
111 | 111 | |
112 | - $table_name='esp_answer'; |
|
113 | - $sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
112 | + $table_name = 'esp_answer'; |
|
113 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
114 | 114 | REG_ID INT UNSIGNED NOT NULL, |
115 | 115 | QST_ID INT UNSIGNED NOT NULL, |
116 | 116 | ANS_value TEXT NOT NULL, |
117 | 117 | PRIMARY KEY (ANS_ID)"; |
118 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
118 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
119 | 119 | |
120 | 120 | $table_name = 'esp_attendee_meta'; |
121 | 121 | $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | CNT_is_EU TINYINT(1) DEFAULT '0', |
156 | 156 | CNT_active TINYINT(1) DEFAULT '0', |
157 | 157 | PRIMARY KEY (CNT_ISO)"; |
158 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
158 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
159 | 159 | |
160 | 160 | |
161 | 161 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | |
178 | 178 | |
179 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
179 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
180 | 180 | $table_name = 'esp_event_meta'; |
181 | 181 | $sql = " |
182 | 182 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
@@ -193,41 +193,41 @@ discard block |
||
193 | 193 | EVT_external_URL VARCHAR(200) NULL, |
194 | 194 | EVT_donations TINYINT(1) NULL, |
195 | 195 | PRIMARY KEY (EVTM_ID)"; |
196 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
196 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
197 | 197 | |
198 | 198 | |
199 | 199 | |
200 | - $table_name='esp_event_question_group'; |
|
201 | - $sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
200 | + $table_name = 'esp_event_question_group'; |
|
201 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
202 | 202 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
203 | 203 | QSG_ID INT UNSIGNED NOT NULL, |
204 | 204 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
205 | 205 | PRIMARY KEY (EQG_ID)"; |
206 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
206 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
207 | 207 | |
208 | 208 | |
209 | 209 | |
210 | - $table_name='esp_event_venue'; |
|
211 | - $sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
210 | + $table_name = 'esp_event_venue'; |
|
211 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
212 | 212 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
213 | 213 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
214 | 214 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
215 | 215 | PRIMARY KEY (EVV_ID)"; |
216 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
216 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
217 | 217 | |
218 | 218 | |
219 | 219 | |
220 | - $table_name='esp_extra_meta'; |
|
221 | - $sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
220 | + $table_name = 'esp_extra_meta'; |
|
221 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
222 | 222 | OBJ_ID INT(11) DEFAULT NULL, |
223 | 223 | EXM_type VARCHAR(45) DEFAULT NULL, |
224 | 224 | EXM_key VARCHAR(45) DEFAULT NULL, |
225 | 225 | EXM_value TEXT, |
226 | 226 | PRIMARY KEY (EXM_ID)"; |
227 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
227 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
228 | 228 | |
229 | - $table_name='esp_line_item'; |
|
230 | - $sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
229 | + $table_name = 'esp_line_item'; |
|
230 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
231 | 231 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
232 | 232 | TXN_ID INT(11) DEFAULT NULL, |
233 | 233 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | OBJ_ID INT(11) DEFAULT NULL, |
244 | 244 | OBJ_type VARCHAR(45)DEFAULT NULL, |
245 | 245 | PRIMARY KEY (LIN_ID)"; |
246 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB' ); |
|
246 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
247 | 247 | |
248 | 248 | $table_name = 'esp_message_template'; |
249 | 249 | $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | PRIMARY KEY (GRP_ID), |
271 | 271 | KEY EVT_ID (EVT_ID), |
272 | 272 | KEY MTP_user_id (MTP_user_id)"; |
273 | - $this->_table_is_new_in_this_version( $table_name, $sql, 'ENGINE=InnoDB'); |
|
273 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
274 | 274 | |
275 | 275 | |
276 | 276 | |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | |
379 | 379 | |
380 | 380 | |
381 | - $table_name='esp_question'; |
|
382 | - $sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
381 | + $table_name = 'esp_question'; |
|
382 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
383 | 383 | QST_display_text TEXT NOT NULL, |
384 | 384 | QST_admin_label VARCHAR(255) NOT NULL, |
385 | 385 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -391,12 +391,12 @@ discard block |
||
391 | 391 | QST_wp_user BIGINT UNSIGNED NULL, |
392 | 392 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
393 | 393 | PRIMARY KEY (QST_ID)'; |
394 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
394 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
395 | 395 | |
396 | - $this->_get_table_manager()->dropIndex( 'esp_question_group', 'QSG_identifier_UNIQUE' ); |
|
396 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
397 | 397 | |
398 | 398 | $table_name = 'esp_question_group'; |
399 | - $sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
399 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
400 | 400 | QSG_name VARCHAR(255) NOT NULL, |
401 | 401 | QSG_identifier VARCHAR(100) NOT NULL, |
402 | 402 | QSG_desc TEXT NULL, |
@@ -407,27 +407,27 @@ discard block |
||
407 | 407 | QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
408 | 408 | PRIMARY KEY (QSG_ID), |
409 | 409 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
410 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
410 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
411 | 411 | |
412 | 412 | |
413 | 413 | |
414 | - $table_name='esp_question_group_question'; |
|
415 | - $sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
414 | + $table_name = 'esp_question_group_question'; |
|
415 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
416 | 416 | QSG_ID INT UNSIGNED NOT NULL, |
417 | 417 | QST_ID INT UNSIGNED NOT NULL, |
418 | 418 | PRIMARY KEY (QGQ_ID) "; |
419 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
419 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
420 | 420 | |
421 | 421 | |
422 | 422 | |
423 | - $table_name='esp_question_option'; |
|
424 | - $sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
423 | + $table_name = 'esp_question_option'; |
|
424 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
425 | 425 | QSO_value VARCHAR(255) NOT NULL, |
426 | 426 | QSO_desc TEXT NOT NULL, |
427 | 427 | QST_ID INT UNSIGNED NOT NULL, |
428 | 428 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
429 | 429 | PRIMARY KEY (QSO_ID)"; |
430 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
430 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
431 | 431 | |
432 | 432 | |
433 | 433 | |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | |
461 | 461 | |
462 | 462 | |
463 | - $table_name='esp_checkin'; |
|
464 | - $sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
463 | + $table_name = 'esp_checkin'; |
|
464 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
465 | 465 | REG_ID INT(10) UNSIGNED NOT NULL, |
466 | 466 | DTT_ID INT(10) UNSIGNED NOT NULL, |
467 | 467 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -568,12 +568,12 @@ discard block |
||
568 | 568 | |
569 | 569 | global $wpdb; |
570 | 570 | $state_table = $wpdb->prefix."esp_state"; |
571 | - if ( $this->_get_table_analysis()->tableExists( $state_table ) ) { |
|
571 | + if ($this->_get_table_analysis()->tableExists($state_table)) { |
|
572 | 572 | |
573 | - $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table; |
|
573 | + $SQL = "SELECT COUNT('STA_ID') FROM ".$state_table; |
|
574 | 574 | $states = $wpdb->get_var($SQL); |
575 | - if ( ! $states ) { |
|
576 | - $SQL = "INSERT INTO " . $state_table . " |
|
575 | + if ( ! $states) { |
|
576 | + $SQL = "INSERT INTO ".$state_table." |
|
577 | 577 | (STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES |
578 | 578 | (1, 'US', 'AK', 'Alaska', 1), |
579 | 579 | (2, 'US', 'AL', 'Alabama', 1), |
@@ -660,12 +660,12 @@ discard block |
||
660 | 660 | |
661 | 661 | global $wpdb; |
662 | 662 | $country_table = $wpdb->prefix."esp_country"; |
663 | - if ( $this->_get_table_analysis()->tableExists( $country_table ) ) { |
|
663 | + if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
664 | 664 | |
665 | - $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table; |
|
665 | + $SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table; |
|
666 | 666 | $countries = $wpdb->get_var($SQL); |
667 | - if ( ! $countries ) { |
|
668 | - $SQL = "INSERT INTO " . $country_table . " |
|
667 | + if ( ! $countries) { |
|
668 | + $SQL = "INSERT INTO ".$country_table." |
|
669 | 669 | (CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES |
670 | 670 | ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
671 | 671 | ('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0), |
@@ -912,20 +912,20 @@ discard block |
||
912 | 912 | global $wpdb; |
913 | 913 | $price_type_table = $wpdb->prefix."esp_price_type"; |
914 | 914 | |
915 | - if ( $this->_get_table_analysis()->tableExists( $price_type_table ) ) { |
|
915 | + if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
916 | 916 | |
917 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
918 | - $price_types_exist = $wpdb->get_var( $SQL ); |
|
917 | + $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table; |
|
918 | + $price_types_exist = $wpdb->get_var($SQL); |
|
919 | 919 | |
920 | - if ( ! $price_types_exist ) { |
|
920 | + if ( ! $price_types_exist) { |
|
921 | 921 | $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES |
922 | - (1, '" . __('Base Price', 'event_espresso') . "', 1, 0, 0, 0), |
|
923 | - (2, '" . __('Percent Discount', 'event_espresso') . "', 2, 1, 20, 0), |
|
924 | - (3, '" . __('Fixed Discount', 'event_espresso') . "', 2, 0, 30, 0), |
|
925 | - (4, '" . __('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, 0), |
|
926 | - (5, '" . __('Fixed Surcharge', 'event_espresso') . "', 3, 0, 50, 0);"; |
|
927 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL ); |
|
928 | - $wpdb->query( $SQL ); |
|
922 | + (1, '".__('Base Price', 'event_espresso')."', 1, 0, 0, 0), |
|
923 | + (2, '" . __('Percent Discount', 'event_espresso')."', 2, 1, 20, 0), |
|
924 | + (3, '" . __('Fixed Discount', 'event_espresso')."', 2, 0, 30, 0), |
|
925 | + (4, '" . __('Percent Surcharge', 'event_espresso')."', 3, 1, 40, 0), |
|
926 | + (5, '" . __('Fixed Surcharge', 'event_espresso')."', 3, 0, 50, 0);"; |
|
927 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL); |
|
928 | + $wpdb->query($SQL); |
|
929 | 929 | } |
930 | 930 | } |
931 | 931 | } |
@@ -945,16 +945,16 @@ discard block |
||
945 | 945 | global $wpdb; |
946 | 946 | $price_table = $wpdb->prefix."esp_price"; |
947 | 947 | |
948 | - if ( $this->_get_table_analysis()->tableExists( $price_table ) ) { |
|
948 | + if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
949 | 949 | |
950 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' .$price_table; |
|
951 | - $prices_exist = $wpdb->get_var( $SQL ); |
|
950 | + $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table; |
|
951 | + $prices_exist = $wpdb->get_var($SQL); |
|
952 | 952 | |
953 | - if ( ! $prices_exist ) { |
|
953 | + if ( ! $prices_exist) { |
|
954 | 954 | $SQL = "INSERT INTO $price_table |
955 | 955 | (PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc, PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES |
956 | 956 | (1, 1, '0.00', 'Free Admission', '', 1, NULL, 0, 0, 0);"; |
957 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL ); |
|
957 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL); |
|
958 | 958 | $wpdb->query($SQL); |
959 | 959 | } |
960 | 960 | } |
@@ -971,34 +971,34 @@ discard block |
||
971 | 971 | |
972 | 972 | global $wpdb; |
973 | 973 | $ticket_table = $wpdb->prefix."esp_ticket"; |
974 | - if ( $this->_get_table_analysis()->tableExists( $ticket_table ) ) { |
|
974 | + if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
975 | 975 | |
976 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
976 | + $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table; |
|
977 | 977 | $tickets_exist = $wpdb->get_var($SQL); |
978 | 978 | |
979 | - if ( ! $tickets_exist ) { |
|
979 | + if ( ! $tickets_exist) { |
|
980 | 980 | $SQL = "INSERT INTO $ticket_table |
981 | 981 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES |
982 | - ( 1, 0, '" . __("Free Ticket", "event_espresso") . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
983 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL ); |
|
982 | + ( 1, 0, '".__("Free Ticket", "event_espresso")."', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
983 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
984 | 984 | $wpdb->query($SQL); |
985 | 985 | } |
986 | 986 | } |
987 | 987 | $ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
988 | 988 | |
989 | - if ( $this->_get_table_analysis()->tableExists( $ticket_price_table ) ) { |
|
989 | + if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
990 | 990 | |
991 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
991 | + $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table; |
|
992 | 992 | $ticket_prc_exist = $wpdb->get_var($SQL); |
993 | 993 | |
994 | - if ( ! $ticket_prc_exist ) { |
|
994 | + if ( ! $ticket_prc_exist) { |
|
995 | 995 | |
996 | 996 | $SQL = "INSERT INTO $ticket_price_table |
997 | 997 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
998 | 998 | ( 1, 1, 1 ) |
999 | 999 | "; |
1000 | 1000 | |
1001 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL ); |
|
1001 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
1002 | 1002 | $wpdb->query($SQL); |
1003 | 1003 | } |
1004 | 1004 | } |
@@ -1011,20 +1011,20 @@ discard block |
||
1011 | 1011 | * @param string $country_name |
1012 | 1012 | * @return array where keys are columns, values are column values |
1013 | 1013 | */ |
1014 | - public function get_or_create_country($country_name){ |
|
1015 | - if( ! $country_name ){ |
|
1014 | + public function get_or_create_country($country_name) { |
|
1015 | + if ( ! $country_name) { |
|
1016 | 1016 | throw new EE_Error(__("Could not get a country because country name is blank", "event_espresso")); |
1017 | 1017 | } |
1018 | 1018 | global $wpdb; |
1019 | 1019 | $country_table = $wpdb->prefix."esp_country"; |
1020 | - if(is_int($country_name)){ |
|
1020 | + if (is_int($country_name)) { |
|
1021 | 1021 | $country_name = $this->get_iso_from_3_1_country_id($country_name); |
1022 | 1022 | } |
1023 | 1023 | $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE |
1024 | 1024 | CNT_ISO LIKE %s OR |
1025 | 1025 | CNT_ISO3 LIKE %s OR |
1026 | - CNT_name LIKE %s LIMIT 1",$country_name,$country_name,$country_name),ARRAY_A); |
|
1027 | - if( ! $country ){ |
|
1026 | + CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A); |
|
1027 | + if ( ! $country) { |
|
1028 | 1028 | //insert a new one then |
1029 | 1029 | $cols_n_values = array( |
1030 | 1030 | 'CNT_ISO'=> $this->_find_available_country_iso(2), |
@@ -1044,26 +1044,26 @@ discard block |
||
1044 | 1044 | 'CNT_active'=>true |
1045 | 1045 | ); |
1046 | 1046 | $data_types = array( |
1047 | - '%s',//CNT_ISO |
|
1048 | - '%s',//CNT_ISO3 |
|
1049 | - '%d',//RGN_ID |
|
1050 | - '%s',//CNT_name |
|
1051 | - '%s',//CNT_cur_code |
|
1052 | - '%s',//CNT_cur_single |
|
1053 | - '%s',//CNT_cur_plural |
|
1054 | - '%s',//CNT_cur_sign |
|
1055 | - '%d',//CNT_cur_sign_b4 |
|
1056 | - '%d',//CNT_cur_dec_plc |
|
1057 | - '%s',//CNT_cur_dec_mrk |
|
1058 | - '%s',//CNT_cur_thsnds |
|
1059 | - '%s',//CNT_tel_code |
|
1060 | - '%d',//CNT_is_EU |
|
1061 | - '%d',//CNT_active |
|
1047 | + '%s', //CNT_ISO |
|
1048 | + '%s', //CNT_ISO3 |
|
1049 | + '%d', //RGN_ID |
|
1050 | + '%s', //CNT_name |
|
1051 | + '%s', //CNT_cur_code |
|
1052 | + '%s', //CNT_cur_single |
|
1053 | + '%s', //CNT_cur_plural |
|
1054 | + '%s', //CNT_cur_sign |
|
1055 | + '%d', //CNT_cur_sign_b4 |
|
1056 | + '%d', //CNT_cur_dec_plc |
|
1057 | + '%s', //CNT_cur_dec_mrk |
|
1058 | + '%s', //CNT_cur_thsnds |
|
1059 | + '%s', //CNT_tel_code |
|
1060 | + '%d', //CNT_is_EU |
|
1061 | + '%d', //CNT_active |
|
1062 | 1062 | ); |
1063 | 1063 | $success = $wpdb->insert($country_table, |
1064 | 1064 | $cols_n_values, |
1065 | 1065 | $data_types); |
1066 | - if( ! $success){ |
|
1066 | + if ( ! $success) { |
|
1067 | 1067 | throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('country_id'=>$country_name), $country_table, $cols_n_values, $data_types)); |
1068 | 1068 | } |
1069 | 1069 | $country = $cols_n_values; |
@@ -1075,13 +1075,13 @@ discard block |
||
1075 | 1075 | * @global type $wpdb |
1076 | 1076 | * @return string |
1077 | 1077 | */ |
1078 | - private function _find_available_country_iso($num_letters = 2){ |
|
1078 | + private function _find_available_country_iso($num_letters = 2) { |
|
1079 | 1079 | global $wpdb; |
1080 | 1080 | $country_table = $wpdb->prefix."esp_country"; |
1081 | - do{ |
|
1081 | + do { |
|
1082 | 1082 | $current_iso = strtoupper(wp_generate_password($num_letters, false)); |
1083 | - $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s",$current_iso)); |
|
1084 | - }while(intval($country_with_that_iso)); |
|
1083 | + $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s", $current_iso)); |
|
1084 | + }while (intval($country_with_that_iso)); |
|
1085 | 1085 | return $current_iso; |
1086 | 1086 | } |
1087 | 1087 | |
@@ -1092,14 +1092,14 @@ discard block |
||
1092 | 1092 | * @param string $state_name |
1093 | 1093 | * @return array where keys are columns, values are column values |
1094 | 1094 | */ |
1095 | - public function get_or_create_state($state_name,$country_name = ''){ |
|
1096 | - if( ! $state_name ){ |
|
1095 | + public function get_or_create_state($state_name, $country_name = '') { |
|
1096 | + if ( ! $state_name) { |
|
1097 | 1097 | throw new EE_Error(__("Could not get-or-create state because no state name was provided", "event_espresso")); |
1098 | 1098 | } |
1099 | - try{ |
|
1099 | + try { |
|
1100 | 1100 | $country = $this->get_or_create_country($country_name); |
1101 | 1101 | $country_iso = $country['CNT_ISO']; |
1102 | - }catch(EE_Error $e){ |
|
1102 | + } catch (EE_Error $e) { |
|
1103 | 1103 | $country_iso = $this->get_default_country_iso(); |
1104 | 1104 | } |
1105 | 1105 | global $wpdb; |
@@ -1107,24 +1107,24 @@ discard block |
||
1107 | 1107 | $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE |
1108 | 1108 | (STA_abbrev LIKE %s OR |
1109 | 1109 | STA_name LIKE %s) AND |
1110 | - CNT_ISO LIKE %s LIMIT 1",$state_name,$state_name,$country_iso),ARRAY_A); |
|
1111 | - if ( ! $state){ |
|
1110 | + CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A); |
|
1111 | + if ( ! $state) { |
|
1112 | 1112 | //insert a new one then |
1113 | 1113 | $cols_n_values = array( |
1114 | 1114 | 'CNT_ISO'=>$country_iso, |
1115 | - 'STA_abbrev'=>substr($state_name,0,6), |
|
1115 | + 'STA_abbrev'=>substr($state_name, 0, 6), |
|
1116 | 1116 | 'STA_name'=>$state_name, |
1117 | 1117 | 'STA_active'=>true |
1118 | 1118 | ); |
1119 | 1119 | $data_types = array( |
1120 | - '%s',//CNT_ISO |
|
1121 | - '%s',//STA_abbrev |
|
1122 | - '%s',//STA_name |
|
1123 | - '%d',//STA_active |
|
1120 | + '%s', //CNT_ISO |
|
1121 | + '%s', //STA_abbrev |
|
1122 | + '%s', //STA_name |
|
1123 | + '%d', //STA_active |
|
1124 | 1124 | ); |
1125 | - $success = $wpdb->insert($state_table,$cols_n_values,$data_types); |
|
1126 | - if ( ! $success ){ |
|
1127 | - throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name,'country_id'=>$country_name), $state_table, $cols_n_values, $data_types)); |
|
1125 | + $success = $wpdb->insert($state_table, $cols_n_values, $data_types); |
|
1126 | + if ( ! $success) { |
|
1127 | + throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name, 'country_id'=>$country_name), $state_table, $cols_n_values, $data_types)); |
|
1128 | 1128 | } |
1129 | 1129 | $state = $cols_n_values; |
1130 | 1130 | $state['STA_ID'] = $wpdb->insert_id; |
@@ -1137,21 +1137,21 @@ discard block |
||
1137 | 1137 | * @param type $timeString |
1138 | 1138 | * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes with leading zeros) |
1139 | 1139 | */ |
1140 | - public function convertTimeFromAMPM($timeString){ |
|
1140 | + public function convertTimeFromAMPM($timeString) { |
|
1141 | 1141 | $matches = array(); |
1142 | - preg_match("~(\\d*):(\\d*)~",$timeString,$matches); |
|
1143 | - if( ! $matches || count($matches)<3){ |
|
1142 | + preg_match("~(\\d*):(\\d*)~", $timeString, $matches); |
|
1143 | + if ( ! $matches || count($matches) < 3) { |
|
1144 | 1144 | $hour = '00'; |
1145 | 1145 | $minutes = '00'; |
1146 | - }else{ |
|
1146 | + } else { |
|
1147 | 1147 | $hour = intval($matches[1]); |
1148 | 1148 | $minutes = $matches[2]; |
1149 | 1149 | } |
1150 | - if(strpos($timeString, 'PM') || strpos($timeString, 'pm')){ |
|
1150 | + if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) { |
|
1151 | 1151 | $hour = intval($hour) + 12; |
1152 | 1152 | } |
1153 | - $hour = str_pad( "$hour", 2, '0',STR_PAD_LEFT); |
|
1154 | - $minutes = str_pad( "$minutes", 2, '0',STR_PAD_LEFT); |
|
1153 | + $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT); |
|
1154 | + $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT); |
|
1155 | 1155 | return "$hour:$minutes"; |
1156 | 1156 | } |
1157 | 1157 | |
@@ -1160,7 +1160,7 @@ discard block |
||
1160 | 1160 | * @param int $country_id |
1161 | 1161 | * @return string the country's ISO3 code |
1162 | 1162 | */ |
1163 | - public function get_iso_from_3_1_country_id($country_id){ |
|
1163 | + public function get_iso_from_3_1_country_id($country_id) { |
|
1164 | 1164 | $old_countries = array( |
1165 | 1165 | array(64, 'United States', 'US', 'USA', 1), |
1166 | 1166 | array(15, 'Australia', 'AU', 'AUS', 1), |
@@ -1386,9 +1386,9 @@ discard block |
||
1386 | 1386 | array(226, 'Zimbabwe', 'ZW', 'ZWE', 1)); |
1387 | 1387 | |
1388 | 1388 | $country_iso = 'US'; |
1389 | - foreach($old_countries as $country_array){ |
|
1389 | + foreach ($old_countries as $country_array) { |
|
1390 | 1390 | //note: index 0 is the 3.1 country ID |
1391 | - if($country_array[0] == $country_id){ |
|
1391 | + if ($country_array[0] == $country_id) { |
|
1392 | 1392 | //note: index 2 is the ISO |
1393 | 1393 | $country_iso = $country_array[2]; |
1394 | 1394 | break; |
@@ -1401,8 +1401,8 @@ discard block |
||
1401 | 1401 | * Gets the ISO3 for the |
1402 | 1402 | * @return string |
1403 | 1403 | */ |
1404 | - public function get_default_country_iso(){ |
|
1405 | - $old_org_options= get_option('events_organization_settings'); |
|
1404 | + public function get_default_country_iso() { |
|
1405 | + $old_org_options = get_option('events_organization_settings'); |
|
1406 | 1406 | $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']); |
1407 | 1407 | return $iso; |
1408 | 1408 | } |
@@ -1414,13 +1414,13 @@ discard block |
||
1414 | 1414 | * the event's DEFAULT payment status, or the attendee's payment status) required pre-approval. |
1415 | 1415 | * @return string STS_ID for use in 4.1 |
1416 | 1416 | */ |
1417 | - public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false){ |
|
1417 | + public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false) { |
|
1418 | 1418 | |
1419 | 1419 | //EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455 |
1420 | - if($this_thing_required_pre_approval){ |
|
1420 | + if ($this_thing_required_pre_approval) { |
|
1421 | 1421 | return 'RNA'; |
1422 | - }else{ |
|
1423 | - $mapping = $default_reg_stati_conversions=array( |
|
1422 | + } else { |
|
1423 | + $mapping = $default_reg_stati_conversions = array( |
|
1424 | 1424 | 'Completed'=>'RAP', |
1425 | 1425 | ''=>'RPP', |
1426 | 1426 | 'Incomplete'=>'RPP', |
@@ -1450,22 +1450,22 @@ discard block |
||
1450 | 1450 | * @param EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added |
1451 | 1451 | * @return boolean whether or not we had to do the big job of creating an image attachment |
1452 | 1452 | */ |
1453 | - public function convert_image_url_to_attachment_and_attach_to_post($guid,$new_cpt_id, EE_Data_Migration_Script_Stage $migration_stage){ |
|
1453 | + public function convert_image_url_to_attachment_and_attach_to_post($guid, $new_cpt_id, EE_Data_Migration_Script_Stage $migration_stage) { |
|
1454 | 1454 | $created_attachment_post = false; |
1455 | 1455 | $guid = $this->_get_original_guid($guid); |
1456 | - if($guid){ |
|
1456 | + if ($guid) { |
|
1457 | 1457 | //check for an existing attachment post with this guid |
1458 | 1458 | $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid); |
1459 | - if( ! $attachment_post_id){ |
|
1459 | + if ( ! $attachment_post_id) { |
|
1460 | 1460 | //post thumbnail with that GUID doesn't exist, we should create one |
1461 | 1461 | $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage); |
1462 | 1462 | $created_attachment_post = true; |
1463 | 1463 | } |
1464 | 1464 | //double-check we actually have an attachment post |
1465 | - if( $attachment_post_id){ |
|
1466 | - update_post_meta($new_cpt_id,'_thumbnail_id',$attachment_post_id); |
|
1467 | - }else{ |
|
1468 | - $migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"),$guid,$new_cpt_id,$attachment_post_id)); |
|
1465 | + if ($attachment_post_id) { |
|
1466 | + update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id); |
|
1467 | + } else { |
|
1468 | + $migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"), $guid, $new_cpt_id, $attachment_post_id)); |
|
1469 | 1469 | } |
1470 | 1470 | } |
1471 | 1471 | return $created_attachment_post; |
@@ -1479,13 +1479,13 @@ discard block |
||
1479 | 1479 | * @param string $guid_in_old_event |
1480 | 1480 | * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was |
1481 | 1481 | */ |
1482 | - private function _get_original_guid($guid_in_old_event){ |
|
1483 | - $original_guid = preg_replace('~-\d*x\d*\.~','.',$guid_in_old_event,1); |
|
1482 | + private function _get_original_guid($guid_in_old_event) { |
|
1483 | + $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1); |
|
1484 | 1484 | //do a head request to verify the file exists |
1485 | 1485 | $head_response = wp_remote_head($original_guid); |
1486 | - if( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK'){ |
|
1486 | + if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') { |
|
1487 | 1487 | return $original_guid; |
1488 | - }else{ |
|
1488 | + } else { |
|
1489 | 1489 | return $guid_in_old_event; |
1490 | 1490 | } |
1491 | 1491 | } |
@@ -1497,32 +1497,32 @@ discard block |
||
1497 | 1497 | * @param EE_Data_Migration_Script_Stage $migration_stage |
1498 | 1498 | * @return int |
1499 | 1499 | */ |
1500 | - private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage){ |
|
1501 | - if ( ! $guid){ |
|
1500 | + private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage) { |
|
1501 | + if ( ! $guid) { |
|
1502 | 1502 | $migration_stage->add_error(sprintf(__("Cannot create image attachment for a blank GUID!", "event_espresso"))); |
1503 | 1503 | return 0; |
1504 | 1504 | } |
1505 | - $wp_filetype = wp_check_filetype(basename($guid), null ); |
|
1505 | + $wp_filetype = wp_check_filetype(basename($guid), null); |
|
1506 | 1506 | $wp_upload_dir = wp_upload_dir(); |
1507 | 1507 | //if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local |
1508 | - if(strpos($guid,$wp_upload_dir['url']) === FALSE){ |
|
1508 | + if (strpos($guid, $wp_upload_dir['url']) === FALSE) { |
|
1509 | 1509 | //image is located remotely. download it and place it in the uploads directory |
1510 | - if( ! is_readable($guid)){ |
|
1511 | - $migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"),$guid)); |
|
1510 | + if ( ! is_readable($guid)) { |
|
1511 | + $migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"), $guid)); |
|
1512 | 1512 | return 0; |
1513 | 1513 | } |
1514 | - $contents= file_get_contents($guid); |
|
1515 | - if($contents === FALSE){ |
|
1516 | - $migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"),$guid)); |
|
1514 | + $contents = file_get_contents($guid); |
|
1515 | + if ($contents === FALSE) { |
|
1516 | + $migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"), $guid)); |
|
1517 | 1517 | return false; |
1518 | 1518 | } |
1519 | - $local_filepath = $wp_upload_dir['path'].DS.basename($guid); |
|
1519 | + $local_filepath = $wp_upload_dir['path'].DS.basename($guid); |
|
1520 | 1520 | $savefile = fopen($local_filepath, 'w'); |
1521 | 1521 | fwrite($savefile, $contents); |
1522 | 1522 | fclose($savefile); |
1523 | - $guid = str_replace($wp_upload_dir['path'],$wp_upload_dir['url'],$local_filepath); |
|
1524 | - }else{ |
|
1525 | - $local_filepath = str_replace($wp_upload_dir['url'],$wp_upload_dir['path'],$guid); |
|
1523 | + $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath); |
|
1524 | + } else { |
|
1525 | + $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid); |
|
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | $attachment = array( |
@@ -1532,24 +1532,24 @@ discard block |
||
1532 | 1532 | 'post_content' => '', |
1533 | 1533 | 'post_status' => 'inherit' |
1534 | 1534 | ); |
1535 | - $attach_id = wp_insert_attachment( $attachment, $guid ); |
|
1536 | - if( ! $attach_id ){ |
|
1537 | - $migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"),$guid,$this->_json_encode($attachment))); |
|
1535 | + $attach_id = wp_insert_attachment($attachment, $guid); |
|
1536 | + if ( ! $attach_id) { |
|
1537 | + $migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"), $guid, $this->_json_encode($attachment))); |
|
1538 | 1538 | return $attach_id; |
1539 | 1539 | } |
1540 | 1540 | |
1541 | 1541 | // you must first include the image.php file |
1542 | 1542 | // for the function wp_generate_attachment_metadata() to work |
1543 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1543 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
1544 | 1544 | |
1545 | - $attach_data = wp_generate_attachment_metadata( $attach_id, $local_filepath ); |
|
1546 | - if( ! $attach_data){ |
|
1547 | - $migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"),$attach_id,$local_filepath,$guid)); |
|
1545 | + $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath); |
|
1546 | + if ( ! $attach_data) { |
|
1547 | + $migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"), $attach_id, $local_filepath, $guid)); |
|
1548 | 1548 | return $attach_id; |
1549 | 1549 | } |
1550 | - $metadata_save_result = wp_update_attachment_metadata( $attach_id, $attach_data ); |
|
1551 | - if( ! $metadata_save_result ){ |
|
1552 | - $migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"),$attach_id,$this->_json_encode($attach_data))); |
|
1550 | + $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data); |
|
1551 | + if ( ! $metadata_save_result) { |
|
1552 | + $migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"), $attach_id, $this->_json_encode($attach_data))); |
|
1553 | 1553 | } |
1554 | 1554 | return $attach_id; |
1555 | 1555 | } |
@@ -1561,9 +1561,9 @@ discard block |
||
1561 | 1561 | * @param string $guid |
1562 | 1562 | * @return int |
1563 | 1563 | */ |
1564 | - private function _get_image_attachment_id_by_GUID($guid){ |
|
1564 | + private function _get_image_attachment_id_by_GUID($guid) { |
|
1565 | 1565 | global $wpdb; |
1566 | - $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1",$guid)); |
|
1566 | + $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid)); |
|
1567 | 1567 | return $attachment_id; |
1568 | 1568 | } |
1569 | 1569 | /** |
@@ -1575,20 +1575,20 @@ discard block |
||
1575 | 1575 | * @param string $timezone |
1576 | 1576 | * @return string |
1577 | 1577 | */ |
1578 | - public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string,$timezone = null){ |
|
1578 | + public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string, $timezone = null) { |
|
1579 | 1579 | $original_tz = $timezone; |
1580 | - if( ! $timezone){ |
|
1580 | + if ( ! $timezone) { |
|
1581 | 1581 | $timezone = $this->_get_wp_timezone(); |
1582 | 1582 | } |
1583 | - if( ! $timezone){ |
|
1584 | - $stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"),$original_tz,$row_of_data)); |
|
1583 | + if ( ! $timezone) { |
|
1584 | + $stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"), $original_tz, $row_of_data)); |
|
1585 | 1585 | $timezone = 'UTC'; |
1586 | 1586 | } |
1587 | - try{ |
|
1588 | - $date_obj = new DateTime( $DATETIME_string, new DateTimeZone( $timezone ) ); |
|
1587 | + try { |
|
1588 | + $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone)); |
|
1589 | 1589 | $date_obj->setTimezone(new DateTimeZone('UTC')); |
1590 | - }catch(Exception $e){ |
|
1591 | - $stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"),$DATETIME_string,$timezone)); |
|
1590 | + } catch (Exception $e) { |
|
1591 | + $stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"), $DATETIME_string, $timezone)); |
|
1592 | 1592 | $date_obj = new DateTime(); |
1593 | 1593 | } |
1594 | 1594 | |
@@ -1599,14 +1599,14 @@ discard block |
||
1599 | 1599 | * Gets the DEFAULT timezone string from wordpress (even if they set a gmt offset) |
1600 | 1600 | * @return string |
1601 | 1601 | */ |
1602 | - private function _get_wp_timezone(){ |
|
1603 | - $timezone = empty( $timezone ) ? get_option('timezone_string') : $timezone; |
|
1602 | + private function _get_wp_timezone() { |
|
1603 | + $timezone = empty($timezone) ? get_option('timezone_string') : $timezone; |
|
1604 | 1604 | |
1605 | 1605 | //if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter |
1606 | - if ( empty( $timezone ) ) { |
|
1606 | + if (empty($timezone)) { |
|
1607 | 1607 | //let's get a the WordPress UTC offset |
1608 | 1608 | $offset = get_option('gmt_offset'); |
1609 | - $timezone = $this->timezone_convert_to_string_from_offset( $offset ); |
|
1609 | + $timezone = $this->timezone_convert_to_string_from_offset($offset); |
|
1610 | 1610 | } |
1611 | 1611 | return $timezone; |
1612 | 1612 | } |
@@ -1615,11 +1615,11 @@ discard block |
||
1615 | 1615 | * @param int $offset |
1616 | 1616 | * @return boolean |
1617 | 1617 | */ |
1618 | - private function timezone_convert_to_string_from_offset($offset){ |
|
1618 | + private function timezone_convert_to_string_from_offset($offset) { |
|
1619 | 1619 | //shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable |
1620 | 1620 | $offset *= 3600; // convert hour offset to seconds |
1621 | 1621 | $abbrarray = timezone_abbreviations_list(); |
1622 | - foreach ($abbrarray as $abbr){ |
|
1622 | + foreach ($abbrarray as $abbr) { |
|
1623 | 1623 | foreach ($abbr as $city) |
1624 | 1624 | { |
1625 | 1625 | if ($city['offset'] == $offset) |
@@ -1633,32 +1633,32 @@ discard block |
||
1633 | 1633 | return FALSE; |
1634 | 1634 | } |
1635 | 1635 | |
1636 | - public function migration_page_hooks(){ |
|
1637 | - add_filter('FHEE__ee_migration_page__header',array($this,'_migrate_page_hook_simplify_version_strings'),10,3); |
|
1638 | - add_filter('FHEE__ee_migration_page__p_after_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1639 | - add_filter('FHEE__ee_migration_page__option_1_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,3); |
|
1640 | - add_filter('FHEE__ee_migration_page__option_1_button_text',array($this,'_migrate_page_hook_simplify_version_strings'),10,3); |
|
1641 | - add_action('AHEE__ee_migration_page__option_1_extra_details',array($this,'_migration_page_hook_option_1_extra_details'),10,3); |
|
1642 | - add_filter('FHEE__ee_migration_page__option_2_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,4); |
|
1643 | - add_filter('FHEE__ee_migration_page__option_2_button_text',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1644 | - add_filter('FHEE__ee_migration_page__option_2_details',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1645 | - add_action('AHEE__ee_migration_page__after_migration_options_table',array($this,'_migration_page_hook_after_migration_options_table')); |
|
1646 | - add_filter('FHEE__ee_migration_page__done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1647 | - add_filter('FHEE__ee_migration_page__p_after_done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1636 | + public function migration_page_hooks() { |
|
1637 | + add_filter('FHEE__ee_migration_page__header', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3); |
|
1638 | + add_filter('FHEE__ee_migration_page__p_after_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1639 | + add_filter('FHEE__ee_migration_page__option_1_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3); |
|
1640 | + add_filter('FHEE__ee_migration_page__option_1_button_text', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3); |
|
1641 | + add_action('AHEE__ee_migration_page__option_1_extra_details', array($this, '_migration_page_hook_option_1_extra_details'), 10, 3); |
|
1642 | + add_filter('FHEE__ee_migration_page__option_2_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 4); |
|
1643 | + add_filter('FHEE__ee_migration_page__option_2_button_text', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1644 | + add_filter('FHEE__ee_migration_page__option_2_details', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1645 | + add_action('AHEE__ee_migration_page__after_migration_options_table', array($this, '_migration_page_hook_after_migration_options_table')); |
|
1646 | + add_filter('FHEE__ee_migration_page__done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1647 | + add_filter('FHEE__ee_migration_page__p_after_done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1648 | 1648 | } |
1649 | 1649 | |
1650 | - public function _migrate_page_hook_simplify_version_strings($old_content,$current_db_state,$next_db_state,$ultimate_db_state = NULL){ |
|
1651 | - return str_replace(array($current_db_state,$next_db_state,$ultimate_db_state),array(__('EE3','event_espresso'),__('EE4','event_espresso'), __("EE4", 'event_espresso')),$old_content); |
|
1650 | + public function _migrate_page_hook_simplify_version_strings($old_content, $current_db_state, $next_db_state, $ultimate_db_state = NULL) { |
|
1651 | + return str_replace(array($current_db_state, $next_db_state, $ultimate_db_state), array(__('EE3', 'event_espresso'), __('EE4', 'event_espresso'), __("EE4", 'event_espresso')), $old_content); |
|
1652 | 1652 | } |
1653 | - public function _migration_page_hook_simplify_next_db_state($old_content,$next_db_state){ |
|
1654 | - return str_replace($next_db_state, __("EE4", 'event_espresso'),$old_content); |
|
1653 | + public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state) { |
|
1654 | + return str_replace($next_db_state, __("EE4", 'event_espresso'), $old_content); |
|
1655 | 1655 | } |
1656 | - public function _migration_page_hook_option_1_extra_details(){ |
|
1657 | - ?><p><?php printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso"));?></p><?php |
|
1656 | + public function _migration_page_hook_option_1_extra_details() { |
|
1657 | + ?><p><?php printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso")); ?></p><?php |
|
1658 | 1658 | } |
1659 | - public function _migration_page_hook_after_migration_options_table(){ |
|
1659 | + public function _migration_page_hook_after_migration_options_table() { |
|
1660 | 1660 | ?><p class="ee-attention"> |
1661 | - <strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso");?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso"); ?> |
|
1661 | + <strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso"); ?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso"); ?> |
|
1662 | 1662 | </p><?php |
1663 | 1663 | } |
1664 | 1664 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -38,32 +38,32 @@ discard block |
||
38 | 38 | public static function set_hooks() { |
39 | 39 | add_filter( |
40 | 40 | 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
41 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) |
|
41 | + array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters') |
|
42 | 42 | ); |
43 | 43 | add_action( |
44 | 44 | 'wp_ajax_switch_spco_billing_form', |
45 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
45 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'wp_ajax_nopriv_switch_spco_billing_form', |
49 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
49 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
50 | 50 | ); |
51 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) ); |
|
51 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
52 | 52 | add_action( |
53 | 53 | 'wp_ajax_nopriv_save_payer_details', |
54 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) |
|
54 | + array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details') |
|
55 | 55 | ); |
56 | 56 | add_action( |
57 | 57 | 'wp_ajax_get_transaction_details_for_gateways', |
58 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
58 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
59 | 59 | ); |
60 | 60 | add_action( |
61 | 61 | 'wp_ajax_nopriv_get_transaction_details_for_gateways', |
62 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
62 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
63 | 63 | ); |
64 | 64 | add_filter( |
65 | 65 | 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
66 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), |
|
66 | + array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), |
|
67 | 67 | 10, |
68 | 68 | 1 |
69 | 69 | ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @throws \EE_Error |
78 | 78 | */ |
79 | 79 | public static function switch_spco_billing_form() { |
80 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
80 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @throws \EE_Error |
89 | 89 | */ |
90 | 90 | public static function save_payer_details() { |
91 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
91 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | 101 | public static function get_transaction_details() { |
102 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
102 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | * @access public |
127 | 127 | * @param EE_Checkout $checkout |
128 | 128 | */ |
129 | - public function __construct( EE_Checkout $checkout ) { |
|
129 | + public function __construct(EE_Checkout $checkout) { |
|
130 | 130 | $this->_slug = 'payment_options'; |
131 | - $this->_name = __( 'Payment Options', 'event_espresso' ); |
|
132 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
131 | + $this->_name = __('Payment Options', 'event_espresso'); |
|
132 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
133 | 133 | $this->checkout = $checkout; |
134 | 134 | $this->_reset_success_message(); |
135 | 135 | $this->set_instructions( |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | /** |
155 | 155 | * @param null $line_item_display |
156 | 156 | */ |
157 | - public function set_line_item_display( $line_item_display ) { |
|
157 | + public function set_line_item_display($line_item_display) { |
|
158 | 158 | $this->line_item_display = $line_item_display; |
159 | 159 | } |
160 | 160 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | /** |
173 | 173 | * @param boolean $handle_IPN_in_this_request |
174 | 174 | */ |
175 | - public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) { |
|
176 | - $this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN ); |
|
175 | + public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) { |
|
176 | + $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | public function enqueue_styles_and_scripts() { |
209 | 209 | $transaction = $this->checkout->transaction; |
210 | 210 | //if the transaction isn't set or nothing is owed on it, don't enqueue any JS |
211 | - if( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats( $transaction->remaining(), 0 ) ) { |
|
211 | + if ( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | - foreach( EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ) as $payment_method ) { |
|
214 | + foreach (EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart) as $payment_method) { |
|
215 | 215 | $type_obj = $payment_method->type_obj(); |
216 | - if( $type_obj instanceof EE_PMT_Base ) { |
|
217 | - $billing_form = $type_obj->generate_new_billing_form( $transaction ); |
|
218 | - if( $billing_form instanceof EE_Form_Section_Proper ) { |
|
216 | + if ($type_obj instanceof EE_PMT_Base) { |
|
217 | + $billing_form = $type_obj->generate_new_billing_form($transaction); |
|
218 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
219 | 219 | $billing_form->enqueue_js(); |
220 | 220 | } |
221 | 221 | } |
@@ -240,20 +240,20 @@ discard block |
||
240 | 240 | // $ 0.00 transactions (no payment required) |
241 | 241 | ! $this->checkout->payment_required() |
242 | 242 | // but do NOT remove if current action being called belongs to this reg step |
243 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
243 | + && ! is_callable(array($this, $this->checkout->action)) |
|
244 | 244 | && ! $this->completed() |
245 | 245 | ) { |
246 | 246 | // and if so, then we no longer need the Payment Options step |
247 | - if ( $this->is_current_step() ) { |
|
247 | + if ($this->is_current_step()) { |
|
248 | 248 | $this->checkout->generate_reg_form = false; |
249 | 249 | } |
250 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
250 | + $this->checkout->remove_reg_step($this->_slug); |
|
251 | 251 | // DEBUG LOG |
252 | 252 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
253 | 253 | return false; |
254 | 254 | } |
255 | 255 | // load EEM_Payment_Method |
256 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
256 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
257 | 257 | // get all active payment methods |
258 | 258 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
259 | 259 | $this->checkout->transaction, |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | $insufficient_spaces_available = array(); |
281 | 281 | $no_payment_required = true; |
282 | 282 | // loop thru registrations to gather info |
283 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
283 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
284 | 284 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
285 | 285 | $registrations, |
286 | 286 | $this->checkout->revisit |
287 | 287 | ); |
288 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
288 | + foreach ($registrations as $REG_ID => $registration) { |
|
289 | 289 | /** @var $registration EE_Registration */ |
290 | 290 | // has this registration lost it's space ? |
291 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
292 | - $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
|
291 | + if (isset($ejected_registrations[$REG_ID])) { |
|
292 | + $insufficient_spaces_available[$registration->event()->ID()] = $registration->event(); |
|
293 | 293 | continue; |
294 | 294 | } |
295 | 295 | // event requires admin approval |
@@ -310,11 +310,11 @@ discard block |
||
310 | 310 | && $registration->status_ID() !== EEM_Registration::status_id_approved |
311 | 311 | && ( |
312 | 312 | $registration->event()->is_sold_out() |
313 | - || $registration->event()->is_sold_out( true ) |
|
313 | + || $registration->event()->is_sold_out(true) |
|
314 | 314 | ) |
315 | 315 | ) { |
316 | 316 | // add event to list of events that are sold out |
317 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
317 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
318 | 318 | do_action( |
319 | 319 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
320 | 320 | $registration->event(), |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | continue; |
324 | 324 | } |
325 | 325 | // are they allowed to pay now and is there monies owing? |
326 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
327 | - $registrations_requiring_payment[ $REG_ID ] = $registration; |
|
326 | + if ($registration->owes_monies_and_can_pay()) { |
|
327 | + $registrations_requiring_payment[$REG_ID] = $registration; |
|
328 | 328 | do_action( |
329 | 329 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
330 | 330 | $registration->event(), |
@@ -335,29 +335,29 @@ discard block |
||
335 | 335 | && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
336 | 336 | && $registration->ticket()->is_free() |
337 | 337 | ) { |
338 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
338 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | $subsections = array(); |
342 | 342 | // now decide which template to load |
343 | - if ( ! empty( $sold_out_events ) ) { |
|
344 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
343 | + if ( ! empty($sold_out_events)) { |
|
344 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
345 | 345 | } |
346 | - if ( ! empty( $insufficient_spaces_available ) ) { |
|
346 | + if ( ! empty($insufficient_spaces_available)) { |
|
347 | 347 | $subsections['insufficient_space'] = $this->_insufficient_spaces_available( |
348 | 348 | $insufficient_spaces_available |
349 | 349 | ); |
350 | 350 | } |
351 | - if ( ! empty( $registrations_requiring_pre_approval ) ) { |
|
351 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
352 | 352 | $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
353 | 353 | $registrations_requiring_pre_approval |
354 | 354 | ); |
355 | 355 | } |
356 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
357 | - $subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events ); |
|
356 | + if ( ! empty($registrations_for_free_events)) { |
|
357 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
358 | 358 | } |
359 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
360 | - if ( $this->checkout->amount_owing > 0 ) { |
|
359 | + if ( ! empty($registrations_requiring_payment)) { |
|
360 | + if ($this->checkout->amount_owing > 0) { |
|
361 | 361 | // autoload Line_Item_Display classes |
362 | 362 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
363 | 363 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -370,15 +370,15 @@ discard block |
||
370 | 370 | /** @var EE_Line_Item $filtered_line_item_tree */ |
371 | 371 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
372 | 372 | EEH_Autoloader::register_line_item_display_autoloaders(); |
373 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
373 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
374 | 374 | $subsections['payment_options'] = $this->_display_payment_options( |
375 | 375 | $this->line_item_display->display_line_item( |
376 | 376 | $filtered_line_item_tree, |
377 | - array( 'registrations' => $registrations ) |
|
377 | + array('registrations' => $registrations) |
|
378 | 378 | ) |
379 | 379 | ); |
380 | 380 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
381 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
381 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
382 | 382 | } |
383 | 383 | $no_payment_required = false; |
384 | 384 | } else { |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | $this->_save_selected_method_of_payment(); |
388 | 388 | |
389 | 389 | $subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs(); |
390 | - $subsections['extra_hidden_inputs' ] = $this->_extra_hidden_inputs( $no_payment_required ); |
|
390 | + $subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required); |
|
391 | 391 | |
392 | 392 | return new EE_Form_Section_Proper( |
393 | 393 | array( |
@@ -414,14 +414,14 @@ discard block |
||
414 | 414 | * @return \EE_Line_Item_Filter_Collection |
415 | 415 | * @throws \EE_Error |
416 | 416 | */ |
417 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
418 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session ) { |
|
417 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
418 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
419 | 419 | return $line_item_filter_collection; |
420 | 420 | } |
421 | - if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout ) { |
|
421 | + if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) { |
|
422 | 422 | return $line_item_filter_collection; |
423 | 423 | } |
424 | - if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction ) { |
|
424 | + if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) { |
|
425 | 425 | return $line_item_filter_collection; |
426 | 426 | } |
427 | 427 | $line_item_filter_collection->add( |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | ) |
434 | 434 | ) |
435 | 435 | ); |
436 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
436 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
437 | 437 | return $line_item_filter_collection; |
438 | 438 | } |
439 | 439 | |
@@ -449,15 +449,15 @@ discard block |
||
449 | 449 | * @return \EE_Registration[] |
450 | 450 | * @throws \EE_Error |
451 | 451 | */ |
452 | - public static function remove_ejected_registrations( array $registrations ) { |
|
452 | + public static function remove_ejected_registrations(array $registrations) { |
|
453 | 453 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
454 | 454 | $registrations, |
455 | 455 | EE_Registry::instance()->SSN->checkout()->revisit |
456 | 456 | ); |
457 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
457 | + foreach ($registrations as $REG_ID => $registration) { |
|
458 | 458 | // has this registration lost it's space ? |
459 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
460 | - unset( $registrations[ $REG_ID ] ); |
|
459 | + if (isset($ejected_registrations[$REG_ID])) { |
|
460 | + unset($registrations[$REG_ID]); |
|
461 | 461 | continue; |
462 | 462 | } |
463 | 463 | } |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | * @return array |
481 | 481 | * @throws \EE_Error |
482 | 482 | */ |
483 | - public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) { |
|
483 | + public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false) { |
|
484 | 484 | // registrations per event |
485 | 485 | $event_reg_count = array(); |
486 | 486 | // spaces left per event |
@@ -489,8 +489,8 @@ discard block |
||
489 | 489 | $tickets_remaining = array(); |
490 | 490 | // registrations that have lost their space |
491 | 491 | $ejected_registrations = array(); |
492 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
493 | - if ( $registration->status_ID() === EEM_Registration::status_id_approved ) { |
|
492 | + foreach ($registrations as $REG_ID => $registration) { |
|
493 | + if ($registration->status_ID() === EEM_Registration::status_id_approved) { |
|
494 | 494 | continue; |
495 | 495 | } |
496 | 496 | $EVT_ID = $registration->event_ID(); |
@@ -511,13 +511,13 @@ discard block |
||
511 | 511 | $revisit |
512 | 512 | && ( |
513 | 513 | $tickets_remaining[$ticket->ID()] === 0 |
514 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
514 | + || $event_reg_count[$EVT_ID] > $event_spaces_remaining[$EVT_ID] |
|
515 | 515 | ) |
516 | 516 | ) { |
517 | - $ejected_registrations[ $REG_ID ] = $registration->event(); |
|
518 | - if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) { |
|
517 | + $ejected_registrations[$REG_ID] = $registration->event(); |
|
518 | + if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) { |
|
519 | 519 | /** @type EE_Registration_Processor $registration_processor */ |
520 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
520 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
521 | 521 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
522 | 522 | $registration_processor->manually_update_registration_status( |
523 | 523 | $registration, |
@@ -552,8 +552,8 @@ discard block |
||
552 | 552 | * @return void |
553 | 553 | */ |
554 | 554 | protected function _hide_reg_step_submit_button_if_revisit() { |
555 | - if ( $this->checkout->revisit ) { |
|
556 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
555 | + if ($this->checkout->revisit) { |
|
556 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
557 | 557 | } |
558 | 558 | } |
559 | 559 | |
@@ -567,13 +567,13 @@ discard block |
||
567 | 567 | * @return \EE_Form_Section_Proper |
568 | 568 | * @throws \EE_Error |
569 | 569 | */ |
570 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
570 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
571 | 571 | // set some defaults |
572 | 572 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
573 | 573 | $sold_out_events = ''; |
574 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
574 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
575 | 575 | $sold_out_events .= EEH_HTML::li( |
576 | - EEH_HTML::span( ' ' .$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
576 | + EEH_HTML::span(' '.$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
577 | 577 | ); |
578 | 578 | } |
579 | 579 | return new EE_Form_Section_Proper( |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | 'sold_out_events_msg' => apply_filters( |
592 | 592 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg', |
593 | 593 | sprintf( |
594 | - __( 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', 'event_espresso' ), |
|
594 | + __('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', 'event_espresso'), |
|
595 | 595 | '<strong>', |
596 | 596 | '</strong>', |
597 | 597 | '<br />' |
@@ -616,14 +616,14 @@ discard block |
||
616 | 616 | * @return \EE_Form_Section_Proper |
617 | 617 | * @throws \EE_Error |
618 | 618 | */ |
619 | - private function _insufficient_spaces_available( $insufficient_spaces_events_array = array() ) { |
|
619 | + private function _insufficient_spaces_available($insufficient_spaces_events_array = array()) { |
|
620 | 620 | // set some defaults |
621 | 621 | $this->checkout->selected_method_of_payment = 'invoice'; |
622 | 622 | $insufficient_space_events = ''; |
623 | - foreach ( $insufficient_spaces_events_array as $event ) { |
|
624 | - if ( $event instanceof EE_Event ) { |
|
623 | + foreach ($insufficient_spaces_events_array as $event) { |
|
624 | + if ($event instanceof EE_Event) { |
|
625 | 625 | $insufficient_space_events .= EEH_HTML::li( |
626 | - EEH_HTML::span( ' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
626 | + EEH_HTML::span(' '.$event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
627 | 627 | ); |
628 | 628 | } |
629 | 629 | } |
@@ -667,17 +667,17 @@ discard block |
||
667 | 667 | * @return \EE_Form_Section_Proper |
668 | 668 | * @throws \EE_Error |
669 | 669 | */ |
670 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) { |
|
670 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
671 | 671 | $events_requiring_pre_approval = ''; |
672 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
673 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
674 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
672 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
673 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
674 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
675 | 675 | EEH_HTML::span( |
676 | 676 | '', |
677 | 677 | '', |
678 | 678 | 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
679 | 679 | ) |
680 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
680 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
681 | 681 | ); |
682 | 682 | } |
683 | 683 | } |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | 'template_args' => apply_filters( |
693 | 693 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
694 | 694 | array( |
695 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
695 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
696 | 696 | 'events_requiring_pre_approval_msg' => apply_filters( |
697 | 697 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
698 | 698 | __( |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | * @return \EE_Form_Section_Proper |
718 | 718 | * @throws \EE_Error |
719 | 719 | */ |
720 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
720 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
721 | 721 | // set some defaults |
722 | 722 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
723 | 723 | // generate no_payment_required form |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | 'ticket_count' => array(), |
738 | 738 | 'registrations_for_free_events' => $registrations_for_free_events, |
739 | 739 | 'no_payment_required_msg' => EEH_HTML::p( |
740 | - __( 'This is a free event, so no billing will occur.', 'event_espresso' ) |
|
740 | + __('This is a free event, so no billing will occur.', 'event_espresso') |
|
741 | 741 | ) |
742 | 742 | ) |
743 | 743 | ), |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | * @return \EE_Form_Section_Proper |
757 | 757 | * @throws \EE_Error |
758 | 758 | */ |
759 | - private function _display_payment_options( $transaction_details = '' ) { |
|
759 | + private function _display_payment_options($transaction_details = '') { |
|
760 | 760 | // has method_of_payment been set by no-js user? |
761 | 761 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
762 | 762 | // build payment options form |
@@ -768,14 +768,14 @@ discard block |
||
768 | 768 | 'before_payment_options' => apply_filters( |
769 | 769 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
770 | 770 | new EE_Form_Section_Proper( |
771 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
771 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
772 | 772 | ) |
773 | 773 | ), |
774 | 774 | 'payment_options' => $this->_setup_payment_options(), |
775 | 775 | 'after_payment_options' => apply_filters( |
776 | 776 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
777 | 777 | new EE_Form_Section_Proper( |
778 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
778 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
779 | 779 | ) |
780 | 780 | ), |
781 | 781 | ), |
@@ -806,10 +806,10 @@ discard block |
||
806 | 806 | * @return \EE_Form_Section_Proper |
807 | 807 | * @throws \EE_Error |
808 | 808 | */ |
809 | - private function _extra_hidden_inputs( $no_payment_required = true ) { |
|
809 | + private function _extra_hidden_inputs($no_payment_required = true) { |
|
810 | 810 | return new EE_Form_Section_Proper( |
811 | 811 | array( |
812 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
812 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
813 | 813 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
814 | 814 | 'subsections' => array( |
815 | 815 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -841,16 +841,16 @@ discard block |
||
841 | 841 | * @access protected |
842 | 842 | * @param array $registrations |
843 | 843 | */ |
844 | - protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
|
844 | + protected function _apply_registration_payments_to_amount_owing(array $registrations) { |
|
845 | 845 | $payments = array(); |
846 | - foreach ( $registrations as $registration ) { |
|
847 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
846 | + foreach ($registrations as $registration) { |
|
847 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
848 | 848 | $payments += $registration->registration_payments(); |
849 | 849 | } |
850 | 850 | } |
851 | - if ( ! empty( $payments ) ) { |
|
852 | - foreach ( $payments as $payment ) { |
|
853 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
851 | + if ( ! empty($payments)) { |
|
852 | + foreach ($payments as $payment) { |
|
853 | + if ($payment instanceof EE_Registration_Payment) { |
|
854 | 854 | $this->checkout->amount_owing -= $payment->amount(); |
855 | 855 | } |
856 | 856 | } |
@@ -866,11 +866,11 @@ discard block |
||
866 | 866 | * @param bool $force_reset |
867 | 867 | * @return void |
868 | 868 | */ |
869 | - private function _reset_selected_method_of_payment( $force_reset = false ) { |
|
869 | + private function _reset_selected_method_of_payment($force_reset = false) { |
|
870 | 870 | $reset_payment_method = $force_reset |
871 | 871 | ? true |
872 | - : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) ); |
|
873 | - if ( $reset_payment_method ) { |
|
872 | + : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false)); |
|
873 | + if ($reset_payment_method) { |
|
874 | 874 | $this->checkout->selected_method_of_payment = null; |
875 | 875 | $this->checkout->payment_method = null; |
876 | 876 | $this->checkout->billing_form = null; |
@@ -889,12 +889,12 @@ discard block |
||
889 | 889 | * @param string $selected_method_of_payment |
890 | 890 | * @return void |
891 | 891 | */ |
892 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
893 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) |
|
892 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
893 | + $selected_method_of_payment = ! empty($selected_method_of_payment) |
|
894 | 894 | ? $selected_method_of_payment |
895 | 895 | : $this->checkout->selected_method_of_payment; |
896 | 896 | EE_Registry::instance()->SSN->set_session_data( |
897 | - array( 'selected_method_of_payment' => $selected_method_of_payment ) |
|
897 | + array('selected_method_of_payment' => $selected_method_of_payment) |
|
898 | 898 | ); |
899 | 899 | } |
900 | 900 | |
@@ -910,19 +910,19 @@ discard block |
||
910 | 910 | // load payment method classes |
911 | 911 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
912 | 912 | // switch up header depending on number of available payment methods |
913 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
913 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
914 | 914 | ? apply_filters( |
915 | 915 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
916 | - __( 'Please Select Your Method of Payment', 'event_espresso' ) |
|
916 | + __('Please Select Your Method of Payment', 'event_espresso') |
|
917 | 917 | ) |
918 | 918 | : apply_filters( |
919 | 919 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
920 | - __( 'Method of Payment', 'event_espresso' ) |
|
920 | + __('Method of Payment', 'event_espresso') |
|
921 | 921 | ); |
922 | 922 | $available_payment_methods = array( |
923 | 923 | // display the "Payment Method" header |
924 | 924 | 'payment_method_header' => new EE_Form_Section_HTML( |
925 | - EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' ) |
|
925 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
926 | 926 | ) |
927 | 927 | ); |
928 | 928 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
@@ -931,32 +931,32 @@ discard block |
||
931 | 931 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
932 | 932 | $payment_methods_billing_info = array( |
933 | 933 | new EE_Form_Section_HTML( |
934 | - EEH_HTML::div( '<br />', '', '', 'clear:both;' ) |
|
934 | + EEH_HTML::div('<br />', '', '', 'clear:both;') |
|
935 | 935 | ) |
936 | 936 | ); |
937 | 937 | // loop through payment methods |
938 | - foreach ( $this->checkout->available_payment_methods as $payment_method ) { |
|
939 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
938 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
939 | + if ($payment_method instanceof EE_Payment_Method) { |
|
940 | 940 | $payment_method_button = EEH_HTML::img( |
941 | 941 | $payment_method->button_url(), |
942 | 942 | $payment_method->name(), |
943 | - 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
943 | + 'spco-payment-method-'.$payment_method->slug().'-btn-img', |
|
944 | 944 | 'spco-payment-method-btn-img' |
945 | 945 | ); |
946 | 946 | // check if any payment methods are set as default |
947 | 947 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
948 | 948 | if ( |
949 | - ( $this->checkout->selected_method_of_payment === $payment_method->slug() ) |
|
950 | - || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() ) |
|
949 | + ($this->checkout->selected_method_of_payment === $payment_method->slug()) |
|
950 | + || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
951 | 951 | ) { |
952 | 952 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
953 | 953 | $this->_save_selected_method_of_payment(); |
954 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
954 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
955 | 955 | } else { |
956 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
956 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
957 | 957 | } |
958 | - $payment_methods_billing_info[ $payment_method->slug() |
|
959 | - . '-info' ] = $this->_payment_method_billing_info( |
|
958 | + $payment_methods_billing_info[$payment_method->slug() |
|
959 | + . '-info'] = $this->_payment_method_billing_info( |
|
960 | 960 | $payment_method |
961 | 961 | ); |
962 | 962 | } |
@@ -986,12 +986,12 @@ discard block |
||
986 | 986 | * @return EE_Payment_Method[] |
987 | 987 | */ |
988 | 988 | protected function _get_available_payment_methods() { |
989 | - if ( ! empty( $this->checkout->available_payment_methods ) ) { |
|
989 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
990 | 990 | return $this->checkout->available_payment_methods; |
991 | 991 | } |
992 | 992 | $available_payment_methods = array(); |
993 | 993 | // load EEM_Payment_Method |
994 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
994 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
995 | 995 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
996 | 996 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
997 | 997 | // get all active payment methods |
@@ -999,9 +999,9 @@ discard block |
||
999 | 999 | $this->checkout->transaction, |
1000 | 1000 | EEM_Payment_Method::scope_cart |
1001 | 1001 | ); |
1002 | - foreach ( $payment_methods as $payment_method ) { |
|
1003 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
1004 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
1002 | + foreach ($payment_methods as $payment_method) { |
|
1003 | + if ($payment_method instanceof EE_Payment_Method) { |
|
1004 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
1005 | 1005 | } |
1006 | 1006 | } |
1007 | 1007 | return $available_payment_methods; |
@@ -1016,14 +1016,14 @@ discard block |
||
1016 | 1016 | * @param array $available_payment_method_options |
1017 | 1017 | * @return \EE_Form_Section_Proper |
1018 | 1018 | */ |
1019 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
1019 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
1020 | 1020 | // generate inputs |
1021 | 1021 | return new EE_Form_Section_Proper( |
1022 | 1022 | array( |
1023 | 1023 | 'html_id' => 'ee-available-payment-method-inputs', |
1024 | 1024 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
1025 | 1025 | 'subsections' => array( |
1026 | - '' => new EE_Radio_Button_Input ( |
|
1026 | + '' => new EE_Radio_Button_Input( |
|
1027 | 1027 | $available_payment_method_options, |
1028 | 1028 | array( |
1029 | 1029 | 'html_name' => 'selected_method_of_payment', |
@@ -1048,28 +1048,28 @@ discard block |
||
1048 | 1048 | * @return \EE_Form_Section_Proper |
1049 | 1049 | * @throws \EE_Error |
1050 | 1050 | */ |
1051 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
1051 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
1052 | 1052 | $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug() |
1053 | 1053 | ? true |
1054 | 1054 | : false; |
1055 | 1055 | // generate the billing form for payment method |
1056 | 1056 | $billing_form = $currently_selected |
1057 | - ? $this->_get_billing_form_for_payment_method( $payment_method ) |
|
1057 | + ? $this->_get_billing_form_for_payment_method($payment_method) |
|
1058 | 1058 | : new EE_Form_Section_HTML(); |
1059 | 1059 | $this->checkout->billing_form = $currently_selected |
1060 | 1060 | ? $billing_form |
1061 | 1061 | : $this->checkout->billing_form; |
1062 | 1062 | // it's all in the details |
1063 | 1063 | $info_html = EEH_HTML::h3( |
1064 | - __( 'Important information regarding your payment', 'event_espresso' ), |
|
1064 | + __('Important information regarding your payment', 'event_espresso'), |
|
1065 | 1065 | '', |
1066 | 1066 | 'spco-payment-method-hdr' |
1067 | 1067 | ); |
1068 | 1068 | // add some info regarding the step, either from what's saved in the admin, |
1069 | 1069 | // or a default string depending on whether the PM has a billing form or not |
1070 | - if ( $payment_method->description() ) { |
|
1070 | + if ($payment_method->description()) { |
|
1071 | 1071 | $payment_method_info = $payment_method->description(); |
1072 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
1072 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
1073 | 1073 | $payment_method_info = sprintf( |
1074 | 1074 | __( |
1075 | 1075 | 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', |
@@ -1079,7 +1079,7 @@ discard block |
||
1079 | 1079 | ); |
1080 | 1080 | } else { |
1081 | 1081 | $payment_method_info = sprintf( |
1082 | - __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), |
|
1082 | + __('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), |
|
1083 | 1083 | $this->submit_button_text() |
1084 | 1084 | ); |
1085 | 1085 | } |
@@ -1093,13 +1093,13 @@ discard block |
||
1093 | 1093 | ); |
1094 | 1094 | return new EE_Form_Section_Proper( |
1095 | 1095 | array( |
1096 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
1096 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
1097 | 1097 | 'html_class' => 'spco-payment-method-info-dv', |
1098 | 1098 | // only display the selected or default PM |
1099 | 1099 | 'html_style' => $currently_selected ? '' : 'display:none;', |
1100 | 1100 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
1101 | 1101 | 'subsections' => array( |
1102 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
1102 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
1103 | 1103 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
1104 | 1104 | ) |
1105 | 1105 | ) |
@@ -1117,15 +1117,15 @@ discard block |
||
1117 | 1117 | */ |
1118 | 1118 | public function get_billing_form_html_for_payment_method() { |
1119 | 1119 | // how have they chosen to pay? |
1120 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1120 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1121 | 1121 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1122 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1122 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1123 | 1123 | return false; |
1124 | 1124 | } |
1125 | - if ( apply_filters( |
|
1125 | + if (apply_filters( |
|
1126 | 1126 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1127 | 1127 | false |
1128 | - ) ) { |
|
1128 | + )) { |
|
1129 | 1129 | EE_Error::add_success( |
1130 | 1130 | apply_filters( |
1131 | 1131 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | ); |
1141 | 1141 | } |
1142 | 1142 | // now generate billing form for selected method of payment |
1143 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
1143 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
1144 | 1144 | // fill form with attendee info if applicable |
1145 | 1145 | if ( |
1146 | 1146 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
@@ -1162,10 +1162,10 @@ discard block |
||
1162 | 1162 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper |
1163 | 1163 | ? $payment_method_billing_form->get_html() |
1164 | 1164 | : ''; |
1165 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) ); |
|
1165 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
1166 | 1166 | // localize validation rules for main form |
1167 | 1167 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
1168 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1168 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1169 | 1169 | return true; |
1170 | 1170 | } |
1171 | 1171 | |
@@ -1179,18 +1179,18 @@ discard block |
||
1179 | 1179 | * @return \EE_Billing_Info_Form|\EE_Form_Section_HTML |
1180 | 1180 | * @throws \EE_Error |
1181 | 1181 | */ |
1182 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
1182 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
1183 | 1183 | $billing_form = $payment_method->type_obj()->billing_form( |
1184 | 1184 | $this->checkout->transaction, |
1185 | - array( 'amount_owing' => $this->checkout->amount_owing ) |
|
1185 | + array('amount_owing' => $this->checkout->amount_owing) |
|
1186 | 1186 | ); |
1187 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
1187 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
1188 | 1188 | if ( |
1189 | 1189 | apply_filters( |
1190 | 1190 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1191 | 1191 | false |
1192 | 1192 | ) |
1193 | - && EE_Registry::instance()->REQ->is_set( 'payment_method' ) |
|
1193 | + && EE_Registry::instance()->REQ->is_set('payment_method') |
|
1194 | 1194 | ) { |
1195 | 1195 | EE_Error::add_success( |
1196 | 1196 | apply_filters( |
@@ -1232,15 +1232,15 @@ discard block |
||
1232 | 1232 | $request_param = 'selected_method_of_payment' |
1233 | 1233 | ) { |
1234 | 1234 | // is selected_method_of_payment set in the request ? |
1235 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false ); |
|
1236 | - if ( $selected_method_of_payment ) { |
|
1235 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false); |
|
1236 | + if ($selected_method_of_payment) { |
|
1237 | 1237 | // sanitize it |
1238 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) |
|
1239 | - ? array_shift( $selected_method_of_payment ) |
|
1238 | + $selected_method_of_payment = is_array($selected_method_of_payment) |
|
1239 | + ? array_shift($selected_method_of_payment) |
|
1240 | 1240 | : $selected_method_of_payment; |
1241 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
1241 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
1242 | 1242 | // store it in the session so that it's available for all subsequent requests including AJAX |
1243 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
1243 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
1244 | 1244 | } else { |
1245 | 1245 | // or is is set in the session ? |
1246 | 1246 | $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | ); |
1249 | 1249 | } |
1250 | 1250 | // do ya really really gotta have it? |
1251 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
1251 | + if (empty($selected_method_of_payment) && $required) { |
|
1252 | 1252 | EE_Error::add_error( |
1253 | 1253 | sprintf( |
1254 | 1254 | __( |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | ), |
1258 | 1258 | '<br/>', |
1259 | 1259 | '<br/>', |
1260 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1260 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1261 | 1261 | ), |
1262 | 1262 | __FILE__, |
1263 | 1263 | __FUNCTION__, |
@@ -1284,13 +1284,13 @@ discard block |
||
1284 | 1284 | * @throws \EE_Error |
1285 | 1285 | */ |
1286 | 1286 | public function switch_payment_method() { |
1287 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1287 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1288 | 1288 | return false; |
1289 | 1289 | } |
1290 | - if ( apply_filters( |
|
1290 | + if (apply_filters( |
|
1291 | 1291 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1292 | 1292 | false |
1293 | - ) ) { |
|
1293 | + )) { |
|
1294 | 1294 | EE_Error::add_success( |
1295 | 1295 | apply_filters( |
1296 | 1296 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1305,13 +1305,13 @@ discard block |
||
1305 | 1305 | ); |
1306 | 1306 | } |
1307 | 1307 | // generate billing form for selected method of payment if it hasn't been done already |
1308 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1308 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1309 | 1309 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1310 | 1310 | $this->checkout->payment_method |
1311 | 1311 | ); |
1312 | 1312 | } |
1313 | 1313 | // fill form with attendee info if applicable |
1314 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
1314 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
1315 | 1315 | && $this->checkout->transaction_has_primary_registrant() |
1316 | 1316 | ) { |
1317 | 1317 | $this->checkout->billing_form->populate_from_attendee( |
@@ -1319,7 +1319,7 @@ discard block |
||
1319 | 1319 | ); |
1320 | 1320 | } |
1321 | 1321 | // and debug content |
1322 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1322 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1323 | 1323 | && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
1324 | 1324 | ) { |
1325 | 1325 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
@@ -1327,15 +1327,15 @@ discard block |
||
1327 | 1327 | ); |
1328 | 1328 | } |
1329 | 1329 | // get html and validation rules for form |
1330 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
1330 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
1331 | 1331 | $this->checkout->json_response->set_return_data( |
1332 | - array( 'payment_method_info' => $this->checkout->billing_form->get_html() ) |
|
1332 | + array('payment_method_info' => $this->checkout->billing_form->get_html()) |
|
1333 | 1333 | ); |
1334 | 1334 | // localize validation rules for main form |
1335 | - $this->checkout->billing_form->localize_validation_rules( true ); |
|
1336 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1335 | + $this->checkout->billing_form->localize_validation_rules(true); |
|
1336 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1337 | 1337 | } else { |
1338 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) ); |
|
1338 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
1339 | 1339 | } |
1340 | 1340 | //prevents advancement to next step |
1341 | 1341 | $this->checkout->continue_reg = false; |
@@ -1352,18 +1352,18 @@ discard block |
||
1352 | 1352 | */ |
1353 | 1353 | protected function _verify_payment_method_is_set() { |
1354 | 1354 | // generate billing form for selected method of payment if it hasn't been done already |
1355 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1355 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1356 | 1356 | // how have they chosen to pay? |
1357 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1357 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1358 | 1358 | } else { |
1359 | 1359 | // choose your own adventure based on method_of_payment |
1360 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
1360 | + switch ($this->checkout->selected_method_of_payment) { |
|
1361 | 1361 | case 'events_sold_out' : |
1362 | 1362 | EE_Error::add_attention( |
1363 | 1363 | apply_filters( |
1364 | 1364 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg', |
1365 | - __( 'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
1366 | - 'event_espresso' ) |
|
1365 | + __('It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
1366 | + 'event_espresso') |
|
1367 | 1367 | ), |
1368 | 1368 | __FILE__, __FUNCTION__, __LINE__ |
1369 | 1369 | ); |
@@ -1373,7 +1373,7 @@ discard block |
||
1373 | 1373 | EE_Error::add_attention( |
1374 | 1374 | apply_filters( |
1375 | 1375 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg', |
1376 | - __( 'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso' ) |
|
1376 | + __('It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso') |
|
1377 | 1377 | ), |
1378 | 1378 | __FILE__, __FUNCTION__, __LINE__ |
1379 | 1379 | ); |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | EE_Error::add_attention( |
1384 | 1384 | apply_filters( |
1385 | 1385 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg', |
1386 | - __( 'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso' ) |
|
1386 | + __('It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso') |
|
1387 | 1387 | ), |
1388 | 1388 | __FILE__, __FUNCTION__, __LINE__ |
1389 | 1389 | ); |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | } |
1394 | 1394 | } |
1395 | 1395 | // verify payment method |
1396 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1396 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1397 | 1397 | // get payment method for selected method of payment |
1398 | 1398 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1399 | 1399 | } |
@@ -1412,25 +1412,25 @@ discard block |
||
1412 | 1412 | * @throws \EE_Error |
1413 | 1413 | */ |
1414 | 1414 | public function save_payer_details_via_ajax() { |
1415 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1415 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1416 | 1416 | return; |
1417 | 1417 | } |
1418 | 1418 | // generate billing form for selected method of payment if it hasn't been done already |
1419 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1419 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1420 | 1420 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1421 | 1421 | $this->checkout->payment_method |
1422 | 1422 | ); |
1423 | 1423 | } |
1424 | 1424 | // generate primary attendee from payer info if applicable |
1425 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1425 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1426 | 1426 | $attendee = $this->_create_attendee_from_request_data(); |
1427 | - if ( $attendee instanceof EE_Attendee ) { |
|
1428 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
1429 | - if ( $registration->is_primary_registrant() ) { |
|
1427 | + if ($attendee instanceof EE_Attendee) { |
|
1428 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
1429 | + if ($registration->is_primary_registrant()) { |
|
1430 | 1430 | $this->checkout->primary_attendee_obj = $attendee; |
1431 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1432 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1433 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1431 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1432 | + $registration->set_attendee_id($attendee->ID()); |
|
1433 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1434 | 1434 | } |
1435 | 1435 | } |
1436 | 1436 | } |
@@ -1448,50 +1448,50 @@ discard block |
||
1448 | 1448 | */ |
1449 | 1449 | protected function _create_attendee_from_request_data() { |
1450 | 1450 | // get State ID |
1451 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
1452 | - if ( ! empty( $STA_ID ) ) { |
|
1451 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
1452 | + if ( ! empty($STA_ID)) { |
|
1453 | 1453 | // can we get state object from name ? |
1454 | - EE_Registry::instance()->load_model( 'State' ); |
|
1455 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' ); |
|
1456 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
1454 | + EE_Registry::instance()->load_model('State'); |
|
1455 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
1456 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
1457 | 1457 | } |
1458 | 1458 | // get Country ISO |
1459 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
1460 | - if ( ! empty( $CNT_ISO ) ) { |
|
1459 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
1460 | + if ( ! empty($CNT_ISO)) { |
|
1461 | 1461 | // can we get country object from name ? |
1462 | - EE_Registry::instance()->load_model( 'Country' ); |
|
1462 | + EE_Registry::instance()->load_model('Country'); |
|
1463 | 1463 | $country = EEM_Country::instance()->get_col( |
1464 | - array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ), |
|
1464 | + array(array('CNT_name' => $CNT_ISO), 'limit' => 1), |
|
1465 | 1465 | 'CNT_ISO' |
1466 | 1466 | ); |
1467 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
1467 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
1468 | 1468 | } |
1469 | 1469 | // grab attendee data |
1470 | 1470 | $attendee_data = array( |
1471 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
1472 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1473 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1474 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1475 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1476 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
1471 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
1472 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1473 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1474 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1475 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1476 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1477 | 1477 | 'STA_ID' => $STA_ID, |
1478 | 1478 | 'CNT_ISO' => $CNT_ISO, |
1479 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1480 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1479 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1480 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1481 | 1481 | ); |
1482 | 1482 | // validate the email address since it is the most important piece of info |
1483 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) { |
|
1483 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) { |
|
1484 | 1484 | EE_Error::add_error( |
1485 | - __( 'An invalid email address was submitted.', 'event_espresso' ), |
|
1485 | + __('An invalid email address was submitted.', 'event_espresso'), |
|
1486 | 1486 | __FILE__, |
1487 | 1487 | __FUNCTION__, |
1488 | 1488 | __LINE__ |
1489 | 1489 | ); |
1490 | 1490 | } |
1491 | 1491 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1492 | - if ( ! empty( $attendee_data['ATT_fname'] ) |
|
1493 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1494 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1492 | + if ( ! empty($attendee_data['ATT_fname']) |
|
1493 | + && ! empty($attendee_data['ATT_lname']) |
|
1494 | + && ! empty($attendee_data['ATT_email']) |
|
1495 | 1495 | ) { |
1496 | 1496 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1497 | 1497 | array( |
@@ -1500,19 +1500,19 @@ discard block |
||
1500 | 1500 | 'ATT_email' => $attendee_data['ATT_email'] |
1501 | 1501 | ) |
1502 | 1502 | ); |
1503 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1503 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1504 | 1504 | return $existing_attendee; |
1505 | 1505 | } |
1506 | 1506 | } |
1507 | 1507 | // no existing attendee? kk let's create a new one |
1508 | 1508 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1509 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) |
|
1509 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) |
|
1510 | 1510 | ? $attendee_data['ATT_fname'] |
1511 | 1511 | : $attendee_data['ATT_email']; |
1512 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) |
|
1512 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) |
|
1513 | 1513 | ? $attendee_data['ATT_lname'] |
1514 | 1514 | : $attendee_data['ATT_email']; |
1515 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1515 | + return EE_Attendee::new_instance($attendee_data); |
|
1516 | 1516 | } |
1517 | 1517 | |
1518 | 1518 | |
@@ -1530,26 +1530,26 @@ discard block |
||
1530 | 1530 | // how have they chosen to pay? |
1531 | 1531 | $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() |
1532 | 1532 | ? 'no_payment_required' |
1533 | - : $this->_get_selected_method_of_payment( true ); |
|
1533 | + : $this->_get_selected_method_of_payment(true); |
|
1534 | 1534 | // choose your own adventure based on method_of_payment |
1535 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
1535 | + switch ($this->checkout->selected_method_of_payment) { |
|
1536 | 1536 | |
1537 | 1537 | case 'events_sold_out' : |
1538 | 1538 | $this->checkout->redirect = true; |
1539 | 1539 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1540 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1540 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1541 | 1541 | // mark this reg step as completed |
1542 | 1542 | $this->set_completed(); |
1543 | 1543 | return false; |
1544 | 1544 | break; |
1545 | 1545 | |
1546 | 1546 | case 'payments_closed' : |
1547 | - if ( apply_filters( |
|
1547 | + if (apply_filters( |
|
1548 | 1548 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', |
1549 | 1549 | false |
1550 | - ) ) { |
|
1550 | + )) { |
|
1551 | 1551 | EE_Error::add_success( |
1552 | - __( 'no payment required at this time.', 'event_espresso' ), |
|
1552 | + __('no payment required at this time.', 'event_espresso'), |
|
1553 | 1553 | __FILE__, |
1554 | 1554 | __FUNCTION__, |
1555 | 1555 | __LINE__ |
@@ -1561,12 +1561,12 @@ discard block |
||
1561 | 1561 | break; |
1562 | 1562 | |
1563 | 1563 | case 'no_payment_required' : |
1564 | - if ( apply_filters( |
|
1564 | + if (apply_filters( |
|
1565 | 1565 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', |
1566 | 1566 | false |
1567 | - ) ) { |
|
1567 | + )) { |
|
1568 | 1568 | EE_Error::add_success( |
1569 | - __( 'no payment required.', 'event_espresso' ), |
|
1569 | + __('no payment required.', 'event_espresso'), |
|
1570 | 1570 | __FILE__, |
1571 | 1571 | __FUNCTION__, |
1572 | 1572 | __LINE__ |
@@ -1586,15 +1586,15 @@ discard block |
||
1586 | 1586 | EE_Registry::instance()->SSN->checkout()->revisit |
1587 | 1587 | ); |
1588 | 1588 | // calculate difference between the two arrays |
1589 | - $registrations = array_diff( $registrations, $ejected_registrations ); |
|
1590 | - if ( empty( $registrations ) ) { |
|
1589 | + $registrations = array_diff($registrations, $ejected_registrations); |
|
1590 | + if (empty($registrations)) { |
|
1591 | 1591 | $this->_redirect_because_event_sold_out(); |
1592 | 1592 | return false; |
1593 | 1593 | } |
1594 | 1594 | $payment_successful = $this->_process_payment(); |
1595 | - if ( $payment_successful ) { |
|
1595 | + if ($payment_successful) { |
|
1596 | 1596 | $this->checkout->continue_reg = true; |
1597 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1597 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1598 | 1598 | } else { |
1599 | 1599 | $this->checkout->continue_reg = false; |
1600 | 1600 | } |
@@ -1615,10 +1615,10 @@ discard block |
||
1615 | 1615 | $this->checkout->continue_reg = false; |
1616 | 1616 | // set redirect URL |
1617 | 1617 | $this->checkout->redirect_url = add_query_arg( |
1618 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1618 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1619 | 1619 | $this->checkout->current_step->reg_step_url() |
1620 | 1620 | ); |
1621 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1621 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1622 | 1622 | } |
1623 | 1623 | |
1624 | 1624 | |
@@ -1631,8 +1631,8 @@ discard block |
||
1631 | 1631 | * @return void |
1632 | 1632 | * @throws \EE_Error |
1633 | 1633 | */ |
1634 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1635 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1634 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1635 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1636 | 1636 | case EE_PMT_Base::offsite : |
1637 | 1637 | break; |
1638 | 1638 | case EE_PMT_Base::onsite : |
@@ -1655,7 +1655,7 @@ discard block |
||
1655 | 1655 | public function update_reg_step() { |
1656 | 1656 | $success = true; |
1657 | 1657 | // if payment required |
1658 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1658 | + if ($this->checkout->transaction->total() > 0) { |
|
1659 | 1659 | do_action( |
1660 | 1660 | 'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', |
1661 | 1661 | $this->checkout->transaction |
@@ -1663,13 +1663,13 @@ discard block |
||
1663 | 1663 | // attempt payment via payment method |
1664 | 1664 | $success = $this->process_reg_step(); |
1665 | 1665 | } |
1666 | - if ( $success && ! $this->checkout->redirect ) { |
|
1666 | + if ($success && ! $this->checkout->redirect) { |
|
1667 | 1667 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
1668 | 1668 | $this->checkout->transaction->ID() |
1669 | 1669 | ); |
1670 | 1670 | // set return URL |
1671 | 1671 | $this->checkout->redirect_url = add_query_arg( |
1672 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1672 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1673 | 1673 | $this->checkout->thank_you_page_url |
1674 | 1674 | ); |
1675 | 1675 | } |
@@ -1687,36 +1687,36 @@ discard block |
||
1687 | 1687 | */ |
1688 | 1688 | private function _process_payment() { |
1689 | 1689 | // basically confirm that the event hasn't sold out since they hit the page |
1690 | - if ( ! $this->_last_second_ticket_verifications() ) { |
|
1690 | + if ( ! $this->_last_second_ticket_verifications()) { |
|
1691 | 1691 | return false; |
1692 | 1692 | } |
1693 | 1693 | // ya gotta make a choice man |
1694 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1694 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1695 | 1695 | $this->checkout->json_response->set_plz_select_method_of_payment( |
1696 | - __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
1696 | + __('Please select a method of payment before proceeding.', 'event_espresso') |
|
1697 | 1697 | ); |
1698 | 1698 | return false; |
1699 | 1699 | } |
1700 | 1700 | // get EE_Payment_Method object |
1701 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1701 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1702 | 1702 | return false; |
1703 | 1703 | } |
1704 | 1704 | // setup billing form |
1705 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1705 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1706 | 1706 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1707 | 1707 | $this->checkout->payment_method |
1708 | 1708 | ); |
1709 | 1709 | // bad billing form ? |
1710 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1710 | + if ( ! $this->_billing_form_is_valid()) { |
|
1711 | 1711 | return false; |
1712 | 1712 | } |
1713 | 1713 | } |
1714 | 1714 | // ensure primary registrant has been fully processed |
1715 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1715 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1716 | 1716 | return false; |
1717 | 1717 | } |
1718 | 1718 | // if session is close to expiring (under 10 minutes by default) |
1719 | - if ( ( time() - EE_Registry::instance()->SSN->expiration() ) < EE_Registry::instance()->SSN->extension() ) { |
|
1719 | + if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) { |
|
1720 | 1720 | // add some time to session expiration so that payment can be completed |
1721 | 1721 | EE_Registry::instance()->SSN->extend_expiration(); |
1722 | 1722 | } |
@@ -1725,12 +1725,12 @@ discard block |
||
1725 | 1725 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
1726 | 1726 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1727 | 1727 | // attempt payment |
1728 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1728 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1729 | 1729 | // process results |
1730 | - $payment = $this->_validate_payment( $payment ); |
|
1731 | - $payment = $this->_post_payment_processing( $payment ); |
|
1730 | + $payment = $this->_validate_payment($payment); |
|
1731 | + $payment = $this->_post_payment_processing($payment); |
|
1732 | 1732 | // verify payment |
1733 | - if ( $payment instanceof EE_Payment ) { |
|
1733 | + if ($payment instanceof EE_Payment) { |
|
1734 | 1734 | // store that for later |
1735 | 1735 | $this->checkout->payment = $payment; |
1736 | 1736 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
@@ -1744,7 +1744,7 @@ discard block |
||
1744 | 1744 | } else { |
1745 | 1745 | return false; |
1746 | 1746 | } |
1747 | - } else if ( $payment === true ) { |
|
1747 | + } else if ($payment === true) { |
|
1748 | 1748 | // please note that offline payment methods will NOT make a payment, |
1749 | 1749 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1750 | 1750 | $this->checkout->payment = $payment; |
@@ -1764,22 +1764,22 @@ discard block |
||
1764 | 1764 | */ |
1765 | 1765 | protected function _last_second_ticket_verifications() { |
1766 | 1766 | // don't bother re-validating if not a return visit |
1767 | - if ( ! $this->checkout->revisit ) { |
|
1767 | + if ( ! $this->checkout->revisit) { |
|
1768 | 1768 | return true; |
1769 | 1769 | } |
1770 | 1770 | $registrations = $this->checkout->transaction->registrations(); |
1771 | - if ( empty( $registrations ) ) { |
|
1771 | + if (empty($registrations)) { |
|
1772 | 1772 | return false; |
1773 | 1773 | } |
1774 | - foreach ( $registrations as $registration ) { |
|
1775 | - if ( $registration instanceof EE_Registration ) { |
|
1774 | + foreach ($registrations as $registration) { |
|
1775 | + if ($registration instanceof EE_Registration) { |
|
1776 | 1776 | $event = $registration->event_obj(); |
1777 | - if ( $event instanceof EE_Event && $event->is_sold_out( true ) ) { |
|
1777 | + if ($event instanceof EE_Event && $event->is_sold_out(true)) { |
|
1778 | 1778 | EE_Error::add_error( |
1779 | 1779 | apply_filters( |
1780 | 1780 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg', |
1781 | 1781 | sprintf( |
1782 | - __( 'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ), |
|
1782 | + __('It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso'), |
|
1783 | 1783 | $event->name() |
1784 | 1784 | ) |
1785 | 1785 | ), |
@@ -1809,7 +1809,7 @@ discard block |
||
1809 | 1809 | ); |
1810 | 1810 | $html = $payment_method_billing_info->get_html(); |
1811 | 1811 | $html .= $this->checkout->redirect_form; |
1812 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1812 | + EE_Registry::instance()->REQ->add_output($html); |
|
1813 | 1813 | return true; |
1814 | 1814 | } |
1815 | 1815 | |
@@ -1823,28 +1823,28 @@ discard block |
||
1823 | 1823 | * @throws \EE_Error |
1824 | 1824 | */ |
1825 | 1825 | private function _billing_form_is_valid() { |
1826 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1826 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1827 | 1827 | return true; |
1828 | 1828 | } |
1829 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1830 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1829 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1830 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1831 | 1831 | $this->checkout->billing_form->receive_form_submission(); |
1832 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1832 | + if ($this->checkout->billing_form->is_valid()) { |
|
1833 | 1833 | return true; |
1834 | 1834 | } |
1835 | 1835 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1836 | 1836 | $error_strings = array(); |
1837 | - foreach ( $validation_errors as $validation_error ) { |
|
1838 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1837 | + foreach ($validation_errors as $validation_error) { |
|
1838 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1839 | 1839 | $form_section = $validation_error->get_form_section(); |
1840 | - if ( $form_section instanceof EE_Form_Input_Base ) { |
|
1840 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1841 | 1841 | $label = $form_section->html_label_text(); |
1842 | - } elseif ( $form_section instanceof EE_Form_Section_Base ) { |
|
1842 | + } elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1843 | 1843 | $label = $form_section->name(); |
1844 | 1844 | } else { |
1845 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1845 | + $label = __('Validation Error', 'event_espresso'); |
|
1846 | 1846 | } |
1847 | - $error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1847 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1848 | 1848 | } |
1849 | 1849 | } |
1850 | 1850 | EE_Error::add_error( |
@@ -1854,7 +1854,7 @@ discard block |
||
1854 | 1854 | 'event_espresso' |
1855 | 1855 | ), |
1856 | 1856 | '<br/>', |
1857 | - implode( '<br/>', $error_strings ) |
|
1857 | + implode('<br/>', $error_strings) |
|
1858 | 1858 | ), |
1859 | 1859 | __FILE__, |
1860 | 1860 | __FUNCTION__, |
@@ -1873,7 +1873,7 @@ discard block |
||
1873 | 1873 | } |
1874 | 1874 | } else { |
1875 | 1875 | EE_Error::add_error( |
1876 | - __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), |
|
1876 | + __('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), |
|
1877 | 1877 | __FILE__, |
1878 | 1878 | __FUNCTION__, |
1879 | 1879 | __LINE__ |
@@ -1912,7 +1912,7 @@ discard block |
||
1912 | 1912 | // save the TXN ( which clears cached copy of primary_registration) |
1913 | 1913 | $this->checkout->transaction->save(); |
1914 | 1914 | // grab TXN ID and save it to the primary_registration |
1915 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1915 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1916 | 1916 | // save what we have so far |
1917 | 1917 | $primary_registration->save(); |
1918 | 1918 | return true; |
@@ -1930,7 +1930,7 @@ discard block |
||
1930 | 1930 | private function _capture_primary_registration_data_from_billing_form() { |
1931 | 1931 | // convert billing form data into an attendee |
1932 | 1932 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1933 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1933 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1934 | 1934 | EE_Error::add_error( |
1935 | 1935 | sprintf( |
1936 | 1936 | __( |
@@ -1938,7 +1938,7 @@ discard block |
||
1938 | 1938 | 'event_espresso' |
1939 | 1939 | ), |
1940 | 1940 | '<br/>', |
1941 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1941 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1942 | 1942 | ), |
1943 | 1943 | __FILE__, |
1944 | 1944 | __FUNCTION__, |
@@ -1947,7 +1947,7 @@ discard block |
||
1947 | 1947 | return false; |
1948 | 1948 | } |
1949 | 1949 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1950 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1950 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1951 | 1951 | EE_Error::add_error( |
1952 | 1952 | sprintf( |
1953 | 1953 | __( |
@@ -1955,7 +1955,7 @@ discard block |
||
1955 | 1955 | 'event_espresso' |
1956 | 1956 | ), |
1957 | 1957 | '<br/>', |
1958 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1958 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1959 | 1959 | ), |
1960 | 1960 | __FILE__, |
1961 | 1961 | __FUNCTION__, |
@@ -1963,7 +1963,7 @@ discard block |
||
1963 | 1963 | ); |
1964 | 1964 | return false; |
1965 | 1965 | } |
1966 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
|
1966 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
1967 | 1967 | instanceof |
1968 | 1968 | EE_Attendee |
1969 | 1969 | ) { |
@@ -1974,7 +1974,7 @@ discard block |
||
1974 | 1974 | 'event_espresso' |
1975 | 1975 | ), |
1976 | 1976 | '<br/>', |
1977 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1977 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1978 | 1978 | ), |
1979 | 1979 | __FILE__, |
1980 | 1980 | __FUNCTION__, |
@@ -1983,9 +1983,9 @@ discard block |
||
1983 | 1983 | return false; |
1984 | 1984 | } |
1985 | 1985 | /** @type EE_Registration_Processor $registration_processor */ |
1986 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1986 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1987 | 1987 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1988 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
1988 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
1989 | 1989 | return true; |
1990 | 1990 | } |
1991 | 1991 | |
@@ -2000,22 +2000,22 @@ discard block |
||
2000 | 2000 | * @throws \EE_Error |
2001 | 2001 | */ |
2002 | 2002 | private function _get_payment_method_for_selected_method_of_payment() { |
2003 | - if ( $this->checkout->selected_method_of_payment === 'events_sold_out' ) { |
|
2003 | + if ($this->checkout->selected_method_of_payment === 'events_sold_out') { |
|
2004 | 2004 | $this->_redirect_because_event_sold_out(); |
2005 | 2005 | return null; |
2006 | 2006 | } |
2007 | 2007 | // get EE_Payment_Method object |
2008 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) { |
|
2009 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
2008 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
2009 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
2010 | 2010 | } else { |
2011 | 2011 | // load EEM_Payment_Method |
2012 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
2012 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
2013 | 2013 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
2014 | 2014 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
2015 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
2015 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
2016 | 2016 | } |
2017 | 2017 | // verify $payment_method |
2018 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
2018 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
2019 | 2019 | // not a payment |
2020 | 2020 | EE_Error::add_error( |
2021 | 2021 | sprintf( |
@@ -2024,7 +2024,7 @@ discard block |
||
2024 | 2024 | 'event_espresso' |
2025 | 2025 | ), |
2026 | 2026 | '<br/>', |
2027 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2027 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2028 | 2028 | ), |
2029 | 2029 | __FILE__, |
2030 | 2030 | __FUNCTION__, |
@@ -2033,7 +2033,7 @@ discard block |
||
2033 | 2033 | return null; |
2034 | 2034 | } |
2035 | 2035 | // and verify it has a valid Payment_Method Type object |
2036 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
2036 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
2037 | 2037 | // not a payment |
2038 | 2038 | EE_Error::add_error( |
2039 | 2039 | sprintf( |
@@ -2042,7 +2042,7 @@ discard block |
||
2042 | 2042 | 'event_espresso' |
2043 | 2043 | ), |
2044 | 2044 | '<br/>', |
2045 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2045 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2046 | 2046 | ), |
2047 | 2047 | __FILE__, |
2048 | 2048 | __FUNCTION__, |
@@ -2063,29 +2063,29 @@ discard block |
||
2063 | 2063 | * @return mixed EE_Payment | boolean |
2064 | 2064 | * @throws \EE_Error |
2065 | 2065 | */ |
2066 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
2066 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
2067 | 2067 | $payment = null; |
2068 | 2068 | $this->checkout->transaction->save(); |
2069 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
2070 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
2069 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2070 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
2071 | 2071 | return false; |
2072 | 2072 | } |
2073 | 2073 | try { |
2074 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
2074 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
2075 | 2075 | // generate payment object |
2076 | 2076 | $payment = $payment_processor->process_payment( |
2077 | 2077 | $payment_method, |
2078 | 2078 | $this->checkout->transaction, |
2079 | 2079 | $this->checkout->amount_owing, |
2080 | 2080 | $this->checkout->billing_form, |
2081 | - $this->_get_return_url( $payment_method ), |
|
2081 | + $this->_get_return_url($payment_method), |
|
2082 | 2082 | 'CART', |
2083 | 2083 | $this->checkout->admin_request, |
2084 | 2084 | true, |
2085 | 2085 | $this->reg_step_url() |
2086 | 2086 | ); |
2087 | - } catch ( Exception $e ) { |
|
2088 | - $this->_handle_payment_processor_exception( $e ); |
|
2087 | + } catch (Exception $e) { |
|
2088 | + $this->_handle_payment_processor_exception($e); |
|
2089 | 2089 | } |
2090 | 2090 | return $payment; |
2091 | 2091 | } |
@@ -2100,7 +2100,7 @@ discard block |
||
2100 | 2100 | * @return void |
2101 | 2101 | * @throws \EE_Error |
2102 | 2102 | */ |
2103 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
2103 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
2104 | 2104 | EE_Error::add_error( |
2105 | 2105 | sprintf( |
2106 | 2106 | __( |
@@ -2108,7 +2108,7 @@ discard block |
||
2108 | 2108 | 'event_espresso' |
2109 | 2109 | ), |
2110 | 2110 | '<br/>', |
2111 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
2111 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
2112 | 2112 | $e->getMessage(), |
2113 | 2113 | $e->getFile(), |
2114 | 2114 | $e->getLine() |
@@ -2129,9 +2129,9 @@ discard block |
||
2129 | 2129 | * @return string |
2130 | 2130 | * @throws \EE_Error |
2131 | 2131 | */ |
2132 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
2132 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
2133 | 2133 | $return_url = ''; |
2134 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
2134 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
2135 | 2135 | case EE_PMT_Base::offsite : |
2136 | 2136 | $return_url = add_query_arg( |
2137 | 2137 | array( |
@@ -2160,12 +2160,12 @@ discard block |
||
2160 | 2160 | * @return EE_Payment | FALSE |
2161 | 2161 | * @throws \EE_Error |
2162 | 2162 | */ |
2163 | - private function _validate_payment( $payment = null ) { |
|
2164 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
2163 | + private function _validate_payment($payment = null) { |
|
2164 | + if ($this->checkout->payment_method->is_off_line()) { |
|
2165 | 2165 | return true; |
2166 | 2166 | } |
2167 | 2167 | // verify payment object |
2168 | - if ( ! $payment instanceof EE_Payment ) { |
|
2168 | + if ( ! $payment instanceof EE_Payment) { |
|
2169 | 2169 | // not a payment |
2170 | 2170 | EE_Error::add_error( |
2171 | 2171 | sprintf( |
@@ -2174,7 +2174,7 @@ discard block |
||
2174 | 2174 | 'event_espresso' |
2175 | 2175 | ), |
2176 | 2176 | '<br/>', |
2177 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2177 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2178 | 2178 | ), |
2179 | 2179 | __FILE__, |
2180 | 2180 | __FUNCTION__, |
@@ -2195,27 +2195,27 @@ discard block |
||
2195 | 2195 | * @return bool |
2196 | 2196 | * @throws \EE_Error |
2197 | 2197 | */ |
2198 | - private function _post_payment_processing( $payment = null ) { |
|
2198 | + private function _post_payment_processing($payment = null) { |
|
2199 | 2199 | // Off-Line payment? |
2200 | - if ( $payment === true ) { |
|
2200 | + if ($payment === true) { |
|
2201 | 2201 | //$this->_setup_redirect_for_next_step(); |
2202 | 2202 | return true; |
2203 | 2203 | // On-Site payment? |
2204 | - } else if ( $this->checkout->payment_method->is_on_site() ) { |
|
2205 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) { |
|
2204 | + } else if ($this->checkout->payment_method->is_on_site()) { |
|
2205 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
2206 | 2206 | //$this->_setup_redirect_for_next_step(); |
2207 | 2207 | $this->checkout->continue_reg = false; |
2208 | 2208 | } |
2209 | 2209 | // Off-Site payment? |
2210 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
2210 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
2211 | 2211 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
2212 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ) { |
|
2213 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
2212 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
2213 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
2214 | 2214 | $this->checkout->redirect = true; |
2215 | 2215 | $this->checkout->redirect_form = $payment->redirect_form(); |
2216 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
2216 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
2217 | 2217 | // set JSON response |
2218 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
2218 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
2219 | 2219 | // set cron job for finalizing the TXN |
2220 | 2220 | // in case the user does not return from the off-site gateway |
2221 | 2221 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -2223,7 +2223,7 @@ discard block |
||
2223 | 2223 | $this->checkout->transaction->ID() |
2224 | 2224 | ); |
2225 | 2225 | // and lastly, let's bump the payment status to pending |
2226 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
2226 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
2227 | 2227 | $payment->save(); |
2228 | 2228 | } else { |
2229 | 2229 | // not a payment |
@@ -2235,7 +2235,7 @@ discard block |
||
2235 | 2235 | 'event_espresso' |
2236 | 2236 | ), |
2237 | 2237 | '<br/>', |
2238 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2238 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2239 | 2239 | ), |
2240 | 2240 | __FILE__, |
2241 | 2241 | __FUNCTION__, |
@@ -2273,21 +2273,21 @@ discard block |
||
2273 | 2273 | * @return bool |
2274 | 2274 | * @throws \EE_Error |
2275 | 2275 | */ |
2276 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
2276 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
2277 | 2277 | // off-line payment? carry on |
2278 | - if ( $payment_occurs === EE_PMT_Base::offline ) { |
|
2278 | + if ($payment_occurs === EE_PMT_Base::offline) { |
|
2279 | 2279 | return true; |
2280 | 2280 | } |
2281 | 2281 | // verify payment validity |
2282 | - if ( $payment instanceof EE_Payment ) { |
|
2283 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
2282 | + if ($payment instanceof EE_Payment) { |
|
2283 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
2284 | 2284 | $msg = $payment->gateway_response(); |
2285 | 2285 | // check results |
2286 | - switch ( $payment->status() ) { |
|
2286 | + switch ($payment->status()) { |
|
2287 | 2287 | // good payment |
2288 | 2288 | case EEM_Payment::status_id_approved : |
2289 | 2289 | EE_Error::add_success( |
2290 | - __( 'Your payment was processed successfully.', 'event_espresso' ), |
|
2290 | + __('Your payment was processed successfully.', 'event_espresso'), |
|
2291 | 2291 | __FILE__, |
2292 | 2292 | __FUNCTION__, |
2293 | 2293 | __LINE__ |
@@ -2296,45 +2296,45 @@ discard block |
||
2296 | 2296 | break; |
2297 | 2297 | // slow payment |
2298 | 2298 | case EEM_Payment::status_id_pending : |
2299 | - if ( empty( $msg ) ) { |
|
2299 | + if (empty($msg)) { |
|
2300 | 2300 | $msg = __( |
2301 | 2301 | 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', |
2302 | 2302 | 'event_espresso' |
2303 | 2303 | ); |
2304 | 2304 | } |
2305 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2305 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2306 | 2306 | return true; |
2307 | 2307 | break; |
2308 | 2308 | // don't wanna payment |
2309 | 2309 | case EEM_Payment::status_id_cancelled : |
2310 | - if ( empty( $msg ) ) { |
|
2310 | + if (empty($msg)) { |
|
2311 | 2311 | $msg = _n( |
2312 | 2312 | 'Payment cancelled. Please try again.', |
2313 | 2313 | 'Payment cancelled. Please try again or select another method of payment.', |
2314 | - count( $this->checkout->available_payment_methods ), |
|
2314 | + count($this->checkout->available_payment_methods), |
|
2315 | 2315 | 'event_espresso' |
2316 | 2316 | ); |
2317 | 2317 | } |
2318 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2318 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2319 | 2319 | return false; |
2320 | 2320 | break; |
2321 | 2321 | // not enough payment |
2322 | 2322 | case EEM_Payment::status_id_declined : |
2323 | - if ( empty( $msg ) ) { |
|
2323 | + if (empty($msg)) { |
|
2324 | 2324 | $msg = _n( |
2325 | 2325 | 'We\'re sorry but your payment was declined. Please try again.', |
2326 | 2326 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
2327 | - count( $this->checkout->available_payment_methods ), |
|
2327 | + count($this->checkout->available_payment_methods), |
|
2328 | 2328 | 'event_espresso' |
2329 | 2329 | ); |
2330 | 2330 | } |
2331 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2331 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2332 | 2332 | return false; |
2333 | 2333 | break; |
2334 | 2334 | // bad payment |
2335 | 2335 | case EEM_Payment::status_id_failed : |
2336 | - if ( ! empty( $msg ) ) { |
|
2337 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2336 | + if ( ! empty($msg)) { |
|
2337 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2338 | 2338 | return false; |
2339 | 2339 | } |
2340 | 2340 | // default to error below |
@@ -2343,7 +2343,7 @@ discard block |
||
2343 | 2343 | } |
2344 | 2344 | // off-site payment gateway responses are too unreliable, so let's just assume that |
2345 | 2345 | // the payment processing is just running slower than the registrant's request |
2346 | - if ( $payment_occurs === EE_PMT_Base::offsite ) { |
|
2346 | + if ($payment_occurs === EE_PMT_Base::offsite) { |
|
2347 | 2347 | return true; |
2348 | 2348 | } |
2349 | 2349 | EE_Error::add_error( |
@@ -2353,7 +2353,7 @@ discard block |
||
2353 | 2353 | 'event_espresso' |
2354 | 2354 | ), |
2355 | 2355 | '<br/>', |
2356 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2356 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2357 | 2357 | ), |
2358 | 2358 | __FILE__, |
2359 | 2359 | __FUNCTION__, |
@@ -2386,13 +2386,13 @@ discard block |
||
2386 | 2386 | public function process_gateway_response() { |
2387 | 2387 | $payment = null; |
2388 | 2388 | // how have they chosen to pay? |
2389 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
2389 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
2390 | 2390 | // get EE_Payment_Method object |
2391 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
2391 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
2392 | 2392 | $this->checkout->continue_reg = false; |
2393 | 2393 | return false; |
2394 | 2394 | } |
2395 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
2395 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
2396 | 2396 | return false; |
2397 | 2397 | } |
2398 | 2398 | $this->_validate_offsite_return(); |
@@ -2406,23 +2406,23 @@ discard block |
||
2406 | 2406 | // true |
2407 | 2407 | //); |
2408 | 2408 | // verify TXN |
2409 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
2409 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
2410 | 2410 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
2411 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
2411 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
2412 | 2412 | $this->checkout->continue_reg = false; |
2413 | 2413 | return false; |
2414 | 2414 | } |
2415 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
2416 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
2417 | - $payment = $this->_validate_payment( $payment ); |
|
2415 | + $payment = $this->_process_off_site_payment($gateway); |
|
2416 | + $payment = $this->_process_cancelled_payments($payment); |
|
2417 | + $payment = $this->_validate_payment($payment); |
|
2418 | 2418 | // if payment was not declined by the payment gateway or cancelled by the registrant |
2419 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
2419 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
2420 | 2420 | //$this->_setup_redirect_for_next_step(); |
2421 | 2421 | // store that for later |
2422 | 2422 | $this->checkout->payment = $payment; |
2423 | 2423 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
2424 | 2424 | // because we will complete this step during the IPN processing then |
2425 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) { |
|
2425 | + if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) { |
|
2426 | 2426 | $this->set_completed(); |
2427 | 2427 | } |
2428 | 2428 | return true; |
@@ -2446,21 +2446,21 @@ discard block |
||
2446 | 2446 | * @throws \EE_Error |
2447 | 2447 | */ |
2448 | 2448 | private function _validate_offsite_return() { |
2449 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
2450 | - if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
|
2449 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
2450 | + if ($TXN_ID !== $this->checkout->transaction->ID()) { |
|
2451 | 2451 | // Houston... we might have a problem |
2452 | 2452 | $invalid_TXN = false; |
2453 | 2453 | // first gather some info |
2454 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
2454 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
2455 | 2455 | $primary_registrant = $valid_TXN instanceof EE_Transaction |
2456 | 2456 | ? $valid_TXN->primary_registration() |
2457 | 2457 | : null; |
2458 | 2458 | // let's start by retrieving the cart for this TXN |
2459 | - $cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction ); |
|
2460 | - if ( $cart instanceof EE_Cart ) { |
|
2459 | + $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction); |
|
2460 | + if ($cart instanceof EE_Cart) { |
|
2461 | 2461 | // verify that the current cart has tickets |
2462 | 2462 | $tickets = $cart->get_tickets(); |
2463 | - if ( empty( $tickets ) ) { |
|
2463 | + if (empty($tickets)) { |
|
2464 | 2464 | $invalid_TXN = true; |
2465 | 2465 | } |
2466 | 2466 | } else { |
@@ -2470,35 +2470,35 @@ discard block |
||
2470 | 2470 | ? $primary_registrant->session_ID() |
2471 | 2471 | : null; |
2472 | 2472 | // validate current Session ID and compare against valid TXN session ID |
2473 | - if ( EE_Session::instance()->id() === null ) { |
|
2473 | + if (EE_Session::instance()->id() === null) { |
|
2474 | 2474 | $invalid_TXN = true; |
2475 | - } else if ( EE_Session::instance()->id() === $valid_TXN_SID ) { |
|
2475 | + } else if (EE_Session::instance()->id() === $valid_TXN_SID) { |
|
2476 | 2476 | // WARNING !!! |
2477 | 2477 | // this could be PayPal sending back duplicate requests (ya they do that) |
2478 | 2478 | // or it **could** mean someone is simply registering AGAIN after having just done so |
2479 | 2479 | // so now we need to determine if this current TXN looks valid or not |
2480 | 2480 | // has this step even been started ? |
2481 | - if ( $this->checkout->transaction->reg_step_completed( $this->slug() === false ) |
|
2481 | + if ($this->checkout->transaction->reg_step_completed($this->slug() === false) |
|
2482 | 2482 | ) { |
2483 | 2483 | // really? you're half way through this reg step, but you never started it ? |
2484 | 2484 | $invalid_TXN = true; |
2485 | 2485 | } |
2486 | 2486 | } |
2487 | - if ( $invalid_TXN ) { |
|
2487 | + if ($invalid_TXN) { |
|
2488 | 2488 | // is the valid TXN completed ? |
2489 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
2489 | + if ($valid_TXN instanceof EE_Transaction) { |
|
2490 | 2490 | // has this step even been started ? |
2491 | - $reg_step_completed = $valid_TXN->reg_step_completed( $this->slug() ); |
|
2492 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
2491 | + $reg_step_completed = $valid_TXN->reg_step_completed($this->slug()); |
|
2492 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
2493 | 2493 | // so it **looks** like this is a double request from PayPal |
2494 | 2494 | // so let's try to pick up where we left off |
2495 | 2495 | $this->checkout->transaction = $valid_TXN; |
2496 | - $this->checkout->refresh_all_entities( true ); |
|
2496 | + $this->checkout->refresh_all_entities(true); |
|
2497 | 2497 | return; |
2498 | 2498 | } |
2499 | 2499 | } |
2500 | 2500 | // you appear to be lost? |
2501 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
2501 | + $this->_redirect_wayward_request($primary_registrant); |
|
2502 | 2502 | } |
2503 | 2503 | } |
2504 | 2504 | } |
@@ -2513,14 +2513,14 @@ discard block |
||
2513 | 2513 | * @return bool |
2514 | 2514 | * @throws \EE_Error |
2515 | 2515 | */ |
2516 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
2517 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2516 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
2517 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2518 | 2518 | // try redirecting based on the current TXN |
2519 | 2519 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
2520 | 2520 | ? $this->checkout->transaction->primary_registration() |
2521 | 2521 | : null; |
2522 | 2522 | } |
2523 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2523 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2524 | 2524 | EE_Error::add_error( |
2525 | 2525 | sprintf( |
2526 | 2526 | __( |
@@ -2528,7 +2528,7 @@ discard block |
||
2528 | 2528 | 'event_espresso' |
2529 | 2529 | ), |
2530 | 2530 | '<br/>', |
2531 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2531 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2532 | 2532 | ), |
2533 | 2533 | __FILE__, |
2534 | 2534 | __FUNCTION__, |
@@ -2559,17 +2559,17 @@ discard block |
||
2559 | 2559 | * @return \EE_Payment |
2560 | 2560 | * @throws \EE_Error |
2561 | 2561 | */ |
2562 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
2562 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
2563 | 2563 | try { |
2564 | 2564 | $request_data = \EE_Registry::instance()->REQ->params(); |
2565 | 2565 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
2566 | 2566 | $this->set_handle_IPN_in_this_request( |
2567 | - $gateway->handle_IPN_in_this_request( $request_data, false ) |
|
2567 | + $gateway->handle_IPN_in_this_request($request_data, false) |
|
2568 | 2568 | ); |
2569 | - if ( $this->handle_IPN_in_this_request() ) { |
|
2569 | + if ($this->handle_IPN_in_this_request()) { |
|
2570 | 2570 | // get payment details and process results |
2571 | 2571 | /** @type EE_Payment_Processor $payment_processor */ |
2572 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
2572 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2573 | 2573 | $payment = $payment_processor->process_ipn( |
2574 | 2574 | $request_data, |
2575 | 2575 | $this->checkout->transaction, |
@@ -2582,14 +2582,14 @@ discard block |
||
2582 | 2582 | $payment = $this->checkout->transaction->last_payment(); |
2583 | 2583 | //$payment_source = 'last_payment'; |
2584 | 2584 | } |
2585 | - } catch ( Exception $e ) { |
|
2585 | + } catch (Exception $e) { |
|
2586 | 2586 | // let's just eat the exception and try to move on using any previously set payment info |
2587 | 2587 | $payment = $this->checkout->transaction->last_payment(); |
2588 | 2588 | //$payment_source = 'last_payment after Exception'; |
2589 | 2589 | // but if we STILL don't have a payment object |
2590 | - if ( ! $payment instanceof EE_Payment ) { |
|
2590 | + if ( ! $payment instanceof EE_Payment) { |
|
2591 | 2591 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
2592 | - $this->_handle_payment_processor_exception( $e ); |
|
2592 | + $this->_handle_payment_processor_exception($e); |
|
2593 | 2593 | } |
2594 | 2594 | } |
2595 | 2595 | // DEBUG LOG |
@@ -2614,13 +2614,13 @@ discard block |
||
2614 | 2614 | * @return EE_Payment | FALSE |
2615 | 2615 | * @throws \EE_Error |
2616 | 2616 | */ |
2617 | - private function _process_cancelled_payments( $payment = null ) { |
|
2617 | + private function _process_cancelled_payments($payment = null) { |
|
2618 | 2618 | if ( |
2619 | 2619 | $payment instanceof EE_Payment |
2620 | - && isset( $_REQUEST['ee_cancel_payment'] ) |
|
2620 | + && isset($_REQUEST['ee_cancel_payment']) |
|
2621 | 2621 | && $payment->status() === EEM_Payment::status_id_failed |
2622 | 2622 | ) { |
2623 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
2623 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
2624 | 2624 | } |
2625 | 2625 | return $payment; |
2626 | 2626 | } |
@@ -2637,14 +2637,14 @@ discard block |
||
2637 | 2637 | public function get_transaction_details_for_gateways() { |
2638 | 2638 | $txn_details = array(); |
2639 | 2639 | // ya gotta make a choice man |
2640 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
2640 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
2641 | 2641 | $txn_details = array( |
2642 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
2642 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
2643 | 2643 | ); |
2644 | 2644 | } |
2645 | 2645 | // get EE_Payment_Method object |
2646 | 2646 | if ( |
2647 | - empty( $txn_details ) |
|
2647 | + empty($txn_details) |
|
2648 | 2648 | && |
2649 | 2649 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
2650 | 2650 | ) { |
@@ -2656,8 +2656,8 @@ discard block |
||
2656 | 2656 | ) |
2657 | 2657 | ); |
2658 | 2658 | } |
2659 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
2660 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
2659 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
2660 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
2661 | 2661 | $txn_details = array( |
2662 | 2662 | 'TXN_ID' => $this->checkout->transaction->ID(), |
2663 | 2663 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -2668,7 +2668,7 @@ discard block |
||
2668 | 2668 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
2669 | 2669 | 'payment_amount' => $this->checkout->amount_owing, |
2670 | 2670 | 'return_url' => $return_url, |
2671 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
2671 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
2672 | 2672 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
2673 | 2673 | array( |
2674 | 2674 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -2677,7 +2677,7 @@ discard block |
||
2677 | 2677 | ) |
2678 | 2678 | ); |
2679 | 2679 | } |
2680 | - echo json_encode( $txn_details ); |
|
2680 | + echo json_encode($txn_details); |
|
2681 | 2681 | exit(); |
2682 | 2682 | } |
2683 | 2683 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'ABSPATH' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('ABSPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | */ |
44 | 44 | |
45 | -if ( function_exists( 'espresso_version' ) ) { |
|
45 | +if (function_exists('espresso_version')) { |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * espresso_duplicate_plugin_error |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | function espresso_duplicate_plugin_error() { |
52 | 52 | ?> |
53 | 53 | <div class="error"> |
54 | - <p><?php _e( 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso' ); ?></p> |
|
54 | + <p><?php _e('Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso'); ?></p> |
|
55 | 55 | </div> |
56 | 56 | <?php |
57 | - espresso_deactivate_plugin( plugin_basename( __FILE__ ) ); |
|
57 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
58 | 58 | } |
59 | - add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 ); |
|
59 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
60 | 60 | |
61 | 61 | } else { |
62 | 62 | |
@@ -67,103 +67,103 @@ discard block |
||
67 | 67 | * @return string |
68 | 68 | */ |
69 | 69 | function espresso_version() { |
70 | - return apply_filters( 'FHEE__espresso__espresso_version', '4.9.13.rc.016' ); |
|
70 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.13.rc.016'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // define versions |
74 | - define( 'EVENT_ESPRESSO_VERSION', espresso_version() ); |
|
75 | - define( 'EE_MIN_WP_VER_REQUIRED', '4.1' ); |
|
76 | - define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' ); |
|
77 | - define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' ); |
|
78 | - define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' ); |
|
79 | - define( 'EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - ' . EVENT_ESPRESSO_VERSION ); |
|
80 | - define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ ); |
|
74 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
75 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
76 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
77 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.0'); |
|
78 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
79 | + define('EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - '.EVENT_ESPRESSO_VERSION); |
|
80 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
81 | 81 | //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
82 | - if ( ! defined( 'DS' ) ) { |
|
83 | - define( 'DS', '/' ); |
|
82 | + if ( ! defined('DS')) { |
|
83 | + define('DS', '/'); |
|
84 | 84 | } |
85 | - if ( ! defined( 'PS' ) ) { |
|
86 | - define( 'PS', PATH_SEPARATOR ); |
|
85 | + if ( ! defined('PS')) { |
|
86 | + define('PS', PATH_SEPARATOR); |
|
87 | 87 | } |
88 | - if ( ! defined( 'SP' ) ) { |
|
89 | - define( 'SP', ' ' ); |
|
88 | + if ( ! defined('SP')) { |
|
89 | + define('SP', ' '); |
|
90 | 90 | } |
91 | - if ( ! defined( 'EENL' ) ) { |
|
92 | - define( 'EENL', "\n" ); |
|
91 | + if ( ! defined('EENL')) { |
|
92 | + define('EENL', "\n"); |
|
93 | 93 | } |
94 | - define( 'EE_SUPPORT_EMAIL', '[email protected]' ); |
|
94 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
95 | 95 | // define the plugin directory and URL |
96 | - define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
97 | - define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
98 | - define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
96 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
97 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
98 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
99 | 99 | // main root folder paths |
100 | - define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS ); |
|
101 | - define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS ); |
|
102 | - define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS ); |
|
103 | - define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS ); |
|
104 | - define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS ); |
|
105 | - define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS ); |
|
106 | - define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS ); |
|
107 | - define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS ); |
|
100 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS); |
|
101 | + define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS); |
|
102 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS); |
|
103 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS); |
|
104 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS); |
|
105 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS); |
|
106 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS); |
|
107 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS); |
|
108 | 108 | // core system paths |
109 | - define( 'EE_ADMIN', EE_CORE . 'admin' . DS ); |
|
110 | - define( 'EE_CPTS', EE_CORE . 'CPTs' . DS ); |
|
111 | - define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS ); |
|
112 | - define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS ); |
|
113 | - define( 'EE_BUSINESS', EE_CORE . 'business' . DS ); |
|
114 | - define( 'EE_MODELS', EE_CORE . 'db_models' . DS ); |
|
115 | - define( 'EE_HELPERS', EE_CORE . 'helpers' . DS ); |
|
116 | - define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS ); |
|
117 | - define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS ); |
|
118 | - define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS ); |
|
119 | - define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS ); |
|
120 | - define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS ); |
|
109 | + define('EE_ADMIN', EE_CORE.'admin'.DS); |
|
110 | + define('EE_CPTS', EE_CORE.'CPTs'.DS); |
|
111 | + define('EE_CLASSES', EE_CORE.'db_classes'.DS); |
|
112 | + define('EE_INTERFACES', EE_CORE.'interfaces'.DS); |
|
113 | + define('EE_BUSINESS', EE_CORE.'business'.DS); |
|
114 | + define('EE_MODELS', EE_CORE.'db_models'.DS); |
|
115 | + define('EE_HELPERS', EE_CORE.'helpers'.DS); |
|
116 | + define('EE_LIBRARIES', EE_CORE.'libraries'.DS); |
|
117 | + define('EE_TEMPLATES', EE_CORE.'templates'.DS); |
|
118 | + define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS); |
|
119 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS); |
|
120 | + define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS); |
|
121 | 121 | // gateways |
122 | - define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS ); |
|
123 | - define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS ); |
|
122 | + define('EE_GATEWAYS', EE_MODULES.'gateways'.DS); |
|
123 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS); |
|
124 | 124 | // asset URL paths |
125 | - define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS ); |
|
126 | - define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS ); |
|
127 | - define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS ); |
|
128 | - define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS ); |
|
129 | - define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' ); |
|
130 | - define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' ); |
|
125 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS); |
|
126 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS); |
|
127 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS); |
|
128 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS); |
|
129 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/'); |
|
130 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/'); |
|
131 | 131 | // define upload paths |
132 | 132 | $uploads = wp_upload_dir(); |
133 | 133 | // define the uploads directory and URL |
134 | - define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS ); |
|
135 | - define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS ); |
|
134 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS); |
|
135 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS); |
|
136 | 136 | // define the templates directory and URL |
137 | - define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
138 | - define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
137 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS); |
|
138 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS); |
|
139 | 139 | // define the gateway directory and URL |
140 | - define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
141 | - define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
140 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS); |
|
141 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS); |
|
142 | 142 | // languages folder/path |
143 | - define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS ); |
|
144 | - define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS ); |
|
143 | + define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS); |
|
144 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS); |
|
145 | 145 | //check for dompdf fonts in uploads |
146 | - if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) { |
|
147 | - define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ); |
|
146 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) { |
|
147 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS); |
|
148 | 148 | } |
149 | 149 | //ajax constants |
150 | - define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false ); |
|
151 | - define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false ); |
|
150 | + define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false); |
|
151 | + define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false); |
|
152 | 152 | //just a handy constant occasionally needed for finding values representing infinity in the DB |
153 | 153 | //you're better to use this than its straight value (currently -1) in case you ever |
154 | 154 | //want to change its default value! or find when -1 means infinity |
155 | - define( 'EE_INF_IN_DB', -1 ); |
|
156 | - define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX ); |
|
157 | - define( 'EE_DEBUG', false ); |
|
155 | + define('EE_INF_IN_DB', -1); |
|
156 | + define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
157 | + define('EE_DEBUG', false); |
|
158 | 158 | |
159 | 159 | /** |
160 | 160 | * espresso_plugin_activation |
161 | 161 | * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
162 | 162 | */ |
163 | 163 | function espresso_plugin_activation() { |
164 | - update_option( 'ee_espresso_activation', true ); |
|
164 | + update_option('ee_espresso_activation', true); |
|
165 | 165 | } |
166 | - register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' ); |
|
166 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
167 | 167 | |
168 | 168 | |
169 | 169 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | // } |
178 | 178 | // |
179 | 179 | } |
180 | - register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' ); |
|
180 | + register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
181 | 181 | |
182 | 182 | |
183 | 183 | |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | */ |
188 | 188 | function espresso_load_error_handling() { |
189 | 189 | // load debugging tools |
190 | - if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) { |
|
191 | - require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ); |
|
190 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
191 | + require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php'); |
|
192 | 192 | EEH_Debug_Tools::instance(); |
193 | 193 | } |
194 | 194 | // load error handling |
195 | - if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) { |
|
196 | - require_once( EE_CORE . 'EE_Error.core.php' ); |
|
195 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
196 | + require_once(EE_CORE.'EE_Error.core.php'); |
|
197 | 197 | } else { |
198 | - wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) ); |
|
198 | + wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
@@ -209,25 +209,25 @@ discard block |
||
209 | 209 | * @param string $full_path_to_file |
210 | 210 | * @throws EE_Error |
211 | 211 | */ |
212 | - function espresso_load_required( $classname, $full_path_to_file ) { |
|
212 | + function espresso_load_required($classname, $full_path_to_file) { |
|
213 | 213 | static $error_handling_loaded = false; |
214 | - if ( ! $error_handling_loaded ) { |
|
214 | + if ( ! $error_handling_loaded) { |
|
215 | 215 | espresso_load_error_handling(); |
216 | 216 | $error_handling_loaded = true; |
217 | 217 | } |
218 | - if ( is_readable( $full_path_to_file ) ) { |
|
219 | - require_once( $full_path_to_file ); |
|
218 | + if (is_readable($full_path_to_file)) { |
|
219 | + require_once($full_path_to_file); |
|
220 | 220 | } else { |
221 | - throw new EE_Error ( sprintf( |
|
222 | - __( 'The %s class file could not be located or is not readable due to file permissions.', 'event_espresso' ), |
|
221 | + throw new EE_Error(sprintf( |
|
222 | + __('The %s class file could not be located or is not readable due to file permissions.', 'event_espresso'), |
|
223 | 223 | $classname |
224 | - ) ); |
|
224 | + )); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | - espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' ); |
|
229 | - espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' ); |
|
230 | - espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' ); |
|
228 | + espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php'); |
|
229 | + espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php'); |
|
230 | + espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php'); |
|
231 | 231 | new EE_Bootstrap(); |
232 | 232 | |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | |
238 | 238 | |
239 | -if ( ! function_exists( 'espresso_deactivate_plugin' ) ) { |
|
239 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
240 | 240 | /** |
241 | 241 | * deactivate_plugin |
242 | 242 | * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
246 | 246 | * @return void |
247 | 247 | */ |
248 | - function espresso_deactivate_plugin( $plugin_basename = '' ) { |
|
249 | - if ( ! function_exists( 'deactivate_plugins' ) ) { |
|
250 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
248 | + function espresso_deactivate_plugin($plugin_basename = '') { |
|
249 | + if ( ! function_exists('deactivate_plugins')) { |
|
250 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
251 | 251 | } |
252 | - unset( $_GET[ 'activate' ], $_REQUEST[ 'activate' ] ); |
|
253 | - deactivate_plugins( $plugin_basename ); |
|
252 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
253 | + deactivate_plugins($plugin_basename); |
|
254 | 254 | } |
255 | 255 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * EEH_Line_Item |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * @return boolean success |
46 | 46 | * @throws \EE_Error |
47 | 47 | */ |
48 | - public static function add_unrelated_item( EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL ){ |
|
49 | - $items_subtotal = self::get_pre_tax_subtotal( $parent_line_item ); |
|
48 | + public static function add_unrelated_item(EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL) { |
|
49 | + $items_subtotal = self::get_pre_tax_subtotal($parent_line_item); |
|
50 | 50 | $line_item = EE_Line_Item::new_instance(array( |
51 | 51 | 'LIN_name' => $name, |
52 | 52 | 'LIN_desc' => $description, |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'LIN_quantity' => $quantity, |
55 | 55 | 'LIN_percent' => null, |
56 | 56 | 'LIN_is_taxable' => $taxable, |
57 | - 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0, |
|
57 | + 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0, |
|
58 | 58 | 'LIN_total' => (float) $unit_price * (int) $quantity, |
59 | 59 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
60 | 60 | 'LIN_code' => $code, |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $line_item, |
65 | 65 | $parent_line_item |
66 | 66 | ); |
67 | - return self::add_item( $parent_line_item, $line_item ); |
|
67 | + return self::add_item($parent_line_item, $line_item); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return boolean success |
87 | 87 | * @throws \EE_Error |
88 | 88 | */ |
89 | - public static function add_percentage_based_item( EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE ){ |
|
89 | + public static function add_percentage_based_item(EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE) { |
|
90 | 90 | $line_item = EE_Line_Item::new_instance(array( |
91 | 91 | 'LIN_name' => $name, |
92 | 92 | 'LIN_desc' => $description, |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | 'LIN_percent' => $percentage_amount, |
95 | 95 | 'LIN_quantity' => NULL, |
96 | 96 | 'LIN_is_taxable' => $taxable, |
97 | - 'LIN_total' => (float) ( $percentage_amount * ( $parent_line_item->total() / 100 ) ), |
|
97 | + 'LIN_total' => (float) ($percentage_amount * ($parent_line_item->total() / 100)), |
|
98 | 98 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
99 | 99 | 'LIN_parent' => $parent_line_item->ID() |
100 | 100 | )); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | 'FHEE__EEH_Line_Item__add_percentage_based_item__line_item', |
103 | 103 | $line_item |
104 | 104 | ); |
105 | - return self::add_item( $parent_line_item, $line_item ); |
|
105 | + return self::add_item($parent_line_item, $line_item); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -123,15 +123,15 @@ discard block |
||
123 | 123 | * @return \EE_Line_Item |
124 | 124 | * @throws \EE_Error |
125 | 125 | */ |
126 | - public static function add_ticket_purchase( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){ |
|
127 | - if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total() ) { |
|
128 | - throw new EE_Error( sprintf( __( 'A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) ); |
|
126 | + public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
127 | + if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total()) { |
|
128 | + throw new EE_Error(sprintf(__('A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso'), $ticket->ID(), $total_line_item->ID())); |
|
129 | 129 | } |
130 | 130 | // either increment the qty for an existing ticket |
131 | - $line_item = self::increment_ticket_qty_if_already_in_cart( $total_line_item, $ticket, $qty ); |
|
131 | + $line_item = self::increment_ticket_qty_if_already_in_cart($total_line_item, $ticket, $qty); |
|
132 | 132 | // or add a new one |
133 | - if ( ! $line_item instanceof EE_Line_Item ) { |
|
134 | - $line_item = self::create_ticket_line_item( $total_line_item, $ticket, $qty ); |
|
133 | + if ( ! $line_item instanceof EE_Line_Item) { |
|
134 | + $line_item = self::create_ticket_line_item($total_line_item, $ticket, $qty); |
|
135 | 135 | } |
136 | 136 | $total_line_item->recalculate_total_including_taxes(); |
137 | 137 | return $line_item; |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | * @return \EE_Line_Item |
148 | 148 | * @throws \EE_Error |
149 | 149 | */ |
150 | - public static function increment_ticket_qty_if_already_in_cart( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
150 | + public static function increment_ticket_qty_if_already_in_cart(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
151 | 151 | $line_item = null; |
152 | - if ( $total_line_item instanceof EE_Line_Item && $total_line_item->is_total() ) { |
|
153 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items( $total_line_item ); |
|
154 | - foreach ( (array)$ticket_line_items as $ticket_line_item ) { |
|
152 | + if ($total_line_item instanceof EE_Line_Item && $total_line_item->is_total()) { |
|
153 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item); |
|
154 | + foreach ((array) $ticket_line_items as $ticket_line_item) { |
|
155 | 155 | if ( |
156 | 156 | $ticket_line_item instanceof EE_Line_Item |
157 | 157 | && (int) $ticket_line_item->OBJ_ID() === (int) $ticket->ID() |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | - if ( $line_item instanceof EE_Line_Item ) { |
|
165 | - EEH_Line_Item::increment_quantity( $line_item, $qty ); |
|
164 | + if ($line_item instanceof EE_Line_Item) { |
|
165 | + EEH_Line_Item::increment_quantity($line_item, $qty); |
|
166 | 166 | return $line_item; |
167 | 167 | } |
168 | 168 | return null; |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | * @return void |
180 | 180 | * @throws \EE_Error |
181 | 181 | */ |
182 | - public static function increment_quantity( EE_Line_Item $line_item, $qty = 1 ) { |
|
183 | - if( ! $line_item->is_percent() ) { |
|
182 | + public static function increment_quantity(EE_Line_Item $line_item, $qty = 1) { |
|
183 | + if ( ! $line_item->is_percent()) { |
|
184 | 184 | $qty += $line_item->quantity(); |
185 | - $line_item->set_quantity( $qty ); |
|
186 | - $line_item->set_total( $line_item->unit_price() * $qty ); |
|
185 | + $line_item->set_quantity($qty); |
|
186 | + $line_item->set_total($line_item->unit_price() * $qty); |
|
187 | 187 | $line_item->save(); |
188 | 188 | } |
189 | - foreach( $line_item->children() as $child ) { |
|
190 | - if( $child->is_sub_line_item() ) { |
|
191 | - EEH_Line_Item::update_quantity( $child, $qty ); |
|
189 | + foreach ($line_item->children() as $child) { |
|
190 | + if ($child->is_sub_line_item()) { |
|
191 | + EEH_Line_Item::update_quantity($child, $qty); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
@@ -204,17 +204,17 @@ discard block |
||
204 | 204 | * @return void |
205 | 205 | * @throws \EE_Error |
206 | 206 | */ |
207 | - public static function decrement_quantity( EE_Line_Item $line_item, $qty = 1 ) { |
|
208 | - if( ! $line_item->is_percent() ) { |
|
207 | + public static function decrement_quantity(EE_Line_Item $line_item, $qty = 1) { |
|
208 | + if ( ! $line_item->is_percent()) { |
|
209 | 209 | $qty = $line_item->quantity() - $qty; |
210 | - $qty = max( $qty, 0 ); |
|
211 | - $line_item->set_quantity( $qty ); |
|
212 | - $line_item->set_total( $line_item->unit_price() * $qty ); |
|
210 | + $qty = max($qty, 0); |
|
211 | + $line_item->set_quantity($qty); |
|
212 | + $line_item->set_total($line_item->unit_price() * $qty); |
|
213 | 213 | $line_item->save(); |
214 | 214 | } |
215 | - foreach( $line_item->children() as $child ) { |
|
216 | - if( $child->is_sub_line_item() ) { |
|
217 | - EEH_Line_Item::update_quantity( $child, $qty ); |
|
215 | + foreach ($line_item->children() as $child) { |
|
216 | + if ($child->is_sub_line_item()) { |
|
217 | + EEH_Line_Item::update_quantity($child, $qty); |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | * @param int $new_quantity |
230 | 230 | * @throws \EE_Error |
231 | 231 | */ |
232 | - public static function update_quantity( EE_Line_Item $line_item, $new_quantity ) { |
|
233 | - if( ! $line_item->is_percent() ) { |
|
234 | - $line_item->set_quantity( $new_quantity ); |
|
235 | - $line_item->set_total( $line_item->unit_price() * $new_quantity ); |
|
232 | + public static function update_quantity(EE_Line_Item $line_item, $new_quantity) { |
|
233 | + if ( ! $line_item->is_percent()) { |
|
234 | + $line_item->set_quantity($new_quantity); |
|
235 | + $line_item->set_total($line_item->unit_price() * $new_quantity); |
|
236 | 236 | $line_item->save(); |
237 | 237 | } |
238 | - foreach( $line_item->children() as $child ) { |
|
239 | - if( $child->is_sub_line_item() ) { |
|
240 | - EEH_Line_Item::update_quantity( $child, $new_quantity ); |
|
238 | + foreach ($line_item->children() as $child) { |
|
239 | + if ($child->is_sub_line_item()) { |
|
240 | + EEH_Line_Item::update_quantity($child, $new_quantity); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | } |
@@ -252,43 +252,43 @@ discard block |
||
252 | 252 | * @return \EE_Line_Item |
253 | 253 | * @throws \EE_Error |
254 | 254 | */ |
255 | - public static function create_ticket_line_item( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
255 | + public static function create_ticket_line_item(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
256 | 256 | $datetimes = $ticket->datetimes(); |
257 | - $first_datetime = reset( $datetimes ); |
|
258 | - if( $first_datetime instanceof EE_Datetime && $first_datetime->event() instanceof EE_Event ) { |
|
257 | + $first_datetime = reset($datetimes); |
|
258 | + if ($first_datetime instanceof EE_Datetime && $first_datetime->event() instanceof EE_Event) { |
|
259 | 259 | $first_datetime_name = $first_datetime->event()->name(); |
260 | 260 | } else { |
261 | - $first_datetime_name = __( 'Event', 'event_espresso' ); |
|
261 | + $first_datetime_name = __('Event', 'event_espresso'); |
|
262 | 262 | } |
263 | - $event = sprintf( _x( '(For %1$s)', '(For Event Name)', 'event_espresso' ), $first_datetime_name ); |
|
263 | + $event = sprintf(_x('(For %1$s)', '(For Event Name)', 'event_espresso'), $first_datetime_name); |
|
264 | 264 | // get event subtotal line |
265 | - $events_sub_total = self::get_event_line_item_for_ticket( $total_line_item, $ticket ); |
|
265 | + $events_sub_total = self::get_event_line_item_for_ticket($total_line_item, $ticket); |
|
266 | 266 | // add $ticket to cart |
267 | - $line_item = EE_Line_Item::new_instance( array( |
|
267 | + $line_item = EE_Line_Item::new_instance(array( |
|
268 | 268 | 'LIN_name' => $ticket->name(), |
269 | - 'LIN_desc' => $ticket->description() !== '' ? $ticket->description() . ' ' . $event : $event, |
|
269 | + 'LIN_desc' => $ticket->description() !== '' ? $ticket->description().' '.$event : $event, |
|
270 | 270 | 'LIN_unit_price' => $ticket->price(), |
271 | 271 | 'LIN_quantity' => $qty, |
272 | 272 | 'LIN_is_taxable' => $ticket->taxable(), |
273 | - 'LIN_order' => count( $events_sub_total->children() ), |
|
273 | + 'LIN_order' => count($events_sub_total->children()), |
|
274 | 274 | 'LIN_total' => $ticket->price() * $qty, |
275 | 275 | 'LIN_type' => EEM_Line_Item::type_line_item, |
276 | 276 | 'OBJ_ID' => $ticket->ID(), |
277 | 277 | 'OBJ_type' => 'Ticket' |
278 | - ) ); |
|
278 | + )); |
|
279 | 279 | $line_item = apply_filters( |
280 | 280 | 'FHEE__EEH_Line_Item__create_ticket_line_item__line_item', |
281 | 281 | $line_item |
282 | 282 | ); |
283 | - $events_sub_total->add_child_line_item( $line_item ); |
|
283 | + $events_sub_total->add_child_line_item($line_item); |
|
284 | 284 | //now add the sub-line items |
285 | 285 | $running_total_for_ticket = 0; |
286 | - foreach ( $ticket->prices( array( 'order_by' => array( 'PRC_order' => 'ASC' ) ) ) as $price ) { |
|
286 | + foreach ($ticket->prices(array('order_by' => array('PRC_order' => 'ASC'))) as $price) { |
|
287 | 287 | $sign = $price->is_discount() ? -1 : 1; |
288 | 288 | $price_total = $price->is_percent() |
289 | 289 | ? $running_total_for_ticket * $price->amount() / 100 |
290 | 290 | : $price->amount() * $qty; |
291 | - $sub_line_item = EE_Line_Item::new_instance( array( |
|
291 | + $sub_line_item = EE_Line_Item::new_instance(array( |
|
292 | 292 | 'LIN_name' => $price->name(), |
293 | 293 | 'LIN_desc' => $price->desc(), |
294 | 294 | 'LIN_quantity' => $price->is_percent() ? null : $qty, |
@@ -298,18 +298,18 @@ discard block |
||
298 | 298 | 'LIN_type' => EEM_Line_Item::type_sub_line_item, |
299 | 299 | 'OBJ_ID' => $price->ID(), |
300 | 300 | 'OBJ_type' => 'Price' |
301 | - ) ); |
|
301 | + )); |
|
302 | 302 | $sub_line_item = apply_filters( |
303 | 303 | 'FHEE__EEH_Line_Item__create_ticket_line_item__sub_line_item', |
304 | 304 | $sub_line_item |
305 | 305 | ); |
306 | - if ( $price->is_percent() ) { |
|
307 | - $sub_line_item->set_percent( $sign * $price->amount() ); |
|
306 | + if ($price->is_percent()) { |
|
307 | + $sub_line_item->set_percent($sign * $price->amount()); |
|
308 | 308 | } else { |
309 | - $sub_line_item->set_unit_price( $sign * $price->amount() ); |
|
309 | + $sub_line_item->set_unit_price($sign * $price->amount()); |
|
310 | 310 | } |
311 | 311 | $running_total_for_ticket += $price_total; |
312 | - $line_item->add_child_line_item( $sub_line_item ); |
|
312 | + $line_item->add_child_line_item($sub_line_item); |
|
313 | 313 | } |
314 | 314 | return $line_item; |
315 | 315 | } |
@@ -329,11 +329,11 @@ discard block |
||
329 | 329 | * @return boolean |
330 | 330 | * @throws \EE_Error |
331 | 331 | */ |
332 | - public static function add_item( EE_Line_Item $total_line_item, EE_Line_Item $item ){ |
|
333 | - $pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item ); |
|
334 | - if ( $pre_tax_subtotal instanceof EE_Line_Item ){ |
|
332 | + public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) { |
|
333 | + $pre_tax_subtotal = self::get_pre_tax_subtotal($total_line_item); |
|
334 | + if ($pre_tax_subtotal instanceof EE_Line_Item) { |
|
335 | 335 | $success = $pre_tax_subtotal->add_child_line_item($item); |
336 | - }else{ |
|
336 | + } else { |
|
337 | 337 | return FALSE; |
338 | 338 | } |
339 | 339 | $total_line_item->recalculate_total_including_taxes(); |
@@ -352,34 +352,34 @@ discard block |
||
352 | 352 | * @return bool success |
353 | 353 | * @throws \EE_Error |
354 | 354 | */ |
355 | - public static function cancel_ticket_line_item( EE_Line_Item $ticket_line_item, $qty = 1 ) { |
|
355 | + public static function cancel_ticket_line_item(EE_Line_Item $ticket_line_item, $qty = 1) { |
|
356 | 356 | // validate incoming line_item |
357 | - if ( $ticket_line_item->OBJ_type() !== 'Ticket' ) { |
|
357 | + if ($ticket_line_item->OBJ_type() !== 'Ticket') { |
|
358 | 358 | throw new EE_Error( |
359 | 359 | sprintf( |
360 | - __( 'The supplied line item must have an Object Type of "Ticket", not %1$s.', 'event_espresso' ), |
|
360 | + __('The supplied line item must have an Object Type of "Ticket", not %1$s.', 'event_espresso'), |
|
361 | 361 | $ticket_line_item->type() |
362 | 362 | ) |
363 | 363 | ); |
364 | 364 | } |
365 | - if ( $ticket_line_item->quantity() < $qty ) { |
|
365 | + if ($ticket_line_item->quantity() < $qty) { |
|
366 | 366 | throw new EE_Error( |
367 | 367 | sprintf( |
368 | - __( 'Can not cancel %1$d ticket(s) because the supplied line item has a quantity of %2$d.', 'event_espresso' ), |
|
368 | + __('Can not cancel %1$d ticket(s) because the supplied line item has a quantity of %2$d.', 'event_espresso'), |
|
369 | 369 | $qty, |
370 | 370 | $ticket_line_item->quantity() |
371 | 371 | ) |
372 | 372 | ); |
373 | 373 | } |
374 | 374 | // decrement ticket quantity; don't rely on auto-fixing when recalculating totals to do this |
375 | - $ticket_line_item->set_quantity( $ticket_line_item->quantity() - $qty ); |
|
376 | - foreach( $ticket_line_item->children() as $child_line_item ) { |
|
377 | - if( |
|
375 | + $ticket_line_item->set_quantity($ticket_line_item->quantity() - $qty); |
|
376 | + foreach ($ticket_line_item->children() as $child_line_item) { |
|
377 | + if ( |
|
378 | 378 | $child_line_item->is_sub_line_item() |
379 | 379 | && ! $child_line_item->is_percent() |
380 | 380 | && ! $child_line_item->is_cancellation() |
381 | 381 | ) { |
382 | - $child_line_item->set_quantity( $child_line_item->quantity() - $qty ); |
|
382 | + $child_line_item->set_quantity($child_line_item->quantity() - $qty); |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | // get cancellation sub line item |
@@ -387,37 +387,37 @@ discard block |
||
387 | 387 | $ticket_line_item, |
388 | 388 | EEM_Line_Item::type_cancellation |
389 | 389 | ); |
390 | - $cancellation_line_item = reset( $cancellation_line_item ); |
|
390 | + $cancellation_line_item = reset($cancellation_line_item); |
|
391 | 391 | // verify that this ticket was indeed previously cancelled |
392 | - if ( $cancellation_line_item instanceof EE_Line_Item ) { |
|
392 | + if ($cancellation_line_item instanceof EE_Line_Item) { |
|
393 | 393 | // increment cancelled quantity |
394 | - $cancellation_line_item->set_quantity( $cancellation_line_item->quantity() + $qty ); |
|
394 | + $cancellation_line_item->set_quantity($cancellation_line_item->quantity() + $qty); |
|
395 | 395 | } else { |
396 | 396 | // create cancellation sub line item |
397 | - $cancellation_line_item = EE_Line_Item::new_instance( array( |
|
398 | - 'LIN_name' => __( 'Cancellation', 'event_espresso' ), |
|
397 | + $cancellation_line_item = EE_Line_Item::new_instance(array( |
|
398 | + 'LIN_name' => __('Cancellation', 'event_espresso'), |
|
399 | 399 | 'LIN_desc' => sprintf( |
400 | - _x( 'Cancelled %1$s : %2$s', 'Cancelled Ticket Name : 2015-01-01 11:11', 'event_espresso' ), |
|
400 | + _x('Cancelled %1$s : %2$s', 'Cancelled Ticket Name : 2015-01-01 11:11', 'event_espresso'), |
|
401 | 401 | $ticket_line_item->name(), |
402 | - current_time( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ) |
|
402 | + current_time(get_option('date_format').' '.get_option('time_format')) |
|
403 | 403 | ), |
404 | 404 | 'LIN_unit_price' => 0, // $ticket_line_item->unit_price() |
405 | 405 | 'LIN_quantity' => $qty, |
406 | 406 | 'LIN_is_taxable' => $ticket_line_item->is_taxable(), |
407 | - 'LIN_order' => count( $ticket_line_item->children() ), |
|
407 | + 'LIN_order' => count($ticket_line_item->children()), |
|
408 | 408 | 'LIN_total' => 0, // $ticket_line_item->unit_price() |
409 | 409 | 'LIN_type' => EEM_Line_Item::type_cancellation, |
410 | - ) ); |
|
411 | - $ticket_line_item->add_child_line_item( $cancellation_line_item ); |
|
410 | + )); |
|
411 | + $ticket_line_item->add_child_line_item($cancellation_line_item); |
|
412 | 412 | } |
413 | - if ( $ticket_line_item->save_this_and_descendants() > 0 ) { |
|
413 | + if ($ticket_line_item->save_this_and_descendants() > 0) { |
|
414 | 414 | // decrement parent line item quantity |
415 | 415 | $event_line_item = $ticket_line_item->parent(); |
416 | - if ( $event_line_item instanceof EE_Line_Item && $event_line_item->OBJ_type() === 'Event' ) { |
|
417 | - $event_line_item->set_quantity( $event_line_item->quantity() - $qty ); |
|
416 | + if ($event_line_item instanceof EE_Line_Item && $event_line_item->OBJ_type() === 'Event') { |
|
417 | + $event_line_item->set_quantity($event_line_item->quantity() - $qty); |
|
418 | 418 | $event_line_item->save(); |
419 | 419 | } |
420 | - EEH_Line_Item::get_grand_total_and_recalculate_everything( $ticket_line_item ); |
|
420 | + EEH_Line_Item::get_grand_total_and_recalculate_everything($ticket_line_item); |
|
421 | 421 | return true; |
422 | 422 | } |
423 | 423 | return false; |
@@ -435,12 +435,12 @@ discard block |
||
435 | 435 | * @return bool success |
436 | 436 | * @throws \EE_Error |
437 | 437 | */ |
438 | - public static function reinstate_canceled_ticket_line_item( EE_Line_Item $ticket_line_item, $qty = 1 ) { |
|
438 | + public static function reinstate_canceled_ticket_line_item(EE_Line_Item $ticket_line_item, $qty = 1) { |
|
439 | 439 | // validate incoming line_item |
440 | - if ( $ticket_line_item->OBJ_type() !== 'Ticket' ) { |
|
440 | + if ($ticket_line_item->OBJ_type() !== 'Ticket') { |
|
441 | 441 | throw new EE_Error( |
442 | 442 | sprintf( |
443 | - __( 'The supplied line item must have an Object Type of "Ticket", not %1$s.', 'event_espresso' ), |
|
443 | + __('The supplied line item must have an Object Type of "Ticket", not %1$s.', 'event_espresso'), |
|
444 | 444 | $ticket_line_item->type() |
445 | 445 | ) |
446 | 446 | ); |
@@ -450,42 +450,42 @@ discard block |
||
450 | 450 | $ticket_line_item, |
451 | 451 | EEM_Line_Item::type_cancellation |
452 | 452 | ); |
453 | - $cancellation_line_item = reset( $cancellation_line_item ); |
|
453 | + $cancellation_line_item = reset($cancellation_line_item); |
|
454 | 454 | // verify that this ticket was indeed previously cancelled |
455 | - if ( ! $cancellation_line_item instanceof EE_Line_Item ) { |
|
455 | + if ( ! $cancellation_line_item instanceof EE_Line_Item) { |
|
456 | 456 | return false; |
457 | 457 | } |
458 | - if ( $cancellation_line_item->quantity() > $qty ) { |
|
458 | + if ($cancellation_line_item->quantity() > $qty) { |
|
459 | 459 | // decrement cancelled quantity |
460 | - $cancellation_line_item->set_quantity( $cancellation_line_item->quantity() - $qty ); |
|
461 | - } else if ( $cancellation_line_item->quantity() == $qty ) { |
|
460 | + $cancellation_line_item->set_quantity($cancellation_line_item->quantity() - $qty); |
|
461 | + } else if ($cancellation_line_item->quantity() == $qty) { |
|
462 | 462 | // decrement cancelled quantity in case anyone still has the object kicking around |
463 | - $cancellation_line_item->set_quantity( $cancellation_line_item->quantity() - $qty ); |
|
463 | + $cancellation_line_item->set_quantity($cancellation_line_item->quantity() - $qty); |
|
464 | 464 | // delete because quantity will end up as 0 |
465 | 465 | $cancellation_line_item->delete(); |
466 | 466 | // and attempt to destroy the object, |
467 | 467 | // even though PHP won't actually destroy it until it needs the memory |
468 | - unset( $cancellation_line_item ); |
|
468 | + unset($cancellation_line_item); |
|
469 | 469 | } else { |
470 | 470 | // what ?!?! negative quantity ?!?! |
471 | 471 | throw new EE_Error( |
472 | 472 | sprintf( |
473 | - __( 'Can not reinstate %1$d cancelled ticket(s) because the cancelled ticket quantity is only %2$d.', |
|
474 | - 'event_espresso' ), |
|
473 | + __('Can not reinstate %1$d cancelled ticket(s) because the cancelled ticket quantity is only %2$d.', |
|
474 | + 'event_espresso'), |
|
475 | 475 | $qty, |
476 | 476 | $cancellation_line_item->quantity() |
477 | 477 | ) |
478 | 478 | ); |
479 | 479 | } |
480 | 480 | // increment ticket quantity |
481 | - $ticket_line_item->set_quantity( $ticket_line_item->quantity() + $qty ); |
|
482 | - if ( $ticket_line_item->save_this_and_descendants() > 0 ) { |
|
481 | + $ticket_line_item->set_quantity($ticket_line_item->quantity() + $qty); |
|
482 | + if ($ticket_line_item->save_this_and_descendants() > 0) { |
|
483 | 483 | // increment parent line item quantity |
484 | 484 | $event_line_item = $ticket_line_item->parent(); |
485 | - if ( $event_line_item instanceof EE_Line_Item && $event_line_item->OBJ_type() === 'Event' ) { |
|
486 | - $event_line_item->set_quantity( $event_line_item->quantity() + $qty ); |
|
485 | + if ($event_line_item instanceof EE_Line_Item && $event_line_item->OBJ_type() === 'Event') { |
|
486 | + $event_line_item->set_quantity($event_line_item->quantity() + $qty); |
|
487 | 487 | } |
488 | - EEH_Line_Item::get_grand_total_and_recalculate_everything( $ticket_line_item ); |
|
488 | + EEH_Line_Item::get_grand_total_and_recalculate_everything($ticket_line_item); |
|
489 | 489 | return true; |
490 | 490 | } |
491 | 491 | return false; |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | * @param EE_Line_Item $line_item |
501 | 501 | * @return \EE_Line_Item |
502 | 502 | */ |
503 | - public static function get_grand_total_and_recalculate_everything( EE_Line_Item $line_item ){ |
|
504 | - $grand_total_line_item = EEH_Line_Item::find_transaction_grand_total_for_line_item( $line_item ); |
|
503 | + public static function get_grand_total_and_recalculate_everything(EE_Line_Item $line_item) { |
|
504 | + $grand_total_line_item = EEH_Line_Item::find_transaction_grand_total_for_line_item($line_item); |
|
505 | 505 | return $grand_total_line_item->recalculate_total_including_taxes(); |
506 | 506 | } |
507 | 507 | |
@@ -514,11 +514,11 @@ discard block |
||
514 | 514 | * @return \EE_Line_Item |
515 | 515 | * @throws \EE_Error |
516 | 516 | */ |
517 | - public static function get_pre_tax_subtotal( EE_Line_Item $total_line_item ){ |
|
518 | - $pre_tax_subtotal = $total_line_item->get_child_line_item( 'pre-tax-subtotal' ); |
|
517 | + public static function get_pre_tax_subtotal(EE_Line_Item $total_line_item) { |
|
518 | + $pre_tax_subtotal = $total_line_item->get_child_line_item('pre-tax-subtotal'); |
|
519 | 519 | return $pre_tax_subtotal instanceof EE_Line_Item |
520 | 520 | ? $pre_tax_subtotal |
521 | - : self::create_pre_tax_subtotal( $total_line_item ); |
|
521 | + : self::create_pre_tax_subtotal($total_line_item); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | |
@@ -530,9 +530,9 @@ discard block |
||
530 | 530 | * @return \EE_Line_Item |
531 | 531 | * @throws \EE_Error |
532 | 532 | */ |
533 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){ |
|
534 | - $taxes = $total_line_item->get_child_line_item( 'taxes' ); |
|
535 | - return $taxes ? $taxes : self::create_taxes_subtotal( $total_line_item ); |
|
533 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item) { |
|
534 | + $taxes = $total_line_item->get_child_line_item('taxes'); |
|
535 | + return $taxes ? $taxes : self::create_taxes_subtotal($total_line_item); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | |
@@ -545,12 +545,12 @@ discard block |
||
545 | 545 | * @return void |
546 | 546 | * @throws \EE_Error |
547 | 547 | */ |
548 | - public static function set_TXN_ID( EE_Line_Item $line_item, $transaction = NULL ){ |
|
549 | - if( $transaction ){ |
|
548 | + public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) { |
|
549 | + if ($transaction) { |
|
550 | 550 | /** @type EEM_Transaction $EEM_Transaction */ |
551 | - $EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' ); |
|
552 | - $TXN_ID = $EEM_Transaction->ensure_is_ID( $transaction ); |
|
553 | - $line_item->set_TXN_ID( $TXN_ID ); |
|
551 | + $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
552 | + $TXN_ID = $EEM_Transaction->ensure_is_ID($transaction); |
|
553 | + $line_item->set_TXN_ID($TXN_ID); |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | |
@@ -565,8 +565,8 @@ discard block |
||
565 | 565 | * @return \EE_Line_Item of type total |
566 | 566 | * @throws \EE_Error |
567 | 567 | */ |
568 | - public static function create_total_line_item( $transaction = NULL ){ |
|
569 | - $total_line_item = EE_Line_Item::new_instance( array( |
|
568 | + public static function create_total_line_item($transaction = NULL) { |
|
569 | + $total_line_item = EE_Line_Item::new_instance(array( |
|
570 | 570 | 'LIN_code' => 'total', |
571 | 571 | 'LIN_name' => __('Grand Total', 'event_espresso'), |
572 | 572 | 'LIN_type' => EEM_Line_Item::type_total, |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | 'FHEE__EEH_Line_Item__create_total_line_item__total_line_item', |
577 | 577 | $total_line_item |
578 | 578 | ); |
579 | - self::set_TXN_ID( $total_line_item, $transaction ); |
|
580 | - self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
581 | - self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
579 | + self::set_TXN_ID($total_line_item, $transaction); |
|
580 | + self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
581 | + self::create_taxes_subtotal($total_line_item, $transaction); |
|
582 | 582 | return $total_line_item; |
583 | 583 | } |
584 | 584 | |
@@ -592,19 +592,19 @@ discard block |
||
592 | 592 | * @return EE_Line_Item |
593 | 593 | * @throws \EE_Error |
594 | 594 | */ |
595 | - protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
596 | - $pre_tax_line_item = EE_Line_Item::new_instance( array( |
|
595 | + protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
596 | + $pre_tax_line_item = EE_Line_Item::new_instance(array( |
|
597 | 597 | 'LIN_code' => 'pre-tax-subtotal', |
598 | - 'LIN_name' => __( 'Pre-Tax Subtotal', 'event_espresso' ), |
|
598 | + 'LIN_name' => __('Pre-Tax Subtotal', 'event_espresso'), |
|
599 | 599 | 'LIN_type' => EEM_Line_Item::type_sub_total |
600 | - ) ); |
|
600 | + )); |
|
601 | 601 | $pre_tax_line_item = apply_filters( |
602 | 602 | 'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item', |
603 | 603 | $pre_tax_line_item |
604 | 604 | ); |
605 | - self::set_TXN_ID( $pre_tax_line_item, $transaction ); |
|
606 | - $total_line_item->add_child_line_item( $pre_tax_line_item ); |
|
607 | - self::create_event_subtotal( $pre_tax_line_item, $transaction ); |
|
605 | + self::set_TXN_ID($pre_tax_line_item, $transaction); |
|
606 | + $total_line_item->add_child_line_item($pre_tax_line_item); |
|
607 | + self::create_event_subtotal($pre_tax_line_item, $transaction); |
|
608 | 608 | return $pre_tax_line_item; |
609 | 609 | } |
610 | 610 | |
@@ -619,21 +619,21 @@ discard block |
||
619 | 619 | * @return EE_Line_Item |
620 | 620 | * @throws \EE_Error |
621 | 621 | */ |
622 | - protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
622 | + protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
623 | 623 | $tax_line_item = EE_Line_Item::new_instance(array( |
624 | 624 | 'LIN_code' => 'taxes', |
625 | 625 | 'LIN_name' => __('Taxes', 'event_espresso'), |
626 | 626 | 'LIN_type' => EEM_Line_Item::type_tax_sub_total, |
627 | - 'LIN_order' => 1000,//this should always come last |
|
627 | + 'LIN_order' => 1000, //this should always come last |
|
628 | 628 | )); |
629 | 629 | $tax_line_item = apply_filters( |
630 | 630 | 'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item', |
631 | 631 | $tax_line_item |
632 | 632 | ); |
633 | - self::set_TXN_ID( $tax_line_item, $transaction ); |
|
634 | - $total_line_item->add_child_line_item( $tax_line_item ); |
|
633 | + self::set_TXN_ID($tax_line_item, $transaction); |
|
634 | + $total_line_item->add_child_line_item($tax_line_item); |
|
635 | 635 | //and lastly, add the actual taxes |
636 | - self::apply_taxes( $total_line_item ); |
|
636 | + self::apply_taxes($total_line_item); |
|
637 | 637 | return $tax_line_item; |
638 | 638 | } |
639 | 639 | |
@@ -648,11 +648,11 @@ discard block |
||
648 | 648 | * @return EE_Line_Item |
649 | 649 | * @throws \EE_Error |
650 | 650 | */ |
651 | - public static function create_event_subtotal( EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL ){ |
|
651 | + public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) { |
|
652 | 652 | $event_line_item = EE_Line_Item::new_instance(array( |
653 | - 'LIN_code' => self::get_event_code( $event ), |
|
654 | - 'LIN_name' => self::get_event_name( $event ), |
|
655 | - 'LIN_desc' => self::get_event_desc( $event ), |
|
653 | + 'LIN_code' => self::get_event_code($event), |
|
654 | + 'LIN_name' => self::get_event_name($event), |
|
655 | + 'LIN_desc' => self::get_event_desc($event), |
|
656 | 656 | 'LIN_type' => EEM_Line_Item::type_sub_total, |
657 | 657 | 'OBJ_type' => 'Event', |
658 | 658 | 'OBJ_ID' => $event instanceof EE_Event ? $event->ID() : 0 |
@@ -661,8 +661,8 @@ discard block |
||
661 | 661 | 'FHEE__EEH_Line_Item__create_event_subtotal__event_line_item', |
662 | 662 | $event_line_item |
663 | 663 | ); |
664 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
665 | - $pre_tax_line_item->add_child_line_item( $event_line_item ); |
|
664 | + self::set_TXN_ID($event_line_item, $transaction); |
|
665 | + $pre_tax_line_item->add_child_line_item($event_line_item); |
|
666 | 666 | return $event_line_item; |
667 | 667 | } |
668 | 668 | |
@@ -675,8 +675,8 @@ discard block |
||
675 | 675 | * @return string |
676 | 676 | * @throws \EE_Error |
677 | 677 | */ |
678 | - public static function get_event_code( $event ) { |
|
679 | - return 'event-' . ( $event instanceof EE_Event ? $event->ID() : '0' ); |
|
678 | + public static function get_event_code($event) { |
|
679 | + return 'event-'.($event instanceof EE_Event ? $event->ID() : '0'); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
@@ -684,8 +684,8 @@ discard block |
||
684 | 684 | * @param EE_Event $event |
685 | 685 | * @return string |
686 | 686 | */ |
687 | - public static function get_event_name( $event ) { |
|
688 | - return $event instanceof EE_Event ? $event->name() : __( 'Event', 'event_espresso' ); |
|
687 | + public static function get_event_name($event) { |
|
688 | + return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * @param EE_Event $event |
694 | 694 | * @return string |
695 | 695 | */ |
696 | - public static function get_event_desc( $event ) { |
|
696 | + public static function get_event_desc($event) { |
|
697 | 697 | return $event instanceof EE_Event ? $event->short_description() : ''; |
698 | 698 | } |
699 | 699 | |
@@ -707,27 +707,27 @@ discard block |
||
707 | 707 | * @throws \EE_Error |
708 | 708 | * @return EE_Line_Item |
709 | 709 | */ |
710 | - public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
|
710 | + public static function get_event_line_item_for_ticket(EE_Line_Item $grand_total, EE_Ticket $ticket) { |
|
711 | 711 | $first_datetime = $ticket->first_datetime(); |
712 | - if ( ! $first_datetime instanceof EE_Datetime ) { |
|
712 | + if ( ! $first_datetime instanceof EE_Datetime) { |
|
713 | 713 | throw new EE_Error( |
714 | - sprintf( __( 'The supplied ticket (ID %d) has no datetimes', 'event_espresso' ), $ticket->ID() ) |
|
714 | + sprintf(__('The supplied ticket (ID %d) has no datetimes', 'event_espresso'), $ticket->ID()) |
|
715 | 715 | ); |
716 | 716 | } |
717 | 717 | $event = $first_datetime->event(); |
718 | - if ( ! $event instanceof EE_Event ) { |
|
718 | + if ( ! $event instanceof EE_Event) { |
|
719 | 719 | throw new EE_Error( |
720 | 720 | sprintf( |
721 | - __( 'The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso' ), |
|
721 | + __('The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso'), |
|
722 | 722 | $ticket->ID() |
723 | 723 | ) |
724 | 724 | ); |
725 | 725 | } |
726 | - $events_sub_total = EEH_Line_Item::get_event_line_item( $grand_total, $event ); |
|
727 | - if ( ! $events_sub_total instanceof EE_Line_Item ) { |
|
726 | + $events_sub_total = EEH_Line_Item::get_event_line_item($grand_total, $event); |
|
727 | + if ( ! $events_sub_total instanceof EE_Line_Item) { |
|
728 | 728 | throw new EE_Error( |
729 | 729 | sprintf( |
730 | - __( 'There is no events sub-total for ticket %s on total line item %d', 'event_espresso' ), |
|
730 | + __('There is no events sub-total for ticket %s on total line item %d', 'event_espresso'), |
|
731 | 731 | $ticket->ID(), |
732 | 732 | $grand_total->ID() |
733 | 733 | ) |
@@ -746,31 +746,31 @@ discard block |
||
746 | 746 | * @return EE_Line_Item for the event subtotal which is a child of $grand_total |
747 | 747 | * @throws \EE_Error |
748 | 748 | */ |
749 | - public static function get_event_line_item( EE_Line_Item $grand_total, $event ) { |
|
749 | + public static function get_event_line_item(EE_Line_Item $grand_total, $event) { |
|
750 | 750 | /** @type EE_Event $event */ |
751 | - $event = EEM_Event::instance()->ensure_is_obj( $event, true ); |
|
751 | + $event = EEM_Event::instance()->ensure_is_obj($event, true); |
|
752 | 752 | $event_line_item = NULL; |
753 | 753 | $found = false; |
754 | - foreach ( EEH_Line_Item::get_event_subtotals( $grand_total ) as $event_line_item ) { |
|
754 | + foreach (EEH_Line_Item::get_event_subtotals($grand_total) as $event_line_item) { |
|
755 | 755 | // default event subtotal, we should only ever find this the first time this method is called |
756 | - if ( ! $event_line_item->OBJ_ID() ) { |
|
756 | + if ( ! $event_line_item->OBJ_ID()) { |
|
757 | 757 | // let's use this! but first... set the event details |
758 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
758 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
759 | 759 | $found = true; |
760 | 760 | break; |
761 | - } else if ( $event_line_item->OBJ_ID() === $event->ID() ) { |
|
761 | + } else if ($event_line_item->OBJ_ID() === $event->ID()) { |
|
762 | 762 | // found existing line item for this event in the cart, so break out of loop and use this one |
763 | 763 | $found = true; |
764 | 764 | break; |
765 | 765 | } |
766 | 766 | } |
767 | - if ( ! $found ) { |
|
767 | + if ( ! $found) { |
|
768 | 768 | //there is no event sub-total yet, so add it |
769 | - $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal( $grand_total ); |
|
769 | + $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal($grand_total); |
|
770 | 770 | // create a new "event" subtotal below that |
771 | - $event_line_item = EEH_Line_Item::create_event_subtotal( $pre_tax_subtotal, null, $event ); |
|
771 | + $event_line_item = EEH_Line_Item::create_event_subtotal($pre_tax_subtotal, null, $event); |
|
772 | 772 | // and set the event details |
773 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
773 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
774 | 774 | } |
775 | 775 | return $event_line_item; |
776 | 776 | } |
@@ -791,13 +791,13 @@ discard block |
||
791 | 791 | EE_Event $event, |
792 | 792 | $transaction = null |
793 | 793 | ) { |
794 | - if ( $event instanceof EE_Event ) { |
|
795 | - $event_line_item->set_code( self::get_event_code( $event ) ); |
|
796 | - $event_line_item->set_name( self::get_event_name( $event ) ); |
|
797 | - $event_line_item->set_desc( self::get_event_desc( $event ) ); |
|
798 | - $event_line_item->set_OBJ_ID( $event->ID() ); |
|
794 | + if ($event instanceof EE_Event) { |
|
795 | + $event_line_item->set_code(self::get_event_code($event)); |
|
796 | + $event_line_item->set_name(self::get_event_name($event)); |
|
797 | + $event_line_item->set_desc(self::get_event_desc($event)); |
|
798 | + $event_line_item->set_OBJ_ID($event->ID()); |
|
799 | 799 | } |
800 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
800 | + self::set_TXN_ID($event_line_item, $transaction); |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | |
@@ -810,19 +810,19 @@ discard block |
||
810 | 810 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
811 | 811 | * @throws \EE_Error |
812 | 812 | */ |
813 | - public static function apply_taxes( EE_Line_Item $total_line_item ){ |
|
813 | + public static function apply_taxes(EE_Line_Item $total_line_item) { |
|
814 | 814 | /** @type EEM_Price $EEM_Price */ |
815 | - $EEM_Price = EE_Registry::instance()->load_model( 'Price' ); |
|
815 | + $EEM_Price = EE_Registry::instance()->load_model('Price'); |
|
816 | 816 | // get array of taxes via Price Model |
817 | 817 | $ordered_taxes = $EEM_Price->get_all_prices_that_are_taxes(); |
818 | - ksort( $ordered_taxes ); |
|
819 | - $taxes_line_item = self::get_taxes_subtotal( $total_line_item ); |
|
818 | + ksort($ordered_taxes); |
|
819 | + $taxes_line_item = self::get_taxes_subtotal($total_line_item); |
|
820 | 820 | //just to be safe, remove its old tax line items |
821 | 821 | $taxes_line_item->delete_children_line_items(); |
822 | 822 | //loop thru taxes |
823 | - foreach ( $ordered_taxes as $order => $taxes ) { |
|
824 | - foreach ( $taxes as $tax ) { |
|
825 | - if ( $tax instanceof EE_Price ) { |
|
823 | + foreach ($ordered_taxes as $order => $taxes) { |
|
824 | + foreach ($taxes as $tax) { |
|
825 | + if ($tax instanceof EE_Price) { |
|
826 | 826 | $tax_line_item = EE_Line_Item::new_instance( |
827 | 827 | array( |
828 | 828 | 'LIN_name' => $tax->name(), |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | 'FHEE__EEH_Line_Item__apply_taxes__tax_line_item', |
841 | 841 | $tax_line_item |
842 | 842 | ); |
843 | - $taxes_line_item->add_child_line_item( $tax_line_item ); |
|
843 | + $taxes_line_item->add_child_line_item($tax_line_item); |
|
844 | 844 | } |
845 | 845 | } |
846 | 846 | } |
@@ -857,10 +857,10 @@ discard block |
||
857 | 857 | * @return float |
858 | 858 | * @throws \EE_Error |
859 | 859 | */ |
860 | - public static function ensure_taxes_applied( $total_line_item ){ |
|
861 | - $taxes_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
862 | - if( ! $taxes_subtotal->children()){ |
|
863 | - self::apply_taxes( $total_line_item ); |
|
860 | + public static function ensure_taxes_applied($total_line_item) { |
|
861 | + $taxes_subtotal = self::get_taxes_subtotal($total_line_item); |
|
862 | + if ( ! $taxes_subtotal->children()) { |
|
863 | + self::apply_taxes($total_line_item); |
|
864 | 864 | } |
865 | 865 | return $taxes_subtotal->total(); |
866 | 866 | } |
@@ -874,16 +874,16 @@ discard block |
||
874 | 874 | * @return bool |
875 | 875 | * @throws \EE_Error |
876 | 876 | */ |
877 | - public static function delete_all_child_items( EE_Line_Item $parent_line_item ) { |
|
877 | + public static function delete_all_child_items(EE_Line_Item $parent_line_item) { |
|
878 | 878 | $deleted = 0; |
879 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
880 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
881 | - $deleted += EEH_Line_Item::delete_all_child_items( $child_line_item ); |
|
882 | - if ( $child_line_item->ID() ) { |
|
879 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
880 | + if ($child_line_item instanceof EE_Line_Item) { |
|
881 | + $deleted += EEH_Line_Item::delete_all_child_items($child_line_item); |
|
882 | + if ($child_line_item->ID()) { |
|
883 | 883 | $child_line_item->delete(); |
884 | - unset( $child_line_item ); |
|
884 | + unset($child_line_item); |
|
885 | 885 | } else { |
886 | - $parent_line_item->delete_child_line_item( $child_line_item->code() ); |
|
886 | + $parent_line_item->delete_child_line_item($child_line_item->code()); |
|
887 | 887 | } |
888 | 888 | $deleted++; |
889 | 889 | } |
@@ -905,9 +905,9 @@ discard block |
||
905 | 905 | * @param array|bool|string $line_item_codes |
906 | 906 | * @return int number of items successfully removed |
907 | 907 | */ |
908 | - public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) { |
|
908 | + public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) { |
|
909 | 909 | |
910 | - if( $total_line_item->type() !== EEM_Line_Item::type_total ){ |
|
910 | + if ($total_line_item->type() !== EEM_Line_Item::type_total) { |
|
911 | 911 | EE_Error::doing_it_wrong( |
912 | 912 | 'EEH_Line_Item::delete_items', |
913 | 913 | __( |
@@ -917,20 +917,20 @@ discard block |
||
917 | 917 | '4.6.18' |
918 | 918 | ); |
919 | 919 | } |
920 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
920 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
921 | 921 | |
922 | 922 | // check if only a single line_item_id was passed |
923 | - if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) { |
|
923 | + if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) { |
|
924 | 924 | // place single line_item_id in an array to appear as multiple line_item_ids |
925 | - $line_item_codes = array ( $line_item_codes ); |
|
925 | + $line_item_codes = array($line_item_codes); |
|
926 | 926 | } |
927 | 927 | $removals = 0; |
928 | 928 | // cycle thru line_item_ids |
929 | - foreach ( $line_item_codes as $line_item_id ) { |
|
929 | + foreach ($line_item_codes as $line_item_id) { |
|
930 | 930 | $removals += $total_line_item->delete_child_line_item($line_item_id); |
931 | 931 | } |
932 | 932 | |
933 | - if ( $removals > 0 ) { |
|
933 | + if ($removals > 0) { |
|
934 | 934 | $total_line_item->recalculate_taxes_and_tax_total(); |
935 | 935 | return $removals; |
936 | 936 | } else { |
@@ -963,33 +963,33 @@ discard block |
||
963 | 963 | $code = null, |
964 | 964 | $add_to_existing_line_item = false |
965 | 965 | ) { |
966 | - $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
966 | + $tax_subtotal = self::get_taxes_subtotal($total_line_item); |
|
967 | 967 | $taxable_total = $total_line_item->taxable_total(); |
968 | 968 | |
969 | - if( $add_to_existing_line_item ) { |
|
970 | - $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
969 | + if ($add_to_existing_line_item) { |
|
970 | + $new_tax = $tax_subtotal->get_child_line_item($code); |
|
971 | 971 | EEM_Line_Item::instance()->delete( |
972 | - array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) |
|
972 | + array(array('LIN_code' => array('!=', $code), 'LIN_parent' => $tax_subtotal->ID())) |
|
973 | 973 | ); |
974 | 974 | } else { |
975 | 975 | $new_tax = null; |
976 | 976 | $tax_subtotal->delete_children_line_items(); |
977 | 977 | } |
978 | - if( $new_tax ) { |
|
979 | - $new_tax->set_total( $new_tax->total() + $amount ); |
|
980 | - $new_tax->set_percent( $taxable_total ? $new_tax->total() / $taxable_total * 100 : 0 ); |
|
978 | + if ($new_tax) { |
|
979 | + $new_tax->set_total($new_tax->total() + $amount); |
|
980 | + $new_tax->set_percent($taxable_total ? $new_tax->total() / $taxable_total * 100 : 0); |
|
981 | 981 | } else { |
982 | 982 | //no existing tax item. Create it |
983 | - $new_tax = EE_Line_Item::new_instance( array( |
|
983 | + $new_tax = EE_Line_Item::new_instance(array( |
|
984 | 984 | 'TXN_ID' => $total_line_item->TXN_ID(), |
985 | - 'LIN_name' => $name ? $name : __( 'Tax', 'event_espresso' ), |
|
985 | + 'LIN_name' => $name ? $name : __('Tax', 'event_espresso'), |
|
986 | 986 | 'LIN_desc' => $description ? $description : '', |
987 | - 'LIN_percent' => $taxable_total ? ( $amount / $taxable_total * 100 ) : 0, |
|
987 | + 'LIN_percent' => $taxable_total ? ($amount / $taxable_total * 100) : 0, |
|
988 | 988 | 'LIN_total' => $amount, |
989 | 989 | 'LIN_parent' => $tax_subtotal->ID(), |
990 | 990 | 'LIN_type' => EEM_Line_Item::type_tax, |
991 | 991 | 'LIN_code' => $code |
992 | - ) ); |
|
992 | + )); |
|
993 | 993 | } |
994 | 994 | |
995 | 995 | $new_tax = apply_filters( |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | $total_line_item |
999 | 999 | ); |
1000 | 1000 | $new_tax->save(); |
1001 | - $tax_subtotal->set_total( $new_tax->total() ); |
|
1001 | + $tax_subtotal->set_total($new_tax->total()); |
|
1002 | 1002 | $tax_subtotal->save(); |
1003 | 1003 | $total_line_item->recalculate_total_including_taxes(); |
1004 | 1004 | return $new_tax; |
@@ -1020,14 +1020,14 @@ discard block |
||
1020 | 1020 | $code_substring_for_whitelist = null |
1021 | 1021 | ) { |
1022 | 1022 | $whitelisted = false; |
1023 | - if( $code_substring_for_whitelist !== null ) { |
|
1024 | - $whitelisted = strpos( $line_item->code(), $code_substring_for_whitelist ) !== false ? true : false; |
|
1023 | + if ($code_substring_for_whitelist !== null) { |
|
1024 | + $whitelisted = strpos($line_item->code(), $code_substring_for_whitelist) !== false ? true : false; |
|
1025 | 1025 | } |
1026 | - if( ! $whitelisted && $line_item->is_line_item() ) { |
|
1027 | - $line_item->set_is_taxable( $taxable ); |
|
1026 | + if ( ! $whitelisted && $line_item->is_line_item()) { |
|
1027 | + $line_item->set_is_taxable($taxable); |
|
1028 | 1028 | } |
1029 | - foreach( $line_item->children() as $child_line_item ) { |
|
1030 | - EEH_Line_Item::set_line_items_taxable( $child_line_item, $taxable, $code_substring_for_whitelist ); |
|
1029 | + foreach ($line_item->children() as $child_line_item) { |
|
1030 | + EEH_Line_Item::set_line_items_taxable($child_line_item, $taxable, $code_substring_for_whitelist); |
|
1031 | 1031 | } |
1032 | 1032 | } |
1033 | 1033 | |
@@ -1040,8 +1040,8 @@ discard block |
||
1040 | 1040 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
1041 | 1041 | * @return EE_Line_Item[] |
1042 | 1042 | */ |
1043 | - public static function get_event_subtotals( EE_Line_Item $parent_line_item ) { |
|
1044 | - return self::get_subtotals_of_object_type( $parent_line_item, 'Event' ); |
|
1043 | + public static function get_event_subtotals(EE_Line_Item $parent_line_item) { |
|
1044 | + return self::get_subtotals_of_object_type($parent_line_item, 'Event'); |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | * @param string $obj_type |
1055 | 1055 | * @return EE_Line_Item[] |
1056 | 1056 | */ |
1057 | - public static function get_subtotals_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
1057 | + public static function get_subtotals_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
1058 | 1058 | return self::_get_descendants_by_type_and_object_type( |
1059 | 1059 | $parent_line_item, |
1060 | 1060 | EEM_Line_Item::type_sub_total, |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
1072 | 1072 | * @return EE_Line_Item[] |
1073 | 1073 | */ |
1074 | - public static function get_ticket_line_items( EE_Line_Item $parent_line_item ) { |
|
1075 | - return self::get_line_items_of_object_type( $parent_line_item, 'Ticket' ); |
|
1074 | + public static function get_ticket_line_items(EE_Line_Item $parent_line_item) { |
|
1075 | + return self::get_line_items_of_object_type($parent_line_item, 'Ticket'); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | |
@@ -1085,8 +1085,8 @@ discard block |
||
1085 | 1085 | * @param string $obj_type |
1086 | 1086 | * @return EE_Line_Item[] |
1087 | 1087 | */ |
1088 | - public static function get_line_items_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
1089 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_line_item, $obj_type ); |
|
1088 | + public static function get_line_items_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
1089 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_line_item, $obj_type); |
|
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | |
@@ -1097,8 +1097,8 @@ discard block |
||
1097 | 1097 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
1098 | 1098 | * @return EE_Line_Item[] |
1099 | 1099 | */ |
1100 | - public static function get_tax_descendants( EE_Line_Item $parent_line_item ) { |
|
1101 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_tax ); |
|
1100 | + public static function get_tax_descendants(EE_Line_Item $parent_line_item) { |
|
1101 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_tax); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | |
@@ -1109,8 +1109,8 @@ discard block |
||
1109 | 1109 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
1110 | 1110 | * @return EE_Line_Item[] |
1111 | 1111 | */ |
1112 | - public static function get_line_item_descendants( EE_Line_Item $parent_line_item ) { |
|
1113 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_line_item ); |
|
1112 | + public static function get_line_item_descendants(EE_Line_Item $parent_line_item) { |
|
1113 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_line_item); |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | |
@@ -1123,8 +1123,8 @@ discard block |
||
1123 | 1123 | * @param string $line_item_type one of the EEM_Line_Item constants |
1124 | 1124 | * @return EE_Line_Item[] |
1125 | 1125 | */ |
1126 | - public static function get_descendants_of_type( EE_Line_Item $parent_line_item, $line_item_type ) { |
|
1127 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, $line_item_type, NULL ); |
|
1126 | + public static function get_descendants_of_type(EE_Line_Item $parent_line_item, $line_item_type) { |
|
1127 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, $line_item_type, NULL); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | |
@@ -1143,8 +1143,8 @@ discard block |
||
1143 | 1143 | $obj_type = null |
1144 | 1144 | ) { |
1145 | 1145 | $objects = array(); |
1146 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
1147 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
1146 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
1147 | + if ($child_line_item instanceof EE_Line_Item) { |
|
1148 | 1148 | if ( |
1149 | 1149 | $child_line_item->type() === $line_item_type |
1150 | 1150 | && ( |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | $OBJ_type = '', |
1185 | 1185 | $OBJ_IDs = array() |
1186 | 1186 | ) { |
1187 | - return self::_get_descendants_by_object_type_and_object_ID( $parent_line_item, $OBJ_type, $OBJ_IDs ); |
|
1187 | + return self::_get_descendants_by_object_type_and_object_ID($parent_line_item, $OBJ_type, $OBJ_IDs); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | |
@@ -1203,12 +1203,12 @@ discard block |
||
1203 | 1203 | $OBJ_IDs |
1204 | 1204 | ) { |
1205 | 1205 | $objects = array(); |
1206 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
1207 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
1206 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
1207 | + if ($child_line_item instanceof EE_Line_Item) { |
|
1208 | 1208 | if ( |
1209 | 1209 | $child_line_item->OBJ_type() === $OBJ_type |
1210 | - && is_array( $OBJ_IDs ) |
|
1211 | - && in_array( $child_line_item->OBJ_ID(), $OBJ_IDs ) |
|
1210 | + && is_array($OBJ_IDs) |
|
1211 | + && in_array($child_line_item->OBJ_ID(), $OBJ_IDs) |
|
1212 | 1212 | ) { |
1213 | 1213 | $objects[] = $child_line_item; |
1214 | 1214 | } else { |
@@ -1238,8 +1238,8 @@ discard block |
||
1238 | 1238 | * @param string $type like one of the EEM_Line_Item::type_* |
1239 | 1239 | * @return EE_Line_Item |
1240 | 1240 | */ |
1241 | - public static function get_nearest_descendant_of_type( EE_Line_Item $parent_line_item, $type ) { |
|
1242 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_type' , $type ); |
|
1241 | + public static function get_nearest_descendant_of_type(EE_Line_Item $parent_line_item, $type) { |
|
1242 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_type', $type); |
|
1243 | 1243 | } |
1244 | 1244 | |
1245 | 1245 | |
@@ -1253,8 +1253,8 @@ discard block |
||
1253 | 1253 | * @param string $code any value used for LIN_code |
1254 | 1254 | * @return EE_Line_Item |
1255 | 1255 | */ |
1256 | - public static function get_nearest_descendant_having_code( EE_Line_Item $parent_line_item, $code ) { |
|
1257 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_code' , $code ); |
|
1256 | + public static function get_nearest_descendant_having_code(EE_Line_Item $parent_line_item, $code) { |
|
1257 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_code', $code); |
|
1258 | 1258 | } |
1259 | 1259 | |
1260 | 1260 | |
@@ -1268,15 +1268,15 @@ discard block |
||
1268 | 1268 | * @param string $value any value stored in $search_field |
1269 | 1269 | * @return EE_Line_Item |
1270 | 1270 | */ |
1271 | - protected static function _get_nearest_descendant( EE_Line_Item $parent_line_item, $search_field, $value ) { |
|
1272 | - foreach( $parent_line_item->children() as $child ){ |
|
1273 | - if ( $child->get( $search_field ) == $value ){ |
|
1271 | + protected static function _get_nearest_descendant(EE_Line_Item $parent_line_item, $search_field, $value) { |
|
1272 | + foreach ($parent_line_item->children() as $child) { |
|
1273 | + if ($child->get($search_field) == $value) { |
|
1274 | 1274 | return $child; |
1275 | 1275 | } |
1276 | 1276 | } |
1277 | - foreach( $parent_line_item->children() as $child ){ |
|
1278 | - $descendant_found = self::_get_nearest_descendant( $child, $search_field, $value ); |
|
1279 | - if ( $descendant_found ){ |
|
1277 | + foreach ($parent_line_item->children() as $child) { |
|
1278 | + $descendant_found = self::_get_nearest_descendant($child, $search_field, $value); |
|
1279 | + if ($descendant_found) { |
|
1280 | 1280 | return $descendant_found; |
1281 | 1281 | } |
1282 | 1282 | } |
@@ -1293,24 +1293,24 @@ discard block |
||
1293 | 1293 | * @return \EE_Line_Item |
1294 | 1294 | * @throws \EE_Error |
1295 | 1295 | */ |
1296 | - public static function find_transaction_grand_total_for_line_item( EE_Line_Item $line_item ){ |
|
1297 | - if ( $line_item->TXN_ID() ) { |
|
1298 | - $total_line_item = $line_item->transaction()->total_line_item( false ); |
|
1299 | - if ( $total_line_item instanceof EE_Line_Item ) { |
|
1296 | + public static function find_transaction_grand_total_for_line_item(EE_Line_Item $line_item) { |
|
1297 | + if ($line_item->TXN_ID()) { |
|
1298 | + $total_line_item = $line_item->transaction()->total_line_item(false); |
|
1299 | + if ($total_line_item instanceof EE_Line_Item) { |
|
1300 | 1300 | return $total_line_item; |
1301 | 1301 | } |
1302 | 1302 | } else { |
1303 | 1303 | $line_item_parent = $line_item->parent(); |
1304 | - if ( $line_item_parent instanceof EE_Line_Item ) { |
|
1305 | - if ( $line_item_parent->is_total() ) { |
|
1304 | + if ($line_item_parent instanceof EE_Line_Item) { |
|
1305 | + if ($line_item_parent->is_total()) { |
|
1306 | 1306 | return $line_item_parent; |
1307 | 1307 | } |
1308 | - return EEH_Line_Item::find_transaction_grand_total_for_line_item( $line_item_parent ); |
|
1308 | + return EEH_Line_Item::find_transaction_grand_total_for_line_item($line_item_parent); |
|
1309 | 1309 | } |
1310 | 1310 | } |
1311 | 1311 | throw new EE_Error( |
1312 | 1312 | sprintf( |
1313 | - __( 'A valid grand total for line item %1$d was not found.', 'event_espresso' ), |
|
1313 | + __('A valid grand total for line item %1$d was not found.', 'event_espresso'), |
|
1314 | 1314 | $line_item->ID() |
1315 | 1315 | ) |
1316 | 1316 | ); |
@@ -1327,31 +1327,31 @@ discard block |
||
1327 | 1327 | * @return void |
1328 | 1328 | * @throws \EE_Error |
1329 | 1329 | */ |
1330 | - public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){ |
|
1330 | + public static function visualize(EE_Line_Item $line_item, $indentation = 0) { |
|
1331 | 1331 | echo defined('EE_TESTS_DIR') ? "\n" : '<br />'; |
1332 | - if ( ! $indentation ) { |
|
1333 | - echo defined( 'EE_TESTS_DIR' ) ? "\n" : '<br />'; |
|
1332 | + if ( ! $indentation) { |
|
1333 | + echo defined('EE_TESTS_DIR') ? "\n" : '<br />'; |
|
1334 | 1334 | } |
1335 | - for( $i = 0; $i < $indentation; $i++ ){ |
|
1335 | + for ($i = 0; $i < $indentation; $i++) { |
|
1336 | 1336 | echo ". "; |
1337 | 1337 | } |
1338 | 1338 | $breakdown = ''; |
1339 | - if ( $line_item->is_line_item()){ |
|
1340 | - if ( $line_item->is_percent() ) { |
|
1339 | + if ($line_item->is_line_item()) { |
|
1340 | + if ($line_item->is_percent()) { |
|
1341 | 1341 | $breakdown = "{$line_item->percent()}%"; |
1342 | 1342 | } else { |
1343 | - $breakdown = '$' . "{$line_item->unit_price()} x {$line_item->quantity()}"; |
|
1343 | + $breakdown = '$'."{$line_item->unit_price()} x {$line_item->quantity()}"; |
|
1344 | 1344 | } |
1345 | 1345 | } |
1346 | - echo $line_item->name() . " [ ID:{$line_item->ID()} | qty:{$line_item->quantity()} ] {$line_item->type()} : " . '$' . "{$line_item->total()}"; |
|
1347 | - if ( $breakdown ) { |
|
1346 | + echo $line_item->name()." [ ID:{$line_item->ID()} | qty:{$line_item->quantity()} ] {$line_item->type()} : ".'$'."{$line_item->total()}"; |
|
1347 | + if ($breakdown) { |
|
1348 | 1348 | echo " ( {$breakdown} )"; |
1349 | 1349 | } |
1350 | - if( $line_item->is_taxable() ){ |
|
1350 | + if ($line_item->is_taxable()) { |
|
1351 | 1351 | echo " * taxable"; |
1352 | 1352 | } |
1353 | - if( $line_item->children() ){ |
|
1354 | - foreach($line_item->children() as $child){ |
|
1353 | + if ($line_item->children()) { |
|
1354 | + foreach ($line_item->children() as $child) { |
|
1355 | 1355 | self::visualize($child, $indentation + 1); |
1356 | 1356 | } |
1357 | 1357 | } |
@@ -1392,97 +1392,97 @@ discard block |
||
1392 | 1392 | * is theirs, which can be done with |
1393 | 1393 | * `EEM_Line_Item::instance()->get_line_item_for_registration( $registration );` |
1394 | 1394 | */ |
1395 | - public static function calculate_reg_final_prices_per_line_item( EE_Line_Item $line_item, $billable_ticket_quantities = array() ) { |
|
1395 | + public static function calculate_reg_final_prices_per_line_item(EE_Line_Item $line_item, $billable_ticket_quantities = array()) { |
|
1396 | 1396 | //init running grand total if not already |
1397 | - if ( ! isset( $running_totals[ 'total' ] ) ) { |
|
1398 | - $running_totals[ 'total' ] = 0; |
|
1397 | + if ( ! isset($running_totals['total'])) { |
|
1398 | + $running_totals['total'] = 0; |
|
1399 | 1399 | } |
1400 | - if( ! isset( $running_totals[ 'taxable' ] ) ) { |
|
1401 | - $running_totals[ 'taxable' ] = array( 'total' => 0 ); |
|
1400 | + if ( ! isset($running_totals['taxable'])) { |
|
1401 | + $running_totals['taxable'] = array('total' => 0); |
|
1402 | 1402 | } |
1403 | - foreach ( $line_item->children() as $child_line_item ) { |
|
1404 | - switch ( $child_line_item->type() ) { |
|
1403 | + foreach ($line_item->children() as $child_line_item) { |
|
1404 | + switch ($child_line_item->type()) { |
|
1405 | 1405 | |
1406 | 1406 | case EEM_Line_Item::type_sub_total : |
1407 | - $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $child_line_item, $billable_ticket_quantities ); |
|
1407 | + $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item($child_line_item, $billable_ticket_quantities); |
|
1408 | 1408 | //combine arrays but preserve numeric keys |
1409 | - $running_totals = array_replace_recursive( $running_totals_from_subtotal, $running_totals ); |
|
1410 | - $running_totals[ 'total' ] += $running_totals_from_subtotal[ 'total' ]; |
|
1411 | - $running_totals[ 'taxable'][ 'total' ] += $running_totals_from_subtotal[ 'taxable' ][ 'total' ]; |
|
1409 | + $running_totals = array_replace_recursive($running_totals_from_subtotal, $running_totals); |
|
1410 | + $running_totals['total'] += $running_totals_from_subtotal['total']; |
|
1411 | + $running_totals['taxable']['total'] += $running_totals_from_subtotal['taxable']['total']; |
|
1412 | 1412 | break; |
1413 | 1413 | |
1414 | 1414 | case EEM_Line_Item::type_tax_sub_total : |
1415 | 1415 | |
1416 | 1416 | //find how much the taxes percentage is |
1417 | - if ( $child_line_item->percent() !== 0 ) { |
|
1417 | + if ($child_line_item->percent() !== 0) { |
|
1418 | 1418 | $tax_percent_decimal = $child_line_item->percent() / 100; |
1419 | 1419 | } else { |
1420 | 1420 | $tax_percent_decimal = EE_Taxes::get_total_taxes_percentage() / 100; |
1421 | 1421 | } |
1422 | 1422 | //and apply to all the taxable totals, and add to the pretax totals |
1423 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1423 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1424 | 1424 | //"total" and "taxable" array key is an exception |
1425 | - if ( $line_item_id === 'taxable' ) { |
|
1425 | + if ($line_item_id === 'taxable') { |
|
1426 | 1426 | continue; |
1427 | 1427 | } |
1428 | - $taxable_total = $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1429 | - $running_totals[ $line_item_id ] += ( $taxable_total * $tax_percent_decimal ); |
|
1428 | + $taxable_total = $running_totals['taxable'][$line_item_id]; |
|
1429 | + $running_totals[$line_item_id] += ($taxable_total * $tax_percent_decimal); |
|
1430 | 1430 | } |
1431 | 1431 | break; |
1432 | 1432 | |
1433 | 1433 | case EEM_Line_Item::type_line_item : |
1434 | 1434 | |
1435 | 1435 | // ticket line items or ???? |
1436 | - if ( $child_line_item->OBJ_type() === 'Ticket' ) { |
|
1436 | + if ($child_line_item->OBJ_type() === 'Ticket') { |
|
1437 | 1437 | // kk it's a ticket |
1438 | - if ( isset( $running_totals[ $child_line_item->ID() ] ) ) { |
|
1438 | + if (isset($running_totals[$child_line_item->ID()])) { |
|
1439 | 1439 | //huh? that shouldn't happen. |
1440 | - $running_totals[ 'total' ] += $child_line_item->total(); |
|
1440 | + $running_totals['total'] += $child_line_item->total(); |
|
1441 | 1441 | } else { |
1442 | 1442 | //its not in our running totals yet. great. |
1443 | - if ( $child_line_item->is_taxable() ) { |
|
1443 | + if ($child_line_item->is_taxable()) { |
|
1444 | 1444 | $taxable_amount = $child_line_item->unit_price(); |
1445 | 1445 | } else { |
1446 | 1446 | $taxable_amount = 0; |
1447 | 1447 | } |
1448 | 1448 | // are we only calculating totals for some tickets? |
1449 | - if ( isset( $billable_ticket_quantities[ $child_line_item->OBJ_ID() ] ) ) { |
|
1450 | - $quantity = $billable_ticket_quantities[ $child_line_item->OBJ_ID() ]; |
|
1451 | - $running_totals[ $child_line_item->ID() ] = $quantity |
|
1449 | + if (isset($billable_ticket_quantities[$child_line_item->OBJ_ID()])) { |
|
1450 | + $quantity = $billable_ticket_quantities[$child_line_item->OBJ_ID()]; |
|
1451 | + $running_totals[$child_line_item->ID()] = $quantity |
|
1452 | 1452 | ? $child_line_item->unit_price() |
1453 | 1453 | : 0; |
1454 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $quantity |
|
1454 | + $running_totals['taxable'][$child_line_item->ID()] = $quantity |
|
1455 | 1455 | ? $taxable_amount |
1456 | 1456 | : 0; |
1457 | 1457 | } else { |
1458 | 1458 | $quantity = $child_line_item->quantity(); |
1459 | - $running_totals[ $child_line_item->ID() ] = $child_line_item->unit_price(); |
|
1460 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $taxable_amount; |
|
1459 | + $running_totals[$child_line_item->ID()] = $child_line_item->unit_price(); |
|
1460 | + $running_totals['taxable'][$child_line_item->ID()] = $taxable_amount; |
|
1461 | 1461 | } |
1462 | - $running_totals[ 'taxable' ][ 'total' ] += $taxable_amount * $quantity; |
|
1463 | - $running_totals[ 'total' ] += $child_line_item->unit_price() * $quantity; |
|
1462 | + $running_totals['taxable']['total'] += $taxable_amount * $quantity; |
|
1463 | + $running_totals['total'] += $child_line_item->unit_price() * $quantity; |
|
1464 | 1464 | } |
1465 | 1465 | } else { |
1466 | 1466 | // it's some other type of item added to the cart |
1467 | 1467 | // it should affect the running totals |
1468 | 1468 | // basically we want to convert it into a PERCENT modifier. Because |
1469 | 1469 | // more clearly affect all registration's final price equally |
1470 | - $line_items_percent_of_running_total = $running_totals[ 'total' ] > 0 |
|
1471 | - ? ( $child_line_item->total() / $running_totals[ 'total' ] ) + 1 |
|
1470 | + $line_items_percent_of_running_total = $running_totals['total'] > 0 |
|
1471 | + ? ($child_line_item->total() / $running_totals['total']) + 1 |
|
1472 | 1472 | : 1; |
1473 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1473 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1474 | 1474 | //the "taxable" array key is an exception |
1475 | - if ( $line_item_id === 'taxable' ) { |
|
1475 | + if ($line_item_id === 'taxable') { |
|
1476 | 1476 | continue; |
1477 | 1477 | } |
1478 | 1478 | // update the running totals |
1479 | 1479 | // yes this actually even works for the running grand total! |
1480 | - $running_totals[ $line_item_id ] = |
|
1480 | + $running_totals[$line_item_id] = |
|
1481 | 1481 | $line_items_percent_of_running_total * $this_running_total; |
1482 | 1482 | |
1483 | - if ( $child_line_item->is_taxable() ) { |
|
1484 | - $running_totals[ 'taxable' ][ $line_item_id ] = |
|
1485 | - $line_items_percent_of_running_total * $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1483 | + if ($child_line_item->is_taxable()) { |
|
1484 | + $running_totals['taxable'][$line_item_id] = |
|
1485 | + $line_items_percent_of_running_total * $running_totals['taxable'][$line_item_id]; |
|
1486 | 1486 | } |
1487 | 1487 | } |
1488 | 1488 | } |
@@ -1500,16 +1500,16 @@ discard block |
||
1500 | 1500 | * @return float | null |
1501 | 1501 | * @throws \OutOfRangeException |
1502 | 1502 | */ |
1503 | - public static function calculate_final_price_for_ticket_line_item( \EE_Line_Item $total_line_item, \EE_Line_Item $ticket_line_item ) { |
|
1503 | + public static function calculate_final_price_for_ticket_line_item(\EE_Line_Item $total_line_item, \EE_Line_Item $ticket_line_item) { |
|
1504 | 1504 | static $final_prices_per_ticket_line_item = array(); |
1505 | - if ( empty( $final_prices_per_ticket_line_item ) ) { |
|
1505 | + if (empty($final_prices_per_ticket_line_item)) { |
|
1506 | 1506 | $final_prices_per_ticket_line_item = \EEH_Line_Item::calculate_reg_final_prices_per_line_item( |
1507 | 1507 | $total_line_item |
1508 | 1508 | ); |
1509 | 1509 | } |
1510 | 1510 | //ok now find this new registration's final price |
1511 | - if ( isset( $final_prices_per_ticket_line_item[ $ticket_line_item->ID() ] ) ) { |
|
1512 | - return $final_prices_per_ticket_line_item[ $ticket_line_item->ID() ]; |
|
1511 | + if (isset($final_prices_per_ticket_line_item[$ticket_line_item->ID()])) { |
|
1512 | + return $final_prices_per_ticket_line_item[$ticket_line_item->ID()]; |
|
1513 | 1513 | } |
1514 | 1514 | $message = sprintf( |
1515 | 1515 | __( |
@@ -1518,10 +1518,10 @@ discard block |
||
1518 | 1518 | ), |
1519 | 1519 | $ticket_line_item->ID() |
1520 | 1520 | ); |
1521 | - if ( WP_DEBUG ) { |
|
1522 | - throw new \OutOfRangeException( $message ); |
|
1521 | + if (WP_DEBUG) { |
|
1522 | + throw new \OutOfRangeException($message); |
|
1523 | 1523 | } else { |
1524 | - EE_Log::instance()->log( __CLASS__, __FUNCTION__, $message ); |
|
1524 | + EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message); |
|
1525 | 1525 | } |
1526 | 1526 | return null; |
1527 | 1527 | } |
@@ -1537,15 +1537,15 @@ discard block |
||
1537 | 1537 | * @return \EE_Line_Item |
1538 | 1538 | * @throws \EE_Error |
1539 | 1539 | */ |
1540 | - public static function billable_line_item_tree( EE_Line_Item $line_item, $registrations ) { |
|
1541 | - $copy_li = EEH_Line_Item::billable_line_item( $line_item, $registrations ); |
|
1542 | - foreach ( $line_item->children() as $child_li ) { |
|
1543 | - $copy_li->add_child_line_item( EEH_Line_Item::billable_line_item_tree( $child_li, $registrations ) ); |
|
1540 | + public static function billable_line_item_tree(EE_Line_Item $line_item, $registrations) { |
|
1541 | + $copy_li = EEH_Line_Item::billable_line_item($line_item, $registrations); |
|
1542 | + foreach ($line_item->children() as $child_li) { |
|
1543 | + $copy_li->add_child_line_item(EEH_Line_Item::billable_line_item_tree($child_li, $registrations)); |
|
1544 | 1544 | } |
1545 | 1545 | //if this is the grand total line item, make sure the totals all add up |
1546 | 1546 | //(we could have duplicated this logic AS we copied the line items, but |
1547 | 1547 | //it seems DRYer this way) |
1548 | - if ( $copy_li->type() === EEM_Line_Item::type_total ) { |
|
1548 | + if ($copy_li->type() === EEM_Line_Item::type_total) { |
|
1549 | 1549 | $copy_li->recalculate_total_including_taxes(); |
1550 | 1550 | } |
1551 | 1551 | return $copy_li; |
@@ -1562,24 +1562,24 @@ discard block |
||
1562 | 1562 | * @throws \EE_Error |
1563 | 1563 | * @param EE_Registration[] $registrations |
1564 | 1564 | */ |
1565 | - public static function billable_line_item( EE_Line_Item $line_item, $registrations ) { |
|
1565 | + public static function billable_line_item(EE_Line_Item $line_item, $registrations) { |
|
1566 | 1566 | $new_li_fields = $line_item->model_field_array(); |
1567 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1567 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1568 | 1568 | $line_item->OBJ_type() === 'Ticket' |
1569 | 1569 | ) { |
1570 | 1570 | $count = 0; |
1571 | - foreach ( $registrations as $registration ) { |
|
1572 | - if ( $line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1573 | - in_array( $registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment() ) |
|
1571 | + foreach ($registrations as $registration) { |
|
1572 | + if ($line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1573 | + in_array($registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment()) |
|
1574 | 1574 | ) { |
1575 | 1575 | $count++; |
1576 | 1576 | } |
1577 | 1577 | } |
1578 | - $new_li_fields[ 'LIN_quantity' ] = $count; |
|
1578 | + $new_li_fields['LIN_quantity'] = $count; |
|
1579 | 1579 | } |
1580 | 1580 | //don't set the total. We'll leave that up to the code that calculates it |
1581 | - unset( $new_li_fields[ 'LIN_ID' ], $new_li_fields[ 'LIN_parent' ], $new_li_fields[ 'LIN_total' ] ); |
|
1582 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1581 | + unset($new_li_fields['LIN_ID'], $new_li_fields['LIN_parent'], $new_li_fields['LIN_total']); |
|
1582 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1583 | 1583 | } |
1584 | 1584 | |
1585 | 1585 | |
@@ -1592,19 +1592,19 @@ discard block |
||
1592 | 1592 | * @return \EE_Line_Item|null |
1593 | 1593 | * @throws \EE_Error |
1594 | 1594 | */ |
1595 | - public static function non_empty_line_items( EE_Line_Item $line_item ) { |
|
1596 | - $copied_li = EEH_Line_Item::non_empty_line_item( $line_item ); |
|
1597 | - if ( $copied_li === null ) { |
|
1595 | + public static function non_empty_line_items(EE_Line_Item $line_item) { |
|
1596 | + $copied_li = EEH_Line_Item::non_empty_line_item($line_item); |
|
1597 | + if ($copied_li === null) { |
|
1598 | 1598 | return null; |
1599 | 1599 | } |
1600 | 1600 | //if this is an event subtotal, we want to only include it if it |
1601 | 1601 | //has a non-zero total and at least one ticket line item child |
1602 | 1602 | $ticket_children = 0; |
1603 | - foreach ( $line_item->children() as $child_li ) { |
|
1604 | - $child_li_copy = EEH_Line_Item::non_empty_line_items( $child_li ); |
|
1605 | - if ( $child_li_copy !== null ) { |
|
1606 | - $copied_li->add_child_line_item( $child_li_copy ); |
|
1607 | - if ( $child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1603 | + foreach ($line_item->children() as $child_li) { |
|
1604 | + $child_li_copy = EEH_Line_Item::non_empty_line_items($child_li); |
|
1605 | + if ($child_li_copy !== null) { |
|
1606 | + $copied_li->add_child_line_item($child_li_copy); |
|
1607 | + if ($child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1608 | 1608 | $child_li_copy->OBJ_type() === 'Ticket' |
1609 | 1609 | ) { |
1610 | 1610 | $ticket_children++; |
@@ -1634,8 +1634,8 @@ discard block |
||
1634 | 1634 | * @return EE_Line_Item |
1635 | 1635 | * @throws \EE_Error |
1636 | 1636 | */ |
1637 | - public static function non_empty_line_item( EE_Line_Item $line_item ) { |
|
1638 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1637 | + public static function non_empty_line_item(EE_Line_Item $line_item) { |
|
1638 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1639 | 1639 | $line_item->OBJ_type() === 'Ticket' && |
1640 | 1640 | $line_item->quantity() === 0 |
1641 | 1641 | ) { |
@@ -1643,8 +1643,8 @@ discard block |
||
1643 | 1643 | } |
1644 | 1644 | $new_li_fields = $line_item->model_field_array(); |
1645 | 1645 | //don't set the total. We'll leave that up to the code that calculates it |
1646 | - unset( $new_li_fields[ 'LIN_ID' ], $new_li_fields[ 'LIN_parent' ] ); |
|
1647 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1646 | + unset($new_li_fields['LIN_ID'], $new_li_fields['LIN_parent']); |
|
1647 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1648 | 1648 | } |
1649 | 1649 | |
1650 | 1650 | |
@@ -1656,9 +1656,9 @@ discard block |
||
1656 | 1656 | * @return \EE_Line_Item |
1657 | 1657 | * @throws \EE_Error |
1658 | 1658 | */ |
1659 | - public static function get_items_subtotal( EE_Line_Item $total_line_item ){ |
|
1660 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1661 | - return self::get_pre_tax_subtotal( $total_line_item ); |
|
1659 | + public static function get_items_subtotal(EE_Line_Item $total_line_item) { |
|
1660 | + EE_Error::doing_it_wrong('EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1661 | + return self::get_pre_tax_subtotal($total_line_item); |
|
1662 | 1662 | } |
1663 | 1663 | |
1664 | 1664 | |
@@ -1669,9 +1669,9 @@ discard block |
||
1669 | 1669 | * @return \EE_Line_Item |
1670 | 1670 | * @throws \EE_Error |
1671 | 1671 | */ |
1672 | - public static function create_default_total_line_item( $transaction = NULL) { |
|
1673 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0' ); |
|
1674 | - return self::create_total_line_item( $transaction ); |
|
1672 | + public static function create_default_total_line_item($transaction = NULL) { |
|
1673 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0'); |
|
1674 | + return self::create_total_line_item($transaction); |
|
1675 | 1675 | } |
1676 | 1676 | |
1677 | 1677 | |
@@ -1683,9 +1683,9 @@ discard block |
||
1683 | 1683 | * @return \EE_Line_Item |
1684 | 1684 | * @throws \EE_Error |
1685 | 1685 | */ |
1686 | - public static function create_default_tickets_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1687 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1688 | - return self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
1686 | + public static function create_default_tickets_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1687 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1688 | + return self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
1689 | 1689 | } |
1690 | 1690 | |
1691 | 1691 | |
@@ -1697,9 +1697,9 @@ discard block |
||
1697 | 1697 | * @return \EE_Line_Item |
1698 | 1698 | * @throws \EE_Error |
1699 | 1699 | */ |
1700 | - public static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1701 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1702 | - return self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
1700 | + public static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1701 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0'); |
|
1702 | + return self::create_taxes_subtotal($total_line_item, $transaction); |
|
1703 | 1703 | } |
1704 | 1704 | |
1705 | 1705 | |
@@ -1711,9 +1711,9 @@ discard block |
||
1711 | 1711 | * @return \EE_Line_Item |
1712 | 1712 | * @throws \EE_Error |
1713 | 1713 | */ |
1714 | - public static function create_default_event_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1715 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1716 | - return self::create_event_subtotal( $total_line_item, $transaction ); |
|
1714 | + public static function create_default_event_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1715 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0'); |
|
1716 | + return self::create_event_subtotal($total_line_item, $transaction); |
|
1717 | 1717 | } |
1718 | 1718 | |
1719 | 1719 |