@@ -12,16 +12,16 @@ discard block |
||
12 | 12 | //(all other times it gets resurrected from a wordpress option) |
13 | 13 | $stages = glob(EE_CORE.'data_migration_scripts/4_5_0_stages/*'); |
14 | 14 | $class_to_filepath = array(); |
15 | -foreach($stages as $filepath){ |
|
15 | +foreach ($stages as $filepath) { |
|
16 | 16 | $matches = array(); |
17 | - preg_match('~4_5_0_stages/(.*).dmsstage.php~',$filepath,$matches); |
|
17 | + preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
18 | 18 | $class_to_filepath[$matches[1]] = $filepath; |
19 | 19 | } |
20 | 20 | //give addons a chance to autoload their stages too |
21 | -$class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages',$class_to_filepath); |
|
21 | +$class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages', $class_to_filepath); |
|
22 | 22 | EEH_Autoloader::register_autoloader($class_to_filepath); |
23 | 23 | |
24 | -class EE_DMS_Core_4_5_0 extends EE_Data_Migration_Script_Base{ |
|
24 | +class EE_DMS_Core_4_5_0 extends EE_Data_Migration_Script_Base { |
|
25 | 25 | |
26 | 26 | |
27 | 27 | |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | } |
40 | 40 | public function can_migrate_from_version($version_array) { |
41 | 41 | $version_string = $version_array['Core']; |
42 | - if($version_string <= '4.5.0' && $version_string >= '4.3.0' ){ |
|
42 | + if ($version_string <= '4.5.0' && $version_string >= '4.3.0') { |
|
43 | 43 | // echo "$version_string can be migrated from"; |
44 | 44 | return true; |
45 | - }elseif( ! $version_string ){ |
|
45 | + }elseif ( ! $version_string) { |
|
46 | 46 | // echo "no version string provided: $version_string"; |
47 | 47 | //no version string provided... this must be pre 4.3 |
48 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
49 | - }else{ |
|
48 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
49 | + } else { |
|
50 | 50 | // echo "$version_string doesnt apply"; |
51 | 51 | return false; |
52 | 52 | } |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | } |
57 | 57 | public function schema_changes_before_migration() { |
58 | 58 | //relies on 4.1's EEH_Activation::create_table |
59 | - require_once( EE_HELPERS . 'EEH_Activation.helper.php' ); |
|
60 | - $table_name='esp_answer'; |
|
61 | - $sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
59 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
60 | + $table_name = 'esp_answer'; |
|
61 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
62 | 62 | REG_ID INT UNSIGNED NOT NULL, |
63 | 63 | QST_ID INT UNSIGNED NOT NULL, |
64 | 64 | ANS_value TEXT NOT NULL, |
65 | 65 | PRIMARY KEY (ANS_ID)"; |
66 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
66 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
67 | 67 | |
68 | 68 | $table_name = 'esp_attendee_meta'; |
69 | 69 | $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | CNT_is_EU TINYINT(1) DEFAULT '0', |
103 | 103 | CNT_active TINYINT(1) DEFAULT '0', |
104 | 104 | PRIMARY KEY (CNT_ISO)"; |
105 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
105 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
106 | 106 | |
107 | 107 | $table_name = 'esp_datetime'; |
108 | 108 | $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | |
125 | 125 | |
126 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
126 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
127 | 127 | $table_name = 'esp_event_meta'; |
128 | 128 | $sql = " |
129 | 129 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
@@ -140,41 +140,41 @@ discard block |
||
140 | 140 | EVT_external_URL VARCHAR(200) NULL, |
141 | 141 | EVT_donations TINYINT(1) NULL, |
142 | 142 | PRIMARY KEY (EVTM_ID)"; |
143 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
143 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
144 | 144 | |
145 | 145 | |
146 | 146 | |
147 | - $table_name='esp_event_question_group'; |
|
148 | - $sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
147 | + $table_name = 'esp_event_question_group'; |
|
148 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
149 | 149 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
150 | 150 | QSG_ID INT UNSIGNED NOT NULL, |
151 | 151 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
152 | 152 | PRIMARY KEY (EQG_ID)"; |
153 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
153 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
154 | 154 | |
155 | 155 | |
156 | 156 | |
157 | - $table_name='esp_event_venue'; |
|
158 | - $sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
157 | + $table_name = 'esp_event_venue'; |
|
158 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
159 | 159 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
160 | 160 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
161 | 161 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
162 | 162 | PRIMARY KEY (EVV_ID)"; |
163 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
163 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
164 | 164 | |
165 | 165 | |
166 | 166 | |
167 | - $table_name='esp_extra_meta'; |
|
168 | - $sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
167 | + $table_name = 'esp_extra_meta'; |
|
168 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
169 | 169 | OBJ_ID INT(11) DEFAULT NULL, |
170 | 170 | EXM_type VARCHAR(45) DEFAULT NULL, |
171 | 171 | EXM_key VARCHAR(45) DEFAULT NULL, |
172 | 172 | EXM_value TEXT, |
173 | 173 | PRIMARY KEY (EXM_ID)"; |
174 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
174 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
175 | 175 | |
176 | - $table_name='esp_line_item'; |
|
177 | - $sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
176 | + $table_name = 'esp_line_item'; |
|
177 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
178 | 178 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
179 | 179 | TXN_ID INT(11) DEFAULT NULL, |
180 | 180 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | OBJ_ID INT(11) DEFAULT NULL, |
191 | 191 | OBJ_type VARCHAR(45)DEFAULT NULL, |
192 | 192 | PRIMARY KEY (LIN_ID)"; |
193 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB' ); |
|
193 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
194 | 194 | |
195 | 195 | $table_name = 'esp_message_template'; |
196 | 196 | $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | KEY GRP_ID (GRP_ID)"; |
203 | 203 | $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
204 | 204 | |
205 | - EEH_Activation::drop_index( 'esp_message_template_group', 'EVT_ID' ); |
|
205 | + EEH_Activation::drop_index('esp_message_template_group', 'EVT_ID'); |
|
206 | 206 | |
207 | 207 | $table_name = 'esp_message_template_group'; |
208 | 208 | $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
218 | 218 | PRIMARY KEY (GRP_ID), |
219 | 219 | KEY MTP_user_id (MTP_user_id)"; |
220 | - $this->_table_should_exist_previously( $table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
221 | 221 | |
222 | 222 | $table_name = 'esp_event_message_template'; |
223 | 223 | $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | PRIMARY KEY (EMT_ID), |
227 | 227 | KEY EVT_ID (EVT_ID), |
228 | 228 | KEY GRP_ID (GRP_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 | |
232 | 232 | $table_name = 'esp_payment'; |
@@ -276,8 +276,8 @@ discard block |
||
276 | 276 | PRIMARY KEY (TTM_ID)"; |
277 | 277 | $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
278 | 278 | |
279 | - $table_name='esp_question'; |
|
280 | - $sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
279 | + $table_name = 'esp_question'; |
|
280 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
281 | 281 | QST_display_text TEXT NOT NULL, |
282 | 282 | QST_admin_label VARCHAR(255) NOT NULL, |
283 | 283 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -289,27 +289,27 @@ discard block |
||
289 | 289 | QST_wp_user BIGINT UNSIGNED NULL, |
290 | 290 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
291 | 291 | PRIMARY KEY (QST_ID)'; |
292 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
292 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
293 | 293 | |
294 | - $table_name='esp_question_group_question'; |
|
295 | - $sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
294 | + $table_name = 'esp_question_group_question'; |
|
295 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
296 | 296 | QSG_ID INT UNSIGNED NOT NULL, |
297 | 297 | QST_ID INT UNSIGNED NOT NULL, |
298 | 298 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
299 | 299 | PRIMARY KEY (QGQ_ID) "; |
300 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
300 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
301 | 301 | |
302 | 302 | |
303 | 303 | |
304 | - $table_name='esp_question_option'; |
|
305 | - $sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
304 | + $table_name = 'esp_question_option'; |
|
305 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
306 | 306 | QSO_value VARCHAR(255) NOT NULL, |
307 | 307 | QSO_desc TEXT NOT NULL, |
308 | 308 | QST_ID INT UNSIGNED NOT NULL, |
309 | 309 | QSO_order INT UNSIGNED NOT NULL DEFAULT 0, |
310 | 310 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
311 | 311 | PRIMARY KEY (QSO_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 | |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | |
343 | 343 | |
344 | 344 | |
345 | - $table_name='esp_checkin'; |
|
346 | - $sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
345 | + $table_name = 'esp_checkin'; |
|
346 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
347 | 347 | REG_ID INT(10) UNSIGNED NOT NULL, |
348 | 348 | DTT_ID INT(10) UNSIGNED NOT NULL, |
349 | 349 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | PRC_wp_user BIGINT UNSIGNED NULL, |
432 | 432 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
433 | 433 | PRIMARY KEY (PRC_ID)"; |
434 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
434 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
435 | 435 | |
436 | 436 | $table_name = "esp_price_type"; |
437 | 437 | $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -468,12 +468,12 @@ discard block |
||
468 | 468 | TKT_parent INT(10) UNSIGNED DEFAULT '0', |
469 | 469 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
470 | 470 | PRIMARY KEY (TKT_ID)"; |
471 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
471 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
472 | 472 | |
473 | - EEH_Activation::drop_index( 'esp_question_group', 'QSG_identifier_UNIQUE' ); |
|
473 | + EEH_Activation::drop_index('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
474 | 474 | |
475 | 475 | $table_name = 'esp_question_group'; |
476 | - $sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
476 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
477 | 477 | QSG_name VARCHAR(255) NOT NULL, |
478 | 478 | QSG_identifier VARCHAR(100) NOT NULL, |
479 | 479 | QSG_desc TEXT NULL, |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | QSG_wp_user BIGINT UNSIGNED NULL, |
486 | 486 | PRIMARY KEY (QSG_ID), |
487 | 487 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
488 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
488 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
489 | 489 | |
490 | 490 | $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
491 | 491 | |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | return true; |
510 | 510 | } |
511 | 511 | |
512 | - public function migration_page_hooks(){ |
|
512 | + public function migration_page_hooks() { |
|
513 | 513 | |
514 | 514 | } |
515 | 515 | |
@@ -523,21 +523,21 @@ discard block |
||
523 | 523 | global $wpdb; |
524 | 524 | $price_type_table = $wpdb->prefix."esp_price_type"; |
525 | 525 | |
526 | - if ( EEH_Activation::table_exists( $price_type_table ) ) { |
|
526 | + if (EEH_Activation::table_exists($price_type_table)) { |
|
527 | 527 | |
528 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
529 | - $price_types_exist = $wpdb->get_var( $SQL ); |
|
528 | + $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table; |
|
529 | + $price_types_exist = $wpdb->get_var($SQL); |
|
530 | 530 | |
531 | - if ( ! $price_types_exist ) { |
|
531 | + if ( ! $price_types_exist) { |
|
532 | 532 | $user_id = EEH_Activation::get_default_creator_id(); |
533 | 533 | $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES |
534 | - (1, '" . __('Base Price', 'event_espresso') . "', 1, 0, 0, $user_id, 0), |
|
535 | - (2, '" . __('Percent Discount', 'event_espresso') . "', 2, 1, 20, $user_id, 0), |
|
536 | - (3, '" . __('Dollar Discount', 'event_espresso') . "', 2, 0, 30, $user_id, 0), |
|
537 | - (4, '" . __('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, $user_id, 0), |
|
538 | - (5, '" . __('Dollar Surcharge', 'event_espresso') . "', 3, 0, 50, $user_id, 0);"; |
|
539 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL ); |
|
540 | - $wpdb->query( $SQL ); |
|
534 | + (1, '".__('Base Price', 'event_espresso')."', 1, 0, 0, $user_id, 0), |
|
535 | + (2, '".__('Percent Discount', 'event_espresso')."', 2, 1, 20, $user_id, 0), |
|
536 | + (3, '".__('Dollar Discount', 'event_espresso')."', 2, 0, 30, $user_id, 0), |
|
537 | + (4, '".__('Percent Surcharge', 'event_espresso')."', 3, 1, 40, $user_id, 0), |
|
538 | + (5, '".__('Dollar Surcharge', 'event_espresso')."', 3, 0, 50, $user_id, 0);"; |
|
539 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL); |
|
540 | + $wpdb->query($SQL); |
|
541 | 541 | } |
542 | 542 | } |
543 | 543 | } |
@@ -557,17 +557,17 @@ discard block |
||
557 | 557 | global $wpdb; |
558 | 558 | $price_table = $wpdb->prefix."esp_price"; |
559 | 559 | |
560 | - if ( EEH_Activation::table_exists( $price_table ) ) { |
|
560 | + if (EEH_Activation::table_exists($price_table)) { |
|
561 | 561 | |
562 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' .$price_table; |
|
563 | - $prices_exist = $wpdb->get_var( $SQL ); |
|
562 | + $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table; |
|
563 | + $prices_exist = $wpdb->get_var($SQL); |
|
564 | 564 | |
565 | - if ( ! $prices_exist ) { |
|
565 | + if ( ! $prices_exist) { |
|
566 | 566 | $user_id = EEH_Activation::get_default_creator_id(); |
567 | 567 | $SQL = "INSERT INTO $price_table |
568 | 568 | (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 |
569 | 569 | (1, 1, '0.00', 'Free Admission', '', 1, NULL, $user_id, 0, 0, 0);"; |
570 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL ); |
|
570 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL); |
|
571 | 571 | $wpdb->query($SQL); |
572 | 572 | } |
573 | 573 | } |
@@ -585,35 +585,35 @@ discard block |
||
585 | 585 | |
586 | 586 | global $wpdb; |
587 | 587 | $ticket_table = $wpdb->prefix."esp_ticket"; |
588 | - if ( EEH_Activation::table_exists( $ticket_table ) ) { |
|
588 | + if (EEH_Activation::table_exists($ticket_table)) { |
|
589 | 589 | |
590 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
590 | + $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table; |
|
591 | 591 | $tickets_exist = $wpdb->get_var($SQL); |
592 | 592 | |
593 | - if ( ! $tickets_exist ) { |
|
593 | + if ( ! $tickets_exist) { |
|
594 | 594 | $user_id = EEH_Activation::get_default_creator_id(); |
595 | 595 | $SQL = "INSERT INTO $ticket_table |
596 | 596 | ( 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 |
597 | - ( 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);"; |
|
598 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL ); |
|
597 | + ( 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);"; |
|
598 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL); |
|
599 | 599 | $wpdb->query($SQL); |
600 | 600 | } |
601 | 601 | } |
602 | 602 | $ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
603 | 603 | |
604 | - if ( EEH_Activation::table_exists( $ticket_price_table ) ) { |
|
604 | + if (EEH_Activation::table_exists($ticket_price_table)) { |
|
605 | 605 | |
606 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
606 | + $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table; |
|
607 | 607 | $ticket_prc_exist = $wpdb->get_var($SQL); |
608 | 608 | |
609 | - if ( ! $ticket_prc_exist ) { |
|
609 | + if ( ! $ticket_prc_exist) { |
|
610 | 610 | |
611 | 611 | $SQL = "INSERT INTO $ticket_price_table |
612 | 612 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
613 | 613 | ( 1, 1, 1 ) |
614 | 614 | "; |
615 | 615 | |
616 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL ); |
|
616 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
617 | 617 | $wpdb->query($SQL); |
618 | 618 | } |
619 | 619 | } |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | //(all other times it gets resurrected from a wordpress option) |
11 | 11 | $stages = glob(EE_CORE.'data_migration_scripts/4_6_0_stages/*'); |
12 | 12 | $class_to_filepath = array(); |
13 | -foreach($stages as $filepath){ |
|
13 | +foreach ($stages as $filepath) { |
|
14 | 14 | $matches = array(); |
15 | - preg_match('~4_6_0_stages/(.*).dmsstage.php~',$filepath,$matches); |
|
15 | + preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
16 | 16 | $class_to_filepath[$matches[1]] = $filepath; |
17 | 17 | } |
18 | 18 | //give addons a chance to autoload their stages too |
19 | -$class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages',$class_to_filepath); |
|
19 | +$class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath); |
|
20 | 20 | EEH_Autoloader::register_autoloader($class_to_filepath); |
21 | 21 | |
22 | 22 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @since 4.6.0 |
33 | 33 | * |
34 | 34 | */ |
35 | -class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base{ |
|
35 | +class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base { |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * return EE_DMS_Core_4_6_0 |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function can_migrate_from_version($version_array) { |
64 | 64 | $version_string = $version_array['Core']; |
65 | - if($version_string <= '4.6.0' && $version_string >= '4.5.0' ){ |
|
65 | + if ($version_string <= '4.6.0' && $version_string >= '4.5.0') { |
|
66 | 66 | // echo "$version_string can be migrated from"; |
67 | 67 | return true; |
68 | - }elseif( ! $version_string ){ |
|
68 | + }elseif ( ! $version_string) { |
|
69 | 69 | // echo "no version string provided: $version_string"; |
70 | 70 | //no version string provided... this must be pre 4.3 |
71 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
72 | - }else{ |
|
71 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
72 | + } else { |
|
73 | 73 | // echo "$version_string doesnt apply"; |
74 | 74 | return false; |
75 | 75 | } |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function schema_changes_before_migration() { |
93 | 93 | //relies on 4.1's EEH_Activation::create_table |
94 | - require_once( EE_HELPERS . 'EEH_Activation.helper.php' ); |
|
95 | - $table_name='esp_answer'; |
|
96 | - $sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
94 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
95 | + $table_name = 'esp_answer'; |
|
96 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
97 | 97 | REG_ID INT UNSIGNED NOT NULL, |
98 | 98 | QST_ID INT UNSIGNED NOT NULL, |
99 | 99 | ANS_value TEXT NOT NULL, |
100 | 100 | PRIMARY KEY (ANS_ID)"; |
101 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
101 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
102 | 102 | |
103 | 103 | $table_name = 'esp_attendee_meta'; |
104 | 104 | $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | CNT_is_EU TINYINT(1) DEFAULT '0', |
138 | 138 | CNT_active TINYINT(1) DEFAULT '0', |
139 | 139 | PRIMARY KEY (CNT_ISO)"; |
140 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
140 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
141 | 141 | |
142 | 142 | $table_name = 'esp_currency'; |
143 | 143 | $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
148 | 148 | CUR_active TINYINT(1) DEFAULT '0', |
149 | 149 | PRIMARY KEY (CUR_code)"; |
150 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
150 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
151 | 151 | |
152 | 152 | |
153 | 153 | $table_name = 'esp_currency_payment_method'; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | |
179 | 179 | |
180 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
180 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
181 | 181 | $table_name = 'esp_event_meta'; |
182 | 182 | $sql = " |
183 | 183 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
@@ -194,41 +194,41 @@ discard block |
||
194 | 194 | EVT_external_URL VARCHAR(200) NULL, |
195 | 195 | EVT_donations TINYINT(1) NULL, |
196 | 196 | PRIMARY KEY (EVTM_ID)"; |
197 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
197 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | 198 | |
199 | 199 | |
200 | 200 | |
201 | - $table_name='esp_event_question_group'; |
|
202 | - $sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
201 | + $table_name = 'esp_event_question_group'; |
|
202 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
203 | 203 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
204 | 204 | QSG_ID INT UNSIGNED NOT NULL, |
205 | 205 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
206 | 206 | PRIMARY KEY (EQG_ID)"; |
207 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
207 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
208 | 208 | |
209 | 209 | |
210 | 210 | |
211 | - $table_name='esp_event_venue'; |
|
212 | - $sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
211 | + $table_name = 'esp_event_venue'; |
|
212 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
213 | 213 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
214 | 214 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
215 | 215 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
216 | 216 | PRIMARY KEY (EVV_ID)"; |
217 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
217 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
218 | 218 | |
219 | 219 | |
220 | 220 | |
221 | - $table_name='esp_extra_meta'; |
|
222 | - $sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
221 | + $table_name = 'esp_extra_meta'; |
|
222 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
223 | 223 | OBJ_ID INT(11) DEFAULT NULL, |
224 | 224 | EXM_type VARCHAR(45) DEFAULT NULL, |
225 | 225 | EXM_key VARCHAR(45) DEFAULT NULL, |
226 | 226 | EXM_value TEXT, |
227 | 227 | PRIMARY KEY (EXM_ID)"; |
228 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
228 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
229 | 229 | |
230 | - $table_name='esp_line_item'; |
|
231 | - $sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
230 | + $table_name = 'esp_line_item'; |
|
231 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
232 | 232 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
233 | 233 | TXN_ID INT(11) DEFAULT NULL, |
234 | 234 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | OBJ_ID INT(11) DEFAULT NULL, |
245 | 245 | OBJ_type VARCHAR(45)DEFAULT NULL, |
246 | 246 | PRIMARY KEY (LIN_ID)"; |
247 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB' ); |
|
247 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
248 | 248 | |
249 | 249 | $table_name = 'esp_log'; |
250 | 250 | $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | KEY GRP_ID (GRP_ID)"; |
268 | 268 | $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
269 | 269 | |
270 | - EEH_Activation::drop_index( 'esp_message_template_group', 'EVT_ID' ); |
|
270 | + EEH_Activation::drop_index('esp_message_template_group', 'EVT_ID'); |
|
271 | 271 | |
272 | 272 | $table_name = 'esp_message_template_group'; |
273 | 273 | $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
283 | 283 | PRIMARY KEY (GRP_ID), |
284 | 284 | KEY MTP_user_id (MTP_user_id)"; |
285 | - $this->_table_should_exist_previously( $table_name, $sql, 'ENGINE=InnoDB'); |
|
285 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
286 | 286 | |
287 | 287 | $table_name = 'esp_event_message_template'; |
288 | 288 | $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | PRIMARY KEY (EMT_ID), |
292 | 292 | KEY EVT_ID (EVT_ID), |
293 | 293 | KEY GRP_ID (GRP_ID)"; |
294 | - $this->_table_should_exist_previously( $table_name, $sql, 'ENGINE=InnoDB'); |
|
294 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
295 | 295 | |
296 | 296 | |
297 | 297 | $table_name = 'esp_payment'; |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | PRIMARY KEY (TTM_ID)"; |
360 | 360 | $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
361 | 361 | |
362 | - $table_name='esp_question'; |
|
363 | - $sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
362 | + $table_name = 'esp_question'; |
|
363 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
364 | 364 | QST_display_text TEXT NOT NULL, |
365 | 365 | QST_admin_label VARCHAR(255) NOT NULL, |
366 | 366 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -372,27 +372,27 @@ discard block |
||
372 | 372 | QST_wp_user BIGINT UNSIGNED NULL, |
373 | 373 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
374 | 374 | PRIMARY KEY (QST_ID)'; |
375 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
375 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
376 | 376 | |
377 | - $table_name='esp_question_group_question'; |
|
378 | - $sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
377 | + $table_name = 'esp_question_group_question'; |
|
378 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
379 | 379 | QSG_ID INT UNSIGNED NOT NULL, |
380 | 380 | QST_ID INT UNSIGNED NOT NULL, |
381 | 381 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
382 | 382 | PRIMARY KEY (QGQ_ID) "; |
383 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
383 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | 384 | |
385 | 385 | |
386 | 386 | |
387 | - $table_name='esp_question_option'; |
|
388 | - $sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
387 | + $table_name = 'esp_question_option'; |
|
388 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
389 | 389 | QSO_value VARCHAR(255) NOT NULL, |
390 | 390 | QSO_desc TEXT NOT NULL, |
391 | 391 | QST_ID INT UNSIGNED NOT NULL, |
392 | 392 | QSO_order INT UNSIGNED NOT NULL DEFAULT 0, |
393 | 393 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
394 | 394 | PRIMARY KEY (QSO_ID)"; |
395 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
395 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
396 | 396 | |
397 | 397 | |
398 | 398 | |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | |
426 | 426 | |
427 | 427 | |
428 | - $table_name='esp_checkin'; |
|
429 | - $sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
428 | + $table_name = 'esp_checkin'; |
|
429 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
430 | 430 | REG_ID INT(10) UNSIGNED NOT NULL, |
431 | 431 | DTT_ID INT(10) UNSIGNED NOT NULL, |
432 | 432 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | PRC_wp_user BIGINT UNSIGNED NULL, |
516 | 516 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
517 | 517 | PRIMARY KEY (PRC_ID)"; |
518 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
518 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
519 | 519 | |
520 | 520 | $table_name = "esp_price_type"; |
521 | 521 | $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -552,12 +552,12 @@ discard block |
||
552 | 552 | TKT_parent INT(10) UNSIGNED DEFAULT '0', |
553 | 553 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
554 | 554 | PRIMARY KEY (TKT_ID)"; |
555 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
555 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
556 | 556 | |
557 | - EEH_Activation::drop_index( 'esp_question_group', 'QSG_identifier_UNIQUE' ); |
|
557 | + EEH_Activation::drop_index('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
558 | 558 | |
559 | 559 | $table_name = 'esp_question_group'; |
560 | - $sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
560 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
561 | 561 | QSG_name VARCHAR(255) NOT NULL, |
562 | 562 | QSG_identifier VARCHAR(100) NOT NULL, |
563 | 563 | QSG_desc TEXT NULL, |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | QSG_wp_user BIGINT UNSIGNED NULL, |
570 | 570 | PRIMARY KEY (QSG_ID), |
571 | 571 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
572 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
572 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
573 | 573 | |
574 | 574 | /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
575 | 575 | $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
@@ -597,15 +597,15 @@ discard block |
||
597 | 597 | return true; |
598 | 598 | } |
599 | 599 | |
600 | - public function migration_page_hooks(){ |
|
600 | + public function migration_page_hooks() { |
|
601 | 601 | |
602 | 602 | } |
603 | 603 | |
604 | - public function add_default_admin_only_payments(){ |
|
604 | + public function add_default_admin_only_payments() { |
|
605 | 605 | global $wpdb; |
606 | 606 | $table_name = $wpdb->prefix."esp_payment_method"; |
607 | 607 | $user_id = EEH_Activation::get_default_creator_id(); |
608 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
608 | + if (EEH_Activation::table_exists($table_name)) { |
|
609 | 609 | |
610 | 610 | $SQL = "SELECT COUNT( * ) FROM $table_name"; |
611 | 611 | $existing_payment_methods = $wpdb->get_var($SQL); |
@@ -626,11 +626,11 @@ discard block |
||
626 | 626 | //so admins can record payments for them from the admin page |
627 | 627 | |
628 | 628 | |
629 | - foreach($default_admin_only_payment_methods as $nicename => $description){ |
|
629 | + foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
630 | 630 | $slug = sanitize_key($nicename); |
631 | 631 | //check that such a payment method exists |
632 | - $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s",$slug)); |
|
633 | - if( ! $exists){ |
|
632 | + $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
633 | + if ( ! $exists) { |
|
634 | 634 | $values = array( |
635 | 635 | 'PMD_type'=>'Admin_Only', |
636 | 636 | 'PMD_name'=>$nicename, |
@@ -644,17 +644,17 @@ discard block |
||
644 | 644 | $table_name, |
645 | 645 | $values, |
646 | 646 | array( |
647 | - '%s',//PMD_type |
|
648 | - '%s',//PMD_name |
|
649 | - '%s',//PMD_admin_name |
|
650 | - '%s',//PMD_admin_desc |
|
651 | - '%s',//PMD_slug |
|
652 | - '%d',//PMD_wp_user |
|
653 | - '%s',//PMD_scope |
|
647 | + '%s', //PMD_type |
|
648 | + '%s', //PMD_name |
|
649 | + '%s', //PMD_admin_name |
|
650 | + '%s', //PMD_admin_desc |
|
651 | + '%s', //PMD_slug |
|
652 | + '%d', //PMD_wp_user |
|
653 | + '%s', //PMD_scope |
|
654 | 654 | ) |
655 | 655 | ); |
656 | - if( ! $success ){ |
|
657 | - $this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", "event_espresso"),$this->_json_encode($values))); |
|
656 | + if ( ! $success) { |
|
657 | + $this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", "event_espresso"), $this->_json_encode($values))); |
|
658 | 658 | } |
659 | 659 | } |
660 | 660 | } |
@@ -672,11 +672,11 @@ discard block |
||
672 | 672 | |
673 | 673 | global $wpdb; |
674 | 674 | $currency_table = $wpdb->prefix."esp_currency"; |
675 | - if ( EEH_Activation::table_exists( $currency_table ) ) { |
|
675 | + if (EEH_Activation::table_exists($currency_table)) { |
|
676 | 676 | |
677 | 677 | $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
678 | 678 | $countries = $wpdb->get_var($SQL); |
679 | - if ( ! $countries ) { |
|
679 | + if ( ! $countries) { |
|
680 | 680 | $SQL = "INSERT INTO $currency_table |
681 | 681 | ( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES |
682 | 682 | ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
@@ -8,15 +8,15 @@ discard block |
||
8 | 8 | //(all other times it gets resurrected from a wordpress option) |
9 | 9 | $stages = glob(EE_CORE.'data_migration_scripts/4_1_0_stages/*'); |
10 | 10 | $class_to_filepath = array(); |
11 | -if ( ! empty( $stages ) ) { |
|
12 | - foreach($stages as $filepath){ |
|
11 | +if ( ! empty($stages)) { |
|
12 | + foreach ($stages as $filepath) { |
|
13 | 13 | $matches = array(); |
14 | - preg_match('~4_1_0_stages/(.*).dmsstage.php~',$filepath,$matches); |
|
14 | + preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | 15 | $class_to_filepath[$matches[1]] = $filepath; |
16 | 16 | } |
17 | 17 | } |
18 | 18 | //give addons a chance to autoload their stages too |
19 | -$class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages',$class_to_filepath); |
|
19 | +$class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages', $class_to_filepath); |
|
20 | 20 | EEH_Autoloader::register_autoloader($class_to_filepath); |
21 | 21 | |
22 | 22 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * --a function named update_espresso_config() which saves the EE_Config object to the database |
35 | 35 | * --...and all its subclasses... really, you're best off copying the whole thin gwhen 4.1 is released into this file and wrapping its declaration in if( ! class_exists()){...} |
36 | 36 | */ |
37 | -class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base{ |
|
37 | +class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base { |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
@@ -67,26 +67,26 @@ discard block |
||
67 | 67 | * @global type $wpdb |
68 | 68 | * @return boolean |
69 | 69 | */ |
70 | - private function _checkin_table_exists(){ |
|
70 | + private function _checkin_table_exists() { |
|
71 | 71 | global $wpdb; |
72 | 72 | $results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'"); |
73 | - if($results){ |
|
73 | + if ($results) { |
|
74 | 74 | return true; |
75 | - }else{ |
|
75 | + } else { |
|
76 | 76 | return false; |
77 | 77 | } |
78 | 78 | } |
79 | 79 | public function can_migrate_from_version($version_array) { |
80 | 80 | $version_string = $version_array['Core']; |
81 | - if($version_string < '4.0.0' && $version_string > '3.1.26' ){ |
|
81 | + if ($version_string < '4.0.0' && $version_string > '3.1.26') { |
|
82 | 82 | // echo "$version_string can be migrated fro"; |
83 | 83 | return true; |
84 | - }elseif( ! $version_string ){ |
|
84 | + }elseif ( ! $version_string) { |
|
85 | 85 | // echo "no version string provided: $version_string"; |
86 | 86 | //no version string provided... this must be pre 4.1 |
87 | 87 | //because since 4.1 we're |
88 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
89 | - }else{ |
|
88 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
89 | + } else { |
|
90 | 90 | // echo "$version_string doesnt apply"; |
91 | 91 | return false; |
92 | 92 | } |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | } |
97 | 97 | public function schema_changes_before_migration() { |
98 | 98 | //relies on 4.1's EEH_Activation::create_table |
99 | - require_once( EE_HELPERS . 'EEH_Activation.helper.php' ); |
|
99 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
100 | 100 | |
101 | - $table_name='esp_answer'; |
|
102 | - $sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
101 | + $table_name = 'esp_answer'; |
|
102 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
103 | 103 | REG_ID INT UNSIGNED NOT NULL, |
104 | 104 | QST_ID INT UNSIGNED NOT NULL, |
105 | 105 | ANS_value TEXT NOT NULL, |
106 | 106 | PRIMARY KEY (ANS_ID)"; |
107 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
107 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
108 | 108 | |
109 | 109 | $table_name = 'esp_attendee_meta'; |
110 | 110 | $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | CNT_is_EU TINYINT(1) DEFAULT '0', |
145 | 145 | CNT_active TINYINT(1) DEFAULT '0', |
146 | 146 | PRIMARY KEY (CNT_ISO)"; |
147 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
147 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
148 | 148 | |
149 | 149 | |
150 | 150 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | |
167 | 167 | |
168 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
168 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
169 | 169 | $table_name = 'esp_event_meta'; |
170 | 170 | $sql = " |
171 | 171 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
@@ -182,41 +182,41 @@ discard block |
||
182 | 182 | EVT_external_URL VARCHAR(200) NULL, |
183 | 183 | EVT_donations TINYINT(1) NULL, |
184 | 184 | PRIMARY KEY (EVTM_ID)"; |
185 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
185 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | 186 | |
187 | 187 | |
188 | 188 | |
189 | - $table_name='esp_event_question_group'; |
|
190 | - $sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
189 | + $table_name = 'esp_event_question_group'; |
|
190 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
191 | 191 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
192 | 192 | QSG_ID INT UNSIGNED NOT NULL, |
193 | 193 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
194 | 194 | PRIMARY KEY (EQG_ID)"; |
195 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
195 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
196 | 196 | |
197 | 197 | |
198 | 198 | |
199 | - $table_name='esp_event_venue'; |
|
200 | - $sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
199 | + $table_name = 'esp_event_venue'; |
|
200 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
201 | 201 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
202 | 202 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
203 | 203 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
204 | 204 | PRIMARY KEY (EVV_ID)"; |
205 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
205 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
206 | 206 | |
207 | 207 | |
208 | 208 | |
209 | - $table_name='esp_extra_meta'; |
|
210 | - $sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
209 | + $table_name = 'esp_extra_meta'; |
|
210 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
211 | 211 | OBJ_ID INT(11) DEFAULT NULL, |
212 | 212 | EXM_type VARCHAR(45) DEFAULT NULL, |
213 | 213 | EXM_key VARCHAR(45) DEFAULT NULL, |
214 | 214 | EXM_value TEXT, |
215 | 215 | PRIMARY KEY (EXM_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 | - $table_name='esp_line_item'; |
|
219 | - $sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
218 | + $table_name = 'esp_line_item'; |
|
219 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
220 | 220 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
221 | 221 | TXN_ID INT(11) DEFAULT NULL, |
222 | 222 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | OBJ_ID INT(11) DEFAULT NULL, |
233 | 233 | OBJ_type VARCHAR(45)DEFAULT NULL, |
234 | 234 | PRIMARY KEY (LIN_ID)"; |
235 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB' ); |
|
235 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
236 | 236 | |
237 | 237 | $table_name = 'esp_message_template'; |
238 | 238 | $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | PRIMARY KEY (GRP_ID), |
260 | 260 | KEY EVT_ID (EVT_ID), |
261 | 261 | KEY MTP_user_id (MTP_user_id)"; |
262 | - $this->_table_is_new_in_this_version( $table_name, $sql, 'ENGINE=InnoDB'); |
|
262 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
263 | 263 | |
264 | 264 | |
265 | 265 | |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | |
368 | 368 | |
369 | 369 | |
370 | - $table_name='esp_question'; |
|
371 | - $sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
370 | + $table_name = 'esp_question'; |
|
371 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
372 | 372 | QST_display_text TEXT NOT NULL, |
373 | 373 | QST_admin_label VARCHAR(255) NOT NULL, |
374 | 374 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -380,12 +380,12 @@ discard block |
||
380 | 380 | QST_wp_user BIGINT UNSIGNED NULL, |
381 | 381 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
382 | 382 | PRIMARY KEY (QST_ID)'; |
383 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
383 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | 384 | |
385 | - EEH_Activation::drop_index( 'esp_question_group', 'QSG_identifier_UNIQUE' ); |
|
385 | + EEH_Activation::drop_index('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
386 | 386 | |
387 | 387 | $table_name = 'esp_question_group'; |
388 | - $sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
388 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
389 | 389 | QSG_name VARCHAR(255) NOT NULL, |
390 | 390 | QSG_identifier VARCHAR(100) NOT NULL, |
391 | 391 | QSG_desc TEXT NULL, |
@@ -396,27 +396,27 @@ discard block |
||
396 | 396 | QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
397 | 397 | PRIMARY KEY (QSG_ID), |
398 | 398 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
399 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
399 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
400 | 400 | |
401 | 401 | |
402 | 402 | |
403 | - $table_name='esp_question_group_question'; |
|
404 | - $sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
403 | + $table_name = 'esp_question_group_question'; |
|
404 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
405 | 405 | QSG_ID INT UNSIGNED NOT NULL, |
406 | 406 | QST_ID INT UNSIGNED NOT NULL, |
407 | 407 | PRIMARY KEY (QGQ_ID) "; |
408 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
408 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
409 | 409 | |
410 | 410 | |
411 | 411 | |
412 | - $table_name='esp_question_option'; |
|
413 | - $sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
412 | + $table_name = 'esp_question_option'; |
|
413 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
414 | 414 | QSO_value VARCHAR(255) NOT NULL, |
415 | 415 | QSO_desc TEXT NOT NULL, |
416 | 416 | QST_ID INT UNSIGNED NOT NULL, |
417 | 417 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
418 | 418 | PRIMARY KEY (QSO_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 | |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | |
450 | 450 | |
451 | 451 | |
452 | - $table_name='esp_checkin'; |
|
453 | - $sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
452 | + $table_name = 'esp_checkin'; |
|
453 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
454 | 454 | REG_ID INT(10) UNSIGNED NOT NULL, |
455 | 455 | DTT_ID INT(10) UNSIGNED NOT NULL, |
456 | 456 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -557,12 +557,12 @@ discard block |
||
557 | 557 | |
558 | 558 | global $wpdb; |
559 | 559 | $state_table = $wpdb->prefix."esp_state"; |
560 | - if ( EEH_Activation::table_exists( $state_table ) ) { |
|
560 | + if (EEH_Activation::table_exists($state_table)) { |
|
561 | 561 | |
562 | - $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table; |
|
562 | + $SQL = "SELECT COUNT('STA_ID') FROM ".$state_table; |
|
563 | 563 | $states = $wpdb->get_var($SQL); |
564 | - if ( ! $states ) { |
|
565 | - $SQL = "INSERT INTO " . $state_table . " |
|
564 | + if ( ! $states) { |
|
565 | + $SQL = "INSERT INTO ".$state_table." |
|
566 | 566 | (STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES |
567 | 567 | (1, 'US', 'AK', 'Alaska', 1), |
568 | 568 | (2, 'US', 'AL', 'Alabama', 1), |
@@ -649,12 +649,12 @@ discard block |
||
649 | 649 | |
650 | 650 | global $wpdb; |
651 | 651 | $country_table = $wpdb->prefix."esp_country"; |
652 | - if ( EEH_Activation::table_exists( $country_table ) ) { |
|
652 | + if (EEH_Activation::table_exists($country_table)) { |
|
653 | 653 | |
654 | - $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table; |
|
654 | + $SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table; |
|
655 | 655 | $countries = $wpdb->get_var($SQL); |
656 | - if ( ! $countries ) { |
|
657 | - $SQL = "INSERT INTO " . $country_table . " |
|
656 | + if ( ! $countries) { |
|
657 | + $SQL = "INSERT INTO ".$country_table." |
|
658 | 658 | (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 |
659 | 659 | ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
660 | 660 | ('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0), |
@@ -901,20 +901,20 @@ discard block |
||
901 | 901 | global $wpdb; |
902 | 902 | $price_type_table = $wpdb->prefix."esp_price_type"; |
903 | 903 | |
904 | - if ( EEH_Activation::table_exists( $price_type_table ) ) { |
|
904 | + if (EEH_Activation::table_exists($price_type_table)) { |
|
905 | 905 | |
906 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
907 | - $price_types_exist = $wpdb->get_var( $SQL ); |
|
906 | + $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table; |
|
907 | + $price_types_exist = $wpdb->get_var($SQL); |
|
908 | 908 | |
909 | - if ( ! $price_types_exist ) { |
|
909 | + if ( ! $price_types_exist) { |
|
910 | 910 | $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES |
911 | - (1, '" . __('Base Price', 'event_espresso') . "', 1, 0, 0, 0), |
|
912 | - (2, '" . __('Percent Discount', 'event_espresso') . "', 2, 1, 20, 0), |
|
913 | - (3, '" . __('Fixed Discount', 'event_espresso') . "', 2, 0, 30, 0), |
|
914 | - (4, '" . __('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, 0), |
|
915 | - (5, '" . __('Fixed Surcharge', 'event_espresso') . "', 3, 0, 50, 0);"; |
|
916 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL ); |
|
917 | - $wpdb->query( $SQL ); |
|
911 | + (1, '".__('Base Price', 'event_espresso')."', 1, 0, 0, 0), |
|
912 | + (2, '" . __('Percent Discount', 'event_espresso')."', 2, 1, 20, 0), |
|
913 | + (3, '" . __('Fixed Discount', 'event_espresso')."', 2, 0, 30, 0), |
|
914 | + (4, '" . __('Percent Surcharge', 'event_espresso')."', 3, 1, 40, 0), |
|
915 | + (5, '" . __('Fixed Surcharge', 'event_espresso')."', 3, 0, 50, 0);"; |
|
916 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL); |
|
917 | + $wpdb->query($SQL); |
|
918 | 918 | } |
919 | 919 | } |
920 | 920 | } |
@@ -934,16 +934,16 @@ discard block |
||
934 | 934 | global $wpdb; |
935 | 935 | $price_table = $wpdb->prefix."esp_price"; |
936 | 936 | |
937 | - if ( EEH_Activation::table_exists( $price_table ) ) { |
|
937 | + if (EEH_Activation::table_exists($price_table)) { |
|
938 | 938 | |
939 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' .$price_table; |
|
940 | - $prices_exist = $wpdb->get_var( $SQL ); |
|
939 | + $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table; |
|
940 | + $prices_exist = $wpdb->get_var($SQL); |
|
941 | 941 | |
942 | - if ( ! $prices_exist ) { |
|
942 | + if ( ! $prices_exist) { |
|
943 | 943 | $SQL = "INSERT INTO $price_table |
944 | 944 | (PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc, PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES |
945 | 945 | (1, 1, '0.00', 'Free Admission', '', 1, NULL, 0, 0, 0);"; |
946 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL ); |
|
946 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL); |
|
947 | 947 | $wpdb->query($SQL); |
948 | 948 | } |
949 | 949 | } |
@@ -960,34 +960,34 @@ discard block |
||
960 | 960 | |
961 | 961 | global $wpdb; |
962 | 962 | $ticket_table = $wpdb->prefix."esp_ticket"; |
963 | - if ( EEH_Activation::table_exists( $ticket_table ) ) { |
|
963 | + if (EEH_Activation::table_exists($ticket_table)) { |
|
964 | 964 | |
965 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
965 | + $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table; |
|
966 | 966 | $tickets_exist = $wpdb->get_var($SQL); |
967 | 967 | |
968 | - if ( ! $tickets_exist ) { |
|
968 | + if ( ! $tickets_exist) { |
|
969 | 969 | $SQL = "INSERT INTO $ticket_table |
970 | 970 | ( 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 |
971 | - ( 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);"; |
|
972 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL ); |
|
971 | + ( 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);"; |
|
972 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
973 | 973 | $wpdb->query($SQL); |
974 | 974 | } |
975 | 975 | } |
976 | 976 | $ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
977 | 977 | |
978 | - if ( EEH_Activation::table_exists( $ticket_price_table ) ) { |
|
978 | + if (EEH_Activation::table_exists($ticket_price_table)) { |
|
979 | 979 | |
980 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
980 | + $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table; |
|
981 | 981 | $ticket_prc_exist = $wpdb->get_var($SQL); |
982 | 982 | |
983 | - if ( ! $ticket_prc_exist ) { |
|
983 | + if ( ! $ticket_prc_exist) { |
|
984 | 984 | |
985 | 985 | $SQL = "INSERT INTO $ticket_price_table |
986 | 986 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
987 | 987 | ( 1, 1, 1 ) |
988 | 988 | "; |
989 | 989 | |
990 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL ); |
|
990 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
991 | 991 | $wpdb->query($SQL); |
992 | 992 | } |
993 | 993 | } |
@@ -1000,20 +1000,20 @@ discard block |
||
1000 | 1000 | * @param string $country_name |
1001 | 1001 | * @return array where keys are columns, values are column values |
1002 | 1002 | */ |
1003 | - public function get_or_create_country($country_name){ |
|
1004 | - if( ! $country_name ){ |
|
1003 | + public function get_or_create_country($country_name) { |
|
1004 | + if ( ! $country_name) { |
|
1005 | 1005 | throw new EE_Error(__("Could not get a country because country name is blank", "event_espresso")); |
1006 | 1006 | } |
1007 | 1007 | global $wpdb; |
1008 | 1008 | $country_table = $wpdb->prefix."esp_country"; |
1009 | - if(is_int($country_name)){ |
|
1009 | + if (is_int($country_name)) { |
|
1010 | 1010 | $country_name = $this->get_iso_from_3_1_country_id($country_name); |
1011 | 1011 | } |
1012 | 1012 | $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE |
1013 | 1013 | CNT_ISO LIKE %s OR |
1014 | 1014 | CNT_ISO3 LIKE %s OR |
1015 | - CNT_name LIKE %s LIMIT 1",$country_name,$country_name,$country_name),ARRAY_A); |
|
1016 | - if( ! $country ){ |
|
1015 | + CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A); |
|
1016 | + if ( ! $country) { |
|
1017 | 1017 | //insert a new one then |
1018 | 1018 | $cols_n_values = array( |
1019 | 1019 | 'CNT_ISO'=> $this->_find_available_country_iso(2), |
@@ -1033,26 +1033,26 @@ discard block |
||
1033 | 1033 | 'CNT_active'=>true |
1034 | 1034 | ); |
1035 | 1035 | $data_types = array( |
1036 | - '%s',//CNT_ISO |
|
1037 | - '%s',//CNT_ISO3 |
|
1038 | - '%d',//RGN_ID |
|
1039 | - '%s',//CNT_name |
|
1040 | - '%s',//CNT_cur_code |
|
1041 | - '%s',//CNT_cur_single |
|
1042 | - '%s',//CNT_cur_plural |
|
1043 | - '%s',//CNT_cur_sign |
|
1044 | - '%d',//CNT_cur_sign_b4 |
|
1045 | - '%d',//CNT_cur_dec_plc |
|
1046 | - '%s',//CNT_cur_dec_mrk |
|
1047 | - '%s',//CNT_cur_thsnds |
|
1048 | - '%s',//CNT_tel_code |
|
1049 | - '%d',//CNT_is_EU |
|
1050 | - '%d',//CNT_active |
|
1036 | + '%s', //CNT_ISO |
|
1037 | + '%s', //CNT_ISO3 |
|
1038 | + '%d', //RGN_ID |
|
1039 | + '%s', //CNT_name |
|
1040 | + '%s', //CNT_cur_code |
|
1041 | + '%s', //CNT_cur_single |
|
1042 | + '%s', //CNT_cur_plural |
|
1043 | + '%s', //CNT_cur_sign |
|
1044 | + '%d', //CNT_cur_sign_b4 |
|
1045 | + '%d', //CNT_cur_dec_plc |
|
1046 | + '%s', //CNT_cur_dec_mrk |
|
1047 | + '%s', //CNT_cur_thsnds |
|
1048 | + '%s', //CNT_tel_code |
|
1049 | + '%d', //CNT_is_EU |
|
1050 | + '%d', //CNT_active |
|
1051 | 1051 | ); |
1052 | 1052 | $success = $wpdb->insert($country_table, |
1053 | 1053 | $cols_n_values, |
1054 | 1054 | $data_types); |
1055 | - if( ! $success){ |
|
1055 | + if ( ! $success) { |
|
1056 | 1056 | 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)); |
1057 | 1057 | } |
1058 | 1058 | $country = $cols_n_values; |
@@ -1064,13 +1064,13 @@ discard block |
||
1064 | 1064 | * @global type $wpdb |
1065 | 1065 | * @return string |
1066 | 1066 | */ |
1067 | - private function _find_available_country_iso($num_letters = 2){ |
|
1067 | + private function _find_available_country_iso($num_letters = 2) { |
|
1068 | 1068 | global $wpdb; |
1069 | 1069 | $country_table = $wpdb->prefix."esp_country"; |
1070 | - do{ |
|
1070 | + do { |
|
1071 | 1071 | $current_iso = strtoupper(wp_generate_password($num_letters, false)); |
1072 | - $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s",$current_iso)); |
|
1073 | - }while(intval($country_with_that_iso)); |
|
1072 | + $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s", $current_iso)); |
|
1073 | + }while (intval($country_with_that_iso)); |
|
1074 | 1074 | return $current_iso; |
1075 | 1075 | } |
1076 | 1076 | |
@@ -1081,14 +1081,14 @@ discard block |
||
1081 | 1081 | * @param string $state_name |
1082 | 1082 | * @return array where keys are columns, values are column values |
1083 | 1083 | */ |
1084 | - public function get_or_create_state($state_name,$country_name = ''){ |
|
1085 | - if( ! $state_name ){ |
|
1084 | + public function get_or_create_state($state_name, $country_name = '') { |
|
1085 | + if ( ! $state_name) { |
|
1086 | 1086 | throw new EE_Error(__("Could not get-or-create state because no state name was provided", "event_espresso")); |
1087 | 1087 | } |
1088 | - try{ |
|
1088 | + try { |
|
1089 | 1089 | $country = $this->get_or_create_country($country_name); |
1090 | 1090 | $country_iso = $country['CNT_ISO']; |
1091 | - }catch(EE_Error $e){ |
|
1091 | + } catch (EE_Error $e) { |
|
1092 | 1092 | $country_iso = $this->get_default_country_iso(); |
1093 | 1093 | } |
1094 | 1094 | global $wpdb; |
@@ -1096,24 +1096,24 @@ discard block |
||
1096 | 1096 | $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE |
1097 | 1097 | (STA_abbrev LIKE %s OR |
1098 | 1098 | STA_name LIKE %s) AND |
1099 | - CNT_ISO LIKE %s LIMIT 1",$state_name,$state_name,$country_iso),ARRAY_A); |
|
1100 | - if ( ! $state){ |
|
1099 | + CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A); |
|
1100 | + if ( ! $state) { |
|
1101 | 1101 | //insert a new one then |
1102 | 1102 | $cols_n_values = array( |
1103 | 1103 | 'CNT_ISO'=>$country_iso, |
1104 | - 'STA_abbrev'=>substr($state_name,0,6), |
|
1104 | + 'STA_abbrev'=>substr($state_name, 0, 6), |
|
1105 | 1105 | 'STA_name'=>$state_name, |
1106 | 1106 | 'STA_active'=>true |
1107 | 1107 | ); |
1108 | 1108 | $data_types = array( |
1109 | - '%s',//CNT_ISO |
|
1110 | - '%s',//STA_abbrev |
|
1111 | - '%s',//STA_name |
|
1112 | - '%d',//STA_active |
|
1109 | + '%s', //CNT_ISO |
|
1110 | + '%s', //STA_abbrev |
|
1111 | + '%s', //STA_name |
|
1112 | + '%d', //STA_active |
|
1113 | 1113 | ); |
1114 | - $success = $wpdb->insert($state_table,$cols_n_values,$data_types); |
|
1115 | - if ( ! $success ){ |
|
1116 | - 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)); |
|
1114 | + $success = $wpdb->insert($state_table, $cols_n_values, $data_types); |
|
1115 | + if ( ! $success) { |
|
1116 | + 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)); |
|
1117 | 1117 | } |
1118 | 1118 | $state = $cols_n_values; |
1119 | 1119 | $state['STA_ID'] = $wpdb->insert_id; |
@@ -1126,21 +1126,21 @@ discard block |
||
1126 | 1126 | * @param type $timeString |
1127 | 1127 | * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes with leading zeros) |
1128 | 1128 | */ |
1129 | - public function convertTimeFromAMPM($timeString){ |
|
1129 | + public function convertTimeFromAMPM($timeString) { |
|
1130 | 1130 | $matches = array(); |
1131 | - preg_match("~(\\d*):(\\d*)~",$timeString,$matches); |
|
1132 | - if( ! $matches || count($matches)<3){ |
|
1131 | + preg_match("~(\\d*):(\\d*)~", $timeString, $matches); |
|
1132 | + if ( ! $matches || count($matches) < 3) { |
|
1133 | 1133 | $hour = '00'; |
1134 | 1134 | $minutes = '00'; |
1135 | - }else{ |
|
1135 | + } else { |
|
1136 | 1136 | $hour = intval($matches[1]); |
1137 | 1137 | $minutes = $matches[2]; |
1138 | 1138 | } |
1139 | - if(strpos($timeString, 'PM') || strpos($timeString, 'pm')){ |
|
1139 | + if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) { |
|
1140 | 1140 | $hour = intval($hour) + 12; |
1141 | 1141 | } |
1142 | - $hour = str_pad( "$hour", 2, '0',STR_PAD_LEFT); |
|
1143 | - $minutes = str_pad( "$minutes", 2, '0',STR_PAD_LEFT); |
|
1142 | + $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT); |
|
1143 | + $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT); |
|
1144 | 1144 | return "$hour:$minutes"; |
1145 | 1145 | } |
1146 | 1146 | |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | * @param int $country_id |
1150 | 1150 | * @return string the country's ISO3 code |
1151 | 1151 | */ |
1152 | - public function get_iso_from_3_1_country_id($country_id){ |
|
1152 | + public function get_iso_from_3_1_country_id($country_id) { |
|
1153 | 1153 | $old_countries = array( |
1154 | 1154 | array(64, 'United States', 'US', 'USA', 1), |
1155 | 1155 | array(15, 'Australia', 'AU', 'AUS', 1), |
@@ -1375,9 +1375,9 @@ discard block |
||
1375 | 1375 | array(226, 'Zimbabwe', 'ZW', 'ZWE', 1)); |
1376 | 1376 | |
1377 | 1377 | $country_iso = 'US'; |
1378 | - foreach($old_countries as $country_array){ |
|
1378 | + foreach ($old_countries as $country_array) { |
|
1379 | 1379 | //note: index 0 is the 3.1 country ID |
1380 | - if($country_array[0] == $country_id){ |
|
1380 | + if ($country_array[0] == $country_id) { |
|
1381 | 1381 | //note: index 2 is the ISO |
1382 | 1382 | $country_iso = $country_array[2]; |
1383 | 1383 | break; |
@@ -1390,8 +1390,8 @@ discard block |
||
1390 | 1390 | * Gets the ISO3 for the |
1391 | 1391 | * @return string |
1392 | 1392 | */ |
1393 | - public function get_default_country_iso(){ |
|
1394 | - $old_org_options= get_option('events_organization_settings'); |
|
1393 | + public function get_default_country_iso() { |
|
1394 | + $old_org_options = get_option('events_organization_settings'); |
|
1395 | 1395 | $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']); |
1396 | 1396 | return $iso; |
1397 | 1397 | } |
@@ -1403,13 +1403,13 @@ discard block |
||
1403 | 1403 | * the event's DEFAULT payment status, or the attendee's payment status) required pre-approval. |
1404 | 1404 | * @return string STS_ID for use in 4.1 |
1405 | 1405 | */ |
1406 | - public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false){ |
|
1406 | + public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false) { |
|
1407 | 1407 | |
1408 | 1408 | //EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455 |
1409 | - if($this_thing_required_pre_approval){ |
|
1409 | + if ($this_thing_required_pre_approval) { |
|
1410 | 1410 | return 'RNA'; |
1411 | - }else{ |
|
1412 | - $mapping = $default_reg_stati_conversions=array( |
|
1411 | + } else { |
|
1412 | + $mapping = $default_reg_stati_conversions = array( |
|
1413 | 1413 | 'Completed'=>'RAP', |
1414 | 1414 | ''=>'RPP', |
1415 | 1415 | 'Incomplete'=>'RPP', |
@@ -1439,22 +1439,22 @@ discard block |
||
1439 | 1439 | * @param EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added |
1440 | 1440 | * @return boolean whether or not we had to do the big job of creating an image attachment |
1441 | 1441 | */ |
1442 | - public function convert_image_url_to_attachment_and_attach_to_post($guid,$new_cpt_id, EE_Data_Migration_Script_Stage $migration_stage){ |
|
1442 | + public function convert_image_url_to_attachment_and_attach_to_post($guid, $new_cpt_id, EE_Data_Migration_Script_Stage $migration_stage) { |
|
1443 | 1443 | $created_attachment_post = false; |
1444 | 1444 | $guid = $this->_get_original_guid($guid); |
1445 | - if($guid){ |
|
1445 | + if ($guid) { |
|
1446 | 1446 | //check for an existing attachment post with this guid |
1447 | 1447 | $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid); |
1448 | - if( ! $attachment_post_id){ |
|
1448 | + if ( ! $attachment_post_id) { |
|
1449 | 1449 | //post thumbnail with that GUID doesn't exist, we should create one |
1450 | 1450 | $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage); |
1451 | 1451 | $created_attachment_post = true; |
1452 | 1452 | } |
1453 | 1453 | //double-check we actually have an attachment post |
1454 | - if( $attachment_post_id){ |
|
1455 | - update_post_meta($new_cpt_id,'_thumbnail_id',$attachment_post_id); |
|
1456 | - }else{ |
|
1457 | - $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)); |
|
1454 | + if ($attachment_post_id) { |
|
1455 | + update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id); |
|
1456 | + } else { |
|
1457 | + $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)); |
|
1458 | 1458 | } |
1459 | 1459 | } |
1460 | 1460 | return $created_attachment_post; |
@@ -1468,13 +1468,13 @@ discard block |
||
1468 | 1468 | * @param string $guid_in_old_event |
1469 | 1469 | * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was |
1470 | 1470 | */ |
1471 | - private function _get_original_guid($guid_in_old_event){ |
|
1472 | - $original_guid = preg_replace('~-\d*x\d*\.~','.',$guid_in_old_event,1); |
|
1471 | + private function _get_original_guid($guid_in_old_event) { |
|
1472 | + $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1); |
|
1473 | 1473 | //do a head request to verify the file exists |
1474 | 1474 | $head_response = wp_remote_head($original_guid); |
1475 | - if( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK'){ |
|
1475 | + if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') { |
|
1476 | 1476 | return $original_guid; |
1477 | - }else{ |
|
1477 | + } else { |
|
1478 | 1478 | return $guid_in_old_event; |
1479 | 1479 | } |
1480 | 1480 | } |
@@ -1486,32 +1486,32 @@ discard block |
||
1486 | 1486 | * @param EE_Data_Migration_Script_Stage $migration_stage |
1487 | 1487 | * @return int |
1488 | 1488 | */ |
1489 | - private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage){ |
|
1490 | - if ( ! $guid){ |
|
1489 | + private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage) { |
|
1490 | + if ( ! $guid) { |
|
1491 | 1491 | $migration_stage->add_error(sprintf(__("Cannot create image attachment for a blank GUID!", "event_espresso"))); |
1492 | 1492 | return 0; |
1493 | 1493 | } |
1494 | - $wp_filetype = wp_check_filetype(basename($guid), null ); |
|
1494 | + $wp_filetype = wp_check_filetype(basename($guid), null); |
|
1495 | 1495 | $wp_upload_dir = wp_upload_dir(); |
1496 | 1496 | //if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local |
1497 | - if(strpos($guid,$wp_upload_dir['url']) === FALSE){ |
|
1497 | + if (strpos($guid, $wp_upload_dir['url']) === FALSE) { |
|
1498 | 1498 | //image is located remotely. download it and place it in the uploads directory |
1499 | - if( ! is_readable($guid)){ |
|
1500 | - $migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"),$guid)); |
|
1499 | + if ( ! is_readable($guid)) { |
|
1500 | + $migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"), $guid)); |
|
1501 | 1501 | return 0; |
1502 | 1502 | } |
1503 | - $contents= file_get_contents($guid); |
|
1504 | - if($contents === FALSE){ |
|
1505 | - $migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"),$guid)); |
|
1503 | + $contents = file_get_contents($guid); |
|
1504 | + if ($contents === FALSE) { |
|
1505 | + $migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"), $guid)); |
|
1506 | 1506 | return false; |
1507 | 1507 | } |
1508 | - $local_filepath = $wp_upload_dir['path'].DS.basename($guid); |
|
1508 | + $local_filepath = $wp_upload_dir['path'].DS.basename($guid); |
|
1509 | 1509 | $savefile = fopen($local_filepath, 'w'); |
1510 | 1510 | fwrite($savefile, $contents); |
1511 | 1511 | fclose($savefile); |
1512 | - $guid = str_replace($wp_upload_dir['path'],$wp_upload_dir['url'],$local_filepath); |
|
1513 | - }else{ |
|
1514 | - $local_filepath = str_replace($wp_upload_dir['url'],$wp_upload_dir['path'],$guid); |
|
1512 | + $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath); |
|
1513 | + } else { |
|
1514 | + $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid); |
|
1515 | 1515 | } |
1516 | 1516 | |
1517 | 1517 | $attachment = array( |
@@ -1521,24 +1521,24 @@ discard block |
||
1521 | 1521 | 'post_content' => '', |
1522 | 1522 | 'post_status' => 'inherit' |
1523 | 1523 | ); |
1524 | - $attach_id = wp_insert_attachment( $attachment, $guid ); |
|
1525 | - if( ! $attach_id ){ |
|
1526 | - $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))); |
|
1524 | + $attach_id = wp_insert_attachment($attachment, $guid); |
|
1525 | + if ( ! $attach_id) { |
|
1526 | + $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))); |
|
1527 | 1527 | return $attach_id; |
1528 | 1528 | } |
1529 | 1529 | |
1530 | 1530 | // you must first include the image.php file |
1531 | 1531 | // for the function wp_generate_attachment_metadata() to work |
1532 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1532 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
1533 | 1533 | |
1534 | - $attach_data = wp_generate_attachment_metadata( $attach_id, $local_filepath ); |
|
1535 | - if( ! $attach_data){ |
|
1536 | - $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)); |
|
1534 | + $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath); |
|
1535 | + if ( ! $attach_data) { |
|
1536 | + $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)); |
|
1537 | 1537 | return $attach_id; |
1538 | 1538 | } |
1539 | - $metadata_save_result = wp_update_attachment_metadata( $attach_id, $attach_data ); |
|
1540 | - if( ! $metadata_save_result ){ |
|
1541 | - $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))); |
|
1539 | + $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data); |
|
1540 | + if ( ! $metadata_save_result) { |
|
1541 | + $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))); |
|
1542 | 1542 | } |
1543 | 1543 | return $attach_id; |
1544 | 1544 | } |
@@ -1550,9 +1550,9 @@ discard block |
||
1550 | 1550 | * @param string $guid |
1551 | 1551 | * @return int |
1552 | 1552 | */ |
1553 | - private function _get_image_attachment_id_by_GUID($guid){ |
|
1553 | + private function _get_image_attachment_id_by_GUID($guid) { |
|
1554 | 1554 | global $wpdb; |
1555 | - $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1",$guid)); |
|
1555 | + $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid)); |
|
1556 | 1556 | return $attachment_id; |
1557 | 1557 | } |
1558 | 1558 | /** |
@@ -1564,20 +1564,20 @@ discard block |
||
1564 | 1564 | * @param string $timezone |
1565 | 1565 | * @return string |
1566 | 1566 | */ |
1567 | - public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string,$timezone = null){ |
|
1567 | + public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string, $timezone = null) { |
|
1568 | 1568 | $original_tz = $timezone; |
1569 | - if( ! $timezone){ |
|
1569 | + if ( ! $timezone) { |
|
1570 | 1570 | $timezone = $this->_get_wp_timezone(); |
1571 | 1571 | } |
1572 | - if( ! $timezone){ |
|
1573 | - $stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"),$original_tz,$row_of_data)); |
|
1572 | + if ( ! $timezone) { |
|
1573 | + $stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"), $original_tz, $row_of_data)); |
|
1574 | 1574 | $timezone = 'UTC'; |
1575 | 1575 | } |
1576 | - try{ |
|
1577 | - $date_obj = new DateTime( $DATETIME_string, new DateTimeZone( $timezone ) ); |
|
1576 | + try { |
|
1577 | + $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone)); |
|
1578 | 1578 | $date_obj->setTimezone(new DateTimeZone('UTC')); |
1579 | - }catch(Exception $e){ |
|
1580 | - $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)); |
|
1579 | + } catch (Exception $e) { |
|
1580 | + $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)); |
|
1581 | 1581 | $date_obj = new DateTime(); |
1582 | 1582 | } |
1583 | 1583 | |
@@ -1588,14 +1588,14 @@ discard block |
||
1588 | 1588 | * Gets the DEFAULT timezone string from wordpress (even if they set a gmt offset) |
1589 | 1589 | * @return string |
1590 | 1590 | */ |
1591 | - private function _get_wp_timezone(){ |
|
1592 | - $timezone = empty( $timezone ) ? get_option('timezone_string') : $timezone; |
|
1591 | + private function _get_wp_timezone() { |
|
1592 | + $timezone = empty($timezone) ? get_option('timezone_string') : $timezone; |
|
1593 | 1593 | |
1594 | 1594 | //if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter |
1595 | - if ( empty( $timezone ) ) { |
|
1595 | + if (empty($timezone)) { |
|
1596 | 1596 | //let's get a the WordPress UTC offset |
1597 | 1597 | $offset = get_option('gmt_offset'); |
1598 | - $timezone = $this->timezone_convert_to_string_from_offset( $offset ); |
|
1598 | + $timezone = $this->timezone_convert_to_string_from_offset($offset); |
|
1599 | 1599 | } |
1600 | 1600 | return $timezone; |
1601 | 1601 | } |
@@ -1604,11 +1604,11 @@ discard block |
||
1604 | 1604 | * @param int $offset |
1605 | 1605 | * @return boolean |
1606 | 1606 | */ |
1607 | - private function timezone_convert_to_string_from_offset($offset){ |
|
1607 | + private function timezone_convert_to_string_from_offset($offset) { |
|
1608 | 1608 | //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 |
1609 | 1609 | $offset *= 3600; // convert hour offset to seconds |
1610 | 1610 | $abbrarray = timezone_abbreviations_list(); |
1611 | - foreach ($abbrarray as $abbr){ |
|
1611 | + foreach ($abbrarray as $abbr) { |
|
1612 | 1612 | foreach ($abbr as $city) |
1613 | 1613 | { |
1614 | 1614 | if ($city['offset'] == $offset) |
@@ -1622,32 +1622,32 @@ discard block |
||
1622 | 1622 | return FALSE; |
1623 | 1623 | } |
1624 | 1624 | |
1625 | - public function migration_page_hooks(){ |
|
1626 | - add_filter('FHEE__ee_migration_page__header',array($this,'_migrate_page_hook_simplify_version_strings'),10,3); |
|
1627 | - add_filter('FHEE__ee_migration_page__p_after_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1628 | - add_filter('FHEE__ee_migration_page__option_1_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,3); |
|
1629 | - add_filter('FHEE__ee_migration_page__option_1_button_text',array($this,'_migrate_page_hook_simplify_version_strings'),10,3); |
|
1630 | - add_action('AHEE__ee_migration_page__option_1_extra_details',array($this,'_migration_page_hook_option_1_extra_details'),10,3); |
|
1631 | - add_filter('FHEE__ee_migration_page__option_2_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,4); |
|
1632 | - add_filter('FHEE__ee_migration_page__option_2_button_text',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1633 | - add_filter('FHEE__ee_migration_page__option_2_details',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1634 | - add_action('AHEE__ee_migration_page__after_migration_options_table',array($this,'_migration_page_hook_after_migration_options_table')); |
|
1635 | - add_filter('FHEE__ee_migration_page__done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1636 | - add_filter('FHEE__ee_migration_page__p_after_done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1625 | + public function migration_page_hooks() { |
|
1626 | + add_filter('FHEE__ee_migration_page__header', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3); |
|
1627 | + add_filter('FHEE__ee_migration_page__p_after_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1628 | + add_filter('FHEE__ee_migration_page__option_1_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3); |
|
1629 | + add_filter('FHEE__ee_migration_page__option_1_button_text', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3); |
|
1630 | + add_action('AHEE__ee_migration_page__option_1_extra_details', array($this, '_migration_page_hook_option_1_extra_details'), 10, 3); |
|
1631 | + add_filter('FHEE__ee_migration_page__option_2_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 4); |
|
1632 | + add_filter('FHEE__ee_migration_page__option_2_button_text', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1633 | + add_filter('FHEE__ee_migration_page__option_2_details', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1634 | + add_action('AHEE__ee_migration_page__after_migration_options_table', array($this, '_migration_page_hook_after_migration_options_table')); |
|
1635 | + add_filter('FHEE__ee_migration_page__done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1636 | + add_filter('FHEE__ee_migration_page__p_after_done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1637 | 1637 | } |
1638 | 1638 | |
1639 | - public function _migrate_page_hook_simplify_version_strings($old_content,$current_db_state,$next_db_state,$ultimate_db_state = NULL){ |
|
1640 | - 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); |
|
1639 | + public function _migrate_page_hook_simplify_version_strings($old_content, $current_db_state, $next_db_state, $ultimate_db_state = NULL) { |
|
1640 | + 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); |
|
1641 | 1641 | } |
1642 | - public function _migration_page_hook_simplify_next_db_state($old_content,$next_db_state){ |
|
1643 | - return str_replace($next_db_state, __("EE4", 'event_espresso'),$old_content); |
|
1642 | + public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state) { |
|
1643 | + return str_replace($next_db_state, __("EE4", 'event_espresso'), $old_content); |
|
1644 | 1644 | } |
1645 | - public function _migration_page_hook_option_1_extra_details(){ |
|
1646 | - ?><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 |
|
1645 | + public function _migration_page_hook_option_1_extra_details() { |
|
1646 | + ?><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 |
|
1647 | 1647 | } |
1648 | - public function _migration_page_hook_after_migration_options_table(){ |
|
1648 | + public function _migration_page_hook_after_migration_options_table() { |
|
1649 | 1649 | ?><p class="ee-attention"> |
1650 | - <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"); ?> |
|
1650 | + <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"); ?> |
|
1651 | 1651 | </p><?php |
1652 | 1652 | } |
1653 | 1653 | } |
@@ -10,18 +10,18 @@ discard block |
||
10 | 10 | //(all other times it gets resurrected from a wordpress option) |
11 | 11 | $stages = glob(EE_CORE.'data_migration_scripts/4_3_0_stages/*'); |
12 | 12 | $class_to_filepath = array(); |
13 | -if ( ! empty( $stages ) ) { |
|
14 | - foreach($stages as $filepath){ |
|
13 | +if ( ! empty($stages)) { |
|
14 | + foreach ($stages as $filepath) { |
|
15 | 15 | $matches = array(); |
16 | - preg_match('~4_3_0_stages/(.*).dmsstage.php~',$filepath,$matches); |
|
16 | + preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | 17 | $class_to_filepath[$matches[1]] = $filepath; |
18 | 18 | } |
19 | 19 | } |
20 | 20 | //give addons a chance to autoload their stages too |
21 | -$class_to_filepath = apply_filters('FHEE__EE_DMS_4_3_0__autoloaded_stages',$class_to_filepath); |
|
21 | +$class_to_filepath = apply_filters('FHEE__EE_DMS_4_3_0__autoloaded_stages', $class_to_filepath); |
|
22 | 22 | EEH_Autoloader::register_autoloader($class_to_filepath); |
23 | 23 | |
24 | -class EE_DMS_Core_4_3_0 extends EE_Data_Migration_Script_Base{ |
|
24 | +class EE_DMS_Core_4_3_0 extends EE_Data_Migration_Script_Base { |
|
25 | 25 | |
26 | 26 | |
27 | 27 | |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | } |
38 | 38 | public function can_migrate_from_version($version_array) { |
39 | 39 | $version_string = $version_array['Core']; |
40 | - if($version_string <= '4.3.0' && $version_string >= '4.2.0' ){ |
|
40 | + if ($version_string <= '4.3.0' && $version_string >= '4.2.0') { |
|
41 | 41 | // echo "$version_string can be migrated fro"; |
42 | 42 | return true; |
43 | - }elseif( ! $version_string ){ |
|
43 | + }elseif ( ! $version_string) { |
|
44 | 44 | // echo "no version string provided: $version_string"; |
45 | 45 | //no version string provided... this must be pre 4.2 |
46 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
47 | - }else{ |
|
46 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
47 | + } else { |
|
48 | 48 | // echo "$version_string doesnt apply"; |
49 | 49 | return false; |
50 | 50 | } |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | } |
55 | 55 | public function schema_changes_before_migration() { |
56 | 56 | //relies on 4.1's EEH_Activation::create_table |
57 | - require_once( EE_HELPERS . 'EEH_Activation.helper.php' ); |
|
58 | - $table_name='esp_answer'; |
|
59 | - $sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
57 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
58 | + $table_name = 'esp_answer'; |
|
59 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
60 | 60 | REG_ID INT UNSIGNED NOT NULL, |
61 | 61 | QST_ID INT UNSIGNED NOT NULL, |
62 | 62 | ANS_value TEXT NOT NULL, |
63 | 63 | PRIMARY KEY (ANS_ID)"; |
64 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
64 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
65 | 65 | |
66 | 66 | $table_name = 'esp_attendee_meta'; |
67 | 67 | $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | CNT_is_EU TINYINT(1) DEFAULT '0', |
101 | 101 | CNT_active TINYINT(1) DEFAULT '0', |
102 | 102 | PRIMARY KEY (CNT_ISO)"; |
103 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
103 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
104 | 104 | |
105 | 105 | |
106 | 106 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | |
125 | 125 | |
126 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB' ); |
|
126 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
127 | 127 | $table_name = 'esp_event_meta'; |
128 | 128 | $sql = " |
129 | 129 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
@@ -140,41 +140,41 @@ discard block |
||
140 | 140 | EVT_external_URL VARCHAR(200) NULL, |
141 | 141 | EVT_donations TINYINT(1) NULL, |
142 | 142 | PRIMARY KEY (EVTM_ID)"; |
143 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
143 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
144 | 144 | |
145 | 145 | |
146 | 146 | |
147 | - $table_name='esp_event_question_group'; |
|
148 | - $sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
147 | + $table_name = 'esp_event_question_group'; |
|
148 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
149 | 149 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
150 | 150 | QSG_ID INT UNSIGNED NOT NULL, |
151 | 151 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
152 | 152 | PRIMARY KEY (EQG_ID)"; |
153 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
153 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
154 | 154 | |
155 | 155 | |
156 | 156 | |
157 | - $table_name='esp_event_venue'; |
|
158 | - $sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
157 | + $table_name = 'esp_event_venue'; |
|
158 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
159 | 159 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
160 | 160 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
161 | 161 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
162 | 162 | PRIMARY KEY (EVV_ID)"; |
163 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
163 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
164 | 164 | |
165 | 165 | |
166 | 166 | |
167 | - $table_name='esp_extra_meta'; |
|
168 | - $sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
167 | + $table_name = 'esp_extra_meta'; |
|
168 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
169 | 169 | OBJ_ID INT(11) DEFAULT NULL, |
170 | 170 | EXM_type VARCHAR(45) DEFAULT NULL, |
171 | 171 | EXM_key VARCHAR(45) DEFAULT NULL, |
172 | 172 | EXM_value TEXT, |
173 | 173 | PRIMARY KEY (EXM_ID)"; |
174 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
174 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
175 | 175 | |
176 | - $table_name='esp_line_item'; |
|
177 | - $sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
176 | + $table_name = 'esp_line_item'; |
|
177 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
178 | 178 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
179 | 179 | TXN_ID INT(11) DEFAULT NULL, |
180 | 180 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | OBJ_ID INT(11) DEFAULT NULL, |
191 | 191 | OBJ_type VARCHAR(45)DEFAULT NULL, |
192 | 192 | PRIMARY KEY (LIN_ID)"; |
193 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB' ); |
|
193 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
194 | 194 | |
195 | 195 | $table_name = 'esp_message_template'; |
196 | 196 | $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | KEY GRP_ID (GRP_ID)"; |
203 | 203 | $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
204 | 204 | |
205 | - EEH_Activation::drop_index( 'esp_message_template_group', 'EVT_ID' ); |
|
205 | + EEH_Activation::drop_index('esp_message_template_group', 'EVT_ID'); |
|
206 | 206 | |
207 | 207 | $table_name = 'esp_message_template_group'; |
208 | 208 | $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
218 | 218 | PRIMARY KEY (GRP_ID), |
219 | 219 | KEY MTP_user_id (MTP_user_id)"; |
220 | - $this->_table_should_exist_previously( $table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
221 | 221 | |
222 | 222 | $table_name = 'esp_event_message_template'; |
223 | 223 | $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | PRIMARY KEY (EMT_ID), |
227 | 227 | KEY EVT_ID (EVT_ID), |
228 | 228 | KEY GRP_ID (GRP_ID)"; |
229 | - $this->_table_is_new_in_this_version( $table_name, $sql, 'ENGINE=InnoDB'); |
|
229 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
230 | 230 | |
231 | 231 | |
232 | 232 | |
@@ -335,8 +335,8 @@ discard block |
||
335 | 335 | |
336 | 336 | |
337 | 337 | |
338 | - $table_name='esp_question'; |
|
339 | - $sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
338 | + $table_name = 'esp_question'; |
|
339 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
340 | 340 | QST_display_text TEXT NOT NULL, |
341 | 341 | QST_admin_label VARCHAR(255) NOT NULL, |
342 | 342 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -348,12 +348,12 @@ discard block |
||
348 | 348 | QST_wp_user BIGINT UNSIGNED NULL, |
349 | 349 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
350 | 350 | PRIMARY KEY (QST_ID)'; |
351 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
351 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
352 | 352 | |
353 | - EEH_Activation::drop_index( 'esp_question_group', 'QSG_identifier_UNIQUE' ); |
|
353 | + EEH_Activation::drop_index('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
354 | 354 | |
355 | 355 | $table_name = 'esp_question_group'; |
356 | - $sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
356 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
357 | 357 | QSG_name VARCHAR(255) NOT NULL, |
358 | 358 | QSG_identifier VARCHAR(100) NOT NULL, |
359 | 359 | QSG_desc TEXT NULL, |
@@ -364,29 +364,29 @@ discard block |
||
364 | 364 | QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
365 | 365 | PRIMARY KEY (QSG_ID), |
366 | 366 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
367 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
367 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
368 | 368 | |
369 | 369 | |
370 | 370 | |
371 | - $table_name='esp_question_group_question'; |
|
372 | - $sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
371 | + $table_name = 'esp_question_group_question'; |
|
372 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
373 | 373 | QSG_ID INT UNSIGNED NOT NULL, |
374 | 374 | QST_ID INT UNSIGNED NOT NULL, |
375 | 375 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
376 | 376 | PRIMARY KEY (QGQ_ID) "; |
377 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
377 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
378 | 378 | |
379 | 379 | |
380 | 380 | |
381 | - $table_name='esp_question_option'; |
|
382 | - $sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
381 | + $table_name = 'esp_question_option'; |
|
382 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
383 | 383 | QSO_value VARCHAR(255) NOT NULL, |
384 | 384 | QSO_desc TEXT NOT NULL, |
385 | 385 | QST_ID INT UNSIGNED NOT NULL, |
386 | 386 | QSO_order INT UNSIGNED NOT NULL DEFAULT 0, |
387 | 387 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
388 | 388 | PRIMARY KEY (QSO_ID)"; |
389 | - $this->_table_should_exist_previously($table_name,$sql, 'ENGINE=InnoDB'); |
|
389 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
390 | 390 | |
391 | 391 | |
392 | 392 | |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | |
420 | 420 | |
421 | 421 | |
422 | - $table_name='esp_checkin'; |
|
423 | - $sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
422 | + $table_name = 'esp_checkin'; |
|
423 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
424 | 424 | REG_ID INT(10) UNSIGNED NOT NULL, |
425 | 425 | DTT_ID INT(10) UNSIGNED NOT NULL, |
426 | 426 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
495 | 495 | |
496 | 496 | |
497 | - $script_with_defaults = EE_Registry::instance()->load_dms( 'Core_4_1_0' ); |
|
497 | + $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
498 | 498 | //setting up the DEFAULT stats and countries is also essential for the data migrations to run |
499 | 499 | //(because many need to convert old string states to foreign keys into the states table) |
500 | 500 | $script_with_defaults->insert_default_states(); |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | return true; |
517 | 517 | } |
518 | 518 | |
519 | - public function migration_page_hooks(){ |
|
519 | + public function migration_page_hooks() { |
|
520 | 520 | |
521 | 521 | } |
522 | 522 | |
@@ -532,34 +532,34 @@ discard block |
||
532 | 532 | |
533 | 533 | global $wpdb; |
534 | 534 | $ticket_table = $wpdb->prefix."esp_ticket"; |
535 | - if ( EEH_Activation::table_exists( $ticket_table ) ) { |
|
535 | + if (EEH_Activation::table_exists($ticket_table)) { |
|
536 | 536 | |
537 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
537 | + $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table; |
|
538 | 538 | $tickets_exist = $wpdb->get_var($SQL); |
539 | 539 | |
540 | - if ( ! $tickets_exist ) { |
|
540 | + if ( ! $tickets_exist) { |
|
541 | 541 | $SQL = "INSERT INTO $ticket_table |
542 | 542 | ( 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 |
543 | - ( 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);"; |
|
544 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL ); |
|
543 | + ( 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);"; |
|
544 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
545 | 545 | $wpdb->query($SQL); |
546 | 546 | } |
547 | 547 | } |
548 | 548 | $ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
549 | 549 | |
550 | - if ( EEH_Activation::table_exists( $ticket_price_table ) ) { |
|
550 | + if (EEH_Activation::table_exists($ticket_price_table)) { |
|
551 | 551 | |
552 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
552 | + $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table; |
|
553 | 553 | $ticket_prc_exist = $wpdb->get_var($SQL); |
554 | 554 | |
555 | - if ( ! $ticket_prc_exist ) { |
|
555 | + if ( ! $ticket_prc_exist) { |
|
556 | 556 | |
557 | 557 | $SQL = "INSERT INTO $ticket_price_table |
558 | 558 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
559 | 559 | ( 1, 1, 1 ) |
560 | 560 | "; |
561 | 561 | |
562 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL ); |
|
562 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
563 | 563 | $wpdb->query($SQL); |
564 | 564 | } |
565 | 565 | } |
@@ -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 | * EEH_Activation Helper |
4 | 4 | * |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * @param $table_name |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
51 | + public static function ensure_table_name_has_prefix($table_name) { |
|
52 | 52 | global $wpdb; |
53 | - return strpos( $table_name, $wpdb->base_prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name; |
|
53 | + return strpos($table_name, $wpdb->base_prefix) === 0 ? $table_name : $wpdb->prefix.$table_name; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @return boolean success, whether the database and folders are setup properly |
79 | 79 | * @throws \EE_Error |
80 | 80 | */ |
81 | - public static function initialize_db_and_folders(){ |
|
81 | + public static function initialize_db_and_folders() { |
|
82 | 82 | $good_filesystem = EEH_Activation::create_upload_directories(); |
83 | 83 | $good_db = EEH_Activation::create_database_tables(); |
84 | 84 | return $good_filesystem && $good_db; |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @throws \EE_Error |
96 | 96 | */ |
97 | - public static function initialize_db_content(){ |
|
97 | + public static function initialize_db_content() { |
|
98 | 98 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
99 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
99 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | EEH_Activation::remove_cron_tasks(); |
114 | 114 | EEH_Activation::create_cron_tasks(); |
115 | 115 | // remove all TXN locks since that is being done via extra meta now |
116 | - delete_option( 'ee_locked_transactions' ); |
|
116 | + delete_option('ee_locked_transactions'); |
|
117 | 117 | //also, check for CAF default db content |
118 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
118 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
119 | 119 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
120 | 120 | //which users really won't care about on initial activation |
121 | 121 | EE_Error::overwrite_success(); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @return array |
136 | 136 | * @throws \EE_Error |
137 | 137 | */ |
138 | - public static function get_cron_tasks( $which_to_include ) { |
|
138 | + public static function get_cron_tasks($which_to_include) { |
|
139 | 139 | $cron_tasks = apply_filters( |
140 | 140 | 'FHEE__EEH_Activation__get_cron_tasks', |
141 | 141 | array( |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
145 | 145 | ) |
146 | 146 | ); |
147 | - if ( $which_to_include === 'old' ) { |
|
147 | + if ($which_to_include === 'old') { |
|
148 | 148 | $cron_tasks = array_filter( |
149 | 149 | $cron_tasks, |
150 | - function ( $value ) { |
|
150 | + function($value) { |
|
151 | 151 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
152 | 152 | } |
153 | 153 | ); |
154 | - } elseif ( $which_to_include === 'current' ) { |
|
155 | - $cron_tasks = array_filter( $cron_tasks ); |
|
156 | - } elseif ( WP_DEBUG && $which_to_include !== 'all' ) { |
|
154 | + } elseif ($which_to_include === 'current') { |
|
155 | + $cron_tasks = array_filter($cron_tasks); |
|
156 | + } elseif (WP_DEBUG && $which_to_include !== 'all') { |
|
157 | 157 | throw new EE_Error( |
158 | 158 | sprintf( |
159 | 159 | __( |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public static function create_cron_tasks() { |
178 | 178 | |
179 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
180 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
181 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
179 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
180 | + if ( ! wp_next_scheduled($hook_name)) { |
|
181 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
193 | 193 | * @throws \EE_Error |
194 | 194 | */ |
195 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
195 | + public static function remove_cron_tasks($remove_all = true) { |
|
196 | 196 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
197 | 197 | $crons = _get_cron_array(); |
198 | - $crons = is_array( $crons ) ? $crons : array(); |
|
198 | + $crons = is_array($crons) ? $crons : array(); |
|
199 | 199 | /* reminder of what $crons look like: |
200 | 200 | * Top-level keys are timestamps, and their values are arrays. |
201 | 201 | * The 2nd level arrays have keys with each of the cron task hook names to run at that time |
@@ -213,23 +213,23 @@ discard block |
||
213 | 213 | * ... |
214 | 214 | * ... |
215 | 215 | */ |
216 | - $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ); |
|
217 | - foreach ( $crons as $timestamp => $hooks_to_fire_at_time ) { |
|
218 | - if ( is_array( $hooks_to_fire_at_time ) ) { |
|
219 | - foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) { |
|
220 | - if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
221 | - && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
216 | + $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
217 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
218 | + if (is_array($hooks_to_fire_at_time)) { |
|
219 | + foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
220 | + if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
221 | + && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
222 | 222 | ) { |
223 | - unset( $crons[ $timestamp ][ $hook_name ] ); |
|
223 | + unset($crons[$timestamp][$hook_name]); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | //also take care of any empty cron timestamps. |
227 | - if ( empty( $hooks_to_fire_at_time ) ) { |
|
228 | - unset( $crons[ $timestamp ] ); |
|
227 | + if (empty($hooks_to_fire_at_time)) { |
|
228 | + unset($crons[$timestamp]); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
232 | - _set_cron_array( $crons ); |
|
232 | + _set_cron_array($crons); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public static function CPT_initialization() { |
246 | 246 | // register Custom Post Types |
247 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
247 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
248 | 248 | flush_rewrite_rules(); |
249 | 249 | } |
250 | 250 | |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | * @return void |
263 | 263 | */ |
264 | 264 | public static function reset_and_update_config() { |
265 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
266 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
265 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
266 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
267 | 267 | //EE_Config::reset(); |
268 | 268 | } |
269 | 269 | |
@@ -276,28 +276,28 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public static function load_calendar_config() { |
278 | 278 | // grab array of all plugin folders and loop thru it |
279 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
280 | - if ( empty( $plugins ) ) { |
|
279 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
280 | + if (empty($plugins)) { |
|
281 | 281 | return; |
282 | 282 | } |
283 | - foreach ( $plugins as $plugin_path ) { |
|
283 | + foreach ($plugins as $plugin_path) { |
|
284 | 284 | // grab plugin folder name from path |
285 | - $plugin = basename( $plugin_path ); |
|
285 | + $plugin = basename($plugin_path); |
|
286 | 286 | // drill down to Espresso plugins |
287 | 287 | // then to calendar related plugins |
288 | 288 | if ( |
289 | - strpos( $plugin, 'espresso' ) !== FALSE |
|
290 | - || strpos( $plugin, 'Espresso' ) !== FALSE |
|
291 | - || strpos( $plugin, 'ee4' ) !== FALSE |
|
292 | - || strpos( $plugin, 'EE4' ) !== FALSE |
|
293 | - || strpos( $plugin, 'calendar' ) !== false |
|
289 | + strpos($plugin, 'espresso') !== FALSE |
|
290 | + || strpos($plugin, 'Espresso') !== FALSE |
|
291 | + || strpos($plugin, 'ee4') !== FALSE |
|
292 | + || strpos($plugin, 'EE4') !== FALSE |
|
293 | + || strpos($plugin, 'calendar') !== false |
|
294 | 294 | ) { |
295 | 295 | // this is what we are looking for |
296 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
296 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
297 | 297 | // does it exist in this folder ? |
298 | - if ( is_readable( $calendar_config )) { |
|
298 | + if (is_readable($calendar_config)) { |
|
299 | 299 | // YEAH! let's load it |
300 | - require_once( $calendar_config ); |
|
300 | + require_once($calendar_config); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | } |
@@ -313,21 +313,21 @@ discard block |
||
313 | 313 | * @param \EE_Config $EE_Config |
314 | 314 | * @return \stdClass |
315 | 315 | */ |
316 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
317 | - $convert_from_array = array( 'addons' ); |
|
316 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
317 | + $convert_from_array = array('addons'); |
|
318 | 318 | // in case old settings were saved as an array |
319 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
319 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
320 | 320 | // convert existing settings to an object |
321 | 321 | $config_array = $settings; |
322 | 322 | $settings = new stdClass(); |
323 | - foreach ( $config_array as $key => $value ){ |
|
324 | - if ( $key === 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
325 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
323 | + foreach ($config_array as $key => $value) { |
|
324 | + if ($key === 'calendar' && class_exists('EE_Calendar_Config')) { |
|
325 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
326 | 326 | } else { |
327 | 327 | $settings->{$key} = $value; |
328 | 328 | } |
329 | 329 | } |
330 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
330 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
331 | 331 | } |
332 | 332 | return $settings; |
333 | 333 | } |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public static function deactivate_event_espresso() { |
345 | 345 | // check permissions |
346 | - if ( current_user_can( 'activate_plugins' )) { |
|
347 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
346 | + if (current_user_can('activate_plugins')) { |
|
347 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
@@ -366,25 +366,25 @@ discard block |
||
366 | 366 | $critical_pages = array( |
367 | 367 | array( |
368 | 368 | 'id' =>'reg_page_id', |
369 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
369 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
370 | 370 | 'post' => NULL, |
371 | 371 | 'code' => 'ESPRESSO_CHECKOUT' |
372 | 372 | ), |
373 | 373 | array( |
374 | 374 | 'id' => 'txn_page_id', |
375 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
375 | + 'name' => __('Transactions', 'event_espresso'), |
|
376 | 376 | 'post' => NULL, |
377 | 377 | 'code' => 'ESPRESSO_TXN_PAGE' |
378 | 378 | ), |
379 | 379 | array( |
380 | 380 | 'id' => 'thank_you_page_id', |
381 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
381 | + 'name' => __('Thank You', 'event_espresso'), |
|
382 | 382 | 'post' => NULL, |
383 | 383 | 'code' => 'ESPRESSO_THANK_YOU' |
384 | 384 | ), |
385 | 385 | array( |
386 | 386 | 'id' => 'cancel_page_id', |
387 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
387 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
388 | 388 | 'post' => NULL, |
389 | 389 | 'code' => 'ESPRESSO_CANCELLED' |
390 | 390 | ), |
@@ -392,62 +392,62 @@ discard block |
||
392 | 392 | |
393 | 393 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
394 | 394 | |
395 | - foreach ( $critical_pages as $critical_page ) { |
|
395 | + foreach ($critical_pages as $critical_page) { |
|
396 | 396 | // is critical page ID set in config ? |
397 | - if ( $EE_Core_Config->{$critical_page[ 'id' ]} !== FALSE ) { |
|
397 | + if ($EE_Core_Config->{$critical_page['id']} !== FALSE) { |
|
398 | 398 | // attempt to find post by ID |
399 | - $critical_page['post'] = get_post( $EE_Core_Config->{$critical_page[ 'id' ]} ); |
|
399 | + $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']} ); |
|
400 | 400 | } |
401 | 401 | // no dice? |
402 | - if ( $critical_page['post'] === null ) { |
|
402 | + if ($critical_page['post'] === null) { |
|
403 | 403 | // attempt to find post by title |
404 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
404 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
405 | 405 | // still nothing? |
406 | - if ( $critical_page['post'] === null ) { |
|
407 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
406 | + if ($critical_page['post'] === null) { |
|
407 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
408 | 408 | // REALLY? Still nothing ??!?!? |
409 | - if ( $critical_page['post'] === null ) { |
|
410 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
411 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
409 | + if ($critical_page['post'] === null) { |
|
410 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
411 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
412 | 412 | break; |
413 | 413 | } |
414 | 414 | } |
415 | 415 | } |
416 | 416 | // track post_shortcodes |
417 | - if ( $critical_page['post'] ) { |
|
418 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
417 | + if ($critical_page['post']) { |
|
418 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
419 | 419 | } |
420 | 420 | // check that Post ID matches critical page ID in config |
421 | 421 | if ( |
422 | - isset( $critical_page['post']->ID ) |
|
423 | - && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page[ 'id' ]} |
|
422 | + isset($critical_page['post']->ID) |
|
423 | + && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']} |
|
424 | 424 | ) { |
425 | 425 | //update Config with post ID |
426 | - $EE_Core_Config->{$critical_page[ 'id' ]} = $critical_page['post']->ID; |
|
427 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
428 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
429 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
426 | + $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
427 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
428 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
429 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
433 | 433 | $critical_page_problem = |
434 | - ! isset( $critical_page['post']->post_status ) |
|
434 | + ! isset($critical_page['post']->post_status) |
|
435 | 435 | || $critical_page['post']->post_status !== 'publish' |
436 | - || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE |
|
436 | + || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE |
|
437 | 437 | ? TRUE |
438 | 438 | : $critical_page_problem; |
439 | 439 | |
440 | 440 | } |
441 | 441 | |
442 | - if ( $critical_page_problem ) { |
|
442 | + if ($critical_page_problem) { |
|
443 | 443 | $msg = sprintf( |
444 | - __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ), |
|
445 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
444 | + __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), |
|
445 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
446 | 446 | ); |
447 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
447 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
448 | 448 | } |
449 | - if ( EE_Error::has_notices() ) { |
|
450 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
449 | + if (EE_Error::has_notices()) { |
|
450 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
@@ -459,13 +459,13 @@ discard block |
||
459 | 459 | * parameter to the shortcode |
460 | 460 | * @return WP_Post or NULl |
461 | 461 | */ |
462 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
462 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
463 | 463 | global $wpdb; |
464 | 464 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
465 | 465 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
466 | - if($post_id){ |
|
466 | + if ($post_id) { |
|
467 | 467 | return get_post($post_id); |
468 | - }else{ |
|
468 | + } else { |
|
469 | 469 | return NULL; |
470 | 470 | } |
471 | 471 | |
@@ -482,32 +482,32 @@ discard block |
||
482 | 482 | * @param array $critical_page |
483 | 483 | * @return array |
484 | 484 | */ |
485 | - public static function create_critical_page( $critical_page ) { |
|
485 | + public static function create_critical_page($critical_page) { |
|
486 | 486 | |
487 | 487 | $post_args = array( |
488 | 488 | 'post_title' => $critical_page['name'], |
489 | 489 | 'post_status' => 'publish', |
490 | 490 | 'post_type' => 'page', |
491 | 491 | 'comment_status' => 'closed', |
492 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
492 | + 'post_content' => '['.$critical_page['code'].']' |
|
493 | 493 | ); |
494 | 494 | |
495 | - $post_id = wp_insert_post( $post_args ); |
|
496 | - if ( ! $post_id ) { |
|
495 | + $post_id = wp_insert_post($post_args); |
|
496 | + if ( ! $post_id) { |
|
497 | 497 | $msg = sprintf( |
498 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
498 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
499 | 499 | $critical_page['name'] |
500 | 500 | ); |
501 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
501 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
502 | 502 | return $critical_page; |
503 | 503 | } |
504 | 504 | // get newly created post's details |
505 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
505 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
506 | 506 | $msg = sprintf( |
507 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
507 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
508 | 508 | $critical_page['name'] |
509 | 509 | ); |
510 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
510 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | return $critical_page; |
@@ -526,35 +526,35 @@ discard block |
||
526 | 526 | * @param array $critical_page |
527 | 527 | * @return void |
528 | 528 | */ |
529 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
529 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
530 | 530 | // check the goods |
531 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
531 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
532 | 532 | $msg = sprintf( |
533 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
533 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
534 | 534 | $critical_page['name'] |
535 | 535 | ); |
536 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
536 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
537 | 537 | return; |
538 | 538 | } |
539 | 539 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
540 | 540 | // map shortcode to post |
541 | - $EE_Core_Config->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
541 | + $EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
542 | 542 | // and make sure it's NOT added to the WP "Posts Page" |
543 | 543 | // name of the WP Posts Page |
544 | 544 | $posts_page = EE_Config::get_page_for_posts(); |
545 | - if ( isset( $EE_Core_Config->post_shortcodes[ $posts_page ] )) { |
|
546 | - unset( $EE_Core_Config->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
545 | + if (isset($EE_Core_Config->post_shortcodes[$posts_page])) { |
|
546 | + unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]); |
|
547 | 547 | } |
548 | - if ( $posts_page !== 'posts' && isset( $EE_Core_Config->post_shortcodes['posts'] )) { |
|
549 | - unset( $EE_Core_Config->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
548 | + if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) { |
|
549 | + unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]); |
|
550 | 550 | } |
551 | 551 | // update post_shortcode CFG |
552 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
552 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
553 | 553 | $msg = sprintf( |
554 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
554 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
555 | 555 | $critical_page['name'] |
556 | 556 | ); |
557 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
557 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
@@ -572,24 +572,24 @@ discard block |
||
572 | 572 | public static function get_default_creator_id() { |
573 | 573 | global $wpdb; |
574 | 574 | |
575 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
575 | + if ( ! empty(self::$_default_creator_id)) { |
|
576 | 576 | return self::$_default_creator_id; |
577 | 577 | }/**/ |
578 | 578 | |
579 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
579 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
580 | 580 | |
581 | 581 | //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
582 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
583 | - if ( $pre_filtered_id !== false ) { |
|
582 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
583 | + if ($pre_filtered_id !== false) { |
|
584 | 584 | return (int) $pre_filtered_id; |
585 | 585 | } |
586 | 586 | |
587 | - $capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' ); |
|
588 | - $query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' ); |
|
589 | - $user_id = $wpdb->get_var( $query ); |
|
590 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
591 | - if ( $user_id && (int)$user_id ) { |
|
592 | - self::$_default_creator_id = (int)$user_id; |
|
587 | + $capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities'); |
|
588 | + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%'); |
|
589 | + $user_id = $wpdb->get_var($query); |
|
590 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
591 | + if ($user_id && (int) $user_id) { |
|
592 | + self::$_default_creator_id = (int) $user_id; |
|
593 | 593 | return self::$_default_creator_id; |
594 | 594 | } else { |
595 | 595 | return NULL; |
@@ -616,29 +616,29 @@ discard block |
||
616 | 616 | * @return void |
617 | 617 | * @throws EE_Error if there are database errors |
618 | 618 | */ |
619 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
620 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
619 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
620 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
621 | 621 | return; |
622 | 622 | } |
623 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
624 | - if ( ! function_exists( 'dbDelta' )) { |
|
625 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
623 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
624 | + if ( ! function_exists('dbDelta')) { |
|
625 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
626 | 626 | } |
627 | 627 | /** @var WPDB $wpdb */ |
628 | 628 | global $wpdb; |
629 | - $wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
629 | + $wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
630 | 630 | // do we need to first delete an existing version of this table ? |
631 | - if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){ |
|
631 | + if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) { |
|
632 | 632 | // ok, delete the table... but ONLY if it's empty |
633 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
633 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
634 | 634 | // table is NOT empty, are you SURE you want to delete this table ??? |
635 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
636 | - EEH_Activation::delete_unused_db_table( $wp_table_name ); |
|
637 | - } else if ( ! $deleted_safely ) { |
|
635 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
636 | + EEH_Activation::delete_unused_db_table($wp_table_name); |
|
637 | + } else if ( ! $deleted_safely) { |
|
638 | 638 | // so we should be more cautious rather than just dropping tables so easily |
639 | 639 | EE_Error::add_persistent_admin_notice( |
640 | - 'bad_table_' . $wp_table_name . '_detected', |
|
641 | - sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ), |
|
640 | + 'bad_table_'.$wp_table_name.'_detected', |
|
641 | + sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'), |
|
642 | 642 | $wp_table_name, |
643 | 643 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
644 | 644 | '<b>wp-config.php</b>', |
@@ -647,25 +647,25 @@ discard block |
||
647 | 647 | } |
648 | 648 | } |
649 | 649 | // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
650 | - if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) { |
|
650 | + if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) { |
|
651 | 651 | $SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
652 | 652 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
653 | 653 | //happened. And then we can choose to tell the end user |
654 | - $old_show_errors_policy = $wpdb->show_errors( TRUE ); |
|
655 | - $old_error_suppression_policy = $wpdb->suppress_errors( FALSE ); |
|
654 | + $old_show_errors_policy = $wpdb->show_errors(TRUE); |
|
655 | + $old_error_suppression_policy = $wpdb->suppress_errors(FALSE); |
|
656 | 656 | ob_start(); |
657 | - dbDelta( $SQL ); |
|
657 | + dbDelta($SQL); |
|
658 | 658 | $output = ob_get_contents(); |
659 | 659 | ob_end_clean(); |
660 | - $wpdb->show_errors( $old_show_errors_policy ); |
|
661 | - $wpdb->suppress_errors( $old_error_suppression_policy ); |
|
662 | - if( ! empty( $output ) ){ |
|
663 | - throw new EE_Error( $output ); |
|
660 | + $wpdb->show_errors($old_show_errors_policy); |
|
661 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
662 | + if ( ! empty($output)) { |
|
663 | + throw new EE_Error($output); |
|
664 | 664 | } |
665 | 665 | } else { |
666 | 666 | throw new EE_Error( |
667 | 667 | sprintf( |
668 | - __( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ), |
|
668 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'), |
|
669 | 669 | '<br />', |
670 | 670 | $sql |
671 | 671 | ) |
@@ -688,15 +688,15 @@ discard block |
||
688 | 688 | * 'VARCHAR(10)' |
689 | 689 | * @return bool|int |
690 | 690 | */ |
691 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
692 | - if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
|
691 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
692 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) { |
|
693 | 693 | return FALSE; |
694 | 694 | } |
695 | 695 | global $wpdb; |
696 | - $full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
696 | + $full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
697 | 697 | $fields = self::get_fields_on_table($table_name); |
698 | - if (!in_array($column_name, $fields)){ |
|
699 | - $alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
698 | + if ( ! in_array($column_name, $fields)) { |
|
699 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
700 | 700 | //echo "alter query:$alter_query"; |
701 | 701 | return $wpdb->query($alter_query); |
702 | 702 | } |
@@ -715,14 +715,14 @@ discard block |
||
715 | 715 | * @param string $table_name, without prefixed $wpdb->prefix |
716 | 716 | * @return array of database column names |
717 | 717 | */ |
718 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
718 | + public static function get_fields_on_table($table_name = NULL) { |
|
719 | 719 | global $wpdb; |
720 | - $table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
721 | - if ( ! empty( $table_name )) { |
|
720 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
721 | + if ( ! empty($table_name)) { |
|
722 | 722 | $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
723 | 723 | if ($columns !== FALSE) { |
724 | 724 | $field_array = array(); |
725 | - foreach($columns as $column ){ |
|
725 | + foreach ($columns as $column) { |
|
726 | 726 | $field_array[] = $column->Field; |
727 | 727 | } |
728 | 728 | return $field_array; |
@@ -741,12 +741,12 @@ discard block |
||
741 | 741 | * @param string $table_name |
742 | 742 | * @return bool |
743 | 743 | */ |
744 | - public static function db_table_is_empty( $table_name ) { |
|
744 | + public static function db_table_is_empty($table_name) { |
|
745 | 745 | global $wpdb; |
746 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
747 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
748 | - $count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" ); |
|
749 | - return absint( $count ) === 0 ? true : false; |
|
746 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
747 | + if (EEH_Activation::table_exists($table_name)) { |
|
748 | + $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
|
749 | + return absint($count) === 0 ? true : false; |
|
750 | 750 | } |
751 | 751 | return false; |
752 | 752 | } |
@@ -761,9 +761,9 @@ discard block |
||
761 | 761 | * @param string $table_name |
762 | 762 | * @return bool | int |
763 | 763 | */ |
764 | - public static function delete_db_table_if_empty( $table_name ) { |
|
765 | - if ( EEH_Activation::db_table_is_empty( $table_name ) ) { |
|
766 | - return EEH_Activation::delete_unused_db_table( $table_name ); |
|
764 | + public static function delete_db_table_if_empty($table_name) { |
|
765 | + if (EEH_Activation::db_table_is_empty($table_name)) { |
|
766 | + return EEH_Activation::delete_unused_db_table($table_name); |
|
767 | 767 | } |
768 | 768 | return false; |
769 | 769 | } |
@@ -778,11 +778,11 @@ discard block |
||
778 | 778 | * @param string $table_name |
779 | 779 | * @return bool | int |
780 | 780 | */ |
781 | - public static function delete_unused_db_table( $table_name ) { |
|
781 | + public static function delete_unused_db_table($table_name) { |
|
782 | 782 | global $wpdb; |
783 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
784 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
785 | - return $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); |
|
783 | + if (EEH_Activation::table_exists($table_name)) { |
|
784 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
785 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
786 | 786 | } |
787 | 787 | return false; |
788 | 788 | } |
@@ -798,18 +798,18 @@ discard block |
||
798 | 798 | * @param string $index_name |
799 | 799 | * @return bool | int |
800 | 800 | */ |
801 | - public static function drop_index( $table_name, $index_name ) { |
|
802 | - if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
|
801 | + public static function drop_index($table_name, $index_name) { |
|
802 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) { |
|
803 | 803 | return FALSE; |
804 | 804 | } |
805 | 805 | global $wpdb; |
806 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
806 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
807 | 807 | $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'"; |
808 | 808 | if ( |
809 | - EEH_Activation::table_exists( $table_name ) |
|
810 | - && $wpdb->get_var( $index_exists_query ) === $table_name //using get_var with the $index_exists_query returns the table's name |
|
809 | + EEH_Activation::table_exists($table_name) |
|
810 | + && $wpdb->get_var($index_exists_query) === $table_name //using get_var with the $index_exists_query returns the table's name |
|
811 | 811 | ) { |
812 | - return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" ); |
|
812 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name"); |
|
813 | 813 | } |
814 | 814 | return TRUE; |
815 | 815 | } |
@@ -825,27 +825,27 @@ discard block |
||
825 | 825 | * @return boolean success (whether database is setup properly or not) |
826 | 826 | */ |
827 | 827 | public static function create_database_tables() { |
828 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
828 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
829 | 829 | //find the migration script that sets the database to be compatible with the code |
830 | 830 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
831 | - if( $dms_name ){ |
|
832 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
833 | - $current_data_migration_script->set_migrating( false ); |
|
831 | + if ($dms_name) { |
|
832 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
833 | + $current_data_migration_script->set_migrating(false); |
|
834 | 834 | $current_data_migration_script->schema_changes_before_migration(); |
835 | 835 | $current_data_migration_script->schema_changes_after_migration(); |
836 | - if( $current_data_migration_script->get_errors() ){ |
|
837 | - if( WP_DEBUG ){ |
|
838 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
839 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
836 | + if ($current_data_migration_script->get_errors()) { |
|
837 | + if (WP_DEBUG) { |
|
838 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
839 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
840 | 840 | } |
841 | - }else{ |
|
842 | - EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
|
841 | + } else { |
|
842 | + EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso')); |
|
843 | 843 | } |
844 | 844 | return false; |
845 | 845 | } |
846 | 846 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
847 | - }else{ |
|
848 | - EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
847 | + } else { |
|
848 | + EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
849 | 849 | return false; |
850 | 850 | } |
851 | 851 | return true; |
@@ -865,27 +865,27 @@ discard block |
||
865 | 865 | public static function initialize_system_questions() { |
866 | 866 | // QUESTION GROUPS |
867 | 867 | global $wpdb; |
868 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' ); |
|
868 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group'); |
|
869 | 869 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
870 | 870 | // what we have |
871 | - $question_groups = $wpdb->get_col( $SQL ); |
|
871 | + $question_groups = $wpdb->get_col($SQL); |
|
872 | 872 | // check the response |
873 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
873 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
874 | 874 | // what we should have |
875 | - $QSG_systems = array( 1, 2 ); |
|
875 | + $QSG_systems = array(1, 2); |
|
876 | 876 | // loop thru what we should have and compare to what we have |
877 | - foreach ( $QSG_systems as $QSG_system ) { |
|
877 | + foreach ($QSG_systems as $QSG_system) { |
|
878 | 878 | // reset values array |
879 | 879 | $QSG_values = array(); |
880 | 880 | // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
881 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
881 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
882 | 882 | // add it |
883 | - switch ( $QSG_system ) { |
|
883 | + switch ($QSG_system) { |
|
884 | 884 | |
885 | 885 | case 1: |
886 | 886 | $QSG_values = array( |
887 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
888 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
887 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
888 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
889 | 889 | 'QSG_desc' => '', |
890 | 890 | 'QSG_order' => 1, |
891 | 891 | 'QSG_show_group_name' => 1, |
@@ -897,8 +897,8 @@ discard block |
||
897 | 897 | |
898 | 898 | case 2: |
899 | 899 | $QSG_values = array( |
900 | - 'QSG_name' => __( 'Address Information','event_espresso' ), |
|
901 | - 'QSG_identifier' => 'address-information-' . time(), |
|
900 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
901 | + 'QSG_identifier' => 'address-information-'.time(), |
|
902 | 902 | 'QSG_desc' => '', |
903 | 903 | 'QSG_order' => 2, |
904 | 904 | 'QSG_show_group_name' => 1, |
@@ -910,14 +910,14 @@ discard block |
||
910 | 910 | |
911 | 911 | } |
912 | 912 | // make sure we have some values before inserting them |
913 | - if ( ! empty( $QSG_values )) { |
|
913 | + if ( ! empty($QSG_values)) { |
|
914 | 914 | // insert system question |
915 | 915 | $wpdb->insert( |
916 | 916 | $table_name, |
917 | 917 | $QSG_values, |
918 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
918 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
919 | 919 | ); |
920 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
920 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
921 | 921 | } |
922 | 922 | } |
923 | 923 | } |
@@ -926,10 +926,10 @@ discard block |
||
926 | 926 | |
927 | 927 | // QUESTIONS |
928 | 928 | global $wpdb; |
929 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' ); |
|
929 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question'); |
|
930 | 930 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
931 | 931 | // what we have |
932 | - $questions = $wpdb->get_col( $SQL ); |
|
932 | + $questions = $wpdb->get_col($SQL); |
|
933 | 933 | // what we should have |
934 | 934 | $QST_systems = array( |
935 | 935 | 'fname', |
@@ -946,25 +946,25 @@ discard block |
||
946 | 946 | $order_for_group_1 = 1; |
947 | 947 | $order_for_group_2 = 1; |
948 | 948 | // loop thru what we should have and compare to what we have |
949 | - foreach ( $QST_systems as $QST_system ) { |
|
949 | + foreach ($QST_systems as $QST_system) { |
|
950 | 950 | // reset values array |
951 | 951 | $QST_values = array(); |
952 | 952 | // if we don't have what we should have |
953 | - if ( ! in_array( $QST_system, $questions )) { |
|
953 | + if ( ! in_array($QST_system, $questions)) { |
|
954 | 954 | // add it |
955 | - switch ( $QST_system ) { |
|
955 | + switch ($QST_system) { |
|
956 | 956 | |
957 | 957 | case 'fname': |
958 | 958 | $QST_values = array( |
959 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
960 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
959 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
960 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
961 | 961 | 'QST_system' => 'fname', |
962 | 962 | 'QST_type' => 'TEXT', |
963 | 963 | 'QST_required' => 1, |
964 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
964 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
965 | 965 | 'QST_order' => 1, |
966 | 966 | 'QST_admin_only' => 0, |
967 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
967 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
968 | 968 | 'QST_wp_user' => self::get_default_creator_id(), |
969 | 969 | 'QST_deleted' => 0 |
970 | 970 | ); |
@@ -972,15 +972,15 @@ discard block |
||
972 | 972 | |
973 | 973 | case 'lname': |
974 | 974 | $QST_values = array( |
975 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
976 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
975 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
976 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
977 | 977 | 'QST_system' => 'lname', |
978 | 978 | 'QST_type' => 'TEXT', |
979 | 979 | 'QST_required' => 1, |
980 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
980 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
981 | 981 | 'QST_order' => 2, |
982 | 982 | 'QST_admin_only' => 0, |
983 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
983 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
984 | 984 | 'QST_wp_user' => self::get_default_creator_id(), |
985 | 985 | 'QST_deleted' => 0 |
986 | 986 | ); |
@@ -988,15 +988,15 @@ discard block |
||
988 | 988 | |
989 | 989 | case 'email': |
990 | 990 | $QST_values = array( |
991 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
992 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
991 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
992 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
993 | 993 | 'QST_system' => 'email', |
994 | 994 | 'QST_type' => 'EMAIL', |
995 | 995 | 'QST_required' => 1, |
996 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
996 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
997 | 997 | 'QST_order' => 3, |
998 | 998 | 'QST_admin_only' => 0, |
999 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
999 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1000 | 1000 | 'QST_wp_user' => self::get_default_creator_id(), |
1001 | 1001 | 'QST_deleted' => 0 |
1002 | 1002 | ); |
@@ -1004,15 +1004,15 @@ discard block |
||
1004 | 1004 | |
1005 | 1005 | case 'address': |
1006 | 1006 | $QST_values = array( |
1007 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
1008 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
1007 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
1008 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
1009 | 1009 | 'QST_system' => 'address', |
1010 | 1010 | 'QST_type' => 'TEXT', |
1011 | 1011 | 'QST_required' => 0, |
1012 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1012 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1013 | 1013 | 'QST_order' => 4, |
1014 | 1014 | 'QST_admin_only' => 0, |
1015 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1015 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1016 | 1016 | 'QST_wp_user' => self::get_default_creator_id(), |
1017 | 1017 | 'QST_deleted' => 0 |
1018 | 1018 | ); |
@@ -1020,15 +1020,15 @@ discard block |
||
1020 | 1020 | |
1021 | 1021 | case 'address2': |
1022 | 1022 | $QST_values = array( |
1023 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
1024 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
1023 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
1024 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
1025 | 1025 | 'QST_system' => 'address2', |
1026 | 1026 | 'QST_type' => 'TEXT', |
1027 | 1027 | 'QST_required' => 0, |
1028 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1028 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1029 | 1029 | 'QST_order' => 5, |
1030 | 1030 | 'QST_admin_only' => 0, |
1031 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1031 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1032 | 1032 | 'QST_wp_user' => self::get_default_creator_id(), |
1033 | 1033 | 'QST_deleted' => 0 |
1034 | 1034 | ); |
@@ -1036,15 +1036,15 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | case 'city': |
1038 | 1038 | $QST_values = array( |
1039 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
1040 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
1039 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1040 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1041 | 1041 | 'QST_system' => 'city', |
1042 | 1042 | 'QST_type' => 'TEXT', |
1043 | 1043 | 'QST_required' => 0, |
1044 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1044 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1045 | 1045 | 'QST_order' => 6, |
1046 | 1046 | 'QST_admin_only' => 0, |
1047 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1047 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1048 | 1048 | 'QST_wp_user' => self::get_default_creator_id(), |
1049 | 1049 | 'QST_deleted' => 0 |
1050 | 1050 | ); |
@@ -1052,12 +1052,12 @@ discard block |
||
1052 | 1052 | |
1053 | 1053 | case 'state': |
1054 | 1054 | $QST_values = array( |
1055 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
1056 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
1055 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1056 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1057 | 1057 | 'QST_system' => 'state', |
1058 | 1058 | 'QST_type' => 'STATE', |
1059 | 1059 | 'QST_required' => 0, |
1060 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1060 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1061 | 1061 | 'QST_order' => 7, |
1062 | 1062 | 'QST_admin_only' => 0, |
1063 | 1063 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1067,12 +1067,12 @@ discard block |
||
1067 | 1067 | |
1068 | 1068 | case 'country' : |
1069 | 1069 | $QST_values = array( |
1070 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
1071 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
1070 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1071 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1072 | 1072 | 'QST_system' => 'country', |
1073 | 1073 | 'QST_type' => 'COUNTRY', |
1074 | 1074 | 'QST_required' => 0, |
1075 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1075 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1076 | 1076 | 'QST_order' => 8, |
1077 | 1077 | 'QST_admin_only' => 0, |
1078 | 1078 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1082,15 +1082,15 @@ discard block |
||
1082 | 1082 | |
1083 | 1083 | case 'zip': |
1084 | 1084 | $QST_values = array( |
1085 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
1086 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
1085 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1086 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1087 | 1087 | 'QST_system' => 'zip', |
1088 | 1088 | 'QST_type' => 'TEXT', |
1089 | 1089 | 'QST_required' => 0, |
1090 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1090 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1091 | 1091 | 'QST_order' => 9, |
1092 | 1092 | 'QST_admin_only' => 0, |
1093 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1093 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1094 | 1094 | 'QST_wp_user' => self::get_default_creator_id(), |
1095 | 1095 | 'QST_deleted' => 0 |
1096 | 1096 | ); |
@@ -1098,49 +1098,49 @@ discard block |
||
1098 | 1098 | |
1099 | 1099 | case 'phone': |
1100 | 1100 | $QST_values = array( |
1101 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
1102 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
1101 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1102 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1103 | 1103 | 'QST_system' => 'phone', |
1104 | 1104 | 'QST_type' => 'TEXT', |
1105 | 1105 | 'QST_required' => 0, |
1106 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1106 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1107 | 1107 | 'QST_order' => 10, |
1108 | 1108 | 'QST_admin_only' => 0, |
1109 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1109 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1110 | 1110 | 'QST_wp_user' => self::get_default_creator_id(), |
1111 | 1111 | 'QST_deleted' => 0 |
1112 | 1112 | ); |
1113 | 1113 | break; |
1114 | 1114 | |
1115 | 1115 | } |
1116 | - if ( ! empty( $QST_values )) { |
|
1116 | + if ( ! empty($QST_values)) { |
|
1117 | 1117 | // insert system question |
1118 | 1118 | $wpdb->insert( |
1119 | 1119 | $table_name, |
1120 | 1120 | $QST_values, |
1121 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
1121 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1122 | 1122 | ); |
1123 | 1123 | $QST_ID = $wpdb->insert_id; |
1124 | 1124 | |
1125 | 1125 | // QUESTION GROUP QUESTIONS |
1126 | - if( in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) { |
|
1126 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1127 | 1127 | $system_question_we_want = EEM_Question_Group::system_personal; |
1128 | 1128 | } else { |
1129 | 1129 | $system_question_we_want = EEM_Question_Group::system_address; |
1130 | 1130 | } |
1131 | - if( isset( $QSG_IDs[ $system_question_we_want ] ) ) { |
|
1132 | - $QSG_ID = $QSG_IDs[ $system_question_we_want ]; |
|
1131 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1132 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1133 | 1133 | } else { |
1134 | - $id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) ); |
|
1135 | - if( is_array( $id_col ) ) { |
|
1136 | - $QSG_ID = reset( $id_col ); |
|
1134 | + $id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1135 | + if (is_array($id_col)) { |
|
1136 | + $QSG_ID = reset($id_col); |
|
1137 | 1137 | } else { |
1138 | 1138 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1139 | 1139 | EE_Log::instance()->log( |
1140 | 1140 | __FILE__, |
1141 | 1141 | __FUNCTION__, |
1142 | 1142 | sprintf( |
1143 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1143 | + __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1144 | 1144 | $QST_ID ), |
1145 | 1145 | 'error' ); |
1146 | 1146 | continue; |
@@ -1149,12 +1149,12 @@ discard block |
||
1149 | 1149 | |
1150 | 1150 | // add system questions to groups |
1151 | 1151 | $wpdb->insert( |
1152 | - EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ), |
|
1153 | - array( 'QSG_ID' => $QSG_ID, |
|
1152 | + EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'), |
|
1153 | + array('QSG_ID' => $QSG_ID, |
|
1154 | 1154 | 'QST_ID' => $QST_ID, |
1155 | - 'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++ |
|
1155 | + 'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++ |
|
1156 | 1156 | ), |
1157 | - array( '%d', '%d', '%d' ) |
|
1157 | + array('%d', '%d', '%d') |
|
1158 | 1158 | ); |
1159 | 1159 | } |
1160 | 1160 | } |
@@ -1170,11 +1170,11 @@ discard block |
||
1170 | 1170 | * |
1171 | 1171 | * @throws \EE_Error |
1172 | 1172 | */ |
1173 | - public static function insert_default_payment_methods(){ |
|
1174 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
1175 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
1176 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
1177 | - }else{ |
|
1173 | + public static function insert_default_payment_methods() { |
|
1174 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1175 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1176 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1177 | + } else { |
|
1178 | 1178 | EEM_Payment_Method::instance()->verify_button_urls(); |
1179 | 1179 | } |
1180 | 1180 | } |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | |
1191 | 1191 | global $wpdb; |
1192 | 1192 | |
1193 | - if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) { |
|
1193 | + if (EEH_Activation::table_exists(EEM_Status::instance()->table())) { |
|
1194 | 1194 | |
1195 | 1195 | $table_name = EEM_Status::instance()->table(); |
1196 | 1196 | |
@@ -1265,33 +1265,33 @@ discard block |
||
1265 | 1265 | $folders = array( |
1266 | 1266 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1267 | 1267 | EVENT_ESPRESSO_GATEWAY_DIR, |
1268 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1269 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1270 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/' |
|
1268 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
1269 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
1270 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/' |
|
1271 | 1271 | ); |
1272 | - foreach ( $folders as $folder ) { |
|
1272 | + foreach ($folders as $folder) { |
|
1273 | 1273 | try { |
1274 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
1275 | - @ chmod( $folder, 0755 ); |
|
1276 | - } catch( EE_Error $e ){ |
|
1274 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1275 | + @ chmod($folder, 0755); |
|
1276 | + } catch (EE_Error $e) { |
|
1277 | 1277 | EE_Error::add_error( |
1278 | 1278 | sprintf( |
1279 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
1279 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1280 | 1280 | $folder, |
1281 | - '<br />' . $e->getMessage() |
|
1281 | + '<br />'.$e->getMessage() |
|
1282 | 1282 | ), |
1283 | 1283 | __FILE__, __FUNCTION__, __LINE__ |
1284 | 1284 | ); |
1285 | 1285 | //indicate we'll need to fix this later |
1286 | - update_option( EEH_Activation::upload_directories_incomplete_option_name, true ); |
|
1286 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1287 | 1287 | return FALSE; |
1288 | 1288 | } |
1289 | 1289 | } |
1290 | 1290 | //just add the .htaccess file to the logs directory to begin with. Even if logging |
1291 | 1291 | //is disabled, there might be activation errors recorded in there |
1292 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' ); |
|
1292 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/'); |
|
1293 | 1293 | //remember EE's folders are all good |
1294 | - delete_option( EEH_Activation::upload_directories_incomplete_option_name ); |
|
1294 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1295 | 1295 | return TRUE; |
1296 | 1296 | } |
1297 | 1297 | |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | * @return boolean |
1305 | 1305 | */ |
1306 | 1306 | public static function upload_directories_incomplete() { |
1307 | - return get_option( EEH_Activation::upload_directories_incomplete_option_name, false ); |
|
1307 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1308 | 1308 | } |
1309 | 1309 | |
1310 | 1310 | |
@@ -1321,7 +1321,7 @@ discard block |
||
1321 | 1321 | */ |
1322 | 1322 | public static function generate_default_message_templates() { |
1323 | 1323 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1324 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1324 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1325 | 1325 | /* |
1326 | 1326 | * This first method is taking care of ensuring any default messengers |
1327 | 1327 | * that should be made active and have templates generated are done. |
@@ -1357,28 +1357,28 @@ discard block |
||
1357 | 1357 | $active_messengers = $message_resource_manager->active_messengers(); |
1358 | 1358 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1359 | 1359 | $templates_created = false; |
1360 | - foreach ( $active_messengers as $active_messenger ) { |
|
1360 | + foreach ($active_messengers as $active_messenger) { |
|
1361 | 1361 | $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
1362 | 1362 | $default_message_type_names_to_activate = array(); |
1363 | 1363 | // looping through each default message type reported by the messenger |
1364 | 1364 | // and setup the actual message types to activate. |
1365 | - foreach ( $default_message_type_names_for_messenger as $default_message_type_name_for_messenger ) { |
|
1365 | + foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1366 | 1366 | // if already active or has already been activated before we skip |
1367 | 1367 | // (otherwise we might reactivate something user's intentionally deactivated.) |
1368 | 1368 | // we also skip if the message type is not installed. |
1369 | 1369 | if ( |
1370 | 1370 | ( |
1371 | - isset( $has_activated[ $active_messenger->name ] ) |
|
1371 | + isset($has_activated[$active_messenger->name]) |
|
1372 | 1372 | && in_array( |
1373 | 1373 | $default_message_type_name_for_messenger, |
1374 | - $has_activated[ $active_messenger->name ] |
|
1374 | + $has_activated[$active_messenger->name] |
|
1375 | 1375 | ) |
1376 | 1376 | ) |
1377 | 1377 | || $message_resource_manager->is_message_type_active_for_messenger( |
1378 | 1378 | $active_messenger->name, |
1379 | 1379 | $default_message_type_name_for_messenger |
1380 | 1380 | ) |
1381 | - || ! isset( $installed_message_types[ $default_message_type_name_for_messenger ] ) |
|
1381 | + || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1382 | 1382 | ) { |
1383 | 1383 | continue; |
1384 | 1384 | } |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | false |
1392 | 1392 | ); |
1393 | 1393 | //activate the templates for these message types |
1394 | - if ( ! empty( $default_message_type_names_to_activate ) ) { |
|
1394 | + if ( ! empty($default_message_type_names_to_activate)) { |
|
1395 | 1395 | $templates_created = EEH_MSG_Template::generate_new_templates( |
1396 | 1396 | $active_messenger->name, |
1397 | 1397 | $default_message_type_names_for_messenger, |
@@ -1418,15 +1418,15 @@ discard block |
||
1418 | 1418 | EE_message_Resource_Manager $message_resource_manager |
1419 | 1419 | ) { |
1420 | 1420 | /** @type EE_messenger[] $messengers_to_generate */ |
1421 | - $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation( $message_resource_manager ); |
|
1421 | + $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1422 | 1422 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1423 | 1423 | $templates_generated = false; |
1424 | - foreach ( $messengers_to_generate as $messenger_to_generate ) { |
|
1424 | + foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1425 | 1425 | $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
1426 | 1426 | //verify the default message types match an installed message type. |
1427 | - foreach ( $default_message_type_names_for_messenger as $key => $name ) { |
|
1428 | - if ( ! isset( $installed_message_types[ $name ] ) ) { |
|
1429 | - unset( $default_message_type_names_for_messenger[ $key ] ); |
|
1427 | + foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1428 | + if ( ! isset($installed_message_types[$name])) { |
|
1429 | + unset($default_message_type_names_for_messenger[$key]); |
|
1430 | 1430 | } |
1431 | 1431 | } |
1432 | 1432 | // in previous iterations, the active_messengers option in the db |
@@ -1440,7 +1440,7 @@ discard block |
||
1440 | 1440 | false |
1441 | 1441 | ); |
1442 | 1442 | //create any templates needing created (or will reactivate templates already generated as necessary). |
1443 | - if ( ! empty( $default_message_type_names_for_messenger ) ) { |
|
1443 | + if ( ! empty($default_message_type_names_for_messenger)) { |
|
1444 | 1444 | $templates_generated = EEH_MSG_Template::generate_new_templates( |
1445 | 1445 | $messenger_to_generate->name, |
1446 | 1446 | $default_message_type_names_for_messenger, |
@@ -1471,18 +1471,18 @@ discard block |
||
1471 | 1471 | $installed_messengers = $message_resource_manager->installed_messengers(); |
1472 | 1472 | $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
1473 | 1473 | $messengers_to_generate = array(); |
1474 | - foreach ( $installed_messengers as $installed_messenger ) { |
|
1474 | + foreach ($installed_messengers as $installed_messenger) { |
|
1475 | 1475 | //if installed messenger is a messenger that should be activated on install |
1476 | 1476 | //and is not already active |
1477 | 1477 | //and has never been activated |
1478 | 1478 | if ( |
1479 | 1479 | ! $installed_messenger->activate_on_install |
1480 | - || isset( $active_messengers[ $installed_messenger->name ] ) |
|
1481 | - || isset( $has_activated[ $installed_messenger->name ] ) |
|
1480 | + || isset($active_messengers[$installed_messenger->name]) |
|
1481 | + || isset($has_activated[$installed_messenger->name]) |
|
1482 | 1482 | ) { |
1483 | 1483 | continue; |
1484 | 1484 | } |
1485 | - $messengers_to_generate[ $installed_messenger->name ] = $installed_messenger; |
|
1485 | + $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
1486 | 1486 | } |
1487 | 1487 | return $messengers_to_generate; |
1488 | 1488 | } |
@@ -1507,9 +1507,9 @@ discard block |
||
1507 | 1507 | */ |
1508 | 1508 | public static function validate_messages_system() { |
1509 | 1509 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1510 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1510 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1511 | 1511 | $message_resource_manager->validate_active_message_types_are_installed(); |
1512 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
1512 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1513 | 1513 | } |
1514 | 1514 | |
1515 | 1515 | |
@@ -1522,12 +1522,12 @@ discard block |
||
1522 | 1522 | * @static |
1523 | 1523 | * @return void |
1524 | 1524 | */ |
1525 | - public static function create_no_ticket_prices_array(){ |
|
1525 | + public static function create_no_ticket_prices_array() { |
|
1526 | 1526 | // this creates an array for tracking events that have no active ticket prices created |
1527 | 1527 | // this allows us to warn admins of the situation so that it can be corrected |
1528 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
1529 | - if ( ! $espresso_no_ticket_prices ) { |
|
1530 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
1528 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
1529 | + if ( ! $espresso_no_ticket_prices) { |
|
1530 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
1531 | 1531 | } |
1532 | 1532 | } |
1533 | 1533 | |
@@ -1552,24 +1552,24 @@ discard block |
||
1552 | 1552 | * @global wpdb $wpdb |
1553 | 1553 | * @throws \EE_Error |
1554 | 1554 | */ |
1555 | - public static function delete_all_espresso_cpt_data(){ |
|
1555 | + public static function delete_all_espresso_cpt_data() { |
|
1556 | 1556 | global $wpdb; |
1557 | 1557 | //get all the CPT post_types |
1558 | 1558 | $ee_post_types = array(); |
1559 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
1560 | - if ( method_exists( $model_name, 'instance' )) { |
|
1561 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1562 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
1563 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
1559 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1560 | + if (method_exists($model_name, 'instance')) { |
|
1561 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1562 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1563 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1564 | 1564 | } |
1565 | 1565 | } |
1566 | 1566 | } |
1567 | 1567 | //get all our CPTs |
1568 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
1568 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1569 | 1569 | $cpt_ids = $wpdb->get_col($query); |
1570 | 1570 | //delete each post meta and term relations too |
1571 | - foreach($cpt_ids as $post_id){ |
|
1572 | - wp_delete_post($post_id,true); |
|
1571 | + foreach ($cpt_ids as $post_id) { |
|
1572 | + wp_delete_post($post_id, true); |
|
1573 | 1573 | } |
1574 | 1574 | } |
1575 | 1575 | |
@@ -1583,18 +1583,18 @@ discard block |
||
1583 | 1583 | * @param bool $remove_all |
1584 | 1584 | * @return void |
1585 | 1585 | */ |
1586 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
1586 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
1587 | 1587 | global $wpdb; |
1588 | 1588 | $undeleted_tables = array(); |
1589 | 1589 | |
1590 | 1590 | // load registry |
1591 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
1592 | - if ( method_exists( $model_name, 'instance' )) { |
|
1593 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1594 | - if ( $model_obj instanceof EEM_Base ) { |
|
1595 | - foreach ( $model_obj->get_tables() as $table ) { |
|
1596 | - if ( strpos( $table->get_table_name(), 'esp_' )) { |
|
1597 | - switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) { |
|
1591 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1592 | + if (method_exists($model_name, 'instance')) { |
|
1593 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1594 | + if ($model_obj instanceof EEM_Base) { |
|
1595 | + foreach ($model_obj->get_tables() as $table) { |
|
1596 | + if (strpos($table->get_table_name(), 'esp_')) { |
|
1597 | + switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) { |
|
1598 | 1598 | case false : |
1599 | 1599 | $undeleted_tables[] = $table->get_table_name(); |
1600 | 1600 | break; |
@@ -1619,8 +1619,8 @@ discard block |
||
1619 | 1619 | 'esp_promotion_rule', |
1620 | 1620 | 'esp_rule' |
1621 | 1621 | ); |
1622 | - foreach( $tables_without_models as $table ){ |
|
1623 | - EEH_Activation::delete_db_table_if_empty( $table ); |
|
1622 | + foreach ($tables_without_models as $table) { |
|
1623 | + EEH_Activation::delete_db_table_if_empty($table); |
|
1624 | 1624 | } |
1625 | 1625 | |
1626 | 1626 | |
@@ -1658,58 +1658,58 @@ discard block |
||
1658 | 1658 | 'ee_job_parameters_' => false, |
1659 | 1659 | 'ee_upload_directories_incomplete' => true, |
1660 | 1660 | ); |
1661 | - if( is_main_site() ) { |
|
1662 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
1661 | + if (is_main_site()) { |
|
1662 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1663 | 1663 | } |
1664 | 1664 | |
1665 | 1665 | $undeleted_options = array(); |
1666 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
1666 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1667 | 1667 | |
1668 | - if( $no_wildcard ){ |
|
1669 | - if( ! delete_option( $option_name ) ){ |
|
1668 | + if ($no_wildcard) { |
|
1669 | + if ( ! delete_option($option_name)) { |
|
1670 | 1670 | $undeleted_options[] = $option_name; |
1671 | 1671 | } |
1672 | - }else{ |
|
1673 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
1674 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
1675 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
1672 | + } else { |
|
1673 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1674 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1675 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1676 | 1676 | $undeleted_options[] = $option_name_from_wildcard; |
1677 | 1677 | } |
1678 | 1678 | } |
1679 | 1679 | } |
1680 | 1680 | } |
1681 | 1681 | //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
1682 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1682 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1683 | 1683 | |
1684 | - if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
|
1684 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1685 | 1685 | $db_update_sans_ee4 = array(); |
1686 | - foreach($espresso_db_update as $version => $times_activated){ |
|
1687 | - if( (string)$version[0] === '3'){//if its NON EE4 |
|
1686 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1687 | + if ((string) $version[0] === '3') {//if its NON EE4 |
|
1688 | 1688 | $db_update_sans_ee4[$version] = $times_activated; |
1689 | 1689 | } |
1690 | 1690 | } |
1691 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
1691 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1692 | 1692 | } |
1693 | 1693 | |
1694 | 1694 | $errors = ''; |
1695 | - if ( ! empty( $undeleted_tables )) { |
|
1695 | + if ( ! empty($undeleted_tables)) { |
|
1696 | 1696 | $errors .= sprintf( |
1697 | - __( 'The following tables could not be deleted: %s%s', 'event_espresso' ), |
|
1697 | + __('The following tables could not be deleted: %s%s', 'event_espresso'), |
|
1698 | 1698 | '<br/>', |
1699 | - implode( ',<br/>', $undeleted_tables ) |
|
1699 | + implode(',<br/>', $undeleted_tables) |
|
1700 | 1700 | ); |
1701 | 1701 | } |
1702 | - if ( ! empty( $undeleted_options )) { |
|
1703 | - $errors .= ! empty( $undeleted_tables ) ? '<br/>' : ''; |
|
1702 | + if ( ! empty($undeleted_options)) { |
|
1703 | + $errors .= ! empty($undeleted_tables) ? '<br/>' : ''; |
|
1704 | 1704 | $errors .= sprintf( |
1705 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
1705 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1706 | 1706 | '<br/>', |
1707 | - implode( ',<br/>', $undeleted_options ) |
|
1707 | + implode(',<br/>', $undeleted_options) |
|
1708 | 1708 | ); |
1709 | 1709 | |
1710 | 1710 | } |
1711 | - if ( ! empty( $errors ) ) { |
|
1712 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
1711 | + if ( ! empty($errors)) { |
|
1712 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1713 | 1713 | } |
1714 | 1714 | } |
1715 | 1715 | |
@@ -1719,23 +1719,23 @@ discard block |
||
1719 | 1719 | * @param string $table_name with or without $wpdb->prefix |
1720 | 1720 | * @return boolean |
1721 | 1721 | */ |
1722 | - public static function table_exists( $table_name ){ |
|
1722 | + public static function table_exists($table_name) { |
|
1723 | 1723 | global $wpdb, $EZSQL_ERROR; |
1724 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
1724 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
1725 | 1725 | //ignore if this causes an sql error |
1726 | 1726 | $old_error = $wpdb->last_error; |
1727 | 1727 | $old_suppress_errors = $wpdb->suppress_errors(); |
1728 | - $old_show_errors_value = $wpdb->show_errors( FALSE ); |
|
1728 | + $old_show_errors_value = $wpdb->show_errors(FALSE); |
|
1729 | 1729 | $ezsql_error_cache = $EZSQL_ERROR; |
1730 | - $wpdb->get_results( "SELECT * from $table_name LIMIT 1"); |
|
1731 | - $wpdb->show_errors( $old_show_errors_value ); |
|
1732 | - $wpdb->suppress_errors( $old_suppress_errors ); |
|
1730 | + $wpdb->get_results("SELECT * from $table_name LIMIT 1"); |
|
1731 | + $wpdb->show_errors($old_show_errors_value); |
|
1732 | + $wpdb->suppress_errors($old_suppress_errors); |
|
1733 | 1733 | $new_error = $wpdb->last_error; |
1734 | 1734 | $wpdb->last_error = $old_error; |
1735 | 1735 | $EZSQL_ERROR = $ezsql_error_cache; |
1736 | - if( empty( $new_error ) ){ |
|
1736 | + if (empty($new_error)) { |
|
1737 | 1737 | return TRUE; |
1738 | - }else{ |
|
1738 | + } else { |
|
1739 | 1739 | return FALSE; |
1740 | 1740 | } |
1741 | 1741 | } |
@@ -1743,7 +1743,7 @@ discard block |
||
1743 | 1743 | /** |
1744 | 1744 | * Resets the cache on EEH_Activation |
1745 | 1745 | */ |
1746 | - public static function reset(){ |
|
1746 | + public static function reset() { |
|
1747 | 1747 | self::$_default_creator_id = NULL; |
1748 | 1748 | self::$_initialized_db_content_already_in_this_request = false; |
1749 | 1749 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | |
5 | 5 | |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return bool |
34 | 34 | */ |
35 | - public function add( $message, $info = null ) { |
|
36 | - $attached = parent::add( $message ); |
|
35 | + public function add($message, $info = null) { |
|
36 | + $attached = parent::add($message); |
|
37 | 37 | //ensure $info is an array if not already |
38 | 38 | $info = $info === null ? $info = array() : (array) $info; |
39 | - $data = $this->_init_data( $info, $attached, $message ); |
|
40 | - if ( $attached ) { |
|
41 | - $this->set_info( $message, $data ); |
|
39 | + $data = $this->_init_data($info, $attached, $message); |
|
40 | + if ($attached) { |
|
41 | + $this->set_info($message, $data); |
|
42 | 42 | } |
43 | 43 | return $attached; |
44 | 44 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param EE_Message $message |
52 | 52 | * @return array |
53 | 53 | */ |
54 | - protected function _init_data( $info, $attached, $message ) { |
|
54 | + protected function _init_data($info, $attached, $message) { |
|
55 | 55 | $data = array( |
56 | 56 | 'test_send' => false, |
57 | 57 | 'preview' => false, |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | 'MSG_generation_data' => array() |
61 | 61 | ) |
62 | 62 | ); |
63 | - if ( isset( $info['preview'] ) ) { |
|
63 | + if (isset($info['preview'])) { |
|
64 | 64 | $data['preview'] = $info['preview']; |
65 | - unset( $info['preview'] ); |
|
65 | + unset($info['preview']); |
|
66 | 66 | } |
67 | - if ( isset( $info['test_send'] ) ) { |
|
67 | + if (isset($info['test_send'])) { |
|
68 | 68 | $data['test_send'] = $info['test_send']; |
69 | - unset( $info['test_send'] ); |
|
69 | + unset($info['test_send']); |
|
70 | 70 | } |
71 | - if ( isset( $info['data_handler_class_name'] ) ) { |
|
71 | + if (isset($info['data_handler_class_name'])) { |
|
72 | 72 | $data['data_handler_class_name'] = $info['data_handler_class_name']; |
73 | - unset( $info['data_handler_class_name'] ); |
|
73 | + unset($info['data_handler_class_name']); |
|
74 | 74 | } |
75 | - if ( $attached && $message->STS_ID() === EEM_Message::status_incomplete ) { |
|
76 | - $generation_data = isset( $info['MSG_generation_data'] ) ? $info['MSG_generation_data'] : array(); |
|
75 | + if ($attached && $message->STS_ID() === EEM_Message::status_incomplete) { |
|
76 | + $generation_data = isset($info['MSG_generation_data']) ? $info['MSG_generation_data'] : array(); |
|
77 | 77 | //if data isn't in $info...let's see if its available via the message object |
78 | 78 | $generation_data = ! $generation_data ? $message->get_generation_data() : $generation_data; |
79 | 79 | //still empty then let's just use info |
@@ -96,19 +96,19 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function saveAll() { |
98 | 98 | $this->rewind(); |
99 | - $save_tracking = array( 'updated' => 0, 'notupdated' => 0, 'errors' => array() ); |
|
99 | + $save_tracking = array('updated' => 0, 'notupdated' => 0, 'errors' => array()); |
|
100 | 100 | |
101 | 101 | //exit early if there is nothing to save. |
102 | - if ( ! $this->count() > 0 ) { |
|
102 | + if ( ! $this->count() > 0) { |
|
103 | 103 | return $save_tracking; |
104 | 104 | } |
105 | 105 | |
106 | - while( $this->valid() ) { |
|
106 | + while ($this->valid()) { |
|
107 | 107 | |
108 | 108 | $saved = $this->current()->save(); |
109 | - if ( $saved === false ) { |
|
109 | + if ($saved === false) { |
|
110 | 110 | $save_tracking['errors'][] = $this->current()->MSG_token(); |
111 | - } elseif ( $saved ) { |
|
111 | + } elseif ($saved) { |
|
112 | 112 | $save_tracking['updated']++; |
113 | 113 | } else { |
114 | 114 | $save_tracking['notupdated']++; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | $this->next(); |
120 | 120 | } |
121 | - do_action( 'AHEE__EE_Message_Repository__saveAll__after', $save_tracking, $this ); |
|
121 | + do_action('AHEE__EE_Message_Repository__saveAll__after', $save_tracking, $this); |
|
122 | 122 | return $save_tracking; |
123 | 123 | } |
124 | 124 | |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | * @param string $token Token. |
134 | 134 | * @return EE_Message | null |
135 | 135 | */ |
136 | - public function getMessageByToken( $token ) { |
|
136 | + public function getMessageByToken($token) { |
|
137 | 137 | $this->rewind(); |
138 | - while( $this->valid() ) { |
|
139 | - if ( $this->current()->MSG_token() === $token ) { |
|
138 | + while ($this->valid()) { |
|
139 | + if ($this->current()->MSG_token() === $token) { |
|
140 | 140 | $message = $this->current(); |
141 | 141 | $this->rewind(); |
142 | 142 | return $message; |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function get_generation_data() { |
159 | 159 | //first verify we're at a valid iterator point. |
160 | - if ( ! $this->valid() ) { |
|
160 | + if ( ! $this->valid()) { |
|
161 | 161 | return array(); |
162 | 162 | } |
163 | 163 | $info = $this->getInfo(); |
164 | - return isset( $info['data'] ) && isset( $info['data']['MSG_generation_data'] ) ? $info['data']['MSG_generation_data'] : array(); |
|
164 | + return isset($info['data']) && isset($info['data']['MSG_generation_data']) ? $info['data']['MSG_generation_data'] : array(); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | * @return string |
173 | 173 | */ |
174 | 174 | public function get_data_handler() { |
175 | - if ( ! $this->valid() ) { |
|
175 | + if ( ! $this->valid()) { |
|
176 | 176 | return ''; |
177 | 177 | } |
178 | 178 | $info = $this->getInfo(); |
179 | - return isset( $info['data_handler_class_name'] ) ? $info['data_handler_class_name'] : ''; |
|
179 | + return isset($info['data_handler_class_name']) ? $info['data_handler_class_name'] : ''; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @return bool |
187 | 187 | */ |
188 | 188 | public function is_preview() { |
189 | - if ( ! $this->valid() ) { |
|
189 | + if ( ! $this->valid()) { |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | $info = $this->getInfo(); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @return bool |
200 | 200 | */ |
201 | 201 | public function is_test_send() { |
202 | - if ( ! $this->valid() ) { |
|
202 | + if ( ! $this->valid()) { |
|
203 | 203 | return false; |
204 | 204 | } |
205 | 205 | $info = $this->getInfo(); |
@@ -214,16 +214,16 @@ discard block |
||
214 | 214 | * data is attached for later retrieval (batch generation). |
215 | 215 | */ |
216 | 216 | protected function _maybe_persist_attached_data() { |
217 | - if ( ! $this->valid() ) { |
|
217 | + if ( ! $this->valid()) { |
|
218 | 218 | return; |
219 | 219 | } |
220 | 220 | |
221 | 221 | $info = $this->getInfo(); |
222 | - $data_handler_class_name = isset( $info['data_handler_class_name'] ) ? $info['data_handler_class_name'] : ''; |
|
223 | - $data = isset( $info['data'] ) && isset( $info['data']['MSG_generation_data'] ) ? $info['data']['MSG_generation_data'] : array(); |
|
224 | - if ( $data && $this->current()->STS_ID() === EEM_Message::status_incomplete ) { |
|
225 | - $this->current()->set_generation_data( $data ); |
|
226 | - $this->current()->set_field_or_extra_meta( 'data_handler_class_name', $data_handler_class_name ); |
|
222 | + $data_handler_class_name = isset($info['data_handler_class_name']) ? $info['data_handler_class_name'] : ''; |
|
223 | + $data = isset($info['data']) && isset($info['data']['MSG_generation_data']) ? $info['data']['MSG_generation_data'] : array(); |
|
224 | + if ($data && $this->current()->STS_ID() === EEM_Message::status_incomplete) { |
|
225 | + $this->current()->set_generation_data($data); |
|
226 | + $this->current()->set_field_or_extra_meta('data_handler_class_name', $data_handler_class_name); |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
@@ -236,15 +236,15 @@ discard block |
||
236 | 236 | * @param array $status the optional status(es) that will also be filtered by when priority matches. |
237 | 237 | * @return int count of messages in the queue matching the conditions. |
238 | 238 | */ |
239 | - public function count_by_priority_and_status( $priority, $status = array() ) { |
|
240 | - if ( ! empty( $status ) ) { |
|
241 | - $status = is_array( $status ) ? $status : array( $status ); |
|
239 | + public function count_by_priority_and_status($priority, $status = array()) { |
|
240 | + if ( ! empty($status)) { |
|
241 | + $status = is_array($status) ? $status : array($status); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | $count = 0; |
245 | 245 | $this->rewind(); |
246 | - while ( $this->valid() ) { |
|
247 | - if ( $this->current()->priority() === $priority && ( ( $status && in_array( $this->current()->STS_ID(), $status ) ) || ! $status ) ) { |
|
246 | + while ($this->valid()) { |
|
247 | + if ($this->current()->priority() === $priority && (($status && in_array($this->current()->STS_ID(), $status)) || ! $status)) { |
|
248 | 248 | $count++; |
249 | 249 | } |
250 | 250 | $this->next(); |
@@ -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 | * |
@@ -37,33 +37,33 @@ discard block |
||
37 | 37 | * @access protected |
38 | 38 | * @return EEM_Payment_Method |
39 | 39 | */ |
40 | - protected function __construct( $timezone = NULL ) { |
|
41 | - $this->singlular_item = __( 'Payment Method', 'event_espresso' ); |
|
42 | - $this->plural_item = __( 'Payment Methods', 'event_espresso' ); |
|
43 | - $this->_tables = array( 'Payment_Method' => new EE_Primary_Table( 'esp_payment_method', 'PMD_ID' ) ); |
|
40 | + protected function __construct($timezone = NULL) { |
|
41 | + $this->singlular_item = __('Payment Method', 'event_espresso'); |
|
42 | + $this->plural_item = __('Payment Methods', 'event_espresso'); |
|
43 | + $this->_tables = array('Payment_Method' => new EE_Primary_Table('esp_payment_method', 'PMD_ID')); |
|
44 | 44 | $this->_fields = array( |
45 | 45 | 'Payment_Method' => array( |
46 | - 'PMD_ID' => new EE_Primary_Key_Int_Field( 'PMD_ID', __( "ID", 'event_espresso' ) ), |
|
47 | - 'PMD_type' => new EE_Plain_Text_Field( 'PMD_type', __( "Payment Method Type", 'event_espresso' ), FALSE, 'Admin_Only' ), |
|
48 | - 'PMD_name' => new EE_Plain_Text_Field( 'PMD_name', __( "Name", 'event_espresso' ), FALSE ), |
|
49 | - 'PMD_desc' => new EE_Post_Content_Field( 'PMD_desc', __( "Description", 'event_espresso' ), FALSE, '' ), |
|
50 | - 'PMD_admin_name' => new EE_Plain_Text_Field( 'PMD_admin_name', __( "Admin-Only Name", 'event_espresso' ), TRUE ), |
|
51 | - 'PMD_admin_desc' => new EE_Post_Content_Field( 'PMD_admin_desc', __( "Admin-Only Description", 'event_espresso' ), TRUE ), |
|
52 | - 'PMD_slug' => new EE_Slug_Field( 'PMD_slug', __( "Slug", 'event_espresso' ), FALSE ), |
|
53 | - 'PMD_order' => new EE_Integer_Field( 'PMD_order', __( "Order", 'event_espresso' ), FALSE, 0 ), |
|
54 | - 'PMD_debug_mode' => new EE_Boolean_Field( 'PMD_debug_mode', __( "Debug Mode On?", 'event_espresso' ), FALSE, FALSE ), |
|
55 | - 'PMD_wp_user' => new EE_WP_User_Field( 'PMD_wp_user', __( "Payment Method Creator ID", 'event_espresso' ), FALSE ), |
|
56 | - 'PMD_open_by_default' => new EE_Boolean_Field( 'PMD_open_by_default', __( "Open by Default?", 'event_espresso' ), FALSE, FALSE ), 'PMD_button_url' => new EE_Plain_Text_Field( 'PMD_button_url', __( "Button URL", 'event_espresso' ), TRUE, '' ), |
|
57 | - 'PMD_scope' => new EE_Serialized_Text_Field( 'PMD_scope', __( "Usable From?", 'event_espresso' ), FALSE, array() ), //possible values currently are 'CART','ADMIN','API' |
|
46 | + 'PMD_ID' => new EE_Primary_Key_Int_Field('PMD_ID', __("ID", 'event_espresso')), |
|
47 | + 'PMD_type' => new EE_Plain_Text_Field('PMD_type', __("Payment Method Type", 'event_espresso'), FALSE, 'Admin_Only'), |
|
48 | + 'PMD_name' => new EE_Plain_Text_Field('PMD_name', __("Name", 'event_espresso'), FALSE), |
|
49 | + 'PMD_desc' => new EE_Post_Content_Field('PMD_desc', __("Description", 'event_espresso'), FALSE, ''), |
|
50 | + 'PMD_admin_name' => new EE_Plain_Text_Field('PMD_admin_name', __("Admin-Only Name", 'event_espresso'), TRUE), |
|
51 | + 'PMD_admin_desc' => new EE_Post_Content_Field('PMD_admin_desc', __("Admin-Only Description", 'event_espresso'), TRUE), |
|
52 | + 'PMD_slug' => new EE_Slug_Field('PMD_slug', __("Slug", 'event_espresso'), FALSE), |
|
53 | + 'PMD_order' => new EE_Integer_Field('PMD_order', __("Order", 'event_espresso'), FALSE, 0), |
|
54 | + 'PMD_debug_mode' => new EE_Boolean_Field('PMD_debug_mode', __("Debug Mode On?", 'event_espresso'), FALSE, FALSE), |
|
55 | + 'PMD_wp_user' => new EE_WP_User_Field('PMD_wp_user', __("Payment Method Creator ID", 'event_espresso'), FALSE), |
|
56 | + 'PMD_open_by_default' => new EE_Boolean_Field('PMD_open_by_default', __("Open by Default?", 'event_espresso'), FALSE, FALSE), 'PMD_button_url' => new EE_Plain_Text_Field('PMD_button_url', __("Button URL", 'event_espresso'), TRUE, ''), |
|
57 | + 'PMD_scope' => new EE_Serialized_Text_Field('PMD_scope', __("Usable From?", 'event_espresso'), FALSE, array()), //possible values currently are 'CART','ADMIN','API' |
|
58 | 58 | ) ); |
59 | 59 | $this->_model_relations = array( |
60 | 60 | // 'Event'=>new EE_HABTM_Relation('Event_Payment_Method'), |
61 | 61 | 'Payment' => new EE_Has_Many_Relation(), |
62 | - 'Currency' => new EE_HABTM_Relation( 'Currency_Payment_Method' ), |
|
62 | + 'Currency' => new EE_HABTM_Relation('Currency_Payment_Method'), |
|
63 | 63 | 'Transaction' => new EE_Has_Many_Relation(), |
64 | 64 | 'WP_User' => new EE_Belongs_To_Relation(), |
65 | 65 | ); |
66 | - parent::__construct( $timezone ); |
|
66 | + parent::__construct($timezone); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * @param string $slug |
74 | 74 | * @return EE_Payment_Method |
75 | 75 | */ |
76 | - public function get_one_by_slug( $slug ) { |
|
77 | - return $this->get_one( array( array( 'PMD_slug' => $slug ) ) ); |
|
76 | + public function get_one_by_slug($slug) { |
|
77 | + return $this->get_one(array(array('PMD_slug' => $slug))); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | return apply_filters( |
89 | 89 | 'FHEE__EEM_Payment_Method__scopes', |
90 | 90 | array( |
91 | - self::scope_cart => __( "Front-end Registration Page", 'event_espresso' ), |
|
92 | - self::scope_admin => __( "Admin Registration Page (no online processing)", 'event_espresso' ) |
|
91 | + self::scope_cart => __("Front-end Registration Page", 'event_espresso'), |
|
92 | + self::scope_admin => __("Admin Registration Page (no online processing)", 'event_espresso') |
|
93 | 93 | ) |
94 | 94 | ); |
95 | 95 | } |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @param string $scope like one of EEM_Payment_Method::instance()->scopes() |
102 | 102 | * @return boolean |
103 | 103 | */ |
104 | - public function is_valid_scope( $scope ) { |
|
104 | + public function is_valid_scope($scope) { |
|
105 | 105 | $scopes = $this->scopes(); |
106 | - if ( isset( $scopes[ $scope ] ) ) { |
|
106 | + if (isset($scopes[$scope])) { |
|
107 | 107 | return TRUE; |
108 | 108 | } else { |
109 | 109 | return FALSE; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | * @throws EE_Error |
120 | 120 | * @return EE_Payment_Method[] |
121 | 121 | */ |
122 | - public function get_all_active( $scope = NULL, $query_params = array() ) { |
|
123 | - if( ! isset( $query_params[ 'order_by' ] ) && ! isset( $query_params[ 'order' ] ) ) { |
|
124 | - $query_params = array( 'order_by' => array( 'PMD_order' => 'ASC', 'PMD_ID' => 'ASC' ) ); |
|
122 | + public function get_all_active($scope = NULL, $query_params = array()) { |
|
123 | + if ( ! isset($query_params['order_by']) && ! isset($query_params['order'])) { |
|
124 | + $query_params = array('order_by' => array('PMD_order' => 'ASC', 'PMD_ID' => 'ASC')); |
|
125 | 125 | } |
126 | - return $this->get_all( $this->_get_query_params_for_all_active( $scope, $query_params ) ); |
|
126 | + return $this->get_all($this->_get_query_params_for_all_active($scope, $query_params)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * @param array $query_params |
133 | 133 | * @return int |
134 | 134 | */ |
135 | - public function count_active( $scope = NULL, $query_params = array() ){ |
|
136 | - return $this->count( $this->_get_query_params_for_all_active( $scope, $query_params ) ); |
|
135 | + public function count_active($scope = NULL, $query_params = array()) { |
|
136 | + return $this->count($this->_get_query_params_for_all_active($scope, $query_params)); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -144,21 +144,21 @@ discard block |
||
144 | 144 | * @return array like param of EEM_Base::get_all() |
145 | 145 | * @throws EE_Error |
146 | 146 | */ |
147 | - protected function _get_query_params_for_all_active( $scope = NULL, $query_params = array() ){ |
|
148 | - if ( $scope ) { |
|
149 | - if ( $this->is_valid_scope( $scope ) ) { |
|
150 | - return array_replace_recursive( array( array( 'PMD_scope' => array( 'LIKE', "%$scope%" ) ) ), $query_params ); |
|
147 | + protected function _get_query_params_for_all_active($scope = NULL, $query_params = array()) { |
|
148 | + if ($scope) { |
|
149 | + if ($this->is_valid_scope($scope)) { |
|
150 | + return array_replace_recursive(array(array('PMD_scope' => array('LIKE', "%$scope%"))), $query_params); |
|
151 | 151 | } else { |
152 | - throw new EE_Error( sprintf( __( "'%s' is not a valid scope for a payment method", "event_espresso" ), $scope ) ); |
|
152 | + throw new EE_Error(sprintf(__("'%s' is not a valid scope for a payment method", "event_espresso"), $scope)); |
|
153 | 153 | } |
154 | 154 | } else { |
155 | 155 | $acceptable_scopes = array(); |
156 | 156 | $count = 0; |
157 | - foreach ( $this->scopes() as $scope_name => $desc ) { |
|
157 | + foreach ($this->scopes() as $scope_name => $desc) { |
|
158 | 158 | $count++; |
159 | - $acceptable_scopes[ 'PMD_scope*' . $count ] = array( 'LIKE', '%' . $scope_name . '%' ); |
|
159 | + $acceptable_scopes['PMD_scope*'.$count] = array('LIKE', '%'.$scope_name.'%'); |
|
160 | 160 | } |
161 | - return array_replace_recursive( array( array( 'OR*active_scope' => $acceptable_scopes ) ), $query_params ); |
|
161 | + return array_replace_recursive(array(array('OR*active_scope' => $acceptable_scopes)), $query_params); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * @return array like param of EEM_Base::get_all() |
171 | 171 | * @throws EE_Error |
172 | 172 | */ |
173 | - public function get_query_params_for_all_active( $scope = NULL, $query_params = array() ) { |
|
174 | - return $this->_get_query_params_for_all_active( $scope, $query_params ); |
|
173 | + public function get_query_params_for_all_active($scope = NULL, $query_params = array()) { |
|
174 | + return $this->_get_query_params_for_all_active($scope, $query_params); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | * @param array $query_params |
182 | 182 | * @return EE_Payment_Method |
183 | 183 | */ |
184 | - public function get_one_active( $scope = NULL, $query_params = array() ) { |
|
185 | - return $this->get_one( $this->_get_query_params_for_all_active( $scope, $query_params ) ); |
|
184 | + public function get_one_active($scope = NULL, $query_params = array()) { |
|
185 | + return $this->get_one($this->_get_query_params_for_all_active($scope, $query_params)); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * @param string $type |
193 | 193 | * @return EE_Payment_Method |
194 | 194 | */ |
195 | - public function get_one_of_type( $type ) { |
|
196 | - return $this->get_one( array( array( 'PMD_type' => $type ) ) ); |
|
195 | + public function get_one_of_type($type) { |
|
196 | + return $this->get_one(array(array('PMD_type' => $type))); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
@@ -206,22 +206,22 @@ discard block |
||
206 | 206 | * @return EE_Payment_Method |
207 | 207 | * @throws EE_Error |
208 | 208 | */ |
209 | - public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ) { |
|
209 | + public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) { |
|
210 | 210 | //first: check if it's a slug |
211 | - if( is_string( $base_class_obj_or_id ) ) { |
|
212 | - $obj = $this->get_one_by_slug( $base_class_obj_or_id ); |
|
213 | - if( $obj ) { |
|
211 | + if (is_string($base_class_obj_or_id)) { |
|
212 | + $obj = $this->get_one_by_slug($base_class_obj_or_id); |
|
213 | + if ($obj) { |
|
214 | 214 | return $obj; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | //ok so it wasn't a slug we were passed. try the usual then (ie, it's an object or an ID) |
218 | 218 | try { |
219 | - return parent::ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db ); |
|
219 | + return parent::ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db); |
|
220 | 220 | } |
221 | - catch ( EE_Error $e ) { |
|
221 | + catch (EE_Error $e) { |
|
222 | 222 | //handle it outside the catch |
223 | 223 | } |
224 | - throw new EE_Error( sprintf( __( "'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso" ), $base_class_obj_or_id ) ); |
|
224 | + throw new EE_Error(sprintf(__("'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso"), $base_class_obj_or_id)); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | * @param mixed $base_obj_or_id_or_slug |
233 | 233 | * @return int |
234 | 234 | */ |
235 | - function ensure_is_ID( $base_obj_or_id_or_slug ) { |
|
236 | - if ( is_string( $base_obj_or_id_or_slug ) ) { |
|
235 | + function ensure_is_ID($base_obj_or_id_or_slug) { |
|
236 | + if (is_string($base_obj_or_id_or_slug)) { |
|
237 | 237 | //assume it's a slug |
238 | - $base_obj_or_id_or_slug = $this->get_one_by_slug( $base_obj_or_id_or_slug ); |
|
238 | + $base_obj_or_id_or_slug = $this->get_one_by_slug($base_obj_or_id_or_slug); |
|
239 | 239 | } |
240 | - return parent::ensure_is_ID( $base_obj_or_id_or_slug ); |
|
240 | + return parent::ensure_is_ID($base_obj_or_id_or_slug); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -246,36 +246,36 @@ discard block |
||
246 | 246 | * Verifies the button urls on all the passed payment methods have a valid button url. If not, resets them to their default. |
247 | 247 | * @param EE_Payment_Method[] $payment_methods. If NULL is provided defaults to all payment methods active in the cart |
248 | 248 | */ |
249 | - function verify_button_urls( $payment_methods = NULL ) { |
|
250 | - $payment_methods = is_array( $payment_methods ) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart); |
|
251 | - foreach ( $payment_methods as $payment_method ) { |
|
249 | + function verify_button_urls($payment_methods = NULL) { |
|
250 | + $payment_methods = is_array($payment_methods) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart); |
|
251 | + foreach ($payment_methods as $payment_method) { |
|
252 | 252 | try { |
253 | 253 | $current_button_url = $payment_method->button_url(); |
254 | - $buttons_urls_to_try = apply_filters( 'FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array( |
|
255 | - 'current_ssl' => str_replace( "http://", "https://", $current_button_url ), |
|
256 | - 'current' => str_replace( "https://", "http://", $current_button_url ), |
|
257 | - 'default_ssl' => str_replace( "http://", "https://", $payment_method->type_obj()->default_button_url() ), |
|
258 | - 'default' => str_replace( "https://", "http://", $payment_method->type_obj()->default_button_url() ), |
|
259 | - ) ); |
|
260 | - foreach( $buttons_urls_to_try as $button_url_to_try ) { |
|
261 | - if( |
|
254 | + $buttons_urls_to_try = apply_filters('FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array( |
|
255 | + 'current_ssl' => str_replace("http://", "https://", $current_button_url), |
|
256 | + 'current' => str_replace("https://", "http://", $current_button_url), |
|
257 | + 'default_ssl' => str_replace("http://", "https://", $payment_method->type_obj()->default_button_url()), |
|
258 | + 'default' => str_replace("https://", "http://", $payment_method->type_obj()->default_button_url()), |
|
259 | + )); |
|
260 | + foreach ($buttons_urls_to_try as $button_url_to_try) { |
|
261 | + if ( |
|
262 | 262 | (//this is the current url and it exists, regardless of SSL issues |
263 | 263 | $button_url_to_try == $current_button_url && |
264 | 264 | EEH_URL::remote_file_exists( |
265 | 265 | $button_url_to_try, |
266 | 266 | array( |
267 | 267 | 'sslverify' => false, |
268 | - 'limit_response_size' => 4095,//we don't really care for a full response, but we do want headers at least. Lets just ask for a one block |
|
268 | + 'limit_response_size' => 4095, //we don't really care for a full response, but we do want headers at least. Lets just ask for a one block |
|
269 | 269 | ) ) |
270 | 270 | ) |
271 | 271 | || |
272 | 272 | (//this is NOT the current url and it exists with a working SSL cert |
273 | 273 | $button_url_to_try != $current_button_url && |
274 | - EEH_URL::remote_file_exists( $button_url_to_try ) |
|
274 | + EEH_URL::remote_file_exists($button_url_to_try) |
|
275 | 275 | ) ) { |
276 | - if( $current_button_url != $button_url_to_try ){ |
|
277 | - $payment_method->save( array( 'PMD_button_url' => $button_url_to_try ) ); |
|
278 | - EE_Error::add_attention( sprintf( __( "Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso" ), $payment_method->name(), $button_url_to_try ) ); |
|
276 | + if ($current_button_url != $button_url_to_try) { |
|
277 | + $payment_method->save(array('PMD_button_url' => $button_url_to_try)); |
|
278 | + EE_Error::add_attention(sprintf(__("Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso"), $payment_method->name(), $button_url_to_try)); |
|
279 | 279 | } |
280 | 280 | //this image exists. So if wasn't set before, now it is; |
281 | 281 | //or if it was already set, we have nothing to do |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
286 | - catch ( EE_Error $e ) { |
|
287 | - $payment_method->set_active( FALSE ); |
|
286 | + catch (EE_Error $e) { |
|
287 | + $payment_method->set_active(FALSE); |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | } |
@@ -298,29 +298,29 @@ discard block |
||
298 | 298 | * @param array $rows |
299 | 299 | * @return EE_Payment_Method[] |
300 | 300 | */ |
301 | - protected function _create_objects( $rows = array() ) { |
|
302 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
303 | - $payment_methods = parent::_create_objects( $rows ); |
|
301 | + protected function _create_objects($rows = array()) { |
|
302 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
303 | + $payment_methods = parent::_create_objects($rows); |
|
304 | 304 | /* @var $payment_methods EE_Payment_Method[] */ |
305 | 305 | $usable_payment_methods = array(); |
306 | - foreach ( $payment_methods as $key => $payment_method ) { |
|
307 | - if ( EE_Payment_Method_Manager::instance()->payment_method_type_exists( $payment_method->type() ) ) { |
|
308 | - $usable_payment_methods[ $key ] = $payment_method; |
|
306 | + foreach ($payment_methods as $key => $payment_method) { |
|
307 | + if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) { |
|
308 | + $usable_payment_methods[$key] = $payment_method; |
|
309 | 309 | //some payment methods enqueue their scripts in EE_PMT_*::__construct |
310 | 310 | //which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue |
311 | 311 | //its scripts). but for backwards-compat we should continue to do that |
312 | 312 | $payment_method->type_obj(); |
313 | - } elseif( $payment_method->active() ) { |
|
313 | + } elseif ($payment_method->active()) { |
|
314 | 314 | //only deactivate and notify the admin if the payment is active somewhere |
315 | 315 | $payment_method->deactivate(); |
316 | 316 | $payment_method->save(); |
317 | 317 | EE_Error::add_persistent_admin_notice( |
318 | - 'auto-deactivated-' . $payment_method->type(), |
|
318 | + 'auto-deactivated-'.$payment_method->type(), |
|
319 | 319 | sprintf( |
320 | - __( 'The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso' ), |
|
320 | + __('The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso'), |
|
321 | 321 | $payment_method->admin_name(), |
322 | 322 | '<br />', |
323 | - '<a href="' . admin_url('plugins.php') . '">', |
|
323 | + '<a href="'.admin_url('plugins.php').'">', |
|
324 | 324 | '</a>' |
325 | 325 | ), |
326 | 326 | true |
@@ -340,16 +340,16 @@ discard block |
||
340 | 340 | * @param string $scope @see EEM_Payment_Method::get_all_for_events |
341 | 341 | * @return EE_Payment_Method[] |
342 | 342 | */ |
343 | - public function get_all_for_transaction( $transaction, $scope ) { |
|
343 | + public function get_all_for_transaction($transaction, $scope) { |
|
344 | 344 | //@todo take relations between events and payment methods into account, once that relation exists |
345 | - if ( $transaction instanceof EE_Transaction ) { |
|
345 | + if ($transaction instanceof EE_Transaction) { |
|
346 | 346 | //@todo take the relation between transaction and currencies into account |
347 | 347 | } |
348 | - $currencies_for_events = array( EE_Config::instance()->currency->code ); |
|
348 | + $currencies_for_events = array(EE_Config::instance()->currency->code); |
|
349 | 349 | //give addons a chance to override what payment methods are chosen based on the transaction |
350 | 350 | return apply_filters( |
351 | 351 | 'FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods', |
352 | - $this->get_all_active( $scope, array( array( 'Currency.CUR_code' => array( 'IN', $currencies_for_events ) ) ) ), |
|
352 | + $this->get_all_active($scope, array(array('Currency.CUR_code' => array('IN', $currencies_for_events)))), |
|
353 | 353 | $transaction, |
354 | 354 | $scope |
355 | 355 | ); |
@@ -365,16 +365,16 @@ discard block |
||
365 | 365 | * @param EE_Registration|int $registration_or_reg_id Either the EE_Registration object or the id for the registration. |
366 | 366 | * @return EE_Payment|null |
367 | 367 | */ |
368 | - public function get_last_used_for_registration( $registration_or_reg_id ) { |
|
369 | - $registration_id = EEM_Registration::instance()->ensure_is_ID( $registration_or_reg_id ); |
|
368 | + public function get_last_used_for_registration($registration_or_reg_id) { |
|
369 | + $registration_id = EEM_Registration::instance()->ensure_is_ID($registration_or_reg_id); |
|
370 | 370 | |
371 | 371 | $query_params = array( |
372 | 372 | 0 => array( |
373 | 373 | 'Payment.Registration.REG_ID' => $registration_id, |
374 | 374 | ), |
375 | - 'order_by' => array( 'Payment.PAY_ID' => 'DESC' ) |
|
375 | + 'order_by' => array('Payment.PAY_ID' => 'DESC') |
|
376 | 376 | ); |
377 | - return $this->get_one( $query_params ); |
|
377 | + return $this->get_one($query_params); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -42,25 +42,25 @@ discard block |
||
42 | 42 | $this->_shortcodes = array( |
43 | 43 | '[TXN_ID]' => __('The transaction id for the purchase.', 'event_espresso'), |
44 | 44 | '[PAYMENT_URL]' => __('This is a link to make a payment for the event', 'event_espresso'), |
45 | - '[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso') . '<ul>' |
|
46 | - . '<li>' . sprintf( __('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
47 | - . '<li>' . sprintf( __('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
48 | - . '<li>' . sprintf( __('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
45 | + '[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso').'<ul>' |
|
46 | + . '<li>'.sprintf(__('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
47 | + . '<li>'.sprintf(__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
48 | + . '<li>'.sprintf(__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
49 | 49 | . '</ul>', |
50 | - '[PAYMENT_DUE_DATE_*]' => __( 'This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso' ) |
|
50 | + '[PAYMENT_DUE_DATE_*]' => __('This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso') |
|
51 | 51 | . '<ul>' |
52 | - . '<li>' . sprintf( __( '%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
53 | - . '<li>' . sprintf( __( '%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
54 | - . '<li>' . sprintf( __( '%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>', |
|
52 | + . '<li>'.sprintf(__('%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
53 | + . '<li>'.sprintf(__('%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
54 | + . '<li>'.sprintf(__('%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso'), '<strong>', '</strong>').'</li>', |
|
55 | 55 | '[INVOICE_LINK]' => __('This is a full html link to the invoice', 'event_espresso'), |
56 | 56 | '[INVOICE_URL]' => __('This is just the url for the invoice', 'event_espresso'), |
57 | 57 | '[INVOICE_LOGO_URL]' => __('This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso'), |
58 | 58 | '[INVOICE_LOGO]' => __('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso'), |
59 | 59 | '[INVOICE_PAYEE_NAME]' => __('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
60 | - '[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
61 | - '[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso' ), |
|
62 | - '[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
63 | - '[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso' ), |
|
60 | + '[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
61 | + '[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso'), |
|
62 | + '[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
63 | + '[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso'), |
|
64 | 64 | '[TOTAL_COST]' => __('The total cost for the transaction', 'event_espresso'), |
65 | 65 | '[TXN_STATUS]' => __('The transaction status for the transaction.', 'event_espresso'), |
66 | 66 | '[TXN_STATUS_ID]' => __('The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso'), |
@@ -71,52 +71,52 @@ discard block |
||
71 | 71 | '[TOTAL_OWING]' => __('The total owing on a transaction with no attributes.', 'event_espresso'), |
72 | 72 | '[TXN_SUBTOTAL]' => __('The subtotal for all txn line items.', 'event_espresso'), |
73 | 73 | '[TXN_TAX_SUBTOTAL]' => __('The subtotal for all tax line items.', 'event_espresso'), |
74 | - '[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso') . '<p></ul>' . |
|
75 | - '<li><strong>still_owing</strong>:' . __('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso' ) . sprintf( __( '%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ) . '</li>' . |
|
76 | - '<li><strong>none_owing</strong>:' . __('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total oweing.', 'event_espresso') . '</li></ul></p>', |
|
74 | + '[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso').'<p></ul>'. |
|
75 | + '<li><strong>still_owing</strong>:'.__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso').sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>').'</li>'. |
|
76 | + '<li><strong>none_owing</strong>:'.__('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total oweing.', 'event_espresso').'</li></ul></p>', |
|
77 | 77 | '[TXN_TOTAL_TICKETS]' => __('The total number of all tickets purchased in a transaction', 'event_espresso'), |
78 | 78 | '[TKT_QTY_PURCHASED]' => __('The total number of all tickets purchased in a transaction. <strong>NOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.</strong>', 'event_espresso'), |
79 | 79 | '[TRANSACTION_ADMIN_URL]' => __('The url to the admin page for this transaction', 'event_espresso'), |
80 | 80 | '[RECEIPT_URL]' => __('This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso'), |
81 | - '[INVOICE_RECEIPT_SWITCHER_URL]' => __( 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
82 | - '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( __( 'The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso' ), '<code>', '</code>' ) |
|
81 | + '[INVOICE_RECEIPT_SWITCHER_URL]' => __('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
82 | + '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso'), '<code>', '</code>') |
|
83 | 83 | ); |
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | - protected function _parser( $shortcode ) { |
|
87 | + protected function _parser($shortcode) { |
|
88 | 88 | |
89 | 89 | //attempt to get the transaction. Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction. |
90 | 90 | $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
91 | - $transaction = ! $transaction instanceof EE_Transaction && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn: $transaction; |
|
91 | + $transaction = ! $transaction instanceof EE_Transaction && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn : $transaction; |
|
92 | 92 | |
93 | 93 | //payment |
94 | 94 | $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null; |
95 | - $payment = ! $payment instanceof EE_Payment && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment: $payment; |
|
95 | + $payment = ! $payment instanceof EE_Payment && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment : $payment; |
|
96 | 96 | |
97 | 97 | |
98 | - if ( ! $transaction instanceof EE_Transaction ) |
|
98 | + if ( ! $transaction instanceof EE_Transaction) |
|
99 | 99 | return ''; |
100 | 100 | |
101 | - switch ( $shortcode ) { |
|
101 | + switch ($shortcode) { |
|
102 | 102 | case '[TXN_ID]' : |
103 | 103 | return $transaction->ID(); |
104 | 104 | break; |
105 | 105 | |
106 | 106 | case '[PAYMENT_URL]' : |
107 | 107 | $payment_url = $transaction->payment_overview_url(); |
108 | - return empty( $payment_url ) ? __( 'http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
108 | + return empty($payment_url) ? __('http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
109 | 109 | break; |
110 | 110 | |
111 | 111 | case '[INVOICE_LINK]' : |
112 | 112 | $invoice_url = $transaction->invoice_url(); |
113 | - $invoice_url = empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
114 | - return sprintf( __('%sClick here for Invoice%s', 'event_espresso'), '<a href="' . $invoice_url . '">', '</a>' ); |
|
113 | + $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
114 | + return sprintf(__('%sClick here for Invoice%s', 'event_espresso'), '<a href="'.$invoice_url.'">', '</a>'); |
|
115 | 115 | break; /**/ |
116 | 116 | |
117 | 117 | case '[INVOICE_URL]' : |
118 | 118 | $invoice_url = $transaction->invoice_url(); |
119 | - return empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
119 | + return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
120 | 120 | break; |
121 | 121 | |
122 | 122 | case '[INVOICE_LOGO_URL]' : |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | break; |
125 | 125 | |
126 | 126 | case '[INVOICE_LOGO]' : |
127 | - return $this->_get_invoice_logo( TRUE ); |
|
127 | + return $this->_get_invoice_logo(TRUE); |
|
128 | 128 | break; |
129 | 129 | |
130 | 130 | case '[INVOICE_PAYEE_NAME]' : |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | |
147 | 147 | case "[TOTAL_COST]" : |
148 | 148 | $total = $transaction->total(); |
149 | - return ! empty($total) ? EEH_Template::format_currency( $total ) : ''; |
|
149 | + return ! empty($total) ? EEH_Template::format_currency($total) : ''; |
|
150 | 150 | break; |
151 | 151 | |
152 | 152 | case "[PAYMENT_STATUS]" : |
153 | 153 | $status = $transaction->pretty_status(); |
154 | - return !empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
154 | + return ! empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
155 | 155 | break; /**/ |
156 | 156 | |
157 | 157 | // note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity. |
158 | 158 | case "[TXN_STATUS]" : |
159 | 159 | $status = $transaction->pretty_status(); |
160 | - return !empty( $status ) ? $status : __('Unknown', 'event_espresso'); |
|
160 | + return ! empty($status) ? $status : __('Unknown', 'event_espresso'); |
|
161 | 161 | break; |
162 | 162 | |
163 | 163 | case "[TXN_STATUS_ID]" : |
@@ -165,21 +165,21 @@ discard block |
||
165 | 165 | break; |
166 | 166 | |
167 | 167 | case "[PAYMENT_GATEWAY]" : |
168 | - return $this->_get_payment_gateway( $transaction ); |
|
168 | + return $this->_get_payment_gateway($transaction); |
|
169 | 169 | break; |
170 | 170 | |
171 | 171 | case "[AMOUNT_PAID]" : |
172 | 172 | $amount = $payment instanceof EE_Payment ? $payment->amount() : 0; |
173 | - return EEH_Template::format_currency( $amount ); |
|
173 | + return EEH_Template::format_currency($amount); |
|
174 | 174 | break; |
175 | 175 | |
176 | 176 | case "[TOTAL_AMOUNT_PAID]" : |
177 | - return EEH_Template::format_currency( $transaction->paid() ); |
|
177 | + return EEH_Template::format_currency($transaction->paid()); |
|
178 | 178 | break; |
179 | 179 | |
180 | 180 | case "[TOTAL_OWING]" : |
181 | 181 | $total_owing = $transaction->remaining(); |
182 | - return EEH_Template::format_currency( $total_owing ); |
|
182 | + return EEH_Template::format_currency($total_owing); |
|
183 | 183 | break; |
184 | 184 | |
185 | 185 | case "[TXN_SUBTOTAL]" : |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | break; |
188 | 188 | |
189 | 189 | case "[TXN_TAX_SUBTOTAL]" : |
190 | - return EEH_Template::format_currency($this->_get_subtotal( TRUE )); |
|
190 | + return EEH_Template::format_currency($this->_get_subtotal(TRUE)); |
|
191 | 191 | break; |
192 | 192 | |
193 | 193 | case "[TKT_QTY_PURCHASED]" : |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | break; |
197 | 197 | |
198 | 198 | case "[TRANSACTION_ADMIN_URL]" : |
199 | - require_once EE_CORE . 'admin/EE_Admin_Page.core.php'; |
|
200 | - $query_args = array( 'page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID() ); |
|
201 | - $url = EE_Admin_Page::add_query_args_and_nonce( $query_args, admin_url('admin.php') ); |
|
199 | + require_once EE_CORE.'admin/EE_Admin_Page.core.php'; |
|
200 | + $query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID()); |
|
201 | + $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php')); |
|
202 | 202 | return $url; |
203 | 203 | break; |
204 | 204 | |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | //get primary_registration |
207 | 207 | $reg = $this->_data->primary_reg_obj; |
208 | 208 | |
209 | - if ( ! $reg instanceof EE_Registration ) { |
|
209 | + if ( ! $reg instanceof EE_Registration) { |
|
210 | 210 | return ''; |
211 | 211 | } |
212 | 212 | return $reg->receipt_url(); |
213 | 213 | break; |
214 | 214 | |
215 | 215 | case "[INVOICE_RECEIPT_SWITCHER_URL]" : |
216 | - return $this->_get_invoice_receipt_switcher( FALSE ); |
|
216 | + return $this->_get_invoice_receipt_switcher(FALSE); |
|
217 | 217 | break; |
218 | 218 | |
219 | 219 | case "[INVOICE_RECEIPT_SWITCHER_BUTTON]" : |
@@ -223,20 +223,20 @@ discard block |
||
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | - if ( strpos( $shortcode, '[OWING_STATUS_MESSAGE_*' ) !== FALSE ) { |
|
227 | - return $this->_get_custom_total_oweing( $shortcode ); |
|
226 | + if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== FALSE) { |
|
227 | + return $this->_get_custom_total_oweing($shortcode); |
|
228 | 228 | } |
229 | 229 | |
230 | - if ( strpos( $shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*' ) !== FALSE ) { |
|
231 | - return $this->_get_invoice_payee_tax_number( $shortcode ); |
|
230 | + if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== FALSE) { |
|
231 | + return $this->_get_invoice_payee_tax_number($shortcode); |
|
232 | 232 | } |
233 | 233 | |
234 | - if ( strpos( $shortcode, '[PAYMENT_LINK_IF_NEEDED_*' ) !== FALSE ) { |
|
235 | - return $this->_get_payment_link_if_needed( $shortcode ); |
|
234 | + if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== FALSE) { |
|
235 | + return $this->_get_payment_link_if_needed($shortcode); |
|
236 | 236 | } |
237 | 237 | |
238 | - if ( strpos( $shortcode, '[PAYMENT_DUE_DATE_*' ) !== false ) { |
|
239 | - return $this->_get_payment_due_date( $shortcode, $transaction ); |
|
238 | + if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) { |
|
239 | + return $this->_get_payment_due_date($shortcode, $transaction); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | return ''; |
@@ -253,19 +253,19 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return string parsed. |
255 | 255 | */ |
256 | - private function _get_custom_total_oweing( $shortcode ) { |
|
257 | - $valid_shortcodes = array( 'transaction' ); |
|
258 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
256 | + private function _get_custom_total_oweing($shortcode) { |
|
257 | + $valid_shortcodes = array('transaction'); |
|
258 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
259 | 259 | |
260 | 260 | //ensure default is set. |
261 | 261 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
262 | 262 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
263 | 263 | |
264 | - if ( $total_owing > 0 ) { |
|
265 | - $owing_content = ! empty( $attrs['still_owing'] ) ? $attrs['still_owing'] : sprintf( __( '%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ); |
|
266 | - $owing_content = $this->_shortcode_helper->parse_message_template( $owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
264 | + if ($total_owing > 0) { |
|
265 | + $owing_content = ! empty($attrs['still_owing']) ? $attrs['still_owing'] : sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>'); |
|
266 | + $owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message); |
|
267 | 267 | } else { |
268 | - $owing_content = !empty( $attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
268 | + $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | return $owing_content; |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | |
274 | 274 | |
275 | 275 | |
276 | - private function _get_payment_gateway( $transaction ) { |
|
277 | - $pm = $this->_get_payment_method( $transaction ); |
|
276 | + private function _get_payment_gateway($transaction) { |
|
277 | + $pm = $this->_get_payment_method($transaction); |
|
278 | 278 | return $pm instanceof EE_Payment_Method ? $pm->name() : ''; |
279 | 279 | } |
280 | 280 | |
@@ -289,37 +289,37 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @return string url or html |
291 | 291 | */ |
292 | - private function _get_invoice_logo( $img_tags = FALSE ) { |
|
292 | + private function _get_invoice_logo($img_tags = FALSE) { |
|
293 | 293 | //try to get the invoice payment method's logo for this transaction image first |
294 | 294 | $pm = $this->_get_payment_method(); |
295 | - if ( $pm instanceof EE_Payment_Method ){ |
|
296 | - $invoice_logo_url = $pm->get_extra_meta( 'pdf_logo_image', TRUE ); |
|
297 | - }else{ |
|
295 | + if ($pm instanceof EE_Payment_Method) { |
|
296 | + $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', TRUE); |
|
297 | + } else { |
|
298 | 298 | $invoice_logo_url = NULL; |
299 | 299 | } |
300 | - if( empty( $invoice_logo_url ) ){ |
|
300 | + if (empty($invoice_logo_url)) { |
|
301 | 301 | $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url; |
302 | 302 | } |
303 | 303 | |
304 | - if ( empty( $invoice_logo_url ) ) { |
|
304 | + if (empty($invoice_logo_url)) { |
|
305 | 305 | return ''; |
306 | 306 | } |
307 | 307 | |
308 | - if ( ! $img_tags ) { |
|
308 | + if ( ! $img_tags) { |
|
309 | 309 | return $invoice_logo_url; |
310 | 310 | } |
311 | 311 | |
312 | 312 | //image tags have been requested. |
313 | - $image_size = getimagesize( $invoice_logo_url ); |
|
313 | + $image_size = getimagesize($invoice_logo_url); |
|
314 | 314 | |
315 | 315 | //if image is wider than 200px, set the wideth to 200 |
316 | - if ( $image_size[0] > 300 ) { |
|
316 | + if ($image_size[0] > 300) { |
|
317 | 317 | $image_width = 300; |
318 | - }else{ |
|
318 | + } else { |
|
319 | 319 | $image_width = $image_size[0]; |
320 | 320 | } |
321 | 321 | |
322 | - return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />'; |
|
322 | + return '<img class="logo screen" src="'.$invoice_logo_url.'" width="'.$image_width.'" alt="logo" />'; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -336,26 +336,26 @@ discard block |
||
336 | 336 | private function _get_invoice_payee_name() { |
337 | 337 | $payee_name = NULL; |
338 | 338 | $pm = $this->_get_payment_method(); |
339 | - if( $pm instanceof EE_Payment_Method ){ |
|
340 | - $payee_name = $pm->get_extra_meta( 'pdf_payee_name', TRUE ); |
|
339 | + if ($pm instanceof EE_Payment_Method) { |
|
340 | + $payee_name = $pm->get_extra_meta('pdf_payee_name', TRUE); |
|
341 | 341 | } |
342 | - $payee_name = empty( $payee_name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : $payee_name; |
|
342 | + $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name; |
|
343 | 343 | return $payee_name; |
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
347 | 347 | * gets the payment method for this transaction. Otherwise gets a default one. |
348 | 348 | */ |
349 | - private function _get_payment_method( $transaction = null ){ |
|
350 | - if( $transaction instanceof EE_Transaction ) { |
|
349 | + private function _get_payment_method($transaction = null) { |
|
350 | + if ($transaction instanceof EE_Transaction) { |
|
351 | 351 | $payment_method = $transaction->payment_method(); |
352 | - if ( empty( $payment_method ) ) { |
|
353 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
352 | + if (empty($payment_method)) { |
|
353 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
354 | 354 | } |
355 | 355 | return $payment_method; |
356 | - }else{ |
|
356 | + } else { |
|
357 | 357 | //get the first payment method we can find |
358 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
358 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
@@ -372,10 +372,10 @@ discard block |
||
372 | 372 | private function _get_invoice_payee_email() { |
373 | 373 | $payee_email = NULL; |
374 | 374 | $pm = $this->_get_payment_method(); |
375 | - if( $pm instanceof EE_Payment_Method ){ |
|
376 | - $payee_email = $pm->get_extra_meta( 'pdf_payee_email', TRUE ); |
|
375 | + if ($pm instanceof EE_Payment_Method) { |
|
376 | + $payee_email = $pm->get_extra_meta('pdf_payee_email', TRUE); |
|
377 | 377 | } |
378 | - $payee_email = empty( $payee_email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : $payee_email; |
|
378 | + $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : $payee_email; |
|
379 | 379 | return $payee_email; |
380 | 380 | } |
381 | 381 | |
@@ -391,24 +391,24 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @return string |
393 | 393 | */ |
394 | - private function _get_invoice_payee_tax_number( $shortcode ) { |
|
394 | + private function _get_invoice_payee_tax_number($shortcode) { |
|
395 | 395 | $payee_tax_number = NULL; |
396 | 396 | $pm = $this->_get_payment_method(); |
397 | - if( $pm instanceof EE_Payment_Method ){ |
|
398 | - $payee_tax_number = $pm->get_extra_meta( 'pdf_payee_tax_number', TRUE ); |
|
397 | + if ($pm instanceof EE_Payment_Method) { |
|
398 | + $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', TRUE); |
|
399 | 399 | } |
400 | - $payee_tax_number = empty( $payee_tax_number ) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
400 | + $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
401 | 401 | |
402 | - if ( empty( $payee_tax_number ) ) { |
|
402 | + if (empty($payee_tax_number)) { |
|
403 | 403 | return ''; |
404 | 404 | } |
405 | 405 | |
406 | 406 | //any attributes? |
407 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
407 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
408 | 408 | |
409 | 409 | //prefix? |
410 | - $prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : __( 'VAT/Tax Number: ', 'event_espresso' ); |
|
411 | - return $prefix . $payee_tax_number; |
|
410 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : __('VAT/Tax Number: ', 'event_espresso'); |
|
411 | + return $prefix.$payee_tax_number; |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | |
@@ -425,22 +425,22 @@ discard block |
||
425 | 425 | private function _get_invoice_payee_address() { |
426 | 426 | $payee_address = NULL; |
427 | 427 | $pm = $this->_get_payment_method(); |
428 | - if( $pm instanceof EE_Payment_Method ){ |
|
429 | - $payee_address = $pm->get_extra_meta( 'pdf_payee_address', TRUE ); |
|
428 | + if ($pm instanceof EE_Payment_Method) { |
|
429 | + $payee_address = $pm->get_extra_meta('pdf_payee_address', TRUE); |
|
430 | 430 | } |
431 | - if ( empty( $payee_address ) ) { |
|
431 | + if (empty($payee_address)) { |
|
432 | 432 | $organization = EE_Registry::instance()->CFG->organization; |
433 | - $payee_address = $organization->get_pretty( 'address_1' ) . '<br>'; |
|
434 | - $payee_address .= !empty( $organization->address_2 ) ? $organization->get_pretty( 'address_2' ) . '<br>' : ''; |
|
435 | - $payee_address .= $organization->get_pretty( 'city' ) . '<br>'; |
|
433 | + $payee_address = $organization->get_pretty('address_1').'<br>'; |
|
434 | + $payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : ''; |
|
435 | + $payee_address .= $organization->get_pretty('city').'<br>'; |
|
436 | 436 | |
437 | 437 | //state |
438 | - $state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $organization->STA_ID ); |
|
439 | - $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
438 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
439 | + $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
440 | 440 | |
441 | 441 | //Country |
442 | - $payee_address .= ! empty( $organization->CNT_ISO ) ? ', ' . $organization->CNT_ISO . '<br>' : ''; |
|
443 | - $payee_address .= ! empty( $organization->zip ) ? $organization->zip : ''; |
|
442 | + $payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : ''; |
|
443 | + $payee_address .= ! empty($organization->zip) ? $organization->zip : ''; |
|
444 | 444 | } |
445 | 445 | return $payee_address; |
446 | 446 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | private function _get_invoice_payment_instructions() { |
459 | 459 | $instructions = NULL; |
460 | 460 | $pm = $this->_get_payment_method(); |
461 | - return ( $pm instanceof EE_Payment_Method ) ? $pm->get_extra_meta( 'pdf_instructions', TRUE) : ''; |
|
461 | + return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', TRUE) : ''; |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | |
@@ -472,27 +472,27 @@ discard block |
||
472 | 472 | * |
473 | 473 | * @return string |
474 | 474 | */ |
475 | - protected function _get_invoice_receipt_switcher( $button = TRUE ) { |
|
475 | + protected function _get_invoice_receipt_switcher($button = TRUE) { |
|
476 | 476 | $reg = $this->_data->primary_reg_obj; |
477 | - $message_type = isset( $this->_extra_data['message_type'] ) ? $this->_extra_data['message_type'] : ''; |
|
478 | - if ( ! $reg instanceof EE_Registration || empty( $message_type ) ) { |
|
477 | + $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : ''; |
|
478 | + if ( ! $reg instanceof EE_Registration || empty($message_type)) { |
|
479 | 479 | return ''; |
480 | 480 | } |
481 | 481 | |
482 | - $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
483 | - $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso' ) : __( 'Switch to Invoice', 'event_espresso' ); |
|
484 | - $switch_to_label = ! $switch_to_invoice ? __( 'Switch to Receipt', 'event_espresso' ) : $switch_to_label; |
|
482 | + $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
483 | + $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso') : __('Switch to Invoice', 'event_espresso'); |
|
484 | + $switch_to_label = ! $switch_to_invoice ? __('Switch to Receipt', 'event_espresso') : $switch_to_label; |
|
485 | 485 | $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url(); |
486 | 486 | |
487 | - if ( ! $button ) { |
|
487 | + if ( ! $button) { |
|
488 | 488 | return $switch_to_url; |
489 | 489 | } |
490 | 490 | |
491 | - if ( ! empty( $switch_to_url ) ) { |
|
491 | + if ( ! empty($switch_to_url)) { |
|
492 | 492 | |
493 | 493 | return ' |
494 | - <form method="post" action="' . $switch_to_url . '" > |
|
495 | - <input class="print_button" type="submit" value="' . $switch_to_label . '" /> |
|
494 | + <form method="post" action="' . $switch_to_url.'" > |
|
495 | + <input class="print_button" type="submit" value="' . $switch_to_label.'" /> |
|
496 | 496 | </form> |
497 | 497 | '; |
498 | 498 | } |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | * |
513 | 513 | * @return string |
514 | 514 | */ |
515 | - private function _get_receipt_url( EE_Transaction $transaction ) { |
|
515 | + private function _get_receipt_url(EE_Transaction $transaction) { |
|
516 | 516 | //get primary_registration |
517 | 517 | $reg = $this->_data->primary_reg_obj; |
518 | 518 | |
519 | - if ( ! $reg instanceof EE_Registration ) { |
|
519 | + if ( ! $reg instanceof EE_Registration) { |
|
520 | 520 | return ''; |
521 | 521 | } |
522 | 522 | |
@@ -532,10 +532,10 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return int |
534 | 534 | */ |
535 | - private function _get_subtotal( $tax = FALSE ) { |
|
536 | - $grand_total = isset( $this->_data->grand_total_line_item ) ? $this->_data->grand_total_line_item : NULL; |
|
535 | + private function _get_subtotal($tax = FALSE) { |
|
536 | + $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : NULL; |
|
537 | 537 | |
538 | - if ( ! $grand_total instanceof EE_Line_Item ) { |
|
538 | + if ( ! $grand_total instanceof EE_Line_Item) { |
|
539 | 539 | return 0; |
540 | 540 | } |
541 | 541 | |
@@ -554,26 +554,26 @@ discard block |
||
554 | 554 | * |
555 | 555 | * @return string parsed. |
556 | 556 | */ |
557 | - private function _get_payment_link_if_needed( $shortcode ) { |
|
558 | - $valid_shortcodes = array( 'transaction' ); |
|
559 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
557 | + private function _get_payment_link_if_needed($shortcode) { |
|
558 | + $valid_shortcodes = array('transaction'); |
|
559 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
560 | 560 | |
561 | 561 | //ensure default is set. |
562 | 562 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
563 | 563 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
564 | 564 | |
565 | - if ( $total_owing > 0 ) { |
|
566 | - $class = isset( $attrs['class'] ) ? $attrs['class'] : 'callout'; |
|
567 | - $custom_text = isset( $attrs['custom_text'] ) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
568 | - $container_tag = isset( $attrs['container_tag'] ) ? $attrs['container_tag'] : 'p'; |
|
569 | - $opening_tag = ! empty( $container_tag ) ? '<' . $container_tag : ''; |
|
570 | - $opening_tag .= ! empty( $opening_tag ) && !empty( $class ) ? ' class="' . $class . '"' : $opening_tag; |
|
571 | - $opening_tag .= !empty( $opening_tag ) ? '>' : $opening_tag; |
|
572 | - $closing_tag = ! empty( $container_tag ) ? '</' . $container_tag .'>' : ''; |
|
573 | - $content = $opening_tag . sprintf( $custom_text, '<a href="[PAYMENT_URL]">', '</a>' ) . $closing_tag; |
|
565 | + if ($total_owing > 0) { |
|
566 | + $class = isset($attrs['class']) ? $attrs['class'] : 'callout'; |
|
567 | + $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
568 | + $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p'; |
|
569 | + $opening_tag = ! empty($container_tag) ? '<'.$container_tag : ''; |
|
570 | + $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag; |
|
571 | + $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag; |
|
572 | + $closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : ''; |
|
573 | + $content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag; |
|
574 | 574 | |
575 | 575 | //we need to re run this string through the parser to catch any shortcodes that are in it. |
576 | - $owing_content = $this->_shortcode_helper->parse_message_template( $content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
576 | + $owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message); |
|
577 | 577 | } else { |
578 | 578 | return ''; |
579 | 579 | } |
@@ -593,31 +593,31 @@ discard block |
||
593 | 593 | * @param EE_Transaction $transaction |
594 | 594 | * @return string |
595 | 595 | */ |
596 | - protected function _get_payment_due_date( $shortcode, EE_Transaction $transaction ) { |
|
596 | + protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) { |
|
597 | 597 | //if transaction is paid in full then we can just return an empty string |
598 | - if ( $transaction->remaining() === 0 ) { |
|
598 | + if ($transaction->remaining() === 0) { |
|
599 | 599 | return ''; |
600 | 600 | } |
601 | 601 | |
602 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
603 | - $format = isset( $attrs['format'] ) ? $attrs['format'] : get_option( 'date_format' ); |
|
604 | - $days_until_due = isset( $attrs['days_until_due'] ) ? (int) $attrs['days_until_due'] : 30; |
|
605 | - $prefix_text = isset( $attrs['prefix_text'] ) ? $attrs['prefix_text'] : __( 'Payment in full due by: ', 'event_espresso' ); |
|
606 | - $transaction_created = $transaction->get_DateTime_object( 'TXN_timestamp' ); |
|
602 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
603 | + $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format'); |
|
604 | + $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30; |
|
605 | + $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : __('Payment in full due by: ', 'event_espresso'); |
|
606 | + $transaction_created = $transaction->get_DateTime_object('TXN_timestamp'); |
|
607 | 607 | |
608 | 608 | //setup date due: |
609 | 609 | try { |
610 | - if ( $transaction_created instanceof DateTime ) { |
|
611 | - $date_due = $transaction_created->add( new DateInterval( 'P' . $days_until_due . 'D' ) )->format( $format ); |
|
610 | + if ($transaction_created instanceof DateTime) { |
|
611 | + $date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format); |
|
612 | 612 | } else { |
613 | 613 | throw new Exception(); |
614 | 614 | } |
615 | - } catch( Exception $e ) { |
|
615 | + } catch (Exception $e) { |
|
616 | 616 | //format was likely invalid. |
617 | 617 | $date_due = 'Unable to calculate date due, likely the format string is invalid.'; |
618 | 618 | } |
619 | 619 | |
620 | - return $prefix_text . $date_due; |
|
620 | + return $prefix_text.$date_due; |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | } //end EE_Transaction Shortcodes library |
@@ -3,14 +3,14 @@ discard block |
||
3 | 3 | * base class for all strategies which operate on form inputs. Generally, they |
4 | 4 | * all need to know about the form input they are operating on. |
5 | 5 | */ |
6 | -abstract class EE_Form_Input_Strategy_Base{ |
|
6 | +abstract class EE_Form_Input_Strategy_Base { |
|
7 | 7 | /** |
8 | 8 | * Form Input to display |
9 | 9 | * @var EE_Form_Input_Base |
10 | 10 | */ |
11 | 11 | protected $_input; |
12 | 12 | |
13 | - function __construct(){ |
|
13 | + function __construct() { |
|
14 | 14 | |
15 | 15 | } |
16 | 16 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * The form input on which this strategy is to perform |
19 | 19 | * @param EE_Form_Input_Base $form_input |
20 | 20 | */ |
21 | - function _construct_finalize(EE_Form_Input_Base $form_input){ |
|
21 | + function _construct_finalize(EE_Form_Input_Base $form_input) { |
|
22 | 22 | $this->_input = $form_input; |
23 | 23 | } |
24 | 24 |