Completed
Branch dev (e59588)
by
unknown
29:01 queued 21:36
created
messages/templates/ee_msg_editor_active_context_element.template.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@
 block discarded – undo
15 15
 use EventEspresso\core\services\request\sanitizers\AllowedTags;
16 16
 
17 17
 $active_message   = sprintf(
18
-    esc_html__(
19
-        'The template for %1$s is currently %2$sactive%3$s.',
20
-        'event_espresso'
21
-    ),
22
-    $context_label,
23
-    '<strong>',
24
-    '</strong>'
18
+	esc_html__(
19
+		'The template for %1$s is currently %2$sactive%3$s.',
20
+		'event_espresso'
21
+	),
22
+	$context_label,
23
+	'<strong>',
24
+	'</strong>'
25 25
 );
26 26
 $inactive_message = sprintf(
27
-    esc_html__(
28
-        'The template for %1$s is currently %2$sinactive%3$s.',
29
-        'event_espresso'
30
-    ),
31
-    $context_label,
32
-    '<strong>',
33
-    '</strong>'
27
+	esc_html__(
28
+		'The template for %1$s is currently %2$sinactive%3$s.',
29
+		'event_espresso'
30
+	),
31
+	$context_label,
32
+	'<strong>',
33
+	'</strong>'
34 34
 );
35 35
 
36 36
 $context = esc_attr($context);
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_1_0.dms.php 2 patches
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 // unfortunately, this needs to be done upon INCLUSION of this file,
12 12
 // instead of construction, because it only gets constructed on first page load
13 13
 // (all other times it gets resurrected from a wordpress option)
14
-$stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*');
14
+$stages = glob(EE_CORE.'data_migration_scripts/4_1_0_stages/*');
15 15
 $class_to_filepath = array();
16
-if (! empty($stages)) {
16
+if ( ! empty($stages)) {
17 17
     foreach ($stages as $filepath) {
18 18
         $matches = array();
19 19
         preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-        $class_to_filepath[ $matches[1] ] = $filepath;
20
+        $class_to_filepath[$matches[1]] = $filepath;
21 21
     }
22 22
 }
23 23
 // give addons a chance to autoload their stages too
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     private function _checkin_table_exists()
90 90
     {
91 91
         global $wpdb;
92
-        $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
92
+        $results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'");
93 93
         if ($results) {
94 94
             return true;
95 95
         } else {
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
         if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) {
106 106
 //          echo "$version_string can be migrated fro";
107 107
             return true;
108
-        } elseif (! $version_string) {
108
+        } elseif ( ! $version_string) {
109 109
 //          echo "no version string provided: $version_string";
110 110
             // no version string provided... this must be pre 4.1
111 111
             // because since 4.1 we're
112
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
112
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
113 113
         } else {
114 114
 //          echo "$version_string doesnt apply";
115 115
             return false;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     public function schema_changes_before_migration()
122 122
     {
123 123
         // relies on 4.1's EEH_Activation::create_table
124
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
124
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
125 125
         $table_name = 'esp_answer';
126 126
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
127 127
 					REG_ID int(10) unsigned NOT NULL,
@@ -505,12 +505,12 @@  discard block
 block discarded – undo
505 505
     public function insert_default_states()
506 506
     {
507 507
         global $wpdb;
508
-        $state_table = $wpdb->prefix . "esp_state";
508
+        $state_table = $wpdb->prefix."esp_state";
509 509
         if ($this->_get_table_analysis()->tableExists($state_table)) {
510
-            $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
510
+            $SQL = "SELECT COUNT('STA_ID') FROM ".$state_table;
511 511
             $states = $wpdb->get_var($SQL);
512
-            if (! $states) {
513
-                $SQL = "INSERT INTO " . $state_table . "
512
+            if ( ! $states) {
513
+                $SQL = "INSERT INTO ".$state_table."
514 514
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
515 515
 				(1, 'US', 'AK', 'Alaska', 1),
516 516
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -601,12 +601,12 @@  discard block
 block discarded – undo
601 601
     public function insert_default_countries()
602 602
     {
603 603
         global $wpdb;
604
-        $country_table = $wpdb->prefix . "esp_country";
604
+        $country_table = $wpdb->prefix."esp_country";
605 605
         if ($this->_get_table_analysis()->tableExists($country_table)) {
606
-            $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
606
+            $SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table;
607 607
             $countries = $wpdb->get_var($SQL);
608
-            if (! $countries) {
609
-                $SQL = "INSERT INTO " . $country_table . "
608
+            if ( ! $countries) {
609
+                $SQL = "INSERT INTO ".$country_table."
610 610
 				(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
611 611
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
612 612
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -851,17 +851,17 @@  discard block
 block discarded – undo
851 851
     public function insert_default_price_types()
852 852
     {
853 853
         global $wpdb;
854
-        $price_type_table = $wpdb->prefix . "esp_price_type";
854
+        $price_type_table = $wpdb->prefix."esp_price_type";
855 855
         if ($this->_get_table_analysis()->tableExists($price_type_table)) {
856
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
856
+            $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table;
857 857
             $price_types_exist = $wpdb->get_var($SQL);
858
-            if (! $price_types_exist) {
858
+            if ( ! $price_types_exist) {
859 859
                 $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
860
-							(1, '" . esc_html__('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
861
-							(2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
862
-							(3, '" . esc_html__('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
863
-							(4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
864
-							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
860
+							(1, '".esc_html__('Base Price', 'event_espresso')."', 1,  0, 0, 0),
861
+							(2, '" . esc_html__('Percent Discount', 'event_espresso')."', 2,  1, 20, 0),
862
+							(3, '" . esc_html__('Fixed Discount', 'event_espresso')."', 2,  0, 30, 0),
863
+							(4, '" . esc_html__('Percent Surcharge', 'event_espresso')."', 3,  1, 40, 0),
864
+							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso')."', 3,  0, 50, 0);";
865 865
                 $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
866 866
                 $wpdb->query($SQL);
867 867
             }
@@ -883,11 +883,11 @@  discard block
 block discarded – undo
883 883
     public function insert_default_prices()
884 884
     {
885 885
         global $wpdb;
886
-        $price_table = $wpdb->prefix . "esp_price";
886
+        $price_table = $wpdb->prefix."esp_price";
887 887
         if ($this->_get_table_analysis()->tableExists($price_table)) {
888
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
888
+            $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table;
889 889
             $prices_exist = $wpdb->get_var($SQL);
890
-            if (! $prices_exist) {
890
+            if ( ! $prices_exist) {
891 891
                 $SQL = "INSERT INTO $price_table
892 892
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES
893 893
 							(1, 1, '0.00', 'Admission', '', 1, null, 0, 0, 0);";
@@ -909,11 +909,11 @@  discard block
 block discarded – undo
909 909
     public function insert_default_tickets()
910 910
     {
911 911
         global $wpdb;
912
-        $ticket_table = $wpdb->prefix . "esp_ticket";
912
+        $ticket_table = $wpdb->prefix."esp_ticket";
913 913
         if ($this->_get_table_analysis()->tableExists($ticket_table)) {
914
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
914
+            $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
915 915
             $tickets_exist = $wpdb->get_var($SQL);
916
-            if (! $tickets_exist) {
916
+            if ( ! $tickets_exist) {
917 917
                 $SQL = "INSERT INTO $ticket_table
918 918
 					( 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
919 919
 					( 1, 0, '"
@@ -923,11 +923,11 @@  discard block
 block discarded – undo
923 923
                 $wpdb->query($SQL);
924 924
             }
925 925
         }
926
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
926
+        $ticket_price_table = $wpdb->prefix."esp_ticket_price";
927 927
         if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
928
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
928
+            $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
929 929
             $ticket_prc_exist = $wpdb->get_var($SQL);
930
-            if (! $ticket_prc_exist) {
930
+            if ( ! $ticket_prc_exist) {
931 931
                 $SQL = "INSERT INTO $ticket_price_table
932 932
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
933 933
 				( 1, 1, 1 )
@@ -951,11 +951,11 @@  discard block
 block discarded – undo
951 951
      */
952 952
     public function get_or_create_country($country_name)
953 953
     {
954
-        if (! $country_name) {
954
+        if ( ! $country_name) {
955 955
             throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
956 956
         }
957 957
         global $wpdb;
958
-        $country_table = $wpdb->prefix . "esp_country";
958
+        $country_table = $wpdb->prefix."esp_country";
959 959
         if (is_int($country_name)) {
960 960
             $country_name = $this->get_iso_from_3_1_country_id($country_name);
961 961
         }
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
 			CNT_ISO LIKE %s OR
964 964
 			CNT_ISO3 LIKE %s OR
965 965
 			CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A);
966
-        if (! $country) {
966
+        if ( ! $country) {
967 967
             // insert a new one then
968 968
             $cols_n_values = array(
969 969
                     'CNT_ISO'         => $this->_find_available_country_iso(2),
@@ -983,28 +983,28 @@  discard block
 block discarded – undo
983 983
                     'CNT_active'      => true,
984 984
             );
985 985
             $data_types = array(
986
-                    '%s',// CNT_ISO
987
-                    '%s',// CNT_ISO3
988
-                    '%d',// RGN_ID
989
-                    '%s',// CNT_name
990
-                    '%s',// CNT_cur_code
991
-                    '%s',// CNT_cur_single
992
-                    '%s',// CNT_cur_plural
993
-                    '%s',// CNT_cur_sign
994
-                    '%d',// CNT_cur_sign_b4
995
-                    '%d',// CNT_cur_dec_plc
996
-                    '%s',// CNT_cur_dec_mrk
997
-                    '%s',// CNT_cur_thsnds
998
-                    '%s',// CNT_tel_code
999
-                    '%d',// CNT_is_EU
1000
-                    '%d',// CNT_active
986
+                    '%s', // CNT_ISO
987
+                    '%s', // CNT_ISO3
988
+                    '%d', // RGN_ID
989
+                    '%s', // CNT_name
990
+                    '%s', // CNT_cur_code
991
+                    '%s', // CNT_cur_single
992
+                    '%s', // CNT_cur_plural
993
+                    '%s', // CNT_cur_sign
994
+                    '%d', // CNT_cur_sign_b4
995
+                    '%d', // CNT_cur_dec_plc
996
+                    '%s', // CNT_cur_dec_mrk
997
+                    '%s', // CNT_cur_thsnds
998
+                    '%s', // CNT_tel_code
999
+                    '%d', // CNT_is_EU
1000
+                    '%d', // CNT_active
1001 1001
             );
1002 1002
             $success = $wpdb->insert(
1003 1003
                 $country_table,
1004 1004
                 $cols_n_values,
1005 1005
                 $data_types
1006 1006
             );
1007
-            if (! $success) {
1007
+            if ( ! $success) {
1008 1008
                 throw new EE_Error($this->_create_error_message_for_db_insertion(
1009 1009
                     'N/A',
1010 1010
                     array('country_id' => $country_name),
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
     private function _find_available_country_iso($num_letters = 2)
1030 1030
     {
1031 1031
         global $wpdb;
1032
-        $country_table = $wpdb->prefix . "esp_country";
1032
+        $country_table = $wpdb->prefix."esp_country";
1033 1033
         $attempts = 0;
1034 1034
         do {
1035 1035
             $current_iso = strtoupper(wp_generate_password($num_letters, false));
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
             // keep going until we find an available country code, or we arbitrarily
1041 1041
             // decide we've tried this enough. Somehow they have way too many countries
1042 1042
             // (probably because they're mis-using the EE3 country_id like a custom question)
1043
-        } while (intval($country_with_that_iso) && $attempts < 200);
1043
+        }while (intval($country_with_that_iso) && $attempts < 200);
1044 1044
         return $current_iso;
1045 1045
     }
1046 1046
 
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
      */
1057 1057
     public function get_or_create_state($state_name, $country_name = '')
1058 1058
     {
1059
-        if (! $state_name) {
1059
+        if ( ! $state_name) {
1060 1060
             throw new EE_Error(esc_html__(
1061 1061
                 "Could not get-or-create state because no state name was provided",
1062 1062
                 "event_espresso"
@@ -1069,12 +1069,12 @@  discard block
 block discarded – undo
1069 1069
             $country_iso = $this->get_default_country_iso();
1070 1070
         }
1071 1071
         global $wpdb;
1072
-        $state_table = $wpdb->prefix . "esp_state";
1072
+        $state_table = $wpdb->prefix."esp_state";
1073 1073
         $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1074 1074
 			(STA_abbrev LIKE %s OR
1075 1075
 			STA_name LIKE %s) AND
1076 1076
 			CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A);
1077
-        if (! $state) {
1077
+        if ( ! $state) {
1078 1078
             // insert a new one then
1079 1079
             $cols_n_values = array(
1080 1080
                     'CNT_ISO'    => $country_iso,
@@ -1083,13 +1083,13 @@  discard block
 block discarded – undo
1083 1083
                     'STA_active' => true,
1084 1084
             );
1085 1085
             $data_types = array(
1086
-                    '%s',// CNT_ISO
1087
-                    '%s',// STA_abbrev
1088
-                    '%s',// STA_name
1089
-                    '%d',// STA_active
1086
+                    '%s', // CNT_ISO
1087
+                    '%s', // STA_abbrev
1088
+                    '%s', // STA_name
1089
+                    '%d', // STA_active
1090 1090
             );
1091 1091
             $success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1092
-            if (! $success) {
1092
+            if ( ! $success) {
1093 1093
                 throw new EE_Error($this->_create_error_message_for_db_insertion(
1094 1094
                     'N/A',
1095 1095
                     array('state' => $state_name, 'country_id' => $country_name),
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
     {
1119 1119
         $matches = array();
1120 1120
         preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1121
-        if (! $matches || count($matches) < 3) {
1121
+        if ( ! $matches || count($matches) < 3) {
1122 1122
             $hour = '00';
1123 1123
             $minutes = '00';
1124 1124
         } else {
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
                     'Declined'         => 'RPP',
1424 1424
             );
1425 1425
         }
1426
-        return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA';
1426
+        return isset($mapping[$payment_status]) ? $mapping[$payment_status] : 'RNA';
1427 1427
     }
1428 1428
 
1429 1429
 
@@ -1447,7 +1447,7 @@  discard block
 block discarded – undo
1447 1447
         if ($guid) {
1448 1448
             // check for an existing attachment post with this guid
1449 1449
             $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1450
-            if (! $attachment_post_id) {
1450
+            if ( ! $attachment_post_id) {
1451 1451
                 // post thumbnail with that GUID doesn't exist, we should create one
1452 1452
                 $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1453 1453
                 $created_attachment_post = true;
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
         $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1483 1483
         // do a head request to verify the file exists
1484 1484
         $head_response = wp_remote_head($original_guid);
1485
-        if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1485
+        if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1486 1486
             return $original_guid;
1487 1487
         } else {
1488 1488
             return $guid_in_old_event;
@@ -1502,7 +1502,7 @@  discard block
 block discarded – undo
1502 1502
      */
1503 1503
     private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1504 1504
     {
1505
-        if (! $guid) {
1505
+        if ( ! $guid) {
1506 1506
             $migration_stage->add_error(sprintf(esc_html__(
1507 1507
                 "Cannot create image attachment for a blank GUID!",
1508 1508
                 "event_espresso"
@@ -1514,7 +1514,7 @@  discard block
 block discarded – undo
1514 1514
         // if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1515 1515
         if (strpos($guid, $wp_upload_dir['url']) === false) {
1516 1516
             // image is located remotely. download it and place it in the uploads directory
1517
-            if (! is_readable($guid)) {
1517
+            if ( ! is_readable($guid)) {
1518 1518
                 $migration_stage->add_error(sprintf(esc_html__(
1519 1519
                     "Could not create image attachment from non-existent file: %s",
1520 1520
                     "event_espresso"
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
                 ), $guid));
1530 1530
                 return false;
1531 1531
             }
1532
-            $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid);
1532
+            $local_filepath = $wp_upload_dir['path'].'/'.basename($guid);
1533 1533
             $savefile = fopen($local_filepath, 'w');
1534 1534
             fwrite($savefile, $contents);
1535 1535
             fclose($savefile);
@@ -1545,7 +1545,7 @@  discard block
 block discarded – undo
1545 1545
                 'post_status'    => 'inherit',
1546 1546
         );
1547 1547
         $attach_id = wp_insert_attachment($attachment, $guid);
1548
-        if (! $attach_id) {
1548
+        if ( ! $attach_id) {
1549 1549
             $migration_stage->add_error(sprintf(esc_html__(
1550 1550
                 "Could not create image attachment post from image '%s'. Attachment data was %s.",
1551 1551
                 "event_espresso"
@@ -1554,9 +1554,9 @@  discard block
 block discarded – undo
1554 1554
         }
1555 1555
         // you must first include the image.php file
1556 1556
         // for the function wp_generate_attachment_metadata() to work
1557
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1557
+        require_once(ABSPATH.'wp-admin/includes/image.php');
1558 1558
         $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1559
-        if (! $attach_data) {
1559
+        if ( ! $attach_data) {
1560 1560
             $migration_stage->add_error(sprintf(esc_html__(
1561 1561
                 "Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1562 1562
                 "event_espresso"
@@ -1564,7 +1564,7 @@  discard block
 block discarded – undo
1564 1564
             return $attach_id;
1565 1565
         }
1566 1566
         $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1567
-        if (! $metadata_save_result) {
1567
+        if ( ! $metadata_save_result) {
1568 1568
             $migration_stage->add_error(sprintf(esc_html__(
1569 1569
                 "Could not update attachment metadata for attachment %d with data %s",
1570 1570
                 "event_espresso"
@@ -1610,10 +1610,10 @@  discard block
 block discarded – undo
1610 1610
         $timezone = null
1611 1611
     ) {
1612 1612
         $original_tz = $timezone;
1613
-        if (! $timezone) {
1613
+        if ( ! $timezone) {
1614 1614
             $timezone = $this->_get_wp_timezone();
1615 1615
         }
1616
-        if (! $timezone) {
1616
+        if ( ! $timezone) {
1617 1617
             $stage->add_error(sprintf(
1618 1618
                 esc_html__("Could not find timezone given %s for %s", "event_espresso"),
1619 1619
                 $original_tz,
@@ -1746,7 +1746,7 @@  discard block
 block discarded – undo
1746 1746
         );
1747 1747
         add_filter(
1748 1748
             'FHEE__ee_migration_page__migration_options_template',
1749
-            array($this,'use_migration_options_from_ee3_template')
1749
+            array($this, 'use_migration_options_from_ee3_template')
1750 1750
         );
1751 1751
     }
1752 1752
 
@@ -1812,6 +1812,6 @@  discard block
 block discarded – undo
1812 1812
      */
1813 1813
     public function use_migration_options_from_ee3_template($template_filepath)
1814 1814
     {
1815
-        return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1815
+        return EE_MAINTENANCE_TEMPLATE_PATH.'migration_options_from_ee3.template.php';
1816 1816
     }
1817 1817
 }
Please login to merge, or discard this patch.
Indentation   +1178 added lines, -1178 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 $stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*');
15 15
 $class_to_filepath = array();
16 16
 if (! empty($stages)) {
17
-    foreach ($stages as $filepath) {
18
-        $matches = array();
19
-        preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-        $class_to_filepath[ $matches[1] ] = $filepath;
21
-    }
17
+	foreach ($stages as $filepath) {
18
+		$matches = array();
19
+		preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
+		$class_to_filepath[ $matches[1] ] = $filepath;
21
+	}
22 22
 }
23 23
 // give addons a chance to autoload their stages too
24 24
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages', $class_to_filepath);
@@ -43,91 +43,91 @@  discard block
 block discarded – undo
43 43
  */
44 44
 class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base
45 45
 {
46
-    /**
47
-     * EE_DMS_Core_4_1_0 constructor.
48
-     *
49
-     * @param TableManager  $table_manager
50
-     * @param TableAnalysis $table_analysis
51
-     */
52
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
53
-    {
54
-        $this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso");
55
-        $this->_priority = 10;
56
-        $this->_migration_stages = array(
57
-                new EE_DMS_4_1_0_org_options(),
58
-                new EE_DMS_4_1_0_shortcodes(),
59
-                new EE_DMS_4_1_0_gateways(),
60
-                new EE_DMS_4_1_0_events(),
61
-                new EE_DMS_4_1_0_prices(),
62
-                new EE_DMS_4_1_0_category_details(),
63
-                new EE_DMS_4_1_0_event_category(),
64
-                new EE_DMS_4_1_0_venues(),
65
-                new EE_DMS_4_1_0_event_venue(),
66
-                new EE_DMS_4_1_0_question_groups(),
67
-                new EE_DMS_4_1_0_questions(),
68
-                new EE_DMS_4_1_0_question_group_question(),
69
-                new EE_DMS_4_1_0_event_question_group(),
70
-                new EE_DMS_4_1_0_attendees(),
71
-                new EE_DMS_4_1_0_line_items(),
72
-                new EE_DMS_4_1_0_answers(),
73
-                new EE_DMS_4_1_0_checkins(),
74
-        );
75
-        parent::__construct($table_manager, $table_analysis);
76
-    }
77
-
78
-
79
-
80
-    /**
81
-     * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
82
-     *
83
-     * @global wpdb $wpdb
84
-     * @return boolean
85
-     */
86
-    private function _checkin_table_exists()
87
-    {
88
-        global $wpdb;
89
-        $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
90
-        if ($results) {
91
-            return true;
92
-        } else {
93
-            return false;
94
-        }
95
-    }
96
-
97
-
98
-
99
-    public function can_migrate_from_version($version_array)
100
-    {
101
-        $version_string = $version_array['Core'];
102
-        if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) {
46
+	/**
47
+	 * EE_DMS_Core_4_1_0 constructor.
48
+	 *
49
+	 * @param TableManager  $table_manager
50
+	 * @param TableAnalysis $table_analysis
51
+	 */
52
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
53
+	{
54
+		$this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso");
55
+		$this->_priority = 10;
56
+		$this->_migration_stages = array(
57
+				new EE_DMS_4_1_0_org_options(),
58
+				new EE_DMS_4_1_0_shortcodes(),
59
+				new EE_DMS_4_1_0_gateways(),
60
+				new EE_DMS_4_1_0_events(),
61
+				new EE_DMS_4_1_0_prices(),
62
+				new EE_DMS_4_1_0_category_details(),
63
+				new EE_DMS_4_1_0_event_category(),
64
+				new EE_DMS_4_1_0_venues(),
65
+				new EE_DMS_4_1_0_event_venue(),
66
+				new EE_DMS_4_1_0_question_groups(),
67
+				new EE_DMS_4_1_0_questions(),
68
+				new EE_DMS_4_1_0_question_group_question(),
69
+				new EE_DMS_4_1_0_event_question_group(),
70
+				new EE_DMS_4_1_0_attendees(),
71
+				new EE_DMS_4_1_0_line_items(),
72
+				new EE_DMS_4_1_0_answers(),
73
+				new EE_DMS_4_1_0_checkins(),
74
+		);
75
+		parent::__construct($table_manager, $table_analysis);
76
+	}
77
+
78
+
79
+
80
+	/**
81
+	 * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
82
+	 *
83
+	 * @global wpdb $wpdb
84
+	 * @return boolean
85
+	 */
86
+	private function _checkin_table_exists()
87
+	{
88
+		global $wpdb;
89
+		$results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
90
+		if ($results) {
91
+			return true;
92
+		} else {
93
+			return false;
94
+		}
95
+	}
96
+
97
+
98
+
99
+	public function can_migrate_from_version($version_array)
100
+	{
101
+		$version_string = $version_array['Core'];
102
+		if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) {
103 103
 //          echo "$version_string can be migrated fro";
104
-            return true;
105
-        } elseif (! $version_string) {
104
+			return true;
105
+		} elseif (! $version_string) {
106 106
 //          echo "no version string provided: $version_string";
107
-            // no version string provided... this must be pre 4.1
108
-            // because since 4.1 we're
109
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
110
-        } else {
107
+			// no version string provided... this must be pre 4.1
108
+			// because since 4.1 we're
109
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
110
+		} else {
111 111
 //          echo "$version_string doesnt apply";
112
-            return false;
113
-        }
114
-    }
112
+			return false;
113
+		}
114
+	}
115 115
 
116 116
 
117 117
 
118
-    public function schema_changes_before_migration()
119
-    {
120
-        // relies on 4.1's EEH_Activation::create_table
121
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
122
-        $table_name = 'esp_answer';
123
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
118
+	public function schema_changes_before_migration()
119
+	{
120
+		// relies on 4.1's EEH_Activation::create_table
121
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
122
+		$table_name = 'esp_answer';
123
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
124 124
 					REG_ID int(10) unsigned NOT NULL,
125 125
 					QST_ID int(10) unsigned NOT NULL,
126 126
 					ANS_value text NOT NULL,
127 127
 					PRIMARY KEY  (ANS_ID)";
128
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
129
-        $table_name = 'esp_attendee_meta';
130
-        $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
128
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
129
+		$table_name = 'esp_attendee_meta';
130
+		$sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
131 131
 						ATT_ID bigint(20) unsigned NOT NULL,
132 132
 						ATT_fname varchar(45) NOT NULL,
133 133
 						ATT_lname varchar(45) NOT NULL,
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 								KEY ATT_fname (ATT_fname),
144 144
 								KEY ATT_lname (ATT_lname),
145 145
 								KEY ATT_email (ATT_email(191))";
146
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
147
-        $table_name = 'esp_country';
148
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
146
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
147
+		$table_name = 'esp_country';
148
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
149 149
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
150 150
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
151 151
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 					  CNT_is_EU tinyint(1) DEFAULT '0',
162 162
 					  CNT_active tinyint(1) DEFAULT '0',
163 163
 					  PRIMARY KEY  (CNT_ISO)";
164
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
165
-        $table_name = 'esp_datetime';
166
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
164
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
165
+		$table_name = 'esp_datetime';
166
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
167 167
 				  EVT_ID bigint(20) unsigned NOT NULL,
168 168
 				  DTT_EVT_start datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
169 169
 				  DTT_EVT_end datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 						PRIMARY KEY  (DTT_ID),
177 177
 						KEY EVT_ID (EVT_ID),
178 178
 						KEY DTT_is_primary (DTT_is_primary)";
179
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
180
-        $table_name = 'esp_event_meta';
181
-        $sql = "
179
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
180
+		$table_name = 'esp_event_meta';
181
+		$sql = "
182 182
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
183 183
 			EVT_ID bigint(20) unsigned NOT NULL,
184 184
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -193,31 +193,31 @@  discard block
 block discarded – undo
193 193
 			EVT_external_URL varchar(200) NULL,
194 194
 			EVT_donations tinyint(1) NULL,
195 195
 			PRIMARY KEY  (EVTM_ID)";
196
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
197
-        $table_name = 'esp_event_question_group';
198
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
196
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
197
+		$table_name = 'esp_event_question_group';
198
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
199 199
 					EVT_ID bigint(20) unsigned NOT NULL,
200 200
 					QSG_ID int(10) unsigned NOT NULL,
201 201
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
202 202
 					PRIMARY KEY  (EQG_ID)";
203
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
204
-        $table_name = 'esp_event_venue';
205
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
203
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
204
+		$table_name = 'esp_event_venue';
205
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
206 206
 				EVT_ID bigint(20) unsigned NOT NULL,
207 207
 				VNU_ID bigint(20) unsigned NOT NULL,
208 208
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
209 209
 				PRIMARY KEY  (EVV_ID)";
210
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
211
-        $table_name = 'esp_extra_meta';
212
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
210
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
211
+		$table_name = 'esp_extra_meta';
212
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
213 213
 				OBJ_ID int(11) DEFAULT NULL,
214 214
 				EXM_type varchar(45) DEFAULT NULL,
215 215
 				EXM_key varchar(45) DEFAULT NULL,
216 216
 				EXM_value text,
217 217
 				PRIMARY KEY  (EXM_ID)";
218
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
219
-        $table_name = 'esp_line_item';
220
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
218
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
219
+		$table_name = 'esp_line_item';
220
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
221 221
 				LIN_code varchar(245) NOT NULL DEFAULT '',
222 222
 				TXN_ID int(11) DEFAULT NULL,
223 223
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -233,18 +233,18 @@  discard block
 block discarded – undo
233 233
 				OBJ_ID int(11) DEFAULT NULL,
234 234
 				OBJ_type varchar(45)DEFAULT NULL,
235 235
 				PRIMARY KEY  (LIN_ID)";
236
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
237
-        $table_name = 'esp_message_template';
238
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
236
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
237
+		$table_name = 'esp_message_template';
238
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
239 239
 					GRP_ID int(10) unsigned NOT NULL,
240 240
 					MTP_context varchar(50) NOT NULL,
241 241
 					MTP_template_field varchar(30) NOT NULL,
242 242
 					MTP_content text NOT NULL,
243 243
 					PRIMARY KEY  (MTP_ID),
244 244
 					KEY GRP_ID (GRP_ID)";
245
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
246
-        $table_name = 'esp_message_template_group';
247
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
245
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
246
+		$table_name = 'esp_message_template_group';
247
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
248 248
 					EVT_ID bigint(20) unsigned DEFAULT NULL,
249 249
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
250 250
 					MTP_messenger varchar(30) NOT NULL,
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 					PRIMARY KEY  (GRP_ID),
257 257
 					KEY EVT_ID (EVT_ID),
258 258
 					KEY MTP_user_id (MTP_user_id)";
259
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
260
-        $table_name = 'esp_payment';
261
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
259
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
260
+		$table_name = 'esp_payment';
261
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
262 262
 					TXN_ID int(10) unsigned DEFAULT NULL,
263 263
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
264 264
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 					PRIMARY KEY  (PAY_ID),
275 275
 					KEY TXN_ID (TXN_ID),
276 276
 					KEY PAY_timestamp (PAY_timestamp)";
277
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
278
-        $table_name = "esp_ticket";
279
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
277
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
278
+		$table_name = "esp_ticket";
279
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
280 280
 					  TTM_ID int(10) unsigned NOT NULL,
281 281
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
282 282
 					  TKT_description text NOT NULL,
@@ -295,28 +295,28 @@  discard block
 block discarded – undo
295 295
 					  TKT_parent int(10) unsigned DEFAULT '0',
296 296
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
297 297
 					  PRIMARY KEY  (TKT_ID)";
298
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
299
-        $table_name = "esp_ticket_price";
300
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
298
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
299
+		$table_name = "esp_ticket_price";
300
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
301 301
 					  TKT_ID int(10) unsigned NOT NULL,
302 302
 					  PRC_ID int(10) unsigned NOT NULL,
303 303
 					  PRIMARY KEY  (TKP_ID)";
304
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
305
-        $table_name = "esp_datetime_ticket";
306
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
304
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
305
+		$table_name = "esp_datetime_ticket";
306
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
307 307
 					  DTT_ID int(10) unsigned NOT NULL,
308 308
 					  TKT_ID int(10) unsigned NOT NULL,
309 309
 					  PRIMARY KEY  (DTK_ID)";
310
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
311
-        $table_name = "esp_ticket_template";
312
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
310
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
311
+		$table_name = "esp_ticket_template";
312
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
313 313
 					  TTM_name varchar(45) NOT NULL,
314 314
 					  TTM_description text,
315 315
 					  TTM_file varchar(45),
316 316
 					  PRIMARY KEY  (TTM_ID)";
317
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
318
-        $table_name = "esp_price";
319
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
317
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
318
+		$table_name = "esp_price";
319
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
320 320
 					  PRT_ID tinyint(3) unsigned NOT NULL,
321 321
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
322 322
 					  PRC_name varchar(245) NOT NULL,
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 					  PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0',
328 328
 					  PRC_parent int(10) unsigned DEFAULT 0,
329 329
 					  PRIMARY KEY  (PRC_ID)";
330
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
331
-        $table_name = "esp_price_type";
332
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
330
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
331
+		$table_name = "esp_price_type";
332
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
333 333
 				  PRT_name varchar(45) NOT NULL,
334 334
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
335 335
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -337,9 +337,9 @@  discard block
 block discarded – undo
337 337
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
338 338
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
339 339
 				  PRIMARY KEY  (PRT_ID)";
340
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
341
-        $table_name = 'esp_question';
342
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
340
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
341
+		$table_name = 'esp_question';
342
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
343 343
 					QST_display_text text NOT NULL,
344 344
 					QST_admin_label varchar(255) NOT NULL,
345 345
 					QST_system varchar(25) DEFAULT NULL,
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
 					QST_wp_user bigint(20) unsigned NULL,
352 352
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
353 353
 					PRIMARY KEY  (QST_ID)';
354
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
355
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
356
-        $table_name = 'esp_question_group';
357
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
354
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
355
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
356
+		$table_name = 'esp_question_group';
357
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
358 358
 					QSG_name varchar(255) NOT NULL,
359 359
 					QSG_identifier varchar(100) NOT NULL,
360 360
 					QSG_desc text NULL,
@@ -365,23 +365,23 @@  discard block
 block discarded – undo
365 365
 					QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
366 366
 					PRIMARY KEY  (QSG_ID),
367 367
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
368
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
369
-        $table_name = 'esp_question_group_question';
370
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
368
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
369
+		$table_name = 'esp_question_group_question';
370
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
371 371
 					QSG_ID int(10) unsigned NOT NULL,
372 372
 					QST_ID int(10) unsigned NOT NULL,
373 373
 					PRIMARY KEY  (QGQ_ID) ";
374
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
375
-        $table_name = 'esp_question_option';
376
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
374
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
375
+		$table_name = 'esp_question_option';
376
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
377 377
 					QSO_value varchar(255) NOT NULL,
378 378
 					QSO_desc text NOT NULL,
379 379
 					QST_ID int(10) unsigned NOT NULL,
380 380
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
381 381
 					PRIMARY KEY  (QSO_ID)";
382
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
383
-        $table_name = 'esp_registration';
384
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
382
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
383
+		$table_name = 'esp_registration';
384
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
385 385
 					  EVT_ID bigint(20) unsigned NOT NULL,
386 386
 					  ATT_ID bigint(20) unsigned NOT NULL,
387 387
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -404,25 +404,25 @@  discard block
 block discarded – undo
404 404
 					  KEY STS_ID (STS_ID),
405 405
 					  KEY REG_url_link (REG_url_link),
406 406
 					  KEY REG_code (REG_code)";
407
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
408
-        $table_name = 'esp_checkin';
409
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
407
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
408
+		$table_name = 'esp_checkin';
409
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
410 410
 					REG_ID int(10) unsigned NOT NULL,
411 411
 					DTT_ID int(10) unsigned NOT NULL,
412 412
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
413 413
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
414 414
 					PRIMARY KEY  (CHK_ID)";
415
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
416
-        $table_name = 'esp_state';
417
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
415
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
416
+		$table_name = 'esp_state';
417
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
418 418
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
419 419
 					  STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL,
420 420
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
421 421
 					  STA_active tinyint(1) DEFAULT '1',
422 422
 					  PRIMARY KEY  (STA_ID)";
423
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
424
-        $table_name = 'esp_status';
425
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
423
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
424
+		$table_name = 'esp_status';
425
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
426 426
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
427 427
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
428 428
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
431 431
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
432 432
 					  KEY STS_type (STS_type)";
433
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
434
-        $table_name = 'esp_transaction';
435
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
433
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
434
+		$table_name = 'esp_transaction';
435
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
436 436
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
437 437
 					  TXN_total decimal(10,3) DEFAULT '0.00',
438 438
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 					  PRIMARY KEY  (TXN_ID),
443 443
 					  KEY TXN_timestamp (TXN_timestamp),
444 444
 					  KEY STS_ID (STS_ID)";
445
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
446
-        $table_name = 'esp_venue_meta';
447
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
445
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
446
+		$table_name = 'esp_venue_meta';
447
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
448 448
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
449 449
 			VNU_address varchar(255) DEFAULT NULL,
450 450
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -462,52 +462,52 @@  discard block
 block discarded – undo
462 462
 			PRIMARY KEY  (VNUM_ID),
463 463
 			KEY STA_ID (STA_ID),
464 464
 			KEY CNT_ISO (CNT_ISO)";
465
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
466
-        // setting up the default stats and countries is also essential for the data migrations to run
467
-        // (because many need to convert old string states to foreign keys into the states table)
468
-        $this->insert_default_states();
469
-        $this->insert_default_countries();
470
-        // setting up default prices, price types, and tickets is also essential for the price migrations
471
-        $this->insert_default_price_types();
472
-        $this->insert_default_prices();
473
-        $this->insert_default_tickets();
474
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
475
-        EE_Config::instance()->update_espresso_config(false, true);
476
-        return true;
477
-    }
478
-
479
-
480
-
481
-    /**
482
-     * Yes we could have cleaned up the ee3 tables here. But just in case someone
483
-     * didn't backup their DB, and decides they want ot keep using EE3, we'll
484
-     * leave them for now. Mayeb remove them in 4.5 or something.
485
-     *
486
-     * @return boolean
487
-     */
488
-    public function schema_changes_after_migration()
489
-    {
490
-        return true;
491
-    }
492
-
493
-
494
-
495
-    /**
496
-     * insert_default_states
497
-     *
498
-     * @access public
499
-     * @static
500
-     * @return void
501
-     */
502
-    public function insert_default_states()
503
-    {
504
-        global $wpdb;
505
-        $state_table = $wpdb->prefix . "esp_state";
506
-        if ($this->_get_table_analysis()->tableExists($state_table)) {
507
-            $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
508
-            $states = $wpdb->get_var($SQL);
509
-            if (! $states) {
510
-                $SQL = "INSERT INTO " . $state_table . "
465
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
466
+		// setting up the default stats and countries is also essential for the data migrations to run
467
+		// (because many need to convert old string states to foreign keys into the states table)
468
+		$this->insert_default_states();
469
+		$this->insert_default_countries();
470
+		// setting up default prices, price types, and tickets is also essential for the price migrations
471
+		$this->insert_default_price_types();
472
+		$this->insert_default_prices();
473
+		$this->insert_default_tickets();
474
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
475
+		EE_Config::instance()->update_espresso_config(false, true);
476
+		return true;
477
+	}
478
+
479
+
480
+
481
+	/**
482
+	 * Yes we could have cleaned up the ee3 tables here. But just in case someone
483
+	 * didn't backup their DB, and decides they want ot keep using EE3, we'll
484
+	 * leave them for now. Mayeb remove them in 4.5 or something.
485
+	 *
486
+	 * @return boolean
487
+	 */
488
+	public function schema_changes_after_migration()
489
+	{
490
+		return true;
491
+	}
492
+
493
+
494
+
495
+	/**
496
+	 * insert_default_states
497
+	 *
498
+	 * @access public
499
+	 * @static
500
+	 * @return void
501
+	 */
502
+	public function insert_default_states()
503
+	{
504
+		global $wpdb;
505
+		$state_table = $wpdb->prefix . "esp_state";
506
+		if ($this->_get_table_analysis()->tableExists($state_table)) {
507
+			$SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
508
+			$states = $wpdb->get_var($SQL);
509
+			if (! $states) {
510
+				$SQL = "INSERT INTO " . $state_table . "
511 511
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
512 512
 				(1, 'US', 'AK', 'Alaska', 1),
513 513
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -581,29 +581,29 @@  discard block
 block discarded – undo
581 581
 				(70, 'CA', 'NT', 'Northwest Territories', 1),
582 582
 				(71, 'CA', 'NU', 'Nunavut', 1),
583 583
 				(72, 'CA', 'YT', 'Yukon', 1);";
584
-                $wpdb->query($SQL);
585
-            }
586
-        }
587
-    }
588
-
589
-
590
-
591
-    /**
592
-     * insert_default_countries
593
-     *
594
-     * @access public
595
-     * @static
596
-     * @return void
597
-     */
598
-    public function insert_default_countries()
599
-    {
600
-        global $wpdb;
601
-        $country_table = $wpdb->prefix . "esp_country";
602
-        if ($this->_get_table_analysis()->tableExists($country_table)) {
603
-            $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
604
-            $countries = $wpdb->get_var($SQL);
605
-            if (! $countries) {
606
-                $SQL = "INSERT INTO " . $country_table . "
584
+				$wpdb->query($SQL);
585
+			}
586
+		}
587
+	}
588
+
589
+
590
+
591
+	/**
592
+	 * insert_default_countries
593
+	 *
594
+	 * @access public
595
+	 * @static
596
+	 * @return void
597
+	 */
598
+	public function insert_default_countries()
599
+	{
600
+		global $wpdb;
601
+		$country_table = $wpdb->prefix . "esp_country";
602
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
603
+			$SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
604
+			$countries = $wpdb->get_var($SQL);
605
+			if (! $countries) {
606
+				$SQL = "INSERT INTO " . $country_table . "
607 607
 				(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
608 608
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
609 609
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -831,984 +831,984 @@  discard block
 block discarded – undo
831 831
 				('ZA', 'ZAF', 0, 'South Africa', 'ZAR', 'Rand', 'Rands', 'R', 1, 2, '+27', 0, 0),
832 832
 				('ZM', 'ZMB', 0, 'Zambia', 'ZMK', 'Kwacha', 'Kwachas', '', 1, 2, '+260', 0, 0),
833 833
 				('ZW', 'ZWE', 0, 'Zimbabwe', 'ZWD', 'Dollar', 'Dollars', 'Z$', 1, 2, '+263', 0, 0);";
834
-                $wpdb->query($SQL);
835
-            }
836
-        }
837
-    }
838
-
839
-
840
-
841
-    /**
842
-     * insert_default_price_types
843
-     *
844
-     * @access public
845
-     * @static
846
-     * @return void
847
-     */
848
-    public function insert_default_price_types()
849
-    {
850
-        global $wpdb;
851
-        $price_type_table = $wpdb->prefix . "esp_price_type";
852
-        if ($this->_get_table_analysis()->tableExists($price_type_table)) {
853
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
854
-            $price_types_exist = $wpdb->get_var($SQL);
855
-            if (! $price_types_exist) {
856
-                $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
834
+				$wpdb->query($SQL);
835
+			}
836
+		}
837
+	}
838
+
839
+
840
+
841
+	/**
842
+	 * insert_default_price_types
843
+	 *
844
+	 * @access public
845
+	 * @static
846
+	 * @return void
847
+	 */
848
+	public function insert_default_price_types()
849
+	{
850
+		global $wpdb;
851
+		$price_type_table = $wpdb->prefix . "esp_price_type";
852
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
853
+			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
854
+			$price_types_exist = $wpdb->get_var($SQL);
855
+			if (! $price_types_exist) {
856
+				$SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
857 857
 							(1, '" . esc_html__('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
858 858
 							(2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
859 859
 							(3, '" . esc_html__('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
860 860
 							(4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
861 861
 							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
862
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
863
-                $wpdb->query($SQL);
864
-            }
865
-        }
866
-    }
867
-
868
-
869
-
870
-    /**
871
-     * insert_default_prices. We assume we're upgrading to regular here.
872
-     * If we're INSTALLING 4.1 CAF, then we add a few extra default prices
873
-     * when EEH_Activaion's initialize_db_content is called via  ahook in
874
-     * EE_BRewing_regular
875
-     *
876
-     * @access public
877
-     * @static
878
-     * @return void
879
-     */
880
-    public function insert_default_prices()
881
-    {
882
-        global $wpdb;
883
-        $price_table = $wpdb->prefix . "esp_price";
884
-        if ($this->_get_table_analysis()->tableExists($price_table)) {
885
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
886
-            $prices_exist = $wpdb->get_var($SQL);
887
-            if (! $prices_exist) {
888
-                $SQL = "INSERT INTO $price_table
862
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
863
+				$wpdb->query($SQL);
864
+			}
865
+		}
866
+	}
867
+
868
+
869
+
870
+	/**
871
+	 * insert_default_prices. We assume we're upgrading to regular here.
872
+	 * If we're INSTALLING 4.1 CAF, then we add a few extra default prices
873
+	 * when EEH_Activaion's initialize_db_content is called via  ahook in
874
+	 * EE_BRewing_regular
875
+	 *
876
+	 * @access public
877
+	 * @static
878
+	 * @return void
879
+	 */
880
+	public function insert_default_prices()
881
+	{
882
+		global $wpdb;
883
+		$price_table = $wpdb->prefix . "esp_price";
884
+		if ($this->_get_table_analysis()->tableExists($price_table)) {
885
+			$SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
886
+			$prices_exist = $wpdb->get_var($SQL);
887
+			if (! $prices_exist) {
888
+				$SQL = "INSERT INTO $price_table
889 889
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES
890 890
 							(1, 1, '0.00', 'Admission', '', 1, null, 0, 0, 0);";
891
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
892
-                $wpdb->query($SQL);
893
-            }
894
-        }
895
-    }
896
-
897
-
898
-
899
-    /**
900
-     * insert default ticket
901
-     *
902
-     * @access public
903
-     * @static
904
-     * @return void
905
-     */
906
-    public function insert_default_tickets()
907
-    {
908
-        global $wpdb;
909
-        $ticket_table = $wpdb->prefix . "esp_ticket";
910
-        if ($this->_get_table_analysis()->tableExists($ticket_table)) {
911
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
912
-            $tickets_exist = $wpdb->get_var($SQL);
913
-            if (! $tickets_exist) {
914
-                $SQL = "INSERT INTO $ticket_table
891
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
892
+				$wpdb->query($SQL);
893
+			}
894
+		}
895
+	}
896
+
897
+
898
+
899
+	/**
900
+	 * insert default ticket
901
+	 *
902
+	 * @access public
903
+	 * @static
904
+	 * @return void
905
+	 */
906
+	public function insert_default_tickets()
907
+	{
908
+		global $wpdb;
909
+		$ticket_table = $wpdb->prefix . "esp_ticket";
910
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
911
+			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
912
+			$tickets_exist = $wpdb->get_var($SQL);
913
+			if (! $tickets_exist) {
914
+				$SQL = "INSERT INTO $ticket_table
915 915
 					( 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
916 916
 					( 1, 0, '"
917
-                       . esc_html__("Free Ticket", "event_espresso")
918
-                       . "', '', 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);";
919
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
920
-                $wpdb->query($SQL);
921
-            }
922
-        }
923
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
924
-        if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
925
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
926
-            $ticket_prc_exist = $wpdb->get_var($SQL);
927
-            if (! $ticket_prc_exist) {
928
-                $SQL = "INSERT INTO $ticket_price_table
917
+					   . esc_html__("Free Ticket", "event_espresso")
918
+					   . "', '', 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);";
919
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
920
+				$wpdb->query($SQL);
921
+			}
922
+		}
923
+		$ticket_price_table = $wpdb->prefix . "esp_ticket_price";
924
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
925
+			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
926
+			$ticket_prc_exist = $wpdb->get_var($SQL);
927
+			if (! $ticket_prc_exist) {
928
+				$SQL = "INSERT INTO $ticket_price_table
929 929
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
930 930
 				( 1, 1, 1 )
931 931
 				";
932
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
933
-                $wpdb->query($SQL);
934
-            }
935
-        }
936
-    }
937
-
938
-
939
-
940
-    /**
941
-     * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(),
942
-     * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1
943
-     * country ID (int), a 2-letter ISO, 3-letter ISO, or name
944
-     *
945
-     * @global type  $wpdb
946
-     * @param string $country_name
947
-     * @return array where keys are columns, values are column values
948
-     */
949
-    public function get_or_create_country($country_name)
950
-    {
951
-        if (! $country_name) {
952
-            throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
953
-        }
954
-        global $wpdb;
955
-        $country_table = $wpdb->prefix . "esp_country";
956
-        if (is_int($country_name)) {
957
-            $country_name = $this->get_iso_from_3_1_country_id($country_name);
958
-        }
959
-        $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
932
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
933
+				$wpdb->query($SQL);
934
+			}
935
+		}
936
+	}
937
+
938
+
939
+
940
+	/**
941
+	 * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(),
942
+	 * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1
943
+	 * country ID (int), a 2-letter ISO, 3-letter ISO, or name
944
+	 *
945
+	 * @global type  $wpdb
946
+	 * @param string $country_name
947
+	 * @return array where keys are columns, values are column values
948
+	 */
949
+	public function get_or_create_country($country_name)
950
+	{
951
+		if (! $country_name) {
952
+			throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
953
+		}
954
+		global $wpdb;
955
+		$country_table = $wpdb->prefix . "esp_country";
956
+		if (is_int($country_name)) {
957
+			$country_name = $this->get_iso_from_3_1_country_id($country_name);
958
+		}
959
+		$country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
960 960
 			CNT_ISO LIKE %s OR
961 961
 			CNT_ISO3 LIKE %s OR
962 962
 			CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A);
963
-        if (! $country) {
964
-            // insert a new one then
965
-            $cols_n_values = array(
966
-                    'CNT_ISO'         => $this->_find_available_country_iso(2),
967
-                    'CNT_ISO3'        => $this->_find_available_country_iso(3),
968
-                    'RGN_ID'          => 0,
969
-                    'CNT_name'        => $country_name,
970
-                    'CNT_cur_code'    => 'USD',
971
-                    'CNT_cur_single'  => 'Dollar',
972
-                    'CNT_cur_plural'  => 'Dollars',
973
-                    'CNT_cur_sign'    => '&#36;',
974
-                    'CNT_cur_sign_b4' => true,
975
-                    'CNT_cur_dec_plc' => 2,
976
-                    'CNT_cur_dec_mrk' => '.',
977
-                    'CNT_cur_thsnds'  => ',',
978
-                    'CNT_tel_code'    => '+1',
979
-                    'CNT_is_EU'       => false,
980
-                    'CNT_active'      => true,
981
-            );
982
-            $data_types = array(
983
-                    '%s',// CNT_ISO
984
-                    '%s',// CNT_ISO3
985
-                    '%d',// RGN_ID
986
-                    '%s',// CNT_name
987
-                    '%s',// CNT_cur_code
988
-                    '%s',// CNT_cur_single
989
-                    '%s',// CNT_cur_plural
990
-                    '%s',// CNT_cur_sign
991
-                    '%d',// CNT_cur_sign_b4
992
-                    '%d',// CNT_cur_dec_plc
993
-                    '%s',// CNT_cur_dec_mrk
994
-                    '%s',// CNT_cur_thsnds
995
-                    '%s',// CNT_tel_code
996
-                    '%d',// CNT_is_EU
997
-                    '%d',// CNT_active
998
-            );
999
-            $success = $wpdb->insert(
1000
-                $country_table,
1001
-                $cols_n_values,
1002
-                $data_types
1003
-            );
1004
-            if (! $success) {
1005
-                throw new EE_Error($this->_create_error_message_for_db_insertion(
1006
-                    'N/A',
1007
-                    array('country_id' => $country_name),
1008
-                    $country_table,
1009
-                    $cols_n_values,
1010
-                    $data_types
1011
-                ));
1012
-            }
1013
-            $country = $cols_n_values;
1014
-        }
1015
-        return $country;
1016
-    }
1017
-
1018
-
1019
-
1020
-    /**
1021
-     * finds a country iso which hasnt been used yet
1022
-     *
1023
-     * @global type $wpdb
1024
-     * @return string
1025
-     */
1026
-    private function _find_available_country_iso($num_letters = 2)
1027
-    {
1028
-        global $wpdb;
1029
-        $country_table = $wpdb->prefix . "esp_country";
1030
-        $attempts = 0;
1031
-        do {
1032
-            $current_iso = strtoupper(wp_generate_password($num_letters, false));
1033
-            $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM "
1034
-                                                                   . $country_table
1035
-                                                                   . " WHERE CNT_ISO=%s", $current_iso));
1036
-            $attempts++;
1037
-            // keep going until we find an available country code, or we arbitrarily
1038
-            // decide we've tried this enough. Somehow they have way too many countries
1039
-            // (probably because they're mis-using the EE3 country_id like a custom question)
1040
-        } while (intval($country_with_that_iso) && $attempts < 200);
1041
-        return $current_iso;
1042
-    }
1043
-
1044
-
1045
-
1046
-    /**
1047
-     * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but
1048
-     * is independent of outside code which can change in future versions of EE
1049
-     *
1050
-     * @global type  $wpdb
1051
-     * @param string $state_name
1052
-     * @return array where keys are columns, values are column values
1053
-     */
1054
-    public function get_or_create_state($state_name, $country_name = '')
1055
-    {
1056
-        if (! $state_name) {
1057
-            throw new EE_Error(esc_html__(
1058
-                "Could not get-or-create state because no state name was provided",
1059
-                "event_espresso"
1060
-            ));
1061
-        }
1062
-        try {
1063
-            $country = $this->get_or_create_country($country_name);
1064
-            $country_iso = $country['CNT_ISO'];
1065
-        } catch (EE_Error $e) {
1066
-            $country_iso = $this->get_default_country_iso();
1067
-        }
1068
-        global $wpdb;
1069
-        $state_table = $wpdb->prefix . "esp_state";
1070
-        $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
963
+		if (! $country) {
964
+			// insert a new one then
965
+			$cols_n_values = array(
966
+					'CNT_ISO'         => $this->_find_available_country_iso(2),
967
+					'CNT_ISO3'        => $this->_find_available_country_iso(3),
968
+					'RGN_ID'          => 0,
969
+					'CNT_name'        => $country_name,
970
+					'CNT_cur_code'    => 'USD',
971
+					'CNT_cur_single'  => 'Dollar',
972
+					'CNT_cur_plural'  => 'Dollars',
973
+					'CNT_cur_sign'    => '&#36;',
974
+					'CNT_cur_sign_b4' => true,
975
+					'CNT_cur_dec_plc' => 2,
976
+					'CNT_cur_dec_mrk' => '.',
977
+					'CNT_cur_thsnds'  => ',',
978
+					'CNT_tel_code'    => '+1',
979
+					'CNT_is_EU'       => false,
980
+					'CNT_active'      => true,
981
+			);
982
+			$data_types = array(
983
+					'%s',// CNT_ISO
984
+					'%s',// CNT_ISO3
985
+					'%d',// RGN_ID
986
+					'%s',// CNT_name
987
+					'%s',// CNT_cur_code
988
+					'%s',// CNT_cur_single
989
+					'%s',// CNT_cur_plural
990
+					'%s',// CNT_cur_sign
991
+					'%d',// CNT_cur_sign_b4
992
+					'%d',// CNT_cur_dec_plc
993
+					'%s',// CNT_cur_dec_mrk
994
+					'%s',// CNT_cur_thsnds
995
+					'%s',// CNT_tel_code
996
+					'%d',// CNT_is_EU
997
+					'%d',// CNT_active
998
+			);
999
+			$success = $wpdb->insert(
1000
+				$country_table,
1001
+				$cols_n_values,
1002
+				$data_types
1003
+			);
1004
+			if (! $success) {
1005
+				throw new EE_Error($this->_create_error_message_for_db_insertion(
1006
+					'N/A',
1007
+					array('country_id' => $country_name),
1008
+					$country_table,
1009
+					$cols_n_values,
1010
+					$data_types
1011
+				));
1012
+			}
1013
+			$country = $cols_n_values;
1014
+		}
1015
+		return $country;
1016
+	}
1017
+
1018
+
1019
+
1020
+	/**
1021
+	 * finds a country iso which hasnt been used yet
1022
+	 *
1023
+	 * @global type $wpdb
1024
+	 * @return string
1025
+	 */
1026
+	private function _find_available_country_iso($num_letters = 2)
1027
+	{
1028
+		global $wpdb;
1029
+		$country_table = $wpdb->prefix . "esp_country";
1030
+		$attempts = 0;
1031
+		do {
1032
+			$current_iso = strtoupper(wp_generate_password($num_letters, false));
1033
+			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM "
1034
+																   . $country_table
1035
+																   . " WHERE CNT_ISO=%s", $current_iso));
1036
+			$attempts++;
1037
+			// keep going until we find an available country code, or we arbitrarily
1038
+			// decide we've tried this enough. Somehow they have way too many countries
1039
+			// (probably because they're mis-using the EE3 country_id like a custom question)
1040
+		} while (intval($country_with_that_iso) && $attempts < 200);
1041
+		return $current_iso;
1042
+	}
1043
+
1044
+
1045
+
1046
+	/**
1047
+	 * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but
1048
+	 * is independent of outside code which can change in future versions of EE
1049
+	 *
1050
+	 * @global type  $wpdb
1051
+	 * @param string $state_name
1052
+	 * @return array where keys are columns, values are column values
1053
+	 */
1054
+	public function get_or_create_state($state_name, $country_name = '')
1055
+	{
1056
+		if (! $state_name) {
1057
+			throw new EE_Error(esc_html__(
1058
+				"Could not get-or-create state because no state name was provided",
1059
+				"event_espresso"
1060
+			));
1061
+		}
1062
+		try {
1063
+			$country = $this->get_or_create_country($country_name);
1064
+			$country_iso = $country['CNT_ISO'];
1065
+		} catch (EE_Error $e) {
1066
+			$country_iso = $this->get_default_country_iso();
1067
+		}
1068
+		global $wpdb;
1069
+		$state_table = $wpdb->prefix . "esp_state";
1070
+		$state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1071 1071
 			(STA_abbrev LIKE %s OR
1072 1072
 			STA_name LIKE %s) AND
1073 1073
 			CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A);
1074
-        if (! $state) {
1075
-            // insert a new one then
1076
-            $cols_n_values = array(
1077
-                    'CNT_ISO'    => $country_iso,
1078
-                    'STA_abbrev' => substr($state_name, 0, 6),
1079
-                    'STA_name'   => $state_name,
1080
-                    'STA_active' => true,
1081
-            );
1082
-            $data_types = array(
1083
-                    '%s',// CNT_ISO
1084
-                    '%s',// STA_abbrev
1085
-                    '%s',// STA_name
1086
-                    '%d',// STA_active
1087
-            );
1088
-            $success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1089
-            if (! $success) {
1090
-                throw new EE_Error($this->_create_error_message_for_db_insertion(
1091
-                    'N/A',
1092
-                    array('state' => $state_name, 'country_id' => $country_name),
1093
-                    $state_table,
1094
-                    $cols_n_values,
1095
-                    $data_types
1096
-                ));
1097
-            }
1098
-            $state = $cols_n_values;
1099
-            $state['STA_ID'] = $wpdb->insert_id;
1100
-        }
1101
-        return $state;
1102
-    }
1103
-
1104
-
1105
-
1106
-    /**
1107
-     * Fixes times like "5:00 PM" into the expected 24-hour format "17:00".
1108
-     * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing
1109
-     *
1110
-     * @param type $timeString
1111
-     * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes
1112
-     *                with leading zeros)
1113
-     */
1114
-    public function convertTimeFromAMPM($timeString)
1115
-    {
1116
-        $matches = array();
1117
-        preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1118
-        if (! $matches || count($matches) < 3) {
1119
-            $hour = '00';
1120
-            $minutes = '00';
1121
-        } else {
1122
-            $hour = intval($matches[1]);
1123
-            $minutes = $matches[2];
1124
-        }
1125
-        if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1126
-            $hour = intval($hour) + 12;
1127
-        }
1128
-        $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1129
-        $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1130
-        return "$hour:$minutes";
1131
-    }
1132
-
1133
-
1134
-
1135
-    /**
1136
-     * Gets the ISO3 fora country given its 3.1 country ID.
1137
-     *
1138
-     * @param int $country_id
1139
-     * @return string the country's ISO3 code
1140
-     */
1141
-    public function get_iso_from_3_1_country_id($country_id)
1142
-    {
1143
-        $old_countries = array(
1144
-                array(64, 'United States', 'US', 'USA', 1),
1145
-                array(15, 'Australia', 'AU', 'AUS', 1),
1146
-                array(39, 'Canada', 'CA', 'CAN', 1),
1147
-                array(171, 'United Kingdom', 'GB', 'GBR', 1),
1148
-                array(70, 'France', 'FR', 'FRA', 2),
1149
-                array(111, 'Italy', 'IT', 'ITA', 2),
1150
-                array(63, 'Spain', 'ES', 'ESP', 2),
1151
-                array(1, 'Afghanistan', 'AF', 'AFG', 1),
1152
-                array(2, 'Albania', 'AL', 'ALB', 1),
1153
-                array(3, 'Germany', 'DE', 'DEU', 2),
1154
-                array(198, 'Switzerland', 'CH', 'CHE', 1),
1155
-                array(87, 'Netherlands', 'NL', 'NLD', 2),
1156
-                array(197, 'Sweden', 'SE', 'SWE', 1),
1157
-                array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2),
1158
-                array(4, 'Andorra', 'AD', 'AND', 2),
1159
-                array(5, 'Angola', 'AO', 'AGO', 1),
1160
-                array(6, 'Anguilla', 'AI', 'AIA', 1),
1161
-                array(7, 'Antarctica', 'AQ', 'ATA', 1),
1162
-                array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1),
1163
-                array(10, 'Saudi Arabia', 'SA', 'SAU', 1),
1164
-                array(11, 'Algeria', 'DZ', 'DZA', 1),
1165
-                array(12, 'Argentina', 'AR', 'ARG', 1),
1166
-                array(13, 'Armenia', 'AM', 'ARM', 1),
1167
-                array(14, 'Aruba', 'AW', 'ABW', 1),
1168
-                array(16, 'Austria', 'AT', 'AUT', 2),
1169
-                array(17, 'Azerbaijan', 'AZ', 'AZE', 1),
1170
-                array(18, 'Bahamas', 'BS', 'BHS', 1),
1171
-                array(19, 'Bahrain', 'BH', 'BHR', 1),
1172
-                array(20, 'Bangladesh', 'BD', 'BGD', 1),
1173
-                array(21, 'Barbados', 'BB', 'BRB', 1),
1174
-                array(22, 'Belgium ', 'BE', 'BEL', 2),
1175
-                array(23, 'Belize', 'BZ', 'BLZ', 1),
1176
-                array(24, 'Benin', 'BJ', 'BEN', 1),
1177
-                array(25, 'Bermudas', 'BM', 'BMU', 1),
1178
-                array(26, 'Belarus', 'BY', 'BLR', 1),
1179
-                array(27, 'Bolivia', 'BO', 'BOL', 1),
1180
-                array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1),
1181
-                array(29, 'Botswana', 'BW', 'BWA', 1),
1182
-                array(96, 'Bouvet Island', 'BV', 'BVT', 1),
1183
-                array(30, 'Brazil', 'BR', 'BRA', 1),
1184
-                array(31, 'Brunei', 'BN', 'BRN', 1),
1185
-                array(32, 'Bulgaria', 'BG', 'BGR', 1),
1186
-                array(33, 'Burkina Faso', 'BF', 'BFA', 1),
1187
-                array(34, 'Burundi', 'BI', 'BDI', 1),
1188
-                array(35, 'Bhutan', 'BT', 'BTN', 1),
1189
-                array(36, 'Cape Verde', 'CV', 'CPV', 1),
1190
-                array(37, 'Cambodia', 'KH', 'KHM', 1),
1191
-                array(38, 'Cameroon', 'CM', 'CMR', 1),
1192
-                array(98, 'Cayman Islands', 'KY', 'CYM', 1),
1193
-                array(172, 'Central African Republic', 'CF', 'CAF', 1),
1194
-                array(40, 'Chad', 'TD', 'TCD', 1),
1195
-                array(41, 'Chile', 'CL', 'CHL', 1),
1196
-                array(42, 'China', 'CN', 'CHN', 1),
1197
-                array(105, 'Christmas Island', 'CX', 'CXR', 1),
1198
-                array(43, 'Cyprus', 'CY', 'CYP', 2),
1199
-                array(99, 'Cocos Island', 'CC', 'CCK', 1),
1200
-                array(100, 'Cook Islands', 'CK', 'COK', 1),
1201
-                array(44, 'Colombia', 'CO', 'COL', 1),
1202
-                array(45, 'Comoros', 'KM', 'COM', 1),
1203
-                array(46, 'Congo', 'CG', 'COG', 1),
1204
-                array(47, 'North Korea', 'KP', 'PRK', 1),
1205
-                array(50, 'Costa Rica', 'CR', 'CRI', 1),
1206
-                array(51, 'Croatia', 'HR', 'HRV', 1),
1207
-                array(52, 'Cuba', 'CU', 'CUB', 1),
1208
-                array(173, 'Czech Republic', 'CZ', 'CZE', 1),
1209
-                array(53, 'Denmark', 'DK', 'DNK', 1),
1210
-                array(54, 'Djibouti', 'DJ', 'DJI', 1),
1211
-                array(55, 'Dominica', 'DM', 'DMA', 1),
1212
-                array(174, 'Dominican Republic', 'DO', 'DOM', 1),
1213
-                array(56, 'Ecuador', 'EC', 'ECU', 1),
1214
-                array(57, 'Egypt', 'EG', 'EGY', 1),
1215
-                array(58, 'El Salvador', 'SV', 'SLV', 1),
1216
-                array(60, 'Eritrea', 'ER', 'ERI', 1),
1217
-                array(61, 'Slovakia', 'SK', 'SVK', 2),
1218
-                array(62, 'Slovenia', 'SI', 'SVN', 2),
1219
-                array(65, 'Estonia', 'EE', 'EST', 2),
1220
-                array(66, 'Ethiopia', 'ET', 'ETH', 1),
1221
-                array(102, 'Faroe islands', 'FO', 'FRO', 1),
1222
-                array(103, 'Falkland Islands', 'FK', 'FLK', 1),
1223
-                array(67, 'Fiji', 'FJ', 'FJI', 1),
1224
-                array(69, 'Finland', 'FI', 'FIN', 2),
1225
-                array(71, 'Gabon', 'GA', 'GAB', 1),
1226
-                array(72, 'Gambia', 'GM', 'GMB', 1),
1227
-                array(73, 'Georgia', 'GE', 'GEO', 1),
1228
-                array(74, 'Ghana', 'GH', 'GHA', 1),
1229
-                array(75, 'Gibraltar', 'GI', 'GIB', 1),
1230
-                array(76, 'Greece', 'GR', 'GRC', 2),
1231
-                array(77, 'Grenada', 'GD', 'GRD', 1),
1232
-                array(78, 'Greenland', 'GL', 'GRL', 1),
1233
-                array(79, 'Guadeloupe', 'GP', 'GLP', 1),
1234
-                array(80, 'Guam', 'GU', 'GUM', 1),
1235
-                array(81, 'Guatemala', 'GT', 'GTM', 1),
1236
-                array(82, 'Guinea', 'GN', 'GIN', 1),
1237
-                array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1),
1238
-                array(84, 'Guinea-Bissau', 'GW', 'GNB', 1),
1239
-                array(85, 'Guyana', 'GY', 'GUY', 1),
1240
-                array(86, 'Haiti', 'HT', 'HTI', 1),
1241
-                array(88, 'Honduras', 'HN', 'HND', 1),
1242
-                array(89, 'Hong Kong', 'HK', 'HKG', 1),
1243
-                array(90, 'Hungary', 'HU', 'HUN', 1),
1244
-                array(91, 'India', 'IN', 'IND', 1),
1245
-                array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1),
1246
-                array(92, 'Indonesia', 'ID', 'IDN', 1),
1247
-                array(93, 'Iraq', 'IQ', 'IRQ', 1),
1248
-                array(94, 'Iran', 'IR', 'IRN', 1),
1249
-                array(95, 'Ireland', 'IE', 'IRL', 2),
1250
-                array(97, 'Iceland', 'IS', 'ISL', 1),
1251
-                array(110, 'Israel', 'IL', 'ISR', 1),
1252
-                array(49, 'Ivory Coast ', 'CI', 'CIV', 1),
1253
-                array(112, 'Jamaica', 'JM', 'JAM', 1),
1254
-                array(113, 'Japan', 'JP', 'JPN', 1),
1255
-                array(114, 'Jordan', 'JO', 'JOR', 1),
1256
-                array(115, 'Kazakhstan', 'KZ', 'KAZ', 1),
1257
-                array(116, 'Kenya', 'KE', 'KEN', 1),
1258
-                array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1),
1259
-                array(118, 'Kiribati', 'KI', 'KIR', 1),
1260
-                array(48, 'South Korea', 'KR', 'KOR', 1),
1261
-                array(228, 'Kosovo', 'XK', 'XKV', 2),
1262
-                // there is no official ISO code for Kosovo yet (http://geonames.wordpress.com/2010/03/08/xk-country-code-for-kosovo/) so using a temporary country code and a modified 3 character code for ISO code -- this should be updated if/when Kosovo gets its own ISO code
1263
-                array(119, 'Kuwait', 'KW', 'KWT', 1),
1264
-                array(120, 'Laos', 'LA', 'LAO', 1),
1265
-                array(121, 'Latvia', 'LV', 'LVA', 2),
1266
-                array(122, 'Lesotho', 'LS', 'LSO', 1),
1267
-                array(123, 'Lebanon', 'LB', 'LBN', 1),
1268
-                array(124, 'Liberia', 'LR', 'LBR', 1),
1269
-                array(125, 'Libya', 'LY', 'LBY', 1),
1270
-                array(126, 'Liechtenstein', 'LI', 'LIE', 1),
1271
-                array(127, 'Lithuania', 'LT', 'LTU', 2),
1272
-                array(128, 'Luxemburg', 'LU', 'LUX', 2),
1273
-                array(129, 'Macao', 'MO', 'MAC', 1),
1274
-                array(130, 'Macedonia', 'MK', 'MKD', 1),
1275
-                array(131, 'Madagascar', 'MG', 'MDG', 1),
1276
-                array(132, 'Malaysia', 'MY', 'MYS', 1),
1277
-                array(133, 'Malawi', 'MW', 'MWI', 1),
1278
-                array(134, 'Maldivas', 'MV', 'MDV', 1),
1279
-                array(135, 'Mali', 'ML', 'MLI', 1),
1280
-                array(136, 'Malta', 'MT', 'MLT', 2),
1281
-                array(101, 'Northern Marianas', 'MP', 'MNP', 1),
1282
-                array(137, 'Morocco', 'MA', 'MAR', 1),
1283
-                array(104, 'Marshall islands', 'MH', 'MHL', 1),
1284
-                array(138, 'Martinique', 'MQ', 'MTQ', 1),
1285
-                array(139, 'Mauritius', 'MU', 'MUS', 1),
1286
-                array(140, 'Mauritania', 'MR', 'MRT', 1),
1287
-                array(141, 'Mayote', 'YT', 'MYT', 2),
1288
-                array(142, 'Mexico', 'MX', 'MEX', 1),
1289
-                array(143, 'Micronesia', 'FM', 'FSM', 1),
1290
-                array(144, 'Moldova', 'MD', 'MDA', 1),
1291
-                array(145, 'Monaco', 'MC', 'MCO', 2),
1292
-                array(146, 'Mongolia', 'MN', 'MNG', 1),
1293
-                array(147, 'Montserrat', 'MS', 'MSR', 1),
1294
-                array(227, 'Montenegro', 'ME', 'MNE', 2),
1295
-                array(148, 'Mozambique', 'MZ', 'MOZ', 1),
1296
-                array(149, 'Myanmar', 'MM', 'MMR', 1),
1297
-                array(150, 'Namibia', 'NA', 'NAM', 1),
1298
-                array(151, 'Nauru', 'NR', 'NRU', 1),
1299
-                array(152, 'Nepal', 'NP', 'NPL', 1),
1300
-                array(9, 'Netherlands Antilles', 'AN', 'ANT', 1),
1301
-                array(153, 'Nicaragua', 'NI', 'NIC', 1),
1302
-                array(154, 'Niger', 'NE', 'NER', 1),
1303
-                array(155, 'Nigeria', 'NG', 'NGA', 1),
1304
-                array(156, 'Niue', 'NU', 'NIU', 1),
1305
-                array(157, 'Norway', 'NO', 'NOR', 1),
1306
-                array(158, 'New Caledonia', 'NC', 'NCL', 1),
1307
-                array(159, 'New Zealand', 'NZ', 'NZL', 1),
1308
-                array(160, 'Oman', 'OM', 'OMN', 1),
1309
-                array(161, 'Pakistan', 'PK', 'PAK', 1),
1310
-                array(162, 'Palau', 'PW', 'PLW', 1),
1311
-                array(163, 'Panama', 'PA', 'PAN', 1),
1312
-                array(164, 'Papua New Guinea', 'PG', 'PNG', 1),
1313
-                array(165, 'Paraguay', 'PY', 'PRY', 1),
1314
-                array(166, 'Peru', 'PE', 'PER', 1),
1315
-                array(68, 'Philippines', 'PH', 'PHL', 1),
1316
-                array(167, 'Poland', 'PL', 'POL', 1),
1317
-                array(168, 'Portugal', 'PT', 'PRT', 2),
1318
-                array(169, 'Puerto Rico', 'PR', 'PRI', 1),
1319
-                array(170, 'Qatar', 'QA', 'QAT', 1),
1320
-                array(176, 'Rwanda', 'RW', 'RWA', 1),
1321
-                array(177, 'Romania', 'RO', 'ROM', 2),
1322
-                array(178, 'Russia', 'RU', 'RUS', 1),
1323
-                array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2),
1324
-                array(180, 'Samoa', 'WS', 'WSM', 1),
1325
-                array(181, 'American Samoa', 'AS', 'ASM', 1),
1326
-                array(183, 'San Marino', 'SM', 'SMR', 2),
1327
-                array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1),
1328
-                array(185, 'Saint Helena', 'SH', 'SHN', 1),
1329
-                array(186, 'Saint Lucia', 'LC', 'LCA', 1),
1330
-                array(188, 'Senegal', 'SN', 'SEN', 1),
1331
-                array(189, 'Seychelles', 'SC', 'SYC', 1),
1332
-                array(190, 'Sierra Leona', 'SL', 'SLE', 1),
1333
-                array(191, 'Singapore', 'SG', 'SGP', 1),
1334
-                array(192, 'Syria', 'SY', 'SYR', 1),
1335
-                array(193, 'Somalia', 'SO', 'SOM', 1),
1336
-                array(194, 'Sri Lanka', 'LK', 'LKA', 1),
1337
-                array(195, 'South Africa', 'ZA', 'ZAF', 1),
1338
-                array(196, 'Sudan', 'SD', 'SDN', 1),
1339
-                array(199, 'Suriname', 'SR', 'SUR', 1),
1340
-                array(200, 'Swaziland', 'SZ', 'SWZ', 1),
1341
-                array(201, 'Thailand', 'TH', 'THA', 1),
1342
-                array(202, 'Taiwan', 'TW', 'TWN', 1),
1343
-                array(203, 'Tanzania', 'TZ', 'TZA', 1),
1344
-                array(204, 'Tajikistan', 'TJ', 'TJK', 1),
1345
-                array(206, 'Timor-Leste', 'TL', 'TLS', 1),
1346
-                array(207, 'Togo', 'TG', 'TGO', 1),
1347
-                array(208, 'Tokelau', 'TK', 'TKL', 1),
1348
-                array(209, 'Tonga', 'TO', 'TON', 1),
1349
-                array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1),
1350
-                array(211, 'Tunisia', 'TN', 'TUN', 1),
1351
-                array(212, 'Turkmenistan', 'TM', 'TKM', 1),
1352
-                array(213, 'Turkey', 'TR', 'TUR', 1),
1353
-                array(214, 'Tuvalu', 'TV', 'TUV', 1),
1354
-                array(215, 'Ukraine', 'UA', 'UKR', 1),
1355
-                array(216, 'Uganda', 'UG', 'UGA', 1),
1356
-                array(59, 'United Arab Emirates', 'AE', 'ARE', 1),
1357
-                array(217, 'Uruguay', 'UY', 'URY', 1),
1358
-                array(218, 'Uzbekistan', 'UZ', 'UZB', 1),
1359
-                array(219, 'Vanuatu', 'VU', 'VUT', 1),
1360
-                array(220, 'Vatican City', 'VA', 'VAT', 2),
1361
-                array(221, 'Venezuela', 'VE', 'VEN', 1),
1362
-                array(222, 'Vietnam', 'VN', 'VNM', 1),
1363
-                array(108, 'Virgin Islands', 'VI', 'VIR', 1),
1364
-                array(223, 'Yemen', 'YE', 'YEM', 1),
1365
-                array(225, 'Zambia', 'ZM', 'ZMB', 1),
1366
-                array(226, 'Zimbabwe', 'ZW', 'ZWE', 1),
1367
-        );
1368
-        $country_iso = 'US';
1369
-        foreach ($old_countries as $country_array) {
1370
-            // note: index 0 is the 3.1 country ID
1371
-            if ($country_array[0] == $country_id) {
1372
-                // note: index 2 is the ISO
1373
-                $country_iso = $country_array[2];
1374
-                break;
1375
-            }
1376
-        }
1377
-        return $country_iso;
1378
-    }
1379
-
1380
-
1381
-
1382
-    /**
1383
-     * Gets the ISO3 for the
1384
-     *
1385
-     * @return string
1386
-     */
1387
-    public function get_default_country_iso()
1388
-    {
1389
-        $old_org_options = get_option('events_organization_settings');
1390
-        $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1391
-        return $iso;
1392
-    }
1393
-
1394
-
1395
-
1396
-    /**
1397
-     * Converst a 3.1 payment status to its equivalent 4.1 regisration status
1398
-     *
1399
-     * @param string  $payment_status                   possible value for 3.1's evens_attendee.payment_status
1400
-     * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's
1401
-     *                                                  default payment status, the event's default payment status, or
1402
-     *                                                  the attendee's payment status) required pre-approval.
1403
-     * @return string STS_ID for use in 4.1
1404
-     */
1405
-    public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false)
1406
-    {
1407
-        // EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1408
-        if ($this_thing_required_pre_approval) {
1409
-            return 'RNA';
1410
-        } else {
1411
-            $mapping = $default_reg_stati_conversions = array(
1412
-                    'Completed'        => 'RAP',
1413
-                    ''                 => 'RPP',
1414
-                    'Incomplete'       => 'RPP',
1415
-                    'Pending'          => 'RAP',
1416
-                    // stati that only occurred on 3.1 attendees:
1417
-                    'Payment Declined' => 'RPP',
1418
-                    'Not Completed'    => 'RPP',
1419
-                    'Cancelled'        => 'RPP',
1420
-                    'Declined'         => 'RPP',
1421
-            );
1422
-        }
1423
-        return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA';
1424
-    }
1425
-
1426
-
1427
-
1428
-    /**
1429
-     * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1430
-     * and sets it as the featured image on the CPT event
1431
-     *
1432
-     * @param type                            $old_event
1433
-     * @param type                            $new_cpt_id
1434
-     * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1435
-     * @return boolean whether or not we had to do the big job of creating an image attachment
1436
-     */
1437
-    public function convert_image_url_to_attachment_and_attach_to_post(
1438
-        $guid,
1439
-        $new_cpt_id,
1440
-        EE_Data_Migration_Script_Stage $migration_stage
1441
-    ) {
1442
-        $created_attachment_post = false;
1443
-        $guid = $this->_get_original_guid($guid);
1444
-        if ($guid) {
1445
-            // check for an existing attachment post with this guid
1446
-            $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1447
-            if (! $attachment_post_id) {
1448
-                // post thumbnail with that GUID doesn't exist, we should create one
1449
-                $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1450
-                $created_attachment_post = true;
1451
-            }
1452
-            // double-check we actually have an attachment post
1453
-            if ($attachment_post_id) {
1454
-                update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1455
-            } else {
1456
-                $migration_stage->add_error(sprintf(esc_html__(
1457
-                    "Could not update event image %s for CPT with ID %d, but attachments post ID is %d",
1458
-                    "event_espresso"
1459
-                ), $guid, $new_cpt_id, $attachment_post_id));
1460
-            }
1461
-        }
1462
-        return $created_attachment_post;
1463
-    }
1464
-
1465
-
1466
-
1467
-    /**
1468
-     * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead
1469
-     * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype,
1470
-     * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of
1471
-     * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it
1472
-     * exists
1473
-     *
1474
-     * @param string $guid_in_old_event
1475
-     * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1476
-     */
1477
-    private function _get_original_guid($guid_in_old_event)
1478
-    {
1479
-        $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1480
-        // do a head request to verify the file exists
1481
-        $head_response = wp_remote_head($original_guid);
1482
-        if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1483
-            return $original_guid;
1484
-        } else {
1485
-            return $guid_in_old_event;
1486
-        }
1487
-    }
1488
-
1489
-
1490
-
1491
-    /**
1492
-     * Creates an image attachment post for the GUID. If the GUID points to a remote image,
1493
-     * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1494
-     * thumbnails)
1495
-     *
1496
-     * @param type                           $guid
1497
-     * @param EE_Data_Migration_Script_Stage $migration_stage
1498
-     * @return int
1499
-     */
1500
-    private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1501
-    {
1502
-        if (! $guid) {
1503
-            $migration_stage->add_error(sprintf(esc_html__(
1504
-                "Cannot create image attachment for a blank GUID!",
1505
-                "event_espresso"
1506
-            )));
1507
-            return 0;
1508
-        }
1509
-        $wp_filetype = wp_check_filetype(basename($guid), null);
1510
-        $wp_upload_dir = wp_upload_dir();
1511
-        // if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1512
-        if (strpos($guid, $wp_upload_dir['url']) === false) {
1513
-            // image is located remotely. download it and place it in the uploads directory
1514
-            if (! is_readable($guid)) {
1515
-                $migration_stage->add_error(sprintf(esc_html__(
1516
-                    "Could not create image attachment from non-existent file: %s",
1517
-                    "event_espresso"
1518
-                ), $guid));
1519
-                return 0;
1520
-            }
1521
-            $contents = file_get_contents($guid);
1522
-            if ($contents === false) {
1523
-                $migration_stage->add_error(sprintf(esc_html__(
1524
-                    "Could not read image at %s, and therefore couldnt create an attachment post for it.",
1525
-                    "event_espresso"
1526
-                ), $guid));
1527
-                return false;
1528
-            }
1529
-            $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid);
1530
-            $savefile = fopen($local_filepath, 'w');
1531
-            fwrite($savefile, $contents);
1532
-            fclose($savefile);
1533
-            $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1534
-        } else {
1535
-            $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1536
-        }
1537
-        $attachment = array(
1538
-                'guid'           => $guid,
1539
-                'post_mime_type' => $wp_filetype['type'],
1540
-                'post_title'     => preg_replace('/\.[^.]+$/', '', basename($guid)),
1541
-                'post_content'   => '',
1542
-                'post_status'    => 'inherit',
1543
-        );
1544
-        $attach_id = wp_insert_attachment($attachment, $guid);
1545
-        if (! $attach_id) {
1546
-            $migration_stage->add_error(sprintf(esc_html__(
1547
-                "Could not create image attachment post from image '%s'. Attachment data was %s.",
1548
-                "event_espresso"
1549
-            ), $guid, $this->_json_encode($attachment)));
1550
-            return $attach_id;
1551
-        }
1552
-        // you must first include the image.php file
1553
-        // for the function wp_generate_attachment_metadata() to work
1554
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1555
-        $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1556
-        if (! $attach_data) {
1557
-            $migration_stage->add_error(sprintf(esc_html__(
1558
-                "Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1559
-                "event_espresso"
1560
-            ), $attach_id, $local_filepath, $guid));
1561
-            return $attach_id;
1562
-        }
1563
-        $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1564
-        if (! $metadata_save_result) {
1565
-            $migration_stage->add_error(sprintf(esc_html__(
1566
-                "Could not update attachment metadata for attachment %d with data %s",
1567
-                "event_espresso"
1568
-            ), $attach_id, $this->_json_encode($attach_data)));
1569
-        }
1570
-        return $attach_id;
1571
-    }
1572
-
1573
-
1574
-
1575
-    /**
1576
-     * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself),
1577
-     * and returns its ID.
1578
-     *
1579
-     * @global type  $wpdb
1580
-     * @param string $guid
1581
-     * @return int
1582
-     */
1583
-    private function _get_image_attachment_id_by_GUID($guid)
1584
-    {
1585
-        global $wpdb;
1586
-        $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1587
-        return $attachment_id;
1588
-    }
1589
-
1590
-
1591
-
1592
-    /**
1593
-     * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1594
-     * (and optionally a timezone; if none is given, the wp default is used)
1595
-     *
1596
-     * @param EE_Data_Migration_Script_base $stage
1597
-     * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1598
-     *                                                   UTC time for
1599
-     * @param string                        $DATETIME_string
1600
-     * @param string                        $timezone
1601
-     * @return string
1602
-     */
1603
-    public function convert_date_string_to_utc(
1604
-        EE_Data_Migration_Script_Stage $stage,
1605
-        $row_of_data,
1606
-        $DATETIME_string,
1607
-        $timezone = null
1608
-    ) {
1609
-        $original_tz = $timezone;
1610
-        if (! $timezone) {
1611
-            $timezone = $this->_get_wp_timezone();
1612
-        }
1613
-        if (! $timezone) {
1614
-            $stage->add_error(sprintf(
1615
-                esc_html__("Could not find timezone given %s for %s", "event_espresso"),
1616
-                $original_tz,
1617
-                $row_of_data
1618
-            ));
1619
-            $timezone = 'UTC';
1620
-        }
1621
-        try {
1622
-            $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1623
-            EEH_DTT_Helper::setTimezone($date_obj, new DateTimeZone('UTC'));
1624
-        } catch (Exception $e) {
1625
-            $stage->add_error(sprintf(esc_html__(
1626
-                "Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.",
1627
-                "event_espresso"
1628
-            ), $DATETIME_string, $timezone));
1629
-            $date_obj = new DateTime();
1630
-        }
1631
-        return $date_obj->format('Y-m-d H:i:s');
1632
-    }
1633
-
1634
-
1635
-
1636
-    /**
1637
-     * Gets the default timezone string from wordpress (even if they set a gmt offset)
1638
-     *
1639
-     * @return string
1640
-     */
1641
-    private function _get_wp_timezone()
1642
-    {
1643
-        $timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1644
-        // if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1645
-        if (empty($timezone)) {
1646
-            // let's get a the WordPress UTC offset
1647
-            $offset = get_option('gmt_offset');
1648
-            $timezone = $this->timezone_convert_to_string_from_offset($offset);
1649
-        }
1650
-        return $timezone;
1651
-    }
1652
-
1653
-
1654
-
1655
-    /**
1656
-     * Gets the wordpress timezone string from a UTC offset
1657
-     *
1658
-     * @param int $offset
1659
-     * @return boolean
1660
-     */
1661
-    private function timezone_convert_to_string_from_offset($offset)
1662
-    {
1663
-        // 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
1664
-        $offset *= 3600; // convert hour offset to seconds
1665
-        $abbrarray = timezone_abbreviations_list();
1666
-        foreach ($abbrarray as $abbr) {
1667
-            foreach ($abbr as $city) {
1668
-                if ($city['offset'] == $offset) {
1669
-                    return $city['timezone_id'];
1670
-                }
1671
-            }
1672
-        }
1673
-        return false;
1674
-    }
1675
-
1676
-
1677
-
1678
-    public function migration_page_hooks()
1679
-    {
1680
-        add_filter(
1681
-            'FHEE__ee_migration_page__header',
1682
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1683
-            10,
1684
-            3
1685
-        );
1686
-        add_filter(
1687
-            'FHEE__ee_migration_page__p_after_header',
1688
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1689
-            10,
1690
-            2
1691
-        );
1692
-        add_filter(
1693
-            'FHEE__ee_migration_page__option_1_main',
1694
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1695
-            10,
1696
-            3
1697
-        );
1698
-        add_filter(
1699
-            'FHEE__ee_migration_page__option_1_button_text',
1700
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1701
-            10,
1702
-            3
1703
-        );
1704
-        add_action(
1705
-            'AHEE__ee_migration_page__option_1_extra_details',
1706
-            array($this, '_migration_page_hook_option_1_extra_details'),
1707
-            10,
1708
-            3
1709
-        );
1710
-        add_filter(
1711
-            'FHEE__ee_migration_page__option_2_main',
1712
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1713
-            10,
1714
-            4
1715
-        );
1716
-        add_filter(
1717
-            'FHEE__ee_migration_page__option_2_button_text',
1718
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1719
-            10,
1720
-            2
1721
-        );
1722
-        add_filter(
1723
-            'FHEE__ee_migration_page__option_2_details',
1724
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1725
-            10,
1726
-            2
1727
-        );
1728
-        add_action(
1729
-            'AHEE__ee_migration_page__after_migration_options_table',
1730
-            array($this, '_migration_page_hook_after_migration_options_table')
1731
-        );
1732
-        add_filter(
1733
-            'FHEE__ee_migration_page__done_migration_header',
1734
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1735
-            10,
1736
-            2
1737
-        );
1738
-        add_filter(
1739
-            'FHEE__ee_migration_page__p_after_done_migration_header',
1740
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1741
-            10,
1742
-            2
1743
-        );
1744
-        add_filter(
1745
-            'FHEE__ee_migration_page__migration_options_template',
1746
-            array($this,'use_migration_options_from_ee3_template')
1747
-        );
1748
-    }
1749
-
1750
-
1751
-
1752
-    public function _migrate_page_hook_simplify_version_strings(
1753
-        $old_content,
1754
-        $current_db_state,
1755
-        $next_db_state,
1756
-        $ultimate_db_state = null
1757
-    ) {
1758
-        return str_replace(
1759
-            array($current_db_state, $next_db_state, $ultimate_db_state),
1760
-            array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')),
1761
-            $old_content
1762
-        );
1763
-    }
1764
-
1765
-
1766
-
1767
-    public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state)
1768
-    {
1769
-        return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content);
1770
-    }
1771
-
1772
-
1773
-
1774
-    public function _migration_page_hook_option_1_extra_details()
1775
-    {
1776
-        ?>
1074
+		if (! $state) {
1075
+			// insert a new one then
1076
+			$cols_n_values = array(
1077
+					'CNT_ISO'    => $country_iso,
1078
+					'STA_abbrev' => substr($state_name, 0, 6),
1079
+					'STA_name'   => $state_name,
1080
+					'STA_active' => true,
1081
+			);
1082
+			$data_types = array(
1083
+					'%s',// CNT_ISO
1084
+					'%s',// STA_abbrev
1085
+					'%s',// STA_name
1086
+					'%d',// STA_active
1087
+			);
1088
+			$success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1089
+			if (! $success) {
1090
+				throw new EE_Error($this->_create_error_message_for_db_insertion(
1091
+					'N/A',
1092
+					array('state' => $state_name, 'country_id' => $country_name),
1093
+					$state_table,
1094
+					$cols_n_values,
1095
+					$data_types
1096
+				));
1097
+			}
1098
+			$state = $cols_n_values;
1099
+			$state['STA_ID'] = $wpdb->insert_id;
1100
+		}
1101
+		return $state;
1102
+	}
1103
+
1104
+
1105
+
1106
+	/**
1107
+	 * Fixes times like "5:00 PM" into the expected 24-hour format "17:00".
1108
+	 * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing
1109
+	 *
1110
+	 * @param type $timeString
1111
+	 * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes
1112
+	 *                with leading zeros)
1113
+	 */
1114
+	public function convertTimeFromAMPM($timeString)
1115
+	{
1116
+		$matches = array();
1117
+		preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1118
+		if (! $matches || count($matches) < 3) {
1119
+			$hour = '00';
1120
+			$minutes = '00';
1121
+		} else {
1122
+			$hour = intval($matches[1]);
1123
+			$minutes = $matches[2];
1124
+		}
1125
+		if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1126
+			$hour = intval($hour) + 12;
1127
+		}
1128
+		$hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1129
+		$minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1130
+		return "$hour:$minutes";
1131
+	}
1132
+
1133
+
1134
+
1135
+	/**
1136
+	 * Gets the ISO3 fora country given its 3.1 country ID.
1137
+	 *
1138
+	 * @param int $country_id
1139
+	 * @return string the country's ISO3 code
1140
+	 */
1141
+	public function get_iso_from_3_1_country_id($country_id)
1142
+	{
1143
+		$old_countries = array(
1144
+				array(64, 'United States', 'US', 'USA', 1),
1145
+				array(15, 'Australia', 'AU', 'AUS', 1),
1146
+				array(39, 'Canada', 'CA', 'CAN', 1),
1147
+				array(171, 'United Kingdom', 'GB', 'GBR', 1),
1148
+				array(70, 'France', 'FR', 'FRA', 2),
1149
+				array(111, 'Italy', 'IT', 'ITA', 2),
1150
+				array(63, 'Spain', 'ES', 'ESP', 2),
1151
+				array(1, 'Afghanistan', 'AF', 'AFG', 1),
1152
+				array(2, 'Albania', 'AL', 'ALB', 1),
1153
+				array(3, 'Germany', 'DE', 'DEU', 2),
1154
+				array(198, 'Switzerland', 'CH', 'CHE', 1),
1155
+				array(87, 'Netherlands', 'NL', 'NLD', 2),
1156
+				array(197, 'Sweden', 'SE', 'SWE', 1),
1157
+				array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2),
1158
+				array(4, 'Andorra', 'AD', 'AND', 2),
1159
+				array(5, 'Angola', 'AO', 'AGO', 1),
1160
+				array(6, 'Anguilla', 'AI', 'AIA', 1),
1161
+				array(7, 'Antarctica', 'AQ', 'ATA', 1),
1162
+				array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1),
1163
+				array(10, 'Saudi Arabia', 'SA', 'SAU', 1),
1164
+				array(11, 'Algeria', 'DZ', 'DZA', 1),
1165
+				array(12, 'Argentina', 'AR', 'ARG', 1),
1166
+				array(13, 'Armenia', 'AM', 'ARM', 1),
1167
+				array(14, 'Aruba', 'AW', 'ABW', 1),
1168
+				array(16, 'Austria', 'AT', 'AUT', 2),
1169
+				array(17, 'Azerbaijan', 'AZ', 'AZE', 1),
1170
+				array(18, 'Bahamas', 'BS', 'BHS', 1),
1171
+				array(19, 'Bahrain', 'BH', 'BHR', 1),
1172
+				array(20, 'Bangladesh', 'BD', 'BGD', 1),
1173
+				array(21, 'Barbados', 'BB', 'BRB', 1),
1174
+				array(22, 'Belgium ', 'BE', 'BEL', 2),
1175
+				array(23, 'Belize', 'BZ', 'BLZ', 1),
1176
+				array(24, 'Benin', 'BJ', 'BEN', 1),
1177
+				array(25, 'Bermudas', 'BM', 'BMU', 1),
1178
+				array(26, 'Belarus', 'BY', 'BLR', 1),
1179
+				array(27, 'Bolivia', 'BO', 'BOL', 1),
1180
+				array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1),
1181
+				array(29, 'Botswana', 'BW', 'BWA', 1),
1182
+				array(96, 'Bouvet Island', 'BV', 'BVT', 1),
1183
+				array(30, 'Brazil', 'BR', 'BRA', 1),
1184
+				array(31, 'Brunei', 'BN', 'BRN', 1),
1185
+				array(32, 'Bulgaria', 'BG', 'BGR', 1),
1186
+				array(33, 'Burkina Faso', 'BF', 'BFA', 1),
1187
+				array(34, 'Burundi', 'BI', 'BDI', 1),
1188
+				array(35, 'Bhutan', 'BT', 'BTN', 1),
1189
+				array(36, 'Cape Verde', 'CV', 'CPV', 1),
1190
+				array(37, 'Cambodia', 'KH', 'KHM', 1),
1191
+				array(38, 'Cameroon', 'CM', 'CMR', 1),
1192
+				array(98, 'Cayman Islands', 'KY', 'CYM', 1),
1193
+				array(172, 'Central African Republic', 'CF', 'CAF', 1),
1194
+				array(40, 'Chad', 'TD', 'TCD', 1),
1195
+				array(41, 'Chile', 'CL', 'CHL', 1),
1196
+				array(42, 'China', 'CN', 'CHN', 1),
1197
+				array(105, 'Christmas Island', 'CX', 'CXR', 1),
1198
+				array(43, 'Cyprus', 'CY', 'CYP', 2),
1199
+				array(99, 'Cocos Island', 'CC', 'CCK', 1),
1200
+				array(100, 'Cook Islands', 'CK', 'COK', 1),
1201
+				array(44, 'Colombia', 'CO', 'COL', 1),
1202
+				array(45, 'Comoros', 'KM', 'COM', 1),
1203
+				array(46, 'Congo', 'CG', 'COG', 1),
1204
+				array(47, 'North Korea', 'KP', 'PRK', 1),
1205
+				array(50, 'Costa Rica', 'CR', 'CRI', 1),
1206
+				array(51, 'Croatia', 'HR', 'HRV', 1),
1207
+				array(52, 'Cuba', 'CU', 'CUB', 1),
1208
+				array(173, 'Czech Republic', 'CZ', 'CZE', 1),
1209
+				array(53, 'Denmark', 'DK', 'DNK', 1),
1210
+				array(54, 'Djibouti', 'DJ', 'DJI', 1),
1211
+				array(55, 'Dominica', 'DM', 'DMA', 1),
1212
+				array(174, 'Dominican Republic', 'DO', 'DOM', 1),
1213
+				array(56, 'Ecuador', 'EC', 'ECU', 1),
1214
+				array(57, 'Egypt', 'EG', 'EGY', 1),
1215
+				array(58, 'El Salvador', 'SV', 'SLV', 1),
1216
+				array(60, 'Eritrea', 'ER', 'ERI', 1),
1217
+				array(61, 'Slovakia', 'SK', 'SVK', 2),
1218
+				array(62, 'Slovenia', 'SI', 'SVN', 2),
1219
+				array(65, 'Estonia', 'EE', 'EST', 2),
1220
+				array(66, 'Ethiopia', 'ET', 'ETH', 1),
1221
+				array(102, 'Faroe islands', 'FO', 'FRO', 1),
1222
+				array(103, 'Falkland Islands', 'FK', 'FLK', 1),
1223
+				array(67, 'Fiji', 'FJ', 'FJI', 1),
1224
+				array(69, 'Finland', 'FI', 'FIN', 2),
1225
+				array(71, 'Gabon', 'GA', 'GAB', 1),
1226
+				array(72, 'Gambia', 'GM', 'GMB', 1),
1227
+				array(73, 'Georgia', 'GE', 'GEO', 1),
1228
+				array(74, 'Ghana', 'GH', 'GHA', 1),
1229
+				array(75, 'Gibraltar', 'GI', 'GIB', 1),
1230
+				array(76, 'Greece', 'GR', 'GRC', 2),
1231
+				array(77, 'Grenada', 'GD', 'GRD', 1),
1232
+				array(78, 'Greenland', 'GL', 'GRL', 1),
1233
+				array(79, 'Guadeloupe', 'GP', 'GLP', 1),
1234
+				array(80, 'Guam', 'GU', 'GUM', 1),
1235
+				array(81, 'Guatemala', 'GT', 'GTM', 1),
1236
+				array(82, 'Guinea', 'GN', 'GIN', 1),
1237
+				array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1),
1238
+				array(84, 'Guinea-Bissau', 'GW', 'GNB', 1),
1239
+				array(85, 'Guyana', 'GY', 'GUY', 1),
1240
+				array(86, 'Haiti', 'HT', 'HTI', 1),
1241
+				array(88, 'Honduras', 'HN', 'HND', 1),
1242
+				array(89, 'Hong Kong', 'HK', 'HKG', 1),
1243
+				array(90, 'Hungary', 'HU', 'HUN', 1),
1244
+				array(91, 'India', 'IN', 'IND', 1),
1245
+				array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1),
1246
+				array(92, 'Indonesia', 'ID', 'IDN', 1),
1247
+				array(93, 'Iraq', 'IQ', 'IRQ', 1),
1248
+				array(94, 'Iran', 'IR', 'IRN', 1),
1249
+				array(95, 'Ireland', 'IE', 'IRL', 2),
1250
+				array(97, 'Iceland', 'IS', 'ISL', 1),
1251
+				array(110, 'Israel', 'IL', 'ISR', 1),
1252
+				array(49, 'Ivory Coast ', 'CI', 'CIV', 1),
1253
+				array(112, 'Jamaica', 'JM', 'JAM', 1),
1254
+				array(113, 'Japan', 'JP', 'JPN', 1),
1255
+				array(114, 'Jordan', 'JO', 'JOR', 1),
1256
+				array(115, 'Kazakhstan', 'KZ', 'KAZ', 1),
1257
+				array(116, 'Kenya', 'KE', 'KEN', 1),
1258
+				array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1),
1259
+				array(118, 'Kiribati', 'KI', 'KIR', 1),
1260
+				array(48, 'South Korea', 'KR', 'KOR', 1),
1261
+				array(228, 'Kosovo', 'XK', 'XKV', 2),
1262
+				// there is no official ISO code for Kosovo yet (http://geonames.wordpress.com/2010/03/08/xk-country-code-for-kosovo/) so using a temporary country code and a modified 3 character code for ISO code -- this should be updated if/when Kosovo gets its own ISO code
1263
+				array(119, 'Kuwait', 'KW', 'KWT', 1),
1264
+				array(120, 'Laos', 'LA', 'LAO', 1),
1265
+				array(121, 'Latvia', 'LV', 'LVA', 2),
1266
+				array(122, 'Lesotho', 'LS', 'LSO', 1),
1267
+				array(123, 'Lebanon', 'LB', 'LBN', 1),
1268
+				array(124, 'Liberia', 'LR', 'LBR', 1),
1269
+				array(125, 'Libya', 'LY', 'LBY', 1),
1270
+				array(126, 'Liechtenstein', 'LI', 'LIE', 1),
1271
+				array(127, 'Lithuania', 'LT', 'LTU', 2),
1272
+				array(128, 'Luxemburg', 'LU', 'LUX', 2),
1273
+				array(129, 'Macao', 'MO', 'MAC', 1),
1274
+				array(130, 'Macedonia', 'MK', 'MKD', 1),
1275
+				array(131, 'Madagascar', 'MG', 'MDG', 1),
1276
+				array(132, 'Malaysia', 'MY', 'MYS', 1),
1277
+				array(133, 'Malawi', 'MW', 'MWI', 1),
1278
+				array(134, 'Maldivas', 'MV', 'MDV', 1),
1279
+				array(135, 'Mali', 'ML', 'MLI', 1),
1280
+				array(136, 'Malta', 'MT', 'MLT', 2),
1281
+				array(101, 'Northern Marianas', 'MP', 'MNP', 1),
1282
+				array(137, 'Morocco', 'MA', 'MAR', 1),
1283
+				array(104, 'Marshall islands', 'MH', 'MHL', 1),
1284
+				array(138, 'Martinique', 'MQ', 'MTQ', 1),
1285
+				array(139, 'Mauritius', 'MU', 'MUS', 1),
1286
+				array(140, 'Mauritania', 'MR', 'MRT', 1),
1287
+				array(141, 'Mayote', 'YT', 'MYT', 2),
1288
+				array(142, 'Mexico', 'MX', 'MEX', 1),
1289
+				array(143, 'Micronesia', 'FM', 'FSM', 1),
1290
+				array(144, 'Moldova', 'MD', 'MDA', 1),
1291
+				array(145, 'Monaco', 'MC', 'MCO', 2),
1292
+				array(146, 'Mongolia', 'MN', 'MNG', 1),
1293
+				array(147, 'Montserrat', 'MS', 'MSR', 1),
1294
+				array(227, 'Montenegro', 'ME', 'MNE', 2),
1295
+				array(148, 'Mozambique', 'MZ', 'MOZ', 1),
1296
+				array(149, 'Myanmar', 'MM', 'MMR', 1),
1297
+				array(150, 'Namibia', 'NA', 'NAM', 1),
1298
+				array(151, 'Nauru', 'NR', 'NRU', 1),
1299
+				array(152, 'Nepal', 'NP', 'NPL', 1),
1300
+				array(9, 'Netherlands Antilles', 'AN', 'ANT', 1),
1301
+				array(153, 'Nicaragua', 'NI', 'NIC', 1),
1302
+				array(154, 'Niger', 'NE', 'NER', 1),
1303
+				array(155, 'Nigeria', 'NG', 'NGA', 1),
1304
+				array(156, 'Niue', 'NU', 'NIU', 1),
1305
+				array(157, 'Norway', 'NO', 'NOR', 1),
1306
+				array(158, 'New Caledonia', 'NC', 'NCL', 1),
1307
+				array(159, 'New Zealand', 'NZ', 'NZL', 1),
1308
+				array(160, 'Oman', 'OM', 'OMN', 1),
1309
+				array(161, 'Pakistan', 'PK', 'PAK', 1),
1310
+				array(162, 'Palau', 'PW', 'PLW', 1),
1311
+				array(163, 'Panama', 'PA', 'PAN', 1),
1312
+				array(164, 'Papua New Guinea', 'PG', 'PNG', 1),
1313
+				array(165, 'Paraguay', 'PY', 'PRY', 1),
1314
+				array(166, 'Peru', 'PE', 'PER', 1),
1315
+				array(68, 'Philippines', 'PH', 'PHL', 1),
1316
+				array(167, 'Poland', 'PL', 'POL', 1),
1317
+				array(168, 'Portugal', 'PT', 'PRT', 2),
1318
+				array(169, 'Puerto Rico', 'PR', 'PRI', 1),
1319
+				array(170, 'Qatar', 'QA', 'QAT', 1),
1320
+				array(176, 'Rwanda', 'RW', 'RWA', 1),
1321
+				array(177, 'Romania', 'RO', 'ROM', 2),
1322
+				array(178, 'Russia', 'RU', 'RUS', 1),
1323
+				array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2),
1324
+				array(180, 'Samoa', 'WS', 'WSM', 1),
1325
+				array(181, 'American Samoa', 'AS', 'ASM', 1),
1326
+				array(183, 'San Marino', 'SM', 'SMR', 2),
1327
+				array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1),
1328
+				array(185, 'Saint Helena', 'SH', 'SHN', 1),
1329
+				array(186, 'Saint Lucia', 'LC', 'LCA', 1),
1330
+				array(188, 'Senegal', 'SN', 'SEN', 1),
1331
+				array(189, 'Seychelles', 'SC', 'SYC', 1),
1332
+				array(190, 'Sierra Leona', 'SL', 'SLE', 1),
1333
+				array(191, 'Singapore', 'SG', 'SGP', 1),
1334
+				array(192, 'Syria', 'SY', 'SYR', 1),
1335
+				array(193, 'Somalia', 'SO', 'SOM', 1),
1336
+				array(194, 'Sri Lanka', 'LK', 'LKA', 1),
1337
+				array(195, 'South Africa', 'ZA', 'ZAF', 1),
1338
+				array(196, 'Sudan', 'SD', 'SDN', 1),
1339
+				array(199, 'Suriname', 'SR', 'SUR', 1),
1340
+				array(200, 'Swaziland', 'SZ', 'SWZ', 1),
1341
+				array(201, 'Thailand', 'TH', 'THA', 1),
1342
+				array(202, 'Taiwan', 'TW', 'TWN', 1),
1343
+				array(203, 'Tanzania', 'TZ', 'TZA', 1),
1344
+				array(204, 'Tajikistan', 'TJ', 'TJK', 1),
1345
+				array(206, 'Timor-Leste', 'TL', 'TLS', 1),
1346
+				array(207, 'Togo', 'TG', 'TGO', 1),
1347
+				array(208, 'Tokelau', 'TK', 'TKL', 1),
1348
+				array(209, 'Tonga', 'TO', 'TON', 1),
1349
+				array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1),
1350
+				array(211, 'Tunisia', 'TN', 'TUN', 1),
1351
+				array(212, 'Turkmenistan', 'TM', 'TKM', 1),
1352
+				array(213, 'Turkey', 'TR', 'TUR', 1),
1353
+				array(214, 'Tuvalu', 'TV', 'TUV', 1),
1354
+				array(215, 'Ukraine', 'UA', 'UKR', 1),
1355
+				array(216, 'Uganda', 'UG', 'UGA', 1),
1356
+				array(59, 'United Arab Emirates', 'AE', 'ARE', 1),
1357
+				array(217, 'Uruguay', 'UY', 'URY', 1),
1358
+				array(218, 'Uzbekistan', 'UZ', 'UZB', 1),
1359
+				array(219, 'Vanuatu', 'VU', 'VUT', 1),
1360
+				array(220, 'Vatican City', 'VA', 'VAT', 2),
1361
+				array(221, 'Venezuela', 'VE', 'VEN', 1),
1362
+				array(222, 'Vietnam', 'VN', 'VNM', 1),
1363
+				array(108, 'Virgin Islands', 'VI', 'VIR', 1),
1364
+				array(223, 'Yemen', 'YE', 'YEM', 1),
1365
+				array(225, 'Zambia', 'ZM', 'ZMB', 1),
1366
+				array(226, 'Zimbabwe', 'ZW', 'ZWE', 1),
1367
+		);
1368
+		$country_iso = 'US';
1369
+		foreach ($old_countries as $country_array) {
1370
+			// note: index 0 is the 3.1 country ID
1371
+			if ($country_array[0] == $country_id) {
1372
+				// note: index 2 is the ISO
1373
+				$country_iso = $country_array[2];
1374
+				break;
1375
+			}
1376
+		}
1377
+		return $country_iso;
1378
+	}
1379
+
1380
+
1381
+
1382
+	/**
1383
+	 * Gets the ISO3 for the
1384
+	 *
1385
+	 * @return string
1386
+	 */
1387
+	public function get_default_country_iso()
1388
+	{
1389
+		$old_org_options = get_option('events_organization_settings');
1390
+		$iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1391
+		return $iso;
1392
+	}
1393
+
1394
+
1395
+
1396
+	/**
1397
+	 * Converst a 3.1 payment status to its equivalent 4.1 regisration status
1398
+	 *
1399
+	 * @param string  $payment_status                   possible value for 3.1's evens_attendee.payment_status
1400
+	 * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's
1401
+	 *                                                  default payment status, the event's default payment status, or
1402
+	 *                                                  the attendee's payment status) required pre-approval.
1403
+	 * @return string STS_ID for use in 4.1
1404
+	 */
1405
+	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false)
1406
+	{
1407
+		// EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1408
+		if ($this_thing_required_pre_approval) {
1409
+			return 'RNA';
1410
+		} else {
1411
+			$mapping = $default_reg_stati_conversions = array(
1412
+					'Completed'        => 'RAP',
1413
+					''                 => 'RPP',
1414
+					'Incomplete'       => 'RPP',
1415
+					'Pending'          => 'RAP',
1416
+					// stati that only occurred on 3.1 attendees:
1417
+					'Payment Declined' => 'RPP',
1418
+					'Not Completed'    => 'RPP',
1419
+					'Cancelled'        => 'RPP',
1420
+					'Declined'         => 'RPP',
1421
+			);
1422
+		}
1423
+		return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA';
1424
+	}
1425
+
1426
+
1427
+
1428
+	/**
1429
+	 * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1430
+	 * and sets it as the featured image on the CPT event
1431
+	 *
1432
+	 * @param type                            $old_event
1433
+	 * @param type                            $new_cpt_id
1434
+	 * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1435
+	 * @return boolean whether or not we had to do the big job of creating an image attachment
1436
+	 */
1437
+	public function convert_image_url_to_attachment_and_attach_to_post(
1438
+		$guid,
1439
+		$new_cpt_id,
1440
+		EE_Data_Migration_Script_Stage $migration_stage
1441
+	) {
1442
+		$created_attachment_post = false;
1443
+		$guid = $this->_get_original_guid($guid);
1444
+		if ($guid) {
1445
+			// check for an existing attachment post with this guid
1446
+			$attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1447
+			if (! $attachment_post_id) {
1448
+				// post thumbnail with that GUID doesn't exist, we should create one
1449
+				$attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1450
+				$created_attachment_post = true;
1451
+			}
1452
+			// double-check we actually have an attachment post
1453
+			if ($attachment_post_id) {
1454
+				update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1455
+			} else {
1456
+				$migration_stage->add_error(sprintf(esc_html__(
1457
+					"Could not update event image %s for CPT with ID %d, but attachments post ID is %d",
1458
+					"event_espresso"
1459
+				), $guid, $new_cpt_id, $attachment_post_id));
1460
+			}
1461
+		}
1462
+		return $created_attachment_post;
1463
+	}
1464
+
1465
+
1466
+
1467
+	/**
1468
+	 * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead
1469
+	 * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype,
1470
+	 * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of
1471
+	 * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it
1472
+	 * exists
1473
+	 *
1474
+	 * @param string $guid_in_old_event
1475
+	 * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1476
+	 */
1477
+	private function _get_original_guid($guid_in_old_event)
1478
+	{
1479
+		$original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1480
+		// do a head request to verify the file exists
1481
+		$head_response = wp_remote_head($original_guid);
1482
+		if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1483
+			return $original_guid;
1484
+		} else {
1485
+			return $guid_in_old_event;
1486
+		}
1487
+	}
1488
+
1489
+
1490
+
1491
+	/**
1492
+	 * Creates an image attachment post for the GUID. If the GUID points to a remote image,
1493
+	 * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1494
+	 * thumbnails)
1495
+	 *
1496
+	 * @param type                           $guid
1497
+	 * @param EE_Data_Migration_Script_Stage $migration_stage
1498
+	 * @return int
1499
+	 */
1500
+	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1501
+	{
1502
+		if (! $guid) {
1503
+			$migration_stage->add_error(sprintf(esc_html__(
1504
+				"Cannot create image attachment for a blank GUID!",
1505
+				"event_espresso"
1506
+			)));
1507
+			return 0;
1508
+		}
1509
+		$wp_filetype = wp_check_filetype(basename($guid), null);
1510
+		$wp_upload_dir = wp_upload_dir();
1511
+		// if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1512
+		if (strpos($guid, $wp_upload_dir['url']) === false) {
1513
+			// image is located remotely. download it and place it in the uploads directory
1514
+			if (! is_readable($guid)) {
1515
+				$migration_stage->add_error(sprintf(esc_html__(
1516
+					"Could not create image attachment from non-existent file: %s",
1517
+					"event_espresso"
1518
+				), $guid));
1519
+				return 0;
1520
+			}
1521
+			$contents = file_get_contents($guid);
1522
+			if ($contents === false) {
1523
+				$migration_stage->add_error(sprintf(esc_html__(
1524
+					"Could not read image at %s, and therefore couldnt create an attachment post for it.",
1525
+					"event_espresso"
1526
+				), $guid));
1527
+				return false;
1528
+			}
1529
+			$local_filepath = $wp_upload_dir['path'] . '/' . basename($guid);
1530
+			$savefile = fopen($local_filepath, 'w');
1531
+			fwrite($savefile, $contents);
1532
+			fclose($savefile);
1533
+			$guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1534
+		} else {
1535
+			$local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1536
+		}
1537
+		$attachment = array(
1538
+				'guid'           => $guid,
1539
+				'post_mime_type' => $wp_filetype['type'],
1540
+				'post_title'     => preg_replace('/\.[^.]+$/', '', basename($guid)),
1541
+				'post_content'   => '',
1542
+				'post_status'    => 'inherit',
1543
+		);
1544
+		$attach_id = wp_insert_attachment($attachment, $guid);
1545
+		if (! $attach_id) {
1546
+			$migration_stage->add_error(sprintf(esc_html__(
1547
+				"Could not create image attachment post from image '%s'. Attachment data was %s.",
1548
+				"event_espresso"
1549
+			), $guid, $this->_json_encode($attachment)));
1550
+			return $attach_id;
1551
+		}
1552
+		// you must first include the image.php file
1553
+		// for the function wp_generate_attachment_metadata() to work
1554
+		require_once(ABSPATH . 'wp-admin/includes/image.php');
1555
+		$attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1556
+		if (! $attach_data) {
1557
+			$migration_stage->add_error(sprintf(esc_html__(
1558
+				"Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1559
+				"event_espresso"
1560
+			), $attach_id, $local_filepath, $guid));
1561
+			return $attach_id;
1562
+		}
1563
+		$metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1564
+		if (! $metadata_save_result) {
1565
+			$migration_stage->add_error(sprintf(esc_html__(
1566
+				"Could not update attachment metadata for attachment %d with data %s",
1567
+				"event_espresso"
1568
+			), $attach_id, $this->_json_encode($attach_data)));
1569
+		}
1570
+		return $attach_id;
1571
+	}
1572
+
1573
+
1574
+
1575
+	/**
1576
+	 * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself),
1577
+	 * and returns its ID.
1578
+	 *
1579
+	 * @global type  $wpdb
1580
+	 * @param string $guid
1581
+	 * @return int
1582
+	 */
1583
+	private function _get_image_attachment_id_by_GUID($guid)
1584
+	{
1585
+		global $wpdb;
1586
+		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1587
+		return $attachment_id;
1588
+	}
1589
+
1590
+
1591
+
1592
+	/**
1593
+	 * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1594
+	 * (and optionally a timezone; if none is given, the wp default is used)
1595
+	 *
1596
+	 * @param EE_Data_Migration_Script_base $stage
1597
+	 * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1598
+	 *                                                   UTC time for
1599
+	 * @param string                        $DATETIME_string
1600
+	 * @param string                        $timezone
1601
+	 * @return string
1602
+	 */
1603
+	public function convert_date_string_to_utc(
1604
+		EE_Data_Migration_Script_Stage $stage,
1605
+		$row_of_data,
1606
+		$DATETIME_string,
1607
+		$timezone = null
1608
+	) {
1609
+		$original_tz = $timezone;
1610
+		if (! $timezone) {
1611
+			$timezone = $this->_get_wp_timezone();
1612
+		}
1613
+		if (! $timezone) {
1614
+			$stage->add_error(sprintf(
1615
+				esc_html__("Could not find timezone given %s for %s", "event_espresso"),
1616
+				$original_tz,
1617
+				$row_of_data
1618
+			));
1619
+			$timezone = 'UTC';
1620
+		}
1621
+		try {
1622
+			$date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1623
+			EEH_DTT_Helper::setTimezone($date_obj, new DateTimeZone('UTC'));
1624
+		} catch (Exception $e) {
1625
+			$stage->add_error(sprintf(esc_html__(
1626
+				"Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.",
1627
+				"event_espresso"
1628
+			), $DATETIME_string, $timezone));
1629
+			$date_obj = new DateTime();
1630
+		}
1631
+		return $date_obj->format('Y-m-d H:i:s');
1632
+	}
1633
+
1634
+
1635
+
1636
+	/**
1637
+	 * Gets the default timezone string from wordpress (even if they set a gmt offset)
1638
+	 *
1639
+	 * @return string
1640
+	 */
1641
+	private function _get_wp_timezone()
1642
+	{
1643
+		$timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1644
+		// if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1645
+		if (empty($timezone)) {
1646
+			// let's get a the WordPress UTC offset
1647
+			$offset = get_option('gmt_offset');
1648
+			$timezone = $this->timezone_convert_to_string_from_offset($offset);
1649
+		}
1650
+		return $timezone;
1651
+	}
1652
+
1653
+
1654
+
1655
+	/**
1656
+	 * Gets the wordpress timezone string from a UTC offset
1657
+	 *
1658
+	 * @param int $offset
1659
+	 * @return boolean
1660
+	 */
1661
+	private function timezone_convert_to_string_from_offset($offset)
1662
+	{
1663
+		// 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
1664
+		$offset *= 3600; // convert hour offset to seconds
1665
+		$abbrarray = timezone_abbreviations_list();
1666
+		foreach ($abbrarray as $abbr) {
1667
+			foreach ($abbr as $city) {
1668
+				if ($city['offset'] == $offset) {
1669
+					return $city['timezone_id'];
1670
+				}
1671
+			}
1672
+		}
1673
+		return false;
1674
+	}
1675
+
1676
+
1677
+
1678
+	public function migration_page_hooks()
1679
+	{
1680
+		add_filter(
1681
+			'FHEE__ee_migration_page__header',
1682
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1683
+			10,
1684
+			3
1685
+		);
1686
+		add_filter(
1687
+			'FHEE__ee_migration_page__p_after_header',
1688
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1689
+			10,
1690
+			2
1691
+		);
1692
+		add_filter(
1693
+			'FHEE__ee_migration_page__option_1_main',
1694
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1695
+			10,
1696
+			3
1697
+		);
1698
+		add_filter(
1699
+			'FHEE__ee_migration_page__option_1_button_text',
1700
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1701
+			10,
1702
+			3
1703
+		);
1704
+		add_action(
1705
+			'AHEE__ee_migration_page__option_1_extra_details',
1706
+			array($this, '_migration_page_hook_option_1_extra_details'),
1707
+			10,
1708
+			3
1709
+		);
1710
+		add_filter(
1711
+			'FHEE__ee_migration_page__option_2_main',
1712
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1713
+			10,
1714
+			4
1715
+		);
1716
+		add_filter(
1717
+			'FHEE__ee_migration_page__option_2_button_text',
1718
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1719
+			10,
1720
+			2
1721
+		);
1722
+		add_filter(
1723
+			'FHEE__ee_migration_page__option_2_details',
1724
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1725
+			10,
1726
+			2
1727
+		);
1728
+		add_action(
1729
+			'AHEE__ee_migration_page__after_migration_options_table',
1730
+			array($this, '_migration_page_hook_after_migration_options_table')
1731
+		);
1732
+		add_filter(
1733
+			'FHEE__ee_migration_page__done_migration_header',
1734
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1735
+			10,
1736
+			2
1737
+		);
1738
+		add_filter(
1739
+			'FHEE__ee_migration_page__p_after_done_migration_header',
1740
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1741
+			10,
1742
+			2
1743
+		);
1744
+		add_filter(
1745
+			'FHEE__ee_migration_page__migration_options_template',
1746
+			array($this,'use_migration_options_from_ee3_template')
1747
+		);
1748
+	}
1749
+
1750
+
1751
+
1752
+	public function _migrate_page_hook_simplify_version_strings(
1753
+		$old_content,
1754
+		$current_db_state,
1755
+		$next_db_state,
1756
+		$ultimate_db_state = null
1757
+	) {
1758
+		return str_replace(
1759
+			array($current_db_state, $next_db_state, $ultimate_db_state),
1760
+			array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')),
1761
+			$old_content
1762
+		);
1763
+	}
1764
+
1765
+
1766
+
1767
+	public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state)
1768
+	{
1769
+		return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content);
1770
+	}
1771
+
1772
+
1773
+
1774
+	public function _migration_page_hook_option_1_extra_details()
1775
+	{
1776
+		?>
1777 1777
         <p><?php printf(esc_html__(
1778
-            "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",
1779
-            "event_espresso"
1780
-        )); ?></p><?php
1781
-    }
1778
+			"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",
1779
+			"event_espresso"
1780
+		)); ?></p><?php
1781
+	}
1782 1782
 
1783 1783
 
1784 1784
 
1785
-    public function _migration_page_hook_after_migration_options_table()
1786
-    {
1787
-        ?><p class="ee-attention">
1785
+	public function _migration_page_hook_after_migration_options_table()
1786
+	{
1787
+		?><p class="ee-attention">
1788 1788
         <strong><span class="reminder-spn">
1789 1789
                 <?php esc_html_e(
1790
-                    "Important note to those using Event Espresso 3 addons: ",
1791
-                    "event_espresso"
1792
-                ); ?></span></strong>
1790
+					"Important note to those using Event Espresso 3 addons: ",
1791
+					"event_espresso"
1792
+				); ?></span></strong>
1793 1793
         <br/>
1794 1794
         <?php esc_html_e(
1795
-            "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.",
1796
-            "event_espresso"
1797
-        ); ?>
1795
+			"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.",
1796
+			"event_espresso"
1797
+		); ?>
1798 1798
         </p><?php
1799
-    }
1799
+	}
1800 1800
 
1801 1801
 
1802 1802
 
1803
-    /**
1804
-     * When showing the migration options, show more options and info than normal (ie, give folks the option
1805
-     * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because
1806
-     * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea).
1807
-     * @param $template_filepath
1808
-     * @return string
1809
-     */
1810
-    public function use_migration_options_from_ee3_template($template_filepath)
1811
-    {
1812
-        return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1813
-    }
1803
+	/**
1804
+	 * When showing the migration options, show more options and info than normal (ie, give folks the option
1805
+	 * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because
1806
+	 * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea).
1807
+	 * @param $template_filepath
1808
+	 * @return string
1809
+	 */
1810
+	public function use_migration_options_from_ee3_template($template_filepath)
1811
+	{
1812
+		return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1813
+	}
1814 1814
 }
Please login to merge, or discard this patch.
form_sections/strategies/layout/EE_Div_Per_Section_Layout.strategy.php 1 patch
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -11,166 +11,166 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Div_Per_Section_Layout extends EE_Form_Section_Layout_Base
13 13
 {
14
-    /**
15
-     * opening div tag for a form
16
-     *
17
-     * @return string
18
-     */
19
-    public function layout_form_begin()
20
-    {
21
-        return EEH_HTML::div(
22
-            '',
23
-            $this->_form_section->html_id(),
24
-            $this->_form_section->html_class(),
25
-            $this->_form_section->html_style()
26
-        );
27
-    }
14
+	/**
15
+	 * opening div tag for a form
16
+	 *
17
+	 * @return string
18
+	 */
19
+	public function layout_form_begin()
20
+	{
21
+		return EEH_HTML::div(
22
+			'',
23
+			$this->_form_section->html_id(),
24
+			$this->_form_section->html_class(),
25
+			$this->_form_section->html_style()
26
+		);
27
+	}
28 28
 
29 29
 
30 30
 
31
-    /**
32
-     * Lays out the row for the input, including label and errors
33
-     *
34
-     * @param EE_Form_Input_Base $input
35
-     * @return string
36
-     * @throws \EE_Error
37
-     */
38
-    public function layout_input($input)
39
-    {
40
-        $html = '';
41
-        // set something unique for the id
42
-        $html_id = (string) $input->html_id() !== ''
43
-            ? (string) $input->html_id()
44
-            : spl_object_hash($input);
45
-        // and add a generic input type class
46
-        $html_class = $this->processHtmlClasses(
47
-            sanitize_key(str_replace('_', '-', get_class($input))),
48
-            '-dv'
49
-        );
50
-        if ($input instanceof EE_Hidden_Input) {
51
-            $html .= EEH_HTML::nl() . $input->get_html_for_input();
52
-        } elseif ($input instanceof EE_Submit_Input) {
53
-            $input_class = $this->processHtmlClasses($input->html_class(), '-submit-dv');
54
-            $html .= EEH_HTML::div(
55
-                $input->get_html_for_input(),
56
-                $html_id . '-submit-dv',
57
-                "$input_class $html_class"
58
-            );
59
-        } elseif ($input instanceof EE_Select_Input) {
60
-            $input_class = $this->processHtmlClasses($input->html_class(), '-input-dv');
61
-            $html .= EEH_HTML::div(
62
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
63
-                EEH_HTML::nl() . $input->get_html_for_errors() .
64
-                EEH_HTML::nl() . $input->get_html_for_input() .
65
-                EEH_HTML::nl() . $input->get_html_for_help(),
66
-                $html_id . '-input-dv',
67
-                "$input_class $html_class"
68
-            );
69
-        } elseif ($input instanceof EE_Form_Input_With_Options_Base) {
70
-            $input_class = $this->processHtmlClasses($input->html_class(), '-input-dv');
71
-            $html .= EEH_HTML::div(
72
-                EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
73
-                EEH_HTML::nl() . $input->get_html_for_errors() .
74
-                EEH_HTML::nl() . $input->get_html_for_input() .
75
-                EEH_HTML::nl() . $input->get_html_for_help(),
76
-                $html_id . '-input-dv',
77
-                "$input_class $html_class"
78
-            );
79
-        } else {
80
-            $input_class = $this->processHtmlClasses($input->html_class(), '-input-dv');
81
-            $html .= EEH_HTML::div(
82
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
83
-                EEH_HTML::nl() . $input->get_html_for_errors() .
84
-                EEH_HTML::nl() . $input->get_html_for_input() .
85
-                EEH_HTML::nl() . $input->get_html_for_help(),
86
-                $html_id . '-input-dv',
87
-                "$input_class $html_class"
88
-            );
89
-        }
90
-        return $html;
91
-    }
31
+	/**
32
+	 * Lays out the row for the input, including label and errors
33
+	 *
34
+	 * @param EE_Form_Input_Base $input
35
+	 * @return string
36
+	 * @throws \EE_Error
37
+	 */
38
+	public function layout_input($input)
39
+	{
40
+		$html = '';
41
+		// set something unique for the id
42
+		$html_id = (string) $input->html_id() !== ''
43
+			? (string) $input->html_id()
44
+			: spl_object_hash($input);
45
+		// and add a generic input type class
46
+		$html_class = $this->processHtmlClasses(
47
+			sanitize_key(str_replace('_', '-', get_class($input))),
48
+			'-dv'
49
+		);
50
+		if ($input instanceof EE_Hidden_Input) {
51
+			$html .= EEH_HTML::nl() . $input->get_html_for_input();
52
+		} elseif ($input instanceof EE_Submit_Input) {
53
+			$input_class = $this->processHtmlClasses($input->html_class(), '-submit-dv');
54
+			$html .= EEH_HTML::div(
55
+				$input->get_html_for_input(),
56
+				$html_id . '-submit-dv',
57
+				"$input_class $html_class"
58
+			);
59
+		} elseif ($input instanceof EE_Select_Input) {
60
+			$input_class = $this->processHtmlClasses($input->html_class(), '-input-dv');
61
+			$html .= EEH_HTML::div(
62
+				EEH_HTML::nl(1) . $input->get_html_for_label() .
63
+				EEH_HTML::nl() . $input->get_html_for_errors() .
64
+				EEH_HTML::nl() . $input->get_html_for_input() .
65
+				EEH_HTML::nl() . $input->get_html_for_help(),
66
+				$html_id . '-input-dv',
67
+				"$input_class $html_class"
68
+			);
69
+		} elseif ($input instanceof EE_Form_Input_With_Options_Base) {
70
+			$input_class = $this->processHtmlClasses($input->html_class(), '-input-dv');
71
+			$html .= EEH_HTML::div(
72
+				EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
73
+				EEH_HTML::nl() . $input->get_html_for_errors() .
74
+				EEH_HTML::nl() . $input->get_html_for_input() .
75
+				EEH_HTML::nl() . $input->get_html_for_help(),
76
+				$html_id . '-input-dv',
77
+				"$input_class $html_class"
78
+			);
79
+		} else {
80
+			$input_class = $this->processHtmlClasses($input->html_class(), '-input-dv');
81
+			$html .= EEH_HTML::div(
82
+				EEH_HTML::nl(1) . $input->get_html_for_label() .
83
+				EEH_HTML::nl() . $input->get_html_for_errors() .
84
+				EEH_HTML::nl() . $input->get_html_for_input() .
85
+				EEH_HTML::nl() . $input->get_html_for_help(),
86
+				$html_id . '-input-dv',
87
+				"$input_class $html_class"
88
+			);
89
+		}
90
+		return $html;
91
+	}
92 92
 
93 93
 
94
-    /**
95
-     * appends one or more css classes in a string with the provided suffix
96
-     *
97
-     * @param array|string $classes
98
-     * @param string $suffix
99
-     * @return string
100
-     * @since 4.10.31.p
101
-     */
102
-    private function processHtmlClasses($classes, string $suffix): string
103
-    {
104
-        $html_classes = [];
105
-        $classes = is_string($classes) ? explode(' ', $classes) : $classes;
106
-        $classes = (array) $classes;
107
-        foreach ($classes as $class) {
108
-            // don't append suffix if class already has "-js" suffix
109
-            $html_classes[] = strpos($class, '-js') !== strlen($class) - 3
110
-                ? "$class$suffix"
111
-                : $class;
112
-        }
113
-        return implode(' ', $html_classes);
114
-    }
94
+	/**
95
+	 * appends one or more css classes in a string with the provided suffix
96
+	 *
97
+	 * @param array|string $classes
98
+	 * @param string $suffix
99
+	 * @return string
100
+	 * @since 4.10.31.p
101
+	 */
102
+	private function processHtmlClasses($classes, string $suffix): string
103
+	{
104
+		$html_classes = [];
105
+		$classes = is_string($classes) ? explode(' ', $classes) : $classes;
106
+		$classes = (array) $classes;
107
+		foreach ($classes as $class) {
108
+			// don't append suffix if class already has "-js" suffix
109
+			$html_classes[] = strpos($class, '-js') !== strlen($class) - 3
110
+				? "$class$suffix"
111
+				: $class;
112
+		}
113
+		return implode(' ', $html_classes);
114
+	}
115 115
 
116 116
 
117 117
 
118
-    /**
119
-     *
120
-     * _display_label_for_option_type_question
121
-     * Gets the HTML for the 'label', which is just text for this (because labels
122
-     * should be for each input)
123
-     *
124
-     * @param EE_Form_Input_With_Options_Base $input
125
-     * @return string
126
-     */
127
-    protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input)
128
-    {
129
-        if ($input->display_html_label_text()) {
130
-            $html_label_text = $input->html_label_text();
131
-            $label_html = EEH_HTML::div(
132
-                $input->required()
133
-                    ? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk')
134
-                    : $html_label_text,
135
-                $input->html_label_id(),
136
-                $input->required()
137
-                    ? 'ee-required-label ' . $input->html_label_class()
138
-                    : $input->html_label_class(),
139
-                $input->html_label_style(),
140
-                $input->other_html_attributes()
141
-            );
142
-            // if no content was provided to EEH_HTML::div() above (ie: an empty label),
143
-            // then we need to close the div manually
144
-            if (empty($html_label_text)) {
145
-                $label_html .= EEH_HTML::divx($input->html_label_id(), $input->html_label_class());
146
-            }
147
-            return $label_html;
148
-        }
149
-        return '';
150
-    }
118
+	/**
119
+	 *
120
+	 * _display_label_for_option_type_question
121
+	 * Gets the HTML for the 'label', which is just text for this (because labels
122
+	 * should be for each input)
123
+	 *
124
+	 * @param EE_Form_Input_With_Options_Base $input
125
+	 * @return string
126
+	 */
127
+	protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input)
128
+	{
129
+		if ($input->display_html_label_text()) {
130
+			$html_label_text = $input->html_label_text();
131
+			$label_html = EEH_HTML::div(
132
+				$input->required()
133
+					? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk')
134
+					: $html_label_text,
135
+				$input->html_label_id(),
136
+				$input->required()
137
+					? 'ee-required-label ' . $input->html_label_class()
138
+					: $input->html_label_class(),
139
+				$input->html_label_style(),
140
+				$input->other_html_attributes()
141
+			);
142
+			// if no content was provided to EEH_HTML::div() above (ie: an empty label),
143
+			// then we need to close the div manually
144
+			if (empty($html_label_text)) {
145
+				$label_html .= EEH_HTML::divx($input->html_label_id(), $input->html_label_class());
146
+			}
147
+			return $label_html;
148
+		}
149
+		return '';
150
+	}
151 151
 
152 152
 
153 153
 
154
-    /**
155
-     * Lays out a row for the subsection
156
-     *
157
-     * @param EE_Form_Section_Proper $form_section
158
-     * @return string
159
-     */
160
-    public function layout_subsection($form_section)
161
-    {
162
-        return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
163
-    }
154
+	/**
155
+	 * Lays out a row for the subsection
156
+	 *
157
+	 * @param EE_Form_Section_Proper $form_section
158
+	 * @return string
159
+	 */
160
+	public function layout_subsection($form_section)
161
+	{
162
+		return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
163
+	}
164 164
 
165 165
 
166 166
 
167
-    /**
168
-     * closing div tag for a form
169
-     *
170
-     * @return string
171
-     */
172
-    public function layout_form_end()
173
-    {
174
-        return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class());
175
-    }
167
+	/**
168
+	 * closing div tag for a form
169
+	 *
170
+	 * @return string
171
+	 */
172
+	public function layout_form_end()
173
+	{
174
+		return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class());
175
+	}
176 176
 }
Please login to merge, or discard this patch.
core/services/request/sanitizers/AllowedTags.php 1 patch
Indentation   +248 added lines, -248 removed lines patch added patch discarded remove patch
@@ -12,281 +12,281 @@
 block discarded – undo
12 12
  */
13 13
 class AllowedTags
14 14
 {
15
-    /**
16
-     * @var array[]
17
-     */
18
-    private static $attributes = [
19
-        'accept-charset'    => 1,
20
-        'action'            => 1,
21
-        'alt'               => 1,
22
-        'allow'             => 1,
23
-        'allowfullscreen'   => 1,
24
-        'align'             => 1,
25
-        'aria-*'            => 1,
26
-        'autocomplete'      => 1,
27
-        'checked'           => 1,
28
-        'class'             => 1,
29
-        'cols'              => 1,
30
-        'content'           => 1,
31
-        'data-*'            => 1,
32
-        'dir'               => 1,
33
-        'disabled'          => 1,
34
-        'enctype'           => 1,
35
-        'for'               => 1,
36
-        'frameborder'       => 1,
37
-        'height'            => 1,
38
-        'href'              => 1,
39
-        'id'                => 1,
40
-        'itemprop'          => 1,
41
-        'itemscope'         => 1,
42
-        'itemtype'          => 1,
43
-        'label'             => 1,
44
-        'lang'              => 1,
45
-        'max'               => 1,
46
-        'maxlength'         => 1,
47
-        'method'            => 1,
48
-        'min'               => 1,
49
-        'multiple'          => 1,
50
-        'name'              => 1,
51
-        'novalidate'        => 1,
52
-        'placeholder'       => 1,
53
-        'readonly'          => 1,
54
-        'rel'               => 1,
55
-        'required'          => 1,
56
-        'rows'              => 1,
57
-        'selected'          => 1,
58
-        'src'               => 1,
59
-        'size'              => 1,
60
-        'style'             => 1,
61
-        'step'              => 1,
62
-        'tabindex'          => 1,
63
-        'target'            => 1,
64
-        'title'             => 1,
65
-        'type'              => 1,
66
-        'value'             => 1,
67
-        'width'             => 1,
68
-        'topmargin'         => 1,
69
-        'leftmargin'        => 1,
70
-        'marginheight'      => 1,
71
-        'marginwidth'       => 1,
72
-        'property'          => 1,
73
-        'bgcolor'           => 1,
74
-        'media'             => 1,
75
-        'cellpadding'       => 1,
76
-        'cellspacing'       => 1,
77
-        'border'            => 1,
78
-    ];
15
+	/**
16
+	 * @var array[]
17
+	 */
18
+	private static $attributes = [
19
+		'accept-charset'    => 1,
20
+		'action'            => 1,
21
+		'alt'               => 1,
22
+		'allow'             => 1,
23
+		'allowfullscreen'   => 1,
24
+		'align'             => 1,
25
+		'aria-*'            => 1,
26
+		'autocomplete'      => 1,
27
+		'checked'           => 1,
28
+		'class'             => 1,
29
+		'cols'              => 1,
30
+		'content'           => 1,
31
+		'data-*'            => 1,
32
+		'dir'               => 1,
33
+		'disabled'          => 1,
34
+		'enctype'           => 1,
35
+		'for'               => 1,
36
+		'frameborder'       => 1,
37
+		'height'            => 1,
38
+		'href'              => 1,
39
+		'id'                => 1,
40
+		'itemprop'          => 1,
41
+		'itemscope'         => 1,
42
+		'itemtype'          => 1,
43
+		'label'             => 1,
44
+		'lang'              => 1,
45
+		'max'               => 1,
46
+		'maxlength'         => 1,
47
+		'method'            => 1,
48
+		'min'               => 1,
49
+		'multiple'          => 1,
50
+		'name'              => 1,
51
+		'novalidate'        => 1,
52
+		'placeholder'       => 1,
53
+		'readonly'          => 1,
54
+		'rel'               => 1,
55
+		'required'          => 1,
56
+		'rows'              => 1,
57
+		'selected'          => 1,
58
+		'src'               => 1,
59
+		'size'              => 1,
60
+		'style'             => 1,
61
+		'step'              => 1,
62
+		'tabindex'          => 1,
63
+		'target'            => 1,
64
+		'title'             => 1,
65
+		'type'              => 1,
66
+		'value'             => 1,
67
+		'width'             => 1,
68
+		'topmargin'         => 1,
69
+		'leftmargin'        => 1,
70
+		'marginheight'      => 1,
71
+		'marginwidth'       => 1,
72
+		'property'          => 1,
73
+		'bgcolor'           => 1,
74
+		'media'             => 1,
75
+		'cellpadding'       => 1,
76
+		'cellspacing'       => 1,
77
+		'border'            => 1,
78
+	];
79 79
 
80 80
 
81
-    /**
82
-     * @var array
83
-     */
84
-    private static $tags = [
85
-        'a',
86
-        'abbr',
87
-        'b',
88
-        'br',
89
-        'code',
90
-        'div',
91
-        'em',
92
-        'h1',
93
-        'h2',
94
-        'h3',
95
-        'h4',
96
-        'h5',
97
-        'h6',
98
-        'hr',
99
-        'i',
100
-        'img',
101
-        'li',
102
-        'ol',
103
-        'p',
104
-        'pre',
105
-        'small',
106
-        'span',
107
-        'strong',
108
-        'table',
109
-        'td',
110
-        'tr',
111
-        'ul',
112
-    ];
81
+	/**
82
+	 * @var array
83
+	 */
84
+	private static $tags = [
85
+		'a',
86
+		'abbr',
87
+		'b',
88
+		'br',
89
+		'code',
90
+		'div',
91
+		'em',
92
+		'h1',
93
+		'h2',
94
+		'h3',
95
+		'h4',
96
+		'h5',
97
+		'h6',
98
+		'hr',
99
+		'i',
100
+		'img',
101
+		'li',
102
+		'ol',
103
+		'p',
104
+		'pre',
105
+		'small',
106
+		'span',
107
+		'strong',
108
+		'table',
109
+		'td',
110
+		'tr',
111
+		'ul',
112
+	];
113 113
 
114 114
 
115
-    /**
116
-     * @var array
117
-     */
118
-    private static $allowed_tags;
115
+	/**
116
+	 * @var array
117
+	 */
118
+	private static $allowed_tags;
119 119
 
120 120
 
121
-    /**
122
-     * @var array
123
-     */
124
-    private static $allowed_with_embed_tags;
121
+	/**
122
+	 * @var array
123
+	 */
124
+	private static $allowed_with_embed_tags;
125 125
 
126 126
 
127
-    /**
128
-     * @var array
129
-     */
130
-    private static $allowed_with_form_tags;
127
+	/**
128
+	 * @var array
129
+	 */
130
+	private static $allowed_with_form_tags;
131 131
 
132 132
 
133
-    /**
134
-     * @var array
135
-     */
136
-    private static $allowed_with_script_and_style_tags;
133
+	/**
134
+	 * @var array
135
+	 */
136
+	private static $allowed_with_script_and_style_tags;
137 137
 
138
-    /**
139
-     * @var array
140
-     */
141
-    private static $allowed_with_full_tags;
138
+	/**
139
+	 * @var array
140
+	 */
141
+	private static $allowed_with_full_tags;
142 142
 
143 143
 
144
-    /**
145
-     * merges additional tags and attributes into the WP post tags
146
-     */
147
-    private static function initializeAllowedTags()
148
-    {
149
-        $allowed_post_tags = wp_kses_allowed_html('post');
150
-        $allowed_tags = [];
151
-        foreach (AllowedTags::$tags as $tag) {
152
-            $allowed_tags[ $tag ] = AllowedTags::$attributes;
153
-        }
154
-        AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags);
155
-    }
144
+	/**
145
+	 * merges additional tags and attributes into the WP post tags
146
+	 */
147
+	private static function initializeAllowedTags()
148
+	{
149
+		$allowed_post_tags = wp_kses_allowed_html('post');
150
+		$allowed_tags = [];
151
+		foreach (AllowedTags::$tags as $tag) {
152
+			$allowed_tags[ $tag ] = AllowedTags::$attributes;
153
+		}
154
+		AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags);
155
+	}
156 156
 
157 157
 
158
-    /**
159
-     * merges embed tags and attributes into the EE all tags
160
-     */
161
-    private static function initializeWithEmbedTags()
162
-    {
163
-        $all_tags = AllowedTags::getAllowedTags();
164
-        $embed_tags = [
165
-            'iframe' => AllowedTags::$attributes
166
-        ];
167
-        AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags);
168
-    }
158
+	/**
159
+	 * merges embed tags and attributes into the EE all tags
160
+	 */
161
+	private static function initializeWithEmbedTags()
162
+	{
163
+		$all_tags = AllowedTags::getAllowedTags();
164
+		$embed_tags = [
165
+			'iframe' => AllowedTags::$attributes
166
+		];
167
+		AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags);
168
+	}
169 169
 
170 170
 
171
-    /**
172
-     * merges form tags and attributes into the EE all tags
173
-     */
174
-    private static function initializeWithFormTags()
175
-    {
176
-        $all_tags = AllowedTags::getAllowedTags();
177
-        $form_tags = [
178
-            'form'     => AllowedTags::$attributes,
179
-            'label'    => AllowedTags::$attributes,
180
-            'input'    => AllowedTags::$attributes,
181
-            'select'   => AllowedTags::$attributes,
182
-            'option'   => AllowedTags::$attributes,
183
-            'optgroup' => AllowedTags::$attributes,
184
-            'textarea' => AllowedTags::$attributes,
185
-            'button'   => AllowedTags::$attributes,
186
-            'fieldset' => AllowedTags::$attributes,
187
-            'output'   => AllowedTags::$attributes,
188
-        ];
189
-        AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags);
190
-    }
171
+	/**
172
+	 * merges form tags and attributes into the EE all tags
173
+	 */
174
+	private static function initializeWithFormTags()
175
+	{
176
+		$all_tags = AllowedTags::getAllowedTags();
177
+		$form_tags = [
178
+			'form'     => AllowedTags::$attributes,
179
+			'label'    => AllowedTags::$attributes,
180
+			'input'    => AllowedTags::$attributes,
181
+			'select'   => AllowedTags::$attributes,
182
+			'option'   => AllowedTags::$attributes,
183
+			'optgroup' => AllowedTags::$attributes,
184
+			'textarea' => AllowedTags::$attributes,
185
+			'button'   => AllowedTags::$attributes,
186
+			'fieldset' => AllowedTags::$attributes,
187
+			'output'   => AllowedTags::$attributes,
188
+		];
189
+		AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags);
190
+	}
191 191
 
192 192
 
193
-    /**
194
-     * merges form script and style tags and attributes into the EE all tags
195
-     */
196
-    private static function initializeWithScriptAndStyleTags()
197
-    {
198
-        $all_tags = AllowedTags::getAllowedTags();
199
-        $script_and_style_tags = [
200
-            'script' => AllowedTags::$attributes,
201
-            'style'  => AllowedTags::$attributes,
202
-            'link'   => AllowedTags::$attributes,
203
-        ];
204
-        AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags);
205
-    }
193
+	/**
194
+	 * merges form script and style tags and attributes into the EE all tags
195
+	 */
196
+	private static function initializeWithScriptAndStyleTags()
197
+	{
198
+		$all_tags = AllowedTags::getAllowedTags();
199
+		$script_and_style_tags = [
200
+			'script' => AllowedTags::$attributes,
201
+			'style'  => AllowedTags::$attributes,
202
+			'link'   => AllowedTags::$attributes,
203
+		];
204
+		AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags);
205
+	}
206 206
 
207
-    /**
208
-     * merges all head and body tags and attributes into the EE all tags
209
-     */
210
-    private static function initializeWithFullTags()
211
-    {
212
-        $all_tags = AllowedTags::getAllowedTags();
213
-        $full_tags = [
214
-            'script'    => AllowedTags::$attributes,
215
-            'style'     => AllowedTags::$attributes,
216
-            'link'      => AllowedTags::$attributes,
217
-            'title'     => AllowedTags::$attributes,
218
-            'meta'      => AllowedTags::$attributes,
219
-            'iframe'    => AllowedTags::$attributes,
220
-            'form'      => AllowedTags::$attributes,
221
-            'label'     => AllowedTags::$attributes,
222
-            'input'     => AllowedTags::$attributes,
223
-            'select'    => AllowedTags::$attributes,
224
-            'option'    => AllowedTags::$attributes,
225
-            'optgroup'  => AllowedTags::$attributes,
226
-            'textarea'  => AllowedTags::$attributes,
227
-            'button'    => AllowedTags::$attributes,
228
-            'fieldset'  => AllowedTags::$attributes,
229
-            'output'    => AllowedTags::$attributes,
230
-        ];
231
-        AllowedTags::$allowed_with_full_tags = array_merge_recursive($all_tags, $full_tags);
232
-    }
207
+	/**
208
+	 * merges all head and body tags and attributes into the EE all tags
209
+	 */
210
+	private static function initializeWithFullTags()
211
+	{
212
+		$all_tags = AllowedTags::getAllowedTags();
213
+		$full_tags = [
214
+			'script'    => AllowedTags::$attributes,
215
+			'style'     => AllowedTags::$attributes,
216
+			'link'      => AllowedTags::$attributes,
217
+			'title'     => AllowedTags::$attributes,
218
+			'meta'      => AllowedTags::$attributes,
219
+			'iframe'    => AllowedTags::$attributes,
220
+			'form'      => AllowedTags::$attributes,
221
+			'label'     => AllowedTags::$attributes,
222
+			'input'     => AllowedTags::$attributes,
223
+			'select'    => AllowedTags::$attributes,
224
+			'option'    => AllowedTags::$attributes,
225
+			'optgroup'  => AllowedTags::$attributes,
226
+			'textarea'  => AllowedTags::$attributes,
227
+			'button'    => AllowedTags::$attributes,
228
+			'fieldset'  => AllowedTags::$attributes,
229
+			'output'    => AllowedTags::$attributes,
230
+		];
231
+		AllowedTags::$allowed_with_full_tags = array_merge_recursive($all_tags, $full_tags);
232
+	}
233 233
 
234 234
 
235
-    /**
236
-     * @return array[]
237
-     */
238
-    public static function getAllowedTags()
239
-    {
240
-        if (empty(AllowedTags::$allowed_tags)) {
241
-            AllowedTags::initializeAllowedTags();
242
-        }
243
-        return AllowedTags::$allowed_tags;
244
-    }
235
+	/**
236
+	 * @return array[]
237
+	 */
238
+	public static function getAllowedTags()
239
+	{
240
+		if (empty(AllowedTags::$allowed_tags)) {
241
+			AllowedTags::initializeAllowedTags();
242
+		}
243
+		return AllowedTags::$allowed_tags;
244
+	}
245 245
 
246 246
 
247
-    /**
248
-     * @return array[]
249
-     */
250
-    public static function getWithEmbedTags()
251
-    {
252
-        if (empty(AllowedTags::$allowed_with_embed_tags)) {
253
-            AllowedTags::initializeWithEmbedTags();
254
-        }
255
-        return AllowedTags::$allowed_with_embed_tags;
256
-    }
247
+	/**
248
+	 * @return array[]
249
+	 */
250
+	public static function getWithEmbedTags()
251
+	{
252
+		if (empty(AllowedTags::$allowed_with_embed_tags)) {
253
+			AllowedTags::initializeWithEmbedTags();
254
+		}
255
+		return AllowedTags::$allowed_with_embed_tags;
256
+	}
257 257
 
258 258
 
259
-    /**
260
-     * @return array[]
261
-     */
262
-    public static function getWithFormTags()
263
-    {
264
-        if (empty(AllowedTags::$allowed_with_form_tags)) {
265
-            AllowedTags::initializeWithFormTags();
266
-        }
267
-        return AllowedTags::$allowed_with_form_tags;
268
-    }
259
+	/**
260
+	 * @return array[]
261
+	 */
262
+	public static function getWithFormTags()
263
+	{
264
+		if (empty(AllowedTags::$allowed_with_form_tags)) {
265
+			AllowedTags::initializeWithFormTags();
266
+		}
267
+		return AllowedTags::$allowed_with_form_tags;
268
+	}
269 269
 
270 270
 
271
-    /**
272
-     * @return array[]
273
-     */
274
-    public static function getWithScriptAndStyleTags()
275
-    {
276
-        if (empty(AllowedTags::$allowed_with_script_and_style_tags)) {
277
-            AllowedTags::initializeWithScriptAndStyleTags();
278
-        }
279
-        return AllowedTags::$allowed_with_script_and_style_tags;
280
-    }
271
+	/**
272
+	 * @return array[]
273
+	 */
274
+	public static function getWithScriptAndStyleTags()
275
+	{
276
+		if (empty(AllowedTags::$allowed_with_script_and_style_tags)) {
277
+			AllowedTags::initializeWithScriptAndStyleTags();
278
+		}
279
+		return AllowedTags::$allowed_with_script_and_style_tags;
280
+	}
281 281
 
282
-    /**
283
-     * @return array[]
284
-     */
285
-    public static function getWithFullTags()
286
-    {
287
-        if (empty(AllowedTags::$allowed_with_full_tags)) {
288
-            AllowedTags::initializeWithFullTags();
289
-        }
290
-        return AllowedTags::$allowed_with_full_tags;
291
-    }
282
+	/**
283
+	 * @return array[]
284
+	 */
285
+	public static function getWithFullTags()
286
+	{
287
+		if (empty(AllowedTags::$allowed_with_full_tags)) {
288
+			AllowedTags::initializeWithFullTags();
289
+		}
290
+		return AllowedTags::$allowed_with_full_tags;
291
+	}
292 292
 }
Please login to merge, or discard this patch.
modules/single_page_checkout/inc/EE_SPCO_JSON_Response.php 1 patch
Indentation   +397 added lines, -397 removed lines patch added patch discarded remove patch
@@ -14,401 +14,401 @@
 block discarded – undo
14 14
  */
15 15
 class EE_SPCO_JSON_Response
16 16
 {
17
-    /**
18
-     * @var string
19
-     */
20
-    protected $_errors = '';
21
-
22
-    /**
23
-     * @var string
24
-     */
25
-    protected $_unexpected_errors = '';
26
-
27
-    /**
28
-     * @var string
29
-     */
30
-    protected $_attention = '';
31
-
32
-    /**
33
-     * @var string
34
-     */
35
-    protected $_success = '';
36
-
37
-    /**
38
-     * @var string
39
-     */
40
-    protected $_plz_select_method_of_payment = '';
41
-
42
-    /**
43
-     * @var string
44
-     */
45
-    protected $_redirect_url = '';
46
-
47
-    /**
48
-     * @var string
49
-     */
50
-    protected $_registration_time_limit = '';
51
-
52
-    /**
53
-     * @var string
54
-     */
55
-    protected $_redirect_form = '';
56
-
57
-    /**
58
-     * @var string
59
-     */
60
-    protected $_reg_step_html = '';
61
-
62
-    /**
63
-     * @var string
64
-     */
65
-    protected $_method_of_payment = '';
66
-
67
-    /**
68
-     * @var float
69
-     */
70
-    protected $_payment_amount;
71
-
72
-    /**
73
-     * @var array
74
-     */
75
-    protected $_return_data = array();
76
-
77
-
78
-    /**
79
-     * @var array
80
-     */
81
-    protected $_validation_rules = array();
82
-
83
-
84
-    /**
85
-     *    class constructor
86
-     */
87
-    public function __construct()
88
-    {
89
-    }
90
-
91
-
92
-    /**
93
-     *    __toString
94
-     *
95
-     *        allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a  JSON encoded string
96
-     *
97
-     * @access    public
98
-     * @return    string
99
-     */
100
-    public function __toString()
101
-    {
102
-        $JSON_response = array();
103
-        // grab notices
104
-        $notices = EE_Error::get_notices(false);
105
-        $this->set_attention(isset($notices['attention']) ? $notices['attention'] : '');
106
-        $this->set_errors(isset($notices['errors']) ? $notices['errors'] : '');
107
-        $this->set_success(isset($notices['success']) ? $notices['success'] : '');
108
-        // add notices to JSON response, but only if they exist
109
-        if ($this->attention()) {
110
-            $JSON_response['attention'] = $this->attention();
111
-        }
112
-        if ($this->errors()) {
113
-            $JSON_response['errors'] = $this->errors();
114
-        }
115
-        if ($this->unexpected_errors()) {
116
-            $JSON_response['unexpected_errors'] = $this->unexpected_errors();
117
-        }
118
-        if ($this->success()) {
119
-            $JSON_response['success'] = $this->success();
120
-        }
121
-        // but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked
122
-        if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) {
123
-            $JSON_response['success'] = null;
124
-        }
125
-        // set redirect_url, IF it exists
126
-        if ($this->redirect_url()) {
127
-            $JSON_response['redirect_url'] = $this->redirect_url();
128
-        }
129
-        // set registration_time_limit, IF it exists
130
-        if ($this->registration_time_limit()) {
131
-            $JSON_response['registration_time_limit'] = $this->registration_time_limit();
132
-        }
133
-        // set payment_amount, IF it exists
134
-        if ($this->payment_amount() !== null) {
135
-            $JSON_response['payment_amount'] = $this->payment_amount();
136
-        }
137
-        // grab generic return data
138
-        $return_data = $this->return_data();
139
-        // add billing form validation rules
140
-        if ($this->validation_rules()) {
141
-            $return_data['validation_rules'] = $this->validation_rules();
142
-        }
143
-        // set reg_step_html, IF it exists
144
-        if ($this->reg_step_html()) {
145
-            $return_data['reg_step_html'] = $this->reg_step_html();
146
-        }
147
-        // set method of payment, IF it exists
148
-        if ($this->method_of_payment()) {
149
-            $return_data['method_of_payment'] = $this->method_of_payment();
150
-        }
151
-        // set "plz_select_method_of_payment" message, IF it exists
152
-        if ($this->plz_select_method_of_payment()) {
153
-            $return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment();
154
-        }
155
-        // set redirect_form, IF it exists
156
-        if ($this->redirect_form()) {
157
-            $return_data['redirect_form'] = $this->redirect_form();
158
-        }
159
-        // and finally, add return_data array to main JSON response array, IF it contains anything
160
-        // why did we add some of the above properties to the return data array?
161
-        // because it is easier and cleaner in the Javascript to deal with this way
162
-        if (! empty($return_data)) {
163
-            $JSON_response['return_data'] = $return_data;
164
-        }
165
-        // filter final array
166
-        $JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response);
167
-        // return encoded array
168
-        return (string) wp_json_encode($JSON_response);
169
-    }
170
-
171
-
172
-    /**
173
-     * @param string $attention
174
-     */
175
-    public function set_attention($attention)
176
-    {
177
-        $this->_attention = $attention;
178
-    }
179
-
180
-
181
-    /**
182
-     * @return string
183
-     */
184
-    public function attention()
185
-    {
186
-        return $this->_attention;
187
-    }
188
-
189
-
190
-    /**
191
-     * @param string $errors
192
-     */
193
-    public function set_errors($errors)
194
-    {
195
-        $this->_errors = $errors;
196
-    }
197
-
198
-
199
-    /**
200
-     * @return string
201
-     */
202
-    public function errors()
203
-    {
204
-        return $this->_errors;
205
-    }
206
-
207
-
208
-    /**
209
-     * @return string
210
-     */
211
-    public function unexpected_errors()
212
-    {
213
-        return $this->_unexpected_errors;
214
-    }
215
-
216
-
217
-    /**
218
-     * @param string $unexpected_errors
219
-     */
220
-    public function set_unexpected_errors($unexpected_errors)
221
-    {
222
-        $this->_unexpected_errors = $unexpected_errors;
223
-    }
224
-
225
-
226
-    /**
227
-     * @param string $success
228
-     */
229
-    public function set_success($success)
230
-    {
231
-        $this->_success = $success;
232
-    }
233
-
234
-
235
-    /**
236
-     * @return string
237
-     */
238
-    public function success()
239
-    {
240
-        return $this->_success;
241
-    }
242
-
243
-
244
-    /**
245
-     * @param string $method_of_payment
246
-     */
247
-    public function set_method_of_payment($method_of_payment)
248
-    {
249
-        $this->_method_of_payment = $method_of_payment;
250
-    }
251
-
252
-
253
-    /**
254
-     * @return string
255
-     */
256
-    public function method_of_payment()
257
-    {
258
-        return $this->_method_of_payment;
259
-    }
260
-
261
-
262
-    /**
263
-     * @return float
264
-     */
265
-    public function payment_amount()
266
-    {
267
-        return $this->_payment_amount;
268
-    }
269
-
270
-
271
-    /**
272
-     * @param float $payment_amount
273
-     * @throws EE_Error
274
-     */
275
-    public function set_payment_amount($payment_amount)
276
-    {
277
-        $this->_payment_amount = (float) $payment_amount;
278
-    }
279
-
280
-
281
-    /**
282
-     * @param string $next_step_html
283
-     */
284
-    public function set_reg_step_html($next_step_html)
285
-    {
286
-        $this->_reg_step_html = $next_step_html;
287
-    }
288
-
289
-
290
-    /**
291
-     * @return string
292
-     */
293
-    public function reg_step_html()
294
-    {
295
-        return $this->_reg_step_html;
296
-    }
297
-
298
-
299
-    /**
300
-     * @param string $redirect_form
301
-     */
302
-    public function set_redirect_form($redirect_form)
303
-    {
304
-        $this->_redirect_form = $redirect_form;
305
-    }
306
-
307
-
308
-    /**
309
-     * @return string
310
-     */
311
-    public function redirect_form()
312
-    {
313
-        return ! empty($this->_redirect_form) ? $this->_redirect_form : false;
314
-    }
315
-
316
-
317
-    /**
318
-     * @param string $plz_select_method_of_payment
319
-     */
320
-    public function set_plz_select_method_of_payment($plz_select_method_of_payment)
321
-    {
322
-        $this->_plz_select_method_of_payment = $plz_select_method_of_payment;
323
-    }
324
-
325
-
326
-    /**
327
-     * @return string
328
-     */
329
-    public function plz_select_method_of_payment()
330
-    {
331
-        return $this->_plz_select_method_of_payment;
332
-    }
333
-
334
-
335
-    /**
336
-     * @param string $redirect_url
337
-     */
338
-    public function set_redirect_url($redirect_url)
339
-    {
340
-        $this->_redirect_url = $redirect_url;
341
-    }
342
-
343
-
344
-    /**
345
-     * @return string
346
-     */
347
-    public function redirect_url()
348
-    {
349
-        return $this->_redirect_url;
350
-    }
351
-
352
-
353
-    /**
354
-     * @return string
355
-     */
356
-    public function registration_time_limit()
357
-    {
358
-        return $this->_registration_time_limit;
359
-    }
360
-
361
-
362
-    /**
363
-     * @param string $registration_time_limit
364
-     */
365
-    public function set_registration_time_limit($registration_time_limit)
366
-    {
367
-        $this->_registration_time_limit = $registration_time_limit;
368
-    }
369
-
370
-
371
-    /**
372
-     * @param array $return_data
373
-     */
374
-    public function set_return_data($return_data)
375
-    {
376
-        $this->_return_data = array_merge($this->_return_data, $return_data);
377
-    }
378
-
379
-
380
-    /**
381
-     * @return array
382
-     */
383
-    public function return_data()
384
-    {
385
-        return $this->_return_data;
386
-    }
387
-
388
-
389
-    /**
390
-     * @param array $validation_rules
391
-     */
392
-    public function add_validation_rules(array $validation_rules = array())
393
-    {
394
-        if (is_array($validation_rules) && ! empty($validation_rules)) {
395
-            $this->_validation_rules = array_merge($this->_validation_rules, $validation_rules);
396
-        }
397
-    }
398
-
399
-
400
-    /**
401
-     * @return array | bool
402
-     */
403
-    public function validation_rules()
404
-    {
405
-        return ! empty($this->_validation_rules) ? $this->_validation_rules : false;
406
-    }
407
-
408
-
409
-    public function echoAndExit()
410
-    {
411
-        echo $this;
412
-        exit();
413
-    }
17
+	/**
18
+	 * @var string
19
+	 */
20
+	protected $_errors = '';
21
+
22
+	/**
23
+	 * @var string
24
+	 */
25
+	protected $_unexpected_errors = '';
26
+
27
+	/**
28
+	 * @var string
29
+	 */
30
+	protected $_attention = '';
31
+
32
+	/**
33
+	 * @var string
34
+	 */
35
+	protected $_success = '';
36
+
37
+	/**
38
+	 * @var string
39
+	 */
40
+	protected $_plz_select_method_of_payment = '';
41
+
42
+	/**
43
+	 * @var string
44
+	 */
45
+	protected $_redirect_url = '';
46
+
47
+	/**
48
+	 * @var string
49
+	 */
50
+	protected $_registration_time_limit = '';
51
+
52
+	/**
53
+	 * @var string
54
+	 */
55
+	protected $_redirect_form = '';
56
+
57
+	/**
58
+	 * @var string
59
+	 */
60
+	protected $_reg_step_html = '';
61
+
62
+	/**
63
+	 * @var string
64
+	 */
65
+	protected $_method_of_payment = '';
66
+
67
+	/**
68
+	 * @var float
69
+	 */
70
+	protected $_payment_amount;
71
+
72
+	/**
73
+	 * @var array
74
+	 */
75
+	protected $_return_data = array();
76
+
77
+
78
+	/**
79
+	 * @var array
80
+	 */
81
+	protected $_validation_rules = array();
82
+
83
+
84
+	/**
85
+	 *    class constructor
86
+	 */
87
+	public function __construct()
88
+	{
89
+	}
90
+
91
+
92
+	/**
93
+	 *    __toString
94
+	 *
95
+	 *        allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a  JSON encoded string
96
+	 *
97
+	 * @access    public
98
+	 * @return    string
99
+	 */
100
+	public function __toString()
101
+	{
102
+		$JSON_response = array();
103
+		// grab notices
104
+		$notices = EE_Error::get_notices(false);
105
+		$this->set_attention(isset($notices['attention']) ? $notices['attention'] : '');
106
+		$this->set_errors(isset($notices['errors']) ? $notices['errors'] : '');
107
+		$this->set_success(isset($notices['success']) ? $notices['success'] : '');
108
+		// add notices to JSON response, but only if they exist
109
+		if ($this->attention()) {
110
+			$JSON_response['attention'] = $this->attention();
111
+		}
112
+		if ($this->errors()) {
113
+			$JSON_response['errors'] = $this->errors();
114
+		}
115
+		if ($this->unexpected_errors()) {
116
+			$JSON_response['unexpected_errors'] = $this->unexpected_errors();
117
+		}
118
+		if ($this->success()) {
119
+			$JSON_response['success'] = $this->success();
120
+		}
121
+		// but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked
122
+		if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) {
123
+			$JSON_response['success'] = null;
124
+		}
125
+		// set redirect_url, IF it exists
126
+		if ($this->redirect_url()) {
127
+			$JSON_response['redirect_url'] = $this->redirect_url();
128
+		}
129
+		// set registration_time_limit, IF it exists
130
+		if ($this->registration_time_limit()) {
131
+			$JSON_response['registration_time_limit'] = $this->registration_time_limit();
132
+		}
133
+		// set payment_amount, IF it exists
134
+		if ($this->payment_amount() !== null) {
135
+			$JSON_response['payment_amount'] = $this->payment_amount();
136
+		}
137
+		// grab generic return data
138
+		$return_data = $this->return_data();
139
+		// add billing form validation rules
140
+		if ($this->validation_rules()) {
141
+			$return_data['validation_rules'] = $this->validation_rules();
142
+		}
143
+		// set reg_step_html, IF it exists
144
+		if ($this->reg_step_html()) {
145
+			$return_data['reg_step_html'] = $this->reg_step_html();
146
+		}
147
+		// set method of payment, IF it exists
148
+		if ($this->method_of_payment()) {
149
+			$return_data['method_of_payment'] = $this->method_of_payment();
150
+		}
151
+		// set "plz_select_method_of_payment" message, IF it exists
152
+		if ($this->plz_select_method_of_payment()) {
153
+			$return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment();
154
+		}
155
+		// set redirect_form, IF it exists
156
+		if ($this->redirect_form()) {
157
+			$return_data['redirect_form'] = $this->redirect_form();
158
+		}
159
+		// and finally, add return_data array to main JSON response array, IF it contains anything
160
+		// why did we add some of the above properties to the return data array?
161
+		// because it is easier and cleaner in the Javascript to deal with this way
162
+		if (! empty($return_data)) {
163
+			$JSON_response['return_data'] = $return_data;
164
+		}
165
+		// filter final array
166
+		$JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response);
167
+		// return encoded array
168
+		return (string) wp_json_encode($JSON_response);
169
+	}
170
+
171
+
172
+	/**
173
+	 * @param string $attention
174
+	 */
175
+	public function set_attention($attention)
176
+	{
177
+		$this->_attention = $attention;
178
+	}
179
+
180
+
181
+	/**
182
+	 * @return string
183
+	 */
184
+	public function attention()
185
+	{
186
+		return $this->_attention;
187
+	}
188
+
189
+
190
+	/**
191
+	 * @param string $errors
192
+	 */
193
+	public function set_errors($errors)
194
+	{
195
+		$this->_errors = $errors;
196
+	}
197
+
198
+
199
+	/**
200
+	 * @return string
201
+	 */
202
+	public function errors()
203
+	{
204
+		return $this->_errors;
205
+	}
206
+
207
+
208
+	/**
209
+	 * @return string
210
+	 */
211
+	public function unexpected_errors()
212
+	{
213
+		return $this->_unexpected_errors;
214
+	}
215
+
216
+
217
+	/**
218
+	 * @param string $unexpected_errors
219
+	 */
220
+	public function set_unexpected_errors($unexpected_errors)
221
+	{
222
+		$this->_unexpected_errors = $unexpected_errors;
223
+	}
224
+
225
+
226
+	/**
227
+	 * @param string $success
228
+	 */
229
+	public function set_success($success)
230
+	{
231
+		$this->_success = $success;
232
+	}
233
+
234
+
235
+	/**
236
+	 * @return string
237
+	 */
238
+	public function success()
239
+	{
240
+		return $this->_success;
241
+	}
242
+
243
+
244
+	/**
245
+	 * @param string $method_of_payment
246
+	 */
247
+	public function set_method_of_payment($method_of_payment)
248
+	{
249
+		$this->_method_of_payment = $method_of_payment;
250
+	}
251
+
252
+
253
+	/**
254
+	 * @return string
255
+	 */
256
+	public function method_of_payment()
257
+	{
258
+		return $this->_method_of_payment;
259
+	}
260
+
261
+
262
+	/**
263
+	 * @return float
264
+	 */
265
+	public function payment_amount()
266
+	{
267
+		return $this->_payment_amount;
268
+	}
269
+
270
+
271
+	/**
272
+	 * @param float $payment_amount
273
+	 * @throws EE_Error
274
+	 */
275
+	public function set_payment_amount($payment_amount)
276
+	{
277
+		$this->_payment_amount = (float) $payment_amount;
278
+	}
279
+
280
+
281
+	/**
282
+	 * @param string $next_step_html
283
+	 */
284
+	public function set_reg_step_html($next_step_html)
285
+	{
286
+		$this->_reg_step_html = $next_step_html;
287
+	}
288
+
289
+
290
+	/**
291
+	 * @return string
292
+	 */
293
+	public function reg_step_html()
294
+	{
295
+		return $this->_reg_step_html;
296
+	}
297
+
298
+
299
+	/**
300
+	 * @param string $redirect_form
301
+	 */
302
+	public function set_redirect_form($redirect_form)
303
+	{
304
+		$this->_redirect_form = $redirect_form;
305
+	}
306
+
307
+
308
+	/**
309
+	 * @return string
310
+	 */
311
+	public function redirect_form()
312
+	{
313
+		return ! empty($this->_redirect_form) ? $this->_redirect_form : false;
314
+	}
315
+
316
+
317
+	/**
318
+	 * @param string $plz_select_method_of_payment
319
+	 */
320
+	public function set_plz_select_method_of_payment($plz_select_method_of_payment)
321
+	{
322
+		$this->_plz_select_method_of_payment = $plz_select_method_of_payment;
323
+	}
324
+
325
+
326
+	/**
327
+	 * @return string
328
+	 */
329
+	public function plz_select_method_of_payment()
330
+	{
331
+		return $this->_plz_select_method_of_payment;
332
+	}
333
+
334
+
335
+	/**
336
+	 * @param string $redirect_url
337
+	 */
338
+	public function set_redirect_url($redirect_url)
339
+	{
340
+		$this->_redirect_url = $redirect_url;
341
+	}
342
+
343
+
344
+	/**
345
+	 * @return string
346
+	 */
347
+	public function redirect_url()
348
+	{
349
+		return $this->_redirect_url;
350
+	}
351
+
352
+
353
+	/**
354
+	 * @return string
355
+	 */
356
+	public function registration_time_limit()
357
+	{
358
+		return $this->_registration_time_limit;
359
+	}
360
+
361
+
362
+	/**
363
+	 * @param string $registration_time_limit
364
+	 */
365
+	public function set_registration_time_limit($registration_time_limit)
366
+	{
367
+		$this->_registration_time_limit = $registration_time_limit;
368
+	}
369
+
370
+
371
+	/**
372
+	 * @param array $return_data
373
+	 */
374
+	public function set_return_data($return_data)
375
+	{
376
+		$this->_return_data = array_merge($this->_return_data, $return_data);
377
+	}
378
+
379
+
380
+	/**
381
+	 * @return array
382
+	 */
383
+	public function return_data()
384
+	{
385
+		return $this->_return_data;
386
+	}
387
+
388
+
389
+	/**
390
+	 * @param array $validation_rules
391
+	 */
392
+	public function add_validation_rules(array $validation_rules = array())
393
+	{
394
+		if (is_array($validation_rules) && ! empty($validation_rules)) {
395
+			$this->_validation_rules = array_merge($this->_validation_rules, $validation_rules);
396
+		}
397
+	}
398
+
399
+
400
+	/**
401
+	 * @return array | bool
402
+	 */
403
+	public function validation_rules()
404
+	{
405
+		return ! empty($this->_validation_rules) ? $this->_validation_rules : false;
406
+	}
407
+
408
+
409
+	public function echoAndExit()
410
+	{
411
+		echo $this;
412
+		exit();
413
+	}
414 414
 }
Please login to merge, or discard this patch.
admin/registrations/list_table/csv_reports/RegistrationsCsvReportParams.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -14,70 +14,70 @@
 block discarded – undo
14 14
  */
15 15
 class RegistrationsCsvReportParams
16 16
 {
17
-    /**
18
-     * @param string $return_url
19
-     * @param array  $request_params
20
-     * @param int    $EVT_ID
21
-     * @param int    $DTT_ID
22
-     * @return array
23
-     */
24
-    public static function getRequestParams(
25
-        $return_url,
26
-        $request_params = [],
27
-        $EVT_ID = 0,
28
-        $DTT_ID = 0
29
-    ) {
30
-        if (
31
-            ! EE_Capabilities::instance()->current_user_can(
32
-                'ee_read_registrations',
33
-                'espresso_registrations_registrations_reports',
34
-                $EVT_ID
35
-            )
36
-        ) {
37
-            return [];
38
-        }
39
-        unset($request_params['_wp_http_referer']);
40
-        add_action(
41
-            'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
42
-            [RegistrationsCsvReportParams::class, 'csvReportNotice']
43
-        );
17
+	/**
18
+	 * @param string $return_url
19
+	 * @param array  $request_params
20
+	 * @param int    $EVT_ID
21
+	 * @param int    $DTT_ID
22
+	 * @return array
23
+	 */
24
+	public static function getRequestParams(
25
+		$return_url,
26
+		$request_params = [],
27
+		$EVT_ID = 0,
28
+		$DTT_ID = 0
29
+	) {
30
+		if (
31
+			! EE_Capabilities::instance()->current_user_can(
32
+				'ee_read_registrations',
33
+				'espresso_registrations_registrations_reports',
34
+				$EVT_ID
35
+			)
36
+		) {
37
+			return [];
38
+		}
39
+		unset($request_params['_wp_http_referer']);
40
+		add_action(
41
+			'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
42
+			[RegistrationsCsvReportParams::class, 'csvReportNotice']
43
+		);
44 44
 
45
-        $route_details = [
46
-            'route'         => 'registrations_report',
47
-            'extra_request' => [ 'return_url' => $return_url ],
48
-            'btn_class'     => 'button button--primary',
49
-        ];
50
-        if (! empty($EVT_ID)) {
51
-            $route_details['extra_request']['EVT_ID'] = $EVT_ID;
52
-        }
53
-        if ($DTT_ID) {
54
-            $route_details['extra_request']['DTT_ID'] = $DTT_ID;
55
-        }
56
-        if (
57
-            isset($request_params['use_filters'])
58
-            && filter_var($request_params['use_filters'], FILTER_VALIDATE_BOOLEAN)
59
-        ) {
60
-            $route_details['extra_request']['filters'] = array_diff_key(
61
-                $request_params,
62
-                [
63
-                    'page'          => '',
64
-                    'action'        => '',
65
-                    'default_nonce' => '',
66
-                ]
67
-            );
68
-        }
69
-        return $route_details;
70
-    }
45
+		$route_details = [
46
+			'route'         => 'registrations_report',
47
+			'extra_request' => [ 'return_url' => $return_url ],
48
+			'btn_class'     => 'button button--primary',
49
+		];
50
+		if (! empty($EVT_ID)) {
51
+			$route_details['extra_request']['EVT_ID'] = $EVT_ID;
52
+		}
53
+		if ($DTT_ID) {
54
+			$route_details['extra_request']['DTT_ID'] = $DTT_ID;
55
+		}
56
+		if (
57
+			isset($request_params['use_filters'])
58
+			&& filter_var($request_params['use_filters'], FILTER_VALIDATE_BOOLEAN)
59
+		) {
60
+			$route_details['extra_request']['filters'] = array_diff_key(
61
+				$request_params,
62
+				[
63
+					'page'          => '',
64
+					'action'        => '',
65
+					'default_nonce' => '',
66
+				]
67
+			);
68
+		}
69
+		return $route_details;
70
+	}
71 71
 
72 72
 
73
-    public static function csvReportNotice()
74
-    {
75
-        echo '
73
+	public static function csvReportNotice()
74
+	{
75
+		echo '
76 76
     <span class="csv-report-notice__wrapper">
77 77
         <span class="dashicons dashicons-info"></span>
78 78
         <span class="csv-report-notice__text">
79 79
         ' .  esc_html('All Registration CSV Reports are now triggered by the preceding button') . '
80 80
         </span>
81 81
     </span>';
82
-    }
82
+	}
83 83
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 
45 45
         $route_details = [
46 46
             'route'         => 'registrations_report',
47
-            'extra_request' => [ 'return_url' => $return_url ],
47
+            'extra_request' => ['return_url' => $return_url],
48 48
             'btn_class'     => 'button button--primary',
49 49
         ];
50
-        if (! empty($EVT_ID)) {
50
+        if ( ! empty($EVT_ID)) {
51 51
             $route_details['extra_request']['EVT_ID'] = $EVT_ID;
52 52
         }
53 53
         if ($DTT_ID) {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     <span class="csv-report-notice__wrapper">
77 77
         <span class="dashicons dashicons-info"></span>
78 78
         <span class="csv-report-notice__text">
79
-        ' .  esc_html('All Registration CSV Reports are now triggered by the preceding button') . '
79
+        ' .  esc_html('All Registration CSV Reports are now triggered by the preceding button').'
80 80
         </span>
81 81
     </span>';
82 82
     }
Please login to merge, or discard this patch.
core/admin/EE_Admin_List_Table.core.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 use EventEspresso\core\services\request\sanitizers\AllowedTags;
4 4
 
5
-if (! class_exists('WP_List_Table')) {
6
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
5
+if ( ! class_exists('WP_List_Table')) {
6
+    require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
7 7
 }
8 8
 
9 9
 
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
         $this->_view         = $this->_admin_page->get_view();
224 224
         $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
225 225
         $this->_current_page = $this->get_pagenum();
226
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
226
+        $this->_screen       = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view();
227 227
         $this->_yes_no       = [
228 228
             esc_html__('No', 'event_espresso'),
229 229
             esc_html__('Yes', 'event_espresso')
230 230
         ];
231 231
 
232
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
232
+        $this->_per_page = $this->get_items_per_page($this->_screen.'_per_page');
233 233
 
234 234
         $this->_setup_data();
235 235
         $this->_add_view_counts();
@@ -309,14 +309,14 @@  discard block
 block discarded – undo
309 309
         $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
310 310
         // if action is STILL empty, then we set it to default
311 311
         $action = empty($action) ? 'default' : $action;
312
-        $field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
313
-        $field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
314
-        $field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
312
+        $field  = '<input type="hidden" name="page" value="'.esc_attr($this->_req_data['page']).'" />'."\n";
313
+        $field  .= '<input type="hidden" name="route" value="'.esc_attr($action).'" />'."\n";
314
+        $field  .= '<input type="hidden" name="perpage" value="'.esc_attr($this->_per_page).'" />'."\n";
315 315
 
316 316
         $bulk_actions = $this->_get_bulk_actions();
317 317
         foreach ($bulk_actions as $bulk_action => $label) {
318
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
319
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
318
+            $field .= '<input type="hidden" name="'.$bulk_action.'_nonce"'
319
+                      . ' value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n";
320 320
         }
321 321
 
322 322
         return $field;
@@ -363,11 +363,11 @@  discard block
 block discarded – undo
363 363
 
364 364
             $data = (array) $data;
365 365
 
366
-            if (! isset($data[1])) {
366
+            if ( ! isset($data[1])) {
367 367
                 $_data[1] = false;
368 368
             }
369 369
 
370
-            $sortable[ $id ] = $_data;
370
+            $sortable[$id] = $_data;
371 371
         }
372 372
         $primary               = $this->get_primary_column_name();
373 373
         $this->_column_headers = [$columns, $hidden, $sortable, $primary];
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
                 // for that page route and skip adding the bulk action if no access for the current logged in user.
428 428
                 foreach ($args['bulk_action'] as $route => $label) {
429 429
                     if ($this->_admin_page->check_user_access($route, true)) {
430
-                        $actions[ $route ] = $label;
430
+                        $actions[$route] = $label;
431 431
                     }
432 432
                 }
433 433
             }
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
     public function display_tablenav($which)
447 447
     {
448 448
         if ('top' === $which) {
449
-            wp_nonce_field('bulk-' . $this->_args['plural']);
449
+            wp_nonce_field('bulk-'.$this->_args['plural']);
450 450
         }
451 451
         ?>
452 452
         <div class="tablenav <?php echo esc_attr($which); ?>">
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
          */
580 580
         ob_start();
581 581
         do_action(
582
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
582
+            'AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id,
583 583
             $item,
584 584
             $this->_screen
585 585
         );
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
          *
609 609
          * @var array
610 610
          */
611
-        return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
611
+        return apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen);
612 612
     }
613 613
 
614 614
 
@@ -642,12 +642,12 @@  discard block
 block discarded – undo
642 642
             $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
643 643
             if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
644 644
                 $filter = "<li";
645
-                $filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
645
+                $filter .= $view['class'] ? " class='".esc_attr($view['class'])."'" : '';
646 646
                 $filter .= ">";
647
-                $filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
648
-                $filter .= '<span class="count">(' . $count . ')</span>';
647
+                $filter .= '<a href="'.esc_url_raw($view['url']).'">'.esc_html($view['label']).'</a>';
648
+                $filter .= '<span class="count">('.$count.')</span>';
649 649
                 $filter .= '</li>';
650
-                $assembled_views[ $view['slug'] ] = $filter;
650
+                $assembled_views[$view['slug']] = $filter;
651 651
             }
652 652
         }
653 653
 
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
     public function single_row($item)
669 669
     {
670 670
         $row_class = $this->_get_row_class($item);
671
-        echo '<tr class="' . esc_attr($row_class) . '">';
671
+        echo '<tr class="'.esc_attr($row_class).'">';
672 672
         $this->single_row_columns($item); // already escaped
673 673
         echo '</tr>';
674 674
     }
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 
689 689
         $new_row_class = $row_class;
690 690
 
691
-        if (! empty($this->_ajax_sorting_callback)) {
691
+        if ( ! empty($this->_ajax_sorting_callback)) {
692 692
             $new_row_class .= ' rowsortable';
693 693
         }
694 694
 
@@ -720,12 +720,12 @@  discard block
 block discarded – undo
720 720
     public function get_hidden_columns()
721 721
     {
722 722
         $user_id     = get_current_user_id();
723
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
723
+        $has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id);
724 724
         if (empty($has_default) && ! empty($this->_hidden_columns)) {
725
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
726
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
725
+            update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', true);
726
+            update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, true);
727 727
         }
728
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
728
+        $ref = 'manage'.$this->screen->id.'columnshidden';
729 729
         return (array) get_user_option($ref, $user_id);
730 730
     }
731 731
 
@@ -750,14 +750,14 @@  discard block
 block discarded – undo
750 750
              */
751 751
             $hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
752 752
 
753
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
753
+            $classes = $column_name.' column-'.$column_name.$hidden_class;
754 754
             if ($primary === $column_name) {
755 755
                 $classes .= ' has-row-actions column-primary';
756 756
             }
757 757
 
758
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
758
+            $data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"';
759 759
 
760
-            $class = 'class="' . esc_attr($classes) . '"';
760
+            $class = 'class="'.esc_attr($classes).'"';
761 761
 
762 762
             $attributes = "{$class}{$data}";
763 763
 
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
                     $this
771 771
                 );
772 772
                 echo '</th>';
773
-            } elseif (method_exists($this, 'column_' . $column_name)) {
773
+            } elseif (method_exists($this, 'column_'.$column_name)) {
774 774
                 echo "<td $attributes>"; // already escaped
775 775
                 echo apply_filters(
776
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
777
-                    call_user_func([$this, 'column_' . $column_name], $item),
776
+                    'FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content',
777
+                    call_user_func([$this, 'column_'.$column_name], $item),
778 778
                     $item,
779 779
                     $this
780 780
                 );
@@ -890,10 +890,10 @@  discard block
 block discarded – undo
890 890
         $action_class = '',
891 891
         $action_id = ''
892 892
     ) {
893
-        $action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
894
-        $action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
895
-        $open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
896
-        $close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
893
+        $action_class = ! empty($action_class) ? ' class="'.esc_attr($action_class).'"' : '';
894
+        $action_id    = ! empty($action_id) ? ' id="'.esc_attr($action_id).'"' : '';
895
+        $open_tag     = ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : '';
896
+        $close_tag    = ! empty($action_container) ? '</'.$action_container.'>' : '';
897 897
         try {
898 898
             $content = apply_filters(
899 899
                 'FHEE__EE_Admin_List_Table___action_string__action_items',
@@ -931,10 +931,10 @@  discard block
 block discarded – undo
931 931
      */
932 932
     protected function columnContent($id, $content, $align = 'start')
933 933
     {
934
-        if (! isset($this->_columns[ $id ])) {
934
+        if ( ! isset($this->_columns[$id])) {
935 935
             throw new DomainException('missing column id');
936 936
         }
937
-        $heading = $id !== 'cb' ? $this->_columns[ $id ] : '';
937
+        $heading = $id !== 'cb' ? $this->_columns[$id] : '';
938 938
         $align = in_array($align, ['start', 'center', 'end']) ? $align : 'start';
939 939
         $align = "ee-responsive-table-cell--{$align}";
940 940
 
@@ -951,13 +951,13 @@  discard block
 block discarded – undo
951 951
         return '
952 952
         <div class="ee-modal-menu">
953 953
             <button class="ee-modal-menu__button button button--secondary button--icon-only ee-aria-tooltip"
954
-                    aria-label="' . esc_attr__('list table actions menu', 'event_espresso') . '"
954
+                    aria-label="' . esc_attr__('list table actions menu', 'event_espresso').'"
955 955
             >
956 956
                 <span class="dashicons dashicons-menu"></span>
957 957
             </button>
958 958
             <div class="ee-modal-menu__content ee-admin-container">
959 959
                 <span class="ee-modal-menu__close dashicons dashicons-no"></span>
960
-                ' . $actions . '
960
+                ' . $actions.'
961 961
             </div>
962 962
         </div>';
963 963
     }
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
         return '
969 969
             <span class="ee-actions-column-header-wrap">
970 970
                 <span class="dashicons dashicons-screenoptions"></span>
971
-                <span class="ee-actions-column-header">' . esc_html__('Actions', 'event_espresso') . '</span>
971
+                <span class="ee-actions-column-header">' . esc_html__('Actions', 'event_espresso').'</span>
972 972
             </span>';
973 973
     }
974 974
 
Please login to merge, or discard this patch.
Indentation   +916 added lines, -916 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\services\request\sanitizers\AllowedTags;
4 4
 
5 5
 if (! class_exists('WP_List_Table')) {
6
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
+	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
7 7
 }
8 8
 
9 9
 
@@ -21,481 +21,481 @@  discard block
 block discarded – undo
21 21
  */
22 22
 abstract class EE_Admin_List_Table extends WP_List_Table
23 23
 {
24
-    const ACTION_COPY    = 'duplicate';
25
-
26
-    const ACTION_DELETE  = 'delete';
27
-
28
-    const ACTION_EDIT    = 'edit';
29
-
30
-    const ACTION_RESTORE = 'restore';
31
-
32
-    const ACTION_TRASH   = 'trash';
33
-
34
-    protected static $actions = [
35
-        self::ACTION_COPY,
36
-        self::ACTION_DELETE,
37
-        self::ACTION_EDIT,
38
-        self::ACTION_RESTORE,
39
-        self::ACTION_TRASH,
40
-    ];
41
-
42
-    /**
43
-     * holds the data that will be processed for the table
44
-     *
45
-     * @var array $_data
46
-     */
47
-    protected $_data;
48
-
49
-
50
-    /**
51
-     * This holds the value of all the data available for the given view (for all pages).
52
-     *
53
-     * @var int $_all_data_count
54
-     */
55
-    protected $_all_data_count;
56
-
57
-
58
-    /**
59
-     * Will contain the count of trashed items for the view label.
60
-     *
61
-     * @var int $_trashed_count
62
-     */
63
-    protected $_trashed_count;
64
-
65
-
66
-    /**
67
-     * This is what will be referenced as the slug for the current screen
68
-     *
69
-     * @var string $_screen
70
-     */
71
-    protected $_screen;
72
-
73
-
74
-    /**
75
-     * this is the EE_Admin_Page object
76
-     *
77
-     * @var EE_Admin_Page $_admin_page
78
-     */
79
-    protected $_admin_page;
80
-
81
-
82
-    /**
83
-     * The current view
84
-     *
85
-     * @var string $_view
86
-     */
87
-    protected $_view;
88
-
89
-
90
-    /**
91
-     * array of possible views for this table
92
-     *
93
-     * @var array $_views
94
-     */
95
-    protected $_views;
96
-
97
-
98
-    /**
99
-     * An array of key => value pairs containing information about the current table
100
-     * array(
101
-     *        'plural' => 'plural label',
102
-     *        'singular' => 'singular label',
103
-     *        'ajax' => false, //whether to use ajax or not
104
-     *        'screen' => null, //string used to reference what screen this is
105
-     *        (WP_List_table converts to screen object)
106
-     * )
107
-     *
108
-     * @var array $_wp_list_args
109
-     */
110
-    protected $_wp_list_args;
111
-
112
-    /**
113
-     * an array of column names
114
-     * array(
115
-     *    'internal-name' => 'Title'
116
-     * )
117
-     *
118
-     * @var array $_columns
119
-     */
120
-    protected $_columns;
121
-
122
-    /**
123
-     * An array of sortable columns
124
-     * array(
125
-     *    'internal-name' => 'orderby' //or
126
-     *    'internal-name' => array( 'orderby', true )
127
-     * )
128
-     *
129
-     * @var array $_sortable_columns
130
-     */
131
-    protected $_sortable_columns;
132
-
133
-    /**
134
-     * callback method used to perform AJAX row reordering
135
-     *
136
-     * @var string $_ajax_sorting_callback
137
-     */
138
-    protected $_ajax_sorting_callback;
139
-
140
-    /**
141
-     * An array of hidden columns (if needed)
142
-     * array('internal-name', 'internal-name')
143
-     *
144
-     * @var array $_hidden_columns
145
-     */
146
-    protected $_hidden_columns;
147
-
148
-    /**
149
-     * holds the per_page value
150
-     *
151
-     * @var int $_per_page
152
-     */
153
-    protected $_per_page;
154
-
155
-    /**
156
-     * holds what page number is currently being viewed
157
-     *
158
-     * @var int $_current_page
159
-     */
160
-    protected $_current_page;
161
-
162
-    /**
163
-     * the reference string for the nonce_action
164
-     *
165
-     * @var string $_nonce_action_ref
166
-     */
167
-    protected $_nonce_action_ref;
168
-
169
-    /**
170
-     * property to hold incoming request data (as set by the admin_page_core)
171
-     *
172
-     * @var array $_req_data
173
-     */
174
-    protected $_req_data;
175
-
176
-
177
-    /**
178
-     * yes / no array for admin form fields
179
-     *
180
-     * @var array $_yes_no
181
-     */
182
-    protected $_yes_no = [];
183
-
184
-    /**
185
-     * Array describing buttons that should appear at the bottom of the page
186
-     * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
187
-     * and the values are another array with the following keys
188
-     * array(
189
-     *    'route' => 'page_route',
190
-     *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
191
-     * )
192
-     *
193
-     * @var array $_bottom_buttons
194
-     */
195
-    protected $_bottom_buttons = [];
196
-
197
-
198
-    /**
199
-     * Used to indicate what should be the primary column for the list table.
200
-     * If not present then falls back to what WP calculates
201
-     * as the primary column.
202
-     *
203
-     * @type string $_primary_column
204
-     */
205
-    protected $_primary_column = '';
206
-
207
-
208
-    /**
209
-     * Used to indicate whether the table has a checkbox column or not.
210
-     *
211
-     * @type bool $_has_checkbox_column
212
-     */
213
-    protected $_has_checkbox_column = false;
214
-
215
-
216
-    /**
217
-     * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
218
-     */
219
-    public function __construct(EE_Admin_Page $admin_page)
220
-    {
221
-        $this->_admin_page   = $admin_page;
222
-        $this->_req_data     = $this->_admin_page->get_request_data();
223
-        $this->_view         = $this->_admin_page->get_view();
224
-        $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
225
-        $this->_current_page = $this->get_pagenum();
226
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
227
-        $this->_yes_no       = [
228
-            esc_html__('No', 'event_espresso'),
229
-            esc_html__('Yes', 'event_espresso')
230
-        ];
231
-
232
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
233
-
234
-        $this->_setup_data();
235
-        $this->_add_view_counts();
236
-
237
-        $this->_nonce_action_ref = $this->_view;
238
-
239
-        $this->_set_properties();
240
-
241
-        // set primary column
242
-        add_filter('list_table_primary_column', [$this, 'set_primary_column']);
243
-
244
-        // set parent defaults
245
-        parent::__construct($this->_wp_list_args);
246
-
247
-        $this->prepare_items();
248
-    }
249
-
250
-
251
-    /**
252
-     * _setup_data
253
-     * this method is used to setup the $_data, $_all_data_count, and _per_page properties
254
-     *
255
-     * @return void
256
-     * @uses $this->_admin_page
257
-     */
258
-    abstract protected function _setup_data();
259
-
260
-
261
-    /**
262
-     * set the properties that this class needs to be able to execute wp_list_table properly
263
-     * properties set:
264
-     * _wp_list_args = what the arguments required for the parent _wp_list_table.
265
-     * _columns = set the columns in an array.
266
-     * _sortable_columns = columns that are sortable (array).
267
-     * _hidden_columns = columns that are hidden (array)
268
-     * _default_orderby = the default orderby for sorting.
269
-     *
270
-     * @abstract
271
-     * @access protected
272
-     * @return void
273
-     */
274
-    abstract protected function _set_properties();
275
-
276
-
277
-    /**
278
-     * _get_table_filters
279
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
280
-     * gets shown in the table.
281
-     *
282
-     * @abstract
283
-     * @access protected
284
-     * @return string
285
-     */
286
-    abstract protected function _get_table_filters();
287
-
288
-
289
-    /**
290
-     * this is a method that child class will do to add counts to the views array so when views are displayed the
291
-     * counts of the views is accurate.
292
-     *
293
-     * @abstract
294
-     * @access protected
295
-     * @return void
296
-     */
297
-    abstract protected function _add_view_counts();
298
-
299
-
300
-    /**
301
-     * _get_hidden_fields
302
-     * returns a html string of hidden fields so if any table filters are used the current view will be respected.
303
-     *
304
-     * @return string
305
-     */
306
-    protected function _get_hidden_fields()
307
-    {
308
-        $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
309
-        $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
310
-        // if action is STILL empty, then we set it to default
311
-        $action = empty($action) ? 'default' : $action;
312
-        $field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
313
-        $field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
314
-        $field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
315
-
316
-        $bulk_actions = $this->_get_bulk_actions();
317
-        foreach ($bulk_actions as $bulk_action => $label) {
318
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
319
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
320
-        }
321
-
322
-        return $field;
323
-    }
324
-
325
-
326
-    /**
327
-     * _set_column_info
328
-     * we're using this to set the column headers property.
329
-     *
330
-     * @access protected
331
-     * @return void
332
-     */
333
-    protected function _set_column_info()
334
-    {
335
-        $columns   = $this->get_columns();
336
-        $hidden    = $this->get_hidden_columns();
337
-        $_sortable = $this->get_sortable_columns();
338
-
339
-        /**
340
-         * Dynamic hook allowing for adding sortable columns in this list table.
341
-         * Note that $this->screen->id is in the format
342
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
343
-         * table it is: event-espresso_page_espresso_messages.
344
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
345
-         * hook prefix ("event-espresso") will be different.
346
-         *
347
-         * @var array
348
-         */
349
-        $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
350
-
351
-        $sortable = [];
352
-        foreach ($_sortable as $id => $data) {
353
-            if (empty($data)) {
354
-                continue;
355
-            }
356
-            // fix for offset errors with WP_List_Table default get_columninfo()
357
-            if (is_array($data)) {
358
-                $_data[0] = key($data);
359
-                $_data[1] = isset($data[1]) ? $data[1] : false;
360
-            } else {
361
-                $_data[0] = $data;
362
-            }
363
-
364
-            $data = (array) $data;
365
-
366
-            if (! isset($data[1])) {
367
-                $_data[1] = false;
368
-            }
369
-
370
-            $sortable[ $id ] = $_data;
371
-        }
372
-        $primary               = $this->get_primary_column_name();
373
-        $this->_column_headers = [$columns, $hidden, $sortable, $primary];
374
-    }
375
-
376
-
377
-    /**
378
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
379
-     *
380
-     * @return string
381
-     */
382
-    protected function get_primary_column_name()
383
-    {
384
-        foreach (class_parents($this) as $parent) {
385
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
386
-                return parent::get_primary_column_name();
387
-            }
388
-        }
389
-        return $this->_primary_column;
390
-    }
391
-
392
-
393
-    /**
394
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
395
-     *
396
-     * @param EE_Base_Class $item
397
-     * @param string        $column_name
398
-     * @param string        $primary
399
-     * @return string
400
-     */
401
-    protected function handle_row_actions($item, $column_name, $primary)
402
-    {
403
-        foreach (class_parents($this) as $parent) {
404
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
405
-                return parent::handle_row_actions($item, $column_name, $primary);
406
-            }
407
-        }
408
-        return '';
409
-    }
410
-
411
-
412
-    /**
413
-     * _get_bulk_actions
414
-     * This is a wrapper called by WP_List_Table::get_bulk_actions()
415
-     *
416
-     * @access protected
417
-     * @return array bulk_actions
418
-     */
419
-    protected function _get_bulk_actions(): array
420
-    {
421
-        $actions = [];
422
-        // the _views property should have the bulk_actions, so let's go through and extract them into a properly
423
-        // formatted array for the wp_list_table();
424
-        foreach ($this->_views as $view => $args) {
425
-            if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
426
-                // each bulk action will correspond with a admin page route, so we can check whatever the capability is
427
-                // for that page route and skip adding the bulk action if no access for the current logged in user.
428
-                foreach ($args['bulk_action'] as $route => $label) {
429
-                    if ($this->_admin_page->check_user_access($route, true)) {
430
-                        $actions[ $route ] = $label;
431
-                    }
432
-                }
433
-            }
434
-        }
435
-        return $actions;
436
-    }
437
-
438
-
439
-    /**
440
-     * Generate the table navigation above or below the table.
441
-     * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
442
-     *
443
-     * @throws EE_Error
444
-     * @since 4.9.44.rc.001
445
-     */
446
-    public function display_tablenav($which)
447
-    {
448
-        if ('top' === $which) {
449
-            wp_nonce_field('bulk-' . $this->_args['plural']);
450
-        }
451
-        ?>
24
+	const ACTION_COPY    = 'duplicate';
25
+
26
+	const ACTION_DELETE  = 'delete';
27
+
28
+	const ACTION_EDIT    = 'edit';
29
+
30
+	const ACTION_RESTORE = 'restore';
31
+
32
+	const ACTION_TRASH   = 'trash';
33
+
34
+	protected static $actions = [
35
+		self::ACTION_COPY,
36
+		self::ACTION_DELETE,
37
+		self::ACTION_EDIT,
38
+		self::ACTION_RESTORE,
39
+		self::ACTION_TRASH,
40
+	];
41
+
42
+	/**
43
+	 * holds the data that will be processed for the table
44
+	 *
45
+	 * @var array $_data
46
+	 */
47
+	protected $_data;
48
+
49
+
50
+	/**
51
+	 * This holds the value of all the data available for the given view (for all pages).
52
+	 *
53
+	 * @var int $_all_data_count
54
+	 */
55
+	protected $_all_data_count;
56
+
57
+
58
+	/**
59
+	 * Will contain the count of trashed items for the view label.
60
+	 *
61
+	 * @var int $_trashed_count
62
+	 */
63
+	protected $_trashed_count;
64
+
65
+
66
+	/**
67
+	 * This is what will be referenced as the slug for the current screen
68
+	 *
69
+	 * @var string $_screen
70
+	 */
71
+	protected $_screen;
72
+
73
+
74
+	/**
75
+	 * this is the EE_Admin_Page object
76
+	 *
77
+	 * @var EE_Admin_Page $_admin_page
78
+	 */
79
+	protected $_admin_page;
80
+
81
+
82
+	/**
83
+	 * The current view
84
+	 *
85
+	 * @var string $_view
86
+	 */
87
+	protected $_view;
88
+
89
+
90
+	/**
91
+	 * array of possible views for this table
92
+	 *
93
+	 * @var array $_views
94
+	 */
95
+	protected $_views;
96
+
97
+
98
+	/**
99
+	 * An array of key => value pairs containing information about the current table
100
+	 * array(
101
+	 *        'plural' => 'plural label',
102
+	 *        'singular' => 'singular label',
103
+	 *        'ajax' => false, //whether to use ajax or not
104
+	 *        'screen' => null, //string used to reference what screen this is
105
+	 *        (WP_List_table converts to screen object)
106
+	 * )
107
+	 *
108
+	 * @var array $_wp_list_args
109
+	 */
110
+	protected $_wp_list_args;
111
+
112
+	/**
113
+	 * an array of column names
114
+	 * array(
115
+	 *    'internal-name' => 'Title'
116
+	 * )
117
+	 *
118
+	 * @var array $_columns
119
+	 */
120
+	protected $_columns;
121
+
122
+	/**
123
+	 * An array of sortable columns
124
+	 * array(
125
+	 *    'internal-name' => 'orderby' //or
126
+	 *    'internal-name' => array( 'orderby', true )
127
+	 * )
128
+	 *
129
+	 * @var array $_sortable_columns
130
+	 */
131
+	protected $_sortable_columns;
132
+
133
+	/**
134
+	 * callback method used to perform AJAX row reordering
135
+	 *
136
+	 * @var string $_ajax_sorting_callback
137
+	 */
138
+	protected $_ajax_sorting_callback;
139
+
140
+	/**
141
+	 * An array of hidden columns (if needed)
142
+	 * array('internal-name', 'internal-name')
143
+	 *
144
+	 * @var array $_hidden_columns
145
+	 */
146
+	protected $_hidden_columns;
147
+
148
+	/**
149
+	 * holds the per_page value
150
+	 *
151
+	 * @var int $_per_page
152
+	 */
153
+	protected $_per_page;
154
+
155
+	/**
156
+	 * holds what page number is currently being viewed
157
+	 *
158
+	 * @var int $_current_page
159
+	 */
160
+	protected $_current_page;
161
+
162
+	/**
163
+	 * the reference string for the nonce_action
164
+	 *
165
+	 * @var string $_nonce_action_ref
166
+	 */
167
+	protected $_nonce_action_ref;
168
+
169
+	/**
170
+	 * property to hold incoming request data (as set by the admin_page_core)
171
+	 *
172
+	 * @var array $_req_data
173
+	 */
174
+	protected $_req_data;
175
+
176
+
177
+	/**
178
+	 * yes / no array for admin form fields
179
+	 *
180
+	 * @var array $_yes_no
181
+	 */
182
+	protected $_yes_no = [];
183
+
184
+	/**
185
+	 * Array describing buttons that should appear at the bottom of the page
186
+	 * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
187
+	 * and the values are another array with the following keys
188
+	 * array(
189
+	 *    'route' => 'page_route',
190
+	 *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
191
+	 * )
192
+	 *
193
+	 * @var array $_bottom_buttons
194
+	 */
195
+	protected $_bottom_buttons = [];
196
+
197
+
198
+	/**
199
+	 * Used to indicate what should be the primary column for the list table.
200
+	 * If not present then falls back to what WP calculates
201
+	 * as the primary column.
202
+	 *
203
+	 * @type string $_primary_column
204
+	 */
205
+	protected $_primary_column = '';
206
+
207
+
208
+	/**
209
+	 * Used to indicate whether the table has a checkbox column or not.
210
+	 *
211
+	 * @type bool $_has_checkbox_column
212
+	 */
213
+	protected $_has_checkbox_column = false;
214
+
215
+
216
+	/**
217
+	 * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
218
+	 */
219
+	public function __construct(EE_Admin_Page $admin_page)
220
+	{
221
+		$this->_admin_page   = $admin_page;
222
+		$this->_req_data     = $this->_admin_page->get_request_data();
223
+		$this->_view         = $this->_admin_page->get_view();
224
+		$this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
225
+		$this->_current_page = $this->get_pagenum();
226
+		$this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
227
+		$this->_yes_no       = [
228
+			esc_html__('No', 'event_espresso'),
229
+			esc_html__('Yes', 'event_espresso')
230
+		];
231
+
232
+		$this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
233
+
234
+		$this->_setup_data();
235
+		$this->_add_view_counts();
236
+
237
+		$this->_nonce_action_ref = $this->_view;
238
+
239
+		$this->_set_properties();
240
+
241
+		// set primary column
242
+		add_filter('list_table_primary_column', [$this, 'set_primary_column']);
243
+
244
+		// set parent defaults
245
+		parent::__construct($this->_wp_list_args);
246
+
247
+		$this->prepare_items();
248
+	}
249
+
250
+
251
+	/**
252
+	 * _setup_data
253
+	 * this method is used to setup the $_data, $_all_data_count, and _per_page properties
254
+	 *
255
+	 * @return void
256
+	 * @uses $this->_admin_page
257
+	 */
258
+	abstract protected function _setup_data();
259
+
260
+
261
+	/**
262
+	 * set the properties that this class needs to be able to execute wp_list_table properly
263
+	 * properties set:
264
+	 * _wp_list_args = what the arguments required for the parent _wp_list_table.
265
+	 * _columns = set the columns in an array.
266
+	 * _sortable_columns = columns that are sortable (array).
267
+	 * _hidden_columns = columns that are hidden (array)
268
+	 * _default_orderby = the default orderby for sorting.
269
+	 *
270
+	 * @abstract
271
+	 * @access protected
272
+	 * @return void
273
+	 */
274
+	abstract protected function _set_properties();
275
+
276
+
277
+	/**
278
+	 * _get_table_filters
279
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
280
+	 * gets shown in the table.
281
+	 *
282
+	 * @abstract
283
+	 * @access protected
284
+	 * @return string
285
+	 */
286
+	abstract protected function _get_table_filters();
287
+
288
+
289
+	/**
290
+	 * this is a method that child class will do to add counts to the views array so when views are displayed the
291
+	 * counts of the views is accurate.
292
+	 *
293
+	 * @abstract
294
+	 * @access protected
295
+	 * @return void
296
+	 */
297
+	abstract protected function _add_view_counts();
298
+
299
+
300
+	/**
301
+	 * _get_hidden_fields
302
+	 * returns a html string of hidden fields so if any table filters are used the current view will be respected.
303
+	 *
304
+	 * @return string
305
+	 */
306
+	protected function _get_hidden_fields()
307
+	{
308
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
309
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
310
+		// if action is STILL empty, then we set it to default
311
+		$action = empty($action) ? 'default' : $action;
312
+		$field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
313
+		$field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
314
+		$field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
315
+
316
+		$bulk_actions = $this->_get_bulk_actions();
317
+		foreach ($bulk_actions as $bulk_action => $label) {
318
+			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
319
+					  . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
320
+		}
321
+
322
+		return $field;
323
+	}
324
+
325
+
326
+	/**
327
+	 * _set_column_info
328
+	 * we're using this to set the column headers property.
329
+	 *
330
+	 * @access protected
331
+	 * @return void
332
+	 */
333
+	protected function _set_column_info()
334
+	{
335
+		$columns   = $this->get_columns();
336
+		$hidden    = $this->get_hidden_columns();
337
+		$_sortable = $this->get_sortable_columns();
338
+
339
+		/**
340
+		 * Dynamic hook allowing for adding sortable columns in this list table.
341
+		 * Note that $this->screen->id is in the format
342
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
343
+		 * table it is: event-espresso_page_espresso_messages.
344
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
345
+		 * hook prefix ("event-espresso") will be different.
346
+		 *
347
+		 * @var array
348
+		 */
349
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
350
+
351
+		$sortable = [];
352
+		foreach ($_sortable as $id => $data) {
353
+			if (empty($data)) {
354
+				continue;
355
+			}
356
+			// fix for offset errors with WP_List_Table default get_columninfo()
357
+			if (is_array($data)) {
358
+				$_data[0] = key($data);
359
+				$_data[1] = isset($data[1]) ? $data[1] : false;
360
+			} else {
361
+				$_data[0] = $data;
362
+			}
363
+
364
+			$data = (array) $data;
365
+
366
+			if (! isset($data[1])) {
367
+				$_data[1] = false;
368
+			}
369
+
370
+			$sortable[ $id ] = $_data;
371
+		}
372
+		$primary               = $this->get_primary_column_name();
373
+		$this->_column_headers = [$columns, $hidden, $sortable, $primary];
374
+	}
375
+
376
+
377
+	/**
378
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
379
+	 *
380
+	 * @return string
381
+	 */
382
+	protected function get_primary_column_name()
383
+	{
384
+		foreach (class_parents($this) as $parent) {
385
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
386
+				return parent::get_primary_column_name();
387
+			}
388
+		}
389
+		return $this->_primary_column;
390
+	}
391
+
392
+
393
+	/**
394
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
395
+	 *
396
+	 * @param EE_Base_Class $item
397
+	 * @param string        $column_name
398
+	 * @param string        $primary
399
+	 * @return string
400
+	 */
401
+	protected function handle_row_actions($item, $column_name, $primary)
402
+	{
403
+		foreach (class_parents($this) as $parent) {
404
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
405
+				return parent::handle_row_actions($item, $column_name, $primary);
406
+			}
407
+		}
408
+		return '';
409
+	}
410
+
411
+
412
+	/**
413
+	 * _get_bulk_actions
414
+	 * This is a wrapper called by WP_List_Table::get_bulk_actions()
415
+	 *
416
+	 * @access protected
417
+	 * @return array bulk_actions
418
+	 */
419
+	protected function _get_bulk_actions(): array
420
+	{
421
+		$actions = [];
422
+		// the _views property should have the bulk_actions, so let's go through and extract them into a properly
423
+		// formatted array for the wp_list_table();
424
+		foreach ($this->_views as $view => $args) {
425
+			if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
426
+				// each bulk action will correspond with a admin page route, so we can check whatever the capability is
427
+				// for that page route and skip adding the bulk action if no access for the current logged in user.
428
+				foreach ($args['bulk_action'] as $route => $label) {
429
+					if ($this->_admin_page->check_user_access($route, true)) {
430
+						$actions[ $route ] = $label;
431
+					}
432
+				}
433
+			}
434
+		}
435
+		return $actions;
436
+	}
437
+
438
+
439
+	/**
440
+	 * Generate the table navigation above or below the table.
441
+	 * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
442
+	 *
443
+	 * @throws EE_Error
444
+	 * @since 4.9.44.rc.001
445
+	 */
446
+	public function display_tablenav($which)
447
+	{
448
+		if ('top' === $which) {
449
+			wp_nonce_field('bulk-' . $this->_args['plural']);
450
+		}
451
+		?>
452 452
         <div class="tablenav <?php echo esc_attr($which); ?>">
453 453
             <?php if ($this->_get_bulk_actions()) { ?>
454 454
                 <div class="alignleft actions bulkactions">
455 455
                     <?php $this->bulk_actions(); ?>
456 456
                 </div>
457 457
             <?php }
458
-            $this->extra_tablenav($which);
459
-            $this->pagination($which);
460
-            ?>
458
+			$this->extra_tablenav($which);
459
+			$this->pagination($which);
460
+			?>
461 461
 
462 462
             <br class="clear" />
463 463
         </div>
464 464
         <?php
465
-    }
466
-
467
-
468
-    /**
469
-     * _filters
470
-     * This receives the filters array from children _get_table_filters() and assembles the string including the filter
471
-     * button.
472
-     *
473
-     * @access private
474
-     * @return void  echos html showing filters
475
-     */
476
-    private function _filters()
477
-    {
478
-        $classname = get_class($this);
479
-        $filters   = apply_filters(
480
-            "FHEE__{$classname}__filters",
481
-            (array) $this->_get_table_filters(),
482
-            $this,
483
-            $this->_screen
484
-        );
485
-
486
-        if (empty($filters)) {
487
-            return;
488
-        }
489
-
490
-        $filters_html = '';
491
-        foreach ($filters as $filter) {
492
-            $filters_html .= wp_kses($filter, AllowedTags::getWithFormTags());
493
-        }
494
-        $filter_submit_btn_text = esc_html__('Filter', 'event_espresso');
495
-        $filter_reset_btn_text = esc_html__('Reset Filters', 'event_espresso');
496
-        $filter_reset_btn_url = esc_url_raw($this->_admin_page->get_current_page_view_url());
497
-
498
-        echo "
465
+	}
466
+
467
+
468
+	/**
469
+	 * _filters
470
+	 * This receives the filters array from children _get_table_filters() and assembles the string including the filter
471
+	 * button.
472
+	 *
473
+	 * @access private
474
+	 * @return void  echos html showing filters
475
+	 */
476
+	private function _filters()
477
+	{
478
+		$classname = get_class($this);
479
+		$filters   = apply_filters(
480
+			"FHEE__{$classname}__filters",
481
+			(array) $this->_get_table_filters(),
482
+			$this,
483
+			$this->_screen
484
+		);
485
+
486
+		if (empty($filters)) {
487
+			return;
488
+		}
489
+
490
+		$filters_html = '';
491
+		foreach ($filters as $filter) {
492
+			$filters_html .= wp_kses($filter, AllowedTags::getWithFormTags());
493
+		}
494
+		$filter_submit_btn_text = esc_html__('Filter', 'event_espresso');
495
+		$filter_reset_btn_text = esc_html__('Reset Filters', 'event_espresso');
496
+		$filter_reset_btn_url = esc_url_raw($this->_admin_page->get_current_page_view_url());
497
+
498
+		echo "
499 499
         <div class='ee-list-table-filters actions alignleft'>
500 500
            $filters_html
501 501
             <span class='ee-list-table-filters__submit-buttons'>
@@ -510,444 +510,444 @@  discard block
 block discarded – undo
510 510
                 </a>
511 511
             </span>
512 512
         </div>";
513
-    }
514
-
515
-
516
-    /**
517
-     * Callback for 'list_table_primary_column' WordPress filter
518
-     * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
519
-     * column when class is instantiated.
520
-     *
521
-     * @param string $column_name
522
-     * @return string
523
-     * @see WP_List_Table::get_primary_column_name
524
-     */
525
-    public function set_primary_column($column_name)
526
-    {
527
-        return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
528
-    }
529
-
530
-
531
-    /**
532
-     *
533
-     */
534
-    public function prepare_items()
535
-    {
536
-        $this->_set_column_info();
537
-        // $this->_column_headers = $this->get_column_info();
538
-        $total_items = $this->_all_data_count;
539
-        $this->process_bulk_action();
540
-
541
-        $this->items = $this->_data;
542
-        $this->set_pagination_args(
543
-            [
544
-                'total_items' => $total_items,
545
-                'per_page'    => $this->_per_page,
546
-                'total_pages' => ceil($total_items / $this->_per_page),
547
-            ]
548
-        );
549
-    }
550
-
551
-
552
-    /**
553
-     * @param object|array $item
554
-     * @return string html content for the column
555
-     */
556
-    protected function column_cb($item)
557
-    {
558
-        return '';
559
-    }
560
-
561
-
562
-    /**
563
-     * This column is the default for when there is no defined column method for a registered column.
564
-     * This can be overridden by child classes, but allows for hooking in for custom columns.
565
-     *
566
-     * @param EE_Base_Class $item
567
-     * @param string        $column_name The column being called.
568
-     * @return string html content for the column
569
-     */
570
-    public function column_default($item, $column_name)
571
-    {
572
-        /**
573
-         * Dynamic hook allowing for adding additional column content in this list table.
574
-         * Note that $this->screen->id is in the format
575
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
576
-         * table it is: event-espresso_page_espresso_messages.
577
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
578
-         * hook prefix ("event-espresso") will be different.
579
-         */
580
-        ob_start();
581
-        do_action(
582
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
583
-            $item,
584
-            $this->_screen
585
-        );
586
-        return ob_get_clean();
587
-    }
588
-
589
-
590
-    /**
591
-     * Get a list of columns. The format is:
592
-     * 'internal-name' => 'Title'
593
-     *
594
-     * @return array
595
-     * @since  3.1.0
596
-     * @access public
597
-     * @abstract
598
-     */
599
-    public function get_columns()
600
-    {
601
-        /**
602
-         * Dynamic hook allowing for adding additional columns in this list table.
603
-         * Note that $this->screen->id is in the format
604
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
605
-         * table it is: event-espresso_page_espresso_messages.
606
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
607
-         * hook prefix ("event-espresso") will be different.
608
-         *
609
-         * @var array
610
-         */
611
-        return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
612
-    }
613
-
614
-
615
-    /**
616
-     * Get an associative array ( id => link ) with the list
617
-     * of views available on this table.
618
-     *
619
-     * @return array
620
-     * @since  3.1.0
621
-     * @access protected
622
-     */
623
-    public function get_views()
624
-    {
625
-        return $this->_views;
626
-    }
627
-
628
-
629
-    /**
630
-     * Generate the views html.
631
-     */
632
-    public function display_views()
633
-    {
634
-        $views           = $this->get_views();
635
-        $assembled_views = [];
636
-
637
-        if (empty($views)) {
638
-            return;
639
-        }
640
-        echo "<ul class='subsubsub'>\n";
641
-        foreach ($views as $view) {
642
-            $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
643
-            if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
644
-                $filter = "<li";
645
-                $filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
646
-                $filter .= ">";
647
-                $filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
648
-                $filter .= '<span class="count">(' . $count . ')</span>';
649
-                $filter .= '</li>';
650
-                $assembled_views[ $view['slug'] ] = $filter;
651
-            }
652
-        }
653
-
654
-        echo ! empty($assembled_views)
655
-            ? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
656
-            : '';
657
-        echo "</ul>";
658
-    }
659
-
660
-
661
-    /**
662
-     * Generates content for a single row of the table
663
-     *
664
-     * @param EE_Base_Class $item The current item
665
-     * @since  4.1
666
-     * @access public
667
-     */
668
-    public function single_row($item)
669
-    {
670
-        $row_class = $this->_get_row_class($item);
671
-        echo '<tr class="' . esc_attr($row_class) . '">';
672
-        $this->single_row_columns($item); // already escaped
673
-        echo '</tr>';
674
-    }
675
-
676
-
677
-    /**
678
-     * This simply sets up the row class for the table rows.
679
-     * Allows for easier overriding of child methods for setting up sorting.
680
-     *
681
-     * @param EE_Base_Class $item the current item
682
-     * @return string
683
-     */
684
-    protected function _get_row_class($item)
685
-    {
686
-        static $row_class = '';
687
-        $row_class = ($row_class === '' ? 'alternate' : '');
688
-
689
-        $new_row_class = $row_class;
690
-
691
-        if (! empty($this->_ajax_sorting_callback)) {
692
-            $new_row_class .= ' rowsortable';
693
-        }
694
-
695
-        return $new_row_class;
696
-    }
697
-
698
-
699
-    /**
700
-     * @return array
701
-     */
702
-    public function get_sortable_columns()
703
-    {
704
-        return (array) $this->_sortable_columns;
705
-    }
706
-
707
-
708
-    /**
709
-     * @return string
710
-     */
711
-    public function get_ajax_sorting_callback()
712
-    {
713
-        return $this->_ajax_sorting_callback;
714
-    }
715
-
716
-
717
-    /**
718
-     * @return array
719
-     */
720
-    public function get_hidden_columns()
721
-    {
722
-        $user_id     = get_current_user_id();
723
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
724
-        if (empty($has_default) && ! empty($this->_hidden_columns)) {
725
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
726
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
727
-        }
728
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
729
-        return (array) get_user_option($ref, $user_id);
730
-    }
731
-
732
-
733
-    /**
734
-     * Generates the columns for a single row of the table.
735
-     * Overridden from wp_list_table so as to allow us to filter the column content for a given
736
-     * column.
737
-     *
738
-     * @param EE_Base_Class $item The current item
739
-     * @since 3.1.0
740
-     */
741
-    public function single_row_columns($item)
742
-    {
743
-        [$columns, $hidden, $sortable, $primary] = $this->get_column_info();
744
-
745
-        foreach ($columns as $column_name => $column_display_name) {
746
-
747
-            /**
748
-             * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
749
-             * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
750
-             */
751
-            $hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
752
-
753
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
754
-            if ($primary === $column_name) {
755
-                $classes .= ' has-row-actions column-primary';
756
-            }
757
-
758
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
759
-
760
-            $class = 'class="' . esc_attr($classes) . '"';
761
-
762
-            $attributes = "{$class}{$data}";
763
-
764
-            if ($column_name === 'cb') {
765
-                echo '<th scope="row" class="check-column">';
766
-                echo apply_filters(
767
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
768
-                    $this->column_cb($item), // already escaped
769
-                    $item,
770
-                    $this
771
-                );
772
-                echo '</th>';
773
-            } elseif (method_exists($this, 'column_' . $column_name)) {
774
-                echo "<td $attributes>"; // already escaped
775
-                echo apply_filters(
776
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
777
-                    call_user_func([$this, 'column_' . $column_name], $item),
778
-                    $item,
779
-                    $this
780
-                );
781
-                echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
782
-                echo "</td>";
783
-            } else {
784
-                echo "<td $attributes>"; // already escaped
785
-                echo apply_filters(
786
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
787
-                    $this->column_default($item, $column_name),
788
-                    $item,
789
-                    $column_name,
790
-                    $this
791
-                );
792
-                echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
793
-                echo "</td>";
794
-            }
795
-        }
796
-    }
797
-
798
-
799
-    /**
800
-     * Extra controls to be displayed between bulk actions and pagination
801
-     *
802
-     * @access public
803
-     * @param string $which
804
-     * @throws EE_Error
805
-     */
806
-    public function extra_tablenav($which)
807
-    {
808
-        if ($which === 'top') {
809
-            $this->_filters();
810
-            echo wp_kses($this->_get_hidden_fields(), AllowedTags::getWithFormTags());
811
-        } else {
812
-            echo '<div class="list-table-bottom-buttons alignleft actions">';
813
-            foreach ($this->_bottom_buttons as $type => $action) {
814
-                $route         = $action['route'] ?? '';
815
-                $extra_request = $action['extra_request'] ?? '';
816
-                $btn_class     = $action['btn_class'] ?? 'button button--secondary';
817
-                // already escaped
818
-                echo wp_kses($this->_admin_page->get_action_link_or_button(
819
-                    $route,
820
-                    $type,
821
-                    $extra_request,
822
-                    $btn_class
823
-                ), AllowedTags::getWithFormTags());
824
-            }
825
-            do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
826
-            echo '</div>';
827
-        }
828
-    }
829
-
830
-
831
-    /**
832
-     * Get an associative array ( option_name => option_title ) with the list
833
-     * of bulk actions available on this table.
834
-     *
835
-     * @return array
836
-     * @since  3.1.0
837
-     * @access protected
838
-     */
839
-    public function get_bulk_actions()
840
-    {
841
-        return (array) $this->_get_bulk_actions();
842
-    }
843
-
844
-
845
-    /**
846
-     * Processing bulk actions.
847
-     */
848
-    public function process_bulk_action()
849
-    {
850
-        // this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
851
-        // reference in case there is a case where it gets used.
852
-    }
853
-
854
-
855
-    /**
856
-     * returns the EE admin page this list table is associated with
857
-     *
858
-     * @return EE_Admin_Page
859
-     */
860
-    public function get_admin_page()
861
-    {
862
-        return $this->_admin_page;
863
-    }
864
-
865
-
866
-    /**
867
-     * A "helper" function for all children to provide an html string of
868
-     * actions to output in their content.  It is preferable for child classes
869
-     * to use this method for generating their actions content so that it's
870
-     * filterable by plugins
871
-     *
872
-     * @param string        $action_container           what are the html container
873
-     *                                                  elements for this actions string?
874
-     * @param string        $action_class               What class is for the container
875
-     *                                                  element.
876
-     * @param string        $action_items               The contents for the action items
877
-     *                                                  container.  This is filtered before
878
-     *                                                  returned.
879
-     * @param string        $action_id                  What id (optional) is used for the
880
-     *                                                  container element.
881
-     * @param EE_Base_Class $item                       The object for the column displaying
882
-     *                                                  the actions.
883
-     * @return string The assembled action elements container.
884
-     */
885
-    protected function _action_string(
886
-        $action_items,
887
-        $item,
888
-        $action_container = 'ul',
889
-        $action_class = '',
890
-        $action_id = ''
891
-    ) {
892
-        $action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
893
-        $action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
894
-        $open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
895
-        $close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
896
-        try {
897
-            $content = apply_filters(
898
-                'FHEE__EE_Admin_List_Table___action_string__action_items',
899
-                $action_items,
900
-                $item,
901
-                $this
902
-            );
903
-        } catch (Exception $e) {
904
-            if (WP_DEBUG) {
905
-                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
906
-            }
907
-            $content = $action_items;
908
-        }
909
-        return "{$open_tag}{$content}{$close_tag}";
910
-    }
911
-
912
-
913
-    /**
914
-     * @return string
915
-     */
916
-    protected function getReturnUrl()
917
-    {
918
-        $host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
919
-        $uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
920
-        return urlencode(esc_url_raw("//{$host}{$uri}"));
921
-    }
922
-
923
-
924
-    /**
925
-     * @param string $id
926
-     * @param string $content
927
-     * @param string $align     start (default), center, end
928
-     * @return string
929
-     * @since   $VID:$
930
-     */
931
-    protected function columnContent($id, $content, $align = 'start')
932
-    {
933
-        if (! isset($this->_columns[ $id ])) {
934
-            throw new DomainException('missing column id');
935
-        }
936
-        $heading = $id !== 'cb' ? $this->_columns[ $id ] : '';
937
-        $align = in_array($align, ['start', 'center', 'end']) ? $align : 'start';
938
-        $align = "ee-responsive-table-cell--{$align}";
939
-
940
-        $html = "<div class='ee-responsive-table-cell ee-responsive-table-cell--column-{$id} {$align} ee-layout-row'>";
941
-        $html .= "<div class='ee-responsive-table-cell__heading'>{$heading}</div>";
942
-        $html .= "<div class='ee-responsive-table-cell__content ee-layout-row'>{$content}</div>";
943
-        $html .= "</div>";
944
-        return $html;
945
-    }
946
-
947
-
948
-    protected function actionsModalMenu($actions): string
949
-    {
950
-        return '
513
+	}
514
+
515
+
516
+	/**
517
+	 * Callback for 'list_table_primary_column' WordPress filter
518
+	 * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
519
+	 * column when class is instantiated.
520
+	 *
521
+	 * @param string $column_name
522
+	 * @return string
523
+	 * @see WP_List_Table::get_primary_column_name
524
+	 */
525
+	public function set_primary_column($column_name)
526
+	{
527
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
528
+	}
529
+
530
+
531
+	/**
532
+	 *
533
+	 */
534
+	public function prepare_items()
535
+	{
536
+		$this->_set_column_info();
537
+		// $this->_column_headers = $this->get_column_info();
538
+		$total_items = $this->_all_data_count;
539
+		$this->process_bulk_action();
540
+
541
+		$this->items = $this->_data;
542
+		$this->set_pagination_args(
543
+			[
544
+				'total_items' => $total_items,
545
+				'per_page'    => $this->_per_page,
546
+				'total_pages' => ceil($total_items / $this->_per_page),
547
+			]
548
+		);
549
+	}
550
+
551
+
552
+	/**
553
+	 * @param object|array $item
554
+	 * @return string html content for the column
555
+	 */
556
+	protected function column_cb($item)
557
+	{
558
+		return '';
559
+	}
560
+
561
+
562
+	/**
563
+	 * This column is the default for when there is no defined column method for a registered column.
564
+	 * This can be overridden by child classes, but allows for hooking in for custom columns.
565
+	 *
566
+	 * @param EE_Base_Class $item
567
+	 * @param string        $column_name The column being called.
568
+	 * @return string html content for the column
569
+	 */
570
+	public function column_default($item, $column_name)
571
+	{
572
+		/**
573
+		 * Dynamic hook allowing for adding additional column content in this list table.
574
+		 * Note that $this->screen->id is in the format
575
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
576
+		 * table it is: event-espresso_page_espresso_messages.
577
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
578
+		 * hook prefix ("event-espresso") will be different.
579
+		 */
580
+		ob_start();
581
+		do_action(
582
+			'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
583
+			$item,
584
+			$this->_screen
585
+		);
586
+		return ob_get_clean();
587
+	}
588
+
589
+
590
+	/**
591
+	 * Get a list of columns. The format is:
592
+	 * 'internal-name' => 'Title'
593
+	 *
594
+	 * @return array
595
+	 * @since  3.1.0
596
+	 * @access public
597
+	 * @abstract
598
+	 */
599
+	public function get_columns()
600
+	{
601
+		/**
602
+		 * Dynamic hook allowing for adding additional columns in this list table.
603
+		 * Note that $this->screen->id is in the format
604
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
605
+		 * table it is: event-espresso_page_espresso_messages.
606
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
607
+		 * hook prefix ("event-espresso") will be different.
608
+		 *
609
+		 * @var array
610
+		 */
611
+		return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
612
+	}
613
+
614
+
615
+	/**
616
+	 * Get an associative array ( id => link ) with the list
617
+	 * of views available on this table.
618
+	 *
619
+	 * @return array
620
+	 * @since  3.1.0
621
+	 * @access protected
622
+	 */
623
+	public function get_views()
624
+	{
625
+		return $this->_views;
626
+	}
627
+
628
+
629
+	/**
630
+	 * Generate the views html.
631
+	 */
632
+	public function display_views()
633
+	{
634
+		$views           = $this->get_views();
635
+		$assembled_views = [];
636
+
637
+		if (empty($views)) {
638
+			return;
639
+		}
640
+		echo "<ul class='subsubsub'>\n";
641
+		foreach ($views as $view) {
642
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
643
+			if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
644
+				$filter = "<li";
645
+				$filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
646
+				$filter .= ">";
647
+				$filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
648
+				$filter .= '<span class="count">(' . $count . ')</span>';
649
+				$filter .= '</li>';
650
+				$assembled_views[ $view['slug'] ] = $filter;
651
+			}
652
+		}
653
+
654
+		echo ! empty($assembled_views)
655
+			? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
656
+			: '';
657
+		echo "</ul>";
658
+	}
659
+
660
+
661
+	/**
662
+	 * Generates content for a single row of the table
663
+	 *
664
+	 * @param EE_Base_Class $item The current item
665
+	 * @since  4.1
666
+	 * @access public
667
+	 */
668
+	public function single_row($item)
669
+	{
670
+		$row_class = $this->_get_row_class($item);
671
+		echo '<tr class="' . esc_attr($row_class) . '">';
672
+		$this->single_row_columns($item); // already escaped
673
+		echo '</tr>';
674
+	}
675
+
676
+
677
+	/**
678
+	 * This simply sets up the row class for the table rows.
679
+	 * Allows for easier overriding of child methods for setting up sorting.
680
+	 *
681
+	 * @param EE_Base_Class $item the current item
682
+	 * @return string
683
+	 */
684
+	protected function _get_row_class($item)
685
+	{
686
+		static $row_class = '';
687
+		$row_class = ($row_class === '' ? 'alternate' : '');
688
+
689
+		$new_row_class = $row_class;
690
+
691
+		if (! empty($this->_ajax_sorting_callback)) {
692
+			$new_row_class .= ' rowsortable';
693
+		}
694
+
695
+		return $new_row_class;
696
+	}
697
+
698
+
699
+	/**
700
+	 * @return array
701
+	 */
702
+	public function get_sortable_columns()
703
+	{
704
+		return (array) $this->_sortable_columns;
705
+	}
706
+
707
+
708
+	/**
709
+	 * @return string
710
+	 */
711
+	public function get_ajax_sorting_callback()
712
+	{
713
+		return $this->_ajax_sorting_callback;
714
+	}
715
+
716
+
717
+	/**
718
+	 * @return array
719
+	 */
720
+	public function get_hidden_columns()
721
+	{
722
+		$user_id     = get_current_user_id();
723
+		$has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
724
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
725
+			update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
726
+			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
727
+		}
728
+		$ref = 'manage' . $this->screen->id . 'columnshidden';
729
+		return (array) get_user_option($ref, $user_id);
730
+	}
731
+
732
+
733
+	/**
734
+	 * Generates the columns for a single row of the table.
735
+	 * Overridden from wp_list_table so as to allow us to filter the column content for a given
736
+	 * column.
737
+	 *
738
+	 * @param EE_Base_Class $item The current item
739
+	 * @since 3.1.0
740
+	 */
741
+	public function single_row_columns($item)
742
+	{
743
+		[$columns, $hidden, $sortable, $primary] = $this->get_column_info();
744
+
745
+		foreach ($columns as $column_name => $column_display_name) {
746
+
747
+			/**
748
+			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
749
+			 * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
750
+			 */
751
+			$hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
752
+
753
+			$classes = $column_name . ' column-' . $column_name . $hidden_class;
754
+			if ($primary === $column_name) {
755
+				$classes .= ' has-row-actions column-primary';
756
+			}
757
+
758
+			$data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
759
+
760
+			$class = 'class="' . esc_attr($classes) . '"';
761
+
762
+			$attributes = "{$class}{$data}";
763
+
764
+			if ($column_name === 'cb') {
765
+				echo '<th scope="row" class="check-column">';
766
+				echo apply_filters(
767
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
768
+					$this->column_cb($item), // already escaped
769
+					$item,
770
+					$this
771
+				);
772
+				echo '</th>';
773
+			} elseif (method_exists($this, 'column_' . $column_name)) {
774
+				echo "<td $attributes>"; // already escaped
775
+				echo apply_filters(
776
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
777
+					call_user_func([$this, 'column_' . $column_name], $item),
778
+					$item,
779
+					$this
780
+				);
781
+				echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
782
+				echo "</td>";
783
+			} else {
784
+				echo "<td $attributes>"; // already escaped
785
+				echo apply_filters(
786
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
787
+					$this->column_default($item, $column_name),
788
+					$item,
789
+					$column_name,
790
+					$this
791
+				);
792
+				echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
793
+				echo "</td>";
794
+			}
795
+		}
796
+	}
797
+
798
+
799
+	/**
800
+	 * Extra controls to be displayed between bulk actions and pagination
801
+	 *
802
+	 * @access public
803
+	 * @param string $which
804
+	 * @throws EE_Error
805
+	 */
806
+	public function extra_tablenav($which)
807
+	{
808
+		if ($which === 'top') {
809
+			$this->_filters();
810
+			echo wp_kses($this->_get_hidden_fields(), AllowedTags::getWithFormTags());
811
+		} else {
812
+			echo '<div class="list-table-bottom-buttons alignleft actions">';
813
+			foreach ($this->_bottom_buttons as $type => $action) {
814
+				$route         = $action['route'] ?? '';
815
+				$extra_request = $action['extra_request'] ?? '';
816
+				$btn_class     = $action['btn_class'] ?? 'button button--secondary';
817
+				// already escaped
818
+				echo wp_kses($this->_admin_page->get_action_link_or_button(
819
+					$route,
820
+					$type,
821
+					$extra_request,
822
+					$btn_class
823
+				), AllowedTags::getWithFormTags());
824
+			}
825
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
826
+			echo '</div>';
827
+		}
828
+	}
829
+
830
+
831
+	/**
832
+	 * Get an associative array ( option_name => option_title ) with the list
833
+	 * of bulk actions available on this table.
834
+	 *
835
+	 * @return array
836
+	 * @since  3.1.0
837
+	 * @access protected
838
+	 */
839
+	public function get_bulk_actions()
840
+	{
841
+		return (array) $this->_get_bulk_actions();
842
+	}
843
+
844
+
845
+	/**
846
+	 * Processing bulk actions.
847
+	 */
848
+	public function process_bulk_action()
849
+	{
850
+		// this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
851
+		// reference in case there is a case where it gets used.
852
+	}
853
+
854
+
855
+	/**
856
+	 * returns the EE admin page this list table is associated with
857
+	 *
858
+	 * @return EE_Admin_Page
859
+	 */
860
+	public function get_admin_page()
861
+	{
862
+		return $this->_admin_page;
863
+	}
864
+
865
+
866
+	/**
867
+	 * A "helper" function for all children to provide an html string of
868
+	 * actions to output in their content.  It is preferable for child classes
869
+	 * to use this method for generating their actions content so that it's
870
+	 * filterable by plugins
871
+	 *
872
+	 * @param string        $action_container           what are the html container
873
+	 *                                                  elements for this actions string?
874
+	 * @param string        $action_class               What class is for the container
875
+	 *                                                  element.
876
+	 * @param string        $action_items               The contents for the action items
877
+	 *                                                  container.  This is filtered before
878
+	 *                                                  returned.
879
+	 * @param string        $action_id                  What id (optional) is used for the
880
+	 *                                                  container element.
881
+	 * @param EE_Base_Class $item                       The object for the column displaying
882
+	 *                                                  the actions.
883
+	 * @return string The assembled action elements container.
884
+	 */
885
+	protected function _action_string(
886
+		$action_items,
887
+		$item,
888
+		$action_container = 'ul',
889
+		$action_class = '',
890
+		$action_id = ''
891
+	) {
892
+		$action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
893
+		$action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
894
+		$open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
895
+		$close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
896
+		try {
897
+			$content = apply_filters(
898
+				'FHEE__EE_Admin_List_Table___action_string__action_items',
899
+				$action_items,
900
+				$item,
901
+				$this
902
+			);
903
+		} catch (Exception $e) {
904
+			if (WP_DEBUG) {
905
+				EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
906
+			}
907
+			$content = $action_items;
908
+		}
909
+		return "{$open_tag}{$content}{$close_tag}";
910
+	}
911
+
912
+
913
+	/**
914
+	 * @return string
915
+	 */
916
+	protected function getReturnUrl()
917
+	{
918
+		$host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
919
+		$uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
920
+		return urlencode(esc_url_raw("//{$host}{$uri}"));
921
+	}
922
+
923
+
924
+	/**
925
+	 * @param string $id
926
+	 * @param string $content
927
+	 * @param string $align     start (default), center, end
928
+	 * @return string
929
+	 * @since   $VID:$
930
+	 */
931
+	protected function columnContent($id, $content, $align = 'start')
932
+	{
933
+		if (! isset($this->_columns[ $id ])) {
934
+			throw new DomainException('missing column id');
935
+		}
936
+		$heading = $id !== 'cb' ? $this->_columns[ $id ] : '';
937
+		$align = in_array($align, ['start', 'center', 'end']) ? $align : 'start';
938
+		$align = "ee-responsive-table-cell--{$align}";
939
+
940
+		$html = "<div class='ee-responsive-table-cell ee-responsive-table-cell--column-{$id} {$align} ee-layout-row'>";
941
+		$html .= "<div class='ee-responsive-table-cell__heading'>{$heading}</div>";
942
+		$html .= "<div class='ee-responsive-table-cell__content ee-layout-row'>{$content}</div>";
943
+		$html .= "</div>";
944
+		return $html;
945
+	}
946
+
947
+
948
+	protected function actionsModalMenu($actions): string
949
+	{
950
+		return '
951 951
         <div class="ee-modal-menu">
952 952
             <button class="ee-modal-menu__button button button--secondary button--icon-only ee-aria-tooltip"
953 953
                     aria-label="' . esc_attr__('list table actions menu', 'event_espresso') . '"
@@ -959,24 +959,24 @@  discard block
 block discarded – undo
959 959
                 ' . $actions . '
960 960
             </div>
961 961
         </div>';
962
-    }
962
+	}
963 963
 
964 964
 
965
-    protected function actionsColumnHeader(): string
966
-    {
967
-        return '
965
+	protected function actionsColumnHeader(): string
966
+	{
967
+		return '
968 968
             <span class="ee-actions-column-header-wrap">
969 969
                 <span class="dashicons dashicons-screenoptions"></span>
970 970
                 <span class="ee-actions-column-header">' . esc_html__('Actions', 'event_espresso') . '</span>
971 971
             </span>';
972
-    }
972
+	}
973 973
 
974 974
 
975
-    protected function getActionLink(string $url, string $display_text, string $label, $class = ''): string
976
-    {
977
-        $class = ! empty($class) ? "{$class} ee-list-table-action" : 'ee-list-table-action';
978
-        $class = ! empty($label) ? "{$class} ee-aria-tooltip" : $class;
979
-        $label = ! empty($label) ? " aria-label='{$label}'" : '';
980
-        return "<a href='{$url}' class='{$class}'{$label}>{$display_text}</a>";
981
-    }
975
+	protected function getActionLink(string $url, string $display_text, string $label, $class = ''): string
976
+	{
977
+		$class = ! empty($class) ? "{$class} ee-list-table-action" : 'ee-list-table-action';
978
+		$class = ! empty($label) ? "{$class} ee-aria-tooltip" : $class;
979
+		$label = ! empty($label) ? " aria-label='{$label}'" : '';
980
+		return "<a href='{$url}' class='{$class}'{$label}>{$display_text}</a>";
981
+	}
982 982
 }
Please login to merge, or discard this patch.
event_single_caff/templates/admin-event-single-settings.template.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -4,10 +4,10 @@  discard block
 block discarded – undo
4 4
 
5 5
 add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
6 6
 $values = EEH_Form_Fields::prep_answer_options(
7
-    array(
8
-        array('id' => 1, 'text' => esc_html__('Yes', 'event_espresso')),
9
-        array('id' => 0, 'text' => esc_html__('No', 'event_espresso')),
10
-    )
7
+	array(
8
+		array('id' => 1, 'text' => esc_html__('Yes', 'event_espresso')),
9
+		array('id' => 0, 'text' => esc_html__('No', 'event_espresso')),
10
+	)
11 11
 );
12 12
 ?>
13 13
 
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 
16 16
 <h2 class="ee-admin-settings-hdr">
17 17
     <?php esc_html_e(
18
-        'Single Event Pages',
19
-        'event_espresso'
20
-    ); ?><?php // echo EEH_Template::get_help_tab_link('event_single_settings_info');?>
18
+		'Single Event Pages',
19
+		'event_espresso'
20
+	); ?><?php // echo EEH_Template::get_help_tab_link('event_single_settings_info');?>
21 21
 </h2>
22 22
 <table class="ee-admin-two-column-layout form-table">
23 23
     <tbody>
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
         </th>
30 30
         <td>
31 31
             <?php echo EEH_Form_Fields::select(
32
-                'display_status_banner_single',
33
-                $display_status_banner_single,
34
-                $values,
35
-                'display_status_banner_single',
36
-                'display_status_banner_single'
37
-            ); ?>
32
+				'display_status_banner_single',
33
+				$display_status_banner_single,
34
+				$values,
35
+				'display_status_banner_single',
36
+				'display_status_banner_single'
37
+			); ?>
38 38
             <p class="description"><?php
39
-                esc_html_e(
40
-                    'Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the single event page.',
41
-                    'event_espresso'
42
-                ); ?></p>
39
+				esc_html_e(
40
+					'Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the single event page.',
41
+					'event_espresso'
42
+				); ?></p>
43 43
         </td>
44 44
     </tr>
45 45
 
@@ -47,23 +47,23 @@  discard block
 block discarded – undo
47 47
         <th>
48 48
             <label for="display_venue">
49 49
                 <?php esc_html_e('Display Venue Details', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
50
-                    'display_addresses_in_reg_form_info'
51
-                ); ?>
50
+					'display_addresses_in_reg_form_info'
51
+				); ?>
52 52
             </label>
53 53
         </th>
54 54
         <td>
55 55
             <?php echo EEH_Form_Fields::select(
56
-                'display_venue',
57
-                $display_venue,
58
-                $values,
59
-                'display_venue',
60
-                'display_venue'
61
-            ); ?>
56
+				'display_venue',
57
+				$display_venue,
58
+				$values,
59
+				'display_venue',
60
+				'display_venue'
61
+			); ?>
62 62
             <p class="description"><?php
63
-                esc_html_e(
64
-                    'Do not use this if you are using the venue shortcodes in your event description.',
65
-                    'event_espresso'
66
-                ); ?></p>
63
+				esc_html_e(
64
+					'Do not use this if you are using the venue shortcodes in your event description.',
65
+					'event_espresso'
66
+				); ?></p>
67 67
         </td>
68 68
     </tr>
69 69
 
@@ -75,37 +75,37 @@  discard block
 block discarded – undo
75 75
         </th>
76 76
         <td>
77 77
             <?php
78
-            echo EEH_Form_Fields::select(
79
-                'use_sortable_display_order',
80
-                $use_sortable_display_order,
81
-                $values,
82
-                'EED_Events_Single_use_sortable_display_order',
83
-                'EED_Events_Single_use_sortable_display_order'
84
-            );
85
-            ?>
78
+			echo EEH_Form_Fields::select(
79
+				'use_sortable_display_order',
80
+				$use_sortable_display_order,
81
+				$values,
82
+				'EED_Events_Single_use_sortable_display_order',
83
+				'EED_Events_Single_use_sortable_display_order'
84
+			);
85
+			?>
86 86
         </td>
87 87
     </tr>
88 88
 
89 89
     <tr>
90 90
         <th>
91 91
             <?php esc_html_e('Display Order', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
92
-                'display_addresses_in_reg_form_info'
93
-            ); ?>
92
+				'display_addresses_in_reg_form_info'
93
+			); ?>
94 94
         </th>
95 95
         <td>
96 96
 
97 97
             <?php wp_nonce_field(
98
-                'espresso_update_event_single_order',
99
-                'espresso_update_event_single_order_nonce',
100
-                false
101
-            ); ?>
98
+				'espresso_update_event_single_order',
99
+				'espresso_update_event_single_order_nonce',
100
+				false
101
+			); ?>
102 102
             <?php echo wp_kses($event_single_display_order, AllowedTags::getWithFormTags()); ?>
103 103
 
104 104
             <p class="description"><?php
105
-                esc_html_e(
106
-                    'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the single event page.',
107
-                    'event_espresso'
108
-                ); ?></p>
105
+				esc_html_e(
106
+					'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the single event page.',
107
+					'event_espresso'
108
+				); ?></p>
109 109
 
110 110
         </td>
111 111
     </tr>
Please login to merge, or discard this patch.
admin_pages/payments/Payments_Admin_Page.core.php 2 patches
Indentation   +1206 added lines, -1206 removed lines patch added patch discarded remove patch
@@ -16,1210 +16,1210 @@
 block discarded – undo
16 16
  */
17 17
 class Payments_Admin_Page extends EE_Admin_Page
18 18
 {
19
-    /**
20
-     * Variables used for when we're re-sorting the logs results,
21
-     * in case we needed to do two queries, and we need to resort
22
-     *
23
-     * @var string
24
-     */
25
-    private $_sort_logs_again_direction;
26
-
27
-
28
-    /**
29
-     * @Constructor
30
-     * @access public
31
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
32
-     * @throws EE_Error
33
-     * @throws InvalidArgumentException
34
-     * @throws InvalidDataTypeException
35
-     * @throws InvalidInterfaceException
36
-     * @throws ReflectionException
37
-     */
38
-    public function __construct($routing = true)
39
-    {
40
-        parent::__construct($routing);
41
-    }
42
-
43
-
44
-    protected function _init_page_props()
45
-    {
46
-        $this->page_slug = EE_PAYMENTS_PG_SLUG;
47
-        $this->page_label = esc_html__('Payment Methods', 'event_espresso');
48
-        $this->_admin_base_url = EE_PAYMENTS_ADMIN_URL;
49
-        $this->_admin_base_path = EE_PAYMENTS_ADMIN;
50
-    }
51
-
52
-
53
-    protected function _ajax_hooks()
54
-    {
55
-        // todo: all hooks for ajax goes here.
56
-    }
57
-
58
-
59
-    protected function _define_page_props()
60
-    {
61
-        $this->_admin_page_title = $this->page_label;
62
-        $this->_labels = array(
63
-            'publishbox' => esc_html__('Update Settings', 'event_espresso'),
64
-        );
65
-    }
66
-
67
-
68
-    protected function _set_page_routes()
69
-    {
70
-        /**
71
-         * note that with payment method capabilities, although we've implemented
72
-         * capability mapping which will be used for accessing payment methods owned by
73
-         * other users.  This is not fully implemented yet in the payment method ui.
74
-         * Currently, only the "plural" caps are in active use.
75
-         * When cap mapping is implemented, some routes will need to use the singular form of
76
-         * capability method and also include the $id of the payment method for the route.
77
-         **/
78
-        $this->_page_routes = array(
79
-            'default'                   => array(
80
-                'func'       => '_payment_methods_list',
81
-                'capability' => 'ee_edit_payment_methods',
82
-            ),
83
-            'payment_settings'          => array(
84
-                'func'       => '_payment_settings',
85
-                'capability' => 'ee_manage_gateways',
86
-            ),
87
-            'activate_payment_method'   => array(
88
-                'func'       => '_activate_payment_method',
89
-                'noheader'   => true,
90
-                'capability' => 'ee_edit_payment_methods',
91
-            ),
92
-            'deactivate_payment_method' => array(
93
-                'func'       => '_deactivate_payment_method',
94
-                'noheader'   => true,
95
-                'capability' => 'ee_delete_payment_methods',
96
-            ),
97
-            'update_payment_method'     => array(
98
-                'func'               => '_update_payment_method',
99
-                'noheader'           => true,
100
-                'headers_sent_route' => 'default',
101
-                'capability'         => 'ee_edit_payment_methods',
102
-            ),
103
-            'update_payment_settings'   => array(
104
-                'func'       => '_update_payment_settings',
105
-                'noheader'   => true,
106
-                'capability' => 'ee_manage_gateways',
107
-            ),
108
-            'payment_log'               => array(
109
-                'func'       => '_payment_log_overview_list_table',
110
-                'capability' => 'ee_read_payment_methods',
111
-            ),
112
-            'payment_log_details'       => array(
113
-                'func'       => '_payment_log_details',
114
-                'capability' => 'ee_read_payment_methods',
115
-            ),
116
-        );
117
-    }
118
-
119
-
120
-    /**
121
-     * @throws EE_Error
122
-     * @throws ReflectionException
123
-     */
124
-    protected function _set_page_config()
125
-    {
126
-        $payment_method_list_config = array(
127
-            'nav'           => array(
128
-                'label' => esc_html__('Payment Methods', 'event_espresso'),
129
-                'icon' => 'dashicons-bank',
130
-                'order' => 10,
131
-            ),
132
-            'metaboxes'     => $this->_default_espresso_metaboxes,
133
-            'help_tabs'     => array_merge(
134
-                array(
135
-                    'payment_methods_overview_help_tab' => array(
136
-                        'title'    => esc_html__('Payment Methods Overview', 'event_espresso'),
137
-                        'filename' => 'payment_methods_overview',
138
-                    ),
139
-                ),
140
-                $this->_add_payment_method_help_tabs()
141
-            ),
142
-            'require_nonce' => false,
143
-        );
144
-        $this->_page_config = array(
145
-            'default'          => $payment_method_list_config,
146
-            'payment_settings' => array(
147
-                'nav'           => array(
148
-                    'label' => esc_html__('Settings', 'event_espresso'),
149
-                    'icon' => 'dashicons-admin-generic',
150
-                    'order' => 20,
151
-                ),
152
-                'help_tabs'     => array(
153
-                    'payment_methods_settings_help_tab' => array(
154
-                        'title'    => esc_html__('Payment Method Settings', 'event_espresso'),
155
-                        'filename' => 'payment_methods_settings',
156
-                    ),
157
-                ),
158
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
159
-                'require_nonce' => false,
160
-            ),
161
-            'payment_log'      => array(
162
-                'nav'           => array(
163
-                    'label' => esc_html__("Logs", 'event_espresso'),
164
-                    'icon' => 'dashicons-text-page',
165
-                    'order' => 30,
166
-                ),
167
-                'list_table'    => 'Payment_Log_Admin_List_Table',
168
-                'metaboxes'     => $this->_default_espresso_metaboxes,
169
-                'require_nonce' => false,
170
-            ),
171
-        );
172
-    }
173
-
174
-
175
-    /**
176
-     * @return array
177
-     * @throws DomainException
178
-     * @throws EE_Error
179
-     * @throws InvalidArgumentException
180
-     * @throws InvalidDataTypeException
181
-     * @throws InvalidInterfaceException
182
-     * @throws ReflectionException
183
-     */
184
-    protected function _add_payment_method_help_tabs()
185
-    {
186
-        EE_Registry::instance()->load_lib('Payment_Method_Manager');
187
-        $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
188
-        $all_pmt_help_tabs_config = array();
189
-        foreach ($payment_method_types as $payment_method_type) {
190
-            if (
191
-                ! EE_Registry::instance()->CAP->current_user_can(
192
-                    $payment_method_type->cap_name(),
193
-                    'specific_payment_method_type_access'
194
-                )
195
-            ) {
196
-                continue;
197
-            }
198
-            foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
199
-                $template_args = isset($config['template_args']) ? $config['template_args'] : array();
200
-                $template_args['admin_page_obj'] = $this;
201
-                $all_pmt_help_tabs_config[ $help_tab_name ] = array(
202
-                    'title'   => $config['title'],
203
-                    'content' => EEH_Template::display_template(
204
-                        $payment_method_type->file_folder() . 'help_tabs/' . $config['filename'] . '.help_tab.php',
205
-                        $template_args,
206
-                        true
207
-                    ),
208
-                );
209
-            }
210
-        }
211
-        return $all_pmt_help_tabs_config;
212
-    }
213
-
214
-
215
-    // none of the below group are currently used for Gateway Settings
216
-    protected function _add_screen_options()
217
-    {
218
-    }
219
-
220
-
221
-    protected function _add_feature_pointers()
222
-    {
223
-    }
224
-
225
-
226
-    public function admin_init()
227
-    {
228
-    }
229
-
230
-
231
-    public function admin_notices()
232
-    {
233
-    }
234
-
235
-
236
-    public function admin_footer_scripts()
237
-    {
238
-    }
239
-
240
-
241
-    public function load_scripts_styles()
242
-    {
243
-        // styles
244
-        wp_enqueue_style('espresso-ui-theme');
245
-        wp_register_style(
246
-            'espresso_payments',
247
-            EE_PAYMENTS_ASSETS_URL . 'ee-payments.css',
248
-            [],
249
-            EVENT_ESPRESSO_VERSION
250
-        );
251
-        // scripts
252
-        wp_enqueue_script('ee_admin_js');
253
-        wp_enqueue_script('ee-text-links');
254
-        wp_enqueue_script(
255
-            'espresso_payments',
256
-            EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
257
-            ['ee-datepicker'],
258
-            EVENT_ESPRESSO_VERSION,
259
-            true
260
-        );
261
-    }
262
-
263
-
264
-    public function load_scripts_styles_default()
265
-    {
266
-        wp_enqueue_style('espresso_payments');
267
-        wp_enqueue_style('ee-text-links');
268
-    }
269
-
270
-
271
-    public function load_scripts_styles_payment_log_details()
272
-    {
273
-        wp_enqueue_style('espresso_payments');
274
-    }
275
-
276
-
277
-    /**
278
-     * @throws EE_Error
279
-     * @throws ReflectionException
280
-     */
281
-    protected function _payment_methods_list()
282
-    {
283
-        /**
284
-         * first let's ensure payment methods have been set up.
285
-         * We do this here because when people activate a payment method for the first time (as an addon),
286
-         * it may not set up its capabilities or get registered correctly due to the loading process.
287
-         * However, people MUST set up the details for the payment method,
288
-         * so it's safe to do a recheck here.
289
-         */
290
-        EE_Registry::instance()->load_lib('Payment_Method_Manager');
291
-        EEM_Payment_Method::instance()->verify_button_urls();
292
-        // set up tabs, one for each payment method type
293
-        $tabs = array();
294
-        $payment_methods = array();
295
-        foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
296
-            // we don't want to show admin-only PMTs for now
297
-            if ($pmt_obj instanceof EE_PMT_Admin_Only) {
298
-                continue;
299
-            }
300
-            // check access
301
-            if (
302
-                ! EE_Registry::instance()->CAP->current_user_can(
303
-                    $pmt_obj->cap_name(),
304
-                    'specific_payment_method_type_access'
305
-                )
306
-            ) {
307
-                continue;
308
-            }
309
-            // check for any active pms of that type
310
-            $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
311
-            if (! $payment_method instanceof EE_Payment_Method) {
312
-                $payment_method = EE_Payment_Method::new_instance(
313
-                    array(
314
-                        'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
315
-                        'PMD_type'       => $pmt_obj->system_name(),
316
-                        'PMD_name'       => $pmt_obj->pretty_name(),
317
-                        'PMD_admin_name' => $pmt_obj->pretty_name(),
318
-                    )
319
-                );
320
-            }
321
-            $payment_methods[ $payment_method->slug() ] = $payment_method;
322
-        }
323
-        $payment_methods = apply_filters(
324
-            'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
325
-            $payment_methods
326
-        );
327
-        foreach ($payment_methods as $payment_method) {
328
-            if ($payment_method instanceof EE_Payment_Method) {
329
-                $this->addMetaBox(
330
-                    // html id
331
-                    'espresso_' . $payment_method->slug() . '_payment_settings',
332
-                    // title
333
-                    sprintf(esc_html__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
334
-                    // callback
335
-                    array($this, 'payment_method_settings_meta_box'),
336
-                    // post type
337
-                    null,
338
-                    // context
339
-                    'normal',
340
-                    // priority
341
-                    'default',
342
-                    // callback args
343
-                    array('payment_method' => $payment_method)
344
-                );
345
-                // setup for tabbed content
346
-                $tabs[ $payment_method->slug() ] = array(
347
-                    'label' => $payment_method->admin_name(),
348
-                    'class' => $payment_method->active() ? 'gateway-active' : '',
349
-                    'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
350
-                    'title' => esc_html__('Modify this Payment Method', 'event_espresso'),
351
-                    'slug'  => $payment_method->slug(),
352
-                    'icon'  => $payment_method->active()
353
-                        ? '<span class="dashicons dashicons-yes-alt"></span>'
354
-                        : '<span class="dashicons dashicons-remove"></span>',
355
-                );
356
-            }
357
-        }
358
-        $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links(
359
-            $tabs,
360
-            'payment_method_links',
361
-            '',
362
-            $this->_get_active_payment_method_slug()
363
-        );
364
-        $this->display_admin_page_with_sidebar();
365
-    }
366
-
367
-
368
-    /**
369
-     *   _get_active_payment_method_slug
370
-     *
371
-     * @return string
372
-     * @throws EE_Error
373
-     */
374
-    protected function _get_active_payment_method_slug()
375
-    {
376
-        $payment_method_slug = false;
377
-        // decide which payment method tab to open first, as dictated by the request's 'payment_method'
378
-        if (isset($this->_req_data['payment_method'])) {
379
-            // if they provided the current payment method, use it
380
-            $payment_method_slug = sanitize_key($this->_req_data['payment_method']);
381
-        }
382
-        /** @var EE_Payment_Method $payment_method */
383
-        $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
384
-        // if that didn't work or wasn't provided, find another way to select the current pm
385
-        if (! $this->_verify_payment_method($payment_method)) {
386
-            // like, looking for an active one
387
-            $payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
388
-            // test that one as well
389
-            if ($this->_verify_payment_method($payment_method)) {
390
-                $payment_method_slug = $payment_method->slug();
391
-            } else {
392
-                $payment_method_slug = 'paypal_standard';
393
-            }
394
-        }
395
-        return $payment_method_slug;
396
-    }
397
-
398
-
399
-    /**
400
-     *    payment_method_settings_meta_box
401
-     *    returns TRUE if the passed payment method is properly constructed and the logged-in user has the correct
402
-     *    capabilities to access it
403
-     *
404
-     * @param EE_Payment_Method $payment_method
405
-     * @return boolean
406
-     * @throws EE_Error
407
-     */
408
-    protected function _verify_payment_method($payment_method)
409
-    {
410
-        if (
411
-            $payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base
412
-            && EE_Registry::instance()->CAP->current_user_can(
413
-                $payment_method->type_obj()->cap_name(),
414
-                'specific_payment_method_type_access'
415
-            )
416
-        ) {
417
-            return true;
418
-        }
419
-        return false;
420
-    }
421
-
422
-
423
-    /**
424
-     *    payment_method_settings_meta_box
425
-     *
426
-     * @param NULL  $post_obj_which_is_null is an object containing the current post (as a $post object)
427
-     * @param array $metabox                is an array with metabox id, title, callback, and args elements. the value
428
-     *                                      at 'args' has key 'payment_method', as set within _payment_methods_list
429
-     * @return void
430
-     * @throws EE_Error
431
-     * @throws ReflectionException
432
-     */
433
-    public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox)
434
-    {
435
-        $payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
436
-            ? $metabox['args']['payment_method'] : null;
437
-        if (! $payment_method instanceof EE_Payment_Method) {
438
-            throw new EE_Error(
439
-                esc_html__(
440
-                    'Payment method metabox setup incorrectly. No Payment method object was supplied',
441
-                    'event_espresso'
442
-                )
443
-            );
444
-        }
445
-        $payment_method_scopes = $payment_method->active();
446
-        // if the payment method really exists show its form, otherwise the activation template
447
-        if ($payment_method->ID() && ! empty($payment_method_scopes)) {
448
-            $form = $this->_generate_payment_method_settings_form($payment_method);
449
-            if ($form->form_data_present_in($this->_req_data)) {
450
-                $form->receive_form_submission($this->_req_data);
451
-            }
452
-            echo wp_kses($form->form_open() . $form->get_html_and_js() . $form->form_close(), AllowedTags::getWithFormTags());
453
-        } else {
454
-            echo wp_kses($this->_activate_payment_method_button($payment_method)->get_html_and_js(), AllowedTags::getWithFormTags());
455
-        }
456
-    }
457
-
458
-
459
-    /**
460
-     * Gets the form for all the settings related to this payment method type
461
-     *
462
-     * @access protected
463
-     * @param EE_Payment_Method $payment_method
464
-     * @return EE_Form_Section_Proper
465
-     * @throws EE_Error
466
-     */
467
-    protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method = null)
468
-    {
469
-        if (! $payment_method instanceof EE_Payment_Method) {
470
-            return new EE_Form_Section_Proper();
471
-        }
472
-        $subsections = apply_filters(
473
-            'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
474
-            [
475
-                'pci_dss_compliance'      => $this->_pci_dss_compliance($payment_method),
476
-                'currency_support'        => $this->_currency_support($payment_method),
477
-                'payment_method_settings' => $this->_payment_method_settings($payment_method),
478
-                'update'                  => $this->_update_payment_method_button($payment_method),
479
-                'deactivate'              => $this->_deactivate_payment_method_button($payment_method),
480
-                'fine_print'              => $this->_fine_print(),
481
-            ],
482
-            $payment_method
483
-        );
484
-        return new EE_Form_Section_Proper(
485
-            array(
486
-                'name'            => $payment_method->slug() . '_settings_form',
487
-                'html_id'         => $payment_method->slug() . '_settings_form',
488
-                'action'          => EE_Admin_Page::add_query_args_and_nonce(
489
-                    array(
490
-                        'action'         => 'update_payment_method',
491
-                        'payment_method' => $payment_method->slug(),
492
-                    ),
493
-                    EE_PAYMENTS_ADMIN_URL
494
-                ),
495
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
496
-                'subsections'     => array_filter($subsections),
497
-            )
498
-        );
499
-    }
500
-
501
-
502
-    /**
503
-     * _pci_dss_compliance
504
-     *
505
-     * @access protected
506
-     * @param EE_Payment_Method $payment_method
507
-     * @return EE_Form_Section_HTML|null
508
-     * @throws EE_Error
509
-     */
510
-    protected function _pci_dss_compliance(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
511
-    {
512
-        if (!$payment_method->type_obj()->requires_https()) {
513
-            return null;
514
-        }
515
-        return new EE_Form_Section_HTML(
516
-            EEH_HTML::table(
517
-                EEH_HTML::tr(
518
-                    EEH_HTML::th(
519
-                        EEH_HTML::label(
520
-                            EEH_HTML::strong(
521
-                                esc_html__('IMPORTANT', 'event_espresso'),
522
-                                '',
523
-                                'important-notice'
524
-                            )
525
-                        )
526
-                    ) .
527
-                    EEH_HTML::td(
528
-                        EEH_HTML::strong(
529
-                            esc_html__(
530
-                                'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.',
531
-                                'event_espresso'
532
-                            )
533
-                        )
534
-                        .
535
-                        EEH_HTML::br()
536
-                        .
537
-                        esc_html__('Learn more about ', 'event_espresso')
538
-                        . EEH_HTML::link(
539
-                            'https://www.pcisecuritystandards.org/merchants/index.php',
540
-                            esc_html__('PCI DSS compliance', 'event_espresso')
541
-                        )
542
-                    )
543
-                )
544
-            )
545
-        );
546
-    }
547
-
548
-
549
-    /**
550
-     * _currency_support
551
-     *
552
-     * @access protected
553
-     * @param EE_Payment_Method $payment_method
554
-     * @return EE_Form_Section_HTML|null
555
-     * @throws EE_Error
556
-     */
557
-    protected function _currency_support(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
558
-    {
559
-        if ($payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
560
-            return null;
561
-        }
562
-        return new EE_Form_Section_HTML(
563
-            EEH_HTML::table(
564
-                EEH_HTML::tr(
565
-                    EEH_HTML::th(
566
-                        EEH_HTML::label(
567
-                            EEH_HTML::strong(
568
-                                esc_html__('IMPORTANT', 'event_espresso'),
569
-                                '',
570
-                                'important-notice'
571
-                            )
572
-                        )
573
-                    ) .
574
-                    EEH_HTML::td(
575
-                        EEH_HTML::strong(
576
-                            sprintf(
577
-                                esc_html__(
578
-                                    'This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.',
579
-                                    'event_espresso'
580
-                                ),
581
-                                EE_Config::instance()->currency->code
582
-                            )
583
-                        )
584
-                    )
585
-                )
586
-            )
587
-        );
588
-    }
589
-
590
-
591
-    /**
592
-     * _update_payment_method_button
593
-     *
594
-     * @access protected
595
-     * @param EE_Payment_Method $payment_method
596
-     * @return EE_Payment_Method_Form
597
-     * @throws EE_Error
598
-     */
599
-    protected function _payment_method_settings(EE_Payment_Method $payment_method)
600
-    {
601
-        // modify the form, so we only have/show fields that will be implemented for this version
602
-        return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
603
-    }
604
-
605
-
606
-    /**
607
-     * Simplifies the form to merely reproduce 4.1's gateway settings functionality
608
-     *
609
-     * @param EE_Form_Section_Proper $form_section
610
-     * @param string                 $payment_method_name
611
-     * @return EE_Payment_Method_Form
612
-     * @throws EE_Error
613
-     */
614
-    protected function _simplify_form($form_section, $payment_method_name = '')
615
-    {
616
-        if ($form_section instanceof EE_Payment_Method_Form) {
617
-            $form_section->exclude(
618
-                array(
619
-                    'PMD_type', // don't want them changing the type
620
-                    'PMD_slug', // or the slug (probably never)
621
-                    'PMD_wp_user', // or the user's ID
622
-                    'Currency' // or the currency, until the rest of EE supports simultaneous currencies
623
-                )
624
-            );
625
-            return $form_section;
626
-        } else {
627
-            throw new EE_Error(
628
-                sprintf(
629
-                    esc_html__(
630
-                        'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.',
631
-                        'event_espresso'
632
-                    ),
633
-                    $payment_method_name
634
-                )
635
-            );
636
-        }
637
-    }
638
-
639
-
640
-    /**
641
-     * _update_payment_method_button
642
-     *
643
-     * @access protected
644
-     * @param EE_Payment_Method $payment_method
645
-     * @return EE_Form_Section_HTML
646
-     * @throws EE_Error
647
-     */
648
-    protected function _update_payment_method_button(EE_Payment_Method $payment_method)
649
-    {
650
-        $update_button = new EE_Submit_Input(
651
-            array(
652
-                'name'       => 'submit',
653
-                'html_id'    => 'save_' . $payment_method->slug() . '_settings',
654
-                'default'    => sprintf(
655
-                    esc_html__('Update %s Payment Settings', 'event_espresso'),
656
-                    $payment_method->admin_name()
657
-                ),
658
-                'html_label' => EEH_HTML::nbsp(),
659
-            )
660
-        );
661
-        return new EE_Form_Section_HTML(
662
-            EEH_HTML::table(
663
-                EEH_HTML::no_row(EEH_HTML::br(2)) .
664
-                EEH_HTML::tr(
665
-                    EEH_HTML::th(esc_html__('Update Settings', 'event_espresso')) .
666
-                    EEH_HTML::td(
667
-                        $update_button->get_html_for_input()
668
-                    )
669
-                )
670
-            )
671
-        );
672
-    }
673
-
674
-
675
-    /**
676
-     * _deactivate_payment_method_button
677
-     *
678
-     * @access protected
679
-     * @param EE_Payment_Method $payment_method
680
-     * @return EE_Form_Section_HTML
681
-     */
682
-    protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method)
683
-    {
684
-        $link_text_and_title = sprintf(
685
-            esc_html__('Deactivate %1$s Payments?', 'event_espresso'),
686
-            $payment_method->admin_name()
687
-        );
688
-        return new EE_Form_Section_HTML(
689
-            EEH_HTML::table(
690
-                EEH_HTML::tr(
691
-                    EEH_HTML::th(esc_html__('Deactivate Payment Method', 'event_espresso')) .
692
-                    EEH_HTML::td(
693
-                        EEH_HTML::link(
694
-                            EE_Admin_Page::add_query_args_and_nonce(
695
-                                array(
696
-                                    'action'         => 'deactivate_payment_method',
697
-                                    'payment_method' => $payment_method->slug(),
698
-                                ),
699
-                                EE_PAYMENTS_ADMIN_URL
700
-                            ),
701
-                            $link_text_and_title,
702
-                            $link_text_and_title,
703
-                            'deactivate_' . $payment_method->slug(),
704
-                            'button button--secondary'
705
-                        )
706
-                    )
707
-                )
708
-            )
709
-        );
710
-    }
711
-
712
-
713
-    /**
714
-     * _activate_payment_method_button
715
-     *
716
-     * @access protected
717
-     * @param EE_Payment_Method $payment_method
718
-     * @return EE_Form_Section_Proper
719
-     * @throws EE_Error
720
-     */
721
-    protected function _activate_payment_method_button(EE_Payment_Method $payment_method)
722
-    {
723
-        $link_text_and_title = sprintf(
724
-            esc_html__('Activate %1$s Payment Method?', 'event_espresso'),
725
-            $payment_method->admin_name()
726
-        );
727
-        return new EE_Form_Section_Proper(
728
-            array(
729
-                'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
730
-                'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
731
-                'action'          => '#',
732
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
733
-                'subsections'     => apply_filters(
734
-                    'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections',
735
-                    array(
736
-                        new EE_Form_Section_HTML(
737
-                            EEH_HTML::table(
738
-                                EEH_HTML::tr(
739
-                                    EEH_HTML::td(
740
-                                        $payment_method->type_obj()->introductory_html(),
741
-                                        '',
742
-                                        '',
743
-                                        '',
744
-                                        'colspan="2"'
745
-                                    )
746
-                                ) .
747
-                                EEH_HTML::tr(
748
-                                    EEH_HTML::th(
749
-                                        EEH_HTML::label(esc_html__('Click to Activate ', 'event_espresso'))
750
-                                    ) .
751
-                                    EEH_HTML::td(
752
-                                        EEH_HTML::link(
753
-                                            EE_Admin_Page::add_query_args_and_nonce(
754
-                                                array(
755
-                                                    'action'              => 'activate_payment_method',
756
-                                                    'payment_method_type' => $payment_method->type(),
757
-                                                ),
758
-                                                EE_PAYMENTS_ADMIN_URL
759
-                                            ),
760
-                                            $link_text_and_title,
761
-                                            $link_text_and_title,
762
-                                            'activate_' . $payment_method->slug(),
763
-                                            'button button--primary-alt'
764
-                                        )
765
-                                    )
766
-                                )
767
-                            )
768
-                        ),
769
-                    ),
770
-                    $payment_method
771
-                ),
772
-            )
773
-        );
774
-    }
775
-
776
-
777
-    /**
778
-     * _fine_print
779
-     *
780
-     * @access protected
781
-     * @return EE_Form_Section_HTML
782
-     */
783
-    protected function _fine_print()
784
-    {
785
-        return new EE_Form_Section_HTML(
786
-            EEH_HTML::table(
787
-                EEH_HTML::tr(
788
-                    EEH_HTML::th() .
789
-                    EEH_HTML::td(
790
-                        EEH_HTML::p(esc_html__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
791
-                    )
792
-                )
793
-            )
794
-        );
795
-    }
796
-
797
-
798
-    /**
799
-     * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
800
-     *
801
-     * @throws EE_Error
802
-     * @throws ReflectionException
803
-     * @global WP_User $current_user
804
-     */
805
-    protected function _activate_payment_method()
806
-    {
807
-        if (isset($this->_req_data['payment_method_type'])) {
808
-            $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
809
-            // see if one exists
810
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
811
-            $payment_method = EE_Payment_Method_Manager::instance()
812
-                                                       ->activate_a_payment_method_of_type($payment_method_type);
813
-            $this->_redirect_after_action(
814
-                1,
815
-                'Payment Method',
816
-                'activated',
817
-                array('action' => 'default', 'payment_method' => $payment_method->slug())
818
-            );
819
-        } else {
820
-            $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
821
-        }
822
-    }
823
-
824
-
825
-    /**
826
-     * @throws EE_Error
827
-     * @throws ReflectionException
828
-     */
829
-    protected function _deactivate_payment_method()
830
-    {
831
-        if (isset($this->_req_data['payment_method'])) {
832
-            $payment_method_slug = sanitize_key($this->_req_data['payment_method']);
833
-            // deactivate it
834
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
835
-            $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
836
-            $this->_redirect_after_action(
837
-                $count_updated,
838
-                'Payment Method',
839
-                'deactivated',
840
-                array('action' => 'default', 'payment_method' => $payment_method_slug)
841
-            );
842
-        } else {
843
-            $this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default'));
844
-        }
845
-    }
846
-
847
-
848
-    /**
849
-     * Processes the payment method form that was submitted. This is slightly trickier than usual form
850
-     * processing because we first need to identify WHICH form was processed and which payment method
851
-     * it corresponds to. Once we have done that, we see if the form is valid. If it is, the
852
-     * form's data is saved, and we redirect to the default payment methods page, setting the updated payment method
853
-     * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the
854
-     * subsequently called 'headers_sent_func' which is _payment_methods_list)
855
-     *
856
-     * @return void
857
-     * @throws EE_Error
858
-     * @throws ReflectionException
859
-     */
860
-    protected function _update_payment_method()
861
-    {
862
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
863
-            // ok let's find which gateway form to use based on the form input
864
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
865
-            /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
866
-            $correct_pmt_form_to_use = null;
867
-            $payment_method = null;
868
-            foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) {
869
-                if ($payment_method instanceof EE_Payment_Method) {
870
-                    // get the form and simplify it, like what we do when we display it
871
-                    $pmt_form = $this->_generate_payment_method_settings_form($payment_method);
872
-                    if ($pmt_form->form_data_present_in($this->_req_data)) {
873
-                        $correct_pmt_form_to_use = $pmt_form;
874
-                        break;
875
-                    }
876
-                }
877
-            }
878
-            // if we couldn't find the correct payment method type...
879
-            if (! $correct_pmt_form_to_use) {
880
-                EE_Error::add_error(
881
-                    esc_html__(
882
-                        "We could not find which payment method type your form submission related to. Please contact support",
883
-                        'event_espresso'
884
-                    ),
885
-                    __FILE__,
886
-                    __FUNCTION__,
887
-                    __LINE__
888
-                );
889
-                $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
890
-            }
891
-            $correct_pmt_form_to_use->receive_form_submission($this->_req_data);
892
-            if ($correct_pmt_form_to_use->is_valid()) {
893
-                $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
894
-                if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
895
-                    throw new EE_Error(
896
-                        sprintf(
897
-                            esc_html__(
898
-                                'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.',
899
-                                'event_espresso'
900
-                            ),
901
-                            'payment_method_settings'
902
-                        )
903
-                    );
904
-                }
905
-                $payment_settings_subform->save();
906
-                /** @var $pm EE_Payment_Method */
907
-                $this->_redirect_after_action(
908
-                    true,
909
-                    'Payment Method',
910
-                    'updated',
911
-                    array('action' => 'default', 'payment_method' => $payment_method->slug())
912
-                );
913
-            } else {
914
-                EE_Error::add_error(
915
-                    sprintf(
916
-                        esc_html__(
917
-                            'Payment method of type %s was not saved because there were validation errors. They have been marked in the form',
918
-                            'event_espresso'
919
-                        ),
920
-                        $payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name()
921
-                            : esc_html__('"(unknown)"', 'event_espresso')
922
-                    ),
923
-                    __FILE__,
924
-                    __FUNCTION__,
925
-                    __LINE__
926
-                );
927
-            }
928
-        }
929
-    }
930
-
931
-
932
-    /**
933
-     * Displays payment settings (not payment METHOD settings, that's _payment_method_settings)
934
-     * @throws DomainException
935
-     * @throws EE_Error
936
-     * @throws InvalidArgumentException
937
-     * @throws InvalidDataTypeException
938
-     * @throws InvalidInterfaceException
939
-     */
940
-    protected function _payment_settings()
941
-    {
942
-        $form = $this->getPaymentSettingsForm();
943
-        $this->_set_add_edit_form_tags('update_payment_settings');
944
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
945
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
946
-            $form->get_html_and_js(),
947
-            '',
948
-            'padding'
949
-        );
950
-        $this->display_admin_page_with_sidebar();
951
-    }
952
-
953
-
954
-    /**
955
-     *        _update_payment_settings
956
-     *
957
-     * @access protected
958
-     * @return void
959
-     * @throws EE_Error
960
-     * @throws InvalidArgumentException
961
-     * @throws InvalidDataTypeException
962
-     * @throws InvalidInterfaceException
963
-     */
964
-    protected function _update_payment_settings()
965
-    {
966
-        $form = $this->getPaymentSettingsForm();
967
-        if ($form->was_submitted($this->_req_data)) {
968
-            $form->receive_form_submission($this->_req_data);
969
-            if ($form->is_valid()) {
970
-                /**
971
-                 * @var $reg_config EE_Registration_Config
972
-                 */
973
-                $loader = LoaderFactory::getLoader();
974
-                $reg_config = $loader->getShared('EE_Registration_Config');
975
-                $valid_data = $form->valid_data();
976
-                $reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options'];
977
-                $reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan'];
978
-            }
979
-        }
980
-        EE_Registry::instance()->CFG = apply_filters(
981
-            'FHEE__Payments_Admin_Page___update_payment_settings__CFG',
982
-            EE_Registry::instance()->CFG
983
-        );
984
-
985
-        $what = esc_html__('Payment Settings', 'event_espresso');
986
-        $success = $this->_update_espresso_configuration(
987
-            $what,
988
-            EE_Registry::instance()->CFG,
989
-            __FILE__,
990
-            __FUNCTION__,
991
-            __LINE__
992
-        );
993
-        $this->_redirect_after_action(
994
-            $success,
995
-            $what,
996
-            esc_html__('updated', 'event_espresso'),
997
-            array('action' => 'payment_settings')
998
-        );
999
-    }
1000
-
1001
-
1002
-    /**
1003
-     * Gets the form used for updating payment settings
1004
-     *
1005
-     * @return EE_Form_Section_Proper
1006
-     * @throws EE_Error
1007
-     * @throws InvalidArgumentException
1008
-     * @throws InvalidDataTypeException
1009
-     * @throws InvalidInterfaceException
1010
-     */
1011
-    protected function getPaymentSettingsForm()
1012
-    {
1013
-        /**
1014
-         * @var $reg_config EE_Registration_Config
1015
-         */
1016
-        $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
1017
-        return new EE_Form_Section_Proper(
1018
-            array(
1019
-                'name' => 'payment-settings',
1020
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1021
-                'subsections' => array(
1022
-                    'show_pending_payment_options' => new EE_Yes_No_Input(
1023
-                        array(
1024
-                            'html_name' => 'show_pending_payment_options',
1025
-                            'default' => $reg_config->show_pending_payment_options,
1026
-                            'html_help_text' => esc_html__(
1027
-                                "If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ",
1028
-                                'event_espresso'
1029
-                            )
1030
-                        )
1031
-                    ),
1032
-                    'gateway_log_lifespan' => new EE_Select_Input(
1033
-                        $reg_config->gatewayLogLifespanOptions(),
1034
-                        array(
1035
-                            'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'),
1036
-                            'html_help_text' => esc_html__('If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.', 'event_espresso'),
1037
-                            'default' => $reg_config->gateway_log_lifespan,
1038
-                        )
1039
-                    )
1040
-                )
1041
-            )
1042
-        );
1043
-    }
1044
-
1045
-
1046
-    /**
1047
-     * @throws EE_Error
1048
-     */
1049
-    protected function _payment_log_overview_list_table()
1050
-    {
1051
-        $this->display_admin_list_table_page_with_sidebar();
1052
-    }
1053
-
1054
-
1055
-    protected function _set_list_table_views_payment_log()
1056
-    {
1057
-        $this->_views = array(
1058
-            'all' => array(
1059
-                'slug'  => 'all',
1060
-                'label' => esc_html__('View All Logs', 'event_espresso'),
1061
-                'count' => 0,
1062
-            ),
1063
-        );
1064
-    }
1065
-
1066
-
1067
-    /**
1068
-     * @param int  $per_page
1069
-     * @param int  $current_page
1070
-     * @param bool $count
1071
-     * @return array|int
1072
-     * @throws EE_Error
1073
-     * @throws ReflectionException
1074
-     */
1075
-    public function get_payment_logs($per_page = 50, $current_page = 0, $count = false)
1076
-    {
1077
-        EE_Registry::instance()->load_model('Change_Log');
1078
-        // we may need to do multiple queries (joining differently), so we actually want an array of query params
1079
-        $query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway));
1080
-        // check if they've selected a specific payment method
1081
-        if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
1082
-            $query_params[0]['OR*pm_or_pay_pm'] = array(
1083
-                'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'],
1084
-                'Payment_Method.PMD_ID'         => $this->_req_data['_payment_method'],
1085
-            );
1086
-        }
1087
-        // take into account search
1088
-        if (isset($this->_req_data['s']) && $this->_req_data['s']) {
1089
-            $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%');
1090
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
1091
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
1092
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
1093
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string;
1094
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string;
1095
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string;
1096
-            $query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1097
-            $query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string;
1098
-            $query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string;
1099
-            $query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string;
1100
-            $query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1101
-        }
1102
-        if (
1103
-            isset($this->_req_data['payment-filter-start-date'])
1104
-            && isset($this->_req_data['payment-filter-end-date'])
1105
-        ) {
1106
-            // add date
1107
-            $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
1108
-            $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
1109
-            // make sure our timestamps start and end right at the boundaries for each day
1110
-            $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1111
-            $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1112
-            // convert to timestamps
1113
-            $start_date = strtotime($start_date);
1114
-            $end_date = strtotime($end_date);
1115
-            // makes sure start date is the lowest value and vice versa
1116
-            $start_date = min($start_date, $end_date);
1117
-            $end_date = max($start_date, $end_date);
1118
-            // convert for query
1119
-            $start_date = EEM_Change_Log::instance()->convert_datetime_for_query(
1120
-                'LOG_time',
1121
-                date('Y-m-d H:i:s', $start_date),
1122
-                'Y-m-d H:i:s'
1123
-            );
1124
-            $end_date   = EEM_Change_Log::instance()->convert_datetime_for_query(
1125
-                'LOG_time',
1126
-                date('Y-m-d H:i:s', $end_date),
1127
-                'Y-m-d H:i:s'
1128
-            );
1129
-            $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
1130
-        }
1131
-        if ($count) {
1132
-            return EEM_Change_Log::instance()->count($query_params);
1133
-        }
1134
-        if (isset($this->_req_data['order'])) {
1135
-            $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
1136
-                ? $this->_req_data['order']
1137
-                : 'DESC';
1138
-            $query_params['order_by'] = array('LOG_time' => $sort);
1139
-        } else {
1140
-            $query_params['order_by'] = array('LOG_time' => 'DESC');
1141
-        }
1142
-        $offset = ($current_page - 1) * $per_page;
1143
-        if (! isset($this->_req_data['download_results'])) {
1144
-            $query_params['limit'] = array($offset, $per_page);
1145
-        }
1146
-        // now they've requested to instead just download the file instead of viewing it.
1147
-        if (isset($this->_req_data['download_results'])) {
1148
-            $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
1149
-            header('Content-Disposition: attachment');
1150
-            header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
1151
-            echo '<h1> '
1152
-                . sprintf(
1153
-                    esc_html__('Payment Logs for %1$s', 'event_espresso'),
1154
-                    esc_url_raw(site_url())
1155
-                )
1156
-                . '</h1 >';
1157
-            echo '<h3>' . esc_html__('Query:', 'event_espresso') . '</h3>';
1158
-            echo esc_html(var_export($query_params, true));
1159
-            echo '<h3>' . esc_html__('Results:', 'event_espresso') . '</h3>';
1160
-            echo esc_html(var_export($wpdb_results, true));
1161
-            die;
1162
-        }
1163
-        return EEM_Change_Log::instance()->get_all($query_params);
1164
-    }
1165
-
1166
-
1167
-    /**
1168
-     * Used by usort to RE-sort log query results, because we lose the ordering
1169
-     * because we're possibly combining the results from two queries
1170
-     *
1171
-     * @param EE_Change_Log $logA
1172
-     * @param EE_Change_Log $logB
1173
-     * @return int
1174
-     * @throws EE_Error
1175
-     * @throws ReflectionException
1176
-     */
1177
-    protected function _sort_logs_again($logA, $logB)
1178
-    {
1179
-        $timeA = $logA->get_raw('LOG_time');
1180
-        $timeB = $logB->get_raw('LOG_time');
1181
-        if ($timeA == $timeB) {
1182
-            return 0;
1183
-        }
1184
-        $comparison = $timeA < $timeB ? -1 : 1;
1185
-        if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
1186
-            return $comparison * -1;
1187
-        }
1188
-        return $comparison;
1189
-    }
1190
-
1191
-
1192
-    /**
1193
-     * @throws EE_Error
1194
-     * @throws ReflectionException
1195
-     */
1196
-    protected function _payment_log_details()
1197
-    {
1198
-        EE_Registry::instance()->load_model('Change_Log');
1199
-        /** @var $payment_log EE_Change_Log */
1200
-        $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
1201
-        $payment_method = null;
1202
-        $transaction = null;
1203
-        if ($payment_log instanceof EE_Change_Log) {
1204
-            if ($payment_log->object() instanceof EE_Payment) {
1205
-                $payment_method = $payment_log->object()->payment_method();
1206
-                $transaction = $payment_log->object()->transaction();
1207
-            } elseif ($payment_log->object() instanceof EE_Payment_Method) {
1208
-                $payment_method = $payment_log->object();
1209
-            } elseif ($payment_log->object() instanceof EE_Transaction) {
1210
-                $transaction = $payment_log->object();
1211
-                $payment_method = $transaction->payment_method();
1212
-            }
1213
-        }
1214
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1215
-            EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1216
-            array(
1217
-                'payment_log'    => $payment_log,
1218
-                'payment_method' => $payment_method,
1219
-                'transaction'    => $transaction,
1220
-            ),
1221
-            true
1222
-        );
1223
-        $this->display_admin_page_with_no_sidebar();
1224
-    }
19
+	/**
20
+	 * Variables used for when we're re-sorting the logs results,
21
+	 * in case we needed to do two queries, and we need to resort
22
+	 *
23
+	 * @var string
24
+	 */
25
+	private $_sort_logs_again_direction;
26
+
27
+
28
+	/**
29
+	 * @Constructor
30
+	 * @access public
31
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
32
+	 * @throws EE_Error
33
+	 * @throws InvalidArgumentException
34
+	 * @throws InvalidDataTypeException
35
+	 * @throws InvalidInterfaceException
36
+	 * @throws ReflectionException
37
+	 */
38
+	public function __construct($routing = true)
39
+	{
40
+		parent::__construct($routing);
41
+	}
42
+
43
+
44
+	protected function _init_page_props()
45
+	{
46
+		$this->page_slug = EE_PAYMENTS_PG_SLUG;
47
+		$this->page_label = esc_html__('Payment Methods', 'event_espresso');
48
+		$this->_admin_base_url = EE_PAYMENTS_ADMIN_URL;
49
+		$this->_admin_base_path = EE_PAYMENTS_ADMIN;
50
+	}
51
+
52
+
53
+	protected function _ajax_hooks()
54
+	{
55
+		// todo: all hooks for ajax goes here.
56
+	}
57
+
58
+
59
+	protected function _define_page_props()
60
+	{
61
+		$this->_admin_page_title = $this->page_label;
62
+		$this->_labels = array(
63
+			'publishbox' => esc_html__('Update Settings', 'event_espresso'),
64
+		);
65
+	}
66
+
67
+
68
+	protected function _set_page_routes()
69
+	{
70
+		/**
71
+		 * note that with payment method capabilities, although we've implemented
72
+		 * capability mapping which will be used for accessing payment methods owned by
73
+		 * other users.  This is not fully implemented yet in the payment method ui.
74
+		 * Currently, only the "plural" caps are in active use.
75
+		 * When cap mapping is implemented, some routes will need to use the singular form of
76
+		 * capability method and also include the $id of the payment method for the route.
77
+		 **/
78
+		$this->_page_routes = array(
79
+			'default'                   => array(
80
+				'func'       => '_payment_methods_list',
81
+				'capability' => 'ee_edit_payment_methods',
82
+			),
83
+			'payment_settings'          => array(
84
+				'func'       => '_payment_settings',
85
+				'capability' => 'ee_manage_gateways',
86
+			),
87
+			'activate_payment_method'   => array(
88
+				'func'       => '_activate_payment_method',
89
+				'noheader'   => true,
90
+				'capability' => 'ee_edit_payment_methods',
91
+			),
92
+			'deactivate_payment_method' => array(
93
+				'func'       => '_deactivate_payment_method',
94
+				'noheader'   => true,
95
+				'capability' => 'ee_delete_payment_methods',
96
+			),
97
+			'update_payment_method'     => array(
98
+				'func'               => '_update_payment_method',
99
+				'noheader'           => true,
100
+				'headers_sent_route' => 'default',
101
+				'capability'         => 'ee_edit_payment_methods',
102
+			),
103
+			'update_payment_settings'   => array(
104
+				'func'       => '_update_payment_settings',
105
+				'noheader'   => true,
106
+				'capability' => 'ee_manage_gateways',
107
+			),
108
+			'payment_log'               => array(
109
+				'func'       => '_payment_log_overview_list_table',
110
+				'capability' => 'ee_read_payment_methods',
111
+			),
112
+			'payment_log_details'       => array(
113
+				'func'       => '_payment_log_details',
114
+				'capability' => 'ee_read_payment_methods',
115
+			),
116
+		);
117
+	}
118
+
119
+
120
+	/**
121
+	 * @throws EE_Error
122
+	 * @throws ReflectionException
123
+	 */
124
+	protected function _set_page_config()
125
+	{
126
+		$payment_method_list_config = array(
127
+			'nav'           => array(
128
+				'label' => esc_html__('Payment Methods', 'event_espresso'),
129
+				'icon' => 'dashicons-bank',
130
+				'order' => 10,
131
+			),
132
+			'metaboxes'     => $this->_default_espresso_metaboxes,
133
+			'help_tabs'     => array_merge(
134
+				array(
135
+					'payment_methods_overview_help_tab' => array(
136
+						'title'    => esc_html__('Payment Methods Overview', 'event_espresso'),
137
+						'filename' => 'payment_methods_overview',
138
+					),
139
+				),
140
+				$this->_add_payment_method_help_tabs()
141
+			),
142
+			'require_nonce' => false,
143
+		);
144
+		$this->_page_config = array(
145
+			'default'          => $payment_method_list_config,
146
+			'payment_settings' => array(
147
+				'nav'           => array(
148
+					'label' => esc_html__('Settings', 'event_espresso'),
149
+					'icon' => 'dashicons-admin-generic',
150
+					'order' => 20,
151
+				),
152
+				'help_tabs'     => array(
153
+					'payment_methods_settings_help_tab' => array(
154
+						'title'    => esc_html__('Payment Method Settings', 'event_espresso'),
155
+						'filename' => 'payment_methods_settings',
156
+					),
157
+				),
158
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
159
+				'require_nonce' => false,
160
+			),
161
+			'payment_log'      => array(
162
+				'nav'           => array(
163
+					'label' => esc_html__("Logs", 'event_espresso'),
164
+					'icon' => 'dashicons-text-page',
165
+					'order' => 30,
166
+				),
167
+				'list_table'    => 'Payment_Log_Admin_List_Table',
168
+				'metaboxes'     => $this->_default_espresso_metaboxes,
169
+				'require_nonce' => false,
170
+			),
171
+		);
172
+	}
173
+
174
+
175
+	/**
176
+	 * @return array
177
+	 * @throws DomainException
178
+	 * @throws EE_Error
179
+	 * @throws InvalidArgumentException
180
+	 * @throws InvalidDataTypeException
181
+	 * @throws InvalidInterfaceException
182
+	 * @throws ReflectionException
183
+	 */
184
+	protected function _add_payment_method_help_tabs()
185
+	{
186
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
187
+		$payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
188
+		$all_pmt_help_tabs_config = array();
189
+		foreach ($payment_method_types as $payment_method_type) {
190
+			if (
191
+				! EE_Registry::instance()->CAP->current_user_can(
192
+					$payment_method_type->cap_name(),
193
+					'specific_payment_method_type_access'
194
+				)
195
+			) {
196
+				continue;
197
+			}
198
+			foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
199
+				$template_args = isset($config['template_args']) ? $config['template_args'] : array();
200
+				$template_args['admin_page_obj'] = $this;
201
+				$all_pmt_help_tabs_config[ $help_tab_name ] = array(
202
+					'title'   => $config['title'],
203
+					'content' => EEH_Template::display_template(
204
+						$payment_method_type->file_folder() . 'help_tabs/' . $config['filename'] . '.help_tab.php',
205
+						$template_args,
206
+						true
207
+					),
208
+				);
209
+			}
210
+		}
211
+		return $all_pmt_help_tabs_config;
212
+	}
213
+
214
+
215
+	// none of the below group are currently used for Gateway Settings
216
+	protected function _add_screen_options()
217
+	{
218
+	}
219
+
220
+
221
+	protected function _add_feature_pointers()
222
+	{
223
+	}
224
+
225
+
226
+	public function admin_init()
227
+	{
228
+	}
229
+
230
+
231
+	public function admin_notices()
232
+	{
233
+	}
234
+
235
+
236
+	public function admin_footer_scripts()
237
+	{
238
+	}
239
+
240
+
241
+	public function load_scripts_styles()
242
+	{
243
+		// styles
244
+		wp_enqueue_style('espresso-ui-theme');
245
+		wp_register_style(
246
+			'espresso_payments',
247
+			EE_PAYMENTS_ASSETS_URL . 'ee-payments.css',
248
+			[],
249
+			EVENT_ESPRESSO_VERSION
250
+		);
251
+		// scripts
252
+		wp_enqueue_script('ee_admin_js');
253
+		wp_enqueue_script('ee-text-links');
254
+		wp_enqueue_script(
255
+			'espresso_payments',
256
+			EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
257
+			['ee-datepicker'],
258
+			EVENT_ESPRESSO_VERSION,
259
+			true
260
+		);
261
+	}
262
+
263
+
264
+	public function load_scripts_styles_default()
265
+	{
266
+		wp_enqueue_style('espresso_payments');
267
+		wp_enqueue_style('ee-text-links');
268
+	}
269
+
270
+
271
+	public function load_scripts_styles_payment_log_details()
272
+	{
273
+		wp_enqueue_style('espresso_payments');
274
+	}
275
+
276
+
277
+	/**
278
+	 * @throws EE_Error
279
+	 * @throws ReflectionException
280
+	 */
281
+	protected function _payment_methods_list()
282
+	{
283
+		/**
284
+		 * first let's ensure payment methods have been set up.
285
+		 * We do this here because when people activate a payment method for the first time (as an addon),
286
+		 * it may not set up its capabilities or get registered correctly due to the loading process.
287
+		 * However, people MUST set up the details for the payment method,
288
+		 * so it's safe to do a recheck here.
289
+		 */
290
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
291
+		EEM_Payment_Method::instance()->verify_button_urls();
292
+		// set up tabs, one for each payment method type
293
+		$tabs = array();
294
+		$payment_methods = array();
295
+		foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
296
+			// we don't want to show admin-only PMTs for now
297
+			if ($pmt_obj instanceof EE_PMT_Admin_Only) {
298
+				continue;
299
+			}
300
+			// check access
301
+			if (
302
+				! EE_Registry::instance()->CAP->current_user_can(
303
+					$pmt_obj->cap_name(),
304
+					'specific_payment_method_type_access'
305
+				)
306
+			) {
307
+				continue;
308
+			}
309
+			// check for any active pms of that type
310
+			$payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
311
+			if (! $payment_method instanceof EE_Payment_Method) {
312
+				$payment_method = EE_Payment_Method::new_instance(
313
+					array(
314
+						'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
315
+						'PMD_type'       => $pmt_obj->system_name(),
316
+						'PMD_name'       => $pmt_obj->pretty_name(),
317
+						'PMD_admin_name' => $pmt_obj->pretty_name(),
318
+					)
319
+				);
320
+			}
321
+			$payment_methods[ $payment_method->slug() ] = $payment_method;
322
+		}
323
+		$payment_methods = apply_filters(
324
+			'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
325
+			$payment_methods
326
+		);
327
+		foreach ($payment_methods as $payment_method) {
328
+			if ($payment_method instanceof EE_Payment_Method) {
329
+				$this->addMetaBox(
330
+					// html id
331
+					'espresso_' . $payment_method->slug() . '_payment_settings',
332
+					// title
333
+					sprintf(esc_html__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
334
+					// callback
335
+					array($this, 'payment_method_settings_meta_box'),
336
+					// post type
337
+					null,
338
+					// context
339
+					'normal',
340
+					// priority
341
+					'default',
342
+					// callback args
343
+					array('payment_method' => $payment_method)
344
+				);
345
+				// setup for tabbed content
346
+				$tabs[ $payment_method->slug() ] = array(
347
+					'label' => $payment_method->admin_name(),
348
+					'class' => $payment_method->active() ? 'gateway-active' : '',
349
+					'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
350
+					'title' => esc_html__('Modify this Payment Method', 'event_espresso'),
351
+					'slug'  => $payment_method->slug(),
352
+					'icon'  => $payment_method->active()
353
+						? '<span class="dashicons dashicons-yes-alt"></span>'
354
+						: '<span class="dashicons dashicons-remove"></span>',
355
+				);
356
+			}
357
+		}
358
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links(
359
+			$tabs,
360
+			'payment_method_links',
361
+			'',
362
+			$this->_get_active_payment_method_slug()
363
+		);
364
+		$this->display_admin_page_with_sidebar();
365
+	}
366
+
367
+
368
+	/**
369
+	 *   _get_active_payment_method_slug
370
+	 *
371
+	 * @return string
372
+	 * @throws EE_Error
373
+	 */
374
+	protected function _get_active_payment_method_slug()
375
+	{
376
+		$payment_method_slug = false;
377
+		// decide which payment method tab to open first, as dictated by the request's 'payment_method'
378
+		if (isset($this->_req_data['payment_method'])) {
379
+			// if they provided the current payment method, use it
380
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
381
+		}
382
+		/** @var EE_Payment_Method $payment_method */
383
+		$payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
384
+		// if that didn't work or wasn't provided, find another way to select the current pm
385
+		if (! $this->_verify_payment_method($payment_method)) {
386
+			// like, looking for an active one
387
+			$payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
388
+			// test that one as well
389
+			if ($this->_verify_payment_method($payment_method)) {
390
+				$payment_method_slug = $payment_method->slug();
391
+			} else {
392
+				$payment_method_slug = 'paypal_standard';
393
+			}
394
+		}
395
+		return $payment_method_slug;
396
+	}
397
+
398
+
399
+	/**
400
+	 *    payment_method_settings_meta_box
401
+	 *    returns TRUE if the passed payment method is properly constructed and the logged-in user has the correct
402
+	 *    capabilities to access it
403
+	 *
404
+	 * @param EE_Payment_Method $payment_method
405
+	 * @return boolean
406
+	 * @throws EE_Error
407
+	 */
408
+	protected function _verify_payment_method($payment_method)
409
+	{
410
+		if (
411
+			$payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base
412
+			&& EE_Registry::instance()->CAP->current_user_can(
413
+				$payment_method->type_obj()->cap_name(),
414
+				'specific_payment_method_type_access'
415
+			)
416
+		) {
417
+			return true;
418
+		}
419
+		return false;
420
+	}
421
+
422
+
423
+	/**
424
+	 *    payment_method_settings_meta_box
425
+	 *
426
+	 * @param NULL  $post_obj_which_is_null is an object containing the current post (as a $post object)
427
+	 * @param array $metabox                is an array with metabox id, title, callback, and args elements. the value
428
+	 *                                      at 'args' has key 'payment_method', as set within _payment_methods_list
429
+	 * @return void
430
+	 * @throws EE_Error
431
+	 * @throws ReflectionException
432
+	 */
433
+	public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox)
434
+	{
435
+		$payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
436
+			? $metabox['args']['payment_method'] : null;
437
+		if (! $payment_method instanceof EE_Payment_Method) {
438
+			throw new EE_Error(
439
+				esc_html__(
440
+					'Payment method metabox setup incorrectly. No Payment method object was supplied',
441
+					'event_espresso'
442
+				)
443
+			);
444
+		}
445
+		$payment_method_scopes = $payment_method->active();
446
+		// if the payment method really exists show its form, otherwise the activation template
447
+		if ($payment_method->ID() && ! empty($payment_method_scopes)) {
448
+			$form = $this->_generate_payment_method_settings_form($payment_method);
449
+			if ($form->form_data_present_in($this->_req_data)) {
450
+				$form->receive_form_submission($this->_req_data);
451
+			}
452
+			echo wp_kses($form->form_open() . $form->get_html_and_js() . $form->form_close(), AllowedTags::getWithFormTags());
453
+		} else {
454
+			echo wp_kses($this->_activate_payment_method_button($payment_method)->get_html_and_js(), AllowedTags::getWithFormTags());
455
+		}
456
+	}
457
+
458
+
459
+	/**
460
+	 * Gets the form for all the settings related to this payment method type
461
+	 *
462
+	 * @access protected
463
+	 * @param EE_Payment_Method $payment_method
464
+	 * @return EE_Form_Section_Proper
465
+	 * @throws EE_Error
466
+	 */
467
+	protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method = null)
468
+	{
469
+		if (! $payment_method instanceof EE_Payment_Method) {
470
+			return new EE_Form_Section_Proper();
471
+		}
472
+		$subsections = apply_filters(
473
+			'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
474
+			[
475
+				'pci_dss_compliance'      => $this->_pci_dss_compliance($payment_method),
476
+				'currency_support'        => $this->_currency_support($payment_method),
477
+				'payment_method_settings' => $this->_payment_method_settings($payment_method),
478
+				'update'                  => $this->_update_payment_method_button($payment_method),
479
+				'deactivate'              => $this->_deactivate_payment_method_button($payment_method),
480
+				'fine_print'              => $this->_fine_print(),
481
+			],
482
+			$payment_method
483
+		);
484
+		return new EE_Form_Section_Proper(
485
+			array(
486
+				'name'            => $payment_method->slug() . '_settings_form',
487
+				'html_id'         => $payment_method->slug() . '_settings_form',
488
+				'action'          => EE_Admin_Page::add_query_args_and_nonce(
489
+					array(
490
+						'action'         => 'update_payment_method',
491
+						'payment_method' => $payment_method->slug(),
492
+					),
493
+					EE_PAYMENTS_ADMIN_URL
494
+				),
495
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
496
+				'subsections'     => array_filter($subsections),
497
+			)
498
+		);
499
+	}
500
+
501
+
502
+	/**
503
+	 * _pci_dss_compliance
504
+	 *
505
+	 * @access protected
506
+	 * @param EE_Payment_Method $payment_method
507
+	 * @return EE_Form_Section_HTML|null
508
+	 * @throws EE_Error
509
+	 */
510
+	protected function _pci_dss_compliance(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
511
+	{
512
+		if (!$payment_method->type_obj()->requires_https()) {
513
+			return null;
514
+		}
515
+		return new EE_Form_Section_HTML(
516
+			EEH_HTML::table(
517
+				EEH_HTML::tr(
518
+					EEH_HTML::th(
519
+						EEH_HTML::label(
520
+							EEH_HTML::strong(
521
+								esc_html__('IMPORTANT', 'event_espresso'),
522
+								'',
523
+								'important-notice'
524
+							)
525
+						)
526
+					) .
527
+					EEH_HTML::td(
528
+						EEH_HTML::strong(
529
+							esc_html__(
530
+								'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.',
531
+								'event_espresso'
532
+							)
533
+						)
534
+						.
535
+						EEH_HTML::br()
536
+						.
537
+						esc_html__('Learn more about ', 'event_espresso')
538
+						. EEH_HTML::link(
539
+							'https://www.pcisecuritystandards.org/merchants/index.php',
540
+							esc_html__('PCI DSS compliance', 'event_espresso')
541
+						)
542
+					)
543
+				)
544
+			)
545
+		);
546
+	}
547
+
548
+
549
+	/**
550
+	 * _currency_support
551
+	 *
552
+	 * @access protected
553
+	 * @param EE_Payment_Method $payment_method
554
+	 * @return EE_Form_Section_HTML|null
555
+	 * @throws EE_Error
556
+	 */
557
+	protected function _currency_support(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
558
+	{
559
+		if ($payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
560
+			return null;
561
+		}
562
+		return new EE_Form_Section_HTML(
563
+			EEH_HTML::table(
564
+				EEH_HTML::tr(
565
+					EEH_HTML::th(
566
+						EEH_HTML::label(
567
+							EEH_HTML::strong(
568
+								esc_html__('IMPORTANT', 'event_espresso'),
569
+								'',
570
+								'important-notice'
571
+							)
572
+						)
573
+					) .
574
+					EEH_HTML::td(
575
+						EEH_HTML::strong(
576
+							sprintf(
577
+								esc_html__(
578
+									'This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.',
579
+									'event_espresso'
580
+								),
581
+								EE_Config::instance()->currency->code
582
+							)
583
+						)
584
+					)
585
+				)
586
+			)
587
+		);
588
+	}
589
+
590
+
591
+	/**
592
+	 * _update_payment_method_button
593
+	 *
594
+	 * @access protected
595
+	 * @param EE_Payment_Method $payment_method
596
+	 * @return EE_Payment_Method_Form
597
+	 * @throws EE_Error
598
+	 */
599
+	protected function _payment_method_settings(EE_Payment_Method $payment_method)
600
+	{
601
+		// modify the form, so we only have/show fields that will be implemented for this version
602
+		return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
603
+	}
604
+
605
+
606
+	/**
607
+	 * Simplifies the form to merely reproduce 4.1's gateway settings functionality
608
+	 *
609
+	 * @param EE_Form_Section_Proper $form_section
610
+	 * @param string                 $payment_method_name
611
+	 * @return EE_Payment_Method_Form
612
+	 * @throws EE_Error
613
+	 */
614
+	protected function _simplify_form($form_section, $payment_method_name = '')
615
+	{
616
+		if ($form_section instanceof EE_Payment_Method_Form) {
617
+			$form_section->exclude(
618
+				array(
619
+					'PMD_type', // don't want them changing the type
620
+					'PMD_slug', // or the slug (probably never)
621
+					'PMD_wp_user', // or the user's ID
622
+					'Currency' // or the currency, until the rest of EE supports simultaneous currencies
623
+				)
624
+			);
625
+			return $form_section;
626
+		} else {
627
+			throw new EE_Error(
628
+				sprintf(
629
+					esc_html__(
630
+						'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.',
631
+						'event_espresso'
632
+					),
633
+					$payment_method_name
634
+				)
635
+			);
636
+		}
637
+	}
638
+
639
+
640
+	/**
641
+	 * _update_payment_method_button
642
+	 *
643
+	 * @access protected
644
+	 * @param EE_Payment_Method $payment_method
645
+	 * @return EE_Form_Section_HTML
646
+	 * @throws EE_Error
647
+	 */
648
+	protected function _update_payment_method_button(EE_Payment_Method $payment_method)
649
+	{
650
+		$update_button = new EE_Submit_Input(
651
+			array(
652
+				'name'       => 'submit',
653
+				'html_id'    => 'save_' . $payment_method->slug() . '_settings',
654
+				'default'    => sprintf(
655
+					esc_html__('Update %s Payment Settings', 'event_espresso'),
656
+					$payment_method->admin_name()
657
+				),
658
+				'html_label' => EEH_HTML::nbsp(),
659
+			)
660
+		);
661
+		return new EE_Form_Section_HTML(
662
+			EEH_HTML::table(
663
+				EEH_HTML::no_row(EEH_HTML::br(2)) .
664
+				EEH_HTML::tr(
665
+					EEH_HTML::th(esc_html__('Update Settings', 'event_espresso')) .
666
+					EEH_HTML::td(
667
+						$update_button->get_html_for_input()
668
+					)
669
+				)
670
+			)
671
+		);
672
+	}
673
+
674
+
675
+	/**
676
+	 * _deactivate_payment_method_button
677
+	 *
678
+	 * @access protected
679
+	 * @param EE_Payment_Method $payment_method
680
+	 * @return EE_Form_Section_HTML
681
+	 */
682
+	protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method)
683
+	{
684
+		$link_text_and_title = sprintf(
685
+			esc_html__('Deactivate %1$s Payments?', 'event_espresso'),
686
+			$payment_method->admin_name()
687
+		);
688
+		return new EE_Form_Section_HTML(
689
+			EEH_HTML::table(
690
+				EEH_HTML::tr(
691
+					EEH_HTML::th(esc_html__('Deactivate Payment Method', 'event_espresso')) .
692
+					EEH_HTML::td(
693
+						EEH_HTML::link(
694
+							EE_Admin_Page::add_query_args_and_nonce(
695
+								array(
696
+									'action'         => 'deactivate_payment_method',
697
+									'payment_method' => $payment_method->slug(),
698
+								),
699
+								EE_PAYMENTS_ADMIN_URL
700
+							),
701
+							$link_text_and_title,
702
+							$link_text_and_title,
703
+							'deactivate_' . $payment_method->slug(),
704
+							'button button--secondary'
705
+						)
706
+					)
707
+				)
708
+			)
709
+		);
710
+	}
711
+
712
+
713
+	/**
714
+	 * _activate_payment_method_button
715
+	 *
716
+	 * @access protected
717
+	 * @param EE_Payment_Method $payment_method
718
+	 * @return EE_Form_Section_Proper
719
+	 * @throws EE_Error
720
+	 */
721
+	protected function _activate_payment_method_button(EE_Payment_Method $payment_method)
722
+	{
723
+		$link_text_and_title = sprintf(
724
+			esc_html__('Activate %1$s Payment Method?', 'event_espresso'),
725
+			$payment_method->admin_name()
726
+		);
727
+		return new EE_Form_Section_Proper(
728
+			array(
729
+				'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
730
+				'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
731
+				'action'          => '#',
732
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
733
+				'subsections'     => apply_filters(
734
+					'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections',
735
+					array(
736
+						new EE_Form_Section_HTML(
737
+							EEH_HTML::table(
738
+								EEH_HTML::tr(
739
+									EEH_HTML::td(
740
+										$payment_method->type_obj()->introductory_html(),
741
+										'',
742
+										'',
743
+										'',
744
+										'colspan="2"'
745
+									)
746
+								) .
747
+								EEH_HTML::tr(
748
+									EEH_HTML::th(
749
+										EEH_HTML::label(esc_html__('Click to Activate ', 'event_espresso'))
750
+									) .
751
+									EEH_HTML::td(
752
+										EEH_HTML::link(
753
+											EE_Admin_Page::add_query_args_and_nonce(
754
+												array(
755
+													'action'              => 'activate_payment_method',
756
+													'payment_method_type' => $payment_method->type(),
757
+												),
758
+												EE_PAYMENTS_ADMIN_URL
759
+											),
760
+											$link_text_and_title,
761
+											$link_text_and_title,
762
+											'activate_' . $payment_method->slug(),
763
+											'button button--primary-alt'
764
+										)
765
+									)
766
+								)
767
+							)
768
+						),
769
+					),
770
+					$payment_method
771
+				),
772
+			)
773
+		);
774
+	}
775
+
776
+
777
+	/**
778
+	 * _fine_print
779
+	 *
780
+	 * @access protected
781
+	 * @return EE_Form_Section_HTML
782
+	 */
783
+	protected function _fine_print()
784
+	{
785
+		return new EE_Form_Section_HTML(
786
+			EEH_HTML::table(
787
+				EEH_HTML::tr(
788
+					EEH_HTML::th() .
789
+					EEH_HTML::td(
790
+						EEH_HTML::p(esc_html__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
791
+					)
792
+				)
793
+			)
794
+		);
795
+	}
796
+
797
+
798
+	/**
799
+	 * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
800
+	 *
801
+	 * @throws EE_Error
802
+	 * @throws ReflectionException
803
+	 * @global WP_User $current_user
804
+	 */
805
+	protected function _activate_payment_method()
806
+	{
807
+		if (isset($this->_req_data['payment_method_type'])) {
808
+			$payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
809
+			// see if one exists
810
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
811
+			$payment_method = EE_Payment_Method_Manager::instance()
812
+													   ->activate_a_payment_method_of_type($payment_method_type);
813
+			$this->_redirect_after_action(
814
+				1,
815
+				'Payment Method',
816
+				'activated',
817
+				array('action' => 'default', 'payment_method' => $payment_method->slug())
818
+			);
819
+		} else {
820
+			$this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
821
+		}
822
+	}
823
+
824
+
825
+	/**
826
+	 * @throws EE_Error
827
+	 * @throws ReflectionException
828
+	 */
829
+	protected function _deactivate_payment_method()
830
+	{
831
+		if (isset($this->_req_data['payment_method'])) {
832
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
833
+			// deactivate it
834
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
835
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
836
+			$this->_redirect_after_action(
837
+				$count_updated,
838
+				'Payment Method',
839
+				'deactivated',
840
+				array('action' => 'default', 'payment_method' => $payment_method_slug)
841
+			);
842
+		} else {
843
+			$this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default'));
844
+		}
845
+	}
846
+
847
+
848
+	/**
849
+	 * Processes the payment method form that was submitted. This is slightly trickier than usual form
850
+	 * processing because we first need to identify WHICH form was processed and which payment method
851
+	 * it corresponds to. Once we have done that, we see if the form is valid. If it is, the
852
+	 * form's data is saved, and we redirect to the default payment methods page, setting the updated payment method
853
+	 * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the
854
+	 * subsequently called 'headers_sent_func' which is _payment_methods_list)
855
+	 *
856
+	 * @return void
857
+	 * @throws EE_Error
858
+	 * @throws ReflectionException
859
+	 */
860
+	protected function _update_payment_method()
861
+	{
862
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
863
+			// ok let's find which gateway form to use based on the form input
864
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
865
+			/** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
866
+			$correct_pmt_form_to_use = null;
867
+			$payment_method = null;
868
+			foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) {
869
+				if ($payment_method instanceof EE_Payment_Method) {
870
+					// get the form and simplify it, like what we do when we display it
871
+					$pmt_form = $this->_generate_payment_method_settings_form($payment_method);
872
+					if ($pmt_form->form_data_present_in($this->_req_data)) {
873
+						$correct_pmt_form_to_use = $pmt_form;
874
+						break;
875
+					}
876
+				}
877
+			}
878
+			// if we couldn't find the correct payment method type...
879
+			if (! $correct_pmt_form_to_use) {
880
+				EE_Error::add_error(
881
+					esc_html__(
882
+						"We could not find which payment method type your form submission related to. Please contact support",
883
+						'event_espresso'
884
+					),
885
+					__FILE__,
886
+					__FUNCTION__,
887
+					__LINE__
888
+				);
889
+				$this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
890
+			}
891
+			$correct_pmt_form_to_use->receive_form_submission($this->_req_data);
892
+			if ($correct_pmt_form_to_use->is_valid()) {
893
+				$payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
894
+				if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
895
+					throw new EE_Error(
896
+						sprintf(
897
+							esc_html__(
898
+								'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.',
899
+								'event_espresso'
900
+							),
901
+							'payment_method_settings'
902
+						)
903
+					);
904
+				}
905
+				$payment_settings_subform->save();
906
+				/** @var $pm EE_Payment_Method */
907
+				$this->_redirect_after_action(
908
+					true,
909
+					'Payment Method',
910
+					'updated',
911
+					array('action' => 'default', 'payment_method' => $payment_method->slug())
912
+				);
913
+			} else {
914
+				EE_Error::add_error(
915
+					sprintf(
916
+						esc_html__(
917
+							'Payment method of type %s was not saved because there were validation errors. They have been marked in the form',
918
+							'event_espresso'
919
+						),
920
+						$payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name()
921
+							: esc_html__('"(unknown)"', 'event_espresso')
922
+					),
923
+					__FILE__,
924
+					__FUNCTION__,
925
+					__LINE__
926
+				);
927
+			}
928
+		}
929
+	}
930
+
931
+
932
+	/**
933
+	 * Displays payment settings (not payment METHOD settings, that's _payment_method_settings)
934
+	 * @throws DomainException
935
+	 * @throws EE_Error
936
+	 * @throws InvalidArgumentException
937
+	 * @throws InvalidDataTypeException
938
+	 * @throws InvalidInterfaceException
939
+	 */
940
+	protected function _payment_settings()
941
+	{
942
+		$form = $this->getPaymentSettingsForm();
943
+		$this->_set_add_edit_form_tags('update_payment_settings');
944
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
945
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
946
+			$form->get_html_and_js(),
947
+			'',
948
+			'padding'
949
+		);
950
+		$this->display_admin_page_with_sidebar();
951
+	}
952
+
953
+
954
+	/**
955
+	 *        _update_payment_settings
956
+	 *
957
+	 * @access protected
958
+	 * @return void
959
+	 * @throws EE_Error
960
+	 * @throws InvalidArgumentException
961
+	 * @throws InvalidDataTypeException
962
+	 * @throws InvalidInterfaceException
963
+	 */
964
+	protected function _update_payment_settings()
965
+	{
966
+		$form = $this->getPaymentSettingsForm();
967
+		if ($form->was_submitted($this->_req_data)) {
968
+			$form->receive_form_submission($this->_req_data);
969
+			if ($form->is_valid()) {
970
+				/**
971
+				 * @var $reg_config EE_Registration_Config
972
+				 */
973
+				$loader = LoaderFactory::getLoader();
974
+				$reg_config = $loader->getShared('EE_Registration_Config');
975
+				$valid_data = $form->valid_data();
976
+				$reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options'];
977
+				$reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan'];
978
+			}
979
+		}
980
+		EE_Registry::instance()->CFG = apply_filters(
981
+			'FHEE__Payments_Admin_Page___update_payment_settings__CFG',
982
+			EE_Registry::instance()->CFG
983
+		);
984
+
985
+		$what = esc_html__('Payment Settings', 'event_espresso');
986
+		$success = $this->_update_espresso_configuration(
987
+			$what,
988
+			EE_Registry::instance()->CFG,
989
+			__FILE__,
990
+			__FUNCTION__,
991
+			__LINE__
992
+		);
993
+		$this->_redirect_after_action(
994
+			$success,
995
+			$what,
996
+			esc_html__('updated', 'event_espresso'),
997
+			array('action' => 'payment_settings')
998
+		);
999
+	}
1000
+
1001
+
1002
+	/**
1003
+	 * Gets the form used for updating payment settings
1004
+	 *
1005
+	 * @return EE_Form_Section_Proper
1006
+	 * @throws EE_Error
1007
+	 * @throws InvalidArgumentException
1008
+	 * @throws InvalidDataTypeException
1009
+	 * @throws InvalidInterfaceException
1010
+	 */
1011
+	protected function getPaymentSettingsForm()
1012
+	{
1013
+		/**
1014
+		 * @var $reg_config EE_Registration_Config
1015
+		 */
1016
+		$reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
1017
+		return new EE_Form_Section_Proper(
1018
+			array(
1019
+				'name' => 'payment-settings',
1020
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1021
+				'subsections' => array(
1022
+					'show_pending_payment_options' => new EE_Yes_No_Input(
1023
+						array(
1024
+							'html_name' => 'show_pending_payment_options',
1025
+							'default' => $reg_config->show_pending_payment_options,
1026
+							'html_help_text' => esc_html__(
1027
+								"If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ",
1028
+								'event_espresso'
1029
+							)
1030
+						)
1031
+					),
1032
+					'gateway_log_lifespan' => new EE_Select_Input(
1033
+						$reg_config->gatewayLogLifespanOptions(),
1034
+						array(
1035
+							'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'),
1036
+							'html_help_text' => esc_html__('If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.', 'event_espresso'),
1037
+							'default' => $reg_config->gateway_log_lifespan,
1038
+						)
1039
+					)
1040
+				)
1041
+			)
1042
+		);
1043
+	}
1044
+
1045
+
1046
+	/**
1047
+	 * @throws EE_Error
1048
+	 */
1049
+	protected function _payment_log_overview_list_table()
1050
+	{
1051
+		$this->display_admin_list_table_page_with_sidebar();
1052
+	}
1053
+
1054
+
1055
+	protected function _set_list_table_views_payment_log()
1056
+	{
1057
+		$this->_views = array(
1058
+			'all' => array(
1059
+				'slug'  => 'all',
1060
+				'label' => esc_html__('View All Logs', 'event_espresso'),
1061
+				'count' => 0,
1062
+			),
1063
+		);
1064
+	}
1065
+
1066
+
1067
+	/**
1068
+	 * @param int  $per_page
1069
+	 * @param int  $current_page
1070
+	 * @param bool $count
1071
+	 * @return array|int
1072
+	 * @throws EE_Error
1073
+	 * @throws ReflectionException
1074
+	 */
1075
+	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false)
1076
+	{
1077
+		EE_Registry::instance()->load_model('Change_Log');
1078
+		// we may need to do multiple queries (joining differently), so we actually want an array of query params
1079
+		$query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway));
1080
+		// check if they've selected a specific payment method
1081
+		if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
1082
+			$query_params[0]['OR*pm_or_pay_pm'] = array(
1083
+				'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'],
1084
+				'Payment_Method.PMD_ID'         => $this->_req_data['_payment_method'],
1085
+			);
1086
+		}
1087
+		// take into account search
1088
+		if (isset($this->_req_data['s']) && $this->_req_data['s']) {
1089
+			$similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%');
1090
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
1091
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
1092
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
1093
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string;
1094
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string;
1095
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string;
1096
+			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1097
+			$query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string;
1098
+			$query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string;
1099
+			$query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string;
1100
+			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1101
+		}
1102
+		if (
1103
+			isset($this->_req_data['payment-filter-start-date'])
1104
+			&& isset($this->_req_data['payment-filter-end-date'])
1105
+		) {
1106
+			// add date
1107
+			$start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
1108
+			$end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
1109
+			// make sure our timestamps start and end right at the boundaries for each day
1110
+			$start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1111
+			$end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1112
+			// convert to timestamps
1113
+			$start_date = strtotime($start_date);
1114
+			$end_date = strtotime($end_date);
1115
+			// makes sure start date is the lowest value and vice versa
1116
+			$start_date = min($start_date, $end_date);
1117
+			$end_date = max($start_date, $end_date);
1118
+			// convert for query
1119
+			$start_date = EEM_Change_Log::instance()->convert_datetime_for_query(
1120
+				'LOG_time',
1121
+				date('Y-m-d H:i:s', $start_date),
1122
+				'Y-m-d H:i:s'
1123
+			);
1124
+			$end_date   = EEM_Change_Log::instance()->convert_datetime_for_query(
1125
+				'LOG_time',
1126
+				date('Y-m-d H:i:s', $end_date),
1127
+				'Y-m-d H:i:s'
1128
+			);
1129
+			$query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
1130
+		}
1131
+		if ($count) {
1132
+			return EEM_Change_Log::instance()->count($query_params);
1133
+		}
1134
+		if (isset($this->_req_data['order'])) {
1135
+			$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
1136
+				? $this->_req_data['order']
1137
+				: 'DESC';
1138
+			$query_params['order_by'] = array('LOG_time' => $sort);
1139
+		} else {
1140
+			$query_params['order_by'] = array('LOG_time' => 'DESC');
1141
+		}
1142
+		$offset = ($current_page - 1) * $per_page;
1143
+		if (! isset($this->_req_data['download_results'])) {
1144
+			$query_params['limit'] = array($offset, $per_page);
1145
+		}
1146
+		// now they've requested to instead just download the file instead of viewing it.
1147
+		if (isset($this->_req_data['download_results'])) {
1148
+			$wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
1149
+			header('Content-Disposition: attachment');
1150
+			header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
1151
+			echo '<h1> '
1152
+				. sprintf(
1153
+					esc_html__('Payment Logs for %1$s', 'event_espresso'),
1154
+					esc_url_raw(site_url())
1155
+				)
1156
+				. '</h1 >';
1157
+			echo '<h3>' . esc_html__('Query:', 'event_espresso') . '</h3>';
1158
+			echo esc_html(var_export($query_params, true));
1159
+			echo '<h3>' . esc_html__('Results:', 'event_espresso') . '</h3>';
1160
+			echo esc_html(var_export($wpdb_results, true));
1161
+			die;
1162
+		}
1163
+		return EEM_Change_Log::instance()->get_all($query_params);
1164
+	}
1165
+
1166
+
1167
+	/**
1168
+	 * Used by usort to RE-sort log query results, because we lose the ordering
1169
+	 * because we're possibly combining the results from two queries
1170
+	 *
1171
+	 * @param EE_Change_Log $logA
1172
+	 * @param EE_Change_Log $logB
1173
+	 * @return int
1174
+	 * @throws EE_Error
1175
+	 * @throws ReflectionException
1176
+	 */
1177
+	protected function _sort_logs_again($logA, $logB)
1178
+	{
1179
+		$timeA = $logA->get_raw('LOG_time');
1180
+		$timeB = $logB->get_raw('LOG_time');
1181
+		if ($timeA == $timeB) {
1182
+			return 0;
1183
+		}
1184
+		$comparison = $timeA < $timeB ? -1 : 1;
1185
+		if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
1186
+			return $comparison * -1;
1187
+		}
1188
+		return $comparison;
1189
+	}
1190
+
1191
+
1192
+	/**
1193
+	 * @throws EE_Error
1194
+	 * @throws ReflectionException
1195
+	 */
1196
+	protected function _payment_log_details()
1197
+	{
1198
+		EE_Registry::instance()->load_model('Change_Log');
1199
+		/** @var $payment_log EE_Change_Log */
1200
+		$payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
1201
+		$payment_method = null;
1202
+		$transaction = null;
1203
+		if ($payment_log instanceof EE_Change_Log) {
1204
+			if ($payment_log->object() instanceof EE_Payment) {
1205
+				$payment_method = $payment_log->object()->payment_method();
1206
+				$transaction = $payment_log->object()->transaction();
1207
+			} elseif ($payment_log->object() instanceof EE_Payment_Method) {
1208
+				$payment_method = $payment_log->object();
1209
+			} elseif ($payment_log->object() instanceof EE_Transaction) {
1210
+				$transaction = $payment_log->object();
1211
+				$payment_method = $transaction->payment_method();
1212
+			}
1213
+		}
1214
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1215
+			EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1216
+			array(
1217
+				'payment_log'    => $payment_log,
1218
+				'payment_method' => $payment_method,
1219
+				'transaction'    => $transaction,
1220
+			),
1221
+			true
1222
+		);
1223
+		$this->display_admin_page_with_no_sidebar();
1224
+	}
1225 1225
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
             foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
199 199
                 $template_args = isset($config['template_args']) ? $config['template_args'] : array();
200 200
                 $template_args['admin_page_obj'] = $this;
201
-                $all_pmt_help_tabs_config[ $help_tab_name ] = array(
201
+                $all_pmt_help_tabs_config[$help_tab_name] = array(
202 202
                     'title'   => $config['title'],
203 203
                     'content' => EEH_Template::display_template(
204
-                        $payment_method_type->file_folder() . 'help_tabs/' . $config['filename'] . '.help_tab.php',
204
+                        $payment_method_type->file_folder().'help_tabs/'.$config['filename'].'.help_tab.php',
205 205
                         $template_args,
206 206
                         true
207 207
                     ),
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         wp_enqueue_style('espresso-ui-theme');
245 245
         wp_register_style(
246 246
             'espresso_payments',
247
-            EE_PAYMENTS_ASSETS_URL . 'ee-payments.css',
247
+            EE_PAYMENTS_ASSETS_URL.'ee-payments.css',
248 248
             [],
249 249
             EVENT_ESPRESSO_VERSION
250 250
         );
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
         wp_enqueue_script('ee-text-links');
254 254
         wp_enqueue_script(
255 255
             'espresso_payments',
256
-            EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
256
+            EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js',
257 257
             ['ee-datepicker'],
258 258
             EVENT_ESPRESSO_VERSION,
259 259
             true
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             }
309 309
             // check for any active pms of that type
310 310
             $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
311
-            if (! $payment_method instanceof EE_Payment_Method) {
311
+            if ( ! $payment_method instanceof EE_Payment_Method) {
312 312
                 $payment_method = EE_Payment_Method::new_instance(
313 313
                     array(
314 314
                         'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
                     )
319 319
                 );
320 320
             }
321
-            $payment_methods[ $payment_method->slug() ] = $payment_method;
321
+            $payment_methods[$payment_method->slug()] = $payment_method;
322 322
         }
323 323
         $payment_methods = apply_filters(
324 324
             'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
             if ($payment_method instanceof EE_Payment_Method) {
329 329
                 $this->addMetaBox(
330 330
                     // html id
331
-                    'espresso_' . $payment_method->slug() . '_payment_settings',
331
+                    'espresso_'.$payment_method->slug().'_payment_settings',
332 332
                     // title
333 333
                     sprintf(esc_html__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
334 334
                     // callback
@@ -343,10 +343,10 @@  discard block
 block discarded – undo
343 343
                     array('payment_method' => $payment_method)
344 344
                 );
345 345
                 // setup for tabbed content
346
-                $tabs[ $payment_method->slug() ] = array(
346
+                $tabs[$payment_method->slug()] = array(
347 347
                     'label' => $payment_method->admin_name(),
348 348
                     'class' => $payment_method->active() ? 'gateway-active' : '',
349
-                    'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
349
+                    'href'  => 'espresso_'.$payment_method->slug().'_payment_settings',
350 350
                     'title' => esc_html__('Modify this Payment Method', 'event_espresso'),
351 351
                     'slug'  => $payment_method->slug(),
352 352
                     'icon'  => $payment_method->active()
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
         /** @var EE_Payment_Method $payment_method */
383 383
         $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
384 384
         // if that didn't work or wasn't provided, find another way to select the current pm
385
-        if (! $this->_verify_payment_method($payment_method)) {
385
+        if ( ! $this->_verify_payment_method($payment_method)) {
386 386
             // like, looking for an active one
387 387
             $payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
388 388
             // test that one as well
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
     {
435 435
         $payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
436 436
             ? $metabox['args']['payment_method'] : null;
437
-        if (! $payment_method instanceof EE_Payment_Method) {
437
+        if ( ! $payment_method instanceof EE_Payment_Method) {
438 438
             throw new EE_Error(
439 439
                 esc_html__(
440 440
                     'Payment method metabox setup incorrectly. No Payment method object was supplied',
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
             if ($form->form_data_present_in($this->_req_data)) {
450 450
                 $form->receive_form_submission($this->_req_data);
451 451
             }
452
-            echo wp_kses($form->form_open() . $form->get_html_and_js() . $form->form_close(), AllowedTags::getWithFormTags());
452
+            echo wp_kses($form->form_open().$form->get_html_and_js().$form->form_close(), AllowedTags::getWithFormTags());
453 453
         } else {
454 454
             echo wp_kses($this->_activate_payment_method_button($payment_method)->get_html_and_js(), AllowedTags::getWithFormTags());
455 455
         }
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
      */
467 467
     protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method = null)
468 468
     {
469
-        if (! $payment_method instanceof EE_Payment_Method) {
469
+        if ( ! $payment_method instanceof EE_Payment_Method) {
470 470
             return new EE_Form_Section_Proper();
471 471
         }
472 472
         $subsections = apply_filters(
@@ -483,8 +483,8 @@  discard block
 block discarded – undo
483 483
         );
484 484
         return new EE_Form_Section_Proper(
485 485
             array(
486
-                'name'            => $payment_method->slug() . '_settings_form',
487
-                'html_id'         => $payment_method->slug() . '_settings_form',
486
+                'name'            => $payment_method->slug().'_settings_form',
487
+                'html_id'         => $payment_method->slug().'_settings_form',
488 488
                 'action'          => EE_Admin_Page::add_query_args_and_nonce(
489 489
                     array(
490 490
                         'action'         => 'update_payment_method',
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
      */
510 510
     protected function _pci_dss_compliance(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
511 511
     {
512
-        if (!$payment_method->type_obj()->requires_https()) {
512
+        if ( ! $payment_method->type_obj()->requires_https()) {
513 513
             return null;
514 514
         }
515 515
         return new EE_Form_Section_HTML(
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
                                 'important-notice'
524 524
                             )
525 525
                         )
526
-                    ) .
526
+                    ).
527 527
                     EEH_HTML::td(
528 528
                         EEH_HTML::strong(
529 529
                             esc_html__(
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
                                 'important-notice'
571 571
                             )
572 572
                         )
573
-                    ) .
573
+                    ).
574 574
                     EEH_HTML::td(
575 575
                         EEH_HTML::strong(
576 576
                             sprintf(
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         $update_button = new EE_Submit_Input(
651 651
             array(
652 652
                 'name'       => 'submit',
653
-                'html_id'    => 'save_' . $payment_method->slug() . '_settings',
653
+                'html_id'    => 'save_'.$payment_method->slug().'_settings',
654 654
                 'default'    => sprintf(
655 655
                     esc_html__('Update %s Payment Settings', 'event_espresso'),
656 656
                     $payment_method->admin_name()
@@ -660,9 +660,9 @@  discard block
 block discarded – undo
660 660
         );
661 661
         return new EE_Form_Section_HTML(
662 662
             EEH_HTML::table(
663
-                EEH_HTML::no_row(EEH_HTML::br(2)) .
663
+                EEH_HTML::no_row(EEH_HTML::br(2)).
664 664
                 EEH_HTML::tr(
665
-                    EEH_HTML::th(esc_html__('Update Settings', 'event_espresso')) .
665
+                    EEH_HTML::th(esc_html__('Update Settings', 'event_espresso')).
666 666
                     EEH_HTML::td(
667 667
                         $update_button->get_html_for_input()
668 668
                     )
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
         return new EE_Form_Section_HTML(
689 689
             EEH_HTML::table(
690 690
                 EEH_HTML::tr(
691
-                    EEH_HTML::th(esc_html__('Deactivate Payment Method', 'event_espresso')) .
691
+                    EEH_HTML::th(esc_html__('Deactivate Payment Method', 'event_espresso')).
692 692
                     EEH_HTML::td(
693 693
                         EEH_HTML::link(
694 694
                             EE_Admin_Page::add_query_args_and_nonce(
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
                             ),
701 701
                             $link_text_and_title,
702 702
                             $link_text_and_title,
703
-                            'deactivate_' . $payment_method->slug(),
703
+                            'deactivate_'.$payment_method->slug(),
704 704
                             'button button--secondary'
705 705
                         )
706 706
                     )
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
         );
727 727
         return new EE_Form_Section_Proper(
728 728
             array(
729
-                'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
730
-                'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
729
+                'name'            => 'activate_'.$payment_method->slug().'_settings_form',
730
+                'html_id'         => 'activate_'.$payment_method->slug().'_settings_form',
731 731
                 'action'          => '#',
732 732
                 'layout_strategy' => new EE_Admin_Two_Column_Layout(),
733 733
                 'subsections'     => apply_filters(
@@ -743,11 +743,11 @@  discard block
 block discarded – undo
743 743
                                         '',
744 744
                                         'colspan="2"'
745 745
                                     )
746
-                                ) .
746
+                                ).
747 747
                                 EEH_HTML::tr(
748 748
                                     EEH_HTML::th(
749 749
                                         EEH_HTML::label(esc_html__('Click to Activate ', 'event_espresso'))
750
-                                    ) .
750
+                                    ).
751 751
                                     EEH_HTML::td(
752 752
                                         EEH_HTML::link(
753 753
                                             EE_Admin_Page::add_query_args_and_nonce(
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
                                             ),
760 760
                                             $link_text_and_title,
761 761
                                             $link_text_and_title,
762
-                                            'activate_' . $payment_method->slug(),
762
+                                            'activate_'.$payment_method->slug(),
763 763
                                             'button button--primary-alt'
764 764
                                         )
765 765
                                     )
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
         return new EE_Form_Section_HTML(
786 786
             EEH_HTML::table(
787 787
                 EEH_HTML::tr(
788
-                    EEH_HTML::th() .
788
+                    EEH_HTML::th().
789 789
                     EEH_HTML::td(
790 790
                         EEH_HTML::p(esc_html__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
791 791
                     )
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
                 }
877 877
             }
878 878
             // if we couldn't find the correct payment method type...
879
-            if (! $correct_pmt_form_to_use) {
879
+            if ( ! $correct_pmt_form_to_use) {
880 880
                 EE_Error::add_error(
881 881
                     esc_html__(
882 882
                         "We could not find which payment method type your form submission related to. Please contact support",
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
             $correct_pmt_form_to_use->receive_form_submission($this->_req_data);
892 892
             if ($correct_pmt_form_to_use->is_valid()) {
893 893
                 $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
894
-                if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
894
+                if ( ! $payment_settings_subform instanceof EE_Payment_Method_Form) {
895 895
                     throw new EE_Error(
896 896
                         sprintf(
897 897
                             esc_html__(
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
         }
1087 1087
         // take into account search
1088 1088
         if (isset($this->_req_data['s']) && $this->_req_data['s']) {
1089
-            $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%');
1089
+            $similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%');
1090 1090
             $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
1091 1091
             $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
1092 1092
             $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
@@ -1107,8 +1107,8 @@  discard block
 block discarded – undo
1107 1107
             $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
1108 1108
             $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
1109 1109
             // make sure our timestamps start and end right at the boundaries for each day
1110
-            $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1111
-            $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1110
+            $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
1111
+            $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
1112 1112
             // convert to timestamps
1113 1113
             $start_date = strtotime($start_date);
1114 1114
             $end_date = strtotime($end_date);
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
                 date('Y-m-d H:i:s', $start_date),
1122 1122
                 'Y-m-d H:i:s'
1123 1123
             );
1124
-            $end_date   = EEM_Change_Log::instance()->convert_datetime_for_query(
1124
+            $end_date = EEM_Change_Log::instance()->convert_datetime_for_query(
1125 1125
                 'LOG_time',
1126 1126
                 date('Y-m-d H:i:s', $end_date),
1127 1127
                 'Y-m-d H:i:s'
@@ -1140,23 +1140,23 @@  discard block
 block discarded – undo
1140 1140
             $query_params['order_by'] = array('LOG_time' => 'DESC');
1141 1141
         }
1142 1142
         $offset = ($current_page - 1) * $per_page;
1143
-        if (! isset($this->_req_data['download_results'])) {
1143
+        if ( ! isset($this->_req_data['download_results'])) {
1144 1144
             $query_params['limit'] = array($offset, $per_page);
1145 1145
         }
1146 1146
         // now they've requested to instead just download the file instead of viewing it.
1147 1147
         if (isset($this->_req_data['download_results'])) {
1148 1148
             $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
1149 1149
             header('Content-Disposition: attachment');
1150
-            header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
1150
+            header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url()));
1151 1151
             echo '<h1> '
1152 1152
                 . sprintf(
1153 1153
                     esc_html__('Payment Logs for %1$s', 'event_espresso'),
1154 1154
                     esc_url_raw(site_url())
1155 1155
                 )
1156 1156
                 . '</h1 >';
1157
-            echo '<h3>' . esc_html__('Query:', 'event_espresso') . '</h3>';
1157
+            echo '<h3>'.esc_html__('Query:', 'event_espresso').'</h3>';
1158 1158
             echo esc_html(var_export($query_params, true));
1159
-            echo '<h3>' . esc_html__('Results:', 'event_espresso') . '</h3>';
1159
+            echo '<h3>'.esc_html__('Results:', 'event_espresso').'</h3>';
1160 1160
             echo esc_html(var_export($wpdb_results, true));
1161 1161
             die;
1162 1162
         }
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
             }
1213 1213
         }
1214 1214
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1215
-            EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1215
+            EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php',
1216 1216
             array(
1217 1217
                 'payment_log'    => $payment_log,
1218 1218
                 'payment_method' => $payment_method,
Please login to merge, or discard this patch.