Completed
Branch feature/checkins-to-csv (6396a5)
by
unknown
07:19 queued 04:57
created
core/services/licensing/LicenseService.php 2 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -15,94 +15,94 @@
 block discarded – undo
15 15
  */
16 16
 class LicenseService
17 17
 {
18
-    /**
19
-     * @var Config
20
-     */
21
-    private $config;
22
-
23
-
24
-    /**
25
-     * @var Stats
26
-     */
27
-    private $stats_collection;
28
-
29
-    public function __construct(Stats $stats_collection, Config $config)
30
-    {
31
-        $this->config = $config;
32
-        $this->stats_collection = $stats_collection;
33
-        $this->loadPueClient();
34
-    }
35
-
36
-    private function loadPueClient()
37
-    {
38
-        // PUE Auto Upgrades stuff
39
-        if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
40
-            require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
41
-
42
-            // $options needs to be an array with the included keys as listed.
43
-            $options = array(
44
-                // 'optionName' => '', //(optional) - used as the reference for saving update information in the
45
-                // clients options table.  Will be automatically set if left blank.
46
-                'apikey'                => $this->config->siteLicenseKey(),
47
-                // (required), you will need to obtain the apikey that the client gets from your site and
48
-                // then saves in their sites options table (see 'getting an api-key' below)
49
-                'lang_domain'           => $this->config->i18nDomain(),
50
-                // (optional) - put here whatever reference you are using for the localization of your plugin (if it's
51
-                // localized).  That way strings in this file will be included in the translation for your plugin.
52
-                'checkPeriod'           => $this->config->checkPeriod(),
53
-                // (optional) - use this parameter to indicate how often you want the client's install to ping your
54
-                // server for update checks.  The integer indicates hours.  If you don't include this parameter it will
55
-                // default to 12 hours.
56
-                'option_key'            => $this->config->optionKey(),
57
-                // this is what is used to reference the api_key in your plugin options.  PUE uses this to trigger
58
-                // updating your information message whenever this option_key is modified.
59
-                'options_page_slug'     => $this->config->optionsPageSlug(),
60
-                'plugin_basename'       => EE_PLUGIN_BASENAME,
61
-                'use_wp_update'         => true,
62
-                // if TRUE then you want FREE versions of the plugin to be updated from WP
63
-                'extra_stats'           => $this->stats_collection->statsCallback(),
64
-                'turn_on_notices_saved' => true,
65
-            );
66
-            // initiate the class and start the plugin update engine!
67
-            new PluginUpdateEngineChecker(
68
-                $this->config->hostServerUrl(),
69
-                $this->config->pluginSlug(),
70
-                $options
71
-            );
72
-        }
73
-    }
74
-
75
-
76
-    /**
77
-     * This is a handy helper method for retrieving whether there is an update available for the given plugin.
78
-     *
79
-     * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
80
-     *                          identify plugins. Defaults to core update
81
-     * @return boolean           True if update available, false if not.
82
-     */
83
-    public static function isUpdateAvailable($basename = '')
84
-    {
85
-        $basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME;
86
-
87
-        $update = false;
88
-
89
-        // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
90
-        $folder = '/' . dirname($basename);
91
-
92
-        $plugins = get_plugins($folder);
93
-        $current = get_site_transient('update_plugins');
94
-
95
-        foreach ((array) $plugins as $plugin_file => $plugin_data) {
96
-            if (isset($current->response['plugin_file'])) {
97
-                $update = true;
98
-            }
99
-        }
100
-
101
-        // it's possible that there is an update but an invalid site-license-key is in use
102
-        if (get_site_option('pue_json_error_' . $basename)) {
103
-            $update = true;
104
-        }
105
-
106
-        return $update;
107
-    }
18
+	/**
19
+	 * @var Config
20
+	 */
21
+	private $config;
22
+
23
+
24
+	/**
25
+	 * @var Stats
26
+	 */
27
+	private $stats_collection;
28
+
29
+	public function __construct(Stats $stats_collection, Config $config)
30
+	{
31
+		$this->config = $config;
32
+		$this->stats_collection = $stats_collection;
33
+		$this->loadPueClient();
34
+	}
35
+
36
+	private function loadPueClient()
37
+	{
38
+		// PUE Auto Upgrades stuff
39
+		if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
40
+			require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
41
+
42
+			// $options needs to be an array with the included keys as listed.
43
+			$options = array(
44
+				// 'optionName' => '', //(optional) - used as the reference for saving update information in the
45
+				// clients options table.  Will be automatically set if left blank.
46
+				'apikey'                => $this->config->siteLicenseKey(),
47
+				// (required), you will need to obtain the apikey that the client gets from your site and
48
+				// then saves in their sites options table (see 'getting an api-key' below)
49
+				'lang_domain'           => $this->config->i18nDomain(),
50
+				// (optional) - put here whatever reference you are using for the localization of your plugin (if it's
51
+				// localized).  That way strings in this file will be included in the translation for your plugin.
52
+				'checkPeriod'           => $this->config->checkPeriod(),
53
+				// (optional) - use this parameter to indicate how often you want the client's install to ping your
54
+				// server for update checks.  The integer indicates hours.  If you don't include this parameter it will
55
+				// default to 12 hours.
56
+				'option_key'            => $this->config->optionKey(),
57
+				// this is what is used to reference the api_key in your plugin options.  PUE uses this to trigger
58
+				// updating your information message whenever this option_key is modified.
59
+				'options_page_slug'     => $this->config->optionsPageSlug(),
60
+				'plugin_basename'       => EE_PLUGIN_BASENAME,
61
+				'use_wp_update'         => true,
62
+				// if TRUE then you want FREE versions of the plugin to be updated from WP
63
+				'extra_stats'           => $this->stats_collection->statsCallback(),
64
+				'turn_on_notices_saved' => true,
65
+			);
66
+			// initiate the class and start the plugin update engine!
67
+			new PluginUpdateEngineChecker(
68
+				$this->config->hostServerUrl(),
69
+				$this->config->pluginSlug(),
70
+				$options
71
+			);
72
+		}
73
+	}
74
+
75
+
76
+	/**
77
+	 * This is a handy helper method for retrieving whether there is an update available for the given plugin.
78
+	 *
79
+	 * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
80
+	 *                          identify plugins. Defaults to core update
81
+	 * @return boolean           True if update available, false if not.
82
+	 */
83
+	public static function isUpdateAvailable($basename = '')
84
+	{
85
+		$basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME;
86
+
87
+		$update = false;
88
+
89
+		// should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
90
+		$folder = '/' . dirname($basename);
91
+
92
+		$plugins = get_plugins($folder);
93
+		$current = get_site_transient('update_plugins');
94
+
95
+		foreach ((array) $plugins as $plugin_file => $plugin_data) {
96
+			if (isset($current->response['plugin_file'])) {
97
+				$update = true;
98
+			}
99
+		}
100
+
101
+		// it's possible that there is an update but an invalid site-license-key is in use
102
+		if (get_site_option('pue_json_error_' . $basename)) {
103
+			$update = true;
104
+		}
105
+
106
+		return $update;
107
+	}
108 108
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
     private function loadPueClient()
37 37
     {
38 38
         // PUE Auto Upgrades stuff
39
-        if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
40
-            require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
39
+        if (is_readable(EE_THIRD_PARTY.'pue/pue-client.php')) { // include the file
40
+            require_once(EE_THIRD_PARTY.'pue/pue-client.php');
41 41
 
42 42
             // $options needs to be an array with the included keys as listed.
43 43
             $options = array(
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $update = false;
88 88
 
89 89
         // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
90
-        $folder = '/' . dirname($basename);
90
+        $folder = '/'.dirname($basename);
91 91
 
92 92
         $plugins = get_plugins($folder);
93 93
         $current = get_site_transient('update_plugins');
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         }
100 100
 
101 101
         // it's possible that there is an update but an invalid site-license-key is in use
102
-        if (get_site_option('pue_json_error_' . $basename)) {
102
+        if (get_site_option('pue_json_error_'.$basename)) {
103 103
             $update = true;
104 104
         }
105 105
 
Please login to merge, or discard this patch.
display_strategies/number_bubbles/NumberBubblesProgressStepsDisplay.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -16,29 +16,29 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * used for setting up css and js required for the display strategy
21
-     *
22
-     * @return void
23
-     */
24
-    public function enqueueStylesAndScripts()
25
-    {
26
-        // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css
27
-        wp_enqueue_style(
28
-            'ee_progress_steps_display_number_bubbles',
29
-            plugin_dir_url(__FILE__) . 'number_bubbles.css'
30
-        );
31
-    }
19
+	/**
20
+	 * used for setting up css and js required for the display strategy
21
+	 *
22
+	 * @return void
23
+	 */
24
+	public function enqueueStylesAndScripts()
25
+	{
26
+		// core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css
27
+		wp_enqueue_style(
28
+			'ee_progress_steps_display_number_bubbles',
29
+			plugin_dir_url(__FILE__) . 'number_bubbles.css'
30
+		);
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * loads and returns a full server path to the template used for the display strategy
36
-     *
37
-     * @return string
38
-     */
39
-    public function getTemplate()
40
-    {
41
-        // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php';
42
-        return __DIR__ . '/number_bubbles.template.php';
43
-    }
34
+	/**
35
+	 * loads and returns a full server path to the template used for the display strategy
36
+	 *
37
+	 * @return string
38
+	 */
39
+	public function getTemplate()
40
+	{
41
+		// return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php';
42
+		return __DIR__ . '/number_bubbles.template.php';
43
+	}
44 44
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css
27 27
         wp_enqueue_style(
28 28
             'ee_progress_steps_display_number_bubbles',
29
-            plugin_dir_url(__FILE__) . 'number_bubbles.css'
29
+            plugin_dir_url(__FILE__).'number_bubbles.css'
30 30
         );
31 31
     }
32 32
 
@@ -39,6 +39,6 @@  discard block
 block discarded – undo
39 39
     public function getTemplate()
40 40
     {
41 41
         // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php';
42
-        return __DIR__ . '/number_bubbles.template.php';
42
+        return __DIR__.'/number_bubbles.template.php';
43 43
     }
44 44
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Proper.form.php 2 patches
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
             // AND we are going to make sure they're in that specified order
112 112
             $reordered_subsections = array();
113 113
             foreach ($options_array['include'] as $input_name) {
114
-                if (isset($this->_subsections[ $input_name ])) {
115
-                    $reordered_subsections[ $input_name ] = $this->_subsections[ $input_name ];
114
+                if (isset($this->_subsections[$input_name])) {
115
+                    $reordered_subsections[$input_name] = $this->_subsections[$input_name];
116 116
                 }
117 117
             }
118 118
             $this->_subsections = $reordered_subsections;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         if (isset($options_array['layout_strategy'])) {
125 125
             $this->_layout_strategy = $options_array['layout_strategy'];
126 126
         }
127
-        if (! $this->_layout_strategy) {
127
+        if ( ! $this->_layout_strategy) {
128 128
             $this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
129 129
         }
130 130
         $this->_layout_strategy->_construct_finalize($this);
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         if ($validate) {
314 314
             $this->_validate();
315 315
             // if it's invalid, we're going to want to re-display so remember what they submitted
316
-            if (! $this->is_valid()) {
316
+            if ( ! $this->is_valid()) {
317 317
                 $this->store_submitted_form_data_in_session();
318 318
             }
319 319
         }
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
     public function populate_defaults($default_data)
427 427
     {
428 428
         foreach ($this->subsections(false) as $subsection_name => $subsection) {
429
-            if (isset($default_data[ $subsection_name ])) {
429
+            if (isset($default_data[$subsection_name])) {
430 430
                 if ($subsection instanceof EE_Form_Input_Base) {
431
-                    $subsection->set_default($default_data[ $subsection_name ]);
431
+                    $subsection->set_default($default_data[$subsection_name]);
432 432
                 } elseif ($subsection instanceof EE_Form_Section_Proper) {
433
-                    $subsection->populate_defaults($default_data[ $subsection_name ]);
433
+                    $subsection->populate_defaults($default_data[$subsection_name]);
434 434
                 }
435 435
             }
436 436
         }
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
      */
446 446
     public function subsection_exists($name)
447 447
     {
448
-        return isset($this->_subsections[ $name ]) ? true : false;
448
+        return isset($this->_subsections[$name]) ? true : false;
449 449
     }
450 450
 
451 451
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
         if ($require_construction_to_be_finalized) {
468 468
             $this->ensure_construct_finalized_called();
469 469
         }
470
-        return $this->subsection_exists($name) ? $this->_subsections[ $name ] : null;
470
+        return $this->subsection_exists($name) ? $this->_subsections[$name] : null;
471 471
     }
472 472
 
473 473
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
         $validatable_subsections = array();
483 483
         foreach ($this->subsections() as $name => $obj) {
484 484
             if ($obj instanceof EE_Form_Section_Validatable) {
485
-                $validatable_subsections[ $name ] = $obj;
485
+                $validatable_subsections[$name] = $obj;
486 486
             }
487 487
         }
488 488
         return $validatable_subsections;
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
             $name,
510 510
             $require_construction_to_be_finalized
511 511
         );
512
-        if (! $subsection instanceof EE_Form_Input_Base) {
512
+        if ( ! $subsection instanceof EE_Form_Input_Base) {
513 513
             throw new EE_Error(
514 514
                 sprintf(
515 515
                     esc_html__(
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
             $name,
547 547
             $require_construction_to_be_finalized
548 548
         );
549
-        if (! $subsection instanceof EE_Form_Section_Proper) {
549
+        if ( ! $subsection instanceof EE_Form_Section_Proper) {
550 550
             throw new EE_Error(
551 551
                 sprintf(
552 552
                     esc_html__(
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
     public function is_valid()
587 587
     {
588 588
         if ($this->is_valid === null) {
589
-            if (! $this->has_received_submission()) {
589
+            if ( ! $this->has_received_submission()) {
590 590
                 throw new EE_Error(
591 591
                     sprintf(
592 592
                         esc_html__(
@@ -596,14 +596,14 @@  discard block
 block discarded – undo
596 596
                     )
597 597
                 );
598 598
             }
599
-            if (! parent::is_valid()) {
599
+            if ( ! parent::is_valid()) {
600 600
                 $this->is_valid = false;
601 601
             } else {
602 602
                 // ok so no general errors to this entire form section.
603 603
                 // so let's check the subsections, but only set errors if that hasn't been done yet
604 604
                 $this->is_valid = true;
605 605
                 foreach ($this->get_validatable_subsections() as $subsection) {
606
-                    if (! $subsection->is_valid()) {
606
+                    if ( ! $subsection->is_valid()) {
607 607
                         $this->is_valid = false;
608 608
                     }
609 609
                 }
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
      */
621 621
     protected function _set_default_name_if_empty()
622 622
     {
623
-        if (! $this->_name) {
623
+        if ( ! $this->_name) {
624 624
             $classname    = get_class($this);
625 625
             $default_name = str_replace('EE_', '', $classname);
626 626
             $this->_name  = $default_name;
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
     {
711 711
         wp_register_script(
712 712
             'ee_form_section_validation',
713
-            EE_GLOBAL_ASSETS_URL . 'scripts' . '/form_section_validation.js',
713
+            EE_GLOBAL_ASSETS_URL.'scripts'.'/form_section_validation.js',
714 714
             array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
715 715
             EVENT_ESPRESSO_VERSION,
716 716
             true
@@ -754,13 +754,13 @@  discard block
 block discarded – undo
754 754
         // we only want to localize vars ONCE for the entire form,
755 755
         // so if the form section doesn't have a parent, then it must be the top dog
756 756
         if ($return_for_subsection || ! $this->parent_section()) {
757
-            EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
757
+            EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array(
758 758
                 'form_section_id'  => $this->html_id(true),
759 759
                 'validation_rules' => $this->get_jquery_validation_rules(),
760 760
                 'other_data'       => $this->get_other_js_data(),
761 761
                 'errors'           => $this->subsection_validation_errors_by_html_name(),
762 762
             );
763
-            EE_Form_Section_Proper::$_scripts_localized                                = true;
763
+            EE_Form_Section_Proper::$_scripts_localized = true;
764 764
         }
765 765
     }
766 766
 
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
         $inputs = array();
796 796
         foreach ($this->subsections() as $subsection) {
797 797
             if ($subsection instanceof EE_Form_Input_Base) {
798
-                $inputs[ $subsection->html_name() ] = $subsection;
798
+                $inputs[$subsection->html_name()] = $subsection;
799 799
             } elseif ($subsection instanceof EE_Form_Section_Proper) {
800 800
                 $inputs += $subsection->inputs_in_subsections();
801 801
             }
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
         $errors = array();
819 819
         foreach ($inputs as $form_input) {
820 820
             if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
821
-                $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
821
+                $errors[$form_input->html_name()] = $form_input->get_validation_error_string();
822 822
             }
823 823
         }
824 824
         return $errors;
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
         $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
842 842
             ? EE_Registry::instance()->CFG->registration->email_validation_level
843 843
             : 'wp_default';
844
-        EE_Form_Section_Proper::$_js_localization['email_validation_level']   = $email_validation_level;
844
+        EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level;
845 845
         wp_enqueue_script('ee_form_section_validation');
846 846
         wp_localize_script(
847 847
             'ee_form_section_validation',
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
      */
859 859
     public function ensure_scripts_localized()
860 860
     {
861
-        if (! EE_Form_Section_Proper::$_scripts_localized) {
861
+        if ( ! EE_Form_Section_Proper::$_scripts_localized) {
862 862
             $this->_enqueue_and_localize_form_js();
863 863
         }
864 864
     }
@@ -954,8 +954,8 @@  discard block
 block discarded – undo
954 954
         // reset the cache of whether this form is valid or not- we're re-validating it now
955 955
         $this->is_valid = null;
956 956
         foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
957
-            if (method_exists($this, '_validate_' . $subsection_name)) {
958
-                call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
957
+            if (method_exists($this, '_validate_'.$subsection_name)) {
958
+                call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection));
959 959
             }
960 960
             $subsection->_validate();
961 961
         }
@@ -973,9 +973,9 @@  discard block
 block discarded – undo
973 973
         $inputs = array();
974 974
         foreach ($this->subsections() as $subsection_name => $subsection) {
975 975
             if ($subsection instanceof EE_Form_Section_Proper) {
976
-                $inputs[ $subsection_name ] = $subsection->valid_data();
976
+                $inputs[$subsection_name] = $subsection->valid_data();
977 977
             } elseif ($subsection instanceof EE_Form_Input_Base) {
978
-                $inputs[ $subsection_name ] = $subsection->normalized_value();
978
+                $inputs[$subsection_name] = $subsection->normalized_value();
979 979
             }
980 980
         }
981 981
         return $inputs;
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
         $inputs = array();
994 994
         foreach ($this->subsections() as $subsection_name => $subsection) {
995 995
             if ($subsection instanceof EE_Form_Input_Base) {
996
-                $inputs[ $subsection_name ] = $subsection;
996
+                $inputs[$subsection_name] = $subsection;
997 997
             }
998 998
         }
999 999
         return $inputs;
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
         $form_sections = array();
1012 1012
         foreach ($this->subsections() as $name => $obj) {
1013 1013
             if ($obj instanceof EE_Form_Section_Proper) {
1014
-                $form_sections[ $name ] = $obj;
1014
+                $form_sections[$name] = $obj;
1015 1015
             }
1016 1016
         }
1017 1017
         return $form_sections;
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
         $input_values = array();
1119 1119
         foreach ($this->subsections() as $subsection_name => $subsection) {
1120 1120
             if ($subsection instanceof EE_Form_Input_Base) {
1121
-                $input_values[ $subsection_name ] = $pretty
1121
+                $input_values[$subsection_name] = $pretty
1122 1122
                     ? $subsection->pretty_value()
1123 1123
                     : $subsection->normalized_value();
1124 1124
             } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
                 if ($flatten) {
1131 1131
                     $input_values = array_merge($input_values, $subform_input_values);
1132 1132
                 } else {
1133
-                    $input_values[ $subsection_name ] = $subform_input_values;
1133
+                    $input_values[$subsection_name] = $subform_input_values;
1134 1134
                 }
1135 1135
             }
1136 1136
         }
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
             if ($subsection instanceof EE_Form_Input_Base) {
1159 1159
                 // is this input part of an array of inputs?
1160 1160
                 if (strpos($subsection->html_name(), '[') !== false) {
1161
-                    $full_input_name  = EEH_Array::convert_array_values_to_keys(
1161
+                    $full_input_name = EEH_Array::convert_array_values_to_keys(
1162 1162
                         explode(
1163 1163
                             '[',
1164 1164
                             str_replace(']', '', $subsection->html_name())
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
                     );
1168 1168
                     $submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1169 1169
                 } else {
1170
-                    $submitted_values[ $subsection->html_name() ] = $subsection->raw_value();
1170
+                    $submitted_values[$subsection->html_name()] = $subsection->raw_value();
1171 1171
                 }
1172 1172
             } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1173 1173
                 $subform_input_values = $subsection->submitted_values($include_subforms);
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
     public function exclude(array $inputs_to_exclude = array())
1203 1203
     {
1204 1204
         foreach ($inputs_to_exclude as $input_to_exclude_name) {
1205
-            unset($this->_subsections[ $input_to_exclude_name ]);
1205
+            unset($this->_subsections[$input_to_exclude_name]);
1206 1206
         }
1207 1207
     }
1208 1208
 
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
     public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1246 1246
     {
1247 1247
         foreach ($new_subsections as $subsection_name => $subsection) {
1248
-            if (! $subsection instanceof EE_Form_Section_Base) {
1248
+            if ( ! $subsection instanceof EE_Form_Section_Base) {
1249 1249
                 EE_Error::add_error(
1250 1250
                     sprintf(
1251 1251
                         esc_html__(
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
                         $this->name()
1258 1258
                     )
1259 1259
                 );
1260
-                unset($new_subsections[ $subsection_name ]);
1260
+                unset($new_subsections[$subsection_name]);
1261 1261
             }
1262 1262
         }
1263 1263
         $this->_subsections = EEH_Array::insert_into_array(
@@ -1372,7 +1372,7 @@  discard block
 block discarded – undo
1372 1372
     public function html_name_prefix()
1373 1373
     {
1374 1374
         if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1375
-            return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1375
+            return $this->parent_section()->html_name_prefix().'['.$this->name().']';
1376 1376
         }
1377 1377
         return $this->name();
1378 1378
     }
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
      */
1413 1413
     public function ensure_construct_finalized_called()
1414 1414
     {
1415
-        if (! $this->_construction_finalized) {
1415
+        if ( ! $this->_construction_finalized) {
1416 1416
             $this->_construct_finalize($this->_parent_section, $this->_name);
1417 1417
         }
1418 1418
     }
Please login to merge, or discard this patch.
Indentation   +1528 added lines, -1528 removed lines patch added patch discarded remove patch
@@ -16,1532 +16,1532 @@
 block discarded – undo
16 16
 class EE_Form_Section_Proper extends EE_Form_Section_Validatable
17 17
 {
18 18
 
19
-    const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data';
20
-
21
-    /**
22
-     * Subsections
23
-     *
24
-     * @var EE_Form_Section_Validatable[]
25
-     */
26
-    protected $_subsections = array();
27
-
28
-    /**
29
-     * Strategy for laying out the form
30
-     *
31
-     * @var EE_Form_Section_Layout_Base
32
-     */
33
-    protected $_layout_strategy;
34
-
35
-    /**
36
-     * Whether or not this form has received and validated a form submission yet
37
-     *
38
-     * @var boolean
39
-     */
40
-    protected $_received_submission = false;
41
-
42
-    /**
43
-     * message displayed to users upon successful form submission
44
-     *
45
-     * @var string
46
-     */
47
-    protected $_form_submission_success_message = '';
48
-
49
-    /**
50
-     * message displayed to users upon unsuccessful form submission
51
-     *
52
-     * @var string
53
-     */
54
-    protected $_form_submission_error_message = '';
55
-
56
-    /**
57
-     * @var array like post / request
58
-     */
59
-    protected $cached_request_data;
60
-
61
-    /**
62
-     * Stores whether this form (and its sub-sections) were found to be valid or not.
63
-     * Starts off as null, but once the form is validated, it set to either true or false
64
-     * @var boolean|null
65
-     */
66
-    protected $is_valid;
67
-
68
-    /**
69
-     * Stores all the data that will localized for form validation
70
-     *
71
-     * @var array
72
-     */
73
-    protected static $_js_localization = array();
74
-
75
-    /**
76
-     * whether or not the form's localized validation JS vars have been set
77
-     *
78
-     * @type boolean
79
-     */
80
-    protected static $_scripts_localized = false;
81
-
82
-
83
-    /**
84
-     * when constructing a proper form section, calls _construct_finalize on children
85
-     * so that they know who their parent is, and what name they've been given.
86
-     *
87
-     * @param array[] $options_array   {
88
-     * @type          $subsections     EE_Form_Section_Validatable[] where keys are the section's name
89
-     * @type          $include         string[] numerically-indexed where values are section names to be included,
90
-     *                                 and in that order. This is handy if you want
91
-     *                                 the subsections to be ordered differently than the default, and if you override
92
-     *                                 which fields are shown
93
-     * @type          $exclude         string[] values are subsections to be excluded. This is handy if you want
94
-     *                                 to remove certain default subsections (note: if you specify BOTH 'include' AND
95
-     *                                 'exclude', the inclusions will be applied first, and the exclusions will exclude
96
-     *                                 items from that list of inclusions)
97
-     * @type          $layout_strategy EE_Form_Section_Layout_Base strategy for laying out the form
98
-     *                                 } @see EE_Form_Section_Validatable::__construct()
99
-     * @throws EE_Error
100
-     */
101
-    public function __construct($options_array = array())
102
-    {
103
-        $options_array = (array) apply_filters(
104
-            'FHEE__EE_Form_Section_Proper___construct__options_array',
105
-            $options_array,
106
-            $this
107
-        );
108
-        // call parent first, as it may be setting the name
109
-        parent::__construct($options_array);
110
-        // if they've included subsections in the constructor, add them now
111
-        if (isset($options_array['include'])) {
112
-            // we are going to make sure we ONLY have those subsections to include
113
-            // AND we are going to make sure they're in that specified order
114
-            $reordered_subsections = array();
115
-            foreach ($options_array['include'] as $input_name) {
116
-                if (isset($this->_subsections[ $input_name ])) {
117
-                    $reordered_subsections[ $input_name ] = $this->_subsections[ $input_name ];
118
-                }
119
-            }
120
-            $this->_subsections = $reordered_subsections;
121
-        }
122
-        if (isset($options_array['exclude'])) {
123
-            $exclude            = $options_array['exclude'];
124
-            $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
125
-        }
126
-        if (isset($options_array['layout_strategy'])) {
127
-            $this->_layout_strategy = $options_array['layout_strategy'];
128
-        }
129
-        if (! $this->_layout_strategy) {
130
-            $this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
131
-        }
132
-        $this->_layout_strategy->_construct_finalize($this);
133
-        // ok so we are definitely going to want the forms JS,
134
-        // so enqueue it or remember to enqueue it during wp_enqueue_scripts
135
-        if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
136
-            // ok so they've constructed this object after when they should have.
137
-            // just enqueue the generic form scripts and initialize the form immediately in the JS
138
-            EE_Form_Section_Proper::wp_enqueue_scripts(true);
139
-        } else {
140
-            add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
141
-            add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
142
-        }
143
-        add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
144
-        /**
145
-         * Gives other plugins a chance to hook in before construct finalize is called.
146
-         * The form probably doesn't yet have a parent form section.
147
-         * Since 4.9.32, when this action was introduced, this is the best place to add a subsection onto a form,
148
-         * assuming you don't care what the form section's name, HTML ID, or HTML name etc are.
149
-         * Also see AHEE__EE_Form_Section_Proper___construct_finalize__end
150
-         *
151
-         * @since 4.9.32
152
-         * @param EE_Form_Section_Proper $this          before __construct is done, but all of its logic,
153
-         *                                              except maybe calling _construct_finalize has been done
154
-         * @param array                  $options_array options passed into the constructor
155
-         */
156
-        do_action(
157
-            'AHEE__EE_Form_Input_Base___construct__before_construct_finalize_called',
158
-            $this,
159
-            $options_array
160
-        );
161
-        if (isset($options_array['name'])) {
162
-            $this->_construct_finalize(null, $options_array['name']);
163
-        }
164
-    }
165
-
166
-
167
-    /**
168
-     * Finishes construction given the parent form section and this form section's name
169
-     *
170
-     * @param EE_Form_Section_Proper $parent_form_section
171
-     * @param string                 $name
172
-     * @throws EE_Error
173
-     */
174
-    public function _construct_finalize($parent_form_section, $name)
175
-    {
176
-        parent::_construct_finalize($parent_form_section, $name);
177
-        $this->_set_default_name_if_empty();
178
-        $this->_set_default_html_id_if_empty();
179
-        foreach ($this->_subsections as $subsection_name => $subsection) {
180
-            if ($subsection instanceof EE_Form_Section_Base) {
181
-                $subsection->_construct_finalize($this, $subsection_name);
182
-            } else {
183
-                throw new EE_Error(
184
-                    sprintf(
185
-                        esc_html__(
186
-                            'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"',
187
-                            'event_espresso'
188
-                        ),
189
-                        $subsection_name,
190
-                        get_class($this),
191
-                        $subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
192
-                    )
193
-                );
194
-            }
195
-        }
196
-        /**
197
-         * Action performed just after form has been given a name (and HTML ID etc) and is fully constructed.
198
-         * If you have code that should modify the form and needs it and its subsections to have a name, HTML ID
199
-         * (or other attributes derived from the name like the HTML label id, etc), this is where it should be done.
200
-         * This might only happen just before displaying the form, or just before it receives form submission data.
201
-         * If you need to modify the form or its subsections before _construct_finalize is called on it (and we've
202
-         * ensured it has a name, HTML IDs, etc
203
-         *
204
-         * @param EE_Form_Section_Proper      $this
205
-         * @param EE_Form_Section_Proper|null $parent_form_section
206
-         * @param string                      $name
207
-         */
208
-        do_action(
209
-            'AHEE__EE_Form_Section_Proper___construct_finalize__end',
210
-            $this,
211
-            $parent_form_section,
212
-            $name
213
-        );
214
-    }
215
-
216
-
217
-    /**
218
-     * Gets the layout strategy for this form section
219
-     *
220
-     * @return EE_Form_Section_Layout_Base
221
-     */
222
-    public function get_layout_strategy()
223
-    {
224
-        return $this->_layout_strategy;
225
-    }
226
-
227
-
228
-    /**
229
-     * Gets the HTML for a single input for this form section according
230
-     * to the layout strategy
231
-     *
232
-     * @param EE_Form_Input_Base $input
233
-     * @return string
234
-     */
235
-    public function get_html_for_input($input)
236
-    {
237
-        return $this->_layout_strategy->layout_input($input);
238
-    }
239
-
240
-
241
-    /**
242
-     * was_submitted - checks if form inputs are present in request data
243
-     * Basically an alias for form_data_present_in() (which is used by both
244
-     * proper form sections and form inputs)
245
-     *
246
-     * @param null $form_data
247
-     * @return boolean
248
-     * @throws EE_Error
249
-     */
250
-    public function was_submitted($form_data = null)
251
-    {
252
-        return $this->form_data_present_in($form_data);
253
-    }
254
-
255
-    /**
256
-     * Gets the cached request data; but if there is none, or $req_data was set with
257
-     * something different, refresh the cache, and then return it
258
-     * @param null $req_data
259
-     * @return array
260
-     */
261
-    protected function getCachedRequest($req_data = null)
262
-    {
263
-        if (
264
-            $this->cached_request_data === null
265
-            || (
266
-                $req_data !== null
267
-                && $req_data !== $this->cached_request_data
268
-            )
269
-        ) {
270
-            $req_data = apply_filters(
271
-                'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
272
-                $req_data,
273
-                $this
274
-            );
275
-            if ($req_data === null) {
276
-                /** @var RequestInterface $request */
277
-                $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
278
-                $req_data = $request->requestParams();
279
-            }
280
-            $req_data = apply_filters(
281
-                'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
282
-                $req_data,
283
-                $this
284
-            );
285
-            $this->cached_request_data = (array) $req_data;
286
-        }
287
-        return $this->cached_request_data;
288
-    }
289
-
290
-
291
-    /**
292
-     * After the form section is initially created, call this to sanitize the data in the submission
293
-     * which relates to this form section, validate it, and set it as properties on the form.
294
-     *
295
-     * @param array|null $req_data should usually be post data (the default).
296
-     *                             However, you CAN supply a different array.
297
-     *                             Consider using set_defaults() instead however.
298
-     *                             (If you rendered the form in the page using echo $form_x->get_html()
299
-     *                             the inputs will have the correct name in the request data for this function
300
-     *                             to find them and populate the form with them.
301
-     *                             If you have a flat form (with only input subsections),
302
-     *                             you can supply a flat array where keys
303
-     *                             are the form input names and values are their values)
304
-     * @param boolean    $validate whether or not to perform validation on this data. Default is,
305
-     *                             of course, to validate that data, and set errors on the invalid values.
306
-     *                             But if the data has already been validated
307
-     *                             (eg you validated the data then stored it in the DB)
308
-     *                             you may want to skip this step.
309
-     * @throws InvalidArgumentException
310
-     * @throws InvalidInterfaceException
311
-     * @throws InvalidDataTypeException
312
-     * @throws EE_Error
313
-     */
314
-    public function receive_form_submission($req_data = null, $validate = true)
315
-    {
316
-        $req_data = $this->getCachedRequest($req_data);
317
-        $this->_normalize($req_data);
318
-        if ($validate) {
319
-            $this->_validate();
320
-            // if it's invalid, we're going to want to re-display so remember what they submitted
321
-            if (! $this->is_valid()) {
322
-                $this->store_submitted_form_data_in_session();
323
-            }
324
-        }
325
-        if ($this->submission_error_message() === '' && ! $this->is_valid()) {
326
-            $this->set_submission_error_message();
327
-        }
328
-        do_action(
329
-            'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
330
-            $req_data,
331
-            $this,
332
-            $validate
333
-        );
334
-    }
335
-
336
-
337
-    /**
338
-     * caches the originally submitted input values in the session
339
-     * so that they can be used to repopulate the form if it failed validation
340
-     *
341
-     * @return boolean whether or not the data was successfully stored in the session
342
-     * @throws InvalidArgumentException
343
-     * @throws InvalidInterfaceException
344
-     * @throws InvalidDataTypeException
345
-     * @throws EE_Error
346
-     */
347
-    protected function store_submitted_form_data_in_session()
348
-    {
349
-        return EE_Registry::instance()->SSN->set_session_data(
350
-            array(
351
-                EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true),
352
-            )
353
-        );
354
-    }
355
-
356
-
357
-    /**
358
-     * retrieves the originally submitted input values in the session
359
-     * so that they can be used to repopulate the form if it failed validation
360
-     *
361
-     * @return array
362
-     * @throws InvalidArgumentException
363
-     * @throws InvalidInterfaceException
364
-     * @throws InvalidDataTypeException
365
-     */
366
-    protected function get_submitted_form_data_from_session()
367
-    {
368
-        $session = EE_Registry::instance()->SSN;
369
-        if ($session instanceof EE_Session) {
370
-            return $session->get_session_data(
371
-                EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY
372
-            );
373
-        }
374
-        return array();
375
-    }
376
-
377
-
378
-    /**
379
-     * flushed the originally submitted input values from the session
380
-     *
381
-     * @return boolean whether or not the data was successfully removed from the session
382
-     * @throws InvalidArgumentException
383
-     * @throws InvalidInterfaceException
384
-     * @throws InvalidDataTypeException
385
-     */
386
-    public static function flush_submitted_form_data_from_session()
387
-    {
388
-        return EE_Registry::instance()->SSN->reset_data(
389
-            array(EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
390
-        );
391
-    }
392
-
393
-
394
-    /**
395
-     * Populates this form and its subsections with data from the session.
396
-     * (Wrapper for EE_Form_Section_Proper::receive_form_submission, so it shows
397
-     * validation errors when displaying too)
398
-     * Returns true if the form was populated from the session, false otherwise
399
-     *
400
-     * @return boolean
401
-     * @throws InvalidArgumentException
402
-     * @throws InvalidInterfaceException
403
-     * @throws InvalidDataTypeException
404
-     * @throws EE_Error
405
-     */
406
-    public function populate_from_session()
407
-    {
408
-        $form_data_in_session = $this->get_submitted_form_data_from_session();
409
-        if (empty($form_data_in_session)) {
410
-            return false;
411
-        }
412
-        $this->receive_form_submission($form_data_in_session);
413
-        add_action('shutdown', array('EE_Form_Section_Proper', 'flush_submitted_form_data_from_session'));
414
-        if ($this->form_data_present_in($form_data_in_session)) {
415
-            return true;
416
-        }
417
-        return false;
418
-    }
419
-
420
-
421
-    /**
422
-     * Populates the default data for the form, given an array where keys are
423
-     * the input names, and values are their values (preferably normalized to be their
424
-     * proper PHP types, not all strings... although that should be ok too).
425
-     * Proper subsections are sub-arrays, the key being the subsection's name, and
426
-     * the value being an array formatted in teh same way
427
-     *
428
-     * @param array $default_data
429
-     * @throws EE_Error
430
-     */
431
-    public function populate_defaults($default_data)
432
-    {
433
-        foreach ($this->subsections(false) as $subsection_name => $subsection) {
434
-            if (isset($default_data[ $subsection_name ])) {
435
-                if ($subsection instanceof EE_Form_Input_Base) {
436
-                    $subsection->set_default($default_data[ $subsection_name ]);
437
-                } elseif ($subsection instanceof EE_Form_Section_Proper) {
438
-                    $subsection->populate_defaults($default_data[ $subsection_name ]);
439
-                }
440
-            }
441
-        }
442
-    }
443
-
444
-
445
-    /**
446
-     * returns true if subsection exists
447
-     *
448
-     * @param string $name
449
-     * @return boolean
450
-     */
451
-    public function subsection_exists($name)
452
-    {
453
-        return isset($this->_subsections[ $name ]) ? true : false;
454
-    }
455
-
456
-
457
-    /**
458
-     * Gets the subsection specified by its name
459
-     *
460
-     * @param string  $name
461
-     * @param boolean $require_construction_to_be_finalized most client code should leave this as TRUE
462
-     *                                                      so that the inputs will be properly configured.
463
-     *                                                      However, some client code may be ok
464
-     *                                                      with construction finalize being called later
465
-     *                                                      (realizing that the subsections' html names
466
-     *                                                      might not be set yet, etc.)
467
-     * @return EE_Form_Section_Base
468
-     * @throws EE_Error
469
-     */
470
-    public function get_subsection($name, $require_construction_to_be_finalized = true)
471
-    {
472
-        if ($require_construction_to_be_finalized) {
473
-            $this->ensure_construct_finalized_called();
474
-        }
475
-        return $this->subsection_exists($name) ? $this->_subsections[ $name ] : null;
476
-    }
477
-
478
-
479
-    /**
480
-     * Gets all the validatable subsections of this form section
481
-     *
482
-     * @return EE_Form_Section_Validatable[]
483
-     * @throws EE_Error
484
-     */
485
-    public function get_validatable_subsections()
486
-    {
487
-        $validatable_subsections = array();
488
-        foreach ($this->subsections() as $name => $obj) {
489
-            if ($obj instanceof EE_Form_Section_Validatable) {
490
-                $validatable_subsections[ $name ] = $obj;
491
-            }
492
-        }
493
-        return $validatable_subsections;
494
-    }
495
-
496
-
497
-    /**
498
-     * Gets an input by the given name. If not found, or if its not an EE_FOrm_Input_Base child,
499
-     * throw an EE_Error.
500
-     *
501
-     * @param string  $name
502
-     * @param boolean $require_construction_to_be_finalized most client code should
503
-     *                                                      leave this as TRUE so that the inputs will be properly
504
-     *                                                      configured. However, some client code may be ok with
505
-     *                                                      construction finalize being called later
506
-     *                                                      (realizing that the subsections' html names might not be
507
-     *                                                      set yet, etc.)
508
-     * @return EE_Form_Input_Base
509
-     * @throws EE_Error
510
-     */
511
-    public function get_input($name, $require_construction_to_be_finalized = true)
512
-    {
513
-        $subsection = $this->get_subsection(
514
-            $name,
515
-            $require_construction_to_be_finalized
516
-        );
517
-        if (! $subsection instanceof EE_Form_Input_Base) {
518
-            throw new EE_Error(
519
-                sprintf(
520
-                    esc_html__(
521
-                        "Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'",
522
-                        'event_espresso'
523
-                    ),
524
-                    $name,
525
-                    get_class($this),
526
-                    $subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
527
-                )
528
-            );
529
-        }
530
-        return $subsection;
531
-    }
532
-
533
-
534
-    /**
535
-     * Like get_input(), gets the proper subsection of the form given the name,
536
-     * otherwise throws an EE_Error
537
-     *
538
-     * @param string  $name
539
-     * @param boolean $require_construction_to_be_finalized most client code should
540
-     *                                                      leave this as TRUE so that the inputs will be properly
541
-     *                                                      configured. However, some client code may be ok with
542
-     *                                                      construction finalize being called later
543
-     *                                                      (realizing that the subsections' html names might not be
544
-     *                                                      set yet, etc.)
545
-     * @return EE_Form_Section_Proper
546
-     * @throws EE_Error
547
-     */
548
-    public function get_proper_subsection($name, $require_construction_to_be_finalized = true)
549
-    {
550
-        $subsection = $this->get_subsection(
551
-            $name,
552
-            $require_construction_to_be_finalized
553
-        );
554
-        if (! $subsection instanceof EE_Form_Section_Proper) {
555
-            throw new EE_Error(
556
-                sprintf(
557
-                    esc_html__(
558
-                        "Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'",
559
-                        'event_espresso'
560
-                    ),
561
-                    $name,
562
-                    get_class($this)
563
-                )
564
-            );
565
-        }
566
-        return $subsection;
567
-    }
568
-
569
-
570
-    /**
571
-     * Gets the value of the specified input. Should be called after receive_form_submission()
572
-     * or populate_defaults() on the form, where the normalized value on the input is set.
573
-     *
574
-     * @param string $name
575
-     * @return mixed depending on the input's type and its normalization strategy
576
-     * @throws EE_Error
577
-     */
578
-    public function get_input_value($name)
579
-    {
580
-        $input = $this->get_input($name);
581
-        return $input->normalized_value();
582
-    }
583
-
584
-
585
-    /**
586
-     * Checks if this form section itself is valid, and then checks its subsections
587
-     *
588
-     * @throws EE_Error
589
-     * @return boolean
590
-     */
591
-    public function is_valid()
592
-    {
593
-        if ($this->is_valid === null) {
594
-            if (! $this->has_received_submission()) {
595
-                throw new EE_Error(
596
-                    sprintf(
597
-                        esc_html__(
598
-                            'You cannot check if a form is valid before receiving the form submission using receive_form_submission',
599
-                            'event_espresso'
600
-                        )
601
-                    )
602
-                );
603
-            }
604
-            if (! parent::is_valid()) {
605
-                $this->is_valid = false;
606
-            } else {
607
-                // ok so no general errors to this entire form section.
608
-                // so let's check the subsections, but only set errors if that hasn't been done yet
609
-                $this->is_valid = true;
610
-                foreach ($this->get_validatable_subsections() as $subsection) {
611
-                    if (! $subsection->is_valid()) {
612
-                        $this->is_valid = false;
613
-                    }
614
-                }
615
-            }
616
-        }
617
-        return $this->is_valid;
618
-    }
619
-
620
-
621
-    /**
622
-     * gets the default name of this form section if none is specified
623
-     *
624
-     * @return void
625
-     */
626
-    protected function _set_default_name_if_empty()
627
-    {
628
-        if (! $this->_name) {
629
-            $classname    = get_class($this);
630
-            $default_name = str_replace('EE_', '', $classname);
631
-            $this->_name  = $default_name;
632
-        }
633
-    }
634
-
635
-
636
-    /**
637
-     * Returns the HTML for the form, except for the form opening and closing tags
638
-     * (as the form section doesn't know where you necessarily want to send the information to),
639
-     * and except for a submit button. Enqueues JS and CSS; if called early enough we will
640
-     * try to enqueue them in the header, otherwise they'll be enqueued in the footer.
641
-     * Not doing_it_wrong because theoretically this CAN be used properly,
642
-     * provided its used during "wp_enqueue_scripts", or it doesn't need to enqueue
643
-     * any CSS.
644
-     *
645
-     * @throws InvalidArgumentException
646
-     * @throws InvalidInterfaceException
647
-     * @throws InvalidDataTypeException
648
-     * @throws EE_Error
649
-     */
650
-    public function get_html_and_js()
651
-    {
652
-        $this->enqueue_js();
653
-        return $this->get_html();
654
-    }
655
-
656
-
657
-    /**
658
-     * returns HTML for displaying this form section. recursively calls display_section() on all subsections
659
-     *
660
-     * @param bool $display_previously_submitted_data
661
-     * @return string
662
-     * @throws InvalidArgumentException
663
-     * @throws InvalidInterfaceException
664
-     * @throws InvalidDataTypeException
665
-     * @throws EE_Error
666
-     * @throws EE_Error
667
-     * @throws EE_Error
668
-     */
669
-    public function get_html($display_previously_submitted_data = true)
670
-    {
671
-        $this->ensure_construct_finalized_called();
672
-        if ($display_previously_submitted_data) {
673
-            $this->populate_from_session();
674
-        }
675
-        return $this->_form_html_filter
676
-            ? $this->_form_html_filter->filterHtml($this->_layout_strategy->layout_form(), $this)
677
-            : $this->_layout_strategy->layout_form();
678
-    }
679
-
680
-
681
-    /**
682
-     * enqueues JS and CSS for the form.
683
-     * It is preferred to call this before wp_enqueue_scripts so the
684
-     * scripts and styles can be put in the header, but if called later
685
-     * they will be put in the footer (which is OK for JS, but in HTML4 CSS should
686
-     * only be in the header; but in HTML5 its ok in the body.
687
-     * See http://stackoverflow.com/questions/4957446/load-external-css-file-in-body-tag.
688
-     * So if your form enqueues CSS, it's preferred to call this before wp_enqueue_scripts.)
689
-     *
690
-     * @return void
691
-     * @throws EE_Error
692
-     */
693
-    public function enqueue_js()
694
-    {
695
-        $this->_enqueue_and_localize_form_js();
696
-        foreach ($this->subsections() as $subsection) {
697
-            $subsection->enqueue_js();
698
-        }
699
-    }
700
-
701
-
702
-    /**
703
-     * adds a filter so that jquery validate gets enqueued in EE_System::wp_enqueue_scripts().
704
-     * This must be done BEFORE wp_enqueue_scripts() gets called, which is on
705
-     * the wp_enqueue_scripts hook.
706
-     * However, registering the form js and localizing it can happen when we
707
-     * actually output the form (which is preferred, seeing how teh form's fields
708
-     * could change until it's actually outputted)
709
-     *
710
-     * @param boolean $init_form_validation_automatically whether or not we want the form validation
711
-     *                                                    to be triggered automatically or not
712
-     * @return void
713
-     */
714
-    public static function wp_enqueue_scripts($init_form_validation_automatically = true)
715
-    {
716
-        wp_register_script(
717
-            'ee_form_section_validation',
718
-            EE_GLOBAL_ASSETS_URL . 'scripts' . '/form_section_validation.js',
719
-            array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
720
-            EVENT_ESPRESSO_VERSION,
721
-            true
722
-        );
723
-        wp_localize_script(
724
-            'ee_form_section_validation',
725
-            'ee_form_section_validation_init',
726
-            array('init' => $init_form_validation_automatically ? '1' : '0')
727
-        );
728
-    }
729
-
730
-
731
-    /**
732
-     * gets the variables used by form_section_validation.js.
733
-     * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
734
-     * but before the wordpress hook wp_loaded
735
-     *
736
-     * @throws EE_Error
737
-     */
738
-    public function _enqueue_and_localize_form_js()
739
-    {
740
-        $this->ensure_construct_finalized_called();
741
-        // actually, we don't want to localize just yet. There may be other forms on the page.
742
-        // so we need to add our form section data to a static variable accessible by all form sections
743
-        // and localize it just before the footer
744
-        $this->localize_validation_rules();
745
-        add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
746
-        add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
747
-    }
748
-
749
-
750
-    /**
751
-     * add our form section data to a static variable accessible by all form sections
752
-     *
753
-     * @param bool $return_for_subsection
754
-     * @return void
755
-     * @throws EE_Error
756
-     */
757
-    public function localize_validation_rules($return_for_subsection = false)
758
-    {
759
-        // we only want to localize vars ONCE for the entire form,
760
-        // so if the form section doesn't have a parent, then it must be the top dog
761
-        if ($return_for_subsection || ! $this->parent_section()) {
762
-            EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
763
-                'form_section_id'  => $this->html_id(true),
764
-                'validation_rules' => $this->get_jquery_validation_rules(),
765
-                'other_data'       => $this->get_other_js_data(),
766
-                'errors'           => $this->subsection_validation_errors_by_html_name(),
767
-            );
768
-            EE_Form_Section_Proper::$_scripts_localized                                = true;
769
-        }
770
-    }
771
-
772
-
773
-    /**
774
-     * Gets an array of extra data that will be useful for client-side javascript.
775
-     * This is primarily data added by inputs and forms in addition to any
776
-     * scripts they might enqueue
777
-     *
778
-     * @param array $form_other_js_data
779
-     * @return array
780
-     * @throws EE_Error
781
-     */
782
-    public function get_other_js_data($form_other_js_data = array())
783
-    {
784
-        foreach ($this->subsections() as $subsection) {
785
-            $form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
786
-        }
787
-        return $form_other_js_data;
788
-    }
789
-
790
-
791
-    /**
792
-     * Gets a flat array of inputs for this form section and its subsections.
793
-     * Keys are their form names, and values are the inputs themselves
794
-     *
795
-     * @return EE_Form_Input_Base
796
-     * @throws EE_Error
797
-     */
798
-    public function inputs_in_subsections()
799
-    {
800
-        $inputs = array();
801
-        foreach ($this->subsections() as $subsection) {
802
-            if ($subsection instanceof EE_Form_Input_Base) {
803
-                $inputs[ $subsection->html_name() ] = $subsection;
804
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
805
-                $inputs += $subsection->inputs_in_subsections();
806
-            }
807
-        }
808
-        return $inputs;
809
-    }
810
-
811
-
812
-    /**
813
-     * Gets a flat array of all the validation errors.
814
-     * Keys are html names (because those should be unique)
815
-     * and values are a string of all their validation errors
816
-     *
817
-     * @return string[]
818
-     * @throws EE_Error
819
-     */
820
-    public function subsection_validation_errors_by_html_name()
821
-    {
822
-        $inputs = $this->inputs();
823
-        $errors = array();
824
-        foreach ($inputs as $form_input) {
825
-            if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
826
-                $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
827
-            }
828
-        }
829
-        return $errors;
830
-    }
831
-
832
-
833
-    /**
834
-     * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
835
-     * Should be setup by each form during the _enqueues_and_localize_form_js
836
-     *
837
-     * @throws InvalidArgumentException
838
-     * @throws InvalidInterfaceException
839
-     * @throws InvalidDataTypeException
840
-     */
841
-    public static function localize_script_for_all_forms()
842
-    {
843
-        // allow inputs and stuff to hook in their JS and stuff here
844
-        do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
845
-        EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
846
-        $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
847
-            ? EE_Registry::instance()->CFG->registration->email_validation_level
848
-            : 'wp_default';
849
-        EE_Form_Section_Proper::$_js_localization['email_validation_level']   = $email_validation_level;
850
-        wp_enqueue_script('ee_form_section_validation');
851
-        wp_localize_script(
852
-            'ee_form_section_validation',
853
-            'ee_form_section_vars',
854
-            EE_Form_Section_Proper::$_js_localization
855
-        );
856
-    }
857
-
858
-
859
-    /**
860
-     * ensure_scripts_localized
861
-     *
862
-     * @throws EE_Error
863
-     */
864
-    public function ensure_scripts_localized()
865
-    {
866
-        if (! EE_Form_Section_Proper::$_scripts_localized) {
867
-            $this->_enqueue_and_localize_form_js();
868
-        }
869
-    }
870
-
871
-
872
-    /**
873
-     * Gets the hard-coded validation error messages to be used in the JS. The convention
874
-     * is that the key here should be the same as the custom validation rule put in the JS file
875
-     *
876
-     * @return array keys are custom validation rules, and values are internationalized strings
877
-     */
878
-    private static function _get_localized_error_messages()
879
-    {
880
-        return array(
881
-            'validUrl' => wp_strip_all_tags(__('This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg', 'event_espresso')),
882
-            'regex'    => wp_strip_all_tags(__('Please check your input', 'event_espresso'))
883
-        );
884
-    }
885
-
886
-
887
-    /**
888
-     * @return array
889
-     */
890
-    public static function js_localization()
891
-    {
892
-        return self::$_js_localization;
893
-    }
894
-
895
-
896
-    /**
897
-     * @return void
898
-     */
899
-    public static function reset_js_localization()
900
-    {
901
-        self::$_js_localization = array();
902
-    }
903
-
904
-
905
-    /**
906
-     * Gets the JS to put inside the jquery validation rules for subsection of this form section.
907
-     * See parent function for more...
908
-     *
909
-     * @return array
910
-     * @throws EE_Error
911
-     */
912
-    public function get_jquery_validation_rules()
913
-    {
914
-        $jquery_validation_rules = array();
915
-        foreach ($this->get_validatable_subsections() as $subsection) {
916
-            $jquery_validation_rules = array_merge(
917
-                $jquery_validation_rules,
918
-                $subsection->get_jquery_validation_rules()
919
-            );
920
-        }
921
-        return $jquery_validation_rules;
922
-    }
923
-
924
-
925
-    /**
926
-     * Sanitizes all the data and sets the sanitized value of each field
927
-     *
928
-     * @param array $req_data
929
-     * @return void
930
-     * @throws EE_Error
931
-     */
932
-    protected function _normalize($req_data)
933
-    {
934
-        $this->_received_submission = true;
935
-        $this->_validation_errors   = array();
936
-        foreach ($this->get_validatable_subsections() as $subsection) {
937
-            try {
938
-                $subsection->_normalize($req_data);
939
-            } catch (EE_Validation_Error $e) {
940
-                $subsection->add_validation_error($e);
941
-            }
942
-        }
943
-    }
944
-
945
-
946
-    /**
947
-     * Performs validation on this form section and its subsections.
948
-     * For each subsection,
949
-     * calls _validate_{subsection_name} on THIS form (if the function exists)
950
-     * and passes it the subsection, then calls _validate on that subsection.
951
-     * If you need to perform validation on the form as a whole (considering multiple)
952
-     * you would be best to override this _validate method,
953
-     * calling parent::_validate() first.
954
-     *
955
-     * @throws EE_Error
956
-     */
957
-    protected function _validate()
958
-    {
959
-        // reset the cache of whether this form is valid or not- we're re-validating it now
960
-        $this->is_valid = null;
961
-        foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
962
-            if (method_exists($this, '_validate_' . $subsection_name)) {
963
-                call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
964
-            }
965
-            $subsection->_validate();
966
-        }
967
-    }
968
-
969
-
970
-    /**
971
-     * Gets all the validated inputs for the form section
972
-     *
973
-     * @return array
974
-     * @throws EE_Error
975
-     */
976
-    public function valid_data()
977
-    {
978
-        $inputs = array();
979
-        foreach ($this->subsections() as $subsection_name => $subsection) {
980
-            if ($subsection instanceof EE_Form_Section_Proper) {
981
-                $inputs[ $subsection_name ] = $subsection->valid_data();
982
-            } elseif ($subsection instanceof EE_Form_Input_Base) {
983
-                $inputs[ $subsection_name ] = $subsection->normalized_value();
984
-            }
985
-        }
986
-        return $inputs;
987
-    }
988
-
989
-
990
-    /**
991
-     * Gets all the inputs on this form section
992
-     *
993
-     * @return EE_Form_Input_Base[]
994
-     * @throws EE_Error
995
-     */
996
-    public function inputs()
997
-    {
998
-        $inputs = array();
999
-        foreach ($this->subsections() as $subsection_name => $subsection) {
1000
-            if ($subsection instanceof EE_Form_Input_Base) {
1001
-                $inputs[ $subsection_name ] = $subsection;
1002
-            }
1003
-        }
1004
-        return $inputs;
1005
-    }
1006
-
1007
-
1008
-    /**
1009
-     * Gets all the subsections which are a proper form
1010
-     *
1011
-     * @return EE_Form_Section_Proper[]
1012
-     * @throws EE_Error
1013
-     */
1014
-    public function subforms()
1015
-    {
1016
-        $form_sections = array();
1017
-        foreach ($this->subsections() as $name => $obj) {
1018
-            if ($obj instanceof EE_Form_Section_Proper) {
1019
-                $form_sections[ $name ] = $obj;
1020
-            }
1021
-        }
1022
-        return $form_sections;
1023
-    }
1024
-
1025
-
1026
-    /**
1027
-     * Gets all the subsections (inputs, proper subsections, or html-only sections).
1028
-     * Consider using inputs() or subforms()
1029
-     * if you only want form inputs or proper form sections.
1030
-     *
1031
-     * @param boolean $require_construction_to_be_finalized most client code should
1032
-     *                                                      leave this as TRUE so that the inputs will be properly
1033
-     *                                                      configured. However, some client code may be ok with
1034
-     *                                                      construction finalize being called later
1035
-     *                                                      (realizing that the subsections' html names might not be
1036
-     *                                                      set yet, etc.)
1037
-     * @return EE_Form_Section_Proper[]
1038
-     * @throws EE_Error
1039
-     */
1040
-    public function subsections($require_construction_to_be_finalized = true)
1041
-    {
1042
-        if ($require_construction_to_be_finalized) {
1043
-            $this->ensure_construct_finalized_called();
1044
-        }
1045
-        return $this->_subsections;
1046
-    }
1047
-
1048
-
1049
-    /**
1050
-     * Returns whether this form has any subforms or inputs
1051
-     * @return bool
1052
-     */
1053
-    public function hasSubsections()
1054
-    {
1055
-        return ! empty($this->_subsections);
1056
-    }
1057
-
1058
-
1059
-    /**
1060
-     * Returns a simple array where keys are input names, and values are their normalized
1061
-     * values. (Similar to calling get_input_value on inputs)
1062
-     *
1063
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1064
-     *                                        or just this forms' direct children inputs
1065
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1066
-     *                                        or allow multidimensional array
1067
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array
1068
-     *                                        with array keys being input names
1069
-     *                                        (regardless of whether they are from a subsection or not),
1070
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1071
-     *                                        where keys are always subsection names and values are either
1072
-     *                                        the input's normalized value, or an array like the top-level array
1073
-     * @throws EE_Error
1074
-     */
1075
-    public function input_values($include_subform_inputs = false, $flatten = false)
1076
-    {
1077
-        return $this->_input_values(false, $include_subform_inputs, $flatten);
1078
-    }
1079
-
1080
-
1081
-    /**
1082
-     * Similar to EE_Form_Section_Proper::input_values(), except this returns the 'display_value'
1083
-     * of each input. On some inputs (especially radio boxes or checkboxes), the value stored
1084
-     * is not necessarily the value we want to display to users. This creates an array
1085
-     * where keys are the input names, and values are their display values
1086
-     *
1087
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1088
-     *                                        or just this forms' direct children inputs
1089
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1090
-     *                                        or allow multidimensional array
1091
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array
1092
-     *                                        with array keys being input names
1093
-     *                                        (regardless of whether they are from a subsection or not),
1094
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1095
-     *                                        where keys are always subsection names and values are either
1096
-     *                                        the input's normalized value, or an array like the top-level array
1097
-     * @throws EE_Error
1098
-     */
1099
-    public function input_pretty_values($include_subform_inputs = false, $flatten = false)
1100
-    {
1101
-        return $this->_input_values(true, $include_subform_inputs, $flatten);
1102
-    }
1103
-
1104
-
1105
-    /**
1106
-     * Gets the input values from the form
1107
-     *
1108
-     * @param boolean $pretty                 Whether to retrieve the pretty value,
1109
-     *                                        or just the normalized value
1110
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1111
-     *                                        or just this forms' direct children inputs
1112
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1113
-     *                                        or allow multidimensional array
1114
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array with array keys being
1115
-     *                                        input names (regardless of whether they are from a subsection or not),
1116
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1117
-     *                                        where keys are always subsection names and values are either
1118
-     *                                        the input's normalized value, or an array like the top-level array
1119
-     * @throws EE_Error
1120
-     */
1121
-    public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false)
1122
-    {
1123
-        $input_values = array();
1124
-        foreach ($this->subsections() as $subsection_name => $subsection) {
1125
-            if ($subsection instanceof EE_Form_Input_Base) {
1126
-                $input_values[ $subsection_name ] = $pretty
1127
-                    ? $subsection->pretty_value()
1128
-                    : $subsection->normalized_value();
1129
-            } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
1130
-                $subform_input_values = $subsection->_input_values(
1131
-                    $pretty,
1132
-                    $include_subform_inputs,
1133
-                    $flatten
1134
-                );
1135
-                if ($flatten) {
1136
-                    $input_values = array_merge($input_values, $subform_input_values);
1137
-                } else {
1138
-                    $input_values[ $subsection_name ] = $subform_input_values;
1139
-                }
1140
-            }
1141
-        }
1142
-        return $input_values;
1143
-    }
1144
-
1145
-
1146
-    /**
1147
-     * Gets the originally submitted input values from the form
1148
-     *
1149
-     * @param boolean $include_subforms  Whether to include inputs from subforms,
1150
-     *                                   or just this forms' direct children inputs
1151
-     * @return array                     if $flatten is TRUE it will always be a 1-dimensional array
1152
-     *                                   with array keys being input names
1153
-     *                                   (regardless of whether they are from a subsection or not),
1154
-     *                                   and if $flatten is FALSE it can be a multidimensional array
1155
-     *                                   where keys are always subsection names and values are either
1156
-     *                                   the input's normalized value, or an array like the top-level array
1157
-     * @throws EE_Error
1158
-     */
1159
-    public function submitted_values($include_subforms = false)
1160
-    {
1161
-        $submitted_values = array();
1162
-        foreach ($this->subsections() as $subsection) {
1163
-            if ($subsection instanceof EE_Form_Input_Base) {
1164
-                // is this input part of an array of inputs?
1165
-                if (strpos($subsection->html_name(), '[') !== false) {
1166
-                    $full_input_name  = EEH_Array::convert_array_values_to_keys(
1167
-                        explode(
1168
-                            '[',
1169
-                            str_replace(']', '', $subsection->html_name())
1170
-                        ),
1171
-                        $subsection->raw_value()
1172
-                    );
1173
-                    $submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1174
-                } else {
1175
-                    $submitted_values[ $subsection->html_name() ] = $subsection->raw_value();
1176
-                }
1177
-            } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1178
-                $subform_input_values = $subsection->submitted_values($include_subforms);
1179
-                $submitted_values     = array_replace_recursive($submitted_values, $subform_input_values);
1180
-            }
1181
-        }
1182
-        return $submitted_values;
1183
-    }
1184
-
1185
-
1186
-    /**
1187
-     * Indicates whether or not this form has received a submission yet
1188
-     * (ie, had receive_form_submission called on it yet)
1189
-     *
1190
-     * @return boolean
1191
-     * @throws EE_Error
1192
-     */
1193
-    public function has_received_submission()
1194
-    {
1195
-        $this->ensure_construct_finalized_called();
1196
-        return $this->_received_submission;
1197
-    }
1198
-
1199
-
1200
-    /**
1201
-     * Equivalent to passing 'exclude' in the constructor's options array.
1202
-     * Removes the listed inputs from the form
1203
-     *
1204
-     * @param array $inputs_to_exclude values are the input names
1205
-     * @return void
1206
-     */
1207
-    public function exclude(array $inputs_to_exclude = array())
1208
-    {
1209
-        foreach ($inputs_to_exclude as $input_to_exclude_name) {
1210
-            unset($this->_subsections[ $input_to_exclude_name ]);
1211
-        }
1212
-    }
1213
-
1214
-
1215
-    /**
1216
-     * Changes these inputs' display strategy to be EE_Hidden_Display_Strategy.
1217
-     * @param array $inputs_to_hide
1218
-     * @throws EE_Error
1219
-     */
1220
-    public function hide(array $inputs_to_hide = array())
1221
-    {
1222
-        foreach ($inputs_to_hide as $input_to_hide) {
1223
-            $input = $this->get_input($input_to_hide);
1224
-            $input->set_display_strategy(new EE_Hidden_Display_Strategy());
1225
-        }
1226
-    }
1227
-
1228
-
1229
-    /**
1230
-     * add_subsections
1231
-     * Adds the listed subsections to the form section.
1232
-     * If $subsection_name_to_target is provided,
1233
-     * then new subsections are added before or after that subsection,
1234
-     * otherwise to the start or end of the entire subsections array.
1235
-     *
1236
-     * @param EE_Form_Section_Base[] $new_subsections           array of new form subsections
1237
-     *                                                          where keys are their names
1238
-     * @param string                 $subsection_name_to_target an existing for section that $new_subsections
1239
-     *                                                          should be added before or after
1240
-     *                                                          IF $subsection_name_to_target is null,
1241
-     *                                                          then $new_subsections will be added to
1242
-     *                                                          the beginning or end of the entire subsections array
1243
-     * @param boolean                $add_before                whether to add $new_subsections, before or after
1244
-     *                                                          $subsection_name_to_target,
1245
-     *                                                          or if $subsection_name_to_target is null,
1246
-     *                                                          before or after entire subsections array
1247
-     * @return void
1248
-     * @throws EE_Error
1249
-     */
1250
-    public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1251
-    {
1252
-        foreach ($new_subsections as $subsection_name => $subsection) {
1253
-            if (! $subsection instanceof EE_Form_Section_Base) {
1254
-                EE_Error::add_error(
1255
-                    sprintf(
1256
-                        esc_html__(
1257
-                            "Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.",
1258
-                            'event_espresso'
1259
-                        ),
1260
-                        get_class($subsection),
1261
-                        $subsection_name,
1262
-                        $this->name()
1263
-                    )
1264
-                );
1265
-                unset($new_subsections[ $subsection_name ]);
1266
-            }
1267
-        }
1268
-        $this->_subsections = EEH_Array::insert_into_array(
1269
-            $this->_subsections,
1270
-            $new_subsections,
1271
-            $subsection_name_to_target,
1272
-            $add_before
1273
-        );
1274
-        if ($this->_construction_finalized) {
1275
-            foreach ($this->_subsections as $name => $subsection) {
1276
-                $subsection->_construct_finalize($this, $name);
1277
-            }
1278
-        }
1279
-    }
1280
-
1281
-
1282
-    /**
1283
-     * @param string $subsection_name
1284
-     * @param bool   $recursive
1285
-     * @return bool
1286
-     */
1287
-    public function has_subsection($subsection_name, $recursive = false)
1288
-    {
1289
-        foreach ($this->_subsections as $name => $subsection) {
1290
-            if (
1291
-                $name === $subsection_name
1292
-                || (
1293
-                    $recursive
1294
-                    && $subsection instanceof EE_Form_Section_Proper
1295
-                    && $subsection->has_subsection($subsection_name, $recursive)
1296
-                )
1297
-            ) {
1298
-                return true;
1299
-            }
1300
-        }
1301
-        return false;
1302
-    }
1303
-
1304
-
1305
-
1306
-    /**
1307
-     * Just gets all validatable subsections to clean their sensitive data
1308
-     *
1309
-     * @throws EE_Error
1310
-     */
1311
-    public function clean_sensitive_data()
1312
-    {
1313
-        foreach ($this->get_validatable_subsections() as $subsection) {
1314
-            $subsection->clean_sensitive_data();
1315
-        }
1316
-    }
1317
-
1318
-
1319
-    /**
1320
-     * Sets the submission error message (aka validation error message for this form section and all sub-sections)
1321
-     * @param string                           $form_submission_error_message
1322
-     * @param EE_Form_Section_Validatable $form_section unused
1323
-     * @throws EE_Error
1324
-     */
1325
-    public function set_submission_error_message(
1326
-        $form_submission_error_message = ''
1327
-    ) {
1328
-        $this->_form_submission_error_message = ! empty($form_submission_error_message)
1329
-            ? $form_submission_error_message
1330
-            : $this->getAllValidationErrorsString();
1331
-    }
1332
-
1333
-
1334
-    /**
1335
-     * Returns the cached error message. A default value is set for this during _validate(),
1336
-     * (called during receive_form_submission) but it can be explicitly set using
1337
-     * set_submission_error_message
1338
-     *
1339
-     * @return string
1340
-     */
1341
-    public function submission_error_message()
1342
-    {
1343
-        return $this->_form_submission_error_message;
1344
-    }
1345
-
1346
-
1347
-    /**
1348
-     * Sets a message to display if the data submitted to the form was valid.
1349
-     * @param string $form_submission_success_message
1350
-     */
1351
-    public function set_submission_success_message($form_submission_success_message = '')
1352
-    {
1353
-        $this->_form_submission_success_message = ! empty($form_submission_success_message)
1354
-            ? $form_submission_success_message
1355
-            : esc_html__('Form submitted successfully', 'event_espresso');
1356
-    }
1357
-
1358
-
1359
-    /**
1360
-     * Gets a message appropriate for display when the form is correctly submitted
1361
-     * @return string
1362
-     */
1363
-    public function submission_success_message()
1364
-    {
1365
-        return $this->_form_submission_success_message;
1366
-    }
1367
-
1368
-
1369
-    /**
1370
-     * Returns the prefix that should be used on child of this form section for
1371
-     * their html names. If this form section itself has a parent, prepends ITS
1372
-     * prefix onto this form section's prefix. Used primarily by
1373
-     * EE_Form_Input_Base::_set_default_html_name_if_empty
1374
-     *
1375
-     * @return string
1376
-     * @throws EE_Error
1377
-     */
1378
-    public function html_name_prefix()
1379
-    {
1380
-        if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1381
-            return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1382
-        }
1383
-        return $this->name();
1384
-    }
1385
-
1386
-
1387
-    /**
1388
-     * Gets the name, but first checks _construct_finalize has been called. If not,
1389
-     * calls it (assumes there is no parent and that we want the name to be whatever
1390
-     * was set, which is probably nothing, or the classname)
1391
-     *
1392
-     * @return string
1393
-     * @throws EE_Error
1394
-     */
1395
-    public function name()
1396
-    {
1397
-        $this->ensure_construct_finalized_called();
1398
-        return parent::name();
1399
-    }
1400
-
1401
-
1402
-    /**
1403
-     * @return EE_Form_Section_Proper
1404
-     * @throws EE_Error
1405
-     */
1406
-    public function parent_section()
1407
-    {
1408
-        $this->ensure_construct_finalized_called();
1409
-        return parent::parent_section();
1410
-    }
1411
-
1412
-
1413
-    /**
1414
-     * make sure construction finalized was called, otherwise children might not be ready
1415
-     *
1416
-     * @return void
1417
-     * @throws EE_Error
1418
-     */
1419
-    public function ensure_construct_finalized_called()
1420
-    {
1421
-        if (! $this->_construction_finalized) {
1422
-            $this->_construct_finalize($this->_parent_section, $this->_name);
1423
-        }
1424
-    }
1425
-
1426
-
1427
-    /**
1428
-     * Checks if any of this form section's inputs, or any of its children's inputs,
1429
-     * are in teh form data. If any are found, returns true. Else false
1430
-     *
1431
-     * @param array $req_data
1432
-     * @return boolean
1433
-     * @throws EE_Error
1434
-     */
1435
-    public function form_data_present_in($req_data = null)
1436
-    {
1437
-        $req_data = $this->getCachedRequest($req_data);
1438
-        foreach ($this->subsections() as $subsection) {
1439
-            if ($subsection instanceof EE_Form_Input_Base) {
1440
-                if ($subsection->form_data_present_in($req_data)) {
1441
-                    return true;
1442
-                }
1443
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
1444
-                if ($subsection->form_data_present_in($req_data)) {
1445
-                    return true;
1446
-                }
1447
-            }
1448
-        }
1449
-        return false;
1450
-    }
1451
-
1452
-
1453
-    /**
1454
-     * Gets validation errors for this form section and subsections
1455
-     * Similar to EE_Form_Section_Validatable::get_validation_errors() except this
1456
-     * gets the validation errors for ALL subsection
1457
-     *
1458
-     * @return EE_Validation_Error[]
1459
-     * @throws EE_Error
1460
-     */
1461
-    public function get_validation_errors_accumulated()
1462
-    {
1463
-        $validation_errors = $this->get_validation_errors();
1464
-        foreach ($this->get_validatable_subsections() as $subsection) {
1465
-            if ($subsection instanceof EE_Form_Section_Proper) {
1466
-                $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1467
-            } else {
1468
-                $validation_errors_on_this_subsection = $subsection->get_validation_errors();
1469
-            }
1470
-            if ($validation_errors_on_this_subsection) {
1471
-                $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1472
-            }
1473
-        }
1474
-        return $validation_errors;
1475
-    }
1476
-
1477
-    /**
1478
-     * Fetch validation errors from children and grandchildren and puts them in a single string.
1479
-     * This traverses the form section tree to generate this, but you probably want to instead use
1480
-     * get_form_submission_error_message() which is usually this message cached (or a custom validation error message)
1481
-     *
1482
-     * @return string
1483
-     * @since 4.9.59.p
1484
-     */
1485
-    protected function getAllValidationErrorsString()
1486
-    {
1487
-        $submission_error_messages = array();
1488
-        // bad, bad, bad registrant
1489
-        foreach ($this->get_validation_errors_accumulated() as $validation_error) {
1490
-            if ($validation_error instanceof EE_Validation_Error) {
1491
-                $form_section = $validation_error->get_form_section();
1492
-                if ($form_section instanceof EE_Form_Input_Base) {
1493
-                    $label = $validation_error->get_form_section()->html_label_text();
1494
-                } elseif ($form_section instanceof EE_Form_Section_Validatable) {
1495
-                    $label = $validation_error->get_form_section()->name();
1496
-                } else {
1497
-                    $label = esc_html__('Unknown', 'event_espresso');
1498
-                }
1499
-                $submission_error_messages[] = sprintf(
1500
-                    esc_html__('%s : %s', 'event_espresso'),
1501
-                    $label,
1502
-                    $validation_error->getMessage()
1503
-                );
1504
-            }
1505
-        }
1506
-        return implode('<br>', $submission_error_messages);
1507
-    }
1508
-
1509
-
1510
-    /**
1511
-     * This isn't just the name of an input, it's a path pointing to an input. The
1512
-     * path is similar to a folder path: slash (/) means to descend into a subsection,
1513
-     * dot-dot-slash (../) means to ascend into the parent section.
1514
-     * After a series of slashes and dot-dot-slashes, there should be the name of an input,
1515
-     * which will be returned.
1516
-     * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
1517
-     * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
1518
-     * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
1519
-     * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
1520
-     * Etc
1521
-     *
1522
-     * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1523
-     * @return EE_Form_Section_Base
1524
-     * @throws EE_Error
1525
-     */
1526
-    public function find_section_from_path($form_section_path)
1527
-    {
1528
-        // check if we can find the input from purely going straight up the tree
1529
-        $input = parent::find_section_from_path($form_section_path);
1530
-        if ($input instanceof EE_Form_Section_Base) {
1531
-            return $input;
1532
-        }
1533
-        $next_slash_pos = strpos($form_section_path, '/');
1534
-        if ($next_slash_pos !== false) {
1535
-            $child_section_name = substr($form_section_path, 0, $next_slash_pos);
1536
-            $subpath            = substr($form_section_path, $next_slash_pos + 1);
1537
-        } else {
1538
-            $child_section_name = $form_section_path;
1539
-            $subpath            = '';
1540
-        }
1541
-        $child_section = $this->get_subsection($child_section_name);
1542
-        if ($child_section instanceof EE_Form_Section_Base) {
1543
-            return $child_section->find_section_from_path($subpath);
1544
-        }
1545
-        return null;
1546
-    }
19
+	const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data';
20
+
21
+	/**
22
+	 * Subsections
23
+	 *
24
+	 * @var EE_Form_Section_Validatable[]
25
+	 */
26
+	protected $_subsections = array();
27
+
28
+	/**
29
+	 * Strategy for laying out the form
30
+	 *
31
+	 * @var EE_Form_Section_Layout_Base
32
+	 */
33
+	protected $_layout_strategy;
34
+
35
+	/**
36
+	 * Whether or not this form has received and validated a form submission yet
37
+	 *
38
+	 * @var boolean
39
+	 */
40
+	protected $_received_submission = false;
41
+
42
+	/**
43
+	 * message displayed to users upon successful form submission
44
+	 *
45
+	 * @var string
46
+	 */
47
+	protected $_form_submission_success_message = '';
48
+
49
+	/**
50
+	 * message displayed to users upon unsuccessful form submission
51
+	 *
52
+	 * @var string
53
+	 */
54
+	protected $_form_submission_error_message = '';
55
+
56
+	/**
57
+	 * @var array like post / request
58
+	 */
59
+	protected $cached_request_data;
60
+
61
+	/**
62
+	 * Stores whether this form (and its sub-sections) were found to be valid or not.
63
+	 * Starts off as null, but once the form is validated, it set to either true or false
64
+	 * @var boolean|null
65
+	 */
66
+	protected $is_valid;
67
+
68
+	/**
69
+	 * Stores all the data that will localized for form validation
70
+	 *
71
+	 * @var array
72
+	 */
73
+	protected static $_js_localization = array();
74
+
75
+	/**
76
+	 * whether or not the form's localized validation JS vars have been set
77
+	 *
78
+	 * @type boolean
79
+	 */
80
+	protected static $_scripts_localized = false;
81
+
82
+
83
+	/**
84
+	 * when constructing a proper form section, calls _construct_finalize on children
85
+	 * so that they know who their parent is, and what name they've been given.
86
+	 *
87
+	 * @param array[] $options_array   {
88
+	 * @type          $subsections     EE_Form_Section_Validatable[] where keys are the section's name
89
+	 * @type          $include         string[] numerically-indexed where values are section names to be included,
90
+	 *                                 and in that order. This is handy if you want
91
+	 *                                 the subsections to be ordered differently than the default, and if you override
92
+	 *                                 which fields are shown
93
+	 * @type          $exclude         string[] values are subsections to be excluded. This is handy if you want
94
+	 *                                 to remove certain default subsections (note: if you specify BOTH 'include' AND
95
+	 *                                 'exclude', the inclusions will be applied first, and the exclusions will exclude
96
+	 *                                 items from that list of inclusions)
97
+	 * @type          $layout_strategy EE_Form_Section_Layout_Base strategy for laying out the form
98
+	 *                                 } @see EE_Form_Section_Validatable::__construct()
99
+	 * @throws EE_Error
100
+	 */
101
+	public function __construct($options_array = array())
102
+	{
103
+		$options_array = (array) apply_filters(
104
+			'FHEE__EE_Form_Section_Proper___construct__options_array',
105
+			$options_array,
106
+			$this
107
+		);
108
+		// call parent first, as it may be setting the name
109
+		parent::__construct($options_array);
110
+		// if they've included subsections in the constructor, add them now
111
+		if (isset($options_array['include'])) {
112
+			// we are going to make sure we ONLY have those subsections to include
113
+			// AND we are going to make sure they're in that specified order
114
+			$reordered_subsections = array();
115
+			foreach ($options_array['include'] as $input_name) {
116
+				if (isset($this->_subsections[ $input_name ])) {
117
+					$reordered_subsections[ $input_name ] = $this->_subsections[ $input_name ];
118
+				}
119
+			}
120
+			$this->_subsections = $reordered_subsections;
121
+		}
122
+		if (isset($options_array['exclude'])) {
123
+			$exclude            = $options_array['exclude'];
124
+			$this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
125
+		}
126
+		if (isset($options_array['layout_strategy'])) {
127
+			$this->_layout_strategy = $options_array['layout_strategy'];
128
+		}
129
+		if (! $this->_layout_strategy) {
130
+			$this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
131
+		}
132
+		$this->_layout_strategy->_construct_finalize($this);
133
+		// ok so we are definitely going to want the forms JS,
134
+		// so enqueue it or remember to enqueue it during wp_enqueue_scripts
135
+		if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
136
+			// ok so they've constructed this object after when they should have.
137
+			// just enqueue the generic form scripts and initialize the form immediately in the JS
138
+			EE_Form_Section_Proper::wp_enqueue_scripts(true);
139
+		} else {
140
+			add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
141
+			add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
142
+		}
143
+		add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
144
+		/**
145
+		 * Gives other plugins a chance to hook in before construct finalize is called.
146
+		 * The form probably doesn't yet have a parent form section.
147
+		 * Since 4.9.32, when this action was introduced, this is the best place to add a subsection onto a form,
148
+		 * assuming you don't care what the form section's name, HTML ID, or HTML name etc are.
149
+		 * Also see AHEE__EE_Form_Section_Proper___construct_finalize__end
150
+		 *
151
+		 * @since 4.9.32
152
+		 * @param EE_Form_Section_Proper $this          before __construct is done, but all of its logic,
153
+		 *                                              except maybe calling _construct_finalize has been done
154
+		 * @param array                  $options_array options passed into the constructor
155
+		 */
156
+		do_action(
157
+			'AHEE__EE_Form_Input_Base___construct__before_construct_finalize_called',
158
+			$this,
159
+			$options_array
160
+		);
161
+		if (isset($options_array['name'])) {
162
+			$this->_construct_finalize(null, $options_array['name']);
163
+		}
164
+	}
165
+
166
+
167
+	/**
168
+	 * Finishes construction given the parent form section and this form section's name
169
+	 *
170
+	 * @param EE_Form_Section_Proper $parent_form_section
171
+	 * @param string                 $name
172
+	 * @throws EE_Error
173
+	 */
174
+	public function _construct_finalize($parent_form_section, $name)
175
+	{
176
+		parent::_construct_finalize($parent_form_section, $name);
177
+		$this->_set_default_name_if_empty();
178
+		$this->_set_default_html_id_if_empty();
179
+		foreach ($this->_subsections as $subsection_name => $subsection) {
180
+			if ($subsection instanceof EE_Form_Section_Base) {
181
+				$subsection->_construct_finalize($this, $subsection_name);
182
+			} else {
183
+				throw new EE_Error(
184
+					sprintf(
185
+						esc_html__(
186
+							'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"',
187
+							'event_espresso'
188
+						),
189
+						$subsection_name,
190
+						get_class($this),
191
+						$subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
192
+					)
193
+				);
194
+			}
195
+		}
196
+		/**
197
+		 * Action performed just after form has been given a name (and HTML ID etc) and is fully constructed.
198
+		 * If you have code that should modify the form and needs it and its subsections to have a name, HTML ID
199
+		 * (or other attributes derived from the name like the HTML label id, etc), this is where it should be done.
200
+		 * This might only happen just before displaying the form, or just before it receives form submission data.
201
+		 * If you need to modify the form or its subsections before _construct_finalize is called on it (and we've
202
+		 * ensured it has a name, HTML IDs, etc
203
+		 *
204
+		 * @param EE_Form_Section_Proper      $this
205
+		 * @param EE_Form_Section_Proper|null $parent_form_section
206
+		 * @param string                      $name
207
+		 */
208
+		do_action(
209
+			'AHEE__EE_Form_Section_Proper___construct_finalize__end',
210
+			$this,
211
+			$parent_form_section,
212
+			$name
213
+		);
214
+	}
215
+
216
+
217
+	/**
218
+	 * Gets the layout strategy for this form section
219
+	 *
220
+	 * @return EE_Form_Section_Layout_Base
221
+	 */
222
+	public function get_layout_strategy()
223
+	{
224
+		return $this->_layout_strategy;
225
+	}
226
+
227
+
228
+	/**
229
+	 * Gets the HTML for a single input for this form section according
230
+	 * to the layout strategy
231
+	 *
232
+	 * @param EE_Form_Input_Base $input
233
+	 * @return string
234
+	 */
235
+	public function get_html_for_input($input)
236
+	{
237
+		return $this->_layout_strategy->layout_input($input);
238
+	}
239
+
240
+
241
+	/**
242
+	 * was_submitted - checks if form inputs are present in request data
243
+	 * Basically an alias for form_data_present_in() (which is used by both
244
+	 * proper form sections and form inputs)
245
+	 *
246
+	 * @param null $form_data
247
+	 * @return boolean
248
+	 * @throws EE_Error
249
+	 */
250
+	public function was_submitted($form_data = null)
251
+	{
252
+		return $this->form_data_present_in($form_data);
253
+	}
254
+
255
+	/**
256
+	 * Gets the cached request data; but if there is none, or $req_data was set with
257
+	 * something different, refresh the cache, and then return it
258
+	 * @param null $req_data
259
+	 * @return array
260
+	 */
261
+	protected function getCachedRequest($req_data = null)
262
+	{
263
+		if (
264
+			$this->cached_request_data === null
265
+			|| (
266
+				$req_data !== null
267
+				&& $req_data !== $this->cached_request_data
268
+			)
269
+		) {
270
+			$req_data = apply_filters(
271
+				'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
272
+				$req_data,
273
+				$this
274
+			);
275
+			if ($req_data === null) {
276
+				/** @var RequestInterface $request */
277
+				$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
278
+				$req_data = $request->requestParams();
279
+			}
280
+			$req_data = apply_filters(
281
+				'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
282
+				$req_data,
283
+				$this
284
+			);
285
+			$this->cached_request_data = (array) $req_data;
286
+		}
287
+		return $this->cached_request_data;
288
+	}
289
+
290
+
291
+	/**
292
+	 * After the form section is initially created, call this to sanitize the data in the submission
293
+	 * which relates to this form section, validate it, and set it as properties on the form.
294
+	 *
295
+	 * @param array|null $req_data should usually be post data (the default).
296
+	 *                             However, you CAN supply a different array.
297
+	 *                             Consider using set_defaults() instead however.
298
+	 *                             (If you rendered the form in the page using echo $form_x->get_html()
299
+	 *                             the inputs will have the correct name in the request data for this function
300
+	 *                             to find them and populate the form with them.
301
+	 *                             If you have a flat form (with only input subsections),
302
+	 *                             you can supply a flat array where keys
303
+	 *                             are the form input names and values are their values)
304
+	 * @param boolean    $validate whether or not to perform validation on this data. Default is,
305
+	 *                             of course, to validate that data, and set errors on the invalid values.
306
+	 *                             But if the data has already been validated
307
+	 *                             (eg you validated the data then stored it in the DB)
308
+	 *                             you may want to skip this step.
309
+	 * @throws InvalidArgumentException
310
+	 * @throws InvalidInterfaceException
311
+	 * @throws InvalidDataTypeException
312
+	 * @throws EE_Error
313
+	 */
314
+	public function receive_form_submission($req_data = null, $validate = true)
315
+	{
316
+		$req_data = $this->getCachedRequest($req_data);
317
+		$this->_normalize($req_data);
318
+		if ($validate) {
319
+			$this->_validate();
320
+			// if it's invalid, we're going to want to re-display so remember what they submitted
321
+			if (! $this->is_valid()) {
322
+				$this->store_submitted_form_data_in_session();
323
+			}
324
+		}
325
+		if ($this->submission_error_message() === '' && ! $this->is_valid()) {
326
+			$this->set_submission_error_message();
327
+		}
328
+		do_action(
329
+			'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
330
+			$req_data,
331
+			$this,
332
+			$validate
333
+		);
334
+	}
335
+
336
+
337
+	/**
338
+	 * caches the originally submitted input values in the session
339
+	 * so that they can be used to repopulate the form if it failed validation
340
+	 *
341
+	 * @return boolean whether or not the data was successfully stored in the session
342
+	 * @throws InvalidArgumentException
343
+	 * @throws InvalidInterfaceException
344
+	 * @throws InvalidDataTypeException
345
+	 * @throws EE_Error
346
+	 */
347
+	protected function store_submitted_form_data_in_session()
348
+	{
349
+		return EE_Registry::instance()->SSN->set_session_data(
350
+			array(
351
+				EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true),
352
+			)
353
+		);
354
+	}
355
+
356
+
357
+	/**
358
+	 * retrieves the originally submitted input values in the session
359
+	 * so that they can be used to repopulate the form if it failed validation
360
+	 *
361
+	 * @return array
362
+	 * @throws InvalidArgumentException
363
+	 * @throws InvalidInterfaceException
364
+	 * @throws InvalidDataTypeException
365
+	 */
366
+	protected function get_submitted_form_data_from_session()
367
+	{
368
+		$session = EE_Registry::instance()->SSN;
369
+		if ($session instanceof EE_Session) {
370
+			return $session->get_session_data(
371
+				EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY
372
+			);
373
+		}
374
+		return array();
375
+	}
376
+
377
+
378
+	/**
379
+	 * flushed the originally submitted input values from the session
380
+	 *
381
+	 * @return boolean whether or not the data was successfully removed from the session
382
+	 * @throws InvalidArgumentException
383
+	 * @throws InvalidInterfaceException
384
+	 * @throws InvalidDataTypeException
385
+	 */
386
+	public static function flush_submitted_form_data_from_session()
387
+	{
388
+		return EE_Registry::instance()->SSN->reset_data(
389
+			array(EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
390
+		);
391
+	}
392
+
393
+
394
+	/**
395
+	 * Populates this form and its subsections with data from the session.
396
+	 * (Wrapper for EE_Form_Section_Proper::receive_form_submission, so it shows
397
+	 * validation errors when displaying too)
398
+	 * Returns true if the form was populated from the session, false otherwise
399
+	 *
400
+	 * @return boolean
401
+	 * @throws InvalidArgumentException
402
+	 * @throws InvalidInterfaceException
403
+	 * @throws InvalidDataTypeException
404
+	 * @throws EE_Error
405
+	 */
406
+	public function populate_from_session()
407
+	{
408
+		$form_data_in_session = $this->get_submitted_form_data_from_session();
409
+		if (empty($form_data_in_session)) {
410
+			return false;
411
+		}
412
+		$this->receive_form_submission($form_data_in_session);
413
+		add_action('shutdown', array('EE_Form_Section_Proper', 'flush_submitted_form_data_from_session'));
414
+		if ($this->form_data_present_in($form_data_in_session)) {
415
+			return true;
416
+		}
417
+		return false;
418
+	}
419
+
420
+
421
+	/**
422
+	 * Populates the default data for the form, given an array where keys are
423
+	 * the input names, and values are their values (preferably normalized to be their
424
+	 * proper PHP types, not all strings... although that should be ok too).
425
+	 * Proper subsections are sub-arrays, the key being the subsection's name, and
426
+	 * the value being an array formatted in teh same way
427
+	 *
428
+	 * @param array $default_data
429
+	 * @throws EE_Error
430
+	 */
431
+	public function populate_defaults($default_data)
432
+	{
433
+		foreach ($this->subsections(false) as $subsection_name => $subsection) {
434
+			if (isset($default_data[ $subsection_name ])) {
435
+				if ($subsection instanceof EE_Form_Input_Base) {
436
+					$subsection->set_default($default_data[ $subsection_name ]);
437
+				} elseif ($subsection instanceof EE_Form_Section_Proper) {
438
+					$subsection->populate_defaults($default_data[ $subsection_name ]);
439
+				}
440
+			}
441
+		}
442
+	}
443
+
444
+
445
+	/**
446
+	 * returns true if subsection exists
447
+	 *
448
+	 * @param string $name
449
+	 * @return boolean
450
+	 */
451
+	public function subsection_exists($name)
452
+	{
453
+		return isset($this->_subsections[ $name ]) ? true : false;
454
+	}
455
+
456
+
457
+	/**
458
+	 * Gets the subsection specified by its name
459
+	 *
460
+	 * @param string  $name
461
+	 * @param boolean $require_construction_to_be_finalized most client code should leave this as TRUE
462
+	 *                                                      so that the inputs will be properly configured.
463
+	 *                                                      However, some client code may be ok
464
+	 *                                                      with construction finalize being called later
465
+	 *                                                      (realizing that the subsections' html names
466
+	 *                                                      might not be set yet, etc.)
467
+	 * @return EE_Form_Section_Base
468
+	 * @throws EE_Error
469
+	 */
470
+	public function get_subsection($name, $require_construction_to_be_finalized = true)
471
+	{
472
+		if ($require_construction_to_be_finalized) {
473
+			$this->ensure_construct_finalized_called();
474
+		}
475
+		return $this->subsection_exists($name) ? $this->_subsections[ $name ] : null;
476
+	}
477
+
478
+
479
+	/**
480
+	 * Gets all the validatable subsections of this form section
481
+	 *
482
+	 * @return EE_Form_Section_Validatable[]
483
+	 * @throws EE_Error
484
+	 */
485
+	public function get_validatable_subsections()
486
+	{
487
+		$validatable_subsections = array();
488
+		foreach ($this->subsections() as $name => $obj) {
489
+			if ($obj instanceof EE_Form_Section_Validatable) {
490
+				$validatable_subsections[ $name ] = $obj;
491
+			}
492
+		}
493
+		return $validatable_subsections;
494
+	}
495
+
496
+
497
+	/**
498
+	 * Gets an input by the given name. If not found, or if its not an EE_FOrm_Input_Base child,
499
+	 * throw an EE_Error.
500
+	 *
501
+	 * @param string  $name
502
+	 * @param boolean $require_construction_to_be_finalized most client code should
503
+	 *                                                      leave this as TRUE so that the inputs will be properly
504
+	 *                                                      configured. However, some client code may be ok with
505
+	 *                                                      construction finalize being called later
506
+	 *                                                      (realizing that the subsections' html names might not be
507
+	 *                                                      set yet, etc.)
508
+	 * @return EE_Form_Input_Base
509
+	 * @throws EE_Error
510
+	 */
511
+	public function get_input($name, $require_construction_to_be_finalized = true)
512
+	{
513
+		$subsection = $this->get_subsection(
514
+			$name,
515
+			$require_construction_to_be_finalized
516
+		);
517
+		if (! $subsection instanceof EE_Form_Input_Base) {
518
+			throw new EE_Error(
519
+				sprintf(
520
+					esc_html__(
521
+						"Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'",
522
+						'event_espresso'
523
+					),
524
+					$name,
525
+					get_class($this),
526
+					$subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
527
+				)
528
+			);
529
+		}
530
+		return $subsection;
531
+	}
532
+
533
+
534
+	/**
535
+	 * Like get_input(), gets the proper subsection of the form given the name,
536
+	 * otherwise throws an EE_Error
537
+	 *
538
+	 * @param string  $name
539
+	 * @param boolean $require_construction_to_be_finalized most client code should
540
+	 *                                                      leave this as TRUE so that the inputs will be properly
541
+	 *                                                      configured. However, some client code may be ok with
542
+	 *                                                      construction finalize being called later
543
+	 *                                                      (realizing that the subsections' html names might not be
544
+	 *                                                      set yet, etc.)
545
+	 * @return EE_Form_Section_Proper
546
+	 * @throws EE_Error
547
+	 */
548
+	public function get_proper_subsection($name, $require_construction_to_be_finalized = true)
549
+	{
550
+		$subsection = $this->get_subsection(
551
+			$name,
552
+			$require_construction_to_be_finalized
553
+		);
554
+		if (! $subsection instanceof EE_Form_Section_Proper) {
555
+			throw new EE_Error(
556
+				sprintf(
557
+					esc_html__(
558
+						"Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'",
559
+						'event_espresso'
560
+					),
561
+					$name,
562
+					get_class($this)
563
+				)
564
+			);
565
+		}
566
+		return $subsection;
567
+	}
568
+
569
+
570
+	/**
571
+	 * Gets the value of the specified input. Should be called after receive_form_submission()
572
+	 * or populate_defaults() on the form, where the normalized value on the input is set.
573
+	 *
574
+	 * @param string $name
575
+	 * @return mixed depending on the input's type and its normalization strategy
576
+	 * @throws EE_Error
577
+	 */
578
+	public function get_input_value($name)
579
+	{
580
+		$input = $this->get_input($name);
581
+		return $input->normalized_value();
582
+	}
583
+
584
+
585
+	/**
586
+	 * Checks if this form section itself is valid, and then checks its subsections
587
+	 *
588
+	 * @throws EE_Error
589
+	 * @return boolean
590
+	 */
591
+	public function is_valid()
592
+	{
593
+		if ($this->is_valid === null) {
594
+			if (! $this->has_received_submission()) {
595
+				throw new EE_Error(
596
+					sprintf(
597
+						esc_html__(
598
+							'You cannot check if a form is valid before receiving the form submission using receive_form_submission',
599
+							'event_espresso'
600
+						)
601
+					)
602
+				);
603
+			}
604
+			if (! parent::is_valid()) {
605
+				$this->is_valid = false;
606
+			} else {
607
+				// ok so no general errors to this entire form section.
608
+				// so let's check the subsections, but only set errors if that hasn't been done yet
609
+				$this->is_valid = true;
610
+				foreach ($this->get_validatable_subsections() as $subsection) {
611
+					if (! $subsection->is_valid()) {
612
+						$this->is_valid = false;
613
+					}
614
+				}
615
+			}
616
+		}
617
+		return $this->is_valid;
618
+	}
619
+
620
+
621
+	/**
622
+	 * gets the default name of this form section if none is specified
623
+	 *
624
+	 * @return void
625
+	 */
626
+	protected function _set_default_name_if_empty()
627
+	{
628
+		if (! $this->_name) {
629
+			$classname    = get_class($this);
630
+			$default_name = str_replace('EE_', '', $classname);
631
+			$this->_name  = $default_name;
632
+		}
633
+	}
634
+
635
+
636
+	/**
637
+	 * Returns the HTML for the form, except for the form opening and closing tags
638
+	 * (as the form section doesn't know where you necessarily want to send the information to),
639
+	 * and except for a submit button. Enqueues JS and CSS; if called early enough we will
640
+	 * try to enqueue them in the header, otherwise they'll be enqueued in the footer.
641
+	 * Not doing_it_wrong because theoretically this CAN be used properly,
642
+	 * provided its used during "wp_enqueue_scripts", or it doesn't need to enqueue
643
+	 * any CSS.
644
+	 *
645
+	 * @throws InvalidArgumentException
646
+	 * @throws InvalidInterfaceException
647
+	 * @throws InvalidDataTypeException
648
+	 * @throws EE_Error
649
+	 */
650
+	public function get_html_and_js()
651
+	{
652
+		$this->enqueue_js();
653
+		return $this->get_html();
654
+	}
655
+
656
+
657
+	/**
658
+	 * returns HTML for displaying this form section. recursively calls display_section() on all subsections
659
+	 *
660
+	 * @param bool $display_previously_submitted_data
661
+	 * @return string
662
+	 * @throws InvalidArgumentException
663
+	 * @throws InvalidInterfaceException
664
+	 * @throws InvalidDataTypeException
665
+	 * @throws EE_Error
666
+	 * @throws EE_Error
667
+	 * @throws EE_Error
668
+	 */
669
+	public function get_html($display_previously_submitted_data = true)
670
+	{
671
+		$this->ensure_construct_finalized_called();
672
+		if ($display_previously_submitted_data) {
673
+			$this->populate_from_session();
674
+		}
675
+		return $this->_form_html_filter
676
+			? $this->_form_html_filter->filterHtml($this->_layout_strategy->layout_form(), $this)
677
+			: $this->_layout_strategy->layout_form();
678
+	}
679
+
680
+
681
+	/**
682
+	 * enqueues JS and CSS for the form.
683
+	 * It is preferred to call this before wp_enqueue_scripts so the
684
+	 * scripts and styles can be put in the header, but if called later
685
+	 * they will be put in the footer (which is OK for JS, but in HTML4 CSS should
686
+	 * only be in the header; but in HTML5 its ok in the body.
687
+	 * See http://stackoverflow.com/questions/4957446/load-external-css-file-in-body-tag.
688
+	 * So if your form enqueues CSS, it's preferred to call this before wp_enqueue_scripts.)
689
+	 *
690
+	 * @return void
691
+	 * @throws EE_Error
692
+	 */
693
+	public function enqueue_js()
694
+	{
695
+		$this->_enqueue_and_localize_form_js();
696
+		foreach ($this->subsections() as $subsection) {
697
+			$subsection->enqueue_js();
698
+		}
699
+	}
700
+
701
+
702
+	/**
703
+	 * adds a filter so that jquery validate gets enqueued in EE_System::wp_enqueue_scripts().
704
+	 * This must be done BEFORE wp_enqueue_scripts() gets called, which is on
705
+	 * the wp_enqueue_scripts hook.
706
+	 * However, registering the form js and localizing it can happen when we
707
+	 * actually output the form (which is preferred, seeing how teh form's fields
708
+	 * could change until it's actually outputted)
709
+	 *
710
+	 * @param boolean $init_form_validation_automatically whether or not we want the form validation
711
+	 *                                                    to be triggered automatically or not
712
+	 * @return void
713
+	 */
714
+	public static function wp_enqueue_scripts($init_form_validation_automatically = true)
715
+	{
716
+		wp_register_script(
717
+			'ee_form_section_validation',
718
+			EE_GLOBAL_ASSETS_URL . 'scripts' . '/form_section_validation.js',
719
+			array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
720
+			EVENT_ESPRESSO_VERSION,
721
+			true
722
+		);
723
+		wp_localize_script(
724
+			'ee_form_section_validation',
725
+			'ee_form_section_validation_init',
726
+			array('init' => $init_form_validation_automatically ? '1' : '0')
727
+		);
728
+	}
729
+
730
+
731
+	/**
732
+	 * gets the variables used by form_section_validation.js.
733
+	 * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
734
+	 * but before the wordpress hook wp_loaded
735
+	 *
736
+	 * @throws EE_Error
737
+	 */
738
+	public function _enqueue_and_localize_form_js()
739
+	{
740
+		$this->ensure_construct_finalized_called();
741
+		// actually, we don't want to localize just yet. There may be other forms on the page.
742
+		// so we need to add our form section data to a static variable accessible by all form sections
743
+		// and localize it just before the footer
744
+		$this->localize_validation_rules();
745
+		add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
746
+		add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
747
+	}
748
+
749
+
750
+	/**
751
+	 * add our form section data to a static variable accessible by all form sections
752
+	 *
753
+	 * @param bool $return_for_subsection
754
+	 * @return void
755
+	 * @throws EE_Error
756
+	 */
757
+	public function localize_validation_rules($return_for_subsection = false)
758
+	{
759
+		// we only want to localize vars ONCE for the entire form,
760
+		// so if the form section doesn't have a parent, then it must be the top dog
761
+		if ($return_for_subsection || ! $this->parent_section()) {
762
+			EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
763
+				'form_section_id'  => $this->html_id(true),
764
+				'validation_rules' => $this->get_jquery_validation_rules(),
765
+				'other_data'       => $this->get_other_js_data(),
766
+				'errors'           => $this->subsection_validation_errors_by_html_name(),
767
+			);
768
+			EE_Form_Section_Proper::$_scripts_localized                                = true;
769
+		}
770
+	}
771
+
772
+
773
+	/**
774
+	 * Gets an array of extra data that will be useful for client-side javascript.
775
+	 * This is primarily data added by inputs and forms in addition to any
776
+	 * scripts they might enqueue
777
+	 *
778
+	 * @param array $form_other_js_data
779
+	 * @return array
780
+	 * @throws EE_Error
781
+	 */
782
+	public function get_other_js_data($form_other_js_data = array())
783
+	{
784
+		foreach ($this->subsections() as $subsection) {
785
+			$form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
786
+		}
787
+		return $form_other_js_data;
788
+	}
789
+
790
+
791
+	/**
792
+	 * Gets a flat array of inputs for this form section and its subsections.
793
+	 * Keys are their form names, and values are the inputs themselves
794
+	 *
795
+	 * @return EE_Form_Input_Base
796
+	 * @throws EE_Error
797
+	 */
798
+	public function inputs_in_subsections()
799
+	{
800
+		$inputs = array();
801
+		foreach ($this->subsections() as $subsection) {
802
+			if ($subsection instanceof EE_Form_Input_Base) {
803
+				$inputs[ $subsection->html_name() ] = $subsection;
804
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
805
+				$inputs += $subsection->inputs_in_subsections();
806
+			}
807
+		}
808
+		return $inputs;
809
+	}
810
+
811
+
812
+	/**
813
+	 * Gets a flat array of all the validation errors.
814
+	 * Keys are html names (because those should be unique)
815
+	 * and values are a string of all their validation errors
816
+	 *
817
+	 * @return string[]
818
+	 * @throws EE_Error
819
+	 */
820
+	public function subsection_validation_errors_by_html_name()
821
+	{
822
+		$inputs = $this->inputs();
823
+		$errors = array();
824
+		foreach ($inputs as $form_input) {
825
+			if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
826
+				$errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
827
+			}
828
+		}
829
+		return $errors;
830
+	}
831
+
832
+
833
+	/**
834
+	 * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
835
+	 * Should be setup by each form during the _enqueues_and_localize_form_js
836
+	 *
837
+	 * @throws InvalidArgumentException
838
+	 * @throws InvalidInterfaceException
839
+	 * @throws InvalidDataTypeException
840
+	 */
841
+	public static function localize_script_for_all_forms()
842
+	{
843
+		// allow inputs and stuff to hook in their JS and stuff here
844
+		do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
845
+		EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
846
+		$email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
847
+			? EE_Registry::instance()->CFG->registration->email_validation_level
848
+			: 'wp_default';
849
+		EE_Form_Section_Proper::$_js_localization['email_validation_level']   = $email_validation_level;
850
+		wp_enqueue_script('ee_form_section_validation');
851
+		wp_localize_script(
852
+			'ee_form_section_validation',
853
+			'ee_form_section_vars',
854
+			EE_Form_Section_Proper::$_js_localization
855
+		);
856
+	}
857
+
858
+
859
+	/**
860
+	 * ensure_scripts_localized
861
+	 *
862
+	 * @throws EE_Error
863
+	 */
864
+	public function ensure_scripts_localized()
865
+	{
866
+		if (! EE_Form_Section_Proper::$_scripts_localized) {
867
+			$this->_enqueue_and_localize_form_js();
868
+		}
869
+	}
870
+
871
+
872
+	/**
873
+	 * Gets the hard-coded validation error messages to be used in the JS. The convention
874
+	 * is that the key here should be the same as the custom validation rule put in the JS file
875
+	 *
876
+	 * @return array keys are custom validation rules, and values are internationalized strings
877
+	 */
878
+	private static function _get_localized_error_messages()
879
+	{
880
+		return array(
881
+			'validUrl' => wp_strip_all_tags(__('This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg', 'event_espresso')),
882
+			'regex'    => wp_strip_all_tags(__('Please check your input', 'event_espresso'))
883
+		);
884
+	}
885
+
886
+
887
+	/**
888
+	 * @return array
889
+	 */
890
+	public static function js_localization()
891
+	{
892
+		return self::$_js_localization;
893
+	}
894
+
895
+
896
+	/**
897
+	 * @return void
898
+	 */
899
+	public static function reset_js_localization()
900
+	{
901
+		self::$_js_localization = array();
902
+	}
903
+
904
+
905
+	/**
906
+	 * Gets the JS to put inside the jquery validation rules for subsection of this form section.
907
+	 * See parent function for more...
908
+	 *
909
+	 * @return array
910
+	 * @throws EE_Error
911
+	 */
912
+	public function get_jquery_validation_rules()
913
+	{
914
+		$jquery_validation_rules = array();
915
+		foreach ($this->get_validatable_subsections() as $subsection) {
916
+			$jquery_validation_rules = array_merge(
917
+				$jquery_validation_rules,
918
+				$subsection->get_jquery_validation_rules()
919
+			);
920
+		}
921
+		return $jquery_validation_rules;
922
+	}
923
+
924
+
925
+	/**
926
+	 * Sanitizes all the data and sets the sanitized value of each field
927
+	 *
928
+	 * @param array $req_data
929
+	 * @return void
930
+	 * @throws EE_Error
931
+	 */
932
+	protected function _normalize($req_data)
933
+	{
934
+		$this->_received_submission = true;
935
+		$this->_validation_errors   = array();
936
+		foreach ($this->get_validatable_subsections() as $subsection) {
937
+			try {
938
+				$subsection->_normalize($req_data);
939
+			} catch (EE_Validation_Error $e) {
940
+				$subsection->add_validation_error($e);
941
+			}
942
+		}
943
+	}
944
+
945
+
946
+	/**
947
+	 * Performs validation on this form section and its subsections.
948
+	 * For each subsection,
949
+	 * calls _validate_{subsection_name} on THIS form (if the function exists)
950
+	 * and passes it the subsection, then calls _validate on that subsection.
951
+	 * If you need to perform validation on the form as a whole (considering multiple)
952
+	 * you would be best to override this _validate method,
953
+	 * calling parent::_validate() first.
954
+	 *
955
+	 * @throws EE_Error
956
+	 */
957
+	protected function _validate()
958
+	{
959
+		// reset the cache of whether this form is valid or not- we're re-validating it now
960
+		$this->is_valid = null;
961
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
962
+			if (method_exists($this, '_validate_' . $subsection_name)) {
963
+				call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
964
+			}
965
+			$subsection->_validate();
966
+		}
967
+	}
968
+
969
+
970
+	/**
971
+	 * Gets all the validated inputs for the form section
972
+	 *
973
+	 * @return array
974
+	 * @throws EE_Error
975
+	 */
976
+	public function valid_data()
977
+	{
978
+		$inputs = array();
979
+		foreach ($this->subsections() as $subsection_name => $subsection) {
980
+			if ($subsection instanceof EE_Form_Section_Proper) {
981
+				$inputs[ $subsection_name ] = $subsection->valid_data();
982
+			} elseif ($subsection instanceof EE_Form_Input_Base) {
983
+				$inputs[ $subsection_name ] = $subsection->normalized_value();
984
+			}
985
+		}
986
+		return $inputs;
987
+	}
988
+
989
+
990
+	/**
991
+	 * Gets all the inputs on this form section
992
+	 *
993
+	 * @return EE_Form_Input_Base[]
994
+	 * @throws EE_Error
995
+	 */
996
+	public function inputs()
997
+	{
998
+		$inputs = array();
999
+		foreach ($this->subsections() as $subsection_name => $subsection) {
1000
+			if ($subsection instanceof EE_Form_Input_Base) {
1001
+				$inputs[ $subsection_name ] = $subsection;
1002
+			}
1003
+		}
1004
+		return $inputs;
1005
+	}
1006
+
1007
+
1008
+	/**
1009
+	 * Gets all the subsections which are a proper form
1010
+	 *
1011
+	 * @return EE_Form_Section_Proper[]
1012
+	 * @throws EE_Error
1013
+	 */
1014
+	public function subforms()
1015
+	{
1016
+		$form_sections = array();
1017
+		foreach ($this->subsections() as $name => $obj) {
1018
+			if ($obj instanceof EE_Form_Section_Proper) {
1019
+				$form_sections[ $name ] = $obj;
1020
+			}
1021
+		}
1022
+		return $form_sections;
1023
+	}
1024
+
1025
+
1026
+	/**
1027
+	 * Gets all the subsections (inputs, proper subsections, or html-only sections).
1028
+	 * Consider using inputs() or subforms()
1029
+	 * if you only want form inputs or proper form sections.
1030
+	 *
1031
+	 * @param boolean $require_construction_to_be_finalized most client code should
1032
+	 *                                                      leave this as TRUE so that the inputs will be properly
1033
+	 *                                                      configured. However, some client code may be ok with
1034
+	 *                                                      construction finalize being called later
1035
+	 *                                                      (realizing that the subsections' html names might not be
1036
+	 *                                                      set yet, etc.)
1037
+	 * @return EE_Form_Section_Proper[]
1038
+	 * @throws EE_Error
1039
+	 */
1040
+	public function subsections($require_construction_to_be_finalized = true)
1041
+	{
1042
+		if ($require_construction_to_be_finalized) {
1043
+			$this->ensure_construct_finalized_called();
1044
+		}
1045
+		return $this->_subsections;
1046
+	}
1047
+
1048
+
1049
+	/**
1050
+	 * Returns whether this form has any subforms or inputs
1051
+	 * @return bool
1052
+	 */
1053
+	public function hasSubsections()
1054
+	{
1055
+		return ! empty($this->_subsections);
1056
+	}
1057
+
1058
+
1059
+	/**
1060
+	 * Returns a simple array where keys are input names, and values are their normalized
1061
+	 * values. (Similar to calling get_input_value on inputs)
1062
+	 *
1063
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1064
+	 *                                        or just this forms' direct children inputs
1065
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1066
+	 *                                        or allow multidimensional array
1067
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array
1068
+	 *                                        with array keys being input names
1069
+	 *                                        (regardless of whether they are from a subsection or not),
1070
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1071
+	 *                                        where keys are always subsection names and values are either
1072
+	 *                                        the input's normalized value, or an array like the top-level array
1073
+	 * @throws EE_Error
1074
+	 */
1075
+	public function input_values($include_subform_inputs = false, $flatten = false)
1076
+	{
1077
+		return $this->_input_values(false, $include_subform_inputs, $flatten);
1078
+	}
1079
+
1080
+
1081
+	/**
1082
+	 * Similar to EE_Form_Section_Proper::input_values(), except this returns the 'display_value'
1083
+	 * of each input. On some inputs (especially radio boxes or checkboxes), the value stored
1084
+	 * is not necessarily the value we want to display to users. This creates an array
1085
+	 * where keys are the input names, and values are their display values
1086
+	 *
1087
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1088
+	 *                                        or just this forms' direct children inputs
1089
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1090
+	 *                                        or allow multidimensional array
1091
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array
1092
+	 *                                        with array keys being input names
1093
+	 *                                        (regardless of whether they are from a subsection or not),
1094
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1095
+	 *                                        where keys are always subsection names and values are either
1096
+	 *                                        the input's normalized value, or an array like the top-level array
1097
+	 * @throws EE_Error
1098
+	 */
1099
+	public function input_pretty_values($include_subform_inputs = false, $flatten = false)
1100
+	{
1101
+		return $this->_input_values(true, $include_subform_inputs, $flatten);
1102
+	}
1103
+
1104
+
1105
+	/**
1106
+	 * Gets the input values from the form
1107
+	 *
1108
+	 * @param boolean $pretty                 Whether to retrieve the pretty value,
1109
+	 *                                        or just the normalized value
1110
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1111
+	 *                                        or just this forms' direct children inputs
1112
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1113
+	 *                                        or allow multidimensional array
1114
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array with array keys being
1115
+	 *                                        input names (regardless of whether they are from a subsection or not),
1116
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1117
+	 *                                        where keys are always subsection names and values are either
1118
+	 *                                        the input's normalized value, or an array like the top-level array
1119
+	 * @throws EE_Error
1120
+	 */
1121
+	public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false)
1122
+	{
1123
+		$input_values = array();
1124
+		foreach ($this->subsections() as $subsection_name => $subsection) {
1125
+			if ($subsection instanceof EE_Form_Input_Base) {
1126
+				$input_values[ $subsection_name ] = $pretty
1127
+					? $subsection->pretty_value()
1128
+					: $subsection->normalized_value();
1129
+			} elseif ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
1130
+				$subform_input_values = $subsection->_input_values(
1131
+					$pretty,
1132
+					$include_subform_inputs,
1133
+					$flatten
1134
+				);
1135
+				if ($flatten) {
1136
+					$input_values = array_merge($input_values, $subform_input_values);
1137
+				} else {
1138
+					$input_values[ $subsection_name ] = $subform_input_values;
1139
+				}
1140
+			}
1141
+		}
1142
+		return $input_values;
1143
+	}
1144
+
1145
+
1146
+	/**
1147
+	 * Gets the originally submitted input values from the form
1148
+	 *
1149
+	 * @param boolean $include_subforms  Whether to include inputs from subforms,
1150
+	 *                                   or just this forms' direct children inputs
1151
+	 * @return array                     if $flatten is TRUE it will always be a 1-dimensional array
1152
+	 *                                   with array keys being input names
1153
+	 *                                   (regardless of whether they are from a subsection or not),
1154
+	 *                                   and if $flatten is FALSE it can be a multidimensional array
1155
+	 *                                   where keys are always subsection names and values are either
1156
+	 *                                   the input's normalized value, or an array like the top-level array
1157
+	 * @throws EE_Error
1158
+	 */
1159
+	public function submitted_values($include_subforms = false)
1160
+	{
1161
+		$submitted_values = array();
1162
+		foreach ($this->subsections() as $subsection) {
1163
+			if ($subsection instanceof EE_Form_Input_Base) {
1164
+				// is this input part of an array of inputs?
1165
+				if (strpos($subsection->html_name(), '[') !== false) {
1166
+					$full_input_name  = EEH_Array::convert_array_values_to_keys(
1167
+						explode(
1168
+							'[',
1169
+							str_replace(']', '', $subsection->html_name())
1170
+						),
1171
+						$subsection->raw_value()
1172
+					);
1173
+					$submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1174
+				} else {
1175
+					$submitted_values[ $subsection->html_name() ] = $subsection->raw_value();
1176
+				}
1177
+			} elseif ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1178
+				$subform_input_values = $subsection->submitted_values($include_subforms);
1179
+				$submitted_values     = array_replace_recursive($submitted_values, $subform_input_values);
1180
+			}
1181
+		}
1182
+		return $submitted_values;
1183
+	}
1184
+
1185
+
1186
+	/**
1187
+	 * Indicates whether or not this form has received a submission yet
1188
+	 * (ie, had receive_form_submission called on it yet)
1189
+	 *
1190
+	 * @return boolean
1191
+	 * @throws EE_Error
1192
+	 */
1193
+	public function has_received_submission()
1194
+	{
1195
+		$this->ensure_construct_finalized_called();
1196
+		return $this->_received_submission;
1197
+	}
1198
+
1199
+
1200
+	/**
1201
+	 * Equivalent to passing 'exclude' in the constructor's options array.
1202
+	 * Removes the listed inputs from the form
1203
+	 *
1204
+	 * @param array $inputs_to_exclude values are the input names
1205
+	 * @return void
1206
+	 */
1207
+	public function exclude(array $inputs_to_exclude = array())
1208
+	{
1209
+		foreach ($inputs_to_exclude as $input_to_exclude_name) {
1210
+			unset($this->_subsections[ $input_to_exclude_name ]);
1211
+		}
1212
+	}
1213
+
1214
+
1215
+	/**
1216
+	 * Changes these inputs' display strategy to be EE_Hidden_Display_Strategy.
1217
+	 * @param array $inputs_to_hide
1218
+	 * @throws EE_Error
1219
+	 */
1220
+	public function hide(array $inputs_to_hide = array())
1221
+	{
1222
+		foreach ($inputs_to_hide as $input_to_hide) {
1223
+			$input = $this->get_input($input_to_hide);
1224
+			$input->set_display_strategy(new EE_Hidden_Display_Strategy());
1225
+		}
1226
+	}
1227
+
1228
+
1229
+	/**
1230
+	 * add_subsections
1231
+	 * Adds the listed subsections to the form section.
1232
+	 * If $subsection_name_to_target is provided,
1233
+	 * then new subsections are added before or after that subsection,
1234
+	 * otherwise to the start or end of the entire subsections array.
1235
+	 *
1236
+	 * @param EE_Form_Section_Base[] $new_subsections           array of new form subsections
1237
+	 *                                                          where keys are their names
1238
+	 * @param string                 $subsection_name_to_target an existing for section that $new_subsections
1239
+	 *                                                          should be added before or after
1240
+	 *                                                          IF $subsection_name_to_target is null,
1241
+	 *                                                          then $new_subsections will be added to
1242
+	 *                                                          the beginning or end of the entire subsections array
1243
+	 * @param boolean                $add_before                whether to add $new_subsections, before or after
1244
+	 *                                                          $subsection_name_to_target,
1245
+	 *                                                          or if $subsection_name_to_target is null,
1246
+	 *                                                          before or after entire subsections array
1247
+	 * @return void
1248
+	 * @throws EE_Error
1249
+	 */
1250
+	public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1251
+	{
1252
+		foreach ($new_subsections as $subsection_name => $subsection) {
1253
+			if (! $subsection instanceof EE_Form_Section_Base) {
1254
+				EE_Error::add_error(
1255
+					sprintf(
1256
+						esc_html__(
1257
+							"Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.",
1258
+							'event_espresso'
1259
+						),
1260
+						get_class($subsection),
1261
+						$subsection_name,
1262
+						$this->name()
1263
+					)
1264
+				);
1265
+				unset($new_subsections[ $subsection_name ]);
1266
+			}
1267
+		}
1268
+		$this->_subsections = EEH_Array::insert_into_array(
1269
+			$this->_subsections,
1270
+			$new_subsections,
1271
+			$subsection_name_to_target,
1272
+			$add_before
1273
+		);
1274
+		if ($this->_construction_finalized) {
1275
+			foreach ($this->_subsections as $name => $subsection) {
1276
+				$subsection->_construct_finalize($this, $name);
1277
+			}
1278
+		}
1279
+	}
1280
+
1281
+
1282
+	/**
1283
+	 * @param string $subsection_name
1284
+	 * @param bool   $recursive
1285
+	 * @return bool
1286
+	 */
1287
+	public function has_subsection($subsection_name, $recursive = false)
1288
+	{
1289
+		foreach ($this->_subsections as $name => $subsection) {
1290
+			if (
1291
+				$name === $subsection_name
1292
+				|| (
1293
+					$recursive
1294
+					&& $subsection instanceof EE_Form_Section_Proper
1295
+					&& $subsection->has_subsection($subsection_name, $recursive)
1296
+				)
1297
+			) {
1298
+				return true;
1299
+			}
1300
+		}
1301
+		return false;
1302
+	}
1303
+
1304
+
1305
+
1306
+	/**
1307
+	 * Just gets all validatable subsections to clean their sensitive data
1308
+	 *
1309
+	 * @throws EE_Error
1310
+	 */
1311
+	public function clean_sensitive_data()
1312
+	{
1313
+		foreach ($this->get_validatable_subsections() as $subsection) {
1314
+			$subsection->clean_sensitive_data();
1315
+		}
1316
+	}
1317
+
1318
+
1319
+	/**
1320
+	 * Sets the submission error message (aka validation error message for this form section and all sub-sections)
1321
+	 * @param string                           $form_submission_error_message
1322
+	 * @param EE_Form_Section_Validatable $form_section unused
1323
+	 * @throws EE_Error
1324
+	 */
1325
+	public function set_submission_error_message(
1326
+		$form_submission_error_message = ''
1327
+	) {
1328
+		$this->_form_submission_error_message = ! empty($form_submission_error_message)
1329
+			? $form_submission_error_message
1330
+			: $this->getAllValidationErrorsString();
1331
+	}
1332
+
1333
+
1334
+	/**
1335
+	 * Returns the cached error message. A default value is set for this during _validate(),
1336
+	 * (called during receive_form_submission) but it can be explicitly set using
1337
+	 * set_submission_error_message
1338
+	 *
1339
+	 * @return string
1340
+	 */
1341
+	public function submission_error_message()
1342
+	{
1343
+		return $this->_form_submission_error_message;
1344
+	}
1345
+
1346
+
1347
+	/**
1348
+	 * Sets a message to display if the data submitted to the form was valid.
1349
+	 * @param string $form_submission_success_message
1350
+	 */
1351
+	public function set_submission_success_message($form_submission_success_message = '')
1352
+	{
1353
+		$this->_form_submission_success_message = ! empty($form_submission_success_message)
1354
+			? $form_submission_success_message
1355
+			: esc_html__('Form submitted successfully', 'event_espresso');
1356
+	}
1357
+
1358
+
1359
+	/**
1360
+	 * Gets a message appropriate for display when the form is correctly submitted
1361
+	 * @return string
1362
+	 */
1363
+	public function submission_success_message()
1364
+	{
1365
+		return $this->_form_submission_success_message;
1366
+	}
1367
+
1368
+
1369
+	/**
1370
+	 * Returns the prefix that should be used on child of this form section for
1371
+	 * their html names. If this form section itself has a parent, prepends ITS
1372
+	 * prefix onto this form section's prefix. Used primarily by
1373
+	 * EE_Form_Input_Base::_set_default_html_name_if_empty
1374
+	 *
1375
+	 * @return string
1376
+	 * @throws EE_Error
1377
+	 */
1378
+	public function html_name_prefix()
1379
+	{
1380
+		if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1381
+			return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1382
+		}
1383
+		return $this->name();
1384
+	}
1385
+
1386
+
1387
+	/**
1388
+	 * Gets the name, but first checks _construct_finalize has been called. If not,
1389
+	 * calls it (assumes there is no parent and that we want the name to be whatever
1390
+	 * was set, which is probably nothing, or the classname)
1391
+	 *
1392
+	 * @return string
1393
+	 * @throws EE_Error
1394
+	 */
1395
+	public function name()
1396
+	{
1397
+		$this->ensure_construct_finalized_called();
1398
+		return parent::name();
1399
+	}
1400
+
1401
+
1402
+	/**
1403
+	 * @return EE_Form_Section_Proper
1404
+	 * @throws EE_Error
1405
+	 */
1406
+	public function parent_section()
1407
+	{
1408
+		$this->ensure_construct_finalized_called();
1409
+		return parent::parent_section();
1410
+	}
1411
+
1412
+
1413
+	/**
1414
+	 * make sure construction finalized was called, otherwise children might not be ready
1415
+	 *
1416
+	 * @return void
1417
+	 * @throws EE_Error
1418
+	 */
1419
+	public function ensure_construct_finalized_called()
1420
+	{
1421
+		if (! $this->_construction_finalized) {
1422
+			$this->_construct_finalize($this->_parent_section, $this->_name);
1423
+		}
1424
+	}
1425
+
1426
+
1427
+	/**
1428
+	 * Checks if any of this form section's inputs, or any of its children's inputs,
1429
+	 * are in teh form data. If any are found, returns true. Else false
1430
+	 *
1431
+	 * @param array $req_data
1432
+	 * @return boolean
1433
+	 * @throws EE_Error
1434
+	 */
1435
+	public function form_data_present_in($req_data = null)
1436
+	{
1437
+		$req_data = $this->getCachedRequest($req_data);
1438
+		foreach ($this->subsections() as $subsection) {
1439
+			if ($subsection instanceof EE_Form_Input_Base) {
1440
+				if ($subsection->form_data_present_in($req_data)) {
1441
+					return true;
1442
+				}
1443
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
1444
+				if ($subsection->form_data_present_in($req_data)) {
1445
+					return true;
1446
+				}
1447
+			}
1448
+		}
1449
+		return false;
1450
+	}
1451
+
1452
+
1453
+	/**
1454
+	 * Gets validation errors for this form section and subsections
1455
+	 * Similar to EE_Form_Section_Validatable::get_validation_errors() except this
1456
+	 * gets the validation errors for ALL subsection
1457
+	 *
1458
+	 * @return EE_Validation_Error[]
1459
+	 * @throws EE_Error
1460
+	 */
1461
+	public function get_validation_errors_accumulated()
1462
+	{
1463
+		$validation_errors = $this->get_validation_errors();
1464
+		foreach ($this->get_validatable_subsections() as $subsection) {
1465
+			if ($subsection instanceof EE_Form_Section_Proper) {
1466
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1467
+			} else {
1468
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors();
1469
+			}
1470
+			if ($validation_errors_on_this_subsection) {
1471
+				$validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1472
+			}
1473
+		}
1474
+		return $validation_errors;
1475
+	}
1476
+
1477
+	/**
1478
+	 * Fetch validation errors from children and grandchildren and puts them in a single string.
1479
+	 * This traverses the form section tree to generate this, but you probably want to instead use
1480
+	 * get_form_submission_error_message() which is usually this message cached (or a custom validation error message)
1481
+	 *
1482
+	 * @return string
1483
+	 * @since 4.9.59.p
1484
+	 */
1485
+	protected function getAllValidationErrorsString()
1486
+	{
1487
+		$submission_error_messages = array();
1488
+		// bad, bad, bad registrant
1489
+		foreach ($this->get_validation_errors_accumulated() as $validation_error) {
1490
+			if ($validation_error instanceof EE_Validation_Error) {
1491
+				$form_section = $validation_error->get_form_section();
1492
+				if ($form_section instanceof EE_Form_Input_Base) {
1493
+					$label = $validation_error->get_form_section()->html_label_text();
1494
+				} elseif ($form_section instanceof EE_Form_Section_Validatable) {
1495
+					$label = $validation_error->get_form_section()->name();
1496
+				} else {
1497
+					$label = esc_html__('Unknown', 'event_espresso');
1498
+				}
1499
+				$submission_error_messages[] = sprintf(
1500
+					esc_html__('%s : %s', 'event_espresso'),
1501
+					$label,
1502
+					$validation_error->getMessage()
1503
+				);
1504
+			}
1505
+		}
1506
+		return implode('<br>', $submission_error_messages);
1507
+	}
1508
+
1509
+
1510
+	/**
1511
+	 * This isn't just the name of an input, it's a path pointing to an input. The
1512
+	 * path is similar to a folder path: slash (/) means to descend into a subsection,
1513
+	 * dot-dot-slash (../) means to ascend into the parent section.
1514
+	 * After a series of slashes and dot-dot-slashes, there should be the name of an input,
1515
+	 * which will be returned.
1516
+	 * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
1517
+	 * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
1518
+	 * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
1519
+	 * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
1520
+	 * Etc
1521
+	 *
1522
+	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1523
+	 * @return EE_Form_Section_Base
1524
+	 * @throws EE_Error
1525
+	 */
1526
+	public function find_section_from_path($form_section_path)
1527
+	{
1528
+		// check if we can find the input from purely going straight up the tree
1529
+		$input = parent::find_section_from_path($form_section_path);
1530
+		if ($input instanceof EE_Form_Section_Base) {
1531
+			return $input;
1532
+		}
1533
+		$next_slash_pos = strpos($form_section_path, '/');
1534
+		if ($next_slash_pos !== false) {
1535
+			$child_section_name = substr($form_section_path, 0, $next_slash_pos);
1536
+			$subpath            = substr($form_section_path, $next_slash_pos + 1);
1537
+		} else {
1538
+			$child_section_name = $form_section_path;
1539
+			$subpath            = '';
1540
+		}
1541
+		$child_section = $this->get_subsection($child_section_name);
1542
+		if ($child_section instanceof EE_Form_Section_Base) {
1543
+			return $child_section->find_section_from_path($subpath);
1544
+		}
1545
+		return null;
1546
+	}
1547 1547
 }
Please login to merge, or discard this patch.
modules/venue_single/EED_Venue_Single.module.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function venue_location($content)
164 164
     {
165
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
165
+        return $content.EEH_Template::locate_template('content-espresso_venues-location.php');
166 166
     }
167 167
 
168 168
 
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
         // get some style
178 178
         if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) {
179 179
             // first check theme folder
180
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
180
+            if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) {
181 181
                 wp_register_style(
182 182
                     $this->theme,
183
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
183
+                    get_stylesheet_directory_uri().$this->theme.'/style.css',
184 184
                     array('dashicons', 'espresso_default')
185 185
                 );
186
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
186
+            } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) {
187 187
                 wp_register_style(
188 188
                     $this->theme,
189
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
189
+                    EE_TEMPLATES_URL.$this->theme.'/style.css',
190 190
                     array('dashicons', 'espresso_default')
191 191
                 );
192 192
             }
Please login to merge, or discard this patch.
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -29,173 +29,173 @@
 block discarded – undo
29 29
 class EED_Venue_Single extends EED_Module
30 30
 {
31 31
 
32
-    /**
33
-     * @return EED_Venue_Single
34
-     */
35
-    public static function instance()
36
-    {
37
-        return parent::get_instance(__CLASS__);
38
-    }
39
-
40
-
41
-    /**
42
-     * set_hooks - for hooking into EE Core, other modules, etc
43
-     *
44
-     * @return void
45
-     * @throws InvalidArgumentException
46
-     * @throws InvalidDataTypeException
47
-     * @throws InvalidInterfaceException
48
-     */
49
-    public static function set_hooks()
50
-    {
51
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
52
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
53
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
54
-        );
55
-        $custom_post_types = $custom_post_type_definitions->getDefinitions();
56
-        EE_Config::register_route(
57
-            $custom_post_types['espresso_venues']['singular_slug'],
58
-            'Venue_Single',
59
-            'run'
60
-        );
61
-    }
62
-
63
-    /**
64
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
-     *
66
-     * @access    public
67
-     * @return    void
68
-     */
69
-    public static function set_hooks_admin()
70
-    {
71
-    }
72
-
73
-
74
-    /**
75
-     * run - initial module setup
76
-     *
77
-     * @access    public
78
-     * @param \WP $WP
79
-     */
80
-    public function run($WP)
81
-    {
82
-        // check what template is loaded
83
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
84
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
85
-    }
86
-
87
-
88
-    /**
89
-     * template_include
90
-     *
91
-     * @access public
92
-     * @param  string $template
93
-     * @return string
94
-     */
95
-    public function template_include($template)
96
-    {
97
-        // not a custom template?
98
-        if (
99
-            EE_Registry::instance()
100
-                       ->load_core('Front_Controller', array(), false, true)
101
-                       ->get_selected_template() != 'single-espresso_venues.php'
102
-        ) {
103
-            EEH_Template::load_espresso_theme_functions();
104
-            // then add extra event data via hooks
105
-            add_filter('the_title', array($this, 'the_title'), 100, 1);
106
-            add_filter('the_content', array($this, 'venue_details'), 100);
107
-            // don't display entry meta because the existing theme will take car of that
108
-            add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
109
-        }
110
-        return $template;
111
-    }
112
-
113
-
114
-    /**
115
-     * the_title
116
-     *
117
-     * @access public
118
-     * @param  string $title
119
-     * @return string
120
-     */
121
-    public function the_title($title = '')
122
-    {
123
-        return $title;
124
-    }
125
-
126
-
127
-    /**
128
-     *    venue_details
129
-     *
130
-     * @access public
131
-     * @param  string $content
132
-     * @return string
133
-     */
134
-    public function venue_details($content)
135
-    {
136
-        global $post;
137
-        if (
138
-            $post->post_type == 'espresso_venues'
139
-            && ! post_password_required()
140
-        ) {
141
-            // since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
142
-            // it uses the_content() for displaying the $post->post_content
143
-            // so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
144
-            // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
145
-            remove_filter('the_content', array($this, 'venue_details'), 100);
146
-            // add filters we want
147
-            add_filter('the_content', array($this, 'venue_location'), 110);
148
-            // now load our template
149
-            $template = EEH_Template::locate_template('content-espresso_venues-details.php');
150
-            // remove other filters we added so they won't get applied to the next post
151
-            remove_filter('the_content', array($this, 'venue_location'), 110);
152
-        }
153
-        // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
154
-        return ! empty($template) ? $template : $content;
155
-    }
156
-
157
-
158
-    /**
159
-     * venue_location
160
-     *
161
-     * @access public
162
-     * @param  string $content
163
-     * @return string
164
-     */
165
-    public function venue_location($content)
166
-    {
167
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
168
-    }
169
-
170
-
171
-    /**
172
-     *    wp_enqueue_scripts
173
-     *
174
-     * @access public
175
-     * @return void
176
-     */
177
-    public function wp_enqueue_scripts()
178
-    {
179
-        // get some style
180
-        if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) {
181
-            // first check theme folder
182
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
183
-                wp_register_style(
184
-                    $this->theme,
185
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
186
-                    array('dashicons', 'espresso_default')
187
-                );
188
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
189
-                wp_register_style(
190
-                    $this->theme,
191
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
192
-                    array('dashicons', 'espresso_default')
193
-                );
194
-            }
195
-            wp_enqueue_style($this->theme);
196
-            if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
197
-                add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
198
-            }
199
-        }
200
-    }
32
+	/**
33
+	 * @return EED_Venue_Single
34
+	 */
35
+	public static function instance()
36
+	{
37
+		return parent::get_instance(__CLASS__);
38
+	}
39
+
40
+
41
+	/**
42
+	 * set_hooks - for hooking into EE Core, other modules, etc
43
+	 *
44
+	 * @return void
45
+	 * @throws InvalidArgumentException
46
+	 * @throws InvalidDataTypeException
47
+	 * @throws InvalidInterfaceException
48
+	 */
49
+	public static function set_hooks()
50
+	{
51
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
52
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
53
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
54
+		);
55
+		$custom_post_types = $custom_post_type_definitions->getDefinitions();
56
+		EE_Config::register_route(
57
+			$custom_post_types['espresso_venues']['singular_slug'],
58
+			'Venue_Single',
59
+			'run'
60
+		);
61
+	}
62
+
63
+	/**
64
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
+	 *
66
+	 * @access    public
67
+	 * @return    void
68
+	 */
69
+	public static function set_hooks_admin()
70
+	{
71
+	}
72
+
73
+
74
+	/**
75
+	 * run - initial module setup
76
+	 *
77
+	 * @access    public
78
+	 * @param \WP $WP
79
+	 */
80
+	public function run($WP)
81
+	{
82
+		// check what template is loaded
83
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
84
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
85
+	}
86
+
87
+
88
+	/**
89
+	 * template_include
90
+	 *
91
+	 * @access public
92
+	 * @param  string $template
93
+	 * @return string
94
+	 */
95
+	public function template_include($template)
96
+	{
97
+		// not a custom template?
98
+		if (
99
+			EE_Registry::instance()
100
+					   ->load_core('Front_Controller', array(), false, true)
101
+					   ->get_selected_template() != 'single-espresso_venues.php'
102
+		) {
103
+			EEH_Template::load_espresso_theme_functions();
104
+			// then add extra event data via hooks
105
+			add_filter('the_title', array($this, 'the_title'), 100, 1);
106
+			add_filter('the_content', array($this, 'venue_details'), 100);
107
+			// don't display entry meta because the existing theme will take car of that
108
+			add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
109
+		}
110
+		return $template;
111
+	}
112
+
113
+
114
+	/**
115
+	 * the_title
116
+	 *
117
+	 * @access public
118
+	 * @param  string $title
119
+	 * @return string
120
+	 */
121
+	public function the_title($title = '')
122
+	{
123
+		return $title;
124
+	}
125
+
126
+
127
+	/**
128
+	 *    venue_details
129
+	 *
130
+	 * @access public
131
+	 * @param  string $content
132
+	 * @return string
133
+	 */
134
+	public function venue_details($content)
135
+	{
136
+		global $post;
137
+		if (
138
+			$post->post_type == 'espresso_venues'
139
+			&& ! post_password_required()
140
+		) {
141
+			// since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
142
+			// it uses the_content() for displaying the $post->post_content
143
+			// so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
144
+			// we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
145
+			remove_filter('the_content', array($this, 'venue_details'), 100);
146
+			// add filters we want
147
+			add_filter('the_content', array($this, 'venue_location'), 110);
148
+			// now load our template
149
+			$template = EEH_Template::locate_template('content-espresso_venues-details.php');
150
+			// remove other filters we added so they won't get applied to the next post
151
+			remove_filter('the_content', array($this, 'venue_location'), 110);
152
+		}
153
+		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
154
+		return ! empty($template) ? $template : $content;
155
+	}
156
+
157
+
158
+	/**
159
+	 * venue_location
160
+	 *
161
+	 * @access public
162
+	 * @param  string $content
163
+	 * @return string
164
+	 */
165
+	public function venue_location($content)
166
+	{
167
+		return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
168
+	}
169
+
170
+
171
+	/**
172
+	 *    wp_enqueue_scripts
173
+	 *
174
+	 * @access public
175
+	 * @return void
176
+	 */
177
+	public function wp_enqueue_scripts()
178
+	{
179
+		// get some style
180
+		if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) {
181
+			// first check theme folder
182
+			if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
183
+				wp_register_style(
184
+					$this->theme,
185
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
186
+					array('dashicons', 'espresso_default')
187
+				);
188
+			} elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
189
+				wp_register_style(
190
+					$this->theme,
191
+					EE_TEMPLATES_URL . $this->theme . '/style.css',
192
+					array('dashicons', 'espresso_default')
193
+				);
194
+			}
195
+			wp_enqueue_style($this->theme);
196
+			if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
197
+				add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
198
+			}
199
+		}
200
+	}
201 201
 }
Please login to merge, or discard this patch.
modules/venues_archive/EED_Venues_Archive.module.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function venue_location($content)
172 172
     {
173
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
173
+        return $content.EEH_Template::locate_template('content-espresso_venues-location.php');
174 174
     }
175 175
 
176 176
 
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
         // get some style
186 186
         if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) {
187 187
             // first check theme folder
188
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
188
+            if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) {
189 189
                 wp_register_style(
190 190
                     $this->theme,
191
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
191
+                    get_stylesheet_directory_uri().$this->theme.'/style.css',
192 192
                     array('dashicons', 'espresso_default')
193 193
                 );
194
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
194
+            } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) {
195 195
                 wp_register_style(
196 196
                     $this->theme,
197
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
197
+                    EE_TEMPLATES_URL.$this->theme.'/style.css',
198 198
                     array('dashicons', 'espresso_default')
199 199
                 );
200 200
             }
Please login to merge, or discard this patch.
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -29,178 +29,178 @@
 block discarded – undo
29 29
 class EED_Venues_Archive extends EED_Module
30 30
 {
31 31
 
32
-    /**
33
-     * @return EED_Venues_Archive
34
-     */
35
-    public static function instance()
36
-    {
37
-        return parent::get_instance(__CLASS__);
38
-    }
39
-
40
-
41
-    /**
42
-     * set_hooks - for hooking into EE Core, other modules, etc
43
-     *
44
-     * @return void
45
-     * @throws InvalidArgumentException
46
-     * @throws InvalidDataTypeException
47
-     * @throws InvalidInterfaceException
48
-     */
49
-    public static function set_hooks()
50
-    {
51
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
52
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
53
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
54
-        );
55
-        $custom_post_types = $custom_post_type_definitions->getDefinitions();
56
-        EE_Config::register_route(
57
-            $custom_post_types['espresso_venues']['plural_slug'],
58
-            'Venues_Archive',
59
-            'run'
60
-        );
61
-    }
62
-
63
-    /**
64
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
-     *
66
-     * @access    public
67
-     * @return    void
68
-     */
69
-    public static function set_hooks_admin()
70
-    {
71
-    }
72
-
73
-
74
-    /**
75
-     * run - initial module setup
76
-     *
77
-     * @access    public
78
-     * @param \WP $WP
79
-     */
80
-    public function run($WP)
81
-    {
82
-        // check what template is loaded
83
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
84
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
85
-    }
86
-
87
-
88
-    /**
89
-     * template_include
90
-     *
91
-     * @access public
92
-     * @param  string $template
93
-     * @return string
94
-     */
95
-    public function template_include($template)
96
-    {
97
-        // not a custom template?
98
-        if (
99
-            EE_Registry::instance()->load_core('Front_Controller', array(), false, true)
100
-                                   ->get_selected_template() != 'archive-espresso_venues.php'
101
-        ) {
102
-            EEH_Template::load_espresso_theme_functions();
103
-            // then add extra event data via hooks
104
-            add_filter('the_title', array($this, 'the_title'), 100, 1);
105
-            // don't know if theme uses the_excerpt
106
-            add_filter('the_excerpt', array($this, 'venue_details'), 100);
107
-            // or the_content
108
-            add_filter('the_content', array($this, 'venue_details'), 100);
109
-            // don't display entry meta because the existing theme will take care of that
110
-            add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
111
-        }
112
-        return $template;
113
-    }
114
-
115
-
116
-    /**
117
-     * the_title
118
-     *
119
-     * @access public
120
-     * @param  string $title
121
-     * @return string
122
-     */
123
-    public function the_title($title = '')
124
-    {
125
-        return $title;
126
-    }
127
-
128
-
129
-    /**
130
-     *    venue_details
131
-     *
132
-     * @access public
133
-     * @param  string $content
134
-     * @return string
135
-     */
136
-    public function venue_details($content)
137
-    {
138
-        global $post;
139
-        if (
140
-            $post->post_type == 'espresso_venues'
141
-            && ! post_password_required()
142
-        ) {
143
-            // since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
144
-            // it uses the_content() for displaying the $post->post_content
145
-            // so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
146
-            // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
147
-            remove_filter('the_excerpt', array($this, 'venue_details'), 100);
148
-            remove_filter('the_content', array($this, 'venue_details'), 100);
149
-            // add filters we want
150
-            add_filter('the_content', array($this, 'venue_location'), 110);
151
-            add_filter('the_excerpt', array($this, 'venue_location'), 110);
152
-            // now load our template
153
-            $template = EEH_Template::locate_template('content-espresso_venues-details.php');
154
-            // now add our filter back in, plus some others
155
-            add_filter('the_excerpt', array($this, 'venue_details'), 100);
156
-            add_filter('the_content', array($this, 'venue_details'), 100);
157
-            // remove other filters we added so they won't get applied to the next post
158
-            remove_filter('the_content', array($this, 'venue_location'), 110);
159
-            remove_filter('the_excerpt', array($this, 'venue_location'), 110);
160
-            // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
161
-        }
162
-        return ! empty($template) ? $template : $content;
163
-    }
164
-
165
-
166
-    /**
167
-     * venue_location
168
-     *
169
-     * @access public
170
-     * @param  string $content
171
-     * @return string
172
-     */
173
-    public function venue_location($content)
174
-    {
175
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
176
-    }
177
-
178
-
179
-    /**
180
-     *    wp_enqueue_scripts
181
-     *
182
-     * @access    public
183
-     * @return    void
184
-     */
185
-    public function wp_enqueue_scripts()
186
-    {
187
-        // get some style
188
-        if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) {
189
-            // first check theme folder
190
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
191
-                wp_register_style(
192
-                    $this->theme,
193
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
194
-                    array('dashicons', 'espresso_default')
195
-                );
196
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
197
-                wp_register_style(
198
-                    $this->theme,
199
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
200
-                    array('dashicons', 'espresso_default')
201
-                );
202
-            }
203
-            wp_enqueue_style($this->theme);
204
-        }
205
-    }
32
+	/**
33
+	 * @return EED_Venues_Archive
34
+	 */
35
+	public static function instance()
36
+	{
37
+		return parent::get_instance(__CLASS__);
38
+	}
39
+
40
+
41
+	/**
42
+	 * set_hooks - for hooking into EE Core, other modules, etc
43
+	 *
44
+	 * @return void
45
+	 * @throws InvalidArgumentException
46
+	 * @throws InvalidDataTypeException
47
+	 * @throws InvalidInterfaceException
48
+	 */
49
+	public static function set_hooks()
50
+	{
51
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
52
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
53
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
54
+		);
55
+		$custom_post_types = $custom_post_type_definitions->getDefinitions();
56
+		EE_Config::register_route(
57
+			$custom_post_types['espresso_venues']['plural_slug'],
58
+			'Venues_Archive',
59
+			'run'
60
+		);
61
+	}
62
+
63
+	/**
64
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
+	 *
66
+	 * @access    public
67
+	 * @return    void
68
+	 */
69
+	public static function set_hooks_admin()
70
+	{
71
+	}
72
+
73
+
74
+	/**
75
+	 * run - initial module setup
76
+	 *
77
+	 * @access    public
78
+	 * @param \WP $WP
79
+	 */
80
+	public function run($WP)
81
+	{
82
+		// check what template is loaded
83
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
84
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
85
+	}
86
+
87
+
88
+	/**
89
+	 * template_include
90
+	 *
91
+	 * @access public
92
+	 * @param  string $template
93
+	 * @return string
94
+	 */
95
+	public function template_include($template)
96
+	{
97
+		// not a custom template?
98
+		if (
99
+			EE_Registry::instance()->load_core('Front_Controller', array(), false, true)
100
+								   ->get_selected_template() != 'archive-espresso_venues.php'
101
+		) {
102
+			EEH_Template::load_espresso_theme_functions();
103
+			// then add extra event data via hooks
104
+			add_filter('the_title', array($this, 'the_title'), 100, 1);
105
+			// don't know if theme uses the_excerpt
106
+			add_filter('the_excerpt', array($this, 'venue_details'), 100);
107
+			// or the_content
108
+			add_filter('the_content', array($this, 'venue_details'), 100);
109
+			// don't display entry meta because the existing theme will take care of that
110
+			add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
111
+		}
112
+		return $template;
113
+	}
114
+
115
+
116
+	/**
117
+	 * the_title
118
+	 *
119
+	 * @access public
120
+	 * @param  string $title
121
+	 * @return string
122
+	 */
123
+	public function the_title($title = '')
124
+	{
125
+		return $title;
126
+	}
127
+
128
+
129
+	/**
130
+	 *    venue_details
131
+	 *
132
+	 * @access public
133
+	 * @param  string $content
134
+	 * @return string
135
+	 */
136
+	public function venue_details($content)
137
+	{
138
+		global $post;
139
+		if (
140
+			$post->post_type == 'espresso_venues'
141
+			&& ! post_password_required()
142
+		) {
143
+			// since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
144
+			// it uses the_content() for displaying the $post->post_content
145
+			// so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
146
+			// we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
147
+			remove_filter('the_excerpt', array($this, 'venue_details'), 100);
148
+			remove_filter('the_content', array($this, 'venue_details'), 100);
149
+			// add filters we want
150
+			add_filter('the_content', array($this, 'venue_location'), 110);
151
+			add_filter('the_excerpt', array($this, 'venue_location'), 110);
152
+			// now load our template
153
+			$template = EEH_Template::locate_template('content-espresso_venues-details.php');
154
+			// now add our filter back in, plus some others
155
+			add_filter('the_excerpt', array($this, 'venue_details'), 100);
156
+			add_filter('the_content', array($this, 'venue_details'), 100);
157
+			// remove other filters we added so they won't get applied to the next post
158
+			remove_filter('the_content', array($this, 'venue_location'), 110);
159
+			remove_filter('the_excerpt', array($this, 'venue_location'), 110);
160
+			// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
161
+		}
162
+		return ! empty($template) ? $template : $content;
163
+	}
164
+
165
+
166
+	/**
167
+	 * venue_location
168
+	 *
169
+	 * @access public
170
+	 * @param  string $content
171
+	 * @return string
172
+	 */
173
+	public function venue_location($content)
174
+	{
175
+		return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
176
+	}
177
+
178
+
179
+	/**
180
+	 *    wp_enqueue_scripts
181
+	 *
182
+	 * @access    public
183
+	 * @return    void
184
+	 */
185
+	public function wp_enqueue_scripts()
186
+	{
187
+		// get some style
188
+		if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) {
189
+			// first check theme folder
190
+			if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
191
+				wp_register_style(
192
+					$this->theme,
193
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
194
+					array('dashicons', 'espresso_default')
195
+				);
196
+			} elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
197
+				wp_register_style(
198
+					$this->theme,
199
+					EE_TEMPLATES_URL . $this->theme . '/style.css',
200
+					array('dashicons', 'espresso_default')
201
+				);
202
+			}
203
+			wp_enqueue_style($this->theme);
204
+		}
205
+	}
206 206
 }
Please login to merge, or discard this patch.
line_item_display/EE_Default_Line_Item_Display_Strategy.strategy.php 2 patches
Indentation   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -1,225 +1,225 @@
 block discarded – undo
1 1
 <?php
2 2
  /**
3
- *
4
- * Class EE_Default_Line_Item_Display_Strategy
5
- *
6
- * Description
7
- *
8
- * @package         Event Espresso
9
- * @subpackage    core
10
- * @author              Brent Christensen
11
- *
12
- *
13
- */
3
+  *
4
+  * Class EE_Default_Line_Item_Display_Strategy
5
+  *
6
+  * Description
7
+  *
8
+  * @package         Event Espresso
9
+  * @subpackage    core
10
+  * @author              Brent Christensen
11
+  *
12
+  *
13
+  */
14 14
 
15 15
 class EE_Default_Line_Item_Display_Strategy implements EEI_Line_Item_Display
16 16
 {
17 17
 
18
-    /**
19
-     * total amount of tax to apply
20
-     * @type float $_tax_rate
21
-     */
22
-    private $_tax_rate = 0;
23
-
24
-    /**
25
-     * total amount including tax we can bill for at this time
26
-     * @type float $_grand_total
27
-     */
28
-    private $_grand_total = 0.00;
29
-
30
-    /**
31
-     * total number of items being billed for
32
-     * @type int $_total_items
33
-     */
34
-    private $_total_items = 0;
35
-
36
-
37
-
38
-    /**
39
-     * @return float
40
-     */
41
-    public function grand_total()
42
-    {
43
-        return $this->_grand_total;
44
-    }
45
-
46
-
47
-
48
-    /**
49
-     * @return int
50
-     */
51
-    public function total_items()
52
-    {
53
-        return $this->_total_items;
54
-    }
55
-
56
-
57
-
58
-    /**
59
-     * @param EE_Line_Item $line_item
60
-     * @param array        $options
61
-     * @return mixed
62
-     */
63
-    public function display_line_item(EE_Line_Item $line_item, $options = array())
64
-    {
65
-
66
-        $html = '';
67
-        // set some default options and merge with incoming
68
-        $default_options = array(
69
-            'show_desc' => true,  //    TRUE        FALSE
70
-            'odd' => false
71
-        );
72
-        $options = array_merge($default_options, (array) $options);
73
-
74
-        switch ($line_item->type()) {
75
-            case EEM_Line_Item::type_line_item:
76
-                // item row
77
-                $html .= $this->_item_row($line_item, $options);
78
-                // got any kids?
79
-                foreach ($line_item->children() as $child_line_item) {
80
-                    $this->display_line_item($child_line_item, $options);
81
-                }
82
-                break;
83
-
84
-            case EEM_Line_Item::type_sub_line_item:
85
-                $html .= $this->_sub_item_row($line_item, $options);
86
-                break;
87
-
88
-            case EEM_Line_Item::type_sub_total:
89
-                break;
90
-
91
-            case EEM_Line_Item::type_tax:
92
-                $this->_tax_rate += $line_item->percent();
93
-                break;
94
-
95
-            case EEM_Line_Item::type_tax_sub_total:
96
-                foreach ($line_item->children() as $child_line_item) {
97
-                    if ($child_line_item->type() == EEM_Line_Item::type_tax) {
98
-                        // recursively feed children back into this method
99
-                        $this->display_line_item($child_line_item, $options);
100
-                    }
101
-                }
102
-                break;
103
-
104
-            case EEM_Line_Item::type_total:
105
-                // get all child line items
106
-                $children = $line_item->children();
107
-                if ($options['set_tax_rate'] === true) {
108
-                    // loop thru tax child line items just to determine tax rate
109
-                    foreach ($children as $child_line_item) {
110
-                        if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) {
111
-                            // recursively feed children back into this method
112
-                            $this->display_line_item($child_line_item, $options);
113
-                        }
114
-                    }
115
-                } else {
116
-                    // now loop thru all non-tax child line items
117
-                    foreach ($children as $child_line_item) {
118
-                        if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) {
119
-                            // recursively feed children back into this method
120
-                            $html .= $this->display_line_item($child_line_item, $options);
121
-                        }
122
-                    }
123
-                }
124
-                break;
125
-        }
126
-
127
-        return $html;
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     *  _total_row
134
-     *
135
-     * @param EE_Line_Item $line_item
136
-     * @param array        $options
137
-     * @return mixed
138
-     */
139
-    private function _item_row(EE_Line_Item $line_item, $options = array())
140
-    {
141
-        // start of row
142
-        $row_class = $options['odd'] ? 'item odd' : 'item';
143
-        $html = EEH_HTML::tr('', '', $row_class);
144
-        // name && desc
145
-        $name_and_desc = apply_filters(
146
-            'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__name',
147
-            $line_item->name(),
148
-            $line_item
149
-        );
150
-        $name_and_desc .= apply_filters(
151
-            'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc',
152
-            ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ),
153
-            $line_item,
154
-            $options
155
-        );
156
-        if ($line_item->is_taxable()) {
157
-            $ticket_price_includes_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes
158
-                ? esc_html__('* price includes taxes', 'event_espresso')
159
-                : esc_html__('* price does not include taxes', 'event_espresso');
160
-            $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
161
-                  . $ticket_price_includes_taxes
162
-                  . '</span>';
163
-        }
164
-
165
-        // name td
166
-        $html .= EEH_HTML::td($name_and_desc, '', 'item_l');
167
-        // quantity td
168
-        $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
169
-        $tax_rate = $line_item->is_taxable()
170
-                    && EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes
171
-            ? 1 + ( $this->_tax_rate / 100 )
172
-            : 1;
173
-        // price td
174
-        $unit_price = apply_filters(
175
-            'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__unit_price',
176
-            EEH_Template::format_currency($line_item->unit_price() * $tax_rate, false, false),
177
-            $line_item,
178
-            $tax_rate
179
-        );
180
-        $html .= EEH_HTML::td($unit_price, '', 'item_c jst-rght');
181
-        // total td
182
-        $total = apply_filters(
183
-            'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__total',
184
-            EEH_Template::format_currency($line_item->unit_price() * $line_item->quantity() * $tax_rate, false, false),
185
-            $line_item,
186
-            $tax_rate
187
-        );
188
-        $html .= EEH_HTML::td($total, '', 'item_r jst-rght');
189
-        // end of row
190
-        $html .= EEH_HTML::trx();
191
-
192
-        return $html;
193
-    }
194
-
195
-
196
-
197
-    /**
198
-     *  _sub_item_row
199
-     *
200
-     * @param EE_Line_Item $line_item
201
-     * @param array        $options
202
-     * @return mixed
203
-     */
204
-    private function _sub_item_row(EE_Line_Item $line_item, $options = array())
205
-    {
206
-        // start of row
207
-        $html = EEH_HTML::tr('', 'item sub-item-row');
208
-        // name && desc
209
-        $name_and_desc = $line_item->name();
210
-        $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '';
211
-        // name td
212
-        $html .= EEH_HTML::td(/*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item');
213
-        // discount/surcharge td
214
-        if ($line_item->is_percent()) {
215
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c');
216
-        } else {
217
-            $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
218
-        }
219
-        // total td
220
-        $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght');
221
-        // end of row
222
-        $html .= EEH_HTML::trx();
223
-        return $html;
224
-    }
18
+	/**
19
+	 * total amount of tax to apply
20
+	 * @type float $_tax_rate
21
+	 */
22
+	private $_tax_rate = 0;
23
+
24
+	/**
25
+	 * total amount including tax we can bill for at this time
26
+	 * @type float $_grand_total
27
+	 */
28
+	private $_grand_total = 0.00;
29
+
30
+	/**
31
+	 * total number of items being billed for
32
+	 * @type int $_total_items
33
+	 */
34
+	private $_total_items = 0;
35
+
36
+
37
+
38
+	/**
39
+	 * @return float
40
+	 */
41
+	public function grand_total()
42
+	{
43
+		return $this->_grand_total;
44
+	}
45
+
46
+
47
+
48
+	/**
49
+	 * @return int
50
+	 */
51
+	public function total_items()
52
+	{
53
+		return $this->_total_items;
54
+	}
55
+
56
+
57
+
58
+	/**
59
+	 * @param EE_Line_Item $line_item
60
+	 * @param array        $options
61
+	 * @return mixed
62
+	 */
63
+	public function display_line_item(EE_Line_Item $line_item, $options = array())
64
+	{
65
+
66
+		$html = '';
67
+		// set some default options and merge with incoming
68
+		$default_options = array(
69
+			'show_desc' => true,  //    TRUE        FALSE
70
+			'odd' => false
71
+		);
72
+		$options = array_merge($default_options, (array) $options);
73
+
74
+		switch ($line_item->type()) {
75
+			case EEM_Line_Item::type_line_item:
76
+				// item row
77
+				$html .= $this->_item_row($line_item, $options);
78
+				// got any kids?
79
+				foreach ($line_item->children() as $child_line_item) {
80
+					$this->display_line_item($child_line_item, $options);
81
+				}
82
+				break;
83
+
84
+			case EEM_Line_Item::type_sub_line_item:
85
+				$html .= $this->_sub_item_row($line_item, $options);
86
+				break;
87
+
88
+			case EEM_Line_Item::type_sub_total:
89
+				break;
90
+
91
+			case EEM_Line_Item::type_tax:
92
+				$this->_tax_rate += $line_item->percent();
93
+				break;
94
+
95
+			case EEM_Line_Item::type_tax_sub_total:
96
+				foreach ($line_item->children() as $child_line_item) {
97
+					if ($child_line_item->type() == EEM_Line_Item::type_tax) {
98
+						// recursively feed children back into this method
99
+						$this->display_line_item($child_line_item, $options);
100
+					}
101
+				}
102
+				break;
103
+
104
+			case EEM_Line_Item::type_total:
105
+				// get all child line items
106
+				$children = $line_item->children();
107
+				if ($options['set_tax_rate'] === true) {
108
+					// loop thru tax child line items just to determine tax rate
109
+					foreach ($children as $child_line_item) {
110
+						if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) {
111
+							// recursively feed children back into this method
112
+							$this->display_line_item($child_line_item, $options);
113
+						}
114
+					}
115
+				} else {
116
+					// now loop thru all non-tax child line items
117
+					foreach ($children as $child_line_item) {
118
+						if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) {
119
+							// recursively feed children back into this method
120
+							$html .= $this->display_line_item($child_line_item, $options);
121
+						}
122
+					}
123
+				}
124
+				break;
125
+		}
126
+
127
+		return $html;
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 *  _total_row
134
+	 *
135
+	 * @param EE_Line_Item $line_item
136
+	 * @param array        $options
137
+	 * @return mixed
138
+	 */
139
+	private function _item_row(EE_Line_Item $line_item, $options = array())
140
+	{
141
+		// start of row
142
+		$row_class = $options['odd'] ? 'item odd' : 'item';
143
+		$html = EEH_HTML::tr('', '', $row_class);
144
+		// name && desc
145
+		$name_and_desc = apply_filters(
146
+			'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__name',
147
+			$line_item->name(),
148
+			$line_item
149
+		);
150
+		$name_and_desc .= apply_filters(
151
+			'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc',
152
+			( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ),
153
+			$line_item,
154
+			$options
155
+		);
156
+		if ($line_item->is_taxable()) {
157
+			$ticket_price_includes_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes
158
+				? esc_html__('* price includes taxes', 'event_espresso')
159
+				: esc_html__('* price does not include taxes', 'event_espresso');
160
+			$name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
161
+				  . $ticket_price_includes_taxes
162
+				  . '</span>';
163
+		}
164
+
165
+		// name td
166
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l');
167
+		// quantity td
168
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
169
+		$tax_rate = $line_item->is_taxable()
170
+					&& EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes
171
+			? 1 + ( $this->_tax_rate / 100 )
172
+			: 1;
173
+		// price td
174
+		$unit_price = apply_filters(
175
+			'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__unit_price',
176
+			EEH_Template::format_currency($line_item->unit_price() * $tax_rate, false, false),
177
+			$line_item,
178
+			$tax_rate
179
+		);
180
+		$html .= EEH_HTML::td($unit_price, '', 'item_c jst-rght');
181
+		// total td
182
+		$total = apply_filters(
183
+			'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__total',
184
+			EEH_Template::format_currency($line_item->unit_price() * $line_item->quantity() * $tax_rate, false, false),
185
+			$line_item,
186
+			$tax_rate
187
+		);
188
+		$html .= EEH_HTML::td($total, '', 'item_r jst-rght');
189
+		// end of row
190
+		$html .= EEH_HTML::trx();
191
+
192
+		return $html;
193
+	}
194
+
195
+
196
+
197
+	/**
198
+	 *  _sub_item_row
199
+	 *
200
+	 * @param EE_Line_Item $line_item
201
+	 * @param array        $options
202
+	 * @return mixed
203
+	 */
204
+	private function _sub_item_row(EE_Line_Item $line_item, $options = array())
205
+	{
206
+		// start of row
207
+		$html = EEH_HTML::tr('', 'item sub-item-row');
208
+		// name && desc
209
+		$name_and_desc = $line_item->name();
210
+		$name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '';
211
+		// name td
212
+		$html .= EEH_HTML::td(/*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item');
213
+		// discount/surcharge td
214
+		if ($line_item->is_percent()) {
215
+			$html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c');
216
+		} else {
217
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
218
+		}
219
+		// total td
220
+		$html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght');
221
+		// end of row
222
+		$html .= EEH_HTML::trx();
223
+		return $html;
224
+	}
225 225
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $html = '';
67 67
         // set some default options and merge with incoming
68 68
         $default_options = array(
69
-            'show_desc' => true,  //    TRUE        FALSE
69
+            'show_desc' => true, //    TRUE        FALSE
70 70
             'odd' => false
71 71
         );
72 72
         $options = array_merge($default_options, (array) $options);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         );
150 150
         $name_and_desc .= apply_filters(
151 151
             'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc',
152
-            ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ),
152
+            ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''),
153 153
             $line_item,
154 154
             $options
155 155
         );
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
169 169
         $tax_rate = $line_item->is_taxable()
170 170
                     && EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes
171
-            ? 1 + ( $this->_tax_rate / 100 )
171
+            ? 1 + ($this->_tax_rate / 100)
172 172
             : 1;
173 173
         // price td
174 174
         $unit_price = apply_filters(
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
         $html = EEH_HTML::tr('', 'item sub-item-row');
208 208
         // name && desc
209 209
         $name_and_desc = $line_item->name();
210
-        $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '';
210
+        $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : '';
211 211
         // name td
212 212
         $html .= EEH_HTML::td(/*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item');
213 213
         // discount/surcharge td
214 214
         if ($line_item->is_percent()) {
215
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c');
215
+            $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c');
216 216
         } else {
217 217
             $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
218 218
         }
Please login to merge, or discard this patch.
core/domain/services/pue/StatsGatherer.php 2 patches
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -16,314 +16,314 @@
 block discarded – undo
16 16
 class StatsGatherer
17 17
 {
18 18
 
19
-    const COUNT_ALL_EVENTS = 'event';
20
-    const COUNT_ACTIVE_EVENTS = 'active_event';
21
-    const COUNT_DATETIMES = 'datetime';
22
-    const COUNT_TICKETS = 'ticket';
23
-    const COUNT_DATETIMES_SOLD = 'datetime_sold';
24
-    const COUNT_TICKETS_FREE = 'free_ticket';
25
-    const COUNT_TICKETS_PAID = 'paid_ticket';
26
-    const COUNT_TICKETS_SOLD = 'ticket_sold';
27
-    const COUNT_REGISTRATIONS_APPROVED = 'registrations_approved';
28
-    const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved';
29
-    const COUNT_REGISTRATIONS_PENDING = 'registrations_pending';
30
-    const COUNT_REGISTRATIONS_INCOMPLETE = 'registrations_incomplete';
31
-    const COUNT_REGISTRATIONS_ALL = 'registrations_all';
32
-    const COUNT_REGISTRATIONS_CANCELLED = 'registrations_cancelled';
33
-    const COUNT_REGISTRATIONS_DECLINED = 'registrations_declined';
34
-    const SUM_TRANSACTIONS_COMPLETE_TOTAL = 'transactions_complete_total_sum';
35
-    const SUM_TRANSACTIONS_ALL_PAID = 'transactions_all_paid';
36
-    const INFO_SITE_CURRENCY = 'site_currency';
19
+	const COUNT_ALL_EVENTS = 'event';
20
+	const COUNT_ACTIVE_EVENTS = 'active_event';
21
+	const COUNT_DATETIMES = 'datetime';
22
+	const COUNT_TICKETS = 'ticket';
23
+	const COUNT_DATETIMES_SOLD = 'datetime_sold';
24
+	const COUNT_TICKETS_FREE = 'free_ticket';
25
+	const COUNT_TICKETS_PAID = 'paid_ticket';
26
+	const COUNT_TICKETS_SOLD = 'ticket_sold';
27
+	const COUNT_REGISTRATIONS_APPROVED = 'registrations_approved';
28
+	const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved';
29
+	const COUNT_REGISTRATIONS_PENDING = 'registrations_pending';
30
+	const COUNT_REGISTRATIONS_INCOMPLETE = 'registrations_incomplete';
31
+	const COUNT_REGISTRATIONS_ALL = 'registrations_all';
32
+	const COUNT_REGISTRATIONS_CANCELLED = 'registrations_cancelled';
33
+	const COUNT_REGISTRATIONS_DECLINED = 'registrations_declined';
34
+	const SUM_TRANSACTIONS_COMPLETE_TOTAL = 'transactions_complete_total_sum';
35
+	const SUM_TRANSACTIONS_ALL_PAID = 'transactions_all_paid';
36
+	const INFO_SITE_CURRENCY = 'site_currency';
37 37
 
38 38
 
39
-    /**
40
-     * @var EEM_Payment_Method
41
-     */
42
-    private $payment_method_model;
39
+	/**
40
+	 * @var EEM_Payment_Method
41
+	 */
42
+	private $payment_method_model;
43 43
 
44 44
 
45
-    /**
46
-     * @var EEM_Event
47
-     */
48
-    private $event_model;
45
+	/**
46
+	 * @var EEM_Event
47
+	 */
48
+	private $event_model;
49 49
 
50
-    /**
51
-     * @var EEM_Datetime
52
-     */
53
-    private $datetime_model;
50
+	/**
51
+	 * @var EEM_Datetime
52
+	 */
53
+	private $datetime_model;
54 54
 
55 55
 
56
-    /**
57
-     * @var EEM_Ticket
58
-     */
59
-    private $ticket_model;
56
+	/**
57
+	 * @var EEM_Ticket
58
+	 */
59
+	private $ticket_model;
60 60
 
61 61
 
62
-    /**
63
-     * @var EEM_Registration
64
-     */
65
-    private $registration_model;
62
+	/**
63
+	 * @var EEM_Registration
64
+	 */
65
+	private $registration_model;
66 66
 
67 67
 
68
-    /**
69
-     * @var EEM_Transaction
70
-     */
71
-    private $transaction_model;
68
+	/**
69
+	 * @var EEM_Transaction
70
+	 */
71
+	private $transaction_model;
72 72
 
73 73
 
74
-    /**
75
-     * @var EE_Config
76
-     */
77
-    private $config;
74
+	/**
75
+	 * @var EE_Config
76
+	 */
77
+	private $config;
78 78
 
79 79
 
80
-    /**
81
-     * StatsGatherer constructor.
82
-     *
83
-     * @param EEM_Payment_Method $payment_method_model
84
-     * @param EEM_Event          $event_model
85
-     * @param EEM_Datetime       $datetime_model
86
-     * @param EEM_Ticket         $ticket_model
87
-     * @param EEM_Registration   $registration_model
88
-     * @param EEM_Transaction    $transaction_model
89
-     * @param EE_Config          $config
90
-     */
91
-    public function __construct(
92
-        EEM_Payment_Method $payment_method_model,
93
-        EEM_Event $event_model,
94
-        EEM_Datetime $datetime_model,
95
-        EEM_Ticket $ticket_model,
96
-        EEM_Registration $registration_model,
97
-        EEM_Transaction $transaction_model,
98
-        EE_Config $config
99
-    ) {
100
-        $this->payment_method_model = $payment_method_model;
101
-        $this->event_model = $event_model;
102
-        $this->datetime_model = $datetime_model;
103
-        $this->ticket_model = $ticket_model;
104
-        $this->registration_model = $registration_model;
105
-        $this->transaction_model = $transaction_model;
106
-        $this->config = $config;
107
-    }
80
+	/**
81
+	 * StatsGatherer constructor.
82
+	 *
83
+	 * @param EEM_Payment_Method $payment_method_model
84
+	 * @param EEM_Event          $event_model
85
+	 * @param EEM_Datetime       $datetime_model
86
+	 * @param EEM_Ticket         $ticket_model
87
+	 * @param EEM_Registration   $registration_model
88
+	 * @param EEM_Transaction    $transaction_model
89
+	 * @param EE_Config          $config
90
+	 */
91
+	public function __construct(
92
+		EEM_Payment_Method $payment_method_model,
93
+		EEM_Event $event_model,
94
+		EEM_Datetime $datetime_model,
95
+		EEM_Ticket $ticket_model,
96
+		EEM_Registration $registration_model,
97
+		EEM_Transaction $transaction_model,
98
+		EE_Config $config
99
+	) {
100
+		$this->payment_method_model = $payment_method_model;
101
+		$this->event_model = $event_model;
102
+		$this->datetime_model = $datetime_model;
103
+		$this->ticket_model = $ticket_model;
104
+		$this->registration_model = $registration_model;
105
+		$this->transaction_model = $transaction_model;
106
+		$this->config = $config;
107
+	}
108 108
 
109 109
 
110
-    /**
111
-     * Return the stats array for PUE UXIP stats.
112
-     *
113
-     * @return array
114
-     */
115
-    public function stats()
116
-    {
117
-        global $wp_version;
118
-        $stats = $this->paymentMethodStats();
119
-        // a-ok so let's setup our stats.
120
-        $stats = array_merge($stats, array(
121
-            'is_multisite'                    => is_multisite() && is_main_site(),
122
-            'active_theme'                    => $this->getActiveThemeStat(),
123
-            'ee4_all_events_count'            => $this->getCountFor(self::COUNT_ALL_EVENTS),
124
-            'ee4_active_events_count'         => $this->getCountFor(self::COUNT_ACTIVE_EVENTS),
125
-            'all_dtts_count'                  => $this->getCountFor(self::COUNT_DATETIMES),
126
-            'dtt_sold'                        => $this->getCountFor(self::COUNT_DATETIMES_SOLD),
127
-            'all_tkt_count'                   => $this->getCountFor(self::COUNT_TICKETS),
128
-            'free_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_FREE),
129
-            'paid_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_PAID),
130
-            'tkt_sold'                        => $this->getCountFor(self::COUNT_TICKETS_SOLD),
131
-            'approve_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED),
132
-            'pending_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING),
133
-            'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED),
134
-            'incomplete_registration_count'   => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE),
135
-            'cancelled_registration_count'    => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED),
136
-            'declined_registration_count'     => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED),
137
-            'all_registration_count'          => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL),
138
-            'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL),
139
-            'all_transaction_paid_sum'        => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID),
140
-            self::INFO_SITE_CURRENCY          => $this->config->currency instanceof EE_Currency_Config
141
-                ? $this->config->currency->code
142
-                : 'unknown',
143
-            'phpversion'                      => implode(
144
-                '.',
145
-                array(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION)
146
-            ),
147
-            'wpversion'                       => $wp_version,
148
-            'active_addons'                   => $this->getActiveAddons(),
149
-        ));
150
-        // remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
151
-        return array_filter($stats, function ($value) {
152
-            return $value !== null;
153
-        });
154
-    }
110
+	/**
111
+	 * Return the stats array for PUE UXIP stats.
112
+	 *
113
+	 * @return array
114
+	 */
115
+	public function stats()
116
+	{
117
+		global $wp_version;
118
+		$stats = $this->paymentMethodStats();
119
+		// a-ok so let's setup our stats.
120
+		$stats = array_merge($stats, array(
121
+			'is_multisite'                    => is_multisite() && is_main_site(),
122
+			'active_theme'                    => $this->getActiveThemeStat(),
123
+			'ee4_all_events_count'            => $this->getCountFor(self::COUNT_ALL_EVENTS),
124
+			'ee4_active_events_count'         => $this->getCountFor(self::COUNT_ACTIVE_EVENTS),
125
+			'all_dtts_count'                  => $this->getCountFor(self::COUNT_DATETIMES),
126
+			'dtt_sold'                        => $this->getCountFor(self::COUNT_DATETIMES_SOLD),
127
+			'all_tkt_count'                   => $this->getCountFor(self::COUNT_TICKETS),
128
+			'free_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_FREE),
129
+			'paid_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_PAID),
130
+			'tkt_sold'                        => $this->getCountFor(self::COUNT_TICKETS_SOLD),
131
+			'approve_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED),
132
+			'pending_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING),
133
+			'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED),
134
+			'incomplete_registration_count'   => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE),
135
+			'cancelled_registration_count'    => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED),
136
+			'declined_registration_count'     => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED),
137
+			'all_registration_count'          => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL),
138
+			'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL),
139
+			'all_transaction_paid_sum'        => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID),
140
+			self::INFO_SITE_CURRENCY          => $this->config->currency instanceof EE_Currency_Config
141
+				? $this->config->currency->code
142
+				: 'unknown',
143
+			'phpversion'                      => implode(
144
+				'.',
145
+				array(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION)
146
+			),
147
+			'wpversion'                       => $wp_version,
148
+			'active_addons'                   => $this->getActiveAddons(),
149
+		));
150
+		// remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
151
+		return array_filter($stats, function ($value) {
152
+			return $value !== null;
153
+		});
154
+	}
155 155
 
156
-    /**
157
-     * @param string $which enum (@see constants prefixed with COUNT)
158
-     * @return int|null
159
-     */
160
-    private function getCountFor($which)
161
-    {
162
-        try {
163
-            switch ($which) {
164
-                case self::COUNT_ALL_EVENTS:
165
-                    $count = $this->event_model->count();
166
-                    break;
167
-                case self::COUNT_TICKETS:
168
-                    $count = $this->ticket_model->count();
169
-                    break;
170
-                case self::COUNT_DATETIMES:
171
-                    $count = $this->datetime_model->count();
172
-                    break;
173
-                case self::COUNT_ACTIVE_EVENTS:
174
-                    $count = $this->event_model->get_active_events(array(), true);
175
-                    break;
176
-                case self::COUNT_DATETIMES_SOLD:
177
-                    $count = $this->datetime_model->sum(array(), 'DTT_sold');
178
-                    break;
179
-                case self::COUNT_TICKETS_FREE:
180
-                    $count = $this->ticket_model->count(array(
181
-                        array(
182
-                            'TKT_price' => 0,
183
-                        ),
184
-                    ));
185
-                    break;
186
-                case self::COUNT_TICKETS_PAID:
187
-                    $count = $this->ticket_model->count(array(
188
-                        array(
189
-                            'TKT_price' => array('>', 0),
190
-                        ),
191
-                    ));
192
-                    break;
193
-                case self::COUNT_TICKETS_SOLD:
194
-                    $count = $this->ticket_model->sum(array(), 'TKT_sold');
195
-                    break;
196
-                case self::COUNT_REGISTRATIONS_ALL:
197
-                    $count = $this->registration_model->count();
198
-                    break;
199
-                case self::COUNT_REGISTRATIONS_CANCELLED:
200
-                    $count = $this->registration_model->count(
201
-                        array(
202
-                            array(
203
-                                'STS_ID' => EEM_Registration::status_id_cancelled,
204
-                            ),
205
-                        )
206
-                    );
207
-                    break;
208
-                case self::COUNT_REGISTRATIONS_INCOMPLETE:
209
-                    $count = $this->registration_model->count(
210
-                        array(
211
-                            array(
212
-                                'STS_ID' => EEM_Registration::status_id_incomplete,
213
-                            ),
214
-                        )
215
-                    );
216
-                    break;
217
-                case self::COUNT_REGISTRATIONS_NOT_APPROVED:
218
-                    $count = $this->registration_model->count(
219
-                        array(
220
-                            array(
221
-                                'STS_ID' => EEM_Registration::status_id_not_approved,
222
-                            ),
223
-                        )
224
-                    );
225
-                    break;
226
-                case self::COUNT_REGISTRATIONS_DECLINED:
227
-                    $count = $this->registration_model->count(
228
-                        array(
229
-                            array(
230
-                                'STS_ID' => EEM_Registration::status_id_declined,
231
-                            ),
232
-                        )
233
-                    );
234
-                    break;
235
-                case self::COUNT_REGISTRATIONS_PENDING:
236
-                    $count = $this->registration_model->count(
237
-                        array(
238
-                            array(
239
-                                'STS_ID' => EEM_Registration::status_id_pending_payment,
240
-                            ),
241
-                        )
242
-                    );
243
-                    break;
244
-                case self::COUNT_REGISTRATIONS_APPROVED:
245
-                    $count = $this->registration_model->count(
246
-                        array(
247
-                            array(
248
-                                'STS_ID' => EEM_Registration::status_id_approved,
249
-                            ),
250
-                        )
251
-                    );
252
-                    break;
253
-                case self::SUM_TRANSACTIONS_COMPLETE_TOTAL:
254
-                    $count = $this->transaction_model->sum(
255
-                        array(
256
-                            array(
257
-                                'STS_ID' => EEM_Transaction::complete_status_code,
258
-                            ),
259
-                        ),
260
-                        'TXN_total'
261
-                    );
262
-                    break;
263
-                case self::SUM_TRANSACTIONS_ALL_PAID:
264
-                    $count = $this->transaction_model->sum(
265
-                        array(),
266
-                        'TXN_paid'
267
-                    );
268
-                    break;
269
-                default:
270
-                    $count = null;
271
-                    break;
272
-            }
273
-        } catch (Exception $e) {
274
-            $count = null;
275
-        }
276
-        return $count;
277
-    }
156
+	/**
157
+	 * @param string $which enum (@see constants prefixed with COUNT)
158
+	 * @return int|null
159
+	 */
160
+	private function getCountFor($which)
161
+	{
162
+		try {
163
+			switch ($which) {
164
+				case self::COUNT_ALL_EVENTS:
165
+					$count = $this->event_model->count();
166
+					break;
167
+				case self::COUNT_TICKETS:
168
+					$count = $this->ticket_model->count();
169
+					break;
170
+				case self::COUNT_DATETIMES:
171
+					$count = $this->datetime_model->count();
172
+					break;
173
+				case self::COUNT_ACTIVE_EVENTS:
174
+					$count = $this->event_model->get_active_events(array(), true);
175
+					break;
176
+				case self::COUNT_DATETIMES_SOLD:
177
+					$count = $this->datetime_model->sum(array(), 'DTT_sold');
178
+					break;
179
+				case self::COUNT_TICKETS_FREE:
180
+					$count = $this->ticket_model->count(array(
181
+						array(
182
+							'TKT_price' => 0,
183
+						),
184
+					));
185
+					break;
186
+				case self::COUNT_TICKETS_PAID:
187
+					$count = $this->ticket_model->count(array(
188
+						array(
189
+							'TKT_price' => array('>', 0),
190
+						),
191
+					));
192
+					break;
193
+				case self::COUNT_TICKETS_SOLD:
194
+					$count = $this->ticket_model->sum(array(), 'TKT_sold');
195
+					break;
196
+				case self::COUNT_REGISTRATIONS_ALL:
197
+					$count = $this->registration_model->count();
198
+					break;
199
+				case self::COUNT_REGISTRATIONS_CANCELLED:
200
+					$count = $this->registration_model->count(
201
+						array(
202
+							array(
203
+								'STS_ID' => EEM_Registration::status_id_cancelled,
204
+							),
205
+						)
206
+					);
207
+					break;
208
+				case self::COUNT_REGISTRATIONS_INCOMPLETE:
209
+					$count = $this->registration_model->count(
210
+						array(
211
+							array(
212
+								'STS_ID' => EEM_Registration::status_id_incomplete,
213
+							),
214
+						)
215
+					);
216
+					break;
217
+				case self::COUNT_REGISTRATIONS_NOT_APPROVED:
218
+					$count = $this->registration_model->count(
219
+						array(
220
+							array(
221
+								'STS_ID' => EEM_Registration::status_id_not_approved,
222
+							),
223
+						)
224
+					);
225
+					break;
226
+				case self::COUNT_REGISTRATIONS_DECLINED:
227
+					$count = $this->registration_model->count(
228
+						array(
229
+							array(
230
+								'STS_ID' => EEM_Registration::status_id_declined,
231
+							),
232
+						)
233
+					);
234
+					break;
235
+				case self::COUNT_REGISTRATIONS_PENDING:
236
+					$count = $this->registration_model->count(
237
+						array(
238
+							array(
239
+								'STS_ID' => EEM_Registration::status_id_pending_payment,
240
+							),
241
+						)
242
+					);
243
+					break;
244
+				case self::COUNT_REGISTRATIONS_APPROVED:
245
+					$count = $this->registration_model->count(
246
+						array(
247
+							array(
248
+								'STS_ID' => EEM_Registration::status_id_approved,
249
+							),
250
+						)
251
+					);
252
+					break;
253
+				case self::SUM_TRANSACTIONS_COMPLETE_TOTAL:
254
+					$count = $this->transaction_model->sum(
255
+						array(
256
+							array(
257
+								'STS_ID' => EEM_Transaction::complete_status_code,
258
+							),
259
+						),
260
+						'TXN_total'
261
+					);
262
+					break;
263
+				case self::SUM_TRANSACTIONS_ALL_PAID:
264
+					$count = $this->transaction_model->sum(
265
+						array(),
266
+						'TXN_paid'
267
+					);
268
+					break;
269
+				default:
270
+					$count = null;
271
+					break;
272
+			}
273
+		} catch (Exception $e) {
274
+			$count = null;
275
+		}
276
+		return $count;
277
+	}
278 278
 
279
-    /**
280
-     * Return the active theme.
281
-     *
282
-     * @return false|string
283
-     */
284
-    private function getActiveThemeStat()
285
-    {
286
-        $theme = wp_get_theme();
287
-        return $theme->get('Name');
288
-    }
279
+	/**
280
+	 * Return the active theme.
281
+	 *
282
+	 * @return false|string
283
+	 */
284
+	private function getActiveThemeStat()
285
+	{
286
+		$theme = wp_get_theme();
287
+		return $theme->get('Name');
288
+	}
289 289
 
290
-    /**
291
-     * @return array
292
-     */
293
-    private function paymentMethodStats()
294
-    {
295
-        $payment_method_stats = array();
296
-        try {
297
-            $active_payment_methods = $this->payment_method_model->get_all_active(
298
-                null,
299
-                array('group_by' => 'PMD_type')
300
-            );
301
-            if ($active_payment_methods) {
302
-                foreach ($active_payment_methods as $payment_method) {
303
-                    $payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
304
-                }
305
-            }
306
-        } catch (Exception $e) {
307
-            // do nothing just prevents fatals.
308
-        }
309
-        return $payment_method_stats;
310
-    }
290
+	/**
291
+	 * @return array
292
+	 */
293
+	private function paymentMethodStats()
294
+	{
295
+		$payment_method_stats = array();
296
+		try {
297
+			$active_payment_methods = $this->payment_method_model->get_all_active(
298
+				null,
299
+				array('group_by' => 'PMD_type')
300
+			);
301
+			if ($active_payment_methods) {
302
+				foreach ($active_payment_methods as $payment_method) {
303
+					$payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
304
+				}
305
+			}
306
+		} catch (Exception $e) {
307
+			// do nothing just prevents fatals.
308
+		}
309
+		return $payment_method_stats;
310
+	}
311 311
 
312 312
 
313
-    /**
314
-     * Return a list of active EE add-ons and their versions.
315
-     *
316
-     * @return string
317
-     */
318
-    private function getActiveAddons()
319
-    {
320
-        $activeAddons = [];
321
-        $addOns = EE_Registry::instance()->addons;
322
-        if (! empty($addOns)) {
323
-            foreach ($addOns as $addon) {
324
-                $activeAddons[] = $addon->name() . '@' . $addon->version();
325
-            }
326
-        }
327
-        return implode(',', $activeAddons);
328
-    }
313
+	/**
314
+	 * Return a list of active EE add-ons and their versions.
315
+	 *
316
+	 * @return string
317
+	 */
318
+	private function getActiveAddons()
319
+	{
320
+		$activeAddons = [];
321
+		$addOns = EE_Registry::instance()->addons;
322
+		if (! empty($addOns)) {
323
+			foreach ($addOns as $addon) {
324
+				$activeAddons[] = $addon->name() . '@' . $addon->version();
325
+			}
326
+		}
327
+		return implode(',', $activeAddons);
328
+	}
329 329
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             'active_addons'                   => $this->getActiveAddons(),
149 149
         ));
150 150
         // remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
151
-        return array_filter($stats, function ($value) {
151
+        return array_filter($stats, function($value) {
152 152
             return $value !== null;
153 153
         });
154 154
     }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
             );
301 301
             if ($active_payment_methods) {
302 302
                 foreach ($active_payment_methods as $payment_method) {
303
-                    $payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
303
+                    $payment_method_stats[$payment_method->name().'_active_payment_method'] = 1;
304 304
                 }
305 305
             }
306 306
         } catch (Exception $e) {
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
     {
320 320
         $activeAddons = [];
321 321
         $addOns = EE_Registry::instance()->addons;
322
-        if (! empty($addOns)) {
322
+        if ( ! empty($addOns)) {
323 323
             foreach ($addOns as $addon) {
324
-                $activeAddons[] = $addon->name() . '@' . $addon->version();
324
+                $activeAddons[] = $addon->name().'@'.$addon->version();
325 325
             }
326 326
         }
327 327
         return implode(',', $activeAddons);
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_8_0.dms.php 2 patches
Indentation   +357 added lines, -357 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
 $stages = glob(EE_CORE . 'data_migration_scripts/4_8_0_stages/*');
18 18
 $class_to_filepath = array();
19 19
 foreach ($stages as $filepath) {
20
-    $matches = array();
21
-    preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22
-    $class_to_filepath[ $matches[1] ] = $filepath;
20
+	$matches = array();
21
+	preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22
+	$class_to_filepath[ $matches[1] ] = $filepath;
23 23
 }
24 24
 // give addons a chance to autoload their stages too
25 25
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath);
@@ -38,71 +38,71 @@  discard block
 block discarded – undo
38 38
 class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base
39 39
 {
40 40
 
41
-    /**
42
-     * return EE_DMS_Core_4_8_0
43
-     *
44
-     * @param TableManager  $table_manager
45
-     * @param TableAnalysis $table_analysis
46
-     */
47
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
48
-    {
49
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso");
50
-        $this->_priority = 10;
51
-        $this->_migration_stages = array(
52
-            new EE_DMS_4_8_0_pretax_totals(),
53
-            new EE_DMS_4_8_0_event_subtotals(),
54
-        );
55
-        parent::__construct($table_manager, $table_analysis);
56
-    }
41
+	/**
42
+	 * return EE_DMS_Core_4_8_0
43
+	 *
44
+	 * @param TableManager  $table_manager
45
+	 * @param TableAnalysis $table_analysis
46
+	 */
47
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
48
+	{
49
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso");
50
+		$this->_priority = 10;
51
+		$this->_migration_stages = array(
52
+			new EE_DMS_4_8_0_pretax_totals(),
53
+			new EE_DMS_4_8_0_event_subtotals(),
54
+		);
55
+		parent::__construct($table_manager, $table_analysis);
56
+	}
57 57
 
58 58
 
59 59
 
60
-    /**
61
-     * Because this is being done at basically the same time as the MER-ready branch
62
-     * of core, it's possible people might have installed MEr-ready branch first,
63
-     * and then this one, in which case we still want to perform this migration,
64
-     * even though the version might not have increased
65
-     *
66
-     * @param array $version_array
67
-     * @return bool
68
-     */
69
-    public function can_migrate_from_version($version_array)
70
-    {
71
-        $version_string = $version_array['Core'];
72
-        if (version_compare($version_string, '4.8.0.decaf', '<') && version_compare($version_string, '4.7.0.decaf', '>=')) {
60
+	/**
61
+	 * Because this is being done at basically the same time as the MER-ready branch
62
+	 * of core, it's possible people might have installed MEr-ready branch first,
63
+	 * and then this one, in which case we still want to perform this migration,
64
+	 * even though the version might not have increased
65
+	 *
66
+	 * @param array $version_array
67
+	 * @return bool
68
+	 */
69
+	public function can_migrate_from_version($version_array)
70
+	{
71
+		$version_string = $version_array['Core'];
72
+		if (version_compare($version_string, '4.8.0.decaf', '<') && version_compare($version_string, '4.7.0.decaf', '>=')) {
73 73
 //          echo "$version_string can be migrated from";
74
-            return true;
75
-        } elseif (! $version_string) {
74
+			return true;
75
+		} elseif (! $version_string) {
76 76
 //          echo "no version string provided: $version_string";
77
-            // no version string provided... this must be pre 4.3
78
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
79
-        } else {
77
+			// no version string provided... this must be pre 4.3
78
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
79
+		} else {
80 80
 //          echo "$version_string doesnt apply";
81
-            return false;
82
-        }
83
-    }
81
+			return false;
82
+		}
83
+	}
84 84
 
85 85
 
86 86
 
87
-    /**
88
-     * @return bool
89
-     */
90
-    public function schema_changes_before_migration()
91
-    {
92
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
93
-        $now_in_mysql = current_time('mysql', true);
94
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
95
-        $table_name = 'esp_answer';
96
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
87
+	/**
88
+	 * @return bool
89
+	 */
90
+	public function schema_changes_before_migration()
91
+	{
92
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
93
+		$now_in_mysql = current_time('mysql', true);
94
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
95
+		$table_name = 'esp_answer';
96
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
97 97
 					REG_ID int(10) unsigned NOT NULL,
98 98
 					QST_ID int(10) unsigned NOT NULL,
99 99
 					ANS_value text NOT NULL,
100 100
 					PRIMARY KEY  (ANS_ID),
101 101
 					KEY REG_ID (REG_ID),
102 102
 					KEY QST_ID (QST_ID)";
103
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
104
-        $table_name = 'esp_attendee_meta';
105
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
103
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
104
+		$table_name = 'esp_attendee_meta';
105
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
106 106
 						ATT_ID bigint(20) unsigned NOT NULL,
107 107
 						ATT_fname varchar(45) NOT NULL,
108 108
 						ATT_lname varchar(45) NOT	NULL,
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 							PRIMARY KEY  (ATTM_ID),
118 118
 								KEY ATT_ID (ATT_ID),
119 119
 								KEY ATT_email (ATT_email(191))";
120
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
121
-        $table_name = 'esp_country';
122
-        $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL,
120
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
121
+		$table_name = 'esp_country';
122
+		$sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL,
123 123
 					  CNT_ISO3 varchar(3) collate utf8_bin NOT NULL,
124 124
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
125 125
 					  CNT_name varchar(45) collate utf8_bin NOT NULL,
@@ -135,25 +135,25 @@  discard block
 block discarded – undo
135 135
 					  CNT_is_EU tinyint(1) DEFAULT '0',
136 136
 					  CNT_active tinyint(1) DEFAULT '0',
137 137
 					  PRIMARY KEY  (CNT_ISO)";
138
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
139
-        $table_name = 'esp_currency';
140
-        $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL,
138
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
139
+		$table_name = 'esp_currency';
140
+		$sql = "CUR_code varchar(6) collate utf8_bin NOT NULL,
141 141
 				CUR_single varchar(45) collate utf8_bin DEFAULT 'dollar',
142 142
 				CUR_plural varchar(45) collate utf8_bin DEFAULT 'dollars',
143 143
 				CUR_sign varchar(45) collate utf8_bin DEFAULT '$',
144 144
 				CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2',
145 145
 				CUR_active tinyint(1) DEFAULT '0',
146 146
 				PRIMARY KEY  (CUR_code)";
147
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
148
-        $table_name = 'esp_currency_payment_method';
149
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
147
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
148
+		$table_name = 'esp_currency_payment_method';
149
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
150 150
 				CUR_code varchar(6) collate utf8_bin NOT NULL,
151 151
 				PMD_ID int(11) NOT NULL,
152 152
 				PRIMARY KEY  (CPM_ID),
153 153
 				KEY PMD_ID (PMD_ID)";
154
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
155
-        $table_name = 'esp_datetime';
156
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
154
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
155
+		$table_name = 'esp_datetime';
156
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
157 157
 				  EVT_ID bigint(20) unsigned NOT NULL,
158 158
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
159 159
 				  DTT_description text NOT NULL,
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 						KEY DTT_EVT_start (DTT_EVT_start),
170 170
 						KEY EVT_ID (EVT_ID),
171 171
 						KEY DTT_is_primary (DTT_is_primary)";
172
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
173
-        $table_name = 'esp_event_meta';
174
-        $sql = "
172
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
173
+		$table_name = 'esp_event_meta';
174
+		$sql = "
175 175
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
176 176
 			EVT_ID bigint(20) unsigned NOT NULL,
177 177
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -187,34 +187,34 @@  discard block
 block discarded – undo
187 187
 			EVT_donations tinyint(1) NULL,
188 188
 			PRIMARY KEY  (EVTM_ID),
189 189
 			KEY EVT_ID (EVT_ID)";
190
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
191
-        $table_name = 'esp_event_question_group';
192
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
190
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
191
+		$table_name = 'esp_event_question_group';
192
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
193 193
 					EVT_ID bigint(20) unsigned NOT NULL,
194 194
 					QSG_ID int(10) unsigned NOT NULL,
195 195
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
196 196
 					PRIMARY KEY  (EQG_ID),
197 197
 					KEY EVT_ID (EVT_ID),
198 198
 					KEY QSG_ID (QSG_ID)";
199
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
200
-        $table_name = 'esp_event_venue';
201
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
199
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
200
+		$table_name = 'esp_event_venue';
201
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
202 202
 				EVT_ID bigint(20) unsigned NOT NULL,
203 203
 				VNU_ID bigint(20) unsigned NOT NULL,
204 204
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
205 205
 				PRIMARY KEY  (EVV_ID)";
206
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
207
-        $table_name = 'esp_extra_meta';
208
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
206
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
207
+		$table_name = 'esp_extra_meta';
208
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
209 209
 				OBJ_ID int(11) DEFAULT NULL,
210 210
 				EXM_type varchar(45) DEFAULT NULL,
211 211
 				EXM_key varchar(45) DEFAULT NULL,
212 212
 				EXM_value text,
213 213
 				PRIMARY KEY  (EXM_ID),
214 214
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
215
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
216
-        $table_name = 'esp_extra_join';
217
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
215
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
216
+		$table_name = 'esp_extra_join';
217
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
218 218
 				EXJ_first_model_id varchar(6) NOT NULL,
219 219
 				EXJ_first_model_name varchar(20) NOT NULL,
220 220
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
 				PRIMARY KEY  (EXJ_ID),
223 223
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
224 224
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
225
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
226
-        $table_name = 'esp_line_item';
227
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
225
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
226
+		$table_name = 'esp_line_item';
227
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
228 228
 				LIN_code varchar(245) NOT NULL DEFAULT '',
229 229
 				TXN_ID int(11) DEFAULT NULL,
230 230
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
 				PRIMARY KEY  (LIN_ID),
244 244
 				KEY LIN_code (LIN_code(191)),
245 245
 				KEY TXN_ID (TXN_ID)";
246
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
-        $table_name = 'esp_log';
248
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
246
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
+		$table_name = 'esp_log';
248
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
249 249
 				LOG_time datetime DEFAULT NULL,
250 250
 				OBJ_ID varchar(45) DEFAULT NULL,
251 251
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -256,18 +256,18 @@  discard block
 block discarded – undo
256 256
 				KEY LOG_time (LOG_time),
257 257
 				KEY OBJ (OBJ_type,OBJ_ID),
258 258
 				KEY LOG_type (LOG_type)";
259
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
260
-        $table_name = 'esp_message_template';
261
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
259
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
260
+		$table_name = 'esp_message_template';
261
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
262 262
 					GRP_ID int(10) unsigned NOT NULL,
263 263
 					MTP_context varchar(50) NOT NULL,
264 264
 					MTP_template_field varchar(30) NOT NULL,
265 265
 					MTP_content text NOT NULL,
266 266
 					PRIMARY KEY  (MTP_ID),
267 267
 					KEY GRP_ID (GRP_ID)";
268
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
269
-        $table_name = 'esp_message_template_group';
270
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
268
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
269
+		$table_name = 'esp_message_template_group';
270
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
271 271
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
272 272
 					MTP_name varchar(245) NOT NULL DEFAULT '',
273 273
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -279,17 +279,17 @@  discard block
 block discarded – undo
279 279
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
280 280
 					PRIMARY KEY  (GRP_ID),
281 281
 					KEY MTP_user_id (MTP_user_id)";
282
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
283
-        $table_name = 'esp_event_message_template';
284
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
282
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
283
+		$table_name = 'esp_event_message_template';
284
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
285 285
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
286 286
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
287 287
 					PRIMARY KEY  (EMT_ID),
288 288
 					KEY EVT_ID (EVT_ID),
289 289
 					KEY GRP_ID (GRP_ID)";
290
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
-        $table_name = 'esp_payment';
292
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
290
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
+		$table_name = 'esp_payment';
292
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
293 293
 					TXN_ID int(10) unsigned DEFAULT NULL,
294 294
 					STS_ID varchar(3) collate utf8_bin DEFAULT NULL,
295 295
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
 					PRIMARY KEY  (PAY_ID),
307 307
 					KEY PAY_timestamp (PAY_timestamp),
308 308
 					KEY TXN_ID (TXN_ID)";
309
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
310
-        $table_name = 'esp_payment_method';
311
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
309
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
310
+		$table_name = 'esp_payment_method';
311
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
312 312
 				PMD_type varchar(124) DEFAULT NULL,
313 313
 				PMD_name varchar(255) DEFAULT NULL,
314 314
 				PMD_desc text,
@@ -324,32 +324,32 @@  discard block
 block discarded – undo
324 324
 				PRIMARY KEY  (PMD_ID),
325 325
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
326 326
 				KEY PMD_type (PMD_type)";
327
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
328
-        $table_name = "esp_ticket_price";
329
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
327
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
328
+		$table_name = "esp_ticket_price";
329
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
330 330
 					  TKT_ID int(10) unsigned NOT NULL,
331 331
 					  PRC_ID int(10) unsigned NOT NULL,
332 332
 					  PRIMARY KEY  (TKP_ID),
333 333
 					  KEY TKT_ID (TKT_ID),
334 334
 					  KEY PRC_ID (PRC_ID)";
335
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
336
-        $table_name = "esp_datetime_ticket";
337
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
335
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
336
+		$table_name = "esp_datetime_ticket";
337
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
338 338
 					  DTT_ID int(10) unsigned NOT NULL,
339 339
 					  TKT_ID int(10) unsigned NOT NULL,
340 340
 					  PRIMARY KEY  (DTK_ID),
341 341
 					  KEY DTT_ID (DTT_ID),
342 342
 					  KEY TKT_ID (TKT_ID)";
343
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
344
-        $table_name = "esp_ticket_template";
345
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
343
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
344
+		$table_name = "esp_ticket_template";
345
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
346 346
 					  TTM_name varchar(45) NOT NULL,
347 347
 					  TTM_description text,
348 348
 					  TTM_file varchar(45),
349 349
 					  PRIMARY KEY  (TTM_ID)";
350
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
-        $table_name = 'esp_question';
352
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
350
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
+		$table_name = 'esp_question';
352
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
353 353
 					QST_display_text text NOT NULL,
354 354
 					QST_admin_label varchar(255) NOT NULL,
355 355
 					QST_system varchar(25) NOT NULL DEFAULT "",
@@ -363,18 +363,18 @@  discard block
 block discarded – undo
363 363
 					QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
364 364
 					PRIMARY KEY  (QST_ID),
365 365
 					KEY QST_order (QST_order)';
366
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
367
-        $table_name = 'esp_question_group_question';
368
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
366
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
367
+		$table_name = 'esp_question_group_question';
368
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
369 369
 					QSG_ID int(10) unsigned NOT NULL,
370 370
 					QST_ID int(10) unsigned NOT NULL,
371 371
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
372 372
 					PRIMARY KEY  (QGQ_ID),
373 373
 					KEY QST_ID (QST_ID),
374 374
 					KEY QSG_ID_order (QSG_ID,QGQ_order)";
375
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
-        $table_name = 'esp_question_option';
377
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
375
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
+		$table_name = 'esp_question_option';
377
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
378 378
 					QSO_value varchar(255) NOT NULL,
379 379
 					QSO_desc text NOT NULL,
380 380
 					QST_ID int(10) unsigned NOT NULL,
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 					PRIMARY KEY  (QSO_ID),
385 385
 					KEY QST_ID (QST_ID),
386 386
 					KEY QSO_order (QSO_order)";
387
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
388
-        $table_name = 'esp_registration';
389
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
387
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
388
+		$table_name = 'esp_registration';
389
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
390 390
 					  EVT_ID bigint(20) unsigned NOT NULL,
391 391
 					  ATT_ID bigint(20) unsigned NOT NULL,
392 392
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 					  KEY TKT_ID (TKT_ID),
411 411
 					  KEY EVT_ID (EVT_ID),
412 412
 					  KEY STS_ID (STS_ID)";
413
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
414
-        $table_name = 'esp_registration_payment';
415
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
413
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
414
+		$table_name = 'esp_registration_payment';
415
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
416 416
 					  REG_ID int(10) unsigned NOT NULL,
417 417
 					  PAY_ID int(10) unsigned NULL,
418 418
 					  RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00',
419 419
 					  PRIMARY KEY  (RPY_ID),
420 420
 					  KEY REG_ID (REG_ID),
421 421
 					  KEY PAY_ID (PAY_ID)";
422
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
423
-        $table_name = 'esp_checkin';
424
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
422
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
423
+		$table_name = 'esp_checkin';
424
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
425 425
 					REG_ID int(10) unsigned NOT NULL,
426 426
 					DTT_ID int(10) unsigned NOT NULL,
427 427
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
 					PRIMARY KEY  (CHK_ID),
430 430
 					KEY REG_ID (REG_ID),
431 431
 					KEY DTT_ID (DTT_ID)";
432
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
433
-        $table_name = 'esp_state';
434
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
432
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
433
+		$table_name = 'esp_state';
434
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
435 435
 					  CNT_ISO varchar(2) collate utf8_bin NOT NULL,
436 436
 					  STA_abbrev varchar(24) collate utf8_bin NOT NULL,
437 437
 					  STA_name varchar(100) collate utf8_bin NOT NULL,
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
 					  PRIMARY KEY  (STA_ID),
440 440
 					  KEY STA_abbrev (STA_abbrev),
441 441
 					  KEY CNT_ISO (CNT_ISO)";
442
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
443
-        $table_name = 'esp_status';
444
-        $sql = "STS_ID varchar(3) NOT NULL,
442
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
443
+		$table_name = 'esp_status';
444
+		$sql = "STS_ID varchar(3) NOT NULL,
445 445
 					  STS_code varchar(45) NOT NULL,
446 446
 					  STS_type varchar(45) NOT NULL,
447 447
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
450 450
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
451 451
 					  KEY STS_type (STS_type)";
452
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
453
-        $table_name = 'esp_transaction';
454
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
452
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
453
+		$table_name = 'esp_transaction';
454
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
455 455
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
456 456
 					  TXN_total decimal(10,3) DEFAULT '0.00',
457 457
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -463,9 +463,9 @@  discard block
 block discarded – undo
463 463
 					  PRIMARY KEY  (TXN_ID),
464 464
 					  KEY TXN_timestamp (TXN_timestamp),
465 465
 					  KEY STS_ID (STS_ID)";
466
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
467
-        $table_name = 'esp_venue_meta';
468
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
466
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
467
+		$table_name = 'esp_venue_meta';
468
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
469 469
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
470 470
 			VNU_address varchar(255) DEFAULT NULL,
471 471
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
 			KEY VNU_ID (VNU_ID),
485 485
 			KEY STA_ID (STA_ID),
486 486
 			KEY CNT_ISO (CNT_ISO)";
487
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
488
-        // modified tables
489
-        $table_name = "esp_price";
490
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
487
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
488
+		// modified tables
489
+		$table_name = "esp_price";
490
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
491 491
 					  PRT_ID tinyint(3) unsigned NOT NULL,
492 492
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
493 493
 					  PRC_name varchar(245) NOT NULL,
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
 					  PRC_parent int(10) unsigned DEFAULT 0,
501 501
 					  PRIMARY KEY  (PRC_ID),
502 502
 					  KEY PRT_ID (PRT_ID)";
503
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
504
-        $table_name = "esp_price_type";
505
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
503
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
504
+		$table_name = "esp_price_type";
505
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
506 506
 				  PRT_name varchar(45) NOT NULL,
507 507
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
508 508
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -511,9 +511,9 @@  discard block
 block discarded – undo
511 511
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
512 512
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
513 513
 				  PRIMARY KEY  (PRT_ID)";
514
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
515
-        $table_name = "esp_ticket";
516
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
514
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
515
+		$table_name = "esp_ticket";
516
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
517 517
 					  TTM_ID int(10) unsigned NOT NULL,
518 518
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
519 519
 					  TKT_description text NOT NULL,
@@ -535,9 +535,9 @@  discard block
 block discarded – undo
535 535
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
536 536
 					  PRIMARY KEY  (TKT_ID),
537 537
 					  KEY TKT_start_date (TKT_start_date)";
538
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
539
-        $table_name = 'esp_question_group';
540
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
538
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
539
+		$table_name = 'esp_question_group';
540
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
541 541
 					QSG_name varchar(255) NOT NULL,
542 542
 					QSG_identifier varchar(100) NOT NULL,
543 543
 					QSG_desc text NULL,
@@ -550,223 +550,223 @@  discard block
 block discarded – undo
550 550
 					PRIMARY KEY  (QSG_ID),
551 551
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
552 552
 					KEY QSG_order (QSG_order)';
553
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
554
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
555
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
556
-        // (because many need to convert old string states to foreign keys into the states table)
557
-        $script_4_1_defaults->insert_default_states();
558
-        $script_4_1_defaults->insert_default_countries();
559
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
560
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
561
-        $script_4_5_defaults->insert_default_price_types();
562
-        $script_4_5_defaults->insert_default_prices();
563
-        $script_4_5_defaults->insert_default_tickets();
564
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
565
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
566
-        $script_4_6_defaults->add_default_admin_only_payments();
567
-        $script_4_6_defaults->insert_default_currencies();
568
-        $this->verify_new_countries();
569
-        $this->verify_new_currencies();
570
-        return true;
571
-    }
553
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
554
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
555
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
556
+		// (because many need to convert old string states to foreign keys into the states table)
557
+		$script_4_1_defaults->insert_default_states();
558
+		$script_4_1_defaults->insert_default_countries();
559
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
560
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
561
+		$script_4_5_defaults->insert_default_price_types();
562
+		$script_4_5_defaults->insert_default_prices();
563
+		$script_4_5_defaults->insert_default_tickets();
564
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
565
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
566
+		$script_4_6_defaults->add_default_admin_only_payments();
567
+		$script_4_6_defaults->insert_default_currencies();
568
+		$this->verify_new_countries();
569
+		$this->verify_new_currencies();
570
+		return true;
571
+	}
572 572
 
573 573
 
574 574
 
575
-    /**
576
-     * @return boolean
577
-     */
578
-    public function schema_changes_after_migration()
579
-    {
580
-        $this->fix_non_default_taxes();
581
-        // this is actually the same as the last DMS
582
-        /** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */
583
-        $script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0');
584
-        return $script_4_7_defaults->schema_changes_after_migration();
585
-    }
575
+	/**
576
+	 * @return boolean
577
+	 */
578
+	public function schema_changes_after_migration()
579
+	{
580
+		$this->fix_non_default_taxes();
581
+		// this is actually the same as the last DMS
582
+		/** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */
583
+		$script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0');
584
+		return $script_4_7_defaults->schema_changes_after_migration();
585
+	}
586 586
 
587 587
 
588 588
 
589
-    public function migration_page_hooks()
590
-    {
591
-    }
589
+	public function migration_page_hooks()
590
+	{
591
+	}
592 592
 
593 593
 
594 594
 
595
-    /**
596
-     * verifies each of the new countries exists that somehow we missed in 4.1
597
-     */
598
-    public function verify_new_countries()
599
-    {
600
-        // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
601
-        // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
602
-        // currency symbols: http://www.xe.com/symbols.php
603
-        // 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
604
-        // ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
605
-        $newer_countries = array(
606
-            array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0),
607
-            array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
608
-            array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0),
609
-            array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0),
610
-            array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
611
-            array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
612
-            array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
613
-            array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0),
614
-            array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0),
615
-            array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0),
616
-            array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0),
617
-            array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0),
618
-            array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0),
619
-            array(
620
-                'BQ',
621
-                'BES',
622
-                0,
623
-                'Bonaire, Saint Eustatius and Saba',
624
-                'USD',
625
-                'Dollar',
626
-                'Dollars',
627
-                '$',
628
-                1,
629
-                2,
630
-                '+599',
631
-                0,
632
-                0,
633
-            ),
634
-            array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0),
635
-            array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0),
636
-            array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0),
637
-            array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0),
638
-            array(
639
-                'HM',
640
-                'HMD',
641
-                0,
642
-                'Heard Island and McDonald Islands',
643
-                'AUD',
644
-                'Dollar',
645
-                'Dollars',
646
-                '$',
647
-                1,
648
-                2,
649
-                '+891',
650
-                0,
651
-                0,
652
-            ),
653
-            array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0),
654
-            array(
655
-                'GS',
656
-                'SGS',
657
-                0,
658
-                'South Georgia and the South Sandwich Islands',
659
-                'GBP',
660
-                'Pound',
661
-                'Pounds',
662
-                '£',
663
-                1,
664
-                2,
665
-                '+500',
666
-                0,
667
-                0,
668
-            ),
669
-            array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0),
670
-            array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0),
671
-            array(
672
-                'UM',
673
-                'UMI',
674
-                0,
675
-                'United States Minor Outlying Islands',
676
-                'USD',
677
-                'Dollar',
678
-                'Dollars',
679
-                '$',
680
-                1,
681
-                2,
682
-                '+1',
683
-                0,
684
-                0,
685
-            ),
686
-        );
687
-        global $wpdb;
688
-        $country_table = $wpdb->prefix . "esp_country";
689
-        $country_format = array(
690
-            "CNT_ISO"         => '%s',
691
-            "CNT_ISO3"        => '%s',
692
-            "RGN_ID"          => '%d',
693
-            "CNT_name"        => '%s',
694
-            "CNT_cur_code"    => '%s',
695
-            "CNT_cur_single"  => '%s',
696
-            "CNT_cur_plural"  => '%s',
697
-            "CNT_cur_sign"    => '%s',
698
-            "CNT_cur_sign_b4" => '%d',
699
-            "CNT_cur_dec_plc" => '%d',
700
-            "CNT_tel_code"    => '%s',
701
-            "CNT_is_EU"       => '%d',
702
-            "CNT_active"      => '%d',
703
-        );
704
-        if ($this->_get_table_analysis()->tableExists($country_table)) {
705
-            foreach ($newer_countries as $country) {
706
-                $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
707
-                $countries = $wpdb->get_var($SQL);
708
-                if (! $countries) {
709
-                    $wpdb->insert(
710
-                        $country_table,
711
-                        array_combine(array_keys($country_format), $country),
712
-                        $country_format
713
-                    );
714
-                }
715
-            }
716
-        }
717
-    }
595
+	/**
596
+	 * verifies each of the new countries exists that somehow we missed in 4.1
597
+	 */
598
+	public function verify_new_countries()
599
+	{
600
+		// a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
601
+		// how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
602
+		// currency symbols: http://www.xe.com/symbols.php
603
+		// 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
604
+		// ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
605
+		$newer_countries = array(
606
+			array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0),
607
+			array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
608
+			array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0),
609
+			array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0),
610
+			array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
611
+			array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
612
+			array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
613
+			array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0),
614
+			array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0),
615
+			array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0),
616
+			array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0),
617
+			array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0),
618
+			array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0),
619
+			array(
620
+				'BQ',
621
+				'BES',
622
+				0,
623
+				'Bonaire, Saint Eustatius and Saba',
624
+				'USD',
625
+				'Dollar',
626
+				'Dollars',
627
+				'$',
628
+				1,
629
+				2,
630
+				'+599',
631
+				0,
632
+				0,
633
+			),
634
+			array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0),
635
+			array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0),
636
+			array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0),
637
+			array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0),
638
+			array(
639
+				'HM',
640
+				'HMD',
641
+				0,
642
+				'Heard Island and McDonald Islands',
643
+				'AUD',
644
+				'Dollar',
645
+				'Dollars',
646
+				'$',
647
+				1,
648
+				2,
649
+				'+891',
650
+				0,
651
+				0,
652
+			),
653
+			array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0),
654
+			array(
655
+				'GS',
656
+				'SGS',
657
+				0,
658
+				'South Georgia and the South Sandwich Islands',
659
+				'GBP',
660
+				'Pound',
661
+				'Pounds',
662
+				'£',
663
+				1,
664
+				2,
665
+				'+500',
666
+				0,
667
+				0,
668
+			),
669
+			array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0),
670
+			array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0),
671
+			array(
672
+				'UM',
673
+				'UMI',
674
+				0,
675
+				'United States Minor Outlying Islands',
676
+				'USD',
677
+				'Dollar',
678
+				'Dollars',
679
+				'$',
680
+				1,
681
+				2,
682
+				'+1',
683
+				0,
684
+				0,
685
+			),
686
+		);
687
+		global $wpdb;
688
+		$country_table = $wpdb->prefix . "esp_country";
689
+		$country_format = array(
690
+			"CNT_ISO"         => '%s',
691
+			"CNT_ISO3"        => '%s',
692
+			"RGN_ID"          => '%d',
693
+			"CNT_name"        => '%s',
694
+			"CNT_cur_code"    => '%s',
695
+			"CNT_cur_single"  => '%s',
696
+			"CNT_cur_plural"  => '%s',
697
+			"CNT_cur_sign"    => '%s',
698
+			"CNT_cur_sign_b4" => '%d',
699
+			"CNT_cur_dec_plc" => '%d',
700
+			"CNT_tel_code"    => '%s',
701
+			"CNT_is_EU"       => '%d',
702
+			"CNT_active"      => '%d',
703
+		);
704
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
705
+			foreach ($newer_countries as $country) {
706
+				$SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
707
+				$countries = $wpdb->get_var($SQL);
708
+				if (! $countries) {
709
+					$wpdb->insert(
710
+						$country_table,
711
+						array_combine(array_keys($country_format), $country),
712
+						$country_format
713
+					);
714
+				}
715
+			}
716
+		}
717
+	}
718 718
 
719 719
 
720 720
 
721
-    /**
722
-     * verifies each of the new currencies exists that somehow we missed in 4.6
723
-     */
724
-    public function verify_new_currencies()
725
-    {
726
-        // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
727
-        // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
728
-        // currency symbols: http://www.xe.com/symbols.php
729
-        // CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active
730
-        // ( 'EUR',  'Euro',  'Euros',  '€',  2,1),
731
-        $newer_currencies = array(
732
-            array('RSD', 'Dinar', 'Dinars', '', 3, 1),
733
-        );
734
-        global $wpdb;
735
-        $currency_table = $wpdb->prefix . "esp_currency";
736
-        $currency_format = array(
737
-            "CUR_code"    => '%s',
738
-            "CUR_single"  => '%s',
739
-            "CUR_plural"  => '%s',
740
-            "CUR_sign"    => '%s',
741
-            "CUR_dec_plc" => '%d',
742
-            "CUR_active"  => '%d',
743
-        );
744
-        if ($this->_get_table_analysis()->tableExists($currency_table)) {
745
-            foreach ($newer_currencies as $currency) {
746
-                $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
747
-                $countries = $wpdb->get_var($SQL);
748
-                if (! $countries) {
749
-                    $wpdb->insert(
750
-                        $currency_table,
751
-                        array_combine(array_keys($currency_format), $currency),
752
-                        $currency_format
753
-                    );
754
-                }
755
-            }
756
-        }
757
-    }
721
+	/**
722
+	 * verifies each of the new currencies exists that somehow we missed in 4.6
723
+	 */
724
+	public function verify_new_currencies()
725
+	{
726
+		// a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
727
+		// how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
728
+		// currency symbols: http://www.xe.com/symbols.php
729
+		// CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active
730
+		// ( 'EUR',  'Euro',  'Euros',  '€',  2,1),
731
+		$newer_currencies = array(
732
+			array('RSD', 'Dinar', 'Dinars', '', 3, 1),
733
+		);
734
+		global $wpdb;
735
+		$currency_table = $wpdb->prefix . "esp_currency";
736
+		$currency_format = array(
737
+			"CUR_code"    => '%s',
738
+			"CUR_single"  => '%s',
739
+			"CUR_plural"  => '%s',
740
+			"CUR_sign"    => '%s',
741
+			"CUR_dec_plc" => '%d',
742
+			"CUR_active"  => '%d',
743
+		);
744
+		if ($this->_get_table_analysis()->tableExists($currency_table)) {
745
+			foreach ($newer_currencies as $currency) {
746
+				$SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
747
+				$countries = $wpdb->get_var($SQL);
748
+				if (! $countries) {
749
+					$wpdb->insert(
750
+						$currency_table,
751
+						array_combine(array_keys($currency_format), $currency),
752
+						$currency_format
753
+					);
754
+				}
755
+			}
756
+		}
757
+	}
758 758
 
759 759
 
760 760
 
761
-    /**
762
-     * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731
763
-     * which should just be a temporary issue for folks who installed 4.8.0-4.8.5;
764
-     * we should be able to stop doing this in 4.9
765
-     */
766
-    public function fix_non_default_taxes()
767
-    {
768
-        global $wpdb;
769
-        $query = $wpdb->prepare("UPDATE
761
+	/**
762
+	 * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731
763
+	 * which should just be a temporary issue for folks who installed 4.8.0-4.8.5;
764
+	 * we should be able to stop doing this in 4.9
765
+	 */
766
+	public function fix_non_default_taxes()
767
+	{
768
+		global $wpdb;
769
+		$query = $wpdb->prepare("UPDATE
770 770
 				{$wpdb->prefix}esp_price p INNER JOIN
771 771
 				{$wpdb->prefix}esp_price_type pt ON p.PRT_ID = pt.PRT_ID
772 772
 			SET
@@ -775,6 +775,6 @@  discard block
 block discarded – undo
775 775
 				p.PRC_is_default = 0 AND
776 776
 				pt.PBT_ID = %d
777 777
 					", EEM_Price_Type::base_type_tax);
778
-        $wpdb->query($query);
779
-    }
778
+		$wpdb->query($query);
779
+	}
780 780
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 // unfortunately, this needs to be done upon INCLUSION of this file,
15 15
 // instead of construction, because it only gets constructed on first page load
16 16
 // (all other times it gets resurrected from a wordpress option)
17
-$stages = glob(EE_CORE . 'data_migration_scripts/4_8_0_stages/*');
17
+$stages = glob(EE_CORE.'data_migration_scripts/4_8_0_stages/*');
18 18
 $class_to_filepath = array();
19 19
 foreach ($stages as $filepath) {
20 20
     $matches = array();
21 21
     preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22
-    $class_to_filepath[ $matches[1] ] = $filepath;
22
+    $class_to_filepath[$matches[1]] = $filepath;
23 23
 }
24 24
 // give addons a chance to autoload their stages too
25 25
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath);
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
         if (version_compare($version_string, '4.8.0.decaf', '<') && version_compare($version_string, '4.7.0.decaf', '>=')) {
73 73
 //          echo "$version_string can be migrated from";
74 74
             return true;
75
-        } elseif (! $version_string) {
75
+        } elseif ( ! $version_string) {
76 76
 //          echo "no version string provided: $version_string";
77 77
             // no version string provided... this must be pre 4.3
78
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
78
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
79 79
         } else {
80 80
 //          echo "$version_string doesnt apply";
81 81
             return false;
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function schema_changes_before_migration()
91 91
     {
92
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
92
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
93 93
         $now_in_mysql = current_time('mysql', true);
94
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
94
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
95 95
         $table_name = 'esp_answer';
96 96
         $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
97 97
 					REG_ID int(10) unsigned NOT NULL,
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
             ),
686 686
         );
687 687
         global $wpdb;
688
-        $country_table = $wpdb->prefix . "esp_country";
688
+        $country_table = $wpdb->prefix."esp_country";
689 689
         $country_format = array(
690 690
             "CNT_ISO"         => '%s',
691 691
             "CNT_ISO3"        => '%s',
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
             foreach ($newer_countries as $country) {
706 706
                 $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
707 707
                 $countries = $wpdb->get_var($SQL);
708
-                if (! $countries) {
708
+                if ( ! $countries) {
709 709
                     $wpdb->insert(
710 710
                         $country_table,
711 711
                         array_combine(array_keys($country_format), $country),
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
             array('RSD', 'Dinar', 'Dinars', '', 3, 1),
733 733
         );
734 734
         global $wpdb;
735
-        $currency_table = $wpdb->prefix . "esp_currency";
735
+        $currency_table = $wpdb->prefix."esp_currency";
736 736
         $currency_format = array(
737 737
             "CUR_code"    => '%s',
738 738
             "CUR_single"  => '%s',
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
             foreach ($newer_currencies as $currency) {
746 746
                 $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
747 747
                 $countries = $wpdb->get_var($SQL);
748
-                if (! $countries) {
748
+                if ( ! $countries) {
749 749
                     $wpdb->insert(
750 750
                         $currency_table,
751 751
                         array_combine(array_keys($currency_format), $currency),
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
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
 // unfortunately, this needs to be done upon INCLUSION of this file,
10 10
 // instead of construction, because it only gets constructed on first page load
11 11
 // (all other times it gets resurrected from a wordpress option)
12
-$stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*');
12
+$stages = glob(EE_CORE.'data_migration_scripts/4_1_0_stages/*');
13 13
 $class_to_filepath = array();
14
-if (! empty($stages)) {
14
+if ( ! empty($stages)) {
15 15
     foreach ($stages as $filepath) {
16 16
         $matches = array();
17 17
         preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18
-        $class_to_filepath[ $matches[1] ] = $filepath;
18
+        $class_to_filepath[$matches[1]] = $filepath;
19 19
     }
20 20
 }
21 21
 // give addons a chance to autoload their stages too
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     private function _checkin_table_exists()
88 88
     {
89 89
         global $wpdb;
90
-        $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
90
+        $results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'");
91 91
         if ($results) {
92 92
             return true;
93 93
         } else {
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
         if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) {
104 104
 //          echo "$version_string can be migrated fro";
105 105
             return true;
106
-        } elseif (! $version_string) {
106
+        } elseif ( ! $version_string) {
107 107
 //          echo "no version string provided: $version_string";
108 108
             // no version string provided... this must be pre 4.1
109 109
             // because since 4.1 we're
110
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
110
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
111 111
         } else {
112 112
 //          echo "$version_string doesnt apply";
113 113
             return false;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     public function schema_changes_before_migration()
120 120
     {
121 121
         // relies on 4.1's EEH_Activation::create_table
122
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
122
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
123 123
         $table_name = 'esp_answer';
124 124
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
125 125
 					REG_ID int(10) unsigned NOT NULL,
@@ -503,12 +503,12 @@  discard block
 block discarded – undo
503 503
     public function insert_default_states()
504 504
     {
505 505
         global $wpdb;
506
-        $state_table = $wpdb->prefix . "esp_state";
506
+        $state_table = $wpdb->prefix."esp_state";
507 507
         if ($this->_get_table_analysis()->tableExists($state_table)) {
508
-            $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
508
+            $SQL = "SELECT COUNT('STA_ID') FROM ".$state_table;
509 509
             $states = $wpdb->get_var($SQL);
510
-            if (! $states) {
511
-                $SQL = "INSERT INTO " . $state_table . "
510
+            if ( ! $states) {
511
+                $SQL = "INSERT INTO ".$state_table."
512 512
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
513 513
 				(1, 'US', 'AK', 'Alaska', 1),
514 514
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -596,12 +596,12 @@  discard block
 block discarded – undo
596 596
     public function insert_default_countries()
597 597
     {
598 598
         global $wpdb;
599
-        $country_table = $wpdb->prefix . "esp_country";
599
+        $country_table = $wpdb->prefix."esp_country";
600 600
         if ($this->_get_table_analysis()->tableExists($country_table)) {
601
-            $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
601
+            $SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table;
602 602
             $countries = $wpdb->get_var($SQL);
603
-            if (! $countries) {
604
-                $SQL = "INSERT INTO " . $country_table . "
603
+            if ( ! $countries) {
604
+                $SQL = "INSERT INTO ".$country_table."
605 605
 				(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
606 606
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
607 607
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -846,17 +846,17 @@  discard block
 block discarded – undo
846 846
     public function insert_default_price_types()
847 847
     {
848 848
         global $wpdb;
849
-        $price_type_table = $wpdb->prefix . "esp_price_type";
849
+        $price_type_table = $wpdb->prefix."esp_price_type";
850 850
         if ($this->_get_table_analysis()->tableExists($price_type_table)) {
851
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
851
+            $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table;
852 852
             $price_types_exist = $wpdb->get_var($SQL);
853
-            if (! $price_types_exist) {
853
+            if ( ! $price_types_exist) {
854 854
                 $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
855
-							(1, '" . esc_html__('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
856
-							(2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
857
-							(3, '" . esc_html__('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
858
-							(4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
859
-							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
855
+							(1, '".esc_html__('Base Price', 'event_espresso')."', 1,  0, 0, 0),
856
+							(2, '" . esc_html__('Percent Discount', 'event_espresso')."', 2,  1, 20, 0),
857
+							(3, '" . esc_html__('Fixed Discount', 'event_espresso')."', 2,  0, 30, 0),
858
+							(4, '" . esc_html__('Percent Surcharge', 'event_espresso')."', 3,  1, 40, 0),
859
+							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso')."', 3,  0, 50, 0);";
860 860
                 $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
861 861
                 $wpdb->query($SQL);
862 862
             }
@@ -878,11 +878,11 @@  discard block
 block discarded – undo
878 878
     public function insert_default_prices()
879 879
     {
880 880
         global $wpdb;
881
-        $price_table = $wpdb->prefix . "esp_price";
881
+        $price_table = $wpdb->prefix."esp_price";
882 882
         if ($this->_get_table_analysis()->tableExists($price_table)) {
883
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
883
+            $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table;
884 884
             $prices_exist = $wpdb->get_var($SQL);
885
-            if (! $prices_exist) {
885
+            if ( ! $prices_exist) {
886 886
                 $SQL = "INSERT INTO $price_table
887 887
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES
888 888
 							(1, 1, '0.00', 'Free Admission', '', 1, null, 0, 0, 0);";
@@ -904,11 +904,11 @@  discard block
 block discarded – undo
904 904
     public function insert_default_tickets()
905 905
     {
906 906
         global $wpdb;
907
-        $ticket_table = $wpdb->prefix . "esp_ticket";
907
+        $ticket_table = $wpdb->prefix."esp_ticket";
908 908
         if ($this->_get_table_analysis()->tableExists($ticket_table)) {
909
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
909
+            $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
910 910
             $tickets_exist = $wpdb->get_var($SQL);
911
-            if (! $tickets_exist) {
911
+            if ( ! $tickets_exist) {
912 912
                 $SQL = "INSERT INTO $ticket_table
913 913
 					( 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
914 914
 					( 1, 0, '"
@@ -918,11 +918,11 @@  discard block
 block discarded – undo
918 918
                 $wpdb->query($SQL);
919 919
             }
920 920
         }
921
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
921
+        $ticket_price_table = $wpdb->prefix."esp_ticket_price";
922 922
         if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
923
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
923
+            $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
924 924
             $ticket_prc_exist = $wpdb->get_var($SQL);
925
-            if (! $ticket_prc_exist) {
925
+            if ( ! $ticket_prc_exist) {
926 926
                 $SQL = "INSERT INTO $ticket_price_table
927 927
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
928 928
 				( 1, 1, 1 )
@@ -946,11 +946,11 @@  discard block
 block discarded – undo
946 946
      */
947 947
     public function get_or_create_country($country_name)
948 948
     {
949
-        if (! $country_name) {
949
+        if ( ! $country_name) {
950 950
             throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
951 951
         }
952 952
         global $wpdb;
953
-        $country_table = $wpdb->prefix . "esp_country";
953
+        $country_table = $wpdb->prefix."esp_country";
954 954
         if (is_int($country_name)) {
955 955
             $country_name = $this->get_iso_from_3_1_country_id($country_name);
956 956
         }
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 			CNT_ISO LIKE %s OR
959 959
 			CNT_ISO3 LIKE %s OR
960 960
 			CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A);
961
-        if (! $country) {
961
+        if ( ! $country) {
962 962
             // insert a new one then
963 963
             $cols_n_values = array(
964 964
                     'CNT_ISO'         => $this->_find_available_country_iso(2),
@@ -978,28 +978,28 @@  discard block
 block discarded – undo
978 978
                     'CNT_active'      => true,
979 979
             );
980 980
             $data_types = array(
981
-                    '%s',// CNT_ISO
982
-                    '%s',// CNT_ISO3
983
-                    '%d',// RGN_ID
984
-                    '%s',// CNT_name
985
-                    '%s',// CNT_cur_code
986
-                    '%s',// CNT_cur_single
987
-                    '%s',// CNT_cur_plural
988
-                    '%s',// CNT_cur_sign
989
-                    '%d',// CNT_cur_sign_b4
990
-                    '%d',// CNT_cur_dec_plc
991
-                    '%s',// CNT_cur_dec_mrk
992
-                    '%s',// CNT_cur_thsnds
993
-                    '%s',// CNT_tel_code
994
-                    '%d',// CNT_is_EU
995
-                    '%d',// CNT_active
981
+                    '%s', // CNT_ISO
982
+                    '%s', // CNT_ISO3
983
+                    '%d', // RGN_ID
984
+                    '%s', // CNT_name
985
+                    '%s', // CNT_cur_code
986
+                    '%s', // CNT_cur_single
987
+                    '%s', // CNT_cur_plural
988
+                    '%s', // CNT_cur_sign
989
+                    '%d', // CNT_cur_sign_b4
990
+                    '%d', // CNT_cur_dec_plc
991
+                    '%s', // CNT_cur_dec_mrk
992
+                    '%s', // CNT_cur_thsnds
993
+                    '%s', // CNT_tel_code
994
+                    '%d', // CNT_is_EU
995
+                    '%d', // CNT_active
996 996
             );
997 997
             $success = $wpdb->insert(
998 998
                 $country_table,
999 999
                 $cols_n_values,
1000 1000
                 $data_types
1001 1001
             );
1002
-            if (! $success) {
1002
+            if ( ! $success) {
1003 1003
                 throw new EE_Error($this->_create_error_message_for_db_insertion(
1004 1004
                     'N/A',
1005 1005
                     array('country_id' => $country_name),
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
     private function _find_available_country_iso($num_letters = 2)
1025 1025
     {
1026 1026
         global $wpdb;
1027
-        $country_table = $wpdb->prefix . "esp_country";
1027
+        $country_table = $wpdb->prefix."esp_country";
1028 1028
         $attempts = 0;
1029 1029
         do {
1030 1030
             $current_iso = strtoupper(wp_generate_password($num_letters, false));
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
             // keep going until we find an available country code, or we arbitrarily
1036 1036
             // decide we've tried this enough. Somehow they have way too many countries
1037 1037
             // (probably because they're mis-using the EE3 country_id like a custom question)
1038
-        } while (intval($country_with_that_iso) && $attempts < 200);
1038
+        }while (intval($country_with_that_iso) && $attempts < 200);
1039 1039
         return $current_iso;
1040 1040
     }
1041 1041
 
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
      */
1052 1052
     public function get_or_create_state($state_name, $country_name = '')
1053 1053
     {
1054
-        if (! $state_name) {
1054
+        if ( ! $state_name) {
1055 1055
             throw new EE_Error(esc_html__(
1056 1056
                 "Could not get-or-create state because no state name was provided",
1057 1057
                 "event_espresso"
@@ -1064,12 +1064,12 @@  discard block
 block discarded – undo
1064 1064
             $country_iso = $this->get_default_country_iso();
1065 1065
         }
1066 1066
         global $wpdb;
1067
-        $state_table = $wpdb->prefix . "esp_state";
1067
+        $state_table = $wpdb->prefix."esp_state";
1068 1068
         $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1069 1069
 			(STA_abbrev LIKE %s OR
1070 1070
 			STA_name LIKE %s) AND
1071 1071
 			CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A);
1072
-        if (! $state) {
1072
+        if ( ! $state) {
1073 1073
             // insert a new one then
1074 1074
             $cols_n_values = array(
1075 1075
                     'CNT_ISO'    => $country_iso,
@@ -1078,13 +1078,13 @@  discard block
 block discarded – undo
1078 1078
                     'STA_active' => true,
1079 1079
             );
1080 1080
             $data_types = array(
1081
-                    '%s',// CNT_ISO
1082
-                    '%s',// STA_abbrev
1083
-                    '%s',// STA_name
1084
-                    '%d',// STA_active
1081
+                    '%s', // CNT_ISO
1082
+                    '%s', // STA_abbrev
1083
+                    '%s', // STA_name
1084
+                    '%d', // STA_active
1085 1085
             );
1086 1086
             $success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1087
-            if (! $success) {
1087
+            if ( ! $success) {
1088 1088
                 throw new EE_Error($this->_create_error_message_for_db_insertion(
1089 1089
                     'N/A',
1090 1090
                     array('state' => $state_name, 'country_id' => $country_name),
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
     {
1114 1114
         $matches = array();
1115 1115
         preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1116
-        if (! $matches || count($matches) < 3) {
1116
+        if ( ! $matches || count($matches) < 3) {
1117 1117
             $hour = '00';
1118 1118
             $minutes = '00';
1119 1119
         } else {
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
                     'Declined'         => 'RPP',
1419 1419
             );
1420 1420
         }
1421
-        return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA';
1421
+        return isset($mapping[$payment_status]) ? $mapping[$payment_status] : 'RNA';
1422 1422
     }
1423 1423
 
1424 1424
 
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
         if ($guid) {
1443 1443
             // check for an existing attachment post with this guid
1444 1444
             $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1445
-            if (! $attachment_post_id) {
1445
+            if ( ! $attachment_post_id) {
1446 1446
                 // post thumbnail with that GUID doesn't exist, we should create one
1447 1447
                 $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1448 1448
                 $created_attachment_post = true;
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
         $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1478 1478
         // do a head request to verify the file exists
1479 1479
         $head_response = wp_remote_head($original_guid);
1480
-        if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1480
+        if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1481 1481
             return $original_guid;
1482 1482
         } else {
1483 1483
             return $guid_in_old_event;
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
      */
1498 1498
     private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1499 1499
     {
1500
-        if (! $guid) {
1500
+        if ( ! $guid) {
1501 1501
             $migration_stage->add_error(sprintf(esc_html__(
1502 1502
                 "Cannot create image attachment for a blank GUID!",
1503 1503
                 "event_espresso"
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
         // if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1510 1510
         if (strpos($guid, $wp_upload_dir['url']) === false) {
1511 1511
             // image is located remotely. download it and place it in the uploads directory
1512
-            if (! is_readable($guid)) {
1512
+            if ( ! is_readable($guid)) {
1513 1513
                 $migration_stage->add_error(sprintf(esc_html__(
1514 1514
                     "Could not create image attachment from non-existent file: %s",
1515 1515
                     "event_espresso"
@@ -1524,7 +1524,7 @@  discard block
 block discarded – undo
1524 1524
                 ), $guid));
1525 1525
                 return false;
1526 1526
             }
1527
-            $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid);
1527
+            $local_filepath = $wp_upload_dir['path'].'/'.basename($guid);
1528 1528
             $savefile = fopen($local_filepath, 'w');
1529 1529
             fwrite($savefile, $contents);
1530 1530
             fclose($savefile);
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
                 'post_status'    => 'inherit',
1541 1541
         );
1542 1542
         $attach_id = wp_insert_attachment($attachment, $guid);
1543
-        if (! $attach_id) {
1543
+        if ( ! $attach_id) {
1544 1544
             $migration_stage->add_error(sprintf(esc_html__(
1545 1545
                 "Could not create image attachment post from image '%s'. Attachment data was %s.",
1546 1546
                 "event_espresso"
@@ -1549,9 +1549,9 @@  discard block
 block discarded – undo
1549 1549
         }
1550 1550
         // you must first include the image.php file
1551 1551
         // for the function wp_generate_attachment_metadata() to work
1552
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1552
+        require_once(ABSPATH.'wp-admin/includes/image.php');
1553 1553
         $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1554
-        if (! $attach_data) {
1554
+        if ( ! $attach_data) {
1555 1555
             $migration_stage->add_error(sprintf(esc_html__(
1556 1556
                 "Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1557 1557
                 "event_espresso"
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
             return $attach_id;
1560 1560
         }
1561 1561
         $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1562
-        if (! $metadata_save_result) {
1562
+        if ( ! $metadata_save_result) {
1563 1563
             $migration_stage->add_error(sprintf(esc_html__(
1564 1564
                 "Could not update attachment metadata for attachment %d with data %s",
1565 1565
                 "event_espresso"
@@ -1605,10 +1605,10 @@  discard block
 block discarded – undo
1605 1605
         $timezone = null
1606 1606
     ) {
1607 1607
         $original_tz = $timezone;
1608
-        if (! $timezone) {
1608
+        if ( ! $timezone) {
1609 1609
             $timezone = $this->_get_wp_timezone();
1610 1610
         }
1611
-        if (! $timezone) {
1611
+        if ( ! $timezone) {
1612 1612
             $stage->add_error(sprintf(
1613 1613
                 esc_html__("Could not find timezone given %s for %s", "event_espresso"),
1614 1614
                 $original_tz,
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
         );
1742 1742
         add_filter(
1743 1743
             'FHEE__ee_migration_page__migration_options_template',
1744
-            array($this,'use_migration_options_from_ee3_template')
1744
+            array($this, 'use_migration_options_from_ee3_template')
1745 1745
         );
1746 1746
     }
1747 1747
 
@@ -1807,6 +1807,6 @@  discard block
 block discarded – undo
1807 1807
      */
1808 1808
     public function use_migration_options_from_ee3_template($template_filepath)
1809 1809
     {
1810
-        return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1810
+        return EE_MAINTENANCE_TEMPLATE_PATH.'migration_options_from_ee3.template.php';
1811 1811
     }
1812 1812
 }
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);
@@ -46,91 +46,91 @@  discard block
 block discarded – undo
46 46
 
47 47
 
48 48
 
49
-    /**
50
-     * EE_DMS_Core_4_1_0 constructor.
51
-     *
52
-     * @param TableManager  $table_manager
53
-     * @param TableAnalysis $table_analysis
54
-     */
55
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
56
-    {
57
-        $this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso");
58
-        $this->_priority = 10;
59
-        $this->_migration_stages = array(
60
-                new EE_DMS_4_1_0_org_options(),
61
-                new EE_DMS_4_1_0_shortcodes(),
62
-                new EE_DMS_4_1_0_gateways(),
63
-                new EE_DMS_4_1_0_events(),
64
-                new EE_DMS_4_1_0_prices(),
65
-                new EE_DMS_4_1_0_category_details(),
66
-                new EE_DMS_4_1_0_event_category(),
67
-                new EE_DMS_4_1_0_venues(),
68
-                new EE_DMS_4_1_0_event_venue(),
69
-                new EE_DMS_4_1_0_question_groups(),
70
-                new EE_DMS_4_1_0_questions(),
71
-                new EE_DMS_4_1_0_question_group_question(),
72
-                new EE_DMS_4_1_0_event_question_group(),
73
-                new EE_DMS_4_1_0_attendees(),
74
-                new EE_DMS_4_1_0_line_items(),
75
-                new EE_DMS_4_1_0_answers(),
76
-                new EE_DMS_4_1_0_checkins(),
77
-        );
78
-        parent::__construct($table_manager, $table_analysis);
79
-    }
80
-
81
-
82
-
83
-    /**
84
-     * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
85
-     *
86
-     * @global wpdb $wpdb
87
-     * @return boolean
88
-     */
89
-    private function _checkin_table_exists()
90
-    {
91
-        global $wpdb;
92
-        $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
93
-        if ($results) {
94
-            return true;
95
-        } else {
96
-            return false;
97
-        }
98
-    }
99
-
100
-
101
-
102
-    public function can_migrate_from_version($version_array)
103
-    {
104
-        $version_string = $version_array['Core'];
105
-        if (version_compare($version_string, '4.0.0.decaf', '<') && version_compare($version_string, '3.1.26', '>=')) {
49
+	/**
50
+	 * EE_DMS_Core_4_1_0 constructor.
51
+	 *
52
+	 * @param TableManager  $table_manager
53
+	 * @param TableAnalysis $table_analysis
54
+	 */
55
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
56
+	{
57
+		$this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso");
58
+		$this->_priority = 10;
59
+		$this->_migration_stages = array(
60
+				new EE_DMS_4_1_0_org_options(),
61
+				new EE_DMS_4_1_0_shortcodes(),
62
+				new EE_DMS_4_1_0_gateways(),
63
+				new EE_DMS_4_1_0_events(),
64
+				new EE_DMS_4_1_0_prices(),
65
+				new EE_DMS_4_1_0_category_details(),
66
+				new EE_DMS_4_1_0_event_category(),
67
+				new EE_DMS_4_1_0_venues(),
68
+				new EE_DMS_4_1_0_event_venue(),
69
+				new EE_DMS_4_1_0_question_groups(),
70
+				new EE_DMS_4_1_0_questions(),
71
+				new EE_DMS_4_1_0_question_group_question(),
72
+				new EE_DMS_4_1_0_event_question_group(),
73
+				new EE_DMS_4_1_0_attendees(),
74
+				new EE_DMS_4_1_0_line_items(),
75
+				new EE_DMS_4_1_0_answers(),
76
+				new EE_DMS_4_1_0_checkins(),
77
+		);
78
+		parent::__construct($table_manager, $table_analysis);
79
+	}
80
+
81
+
82
+
83
+	/**
84
+	 * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
85
+	 *
86
+	 * @global wpdb $wpdb
87
+	 * @return boolean
88
+	 */
89
+	private function _checkin_table_exists()
90
+	{
91
+		global $wpdb;
92
+		$results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
93
+		if ($results) {
94
+			return true;
95
+		} else {
96
+			return false;
97
+		}
98
+	}
99
+
100
+
101
+
102
+	public function can_migrate_from_version($version_array)
103
+	{
104
+		$version_string = $version_array['Core'];
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
-            return true;
108
-        } elseif (! $version_string) {
107
+			return true;
108
+		} elseif (! $version_string) {
109 109
 //          echo "no version string provided: $version_string";
110
-            // no version string provided... this must be pre 4.1
111
-            // because since 4.1 we're
112
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
113
-        } else {
110
+			// no version string provided... this must be pre 4.1
111
+			// because since 4.1 we're
112
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
113
+		} else {
114 114
 //          echo "$version_string doesnt apply";
115
-            return false;
116
-        }
117
-    }
115
+			return false;
116
+		}
117
+	}
118 118
 
119 119
 
120 120
 
121
-    public function schema_changes_before_migration()
122
-    {
123
-        // relies on 4.1's EEH_Activation::create_table
124
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
125
-        $table_name = 'esp_answer';
126
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
121
+	public function schema_changes_before_migration()
122
+	{
123
+		// relies on 4.1's EEH_Activation::create_table
124
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
125
+		$table_name = 'esp_answer';
126
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
127 127
 					REG_ID int(10) unsigned NOT NULL,
128 128
 					QST_ID int(10) unsigned NOT NULL,
129 129
 					ANS_value text NOT NULL,
130 130
 					PRIMARY KEY  (ANS_ID)";
131
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
132
-        $table_name = 'esp_attendee_meta';
133
-        $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
131
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
132
+		$table_name = 'esp_attendee_meta';
133
+		$sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
134 134
 						ATT_ID bigint(20) unsigned NOT NULL,
135 135
 						ATT_fname varchar(45) NOT NULL,
136 136
 						ATT_lname varchar(45) NOT NULL,
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
 								KEY ATT_fname (ATT_fname),
147 147
 								KEY ATT_lname (ATT_lname),
148 148
 								KEY ATT_email (ATT_email(191))";
149
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
150
-        $table_name = 'esp_country';
151
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
149
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
150
+		$table_name = 'esp_country';
151
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
152 152
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
153 153
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
154 154
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 					  CNT_is_EU tinyint(1) DEFAULT '0',
165 165
 					  CNT_active tinyint(1) DEFAULT '0',
166 166
 					  PRIMARY KEY  (CNT_ISO)";
167
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
168
-        $table_name = 'esp_datetime';
169
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
167
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
168
+		$table_name = 'esp_datetime';
169
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
170 170
 				  EVT_ID bigint(20) unsigned NOT NULL,
171 171
 				  DTT_EVT_start datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
172 172
 				  DTT_EVT_end datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 						PRIMARY KEY  (DTT_ID),
180 180
 						KEY EVT_ID (EVT_ID),
181 181
 						KEY DTT_is_primary (DTT_is_primary)";
182
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
183
-        $table_name = 'esp_event_meta';
184
-        $sql = "
182
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
183
+		$table_name = 'esp_event_meta';
184
+		$sql = "
185 185
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
186 186
 			EVT_ID bigint(20) unsigned NOT NULL,
187 187
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -196,31 +196,31 @@  discard block
 block discarded – undo
196 196
 			EVT_external_URL varchar(200) NULL,
197 197
 			EVT_donations tinyint(1) NULL,
198 198
 			PRIMARY KEY  (EVTM_ID)";
199
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
200
-        $table_name = 'esp_event_question_group';
201
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
199
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
200
+		$table_name = 'esp_event_question_group';
201
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
202 202
 					EVT_ID bigint(20) unsigned NOT NULL,
203 203
 					QSG_ID int(10) unsigned NOT NULL,
204 204
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
205 205
 					PRIMARY KEY  (EQG_ID)";
206
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
207
-        $table_name = 'esp_event_venue';
208
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
206
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
207
+		$table_name = 'esp_event_venue';
208
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
209 209
 				EVT_ID bigint(20) unsigned NOT NULL,
210 210
 				VNU_ID bigint(20) unsigned NOT NULL,
211 211
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
212 212
 				PRIMARY KEY  (EVV_ID)";
213
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
214
-        $table_name = 'esp_extra_meta';
215
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
213
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
214
+		$table_name = 'esp_extra_meta';
215
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
216 216
 				OBJ_ID int(11) DEFAULT NULL,
217 217
 				EXM_type varchar(45) DEFAULT NULL,
218 218
 				EXM_key varchar(45) DEFAULT NULL,
219 219
 				EXM_value text,
220 220
 				PRIMARY KEY  (EXM_ID)";
221
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
222
-        $table_name = 'esp_line_item';
223
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
221
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
222
+		$table_name = 'esp_line_item';
223
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
224 224
 				LIN_code varchar(245) NOT NULL DEFAULT '',
225 225
 				TXN_ID int(11) DEFAULT NULL,
226 226
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -236,18 +236,18 @@  discard block
 block discarded – undo
236 236
 				OBJ_ID int(11) DEFAULT NULL,
237 237
 				OBJ_type varchar(45)DEFAULT NULL,
238 238
 				PRIMARY KEY  (LIN_ID)";
239
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
240
-        $table_name = 'esp_message_template';
241
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
239
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
240
+		$table_name = 'esp_message_template';
241
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
242 242
 					GRP_ID int(10) unsigned NOT NULL,
243 243
 					MTP_context varchar(50) NOT NULL,
244 244
 					MTP_template_field varchar(30) NOT NULL,
245 245
 					MTP_content text NOT NULL,
246 246
 					PRIMARY KEY  (MTP_ID),
247 247
 					KEY GRP_ID (GRP_ID)";
248
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
249
-        $table_name = 'esp_message_template_group';
250
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
248
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
249
+		$table_name = 'esp_message_template_group';
250
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
251 251
 					EVT_ID bigint(20) unsigned DEFAULT NULL,
252 252
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
253 253
 					MTP_messenger varchar(30) NOT NULL,
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
 					PRIMARY KEY  (GRP_ID),
260 260
 					KEY EVT_ID (EVT_ID),
261 261
 					KEY MTP_user_id (MTP_user_id)";
262
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
263
-        $table_name = 'esp_payment';
264
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
262
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
263
+		$table_name = 'esp_payment';
264
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
265 265
 					TXN_ID int(10) unsigned DEFAULT NULL,
266 266
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
267 267
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -277,9 +277,9 @@  discard block
 block discarded – undo
277 277
 					PRIMARY KEY  (PAY_ID),
278 278
 					KEY TXN_ID (TXN_ID),
279 279
 					KEY PAY_timestamp (PAY_timestamp)";
280
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
281
-        $table_name = "esp_ticket";
282
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
280
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
281
+		$table_name = "esp_ticket";
282
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
283 283
 					  TTM_ID int(10) unsigned NOT NULL,
284 284
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
285 285
 					  TKT_description text NOT NULL,
@@ -298,28 +298,28 @@  discard block
 block discarded – undo
298 298
 					  TKT_parent int(10) unsigned DEFAULT '0',
299 299
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
300 300
 					  PRIMARY KEY  (TKT_ID)";
301
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
302
-        $table_name = "esp_ticket_price";
303
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
301
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
302
+		$table_name = "esp_ticket_price";
303
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
304 304
 					  TKT_ID int(10) unsigned NOT NULL,
305 305
 					  PRC_ID int(10) unsigned NOT NULL,
306 306
 					  PRIMARY KEY  (TKP_ID)";
307
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
308
-        $table_name = "esp_datetime_ticket";
309
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
307
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
308
+		$table_name = "esp_datetime_ticket";
309
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
310 310
 					  DTT_ID int(10) unsigned NOT NULL,
311 311
 					  TKT_ID int(10) unsigned NOT NULL,
312 312
 					  PRIMARY KEY  (DTK_ID)";
313
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
314
-        $table_name = "esp_ticket_template";
315
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
313
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
314
+		$table_name = "esp_ticket_template";
315
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
316 316
 					  TTM_name varchar(45) NOT NULL,
317 317
 					  TTM_description text,
318 318
 					  TTM_file varchar(45),
319 319
 					  PRIMARY KEY  (TTM_ID)";
320
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
321
-        $table_name = "esp_price";
322
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
320
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
321
+		$table_name = "esp_price";
322
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
323 323
 					  PRT_ID tinyint(3) unsigned NOT NULL,
324 324
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
325 325
 					  PRC_name varchar(245) NOT NULL,
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
 					  PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0',
331 331
 					  PRC_parent int(10) unsigned DEFAULT 0,
332 332
 					  PRIMARY KEY  (PRC_ID)";
333
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
334
-        $table_name = "esp_price_type";
335
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
333
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
334
+		$table_name = "esp_price_type";
335
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
336 336
 				  PRT_name varchar(45) NOT NULL,
337 337
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
338 338
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
341 341
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
342 342
 				  PRIMARY KEY  (PRT_ID)";
343
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
344
-        $table_name = 'esp_question';
345
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
343
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
344
+		$table_name = 'esp_question';
345
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
346 346
 					QST_display_text text NOT NULL,
347 347
 					QST_admin_label varchar(255) NOT NULL,
348 348
 					QST_system varchar(25) DEFAULT NULL,
@@ -354,10 +354,10 @@  discard block
 block discarded – undo
354 354
 					QST_wp_user bigint(20) unsigned NULL,
355 355
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
356 356
 					PRIMARY KEY  (QST_ID)';
357
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
358
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
359
-        $table_name = 'esp_question_group';
360
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
357
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
358
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
359
+		$table_name = 'esp_question_group';
360
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
361 361
 					QSG_name varchar(255) NOT NULL,
362 362
 					QSG_identifier varchar(100) NOT NULL,
363 363
 					QSG_desc text NULL,
@@ -368,23 +368,23 @@  discard block
 block discarded – undo
368 368
 					QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
369 369
 					PRIMARY KEY  (QSG_ID),
370 370
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
371
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
372
-        $table_name = 'esp_question_group_question';
373
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
371
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
372
+		$table_name = 'esp_question_group_question';
373
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
374 374
 					QSG_ID int(10) unsigned NOT NULL,
375 375
 					QST_ID int(10) unsigned NOT NULL,
376 376
 					PRIMARY KEY  (QGQ_ID) ";
377
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
378
-        $table_name = 'esp_question_option';
379
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
377
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
378
+		$table_name = 'esp_question_option';
379
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
380 380
 					QSO_value varchar(255) NOT NULL,
381 381
 					QSO_desc text NOT NULL,
382 382
 					QST_ID int(10) unsigned NOT NULL,
383 383
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
384 384
 					PRIMARY KEY  (QSO_ID)";
385
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
386
-        $table_name = 'esp_registration';
387
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
385
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
386
+		$table_name = 'esp_registration';
387
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
388 388
 					  EVT_ID bigint(20) unsigned NOT NULL,
389 389
 					  ATT_ID bigint(20) unsigned NOT NULL,
390 390
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -407,25 +407,25 @@  discard block
 block discarded – undo
407 407
 					  KEY STS_ID (STS_ID),
408 408
 					  KEY REG_url_link (REG_url_link),
409 409
 					  KEY REG_code (REG_code)";
410
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
411
-        $table_name = 'esp_checkin';
412
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
410
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
411
+		$table_name = 'esp_checkin';
412
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
413 413
 					REG_ID int(10) unsigned NOT NULL,
414 414
 					DTT_ID int(10) unsigned NOT NULL,
415 415
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
416 416
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
417 417
 					PRIMARY KEY  (CHK_ID)";
418
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
419
-        $table_name = 'esp_state';
420
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
418
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
419
+		$table_name = 'esp_state';
420
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
421 421
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
422 422
 					  STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL,
423 423
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
424 424
 					  STA_active tinyint(1) DEFAULT '1',
425 425
 					  PRIMARY KEY  (STA_ID)";
426
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
427
-        $table_name = 'esp_status';
428
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
426
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
427
+		$table_name = 'esp_status';
428
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
429 429
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
430 430
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
431 431
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
434 434
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
435 435
 					  KEY STS_type (STS_type)";
436
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
437
-        $table_name = 'esp_transaction';
438
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
436
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
437
+		$table_name = 'esp_transaction';
438
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
439 439
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
440 440
 					  TXN_total decimal(10,3) DEFAULT '0.00',
441 441
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
 					  PRIMARY KEY  (TXN_ID),
446 446
 					  KEY TXN_timestamp (TXN_timestamp),
447 447
 					  KEY STS_ID (STS_ID)";
448
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
449
-        $table_name = 'esp_venue_meta';
450
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
448
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
449
+		$table_name = 'esp_venue_meta';
450
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
451 451
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
452 452
 			VNU_address varchar(255) DEFAULT NULL,
453 453
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -465,52 +465,52 @@  discard block
 block discarded – undo
465 465
 			PRIMARY KEY  (VNUM_ID),
466 466
 			KEY STA_ID (STA_ID),
467 467
 			KEY CNT_ISO (CNT_ISO)";
468
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
469
-        // setting up the default stats and countries is also essential for the data migrations to run
470
-        // (because many need to convert old string states to foreign keys into the states table)
471
-        $this->insert_default_states();
472
-        $this->insert_default_countries();
473
-        // setting up default prices, price types, and tickets is also essential for the price migrations
474
-        $this->insert_default_price_types();
475
-        $this->insert_default_prices();
476
-        $this->insert_default_tickets();
477
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
478
-        EE_Config::instance()->update_espresso_config(false, true);
479
-        return true;
480
-    }
481
-
482
-
483
-
484
-    /**
485
-     * Yes we could have cleaned up the ee3 tables here. But just in case someone
486
-     * didn't backup their DB, and decides they want ot keep using EE3, we'll
487
-     * leave them for now. Mayeb remove them in 4.5 or something.
488
-     *
489
-     * @return boolean
490
-     */
491
-    public function schema_changes_after_migration()
492
-    {
493
-        return true;
494
-    }
495
-
496
-
497
-
498
-    /**
499
-     * insert_default_states
500
-     *
501
-     * @access public
502
-     * @static
503
-     * @return void
504
-     */
505
-    public function insert_default_states()
506
-    {
507
-        global $wpdb;
508
-        $state_table = $wpdb->prefix . "esp_state";
509
-        if ($this->_get_table_analysis()->tableExists($state_table)) {
510
-            $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
511
-            $states = $wpdb->get_var($SQL);
512
-            if (! $states) {
513
-                $SQL = "INSERT INTO " . $state_table . "
468
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
469
+		// setting up the default stats and countries is also essential for the data migrations to run
470
+		// (because many need to convert old string states to foreign keys into the states table)
471
+		$this->insert_default_states();
472
+		$this->insert_default_countries();
473
+		// setting up default prices, price types, and tickets is also essential for the price migrations
474
+		$this->insert_default_price_types();
475
+		$this->insert_default_prices();
476
+		$this->insert_default_tickets();
477
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
478
+		EE_Config::instance()->update_espresso_config(false, true);
479
+		return true;
480
+	}
481
+
482
+
483
+
484
+	/**
485
+	 * Yes we could have cleaned up the ee3 tables here. But just in case someone
486
+	 * didn't backup their DB, and decides they want ot keep using EE3, we'll
487
+	 * leave them for now. Mayeb remove them in 4.5 or something.
488
+	 *
489
+	 * @return boolean
490
+	 */
491
+	public function schema_changes_after_migration()
492
+	{
493
+		return true;
494
+	}
495
+
496
+
497
+
498
+	/**
499
+	 * insert_default_states
500
+	 *
501
+	 * @access public
502
+	 * @static
503
+	 * @return void
504
+	 */
505
+	public function insert_default_states()
506
+	{
507
+		global $wpdb;
508
+		$state_table = $wpdb->prefix . "esp_state";
509
+		if ($this->_get_table_analysis()->tableExists($state_table)) {
510
+			$SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
511
+			$states = $wpdb->get_var($SQL);
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),
@@ -584,29 +584,29 @@  discard block
 block discarded – undo
584 584
 				(70, 'CA', 'NT', 'Northwest Territories', 1),
585 585
 				(71, 'CA', 'NU', 'Nunavut', 1),
586 586
 				(72, 'CA', 'YT', 'Yukon', 1);";
587
-                $wpdb->query($SQL);
588
-            }
589
-        }
590
-    }
591
-
592
-
593
-
594
-    /**
595
-     * insert_default_countries
596
-     *
597
-     * @access public
598
-     * @static
599
-     * @return void
600
-     */
601
-    public function insert_default_countries()
602
-    {
603
-        global $wpdb;
604
-        $country_table = $wpdb->prefix . "esp_country";
605
-        if ($this->_get_table_analysis()->tableExists($country_table)) {
606
-            $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
607
-            $countries = $wpdb->get_var($SQL);
608
-            if (! $countries) {
609
-                $SQL = "INSERT INTO " . $country_table . "
587
+				$wpdb->query($SQL);
588
+			}
589
+		}
590
+	}
591
+
592
+
593
+
594
+	/**
595
+	 * insert_default_countries
596
+	 *
597
+	 * @access public
598
+	 * @static
599
+	 * @return void
600
+	 */
601
+	public function insert_default_countries()
602
+	{
603
+		global $wpdb;
604
+		$country_table = $wpdb->prefix . "esp_country";
605
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
606
+			$SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
607
+			$countries = $wpdb->get_var($SQL);
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),
@@ -834,984 +834,984 @@  discard block
 block discarded – undo
834 834
 				('ZA', 'ZAF', 0, 'South Africa', 'ZAR', 'Rand', 'Rands', 'R', 1, 2, '+27', 0, 0),
835 835
 				('ZM', 'ZMB', 0, 'Zambia', 'ZMK', 'Kwacha', 'Kwachas', '', 1, 2, '+260', 0, 0),
836 836
 				('ZW', 'ZWE', 0, 'Zimbabwe', 'ZWD', 'Dollar', 'Dollars', 'Z$', 1, 2, '+263', 0, 0);";
837
-                $wpdb->query($SQL);
838
-            }
839
-        }
840
-    }
841
-
842
-
843
-
844
-    /**
845
-     * insert_default_price_types
846
-     *
847
-     * @access public
848
-     * @static
849
-     * @return void
850
-     */
851
-    public function insert_default_price_types()
852
-    {
853
-        global $wpdb;
854
-        $price_type_table = $wpdb->prefix . "esp_price_type";
855
-        if ($this->_get_table_analysis()->tableExists($price_type_table)) {
856
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
857
-            $price_types_exist = $wpdb->get_var($SQL);
858
-            if (! $price_types_exist) {
859
-                $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
837
+				$wpdb->query($SQL);
838
+			}
839
+		}
840
+	}
841
+
842
+
843
+
844
+	/**
845
+	 * insert_default_price_types
846
+	 *
847
+	 * @access public
848
+	 * @static
849
+	 * @return void
850
+	 */
851
+	public function insert_default_price_types()
852
+	{
853
+		global $wpdb;
854
+		$price_type_table = $wpdb->prefix . "esp_price_type";
855
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
856
+			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
857
+			$price_types_exist = $wpdb->get_var($SQL);
858
+			if (! $price_types_exist) {
859
+				$SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
860 860
 							(1, '" . esc_html__('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
861 861
 							(2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
862 862
 							(3, '" . esc_html__('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
863 863
 							(4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
864 864
 							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
865
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
866
-                $wpdb->query($SQL);
867
-            }
868
-        }
869
-    }
870
-
871
-
872
-
873
-    /**
874
-     * insert_default_prices. We assume we're upgrading to regular here.
875
-     * If we're INSTALLING 4.1 CAF, then we add a few extra default prices
876
-     * when EEH_Activaion's initialize_db_content is called via  ahook in
877
-     * EE_BRewing_regular
878
-     *
879
-     * @access public
880
-     * @static
881
-     * @return void
882
-     */
883
-    public function insert_default_prices()
884
-    {
885
-        global $wpdb;
886
-        $price_table = $wpdb->prefix . "esp_price";
887
-        if ($this->_get_table_analysis()->tableExists($price_table)) {
888
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
889
-            $prices_exist = $wpdb->get_var($SQL);
890
-            if (! $prices_exist) {
891
-                $SQL = "INSERT INTO $price_table
865
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
866
+				$wpdb->query($SQL);
867
+			}
868
+		}
869
+	}
870
+
871
+
872
+
873
+	/**
874
+	 * insert_default_prices. We assume we're upgrading to regular here.
875
+	 * If we're INSTALLING 4.1 CAF, then we add a few extra default prices
876
+	 * when EEH_Activaion's initialize_db_content is called via  ahook in
877
+	 * EE_BRewing_regular
878
+	 *
879
+	 * @access public
880
+	 * @static
881
+	 * @return void
882
+	 */
883
+	public function insert_default_prices()
884
+	{
885
+		global $wpdb;
886
+		$price_table = $wpdb->prefix . "esp_price";
887
+		if ($this->_get_table_analysis()->tableExists($price_table)) {
888
+			$SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
889
+			$prices_exist = $wpdb->get_var($SQL);
890
+			if (! $prices_exist) {
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', 'Free Admission', '', 1, null, 0, 0, 0);";
894
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
895
-                $wpdb->query($SQL);
896
-            }
897
-        }
898
-    }
899
-
900
-
901
-
902
-    /**
903
-     * insert default ticket
904
-     *
905
-     * @access public
906
-     * @static
907
-     * @return void
908
-     */
909
-    public function insert_default_tickets()
910
-    {
911
-        global $wpdb;
912
-        $ticket_table = $wpdb->prefix . "esp_ticket";
913
-        if ($this->_get_table_analysis()->tableExists($ticket_table)) {
914
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
915
-            $tickets_exist = $wpdb->get_var($SQL);
916
-            if (! $tickets_exist) {
917
-                $SQL = "INSERT INTO $ticket_table
894
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
895
+				$wpdb->query($SQL);
896
+			}
897
+		}
898
+	}
899
+
900
+
901
+
902
+	/**
903
+	 * insert default ticket
904
+	 *
905
+	 * @access public
906
+	 * @static
907
+	 * @return void
908
+	 */
909
+	public function insert_default_tickets()
910
+	{
911
+		global $wpdb;
912
+		$ticket_table = $wpdb->prefix . "esp_ticket";
913
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
914
+			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
915
+			$tickets_exist = $wpdb->get_var($SQL);
916
+			if (! $tickets_exist) {
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, '"
920
-                       . esc_html__("Free Ticket", "event_espresso")
921
-                       . "', '', 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);";
922
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
923
-                $wpdb->query($SQL);
924
-            }
925
-        }
926
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
927
-        if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
928
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
929
-            $ticket_prc_exist = $wpdb->get_var($SQL);
930
-            if (! $ticket_prc_exist) {
931
-                $SQL = "INSERT INTO $ticket_price_table
920
+					   . esc_html__("Free Ticket", "event_espresso")
921
+					   . "', '', 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);";
922
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
923
+				$wpdb->query($SQL);
924
+			}
925
+		}
926
+		$ticket_price_table = $wpdb->prefix . "esp_ticket_price";
927
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
928
+			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
929
+			$ticket_prc_exist = $wpdb->get_var($SQL);
930
+			if (! $ticket_prc_exist) {
931
+				$SQL = "INSERT INTO $ticket_price_table
932 932
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
933 933
 				( 1, 1, 1 )
934 934
 				";
935
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
936
-                $wpdb->query($SQL);
937
-            }
938
-        }
939
-    }
940
-
941
-
942
-
943
-    /**
944
-     * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(),
945
-     * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1
946
-     * country ID (int), a 2-letter ISO, 3-letter ISO, or name
947
-     *
948
-     * @global type  $wpdb
949
-     * @param string $country_name
950
-     * @return array where keys are columns, values are column values
951
-     */
952
-    public function get_or_create_country($country_name)
953
-    {
954
-        if (! $country_name) {
955
-            throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
956
-        }
957
-        global $wpdb;
958
-        $country_table = $wpdb->prefix . "esp_country";
959
-        if (is_int($country_name)) {
960
-            $country_name = $this->get_iso_from_3_1_country_id($country_name);
961
-        }
962
-        $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
935
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
936
+				$wpdb->query($SQL);
937
+			}
938
+		}
939
+	}
940
+
941
+
942
+
943
+	/**
944
+	 * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(),
945
+	 * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1
946
+	 * country ID (int), a 2-letter ISO, 3-letter ISO, or name
947
+	 *
948
+	 * @global type  $wpdb
949
+	 * @param string $country_name
950
+	 * @return array where keys are columns, values are column values
951
+	 */
952
+	public function get_or_create_country($country_name)
953
+	{
954
+		if (! $country_name) {
955
+			throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
956
+		}
957
+		global $wpdb;
958
+		$country_table = $wpdb->prefix . "esp_country";
959
+		if (is_int($country_name)) {
960
+			$country_name = $this->get_iso_from_3_1_country_id($country_name);
961
+		}
962
+		$country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
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) {
967
-            // insert a new one then
968
-            $cols_n_values = array(
969
-                    'CNT_ISO'         => $this->_find_available_country_iso(2),
970
-                    'CNT_ISO3'        => $this->_find_available_country_iso(3),
971
-                    'RGN_ID'          => 0,
972
-                    'CNT_name'        => $country_name,
973
-                    'CNT_cur_code'    => 'USD',
974
-                    'CNT_cur_single'  => 'Dollar',
975
-                    'CNT_cur_plural'  => 'Dollars',
976
-                    'CNT_cur_sign'    => '&#36;',
977
-                    'CNT_cur_sign_b4' => true,
978
-                    'CNT_cur_dec_plc' => 2,
979
-                    'CNT_cur_dec_mrk' => '.',
980
-                    'CNT_cur_thsnds'  => ',',
981
-                    'CNT_tel_code'    => '+1',
982
-                    'CNT_is_EU'       => false,
983
-                    'CNT_active'      => true,
984
-            );
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
1001
-            );
1002
-            $success = $wpdb->insert(
1003
-                $country_table,
1004
-                $cols_n_values,
1005
-                $data_types
1006
-            );
1007
-            if (! $success) {
1008
-                throw new EE_Error($this->_create_error_message_for_db_insertion(
1009
-                    'N/A',
1010
-                    array('country_id' => $country_name),
1011
-                    $country_table,
1012
-                    $cols_n_values,
1013
-                    $data_types
1014
-                ));
1015
-            }
1016
-            $country = $cols_n_values;
1017
-        }
1018
-        return $country;
1019
-    }
1020
-
1021
-
1022
-
1023
-    /**
1024
-     * finds a country iso which hasnt been used yet
1025
-     *
1026
-     * @global type $wpdb
1027
-     * @return string
1028
-     */
1029
-    private function _find_available_country_iso($num_letters = 2)
1030
-    {
1031
-        global $wpdb;
1032
-        $country_table = $wpdb->prefix . "esp_country";
1033
-        $attempts = 0;
1034
-        do {
1035
-            $current_iso = strtoupper(wp_generate_password($num_letters, false));
1036
-            $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM "
1037
-                                                                   . $country_table
1038
-                                                                   . " WHERE CNT_ISO=%s", $current_iso));
1039
-            $attempts++;
1040
-            // keep going until we find an available country code, or we arbitrarily
1041
-            // decide we've tried this enough. Somehow they have way too many countries
1042
-            // (probably because they're mis-using the EE3 country_id like a custom question)
1043
-        } while (intval($country_with_that_iso) && $attempts < 200);
1044
-        return $current_iso;
1045
-    }
1046
-
1047
-
1048
-
1049
-    /**
1050
-     * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but
1051
-     * is independent of outside code which can change in future versions of EE
1052
-     *
1053
-     * @global type  $wpdb
1054
-     * @param string $state_name
1055
-     * @return array where keys are columns, values are column values
1056
-     */
1057
-    public function get_or_create_state($state_name, $country_name = '')
1058
-    {
1059
-        if (! $state_name) {
1060
-            throw new EE_Error(esc_html__(
1061
-                "Could not get-or-create state because no state name was provided",
1062
-                "event_espresso"
1063
-            ));
1064
-        }
1065
-        try {
1066
-            $country = $this->get_or_create_country($country_name);
1067
-            $country_iso = $country['CNT_ISO'];
1068
-        } catch (EE_Error $e) {
1069
-            $country_iso = $this->get_default_country_iso();
1070
-        }
1071
-        global $wpdb;
1072
-        $state_table = $wpdb->prefix . "esp_state";
1073
-        $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
966
+		if (! $country) {
967
+			// insert a new one then
968
+			$cols_n_values = array(
969
+					'CNT_ISO'         => $this->_find_available_country_iso(2),
970
+					'CNT_ISO3'        => $this->_find_available_country_iso(3),
971
+					'RGN_ID'          => 0,
972
+					'CNT_name'        => $country_name,
973
+					'CNT_cur_code'    => 'USD',
974
+					'CNT_cur_single'  => 'Dollar',
975
+					'CNT_cur_plural'  => 'Dollars',
976
+					'CNT_cur_sign'    => '&#36;',
977
+					'CNT_cur_sign_b4' => true,
978
+					'CNT_cur_dec_plc' => 2,
979
+					'CNT_cur_dec_mrk' => '.',
980
+					'CNT_cur_thsnds'  => ',',
981
+					'CNT_tel_code'    => '+1',
982
+					'CNT_is_EU'       => false,
983
+					'CNT_active'      => true,
984
+			);
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
1001
+			);
1002
+			$success = $wpdb->insert(
1003
+				$country_table,
1004
+				$cols_n_values,
1005
+				$data_types
1006
+			);
1007
+			if (! $success) {
1008
+				throw new EE_Error($this->_create_error_message_for_db_insertion(
1009
+					'N/A',
1010
+					array('country_id' => $country_name),
1011
+					$country_table,
1012
+					$cols_n_values,
1013
+					$data_types
1014
+				));
1015
+			}
1016
+			$country = $cols_n_values;
1017
+		}
1018
+		return $country;
1019
+	}
1020
+
1021
+
1022
+
1023
+	/**
1024
+	 * finds a country iso which hasnt been used yet
1025
+	 *
1026
+	 * @global type $wpdb
1027
+	 * @return string
1028
+	 */
1029
+	private function _find_available_country_iso($num_letters = 2)
1030
+	{
1031
+		global $wpdb;
1032
+		$country_table = $wpdb->prefix . "esp_country";
1033
+		$attempts = 0;
1034
+		do {
1035
+			$current_iso = strtoupper(wp_generate_password($num_letters, false));
1036
+			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM "
1037
+																   . $country_table
1038
+																   . " WHERE CNT_ISO=%s", $current_iso));
1039
+			$attempts++;
1040
+			// keep going until we find an available country code, or we arbitrarily
1041
+			// decide we've tried this enough. Somehow they have way too many countries
1042
+			// (probably because they're mis-using the EE3 country_id like a custom question)
1043
+		} while (intval($country_with_that_iso) && $attempts < 200);
1044
+		return $current_iso;
1045
+	}
1046
+
1047
+
1048
+
1049
+	/**
1050
+	 * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but
1051
+	 * is independent of outside code which can change in future versions of EE
1052
+	 *
1053
+	 * @global type  $wpdb
1054
+	 * @param string $state_name
1055
+	 * @return array where keys are columns, values are column values
1056
+	 */
1057
+	public function get_or_create_state($state_name, $country_name = '')
1058
+	{
1059
+		if (! $state_name) {
1060
+			throw new EE_Error(esc_html__(
1061
+				"Could not get-or-create state because no state name was provided",
1062
+				"event_espresso"
1063
+			));
1064
+		}
1065
+		try {
1066
+			$country = $this->get_or_create_country($country_name);
1067
+			$country_iso = $country['CNT_ISO'];
1068
+		} catch (EE_Error $e) {
1069
+			$country_iso = $this->get_default_country_iso();
1070
+		}
1071
+		global $wpdb;
1072
+		$state_table = $wpdb->prefix . "esp_state";
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) {
1078
-            // insert a new one then
1079
-            $cols_n_values = array(
1080
-                    'CNT_ISO'    => $country_iso,
1081
-                    'STA_abbrev' => substr($state_name, 0, 6),
1082
-                    'STA_name'   => $state_name,
1083
-                    'STA_active' => true,
1084
-            );
1085
-            $data_types = array(
1086
-                    '%s',// CNT_ISO
1087
-                    '%s',// STA_abbrev
1088
-                    '%s',// STA_name
1089
-                    '%d',// STA_active
1090
-            );
1091
-            $success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1092
-            if (! $success) {
1093
-                throw new EE_Error($this->_create_error_message_for_db_insertion(
1094
-                    'N/A',
1095
-                    array('state' => $state_name, 'country_id' => $country_name),
1096
-                    $state_table,
1097
-                    $cols_n_values,
1098
-                    $data_types
1099
-                ));
1100
-            }
1101
-            $state = $cols_n_values;
1102
-            $state['STA_ID'] = $wpdb->insert_id;
1103
-        }
1104
-        return $state;
1105
-    }
1106
-
1107
-
1108
-
1109
-    /**
1110
-     * Fixes times like "5:00 PM" into the expected 24-hour format "17:00".
1111
-     * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing
1112
-     *
1113
-     * @param type $timeString
1114
-     * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes
1115
-     *                with leading zeros)
1116
-     */
1117
-    public function convertTimeFromAMPM($timeString)
1118
-    {
1119
-        $matches = array();
1120
-        preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1121
-        if (! $matches || count($matches) < 3) {
1122
-            $hour = '00';
1123
-            $minutes = '00';
1124
-        } else {
1125
-            $hour = intval($matches[1]);
1126
-            $minutes = $matches[2];
1127
-        }
1128
-        if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1129
-            $hour = intval($hour) + 12;
1130
-        }
1131
-        $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1132
-        $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1133
-        return "$hour:$minutes";
1134
-    }
1135
-
1136
-
1137
-
1138
-    /**
1139
-     * Gets the ISO3 fora country given its 3.1 country ID.
1140
-     *
1141
-     * @param int $country_id
1142
-     * @return string the country's ISO3 code
1143
-     */
1144
-    public function get_iso_from_3_1_country_id($country_id)
1145
-    {
1146
-        $old_countries = array(
1147
-                array(64, 'United States', 'US', 'USA', 1),
1148
-                array(15, 'Australia', 'AU', 'AUS', 1),
1149
-                array(39, 'Canada', 'CA', 'CAN', 1),
1150
-                array(171, 'United Kingdom', 'GB', 'GBR', 1),
1151
-                array(70, 'France', 'FR', 'FRA', 2),
1152
-                array(111, 'Italy', 'IT', 'ITA', 2),
1153
-                array(63, 'Spain', 'ES', 'ESP', 2),
1154
-                array(1, 'Afghanistan', 'AF', 'AFG', 1),
1155
-                array(2, 'Albania', 'AL', 'ALB', 1),
1156
-                array(3, 'Germany', 'DE', 'DEU', 2),
1157
-                array(198, 'Switzerland', 'CH', 'CHE', 1),
1158
-                array(87, 'Netherlands', 'NL', 'NLD', 2),
1159
-                array(197, 'Sweden', 'SE', 'SWE', 1),
1160
-                array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2),
1161
-                array(4, 'Andorra', 'AD', 'AND', 2),
1162
-                array(5, 'Angola', 'AO', 'AGO', 1),
1163
-                array(6, 'Anguilla', 'AI', 'AIA', 1),
1164
-                array(7, 'Antarctica', 'AQ', 'ATA', 1),
1165
-                array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1),
1166
-                array(10, 'Saudi Arabia', 'SA', 'SAU', 1),
1167
-                array(11, 'Algeria', 'DZ', 'DZA', 1),
1168
-                array(12, 'Argentina', 'AR', 'ARG', 1),
1169
-                array(13, 'Armenia', 'AM', 'ARM', 1),
1170
-                array(14, 'Aruba', 'AW', 'ABW', 1),
1171
-                array(16, 'Austria', 'AT', 'AUT', 2),
1172
-                array(17, 'Azerbaijan', 'AZ', 'AZE', 1),
1173
-                array(18, 'Bahamas', 'BS', 'BHS', 1),
1174
-                array(19, 'Bahrain', 'BH', 'BHR', 1),
1175
-                array(20, 'Bangladesh', 'BD', 'BGD', 1),
1176
-                array(21, 'Barbados', 'BB', 'BRB', 1),
1177
-                array(22, 'Belgium ', 'BE', 'BEL', 2),
1178
-                array(23, 'Belize', 'BZ', 'BLZ', 1),
1179
-                array(24, 'Benin', 'BJ', 'BEN', 1),
1180
-                array(25, 'Bermudas', 'BM', 'BMU', 1),
1181
-                array(26, 'Belarus', 'BY', 'BLR', 1),
1182
-                array(27, 'Bolivia', 'BO', 'BOL', 1),
1183
-                array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1),
1184
-                array(29, 'Botswana', 'BW', 'BWA', 1),
1185
-                array(96, 'Bouvet Island', 'BV', 'BVT', 1),
1186
-                array(30, 'Brazil', 'BR', 'BRA', 1),
1187
-                array(31, 'Brunei', 'BN', 'BRN', 1),
1188
-                array(32, 'Bulgaria', 'BG', 'BGR', 1),
1189
-                array(33, 'Burkina Faso', 'BF', 'BFA', 1),
1190
-                array(34, 'Burundi', 'BI', 'BDI', 1),
1191
-                array(35, 'Bhutan', 'BT', 'BTN', 1),
1192
-                array(36, 'Cape Verde', 'CV', 'CPV', 1),
1193
-                array(37, 'Cambodia', 'KH', 'KHM', 1),
1194
-                array(38, 'Cameroon', 'CM', 'CMR', 1),
1195
-                array(98, 'Cayman Islands', 'KY', 'CYM', 1),
1196
-                array(172, 'Central African Republic', 'CF', 'CAF', 1),
1197
-                array(40, 'Chad', 'TD', 'TCD', 1),
1198
-                array(41, 'Chile', 'CL', 'CHL', 1),
1199
-                array(42, 'China', 'CN', 'CHN', 1),
1200
-                array(105, 'Christmas Island', 'CX', 'CXR', 1),
1201
-                array(43, 'Cyprus', 'CY', 'CYP', 2),
1202
-                array(99, 'Cocos Island', 'CC', 'CCK', 1),
1203
-                array(100, 'Cook Islands', 'CK', 'COK', 1),
1204
-                array(44, 'Colombia', 'CO', 'COL', 1),
1205
-                array(45, 'Comoros', 'KM', 'COM', 1),
1206
-                array(46, 'Congo', 'CG', 'COG', 1),
1207
-                array(47, 'North Korea', 'KP', 'PRK', 1),
1208
-                array(50, 'Costa Rica', 'CR', 'CRI', 1),
1209
-                array(51, 'Croatia', 'HR', 'HRV', 1),
1210
-                array(52, 'Cuba', 'CU', 'CUB', 1),
1211
-                array(173, 'Czech Republic', 'CZ', 'CZE', 1),
1212
-                array(53, 'Denmark', 'DK', 'DNK', 1),
1213
-                array(54, 'Djibouti', 'DJ', 'DJI', 1),
1214
-                array(55, 'Dominica', 'DM', 'DMA', 1),
1215
-                array(174, 'Dominican Republic', 'DO', 'DOM', 1),
1216
-                array(56, 'Ecuador', 'EC', 'ECU', 1),
1217
-                array(57, 'Egypt', 'EG', 'EGY', 1),
1218
-                array(58, 'El Salvador', 'SV', 'SLV', 1),
1219
-                array(60, 'Eritrea', 'ER', 'ERI', 1),
1220
-                array(61, 'Slovakia', 'SK', 'SVK', 2),
1221
-                array(62, 'Slovenia', 'SI', 'SVN', 2),
1222
-                array(65, 'Estonia', 'EE', 'EST', 2),
1223
-                array(66, 'Ethiopia', 'ET', 'ETH', 1),
1224
-                array(102, 'Faroe islands', 'FO', 'FRO', 1),
1225
-                array(103, 'Falkland Islands', 'FK', 'FLK', 1),
1226
-                array(67, 'Fiji', 'FJ', 'FJI', 1),
1227
-                array(69, 'Finland', 'FI', 'FIN', 2),
1228
-                array(71, 'Gabon', 'GA', 'GAB', 1),
1229
-                array(72, 'Gambia', 'GM', 'GMB', 1),
1230
-                array(73, 'Georgia', 'GE', 'GEO', 1),
1231
-                array(74, 'Ghana', 'GH', 'GHA', 1),
1232
-                array(75, 'Gibraltar', 'GI', 'GIB', 1),
1233
-                array(76, 'Greece', 'GR', 'GRC', 2),
1234
-                array(77, 'Grenada', 'GD', 'GRD', 1),
1235
-                array(78, 'Greenland', 'GL', 'GRL', 1),
1236
-                array(79, 'Guadeloupe', 'GP', 'GLP', 1),
1237
-                array(80, 'Guam', 'GU', 'GUM', 1),
1238
-                array(81, 'Guatemala', 'GT', 'GTM', 1),
1239
-                array(82, 'Guinea', 'GN', 'GIN', 1),
1240
-                array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1),
1241
-                array(84, 'Guinea-Bissau', 'GW', 'GNB', 1),
1242
-                array(85, 'Guyana', 'GY', 'GUY', 1),
1243
-                array(86, 'Haiti', 'HT', 'HTI', 1),
1244
-                array(88, 'Honduras', 'HN', 'HND', 1),
1245
-                array(89, 'Hong Kong', 'HK', 'HKG', 1),
1246
-                array(90, 'Hungary', 'HU', 'HUN', 1),
1247
-                array(91, 'India', 'IN', 'IND', 1),
1248
-                array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1),
1249
-                array(92, 'Indonesia', 'ID', 'IDN', 1),
1250
-                array(93, 'Iraq', 'IQ', 'IRQ', 1),
1251
-                array(94, 'Iran', 'IR', 'IRN', 1),
1252
-                array(95, 'Ireland', 'IE', 'IRL', 2),
1253
-                array(97, 'Iceland', 'IS', 'ISL', 1),
1254
-                array(110, 'Israel', 'IL', 'ISR', 1),
1255
-                array(49, 'Ivory Coast ', 'CI', 'CIV', 1),
1256
-                array(112, 'Jamaica', 'JM', 'JAM', 1),
1257
-                array(113, 'Japan', 'JP', 'JPN', 1),
1258
-                array(114, 'Jordan', 'JO', 'JOR', 1),
1259
-                array(115, 'Kazakhstan', 'KZ', 'KAZ', 1),
1260
-                array(116, 'Kenya', 'KE', 'KEN', 1),
1261
-                array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1),
1262
-                array(118, 'Kiribati', 'KI', 'KIR', 1),
1263
-                array(48, 'South Korea', 'KR', 'KOR', 1),
1264
-                array(228, 'Kosovo', 'XK', 'XKV', 2),
1265
-                // 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
1266
-                array(119, 'Kuwait', 'KW', 'KWT', 1),
1267
-                array(120, 'Laos', 'LA', 'LAO', 1),
1268
-                array(121, 'Latvia', 'LV', 'LVA', 2),
1269
-                array(122, 'Lesotho', 'LS', 'LSO', 1),
1270
-                array(123, 'Lebanon', 'LB', 'LBN', 1),
1271
-                array(124, 'Liberia', 'LR', 'LBR', 1),
1272
-                array(125, 'Libya', 'LY', 'LBY', 1),
1273
-                array(126, 'Liechtenstein', 'LI', 'LIE', 1),
1274
-                array(127, 'Lithuania', 'LT', 'LTU', 2),
1275
-                array(128, 'Luxemburg', 'LU', 'LUX', 2),
1276
-                array(129, 'Macao', 'MO', 'MAC', 1),
1277
-                array(130, 'Macedonia', 'MK', 'MKD', 1),
1278
-                array(131, 'Madagascar', 'MG', 'MDG', 1),
1279
-                array(132, 'Malaysia', 'MY', 'MYS', 1),
1280
-                array(133, 'Malawi', 'MW', 'MWI', 1),
1281
-                array(134, 'Maldivas', 'MV', 'MDV', 1),
1282
-                array(135, 'Mali', 'ML', 'MLI', 1),
1283
-                array(136, 'Malta', 'MT', 'MLT', 2),
1284
-                array(101, 'Northern Marianas', 'MP', 'MNP', 1),
1285
-                array(137, 'Morocco', 'MA', 'MAR', 1),
1286
-                array(104, 'Marshall islands', 'MH', 'MHL', 1),
1287
-                array(138, 'Martinique', 'MQ', 'MTQ', 1),
1288
-                array(139, 'Mauritius', 'MU', 'MUS', 1),
1289
-                array(140, 'Mauritania', 'MR', 'MRT', 1),
1290
-                array(141, 'Mayote', 'YT', 'MYT', 2),
1291
-                array(142, 'Mexico', 'MX', 'MEX', 1),
1292
-                array(143, 'Micronesia', 'FM', 'FSM', 1),
1293
-                array(144, 'Moldova', 'MD', 'MDA', 1),
1294
-                array(145, 'Monaco', 'MC', 'MCO', 2),
1295
-                array(146, 'Mongolia', 'MN', 'MNG', 1),
1296
-                array(147, 'Montserrat', 'MS', 'MSR', 1),
1297
-                array(227, 'Montenegro', 'ME', 'MNE', 2),
1298
-                array(148, 'Mozambique', 'MZ', 'MOZ', 1),
1299
-                array(149, 'Myanmar', 'MM', 'MMR', 1),
1300
-                array(150, 'Namibia', 'NA', 'NAM', 1),
1301
-                array(151, 'Nauru', 'NR', 'NRU', 1),
1302
-                array(152, 'Nepal', 'NP', 'NPL', 1),
1303
-                array(9, 'Netherlands Antilles', 'AN', 'ANT', 1),
1304
-                array(153, 'Nicaragua', 'NI', 'NIC', 1),
1305
-                array(154, 'Niger', 'NE', 'NER', 1),
1306
-                array(155, 'Nigeria', 'NG', 'NGA', 1),
1307
-                array(156, 'Niue', 'NU', 'NIU', 1),
1308
-                array(157, 'Norway', 'NO', 'NOR', 1),
1309
-                array(158, 'New Caledonia', 'NC', 'NCL', 1),
1310
-                array(159, 'New Zealand', 'NZ', 'NZL', 1),
1311
-                array(160, 'Oman', 'OM', 'OMN', 1),
1312
-                array(161, 'Pakistan', 'PK', 'PAK', 1),
1313
-                array(162, 'Palau', 'PW', 'PLW', 1),
1314
-                array(163, 'Panama', 'PA', 'PAN', 1),
1315
-                array(164, 'Papua New Guinea', 'PG', 'PNG', 1),
1316
-                array(165, 'Paraguay', 'PY', 'PRY', 1),
1317
-                array(166, 'Peru', 'PE', 'PER', 1),
1318
-                array(68, 'Philippines', 'PH', 'PHL', 1),
1319
-                array(167, 'Poland', 'PL', 'POL', 1),
1320
-                array(168, 'Portugal', 'PT', 'PRT', 2),
1321
-                array(169, 'Puerto Rico', 'PR', 'PRI', 1),
1322
-                array(170, 'Qatar', 'QA', 'QAT', 1),
1323
-                array(176, 'Rwanda', 'RW', 'RWA', 1),
1324
-                array(177, 'Romania', 'RO', 'ROM', 2),
1325
-                array(178, 'Russia', 'RU', 'RUS', 1),
1326
-                array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2),
1327
-                array(180, 'Samoa', 'WS', 'WSM', 1),
1328
-                array(181, 'American Samoa', 'AS', 'ASM', 1),
1329
-                array(183, 'San Marino', 'SM', 'SMR', 2),
1330
-                array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1),
1331
-                array(185, 'Saint Helena', 'SH', 'SHN', 1),
1332
-                array(186, 'Saint Lucia', 'LC', 'LCA', 1),
1333
-                array(188, 'Senegal', 'SN', 'SEN', 1),
1334
-                array(189, 'Seychelles', 'SC', 'SYC', 1),
1335
-                array(190, 'Sierra Leona', 'SL', 'SLE', 1),
1336
-                array(191, 'Singapore', 'SG', 'SGP', 1),
1337
-                array(192, 'Syria', 'SY', 'SYR', 1),
1338
-                array(193, 'Somalia', 'SO', 'SOM', 1),
1339
-                array(194, 'Sri Lanka', 'LK', 'LKA', 1),
1340
-                array(195, 'South Africa', 'ZA', 'ZAF', 1),
1341
-                array(196, 'Sudan', 'SD', 'SDN', 1),
1342
-                array(199, 'Suriname', 'SR', 'SUR', 1),
1343
-                array(200, 'Swaziland', 'SZ', 'SWZ', 1),
1344
-                array(201, 'Thailand', 'TH', 'THA', 1),
1345
-                array(202, 'Taiwan', 'TW', 'TWN', 1),
1346
-                array(203, 'Tanzania', 'TZ', 'TZA', 1),
1347
-                array(204, 'Tajikistan', 'TJ', 'TJK', 1),
1348
-                array(206, 'Timor-Leste', 'TL', 'TLS', 1),
1349
-                array(207, 'Togo', 'TG', 'TGO', 1),
1350
-                array(208, 'Tokelau', 'TK', 'TKL', 1),
1351
-                array(209, 'Tonga', 'TO', 'TON', 1),
1352
-                array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1),
1353
-                array(211, 'Tunisia', 'TN', 'TUN', 1),
1354
-                array(212, 'Turkmenistan', 'TM', 'TKM', 1),
1355
-                array(213, 'Turkey', 'TR', 'TUR', 1),
1356
-                array(214, 'Tuvalu', 'TV', 'TUV', 1),
1357
-                array(215, 'Ukraine', 'UA', 'UKR', 1),
1358
-                array(216, 'Uganda', 'UG', 'UGA', 1),
1359
-                array(59, 'United Arab Emirates', 'AE', 'ARE', 1),
1360
-                array(217, 'Uruguay', 'UY', 'URY', 1),
1361
-                array(218, 'Uzbekistan', 'UZ', 'UZB', 1),
1362
-                array(219, 'Vanuatu', 'VU', 'VUT', 1),
1363
-                array(220, 'Vatican City', 'VA', 'VAT', 2),
1364
-                array(221, 'Venezuela', 'VE', 'VEN', 1),
1365
-                array(222, 'Vietnam', 'VN', 'VNM', 1),
1366
-                array(108, 'Virgin Islands', 'VI', 'VIR', 1),
1367
-                array(223, 'Yemen', 'YE', 'YEM', 1),
1368
-                array(225, 'Zambia', 'ZM', 'ZMB', 1),
1369
-                array(226, 'Zimbabwe', 'ZW', 'ZWE', 1),
1370
-        );
1371
-        $country_iso = 'US';
1372
-        foreach ($old_countries as $country_array) {
1373
-            // note: index 0 is the 3.1 country ID
1374
-            if ($country_array[0] == $country_id) {
1375
-                // note: index 2 is the ISO
1376
-                $country_iso = $country_array[2];
1377
-                break;
1378
-            }
1379
-        }
1380
-        return $country_iso;
1381
-    }
1382
-
1383
-
1384
-
1385
-    /**
1386
-     * Gets the ISO3 for the
1387
-     *
1388
-     * @return string
1389
-     */
1390
-    public function get_default_country_iso()
1391
-    {
1392
-        $old_org_options = get_option('events_organization_settings');
1393
-        $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1394
-        return $iso;
1395
-    }
1396
-
1397
-
1398
-
1399
-    /**
1400
-     * Converst a 3.1 payment status to its equivalent 4.1 regisration status
1401
-     *
1402
-     * @param string  $payment_status                   possible value for 3.1's evens_attendee.payment_status
1403
-     * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's
1404
-     *                                                  default payment status, the event's default payment status, or
1405
-     *                                                  the attendee's payment status) required pre-approval.
1406
-     * @return string STS_ID for use in 4.1
1407
-     */
1408
-    public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false)
1409
-    {
1410
-        // EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1411
-        if ($this_thing_required_pre_approval) {
1412
-            return 'RNA';
1413
-        } else {
1414
-            $mapping = $default_reg_stati_conversions = array(
1415
-                    'Completed'        => 'RAP',
1416
-                    ''                 => 'RPP',
1417
-                    'Incomplete'       => 'RPP',
1418
-                    'Pending'          => 'RAP',
1419
-                    // stati that only occurred on 3.1 attendees:
1420
-                    'Payment Declined' => 'RPP',
1421
-                    'Not Completed'    => 'RPP',
1422
-                    'Cancelled'        => 'RPP',
1423
-                    'Declined'         => 'RPP',
1424
-            );
1425
-        }
1426
-        return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA';
1427
-    }
1428
-
1429
-
1430
-
1431
-    /**
1432
-     * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1433
-     * and sets it as the featured image on the CPT event
1434
-     *
1435
-     * @param type                            $old_event
1436
-     * @param type                            $new_cpt_id
1437
-     * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1438
-     * @return boolean whether or not we had to do the big job of creating an image attachment
1439
-     */
1440
-    public function convert_image_url_to_attachment_and_attach_to_post(
1441
-        $guid,
1442
-        $new_cpt_id,
1443
-        EE_Data_Migration_Script_Stage $migration_stage
1444
-    ) {
1445
-        $created_attachment_post = false;
1446
-        $guid = $this->_get_original_guid($guid);
1447
-        if ($guid) {
1448
-            // check for an existing attachment post with this guid
1449
-            $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1450
-            if (! $attachment_post_id) {
1451
-                // post thumbnail with that GUID doesn't exist, we should create one
1452
-                $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1453
-                $created_attachment_post = true;
1454
-            }
1455
-            // double-check we actually have an attachment post
1456
-            if ($attachment_post_id) {
1457
-                update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1458
-            } else {
1459
-                $migration_stage->add_error(sprintf(esc_html__(
1460
-                    "Could not update event image %s for CPT with ID %d, but attachments post ID is %d",
1461
-                    "event_espresso"
1462
-                ), $guid, $new_cpt_id, $attachment_post_id));
1463
-            }
1464
-        }
1465
-        return $created_attachment_post;
1466
-    }
1467
-
1468
-
1469
-
1470
-    /**
1471
-     * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead
1472
-     * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype,
1473
-     * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of
1474
-     * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it
1475
-     * exists
1476
-     *
1477
-     * @param string $guid_in_old_event
1478
-     * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1479
-     */
1480
-    private function _get_original_guid($guid_in_old_event)
1481
-    {
1482
-        $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1483
-        // do a head request to verify the file exists
1484
-        $head_response = wp_remote_head($original_guid);
1485
-        if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1486
-            return $original_guid;
1487
-        } else {
1488
-            return $guid_in_old_event;
1489
-        }
1490
-    }
1491
-
1492
-
1493
-
1494
-    /**
1495
-     * Creates an image attachment post for the GUID. If the GUID points to a remote image,
1496
-     * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1497
-     * thumbnails)
1498
-     *
1499
-     * @param type                           $guid
1500
-     * @param EE_Data_Migration_Script_Stage $migration_stage
1501
-     * @return int
1502
-     */
1503
-    private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1504
-    {
1505
-        if (! $guid) {
1506
-            $migration_stage->add_error(sprintf(esc_html__(
1507
-                "Cannot create image attachment for a blank GUID!",
1508
-                "event_espresso"
1509
-            )));
1510
-            return 0;
1511
-        }
1512
-        $wp_filetype = wp_check_filetype(basename($guid), null);
1513
-        $wp_upload_dir = wp_upload_dir();
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
-        if (strpos($guid, $wp_upload_dir['url']) === false) {
1516
-            // image is located remotely. download it and place it in the uploads directory
1517
-            if (! is_readable($guid)) {
1518
-                $migration_stage->add_error(sprintf(esc_html__(
1519
-                    "Could not create image attachment from non-existent file: %s",
1520
-                    "event_espresso"
1521
-                ), $guid));
1522
-                return 0;
1523
-            }
1524
-            $contents = file_get_contents($guid);
1525
-            if ($contents === false) {
1526
-                $migration_stage->add_error(sprintf(esc_html__(
1527
-                    "Could not read image at %s, and therefore couldnt create an attachment post for it.",
1528
-                    "event_espresso"
1529
-                ), $guid));
1530
-                return false;
1531
-            }
1532
-            $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid);
1533
-            $savefile = fopen($local_filepath, 'w');
1534
-            fwrite($savefile, $contents);
1535
-            fclose($savefile);
1536
-            $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1537
-        } else {
1538
-            $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1539
-        }
1540
-        $attachment = array(
1541
-                'guid'           => $guid,
1542
-                'post_mime_type' => $wp_filetype['type'],
1543
-                'post_title'     => preg_replace('/\.[^.]+$/', '', basename($guid)),
1544
-                'post_content'   => '',
1545
-                'post_status'    => 'inherit',
1546
-        );
1547
-        $attach_id = wp_insert_attachment($attachment, $guid);
1548
-        if (! $attach_id) {
1549
-            $migration_stage->add_error(sprintf(esc_html__(
1550
-                "Could not create image attachment post from image '%s'. Attachment data was %s.",
1551
-                "event_espresso"
1552
-            ), $guid, $this->_json_encode($attachment)));
1553
-            return $attach_id;
1554
-        }
1555
-        // you must first include the image.php file
1556
-        // for the function wp_generate_attachment_metadata() to work
1557
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1558
-        $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1559
-        if (! $attach_data) {
1560
-            $migration_stage->add_error(sprintf(esc_html__(
1561
-                "Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1562
-                "event_espresso"
1563
-            ), $attach_id, $local_filepath, $guid));
1564
-            return $attach_id;
1565
-        }
1566
-        $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1567
-        if (! $metadata_save_result) {
1568
-            $migration_stage->add_error(sprintf(esc_html__(
1569
-                "Could not update attachment metadata for attachment %d with data %s",
1570
-                "event_espresso"
1571
-            ), $attach_id, $this->_json_encode($attach_data)));
1572
-        }
1573
-        return $attach_id;
1574
-    }
1575
-
1576
-
1577
-
1578
-    /**
1579
-     * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself),
1580
-     * and returns its ID.
1581
-     *
1582
-     * @global type  $wpdb
1583
-     * @param string $guid
1584
-     * @return int
1585
-     */
1586
-    private function _get_image_attachment_id_by_GUID($guid)
1587
-    {
1588
-        global $wpdb;
1589
-        $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1590
-        return $attachment_id;
1591
-    }
1592
-
1593
-
1594
-
1595
-    /**
1596
-     * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1597
-     * (and optionally a timezone; if none is given, the wp default is used)
1598
-     *
1599
-     * @param EE_Data_Migration_Script_base $stage
1600
-     * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1601
-     *                                                   UTC time for
1602
-     * @param string                        $DATETIME_string
1603
-     * @param string                        $timezone
1604
-     * @return string
1605
-     */
1606
-    public function convert_date_string_to_utc(
1607
-        EE_Data_Migration_Script_Stage $stage,
1608
-        $row_of_data,
1609
-        $DATETIME_string,
1610
-        $timezone = null
1611
-    ) {
1612
-        $original_tz = $timezone;
1613
-        if (! $timezone) {
1614
-            $timezone = $this->_get_wp_timezone();
1615
-        }
1616
-        if (! $timezone) {
1617
-            $stage->add_error(sprintf(
1618
-                esc_html__("Could not find timezone given %s for %s", "event_espresso"),
1619
-                $original_tz,
1620
-                $row_of_data
1621
-            ));
1622
-            $timezone = 'UTC';
1623
-        }
1624
-        try {
1625
-            $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1626
-            EEH_DTT_Helper::setTimezone($date_obj, new DateTimeZone('UTC'));
1627
-        } catch (Exception $e) {
1628
-            $stage->add_error(sprintf(esc_html__(
1629
-                "Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.",
1630
-                "event_espresso"
1631
-            ), $DATETIME_string, $timezone));
1632
-            $date_obj = new DateTime();
1633
-        }
1634
-        return $date_obj->format('Y-m-d H:i:s');
1635
-    }
1636
-
1637
-
1638
-
1639
-    /**
1640
-     * Gets the default timezone string from wordpress (even if they set a gmt offset)
1641
-     *
1642
-     * @return string
1643
-     */
1644
-    private function _get_wp_timezone()
1645
-    {
1646
-        $timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1647
-        // if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1648
-        if (empty($timezone)) {
1649
-            // let's get a the WordPress UTC offset
1650
-            $offset = get_option('gmt_offset');
1651
-            $timezone = $this->timezone_convert_to_string_from_offset($offset);
1652
-        }
1653
-        return $timezone;
1654
-    }
1655
-
1656
-
1657
-
1658
-    /**
1659
-     * Gets the wordpress timezone string from a UTC offset
1660
-     *
1661
-     * @param int $offset
1662
-     * @return boolean
1663
-     */
1664
-    private function timezone_convert_to_string_from_offset($offset)
1665
-    {
1666
-        // 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
1667
-        $offset *= 3600; // convert hour offset to seconds
1668
-        $abbrarray = timezone_abbreviations_list();
1669
-        foreach ($abbrarray as $abbr) {
1670
-            foreach ($abbr as $city) {
1671
-                if ($city['offset'] == $offset) {
1672
-                    return $city['timezone_id'];
1673
-                }
1674
-            }
1675
-        }
1676
-        return false;
1677
-    }
1678
-
1679
-
1680
-
1681
-    public function migration_page_hooks()
1682
-    {
1683
-        add_filter(
1684
-            'FHEE__ee_migration_page__header',
1685
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1686
-            10,
1687
-            3
1688
-        );
1689
-        add_filter(
1690
-            'FHEE__ee_migration_page__p_after_header',
1691
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1692
-            10,
1693
-            2
1694
-        );
1695
-        add_filter(
1696
-            'FHEE__ee_migration_page__option_1_main',
1697
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1698
-            10,
1699
-            3
1700
-        );
1701
-        add_filter(
1702
-            'FHEE__ee_migration_page__option_1_button_text',
1703
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1704
-            10,
1705
-            3
1706
-        );
1707
-        add_action(
1708
-            'AHEE__ee_migration_page__option_1_extra_details',
1709
-            array($this, '_migration_page_hook_option_1_extra_details'),
1710
-            10,
1711
-            3
1712
-        );
1713
-        add_filter(
1714
-            'FHEE__ee_migration_page__option_2_main',
1715
-            array($this, '_migrate_page_hook_simplify_version_strings'),
1716
-            10,
1717
-            4
1718
-        );
1719
-        add_filter(
1720
-            'FHEE__ee_migration_page__option_2_button_text',
1721
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1722
-            10,
1723
-            2
1724
-        );
1725
-        add_filter(
1726
-            'FHEE__ee_migration_page__option_2_details',
1727
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1728
-            10,
1729
-            2
1730
-        );
1731
-        add_action(
1732
-            'AHEE__ee_migration_page__after_migration_options_table',
1733
-            array($this, '_migration_page_hook_after_migration_options_table')
1734
-        );
1735
-        add_filter(
1736
-            'FHEE__ee_migration_page__done_migration_header',
1737
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1738
-            10,
1739
-            2
1740
-        );
1741
-        add_filter(
1742
-            'FHEE__ee_migration_page__p_after_done_migration_header',
1743
-            array($this, '_migration_page_hook_simplify_next_db_state'),
1744
-            10,
1745
-            2
1746
-        );
1747
-        add_filter(
1748
-            'FHEE__ee_migration_page__migration_options_template',
1749
-            array($this,'use_migration_options_from_ee3_template')
1750
-        );
1751
-    }
1752
-
1753
-
1754
-
1755
-    public function _migrate_page_hook_simplify_version_strings(
1756
-        $old_content,
1757
-        $current_db_state,
1758
-        $next_db_state,
1759
-        $ultimate_db_state = null
1760
-    ) {
1761
-        return str_replace(
1762
-            array($current_db_state, $next_db_state, $ultimate_db_state),
1763
-            array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')),
1764
-            $old_content
1765
-        );
1766
-    }
1767
-
1768
-
1769
-
1770
-    public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state)
1771
-    {
1772
-        return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content);
1773
-    }
1774
-
1775
-
1776
-
1777
-    public function _migration_page_hook_option_1_extra_details()
1778
-    {
1779
-        ?>
1077
+		if (! $state) {
1078
+			// insert a new one then
1079
+			$cols_n_values = array(
1080
+					'CNT_ISO'    => $country_iso,
1081
+					'STA_abbrev' => substr($state_name, 0, 6),
1082
+					'STA_name'   => $state_name,
1083
+					'STA_active' => true,
1084
+			);
1085
+			$data_types = array(
1086
+					'%s',// CNT_ISO
1087
+					'%s',// STA_abbrev
1088
+					'%s',// STA_name
1089
+					'%d',// STA_active
1090
+			);
1091
+			$success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1092
+			if (! $success) {
1093
+				throw new EE_Error($this->_create_error_message_for_db_insertion(
1094
+					'N/A',
1095
+					array('state' => $state_name, 'country_id' => $country_name),
1096
+					$state_table,
1097
+					$cols_n_values,
1098
+					$data_types
1099
+				));
1100
+			}
1101
+			$state = $cols_n_values;
1102
+			$state['STA_ID'] = $wpdb->insert_id;
1103
+		}
1104
+		return $state;
1105
+	}
1106
+
1107
+
1108
+
1109
+	/**
1110
+	 * Fixes times like "5:00 PM" into the expected 24-hour format "17:00".
1111
+	 * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing
1112
+	 *
1113
+	 * @param type $timeString
1114
+	 * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes
1115
+	 *                with leading zeros)
1116
+	 */
1117
+	public function convertTimeFromAMPM($timeString)
1118
+	{
1119
+		$matches = array();
1120
+		preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1121
+		if (! $matches || count($matches) < 3) {
1122
+			$hour = '00';
1123
+			$minutes = '00';
1124
+		} else {
1125
+			$hour = intval($matches[1]);
1126
+			$minutes = $matches[2];
1127
+		}
1128
+		if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1129
+			$hour = intval($hour) + 12;
1130
+		}
1131
+		$hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1132
+		$minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1133
+		return "$hour:$minutes";
1134
+	}
1135
+
1136
+
1137
+
1138
+	/**
1139
+	 * Gets the ISO3 fora country given its 3.1 country ID.
1140
+	 *
1141
+	 * @param int $country_id
1142
+	 * @return string the country's ISO3 code
1143
+	 */
1144
+	public function get_iso_from_3_1_country_id($country_id)
1145
+	{
1146
+		$old_countries = array(
1147
+				array(64, 'United States', 'US', 'USA', 1),
1148
+				array(15, 'Australia', 'AU', 'AUS', 1),
1149
+				array(39, 'Canada', 'CA', 'CAN', 1),
1150
+				array(171, 'United Kingdom', 'GB', 'GBR', 1),
1151
+				array(70, 'France', 'FR', 'FRA', 2),
1152
+				array(111, 'Italy', 'IT', 'ITA', 2),
1153
+				array(63, 'Spain', 'ES', 'ESP', 2),
1154
+				array(1, 'Afghanistan', 'AF', 'AFG', 1),
1155
+				array(2, 'Albania', 'AL', 'ALB', 1),
1156
+				array(3, 'Germany', 'DE', 'DEU', 2),
1157
+				array(198, 'Switzerland', 'CH', 'CHE', 1),
1158
+				array(87, 'Netherlands', 'NL', 'NLD', 2),
1159
+				array(197, 'Sweden', 'SE', 'SWE', 1),
1160
+				array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2),
1161
+				array(4, 'Andorra', 'AD', 'AND', 2),
1162
+				array(5, 'Angola', 'AO', 'AGO', 1),
1163
+				array(6, 'Anguilla', 'AI', 'AIA', 1),
1164
+				array(7, 'Antarctica', 'AQ', 'ATA', 1),
1165
+				array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1),
1166
+				array(10, 'Saudi Arabia', 'SA', 'SAU', 1),
1167
+				array(11, 'Algeria', 'DZ', 'DZA', 1),
1168
+				array(12, 'Argentina', 'AR', 'ARG', 1),
1169
+				array(13, 'Armenia', 'AM', 'ARM', 1),
1170
+				array(14, 'Aruba', 'AW', 'ABW', 1),
1171
+				array(16, 'Austria', 'AT', 'AUT', 2),
1172
+				array(17, 'Azerbaijan', 'AZ', 'AZE', 1),
1173
+				array(18, 'Bahamas', 'BS', 'BHS', 1),
1174
+				array(19, 'Bahrain', 'BH', 'BHR', 1),
1175
+				array(20, 'Bangladesh', 'BD', 'BGD', 1),
1176
+				array(21, 'Barbados', 'BB', 'BRB', 1),
1177
+				array(22, 'Belgium ', 'BE', 'BEL', 2),
1178
+				array(23, 'Belize', 'BZ', 'BLZ', 1),
1179
+				array(24, 'Benin', 'BJ', 'BEN', 1),
1180
+				array(25, 'Bermudas', 'BM', 'BMU', 1),
1181
+				array(26, 'Belarus', 'BY', 'BLR', 1),
1182
+				array(27, 'Bolivia', 'BO', 'BOL', 1),
1183
+				array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1),
1184
+				array(29, 'Botswana', 'BW', 'BWA', 1),
1185
+				array(96, 'Bouvet Island', 'BV', 'BVT', 1),
1186
+				array(30, 'Brazil', 'BR', 'BRA', 1),
1187
+				array(31, 'Brunei', 'BN', 'BRN', 1),
1188
+				array(32, 'Bulgaria', 'BG', 'BGR', 1),
1189
+				array(33, 'Burkina Faso', 'BF', 'BFA', 1),
1190
+				array(34, 'Burundi', 'BI', 'BDI', 1),
1191
+				array(35, 'Bhutan', 'BT', 'BTN', 1),
1192
+				array(36, 'Cape Verde', 'CV', 'CPV', 1),
1193
+				array(37, 'Cambodia', 'KH', 'KHM', 1),
1194
+				array(38, 'Cameroon', 'CM', 'CMR', 1),
1195
+				array(98, 'Cayman Islands', 'KY', 'CYM', 1),
1196
+				array(172, 'Central African Republic', 'CF', 'CAF', 1),
1197
+				array(40, 'Chad', 'TD', 'TCD', 1),
1198
+				array(41, 'Chile', 'CL', 'CHL', 1),
1199
+				array(42, 'China', 'CN', 'CHN', 1),
1200
+				array(105, 'Christmas Island', 'CX', 'CXR', 1),
1201
+				array(43, 'Cyprus', 'CY', 'CYP', 2),
1202
+				array(99, 'Cocos Island', 'CC', 'CCK', 1),
1203
+				array(100, 'Cook Islands', 'CK', 'COK', 1),
1204
+				array(44, 'Colombia', 'CO', 'COL', 1),
1205
+				array(45, 'Comoros', 'KM', 'COM', 1),
1206
+				array(46, 'Congo', 'CG', 'COG', 1),
1207
+				array(47, 'North Korea', 'KP', 'PRK', 1),
1208
+				array(50, 'Costa Rica', 'CR', 'CRI', 1),
1209
+				array(51, 'Croatia', 'HR', 'HRV', 1),
1210
+				array(52, 'Cuba', 'CU', 'CUB', 1),
1211
+				array(173, 'Czech Republic', 'CZ', 'CZE', 1),
1212
+				array(53, 'Denmark', 'DK', 'DNK', 1),
1213
+				array(54, 'Djibouti', 'DJ', 'DJI', 1),
1214
+				array(55, 'Dominica', 'DM', 'DMA', 1),
1215
+				array(174, 'Dominican Republic', 'DO', 'DOM', 1),
1216
+				array(56, 'Ecuador', 'EC', 'ECU', 1),
1217
+				array(57, 'Egypt', 'EG', 'EGY', 1),
1218
+				array(58, 'El Salvador', 'SV', 'SLV', 1),
1219
+				array(60, 'Eritrea', 'ER', 'ERI', 1),
1220
+				array(61, 'Slovakia', 'SK', 'SVK', 2),
1221
+				array(62, 'Slovenia', 'SI', 'SVN', 2),
1222
+				array(65, 'Estonia', 'EE', 'EST', 2),
1223
+				array(66, 'Ethiopia', 'ET', 'ETH', 1),
1224
+				array(102, 'Faroe islands', 'FO', 'FRO', 1),
1225
+				array(103, 'Falkland Islands', 'FK', 'FLK', 1),
1226
+				array(67, 'Fiji', 'FJ', 'FJI', 1),
1227
+				array(69, 'Finland', 'FI', 'FIN', 2),
1228
+				array(71, 'Gabon', 'GA', 'GAB', 1),
1229
+				array(72, 'Gambia', 'GM', 'GMB', 1),
1230
+				array(73, 'Georgia', 'GE', 'GEO', 1),
1231
+				array(74, 'Ghana', 'GH', 'GHA', 1),
1232
+				array(75, 'Gibraltar', 'GI', 'GIB', 1),
1233
+				array(76, 'Greece', 'GR', 'GRC', 2),
1234
+				array(77, 'Grenada', 'GD', 'GRD', 1),
1235
+				array(78, 'Greenland', 'GL', 'GRL', 1),
1236
+				array(79, 'Guadeloupe', 'GP', 'GLP', 1),
1237
+				array(80, 'Guam', 'GU', 'GUM', 1),
1238
+				array(81, 'Guatemala', 'GT', 'GTM', 1),
1239
+				array(82, 'Guinea', 'GN', 'GIN', 1),
1240
+				array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1),
1241
+				array(84, 'Guinea-Bissau', 'GW', 'GNB', 1),
1242
+				array(85, 'Guyana', 'GY', 'GUY', 1),
1243
+				array(86, 'Haiti', 'HT', 'HTI', 1),
1244
+				array(88, 'Honduras', 'HN', 'HND', 1),
1245
+				array(89, 'Hong Kong', 'HK', 'HKG', 1),
1246
+				array(90, 'Hungary', 'HU', 'HUN', 1),
1247
+				array(91, 'India', 'IN', 'IND', 1),
1248
+				array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1),
1249
+				array(92, 'Indonesia', 'ID', 'IDN', 1),
1250
+				array(93, 'Iraq', 'IQ', 'IRQ', 1),
1251
+				array(94, 'Iran', 'IR', 'IRN', 1),
1252
+				array(95, 'Ireland', 'IE', 'IRL', 2),
1253
+				array(97, 'Iceland', 'IS', 'ISL', 1),
1254
+				array(110, 'Israel', 'IL', 'ISR', 1),
1255
+				array(49, 'Ivory Coast ', 'CI', 'CIV', 1),
1256
+				array(112, 'Jamaica', 'JM', 'JAM', 1),
1257
+				array(113, 'Japan', 'JP', 'JPN', 1),
1258
+				array(114, 'Jordan', 'JO', 'JOR', 1),
1259
+				array(115, 'Kazakhstan', 'KZ', 'KAZ', 1),
1260
+				array(116, 'Kenya', 'KE', 'KEN', 1),
1261
+				array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1),
1262
+				array(118, 'Kiribati', 'KI', 'KIR', 1),
1263
+				array(48, 'South Korea', 'KR', 'KOR', 1),
1264
+				array(228, 'Kosovo', 'XK', 'XKV', 2),
1265
+				// 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
1266
+				array(119, 'Kuwait', 'KW', 'KWT', 1),
1267
+				array(120, 'Laos', 'LA', 'LAO', 1),
1268
+				array(121, 'Latvia', 'LV', 'LVA', 2),
1269
+				array(122, 'Lesotho', 'LS', 'LSO', 1),
1270
+				array(123, 'Lebanon', 'LB', 'LBN', 1),
1271
+				array(124, 'Liberia', 'LR', 'LBR', 1),
1272
+				array(125, 'Libya', 'LY', 'LBY', 1),
1273
+				array(126, 'Liechtenstein', 'LI', 'LIE', 1),
1274
+				array(127, 'Lithuania', 'LT', 'LTU', 2),
1275
+				array(128, 'Luxemburg', 'LU', 'LUX', 2),
1276
+				array(129, 'Macao', 'MO', 'MAC', 1),
1277
+				array(130, 'Macedonia', 'MK', 'MKD', 1),
1278
+				array(131, 'Madagascar', 'MG', 'MDG', 1),
1279
+				array(132, 'Malaysia', 'MY', 'MYS', 1),
1280
+				array(133, 'Malawi', 'MW', 'MWI', 1),
1281
+				array(134, 'Maldivas', 'MV', 'MDV', 1),
1282
+				array(135, 'Mali', 'ML', 'MLI', 1),
1283
+				array(136, 'Malta', 'MT', 'MLT', 2),
1284
+				array(101, 'Northern Marianas', 'MP', 'MNP', 1),
1285
+				array(137, 'Morocco', 'MA', 'MAR', 1),
1286
+				array(104, 'Marshall islands', 'MH', 'MHL', 1),
1287
+				array(138, 'Martinique', 'MQ', 'MTQ', 1),
1288
+				array(139, 'Mauritius', 'MU', 'MUS', 1),
1289
+				array(140, 'Mauritania', 'MR', 'MRT', 1),
1290
+				array(141, 'Mayote', 'YT', 'MYT', 2),
1291
+				array(142, 'Mexico', 'MX', 'MEX', 1),
1292
+				array(143, 'Micronesia', 'FM', 'FSM', 1),
1293
+				array(144, 'Moldova', 'MD', 'MDA', 1),
1294
+				array(145, 'Monaco', 'MC', 'MCO', 2),
1295
+				array(146, 'Mongolia', 'MN', 'MNG', 1),
1296
+				array(147, 'Montserrat', 'MS', 'MSR', 1),
1297
+				array(227, 'Montenegro', 'ME', 'MNE', 2),
1298
+				array(148, 'Mozambique', 'MZ', 'MOZ', 1),
1299
+				array(149, 'Myanmar', 'MM', 'MMR', 1),
1300
+				array(150, 'Namibia', 'NA', 'NAM', 1),
1301
+				array(151, 'Nauru', 'NR', 'NRU', 1),
1302
+				array(152, 'Nepal', 'NP', 'NPL', 1),
1303
+				array(9, 'Netherlands Antilles', 'AN', 'ANT', 1),
1304
+				array(153, 'Nicaragua', 'NI', 'NIC', 1),
1305
+				array(154, 'Niger', 'NE', 'NER', 1),
1306
+				array(155, 'Nigeria', 'NG', 'NGA', 1),
1307
+				array(156, 'Niue', 'NU', 'NIU', 1),
1308
+				array(157, 'Norway', 'NO', 'NOR', 1),
1309
+				array(158, 'New Caledonia', 'NC', 'NCL', 1),
1310
+				array(159, 'New Zealand', 'NZ', 'NZL', 1),
1311
+				array(160, 'Oman', 'OM', 'OMN', 1),
1312
+				array(161, 'Pakistan', 'PK', 'PAK', 1),
1313
+				array(162, 'Palau', 'PW', 'PLW', 1),
1314
+				array(163, 'Panama', 'PA', 'PAN', 1),
1315
+				array(164, 'Papua New Guinea', 'PG', 'PNG', 1),
1316
+				array(165, 'Paraguay', 'PY', 'PRY', 1),
1317
+				array(166, 'Peru', 'PE', 'PER', 1),
1318
+				array(68, 'Philippines', 'PH', 'PHL', 1),
1319
+				array(167, 'Poland', 'PL', 'POL', 1),
1320
+				array(168, 'Portugal', 'PT', 'PRT', 2),
1321
+				array(169, 'Puerto Rico', 'PR', 'PRI', 1),
1322
+				array(170, 'Qatar', 'QA', 'QAT', 1),
1323
+				array(176, 'Rwanda', 'RW', 'RWA', 1),
1324
+				array(177, 'Romania', 'RO', 'ROM', 2),
1325
+				array(178, 'Russia', 'RU', 'RUS', 1),
1326
+				array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2),
1327
+				array(180, 'Samoa', 'WS', 'WSM', 1),
1328
+				array(181, 'American Samoa', 'AS', 'ASM', 1),
1329
+				array(183, 'San Marino', 'SM', 'SMR', 2),
1330
+				array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1),
1331
+				array(185, 'Saint Helena', 'SH', 'SHN', 1),
1332
+				array(186, 'Saint Lucia', 'LC', 'LCA', 1),
1333
+				array(188, 'Senegal', 'SN', 'SEN', 1),
1334
+				array(189, 'Seychelles', 'SC', 'SYC', 1),
1335
+				array(190, 'Sierra Leona', 'SL', 'SLE', 1),
1336
+				array(191, 'Singapore', 'SG', 'SGP', 1),
1337
+				array(192, 'Syria', 'SY', 'SYR', 1),
1338
+				array(193, 'Somalia', 'SO', 'SOM', 1),
1339
+				array(194, 'Sri Lanka', 'LK', 'LKA', 1),
1340
+				array(195, 'South Africa', 'ZA', 'ZAF', 1),
1341
+				array(196, 'Sudan', 'SD', 'SDN', 1),
1342
+				array(199, 'Suriname', 'SR', 'SUR', 1),
1343
+				array(200, 'Swaziland', 'SZ', 'SWZ', 1),
1344
+				array(201, 'Thailand', 'TH', 'THA', 1),
1345
+				array(202, 'Taiwan', 'TW', 'TWN', 1),
1346
+				array(203, 'Tanzania', 'TZ', 'TZA', 1),
1347
+				array(204, 'Tajikistan', 'TJ', 'TJK', 1),
1348
+				array(206, 'Timor-Leste', 'TL', 'TLS', 1),
1349
+				array(207, 'Togo', 'TG', 'TGO', 1),
1350
+				array(208, 'Tokelau', 'TK', 'TKL', 1),
1351
+				array(209, 'Tonga', 'TO', 'TON', 1),
1352
+				array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1),
1353
+				array(211, 'Tunisia', 'TN', 'TUN', 1),
1354
+				array(212, 'Turkmenistan', 'TM', 'TKM', 1),
1355
+				array(213, 'Turkey', 'TR', 'TUR', 1),
1356
+				array(214, 'Tuvalu', 'TV', 'TUV', 1),
1357
+				array(215, 'Ukraine', 'UA', 'UKR', 1),
1358
+				array(216, 'Uganda', 'UG', 'UGA', 1),
1359
+				array(59, 'United Arab Emirates', 'AE', 'ARE', 1),
1360
+				array(217, 'Uruguay', 'UY', 'URY', 1),
1361
+				array(218, 'Uzbekistan', 'UZ', 'UZB', 1),
1362
+				array(219, 'Vanuatu', 'VU', 'VUT', 1),
1363
+				array(220, 'Vatican City', 'VA', 'VAT', 2),
1364
+				array(221, 'Venezuela', 'VE', 'VEN', 1),
1365
+				array(222, 'Vietnam', 'VN', 'VNM', 1),
1366
+				array(108, 'Virgin Islands', 'VI', 'VIR', 1),
1367
+				array(223, 'Yemen', 'YE', 'YEM', 1),
1368
+				array(225, 'Zambia', 'ZM', 'ZMB', 1),
1369
+				array(226, 'Zimbabwe', 'ZW', 'ZWE', 1),
1370
+		);
1371
+		$country_iso = 'US';
1372
+		foreach ($old_countries as $country_array) {
1373
+			// note: index 0 is the 3.1 country ID
1374
+			if ($country_array[0] == $country_id) {
1375
+				// note: index 2 is the ISO
1376
+				$country_iso = $country_array[2];
1377
+				break;
1378
+			}
1379
+		}
1380
+		return $country_iso;
1381
+	}
1382
+
1383
+
1384
+
1385
+	/**
1386
+	 * Gets the ISO3 for the
1387
+	 *
1388
+	 * @return string
1389
+	 */
1390
+	public function get_default_country_iso()
1391
+	{
1392
+		$old_org_options = get_option('events_organization_settings');
1393
+		$iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1394
+		return $iso;
1395
+	}
1396
+
1397
+
1398
+
1399
+	/**
1400
+	 * Converst a 3.1 payment status to its equivalent 4.1 regisration status
1401
+	 *
1402
+	 * @param string  $payment_status                   possible value for 3.1's evens_attendee.payment_status
1403
+	 * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's
1404
+	 *                                                  default payment status, the event's default payment status, or
1405
+	 *                                                  the attendee's payment status) required pre-approval.
1406
+	 * @return string STS_ID for use in 4.1
1407
+	 */
1408
+	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false)
1409
+	{
1410
+		// EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1411
+		if ($this_thing_required_pre_approval) {
1412
+			return 'RNA';
1413
+		} else {
1414
+			$mapping = $default_reg_stati_conversions = array(
1415
+					'Completed'        => 'RAP',
1416
+					''                 => 'RPP',
1417
+					'Incomplete'       => 'RPP',
1418
+					'Pending'          => 'RAP',
1419
+					// stati that only occurred on 3.1 attendees:
1420
+					'Payment Declined' => 'RPP',
1421
+					'Not Completed'    => 'RPP',
1422
+					'Cancelled'        => 'RPP',
1423
+					'Declined'         => 'RPP',
1424
+			);
1425
+		}
1426
+		return isset($mapping[ $payment_status ]) ? $mapping[ $payment_status ] : 'RNA';
1427
+	}
1428
+
1429
+
1430
+
1431
+	/**
1432
+	 * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1433
+	 * and sets it as the featured image on the CPT event
1434
+	 *
1435
+	 * @param type                            $old_event
1436
+	 * @param type                            $new_cpt_id
1437
+	 * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1438
+	 * @return boolean whether or not we had to do the big job of creating an image attachment
1439
+	 */
1440
+	public function convert_image_url_to_attachment_and_attach_to_post(
1441
+		$guid,
1442
+		$new_cpt_id,
1443
+		EE_Data_Migration_Script_Stage $migration_stage
1444
+	) {
1445
+		$created_attachment_post = false;
1446
+		$guid = $this->_get_original_guid($guid);
1447
+		if ($guid) {
1448
+			// check for an existing attachment post with this guid
1449
+			$attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1450
+			if (! $attachment_post_id) {
1451
+				// post thumbnail with that GUID doesn't exist, we should create one
1452
+				$attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1453
+				$created_attachment_post = true;
1454
+			}
1455
+			// double-check we actually have an attachment post
1456
+			if ($attachment_post_id) {
1457
+				update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1458
+			} else {
1459
+				$migration_stage->add_error(sprintf(esc_html__(
1460
+					"Could not update event image %s for CPT with ID %d, but attachments post ID is %d",
1461
+					"event_espresso"
1462
+				), $guid, $new_cpt_id, $attachment_post_id));
1463
+			}
1464
+		}
1465
+		return $created_attachment_post;
1466
+	}
1467
+
1468
+
1469
+
1470
+	/**
1471
+	 * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead
1472
+	 * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype,
1473
+	 * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of
1474
+	 * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it
1475
+	 * exists
1476
+	 *
1477
+	 * @param string $guid_in_old_event
1478
+	 * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1479
+	 */
1480
+	private function _get_original_guid($guid_in_old_event)
1481
+	{
1482
+		$original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1483
+		// do a head request to verify the file exists
1484
+		$head_response = wp_remote_head($original_guid);
1485
+		if (! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1486
+			return $original_guid;
1487
+		} else {
1488
+			return $guid_in_old_event;
1489
+		}
1490
+	}
1491
+
1492
+
1493
+
1494
+	/**
1495
+	 * Creates an image attachment post for the GUID. If the GUID points to a remote image,
1496
+	 * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1497
+	 * thumbnails)
1498
+	 *
1499
+	 * @param type                           $guid
1500
+	 * @param EE_Data_Migration_Script_Stage $migration_stage
1501
+	 * @return int
1502
+	 */
1503
+	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1504
+	{
1505
+		if (! $guid) {
1506
+			$migration_stage->add_error(sprintf(esc_html__(
1507
+				"Cannot create image attachment for a blank GUID!",
1508
+				"event_espresso"
1509
+			)));
1510
+			return 0;
1511
+		}
1512
+		$wp_filetype = wp_check_filetype(basename($guid), null);
1513
+		$wp_upload_dir = wp_upload_dir();
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
+		if (strpos($guid, $wp_upload_dir['url']) === false) {
1516
+			// image is located remotely. download it and place it in the uploads directory
1517
+			if (! is_readable($guid)) {
1518
+				$migration_stage->add_error(sprintf(esc_html__(
1519
+					"Could not create image attachment from non-existent file: %s",
1520
+					"event_espresso"
1521
+				), $guid));
1522
+				return 0;
1523
+			}
1524
+			$contents = file_get_contents($guid);
1525
+			if ($contents === false) {
1526
+				$migration_stage->add_error(sprintf(esc_html__(
1527
+					"Could not read image at %s, and therefore couldnt create an attachment post for it.",
1528
+					"event_espresso"
1529
+				), $guid));
1530
+				return false;
1531
+			}
1532
+			$local_filepath = $wp_upload_dir['path'] . '/' . basename($guid);
1533
+			$savefile = fopen($local_filepath, 'w');
1534
+			fwrite($savefile, $contents);
1535
+			fclose($savefile);
1536
+			$guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1537
+		} else {
1538
+			$local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1539
+		}
1540
+		$attachment = array(
1541
+				'guid'           => $guid,
1542
+				'post_mime_type' => $wp_filetype['type'],
1543
+				'post_title'     => preg_replace('/\.[^.]+$/', '', basename($guid)),
1544
+				'post_content'   => '',
1545
+				'post_status'    => 'inherit',
1546
+		);
1547
+		$attach_id = wp_insert_attachment($attachment, $guid);
1548
+		if (! $attach_id) {
1549
+			$migration_stage->add_error(sprintf(esc_html__(
1550
+				"Could not create image attachment post from image '%s'. Attachment data was %s.",
1551
+				"event_espresso"
1552
+			), $guid, $this->_json_encode($attachment)));
1553
+			return $attach_id;
1554
+		}
1555
+		// you must first include the image.php file
1556
+		// for the function wp_generate_attachment_metadata() to work
1557
+		require_once(ABSPATH . 'wp-admin/includes/image.php');
1558
+		$attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1559
+		if (! $attach_data) {
1560
+			$migration_stage->add_error(sprintf(esc_html__(
1561
+				"Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1562
+				"event_espresso"
1563
+			), $attach_id, $local_filepath, $guid));
1564
+			return $attach_id;
1565
+		}
1566
+		$metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1567
+		if (! $metadata_save_result) {
1568
+			$migration_stage->add_error(sprintf(esc_html__(
1569
+				"Could not update attachment metadata for attachment %d with data %s",
1570
+				"event_espresso"
1571
+			), $attach_id, $this->_json_encode($attach_data)));
1572
+		}
1573
+		return $attach_id;
1574
+	}
1575
+
1576
+
1577
+
1578
+	/**
1579
+	 * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself),
1580
+	 * and returns its ID.
1581
+	 *
1582
+	 * @global type  $wpdb
1583
+	 * @param string $guid
1584
+	 * @return int
1585
+	 */
1586
+	private function _get_image_attachment_id_by_GUID($guid)
1587
+	{
1588
+		global $wpdb;
1589
+		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1590
+		return $attachment_id;
1591
+	}
1592
+
1593
+
1594
+
1595
+	/**
1596
+	 * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1597
+	 * (and optionally a timezone; if none is given, the wp default is used)
1598
+	 *
1599
+	 * @param EE_Data_Migration_Script_base $stage
1600
+	 * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1601
+	 *                                                   UTC time for
1602
+	 * @param string                        $DATETIME_string
1603
+	 * @param string                        $timezone
1604
+	 * @return string
1605
+	 */
1606
+	public function convert_date_string_to_utc(
1607
+		EE_Data_Migration_Script_Stage $stage,
1608
+		$row_of_data,
1609
+		$DATETIME_string,
1610
+		$timezone = null
1611
+	) {
1612
+		$original_tz = $timezone;
1613
+		if (! $timezone) {
1614
+			$timezone = $this->_get_wp_timezone();
1615
+		}
1616
+		if (! $timezone) {
1617
+			$stage->add_error(sprintf(
1618
+				esc_html__("Could not find timezone given %s for %s", "event_espresso"),
1619
+				$original_tz,
1620
+				$row_of_data
1621
+			));
1622
+			$timezone = 'UTC';
1623
+		}
1624
+		try {
1625
+			$date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1626
+			EEH_DTT_Helper::setTimezone($date_obj, new DateTimeZone('UTC'));
1627
+		} catch (Exception $e) {
1628
+			$stage->add_error(sprintf(esc_html__(
1629
+				"Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.",
1630
+				"event_espresso"
1631
+			), $DATETIME_string, $timezone));
1632
+			$date_obj = new DateTime();
1633
+		}
1634
+		return $date_obj->format('Y-m-d H:i:s');
1635
+	}
1636
+
1637
+
1638
+
1639
+	/**
1640
+	 * Gets the default timezone string from wordpress (even if they set a gmt offset)
1641
+	 *
1642
+	 * @return string
1643
+	 */
1644
+	private function _get_wp_timezone()
1645
+	{
1646
+		$timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1647
+		// if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1648
+		if (empty($timezone)) {
1649
+			// let's get a the WordPress UTC offset
1650
+			$offset = get_option('gmt_offset');
1651
+			$timezone = $this->timezone_convert_to_string_from_offset($offset);
1652
+		}
1653
+		return $timezone;
1654
+	}
1655
+
1656
+
1657
+
1658
+	/**
1659
+	 * Gets the wordpress timezone string from a UTC offset
1660
+	 *
1661
+	 * @param int $offset
1662
+	 * @return boolean
1663
+	 */
1664
+	private function timezone_convert_to_string_from_offset($offset)
1665
+	{
1666
+		// 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
1667
+		$offset *= 3600; // convert hour offset to seconds
1668
+		$abbrarray = timezone_abbreviations_list();
1669
+		foreach ($abbrarray as $abbr) {
1670
+			foreach ($abbr as $city) {
1671
+				if ($city['offset'] == $offset) {
1672
+					return $city['timezone_id'];
1673
+				}
1674
+			}
1675
+		}
1676
+		return false;
1677
+	}
1678
+
1679
+
1680
+
1681
+	public function migration_page_hooks()
1682
+	{
1683
+		add_filter(
1684
+			'FHEE__ee_migration_page__header',
1685
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1686
+			10,
1687
+			3
1688
+		);
1689
+		add_filter(
1690
+			'FHEE__ee_migration_page__p_after_header',
1691
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1692
+			10,
1693
+			2
1694
+		);
1695
+		add_filter(
1696
+			'FHEE__ee_migration_page__option_1_main',
1697
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1698
+			10,
1699
+			3
1700
+		);
1701
+		add_filter(
1702
+			'FHEE__ee_migration_page__option_1_button_text',
1703
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1704
+			10,
1705
+			3
1706
+		);
1707
+		add_action(
1708
+			'AHEE__ee_migration_page__option_1_extra_details',
1709
+			array($this, '_migration_page_hook_option_1_extra_details'),
1710
+			10,
1711
+			3
1712
+		);
1713
+		add_filter(
1714
+			'FHEE__ee_migration_page__option_2_main',
1715
+			array($this, '_migrate_page_hook_simplify_version_strings'),
1716
+			10,
1717
+			4
1718
+		);
1719
+		add_filter(
1720
+			'FHEE__ee_migration_page__option_2_button_text',
1721
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1722
+			10,
1723
+			2
1724
+		);
1725
+		add_filter(
1726
+			'FHEE__ee_migration_page__option_2_details',
1727
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1728
+			10,
1729
+			2
1730
+		);
1731
+		add_action(
1732
+			'AHEE__ee_migration_page__after_migration_options_table',
1733
+			array($this, '_migration_page_hook_after_migration_options_table')
1734
+		);
1735
+		add_filter(
1736
+			'FHEE__ee_migration_page__done_migration_header',
1737
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1738
+			10,
1739
+			2
1740
+		);
1741
+		add_filter(
1742
+			'FHEE__ee_migration_page__p_after_done_migration_header',
1743
+			array($this, '_migration_page_hook_simplify_next_db_state'),
1744
+			10,
1745
+			2
1746
+		);
1747
+		add_filter(
1748
+			'FHEE__ee_migration_page__migration_options_template',
1749
+			array($this,'use_migration_options_from_ee3_template')
1750
+		);
1751
+	}
1752
+
1753
+
1754
+
1755
+	public function _migrate_page_hook_simplify_version_strings(
1756
+		$old_content,
1757
+		$current_db_state,
1758
+		$next_db_state,
1759
+		$ultimate_db_state = null
1760
+	) {
1761
+		return str_replace(
1762
+			array($current_db_state, $next_db_state, $ultimate_db_state),
1763
+			array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')),
1764
+			$old_content
1765
+		);
1766
+	}
1767
+
1768
+
1769
+
1770
+	public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state)
1771
+	{
1772
+		return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content);
1773
+	}
1774
+
1775
+
1776
+
1777
+	public function _migration_page_hook_option_1_extra_details()
1778
+	{
1779
+		?>
1780 1780
         <p><?php printf(esc_html__(
1781
-            "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",
1782
-            "event_espresso"
1783
-        )); ?></p><?php
1784
-    }
1781
+			"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",
1782
+			"event_espresso"
1783
+		)); ?></p><?php
1784
+	}
1785 1785
 
1786 1786
 
1787 1787
 
1788
-    public function _migration_page_hook_after_migration_options_table()
1789
-    {
1790
-        ?><p class="ee-attention">
1788
+	public function _migration_page_hook_after_migration_options_table()
1789
+	{
1790
+		?><p class="ee-attention">
1791 1791
         <strong><span class="reminder-spn">
1792 1792
                 <?php esc_html_e(
1793
-                    "Important note to those using Event Espresso 3 addons: ",
1794
-                    "event_espresso"
1795
-                ); ?></span></strong>
1793
+					"Important note to those using Event Espresso 3 addons: ",
1794
+					"event_espresso"
1795
+				); ?></span></strong>
1796 1796
         <br/>
1797 1797
         <?php esc_html_e(
1798
-            "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.",
1799
-            "event_espresso"
1800
-        ); ?>
1798
+			"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.",
1799
+			"event_espresso"
1800
+		); ?>
1801 1801
         </p><?php
1802
-    }
1802
+	}
1803 1803
 
1804 1804
 
1805 1805
 
1806
-    /**
1807
-     * When showing the migration options, show more options and info than normal (ie, give folks the option
1808
-     * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because
1809
-     * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea).
1810
-     * @param $template_filepath
1811
-     * @return string
1812
-     */
1813
-    public function use_migration_options_from_ee3_template($template_filepath)
1814
-    {
1815
-        return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1816
-    }
1806
+	/**
1807
+	 * When showing the migration options, show more options and info than normal (ie, give folks the option
1808
+	 * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because
1809
+	 * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea).
1810
+	 * @param $template_filepath
1811
+	 * @return string
1812
+	 */
1813
+	public function use_migration_options_from_ee3_template($template_filepath)
1814
+	{
1815
+		return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1816
+	}
1817 1817
 }
Please login to merge, or discard this patch.