Completed
Branch FET/reg-form-builder/main (d0d867)
by
unknown
09:57 queued 24s
created
core/domain/services/factories/CartFactory.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@
 block discarded – undo
23 23
 class CartFactory
24 24
 {
25 25
 
26
-    /**
27
-     * @return EE_Cart
28
-     * @throws InvalidArgumentException
29
-     * @throws InvalidInterfaceException
30
-     * @throws InvalidDataTypeException
31
-     */
32
-    public static function getCart()
33
-    {
34
-        return LoaderFactory::getLoader()->getShared('EE_Cart');
35
-    }
26
+	/**
27
+	 * @return EE_Cart
28
+	 * @throws InvalidArgumentException
29
+	 * @throws InvalidInterfaceException
30
+	 * @throws InvalidDataTypeException
31
+	 */
32
+	public static function getCart()
33
+	{
34
+		return LoaderFactory::getLoader()->getShared('EE_Cart');
35
+	}
36 36
 }
Please login to merge, or discard this patch.
core/EE_Config.core.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
      * @param    string         $name
534 534
      * @param    string         $config_class
535 535
      * @param    EE_Config_Base $config_obj
536
-     * @param    array          $tests_to_run
536
+     * @param    integer[]          $tests_to_run
537 537
      * @param    bool           $display_errors
538 538
      * @return    bool    TRUE on success, FALSE on fail
539 539
      */
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
      * @access    public
798 798
      * @param    string                $section
799 799
      * @param    string                $name
800
-     * @param    EE_Config_Base|string $config_obj
800
+     * @param    EE_Config_Base $config_obj
801 801
      * @param    bool                  $throw_errors
802 802
      * @return    bool
803 803
      */
@@ -1764,7 +1764,7 @@  discard block
 block discarded – undo
1764 1764
 
1765 1765
 
1766 1766
     /**
1767
-     * @return array
1767
+     * @return integer[]
1768 1768
      */
1769 1769
     public function get_critical_pages_array()
1770 1770
     {
@@ -1779,7 +1779,7 @@  discard block
 block discarded – undo
1779 1779
 
1780 1780
 
1781 1781
     /**
1782
-     * @return array
1782
+     * @return string[]
1783 1783
      */
1784 1784
     public function get_critical_pages_shortcodes_array()
1785 1785
     {
@@ -3122,7 +3122,7 @@  discard block
 block discarded – undo
3122 3122
      * according to max_input_vars
3123 3123
      *
3124 3124
      * @param int   $input_count the count of input vars.
3125
-     * @return array {
3125
+     * @return string {
3126 3126
      *                           An array that represents whether available space and if no available space the error
3127 3127
      *                           message.
3128 3128
      * @type bool   $has_space   whether more inputs can be added.
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     public static function instance()
146 146
     {
147 147
         // check if class object is instantiated, and instantiated properly
148
-        if (! self::$_instance instanceof EE_Config) {
148
+        if ( ! self::$_instance instanceof EE_Config) {
149 149
             self::$_instance = new self();
150 150
         }
151 151
         return self::$_instance;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                 $this
284 284
             );
285 285
             if (is_object($settings) && property_exists($this, $config)) {
286
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
286
+                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
287 287
                 // call configs populate method to ensure any defaults are set for empty values.
288 288
                 if (method_exists($settings, 'populate')) {
289 289
                     $this->{$config}->populate();
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
                         break;
557 557
                     // TEST #2 : check that settings section exists
558 558
                     case 2:
559
-                        if (! isset($this->{$section})) {
559
+                        if ( ! isset($this->{$section})) {
560 560
                             if ($display_errors) {
561 561
                                 throw new EE_Error(
562 562
                                     sprintf(
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
                         break;
618 618
                     // TEST #6 : verify config class is accessible
619 619
                     case 6:
620
-                        if (! class_exists($config_class)) {
620
+                        if ( ! class_exists($config_class)) {
621 621
                             if ($display_errors) {
622 622
                                 throw new EE_Error(
623 623
                                     sprintf(
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
                         break;
635 635
                     // TEST #7 : check that config has even been set
636 636
                     case 7:
637
-                        if (! isset($this->{$section}->{$name})) {
637
+                        if ( ! isset($this->{$section}->{$name})) {
638 638
                             if ($display_errors) {
639 639
                                 throw new EE_Error(
640 640
                                     sprintf(
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
                         break;
653 653
                     // TEST #8 : check that config is the requested type
654 654
                     case 8:
655
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
655
+                        if ( ! $this->{$section}->{$name} instanceof $config_class) {
656 656
                             if ($display_errors) {
657 657
                                 throw new EE_Error(
658 658
                                     sprintf(
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
                         break;
672 672
                     // TEST #9 : verify config object
673 673
                     case 9:
674
-                        if (! $config_obj instanceof EE_Config_Base) {
674
+                        if ( ! $config_obj instanceof EE_Config_Base) {
675 675
                             if ($display_errors) {
676 676
                                 throw new EE_Error(
677 677
                                     sprintf(
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
      */
704 704
     private function _generate_config_option_name($section = '', $name = '')
705 705
     {
706
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
706
+        return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
707 707
     }
708 708
 
709 709
 
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
     {
721 721
         return ! empty($config_class)
722 722
             ? $config_class
723
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
723
+            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
724 724
     }
725 725
 
726 726
 
@@ -739,17 +739,17 @@  discard block
 block discarded – undo
739 739
         // ensure config class is set to something
740 740
         $config_class = $this->_set_config_class($config_class, $name);
741 741
         // run tests 1-4, 6, and 7 to verify all config params are set and valid
742
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
742
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
743 743
             return null;
744 744
         }
745 745
         $config_option_name = $this->_generate_config_option_name($section, $name);
746 746
         // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
747
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
748
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
747
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
748
+            $this->_addon_option_names[$config_option_name] = $config_class;
749 749
             $this->update_addon_option_names();
750 750
         }
751 751
         // verify the incoming config object but suppress errors
752
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
752
+        if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
753 753
             $config_obj = new $config_class();
754 754
         }
755 755
         if (get_option($config_option_name)) {
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
         }
810 810
         $config_option_name = $this->_generate_config_option_name($section, $name);
811 811
         // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
812
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
812
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
813 813
             // save new config to db
814 814
             if ($this->set_config($section, $name, $config_class, $config_obj)) {
815 815
                 return true;
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
                             'event_espresso'
836 836
                         ),
837 837
                         $config_class,
838
-                        'EE_Config->' . $section . '->' . $name
838
+                        'EE_Config->'.$section.'->'.$name
839 839
                     ),
840 840
                     __FILE__,
841 841
                     __FUNCTION__,
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
         // ensure config class is set to something
862 862
         $config_class = $this->_set_config_class($config_class, $name);
863 863
         // run tests 1-4, 6 and 7 to verify that all params have been set
864
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
864
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
865 865
             return null;
866 866
         }
867 867
         // now test if the requested config object exists, but suppress errors
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
         // retrieve the wp-option for this config class.
907 907
         $config_option = maybe_unserialize(get_option($config_option_name, array()));
908 908
         if (empty($config_option)) {
909
-            EE_Config::log($config_option_name . '-NOT-FOUND');
909
+            EE_Config::log($config_option_name.'-NOT-FOUND');
910 910
         }
911 911
         return $config_option;
912 912
     }
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
             // copy incoming $_REQUEST and sanitize it so we can save it
925 925
             $_request = $_REQUEST;
926 926
             array_walk_recursive($_request, 'sanitize_text_field');
927
-            $config_log[ (string) microtime(true) ] = array(
927
+            $config_log[(string) microtime(true)] = array(
928 928
                 'config_name' => $config_option_name,
929 929
                 'request'     => $_request,
930 930
             );
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
      */
940 940
     public static function trim_log()
941 941
     {
942
-        if (! EE_Config::logging_enabled()) {
942
+        if ( ! EE_Config::logging_enabled()) {
943 943
             return;
944 944
         }
945 945
         $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
     public static function get_page_for_posts()
964 964
     {
965 965
         $page_for_posts = get_option('page_for_posts');
966
-        if (! $page_for_posts) {
966
+        if ( ! $page_for_posts) {
967 967
             return 'posts';
968 968
         }
969 969
         /** @type WPDB $wpdb */
@@ -1021,13 +1021,13 @@  discard block
 block discarded – undo
1021 1021
             )
1022 1022
         ) {
1023 1023
             // grab list of installed widgets
1024
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1024
+            $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
1025 1025
             // filter list of modules to register
1026 1026
             $widgets_to_register = apply_filters(
1027 1027
                 'FHEE__EE_Config__register_widgets__widgets_to_register',
1028 1028
                 $widgets_to_register
1029 1029
             );
1030
-            if (! empty($widgets_to_register)) {
1030
+            if ( ! empty($widgets_to_register)) {
1031 1031
                 // cycle thru widget folders
1032 1032
                 foreach ($widgets_to_register as $widget_path) {
1033 1033
                     // add to list of installed widget modules
@@ -1077,31 +1077,31 @@  discard block
 block discarded – undo
1077 1077
         // create classname from widget directory name
1078 1078
         $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1079 1079
         // add class prefix
1080
-        $widget_class = 'EEW_' . $widget;
1080
+        $widget_class = 'EEW_'.$widget;
1081 1081
         // does the widget exist ?
1082
-        if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1082
+        if ( ! is_readable($widget_path.'/'.$widget_class.$widget_ext)) {
1083 1083
             $msg = sprintf(
1084 1084
                 __(
1085 1085
                     'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1086 1086
                     'event_espresso'
1087 1087
                 ),
1088 1088
                 $widget_class,
1089
-                $widget_path . '/' . $widget_class . $widget_ext
1089
+                $widget_path.'/'.$widget_class.$widget_ext
1090 1090
             );
1091
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1091
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1092 1092
             return;
1093 1093
         }
1094 1094
         // load the widget class file
1095
-        require_once($widget_path . '/' . $widget_class . $widget_ext);
1095
+        require_once($widget_path.'/'.$widget_class.$widget_ext);
1096 1096
         // verify that class exists
1097
-        if (! class_exists($widget_class)) {
1097
+        if ( ! class_exists($widget_class)) {
1098 1098
             $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1099
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1099
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1100 1100
             return;
1101 1101
         }
1102 1102
         register_widget($widget_class);
1103 1103
         // add to array of registered widgets
1104
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1104
+        EE_Registry::instance()->widgets->{$widget_class} = $widget_path.'/'.$widget_class.$widget_ext;
1105 1105
     }
1106 1106
 
1107 1107
 
@@ -1114,19 +1114,19 @@  discard block
 block discarded – undo
1114 1114
     private function _register_modules()
1115 1115
     {
1116 1116
         // grab list of installed modules
1117
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1117
+        $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1118 1118
         // filter list of modules to register
1119 1119
         $modules_to_register = apply_filters(
1120 1120
             'FHEE__EE_Config__register_modules__modules_to_register',
1121 1121
             $modules_to_register
1122 1122
         );
1123
-        if (! empty($modules_to_register)) {
1123
+        if ( ! empty($modules_to_register)) {
1124 1124
             // loop through folders
1125 1125
             foreach ($modules_to_register as $module_path) {
1126 1126
                 /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1127 1127
                 if (
1128
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1129
-                    && $module_path !== EE_MODULES . 'gateways'
1128
+                    $module_path !== EE_MODULES.'zzz-copy-this-module-template'
1129
+                    && $module_path !== EE_MODULES.'gateways'
1130 1130
                 ) {
1131 1131
                     // add to list of installed modules
1132 1132
                     EE_Config::register_module($module_path);
@@ -1163,25 +1163,25 @@  discard block
 block discarded – undo
1163 1163
             // remove last segment
1164 1164
             array_pop($module_path);
1165 1165
             // glue it back together
1166
-            $module_path = implode('/', $module_path) . '/';
1166
+            $module_path = implode('/', $module_path).'/';
1167 1167
             // take first segment from file name pieces and sanitize it
1168 1168
             $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1169 1169
             // ensure class prefix is added
1170
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1170
+            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1171 1171
         } else {
1172 1172
             // we need to generate the filename based off of the folder name
1173 1173
             // grab and sanitize module name
1174 1174
             $module = strtolower(basename($module_path));
1175 1175
             $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1176 1176
             // like trailingslashit()
1177
-            $module_path = rtrim($module_path, '/') . '/';
1177
+            $module_path = rtrim($module_path, '/').'/';
1178 1178
             // create classname from module directory name
1179 1179
             $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1180 1180
             // add class prefix
1181
-            $module_class = 'EED_' . $module;
1181
+            $module_class = 'EED_'.$module;
1182 1182
         }
1183 1183
         // does the module exist ?
1184
-        if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1184
+        if ( ! is_readable($module_path.'/'.$module_class.$module_ext)) {
1185 1185
             $msg = sprintf(
1186 1186
                 __(
1187 1187
                     'The requested %s module file could not be found or is not readable due to file permissions.',
@@ -1189,19 +1189,19 @@  discard block
 block discarded – undo
1189 1189
                 ),
1190 1190
                 $module
1191 1191
             );
1192
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1192
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1193 1193
             return false;
1194 1194
         }
1195 1195
         // load the module class file
1196
-        require_once($module_path . $module_class . $module_ext);
1196
+        require_once($module_path.$module_class.$module_ext);
1197 1197
         // verify that class exists
1198
-        if (! class_exists($module_class)) {
1198
+        if ( ! class_exists($module_class)) {
1199 1199
             $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1200
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1200
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1201 1201
             return false;
1202 1202
         }
1203 1203
         // add to array of registered modules
1204
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1204
+        EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1205 1205
         do_action(
1206 1206
             'AHEE__EE_Config__register_module__complete',
1207 1207
             $module_class,
@@ -1252,26 +1252,26 @@  discard block
 block discarded – undo
1252 1252
     {
1253 1253
         do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1254 1254
         $module = str_replace('EED_', '', $module);
1255
-        $module_class = 'EED_' . $module;
1256
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1255
+        $module_class = 'EED_'.$module;
1256
+        if ( ! isset(EE_Registry::instance()->modules->{$module_class})) {
1257 1257
             $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1258
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1258
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1259 1259
             return false;
1260 1260
         }
1261 1261
         if (empty($route)) {
1262 1262
             $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1263
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1263
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1264 1264
             return false;
1265 1265
         }
1266
-        if (! method_exists('EED_' . $module, $method_name)) {
1266
+        if ( ! method_exists('EED_'.$module, $method_name)) {
1267 1267
             $msg = sprintf(
1268 1268
                 __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1269 1269
                 $route
1270 1270
             );
1271
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1271
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1272 1272
             return false;
1273 1273
         }
1274
-        EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1274
+        EE_Config::$_module_route_map[(string) $key][(string) $route] = array('EED_'.$module, $method_name);
1275 1275
         return true;
1276 1276
     }
1277 1277
 
@@ -1288,8 +1288,8 @@  discard block
 block discarded – undo
1288 1288
     {
1289 1289
         do_action('AHEE__EE_Config__get_route__begin', $route);
1290 1290
         $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1291
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1292
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1291
+        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1292
+            return EE_Config::$_module_route_map[$key][$route];
1293 1293
         }
1294 1294
         return null;
1295 1295
     }
@@ -1321,47 +1321,47 @@  discard block
 block discarded – undo
1321 1321
     public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1322 1322
     {
1323 1323
         do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1324
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1324
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1325 1325
             $msg = sprintf(
1326 1326
                 __('The module route %s for this forward has not been registered.', 'event_espresso'),
1327 1327
                 $route
1328 1328
             );
1329
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1329
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1330 1330
             return false;
1331 1331
         }
1332 1332
         if (empty($forward)) {
1333 1333
             $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1334
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1334
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1335 1335
             return false;
1336 1336
         }
1337 1337
         if (is_array($forward)) {
1338
-            if (! isset($forward[1])) {
1338
+            if ( ! isset($forward[1])) {
1339 1339
                 $msg = sprintf(
1340 1340
                     __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1341 1341
                     $route
1342 1342
                 );
1343
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1343
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1344 1344
                 return false;
1345 1345
             }
1346
-            if (! method_exists($forward[0], $forward[1])) {
1346
+            if ( ! method_exists($forward[0], $forward[1])) {
1347 1347
                 $msg = sprintf(
1348 1348
                     __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1349 1349
                     $forward[1],
1350 1350
                     $route
1351 1351
                 );
1352
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1352
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1353 1353
                 return false;
1354 1354
             }
1355
-        } elseif (! function_exists($forward)) {
1355
+        } elseif ( ! function_exists($forward)) {
1356 1356
             $msg = sprintf(
1357 1357
                 __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1358 1358
                 $forward,
1359 1359
                 $route
1360 1360
             );
1361
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1361
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1362 1362
             return false;
1363 1363
         }
1364
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1364
+        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1365 1365
         return true;
1366 1366
     }
1367 1367
 
@@ -1379,10 +1379,10 @@  discard block
 block discarded – undo
1379 1379
     public static function get_forward($route = null, $status = 0, $key = 'ee')
1380 1380
     {
1381 1381
         do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1382
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1382
+        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1383 1383
             return apply_filters(
1384 1384
                 'FHEE__EE_Config__get_forward',
1385
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1385
+                EE_Config::$_module_forward_map[$key][$route][$status],
1386 1386
                 $route,
1387 1387
                 $status
1388 1388
             );
@@ -1406,15 +1406,15 @@  discard block
 block discarded – undo
1406 1406
     public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1407 1407
     {
1408 1408
         do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1409
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1409
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1410 1410
             $msg = sprintf(
1411 1411
                 __('The module route %s for this view has not been registered.', 'event_espresso'),
1412 1412
                 $route
1413 1413
             );
1414
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1414
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1415 1415
             return false;
1416 1416
         }
1417
-        if (! is_readable($view)) {
1417
+        if ( ! is_readable($view)) {
1418 1418
             $msg = sprintf(
1419 1419
                 __(
1420 1420
                     'The %s view file could not be found or is not readable due to file permissions.',
@@ -1422,10 +1422,10 @@  discard block
 block discarded – undo
1422 1422
                 ),
1423 1423
                 $view
1424 1424
             );
1425
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1425
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1426 1426
             return false;
1427 1427
         }
1428
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1428
+        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1429 1429
         return true;
1430 1430
     }
1431 1431
 
@@ -1443,10 +1443,10 @@  discard block
 block discarded – undo
1443 1443
     public static function get_view($route = null, $status = 0, $key = 'ee')
1444 1444
     {
1445 1445
         do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1446
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1446
+        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1447 1447
             return apply_filters(
1448 1448
                 'FHEE__EE_Config__get_view',
1449
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1449
+                EE_Config::$_module_view_map[$key][$route][$status],
1450 1450
                 $route,
1451 1451
                 $status
1452 1452
             );
@@ -1473,7 +1473,7 @@  discard block
 block discarded – undo
1473 1473
     public static function getLegacyShortcodesManager()
1474 1474
     {
1475 1475
 
1476
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1476
+        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1477 1477
             EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1478 1478
                 EE_Registry::instance()
1479 1479
             );
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
      */
1521 1521
     public function get_pretty($property)
1522 1522
     {
1523
-        if (! property_exists($this, $property)) {
1523
+        if ( ! property_exists($this, $property)) {
1524 1524
             throw new EE_Error(
1525 1525
                 sprintf(
1526 1526
                     __(
@@ -1749,11 +1749,11 @@  discard block
 block discarded – undo
1749 1749
      */
1750 1750
     public function reg_page_url()
1751 1751
     {
1752
-        if (! $this->reg_page_url) {
1752
+        if ( ! $this->reg_page_url) {
1753 1753
             $this->reg_page_url = add_query_arg(
1754 1754
                 array('uts' => time()),
1755 1755
                 get_permalink($this->reg_page_id)
1756
-            ) . '#checkout';
1756
+            ).'#checkout';
1757 1757
         }
1758 1758
         return $this->reg_page_url;
1759 1759
     }
@@ -1769,7 +1769,7 @@  discard block
 block discarded – undo
1769 1769
      */
1770 1770
     public function txn_page_url($query_args = array())
1771 1771
     {
1772
-        if (! $this->txn_page_url) {
1772
+        if ( ! $this->txn_page_url) {
1773 1773
             $this->txn_page_url = get_permalink($this->txn_page_id);
1774 1774
         }
1775 1775
         if ($query_args) {
@@ -1790,7 +1790,7 @@  discard block
 block discarded – undo
1790 1790
      */
1791 1791
     public function thank_you_page_url($query_args = array())
1792 1792
     {
1793
-        if (! $this->thank_you_page_url) {
1793
+        if ( ! $this->thank_you_page_url) {
1794 1794
             $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1795 1795
         }
1796 1796
         if ($query_args) {
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
      */
1810 1810
     public function cancel_page_url()
1811 1811
     {
1812
-        if (! $this->cancel_page_url) {
1812
+        if ( ! $this->cancel_page_url) {
1813 1813
             $this->cancel_page_url = get_permalink($this->cancel_page_id);
1814 1814
         }
1815 1815
         return $this->cancel_page_url;
@@ -1852,13 +1852,13 @@  discard block
 block discarded – undo
1852 1852
         $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1853 1853
         $option = self::OPTION_NAME_UXIP;
1854 1854
         // set correct table for query
1855
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1855
+        $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1856 1856
         // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1857 1857
         // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1858 1858
         // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1859 1859
         // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1860 1860
         // for the purpose of caching.
1861
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1861
+        $pre = apply_filters('pre_option_'.$option, false, $option);
1862 1862
         if (false !== $pre) {
1863 1863
             EE_Core_Config::$ee_ueip_option = $pre;
1864 1864
             return EE_Core_Config::$ee_ueip_option;
@@ -1872,10 +1872,10 @@  discard block
 block discarded – undo
1872 1872
         if (is_object($row)) {
1873 1873
             $value = $row->option_value;
1874 1874
         } else { // option does not exist so use default.
1875
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1875
+            EE_Core_Config::$ee_ueip_option = apply_filters('default_option_'.$option, false, $option);
1876 1876
             return EE_Core_Config::$ee_ueip_option;
1877 1877
         }
1878
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1878
+        EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
1879 1879
         return EE_Core_Config::$ee_ueip_option;
1880 1880
     }
1881 1881
 
@@ -2137,30 +2137,30 @@  discard block
 block discarded – undo
2137 2137
             // retrieve the country settings from the db, just in case they have been customized
2138 2138
             $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2139 2139
             if ($country instanceof EE_Country) {
2140
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2141
-                $this->name = $country->currency_name_single();    // Dollar
2142
-                $this->plural = $country->currency_name_plural();    // Dollars
2143
-                $this->sign = $country->currency_sign();            // currency sign: $
2140
+                $this->code = $country->currency_code(); // currency code: USD, CAD, EUR
2141
+                $this->name = $country->currency_name_single(); // Dollar
2142
+                $this->plural = $country->currency_name_plural(); // Dollars
2143
+                $this->sign = $country->currency_sign(); // currency sign: $
2144 2144
                 $this->sign_b4 = $country->currency_sign_before(
2145
-                );        // currency sign before or after: $TRUE  or  FALSE$
2146
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2145
+                ); // currency sign before or after: $TRUE  or  FALSE$
2146
+                $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
2147 2147
                 $this->dec_mrk = $country->currency_decimal_mark(
2148
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2148
+                ); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2149 2149
                 $this->thsnds = $country->currency_thousands_separator(
2150
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2150
+                ); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2151 2151
             }
2152 2152
         }
2153 2153
         // fallback to hardcoded defaults, in case the above failed
2154 2154
         if (empty($this->code)) {
2155 2155
             // set default currency settings
2156
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2157
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2158
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2159
-            $this->sign = '$';    // currency sign: $
2160
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2161
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2162
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2163
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2156
+            $this->code = 'USD'; // currency code: USD, CAD, EUR
2157
+            $this->name = __('Dollar', 'event_espresso'); // Dollar
2158
+            $this->plural = __('Dollars', 'event_espresso'); // Dollars
2159
+            $this->sign = '$'; // currency sign: $
2160
+            $this->sign_b4 = true; // currency sign before or after: $TRUE  or  FALSE$
2161
+            $this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
2162
+            $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2163
+            $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2164 2164
         }
2165 2165
     }
2166 2166
 }
@@ -2429,8 +2429,8 @@  discard block
 block discarded – undo
2429 2429
             $closing_a_tag = '';
2430 2430
             if (function_exists('get_privacy_policy_url')) {
2431 2431
                 $privacy_page_url = get_privacy_policy_url();
2432
-                if (! empty($privacy_page_url)) {
2433
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2432
+                if ( ! empty($privacy_page_url)) {
2433
+                    $opening_a_tag = '<a href="'.$privacy_page_url.'" target="_blank">';
2434 2434
                     $closing_a_tag = '</a>';
2435 2435
                 }
2436 2436
             }
@@ -2665,7 +2665,7 @@  discard block
 block discarded – undo
2665 2665
     public function log_file_name($reset = false)
2666 2666
     {
2667 2667
         if (empty($this->log_file_name) || $reset) {
2668
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2668
+            $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt';
2669 2669
             EE_Config::instance()->update_espresso_config(false, false);
2670 2670
         }
2671 2671
         return $this->log_file_name;
@@ -2679,7 +2679,7 @@  discard block
 block discarded – undo
2679 2679
     public function debug_file_name($reset = false)
2680 2680
     {
2681 2681
         if (empty($this->debug_file_name) || $reset) {
2682
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2682
+            $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt';
2683 2683
             EE_Config::instance()->update_espresso_config(false, false);
2684 2684
         }
2685 2685
         return $this->debug_file_name;
@@ -2906,21 +2906,21 @@  discard block
 block discarded – undo
2906 2906
         $this->use_google_maps = true;
2907 2907
         $this->google_map_api_key = '';
2908 2908
         // for event details pages (reg page)
2909
-        $this->event_details_map_width = 585;            // ee_map_width_single
2910
-        $this->event_details_map_height = 362;            // ee_map_height_single
2911
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2912
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2913
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2914
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2915
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2909
+        $this->event_details_map_width = 585; // ee_map_width_single
2910
+        $this->event_details_map_height = 362; // ee_map_height_single
2911
+        $this->event_details_map_zoom = 14; // ee_map_zoom_single
2912
+        $this->event_details_display_nav = true; // ee_map_nav_display_single
2913
+        $this->event_details_nav_size = false; // ee_map_nav_size_single
2914
+        $this->event_details_control_type = 'default'; // ee_map_type_control_single
2915
+        $this->event_details_map_align = 'center'; // ee_map_align_single
2916 2916
         // for event list pages
2917
-        $this->event_list_map_width = 300;            // ee_map_width
2918
-        $this->event_list_map_height = 185;        // ee_map_height
2919
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2920
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2921
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2922
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2923
-        $this->event_list_map_align = 'center';            // ee_map_align
2917
+        $this->event_list_map_width = 300; // ee_map_width
2918
+        $this->event_list_map_height = 185; // ee_map_height
2919
+        $this->event_list_map_zoom = 12; // ee_map_zoom
2920
+        $this->event_list_display_nav = false; // ee_map_nav_display
2921
+        $this->event_list_nav_size = true; // ee_map_nav_size
2922
+        $this->event_list_control_type = 'dropdown'; // ee_map_type_control
2923
+        $this->event_list_map_align = 'center'; // ee_map_align
2924 2924
     }
2925 2925
 }
2926 2926
 
Please login to merge, or discard this patch.
Indentation   +3213 added lines, -3213 removed lines patch added patch discarded remove patch
@@ -14,2544 +14,2544 @@  discard block
 block discarded – undo
14 14
 final class EE_Config implements ResettableInterface
15 15
 {
16 16
 
17
-    const OPTION_NAME = 'ee_config';
18
-
19
-    const LOG_NAME = 'ee_config_log';
20
-
21
-    const LOG_LENGTH = 100;
22
-
23
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
24
-
25
-    /**
26
-     *    instance of the EE_Config object
27
-     *
28
-     * @var    EE_Config $_instance
29
-     * @access    private
30
-     */
31
-    private static $_instance;
32
-
33
-    /**
34
-     * @var boolean $_logging_enabled
35
-     */
36
-    private static $_logging_enabled = false;
37
-
38
-    /**
39
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
40
-     */
41
-    private $legacy_shortcodes_manager;
42
-
43
-    /**
44
-     * An StdClass whose property names are addon slugs,
45
-     * and values are their config classes
46
-     *
47
-     * @var StdClass
48
-     */
49
-    public $addons;
50
-
51
-    /**
52
-     * @var EE_Admin_Config
53
-     */
54
-    public $admin;
55
-
56
-    /**
57
-     * @var EE_Core_Config
58
-     */
59
-    public $core;
60
-
61
-    /**
62
-     * @var EE_Currency_Config
63
-     */
64
-    public $currency;
65
-
66
-    /**
67
-     * @var EE_Organization_Config
68
-     */
69
-    public $organization;
70
-
71
-    /**
72
-     * @var EE_Registration_Config
73
-     */
74
-    public $registration;
75
-
76
-    /**
77
-     * @var EE_Template_Config
78
-     */
79
-    public $template_settings;
80
-
81
-    /**
82
-     * Holds EE environment values.
83
-     *
84
-     * @var EE_Environment_Config
85
-     */
86
-    public $environment;
87
-
88
-    /**
89
-     * settings pertaining to Google maps
90
-     *
91
-     * @var EE_Map_Config
92
-     */
93
-    public $map_settings;
94
-
95
-    /**
96
-     * settings pertaining to Taxes
97
-     *
98
-     * @var EE_Tax_Config
99
-     */
100
-    public $tax_settings;
101
-
102
-    /**
103
-     * Settings pertaining to global messages settings.
104
-     *
105
-     * @var EE_Messages_Config
106
-     */
107
-    public $messages;
108
-
109
-    /**
110
-     * @deprecated
111
-     * @var EE_Gateway_Config
112
-     */
113
-    public $gateway;
114
-
115
-    /**
116
-     * @var    array $_addon_option_names
117
-     * @access    private
118
-     */
119
-    private $_addon_option_names = array();
120
-
121
-    /**
122
-     * @var    array $_module_route_map
123
-     * @access    private
124
-     */
125
-    private static $_module_route_map = array();
126
-
127
-    /**
128
-     * @var    array $_module_forward_map
129
-     * @access    private
130
-     */
131
-    private static $_module_forward_map = array();
132
-
133
-    /**
134
-     * @var    array $_module_view_map
135
-     * @access    private
136
-     */
137
-    private static $_module_view_map = array();
138
-
139
-
140
-    /**
141
-     * @singleton method used to instantiate class object
142
-     * @access    public
143
-     * @return EE_Config instance
144
-     */
145
-    public static function instance()
146
-    {
147
-        // check if class object is instantiated, and instantiated properly
148
-        if (! self::$_instance instanceof EE_Config) {
149
-            self::$_instance = new self();
150
-        }
151
-        return self::$_instance;
152
-    }
153
-
154
-
155
-    /**
156
-     * Resets the config
157
-     *
158
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
159
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
160
-     *                               reflect its state in the database
161
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
162
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
163
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
164
-     *                               site was put into maintenance mode)
165
-     * @return EE_Config
166
-     */
167
-    public static function reset($hard_reset = false, $reinstantiate = true)
168
-    {
169
-        if (self::$_instance instanceof EE_Config) {
170
-            if ($hard_reset) {
171
-                self::$_instance->legacy_shortcodes_manager = null;
172
-                self::$_instance->_addon_option_names = array();
173
-                self::$_instance->_initialize_config();
174
-                self::$_instance->update_espresso_config();
175
-            }
176
-            self::$_instance->update_addon_option_names();
177
-        }
178
-        self::$_instance = null;
179
-        // we don't need to reset the static properties imo because those should
180
-        // only change when a module is added or removed. Currently we don't
181
-        // support removing a module during a request when it previously existed
182
-        if ($reinstantiate) {
183
-            return self::instance();
184
-        } else {
185
-            return null;
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     *    class constructor
192
-     *
193
-     * @access    private
194
-     */
195
-    private function __construct()
196
-    {
197
-        do_action('AHEE__EE_Config__construct__begin', $this);
198
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
199
-        // setup empty config classes
200
-        $this->_initialize_config();
201
-        // load existing EE site settings
202
-        $this->_load_core_config();
203
-        // confirm everything loaded correctly and set filtered defaults if not
204
-        $this->_verify_config();
205
-        //  register shortcodes and modules
206
-        add_action(
207
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
208
-            array($this, 'register_shortcodes_and_modules'),
209
-            999
210
-        );
211
-        //  initialize shortcodes and modules
212
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
213
-        // register widgets
214
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
215
-        // shutdown
216
-        add_action('shutdown', array($this, 'shutdown'), 10);
217
-        // construct__end hook
218
-        do_action('AHEE__EE_Config__construct__end', $this);
219
-        // hardcoded hack
220
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
221
-    }
222
-
223
-
224
-    /**
225
-     * @return boolean
226
-     */
227
-    public static function logging_enabled()
228
-    {
229
-        return self::$_logging_enabled;
230
-    }
231
-
232
-
233
-    /**
234
-     * use to get the current theme if needed from static context
235
-     *
236
-     * @return string current theme set.
237
-     */
238
-    public static function get_current_theme()
239
-    {
240
-        return isset(self::$_instance->template_settings->current_espresso_theme)
241
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
242
-    }
243
-
244
-
245
-    /**
246
-     *        _initialize_config
247
-     *
248
-     * @access private
249
-     * @return void
250
-     */
251
-    private function _initialize_config()
252
-    {
253
-        EE_Config::trim_log();
254
-        // set defaults
255
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
256
-        $this->addons = new stdClass();
257
-        // set _module_route_map
258
-        EE_Config::$_module_route_map = array();
259
-        // set _module_forward_map
260
-        EE_Config::$_module_forward_map = array();
261
-        // set _module_view_map
262
-        EE_Config::$_module_view_map = array();
263
-    }
264
-
265
-
266
-    /**
267
-     *        load core plugin configuration
268
-     *
269
-     * @access private
270
-     * @return void
271
-     */
272
-    private function _load_core_config()
273
-    {
274
-        // load_core_config__start hook
275
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
276
-        $espresso_config = $this->get_espresso_config();
277
-        foreach ($espresso_config as $config => $settings) {
278
-            // load_core_config__start hook
279
-            $settings = apply_filters(
280
-                'FHEE__EE_Config___load_core_config__config_settings',
281
-                $settings,
282
-                $config,
283
-                $this
284
-            );
285
-            if (is_object($settings) && property_exists($this, $config)) {
286
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
287
-                // call configs populate method to ensure any defaults are set for empty values.
288
-                if (method_exists($settings, 'populate')) {
289
-                    $this->{$config}->populate();
290
-                }
291
-                if (method_exists($settings, 'do_hooks')) {
292
-                    $this->{$config}->do_hooks();
293
-                }
294
-            }
295
-        }
296
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
297
-            $this->update_espresso_config();
298
-        }
299
-        // load_core_config__end hook
300
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
301
-    }
302
-
303
-
304
-    /**
305
-     *    _verify_config
306
-     *
307
-     * @access    protected
308
-     * @return    void
309
-     */
310
-    protected function _verify_config()
311
-    {
312
-        $this->core = $this->core instanceof EE_Core_Config
313
-            ? $this->core
314
-            : new EE_Core_Config();
315
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
316
-        $this->organization = $this->organization instanceof EE_Organization_Config
317
-            ? $this->organization
318
-            : new EE_Organization_Config();
319
-        $this->organization = apply_filters(
320
-            'FHEE__EE_Config___initialize_config__organization',
321
-            $this->organization
322
-        );
323
-        $this->currency = $this->currency instanceof EE_Currency_Config
324
-            ? $this->currency
325
-            : new EE_Currency_Config();
326
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
327
-        $this->registration = $this->registration instanceof EE_Registration_Config
328
-            ? $this->registration
329
-            : new EE_Registration_Config();
330
-        $this->registration = apply_filters(
331
-            'FHEE__EE_Config___initialize_config__registration',
332
-            $this->registration
333
-        );
334
-        $this->admin = $this->admin instanceof EE_Admin_Config
335
-            ? $this->admin
336
-            : new EE_Admin_Config();
337
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
338
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
339
-            ? $this->template_settings
340
-            : new EE_Template_Config();
341
-        $this->template_settings = apply_filters(
342
-            'FHEE__EE_Config___initialize_config__template_settings',
343
-            $this->template_settings
344
-        );
345
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
346
-            ? $this->map_settings
347
-            : new EE_Map_Config();
348
-        $this->map_settings = apply_filters(
349
-            'FHEE__EE_Config___initialize_config__map_settings',
350
-            $this->map_settings
351
-        );
352
-        $this->environment = $this->environment instanceof EE_Environment_Config
353
-            ? $this->environment
354
-            : new EE_Environment_Config();
355
-        $this->environment = apply_filters(
356
-            'FHEE__EE_Config___initialize_config__environment',
357
-            $this->environment
358
-        );
359
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
360
-            ? $this->tax_settings
361
-            : new EE_Tax_Config();
362
-        $this->tax_settings = apply_filters(
363
-            'FHEE__EE_Config___initialize_config__tax_settings',
364
-            $this->tax_settings
365
-        );
366
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
367
-        $this->messages = $this->messages instanceof EE_Messages_Config
368
-            ? $this->messages
369
-            : new EE_Messages_Config();
370
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
371
-            ? $this->gateway
372
-            : new EE_Gateway_Config();
373
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
374
-        $this->legacy_shortcodes_manager = null;
375
-    }
376
-
377
-
378
-    /**
379
-     *    get_espresso_config
380
-     *
381
-     * @access    public
382
-     * @return    array of espresso config stuff
383
-     */
384
-    public function get_espresso_config()
385
-    {
386
-        // grab espresso configuration
387
-        return apply_filters(
388
-            'FHEE__EE_Config__get_espresso_config__CFG',
389
-            get_option(EE_Config::OPTION_NAME, array())
390
-        );
391
-    }
392
-
393
-
394
-    /**
395
-     *    double_check_config_comparison
396
-     *
397
-     * @access    public
398
-     * @param string $option
399
-     * @param        $old_value
400
-     * @param        $value
401
-     */
402
-    public function double_check_config_comparison($option = '', $old_value, $value)
403
-    {
404
-        // make sure we're checking the ee config
405
-        if ($option === EE_Config::OPTION_NAME) {
406
-            // run a loose comparison of the old value against the new value for type and properties,
407
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
408
-            if ($value != $old_value) {
409
-                // if they are NOT the same, then remove the hook,
410
-                // which means the subsequent update results will be based solely on the update query results
411
-                // the reason we do this is because, as stated above,
412
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
413
-                // this happens PRIOR to serialization and any subsequent update.
414
-                // If values are found to match their previous old value,
415
-                // then WP bails before performing any update.
416
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
417
-                // it just pulled from the db, with the one being passed to it (which will not match).
418
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
419
-                // MySQL MAY ALSO NOT perform the update because
420
-                // the string it sees in the db looks the same as the new one it has been passed!!!
421
-                // This results in the query returning an "affected rows" value of ZERO,
422
-                // which gets returned immediately by WP update_option and looks like an error.
423
-                remove_action('update_option', array($this, 'check_config_updated'));
424
-            }
425
-        }
426
-    }
427
-
428
-
429
-    /**
430
-     *    update_espresso_config
431
-     *
432
-     * @access   public
433
-     */
434
-    protected function _reset_espresso_addon_config()
435
-    {
436
-        $this->_addon_option_names = array();
437
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
438
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
439
-            if ($addon_config_obj instanceof EE_Config_Base) {
440
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
441
-            }
442
-            $this->addons->{$addon_name} = null;
443
-        }
444
-    }
445
-
446
-
447
-    /**
448
-     *    update_espresso_config
449
-     *
450
-     * @access   public
451
-     * @param   bool $add_success
452
-     * @param   bool $add_error
453
-     * @return   bool
454
-     */
455
-    public function update_espresso_config($add_success = false, $add_error = true)
456
-    {
457
-        // don't allow config updates during WP heartbeats
458
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
459
-            return false;
460
-        }
461
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
462
-        // $clone = clone( self::$_instance );
463
-        // self::$_instance = NULL;
464
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
465
-        $this->_reset_espresso_addon_config();
466
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
467
-        // but BEFORE the actual update occurs
468
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
469
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
470
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
471
-        $this->legacy_shortcodes_manager = null;
472
-        // now update "ee_config"
473
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
474
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
475
-        EE_Config::log(EE_Config::OPTION_NAME);
476
-        // if not saved... check if the hook we just added still exists;
477
-        // if it does, it means one of two things:
478
-        // that update_option bailed at the($value === $old_value) conditional,
479
-        // or...
480
-        // the db update query returned 0 rows affected
481
-        // (probably because the data  value was the same from it's perspective)
482
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
483
-        // but just means no update occurred, so don't display an error to the user.
484
-        // BUT... if update_option returns FALSE, AND the hook is missing,
485
-        // then it means that something truly went wrong
486
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
487
-        // remove our action since we don't want it in the system anymore
488
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
489
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
490
-        // self::$_instance = $clone;
491
-        // unset( $clone );
492
-        // if config remains the same or was updated successfully
493
-        if ($saved) {
494
-            if ($add_success) {
495
-                EE_Error::add_success(
496
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
497
-                    __FILE__,
498
-                    __FUNCTION__,
499
-                    __LINE__
500
-                );
501
-            }
502
-            return true;
503
-        } else {
504
-            if ($add_error) {
505
-                EE_Error::add_error(
506
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
507
-                    __FILE__,
508
-                    __FUNCTION__,
509
-                    __LINE__
510
-                );
511
-            }
512
-            return false;
513
-        }
514
-    }
515
-
516
-
517
-    /**
518
-     *    _verify_config_params
519
-     *
520
-     * @access    private
521
-     * @param    string         $section
522
-     * @param    string         $name
523
-     * @param    string         $config_class
524
-     * @param    EE_Config_Base $config_obj
525
-     * @param    array          $tests_to_run
526
-     * @param    bool           $display_errors
527
-     * @return    bool    TRUE on success, FALSE on fail
528
-     */
529
-    private function _verify_config_params(
530
-        $section = '',
531
-        $name = '',
532
-        $config_class = '',
533
-        $config_obj = null,
534
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
535
-        $display_errors = true
536
-    ) {
537
-        try {
538
-            foreach ($tests_to_run as $test) {
539
-                switch ($test) {
540
-                    // TEST #1 : check that section was set
541
-                    case 1:
542
-                        if (empty($section)) {
543
-                            if ($display_errors) {
544
-                                throw new EE_Error(
545
-                                    sprintf(
546
-                                        __(
547
-                                            'No configuration section has been provided while attempting to save "%s".',
548
-                                            'event_espresso'
549
-                                        ),
550
-                                        $config_class
551
-                                    )
552
-                                );
553
-                            }
554
-                            return false;
555
-                        }
556
-                        break;
557
-                    // TEST #2 : check that settings section exists
558
-                    case 2:
559
-                        if (! isset($this->{$section})) {
560
-                            if ($display_errors) {
561
-                                throw new EE_Error(
562
-                                    sprintf(
563
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
564
-                                        $section
565
-                                    )
566
-                                );
567
-                            }
568
-                            return false;
569
-                        }
570
-                        break;
571
-                    // TEST #3 : check that section is the proper format
572
-                    case 3:
573
-                        if (
574
-                            ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
575
-                        ) {
576
-                            if ($display_errors) {
577
-                                throw new EE_Error(
578
-                                    sprintf(
579
-                                        __(
580
-                                            'The "%s" configuration settings have not been formatted correctly.',
581
-                                            'event_espresso'
582
-                                        ),
583
-                                        $section
584
-                                    )
585
-                                );
586
-                            }
587
-                            return false;
588
-                        }
589
-                        break;
590
-                    // TEST #4 : check that config section name has been set
591
-                    case 4:
592
-                        if (empty($name)) {
593
-                            if ($display_errors) {
594
-                                throw new EE_Error(
595
-                                    __(
596
-                                        'No name has been provided for the specific configuration section.',
597
-                                        'event_espresso'
598
-                                    )
599
-                                );
600
-                            }
601
-                            return false;
602
-                        }
603
-                        break;
604
-                    // TEST #5 : check that a config class name has been set
605
-                    case 5:
606
-                        if (empty($config_class)) {
607
-                            if ($display_errors) {
608
-                                throw new EE_Error(
609
-                                    __(
610
-                                        'No class name has been provided for the specific configuration section.',
611
-                                        'event_espresso'
612
-                                    )
613
-                                );
614
-                            }
615
-                            return false;
616
-                        }
617
-                        break;
618
-                    // TEST #6 : verify config class is accessible
619
-                    case 6:
620
-                        if (! class_exists($config_class)) {
621
-                            if ($display_errors) {
622
-                                throw new EE_Error(
623
-                                    sprintf(
624
-                                        __(
625
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
626
-                                            'event_espresso'
627
-                                        ),
628
-                                        $config_class
629
-                                    )
630
-                                );
631
-                            }
632
-                            return false;
633
-                        }
634
-                        break;
635
-                    // TEST #7 : check that config has even been set
636
-                    case 7:
637
-                        if (! isset($this->{$section}->{$name})) {
638
-                            if ($display_errors) {
639
-                                throw new EE_Error(
640
-                                    sprintf(
641
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
642
-                                        $section,
643
-                                        $name
644
-                                    )
645
-                                );
646
-                            }
647
-                            return false;
648
-                        } else {
649
-                            // and make sure it's not serialized
650
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
651
-                        }
652
-                        break;
653
-                    // TEST #8 : check that config is the requested type
654
-                    case 8:
655
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
656
-                            if ($display_errors) {
657
-                                throw new EE_Error(
658
-                                    sprintf(
659
-                                        __(
660
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
661
-                                            'event_espresso'
662
-                                        ),
663
-                                        $section,
664
-                                        $name,
665
-                                        $config_class
666
-                                    )
667
-                                );
668
-                            }
669
-                            return false;
670
-                        }
671
-                        break;
672
-                    // TEST #9 : verify config object
673
-                    case 9:
674
-                        if (! $config_obj instanceof EE_Config_Base) {
675
-                            if ($display_errors) {
676
-                                throw new EE_Error(
677
-                                    sprintf(
678
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
679
-                                        print_r($config_obj, true)
680
-                                    )
681
-                                );
682
-                            }
683
-                            return false;
684
-                        }
685
-                        break;
686
-                }
687
-            }
688
-        } catch (EE_Error $e) {
689
-            $e->get_error();
690
-        }
691
-        // you have successfully run the gauntlet
692
-        return true;
693
-    }
694
-
695
-
696
-    /**
697
-     *    _generate_config_option_name
698
-     *
699
-     * @access        protected
700
-     * @param        string $section
701
-     * @param        string $name
702
-     * @return        string
703
-     */
704
-    private function _generate_config_option_name($section = '', $name = '')
705
-    {
706
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
707
-    }
708
-
709
-
710
-    /**
711
-     *    _set_config_class
712
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
713
-     *
714
-     * @access    private
715
-     * @param    string $config_class
716
-     * @param    string $name
717
-     * @return    string
718
-     */
719
-    private function _set_config_class($config_class = '', $name = '')
720
-    {
721
-        return ! empty($config_class)
722
-            ? $config_class
723
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
724
-    }
725
-
726
-
727
-    /**
728
-     *    set_config
729
-     *
730
-     * @access    protected
731
-     * @param    string         $section
732
-     * @param    string         $name
733
-     * @param    string         $config_class
734
-     * @param    EE_Config_Base $config_obj
735
-     * @return    EE_Config_Base
736
-     */
737
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
738
-    {
739
-        // ensure config class is set to something
740
-        $config_class = $this->_set_config_class($config_class, $name);
741
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
742
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
743
-            return null;
744
-        }
745
-        $config_option_name = $this->_generate_config_option_name($section, $name);
746
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
747
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
748
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
749
-            $this->update_addon_option_names();
750
-        }
751
-        // verify the incoming config object but suppress errors
752
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
753
-            $config_obj = new $config_class();
754
-        }
755
-        if (get_option($config_option_name)) {
756
-            EE_Config::log($config_option_name);
757
-            update_option($config_option_name, $config_obj);
758
-            $this->{$section}->{$name} = $config_obj;
759
-            return $this->{$section}->{$name};
760
-        } else {
761
-            // create a wp-option for this config
762
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
763
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
764
-                return $this->{$section}->{$name};
765
-            } else {
766
-                EE_Error::add_error(
767
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
768
-                    __FILE__,
769
-                    __FUNCTION__,
770
-                    __LINE__
771
-                );
772
-                return null;
773
-            }
774
-        }
775
-    }
776
-
777
-
778
-    /**
779
-     *    update_config
780
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
781
-     *
782
-     * @access    public
783
-     * @param    string                $section
784
-     * @param    string                $name
785
-     * @param    EE_Config_Base|string $config_obj
786
-     * @param    bool                  $throw_errors
787
-     * @return    bool
788
-     */
789
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
790
-    {
791
-        // don't allow config updates during WP heartbeats
792
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
793
-            return false;
794
-        }
795
-        $config_obj = maybe_unserialize($config_obj);
796
-        // get class name of the incoming object
797
-        $config_class = get_class($config_obj);
798
-        // run tests 1-5 and 9 to verify config
799
-        if (
800
-            ! $this->_verify_config_params(
801
-                $section,
802
-                $name,
803
-                $config_class,
804
-                $config_obj,
805
-                array(1, 2, 3, 4, 7, 9)
806
-            )
807
-        ) {
808
-            return false;
809
-        }
810
-        $config_option_name = $this->_generate_config_option_name($section, $name);
811
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
812
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
813
-            // save new config to db
814
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
815
-                return true;
816
-            }
817
-        } else {
818
-            // first check if the record already exists
819
-            $existing_config = get_option($config_option_name);
820
-            $config_obj = serialize($config_obj);
821
-            // just return if db record is already up to date (NOT type safe comparison)
822
-            if ($existing_config == $config_obj) {
823
-                $this->{$section}->{$name} = $config_obj;
824
-                return true;
825
-            } elseif (update_option($config_option_name, $config_obj)) {
826
-                EE_Config::log($config_option_name);
827
-                // update wp-option for this config class
828
-                $this->{$section}->{$name} = $config_obj;
829
-                return true;
830
-            } elseif ($throw_errors) {
831
-                EE_Error::add_error(
832
-                    sprintf(
833
-                        __(
834
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
835
-                            'event_espresso'
836
-                        ),
837
-                        $config_class,
838
-                        'EE_Config->' . $section . '->' . $name
839
-                    ),
840
-                    __FILE__,
841
-                    __FUNCTION__,
842
-                    __LINE__
843
-                );
844
-            }
845
-        }
846
-        return false;
847
-    }
848
-
849
-
850
-    /**
851
-     *    get_config
852
-     *
853
-     * @access    public
854
-     * @param    string $section
855
-     * @param    string $name
856
-     * @param    string $config_class
857
-     * @return    mixed EE_Config_Base | NULL
858
-     */
859
-    public function get_config($section = '', $name = '', $config_class = '')
860
-    {
861
-        // ensure config class is set to something
862
-        $config_class = $this->_set_config_class($config_class, $name);
863
-        // run tests 1-4, 6 and 7 to verify that all params have been set
864
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
865
-            return null;
866
-        }
867
-        // now test if the requested config object exists, but suppress errors
868
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
869
-            // config already exists, so pass it back
870
-            return $this->{$section}->{$name};
871
-        }
872
-        // load config option from db if it exists
873
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
874
-        // verify the newly retrieved config object, but suppress errors
875
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
876
-            // config is good, so set it and pass it back
877
-            $this->{$section}->{$name} = $config_obj;
878
-            return $this->{$section}->{$name};
879
-        }
880
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
881
-        $config_obj = $this->set_config($section, $name, $config_class);
882
-        // verify the newly created config object
883
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
884
-            return $this->{$section}->{$name};
885
-        } else {
886
-            EE_Error::add_error(
887
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
888
-                __FILE__,
889
-                __FUNCTION__,
890
-                __LINE__
891
-            );
892
-        }
893
-        return null;
894
-    }
895
-
896
-
897
-    /**
898
-     *    get_config_option
899
-     *
900
-     * @access    public
901
-     * @param    string $config_option_name
902
-     * @return    mixed EE_Config_Base | FALSE
903
-     */
904
-    public function get_config_option($config_option_name = '')
905
-    {
906
-        // retrieve the wp-option for this config class.
907
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
908
-        if (empty($config_option)) {
909
-            EE_Config::log($config_option_name . '-NOT-FOUND');
910
-        }
911
-        return $config_option;
912
-    }
913
-
914
-
915
-    /**
916
-     * log
917
-     *
918
-     * @param string $config_option_name
919
-     */
920
-    public static function log($config_option_name = '')
921
-    {
922
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
923
-            $config_log = get_option(EE_Config::LOG_NAME, array());
924
-            // copy incoming $_REQUEST and sanitize it so we can save it
925
-            $_request = $_REQUEST;
926
-            array_walk_recursive($_request, 'sanitize_text_field');
927
-            $config_log[ (string) microtime(true) ] = array(
928
-                'config_name' => $config_option_name,
929
-                'request'     => $_request,
930
-            );
931
-            update_option(EE_Config::LOG_NAME, $config_log);
932
-        }
933
-    }
934
-
935
-
936
-    /**
937
-     * trim_log
938
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
939
-     */
940
-    public static function trim_log()
941
-    {
942
-        if (! EE_Config::logging_enabled()) {
943
-            return;
944
-        }
945
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
946
-        $log_length = count($config_log);
947
-        if ($log_length > EE_Config::LOG_LENGTH) {
948
-            ksort($config_log);
949
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
950
-            update_option(EE_Config::LOG_NAME, $config_log);
951
-        }
952
-    }
953
-
954
-
955
-    /**
956
-     *    get_page_for_posts
957
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
958
-     *    wp-option "page_for_posts", or "posts" if no page is selected
959
-     *
960
-     * @access    public
961
-     * @return    string
962
-     */
963
-    public static function get_page_for_posts()
964
-    {
965
-        $page_for_posts = get_option('page_for_posts');
966
-        if (! $page_for_posts) {
967
-            return 'posts';
968
-        }
969
-        /** @type WPDB $wpdb */
970
-        global $wpdb;
971
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
972
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
973
-    }
974
-
975
-
976
-    /**
977
-     *    register_shortcodes_and_modules.
978
-     *    At this point, it's too early to tell if we're maintenance mode or not.
979
-     *    In fact, this is where we give modules a chance to let core know they exist
980
-     *    so they can help trigger maintenance mode if it's needed
981
-     *
982
-     * @access    public
983
-     * @return    void
984
-     */
985
-    public function register_shortcodes_and_modules()
986
-    {
987
-        // allow modules to set hooks for the rest of the system
988
-        EE_Registry::instance()->modules = $this->_register_modules();
989
-    }
990
-
991
-
992
-    /**
993
-     *    initialize_shortcodes_and_modules
994
-     *    meaning they can start adding their hooks to get stuff done
995
-     *
996
-     * @access    public
997
-     * @return    void
998
-     */
999
-    public function initialize_shortcodes_and_modules()
1000
-    {
1001
-        // allow modules to set hooks for the rest of the system
1002
-        $this->_initialize_modules();
1003
-    }
1004
-
1005
-
1006
-    /**
1007
-     *    widgets_init
1008
-     *
1009
-     * @access private
1010
-     * @return void
1011
-     */
1012
-    public function widgets_init()
1013
-    {
1014
-        // only init widgets on admin pages when not in complete maintenance, and
1015
-        // on frontend when not in any maintenance mode
1016
-        if (
1017
-            ! EE_Maintenance_Mode::instance()->level()
1018
-            || (
1019
-                is_admin()
1020
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1021
-            )
1022
-        ) {
1023
-            // grab list of installed widgets
1024
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1025
-            // filter list of modules to register
1026
-            $widgets_to_register = apply_filters(
1027
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1028
-                $widgets_to_register
1029
-            );
1030
-            if (! empty($widgets_to_register)) {
1031
-                // cycle thru widget folders
1032
-                foreach ($widgets_to_register as $widget_path) {
1033
-                    // add to list of installed widget modules
1034
-                    EE_Config::register_ee_widget($widget_path);
1035
-                }
1036
-            }
1037
-            // filter list of installed modules
1038
-            EE_Registry::instance()->widgets = apply_filters(
1039
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1040
-                EE_Registry::instance()->widgets
1041
-            );
1042
-        }
1043
-    }
1044
-
1045
-
1046
-    /**
1047
-     *    register_ee_widget - makes core aware of this widget
1048
-     *
1049
-     * @access    public
1050
-     * @param    string $widget_path - full path up to and including widget folder
1051
-     * @return    void
1052
-     */
1053
-    public static function register_ee_widget($widget_path = null)
1054
-    {
1055
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1056
-        $widget_ext = '.widget.php';
1057
-        // make all separators match
1058
-        $widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1059
-        // does the file path INCLUDE the actual file name as part of the path ?
1060
-        if (strpos($widget_path, $widget_ext) !== false) {
1061
-            // grab and shortcode file name from directory name and break apart at dots
1062
-            $file_name = explode('.', basename($widget_path));
1063
-            // take first segment from file name pieces and remove class prefix if it exists
1064
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1065
-            // sanitize shortcode directory name
1066
-            $widget = sanitize_key($widget);
1067
-            // now we need to rebuild the shortcode path
1068
-            $widget_path = explode('/', $widget_path);
1069
-            // remove last segment
1070
-            array_pop($widget_path);
1071
-            // glue it back together
1072
-            $widget_path = implode(DS, $widget_path);
1073
-        } else {
1074
-            // grab and sanitize widget directory name
1075
-            $widget = sanitize_key(basename($widget_path));
1076
-        }
1077
-        // create classname from widget directory name
1078
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1079
-        // add class prefix
1080
-        $widget_class = 'EEW_' . $widget;
1081
-        // does the widget exist ?
1082
-        if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1083
-            $msg = sprintf(
1084
-                __(
1085
-                    'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1086
-                    'event_espresso'
1087
-                ),
1088
-                $widget_class,
1089
-                $widget_path . '/' . $widget_class . $widget_ext
1090
-            );
1091
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1092
-            return;
1093
-        }
1094
-        // load the widget class file
1095
-        require_once($widget_path . '/' . $widget_class . $widget_ext);
1096
-        // verify that class exists
1097
-        if (! class_exists($widget_class)) {
1098
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1099
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1100
-            return;
1101
-        }
1102
-        register_widget($widget_class);
1103
-        // add to array of registered widgets
1104
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1105
-    }
1106
-
1107
-
1108
-    /**
1109
-     *        _register_modules
1110
-     *
1111
-     * @access private
1112
-     * @return array
1113
-     */
1114
-    private function _register_modules()
1115
-    {
1116
-        // grab list of installed modules
1117
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1118
-        // filter list of modules to register
1119
-        $modules_to_register = apply_filters(
1120
-            'FHEE__EE_Config__register_modules__modules_to_register',
1121
-            $modules_to_register
1122
-        );
1123
-        if (! empty($modules_to_register)) {
1124
-            // loop through folders
1125
-            foreach ($modules_to_register as $module_path) {
1126
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1127
-                if (
1128
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1129
-                    && $module_path !== EE_MODULES . 'gateways'
1130
-                ) {
1131
-                    // add to list of installed modules
1132
-                    EE_Config::register_module($module_path);
1133
-                }
1134
-            }
1135
-        }
1136
-        // filter list of installed modules
1137
-        return apply_filters(
1138
-            'FHEE__EE_Config___register_modules__installed_modules',
1139
-            EE_Registry::instance()->modules
1140
-        );
1141
-    }
1142
-
1143
-
1144
-    /**
1145
-     *    register_module - makes core aware of this module
1146
-     *
1147
-     * @access    public
1148
-     * @param    string $module_path - full path up to and including module folder
1149
-     * @return    bool
1150
-     */
1151
-    public static function register_module($module_path = null)
1152
-    {
1153
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1154
-        $module_ext = '.module.php';
1155
-        // make all separators match
1156
-        $module_path = str_replace(array('\\', '/'), '/', $module_path);
1157
-        // does the file path INCLUDE the actual file name as part of the path ?
1158
-        if (strpos($module_path, $module_ext) !== false) {
1159
-            // grab and shortcode file name from directory name and break apart at dots
1160
-            $module_file = explode('.', basename($module_path));
1161
-            // now we need to rebuild the shortcode path
1162
-            $module_path = explode('/', $module_path);
1163
-            // remove last segment
1164
-            array_pop($module_path);
1165
-            // glue it back together
1166
-            $module_path = implode('/', $module_path) . '/';
1167
-            // take first segment from file name pieces and sanitize it
1168
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1169
-            // ensure class prefix is added
1170
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1171
-        } else {
1172
-            // we need to generate the filename based off of the folder name
1173
-            // grab and sanitize module name
1174
-            $module = strtolower(basename($module_path));
1175
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1176
-            // like trailingslashit()
1177
-            $module_path = rtrim($module_path, '/') . '/';
1178
-            // create classname from module directory name
1179
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1180
-            // add class prefix
1181
-            $module_class = 'EED_' . $module;
1182
-        }
1183
-        // does the module exist ?
1184
-        if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1185
-            $msg = sprintf(
1186
-                __(
1187
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1188
-                    'event_espresso'
1189
-                ),
1190
-                $module
1191
-            );
1192
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1193
-            return false;
1194
-        }
1195
-        // load the module class file
1196
-        require_once($module_path . $module_class . $module_ext);
1197
-        // verify that class exists
1198
-        if (! class_exists($module_class)) {
1199
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1200
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1201
-            return false;
1202
-        }
1203
-        // add to array of registered modules
1204
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1205
-        do_action(
1206
-            'AHEE__EE_Config__register_module__complete',
1207
-            $module_class,
1208
-            EE_Registry::instance()->modules->{$module_class}
1209
-        );
1210
-        return true;
1211
-    }
1212
-
1213
-
1214
-    /**
1215
-     *    _initialize_modules
1216
-     *    allow modules to set hooks for the rest of the system
1217
-     *
1218
-     * @access private
1219
-     * @return void
1220
-     */
1221
-    private function _initialize_modules()
1222
-    {
1223
-        // cycle thru shortcode folders
1224
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1225
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1226
-            // which set hooks ?
1227
-            if (is_admin()) {
1228
-                // fire immediately
1229
-                call_user_func(array($module_class, 'set_hooks_admin'));
1230
-            } else {
1231
-                // delay until other systems are online
1232
-                add_action(
1233
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1234
-                    array($module_class, 'set_hooks')
1235
-                );
1236
-            }
1237
-        }
1238
-    }
1239
-
1240
-
1241
-    /**
1242
-     *    register_route - adds module method routes to route_map
1243
-     *
1244
-     * @access    public
1245
-     * @param    string $route       - "pretty" public alias for module method
1246
-     * @param    string $module      - module name (classname without EED_ prefix)
1247
-     * @param    string $method_name - the actual module method to be routed to
1248
-     * @param    string $key         - url param key indicating a route is being called
1249
-     * @return    bool
1250
-     */
1251
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1252
-    {
1253
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1254
-        $module = str_replace('EED_', '', $module);
1255
-        $module_class = 'EED_' . $module;
1256
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1257
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1258
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1259
-            return false;
1260
-        }
1261
-        if (empty($route)) {
1262
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1263
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1264
-            return false;
1265
-        }
1266
-        if (! method_exists('EED_' . $module, $method_name)) {
1267
-            $msg = sprintf(
1268
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1269
-                $route
1270
-            );
1271
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1272
-            return false;
1273
-        }
1274
-        EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1275
-        return true;
1276
-    }
1277
-
1278
-
1279
-    /**
1280
-     *    get_route - get module method route
1281
-     *
1282
-     * @access    public
1283
-     * @param    string $route - "pretty" public alias for module method
1284
-     * @param    string $key   - url param key indicating a route is being called
1285
-     * @return    string
1286
-     */
1287
-    public static function get_route($route = null, $key = 'ee')
1288
-    {
1289
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1290
-        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1291
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1292
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1293
-        }
1294
-        return null;
1295
-    }
1296
-
1297
-
1298
-    /**
1299
-     *    get_routes - get ALL module method routes
1300
-     *
1301
-     * @access    public
1302
-     * @return    array
1303
-     */
1304
-    public static function get_routes()
1305
-    {
1306
-        return EE_Config::$_module_route_map;
1307
-    }
1308
-
1309
-
1310
-    /**
1311
-     *    register_forward - allows modules to forward request to another module for further processing
1312
-     *
1313
-     * @access    public
1314
-     * @param    string       $route   - "pretty" public alias for module method
1315
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1316
-     *                                 class, allows different forwards to be served based on status
1317
-     * @param    array|string $forward - function name or array( class, method )
1318
-     * @param    string       $key     - url param key indicating a route is being called
1319
-     * @return    bool
1320
-     */
1321
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1322
-    {
1323
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1324
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1325
-            $msg = sprintf(
1326
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1327
-                $route
1328
-            );
1329
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1330
-            return false;
1331
-        }
1332
-        if (empty($forward)) {
1333
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1334
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1335
-            return false;
1336
-        }
1337
-        if (is_array($forward)) {
1338
-            if (! isset($forward[1])) {
1339
-                $msg = sprintf(
1340
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1341
-                    $route
1342
-                );
1343
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1344
-                return false;
1345
-            }
1346
-            if (! method_exists($forward[0], $forward[1])) {
1347
-                $msg = sprintf(
1348
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1349
-                    $forward[1],
1350
-                    $route
1351
-                );
1352
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1353
-                return false;
1354
-            }
1355
-        } elseif (! function_exists($forward)) {
1356
-            $msg = sprintf(
1357
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1358
-                $forward,
1359
-                $route
1360
-            );
1361
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1362
-            return false;
1363
-        }
1364
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1365
-        return true;
1366
-    }
1367
-
1368
-
1369
-    /**
1370
-     *    get_forward - get forwarding route
1371
-     *
1372
-     * @access    public
1373
-     * @param    string  $route  - "pretty" public alias for module method
1374
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1375
-     *                           allows different forwards to be served based on status
1376
-     * @param    string  $key    - url param key indicating a route is being called
1377
-     * @return    string
1378
-     */
1379
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1380
-    {
1381
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1382
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1383
-            return apply_filters(
1384
-                'FHEE__EE_Config__get_forward',
1385
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1386
-                $route,
1387
-                $status
1388
-            );
1389
-        }
1390
-        return null;
1391
-    }
1392
-
1393
-
1394
-    /**
1395
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1396
-     *    results
1397
-     *
1398
-     * @access    public
1399
-     * @param    string  $route  - "pretty" public alias for module method
1400
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1401
-     *                           allows different views to be served based on status
1402
-     * @param    string  $view
1403
-     * @param    string  $key    - url param key indicating a route is being called
1404
-     * @return    bool
1405
-     */
1406
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1407
-    {
1408
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1409
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1410
-            $msg = sprintf(
1411
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1412
-                $route
1413
-            );
1414
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1415
-            return false;
1416
-        }
1417
-        if (! is_readable($view)) {
1418
-            $msg = sprintf(
1419
-                __(
1420
-                    'The %s view file could not be found or is not readable due to file permissions.',
1421
-                    'event_espresso'
1422
-                ),
1423
-                $view
1424
-            );
1425
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1426
-            return false;
1427
-        }
1428
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1429
-        return true;
1430
-    }
1431
-
1432
-
1433
-    /**
1434
-     *    get_view - get view for route and status
1435
-     *
1436
-     * @access    public
1437
-     * @param    string  $route  - "pretty" public alias for module method
1438
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1439
-     *                           allows different views to be served based on status
1440
-     * @param    string  $key    - url param key indicating a route is being called
1441
-     * @return    string
1442
-     */
1443
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1444
-    {
1445
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1446
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1447
-            return apply_filters(
1448
-                'FHEE__EE_Config__get_view',
1449
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1450
-                $route,
1451
-                $status
1452
-            );
1453
-        }
1454
-        return null;
1455
-    }
1456
-
1457
-
1458
-    public function update_addon_option_names()
1459
-    {
1460
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1461
-    }
1462
-
1463
-
1464
-    public function shutdown()
1465
-    {
1466
-        $this->update_addon_option_names();
1467
-    }
1468
-
1469
-
1470
-    /**
1471
-     * @return LegacyShortcodesManager
1472
-     */
1473
-    public static function getLegacyShortcodesManager()
1474
-    {
1475
-
1476
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1477
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1478
-                EE_Registry::instance()
1479
-            );
1480
-        }
1481
-        return EE_Config::instance()->legacy_shortcodes_manager;
1482
-    }
1483
-
1484
-
1485
-    /**
1486
-     * register_shortcode - makes core aware of this shortcode
1487
-     *
1488
-     * @deprecated 4.9.26
1489
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1490
-     * @return    bool
1491
-     */
1492
-    public static function register_shortcode($shortcode_path = null)
1493
-    {
1494
-        EE_Error::doing_it_wrong(
1495
-            __METHOD__,
1496
-            __(
1497
-                'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1498
-                'event_espresso'
1499
-            ),
1500
-            '4.9.26'
1501
-        );
1502
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1503
-    }
1504
-}
1505
-
1506
-/**
1507
- * Base class used for config classes. These classes should generally not have
1508
- * magic functions in use, except we'll allow them to magically set and get stuff...
1509
- * basically, they should just be well-defined stdClasses
1510
- */
1511
-class EE_Config_Base
1512
-{
1513
-
1514
-    /**
1515
-     * Utility function for escaping the value of a property and returning.
1516
-     *
1517
-     * @param string $property property name (checks to see if exists).
1518
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1519
-     * @throws \EE_Error
1520
-     */
1521
-    public function get_pretty($property)
1522
-    {
1523
-        if (! property_exists($this, $property)) {
1524
-            throw new EE_Error(
1525
-                sprintf(
1526
-                    __(
1527
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1528
-                        'event_espresso'
1529
-                    ),
1530
-                    get_class($this),
1531
-                    $property
1532
-                )
1533
-            );
1534
-        }
1535
-        // just handling escaping of strings for now.
1536
-        if (is_string($this->{$property})) {
1537
-            return stripslashes($this->{$property});
1538
-        }
1539
-        return $this->{$property};
1540
-    }
1541
-
1542
-
1543
-    public function populate()
1544
-    {
1545
-        // grab defaults via a new instance of this class.
1546
-        $class_name = get_class($this);
1547
-        $defaults = new $class_name();
1548
-        // loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1549
-        // default from our $defaults object.
1550
-        foreach (get_object_vars($defaults) as $property => $value) {
1551
-            if ($this->{$property} === null) {
1552
-                $this->{$property} = $value;
1553
-            }
1554
-        }
1555
-        // cleanup
1556
-        unset($defaults);
1557
-    }
1558
-
1559
-
1560
-    /**
1561
-     *        __isset
1562
-     *
1563
-     * @param $a
1564
-     * @return bool
1565
-     */
1566
-    public function __isset($a)
1567
-    {
1568
-        return false;
1569
-    }
1570
-
1571
-
1572
-    /**
1573
-     *        __unset
1574
-     *
1575
-     * @param $a
1576
-     * @return bool
1577
-     */
1578
-    public function __unset($a)
1579
-    {
1580
-        return false;
1581
-    }
1582
-
1583
-
1584
-    /**
1585
-     *        __clone
1586
-     */
1587
-    public function __clone()
1588
-    {
1589
-    }
1590
-
1591
-
1592
-    /**
1593
-     *        __wakeup
1594
-     */
1595
-    public function __wakeup()
1596
-    {
1597
-    }
1598
-
1599
-
1600
-    /**
1601
-     *        __destruct
1602
-     */
1603
-    public function __destruct()
1604
-    {
1605
-    }
1606
-}
1607
-
1608
-/**
1609
- * Class for defining what's in the EE_Config relating to registration settings
1610
- */
1611
-class EE_Core_Config extends EE_Config_Base
1612
-{
1613
-
1614
-    const OPTION_NAME_UXIP = 'ee_ueip_optin';
1615
-
1616
-
1617
-    public $current_blog_id;
1618
-
1619
-    public $ee_ueip_optin;
1620
-
1621
-    public $ee_ueip_has_notified;
1622
-
1623
-    /**
1624
-     * Not to be confused with the 4 critical page variables (See
1625
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1626
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1627
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1628
-     *
1629
-     * @var array
1630
-     */
1631
-    public $post_shortcodes;
1632
-
1633
-    public $module_route_map;
1634
-
1635
-    public $module_forward_map;
1636
-
1637
-    public $module_view_map;
1638
-
1639
-    /**
1640
-     * The next 4 vars are the IDs of critical EE pages.
1641
-     *
1642
-     * @var int
1643
-     */
1644
-    public $reg_page_id;
1645
-
1646
-    public $txn_page_id;
1647
-
1648
-    public $thank_you_page_id;
1649
-
1650
-    public $cancel_page_id;
1651
-
1652
-    /**
1653
-     * The next 4 vars are the URLs of critical EE pages.
1654
-     *
1655
-     * @var int
1656
-     */
1657
-    public $reg_page_url;
1658
-
1659
-    public $txn_page_url;
1660
-
1661
-    public $thank_you_page_url;
1662
-
1663
-    public $cancel_page_url;
1664
-
1665
-    /**
1666
-     * The next vars relate to the custom slugs for EE CPT routes
1667
-     */
1668
-    public $event_cpt_slug;
1669
-
1670
-    /**
1671
-     * This caches the _ee_ueip_option in case this config is reset in the same
1672
-     * request across blog switches in a multisite context.
1673
-     * Avoids extra queries to the db for this option.
1674
-     *
1675
-     * @var bool
1676
-     */
1677
-    public static $ee_ueip_option;
1678
-
1679
-
1680
-    /**
1681
-     *    class constructor
1682
-     *
1683
-     * @access    public
1684
-     */
1685
-    public function __construct()
1686
-    {
1687
-        // set default organization settings
1688
-        $this->current_blog_id = get_current_blog_id();
1689
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1690
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1691
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1692
-        $this->post_shortcodes = array();
1693
-        $this->module_route_map = array();
1694
-        $this->module_forward_map = array();
1695
-        $this->module_view_map = array();
1696
-        // critical EE page IDs
1697
-        $this->reg_page_id = 0;
1698
-        $this->txn_page_id = 0;
1699
-        $this->thank_you_page_id = 0;
1700
-        $this->cancel_page_id = 0;
1701
-        // critical EE page URLs
1702
-        $this->reg_page_url = '';
1703
-        $this->txn_page_url = '';
1704
-        $this->thank_you_page_url = '';
1705
-        $this->cancel_page_url = '';
1706
-        // cpt slugs
1707
-        $this->event_cpt_slug = __('events', 'event_espresso');
1708
-        // ueip constant check
1709
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1710
-            $this->ee_ueip_optin = false;
1711
-            $this->ee_ueip_has_notified = true;
1712
-        }
1713
-    }
1714
-
1715
-
1716
-    /**
1717
-     * @return array
1718
-     */
1719
-    public function get_critical_pages_array()
1720
-    {
1721
-        return array(
1722
-            $this->reg_page_id,
1723
-            $this->txn_page_id,
1724
-            $this->thank_you_page_id,
1725
-            $this->cancel_page_id,
1726
-        );
1727
-    }
1728
-
1729
-
1730
-    /**
1731
-     * @return array
1732
-     */
1733
-    public function get_critical_pages_shortcodes_array()
1734
-    {
1735
-        return array(
1736
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1737
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1738
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1739
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1740
-        );
1741
-    }
1742
-
1743
-
1744
-    /**
1745
-     *  gets/returns URL for EE reg_page
1746
-     *
1747
-     * @access    public
1748
-     * @return    string
1749
-     */
1750
-    public function reg_page_url()
1751
-    {
1752
-        if (! $this->reg_page_url) {
1753
-            $this->reg_page_url = add_query_arg(
1754
-                array('uts' => time()),
1755
-                get_permalink($this->reg_page_id)
1756
-            ) . '#checkout';
1757
-        }
1758
-        return $this->reg_page_url;
1759
-    }
1760
-
1761
-
1762
-    /**
1763
-     *  gets/returns URL for EE txn_page
1764
-     *
1765
-     * @param array $query_args like what gets passed to
1766
-     *                          add_query_arg() as the first argument
1767
-     * @access    public
1768
-     * @return    string
1769
-     */
1770
-    public function txn_page_url($query_args = array())
1771
-    {
1772
-        if (! $this->txn_page_url) {
1773
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1774
-        }
1775
-        if ($query_args) {
1776
-            return add_query_arg($query_args, $this->txn_page_url);
1777
-        } else {
1778
-            return $this->txn_page_url;
1779
-        }
1780
-    }
1781
-
1782
-
1783
-    /**
1784
-     *  gets/returns URL for EE thank_you_page
1785
-     *
1786
-     * @param array $query_args like what gets passed to
1787
-     *                          add_query_arg() as the first argument
1788
-     * @access    public
1789
-     * @return    string
1790
-     */
1791
-    public function thank_you_page_url($query_args = array())
1792
-    {
1793
-        if (! $this->thank_you_page_url) {
1794
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1795
-        }
1796
-        if ($query_args) {
1797
-            return add_query_arg($query_args, $this->thank_you_page_url);
1798
-        } else {
1799
-            return $this->thank_you_page_url;
1800
-        }
1801
-    }
1802
-
1803
-
1804
-    /**
1805
-     *  gets/returns URL for EE cancel_page
1806
-     *
1807
-     * @access    public
1808
-     * @return    string
1809
-     */
1810
-    public function cancel_page_url()
1811
-    {
1812
-        if (! $this->cancel_page_url) {
1813
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1814
-        }
1815
-        return $this->cancel_page_url;
1816
-    }
1817
-
1818
-
1819
-    /**
1820
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1821
-     *
1822
-     * @since 4.7.5
1823
-     */
1824
-    protected function _reset_urls()
1825
-    {
1826
-        $this->reg_page_url = '';
1827
-        $this->txn_page_url = '';
1828
-        $this->cancel_page_url = '';
1829
-        $this->thank_you_page_url = '';
1830
-    }
1831
-
1832
-
1833
-    /**
1834
-     * Used to return what the optin value is set for the EE User Experience Program.
1835
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1836
-     * on the main site only.
1837
-     *
1838
-     * @return bool
1839
-     */
1840
-    protected function _get_main_ee_ueip_optin()
1841
-    {
1842
-        // if this is the main site then we can just bypass our direct query.
1843
-        if (is_main_site()) {
1844
-            return get_option(self::OPTION_NAME_UXIP, false);
1845
-        }
1846
-        // is this already cached for this request?  If so use it.
1847
-        if (EE_Core_Config::$ee_ueip_option !== null) {
1848
-            return EE_Core_Config::$ee_ueip_option;
1849
-        }
1850
-        global $wpdb;
1851
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1852
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1853
-        $option = self::OPTION_NAME_UXIP;
1854
-        // set correct table for query
1855
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1856
-        // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1857
-        // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1858
-        // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1859
-        // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1860
-        // for the purpose of caching.
1861
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1862
-        if (false !== $pre) {
1863
-            EE_Core_Config::$ee_ueip_option = $pre;
1864
-            return EE_Core_Config::$ee_ueip_option;
1865
-        }
1866
-        $row = $wpdb->get_row(
1867
-            $wpdb->prepare(
1868
-                "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1869
-                $option
1870
-            )
1871
-        );
1872
-        if (is_object($row)) {
1873
-            $value = $row->option_value;
1874
-        } else { // option does not exist so use default.
1875
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1876
-            return EE_Core_Config::$ee_ueip_option;
1877
-        }
1878
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1879
-        return EE_Core_Config::$ee_ueip_option;
1880
-    }
1881
-
1882
-
1883
-    /**
1884
-     * Utility function for escaping the value of a property and returning.
1885
-     *
1886
-     * @param string $property property name (checks to see if exists).
1887
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1888
-     * @throws \EE_Error
1889
-     */
1890
-    public function get_pretty($property)
1891
-    {
1892
-        if ($property === self::OPTION_NAME_UXIP) {
1893
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1894
-        }
1895
-        return parent::get_pretty($property);
1896
-    }
1897
-
1898
-
1899
-    /**
1900
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1901
-     * on the object.
1902
-     *
1903
-     * @return array
1904
-     */
1905
-    public function __sleep()
1906
-    {
1907
-        // reset all url properties
1908
-        $this->_reset_urls();
1909
-        // return what to save to db
1910
-        return array_keys(get_object_vars($this));
1911
-    }
1912
-}
1913
-
1914
-/**
1915
- * Config class for storing info on the Organization
1916
- */
1917
-class EE_Organization_Config extends EE_Config_Base
1918
-{
1919
-
1920
-    /**
1921
-     * @var string $name
1922
-     * eg EE4.1
1923
-     */
1924
-    public $name;
1925
-
1926
-    /**
1927
-     * @var string $address_1
1928
-     * eg 123 Onna Road
1929
-     */
1930
-    public $address_1 = '';
1931
-
1932
-    /**
1933
-     * @var string $address_2
1934
-     * eg PO Box 123
1935
-     */
1936
-    public $address_2 = '';
1937
-
1938
-    /**
1939
-     * @var string $city
1940
-     * eg Inna City
1941
-     */
1942
-    public $city = '';
1943
-
1944
-    /**
1945
-     * @var int $STA_ID
1946
-     * eg 4
1947
-     */
1948
-    public $STA_ID = 0;
1949
-
1950
-    /**
1951
-     * @var string $CNT_ISO
1952
-     * eg US
1953
-     */
1954
-    public $CNT_ISO = '';
1955
-
1956
-    /**
1957
-     * @var string $zip
1958
-     * eg 12345  or V1A 2B3
1959
-     */
1960
-    public $zip = '';
1961
-
1962
-    /**
1963
-     * @var string $email
1964
-     * eg [email protected]
1965
-     */
1966
-    public $email;
1967
-
1968
-    /**
1969
-     * @var string $phone
1970
-     * eg. 111-111-1111
1971
-     */
1972
-    public $phone = '';
1973
-
1974
-    /**
1975
-     * @var string $vat
1976
-     * VAT/Tax Number
1977
-     */
1978
-    public $vat = '';
1979
-
1980
-    /**
1981
-     * @var string $logo_url
1982
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1983
-     */
1984
-    public $logo_url = '';
1985
-
1986
-    /**
1987
-     * The below are all various properties for holding links to organization social network profiles
1988
-     *
1989
-     * @var string
1990
-     */
1991
-    /**
1992
-     * facebook (facebook.com/profile.name)
1993
-     *
1994
-     * @var string
1995
-     */
1996
-    public $facebook = '';
1997
-
1998
-    /**
1999
-     * twitter (twitter.com/twitter_handle)
2000
-     *
2001
-     * @var string
2002
-     */
2003
-    public $twitter = '';
2004
-
2005
-    /**
2006
-     * linkedin (linkedin.com/in/profile_name)
2007
-     *
2008
-     * @var string
2009
-     */
2010
-    public $linkedin = '';
2011
-
2012
-    /**
2013
-     * pinterest (www.pinterest.com/profile_name)
2014
-     *
2015
-     * @var string
2016
-     */
2017
-    public $pinterest = '';
2018
-
2019
-    /**
2020
-     * google+ (google.com/+profileName)
2021
-     *
2022
-     * @var string
2023
-     */
2024
-    public $google = '';
2025
-
2026
-    /**
2027
-     * instagram (instagram.com/handle)
2028
-     *
2029
-     * @var string
2030
-     */
2031
-    public $instagram = '';
2032
-
2033
-
2034
-    /**
2035
-     *    class constructor
2036
-     *
2037
-     * @access    public
2038
-     */
2039
-    public function __construct()
2040
-    {
2041
-        // set default organization settings
2042
-        // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2043
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2044
-        $this->email = get_bloginfo('admin_email');
2045
-    }
2046
-}
2047
-
2048
-/**
2049
- * Class for defining what's in the EE_Config relating to currency
2050
- */
2051
-class EE_Currency_Config extends EE_Config_Base
2052
-{
2053
-
2054
-    /**
2055
-     * @var string $code
2056
-     * eg 'US'
2057
-     */
2058
-    public $code;
2059
-
2060
-    /**
2061
-     * @var string $name
2062
-     * eg 'Dollar'
2063
-     */
2064
-    public $name;
2065
-
2066
-    /**
2067
-     * plural name
2068
-     *
2069
-     * @var string $plural
2070
-     * eg 'Dollars'
2071
-     */
2072
-    public $plural;
2073
-
2074
-    /**
2075
-     * currency sign
2076
-     *
2077
-     * @var string $sign
2078
-     * eg '$'
2079
-     */
2080
-    public $sign;
2081
-
2082
-    /**
2083
-     * Whether the currency sign should come before the number or not
2084
-     *
2085
-     * @var boolean $sign_b4
2086
-     */
2087
-    public $sign_b4;
2088
-
2089
-    /**
2090
-     * How many digits should come after the decimal place
2091
-     *
2092
-     * @var int $dec_plc
2093
-     */
2094
-    public $dec_plc;
2095
-
2096
-    /**
2097
-     * Symbol to use for decimal mark
2098
-     *
2099
-     * @var string $dec_mrk
2100
-     * eg '.'
2101
-     */
2102
-    public $dec_mrk;
2103
-
2104
-    /**
2105
-     * Symbol to use for thousands
2106
-     *
2107
-     * @var string $thsnds
2108
-     * eg ','
2109
-     */
2110
-    public $thsnds;
2111
-
2112
-
2113
-    /**
2114
-     *    class constructor
2115
-     *
2116
-     * @access    public
2117
-     * @param string $CNT_ISO
2118
-     * @throws \EE_Error
2119
-     */
2120
-    public function __construct($CNT_ISO = '')
2121
-    {
2122
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2123
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2124
-        // get country code from organization settings or use default
2125
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2126
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2127
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2128
-            : '';
2129
-        // but override if requested
2130
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2131
-        // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2132
-        if (
2133
-            ! empty($CNT_ISO)
2134
-            && EE_Maintenance_Mode::instance()->models_can_query()
2135
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2136
-        ) {
2137
-            // retrieve the country settings from the db, just in case they have been customized
2138
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2139
-            if ($country instanceof EE_Country) {
2140
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2141
-                $this->name = $country->currency_name_single();    // Dollar
2142
-                $this->plural = $country->currency_name_plural();    // Dollars
2143
-                $this->sign = $country->currency_sign();            // currency sign: $
2144
-                $this->sign_b4 = $country->currency_sign_before(
2145
-                );        // currency sign before or after: $TRUE  or  FALSE$
2146
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2147
-                $this->dec_mrk = $country->currency_decimal_mark(
2148
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2149
-                $this->thsnds = $country->currency_thousands_separator(
2150
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2151
-            }
2152
-        }
2153
-        // fallback to hardcoded defaults, in case the above failed
2154
-        if (empty($this->code)) {
2155
-            // set default currency settings
2156
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2157
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2158
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2159
-            $this->sign = '$';    // currency sign: $
2160
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2161
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2162
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2163
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2164
-        }
2165
-    }
2166
-}
2167
-
2168
-/**
2169
- * Class for defining what's in the EE_Config relating to registration settings
2170
- */
2171
-class EE_Registration_Config extends EE_Config_Base
2172
-{
2173
-
2174
-    /**
2175
-     * Default registration status
2176
-     *
2177
-     * @var string $default_STS_ID
2178
-     * eg 'RPP'
2179
-     */
2180
-    public $default_STS_ID;
2181
-
2182
-    /**
2183
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2184
-     * registrations)
2185
-     *
2186
-     * @var int
2187
-     */
2188
-    public $default_maximum_number_of_tickets;
2189
-
2190
-    /**
2191
-     * level of validation to apply to email addresses
2192
-     *
2193
-     * @var string $email_validation_level
2194
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2195
-     */
2196
-    public $email_validation_level;
2197
-
2198
-    /**
2199
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2200
-     *
2201
-     * @var boolean $show_pending_payment_options
2202
-     */
2203
-    public $show_pending_payment_options;
2204
-
2205
-    /**
2206
-     * Whether to skip the registration confirmation page
2207
-     *
2208
-     * @var boolean $skip_reg_confirmation
2209
-     */
2210
-    public $skip_reg_confirmation;
2211
-
2212
-    /**
2213
-     * an array of SPCO reg steps where:
2214
-     *        the keys denotes the reg step order
2215
-     *        each element consists of an array with the following elements:
2216
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2217
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2218
-     *            "slug" => the URL param used to trigger the reg step
2219
-     *
2220
-     * @var array $reg_steps
2221
-     */
2222
-    public $reg_steps;
2223
-
2224
-    /**
2225
-     * Whether registration confirmation should be the last page of SPCO
2226
-     *
2227
-     * @var boolean $reg_confirmation_last
2228
-     */
2229
-    public $reg_confirmation_last;
2230
-
2231
-    /**
2232
-     * Whether or not to enable the EE Bot Trap
2233
-     *
2234
-     * @var boolean $use_bot_trap
2235
-     */
2236
-    public $use_bot_trap;
2237
-
2238
-    /**
2239
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2240
-     *
2241
-     * @var boolean $use_encryption
2242
-     */
2243
-    public $use_encryption;
2244
-
2245
-    /**
2246
-     * Whether or not to use ReCaptcha
2247
-     *
2248
-     * @var boolean $use_captcha
2249
-     */
2250
-    public $use_captcha;
2251
-
2252
-    /**
2253
-     * ReCaptcha Theme
2254
-     *
2255
-     * @var string $recaptcha_theme
2256
-     *    options: 'dark', 'light', 'invisible'
2257
-     */
2258
-    public $recaptcha_theme;
2259
-
2260
-    /**
2261
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2262
-     *
2263
-     * @var string $recaptcha_badge
2264
-     *    options: 'bottomright', 'bottomleft', 'inline'
2265
-     */
2266
-    public $recaptcha_badge;
17
+	const OPTION_NAME = 'ee_config';
18
+
19
+	const LOG_NAME = 'ee_config_log';
20
+
21
+	const LOG_LENGTH = 100;
22
+
23
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
24
+
25
+	/**
26
+	 *    instance of the EE_Config object
27
+	 *
28
+	 * @var    EE_Config $_instance
29
+	 * @access    private
30
+	 */
31
+	private static $_instance;
32
+
33
+	/**
34
+	 * @var boolean $_logging_enabled
35
+	 */
36
+	private static $_logging_enabled = false;
37
+
38
+	/**
39
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
40
+	 */
41
+	private $legacy_shortcodes_manager;
42
+
43
+	/**
44
+	 * An StdClass whose property names are addon slugs,
45
+	 * and values are their config classes
46
+	 *
47
+	 * @var StdClass
48
+	 */
49
+	public $addons;
50
+
51
+	/**
52
+	 * @var EE_Admin_Config
53
+	 */
54
+	public $admin;
55
+
56
+	/**
57
+	 * @var EE_Core_Config
58
+	 */
59
+	public $core;
60
+
61
+	/**
62
+	 * @var EE_Currency_Config
63
+	 */
64
+	public $currency;
65
+
66
+	/**
67
+	 * @var EE_Organization_Config
68
+	 */
69
+	public $organization;
70
+
71
+	/**
72
+	 * @var EE_Registration_Config
73
+	 */
74
+	public $registration;
75
+
76
+	/**
77
+	 * @var EE_Template_Config
78
+	 */
79
+	public $template_settings;
80
+
81
+	/**
82
+	 * Holds EE environment values.
83
+	 *
84
+	 * @var EE_Environment_Config
85
+	 */
86
+	public $environment;
87
+
88
+	/**
89
+	 * settings pertaining to Google maps
90
+	 *
91
+	 * @var EE_Map_Config
92
+	 */
93
+	public $map_settings;
94
+
95
+	/**
96
+	 * settings pertaining to Taxes
97
+	 *
98
+	 * @var EE_Tax_Config
99
+	 */
100
+	public $tax_settings;
101
+
102
+	/**
103
+	 * Settings pertaining to global messages settings.
104
+	 *
105
+	 * @var EE_Messages_Config
106
+	 */
107
+	public $messages;
108
+
109
+	/**
110
+	 * @deprecated
111
+	 * @var EE_Gateway_Config
112
+	 */
113
+	public $gateway;
114
+
115
+	/**
116
+	 * @var    array $_addon_option_names
117
+	 * @access    private
118
+	 */
119
+	private $_addon_option_names = array();
120
+
121
+	/**
122
+	 * @var    array $_module_route_map
123
+	 * @access    private
124
+	 */
125
+	private static $_module_route_map = array();
126
+
127
+	/**
128
+	 * @var    array $_module_forward_map
129
+	 * @access    private
130
+	 */
131
+	private static $_module_forward_map = array();
132
+
133
+	/**
134
+	 * @var    array $_module_view_map
135
+	 * @access    private
136
+	 */
137
+	private static $_module_view_map = array();
138
+
139
+
140
+	/**
141
+	 * @singleton method used to instantiate class object
142
+	 * @access    public
143
+	 * @return EE_Config instance
144
+	 */
145
+	public static function instance()
146
+	{
147
+		// check if class object is instantiated, and instantiated properly
148
+		if (! self::$_instance instanceof EE_Config) {
149
+			self::$_instance = new self();
150
+		}
151
+		return self::$_instance;
152
+	}
153
+
154
+
155
+	/**
156
+	 * Resets the config
157
+	 *
158
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
159
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
160
+	 *                               reflect its state in the database
161
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
162
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
163
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
164
+	 *                               site was put into maintenance mode)
165
+	 * @return EE_Config
166
+	 */
167
+	public static function reset($hard_reset = false, $reinstantiate = true)
168
+	{
169
+		if (self::$_instance instanceof EE_Config) {
170
+			if ($hard_reset) {
171
+				self::$_instance->legacy_shortcodes_manager = null;
172
+				self::$_instance->_addon_option_names = array();
173
+				self::$_instance->_initialize_config();
174
+				self::$_instance->update_espresso_config();
175
+			}
176
+			self::$_instance->update_addon_option_names();
177
+		}
178
+		self::$_instance = null;
179
+		// we don't need to reset the static properties imo because those should
180
+		// only change when a module is added or removed. Currently we don't
181
+		// support removing a module during a request when it previously existed
182
+		if ($reinstantiate) {
183
+			return self::instance();
184
+		} else {
185
+			return null;
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 *    class constructor
192
+	 *
193
+	 * @access    private
194
+	 */
195
+	private function __construct()
196
+	{
197
+		do_action('AHEE__EE_Config__construct__begin', $this);
198
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
199
+		// setup empty config classes
200
+		$this->_initialize_config();
201
+		// load existing EE site settings
202
+		$this->_load_core_config();
203
+		// confirm everything loaded correctly and set filtered defaults if not
204
+		$this->_verify_config();
205
+		//  register shortcodes and modules
206
+		add_action(
207
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
208
+			array($this, 'register_shortcodes_and_modules'),
209
+			999
210
+		);
211
+		//  initialize shortcodes and modules
212
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
213
+		// register widgets
214
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
215
+		// shutdown
216
+		add_action('shutdown', array($this, 'shutdown'), 10);
217
+		// construct__end hook
218
+		do_action('AHEE__EE_Config__construct__end', $this);
219
+		// hardcoded hack
220
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
221
+	}
222
+
223
+
224
+	/**
225
+	 * @return boolean
226
+	 */
227
+	public static function logging_enabled()
228
+	{
229
+		return self::$_logging_enabled;
230
+	}
231
+
232
+
233
+	/**
234
+	 * use to get the current theme if needed from static context
235
+	 *
236
+	 * @return string current theme set.
237
+	 */
238
+	public static function get_current_theme()
239
+	{
240
+		return isset(self::$_instance->template_settings->current_espresso_theme)
241
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
242
+	}
243
+
244
+
245
+	/**
246
+	 *        _initialize_config
247
+	 *
248
+	 * @access private
249
+	 * @return void
250
+	 */
251
+	private function _initialize_config()
252
+	{
253
+		EE_Config::trim_log();
254
+		// set defaults
255
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
256
+		$this->addons = new stdClass();
257
+		// set _module_route_map
258
+		EE_Config::$_module_route_map = array();
259
+		// set _module_forward_map
260
+		EE_Config::$_module_forward_map = array();
261
+		// set _module_view_map
262
+		EE_Config::$_module_view_map = array();
263
+	}
264
+
265
+
266
+	/**
267
+	 *        load core plugin configuration
268
+	 *
269
+	 * @access private
270
+	 * @return void
271
+	 */
272
+	private function _load_core_config()
273
+	{
274
+		// load_core_config__start hook
275
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
276
+		$espresso_config = $this->get_espresso_config();
277
+		foreach ($espresso_config as $config => $settings) {
278
+			// load_core_config__start hook
279
+			$settings = apply_filters(
280
+				'FHEE__EE_Config___load_core_config__config_settings',
281
+				$settings,
282
+				$config,
283
+				$this
284
+			);
285
+			if (is_object($settings) && property_exists($this, $config)) {
286
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
287
+				// call configs populate method to ensure any defaults are set for empty values.
288
+				if (method_exists($settings, 'populate')) {
289
+					$this->{$config}->populate();
290
+				}
291
+				if (method_exists($settings, 'do_hooks')) {
292
+					$this->{$config}->do_hooks();
293
+				}
294
+			}
295
+		}
296
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
297
+			$this->update_espresso_config();
298
+		}
299
+		// load_core_config__end hook
300
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
301
+	}
302
+
303
+
304
+	/**
305
+	 *    _verify_config
306
+	 *
307
+	 * @access    protected
308
+	 * @return    void
309
+	 */
310
+	protected function _verify_config()
311
+	{
312
+		$this->core = $this->core instanceof EE_Core_Config
313
+			? $this->core
314
+			: new EE_Core_Config();
315
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
316
+		$this->organization = $this->organization instanceof EE_Organization_Config
317
+			? $this->organization
318
+			: new EE_Organization_Config();
319
+		$this->organization = apply_filters(
320
+			'FHEE__EE_Config___initialize_config__organization',
321
+			$this->organization
322
+		);
323
+		$this->currency = $this->currency instanceof EE_Currency_Config
324
+			? $this->currency
325
+			: new EE_Currency_Config();
326
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
327
+		$this->registration = $this->registration instanceof EE_Registration_Config
328
+			? $this->registration
329
+			: new EE_Registration_Config();
330
+		$this->registration = apply_filters(
331
+			'FHEE__EE_Config___initialize_config__registration',
332
+			$this->registration
333
+		);
334
+		$this->admin = $this->admin instanceof EE_Admin_Config
335
+			? $this->admin
336
+			: new EE_Admin_Config();
337
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
338
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
339
+			? $this->template_settings
340
+			: new EE_Template_Config();
341
+		$this->template_settings = apply_filters(
342
+			'FHEE__EE_Config___initialize_config__template_settings',
343
+			$this->template_settings
344
+		);
345
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
346
+			? $this->map_settings
347
+			: new EE_Map_Config();
348
+		$this->map_settings = apply_filters(
349
+			'FHEE__EE_Config___initialize_config__map_settings',
350
+			$this->map_settings
351
+		);
352
+		$this->environment = $this->environment instanceof EE_Environment_Config
353
+			? $this->environment
354
+			: new EE_Environment_Config();
355
+		$this->environment = apply_filters(
356
+			'FHEE__EE_Config___initialize_config__environment',
357
+			$this->environment
358
+		);
359
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
360
+			? $this->tax_settings
361
+			: new EE_Tax_Config();
362
+		$this->tax_settings = apply_filters(
363
+			'FHEE__EE_Config___initialize_config__tax_settings',
364
+			$this->tax_settings
365
+		);
366
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
367
+		$this->messages = $this->messages instanceof EE_Messages_Config
368
+			? $this->messages
369
+			: new EE_Messages_Config();
370
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
371
+			? $this->gateway
372
+			: new EE_Gateway_Config();
373
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
374
+		$this->legacy_shortcodes_manager = null;
375
+	}
376
+
377
+
378
+	/**
379
+	 *    get_espresso_config
380
+	 *
381
+	 * @access    public
382
+	 * @return    array of espresso config stuff
383
+	 */
384
+	public function get_espresso_config()
385
+	{
386
+		// grab espresso configuration
387
+		return apply_filters(
388
+			'FHEE__EE_Config__get_espresso_config__CFG',
389
+			get_option(EE_Config::OPTION_NAME, array())
390
+		);
391
+	}
392
+
393
+
394
+	/**
395
+	 *    double_check_config_comparison
396
+	 *
397
+	 * @access    public
398
+	 * @param string $option
399
+	 * @param        $old_value
400
+	 * @param        $value
401
+	 */
402
+	public function double_check_config_comparison($option = '', $old_value, $value)
403
+	{
404
+		// make sure we're checking the ee config
405
+		if ($option === EE_Config::OPTION_NAME) {
406
+			// run a loose comparison of the old value against the new value for type and properties,
407
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
408
+			if ($value != $old_value) {
409
+				// if they are NOT the same, then remove the hook,
410
+				// which means the subsequent update results will be based solely on the update query results
411
+				// the reason we do this is because, as stated above,
412
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
413
+				// this happens PRIOR to serialization and any subsequent update.
414
+				// If values are found to match their previous old value,
415
+				// then WP bails before performing any update.
416
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
417
+				// it just pulled from the db, with the one being passed to it (which will not match).
418
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
419
+				// MySQL MAY ALSO NOT perform the update because
420
+				// the string it sees in the db looks the same as the new one it has been passed!!!
421
+				// This results in the query returning an "affected rows" value of ZERO,
422
+				// which gets returned immediately by WP update_option and looks like an error.
423
+				remove_action('update_option', array($this, 'check_config_updated'));
424
+			}
425
+		}
426
+	}
427
+
428
+
429
+	/**
430
+	 *    update_espresso_config
431
+	 *
432
+	 * @access   public
433
+	 */
434
+	protected function _reset_espresso_addon_config()
435
+	{
436
+		$this->_addon_option_names = array();
437
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
438
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
439
+			if ($addon_config_obj instanceof EE_Config_Base) {
440
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
441
+			}
442
+			$this->addons->{$addon_name} = null;
443
+		}
444
+	}
445
+
446
+
447
+	/**
448
+	 *    update_espresso_config
449
+	 *
450
+	 * @access   public
451
+	 * @param   bool $add_success
452
+	 * @param   bool $add_error
453
+	 * @return   bool
454
+	 */
455
+	public function update_espresso_config($add_success = false, $add_error = true)
456
+	{
457
+		// don't allow config updates during WP heartbeats
458
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
459
+			return false;
460
+		}
461
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
462
+		// $clone = clone( self::$_instance );
463
+		// self::$_instance = NULL;
464
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
465
+		$this->_reset_espresso_addon_config();
466
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
467
+		// but BEFORE the actual update occurs
468
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
469
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
470
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
471
+		$this->legacy_shortcodes_manager = null;
472
+		// now update "ee_config"
473
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
474
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
475
+		EE_Config::log(EE_Config::OPTION_NAME);
476
+		// if not saved... check if the hook we just added still exists;
477
+		// if it does, it means one of two things:
478
+		// that update_option bailed at the($value === $old_value) conditional,
479
+		// or...
480
+		// the db update query returned 0 rows affected
481
+		// (probably because the data  value was the same from it's perspective)
482
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
483
+		// but just means no update occurred, so don't display an error to the user.
484
+		// BUT... if update_option returns FALSE, AND the hook is missing,
485
+		// then it means that something truly went wrong
486
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
487
+		// remove our action since we don't want it in the system anymore
488
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
489
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
490
+		// self::$_instance = $clone;
491
+		// unset( $clone );
492
+		// if config remains the same or was updated successfully
493
+		if ($saved) {
494
+			if ($add_success) {
495
+				EE_Error::add_success(
496
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
497
+					__FILE__,
498
+					__FUNCTION__,
499
+					__LINE__
500
+				);
501
+			}
502
+			return true;
503
+		} else {
504
+			if ($add_error) {
505
+				EE_Error::add_error(
506
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
507
+					__FILE__,
508
+					__FUNCTION__,
509
+					__LINE__
510
+				);
511
+			}
512
+			return false;
513
+		}
514
+	}
515
+
516
+
517
+	/**
518
+	 *    _verify_config_params
519
+	 *
520
+	 * @access    private
521
+	 * @param    string         $section
522
+	 * @param    string         $name
523
+	 * @param    string         $config_class
524
+	 * @param    EE_Config_Base $config_obj
525
+	 * @param    array          $tests_to_run
526
+	 * @param    bool           $display_errors
527
+	 * @return    bool    TRUE on success, FALSE on fail
528
+	 */
529
+	private function _verify_config_params(
530
+		$section = '',
531
+		$name = '',
532
+		$config_class = '',
533
+		$config_obj = null,
534
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
535
+		$display_errors = true
536
+	) {
537
+		try {
538
+			foreach ($tests_to_run as $test) {
539
+				switch ($test) {
540
+					// TEST #1 : check that section was set
541
+					case 1:
542
+						if (empty($section)) {
543
+							if ($display_errors) {
544
+								throw new EE_Error(
545
+									sprintf(
546
+										__(
547
+											'No configuration section has been provided while attempting to save "%s".',
548
+											'event_espresso'
549
+										),
550
+										$config_class
551
+									)
552
+								);
553
+							}
554
+							return false;
555
+						}
556
+						break;
557
+					// TEST #2 : check that settings section exists
558
+					case 2:
559
+						if (! isset($this->{$section})) {
560
+							if ($display_errors) {
561
+								throw new EE_Error(
562
+									sprintf(
563
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
564
+										$section
565
+									)
566
+								);
567
+							}
568
+							return false;
569
+						}
570
+						break;
571
+					// TEST #3 : check that section is the proper format
572
+					case 3:
573
+						if (
574
+							! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
575
+						) {
576
+							if ($display_errors) {
577
+								throw new EE_Error(
578
+									sprintf(
579
+										__(
580
+											'The "%s" configuration settings have not been formatted correctly.',
581
+											'event_espresso'
582
+										),
583
+										$section
584
+									)
585
+								);
586
+							}
587
+							return false;
588
+						}
589
+						break;
590
+					// TEST #4 : check that config section name has been set
591
+					case 4:
592
+						if (empty($name)) {
593
+							if ($display_errors) {
594
+								throw new EE_Error(
595
+									__(
596
+										'No name has been provided for the specific configuration section.',
597
+										'event_espresso'
598
+									)
599
+								);
600
+							}
601
+							return false;
602
+						}
603
+						break;
604
+					// TEST #5 : check that a config class name has been set
605
+					case 5:
606
+						if (empty($config_class)) {
607
+							if ($display_errors) {
608
+								throw new EE_Error(
609
+									__(
610
+										'No class name has been provided for the specific configuration section.',
611
+										'event_espresso'
612
+									)
613
+								);
614
+							}
615
+							return false;
616
+						}
617
+						break;
618
+					// TEST #6 : verify config class is accessible
619
+					case 6:
620
+						if (! class_exists($config_class)) {
621
+							if ($display_errors) {
622
+								throw new EE_Error(
623
+									sprintf(
624
+										__(
625
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
626
+											'event_espresso'
627
+										),
628
+										$config_class
629
+									)
630
+								);
631
+							}
632
+							return false;
633
+						}
634
+						break;
635
+					// TEST #7 : check that config has even been set
636
+					case 7:
637
+						if (! isset($this->{$section}->{$name})) {
638
+							if ($display_errors) {
639
+								throw new EE_Error(
640
+									sprintf(
641
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
642
+										$section,
643
+										$name
644
+									)
645
+								);
646
+							}
647
+							return false;
648
+						} else {
649
+							// and make sure it's not serialized
650
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
651
+						}
652
+						break;
653
+					// TEST #8 : check that config is the requested type
654
+					case 8:
655
+						if (! $this->{$section}->{$name} instanceof $config_class) {
656
+							if ($display_errors) {
657
+								throw new EE_Error(
658
+									sprintf(
659
+										__(
660
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
661
+											'event_espresso'
662
+										),
663
+										$section,
664
+										$name,
665
+										$config_class
666
+									)
667
+								);
668
+							}
669
+							return false;
670
+						}
671
+						break;
672
+					// TEST #9 : verify config object
673
+					case 9:
674
+						if (! $config_obj instanceof EE_Config_Base) {
675
+							if ($display_errors) {
676
+								throw new EE_Error(
677
+									sprintf(
678
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
679
+										print_r($config_obj, true)
680
+									)
681
+								);
682
+							}
683
+							return false;
684
+						}
685
+						break;
686
+				}
687
+			}
688
+		} catch (EE_Error $e) {
689
+			$e->get_error();
690
+		}
691
+		// you have successfully run the gauntlet
692
+		return true;
693
+	}
694
+
695
+
696
+	/**
697
+	 *    _generate_config_option_name
698
+	 *
699
+	 * @access        protected
700
+	 * @param        string $section
701
+	 * @param        string $name
702
+	 * @return        string
703
+	 */
704
+	private function _generate_config_option_name($section = '', $name = '')
705
+	{
706
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
707
+	}
708
+
709
+
710
+	/**
711
+	 *    _set_config_class
712
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
713
+	 *
714
+	 * @access    private
715
+	 * @param    string $config_class
716
+	 * @param    string $name
717
+	 * @return    string
718
+	 */
719
+	private function _set_config_class($config_class = '', $name = '')
720
+	{
721
+		return ! empty($config_class)
722
+			? $config_class
723
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
724
+	}
725
+
726
+
727
+	/**
728
+	 *    set_config
729
+	 *
730
+	 * @access    protected
731
+	 * @param    string         $section
732
+	 * @param    string         $name
733
+	 * @param    string         $config_class
734
+	 * @param    EE_Config_Base $config_obj
735
+	 * @return    EE_Config_Base
736
+	 */
737
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
738
+	{
739
+		// ensure config class is set to something
740
+		$config_class = $this->_set_config_class($config_class, $name);
741
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
742
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
743
+			return null;
744
+		}
745
+		$config_option_name = $this->_generate_config_option_name($section, $name);
746
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
747
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
748
+			$this->_addon_option_names[ $config_option_name ] = $config_class;
749
+			$this->update_addon_option_names();
750
+		}
751
+		// verify the incoming config object but suppress errors
752
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
753
+			$config_obj = new $config_class();
754
+		}
755
+		if (get_option($config_option_name)) {
756
+			EE_Config::log($config_option_name);
757
+			update_option($config_option_name, $config_obj);
758
+			$this->{$section}->{$name} = $config_obj;
759
+			return $this->{$section}->{$name};
760
+		} else {
761
+			// create a wp-option for this config
762
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
763
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
764
+				return $this->{$section}->{$name};
765
+			} else {
766
+				EE_Error::add_error(
767
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
768
+					__FILE__,
769
+					__FUNCTION__,
770
+					__LINE__
771
+				);
772
+				return null;
773
+			}
774
+		}
775
+	}
776
+
777
+
778
+	/**
779
+	 *    update_config
780
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
781
+	 *
782
+	 * @access    public
783
+	 * @param    string                $section
784
+	 * @param    string                $name
785
+	 * @param    EE_Config_Base|string $config_obj
786
+	 * @param    bool                  $throw_errors
787
+	 * @return    bool
788
+	 */
789
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
790
+	{
791
+		// don't allow config updates during WP heartbeats
792
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
793
+			return false;
794
+		}
795
+		$config_obj = maybe_unserialize($config_obj);
796
+		// get class name of the incoming object
797
+		$config_class = get_class($config_obj);
798
+		// run tests 1-5 and 9 to verify config
799
+		if (
800
+			! $this->_verify_config_params(
801
+				$section,
802
+				$name,
803
+				$config_class,
804
+				$config_obj,
805
+				array(1, 2, 3, 4, 7, 9)
806
+			)
807
+		) {
808
+			return false;
809
+		}
810
+		$config_option_name = $this->_generate_config_option_name($section, $name);
811
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
812
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
813
+			// save new config to db
814
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
815
+				return true;
816
+			}
817
+		} else {
818
+			// first check if the record already exists
819
+			$existing_config = get_option($config_option_name);
820
+			$config_obj = serialize($config_obj);
821
+			// just return if db record is already up to date (NOT type safe comparison)
822
+			if ($existing_config == $config_obj) {
823
+				$this->{$section}->{$name} = $config_obj;
824
+				return true;
825
+			} elseif (update_option($config_option_name, $config_obj)) {
826
+				EE_Config::log($config_option_name);
827
+				// update wp-option for this config class
828
+				$this->{$section}->{$name} = $config_obj;
829
+				return true;
830
+			} elseif ($throw_errors) {
831
+				EE_Error::add_error(
832
+					sprintf(
833
+						__(
834
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
835
+							'event_espresso'
836
+						),
837
+						$config_class,
838
+						'EE_Config->' . $section . '->' . $name
839
+					),
840
+					__FILE__,
841
+					__FUNCTION__,
842
+					__LINE__
843
+				);
844
+			}
845
+		}
846
+		return false;
847
+	}
848
+
849
+
850
+	/**
851
+	 *    get_config
852
+	 *
853
+	 * @access    public
854
+	 * @param    string $section
855
+	 * @param    string $name
856
+	 * @param    string $config_class
857
+	 * @return    mixed EE_Config_Base | NULL
858
+	 */
859
+	public function get_config($section = '', $name = '', $config_class = '')
860
+	{
861
+		// ensure config class is set to something
862
+		$config_class = $this->_set_config_class($config_class, $name);
863
+		// run tests 1-4, 6 and 7 to verify that all params have been set
864
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
865
+			return null;
866
+		}
867
+		// now test if the requested config object exists, but suppress errors
868
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
869
+			// config already exists, so pass it back
870
+			return $this->{$section}->{$name};
871
+		}
872
+		// load config option from db if it exists
873
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
874
+		// verify the newly retrieved config object, but suppress errors
875
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
876
+			// config is good, so set it and pass it back
877
+			$this->{$section}->{$name} = $config_obj;
878
+			return $this->{$section}->{$name};
879
+		}
880
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
881
+		$config_obj = $this->set_config($section, $name, $config_class);
882
+		// verify the newly created config object
883
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
884
+			return $this->{$section}->{$name};
885
+		} else {
886
+			EE_Error::add_error(
887
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
888
+				__FILE__,
889
+				__FUNCTION__,
890
+				__LINE__
891
+			);
892
+		}
893
+		return null;
894
+	}
895
+
896
+
897
+	/**
898
+	 *    get_config_option
899
+	 *
900
+	 * @access    public
901
+	 * @param    string $config_option_name
902
+	 * @return    mixed EE_Config_Base | FALSE
903
+	 */
904
+	public function get_config_option($config_option_name = '')
905
+	{
906
+		// retrieve the wp-option for this config class.
907
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
908
+		if (empty($config_option)) {
909
+			EE_Config::log($config_option_name . '-NOT-FOUND');
910
+		}
911
+		return $config_option;
912
+	}
913
+
914
+
915
+	/**
916
+	 * log
917
+	 *
918
+	 * @param string $config_option_name
919
+	 */
920
+	public static function log($config_option_name = '')
921
+	{
922
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
923
+			$config_log = get_option(EE_Config::LOG_NAME, array());
924
+			// copy incoming $_REQUEST and sanitize it so we can save it
925
+			$_request = $_REQUEST;
926
+			array_walk_recursive($_request, 'sanitize_text_field');
927
+			$config_log[ (string) microtime(true) ] = array(
928
+				'config_name' => $config_option_name,
929
+				'request'     => $_request,
930
+			);
931
+			update_option(EE_Config::LOG_NAME, $config_log);
932
+		}
933
+	}
934
+
935
+
936
+	/**
937
+	 * trim_log
938
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
939
+	 */
940
+	public static function trim_log()
941
+	{
942
+		if (! EE_Config::logging_enabled()) {
943
+			return;
944
+		}
945
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
946
+		$log_length = count($config_log);
947
+		if ($log_length > EE_Config::LOG_LENGTH) {
948
+			ksort($config_log);
949
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
950
+			update_option(EE_Config::LOG_NAME, $config_log);
951
+		}
952
+	}
953
+
954
+
955
+	/**
956
+	 *    get_page_for_posts
957
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
958
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
959
+	 *
960
+	 * @access    public
961
+	 * @return    string
962
+	 */
963
+	public static function get_page_for_posts()
964
+	{
965
+		$page_for_posts = get_option('page_for_posts');
966
+		if (! $page_for_posts) {
967
+			return 'posts';
968
+		}
969
+		/** @type WPDB $wpdb */
970
+		global $wpdb;
971
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
972
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
973
+	}
974
+
975
+
976
+	/**
977
+	 *    register_shortcodes_and_modules.
978
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
979
+	 *    In fact, this is where we give modules a chance to let core know they exist
980
+	 *    so they can help trigger maintenance mode if it's needed
981
+	 *
982
+	 * @access    public
983
+	 * @return    void
984
+	 */
985
+	public function register_shortcodes_and_modules()
986
+	{
987
+		// allow modules to set hooks for the rest of the system
988
+		EE_Registry::instance()->modules = $this->_register_modules();
989
+	}
990
+
991
+
992
+	/**
993
+	 *    initialize_shortcodes_and_modules
994
+	 *    meaning they can start adding their hooks to get stuff done
995
+	 *
996
+	 * @access    public
997
+	 * @return    void
998
+	 */
999
+	public function initialize_shortcodes_and_modules()
1000
+	{
1001
+		// allow modules to set hooks for the rest of the system
1002
+		$this->_initialize_modules();
1003
+	}
1004
+
1005
+
1006
+	/**
1007
+	 *    widgets_init
1008
+	 *
1009
+	 * @access private
1010
+	 * @return void
1011
+	 */
1012
+	public function widgets_init()
1013
+	{
1014
+		// only init widgets on admin pages when not in complete maintenance, and
1015
+		// on frontend when not in any maintenance mode
1016
+		if (
1017
+			! EE_Maintenance_Mode::instance()->level()
1018
+			|| (
1019
+				is_admin()
1020
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1021
+			)
1022
+		) {
1023
+			// grab list of installed widgets
1024
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1025
+			// filter list of modules to register
1026
+			$widgets_to_register = apply_filters(
1027
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1028
+				$widgets_to_register
1029
+			);
1030
+			if (! empty($widgets_to_register)) {
1031
+				// cycle thru widget folders
1032
+				foreach ($widgets_to_register as $widget_path) {
1033
+					// add to list of installed widget modules
1034
+					EE_Config::register_ee_widget($widget_path);
1035
+				}
1036
+			}
1037
+			// filter list of installed modules
1038
+			EE_Registry::instance()->widgets = apply_filters(
1039
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1040
+				EE_Registry::instance()->widgets
1041
+			);
1042
+		}
1043
+	}
1044
+
1045
+
1046
+	/**
1047
+	 *    register_ee_widget - makes core aware of this widget
1048
+	 *
1049
+	 * @access    public
1050
+	 * @param    string $widget_path - full path up to and including widget folder
1051
+	 * @return    void
1052
+	 */
1053
+	public static function register_ee_widget($widget_path = null)
1054
+	{
1055
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1056
+		$widget_ext = '.widget.php';
1057
+		// make all separators match
1058
+		$widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1059
+		// does the file path INCLUDE the actual file name as part of the path ?
1060
+		if (strpos($widget_path, $widget_ext) !== false) {
1061
+			// grab and shortcode file name from directory name and break apart at dots
1062
+			$file_name = explode('.', basename($widget_path));
1063
+			// take first segment from file name pieces and remove class prefix if it exists
1064
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1065
+			// sanitize shortcode directory name
1066
+			$widget = sanitize_key($widget);
1067
+			// now we need to rebuild the shortcode path
1068
+			$widget_path = explode('/', $widget_path);
1069
+			// remove last segment
1070
+			array_pop($widget_path);
1071
+			// glue it back together
1072
+			$widget_path = implode(DS, $widget_path);
1073
+		} else {
1074
+			// grab and sanitize widget directory name
1075
+			$widget = sanitize_key(basename($widget_path));
1076
+		}
1077
+		// create classname from widget directory name
1078
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1079
+		// add class prefix
1080
+		$widget_class = 'EEW_' . $widget;
1081
+		// does the widget exist ?
1082
+		if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1083
+			$msg = sprintf(
1084
+				__(
1085
+					'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1086
+					'event_espresso'
1087
+				),
1088
+				$widget_class,
1089
+				$widget_path . '/' . $widget_class . $widget_ext
1090
+			);
1091
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1092
+			return;
1093
+		}
1094
+		// load the widget class file
1095
+		require_once($widget_path . '/' . $widget_class . $widget_ext);
1096
+		// verify that class exists
1097
+		if (! class_exists($widget_class)) {
1098
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1099
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1100
+			return;
1101
+		}
1102
+		register_widget($widget_class);
1103
+		// add to array of registered widgets
1104
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1105
+	}
1106
+
1107
+
1108
+	/**
1109
+	 *        _register_modules
1110
+	 *
1111
+	 * @access private
1112
+	 * @return array
1113
+	 */
1114
+	private function _register_modules()
1115
+	{
1116
+		// grab list of installed modules
1117
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1118
+		// filter list of modules to register
1119
+		$modules_to_register = apply_filters(
1120
+			'FHEE__EE_Config__register_modules__modules_to_register',
1121
+			$modules_to_register
1122
+		);
1123
+		if (! empty($modules_to_register)) {
1124
+			// loop through folders
1125
+			foreach ($modules_to_register as $module_path) {
1126
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1127
+				if (
1128
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1129
+					&& $module_path !== EE_MODULES . 'gateways'
1130
+				) {
1131
+					// add to list of installed modules
1132
+					EE_Config::register_module($module_path);
1133
+				}
1134
+			}
1135
+		}
1136
+		// filter list of installed modules
1137
+		return apply_filters(
1138
+			'FHEE__EE_Config___register_modules__installed_modules',
1139
+			EE_Registry::instance()->modules
1140
+		);
1141
+	}
1142
+
1143
+
1144
+	/**
1145
+	 *    register_module - makes core aware of this module
1146
+	 *
1147
+	 * @access    public
1148
+	 * @param    string $module_path - full path up to and including module folder
1149
+	 * @return    bool
1150
+	 */
1151
+	public static function register_module($module_path = null)
1152
+	{
1153
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1154
+		$module_ext = '.module.php';
1155
+		// make all separators match
1156
+		$module_path = str_replace(array('\\', '/'), '/', $module_path);
1157
+		// does the file path INCLUDE the actual file name as part of the path ?
1158
+		if (strpos($module_path, $module_ext) !== false) {
1159
+			// grab and shortcode file name from directory name and break apart at dots
1160
+			$module_file = explode('.', basename($module_path));
1161
+			// now we need to rebuild the shortcode path
1162
+			$module_path = explode('/', $module_path);
1163
+			// remove last segment
1164
+			array_pop($module_path);
1165
+			// glue it back together
1166
+			$module_path = implode('/', $module_path) . '/';
1167
+			// take first segment from file name pieces and sanitize it
1168
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1169
+			// ensure class prefix is added
1170
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1171
+		} else {
1172
+			// we need to generate the filename based off of the folder name
1173
+			// grab and sanitize module name
1174
+			$module = strtolower(basename($module_path));
1175
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1176
+			// like trailingslashit()
1177
+			$module_path = rtrim($module_path, '/') . '/';
1178
+			// create classname from module directory name
1179
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1180
+			// add class prefix
1181
+			$module_class = 'EED_' . $module;
1182
+		}
1183
+		// does the module exist ?
1184
+		if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1185
+			$msg = sprintf(
1186
+				__(
1187
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1188
+					'event_espresso'
1189
+				),
1190
+				$module
1191
+			);
1192
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1193
+			return false;
1194
+		}
1195
+		// load the module class file
1196
+		require_once($module_path . $module_class . $module_ext);
1197
+		// verify that class exists
1198
+		if (! class_exists($module_class)) {
1199
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1200
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1201
+			return false;
1202
+		}
1203
+		// add to array of registered modules
1204
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1205
+		do_action(
1206
+			'AHEE__EE_Config__register_module__complete',
1207
+			$module_class,
1208
+			EE_Registry::instance()->modules->{$module_class}
1209
+		);
1210
+		return true;
1211
+	}
1212
+
1213
+
1214
+	/**
1215
+	 *    _initialize_modules
1216
+	 *    allow modules to set hooks for the rest of the system
1217
+	 *
1218
+	 * @access private
1219
+	 * @return void
1220
+	 */
1221
+	private function _initialize_modules()
1222
+	{
1223
+		// cycle thru shortcode folders
1224
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1225
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1226
+			// which set hooks ?
1227
+			if (is_admin()) {
1228
+				// fire immediately
1229
+				call_user_func(array($module_class, 'set_hooks_admin'));
1230
+			} else {
1231
+				// delay until other systems are online
1232
+				add_action(
1233
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1234
+					array($module_class, 'set_hooks')
1235
+				);
1236
+			}
1237
+		}
1238
+	}
1239
+
1240
+
1241
+	/**
1242
+	 *    register_route - adds module method routes to route_map
1243
+	 *
1244
+	 * @access    public
1245
+	 * @param    string $route       - "pretty" public alias for module method
1246
+	 * @param    string $module      - module name (classname without EED_ prefix)
1247
+	 * @param    string $method_name - the actual module method to be routed to
1248
+	 * @param    string $key         - url param key indicating a route is being called
1249
+	 * @return    bool
1250
+	 */
1251
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1252
+	{
1253
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1254
+		$module = str_replace('EED_', '', $module);
1255
+		$module_class = 'EED_' . $module;
1256
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1257
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1258
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1259
+			return false;
1260
+		}
1261
+		if (empty($route)) {
1262
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1263
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1264
+			return false;
1265
+		}
1266
+		if (! method_exists('EED_' . $module, $method_name)) {
1267
+			$msg = sprintf(
1268
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1269
+				$route
1270
+			);
1271
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1272
+			return false;
1273
+		}
1274
+		EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1275
+		return true;
1276
+	}
1277
+
1278
+
1279
+	/**
1280
+	 *    get_route - get module method route
1281
+	 *
1282
+	 * @access    public
1283
+	 * @param    string $route - "pretty" public alias for module method
1284
+	 * @param    string $key   - url param key indicating a route is being called
1285
+	 * @return    string
1286
+	 */
1287
+	public static function get_route($route = null, $key = 'ee')
1288
+	{
1289
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1290
+		$route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1291
+		if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1292
+			return EE_Config::$_module_route_map[ $key ][ $route ];
1293
+		}
1294
+		return null;
1295
+	}
1296
+
1297
+
1298
+	/**
1299
+	 *    get_routes - get ALL module method routes
1300
+	 *
1301
+	 * @access    public
1302
+	 * @return    array
1303
+	 */
1304
+	public static function get_routes()
1305
+	{
1306
+		return EE_Config::$_module_route_map;
1307
+	}
1308
+
1309
+
1310
+	/**
1311
+	 *    register_forward - allows modules to forward request to another module for further processing
1312
+	 *
1313
+	 * @access    public
1314
+	 * @param    string       $route   - "pretty" public alias for module method
1315
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1316
+	 *                                 class, allows different forwards to be served based on status
1317
+	 * @param    array|string $forward - function name or array( class, method )
1318
+	 * @param    string       $key     - url param key indicating a route is being called
1319
+	 * @return    bool
1320
+	 */
1321
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1322
+	{
1323
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1324
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1325
+			$msg = sprintf(
1326
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1327
+				$route
1328
+			);
1329
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1330
+			return false;
1331
+		}
1332
+		if (empty($forward)) {
1333
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1334
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1335
+			return false;
1336
+		}
1337
+		if (is_array($forward)) {
1338
+			if (! isset($forward[1])) {
1339
+				$msg = sprintf(
1340
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1341
+					$route
1342
+				);
1343
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1344
+				return false;
1345
+			}
1346
+			if (! method_exists($forward[0], $forward[1])) {
1347
+				$msg = sprintf(
1348
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1349
+					$forward[1],
1350
+					$route
1351
+				);
1352
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1353
+				return false;
1354
+			}
1355
+		} elseif (! function_exists($forward)) {
1356
+			$msg = sprintf(
1357
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1358
+				$forward,
1359
+				$route
1360
+			);
1361
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1362
+			return false;
1363
+		}
1364
+		EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1365
+		return true;
1366
+	}
1367
+
1368
+
1369
+	/**
1370
+	 *    get_forward - get forwarding route
1371
+	 *
1372
+	 * @access    public
1373
+	 * @param    string  $route  - "pretty" public alias for module method
1374
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1375
+	 *                           allows different forwards to be served based on status
1376
+	 * @param    string  $key    - url param key indicating a route is being called
1377
+	 * @return    string
1378
+	 */
1379
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1380
+	{
1381
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1382
+		if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1383
+			return apply_filters(
1384
+				'FHEE__EE_Config__get_forward',
1385
+				EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1386
+				$route,
1387
+				$status
1388
+			);
1389
+		}
1390
+		return null;
1391
+	}
1392
+
1393
+
1394
+	/**
1395
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1396
+	 *    results
1397
+	 *
1398
+	 * @access    public
1399
+	 * @param    string  $route  - "pretty" public alias for module method
1400
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1401
+	 *                           allows different views to be served based on status
1402
+	 * @param    string  $view
1403
+	 * @param    string  $key    - url param key indicating a route is being called
1404
+	 * @return    bool
1405
+	 */
1406
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1407
+	{
1408
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1409
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1410
+			$msg = sprintf(
1411
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1412
+				$route
1413
+			);
1414
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1415
+			return false;
1416
+		}
1417
+		if (! is_readable($view)) {
1418
+			$msg = sprintf(
1419
+				__(
1420
+					'The %s view file could not be found or is not readable due to file permissions.',
1421
+					'event_espresso'
1422
+				),
1423
+				$view
1424
+			);
1425
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1426
+			return false;
1427
+		}
1428
+		EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1429
+		return true;
1430
+	}
1431
+
1432
+
1433
+	/**
1434
+	 *    get_view - get view for route and status
1435
+	 *
1436
+	 * @access    public
1437
+	 * @param    string  $route  - "pretty" public alias for module method
1438
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1439
+	 *                           allows different views to be served based on status
1440
+	 * @param    string  $key    - url param key indicating a route is being called
1441
+	 * @return    string
1442
+	 */
1443
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1444
+	{
1445
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1446
+		if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1447
+			return apply_filters(
1448
+				'FHEE__EE_Config__get_view',
1449
+				EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1450
+				$route,
1451
+				$status
1452
+			);
1453
+		}
1454
+		return null;
1455
+	}
1456
+
1457
+
1458
+	public function update_addon_option_names()
1459
+	{
1460
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1461
+	}
1462
+
1463
+
1464
+	public function shutdown()
1465
+	{
1466
+		$this->update_addon_option_names();
1467
+	}
1468
+
1469
+
1470
+	/**
1471
+	 * @return LegacyShortcodesManager
1472
+	 */
1473
+	public static function getLegacyShortcodesManager()
1474
+	{
1475
+
1476
+		if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1477
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1478
+				EE_Registry::instance()
1479
+			);
1480
+		}
1481
+		return EE_Config::instance()->legacy_shortcodes_manager;
1482
+	}
1483
+
1484
+
1485
+	/**
1486
+	 * register_shortcode - makes core aware of this shortcode
1487
+	 *
1488
+	 * @deprecated 4.9.26
1489
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1490
+	 * @return    bool
1491
+	 */
1492
+	public static function register_shortcode($shortcode_path = null)
1493
+	{
1494
+		EE_Error::doing_it_wrong(
1495
+			__METHOD__,
1496
+			__(
1497
+				'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1498
+				'event_espresso'
1499
+			),
1500
+			'4.9.26'
1501
+		);
1502
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1503
+	}
1504
+}
2267 1505
 
2268
-    /**
2269
-     * ReCaptcha Type
2270
-     *
2271
-     * @var string $recaptcha_type
2272
-     *    options: 'audio', 'image'
2273
-     */
2274
-    public $recaptcha_type;
1506
+/**
1507
+ * Base class used for config classes. These classes should generally not have
1508
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1509
+ * basically, they should just be well-defined stdClasses
1510
+ */
1511
+class EE_Config_Base
1512
+{
2275 1513
 
2276
-    /**
2277
-     * ReCaptcha language
2278
-     *
2279
-     * @var string $recaptcha_language
2280
-     * eg 'en'
2281
-     */
2282
-    public $recaptcha_language;
1514
+	/**
1515
+	 * Utility function for escaping the value of a property and returning.
1516
+	 *
1517
+	 * @param string $property property name (checks to see if exists).
1518
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1519
+	 * @throws \EE_Error
1520
+	 */
1521
+	public function get_pretty($property)
1522
+	{
1523
+		if (! property_exists($this, $property)) {
1524
+			throw new EE_Error(
1525
+				sprintf(
1526
+					__(
1527
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1528
+						'event_espresso'
1529
+					),
1530
+					get_class($this),
1531
+					$property
1532
+				)
1533
+			);
1534
+		}
1535
+		// just handling escaping of strings for now.
1536
+		if (is_string($this->{$property})) {
1537
+			return stripslashes($this->{$property});
1538
+		}
1539
+		return $this->{$property};
1540
+	}
1541
+
1542
+
1543
+	public function populate()
1544
+	{
1545
+		// grab defaults via a new instance of this class.
1546
+		$class_name = get_class($this);
1547
+		$defaults = new $class_name();
1548
+		// loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1549
+		// default from our $defaults object.
1550
+		foreach (get_object_vars($defaults) as $property => $value) {
1551
+			if ($this->{$property} === null) {
1552
+				$this->{$property} = $value;
1553
+			}
1554
+		}
1555
+		// cleanup
1556
+		unset($defaults);
1557
+	}
1558
+
1559
+
1560
+	/**
1561
+	 *        __isset
1562
+	 *
1563
+	 * @param $a
1564
+	 * @return bool
1565
+	 */
1566
+	public function __isset($a)
1567
+	{
1568
+		return false;
1569
+	}
1570
+
1571
+
1572
+	/**
1573
+	 *        __unset
1574
+	 *
1575
+	 * @param $a
1576
+	 * @return bool
1577
+	 */
1578
+	public function __unset($a)
1579
+	{
1580
+		return false;
1581
+	}
1582
+
1583
+
1584
+	/**
1585
+	 *        __clone
1586
+	 */
1587
+	public function __clone()
1588
+	{
1589
+	}
1590
+
1591
+
1592
+	/**
1593
+	 *        __wakeup
1594
+	 */
1595
+	public function __wakeup()
1596
+	{
1597
+	}
1598
+
1599
+
1600
+	/**
1601
+	 *        __destruct
1602
+	 */
1603
+	public function __destruct()
1604
+	{
1605
+	}
1606
+}
2283 1607
 
2284
-    /**
2285
-     * ReCaptcha public key
2286
-     *
2287
-     * @var string $recaptcha_publickey
2288
-     */
2289
-    public $recaptcha_publickey;
1608
+/**
1609
+ * Class for defining what's in the EE_Config relating to registration settings
1610
+ */
1611
+class EE_Core_Config extends EE_Config_Base
1612
+{
2290 1613
 
2291
-    /**
2292
-     * ReCaptcha private key
2293
-     *
2294
-     * @var string $recaptcha_privatekey
2295
-     */
2296
-    public $recaptcha_privatekey;
1614
+	const OPTION_NAME_UXIP = 'ee_ueip_optin';
1615
+
1616
+
1617
+	public $current_blog_id;
1618
+
1619
+	public $ee_ueip_optin;
1620
+
1621
+	public $ee_ueip_has_notified;
1622
+
1623
+	/**
1624
+	 * Not to be confused with the 4 critical page variables (See
1625
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1626
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1627
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1628
+	 *
1629
+	 * @var array
1630
+	 */
1631
+	public $post_shortcodes;
1632
+
1633
+	public $module_route_map;
1634
+
1635
+	public $module_forward_map;
1636
+
1637
+	public $module_view_map;
1638
+
1639
+	/**
1640
+	 * The next 4 vars are the IDs of critical EE pages.
1641
+	 *
1642
+	 * @var int
1643
+	 */
1644
+	public $reg_page_id;
1645
+
1646
+	public $txn_page_id;
1647
+
1648
+	public $thank_you_page_id;
1649
+
1650
+	public $cancel_page_id;
1651
+
1652
+	/**
1653
+	 * The next 4 vars are the URLs of critical EE pages.
1654
+	 *
1655
+	 * @var int
1656
+	 */
1657
+	public $reg_page_url;
1658
+
1659
+	public $txn_page_url;
1660
+
1661
+	public $thank_you_page_url;
1662
+
1663
+	public $cancel_page_url;
1664
+
1665
+	/**
1666
+	 * The next vars relate to the custom slugs for EE CPT routes
1667
+	 */
1668
+	public $event_cpt_slug;
1669
+
1670
+	/**
1671
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1672
+	 * request across blog switches in a multisite context.
1673
+	 * Avoids extra queries to the db for this option.
1674
+	 *
1675
+	 * @var bool
1676
+	 */
1677
+	public static $ee_ueip_option;
1678
+
1679
+
1680
+	/**
1681
+	 *    class constructor
1682
+	 *
1683
+	 * @access    public
1684
+	 */
1685
+	public function __construct()
1686
+	{
1687
+		// set default organization settings
1688
+		$this->current_blog_id = get_current_blog_id();
1689
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1690
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1691
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1692
+		$this->post_shortcodes = array();
1693
+		$this->module_route_map = array();
1694
+		$this->module_forward_map = array();
1695
+		$this->module_view_map = array();
1696
+		// critical EE page IDs
1697
+		$this->reg_page_id = 0;
1698
+		$this->txn_page_id = 0;
1699
+		$this->thank_you_page_id = 0;
1700
+		$this->cancel_page_id = 0;
1701
+		// critical EE page URLs
1702
+		$this->reg_page_url = '';
1703
+		$this->txn_page_url = '';
1704
+		$this->thank_you_page_url = '';
1705
+		$this->cancel_page_url = '';
1706
+		// cpt slugs
1707
+		$this->event_cpt_slug = __('events', 'event_espresso');
1708
+		// ueip constant check
1709
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1710
+			$this->ee_ueip_optin = false;
1711
+			$this->ee_ueip_has_notified = true;
1712
+		}
1713
+	}
1714
+
1715
+
1716
+	/**
1717
+	 * @return array
1718
+	 */
1719
+	public function get_critical_pages_array()
1720
+	{
1721
+		return array(
1722
+			$this->reg_page_id,
1723
+			$this->txn_page_id,
1724
+			$this->thank_you_page_id,
1725
+			$this->cancel_page_id,
1726
+		);
1727
+	}
1728
+
1729
+
1730
+	/**
1731
+	 * @return array
1732
+	 */
1733
+	public function get_critical_pages_shortcodes_array()
1734
+	{
1735
+		return array(
1736
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1737
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1738
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1739
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1740
+		);
1741
+	}
1742
+
1743
+
1744
+	/**
1745
+	 *  gets/returns URL for EE reg_page
1746
+	 *
1747
+	 * @access    public
1748
+	 * @return    string
1749
+	 */
1750
+	public function reg_page_url()
1751
+	{
1752
+		if (! $this->reg_page_url) {
1753
+			$this->reg_page_url = add_query_arg(
1754
+				array('uts' => time()),
1755
+				get_permalink($this->reg_page_id)
1756
+			) . '#checkout';
1757
+		}
1758
+		return $this->reg_page_url;
1759
+	}
1760
+
1761
+
1762
+	/**
1763
+	 *  gets/returns URL for EE txn_page
1764
+	 *
1765
+	 * @param array $query_args like what gets passed to
1766
+	 *                          add_query_arg() as the first argument
1767
+	 * @access    public
1768
+	 * @return    string
1769
+	 */
1770
+	public function txn_page_url($query_args = array())
1771
+	{
1772
+		if (! $this->txn_page_url) {
1773
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1774
+		}
1775
+		if ($query_args) {
1776
+			return add_query_arg($query_args, $this->txn_page_url);
1777
+		} else {
1778
+			return $this->txn_page_url;
1779
+		}
1780
+	}
1781
+
1782
+
1783
+	/**
1784
+	 *  gets/returns URL for EE thank_you_page
1785
+	 *
1786
+	 * @param array $query_args like what gets passed to
1787
+	 *                          add_query_arg() as the first argument
1788
+	 * @access    public
1789
+	 * @return    string
1790
+	 */
1791
+	public function thank_you_page_url($query_args = array())
1792
+	{
1793
+		if (! $this->thank_you_page_url) {
1794
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1795
+		}
1796
+		if ($query_args) {
1797
+			return add_query_arg($query_args, $this->thank_you_page_url);
1798
+		} else {
1799
+			return $this->thank_you_page_url;
1800
+		}
1801
+	}
1802
+
1803
+
1804
+	/**
1805
+	 *  gets/returns URL for EE cancel_page
1806
+	 *
1807
+	 * @access    public
1808
+	 * @return    string
1809
+	 */
1810
+	public function cancel_page_url()
1811
+	{
1812
+		if (! $this->cancel_page_url) {
1813
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1814
+		}
1815
+		return $this->cancel_page_url;
1816
+	}
1817
+
1818
+
1819
+	/**
1820
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1821
+	 *
1822
+	 * @since 4.7.5
1823
+	 */
1824
+	protected function _reset_urls()
1825
+	{
1826
+		$this->reg_page_url = '';
1827
+		$this->txn_page_url = '';
1828
+		$this->cancel_page_url = '';
1829
+		$this->thank_you_page_url = '';
1830
+	}
1831
+
1832
+
1833
+	/**
1834
+	 * Used to return what the optin value is set for the EE User Experience Program.
1835
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1836
+	 * on the main site only.
1837
+	 *
1838
+	 * @return bool
1839
+	 */
1840
+	protected function _get_main_ee_ueip_optin()
1841
+	{
1842
+		// if this is the main site then we can just bypass our direct query.
1843
+		if (is_main_site()) {
1844
+			return get_option(self::OPTION_NAME_UXIP, false);
1845
+		}
1846
+		// is this already cached for this request?  If so use it.
1847
+		if (EE_Core_Config::$ee_ueip_option !== null) {
1848
+			return EE_Core_Config::$ee_ueip_option;
1849
+		}
1850
+		global $wpdb;
1851
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1852
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1853
+		$option = self::OPTION_NAME_UXIP;
1854
+		// set correct table for query
1855
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1856
+		// rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1857
+		// get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1858
+		// re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1859
+		// this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1860
+		// for the purpose of caching.
1861
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1862
+		if (false !== $pre) {
1863
+			EE_Core_Config::$ee_ueip_option = $pre;
1864
+			return EE_Core_Config::$ee_ueip_option;
1865
+		}
1866
+		$row = $wpdb->get_row(
1867
+			$wpdb->prepare(
1868
+				"SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1869
+				$option
1870
+			)
1871
+		);
1872
+		if (is_object($row)) {
1873
+			$value = $row->option_value;
1874
+		} else { // option does not exist so use default.
1875
+			EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1876
+			return EE_Core_Config::$ee_ueip_option;
1877
+		}
1878
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1879
+		return EE_Core_Config::$ee_ueip_option;
1880
+	}
1881
+
1882
+
1883
+	/**
1884
+	 * Utility function for escaping the value of a property and returning.
1885
+	 *
1886
+	 * @param string $property property name (checks to see if exists).
1887
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1888
+	 * @throws \EE_Error
1889
+	 */
1890
+	public function get_pretty($property)
1891
+	{
1892
+		if ($property === self::OPTION_NAME_UXIP) {
1893
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1894
+		}
1895
+		return parent::get_pretty($property);
1896
+	}
1897
+
1898
+
1899
+	/**
1900
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1901
+	 * on the object.
1902
+	 *
1903
+	 * @return array
1904
+	 */
1905
+	public function __sleep()
1906
+	{
1907
+		// reset all url properties
1908
+		$this->_reset_urls();
1909
+		// return what to save to db
1910
+		return array_keys(get_object_vars($this));
1911
+	}
1912
+}
2297 1913
 
2298
-    /**
2299
-     * array of form names protected by ReCaptcha
2300
-     *
2301
-     * @var array $recaptcha_protected_forms
2302
-     */
2303
-    public $recaptcha_protected_forms;
1914
+/**
1915
+ * Config class for storing info on the Organization
1916
+ */
1917
+class EE_Organization_Config extends EE_Config_Base
1918
+{
2304 1919
 
2305
-    /**
2306
-     * ReCaptcha width
2307
-     *
2308
-     * @var int $recaptcha_width
2309
-     * @deprecated
2310
-     */
2311
-    public $recaptcha_width;
1920
+	/**
1921
+	 * @var string $name
1922
+	 * eg EE4.1
1923
+	 */
1924
+	public $name;
1925
+
1926
+	/**
1927
+	 * @var string $address_1
1928
+	 * eg 123 Onna Road
1929
+	 */
1930
+	public $address_1 = '';
1931
+
1932
+	/**
1933
+	 * @var string $address_2
1934
+	 * eg PO Box 123
1935
+	 */
1936
+	public $address_2 = '';
1937
+
1938
+	/**
1939
+	 * @var string $city
1940
+	 * eg Inna City
1941
+	 */
1942
+	public $city = '';
1943
+
1944
+	/**
1945
+	 * @var int $STA_ID
1946
+	 * eg 4
1947
+	 */
1948
+	public $STA_ID = 0;
1949
+
1950
+	/**
1951
+	 * @var string $CNT_ISO
1952
+	 * eg US
1953
+	 */
1954
+	public $CNT_ISO = '';
1955
+
1956
+	/**
1957
+	 * @var string $zip
1958
+	 * eg 12345  or V1A 2B3
1959
+	 */
1960
+	public $zip = '';
1961
+
1962
+	/**
1963
+	 * @var string $email
1964
+	 * eg [email protected]
1965
+	 */
1966
+	public $email;
1967
+
1968
+	/**
1969
+	 * @var string $phone
1970
+	 * eg. 111-111-1111
1971
+	 */
1972
+	public $phone = '';
1973
+
1974
+	/**
1975
+	 * @var string $vat
1976
+	 * VAT/Tax Number
1977
+	 */
1978
+	public $vat = '';
1979
+
1980
+	/**
1981
+	 * @var string $logo_url
1982
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1983
+	 */
1984
+	public $logo_url = '';
1985
+
1986
+	/**
1987
+	 * The below are all various properties for holding links to organization social network profiles
1988
+	 *
1989
+	 * @var string
1990
+	 */
1991
+	/**
1992
+	 * facebook (facebook.com/profile.name)
1993
+	 *
1994
+	 * @var string
1995
+	 */
1996
+	public $facebook = '';
1997
+
1998
+	/**
1999
+	 * twitter (twitter.com/twitter_handle)
2000
+	 *
2001
+	 * @var string
2002
+	 */
2003
+	public $twitter = '';
2004
+
2005
+	/**
2006
+	 * linkedin (linkedin.com/in/profile_name)
2007
+	 *
2008
+	 * @var string
2009
+	 */
2010
+	public $linkedin = '';
2011
+
2012
+	/**
2013
+	 * pinterest (www.pinterest.com/profile_name)
2014
+	 *
2015
+	 * @var string
2016
+	 */
2017
+	public $pinterest = '';
2018
+
2019
+	/**
2020
+	 * google+ (google.com/+profileName)
2021
+	 *
2022
+	 * @var string
2023
+	 */
2024
+	public $google = '';
2025
+
2026
+	/**
2027
+	 * instagram (instagram.com/handle)
2028
+	 *
2029
+	 * @var string
2030
+	 */
2031
+	public $instagram = '';
2032
+
2033
+
2034
+	/**
2035
+	 *    class constructor
2036
+	 *
2037
+	 * @access    public
2038
+	 */
2039
+	public function __construct()
2040
+	{
2041
+		// set default organization settings
2042
+		// decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2043
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2044
+		$this->email = get_bloginfo('admin_email');
2045
+	}
2046
+}
2312 2047
 
2313
-    /**
2314
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2315
-     *
2316
-     * @var boolean $track_invalid_checkout_access
2317
-     */
2318
-    protected $track_invalid_checkout_access = true;
2048
+/**
2049
+ * Class for defining what's in the EE_Config relating to currency
2050
+ */
2051
+class EE_Currency_Config extends EE_Config_Base
2052
+{
2319 2053
 
2320
-    /**
2321
-     * Whether or not to show the privacy policy consent checkbox
2322
-     *
2323
-     * @var bool
2324
-     */
2325
-    public $consent_checkbox_enabled;
2054
+	/**
2055
+	 * @var string $code
2056
+	 * eg 'US'
2057
+	 */
2058
+	public $code;
2059
+
2060
+	/**
2061
+	 * @var string $name
2062
+	 * eg 'Dollar'
2063
+	 */
2064
+	public $name;
2065
+
2066
+	/**
2067
+	 * plural name
2068
+	 *
2069
+	 * @var string $plural
2070
+	 * eg 'Dollars'
2071
+	 */
2072
+	public $plural;
2073
+
2074
+	/**
2075
+	 * currency sign
2076
+	 *
2077
+	 * @var string $sign
2078
+	 * eg '$'
2079
+	 */
2080
+	public $sign;
2081
+
2082
+	/**
2083
+	 * Whether the currency sign should come before the number or not
2084
+	 *
2085
+	 * @var boolean $sign_b4
2086
+	 */
2087
+	public $sign_b4;
2088
+
2089
+	/**
2090
+	 * How many digits should come after the decimal place
2091
+	 *
2092
+	 * @var int $dec_plc
2093
+	 */
2094
+	public $dec_plc;
2095
+
2096
+	/**
2097
+	 * Symbol to use for decimal mark
2098
+	 *
2099
+	 * @var string $dec_mrk
2100
+	 * eg '.'
2101
+	 */
2102
+	public $dec_mrk;
2103
+
2104
+	/**
2105
+	 * Symbol to use for thousands
2106
+	 *
2107
+	 * @var string $thsnds
2108
+	 * eg ','
2109
+	 */
2110
+	public $thsnds;
2111
+
2112
+
2113
+	/**
2114
+	 *    class constructor
2115
+	 *
2116
+	 * @access    public
2117
+	 * @param string $CNT_ISO
2118
+	 * @throws \EE_Error
2119
+	 */
2120
+	public function __construct($CNT_ISO = '')
2121
+	{
2122
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2123
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2124
+		// get country code from organization settings or use default
2125
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2126
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2127
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2128
+			: '';
2129
+		// but override if requested
2130
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2131
+		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2132
+		if (
2133
+			! empty($CNT_ISO)
2134
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2135
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2136
+		) {
2137
+			// retrieve the country settings from the db, just in case they have been customized
2138
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2139
+			if ($country instanceof EE_Country) {
2140
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2141
+				$this->name = $country->currency_name_single();    // Dollar
2142
+				$this->plural = $country->currency_name_plural();    // Dollars
2143
+				$this->sign = $country->currency_sign();            // currency sign: $
2144
+				$this->sign_b4 = $country->currency_sign_before(
2145
+				);        // currency sign before or after: $TRUE  or  FALSE$
2146
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2147
+				$this->dec_mrk = $country->currency_decimal_mark(
2148
+				);    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2149
+				$this->thsnds = $country->currency_thousands_separator(
2150
+				);    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2151
+			}
2152
+		}
2153
+		// fallback to hardcoded defaults, in case the above failed
2154
+		if (empty($this->code)) {
2155
+			// set default currency settings
2156
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2157
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2158
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2159
+			$this->sign = '$';    // currency sign: $
2160
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2161
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2162
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2163
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2164
+		}
2165
+	}
2166
+}
2326 2167
 
2327
-    /**
2328
-     * Label text to show on the checkbox
2329
-     *
2330
-     * @var string
2331
-     */
2332
-    public $consent_checkbox_label_text;
2168
+/**
2169
+ * Class for defining what's in the EE_Config relating to registration settings
2170
+ */
2171
+class EE_Registration_Config extends EE_Config_Base
2172
+{
2333 2173
 
2334
-    /*
2174
+	/**
2175
+	 * Default registration status
2176
+	 *
2177
+	 * @var string $default_STS_ID
2178
+	 * eg 'RPP'
2179
+	 */
2180
+	public $default_STS_ID;
2181
+
2182
+	/**
2183
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2184
+	 * registrations)
2185
+	 *
2186
+	 * @var int
2187
+	 */
2188
+	public $default_maximum_number_of_tickets;
2189
+
2190
+	/**
2191
+	 * level of validation to apply to email addresses
2192
+	 *
2193
+	 * @var string $email_validation_level
2194
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2195
+	 */
2196
+	public $email_validation_level;
2197
+
2198
+	/**
2199
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2200
+	 *
2201
+	 * @var boolean $show_pending_payment_options
2202
+	 */
2203
+	public $show_pending_payment_options;
2204
+
2205
+	/**
2206
+	 * Whether to skip the registration confirmation page
2207
+	 *
2208
+	 * @var boolean $skip_reg_confirmation
2209
+	 */
2210
+	public $skip_reg_confirmation;
2211
+
2212
+	/**
2213
+	 * an array of SPCO reg steps where:
2214
+	 *        the keys denotes the reg step order
2215
+	 *        each element consists of an array with the following elements:
2216
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2217
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2218
+	 *            "slug" => the URL param used to trigger the reg step
2219
+	 *
2220
+	 * @var array $reg_steps
2221
+	 */
2222
+	public $reg_steps;
2223
+
2224
+	/**
2225
+	 * Whether registration confirmation should be the last page of SPCO
2226
+	 *
2227
+	 * @var boolean $reg_confirmation_last
2228
+	 */
2229
+	public $reg_confirmation_last;
2230
+
2231
+	/**
2232
+	 * Whether or not to enable the EE Bot Trap
2233
+	 *
2234
+	 * @var boolean $use_bot_trap
2235
+	 */
2236
+	public $use_bot_trap;
2237
+
2238
+	/**
2239
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2240
+	 *
2241
+	 * @var boolean $use_encryption
2242
+	 */
2243
+	public $use_encryption;
2244
+
2245
+	/**
2246
+	 * Whether or not to use ReCaptcha
2247
+	 *
2248
+	 * @var boolean $use_captcha
2249
+	 */
2250
+	public $use_captcha;
2251
+
2252
+	/**
2253
+	 * ReCaptcha Theme
2254
+	 *
2255
+	 * @var string $recaptcha_theme
2256
+	 *    options: 'dark', 'light', 'invisible'
2257
+	 */
2258
+	public $recaptcha_theme;
2259
+
2260
+	/**
2261
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2262
+	 *
2263
+	 * @var string $recaptcha_badge
2264
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2265
+	 */
2266
+	public $recaptcha_badge;
2267
+
2268
+	/**
2269
+	 * ReCaptcha Type
2270
+	 *
2271
+	 * @var string $recaptcha_type
2272
+	 *    options: 'audio', 'image'
2273
+	 */
2274
+	public $recaptcha_type;
2275
+
2276
+	/**
2277
+	 * ReCaptcha language
2278
+	 *
2279
+	 * @var string $recaptcha_language
2280
+	 * eg 'en'
2281
+	 */
2282
+	public $recaptcha_language;
2283
+
2284
+	/**
2285
+	 * ReCaptcha public key
2286
+	 *
2287
+	 * @var string $recaptcha_publickey
2288
+	 */
2289
+	public $recaptcha_publickey;
2290
+
2291
+	/**
2292
+	 * ReCaptcha private key
2293
+	 *
2294
+	 * @var string $recaptcha_privatekey
2295
+	 */
2296
+	public $recaptcha_privatekey;
2297
+
2298
+	/**
2299
+	 * array of form names protected by ReCaptcha
2300
+	 *
2301
+	 * @var array $recaptcha_protected_forms
2302
+	 */
2303
+	public $recaptcha_protected_forms;
2304
+
2305
+	/**
2306
+	 * ReCaptcha width
2307
+	 *
2308
+	 * @var int $recaptcha_width
2309
+	 * @deprecated
2310
+	 */
2311
+	public $recaptcha_width;
2312
+
2313
+	/**
2314
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2315
+	 *
2316
+	 * @var boolean $track_invalid_checkout_access
2317
+	 */
2318
+	protected $track_invalid_checkout_access = true;
2319
+
2320
+	/**
2321
+	 * Whether or not to show the privacy policy consent checkbox
2322
+	 *
2323
+	 * @var bool
2324
+	 */
2325
+	public $consent_checkbox_enabled;
2326
+
2327
+	/**
2328
+	 * Label text to show on the checkbox
2329
+	 *
2330
+	 * @var string
2331
+	 */
2332
+	public $consent_checkbox_label_text;
2333
+
2334
+	/*
2335 2335
      * String describing how long to keep payment logs. Passed into DateTime constructor
2336 2336
      * @var string
2337 2337
      */
2338
-    public $gateway_log_lifespan = '1 week';
2339
-
2340
-    /**
2341
-     * Enable copy attendee info at form
2342
-     *
2343
-     * @var boolean $enable_copy_attendee
2344
-     */
2345
-    protected $copy_attendee_info = true;
2346
-
2347
-
2348
-    /**
2349
-     *    class constructor
2350
-     *
2351
-     * @access    public
2352
-     */
2353
-    public function __construct()
2354
-    {
2355
-        // set default registration settings
2356
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2357
-        $this->email_validation_level = 'wp_default';
2358
-        $this->show_pending_payment_options = true;
2359
-        $this->skip_reg_confirmation = true;
2360
-        $this->reg_steps = array();
2361
-        $this->reg_confirmation_last = false;
2362
-        $this->use_bot_trap = true;
2363
-        $this->use_encryption = true;
2364
-        $this->use_captcha = false;
2365
-        $this->recaptcha_theme = 'light';
2366
-        $this->recaptcha_badge = 'bottomleft';
2367
-        $this->recaptcha_type = 'image';
2368
-        $this->recaptcha_language = 'en';
2369
-        $this->recaptcha_publickey = null;
2370
-        $this->recaptcha_privatekey = null;
2371
-        $this->recaptcha_protected_forms = array();
2372
-        $this->recaptcha_width = 500;
2373
-        $this->default_maximum_number_of_tickets = 10;
2374
-        $this->consent_checkbox_enabled = false;
2375
-        $this->consent_checkbox_label_text = '';
2376
-        $this->gateway_log_lifespan = '7 days';
2377
-        $this->copy_attendee_info = true;
2378
-    }
2379
-
2380
-
2381
-    /**
2382
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2383
-     *
2384
-     * @since 4.8.8.rc.019
2385
-     */
2386
-    public function do_hooks()
2387
-    {
2388
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2389
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2390
-        add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2391
-    }
2392
-
2393
-
2394
-    /**
2395
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2396
-     * EVT_default_registration_status field matches the config setting for default_STS_ID.
2397
-     */
2398
-    public function set_default_reg_status_on_EEM_Event()
2399
-    {
2400
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2401
-    }
2402
-
2403
-
2404
-    /**
2405
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2406
-     * for Events matches the config setting for default_maximum_number_of_tickets
2407
-     */
2408
-    public function set_default_max_ticket_on_EEM_Event()
2409
-    {
2410
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2411
-    }
2412
-
2413
-
2414
-    /**
2415
-     * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2416
-     * constructed because that happens before we can get the privacy policy page's permalink.
2417
-     *
2418
-     * @throws InvalidArgumentException
2419
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2420
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2421
-     */
2422
-    public function setDefaultCheckboxLabelText()
2423
-    {
2424
-        if (
2425
-            $this->getConsentCheckboxLabelText() === null
2426
-            || $this->getConsentCheckboxLabelText() === ''
2427
-        ) {
2428
-            $opening_a_tag = '';
2429
-            $closing_a_tag = '';
2430
-            if (function_exists('get_privacy_policy_url')) {
2431
-                $privacy_page_url = get_privacy_policy_url();
2432
-                if (! empty($privacy_page_url)) {
2433
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2434
-                    $closing_a_tag = '</a>';
2435
-                }
2436
-            }
2437
-            $loader = LoaderFactory::getLoader();
2438
-            $org_config = $loader->getShared('EE_Organization_Config');
2439
-            /**
2440
-             * @var $org_config EE_Organization_Config
2441
-             */
2442
-
2443
-            $this->setConsentCheckboxLabelText(
2444
-                sprintf(
2445
-                    esc_html__(
2446
-                        'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2447
-                        'event_espresso'
2448
-                    ),
2449
-                    $org_config->name,
2450
-                    $opening_a_tag,
2451
-                    $closing_a_tag
2452
-                )
2453
-            );
2454
-        }
2455
-    }
2456
-
2457
-
2458
-    /**
2459
-     * @return boolean
2460
-     */
2461
-    public function track_invalid_checkout_access()
2462
-    {
2463
-        return $this->track_invalid_checkout_access;
2464
-    }
2465
-
2466
-
2467
-    /**
2468
-     * @param boolean $track_invalid_checkout_access
2469
-     */
2470
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2471
-    {
2472
-        $this->track_invalid_checkout_access = filter_var(
2473
-            $track_invalid_checkout_access,
2474
-            FILTER_VALIDATE_BOOLEAN
2475
-        );
2476
-    }
2477
-
2478
-    /**
2479
-     * @return boolean
2480
-     */
2481
-    public function copyAttendeeInfo()
2482
-    {
2483
-        return $this->copy_attendee_info;
2484
-    }
2485
-
2486
-
2487
-    /**
2488
-     * @param boolean $copy_attendee_info
2489
-     */
2490
-    public function setCopyAttendeeInfo($copy_attendee_info)
2491
-    {
2492
-        $this->copy_attendee_info = filter_var(
2493
-            $copy_attendee_info,
2494
-            FILTER_VALIDATE_BOOLEAN
2495
-        );
2496
-    }
2497
-
2498
-
2499
-    /**
2500
-     * Gets the options to make availalbe for the gateway log lifespan
2501
-     * @return array
2502
-     */
2503
-    public function gatewayLogLifespanOptions()
2504
-    {
2505
-        return (array) apply_filters(
2506
-            'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2507
-            array(
2508
-                '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2509
-                '1 day' => esc_html__('1 Day', 'event_espresso'),
2510
-                '7 days' => esc_html__('7 Days', 'event_espresso'),
2511
-                '14 days' => esc_html__('14 Days', 'event_espresso'),
2512
-                '30 days' => esc_html__('30 Days', 'event_espresso')
2513
-            )
2514
-        );
2515
-    }
2516
-
2517
-
2518
-    /**
2519
-     * @return bool
2520
-     */
2521
-    public function isConsentCheckboxEnabled()
2522
-    {
2523
-        return $this->consent_checkbox_enabled;
2524
-    }
2525
-
2526
-
2527
-    /**
2528
-     * @param bool $consent_checkbox_enabled
2529
-     */
2530
-    public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2531
-    {
2532
-        $this->consent_checkbox_enabled = filter_var(
2533
-            $consent_checkbox_enabled,
2534
-            FILTER_VALIDATE_BOOLEAN
2535
-        );
2536
-    }
2537
-
2538
-
2539
-    /**
2540
-     * @return string
2541
-     */
2542
-    public function getConsentCheckboxLabelText()
2543
-    {
2544
-        return $this->consent_checkbox_label_text;
2545
-    }
2546
-
2547
-
2548
-    /**
2549
-     * @param string $consent_checkbox_label_text
2550
-     */
2551
-    public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2552
-    {
2553
-        $this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2554
-    }
2338
+	public $gateway_log_lifespan = '1 week';
2339
+
2340
+	/**
2341
+	 * Enable copy attendee info at form
2342
+	 *
2343
+	 * @var boolean $enable_copy_attendee
2344
+	 */
2345
+	protected $copy_attendee_info = true;
2346
+
2347
+
2348
+	/**
2349
+	 *    class constructor
2350
+	 *
2351
+	 * @access    public
2352
+	 */
2353
+	public function __construct()
2354
+	{
2355
+		// set default registration settings
2356
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2357
+		$this->email_validation_level = 'wp_default';
2358
+		$this->show_pending_payment_options = true;
2359
+		$this->skip_reg_confirmation = true;
2360
+		$this->reg_steps = array();
2361
+		$this->reg_confirmation_last = false;
2362
+		$this->use_bot_trap = true;
2363
+		$this->use_encryption = true;
2364
+		$this->use_captcha = false;
2365
+		$this->recaptcha_theme = 'light';
2366
+		$this->recaptcha_badge = 'bottomleft';
2367
+		$this->recaptcha_type = 'image';
2368
+		$this->recaptcha_language = 'en';
2369
+		$this->recaptcha_publickey = null;
2370
+		$this->recaptcha_privatekey = null;
2371
+		$this->recaptcha_protected_forms = array();
2372
+		$this->recaptcha_width = 500;
2373
+		$this->default_maximum_number_of_tickets = 10;
2374
+		$this->consent_checkbox_enabled = false;
2375
+		$this->consent_checkbox_label_text = '';
2376
+		$this->gateway_log_lifespan = '7 days';
2377
+		$this->copy_attendee_info = true;
2378
+	}
2379
+
2380
+
2381
+	/**
2382
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2383
+	 *
2384
+	 * @since 4.8.8.rc.019
2385
+	 */
2386
+	public function do_hooks()
2387
+	{
2388
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2389
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2390
+		add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2391
+	}
2392
+
2393
+
2394
+	/**
2395
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2396
+	 * EVT_default_registration_status field matches the config setting for default_STS_ID.
2397
+	 */
2398
+	public function set_default_reg_status_on_EEM_Event()
2399
+	{
2400
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2401
+	}
2402
+
2403
+
2404
+	/**
2405
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2406
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2407
+	 */
2408
+	public function set_default_max_ticket_on_EEM_Event()
2409
+	{
2410
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2411
+	}
2412
+
2413
+
2414
+	/**
2415
+	 * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2416
+	 * constructed because that happens before we can get the privacy policy page's permalink.
2417
+	 *
2418
+	 * @throws InvalidArgumentException
2419
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2420
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2421
+	 */
2422
+	public function setDefaultCheckboxLabelText()
2423
+	{
2424
+		if (
2425
+			$this->getConsentCheckboxLabelText() === null
2426
+			|| $this->getConsentCheckboxLabelText() === ''
2427
+		) {
2428
+			$opening_a_tag = '';
2429
+			$closing_a_tag = '';
2430
+			if (function_exists('get_privacy_policy_url')) {
2431
+				$privacy_page_url = get_privacy_policy_url();
2432
+				if (! empty($privacy_page_url)) {
2433
+					$opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2434
+					$closing_a_tag = '</a>';
2435
+				}
2436
+			}
2437
+			$loader = LoaderFactory::getLoader();
2438
+			$org_config = $loader->getShared('EE_Organization_Config');
2439
+			/**
2440
+			 * @var $org_config EE_Organization_Config
2441
+			 */
2442
+
2443
+			$this->setConsentCheckboxLabelText(
2444
+				sprintf(
2445
+					esc_html__(
2446
+						'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2447
+						'event_espresso'
2448
+					),
2449
+					$org_config->name,
2450
+					$opening_a_tag,
2451
+					$closing_a_tag
2452
+				)
2453
+			);
2454
+		}
2455
+	}
2456
+
2457
+
2458
+	/**
2459
+	 * @return boolean
2460
+	 */
2461
+	public function track_invalid_checkout_access()
2462
+	{
2463
+		return $this->track_invalid_checkout_access;
2464
+	}
2465
+
2466
+
2467
+	/**
2468
+	 * @param boolean $track_invalid_checkout_access
2469
+	 */
2470
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2471
+	{
2472
+		$this->track_invalid_checkout_access = filter_var(
2473
+			$track_invalid_checkout_access,
2474
+			FILTER_VALIDATE_BOOLEAN
2475
+		);
2476
+	}
2477
+
2478
+	/**
2479
+	 * @return boolean
2480
+	 */
2481
+	public function copyAttendeeInfo()
2482
+	{
2483
+		return $this->copy_attendee_info;
2484
+	}
2485
+
2486
+
2487
+	/**
2488
+	 * @param boolean $copy_attendee_info
2489
+	 */
2490
+	public function setCopyAttendeeInfo($copy_attendee_info)
2491
+	{
2492
+		$this->copy_attendee_info = filter_var(
2493
+			$copy_attendee_info,
2494
+			FILTER_VALIDATE_BOOLEAN
2495
+		);
2496
+	}
2497
+
2498
+
2499
+	/**
2500
+	 * Gets the options to make availalbe for the gateway log lifespan
2501
+	 * @return array
2502
+	 */
2503
+	public function gatewayLogLifespanOptions()
2504
+	{
2505
+		return (array) apply_filters(
2506
+			'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2507
+			array(
2508
+				'1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2509
+				'1 day' => esc_html__('1 Day', 'event_espresso'),
2510
+				'7 days' => esc_html__('7 Days', 'event_espresso'),
2511
+				'14 days' => esc_html__('14 Days', 'event_espresso'),
2512
+				'30 days' => esc_html__('30 Days', 'event_espresso')
2513
+			)
2514
+		);
2515
+	}
2516
+
2517
+
2518
+	/**
2519
+	 * @return bool
2520
+	 */
2521
+	public function isConsentCheckboxEnabled()
2522
+	{
2523
+		return $this->consent_checkbox_enabled;
2524
+	}
2525
+
2526
+
2527
+	/**
2528
+	 * @param bool $consent_checkbox_enabled
2529
+	 */
2530
+	public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2531
+	{
2532
+		$this->consent_checkbox_enabled = filter_var(
2533
+			$consent_checkbox_enabled,
2534
+			FILTER_VALIDATE_BOOLEAN
2535
+		);
2536
+	}
2537
+
2538
+
2539
+	/**
2540
+	 * @return string
2541
+	 */
2542
+	public function getConsentCheckboxLabelText()
2543
+	{
2544
+		return $this->consent_checkbox_label_text;
2545
+	}
2546
+
2547
+
2548
+	/**
2549
+	 * @param string $consent_checkbox_label_text
2550
+	 */
2551
+	public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2552
+	{
2553
+		$this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2554
+	}
2555 2555
 }
2556 2556
 
2557 2557
 /**
@@ -2560,180 +2560,180 @@  discard block
 block discarded – undo
2560 2560
 class EE_Admin_Config extends EE_Config_Base
2561 2561
 {
2562 2562
 
2563
-    /**
2564
-     * @var boolean $useAdvancedEditor
2565
-     */
2566
-    private $useAdvancedEditor;
2567
-
2568
-    /**
2569
-     * @var boolean $use_personnel_manager
2570
-     */
2571
-    public $use_personnel_manager;
2572
-
2573
-    /**
2574
-     * @var boolean $use_dashboard_widget
2575
-     */
2576
-    public $use_dashboard_widget;
2577
-
2578
-    /**
2579
-     * @var int $events_in_dashboard
2580
-     */
2581
-    public $events_in_dashboard;
2582
-
2583
-    /**
2584
-     * @var boolean $use_event_timezones
2585
-     */
2586
-    public $use_event_timezones;
2587
-
2588
-    /**
2589
-     * @var string $log_file_name
2590
-     */
2591
-    public $log_file_name;
2592
-
2593
-    /**
2594
-     * @var string $debug_file_name
2595
-     */
2596
-    public $debug_file_name;
2597
-
2598
-    /**
2599
-     * @var boolean $use_remote_logging
2600
-     */
2601
-    public $use_remote_logging;
2602
-
2603
-    /**
2604
-     * @var string $remote_logging_url
2605
-     */
2606
-    public $remote_logging_url;
2607
-
2608
-    /**
2609
-     * @var boolean $show_reg_footer
2610
-     */
2611
-    public $show_reg_footer;
2612
-
2613
-    /**
2614
-     * @var string $affiliate_id
2615
-     */
2616
-    public $affiliate_id;
2617
-
2618
-    /**
2619
-     * help tours on or off (global setting)
2620
-     *
2621
-     * @var boolean
2622
-     */
2623
-    public $help_tour_activation;
2624
-
2625
-    /**
2626
-     * adds extra layer of encoding to session data to prevent serialization errors
2627
-     * but is incompatible with some server configuration errors
2628
-     * if you get "500 internal server errors" during registration, try turning this on
2629
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2630
-     *
2631
-     * @var boolean $encode_session_data
2632
-     */
2633
-    private $encode_session_data = false;
2634
-
2635
-
2636
-    /**
2637
-     *    class constructor
2638
-     *
2639
-     * @access    public
2640
-     */
2641
-    public function __construct()
2642
-    {
2643
-        // set default general admin settings
2644
-        $this->useAdvancedEditor = true;
2645
-        $this->use_personnel_manager = true;
2646
-        $this->use_dashboard_widget = true;
2647
-        $this->events_in_dashboard = 30;
2648
-        $this->use_event_timezones = false;
2649
-        $this->use_remote_logging = false;
2650
-        $this->remote_logging_url = null;
2651
-        $this->show_reg_footer = apply_filters(
2652
-            'FHEE__EE_Admin_Config__show_reg_footer__default',
2653
-            false
2654
-        );
2655
-        $this->affiliate_id = 'default';
2656
-        $this->help_tour_activation = false;
2657
-        $this->encode_session_data = false;
2658
-    }
2659
-
2660
-
2661
-    /**
2662
-     * @param bool $reset
2663
-     * @return string
2664
-     */
2665
-    public function log_file_name($reset = false)
2666
-    {
2667
-        if (empty($this->log_file_name) || $reset) {
2668
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2669
-            EE_Config::instance()->update_espresso_config(false, false);
2670
-        }
2671
-        return $this->log_file_name;
2672
-    }
2673
-
2674
-
2675
-    /**
2676
-     * @param bool $reset
2677
-     * @return string
2678
-     */
2679
-    public function debug_file_name($reset = false)
2680
-    {
2681
-        if (empty($this->debug_file_name) || $reset) {
2682
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2683
-            EE_Config::instance()->update_espresso_config(false, false);
2684
-        }
2685
-        return $this->debug_file_name;
2686
-    }
2687
-
2688
-
2689
-    /**
2690
-     * @return string
2691
-     */
2692
-    public function affiliate_id()
2693
-    {
2694
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2695
-    }
2696
-
2697
-
2698
-    /**
2699
-     * @return boolean
2700
-     */
2701
-    public function encode_session_data()
2702
-    {
2703
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2704
-    }
2705
-
2706
-
2707
-    /**
2708
-     * @param boolean $encode_session_data
2709
-     */
2710
-    public function set_encode_session_data($encode_session_data)
2711
-    {
2712
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2713
-    }
2714
-
2715
-    /**
2716
-     * @return boolean
2717
-     */
2718
-    public function useAdvancedEditor()
2719
-    {
2720
-        $domain = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\Domain');
2721
-        return $this->useAdvancedEditor && $domain->isCaffeinated();
2722
-    }
2723
-
2724
-    /**
2725
-     * @param boolean $use_advanced_editor
2726
-     */
2727
-    public function setUseAdvancedEditor($use_advanced_editor = true)
2728
-    {
2729
-        $this->useAdvancedEditor = filter_var(
2730
-            apply_filters(
2731
-                'FHEE__EE_Admin_Config__setUseAdvancedEditor__use_advanced_editor',
2732
-                $use_advanced_editor
2733
-            ),
2734
-            FILTER_VALIDATE_BOOLEAN
2735
-        );
2736
-    }
2563
+	/**
2564
+	 * @var boolean $useAdvancedEditor
2565
+	 */
2566
+	private $useAdvancedEditor;
2567
+
2568
+	/**
2569
+	 * @var boolean $use_personnel_manager
2570
+	 */
2571
+	public $use_personnel_manager;
2572
+
2573
+	/**
2574
+	 * @var boolean $use_dashboard_widget
2575
+	 */
2576
+	public $use_dashboard_widget;
2577
+
2578
+	/**
2579
+	 * @var int $events_in_dashboard
2580
+	 */
2581
+	public $events_in_dashboard;
2582
+
2583
+	/**
2584
+	 * @var boolean $use_event_timezones
2585
+	 */
2586
+	public $use_event_timezones;
2587
+
2588
+	/**
2589
+	 * @var string $log_file_name
2590
+	 */
2591
+	public $log_file_name;
2592
+
2593
+	/**
2594
+	 * @var string $debug_file_name
2595
+	 */
2596
+	public $debug_file_name;
2597
+
2598
+	/**
2599
+	 * @var boolean $use_remote_logging
2600
+	 */
2601
+	public $use_remote_logging;
2602
+
2603
+	/**
2604
+	 * @var string $remote_logging_url
2605
+	 */
2606
+	public $remote_logging_url;
2607
+
2608
+	/**
2609
+	 * @var boolean $show_reg_footer
2610
+	 */
2611
+	public $show_reg_footer;
2612
+
2613
+	/**
2614
+	 * @var string $affiliate_id
2615
+	 */
2616
+	public $affiliate_id;
2617
+
2618
+	/**
2619
+	 * help tours on or off (global setting)
2620
+	 *
2621
+	 * @var boolean
2622
+	 */
2623
+	public $help_tour_activation;
2624
+
2625
+	/**
2626
+	 * adds extra layer of encoding to session data to prevent serialization errors
2627
+	 * but is incompatible with some server configuration errors
2628
+	 * if you get "500 internal server errors" during registration, try turning this on
2629
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2630
+	 *
2631
+	 * @var boolean $encode_session_data
2632
+	 */
2633
+	private $encode_session_data = false;
2634
+
2635
+
2636
+	/**
2637
+	 *    class constructor
2638
+	 *
2639
+	 * @access    public
2640
+	 */
2641
+	public function __construct()
2642
+	{
2643
+		// set default general admin settings
2644
+		$this->useAdvancedEditor = true;
2645
+		$this->use_personnel_manager = true;
2646
+		$this->use_dashboard_widget = true;
2647
+		$this->events_in_dashboard = 30;
2648
+		$this->use_event_timezones = false;
2649
+		$this->use_remote_logging = false;
2650
+		$this->remote_logging_url = null;
2651
+		$this->show_reg_footer = apply_filters(
2652
+			'FHEE__EE_Admin_Config__show_reg_footer__default',
2653
+			false
2654
+		);
2655
+		$this->affiliate_id = 'default';
2656
+		$this->help_tour_activation = false;
2657
+		$this->encode_session_data = false;
2658
+	}
2659
+
2660
+
2661
+	/**
2662
+	 * @param bool $reset
2663
+	 * @return string
2664
+	 */
2665
+	public function log_file_name($reset = false)
2666
+	{
2667
+		if (empty($this->log_file_name) || $reset) {
2668
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2669
+			EE_Config::instance()->update_espresso_config(false, false);
2670
+		}
2671
+		return $this->log_file_name;
2672
+	}
2673
+
2674
+
2675
+	/**
2676
+	 * @param bool $reset
2677
+	 * @return string
2678
+	 */
2679
+	public function debug_file_name($reset = false)
2680
+	{
2681
+		if (empty($this->debug_file_name) || $reset) {
2682
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2683
+			EE_Config::instance()->update_espresso_config(false, false);
2684
+		}
2685
+		return $this->debug_file_name;
2686
+	}
2687
+
2688
+
2689
+	/**
2690
+	 * @return string
2691
+	 */
2692
+	public function affiliate_id()
2693
+	{
2694
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2695
+	}
2696
+
2697
+
2698
+	/**
2699
+	 * @return boolean
2700
+	 */
2701
+	public function encode_session_data()
2702
+	{
2703
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2704
+	}
2705
+
2706
+
2707
+	/**
2708
+	 * @param boolean $encode_session_data
2709
+	 */
2710
+	public function set_encode_session_data($encode_session_data)
2711
+	{
2712
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2713
+	}
2714
+
2715
+	/**
2716
+	 * @return boolean
2717
+	 */
2718
+	public function useAdvancedEditor()
2719
+	{
2720
+		$domain = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\Domain');
2721
+		return $this->useAdvancedEditor && $domain->isCaffeinated();
2722
+	}
2723
+
2724
+	/**
2725
+	 * @param boolean $use_advanced_editor
2726
+	 */
2727
+	public function setUseAdvancedEditor($use_advanced_editor = true)
2728
+	{
2729
+		$this->useAdvancedEditor = filter_var(
2730
+			apply_filters(
2731
+				'FHEE__EE_Admin_Config__setUseAdvancedEditor__use_advanced_editor',
2732
+				$use_advanced_editor
2733
+			),
2734
+			FILTER_VALIDATE_BOOLEAN
2735
+		);
2736
+	}
2737 2737
 }
2738 2738
 
2739 2739
 /**
@@ -2742,70 +2742,70 @@  discard block
 block discarded – undo
2742 2742
 class EE_Template_Config extends EE_Config_Base
2743 2743
 {
2744 2744
 
2745
-    /**
2746
-     * @var boolean $enable_default_style
2747
-     */
2748
-    public $enable_default_style;
2749
-
2750
-    /**
2751
-     * @var string $custom_style_sheet
2752
-     */
2753
-    public $custom_style_sheet;
2754
-
2755
-    /**
2756
-     * @var boolean $display_address_in_regform
2757
-     */
2758
-    public $display_address_in_regform;
2759
-
2760
-    /**
2761
-     * @var int $display_description_on_multi_reg_page
2762
-     */
2763
-    public $display_description_on_multi_reg_page;
2764
-
2765
-    /**
2766
-     * @var boolean $use_custom_templates
2767
-     */
2768
-    public $use_custom_templates;
2769
-
2770
-    /**
2771
-     * @var string $current_espresso_theme
2772
-     */
2773
-    public $current_espresso_theme;
2774
-
2775
-    /**
2776
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2777
-     */
2778
-    public $EED_Ticket_Selector;
2779
-
2780
-    /**
2781
-     * @var EE_Event_Single_Config $EED_Event_Single
2782
-     */
2783
-    public $EED_Event_Single;
2784
-
2785
-    /**
2786
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2787
-     */
2788
-    public $EED_Events_Archive;
2789
-
2790
-
2791
-    /**
2792
-     *    class constructor
2793
-     *
2794
-     * @access    public
2795
-     */
2796
-    public function __construct()
2797
-    {
2798
-        // set default template settings
2799
-        $this->enable_default_style = true;
2800
-        $this->custom_style_sheet = null;
2801
-        $this->display_address_in_regform = true;
2802
-        $this->display_description_on_multi_reg_page = false;
2803
-        $this->use_custom_templates = false;
2804
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2805
-        $this->EED_Event_Single = null;
2806
-        $this->EED_Events_Archive = null;
2807
-        $this->EED_Ticket_Selector = null;
2808
-    }
2745
+	/**
2746
+	 * @var boolean $enable_default_style
2747
+	 */
2748
+	public $enable_default_style;
2749
+
2750
+	/**
2751
+	 * @var string $custom_style_sheet
2752
+	 */
2753
+	public $custom_style_sheet;
2754
+
2755
+	/**
2756
+	 * @var boolean $display_address_in_regform
2757
+	 */
2758
+	public $display_address_in_regform;
2759
+
2760
+	/**
2761
+	 * @var int $display_description_on_multi_reg_page
2762
+	 */
2763
+	public $display_description_on_multi_reg_page;
2764
+
2765
+	/**
2766
+	 * @var boolean $use_custom_templates
2767
+	 */
2768
+	public $use_custom_templates;
2769
+
2770
+	/**
2771
+	 * @var string $current_espresso_theme
2772
+	 */
2773
+	public $current_espresso_theme;
2774
+
2775
+	/**
2776
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2777
+	 */
2778
+	public $EED_Ticket_Selector;
2779
+
2780
+	/**
2781
+	 * @var EE_Event_Single_Config $EED_Event_Single
2782
+	 */
2783
+	public $EED_Event_Single;
2784
+
2785
+	/**
2786
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2787
+	 */
2788
+	public $EED_Events_Archive;
2789
+
2790
+
2791
+	/**
2792
+	 *    class constructor
2793
+	 *
2794
+	 * @access    public
2795
+	 */
2796
+	public function __construct()
2797
+	{
2798
+		// set default template settings
2799
+		$this->enable_default_style = true;
2800
+		$this->custom_style_sheet = null;
2801
+		$this->display_address_in_regform = true;
2802
+		$this->display_description_on_multi_reg_page = false;
2803
+		$this->use_custom_templates = false;
2804
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2805
+		$this->EED_Event_Single = null;
2806
+		$this->EED_Events_Archive = null;
2807
+		$this->EED_Ticket_Selector = null;
2808
+	}
2809 2809
 }
2810 2810
 
2811 2811
 /**
@@ -2814,114 +2814,114 @@  discard block
 block discarded – undo
2814 2814
 class EE_Map_Config extends EE_Config_Base
2815 2815
 {
2816 2816
 
2817
-    /**
2818
-     * @var boolean $use_google_maps
2819
-     */
2820
-    public $use_google_maps;
2821
-
2822
-    /**
2823
-     * @var string $api_key
2824
-     */
2825
-    public $google_map_api_key;
2826
-
2827
-    /**
2828
-     * @var int $event_details_map_width
2829
-     */
2830
-    public $event_details_map_width;
2831
-
2832
-    /**
2833
-     * @var int $event_details_map_height
2834
-     */
2835
-    public $event_details_map_height;
2836
-
2837
-    /**
2838
-     * @var int $event_details_map_zoom
2839
-     */
2840
-    public $event_details_map_zoom;
2841
-
2842
-    /**
2843
-     * @var boolean $event_details_display_nav
2844
-     */
2845
-    public $event_details_display_nav;
2846
-
2847
-    /**
2848
-     * @var boolean $event_details_nav_size
2849
-     */
2850
-    public $event_details_nav_size;
2851
-
2852
-    /**
2853
-     * @var string $event_details_control_type
2854
-     */
2855
-    public $event_details_control_type;
2856
-
2857
-    /**
2858
-     * @var string $event_details_map_align
2859
-     */
2860
-    public $event_details_map_align;
2861
-
2862
-    /**
2863
-     * @var int $event_list_map_width
2864
-     */
2865
-    public $event_list_map_width;
2866
-
2867
-    /**
2868
-     * @var int $event_list_map_height
2869
-     */
2870
-    public $event_list_map_height;
2871
-
2872
-    /**
2873
-     * @var int $event_list_map_zoom
2874
-     */
2875
-    public $event_list_map_zoom;
2876
-
2877
-    /**
2878
-     * @var boolean $event_list_display_nav
2879
-     */
2880
-    public $event_list_display_nav;
2881
-
2882
-    /**
2883
-     * @var boolean $event_list_nav_size
2884
-     */
2885
-    public $event_list_nav_size;
2886
-
2887
-    /**
2888
-     * @var string $event_list_control_type
2889
-     */
2890
-    public $event_list_control_type;
2891
-
2892
-    /**
2893
-     * @var string $event_list_map_align
2894
-     */
2895
-    public $event_list_map_align;
2896
-
2897
-
2898
-    /**
2899
-     *    class constructor
2900
-     *
2901
-     * @access    public
2902
-     */
2903
-    public function __construct()
2904
-    {
2905
-        // set default map settings
2906
-        $this->use_google_maps = true;
2907
-        $this->google_map_api_key = '';
2908
-        // for event details pages (reg page)
2909
-        $this->event_details_map_width = 585;            // ee_map_width_single
2910
-        $this->event_details_map_height = 362;            // ee_map_height_single
2911
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2912
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2913
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2914
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2915
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2916
-        // for event list pages
2917
-        $this->event_list_map_width = 300;            // ee_map_width
2918
-        $this->event_list_map_height = 185;        // ee_map_height
2919
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2920
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2921
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2922
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2923
-        $this->event_list_map_align = 'center';            // ee_map_align
2924
-    }
2817
+	/**
2818
+	 * @var boolean $use_google_maps
2819
+	 */
2820
+	public $use_google_maps;
2821
+
2822
+	/**
2823
+	 * @var string $api_key
2824
+	 */
2825
+	public $google_map_api_key;
2826
+
2827
+	/**
2828
+	 * @var int $event_details_map_width
2829
+	 */
2830
+	public $event_details_map_width;
2831
+
2832
+	/**
2833
+	 * @var int $event_details_map_height
2834
+	 */
2835
+	public $event_details_map_height;
2836
+
2837
+	/**
2838
+	 * @var int $event_details_map_zoom
2839
+	 */
2840
+	public $event_details_map_zoom;
2841
+
2842
+	/**
2843
+	 * @var boolean $event_details_display_nav
2844
+	 */
2845
+	public $event_details_display_nav;
2846
+
2847
+	/**
2848
+	 * @var boolean $event_details_nav_size
2849
+	 */
2850
+	public $event_details_nav_size;
2851
+
2852
+	/**
2853
+	 * @var string $event_details_control_type
2854
+	 */
2855
+	public $event_details_control_type;
2856
+
2857
+	/**
2858
+	 * @var string $event_details_map_align
2859
+	 */
2860
+	public $event_details_map_align;
2861
+
2862
+	/**
2863
+	 * @var int $event_list_map_width
2864
+	 */
2865
+	public $event_list_map_width;
2866
+
2867
+	/**
2868
+	 * @var int $event_list_map_height
2869
+	 */
2870
+	public $event_list_map_height;
2871
+
2872
+	/**
2873
+	 * @var int $event_list_map_zoom
2874
+	 */
2875
+	public $event_list_map_zoom;
2876
+
2877
+	/**
2878
+	 * @var boolean $event_list_display_nav
2879
+	 */
2880
+	public $event_list_display_nav;
2881
+
2882
+	/**
2883
+	 * @var boolean $event_list_nav_size
2884
+	 */
2885
+	public $event_list_nav_size;
2886
+
2887
+	/**
2888
+	 * @var string $event_list_control_type
2889
+	 */
2890
+	public $event_list_control_type;
2891
+
2892
+	/**
2893
+	 * @var string $event_list_map_align
2894
+	 */
2895
+	public $event_list_map_align;
2896
+
2897
+
2898
+	/**
2899
+	 *    class constructor
2900
+	 *
2901
+	 * @access    public
2902
+	 */
2903
+	public function __construct()
2904
+	{
2905
+		// set default map settings
2906
+		$this->use_google_maps = true;
2907
+		$this->google_map_api_key = '';
2908
+		// for event details pages (reg page)
2909
+		$this->event_details_map_width = 585;            // ee_map_width_single
2910
+		$this->event_details_map_height = 362;            // ee_map_height_single
2911
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2912
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2913
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2914
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2915
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2916
+		// for event list pages
2917
+		$this->event_list_map_width = 300;            // ee_map_width
2918
+		$this->event_list_map_height = 185;        // ee_map_height
2919
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2920
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2921
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2922
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2923
+		$this->event_list_map_align = 'center';            // ee_map_align
2924
+	}
2925 2925
 }
2926 2926
 
2927 2927
 /**
@@ -2930,46 +2930,46 @@  discard block
 block discarded – undo
2930 2930
 class EE_Events_Archive_Config extends EE_Config_Base
2931 2931
 {
2932 2932
 
2933
-    public $display_status_banner;
2933
+	public $display_status_banner;
2934 2934
 
2935
-    public $display_description;
2935
+	public $display_description;
2936 2936
 
2937
-    public $display_ticket_selector;
2937
+	public $display_ticket_selector;
2938 2938
 
2939
-    public $display_datetimes;
2939
+	public $display_datetimes;
2940 2940
 
2941
-    public $display_venue;
2941
+	public $display_venue;
2942 2942
 
2943
-    public $display_expired_events;
2943
+	public $display_expired_events;
2944 2944
 
2945
-    public $use_sortable_display_order;
2945
+	public $use_sortable_display_order;
2946 2946
 
2947
-    public $display_order_tickets;
2947
+	public $display_order_tickets;
2948 2948
 
2949
-    public $display_order_datetimes;
2949
+	public $display_order_datetimes;
2950 2950
 
2951
-    public $display_order_event;
2951
+	public $display_order_event;
2952 2952
 
2953
-    public $display_order_venue;
2953
+	public $display_order_venue;
2954 2954
 
2955 2955
 
2956
-    /**
2957
-     *    class constructor
2958
-     */
2959
-    public function __construct()
2960
-    {
2961
-        $this->display_status_banner = 0;
2962
-        $this->display_description = 1;
2963
-        $this->display_ticket_selector = 0;
2964
-        $this->display_datetimes = 1;
2965
-        $this->display_venue = 0;
2966
-        $this->display_expired_events = 0;
2967
-        $this->use_sortable_display_order = false;
2968
-        $this->display_order_tickets = 100;
2969
-        $this->display_order_datetimes = 110;
2970
-        $this->display_order_event = 120;
2971
-        $this->display_order_venue = 130;
2972
-    }
2956
+	/**
2957
+	 *    class constructor
2958
+	 */
2959
+	public function __construct()
2960
+	{
2961
+		$this->display_status_banner = 0;
2962
+		$this->display_description = 1;
2963
+		$this->display_ticket_selector = 0;
2964
+		$this->display_datetimes = 1;
2965
+		$this->display_venue = 0;
2966
+		$this->display_expired_events = 0;
2967
+		$this->use_sortable_display_order = false;
2968
+		$this->display_order_tickets = 100;
2969
+		$this->display_order_datetimes = 110;
2970
+		$this->display_order_event = 120;
2971
+		$this->display_order_venue = 130;
2972
+	}
2973 2973
 }
2974 2974
 
2975 2975
 /**
@@ -2978,34 +2978,34 @@  discard block
 block discarded – undo
2978 2978
 class EE_Event_Single_Config extends EE_Config_Base
2979 2979
 {
2980 2980
 
2981
-    public $display_status_banner_single;
2981
+	public $display_status_banner_single;
2982 2982
 
2983
-    public $display_venue;
2983
+	public $display_venue;
2984 2984
 
2985
-    public $use_sortable_display_order;
2985
+	public $use_sortable_display_order;
2986 2986
 
2987
-    public $display_order_tickets;
2987
+	public $display_order_tickets;
2988 2988
 
2989
-    public $display_order_datetimes;
2989
+	public $display_order_datetimes;
2990 2990
 
2991
-    public $display_order_event;
2991
+	public $display_order_event;
2992 2992
 
2993
-    public $display_order_venue;
2993
+	public $display_order_venue;
2994 2994
 
2995 2995
 
2996
-    /**
2997
-     *    class constructor
2998
-     */
2999
-    public function __construct()
3000
-    {
3001
-        $this->display_status_banner_single = 0;
3002
-        $this->display_venue = 1;
3003
-        $this->use_sortable_display_order = false;
3004
-        $this->display_order_tickets = 100;
3005
-        $this->display_order_datetimes = 110;
3006
-        $this->display_order_event = 120;
3007
-        $this->display_order_venue = 130;
3008
-    }
2996
+	/**
2997
+	 *    class constructor
2998
+	 */
2999
+	public function __construct()
3000
+	{
3001
+		$this->display_status_banner_single = 0;
3002
+		$this->display_venue = 1;
3003
+		$this->use_sortable_display_order = false;
3004
+		$this->display_order_tickets = 100;
3005
+		$this->display_order_datetimes = 110;
3006
+		$this->display_order_event = 120;
3007
+		$this->display_order_venue = 130;
3008
+	}
3009 3009
 }
3010 3010
 
3011 3011
 /**
@@ -3014,172 +3014,172 @@  discard block
 block discarded – undo
3014 3014
 class EE_Ticket_Selector_Config extends EE_Config_Base
3015 3015
 {
3016 3016
 
3017
-    /**
3018
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
3019
-     */
3020
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
3021
-
3022
-    /**
3023
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
3024
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
3025
-     */
3026
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
3027
-
3028
-    /**
3029
-     * @var boolean $show_ticket_sale_columns
3030
-     */
3031
-    public $show_ticket_sale_columns;
3032
-
3033
-    /**
3034
-     * @var boolean $show_ticket_details
3035
-     */
3036
-    public $show_ticket_details;
3037
-
3038
-    /**
3039
-     * @var boolean $show_expired_tickets
3040
-     */
3041
-    public $show_expired_tickets;
3042
-
3043
-    /**
3044
-     * whether or not to display a dropdown box populated with event datetimes
3045
-     * that toggles which tickets are displayed for a ticket selector.
3046
-     * uses one of the *_DATETIME_SELECTOR constants defined above
3047
-     *
3048
-     * @var string $show_datetime_selector
3049
-     */
3050
-    private $show_datetime_selector = 'no_datetime_selector';
3051
-
3052
-    /**
3053
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
3054
-     *
3055
-     * @var int $datetime_selector_threshold
3056
-     */
3057
-    private $datetime_selector_threshold = 3;
3058
-
3059
-    /**
3060
-     * determines the maximum number of "checked" dates in the date and time filter
3061
-     *
3062
-     * @var int $datetime_selector_checked
3063
-     */
3064
-    private $datetime_selector_max_checked = 10;
3065
-
3066
-
3067
-    /**
3068
-     *    class constructor
3069
-     */
3070
-    public function __construct()
3071
-    {
3072
-        $this->show_ticket_sale_columns = true;
3073
-        $this->show_ticket_details = true;
3074
-        $this->show_expired_tickets = true;
3075
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3076
-        $this->datetime_selector_threshold = 3;
3077
-        $this->datetime_selector_max_checked = 10;
3078
-    }
3079
-
3080
-
3081
-    /**
3082
-     * returns true if a datetime selector should be displayed
3083
-     *
3084
-     * @param array $datetimes
3085
-     * @return bool
3086
-     */
3087
-    public function showDatetimeSelector(array $datetimes)
3088
-    {
3089
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3090
-        return ! (
3091
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3092
-            || (
3093
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3094
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3095
-            )
3096
-        );
3097
-    }
3098
-
3099
-
3100
-    /**
3101
-     * @return string
3102
-     */
3103
-    public function getShowDatetimeSelector()
3104
-    {
3105
-        return $this->show_datetime_selector;
3106
-    }
3107
-
3108
-
3109
-    /**
3110
-     * @param bool $keys_only
3111
-     * @return array
3112
-     */
3113
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3114
-    {
3115
-        return $keys_only
3116
-            ? array(
3117
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3118
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3119
-            )
3120
-            : array(
3121
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3122
-                    'Do not show date & time filter',
3123
-                    'event_espresso'
3124
-                ),
3125
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3126
-                    'Maybe show date & time filter',
3127
-                    'event_espresso'
3128
-                ),
3129
-            );
3130
-    }
3131
-
3132
-
3133
-    /**
3134
-     * @param string $show_datetime_selector
3135
-     */
3136
-    public function setShowDatetimeSelector($show_datetime_selector)
3137
-    {
3138
-        $this->show_datetime_selector = in_array(
3139
-            $show_datetime_selector,
3140
-            $this->getShowDatetimeSelectorOptions(),
3141
-            true
3142
-        )
3143
-            ? $show_datetime_selector
3144
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3145
-    }
3146
-
3147
-
3148
-    /**
3149
-     * @return int
3150
-     */
3151
-    public function getDatetimeSelectorThreshold()
3152
-    {
3153
-        return $this->datetime_selector_threshold;
3154
-    }
3155
-
3156
-
3157
-    /**
3158
-     * @param int $datetime_selector_threshold
3159
-     */
3160
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3161
-    {
3162
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3163
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3164
-    }
3165
-
3166
-
3167
-    /**
3168
-     * @return int
3169
-     */
3170
-    public function getDatetimeSelectorMaxChecked()
3171
-    {
3172
-        return $this->datetime_selector_max_checked;
3173
-    }
3174
-
3175
-
3176
-    /**
3177
-     * @param int $datetime_selector_max_checked
3178
-     */
3179
-    public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3180
-    {
3181
-        $this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3182
-    }
3017
+	/**
3018
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
3019
+	 */
3020
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
3021
+
3022
+	/**
3023
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
3024
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
3025
+	 */
3026
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
3027
+
3028
+	/**
3029
+	 * @var boolean $show_ticket_sale_columns
3030
+	 */
3031
+	public $show_ticket_sale_columns;
3032
+
3033
+	/**
3034
+	 * @var boolean $show_ticket_details
3035
+	 */
3036
+	public $show_ticket_details;
3037
+
3038
+	/**
3039
+	 * @var boolean $show_expired_tickets
3040
+	 */
3041
+	public $show_expired_tickets;
3042
+
3043
+	/**
3044
+	 * whether or not to display a dropdown box populated with event datetimes
3045
+	 * that toggles which tickets are displayed for a ticket selector.
3046
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
3047
+	 *
3048
+	 * @var string $show_datetime_selector
3049
+	 */
3050
+	private $show_datetime_selector = 'no_datetime_selector';
3051
+
3052
+	/**
3053
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
3054
+	 *
3055
+	 * @var int $datetime_selector_threshold
3056
+	 */
3057
+	private $datetime_selector_threshold = 3;
3058
+
3059
+	/**
3060
+	 * determines the maximum number of "checked" dates in the date and time filter
3061
+	 *
3062
+	 * @var int $datetime_selector_checked
3063
+	 */
3064
+	private $datetime_selector_max_checked = 10;
3065
+
3066
+
3067
+	/**
3068
+	 *    class constructor
3069
+	 */
3070
+	public function __construct()
3071
+	{
3072
+		$this->show_ticket_sale_columns = true;
3073
+		$this->show_ticket_details = true;
3074
+		$this->show_expired_tickets = true;
3075
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3076
+		$this->datetime_selector_threshold = 3;
3077
+		$this->datetime_selector_max_checked = 10;
3078
+	}
3079
+
3080
+
3081
+	/**
3082
+	 * returns true if a datetime selector should be displayed
3083
+	 *
3084
+	 * @param array $datetimes
3085
+	 * @return bool
3086
+	 */
3087
+	public function showDatetimeSelector(array $datetimes)
3088
+	{
3089
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3090
+		return ! (
3091
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3092
+			|| (
3093
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3094
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3095
+			)
3096
+		);
3097
+	}
3098
+
3099
+
3100
+	/**
3101
+	 * @return string
3102
+	 */
3103
+	public function getShowDatetimeSelector()
3104
+	{
3105
+		return $this->show_datetime_selector;
3106
+	}
3107
+
3108
+
3109
+	/**
3110
+	 * @param bool $keys_only
3111
+	 * @return array
3112
+	 */
3113
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3114
+	{
3115
+		return $keys_only
3116
+			? array(
3117
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3118
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3119
+			)
3120
+			: array(
3121
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3122
+					'Do not show date & time filter',
3123
+					'event_espresso'
3124
+				),
3125
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3126
+					'Maybe show date & time filter',
3127
+					'event_espresso'
3128
+				),
3129
+			);
3130
+	}
3131
+
3132
+
3133
+	/**
3134
+	 * @param string $show_datetime_selector
3135
+	 */
3136
+	public function setShowDatetimeSelector($show_datetime_selector)
3137
+	{
3138
+		$this->show_datetime_selector = in_array(
3139
+			$show_datetime_selector,
3140
+			$this->getShowDatetimeSelectorOptions(),
3141
+			true
3142
+		)
3143
+			? $show_datetime_selector
3144
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3145
+	}
3146
+
3147
+
3148
+	/**
3149
+	 * @return int
3150
+	 */
3151
+	public function getDatetimeSelectorThreshold()
3152
+	{
3153
+		return $this->datetime_selector_threshold;
3154
+	}
3155
+
3156
+
3157
+	/**
3158
+	 * @param int $datetime_selector_threshold
3159
+	 */
3160
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3161
+	{
3162
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3163
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3164
+	}
3165
+
3166
+
3167
+	/**
3168
+	 * @return int
3169
+	 */
3170
+	public function getDatetimeSelectorMaxChecked()
3171
+	{
3172
+		return $this->datetime_selector_max_checked;
3173
+	}
3174
+
3175
+
3176
+	/**
3177
+	 * @param int $datetime_selector_max_checked
3178
+	 */
3179
+	public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3180
+	{
3181
+		$this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3182
+	}
3183 3183
 }
3184 3184
 
3185 3185
 /**
@@ -3192,87 +3192,87 @@  discard block
 block discarded – undo
3192 3192
 class EE_Environment_Config extends EE_Config_Base
3193 3193
 {
3194 3194
 
3195
-    /**
3196
-     * Hold any php environment variables that we want to track.
3197
-     *
3198
-     * @var stdClass;
3199
-     */
3200
-    public $php;
3201
-
3202
-
3203
-    /**
3204
-     *    constructor
3205
-     */
3206
-    public function __construct()
3207
-    {
3208
-        $this->php = new stdClass();
3209
-        $this->_set_php_values();
3210
-    }
3211
-
3212
-
3213
-    /**
3214
-     * This sets the php environment variables.
3215
-     *
3216
-     * @since 4.4.0
3217
-     * @return void
3218
-     */
3219
-    protected function _set_php_values()
3220
-    {
3221
-        $this->php->max_input_vars = ini_get('max_input_vars');
3222
-        $this->php->version = phpversion();
3223
-    }
3224
-
3225
-
3226
-    /**
3227
-     * helper method for determining whether input_count is
3228
-     * reaching the potential maximum the server can handle
3229
-     * according to max_input_vars
3230
-     *
3231
-     * @param int   $input_count the count of input vars.
3232
-     * @return array {
3233
-     *                           An array that represents whether available space and if no available space the error
3234
-     *                           message.
3235
-     * @type bool   $has_space   whether more inputs can be added.
3236
-     * @type string $msg         Any message to be displayed.
3237
-     *                           }
3238
-     */
3239
-    public function max_input_vars_limit_check($input_count = 0)
3240
-    {
3241
-        if (
3242
-            ! empty($this->php->max_input_vars)
3243
-            && ($input_count >= $this->php->max_input_vars)
3244
-        ) {
3245
-            // check the server setting because the config value could be stale
3246
-            $max_input_vars = ini_get('max_input_vars');
3247
-            if ($input_count >= $max_input_vars) {
3248
-                return sprintf(
3249
-                    esc_html__(
3250
-                        'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3251
-                        'event_espresso'
3252
-                    ),
3253
-                    '<br>',
3254
-                    $input_count,
3255
-                    $max_input_vars
3256
-                );
3257
-            } else {
3258
-                return '';
3259
-            }
3260
-        } else {
3261
-            return '';
3262
-        }
3263
-    }
3264
-
3265
-
3266
-    /**
3267
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3268
-     *
3269
-     * @since 4.4.1
3270
-     * @return void
3271
-     */
3272
-    public function recheck_values()
3273
-    {
3274
-        $this->_set_php_values();
3275
-    }
3195
+	/**
3196
+	 * Hold any php environment variables that we want to track.
3197
+	 *
3198
+	 * @var stdClass;
3199
+	 */
3200
+	public $php;
3201
+
3202
+
3203
+	/**
3204
+	 *    constructor
3205
+	 */
3206
+	public function __construct()
3207
+	{
3208
+		$this->php = new stdClass();
3209
+		$this->_set_php_values();
3210
+	}
3211
+
3212
+
3213
+	/**
3214
+	 * This sets the php environment variables.
3215
+	 *
3216
+	 * @since 4.4.0
3217
+	 * @return void
3218
+	 */
3219
+	protected function _set_php_values()
3220
+	{
3221
+		$this->php->max_input_vars = ini_get('max_input_vars');
3222
+		$this->php->version = phpversion();
3223
+	}
3224
+
3225
+
3226
+	/**
3227
+	 * helper method for determining whether input_count is
3228
+	 * reaching the potential maximum the server can handle
3229
+	 * according to max_input_vars
3230
+	 *
3231
+	 * @param int   $input_count the count of input vars.
3232
+	 * @return array {
3233
+	 *                           An array that represents whether available space and if no available space the error
3234
+	 *                           message.
3235
+	 * @type bool   $has_space   whether more inputs can be added.
3236
+	 * @type string $msg         Any message to be displayed.
3237
+	 *                           }
3238
+	 */
3239
+	public function max_input_vars_limit_check($input_count = 0)
3240
+	{
3241
+		if (
3242
+			! empty($this->php->max_input_vars)
3243
+			&& ($input_count >= $this->php->max_input_vars)
3244
+		) {
3245
+			// check the server setting because the config value could be stale
3246
+			$max_input_vars = ini_get('max_input_vars');
3247
+			if ($input_count >= $max_input_vars) {
3248
+				return sprintf(
3249
+					esc_html__(
3250
+						'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3251
+						'event_espresso'
3252
+					),
3253
+					'<br>',
3254
+					$input_count,
3255
+					$max_input_vars
3256
+				);
3257
+			} else {
3258
+				return '';
3259
+			}
3260
+		} else {
3261
+			return '';
3262
+		}
3263
+	}
3264
+
3265
+
3266
+	/**
3267
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3268
+	 *
3269
+	 * @since 4.4.1
3270
+	 * @return void
3271
+	 */
3272
+	public function recheck_values()
3273
+	{
3274
+		$this->_set_php_values();
3275
+	}
3276 3276
 }
3277 3277
 
3278 3278
 /**
@@ -3285,21 +3285,21 @@  discard block
 block discarded – undo
3285 3285
 class EE_Tax_Config extends EE_Config_Base
3286 3286
 {
3287 3287
 
3288
-    /*
3288
+	/*
3289 3289
      * flag to indicate whether or not to display ticket prices with the taxes included
3290 3290
      *
3291 3291
      * @var boolean $prices_displayed_including_taxes
3292 3292
      */
3293
-    public $prices_displayed_including_taxes;
3293
+	public $prices_displayed_including_taxes;
3294 3294
 
3295 3295
 
3296
-    /**
3297
-     *    class constructor
3298
-     */
3299
-    public function __construct()
3300
-    {
3301
-        $this->prices_displayed_including_taxes = true;
3302
-    }
3296
+	/**
3297
+	 *    class constructor
3298
+	 */
3299
+	public function __construct()
3300
+	{
3301
+		$this->prices_displayed_including_taxes = true;
3302
+	}
3303 3303
 }
3304 3304
 
3305 3305
 /**
@@ -3313,19 +3313,19 @@  discard block
 block discarded – undo
3313 3313
 class EE_Messages_Config extends EE_Config_Base
3314 3314
 {
3315 3315
 
3316
-    /**
3317
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3318
-     * A value of 0 represents never deleting.  Default is 0.
3319
-     *
3320
-     * @var integer
3321
-     */
3322
-    public $delete_threshold;
3316
+	/**
3317
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3318
+	 * A value of 0 represents never deleting.  Default is 0.
3319
+	 *
3320
+	 * @var integer
3321
+	 */
3322
+	public $delete_threshold;
3323 3323
 
3324 3324
 
3325
-    public function __construct()
3326
-    {
3327
-        $this->delete_threshold = 0;
3328
-    }
3325
+	public function __construct()
3326
+	{
3327
+		$this->delete_threshold = 0;
3328
+	}
3329 3329
 }
3330 3330
 
3331 3331
 /**
@@ -3336,31 +3336,31 @@  discard block
 block discarded – undo
3336 3336
 class EE_Gateway_Config extends EE_Config_Base
3337 3337
 {
3338 3338
 
3339
-    /**
3340
-     * Array with keys that are payment gateways slugs, and values are arrays
3341
-     * with any config info the gateway wants to store
3342
-     *
3343
-     * @var array
3344
-     */
3345
-    public $payment_settings;
3346
-
3347
-    /**
3348
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3349
-     * the gateway is stored in the uploads directory
3350
-     *
3351
-     * @var array
3352
-     */
3353
-    public $active_gateways;
3354
-
3355
-
3356
-    /**
3357
-     *    class constructor
3358
-     *
3359
-     * @deprecated
3360
-     */
3361
-    public function __construct()
3362
-    {
3363
-        $this->payment_settings = array();
3364
-        $this->active_gateways = array('Invoice' => false);
3365
-    }
3339
+	/**
3340
+	 * Array with keys that are payment gateways slugs, and values are arrays
3341
+	 * with any config info the gateway wants to store
3342
+	 *
3343
+	 * @var array
3344
+	 */
3345
+	public $payment_settings;
3346
+
3347
+	/**
3348
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3349
+	 * the gateway is stored in the uploads directory
3350
+	 *
3351
+	 * @var array
3352
+	 */
3353
+	public $active_gateways;
3354
+
3355
+
3356
+	/**
3357
+	 *    class constructor
3358
+	 *
3359
+	 * @deprecated
3360
+	 */
3361
+	public function __construct()
3362
+	{
3363
+		$this->payment_settings = array();
3364
+		$this->active_gateways = array('Invoice' => false);
3365
+	}
3366 3366
 }
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Attendee_Contact_List_Table.class.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      * ATT_address column
304 304
      *
305 305
      * @param EE_Attendee $attendee
306
-     * @return mixed
306
+     * @return string
307 307
      * @throws EE_Error
308 308
      */
309 309
     public function column_ATT_address(EE_Attendee $attendee)
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      * ATT_city column
317 317
      *
318 318
      * @param EE_Attendee $attendee
319
-     * @return mixed
319
+     * @return string
320 320
      * @throws EE_Error
321 321
      */
322 322
     public function column_ATT_city(EE_Attendee $attendee)
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
      * Phone Number column
370 370
      *
371 371
      * @param EE_Attendee $attendee
372
-     * @return mixed
372
+     * @return string
373 373
      * @throws EE_Error
374 374
      */
375 375
     public function column_ATT_phone(EE_Attendee $attendee)
Please login to merge, or discard this patch.
Indentation   +378 added lines, -378 removed lines patch added patch discarded remove patch
@@ -12,382 +12,382 @@
 block discarded – undo
12 12
  */
13 13
 class EE_Attendee_Contact_List_Table extends EE_Admin_List_Table
14 14
 {
15
-    /**
16
-     * Initial setup of data (called by parent).
17
-     */
18
-    protected function _setup_data()
19
-    {
20
-        $this->_data = $this->_view !== 'trash'
21
-            ? $this->_admin_page->get_attendees($this->_per_page)
22
-            : $this->_admin_page->get_attendees($this->_per_page, false, true);
23
-        $this->_all_data_count = $this->_view !== 'trash'
24
-            ? $this->_admin_page->get_attendees($this->_per_page, true)
25
-            : $this->_admin_page->get_attendees($this->_per_page, true, true);
26
-    }
27
-
28
-
29
-    /**
30
-     * Initial setup of properties.
31
-     */
32
-    protected function _set_properties()
33
-    {
34
-        $this->_wp_list_args = array(
35
-            'singular' => esc_html__('attendee', 'event_espresso'),
36
-            'plural'   => esc_html__('attendees', 'event_espresso'),
37
-            'ajax'     => true,
38
-            'screen'   => $this->_admin_page->get_current_screen()->id,
39
-        );
40
-
41
-        $this->_columns = array(
42
-            'cb'                 => '<input type="checkbox" />', // Render a checkbox instead of text
43
-            'ATT_ID'             => esc_html__('ID', 'event_espresso'),
44
-            'ATT_fname'          => esc_html__('First Name', 'event_espresso'),
45
-            'ATT_lname'          => esc_html__('Last Name', 'event_espresso'),
46
-            'ATT_email'          => esc_html__('Email Address', 'event_espresso'),
47
-            'Registration_Count' => esc_html__('# Registrations', 'event_espresso'),
48
-            'ATT_phone'          => esc_html__('Phone', 'event_espresso'),
49
-            'ATT_address'        => esc_html__('Address', 'event_espresso'),
50
-            'ATT_city'           => esc_html__('City', 'event_espresso'),
51
-            'STA_ID'             => esc_html__('State/Province', 'event_espresso'),
52
-            'CNT_ISO'            => esc_html__('Country', 'event_espresso'),
53
-        );
54
-
55
-        $this->_sortable_columns = array(
56
-            'ATT_ID'             => array('ATT_ID' => false),
57
-            'ATT_lname'          => array('ATT_lname' => true), // true means its already sorted
58
-            'ATT_fname'          => array('ATT_fname' => false),
59
-            'ATT_email'          => array('ATT_email' => false),
60
-            'Registration_Count' => array('Registration_Count' => false),
61
-            'ATT_city'           => array('ATT_city' => false),
62
-            'STA_ID'             => array('STA_ID' => false),
63
-            'CNT_ISO'            => array('CNT_ISO' => false),
64
-        );
65
-
66
-        $this->_hidden_columns = array(
67
-            'ATT_phone',
68
-            'ATT_address',
69
-            'ATT_city',
70
-            'STA_ID',
71
-            'CNT_ISO',
72
-        );
73
-    }
74
-
75
-
76
-    /**
77
-     * Initial setup of filters
78
-     *
79
-     * @return array
80
-     */
81
-    protected function _get_table_filters()
82
-    {
83
-        return array();
84
-    }
85
-
86
-
87
-    /**
88
-     * Initial setup of counts for views
89
-     *
90
-     * @throws InvalidArgumentException
91
-     * @throws InvalidDataTypeException
92
-     * @throws InvalidInterfaceException
93
-     */
94
-    protected function _add_view_counts()
95
-    {
96
-        $this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true);
97
-        if (
98
-            EE_Registry::instance()->CAP->current_user_can(
99
-                'ee_delete_contacts',
100
-                'espresso_registrations_delete_registration'
101
-            )
102
-        ) {
103
-            $this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
104
-        }
105
-    }
106
-
107
-
108
-    /**
109
-     * Get count of attendees.
110
-     *
111
-     * @return int
112
-     * @throws EE_Error
113
-     * @throws InvalidArgumentException
114
-     * @throws InvalidDataTypeException
115
-     * @throws InvalidInterfaceException
116
-     */
117
-    protected function _get_attendees_count()
118
-    {
119
-        return EEM_Attendee::instance()->count();
120
-    }
121
-
122
-
123
-    /**
124
-     * Checkbox column
125
-     *
126
-     * @param EE_Attendee $attendee Unable to typehint this method because overrides parent.
127
-     * @return string
128
-     * @throws EE_Error
129
-     */
130
-    public function column_cb($attendee)
131
-    {
132
-        if (! $attendee instanceof EE_Attendee) {
133
-            return '';
134
-        }
135
-        return sprintf(
136
-            '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
137
-            $attendee->ID()
138
-        );
139
-    }
140
-
141
-
142
-    /**
143
-     * ATT_ID column
144
-     *
145
-     * @param EE_Attendee $attendee
146
-     * @return string
147
-     * @throws EE_Error
148
-     */
149
-    public function column_ATT_ID(EE_Attendee $attendee)
150
-    {
151
-        $content = $attendee->ID();
152
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
153
-        $content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
154
-        return $content;
155
-    }
156
-
157
-
158
-    /**
159
-     * ATT_lname column
160
-     *
161
-     * @param EE_Attendee $attendee
162
-     * @return string
163
-     * @throws InvalidArgumentException
164
-     * @throws InvalidDataTypeException
165
-     * @throws InvalidInterfaceException
166
-     * @throws EE_Error
167
-     */
168
-    public function column_ATT_lname(EE_Attendee $attendee)
169
-    {
170
-        // edit attendee link
171
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
172
-            array(
173
-                'action' => 'edit_attendee',
174
-                'post'   => $attendee->ID(),
175
-            ),
176
-            REG_ADMIN_URL
177
-        );
178
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
179
-            'ee_edit_contacts',
180
-            'espresso_registrations_edit_attendee'
181
-        )
182
-            ? '<a href="' . $edit_lnk_url . '" title="'
183
-              . esc_attr__('Edit Contact', 'event_espresso') . '">'
184
-              . $attendee->lname() . '</a>'
185
-            : $attendee->lname();
186
-        return $name_link;
187
-    }
188
-
189
-
190
-    /**
191
-     * ATT_fname column
192
-     *
193
-     * @param EE_Attendee $attendee
194
-     * @return string
195
-     * @throws InvalidArgumentException
196
-     * @throws InvalidDataTypeException
197
-     * @throws InvalidInterfaceException
198
-     * @throws EE_Error
199
-     */
200
-    public function column_ATT_fname(EE_Attendee $attendee)
201
-    {
202
-        // Build row actions
203
-        $actions = array();
204
-        // edit attendee link
205
-        if (
206
-            EE_Registry::instance()->CAP->current_user_can(
207
-                'ee_edit_contacts',
208
-                'espresso_registrations_edit_attendee'
209
-            )
210
-        ) {
211
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
212
-                array(
213
-                    'action' => 'edit_attendee',
214
-                    'post'   => $attendee->ID(),
215
-                ),
216
-                REG_ADMIN_URL
217
-            );
218
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
219
-                               . esc_attr__('Edit Contact', 'event_espresso') . '">'
220
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
221
-        }
222
-
223
-        if ($this->_view === 'in_use') {
224
-            // trash attendee link
225
-            if (
226
-                EE_Registry::instance()->CAP->current_user_can(
227
-                    'ee_delete_contacts',
228
-                    'espresso_registrations_trash_attendees'
229
-                )
230
-            ) {
231
-                $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
232
-                    array(
233
-                        'action' => 'trash_attendee',
234
-                        'ATT_ID' => $attendee->ID(),
235
-                    ),
236
-                    REG_ADMIN_URL
237
-                );
238
-                $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
239
-                                    . esc_attr__('Move Contact to Trash', 'event_espresso')
240
-                                    . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
241
-            }
242
-        } else {
243
-            if (
244
-                EE_Registry::instance()->CAP->current_user_can(
245
-                    'ee_delete_contacts',
246
-                    'espresso_registrations_restore_attendees'
247
-                )
248
-            ) {
249
-                // restore attendee link
250
-                $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
251
-                    array(
252
-                        'action' => 'restore_attendees',
253
-                        'ATT_ID' => $attendee->ID(),
254
-                    ),
255
-                    REG_ADMIN_URL
256
-                );
257
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
258
-                                      . esc_attr__('Restore Contact', 'event_espresso') . '">'
259
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
260
-            }
261
-        }
262
-
263
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
264
-            array(
265
-                'action' => 'edit_attendee',
266
-                'post'   => $attendee->ID(),
267
-            ),
268
-            REG_ADMIN_URL
269
-        );
270
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
271
-            'ee_edit_contacts',
272
-            'espresso_registrations_edit_attendee'
273
-        )
274
-            ? '<a href="' . $edit_lnk_url . '" title="'
275
-              . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
276
-            : $attendee->fname();
277
-
278
-        // Return the name contents
279
-        return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
280
-    }
281
-
282
-
283
-    /**
284
-     * Email Column
285
-     *
286
-     * @param EE_Attendee $attendee
287
-     * @return string
288
-     * @throws EE_Error
289
-     */
290
-    public function column_ATT_email(EE_Attendee $attendee)
291
-    {
292
-        return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
293
-    }
294
-
295
-
296
-    /**
297
-     * Column displaying count of registrations attached to Attendee.
298
-     *
299
-     * @param EE_Attendee $attendee
300
-     * @return string
301
-     * @throws EE_Error
302
-     */
303
-    public function column_Registration_Count(EE_Attendee $attendee)
304
-    {
305
-        $link = EEH_URL::add_query_args_and_nonce(
306
-            array(
307
-                'action' => 'default',
308
-                'ATT_ID' => $attendee->ID(),
309
-            ),
310
-            REG_ADMIN_URL
311
-        );
312
-        return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
313
-    }
314
-
315
-
316
-    /**
317
-     * ATT_address column
318
-     *
319
-     * @param EE_Attendee $attendee
320
-     * @return mixed
321
-     * @throws EE_Error
322
-     */
323
-    public function column_ATT_address(EE_Attendee $attendee)
324
-    {
325
-        return $attendee->address();
326
-    }
327
-
328
-
329
-    /**
330
-     * ATT_city column
331
-     *
332
-     * @param EE_Attendee $attendee
333
-     * @return mixed
334
-     * @throws EE_Error
335
-     */
336
-    public function column_ATT_city(EE_Attendee $attendee)
337
-    {
338
-        return $attendee->city();
339
-    }
340
-
341
-
342
-    /**
343
-     * State Column
344
-     *
345
-     * @param EE_Attendee $attendee
346
-     * @return string
347
-     * @throws EE_Error
348
-     * @throws InvalidArgumentException
349
-     * @throws InvalidDataTypeException
350
-     * @throws InvalidInterfaceException
351
-     */
352
-    public function column_STA_ID(EE_Attendee $attendee)
353
-    {
354
-        $states = EEM_State::instance()->get_all_states();
355
-        $state = isset($states[ $attendee->state_ID() ])
356
-            ? $states[ $attendee->state_ID() ]->get('STA_name')
357
-            : $attendee->state_ID();
358
-        return ! is_numeric($state) ? $state : '';
359
-    }
360
-
361
-
362
-    /**
363
-     * Country Column
364
-     *
365
-     * @param EE_Attendee $attendee
366
-     * @return string
367
-     * @throws EE_Error
368
-     * @throws InvalidArgumentException
369
-     * @throws InvalidDataTypeException
370
-     * @throws InvalidInterfaceException
371
-     */
372
-    public function column_CNT_ISO(EE_Attendee $attendee)
373
-    {
374
-        $countries = EEM_Country::instance()->get_all_countries();
375
-        $country = isset($countries[ $attendee->country_ID() ])
376
-            ? $countries[ $attendee->country_ID() ]->get('CNT_name')
377
-            : $attendee->country_ID();
378
-        return ! is_numeric($country) ? $country : '';
379
-    }
380
-
381
-
382
-    /**
383
-     * Phone Number column
384
-     *
385
-     * @param EE_Attendee $attendee
386
-     * @return mixed
387
-     * @throws EE_Error
388
-     */
389
-    public function column_ATT_phone(EE_Attendee $attendee)
390
-    {
391
-        return $attendee->phone();
392
-    }
15
+	/**
16
+	 * Initial setup of data (called by parent).
17
+	 */
18
+	protected function _setup_data()
19
+	{
20
+		$this->_data = $this->_view !== 'trash'
21
+			? $this->_admin_page->get_attendees($this->_per_page)
22
+			: $this->_admin_page->get_attendees($this->_per_page, false, true);
23
+		$this->_all_data_count = $this->_view !== 'trash'
24
+			? $this->_admin_page->get_attendees($this->_per_page, true)
25
+			: $this->_admin_page->get_attendees($this->_per_page, true, true);
26
+	}
27
+
28
+
29
+	/**
30
+	 * Initial setup of properties.
31
+	 */
32
+	protected function _set_properties()
33
+	{
34
+		$this->_wp_list_args = array(
35
+			'singular' => esc_html__('attendee', 'event_espresso'),
36
+			'plural'   => esc_html__('attendees', 'event_espresso'),
37
+			'ajax'     => true,
38
+			'screen'   => $this->_admin_page->get_current_screen()->id,
39
+		);
40
+
41
+		$this->_columns = array(
42
+			'cb'                 => '<input type="checkbox" />', // Render a checkbox instead of text
43
+			'ATT_ID'             => esc_html__('ID', 'event_espresso'),
44
+			'ATT_fname'          => esc_html__('First Name', 'event_espresso'),
45
+			'ATT_lname'          => esc_html__('Last Name', 'event_espresso'),
46
+			'ATT_email'          => esc_html__('Email Address', 'event_espresso'),
47
+			'Registration_Count' => esc_html__('# Registrations', 'event_espresso'),
48
+			'ATT_phone'          => esc_html__('Phone', 'event_espresso'),
49
+			'ATT_address'        => esc_html__('Address', 'event_espresso'),
50
+			'ATT_city'           => esc_html__('City', 'event_espresso'),
51
+			'STA_ID'             => esc_html__('State/Province', 'event_espresso'),
52
+			'CNT_ISO'            => esc_html__('Country', 'event_espresso'),
53
+		);
54
+
55
+		$this->_sortable_columns = array(
56
+			'ATT_ID'             => array('ATT_ID' => false),
57
+			'ATT_lname'          => array('ATT_lname' => true), // true means its already sorted
58
+			'ATT_fname'          => array('ATT_fname' => false),
59
+			'ATT_email'          => array('ATT_email' => false),
60
+			'Registration_Count' => array('Registration_Count' => false),
61
+			'ATT_city'           => array('ATT_city' => false),
62
+			'STA_ID'             => array('STA_ID' => false),
63
+			'CNT_ISO'            => array('CNT_ISO' => false),
64
+		);
65
+
66
+		$this->_hidden_columns = array(
67
+			'ATT_phone',
68
+			'ATT_address',
69
+			'ATT_city',
70
+			'STA_ID',
71
+			'CNT_ISO',
72
+		);
73
+	}
74
+
75
+
76
+	/**
77
+	 * Initial setup of filters
78
+	 *
79
+	 * @return array
80
+	 */
81
+	protected function _get_table_filters()
82
+	{
83
+		return array();
84
+	}
85
+
86
+
87
+	/**
88
+	 * Initial setup of counts for views
89
+	 *
90
+	 * @throws InvalidArgumentException
91
+	 * @throws InvalidDataTypeException
92
+	 * @throws InvalidInterfaceException
93
+	 */
94
+	protected function _add_view_counts()
95
+	{
96
+		$this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true);
97
+		if (
98
+			EE_Registry::instance()->CAP->current_user_can(
99
+				'ee_delete_contacts',
100
+				'espresso_registrations_delete_registration'
101
+			)
102
+		) {
103
+			$this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
104
+		}
105
+	}
106
+
107
+
108
+	/**
109
+	 * Get count of attendees.
110
+	 *
111
+	 * @return int
112
+	 * @throws EE_Error
113
+	 * @throws InvalidArgumentException
114
+	 * @throws InvalidDataTypeException
115
+	 * @throws InvalidInterfaceException
116
+	 */
117
+	protected function _get_attendees_count()
118
+	{
119
+		return EEM_Attendee::instance()->count();
120
+	}
121
+
122
+
123
+	/**
124
+	 * Checkbox column
125
+	 *
126
+	 * @param EE_Attendee $attendee Unable to typehint this method because overrides parent.
127
+	 * @return string
128
+	 * @throws EE_Error
129
+	 */
130
+	public function column_cb($attendee)
131
+	{
132
+		if (! $attendee instanceof EE_Attendee) {
133
+			return '';
134
+		}
135
+		return sprintf(
136
+			'<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
137
+			$attendee->ID()
138
+		);
139
+	}
140
+
141
+
142
+	/**
143
+	 * ATT_ID column
144
+	 *
145
+	 * @param EE_Attendee $attendee
146
+	 * @return string
147
+	 * @throws EE_Error
148
+	 */
149
+	public function column_ATT_ID(EE_Attendee $attendee)
150
+	{
151
+		$content = $attendee->ID();
152
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
153
+		$content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
154
+		return $content;
155
+	}
156
+
157
+
158
+	/**
159
+	 * ATT_lname column
160
+	 *
161
+	 * @param EE_Attendee $attendee
162
+	 * @return string
163
+	 * @throws InvalidArgumentException
164
+	 * @throws InvalidDataTypeException
165
+	 * @throws InvalidInterfaceException
166
+	 * @throws EE_Error
167
+	 */
168
+	public function column_ATT_lname(EE_Attendee $attendee)
169
+	{
170
+		// edit attendee link
171
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
172
+			array(
173
+				'action' => 'edit_attendee',
174
+				'post'   => $attendee->ID(),
175
+			),
176
+			REG_ADMIN_URL
177
+		);
178
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
179
+			'ee_edit_contacts',
180
+			'espresso_registrations_edit_attendee'
181
+		)
182
+			? '<a href="' . $edit_lnk_url . '" title="'
183
+			  . esc_attr__('Edit Contact', 'event_espresso') . '">'
184
+			  . $attendee->lname() . '</a>'
185
+			: $attendee->lname();
186
+		return $name_link;
187
+	}
188
+
189
+
190
+	/**
191
+	 * ATT_fname column
192
+	 *
193
+	 * @param EE_Attendee $attendee
194
+	 * @return string
195
+	 * @throws InvalidArgumentException
196
+	 * @throws InvalidDataTypeException
197
+	 * @throws InvalidInterfaceException
198
+	 * @throws EE_Error
199
+	 */
200
+	public function column_ATT_fname(EE_Attendee $attendee)
201
+	{
202
+		// Build row actions
203
+		$actions = array();
204
+		// edit attendee link
205
+		if (
206
+			EE_Registry::instance()->CAP->current_user_can(
207
+				'ee_edit_contacts',
208
+				'espresso_registrations_edit_attendee'
209
+			)
210
+		) {
211
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
212
+				array(
213
+					'action' => 'edit_attendee',
214
+					'post'   => $attendee->ID(),
215
+				),
216
+				REG_ADMIN_URL
217
+			);
218
+			$actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
219
+							   . esc_attr__('Edit Contact', 'event_espresso') . '">'
220
+							   . esc_html__('Edit', 'event_espresso') . '</a>';
221
+		}
222
+
223
+		if ($this->_view === 'in_use') {
224
+			// trash attendee link
225
+			if (
226
+				EE_Registry::instance()->CAP->current_user_can(
227
+					'ee_delete_contacts',
228
+					'espresso_registrations_trash_attendees'
229
+				)
230
+			) {
231
+				$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
232
+					array(
233
+						'action' => 'trash_attendee',
234
+						'ATT_ID' => $attendee->ID(),
235
+					),
236
+					REG_ADMIN_URL
237
+				);
238
+				$actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
239
+									. esc_attr__('Move Contact to Trash', 'event_espresso')
240
+									. '">' . esc_html__('Trash', 'event_espresso') . '</a>';
241
+			}
242
+		} else {
243
+			if (
244
+				EE_Registry::instance()->CAP->current_user_can(
245
+					'ee_delete_contacts',
246
+					'espresso_registrations_restore_attendees'
247
+				)
248
+			) {
249
+				// restore attendee link
250
+				$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
251
+					array(
252
+						'action' => 'restore_attendees',
253
+						'ATT_ID' => $attendee->ID(),
254
+					),
255
+					REG_ADMIN_URL
256
+				);
257
+				$actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
258
+									  . esc_attr__('Restore Contact', 'event_espresso') . '">'
259
+									  . esc_html__('Restore', 'event_espresso') . '</a>';
260
+			}
261
+		}
262
+
263
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
264
+			array(
265
+				'action' => 'edit_attendee',
266
+				'post'   => $attendee->ID(),
267
+			),
268
+			REG_ADMIN_URL
269
+		);
270
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
271
+			'ee_edit_contacts',
272
+			'espresso_registrations_edit_attendee'
273
+		)
274
+			? '<a href="' . $edit_lnk_url . '" title="'
275
+			  . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
276
+			: $attendee->fname();
277
+
278
+		// Return the name contents
279
+		return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
280
+	}
281
+
282
+
283
+	/**
284
+	 * Email Column
285
+	 *
286
+	 * @param EE_Attendee $attendee
287
+	 * @return string
288
+	 * @throws EE_Error
289
+	 */
290
+	public function column_ATT_email(EE_Attendee $attendee)
291
+	{
292
+		return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
293
+	}
294
+
295
+
296
+	/**
297
+	 * Column displaying count of registrations attached to Attendee.
298
+	 *
299
+	 * @param EE_Attendee $attendee
300
+	 * @return string
301
+	 * @throws EE_Error
302
+	 */
303
+	public function column_Registration_Count(EE_Attendee $attendee)
304
+	{
305
+		$link = EEH_URL::add_query_args_and_nonce(
306
+			array(
307
+				'action' => 'default',
308
+				'ATT_ID' => $attendee->ID(),
309
+			),
310
+			REG_ADMIN_URL
311
+		);
312
+		return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
313
+	}
314
+
315
+
316
+	/**
317
+	 * ATT_address column
318
+	 *
319
+	 * @param EE_Attendee $attendee
320
+	 * @return mixed
321
+	 * @throws EE_Error
322
+	 */
323
+	public function column_ATT_address(EE_Attendee $attendee)
324
+	{
325
+		return $attendee->address();
326
+	}
327
+
328
+
329
+	/**
330
+	 * ATT_city column
331
+	 *
332
+	 * @param EE_Attendee $attendee
333
+	 * @return mixed
334
+	 * @throws EE_Error
335
+	 */
336
+	public function column_ATT_city(EE_Attendee $attendee)
337
+	{
338
+		return $attendee->city();
339
+	}
340
+
341
+
342
+	/**
343
+	 * State Column
344
+	 *
345
+	 * @param EE_Attendee $attendee
346
+	 * @return string
347
+	 * @throws EE_Error
348
+	 * @throws InvalidArgumentException
349
+	 * @throws InvalidDataTypeException
350
+	 * @throws InvalidInterfaceException
351
+	 */
352
+	public function column_STA_ID(EE_Attendee $attendee)
353
+	{
354
+		$states = EEM_State::instance()->get_all_states();
355
+		$state = isset($states[ $attendee->state_ID() ])
356
+			? $states[ $attendee->state_ID() ]->get('STA_name')
357
+			: $attendee->state_ID();
358
+		return ! is_numeric($state) ? $state : '';
359
+	}
360
+
361
+
362
+	/**
363
+	 * Country Column
364
+	 *
365
+	 * @param EE_Attendee $attendee
366
+	 * @return string
367
+	 * @throws EE_Error
368
+	 * @throws InvalidArgumentException
369
+	 * @throws InvalidDataTypeException
370
+	 * @throws InvalidInterfaceException
371
+	 */
372
+	public function column_CNT_ISO(EE_Attendee $attendee)
373
+	{
374
+		$countries = EEM_Country::instance()->get_all_countries();
375
+		$country = isset($countries[ $attendee->country_ID() ])
376
+			? $countries[ $attendee->country_ID() ]->get('CNT_name')
377
+			: $attendee->country_ID();
378
+		return ! is_numeric($country) ? $country : '';
379
+	}
380
+
381
+
382
+	/**
383
+	 * Phone Number column
384
+	 *
385
+	 * @param EE_Attendee $attendee
386
+	 * @return mixed
387
+	 * @throws EE_Error
388
+	 */
389
+	public function column_ATT_phone(EE_Attendee $attendee)
390
+	{
391
+		return $attendee->phone();
392
+	}
393 393
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function column_cb($attendee)
131 131
     {
132
-        if (! $attendee instanceof EE_Attendee) {
132
+        if ( ! $attendee instanceof EE_Attendee) {
133 133
             return '';
134 134
         }
135 135
         return sprintf(
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     {
151 151
         $content = $attendee->ID();
152 152
         $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
153
-        $content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
153
+        $content .= '  <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
154 154
         return $content;
155 155
     }
156 156
 
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
             'ee_edit_contacts',
180 180
             'espresso_registrations_edit_attendee'
181 181
         )
182
-            ? '<a href="' . $edit_lnk_url . '" title="'
183
-              . esc_attr__('Edit Contact', 'event_espresso') . '">'
184
-              . $attendee->lname() . '</a>'
182
+            ? '<a href="'.$edit_lnk_url.'" title="'
183
+              . esc_attr__('Edit Contact', 'event_espresso').'">'
184
+              . $attendee->lname().'</a>'
185 185
             : $attendee->lname();
186 186
         return $name_link;
187 187
     }
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
                 ),
216 216
                 REG_ADMIN_URL
217 217
             );
218
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
219
-                               . esc_attr__('Edit Contact', 'event_espresso') . '">'
220
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
218
+            $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'
219
+                               . esc_attr__('Edit Contact', 'event_espresso').'">'
220
+                               . esc_html__('Edit', 'event_espresso').'</a>';
221 221
         }
222 222
 
223 223
         if ($this->_view === 'in_use') {
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
                     ),
236 236
                     REG_ADMIN_URL
237 237
                 );
238
-                $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
238
+                $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'
239 239
                                     . esc_attr__('Move Contact to Trash', 'event_espresso')
240
-                                    . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
240
+                                    . '">'.esc_html__('Trash', 'event_espresso').'</a>';
241 241
             }
242 242
         } else {
243 243
             if (
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
                     ),
255 255
                     REG_ADMIN_URL
256 256
                 );
257
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
258
-                                      . esc_attr__('Restore Contact', 'event_espresso') . '">'
259
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
257
+                $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'
258
+                                      . esc_attr__('Restore Contact', 'event_espresso').'">'
259
+                                      . esc_html__('Restore', 'event_espresso').'</a>';
260 260
             }
261 261
         }
262 262
 
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
             'ee_edit_contacts',
272 272
             'espresso_registrations_edit_attendee'
273 273
         )
274
-            ? '<a href="' . $edit_lnk_url . '" title="'
275
-              . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
274
+            ? '<a href="'.$edit_lnk_url.'" title="'
275
+              . esc_attr__('Edit Contact', 'event_espresso').'">'.$attendee->fname().'</a>'
276 276
             : $attendee->fname();
277 277
 
278 278
         // Return the name contents
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      */
290 290
     public function column_ATT_email(EE_Attendee $attendee)
291 291
     {
292
-        return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
292
+        return '<a href="mailto:'.$attendee->email().'">'.$attendee->email().'</a>';
293 293
     }
294 294
 
295 295
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             ),
310 310
             REG_ADMIN_URL
311 311
         );
312
-        return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
312
+        return '<a href="'.$link.'">'.$attendee->getCustomSelect('Registration_Count').'</a>';
313 313
     }
314 314
 
315 315
 
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
     public function column_STA_ID(EE_Attendee $attendee)
353 353
     {
354 354
         $states = EEM_State::instance()->get_all_states();
355
-        $state = isset($states[ $attendee->state_ID() ])
356
-            ? $states[ $attendee->state_ID() ]->get('STA_name')
355
+        $state = isset($states[$attendee->state_ID()])
356
+            ? $states[$attendee->state_ID()]->get('STA_name')
357 357
             : $attendee->state_ID();
358 358
         return ! is_numeric($state) ? $state : '';
359 359
     }
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
     public function column_CNT_ISO(EE_Attendee $attendee)
373 373
     {
374 374
         $countries = EEM_Country::instance()->get_all_countries();
375
-        $country = isset($countries[ $attendee->country_ID() ])
376
-            ? $countries[ $attendee->country_ID() ]->get('CNT_name')
375
+        $country = isset($countries[$attendee->country_ID()])
376
+            ? $countries[$attendee->country_ID()]->get('CNT_name')
377 377
             : $attendee->country_ID();
378 378
         return ! is_numeric($country) ? $country : '';
379 379
     }
Please login to merge, or discard this patch.
core/domain/services/factories/ModelFactory.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@
 block discarded – undo
25 25
 class ModelFactory
26 26
 {
27 27
 
28
-    /**
29
-     * @param string $model_name
30
-     * @return bool|EEM_Base
31
-     * @throws EE_Error
32
-     * @throws InvalidDataTypeException
33
-     * @throws InvalidInterfaceException
34
-     * @throws InvalidArgumentException
35
-     * @throws ReflectionException
36
-     */
37
-    public static function getModel($model_name)
38
-    {
39
-        return EE_Registry::instance()->load_model($model_name);
40
-    }
28
+	/**
29
+	 * @param string $model_name
30
+	 * @return bool|EEM_Base
31
+	 * @throws EE_Error
32
+	 * @throws InvalidDataTypeException
33
+	 * @throws InvalidInterfaceException
34
+	 * @throws InvalidArgumentException
35
+	 * @throws ReflectionException
36
+	 */
37
+	public static function getModel($model_name)
38
+	{
39
+		return EE_Registry::instance()->load_model($model_name);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
modules/ticket_selector/TicketDatetimeAvailabilityTracker.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -66,24 +66,24 @@  discard block
 block discarded – undo
66 66
     public function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
67 67
     {
68 68
         // if the $_available_spaces array has not been set up yet...
69
-        if (! isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
69
+        if ( ! isset($this->available_spaces['tickets'][$ticket->ID()])) {
70 70
             $this->setInitialTicketDatetimeAvailability($ticket);
71 71
         }
72 72
         $available_spaces = $ticket->qty() - $ticket->sold();
73
-        if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
73
+        if (isset($this->available_spaces['tickets'][$ticket->ID()])) {
74 74
             // loop thru tickets, which will ALSO include individual ticket records AND a total
75
-            foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
75
+            foreach ($this->available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
76 76
                 // if we want the original datetime availability BEFORE we started subtracting tickets ?
77 77
                 if ($get_original_ticket_spaces) {
78 78
                     // then grab the available spaces from the "tickets" array
79 79
                     // and compare with the above to get the lowest number
80 80
                     $available_spaces = min(
81 81
                         $available_spaces,
82
-                        $this->available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
82
+                        $this->available_spaces['tickets'][$ticket->ID()][$DTD_ID]
83 83
                     );
84 84
                 } else {
85 85
                     // we want the updated ticket availability as stored in the "datetimes" array
86
-                    $available_spaces = min($available_spaces, $this->available_spaces['datetimes'][ $DTD_ID ]);
86
+                    $available_spaces = min($available_spaces, $this->available_spaces['datetimes'][$DTD_ID]);
87 87
                 }
88 88
             }
89 89
         }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
                 'order_by' => array('DTT_EVT_start' => 'ASC'),
115 115
             )
116 116
         );
117
-        if (! empty($datetimes)) {
117
+        if ( ! empty($datetimes)) {
118 118
             // now loop thru all of the datetimes
119 119
             foreach ($datetimes as $datetime) {
120 120
                 if ($datetime instanceof EE_Datetime) {
@@ -122,17 +122,17 @@  discard block
 block discarded – undo
122 122
                     $spaces_remaining = $datetime->spaces_remaining();
123 123
                     // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
124 124
                     // or the datetime spaces remaining) to this ticket using the datetime ID as the key
125
-                    $this->available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
125
+                    $this->available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(
126 126
                         $ticket->qty() - $ticket->sold(),
127 127
                         $spaces_remaining
128 128
                     );
129 129
                     // if the remaining spaces for this datetime is already set,
130 130
                     // then compare that against the datetime spaces remaining, and take the lowest number,
131 131
                     // else just take the datetime spaces remaining, and assign to the datetimes array
132
-                    $this->available_spaces['datetimes'][ $datetime->ID() ] = isset(
133
-                        $this->available_spaces['datetimes'][ $datetime->ID() ]
132
+                    $this->available_spaces['datetimes'][$datetime->ID()] = isset(
133
+                        $this->available_spaces['datetimes'][$datetime->ID()]
134 134
                     )
135
-                        ? min($this->available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
135
+                        ? min($this->available_spaces['datetimes'][$datetime->ID()], $spaces_remaining)
136 136
                         : $spaces_remaining;
137 137
                 }
138 138
             }
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
150 150
     {
151
-        if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
151
+        if (isset($this->available_spaces['tickets'][$ticket->ID()])) {
152 152
             // loop thru tickets, which will ALSO include individual ticket records AND a total
153
-            foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
153
+            foreach ($this->available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
154 154
                 // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
155
-                $this->available_spaces['datetimes'][ $DTD_ID ] -= $qty;
155
+                $this->available_spaces['datetimes'][$DTD_ID] -= $qty;
156 156
             }
157 157
         }
158 158
     }
Please login to merge, or discard this patch.
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -22,217 +22,217 @@
 block discarded – undo
22 22
 class TicketDatetimeAvailabilityTracker
23 23
 {
24 24
 
25
-    /**
26
-     * array of datetimes and the spaces available for them
27
-     *
28
-     * @var array[][]
29
-     */
30
-    private $available_spaces = array();
31
-
32
-    /**
33
-     * @var EEM_Datetime $datetime_model
34
-     */
35
-    private $datetime_model;
36
-
37
-
38
-    /**
39
-     * TicketDatetimeAvailabilityTracker constructor.
40
-     *
41
-     * @param EEM_Datetime $datetime_model
42
-     */
43
-    public function __construct(EEM_Datetime $datetime_model)
44
-    {
45
-        $this->datetime_model = $datetime_model;
46
-    }
47
-
48
-
49
-    /**
50
-     * ticketDatetimeAvailability
51
-     * creates an array of tickets plus all of the datetimes available to each ticket
52
-     * and tracks the spaces remaining for each of those datetimes
53
-     *
54
-     * @param EE_Ticket $ticket - selected ticket
55
-     * @param bool      $get_original_ticket_spaces
56
-     * @return int
57
-     * @throws EE_Error
58
-     * @throws InvalidArgumentException
59
-     * @throws InvalidDataTypeException
60
-     * @throws InvalidInterfaceException
61
-     */
62
-    public function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
63
-    {
64
-        // if the $_available_spaces array has not been set up yet...
65
-        if (! isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
66
-            $this->setInitialTicketDatetimeAvailability($ticket);
67
-        }
68
-        $available_spaces = $ticket->qty() - $ticket->sold();
69
-        if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
70
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
71
-            foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
72
-                // if we want the original datetime availability BEFORE we started subtracting tickets ?
73
-                if ($get_original_ticket_spaces) {
74
-                    // then grab the available spaces from the "tickets" array
75
-                    // and compare with the above to get the lowest number
76
-                    $available_spaces = min(
77
-                        $available_spaces,
78
-                        $this->available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
79
-                    );
80
-                } else {
81
-                    // we want the updated ticket availability as stored in the "datetimes" array
82
-                    $available_spaces = min($available_spaces, $this->available_spaces['datetimes'][ $DTD_ID ]);
83
-                }
84
-            }
85
-        }
86
-        return $available_spaces;
87
-    }
88
-
89
-
90
-    /**
91
-     * @param EE_Ticket $ticket
92
-     * @return void
93
-     * @throws InvalidArgumentException
94
-     * @throws InvalidInterfaceException
95
-     * @throws InvalidDataTypeException
96
-     * @throws EE_Error
97
-     */
98
-    private function setInitialTicketDatetimeAvailability(EE_Ticket $ticket)
99
-    {
100
-        // first, get all of the datetimes that are available to this ticket
101
-        $datetimes = $ticket->get_many_related(
102
-            'Datetime',
103
-            array(
104
-                array(
105
-                    'DTT_EVT_end' => array(
106
-                        '>=',
107
-                        $this->datetime_model->current_time_for_query('DTT_EVT_end'),
108
-                    ),
109
-                ),
110
-                'order_by' => array('DTT_EVT_start' => 'ASC'),
111
-            )
112
-        );
113
-        if (! empty($datetimes)) {
114
-            // now loop thru all of the datetimes
115
-            foreach ($datetimes as $datetime) {
116
-                if ($datetime instanceof EE_Datetime) {
117
-                    // the number of spaces available for the datetime without considering individual ticket quantities
118
-                    $spaces_remaining = $datetime->spaces_remaining();
119
-                    // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
120
-                    // or the datetime spaces remaining) to this ticket using the datetime ID as the key
121
-                    $this->available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
122
-                        $ticket->qty() - $ticket->sold(),
123
-                        $spaces_remaining
124
-                    );
125
-                    // if the remaining spaces for this datetime is already set,
126
-                    // then compare that against the datetime spaces remaining, and take the lowest number,
127
-                    // else just take the datetime spaces remaining, and assign to the datetimes array
128
-                    $this->available_spaces['datetimes'][ $datetime->ID() ] = isset(
129
-                        $this->available_spaces['datetimes'][ $datetime->ID() ]
130
-                    )
131
-                        ? min($this->available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
132
-                        : $spaces_remaining;
133
-                }
134
-            }
135
-        }
136
-    }
137
-
138
-
139
-    /**
140
-     * @param    EE_Ticket $ticket
141
-     * @param    int       $qty
142
-     * @return    void
143
-     * @throws EE_Error
144
-     */
145
-    public function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
146
-    {
147
-        if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
148
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
149
-            foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
150
-                // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
151
-                $this->available_spaces['datetimes'][ $DTD_ID ] -= $qty;
152
-            }
153
-        }
154
-    }
155
-
156
-
157
-    /**
158
-     * @param EE_Ticket $ticket
159
-     * @param           $qty
160
-     * @param int       $total_ticket_count
161
-     * @throws EE_Error
162
-     * @throws InvalidArgumentException
163
-     * @throws InvalidDataTypeException
164
-     * @throws InvalidInterfaceException
165
-     */
166
-    public function processAvailabilityError(EE_Ticket $ticket, $qty, $total_ticket_count = 1)
167
-    {
168
-        // tickets can not be purchased but let's find the exact number left
169
-        // for the last ticket selected PRIOR to subtracting tickets
170
-        $available_spaces = $this->ticketDatetimeAvailability($ticket, true);
171
-        // greedy greedy greedy eh?
172
-        if ($available_spaces > 0) {
173
-            if (
174
-                apply_filters(
175
-                    'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
176
-                    true,
177
-                    $ticket,
178
-                    $qty,
179
-                    $available_spaces
180
-                )
181
-            ) {
182
-                $this->availabilityError(
183
-                    $available_spaces,
184
-                    $total_ticket_count
185
-                );
186
-            }
187
-        } else {
188
-            EE_Error::add_error(
189
-                esc_html__(
190
-                    'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
191
-                    'event_espresso'
192
-                ),
193
-                __FILE__,
194
-                __FUNCTION__,
195
-                __LINE__
196
-            );
197
-        }
198
-    }
199
-
200
-
201
-    /**
202
-     * @param int $available_spaces
203
-     * @param int $total_ticket_count
204
-     */
205
-    private function availabilityError($available_spaces = 1, $total_ticket_count = 1)
206
-    {
207
-        // add error messaging - we're using the _n function that will generate
208
-        // the appropriate singular or plural message based on the number of $available_spaces
209
-        if ($total_ticket_count) {
210
-            $msg = sprintf(
211
-                esc_html(
212
-                    _n(
213
-                        'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
214
-                        'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
215
-                        $available_spaces,
216
-                        'event_espresso'
217
-                    )
218
-                ),
219
-                $available_spaces,
220
-                '<br />'
221
-            );
222
-        } else {
223
-            $msg = sprintf(
224
-                esc_html(
225
-                    _n(
226
-                        'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
227
-                        'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
228
-                        $available_spaces,
229
-                        'event_espresso'
230
-                    )
231
-                ),
232
-                $available_spaces,
233
-                '<br />'
234
-            );
235
-        }
236
-        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
237
-    }
25
+	/**
26
+	 * array of datetimes and the spaces available for them
27
+	 *
28
+	 * @var array[][]
29
+	 */
30
+	private $available_spaces = array();
31
+
32
+	/**
33
+	 * @var EEM_Datetime $datetime_model
34
+	 */
35
+	private $datetime_model;
36
+
37
+
38
+	/**
39
+	 * TicketDatetimeAvailabilityTracker constructor.
40
+	 *
41
+	 * @param EEM_Datetime $datetime_model
42
+	 */
43
+	public function __construct(EEM_Datetime $datetime_model)
44
+	{
45
+		$this->datetime_model = $datetime_model;
46
+	}
47
+
48
+
49
+	/**
50
+	 * ticketDatetimeAvailability
51
+	 * creates an array of tickets plus all of the datetimes available to each ticket
52
+	 * and tracks the spaces remaining for each of those datetimes
53
+	 *
54
+	 * @param EE_Ticket $ticket - selected ticket
55
+	 * @param bool      $get_original_ticket_spaces
56
+	 * @return int
57
+	 * @throws EE_Error
58
+	 * @throws InvalidArgumentException
59
+	 * @throws InvalidDataTypeException
60
+	 * @throws InvalidInterfaceException
61
+	 */
62
+	public function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
63
+	{
64
+		// if the $_available_spaces array has not been set up yet...
65
+		if (! isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
66
+			$this->setInitialTicketDatetimeAvailability($ticket);
67
+		}
68
+		$available_spaces = $ticket->qty() - $ticket->sold();
69
+		if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
70
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
71
+			foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
72
+				// if we want the original datetime availability BEFORE we started subtracting tickets ?
73
+				if ($get_original_ticket_spaces) {
74
+					// then grab the available spaces from the "tickets" array
75
+					// and compare with the above to get the lowest number
76
+					$available_spaces = min(
77
+						$available_spaces,
78
+						$this->available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
79
+					);
80
+				} else {
81
+					// we want the updated ticket availability as stored in the "datetimes" array
82
+					$available_spaces = min($available_spaces, $this->available_spaces['datetimes'][ $DTD_ID ]);
83
+				}
84
+			}
85
+		}
86
+		return $available_spaces;
87
+	}
88
+
89
+
90
+	/**
91
+	 * @param EE_Ticket $ticket
92
+	 * @return void
93
+	 * @throws InvalidArgumentException
94
+	 * @throws InvalidInterfaceException
95
+	 * @throws InvalidDataTypeException
96
+	 * @throws EE_Error
97
+	 */
98
+	private function setInitialTicketDatetimeAvailability(EE_Ticket $ticket)
99
+	{
100
+		// first, get all of the datetimes that are available to this ticket
101
+		$datetimes = $ticket->get_many_related(
102
+			'Datetime',
103
+			array(
104
+				array(
105
+					'DTT_EVT_end' => array(
106
+						'>=',
107
+						$this->datetime_model->current_time_for_query('DTT_EVT_end'),
108
+					),
109
+				),
110
+				'order_by' => array('DTT_EVT_start' => 'ASC'),
111
+			)
112
+		);
113
+		if (! empty($datetimes)) {
114
+			// now loop thru all of the datetimes
115
+			foreach ($datetimes as $datetime) {
116
+				if ($datetime instanceof EE_Datetime) {
117
+					// the number of spaces available for the datetime without considering individual ticket quantities
118
+					$spaces_remaining = $datetime->spaces_remaining();
119
+					// save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
120
+					// or the datetime spaces remaining) to this ticket using the datetime ID as the key
121
+					$this->available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
122
+						$ticket->qty() - $ticket->sold(),
123
+						$spaces_remaining
124
+					);
125
+					// if the remaining spaces for this datetime is already set,
126
+					// then compare that against the datetime spaces remaining, and take the lowest number,
127
+					// else just take the datetime spaces remaining, and assign to the datetimes array
128
+					$this->available_spaces['datetimes'][ $datetime->ID() ] = isset(
129
+						$this->available_spaces['datetimes'][ $datetime->ID() ]
130
+					)
131
+						? min($this->available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
132
+						: $spaces_remaining;
133
+				}
134
+			}
135
+		}
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param    EE_Ticket $ticket
141
+	 * @param    int       $qty
142
+	 * @return    void
143
+	 * @throws EE_Error
144
+	 */
145
+	public function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
146
+	{
147
+		if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
148
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
149
+			foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
150
+				// subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
151
+				$this->available_spaces['datetimes'][ $DTD_ID ] -= $qty;
152
+			}
153
+		}
154
+	}
155
+
156
+
157
+	/**
158
+	 * @param EE_Ticket $ticket
159
+	 * @param           $qty
160
+	 * @param int       $total_ticket_count
161
+	 * @throws EE_Error
162
+	 * @throws InvalidArgumentException
163
+	 * @throws InvalidDataTypeException
164
+	 * @throws InvalidInterfaceException
165
+	 */
166
+	public function processAvailabilityError(EE_Ticket $ticket, $qty, $total_ticket_count = 1)
167
+	{
168
+		// tickets can not be purchased but let's find the exact number left
169
+		// for the last ticket selected PRIOR to subtracting tickets
170
+		$available_spaces = $this->ticketDatetimeAvailability($ticket, true);
171
+		// greedy greedy greedy eh?
172
+		if ($available_spaces > 0) {
173
+			if (
174
+				apply_filters(
175
+					'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
176
+					true,
177
+					$ticket,
178
+					$qty,
179
+					$available_spaces
180
+				)
181
+			) {
182
+				$this->availabilityError(
183
+					$available_spaces,
184
+					$total_ticket_count
185
+				);
186
+			}
187
+		} else {
188
+			EE_Error::add_error(
189
+				esc_html__(
190
+					'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
191
+					'event_espresso'
192
+				),
193
+				__FILE__,
194
+				__FUNCTION__,
195
+				__LINE__
196
+			);
197
+		}
198
+	}
199
+
200
+
201
+	/**
202
+	 * @param int $available_spaces
203
+	 * @param int $total_ticket_count
204
+	 */
205
+	private function availabilityError($available_spaces = 1, $total_ticket_count = 1)
206
+	{
207
+		// add error messaging - we're using the _n function that will generate
208
+		// the appropriate singular or plural message based on the number of $available_spaces
209
+		if ($total_ticket_count) {
210
+			$msg = sprintf(
211
+				esc_html(
212
+					_n(
213
+						'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
214
+						'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
215
+						$available_spaces,
216
+						'event_espresso'
217
+					)
218
+				),
219
+				$available_spaces,
220
+				'<br />'
221
+			);
222
+		} else {
223
+			$msg = sprintf(
224
+				esc_html(
225
+					_n(
226
+						'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
227
+						'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
228
+						$available_spaces,
229
+						'event_espresso'
230
+					)
231
+				),
232
+				$available_spaces,
233
+				'<br />'
234
+			);
235
+		}
236
+		EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
237
+	}
238 238
 }
Please login to merge, or discard this patch.
core/domain/entities/notifications/PersistentAdminNotice.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     private function setName($name)
132 132
     {
133
-        if (! is_string($name)) {
133
+        if ( ! is_string($name)) {
134 134
             throw new InvalidDataTypeException('$name', $name, 'string');
135 135
         }
136 136
         $this->name = sanitize_key($name);
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      */
155 155
     private function setMessage($message)
156 156
     {
157
-        if (! is_string($message)) {
157
+        if ( ! is_string($message)) {
158 158
             throw new InvalidDataTypeException('$message', $message, 'string');
159 159
         }
160 160
         global $allowedtags;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      */
201 201
     private function setCapability($capability)
202 202
     {
203
-        if (! is_string($capability)) {
203
+        if ( ! is_string($capability)) {
204 204
             throw new InvalidDataTypeException('$capability', $capability, 'string');
205 205
         }
206 206
         $this->capability = ! empty($capability) ? $capability : 'manage_options';
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      */
225 225
     private function setCapContext($cap_context)
226 226
     {
227
-        if (! is_string($cap_context)) {
227
+        if ( ! is_string($cap_context)) {
228 228
             throw new InvalidDataTypeException('$cap_context', $cap_context, 'string');
229 229
         }
230 230
         $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      */
259 259
     public function getCapCheck()
260 260
     {
261
-        if (! $this->cap_check instanceof CapCheckInterface) {
261
+        if ( ! $this->cap_check instanceof CapCheckInterface) {
262 262
             $this->setCapCheck(
263 263
                 new CapCheck(
264 264
                     $this->capability,
@@ -343,10 +343,10 @@  discard block
 block discarded – undo
343 343
      */
344 344
     public function confirmRegistered()
345 345
     {
346
-        if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
346
+        if ( ! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
347 347
             PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
348 348
         }
349
-        if (! $this->registered && WP_DEBUG) {
349
+        if ( ! $this->registered && WP_DEBUG) {
350 350
             throw new DomainException(
351 351
                 sprintf(
352 352
                     esc_html__(
Please login to merge, or discard this patch.
Indentation   +312 added lines, -312 removed lines patch added patch discarded remove patch
@@ -25,316 +25,316 @@
 block discarded – undo
25 25
 class PersistentAdminNotice implements RequiresCapCheckInterface
26 26
 {
27 27
 
28
-    /**
29
-     * @var string $name
30
-     */
31
-    protected $name = '';
32
-
33
-    /**
34
-     * @var string $message
35
-     */
36
-    protected $message = '';
37
-
38
-    /**
39
-     * @var boolean $force_update
40
-     */
41
-    protected $force_update = false;
42
-
43
-    /**
44
-     * @var string $capability
45
-     */
46
-    protected $capability = 'manage_options';
47
-
48
-    /**
49
-     * @var string $cap_context
50
-     */
51
-    protected $cap_context = 'view persistent admin notice';
52
-
53
-    /**
54
-     * @var boolean $dismissed
55
-     */
56
-    protected $dismissed = false;
57
-
58
-    /**
59
-     * @var CapCheckInterface $cap_check
60
-     */
61
-    protected $cap_check;
62
-
63
-    /**
64
-     * if true, then this notice will be deleted from the database
65
-     *
66
-     * @var boolean $purge
67
-     */
68
-    protected $purge = false;
69
-
70
-    /**
71
-     * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager
72
-     * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer
73
-     *
74
-     * @var boolean $registered
75
-     */
76
-    private $registered = false;
77
-
78
-
79
-    /**
80
-     * PersistentAdminNotice constructor
81
-     *
82
-     * @param string $name         [required] the name, or key of the Persistent Admin Notice to be stored
83
-     * @param string $message      [required] the message to be stored persistently until dismissed
84
-     * @param bool   $force_update enforce the reappearance of a persistent message
85
-     * @param string $capability   user capability required to view this notice
86
-     * @param string $cap_context  description for why the cap check is being performed
87
-     * @param bool   $dismissed    whether or not the user has already dismissed/viewed this notice
88
-     * @throws InvalidDataTypeException
89
-     */
90
-    public function __construct(
91
-        $name,
92
-        $message,
93
-        $force_update = false,
94
-        $capability = 'manage_options',
95
-        $cap_context = 'view persistent admin notice',
96
-        $dismissed = false
97
-    ) {
98
-        $this->setName($name);
99
-        $this->setMessage($message);
100
-        $this->setForceUpdate($force_update);
101
-        $this->setCapability($capability);
102
-        $this->setCapContext($cap_context);
103
-        $this->setDismissed($dismissed);
104
-        add_action(
105
-            'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
106
-            array($this, 'registerPersistentAdminNotice')
107
-        );
108
-        add_action('shutdown', array($this, 'confirmRegistered'), 999);
109
-    }
110
-
111
-
112
-    /**
113
-     * @return string
114
-     */
115
-    public function getName()
116
-    {
117
-        return $this->name;
118
-    }
119
-
120
-
121
-    /**
122
-     * @param string $name
123
-     * @throws InvalidDataTypeException
124
-     */
125
-    private function setName($name)
126
-    {
127
-        if (! is_string($name)) {
128
-            throw new InvalidDataTypeException('$name', $name, 'string');
129
-        }
130
-        $this->name = sanitize_key($name);
131
-    }
132
-
133
-
134
-    /**
135
-     * @return string
136
-     */
137
-    public function getMessage()
138
-    {
139
-        return $this->message;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param string $message
145
-     * @throws InvalidDataTypeException
146
-     */
147
-    private function setMessage($message)
148
-    {
149
-        if (! is_string($message)) {
150
-            throw new InvalidDataTypeException('$message', $message, 'string');
151
-        }
152
-        global $allowedtags;
153
-        $allowedtags['br'] = array();
154
-        $this->message = wp_kses($message, $allowedtags);
155
-    }
156
-
157
-
158
-    /**
159
-     * @return bool
160
-     */
161
-    public function getForceUpdate()
162
-    {
163
-        return $this->force_update;
164
-    }
165
-
166
-
167
-    /**
168
-     * @param bool $force_update
169
-     */
170
-    private function setForceUpdate($force_update)
171
-    {
172
-        $this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN);
173
-    }
174
-
175
-
176
-    /**
177
-     * @return string
178
-     */
179
-    public function getCapability()
180
-    {
181
-        return $this->capability;
182
-    }
183
-
184
-
185
-    /**
186
-     * @param string $capability
187
-     * @throws InvalidDataTypeException
188
-     */
189
-    private function setCapability($capability)
190
-    {
191
-        if (! is_string($capability)) {
192
-            throw new InvalidDataTypeException('$capability', $capability, 'string');
193
-        }
194
-        $this->capability = ! empty($capability) ? $capability : 'manage_options';
195
-    }
196
-
197
-
198
-    /**
199
-     * @return string
200
-     */
201
-    public function getCapContext()
202
-    {
203
-        return $this->cap_context;
204
-    }
205
-
206
-
207
-    /**
208
-     * @param string $cap_context
209
-     * @throws InvalidDataTypeException
210
-     */
211
-    private function setCapContext($cap_context)
212
-    {
213
-        if (! is_string($cap_context)) {
214
-            throw new InvalidDataTypeException('$cap_context', $cap_context, 'string');
215
-        }
216
-        $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
217
-    }
218
-
219
-
220
-    /**
221
-     * @return bool
222
-     */
223
-    public function getDismissed()
224
-    {
225
-        return $this->dismissed;
226
-    }
227
-
228
-
229
-    /**
230
-     * @param bool $dismissed
231
-     */
232
-    public function setDismissed($dismissed)
233
-    {
234
-        $this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN);
235
-    }
236
-
237
-
238
-    /**
239
-     * @return CapCheckInterface
240
-     * @throws InvalidDataTypeException
241
-     */
242
-    public function getCapCheck()
243
-    {
244
-        if (! $this->cap_check instanceof CapCheckInterface) {
245
-            $this->setCapCheck(
246
-                new CapCheck(
247
-                    $this->capability,
248
-                    $this->cap_context
249
-                )
250
-            );
251
-        }
252
-        return $this->cap_check;
253
-    }
254
-
255
-
256
-    /**
257
-     * @param CapCheckInterface $cap_check
258
-     */
259
-    private function setCapCheck(CapCheckInterface $cap_check)
260
-    {
261
-        $this->cap_check = $cap_check;
262
-    }
263
-
264
-
265
-    /**
266
-     * @return bool
267
-     */
268
-    public function getPurge()
269
-    {
270
-        return $this->purge;
271
-    }
272
-
273
-
274
-    /**
275
-     * @param bool $purge
276
-     */
277
-    public function setPurge($purge)
278
-    {
279
-        $this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN);
280
-    }
281
-
282
-
283
-    /**
284
-     * given a valid PersistentAdminNotice Collection,
285
-     * this notice will be added if it is not already found in the collection (using its name as the identifier)
286
-     * if an existing notice is found that has already been dismissed,
287
-     * but we are overriding with a forced update, then we will toggle its dismissed state,
288
-     * so that the notice is displayed again
289
-     *
290
-     * @param Collection $persistent_admin_notice_collection
291
-     * @throws InvalidEntityException
292
-     * @throws InvalidDataTypeException
293
-     * @throws DuplicateCollectionIdentifierException
294
-     */
295
-    public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection)
296
-    {
297
-        if ($this->registered) {
298
-            return;
299
-        }
300
-        // first check if this notice has already been added to the collection
301
-        if ($persistent_admin_notice_collection->has($this->name)) {
302
-            /** @var PersistentAdminNotice $existing */
303
-            $existing = $persistent_admin_notice_collection->get($this->name);
304
-            // we don't need to add it again (we can't actually)
305
-            // but if it has already been dismissed, and we are overriding with a forced update
306
-            if ($existing->getDismissed() && $this->getForceUpdate()) {
307
-                // then toggle the notice's dismissed state to true
308
-                // so that it gets displayed again
309
-                $existing->setDismissed(false);
310
-                // and make sure the message is set
311
-                $existing->setMessage($this->message);
312
-            }
313
-        } else {
314
-            $persistent_admin_notice_collection->add($this, $this->name);
315
-        }
316
-        $this->registered = true;
317
-    }
318
-
319
-
320
-    /**
321
-     * @throws Exception
322
-     */
323
-    public function confirmRegistered()
324
-    {
325
-        if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
326
-            PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
327
-        }
328
-        if (! $this->registered && WP_DEBUG) {
329
-            throw new DomainException(
330
-                sprintf(
331
-                    esc_html__(
332
-                        'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.',
333
-                        'event_espresso'
334
-                    ),
335
-                    $this->name
336
-                )
337
-            );
338
-        }
339
-    }
28
+	/**
29
+	 * @var string $name
30
+	 */
31
+	protected $name = '';
32
+
33
+	/**
34
+	 * @var string $message
35
+	 */
36
+	protected $message = '';
37
+
38
+	/**
39
+	 * @var boolean $force_update
40
+	 */
41
+	protected $force_update = false;
42
+
43
+	/**
44
+	 * @var string $capability
45
+	 */
46
+	protected $capability = 'manage_options';
47
+
48
+	/**
49
+	 * @var string $cap_context
50
+	 */
51
+	protected $cap_context = 'view persistent admin notice';
52
+
53
+	/**
54
+	 * @var boolean $dismissed
55
+	 */
56
+	protected $dismissed = false;
57
+
58
+	/**
59
+	 * @var CapCheckInterface $cap_check
60
+	 */
61
+	protected $cap_check;
62
+
63
+	/**
64
+	 * if true, then this notice will be deleted from the database
65
+	 *
66
+	 * @var boolean $purge
67
+	 */
68
+	protected $purge = false;
69
+
70
+	/**
71
+	 * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager
72
+	 * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer
73
+	 *
74
+	 * @var boolean $registered
75
+	 */
76
+	private $registered = false;
77
+
78
+
79
+	/**
80
+	 * PersistentAdminNotice constructor
81
+	 *
82
+	 * @param string $name         [required] the name, or key of the Persistent Admin Notice to be stored
83
+	 * @param string $message      [required] the message to be stored persistently until dismissed
84
+	 * @param bool   $force_update enforce the reappearance of a persistent message
85
+	 * @param string $capability   user capability required to view this notice
86
+	 * @param string $cap_context  description for why the cap check is being performed
87
+	 * @param bool   $dismissed    whether or not the user has already dismissed/viewed this notice
88
+	 * @throws InvalidDataTypeException
89
+	 */
90
+	public function __construct(
91
+		$name,
92
+		$message,
93
+		$force_update = false,
94
+		$capability = 'manage_options',
95
+		$cap_context = 'view persistent admin notice',
96
+		$dismissed = false
97
+	) {
98
+		$this->setName($name);
99
+		$this->setMessage($message);
100
+		$this->setForceUpdate($force_update);
101
+		$this->setCapability($capability);
102
+		$this->setCapContext($cap_context);
103
+		$this->setDismissed($dismissed);
104
+		add_action(
105
+			'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
106
+			array($this, 'registerPersistentAdminNotice')
107
+		);
108
+		add_action('shutdown', array($this, 'confirmRegistered'), 999);
109
+	}
110
+
111
+
112
+	/**
113
+	 * @return string
114
+	 */
115
+	public function getName()
116
+	{
117
+		return $this->name;
118
+	}
119
+
120
+
121
+	/**
122
+	 * @param string $name
123
+	 * @throws InvalidDataTypeException
124
+	 */
125
+	private function setName($name)
126
+	{
127
+		if (! is_string($name)) {
128
+			throw new InvalidDataTypeException('$name', $name, 'string');
129
+		}
130
+		$this->name = sanitize_key($name);
131
+	}
132
+
133
+
134
+	/**
135
+	 * @return string
136
+	 */
137
+	public function getMessage()
138
+	{
139
+		return $this->message;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param string $message
145
+	 * @throws InvalidDataTypeException
146
+	 */
147
+	private function setMessage($message)
148
+	{
149
+		if (! is_string($message)) {
150
+			throw new InvalidDataTypeException('$message', $message, 'string');
151
+		}
152
+		global $allowedtags;
153
+		$allowedtags['br'] = array();
154
+		$this->message = wp_kses($message, $allowedtags);
155
+	}
156
+
157
+
158
+	/**
159
+	 * @return bool
160
+	 */
161
+	public function getForceUpdate()
162
+	{
163
+		return $this->force_update;
164
+	}
165
+
166
+
167
+	/**
168
+	 * @param bool $force_update
169
+	 */
170
+	private function setForceUpdate($force_update)
171
+	{
172
+		$this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN);
173
+	}
174
+
175
+
176
+	/**
177
+	 * @return string
178
+	 */
179
+	public function getCapability()
180
+	{
181
+		return $this->capability;
182
+	}
183
+
184
+
185
+	/**
186
+	 * @param string $capability
187
+	 * @throws InvalidDataTypeException
188
+	 */
189
+	private function setCapability($capability)
190
+	{
191
+		if (! is_string($capability)) {
192
+			throw new InvalidDataTypeException('$capability', $capability, 'string');
193
+		}
194
+		$this->capability = ! empty($capability) ? $capability : 'manage_options';
195
+	}
196
+
197
+
198
+	/**
199
+	 * @return string
200
+	 */
201
+	public function getCapContext()
202
+	{
203
+		return $this->cap_context;
204
+	}
205
+
206
+
207
+	/**
208
+	 * @param string $cap_context
209
+	 * @throws InvalidDataTypeException
210
+	 */
211
+	private function setCapContext($cap_context)
212
+	{
213
+		if (! is_string($cap_context)) {
214
+			throw new InvalidDataTypeException('$cap_context', $cap_context, 'string');
215
+		}
216
+		$this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
217
+	}
218
+
219
+
220
+	/**
221
+	 * @return bool
222
+	 */
223
+	public function getDismissed()
224
+	{
225
+		return $this->dismissed;
226
+	}
227
+
228
+
229
+	/**
230
+	 * @param bool $dismissed
231
+	 */
232
+	public function setDismissed($dismissed)
233
+	{
234
+		$this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN);
235
+	}
236
+
237
+
238
+	/**
239
+	 * @return CapCheckInterface
240
+	 * @throws InvalidDataTypeException
241
+	 */
242
+	public function getCapCheck()
243
+	{
244
+		if (! $this->cap_check instanceof CapCheckInterface) {
245
+			$this->setCapCheck(
246
+				new CapCheck(
247
+					$this->capability,
248
+					$this->cap_context
249
+				)
250
+			);
251
+		}
252
+		return $this->cap_check;
253
+	}
254
+
255
+
256
+	/**
257
+	 * @param CapCheckInterface $cap_check
258
+	 */
259
+	private function setCapCheck(CapCheckInterface $cap_check)
260
+	{
261
+		$this->cap_check = $cap_check;
262
+	}
263
+
264
+
265
+	/**
266
+	 * @return bool
267
+	 */
268
+	public function getPurge()
269
+	{
270
+		return $this->purge;
271
+	}
272
+
273
+
274
+	/**
275
+	 * @param bool $purge
276
+	 */
277
+	public function setPurge($purge)
278
+	{
279
+		$this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN);
280
+	}
281
+
282
+
283
+	/**
284
+	 * given a valid PersistentAdminNotice Collection,
285
+	 * this notice will be added if it is not already found in the collection (using its name as the identifier)
286
+	 * if an existing notice is found that has already been dismissed,
287
+	 * but we are overriding with a forced update, then we will toggle its dismissed state,
288
+	 * so that the notice is displayed again
289
+	 *
290
+	 * @param Collection $persistent_admin_notice_collection
291
+	 * @throws InvalidEntityException
292
+	 * @throws InvalidDataTypeException
293
+	 * @throws DuplicateCollectionIdentifierException
294
+	 */
295
+	public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection)
296
+	{
297
+		if ($this->registered) {
298
+			return;
299
+		}
300
+		// first check if this notice has already been added to the collection
301
+		if ($persistent_admin_notice_collection->has($this->name)) {
302
+			/** @var PersistentAdminNotice $existing */
303
+			$existing = $persistent_admin_notice_collection->get($this->name);
304
+			// we don't need to add it again (we can't actually)
305
+			// but if it has already been dismissed, and we are overriding with a forced update
306
+			if ($existing->getDismissed() && $this->getForceUpdate()) {
307
+				// then toggle the notice's dismissed state to true
308
+				// so that it gets displayed again
309
+				$existing->setDismissed(false);
310
+				// and make sure the message is set
311
+				$existing->setMessage($this->message);
312
+			}
313
+		} else {
314
+			$persistent_admin_notice_collection->add($this, $this->name);
315
+		}
316
+		$this->registered = true;
317
+	}
318
+
319
+
320
+	/**
321
+	 * @throws Exception
322
+	 */
323
+	public function confirmRegistered()
324
+	{
325
+		if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
326
+			PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
327
+		}
328
+		if (! $this->registered && WP_DEBUG) {
329
+			throw new DomainException(
330
+				sprintf(
331
+					esc_html__(
332
+						'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.',
333
+						'event_espresso'
334
+					),
335
+					$this->name
336
+				)
337
+			);
338
+		}
339
+	}
340 340
 }
Please login to merge, or discard this patch.
admin_pages/payments/Payment_Log_Admin_List_Table.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@
 block discarded – undo
101 101
     /**
102 102
      * _get_table_filters
103 103
      *
104
-     * @return array
104
+     * @return string[]
105 105
      */
106 106
     protected function _get_table_filters()
107 107
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
              . __(
57 57
                  'Download Results',
58 58
                  'event_espresso'
59
-             ) . "'>";
59
+             )."'>";
60 60
     }
61 61
 
62 62
 
Please login to merge, or discard this patch.
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -13,111 +13,111 @@  discard block
 block discarded – undo
13 13
 class Payment_Log_Admin_List_Table extends EE_Admin_List_Table
14 14
 {
15 15
 
16
-    /**
17
-     * @param \EE_Admin_Page $admin_page
18
-     * @return Payment_Log_Admin_List_Table
19
-     */
20
-    public function __construct($admin_page)
21
-    {
22
-        parent::__construct($admin_page);
23
-    }
24
-
25
-
26
-    /**
27
-     * _setup_data
28
-     *
29
-     * @return void
30
-     */
31
-    protected function _setup_data()
32
-    {
33
-        $this->_data = $this->_admin_page->get_payment_logs($this->_per_page, $this->_current_page);
34
-        // if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'trash') {
35
-        //     $this->_data = $this->_admin_page->get_trashed_questions($this->_per_page, $this->_current_page, false);
36
-        // } else {
37
-        //     $this->_data = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, false);
38
-        // }
39
-        $this->_all_data_count = $this->_admin_page->get_payment_logs($this->_per_page, $this->_current_page, true);
40
-        add_action(
41
-            'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
42
-            array($this, 'add_download_logs_checkbox')
43
-        );
44
-    }
45
-
46
-
47
-    /**
48
-     * add_download_logs_checkbox
49
-     * adds a checkbox to the bottom of the list table, instead of at the top with the rest of the filters
50
-     *
51
-     * @return void
52
-     */
53
-    public function add_download_logs_checkbox()
54
-    {
55
-        echo "<input type='submit' class='button-primary' id='download_results' name='download_results' value='"
56
-             . __(
57
-                 'Download Results',
58
-                 'event_espresso'
59
-             ) . "'>";
60
-    }
61
-
62
-
63
-    /**
64
-     * _set_properties
65
-     *
66
-     * @return void
67
-     */
68
-    protected function _set_properties()
69
-    {
70
-        $this->_wp_list_args = array(
71
-            'singular' => __('payment log', 'event_espresso'),
72
-            'plural'   => __('payment logs', 'event_espresso'),
73
-            'ajax'     => true, // for now,
74
-            'screen'   => $this->_admin_page->get_current_screen()->id,
75
-        );
76
-        $this->_columns = array(
77
-            'cb'       => '<input type="checkbox" />',
78
-            'id'       => __('ID', 'event_espresso'),
79
-            'LOG_time' => __('Time', 'event_espresso'),
80
-            'PMD_ID'   => __('Payment Method', 'event_espresso'),
81
-            'TXN_ID'   => __('Transaction ID', 'event_espresso'),
82
-        );
83
-        $this->_sortable_columns = array(
84
-            'LOG_time' => array('LOG_time' => true),
85
-        );
86
-        $this->_hidden_columns = array();
87
-    }
88
-
89
-
90
-    /**
91
-     * _get_table_filters
92
-     *
93
-     * @return array
94
-     */
95
-    protected function _get_table_filters()
96
-    {
97
-        $filters = array();
98
-        // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
99
-        $payment_methods = EEM_Payment_Method::instance()->get_all();
100
-        $payment_method_names = array(
101
-            array('id' => 'all', 'text' => __("All", 'event_espresso')),
102
-            array('id' => '0', 'text' => __("Unknown Payment Method", 'event_espresso')),
103
-        );
104
-        foreach ($payment_methods as $payment_method) {
105
-            $payment_method_names[] = array('id' => $payment_method->ID(), 'text' => $payment_method->admin_name());
106
-        }
107
-        $filters[] = EEH_Form_Fields::select_input(
108
-            '_payment_method',
109
-            $payment_method_names,
110
-            isset($this->_req_data['_payment_method'])
111
-                ? $this->_req_data['_payment_method'] : 'all'
112
-        );
113
-        $start_date = isset($this->_req_data['payment-filter-start-date']) ? wp_strip_all_tags(
114
-            $this->_req_data['payment-filter-start-date']
115
-        ) : date('m/d/Y', strtotime('-6 months'));
116
-        $end_date = isset($this->_req_data['payment-filter-end-date']) ? wp_strip_all_tags(
117
-            $this->_req_data['payment-filter-end-date']
118
-        ) : date('m/d/Y');
119
-        ob_start();
120
-        ?>
16
+	/**
17
+	 * @param \EE_Admin_Page $admin_page
18
+	 * @return Payment_Log_Admin_List_Table
19
+	 */
20
+	public function __construct($admin_page)
21
+	{
22
+		parent::__construct($admin_page);
23
+	}
24
+
25
+
26
+	/**
27
+	 * _setup_data
28
+	 *
29
+	 * @return void
30
+	 */
31
+	protected function _setup_data()
32
+	{
33
+		$this->_data = $this->_admin_page->get_payment_logs($this->_per_page, $this->_current_page);
34
+		// if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'trash') {
35
+		//     $this->_data = $this->_admin_page->get_trashed_questions($this->_per_page, $this->_current_page, false);
36
+		// } else {
37
+		//     $this->_data = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, false);
38
+		// }
39
+		$this->_all_data_count = $this->_admin_page->get_payment_logs($this->_per_page, $this->_current_page, true);
40
+		add_action(
41
+			'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
42
+			array($this, 'add_download_logs_checkbox')
43
+		);
44
+	}
45
+
46
+
47
+	/**
48
+	 * add_download_logs_checkbox
49
+	 * adds a checkbox to the bottom of the list table, instead of at the top with the rest of the filters
50
+	 *
51
+	 * @return void
52
+	 */
53
+	public function add_download_logs_checkbox()
54
+	{
55
+		echo "<input type='submit' class='button-primary' id='download_results' name='download_results' value='"
56
+			 . __(
57
+				 'Download Results',
58
+				 'event_espresso'
59
+			 ) . "'>";
60
+	}
61
+
62
+
63
+	/**
64
+	 * _set_properties
65
+	 *
66
+	 * @return void
67
+	 */
68
+	protected function _set_properties()
69
+	{
70
+		$this->_wp_list_args = array(
71
+			'singular' => __('payment log', 'event_espresso'),
72
+			'plural'   => __('payment logs', 'event_espresso'),
73
+			'ajax'     => true, // for now,
74
+			'screen'   => $this->_admin_page->get_current_screen()->id,
75
+		);
76
+		$this->_columns = array(
77
+			'cb'       => '<input type="checkbox" />',
78
+			'id'       => __('ID', 'event_espresso'),
79
+			'LOG_time' => __('Time', 'event_espresso'),
80
+			'PMD_ID'   => __('Payment Method', 'event_espresso'),
81
+			'TXN_ID'   => __('Transaction ID', 'event_espresso'),
82
+		);
83
+		$this->_sortable_columns = array(
84
+			'LOG_time' => array('LOG_time' => true),
85
+		);
86
+		$this->_hidden_columns = array();
87
+	}
88
+
89
+
90
+	/**
91
+	 * _get_table_filters
92
+	 *
93
+	 * @return array
94
+	 */
95
+	protected function _get_table_filters()
96
+	{
97
+		$filters = array();
98
+		// todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
99
+		$payment_methods = EEM_Payment_Method::instance()->get_all();
100
+		$payment_method_names = array(
101
+			array('id' => 'all', 'text' => __("All", 'event_espresso')),
102
+			array('id' => '0', 'text' => __("Unknown Payment Method", 'event_espresso')),
103
+		);
104
+		foreach ($payment_methods as $payment_method) {
105
+			$payment_method_names[] = array('id' => $payment_method->ID(), 'text' => $payment_method->admin_name());
106
+		}
107
+		$filters[] = EEH_Form_Fields::select_input(
108
+			'_payment_method',
109
+			$payment_method_names,
110
+			isset($this->_req_data['_payment_method'])
111
+				? $this->_req_data['_payment_method'] : 'all'
112
+		);
113
+		$start_date = isset($this->_req_data['payment-filter-start-date']) ? wp_strip_all_tags(
114
+			$this->_req_data['payment-filter-start-date']
115
+		) : date('m/d/Y', strtotime('-6 months'));
116
+		$end_date = isset($this->_req_data['payment-filter-end-date']) ? wp_strip_all_tags(
117
+			$this->_req_data['payment-filter-end-date']
118
+		) : date('m/d/Y');
119
+		ob_start();
120
+		?>
121 121
         <label for="txn-filter-start-date"><?php _e('Display Transactions from ', 'event_espresso'); ?></label>
122 122
         <input id="payment-filter-start-date" class="datepicker" type="text" value="<?php echo $start_date; ?>"
123 123
                name="payment-filter-start-date" size="15"/>
@@ -125,126 +125,126 @@  discard block
 block discarded – undo
125 125
         <input id="payment-filter-end-date" class="datepicker" type="text" value="<?php echo $end_date; ?>"
126 126
                name="payment-filter-end-date" size="15"/>
127 127
         <?php
128
-        $filters[] = ob_get_clean();
129
-        return $filters;
130
-    }
131
-
132
-
133
-    /**
134
-     * _add_view_counts
135
-     *
136
-     * @return void
137
-     */
138
-    protected function _add_view_counts()
139
-    {
140
-        $this->_views['all']['count'] = $this->_admin_page->get_payment_logs(
141
-            $this->_per_page,
142
-            $this->_current_page,
143
-            true
144
-        );
145
-    }
146
-
147
-
148
-    /**
149
-     * column_cb
150
-     *
151
-     * @param \EE_Change_Log $item
152
-     * @return string
153
-     */
154
-    public function column_cb($item)
155
-    {
156
-        return sprintf('<input type="checkbox" class="option_id" name="checkbox[%1$d]" value="%1$d" />', $item->ID());
157
-    }
158
-
159
-
160
-    /**
161
-     * column_id
162
-     *
163
-     * @param \EE_Change_Log $item
164
-     * @return string
165
-     */
166
-    public function column_id(EE_Change_Log $item)
167
-    {
168
-        $details_query_args = array(
169
-            'action' => 'payment_log_details',
170
-            'ID'     => $item->ID(),
171
-        );
172
-        $url = EE_Admin_Page::add_query_args_and_nonce($details_query_args, EE_PAYMENTS_ADMIN_URL);
173
-        return "<a href='$url'>{$item->ID()}</a>";
174
-    }
175
-
176
-
177
-    /**
178
-     * column_LOG_time
179
-     *
180
-     * @param \EE_Change_Log $item
181
-     * @return string
182
-     */
183
-    public function column_LOG_time(EE_Change_Log $item)
184
-    {
185
-        return $item->get_datetime('LOG_time');
186
-    }
187
-
188
-
189
-    /**
190
-     * column_PMD_ID
191
-     *
192
-     * @param \EE_Change_Log $item
193
-     * @return string
194
-     */
195
-    public function column_PMD_ID(EE_Change_Log $item)
196
-    {
197
-        if ($item->object() instanceof EE_Payment_Method) {
198
-            return $item->object()->admin_name();
199
-        } elseif ($item->object() instanceof EE_Payment && $item->object()->payment_method()) {
200
-            return $item->object()->payment_method()->admin_name();
201
-        } elseif ($item->object() instanceof EE_Transaction) {
202
-            return esc_html__('Unknown', 'event_espresso');
203
-        } else {
204
-            return esc_html__("No longer exists", 'event_espresso');
205
-        }
206
-    }
207
-
208
-
209
-    /**
210
-     * column_TXN_ID
211
-     *
212
-     * @param \EE_Change_Log $item
213
-     * @return string
214
-     */
215
-    public function column_TXN_ID(EE_Change_Log $item)
216
-    {
217
-        if ($item->object() instanceof EE_Payment) {
218
-            $transaction_id = $item->object()->TXN_ID();
219
-        } elseif ($item->object() instanceof EE_Transaction) {
220
-            $transaction_id = $item->object()->ID();
221
-        } else {
222
-            $transaction_id = null;
223
-        }
224
-        if (
225
-            $transaction_id
226
-            && EE_Registry::instance()->CAP->current_user_can(
227
-                'ee_read_transaction',
228
-                'espresso_transactions_view_transaction',
229
-                $transaction_id
230
-            )
231
-        ) {
232
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
233
-                array('action' => 'view_transaction', 'TXN_ID' => $transaction_id),
234
-                TXN_ADMIN_URL
235
-            );
236
-            return '<a href="'
237
-                   . $view_txn_lnk_url
238
-                   . '"  title="'
239
-                   . sprintf(
240
-                       esc_attr__('click to view transaction #%s', 'event_espresso'),
241
-                       $transaction_id
242
-                   )
243
-                   . '">'
244
-                   . sprintf(esc_html__('view txn %s', 'event_espresso'), $transaction_id)
245
-                   . '</a>';
246
-        }
247
-        // No transaction id or use can not view the transaction.
248
-        return __("Unable to find transaction", 'event_espresso');
249
-    }
128
+		$filters[] = ob_get_clean();
129
+		return $filters;
130
+	}
131
+
132
+
133
+	/**
134
+	 * _add_view_counts
135
+	 *
136
+	 * @return void
137
+	 */
138
+	protected function _add_view_counts()
139
+	{
140
+		$this->_views['all']['count'] = $this->_admin_page->get_payment_logs(
141
+			$this->_per_page,
142
+			$this->_current_page,
143
+			true
144
+		);
145
+	}
146
+
147
+
148
+	/**
149
+	 * column_cb
150
+	 *
151
+	 * @param \EE_Change_Log $item
152
+	 * @return string
153
+	 */
154
+	public function column_cb($item)
155
+	{
156
+		return sprintf('<input type="checkbox" class="option_id" name="checkbox[%1$d]" value="%1$d" />', $item->ID());
157
+	}
158
+
159
+
160
+	/**
161
+	 * column_id
162
+	 *
163
+	 * @param \EE_Change_Log $item
164
+	 * @return string
165
+	 */
166
+	public function column_id(EE_Change_Log $item)
167
+	{
168
+		$details_query_args = array(
169
+			'action' => 'payment_log_details',
170
+			'ID'     => $item->ID(),
171
+		);
172
+		$url = EE_Admin_Page::add_query_args_and_nonce($details_query_args, EE_PAYMENTS_ADMIN_URL);
173
+		return "<a href='$url'>{$item->ID()}</a>";
174
+	}
175
+
176
+
177
+	/**
178
+	 * column_LOG_time
179
+	 *
180
+	 * @param \EE_Change_Log $item
181
+	 * @return string
182
+	 */
183
+	public function column_LOG_time(EE_Change_Log $item)
184
+	{
185
+		return $item->get_datetime('LOG_time');
186
+	}
187
+
188
+
189
+	/**
190
+	 * column_PMD_ID
191
+	 *
192
+	 * @param \EE_Change_Log $item
193
+	 * @return string
194
+	 */
195
+	public function column_PMD_ID(EE_Change_Log $item)
196
+	{
197
+		if ($item->object() instanceof EE_Payment_Method) {
198
+			return $item->object()->admin_name();
199
+		} elseif ($item->object() instanceof EE_Payment && $item->object()->payment_method()) {
200
+			return $item->object()->payment_method()->admin_name();
201
+		} elseif ($item->object() instanceof EE_Transaction) {
202
+			return esc_html__('Unknown', 'event_espresso');
203
+		} else {
204
+			return esc_html__("No longer exists", 'event_espresso');
205
+		}
206
+	}
207
+
208
+
209
+	/**
210
+	 * column_TXN_ID
211
+	 *
212
+	 * @param \EE_Change_Log $item
213
+	 * @return string
214
+	 */
215
+	public function column_TXN_ID(EE_Change_Log $item)
216
+	{
217
+		if ($item->object() instanceof EE_Payment) {
218
+			$transaction_id = $item->object()->TXN_ID();
219
+		} elseif ($item->object() instanceof EE_Transaction) {
220
+			$transaction_id = $item->object()->ID();
221
+		} else {
222
+			$transaction_id = null;
223
+		}
224
+		if (
225
+			$transaction_id
226
+			&& EE_Registry::instance()->CAP->current_user_can(
227
+				'ee_read_transaction',
228
+				'espresso_transactions_view_transaction',
229
+				$transaction_id
230
+			)
231
+		) {
232
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
233
+				array('action' => 'view_transaction', 'TXN_ID' => $transaction_id),
234
+				TXN_ADMIN_URL
235
+			);
236
+			return '<a href="'
237
+				   . $view_txn_lnk_url
238
+				   . '"  title="'
239
+				   . sprintf(
240
+					   esc_attr__('click to view transaction #%s', 'event_espresso'),
241
+					   $transaction_id
242
+				   )
243
+				   . '">'
244
+				   . sprintf(esc_html__('view txn %s', 'event_espresso'), $transaction_id)
245
+				   . '</a>';
246
+		}
247
+		// No transaction id or use can not view the transaction.
248
+		return __("Unable to find transaction", 'event_espresso');
249
+	}
250 250
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Datetime.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
      * @param string $dt_frmt     string representation of date format defaults to WP settings
579 579
      * @param string $conjunction conjunction junction what's your function ?
580 580
      *                            this string joins the start date with the end date ie: Jan 01 "to" Dec 31
581
-     * @return mixed              string on success, FALSE on fail
581
+     * @return string              string on success, FALSE on fail
582 582
      * @throws ReflectionException
583 583
      * @throws InvalidArgumentException
584 584
      * @throws InvalidInterfaceException
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
      * @param string $tm_format   string representation of time format defaults to 'g:i a'
687 687
      * @param string $conjunction conjunction junction what's your function ?
688 688
      *                            this string joins the start date with the end date ie: Jan 01 "to" Dec 31
689
-     * @return mixed              string on success, FALSE on fail
689
+     * @return string              string on success, FALSE on fail
690 690
      * @throws ReflectionException
691 691
      * @throws InvalidArgumentException
692 692
      * @throws InvalidInterfaceException
Please login to merge, or discard this patch.
Indentation   +1404 added lines, -1404 removed lines patch added patch discarded remove patch
@@ -13,1412 +13,1412 @@
 block discarded – undo
13 13
 class EE_Datetime extends EE_Soft_Delete_Base_Class
14 14
 {
15 15
 
16
-    /**
17
-     * constant used by get_active_status, indicates datetime has no more available spaces
18
-     */
19
-    const sold_out = 'DTS';
20
-
21
-    /**
22
-     * constant used by get_active_status, indicating datetime is still active (even is not over, can be registered-for)
23
-     */
24
-    const active = 'DTA';
25
-
26
-    /**
27
-     * constant used by get_active_status, indicating the datetime cannot be used for registrations yet, but has not
28
-     * expired
29
-     */
30
-    const upcoming = 'DTU';
31
-
32
-    /**
33
-     * Datetime is postponed
34
-     */
35
-    const postponed = 'DTP';
36
-
37
-    /**
38
-     * Datetime is cancelled
39
-     */
40
-    const cancelled = 'DTC';
41
-
42
-    /**
43
-     * constant used by get_active_status, indicates datetime has expired (event is over)
44
-     */
45
-    const expired = 'DTE';
46
-
47
-    /**
48
-     * constant used in various places indicating that an event is INACTIVE (not yet ready to be published)
49
-     */
50
-    const inactive = 'DTI';
51
-
52
-
53
-    /**
54
-     * @param array  $props_n_values    incoming values
55
-     * @param string $timezone          incoming timezone (if not set the timezone set for the website will be used.)
56
-     * @param array  $date_formats      incoming date_formats in an array where the first value is the date_format
57
-     *                                  and the second value is the time format
58
-     * @return EE_Datetime
59
-     * @throws ReflectionException
60
-     * @throws InvalidArgumentException
61
-     * @throws InvalidInterfaceException
62
-     * @throws InvalidDataTypeException
63
-     * @throws EE_Error
64
-     */
65
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
66
-    {
67
-        $has_object = parent::_check_for_object(
68
-            $props_n_values,
69
-            __CLASS__,
70
-            $timezone,
71
-            $date_formats
72
-        );
73
-        return $has_object
74
-            ? $has_object
75
-            : new self($props_n_values, false, $timezone, $date_formats);
76
-    }
77
-
78
-
79
-    /**
80
-     * @param array  $props_n_values  incoming values from the database
81
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
82
-     *                                the website will be used.
83
-     * @return EE_Datetime
84
-     * @throws ReflectionException
85
-     * @throws InvalidArgumentException
86
-     * @throws InvalidInterfaceException
87
-     * @throws InvalidDataTypeException
88
-     * @throws EE_Error
89
-     */
90
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
91
-    {
92
-        return new self($props_n_values, true, $timezone);
93
-    }
94
-
95
-
96
-    /**
97
-     * @param $name
98
-     * @throws ReflectionException
99
-     * @throws InvalidArgumentException
100
-     * @throws InvalidInterfaceException
101
-     * @throws InvalidDataTypeException
102
-     * @throws EE_Error
103
-     */
104
-    public function set_name($name)
105
-    {
106
-        $this->set('DTT_name', $name);
107
-    }
108
-
109
-
110
-    /**
111
-     * @param $description
112
-     * @throws ReflectionException
113
-     * @throws InvalidArgumentException
114
-     * @throws InvalidInterfaceException
115
-     * @throws InvalidDataTypeException
116
-     * @throws EE_Error
117
-     */
118
-    public function set_description($description)
119
-    {
120
-        $this->set('DTT_description', $description);
121
-    }
122
-
123
-
124
-    /**
125
-     * Set event start date
126
-     * set the start date for an event
127
-     *
128
-     * @param string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
129
-     * @throws ReflectionException
130
-     * @throws InvalidArgumentException
131
-     * @throws InvalidInterfaceException
132
-     * @throws InvalidDataTypeException
133
-     * @throws EE_Error
134
-     */
135
-    public function set_start_date($date)
136
-    {
137
-        $this->_set_date_for($date, 'DTT_EVT_start');
138
-    }
139
-
140
-
141
-    /**
142
-     * Set event start time
143
-     * set the start time for an event
144
-     *
145
-     * @param string $time a string representation of the event time ex:  9am  or  7:30 PM
146
-     * @throws ReflectionException
147
-     * @throws InvalidArgumentException
148
-     * @throws InvalidInterfaceException
149
-     * @throws InvalidDataTypeException
150
-     * @throws EE_Error
151
-     */
152
-    public function set_start_time($time)
153
-    {
154
-        $this->_set_time_for($time, 'DTT_EVT_start');
155
-    }
156
-
157
-
158
-    /**
159
-     * Set event end date
160
-     * set the end date for an event
161
-     *
162
-     * @param string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
163
-     * @throws ReflectionException
164
-     * @throws InvalidArgumentException
165
-     * @throws InvalidInterfaceException
166
-     * @throws InvalidDataTypeException
167
-     * @throws EE_Error
168
-     */
169
-    public function set_end_date($date)
170
-    {
171
-        $this->_set_date_for($date, 'DTT_EVT_end');
172
-    }
173
-
174
-
175
-    /**
176
-     * Set event end time
177
-     * set the end time for an event
178
-     *
179
-     * @param string $time a string representation of the event time ex:  9am  or  7:30 PM
180
-     * @throws ReflectionException
181
-     * @throws InvalidArgumentException
182
-     * @throws InvalidInterfaceException
183
-     * @throws InvalidDataTypeException
184
-     * @throws EE_Error
185
-     */
186
-    public function set_end_time($time)
187
-    {
188
-        $this->_set_time_for($time, 'DTT_EVT_end');
189
-    }
190
-
191
-
192
-    /**
193
-     * Set registration limit
194
-     * set the maximum number of attendees that can be registered for this datetime slot
195
-     *
196
-     * @param int $reg_limit
197
-     * @throws ReflectionException
198
-     * @throws InvalidArgumentException
199
-     * @throws InvalidInterfaceException
200
-     * @throws InvalidDataTypeException
201
-     * @throws EE_Error
202
-     */
203
-    public function set_reg_limit($reg_limit)
204
-    {
205
-        $this->set('DTT_reg_limit', $reg_limit);
206
-    }
207
-
208
-
209
-    /**
210
-     * get the number of tickets sold for this datetime slot
211
-     *
212
-     * @return mixed int on success, FALSE on fail
213
-     * @throws ReflectionException
214
-     * @throws InvalidArgumentException
215
-     * @throws InvalidInterfaceException
216
-     * @throws InvalidDataTypeException
217
-     * @throws EE_Error
218
-     */
219
-    public function sold()
220
-    {
221
-        return $this->get_raw('DTT_sold');
222
-    }
223
-
224
-
225
-    /**
226
-     * @param int $sold
227
-     * @throws ReflectionException
228
-     * @throws InvalidArgumentException
229
-     * @throws InvalidInterfaceException
230
-     * @throws InvalidDataTypeException
231
-     * @throws EE_Error
232
-     */
233
-    public function set_sold($sold)
234
-    {
235
-        // sold can not go below zero
236
-        $sold = max(0, $sold);
237
-        $this->set('DTT_sold', $sold);
238
-    }
239
-
240
-
241
-    /**
242
-     * Increments sold by amount passed by $qty, and persists it immediately to the database.
243
-     * Simultaneously decreases the reserved count, unless $also_decrease_reserved is false.
244
-     *
245
-     * @param int $qty
246
-     * @param boolean $also_decrease_reserved
247
-     * @return boolean indicating success
248
-     * @throws ReflectionException
249
-     * @throws InvalidArgumentException
250
-     * @throws InvalidInterfaceException
251
-     * @throws InvalidDataTypeException
252
-     * @throws EE_Error
253
-     */
254
-    public function increaseSold($qty = 1, $also_decrease_reserved = true)
255
-    {
256
-        $qty = absint($qty);
257
-        if ($also_decrease_reserved) {
258
-            $success = $this->adjustNumericFieldsInDb(
259
-                [
260
-                    'DTT_reserved' => $qty * -1,
261
-                    'DTT_sold' => $qty
262
-                ]
263
-            );
264
-        } else {
265
-            $success = $this->adjustNumericFieldsInDb(
266
-                [
267
-                    'DTT_sold' => $qty
268
-                ]
269
-            );
270
-        }
271
-
272
-        do_action(
273
-            'AHEE__EE_Datetime__increase_sold',
274
-            $this,
275
-            $qty,
276
-            $this->sold(),
277
-            $success
278
-        );
279
-        return $success;
280
-    }
281
-
282
-
283
-    /**
284
-     * Decrements (subtracts) sold amount passed by $qty directly in the DB and on the model object. (Ie, no need
285
-     * to save afterwards.)
286
-     *
287
-     * @param int $qty
288
-     * @return boolean indicating success
289
-     * @throws ReflectionException
290
-     * @throws InvalidArgumentException
291
-     * @throws InvalidInterfaceException
292
-     * @throws InvalidDataTypeException
293
-     * @throws EE_Error
294
-     */
295
-    public function decreaseSold($qty = 1)
296
-    {
297
-        $qty = absint($qty);
298
-        $success = $this->adjustNumericFieldsInDb(
299
-            [
300
-                'DTT_sold' => $qty * -1
301
-            ]
302
-        );
303
-        do_action(
304
-            'AHEE__EE_Datetime__decrease_sold',
305
-            $this,
306
-            $qty,
307
-            $this->sold(),
308
-            $success
309
-        );
310
-        return $success;
311
-    }
312
-
313
-
314
-    /**
315
-     * Gets qty of reserved tickets for this datetime
316
-     *
317
-     * @return int
318
-     * @throws ReflectionException
319
-     * @throws InvalidArgumentException
320
-     * @throws InvalidInterfaceException
321
-     * @throws InvalidDataTypeException
322
-     * @throws EE_Error
323
-     */
324
-    public function reserved()
325
-    {
326
-        return $this->get_raw('DTT_reserved');
327
-    }
328
-
329
-
330
-    /**
331
-     * Sets qty of reserved tickets for this datetime
332
-     *
333
-     * @param int $reserved
334
-     * @throws ReflectionException
335
-     * @throws InvalidArgumentException
336
-     * @throws InvalidInterfaceException
337
-     * @throws InvalidDataTypeException
338
-     * @throws EE_Error
339
-     */
340
-    public function set_reserved($reserved)
341
-    {
342
-        // reserved can not go below zero
343
-        $reserved = max(0, (int) $reserved);
344
-        $this->set('DTT_reserved', $reserved);
345
-    }
346
-
347
-
348
-    /**
349
-     * Increments reserved by amount passed by $qty, and persists it immediately to the database.
350
-     *
351
-     * @param int $qty
352
-     * @return boolean indicating success
353
-     * @throws ReflectionException
354
-     * @throws InvalidArgumentException
355
-     * @throws InvalidInterfaceException
356
-     * @throws InvalidDataTypeException
357
-     * @throws EE_Error
358
-     */
359
-    public function increaseReserved($qty = 1)
360
-    {
361
-        $qty = absint($qty);
362
-        $success = $this->incrementFieldConditionallyInDb(
363
-            'DTT_reserved',
364
-            'DTT_sold',
365
-            'DTT_reg_limit',
366
-            $qty
367
-        );
368
-        do_action(
369
-            'AHEE__EE_Datetime__increase_reserved',
370
-            $this,
371
-            $qty,
372
-            $this->reserved(),
373
-            $success
374
-        );
375
-        return $success;
376
-    }
377
-
378
-
379
-    /**
380
-     * Decrements (subtracts) reserved by amount passed by $qty, and persists it immediately to the database.
381
-     *
382
-     * @param int $qty
383
-     * @return boolean indicating success
384
-     * @throws ReflectionException
385
-     * @throws InvalidArgumentException
386
-     * @throws InvalidInterfaceException
387
-     * @throws InvalidDataTypeException
388
-     * @throws EE_Error
389
-     */
390
-    public function decreaseReserved($qty = 1)
391
-    {
392
-        $qty = absint($qty);
393
-        $success = $this->adjustNumericFieldsInDb(
394
-            [
395
-                'DTT_reserved' => $qty * -1
396
-            ]
397
-        );
398
-        do_action(
399
-            'AHEE__EE_Datetime__decrease_reserved',
400
-            $this,
401
-            $qty,
402
-            $this->reserved(),
403
-            $success
404
-        );
405
-        return $success;
406
-    }
407
-
408
-
409
-    /**
410
-     * total sold and reserved tickets
411
-     *
412
-     * @return int
413
-     * @throws ReflectionException
414
-     * @throws InvalidArgumentException
415
-     * @throws InvalidInterfaceException
416
-     * @throws InvalidDataTypeException
417
-     * @throws EE_Error
418
-     */
419
-    public function sold_and_reserved()
420
-    {
421
-        return $this->sold() + $this->reserved();
422
-    }
423
-
424
-
425
-    /**
426
-     * returns the datetime name
427
-     *
428
-     * @return string
429
-     * @throws ReflectionException
430
-     * @throws InvalidArgumentException
431
-     * @throws InvalidInterfaceException
432
-     * @throws InvalidDataTypeException
433
-     * @throws EE_Error
434
-     */
435
-    public function name()
436
-    {
437
-        return $this->get('DTT_name');
438
-    }
439
-
440
-
441
-    /**
442
-     * returns the datetime description
443
-     *
444
-     * @return string
445
-     * @throws ReflectionException
446
-     * @throws InvalidArgumentException
447
-     * @throws InvalidInterfaceException
448
-     * @throws InvalidDataTypeException
449
-     * @throws EE_Error
450
-     */
451
-    public function description()
452
-    {
453
-        return $this->get('DTT_description');
454
-    }
455
-
456
-
457
-    /**
458
-     * This helper simply returns whether the event_datetime for the current datetime is a primary datetime
459
-     *
460
-     * @return boolean  TRUE if is primary, FALSE if not.
461
-     * @throws ReflectionException
462
-     * @throws InvalidArgumentException
463
-     * @throws InvalidInterfaceException
464
-     * @throws InvalidDataTypeException
465
-     * @throws EE_Error
466
-     */
467
-    public function is_primary()
468
-    {
469
-        return $this->get('DTT_is_primary');
470
-    }
471
-
472
-
473
-    /**
474
-     * This helper simply returns the order for the datetime
475
-     *
476
-     * @return int  The order of the datetime for this event.
477
-     * @throws ReflectionException
478
-     * @throws InvalidArgumentException
479
-     * @throws InvalidInterfaceException
480
-     * @throws InvalidDataTypeException
481
-     * @throws EE_Error
482
-     */
483
-    public function order()
484
-    {
485
-        return $this->get('DTT_order');
486
-    }
487
-
488
-
489
-    /**
490
-     * This helper simply returns the parent id for the datetime
491
-     *
492
-     * @return int
493
-     * @throws ReflectionException
494
-     * @throws InvalidArgumentException
495
-     * @throws InvalidInterfaceException
496
-     * @throws InvalidDataTypeException
497
-     * @throws EE_Error
498
-     */
499
-    public function parent()
500
-    {
501
-        return $this->get('DTT_parent');
502
-    }
503
-
504
-
505
-    /**
506
-     * show date and/or time
507
-     *
508
-     * @param string $date_or_time    whether to display a date or time or both
509
-     * @param string $start_or_end    whether to display start or end datetimes
510
-     * @param string $dt_frmt
511
-     * @param string $tm_frmt
512
-     * @param bool   $echo            whether we echo or return (note echoing uses "pretty" formats,
513
-     *                                otherwise we use the standard formats)
514
-     * @return string|bool  string on success, FALSE on fail
515
-     * @throws ReflectionException
516
-     * @throws InvalidArgumentException
517
-     * @throws InvalidInterfaceException
518
-     * @throws InvalidDataTypeException
519
-     * @throws EE_Error
520
-     */
521
-    private function _show_datetime(
522
-        $date_or_time = null,
523
-        $start_or_end = 'start',
524
-        $dt_frmt = '',
525
-        $tm_frmt = '',
526
-        $echo = false
527
-    ) {
528
-        $field_name = "DTT_EVT_{$start_or_end}";
529
-        $dtt = $this->_get_datetime(
530
-            $field_name,
531
-            $dt_frmt,
532
-            $tm_frmt,
533
-            $date_or_time,
534
-            $echo
535
-        );
536
-        if (! $echo) {
537
-            return $dtt;
538
-        }
539
-        return '';
540
-    }
541
-
542
-
543
-    /**
544
-     * get event start date.  Provide either the date format, or NULL to re-use the
545
-     * last-used format, or '' to use the default date format
546
-     *
547
-     * @param string $dt_frmt string representation of date format defaults to 'F j, Y'
548
-     * @return mixed            string on success, FALSE on fail
549
-     * @throws ReflectionException
550
-     * @throws InvalidArgumentException
551
-     * @throws InvalidInterfaceException
552
-     * @throws InvalidDataTypeException
553
-     * @throws EE_Error
554
-     */
555
-    public function start_date($dt_frmt = '')
556
-    {
557
-        return $this->_show_datetime('D', 'start', $dt_frmt);
558
-    }
559
-
560
-
561
-    /**
562
-     * Echoes start_date()
563
-     *
564
-     * @param string $dt_frmt
565
-     * @throws ReflectionException
566
-     * @throws InvalidArgumentException
567
-     * @throws InvalidInterfaceException
568
-     * @throws InvalidDataTypeException
569
-     * @throws EE_Error
570
-     */
571
-    public function e_start_date($dt_frmt = '')
572
-    {
573
-        $this->_show_datetime('D', 'start', $dt_frmt, null, true);
574
-    }
575
-
576
-
577
-    /**
578
-     * get end date. Provide either the date format, or NULL to re-use the
579
-     * last-used format, or '' to use the default date format
580
-     *
581
-     * @param string $dt_frmt string representation of date format defaults to 'F j, Y'
582
-     * @return mixed            string on success, FALSE on fail
583
-     * @throws ReflectionException
584
-     * @throws InvalidArgumentException
585
-     * @throws InvalidInterfaceException
586
-     * @throws InvalidDataTypeException
587
-     * @throws EE_Error
588
-     */
589
-    public function end_date($dt_frmt = '')
590
-    {
591
-        return $this->_show_datetime('D', 'end', $dt_frmt);
592
-    }
593
-
594
-
595
-    /**
596
-     * Echoes the end date. See end_date()
597
-     *
598
-     * @param string $dt_frmt
599
-     * @throws ReflectionException
600
-     * @throws InvalidArgumentException
601
-     * @throws InvalidInterfaceException
602
-     * @throws InvalidDataTypeException
603
-     * @throws EE_Error
604
-     */
605
-    public function e_end_date($dt_frmt = '')
606
-    {
607
-        $this->_show_datetime('D', 'end', $dt_frmt, null, true);
608
-    }
609
-
610
-
611
-    /**
612
-     * get date_range - meaning the start AND end date
613
-     *
614
-     * @access public
615
-     * @param string $dt_frmt     string representation of date format defaults to WP settings
616
-     * @param string $conjunction conjunction junction what's your function ?
617
-     *                            this string joins the start date with the end date ie: Jan 01 "to" Dec 31
618
-     * @return mixed              string on success, FALSE on fail
619
-     * @throws ReflectionException
620
-     * @throws InvalidArgumentException
621
-     * @throws InvalidInterfaceException
622
-     * @throws InvalidDataTypeException
623
-     * @throws EE_Error
624
-     */
625
-    public function date_range($dt_frmt = '', $conjunction = ' - ')
626
-    {
627
-        $dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt;
628
-        $start = str_replace(
629
-            ' ',
630
-            '&nbsp;',
631
-            $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)
632
-        );
633
-        $end = str_replace(
634
-            ' ',
635
-            '&nbsp;',
636
-            $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)
637
-        );
638
-        return $start !== $end ? $start . $conjunction . $end : $start;
639
-    }
640
-
641
-
642
-    /**
643
-     * @param string $dt_frmt
644
-     * @param string $conjunction
645
-     * @throws ReflectionException
646
-     * @throws InvalidArgumentException
647
-     * @throws InvalidInterfaceException
648
-     * @throws InvalidDataTypeException
649
-     * @throws EE_Error
650
-     */
651
-    public function e_date_range($dt_frmt = '', $conjunction = ' - ')
652
-    {
653
-        echo $this->date_range($dt_frmt, $conjunction);
654
-    }
655
-
656
-
657
-    /**
658
-     * get start time
659
-     *
660
-     * @param string $tm_format - string representation of time format defaults to 'g:i a'
661
-     * @return mixed        string on success, FALSE on fail
662
-     * @throws ReflectionException
663
-     * @throws InvalidArgumentException
664
-     * @throws InvalidInterfaceException
665
-     * @throws InvalidDataTypeException
666
-     * @throws EE_Error
667
-     */
668
-    public function start_time($tm_format = '')
669
-    {
670
-        return $this->_show_datetime('T', 'start', null, $tm_format);
671
-    }
672
-
673
-
674
-    /**
675
-     * @param string $tm_format
676
-     * @throws ReflectionException
677
-     * @throws InvalidArgumentException
678
-     * @throws InvalidInterfaceException
679
-     * @throws InvalidDataTypeException
680
-     * @throws EE_Error
681
-     */
682
-    public function e_start_time($tm_format = '')
683
-    {
684
-        $this->_show_datetime('T', 'start', null, $tm_format, true);
685
-    }
686
-
687
-
688
-    /**
689
-     * get end time
690
-     *
691
-     * @param string $tm_format string representation of time format defaults to 'g:i a'
692
-     * @return mixed                string on success, FALSE on fail
693
-     * @throws ReflectionException
694
-     * @throws InvalidArgumentException
695
-     * @throws InvalidInterfaceException
696
-     * @throws InvalidDataTypeException
697
-     * @throws EE_Error
698
-     */
699
-    public function end_time($tm_format = '')
700
-    {
701
-        return $this->_show_datetime('T', 'end', null, $tm_format);
702
-    }
703
-
704
-
705
-    /**
706
-     * @param string $tm_format
707
-     * @throws ReflectionException
708
-     * @throws InvalidArgumentException
709
-     * @throws InvalidInterfaceException
710
-     * @throws InvalidDataTypeException
711
-     * @throws EE_Error
712
-     */
713
-    public function e_end_time($tm_format = '')
714
-    {
715
-        $this->_show_datetime('T', 'end', null, $tm_format, true);
716
-    }
717
-
718
-
719
-    /**
720
-     * get time_range
721
-     *
722
-     * @access public
723
-     * @param string $tm_format   string representation of time format defaults to 'g:i a'
724
-     * @param string $conjunction conjunction junction what's your function ?
725
-     *                            this string joins the start date with the end date ie: Jan 01 "to" Dec 31
726
-     * @return mixed              string on success, FALSE on fail
727
-     * @throws ReflectionException
728
-     * @throws InvalidArgumentException
729
-     * @throws InvalidInterfaceException
730
-     * @throws InvalidDataTypeException
731
-     * @throws EE_Error
732
-     */
733
-    public function time_range($tm_format = '', $conjunction = ' - ')
734
-    {
735
-        $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
736
-        $start = str_replace(
737
-            ' ',
738
-            '&nbsp;',
739
-            $this->get_i18n_datetime('DTT_EVT_start', $tm_format)
740
-        );
741
-        $end = str_replace(
742
-            ' ',
743
-            '&nbsp;',
744
-            $this->get_i18n_datetime('DTT_EVT_end', $tm_format)
745
-        );
746
-        return $start !== $end ? $start . $conjunction . $end : $start;
747
-    }
748
-
749
-
750
-    /**
751
-     * @param string $tm_format
752
-     * @param string $conjunction
753
-     * @throws ReflectionException
754
-     * @throws InvalidArgumentException
755
-     * @throws InvalidInterfaceException
756
-     * @throws InvalidDataTypeException
757
-     * @throws EE_Error
758
-     */
759
-    public function e_time_range($tm_format = '', $conjunction = ' - ')
760
-    {
761
-        echo $this->time_range($tm_format, $conjunction);
762
-    }
763
-
764
-
765
-    /**
766
-     * This returns a range representation of the date and times.
767
-     * Output is dependent on the difference (or similarity) between DTT_EVT_start and DTT_EVT_end.
768
-     * Also, the return value is localized.
769
-     *
770
-     * @param string $dt_format
771
-     * @param string $tm_format
772
-     * @param string $conjunction used between two different dates or times.
773
-     *                            ex: Dec 1{$conjunction}}Dec 6, or 2pm{$conjunction}3pm
774
-     * @param string $separator   used between the date and time formats.
775
-     *                            ex: Dec 1, 2016{$separator}2pm
776
-     * @return string
777
-     * @throws ReflectionException
778
-     * @throws InvalidArgumentException
779
-     * @throws InvalidInterfaceException
780
-     * @throws InvalidDataTypeException
781
-     * @throws EE_Error
782
-     */
783
-    public function date_and_time_range(
784
-        $dt_format = '',
785
-        $tm_format = '',
786
-        $conjunction = ' - ',
787
-        $separator = ' '
788
-    ) {
789
-        $dt_format = ! empty($dt_format) ? $dt_format : $this->_dt_frmt;
790
-        $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
791
-        $full_format = $dt_format . $separator . $tm_format;
792
-        // the range output depends on various conditions
793
-        switch (true) {
794
-            // start date timestamp and end date timestamp are the same.
795
-            case ($this->get_raw('DTT_EVT_start') === $this->get_raw('DTT_EVT_end')):
796
-                $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format);
797
-                break;
798
-            // start and end date are the same but times are different
799
-            case ($this->start_date() === $this->end_date()):
800
-                $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format)
801
-                          . $conjunction
802
-                          . $this->get_i18n_datetime('DTT_EVT_end', $tm_format);
803
-                break;
804
-            // all other conditions
805
-            default:
806
-                $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format)
807
-                          . $conjunction
808
-                          . $this->get_i18n_datetime('DTT_EVT_end', $full_format);
809
-                break;
810
-        }
811
-        return $output;
812
-    }
813
-
814
-
815
-    /**
816
-     * This echos the results of date and time range.
817
-     *
818
-     * @see date_and_time_range() for more details on purpose.
819
-     * @param string $dt_format
820
-     * @param string $tm_format
821
-     * @param string $conjunction
822
-     * @return void
823
-     * @throws ReflectionException
824
-     * @throws InvalidArgumentException
825
-     * @throws InvalidInterfaceException
826
-     * @throws InvalidDataTypeException
827
-     * @throws EE_Error
828
-     */
829
-    public function e_date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ')
830
-    {
831
-        echo $this->date_and_time_range($dt_format, $tm_format, $conjunction);
832
-    }
833
-
834
-
835
-    /**
836
-     * get start date and start time
837
-     *
838
-     * @param    string $dt_format - string representation of date format defaults to 'F j, Y'
839
-     * @param    string $tm_format - string representation of time format defaults to 'g:i a'
840
-     * @return    mixed    string on success, FALSE on fail
841
-     * @throws ReflectionException
842
-     * @throws InvalidArgumentException
843
-     * @throws InvalidInterfaceException
844
-     * @throws InvalidDataTypeException
845
-     * @throws EE_Error
846
-     */
847
-    public function start_date_and_time($dt_format = '', $tm_format = '')
848
-    {
849
-        return $this->_show_datetime('', 'start', $dt_format, $tm_format);
850
-    }
851
-
852
-
853
-    /**
854
-     * @param string $dt_frmt
855
-     * @param string $tm_format
856
-     * @throws ReflectionException
857
-     * @throws InvalidArgumentException
858
-     * @throws InvalidInterfaceException
859
-     * @throws InvalidDataTypeException
860
-     * @throws EE_Error
861
-     */
862
-    public function e_start_date_and_time($dt_frmt = '', $tm_format = '')
863
-    {
864
-        $this->_show_datetime('', 'start', $dt_frmt, $tm_format, true);
865
-    }
866
-
867
-
868
-    /**
869
-     * Shows the length of the event (start to end time).
870
-     * Can be shown in 'seconds','minutes','hours', or 'days'.
871
-     * By default, rounds up. (So if you use 'days', and then event
872
-     * only occurs for 1 hour, it will return 1 day).
873
-     *
874
-     * @param string $units 'seconds','minutes','hours','days'
875
-     * @param bool   $round_up
876
-     * @return float|int|mixed
877
-     * @throws ReflectionException
878
-     * @throws InvalidArgumentException
879
-     * @throws InvalidInterfaceException
880
-     * @throws InvalidDataTypeException
881
-     * @throws EE_Error
882
-     */
883
-    public function length($units = 'seconds', $round_up = false)
884
-    {
885
-        $start = $this->get_raw('DTT_EVT_start');
886
-        $end = $this->get_raw('DTT_EVT_end');
887
-        $length_in_units = $end - $start;
888
-        switch ($units) {
889
-            // NOTE: We purposefully don't use "break;" in order to chain the divisions
890
-            /** @noinspection PhpMissingBreakStatementInspection */
891
-            // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
892
-            case 'days':
893
-                $length_in_units /= 24;
894
-            /** @noinspection PhpMissingBreakStatementInspection */
895
-            case 'hours':
896
-                // fall through is intentional
897
-                $length_in_units /= 60;
898
-            /** @noinspection PhpMissingBreakStatementInspection */
899
-            case 'minutes':
900
-                // fall through is intentional
901
-                $length_in_units /= 60;
902
-            case 'seconds':
903
-            default:
904
-                $length_in_units = ceil($length_in_units);
905
-        }
906
-        // phpcs:enable
907
-        if ($round_up) {
908
-            $length_in_units = max($length_in_units, 1);
909
-        }
910
-        return $length_in_units;
911
-    }
912
-
913
-
914
-    /**
915
-     *        get end date and time
916
-     *
917
-     * @param string $dt_frmt   - string representation of date format defaults to 'F j, Y'
918
-     * @param string $tm_format - string representation of time format defaults to 'g:i a'
919
-     * @return    mixed                string on success, FALSE on fail
920
-     * @throws ReflectionException
921
-     * @throws InvalidArgumentException
922
-     * @throws InvalidInterfaceException
923
-     * @throws InvalidDataTypeException
924
-     * @throws EE_Error
925
-     */
926
-    public function end_date_and_time($dt_frmt = '', $tm_format = '')
927
-    {
928
-        return $this->_show_datetime('', 'end', $dt_frmt, $tm_format);
929
-    }
930
-
931
-
932
-    /**
933
-     * @param string $dt_frmt
934
-     * @param string $tm_format
935
-     * @throws ReflectionException
936
-     * @throws InvalidArgumentException
937
-     * @throws InvalidInterfaceException
938
-     * @throws InvalidDataTypeException
939
-     * @throws EE_Error
940
-     */
941
-    public function e_end_date_and_time($dt_frmt = '', $tm_format = '')
942
-    {
943
-        $this->_show_datetime('', 'end', $dt_frmt, $tm_format, true);
944
-    }
945
-
946
-
947
-    /**
948
-     *        get start timestamp
949
-     *
950
-     * @return        int
951
-     * @throws ReflectionException
952
-     * @throws InvalidArgumentException
953
-     * @throws InvalidInterfaceException
954
-     * @throws InvalidDataTypeException
955
-     * @throws EE_Error
956
-     */
957
-    public function start()
958
-    {
959
-        return $this->get_raw('DTT_EVT_start');
960
-    }
961
-
962
-
963
-    /**
964
-     *        get end timestamp
965
-     *
966
-     * @return        int
967
-     * @throws ReflectionException
968
-     * @throws InvalidArgumentException
969
-     * @throws InvalidInterfaceException
970
-     * @throws InvalidDataTypeException
971
-     * @throws EE_Error
972
-     */
973
-    public function end()
974
-    {
975
-        return $this->get_raw('DTT_EVT_end');
976
-    }
977
-
978
-
979
-    /**
980
-     *    get the registration limit for this datetime slot
981
-     *
982
-     * @return        mixed        int on success, FALSE on fail
983
-     * @throws ReflectionException
984
-     * @throws InvalidArgumentException
985
-     * @throws InvalidInterfaceException
986
-     * @throws InvalidDataTypeException
987
-     * @throws EE_Error
988
-     */
989
-    public function reg_limit()
990
-    {
991
-        return $this->get_raw('DTT_reg_limit');
992
-    }
993
-
994
-
995
-    /**
996
-     *    have the tickets sold for this datetime, met or exceed the registration limit ?
997
-     *
998
-     * @return        boolean
999
-     * @throws ReflectionException
1000
-     * @throws InvalidArgumentException
1001
-     * @throws InvalidInterfaceException
1002
-     * @throws InvalidDataTypeException
1003
-     * @throws EE_Error
1004
-     */
1005
-    public function sold_out()
1006
-    {
1007
-        return $this->reg_limit() > 0 && $this->sold() >= $this->reg_limit();
1008
-    }
1009
-
1010
-
1011
-    /**
1012
-     * return the total number of spaces remaining at this venue.
1013
-     * This only takes the venue's capacity into account, NOT the tickets available for sale
1014
-     *
1015
-     * @param bool $consider_tickets Whether to consider tickets remaining when determining if there are any spaces left
1016
-     *                               Because if all tickets attached to this datetime have no spaces left,
1017
-     *                               then this datetime IS effectively sold out.
1018
-     *                               However, there are cases where we just want to know the spaces
1019
-     *                               remaining for this particular datetime, hence the flag.
1020
-     * @return int
1021
-     * @throws ReflectionException
1022
-     * @throws InvalidArgumentException
1023
-     * @throws InvalidInterfaceException
1024
-     * @throws InvalidDataTypeException
1025
-     * @throws EE_Error
1026
-     */
1027
-    public function spaces_remaining($consider_tickets = false)
1028
-    {
1029
-        // tickets remaining available for purchase
1030
-        // no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF
1031
-        $dtt_remaining = $this->reg_limit() - $this->sold_and_reserved();
1032
-        if (! $consider_tickets) {
1033
-            return $dtt_remaining;
1034
-        }
1035
-        $tickets_remaining = $this->tickets_remaining();
1036
-        return min($dtt_remaining, $tickets_remaining);
1037
-    }
1038
-
1039
-
1040
-    /**
1041
-     * Counts the total tickets available
1042
-     * (from all the different types of tickets which are available for this datetime).
1043
-     *
1044
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1045
-     * @return int
1046
-     * @throws ReflectionException
1047
-     * @throws InvalidArgumentException
1048
-     * @throws InvalidInterfaceException
1049
-     * @throws InvalidDataTypeException
1050
-     * @throws EE_Error
1051
-     */
1052
-    public function tickets_remaining($query_params = array())
1053
-    {
1054
-        $sum = 0;
1055
-        $tickets = $this->tickets($query_params);
1056
-        if (! empty($tickets)) {
1057
-            foreach ($tickets as $ticket) {
1058
-                if ($ticket instanceof EE_Ticket) {
1059
-                    // get the actual amount of tickets that can be sold
1060
-                    $qty = $ticket->qty('saleable');
1061
-                    if ($qty === EE_INF) {
1062
-                        return EE_INF;
1063
-                    }
1064
-                    // no negative ticket quantities plz
1065
-                    if ($qty > 0) {
1066
-                        $sum += $qty;
1067
-                    }
1068
-                }
1069
-            }
1070
-        }
1071
-        return $sum;
1072
-    }
1073
-
1074
-
1075
-    /**
1076
-     * Gets the count of all the tickets available at this datetime (not ticket types)
1077
-     * before any were sold
1078
-     *
1079
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1080
-     * @return int
1081
-     * @throws ReflectionException
1082
-     * @throws InvalidArgumentException
1083
-     * @throws InvalidInterfaceException
1084
-     * @throws InvalidDataTypeException
1085
-     * @throws EE_Error
1086
-     */
1087
-    public function sum_tickets_initially_available($query_params = array())
1088
-    {
1089
-        return $this->sum_related('Ticket', $query_params, 'TKT_qty');
1090
-    }
1091
-
1092
-
1093
-    /**
1094
-     * Returns the lesser-of-the two: spaces remaining at this datetime, or
1095
-     * the total tickets remaining (a sum of the tickets remaining for each ticket type
1096
-     * that is available for this datetime).
1097
-     *
1098
-     * @return int
1099
-     * @throws ReflectionException
1100
-     * @throws InvalidArgumentException
1101
-     * @throws InvalidInterfaceException
1102
-     * @throws InvalidDataTypeException
1103
-     * @throws EE_Error
1104
-     */
1105
-    public function total_tickets_available_at_this_datetime()
1106
-    {
1107
-        return $this->spaces_remaining(true);
1108
-    }
1109
-
1110
-
1111
-    /**
1112
-     * This simply compares the internal dtt for the given string with NOW
1113
-     * and determines if the date is upcoming or not.
1114
-     *
1115
-     * @access public
1116
-     * @return boolean
1117
-     * @throws ReflectionException
1118
-     * @throws InvalidArgumentException
1119
-     * @throws InvalidInterfaceException
1120
-     * @throws InvalidDataTypeException
1121
-     * @throws EE_Error
1122
-     */
1123
-    public function is_upcoming()
1124
-    {
1125
-        return ($this->get_raw('DTT_EVT_start') > time());
1126
-    }
1127
-
1128
-
1129
-    /**
1130
-     * This simply compares the internal datetime for the given string with NOW
1131
-     * and returns if the date is active (i.e. start and end time)
1132
-     *
1133
-     * @return boolean
1134
-     * @throws ReflectionException
1135
-     * @throws InvalidArgumentException
1136
-     * @throws InvalidInterfaceException
1137
-     * @throws InvalidDataTypeException
1138
-     * @throws EE_Error
1139
-     */
1140
-    public function is_active()
1141
-    {
1142
-        return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time());
1143
-    }
1144
-
1145
-
1146
-    /**
1147
-     * This simply compares the internal dtt for the given string with NOW
1148
-     * and determines if the date is expired or not.
1149
-     *
1150
-     * @return boolean
1151
-     * @throws ReflectionException
1152
-     * @throws InvalidArgumentException
1153
-     * @throws InvalidInterfaceException
1154
-     * @throws InvalidDataTypeException
1155
-     * @throws EE_Error
1156
-     */
1157
-    public function is_expired()
1158
-    {
1159
-        return ($this->get_raw('DTT_EVT_end') < time());
1160
-    }
1161
-
1162
-
1163
-    /**
1164
-     * This returns the active status for whether an event is active, upcoming, or expired
1165
-     *
1166
-     * @return int return value will be one of the EE_Datetime status constants.
1167
-     * @throws ReflectionException
1168
-     * @throws InvalidArgumentException
1169
-     * @throws InvalidInterfaceException
1170
-     * @throws InvalidDataTypeException
1171
-     * @throws EE_Error
1172
-     */
1173
-    public function get_active_status()
1174
-    {
1175
-        $total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime();
1176
-        if ($total_tickets_for_this_dtt !== false && $total_tickets_for_this_dtt < 1) {
1177
-            return EE_Datetime::sold_out;
1178
-        }
1179
-        if ($this->is_expired()) {
1180
-            return EE_Datetime::expired;
1181
-        }
1182
-        if ($this->is_upcoming()) {
1183
-            return EE_Datetime::upcoming;
1184
-        }
1185
-        if ($this->is_active()) {
1186
-            return EE_Datetime::active;
1187
-        }
1188
-        return null;
1189
-    }
1190
-
1191
-
1192
-    /**
1193
-     * This returns a nice display name for the datetime that is contingent on the span between the dates and times.
1194
-     *
1195
-     * @param  boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty.
1196
-     * @return string
1197
-     * @throws ReflectionException
1198
-     * @throws InvalidArgumentException
1199
-     * @throws InvalidInterfaceException
1200
-     * @throws InvalidDataTypeException
1201
-     * @throws EE_Error
1202
-     */
1203
-    public function get_dtt_display_name($use_dtt_name = false)
1204
-    {
1205
-        if ($use_dtt_name) {
1206
-            $dtt_name = $this->name();
1207
-            if (! empty($dtt_name)) {
1208
-                return $dtt_name;
1209
-            }
1210
-        }
1211
-        // first condition is to see if the months are different
1212
-        if (
1213
-            date('m', $this->get_raw('DTT_EVT_start')) !== date('m', $this->get_raw('DTT_EVT_end'))
1214
-        ) {
1215
-            $display_date = $this->start_date('M j\, Y g:i a') . ' - ' . $this->end_date('M j\, Y g:i a');
1216
-            // next condition is if its the same month but different day
1217
-        } else {
1218
-            if (
1219
-                date('m', $this->get_raw('DTT_EVT_start')) === date('m', $this->get_raw('DTT_EVT_end'))
1220
-                && date('d', $this->get_raw('DTT_EVT_start')) !== date('d', $this->get_raw('DTT_EVT_end'))
1221
-            ) {
1222
-                $display_date = $this->start_date('M j\, g:i a') . ' - ' . $this->end_date('M j\, g:i a Y');
1223
-            } else {
1224
-                $display_date = $this->start_date('F j\, Y')
1225
-                                . ' @ '
1226
-                                . $this->start_date('g:i a')
1227
-                                . ' - '
1228
-                                . $this->end_date('g:i a');
1229
-            }
1230
-        }
1231
-        return $display_date;
1232
-    }
1233
-
1234
-
1235
-    /**
1236
-     * Gets all the tickets for this datetime
1237
-     *
1238
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1239
-     * @return EE_Base_Class[]|EE_Ticket[]
1240
-     * @throws ReflectionException
1241
-     * @throws InvalidArgumentException
1242
-     * @throws InvalidInterfaceException
1243
-     * @throws InvalidDataTypeException
1244
-     * @throws EE_Error
1245
-     */
1246
-    public function tickets($query_params = array())
1247
-    {
1248
-        return $this->get_many_related('Ticket', $query_params);
1249
-    }
1250
-
1251
-
1252
-    /**
1253
-     * Gets all the ticket types currently available for purchase
1254
-     *
1255
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1256
-     * @return EE_Ticket[]
1257
-     * @throws ReflectionException
1258
-     * @throws InvalidArgumentException
1259
-     * @throws InvalidInterfaceException
1260
-     * @throws InvalidDataTypeException
1261
-     * @throws EE_Error
1262
-     */
1263
-    public function ticket_types_available_for_purchase($query_params = array())
1264
-    {
1265
-        // first check if datetime is valid
1266
-        if ($this->sold_out() || ! ($this->is_upcoming() || $this->is_active())) {
1267
-            return array();
1268
-        }
1269
-        if (empty($query_params)) {
1270
-            $query_params = array(
1271
-                array(
1272
-                    'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')),
1273
-                    'TKT_end_date'   => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')),
1274
-                    'TKT_deleted'    => false,
1275
-                ),
1276
-            );
1277
-        }
1278
-        return $this->tickets($query_params);
1279
-    }
1280
-
1281
-
1282
-    /**
1283
-     * @return EE_Base_Class|EE_Event
1284
-     * @throws ReflectionException
1285
-     * @throws InvalidArgumentException
1286
-     * @throws InvalidInterfaceException
1287
-     * @throws InvalidDataTypeException
1288
-     * @throws EE_Error
1289
-     */
1290
-    public function event()
1291
-    {
1292
-        return $this->get_first_related('Event');
1293
-    }
1294
-
1295
-
1296
-    /**
1297
-     * Updates the DTT_sold attribute (and saves) based on the number of registrations for this datetime
1298
-     * (via the tickets).
1299
-     *
1300
-     * @return int
1301
-     * @throws ReflectionException
1302
-     * @throws InvalidArgumentException
1303
-     * @throws InvalidInterfaceException
1304
-     * @throws InvalidDataTypeException
1305
-     * @throws EE_Error
1306
-     */
1307
-    public function update_sold()
1308
-    {
1309
-        $count_regs_for_this_datetime = EEM_Registration::instance()->count(
1310
-            array(
1311
-                array(
1312
-                    'STS_ID'                 => EEM_Registration::status_id_approved,
1313
-                    'REG_deleted'            => 0,
1314
-                    'Ticket.Datetime.DTT_ID' => $this->ID(),
1315
-                ),
1316
-            )
1317
-        );
1318
-        $this->set_sold($count_regs_for_this_datetime);
1319
-        $this->save();
1320
-        return $count_regs_for_this_datetime;
1321
-    }
1322
-
1323
-
1324
-    /*******************************************************************
16
+	/**
17
+	 * constant used by get_active_status, indicates datetime has no more available spaces
18
+	 */
19
+	const sold_out = 'DTS';
20
+
21
+	/**
22
+	 * constant used by get_active_status, indicating datetime is still active (even is not over, can be registered-for)
23
+	 */
24
+	const active = 'DTA';
25
+
26
+	/**
27
+	 * constant used by get_active_status, indicating the datetime cannot be used for registrations yet, but has not
28
+	 * expired
29
+	 */
30
+	const upcoming = 'DTU';
31
+
32
+	/**
33
+	 * Datetime is postponed
34
+	 */
35
+	const postponed = 'DTP';
36
+
37
+	/**
38
+	 * Datetime is cancelled
39
+	 */
40
+	const cancelled = 'DTC';
41
+
42
+	/**
43
+	 * constant used by get_active_status, indicates datetime has expired (event is over)
44
+	 */
45
+	const expired = 'DTE';
46
+
47
+	/**
48
+	 * constant used in various places indicating that an event is INACTIVE (not yet ready to be published)
49
+	 */
50
+	const inactive = 'DTI';
51
+
52
+
53
+	/**
54
+	 * @param array  $props_n_values    incoming values
55
+	 * @param string $timezone          incoming timezone (if not set the timezone set for the website will be used.)
56
+	 * @param array  $date_formats      incoming date_formats in an array where the first value is the date_format
57
+	 *                                  and the second value is the time format
58
+	 * @return EE_Datetime
59
+	 * @throws ReflectionException
60
+	 * @throws InvalidArgumentException
61
+	 * @throws InvalidInterfaceException
62
+	 * @throws InvalidDataTypeException
63
+	 * @throws EE_Error
64
+	 */
65
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
66
+	{
67
+		$has_object = parent::_check_for_object(
68
+			$props_n_values,
69
+			__CLASS__,
70
+			$timezone,
71
+			$date_formats
72
+		);
73
+		return $has_object
74
+			? $has_object
75
+			: new self($props_n_values, false, $timezone, $date_formats);
76
+	}
77
+
78
+
79
+	/**
80
+	 * @param array  $props_n_values  incoming values from the database
81
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
82
+	 *                                the website will be used.
83
+	 * @return EE_Datetime
84
+	 * @throws ReflectionException
85
+	 * @throws InvalidArgumentException
86
+	 * @throws InvalidInterfaceException
87
+	 * @throws InvalidDataTypeException
88
+	 * @throws EE_Error
89
+	 */
90
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
91
+	{
92
+		return new self($props_n_values, true, $timezone);
93
+	}
94
+
95
+
96
+	/**
97
+	 * @param $name
98
+	 * @throws ReflectionException
99
+	 * @throws InvalidArgumentException
100
+	 * @throws InvalidInterfaceException
101
+	 * @throws InvalidDataTypeException
102
+	 * @throws EE_Error
103
+	 */
104
+	public function set_name($name)
105
+	{
106
+		$this->set('DTT_name', $name);
107
+	}
108
+
109
+
110
+	/**
111
+	 * @param $description
112
+	 * @throws ReflectionException
113
+	 * @throws InvalidArgumentException
114
+	 * @throws InvalidInterfaceException
115
+	 * @throws InvalidDataTypeException
116
+	 * @throws EE_Error
117
+	 */
118
+	public function set_description($description)
119
+	{
120
+		$this->set('DTT_description', $description);
121
+	}
122
+
123
+
124
+	/**
125
+	 * Set event start date
126
+	 * set the start date for an event
127
+	 *
128
+	 * @param string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
129
+	 * @throws ReflectionException
130
+	 * @throws InvalidArgumentException
131
+	 * @throws InvalidInterfaceException
132
+	 * @throws InvalidDataTypeException
133
+	 * @throws EE_Error
134
+	 */
135
+	public function set_start_date($date)
136
+	{
137
+		$this->_set_date_for($date, 'DTT_EVT_start');
138
+	}
139
+
140
+
141
+	/**
142
+	 * Set event start time
143
+	 * set the start time for an event
144
+	 *
145
+	 * @param string $time a string representation of the event time ex:  9am  or  7:30 PM
146
+	 * @throws ReflectionException
147
+	 * @throws InvalidArgumentException
148
+	 * @throws InvalidInterfaceException
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws EE_Error
151
+	 */
152
+	public function set_start_time($time)
153
+	{
154
+		$this->_set_time_for($time, 'DTT_EVT_start');
155
+	}
156
+
157
+
158
+	/**
159
+	 * Set event end date
160
+	 * set the end date for an event
161
+	 *
162
+	 * @param string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
163
+	 * @throws ReflectionException
164
+	 * @throws InvalidArgumentException
165
+	 * @throws InvalidInterfaceException
166
+	 * @throws InvalidDataTypeException
167
+	 * @throws EE_Error
168
+	 */
169
+	public function set_end_date($date)
170
+	{
171
+		$this->_set_date_for($date, 'DTT_EVT_end');
172
+	}
173
+
174
+
175
+	/**
176
+	 * Set event end time
177
+	 * set the end time for an event
178
+	 *
179
+	 * @param string $time a string representation of the event time ex:  9am  or  7:30 PM
180
+	 * @throws ReflectionException
181
+	 * @throws InvalidArgumentException
182
+	 * @throws InvalidInterfaceException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws EE_Error
185
+	 */
186
+	public function set_end_time($time)
187
+	{
188
+		$this->_set_time_for($time, 'DTT_EVT_end');
189
+	}
190
+
191
+
192
+	/**
193
+	 * Set registration limit
194
+	 * set the maximum number of attendees that can be registered for this datetime slot
195
+	 *
196
+	 * @param int $reg_limit
197
+	 * @throws ReflectionException
198
+	 * @throws InvalidArgumentException
199
+	 * @throws InvalidInterfaceException
200
+	 * @throws InvalidDataTypeException
201
+	 * @throws EE_Error
202
+	 */
203
+	public function set_reg_limit($reg_limit)
204
+	{
205
+		$this->set('DTT_reg_limit', $reg_limit);
206
+	}
207
+
208
+
209
+	/**
210
+	 * get the number of tickets sold for this datetime slot
211
+	 *
212
+	 * @return mixed int on success, FALSE on fail
213
+	 * @throws ReflectionException
214
+	 * @throws InvalidArgumentException
215
+	 * @throws InvalidInterfaceException
216
+	 * @throws InvalidDataTypeException
217
+	 * @throws EE_Error
218
+	 */
219
+	public function sold()
220
+	{
221
+		return $this->get_raw('DTT_sold');
222
+	}
223
+
224
+
225
+	/**
226
+	 * @param int $sold
227
+	 * @throws ReflectionException
228
+	 * @throws InvalidArgumentException
229
+	 * @throws InvalidInterfaceException
230
+	 * @throws InvalidDataTypeException
231
+	 * @throws EE_Error
232
+	 */
233
+	public function set_sold($sold)
234
+	{
235
+		// sold can not go below zero
236
+		$sold = max(0, $sold);
237
+		$this->set('DTT_sold', $sold);
238
+	}
239
+
240
+
241
+	/**
242
+	 * Increments sold by amount passed by $qty, and persists it immediately to the database.
243
+	 * Simultaneously decreases the reserved count, unless $also_decrease_reserved is false.
244
+	 *
245
+	 * @param int $qty
246
+	 * @param boolean $also_decrease_reserved
247
+	 * @return boolean indicating success
248
+	 * @throws ReflectionException
249
+	 * @throws InvalidArgumentException
250
+	 * @throws InvalidInterfaceException
251
+	 * @throws InvalidDataTypeException
252
+	 * @throws EE_Error
253
+	 */
254
+	public function increaseSold($qty = 1, $also_decrease_reserved = true)
255
+	{
256
+		$qty = absint($qty);
257
+		if ($also_decrease_reserved) {
258
+			$success = $this->adjustNumericFieldsInDb(
259
+				[
260
+					'DTT_reserved' => $qty * -1,
261
+					'DTT_sold' => $qty
262
+				]
263
+			);
264
+		} else {
265
+			$success = $this->adjustNumericFieldsInDb(
266
+				[
267
+					'DTT_sold' => $qty
268
+				]
269
+			);
270
+		}
271
+
272
+		do_action(
273
+			'AHEE__EE_Datetime__increase_sold',
274
+			$this,
275
+			$qty,
276
+			$this->sold(),
277
+			$success
278
+		);
279
+		return $success;
280
+	}
281
+
282
+
283
+	/**
284
+	 * Decrements (subtracts) sold amount passed by $qty directly in the DB and on the model object. (Ie, no need
285
+	 * to save afterwards.)
286
+	 *
287
+	 * @param int $qty
288
+	 * @return boolean indicating success
289
+	 * @throws ReflectionException
290
+	 * @throws InvalidArgumentException
291
+	 * @throws InvalidInterfaceException
292
+	 * @throws InvalidDataTypeException
293
+	 * @throws EE_Error
294
+	 */
295
+	public function decreaseSold($qty = 1)
296
+	{
297
+		$qty = absint($qty);
298
+		$success = $this->adjustNumericFieldsInDb(
299
+			[
300
+				'DTT_sold' => $qty * -1
301
+			]
302
+		);
303
+		do_action(
304
+			'AHEE__EE_Datetime__decrease_sold',
305
+			$this,
306
+			$qty,
307
+			$this->sold(),
308
+			$success
309
+		);
310
+		return $success;
311
+	}
312
+
313
+
314
+	/**
315
+	 * Gets qty of reserved tickets for this datetime
316
+	 *
317
+	 * @return int
318
+	 * @throws ReflectionException
319
+	 * @throws InvalidArgumentException
320
+	 * @throws InvalidInterfaceException
321
+	 * @throws InvalidDataTypeException
322
+	 * @throws EE_Error
323
+	 */
324
+	public function reserved()
325
+	{
326
+		return $this->get_raw('DTT_reserved');
327
+	}
328
+
329
+
330
+	/**
331
+	 * Sets qty of reserved tickets for this datetime
332
+	 *
333
+	 * @param int $reserved
334
+	 * @throws ReflectionException
335
+	 * @throws InvalidArgumentException
336
+	 * @throws InvalidInterfaceException
337
+	 * @throws InvalidDataTypeException
338
+	 * @throws EE_Error
339
+	 */
340
+	public function set_reserved($reserved)
341
+	{
342
+		// reserved can not go below zero
343
+		$reserved = max(0, (int) $reserved);
344
+		$this->set('DTT_reserved', $reserved);
345
+	}
346
+
347
+
348
+	/**
349
+	 * Increments reserved by amount passed by $qty, and persists it immediately to the database.
350
+	 *
351
+	 * @param int $qty
352
+	 * @return boolean indicating success
353
+	 * @throws ReflectionException
354
+	 * @throws InvalidArgumentException
355
+	 * @throws InvalidInterfaceException
356
+	 * @throws InvalidDataTypeException
357
+	 * @throws EE_Error
358
+	 */
359
+	public function increaseReserved($qty = 1)
360
+	{
361
+		$qty = absint($qty);
362
+		$success = $this->incrementFieldConditionallyInDb(
363
+			'DTT_reserved',
364
+			'DTT_sold',
365
+			'DTT_reg_limit',
366
+			$qty
367
+		);
368
+		do_action(
369
+			'AHEE__EE_Datetime__increase_reserved',
370
+			$this,
371
+			$qty,
372
+			$this->reserved(),
373
+			$success
374
+		);
375
+		return $success;
376
+	}
377
+
378
+
379
+	/**
380
+	 * Decrements (subtracts) reserved by amount passed by $qty, and persists it immediately to the database.
381
+	 *
382
+	 * @param int $qty
383
+	 * @return boolean indicating success
384
+	 * @throws ReflectionException
385
+	 * @throws InvalidArgumentException
386
+	 * @throws InvalidInterfaceException
387
+	 * @throws InvalidDataTypeException
388
+	 * @throws EE_Error
389
+	 */
390
+	public function decreaseReserved($qty = 1)
391
+	{
392
+		$qty = absint($qty);
393
+		$success = $this->adjustNumericFieldsInDb(
394
+			[
395
+				'DTT_reserved' => $qty * -1
396
+			]
397
+		);
398
+		do_action(
399
+			'AHEE__EE_Datetime__decrease_reserved',
400
+			$this,
401
+			$qty,
402
+			$this->reserved(),
403
+			$success
404
+		);
405
+		return $success;
406
+	}
407
+
408
+
409
+	/**
410
+	 * total sold and reserved tickets
411
+	 *
412
+	 * @return int
413
+	 * @throws ReflectionException
414
+	 * @throws InvalidArgumentException
415
+	 * @throws InvalidInterfaceException
416
+	 * @throws InvalidDataTypeException
417
+	 * @throws EE_Error
418
+	 */
419
+	public function sold_and_reserved()
420
+	{
421
+		return $this->sold() + $this->reserved();
422
+	}
423
+
424
+
425
+	/**
426
+	 * returns the datetime name
427
+	 *
428
+	 * @return string
429
+	 * @throws ReflectionException
430
+	 * @throws InvalidArgumentException
431
+	 * @throws InvalidInterfaceException
432
+	 * @throws InvalidDataTypeException
433
+	 * @throws EE_Error
434
+	 */
435
+	public function name()
436
+	{
437
+		return $this->get('DTT_name');
438
+	}
439
+
440
+
441
+	/**
442
+	 * returns the datetime description
443
+	 *
444
+	 * @return string
445
+	 * @throws ReflectionException
446
+	 * @throws InvalidArgumentException
447
+	 * @throws InvalidInterfaceException
448
+	 * @throws InvalidDataTypeException
449
+	 * @throws EE_Error
450
+	 */
451
+	public function description()
452
+	{
453
+		return $this->get('DTT_description');
454
+	}
455
+
456
+
457
+	/**
458
+	 * This helper simply returns whether the event_datetime for the current datetime is a primary datetime
459
+	 *
460
+	 * @return boolean  TRUE if is primary, FALSE if not.
461
+	 * @throws ReflectionException
462
+	 * @throws InvalidArgumentException
463
+	 * @throws InvalidInterfaceException
464
+	 * @throws InvalidDataTypeException
465
+	 * @throws EE_Error
466
+	 */
467
+	public function is_primary()
468
+	{
469
+		return $this->get('DTT_is_primary');
470
+	}
471
+
472
+
473
+	/**
474
+	 * This helper simply returns the order for the datetime
475
+	 *
476
+	 * @return int  The order of the datetime for this event.
477
+	 * @throws ReflectionException
478
+	 * @throws InvalidArgumentException
479
+	 * @throws InvalidInterfaceException
480
+	 * @throws InvalidDataTypeException
481
+	 * @throws EE_Error
482
+	 */
483
+	public function order()
484
+	{
485
+		return $this->get('DTT_order');
486
+	}
487
+
488
+
489
+	/**
490
+	 * This helper simply returns the parent id for the datetime
491
+	 *
492
+	 * @return int
493
+	 * @throws ReflectionException
494
+	 * @throws InvalidArgumentException
495
+	 * @throws InvalidInterfaceException
496
+	 * @throws InvalidDataTypeException
497
+	 * @throws EE_Error
498
+	 */
499
+	public function parent()
500
+	{
501
+		return $this->get('DTT_parent');
502
+	}
503
+
504
+
505
+	/**
506
+	 * show date and/or time
507
+	 *
508
+	 * @param string $date_or_time    whether to display a date or time or both
509
+	 * @param string $start_or_end    whether to display start or end datetimes
510
+	 * @param string $dt_frmt
511
+	 * @param string $tm_frmt
512
+	 * @param bool   $echo            whether we echo or return (note echoing uses "pretty" formats,
513
+	 *                                otherwise we use the standard formats)
514
+	 * @return string|bool  string on success, FALSE on fail
515
+	 * @throws ReflectionException
516
+	 * @throws InvalidArgumentException
517
+	 * @throws InvalidInterfaceException
518
+	 * @throws InvalidDataTypeException
519
+	 * @throws EE_Error
520
+	 */
521
+	private function _show_datetime(
522
+		$date_or_time = null,
523
+		$start_or_end = 'start',
524
+		$dt_frmt = '',
525
+		$tm_frmt = '',
526
+		$echo = false
527
+	) {
528
+		$field_name = "DTT_EVT_{$start_or_end}";
529
+		$dtt = $this->_get_datetime(
530
+			$field_name,
531
+			$dt_frmt,
532
+			$tm_frmt,
533
+			$date_or_time,
534
+			$echo
535
+		);
536
+		if (! $echo) {
537
+			return $dtt;
538
+		}
539
+		return '';
540
+	}
541
+
542
+
543
+	/**
544
+	 * get event start date.  Provide either the date format, or NULL to re-use the
545
+	 * last-used format, or '' to use the default date format
546
+	 *
547
+	 * @param string $dt_frmt string representation of date format defaults to 'F j, Y'
548
+	 * @return mixed            string on success, FALSE on fail
549
+	 * @throws ReflectionException
550
+	 * @throws InvalidArgumentException
551
+	 * @throws InvalidInterfaceException
552
+	 * @throws InvalidDataTypeException
553
+	 * @throws EE_Error
554
+	 */
555
+	public function start_date($dt_frmt = '')
556
+	{
557
+		return $this->_show_datetime('D', 'start', $dt_frmt);
558
+	}
559
+
560
+
561
+	/**
562
+	 * Echoes start_date()
563
+	 *
564
+	 * @param string $dt_frmt
565
+	 * @throws ReflectionException
566
+	 * @throws InvalidArgumentException
567
+	 * @throws InvalidInterfaceException
568
+	 * @throws InvalidDataTypeException
569
+	 * @throws EE_Error
570
+	 */
571
+	public function e_start_date($dt_frmt = '')
572
+	{
573
+		$this->_show_datetime('D', 'start', $dt_frmt, null, true);
574
+	}
575
+
576
+
577
+	/**
578
+	 * get end date. Provide either the date format, or NULL to re-use the
579
+	 * last-used format, or '' to use the default date format
580
+	 *
581
+	 * @param string $dt_frmt string representation of date format defaults to 'F j, Y'
582
+	 * @return mixed            string on success, FALSE on fail
583
+	 * @throws ReflectionException
584
+	 * @throws InvalidArgumentException
585
+	 * @throws InvalidInterfaceException
586
+	 * @throws InvalidDataTypeException
587
+	 * @throws EE_Error
588
+	 */
589
+	public function end_date($dt_frmt = '')
590
+	{
591
+		return $this->_show_datetime('D', 'end', $dt_frmt);
592
+	}
593
+
594
+
595
+	/**
596
+	 * Echoes the end date. See end_date()
597
+	 *
598
+	 * @param string $dt_frmt
599
+	 * @throws ReflectionException
600
+	 * @throws InvalidArgumentException
601
+	 * @throws InvalidInterfaceException
602
+	 * @throws InvalidDataTypeException
603
+	 * @throws EE_Error
604
+	 */
605
+	public function e_end_date($dt_frmt = '')
606
+	{
607
+		$this->_show_datetime('D', 'end', $dt_frmt, null, true);
608
+	}
609
+
610
+
611
+	/**
612
+	 * get date_range - meaning the start AND end date
613
+	 *
614
+	 * @access public
615
+	 * @param string $dt_frmt     string representation of date format defaults to WP settings
616
+	 * @param string $conjunction conjunction junction what's your function ?
617
+	 *                            this string joins the start date with the end date ie: Jan 01 "to" Dec 31
618
+	 * @return mixed              string on success, FALSE on fail
619
+	 * @throws ReflectionException
620
+	 * @throws InvalidArgumentException
621
+	 * @throws InvalidInterfaceException
622
+	 * @throws InvalidDataTypeException
623
+	 * @throws EE_Error
624
+	 */
625
+	public function date_range($dt_frmt = '', $conjunction = ' - ')
626
+	{
627
+		$dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt;
628
+		$start = str_replace(
629
+			' ',
630
+			'&nbsp;',
631
+			$this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)
632
+		);
633
+		$end = str_replace(
634
+			' ',
635
+			'&nbsp;',
636
+			$this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)
637
+		);
638
+		return $start !== $end ? $start . $conjunction . $end : $start;
639
+	}
640
+
641
+
642
+	/**
643
+	 * @param string $dt_frmt
644
+	 * @param string $conjunction
645
+	 * @throws ReflectionException
646
+	 * @throws InvalidArgumentException
647
+	 * @throws InvalidInterfaceException
648
+	 * @throws InvalidDataTypeException
649
+	 * @throws EE_Error
650
+	 */
651
+	public function e_date_range($dt_frmt = '', $conjunction = ' - ')
652
+	{
653
+		echo $this->date_range($dt_frmt, $conjunction);
654
+	}
655
+
656
+
657
+	/**
658
+	 * get start time
659
+	 *
660
+	 * @param string $tm_format - string representation of time format defaults to 'g:i a'
661
+	 * @return mixed        string on success, FALSE on fail
662
+	 * @throws ReflectionException
663
+	 * @throws InvalidArgumentException
664
+	 * @throws InvalidInterfaceException
665
+	 * @throws InvalidDataTypeException
666
+	 * @throws EE_Error
667
+	 */
668
+	public function start_time($tm_format = '')
669
+	{
670
+		return $this->_show_datetime('T', 'start', null, $tm_format);
671
+	}
672
+
673
+
674
+	/**
675
+	 * @param string $tm_format
676
+	 * @throws ReflectionException
677
+	 * @throws InvalidArgumentException
678
+	 * @throws InvalidInterfaceException
679
+	 * @throws InvalidDataTypeException
680
+	 * @throws EE_Error
681
+	 */
682
+	public function e_start_time($tm_format = '')
683
+	{
684
+		$this->_show_datetime('T', 'start', null, $tm_format, true);
685
+	}
686
+
687
+
688
+	/**
689
+	 * get end time
690
+	 *
691
+	 * @param string $tm_format string representation of time format defaults to 'g:i a'
692
+	 * @return mixed                string on success, FALSE on fail
693
+	 * @throws ReflectionException
694
+	 * @throws InvalidArgumentException
695
+	 * @throws InvalidInterfaceException
696
+	 * @throws InvalidDataTypeException
697
+	 * @throws EE_Error
698
+	 */
699
+	public function end_time($tm_format = '')
700
+	{
701
+		return $this->_show_datetime('T', 'end', null, $tm_format);
702
+	}
703
+
704
+
705
+	/**
706
+	 * @param string $tm_format
707
+	 * @throws ReflectionException
708
+	 * @throws InvalidArgumentException
709
+	 * @throws InvalidInterfaceException
710
+	 * @throws InvalidDataTypeException
711
+	 * @throws EE_Error
712
+	 */
713
+	public function e_end_time($tm_format = '')
714
+	{
715
+		$this->_show_datetime('T', 'end', null, $tm_format, true);
716
+	}
717
+
718
+
719
+	/**
720
+	 * get time_range
721
+	 *
722
+	 * @access public
723
+	 * @param string $tm_format   string representation of time format defaults to 'g:i a'
724
+	 * @param string $conjunction conjunction junction what's your function ?
725
+	 *                            this string joins the start date with the end date ie: Jan 01 "to" Dec 31
726
+	 * @return mixed              string on success, FALSE on fail
727
+	 * @throws ReflectionException
728
+	 * @throws InvalidArgumentException
729
+	 * @throws InvalidInterfaceException
730
+	 * @throws InvalidDataTypeException
731
+	 * @throws EE_Error
732
+	 */
733
+	public function time_range($tm_format = '', $conjunction = ' - ')
734
+	{
735
+		$tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
736
+		$start = str_replace(
737
+			' ',
738
+			'&nbsp;',
739
+			$this->get_i18n_datetime('DTT_EVT_start', $tm_format)
740
+		);
741
+		$end = str_replace(
742
+			' ',
743
+			'&nbsp;',
744
+			$this->get_i18n_datetime('DTT_EVT_end', $tm_format)
745
+		);
746
+		return $start !== $end ? $start . $conjunction . $end : $start;
747
+	}
748
+
749
+
750
+	/**
751
+	 * @param string $tm_format
752
+	 * @param string $conjunction
753
+	 * @throws ReflectionException
754
+	 * @throws InvalidArgumentException
755
+	 * @throws InvalidInterfaceException
756
+	 * @throws InvalidDataTypeException
757
+	 * @throws EE_Error
758
+	 */
759
+	public function e_time_range($tm_format = '', $conjunction = ' - ')
760
+	{
761
+		echo $this->time_range($tm_format, $conjunction);
762
+	}
763
+
764
+
765
+	/**
766
+	 * This returns a range representation of the date and times.
767
+	 * Output is dependent on the difference (or similarity) between DTT_EVT_start and DTT_EVT_end.
768
+	 * Also, the return value is localized.
769
+	 *
770
+	 * @param string $dt_format
771
+	 * @param string $tm_format
772
+	 * @param string $conjunction used between two different dates or times.
773
+	 *                            ex: Dec 1{$conjunction}}Dec 6, or 2pm{$conjunction}3pm
774
+	 * @param string $separator   used between the date and time formats.
775
+	 *                            ex: Dec 1, 2016{$separator}2pm
776
+	 * @return string
777
+	 * @throws ReflectionException
778
+	 * @throws InvalidArgumentException
779
+	 * @throws InvalidInterfaceException
780
+	 * @throws InvalidDataTypeException
781
+	 * @throws EE_Error
782
+	 */
783
+	public function date_and_time_range(
784
+		$dt_format = '',
785
+		$tm_format = '',
786
+		$conjunction = ' - ',
787
+		$separator = ' '
788
+	) {
789
+		$dt_format = ! empty($dt_format) ? $dt_format : $this->_dt_frmt;
790
+		$tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
791
+		$full_format = $dt_format . $separator . $tm_format;
792
+		// the range output depends on various conditions
793
+		switch (true) {
794
+			// start date timestamp and end date timestamp are the same.
795
+			case ($this->get_raw('DTT_EVT_start') === $this->get_raw('DTT_EVT_end')):
796
+				$output = $this->get_i18n_datetime('DTT_EVT_start', $full_format);
797
+				break;
798
+			// start and end date are the same but times are different
799
+			case ($this->start_date() === $this->end_date()):
800
+				$output = $this->get_i18n_datetime('DTT_EVT_start', $full_format)
801
+						  . $conjunction
802
+						  . $this->get_i18n_datetime('DTT_EVT_end', $tm_format);
803
+				break;
804
+			// all other conditions
805
+			default:
806
+				$output = $this->get_i18n_datetime('DTT_EVT_start', $full_format)
807
+						  . $conjunction
808
+						  . $this->get_i18n_datetime('DTT_EVT_end', $full_format);
809
+				break;
810
+		}
811
+		return $output;
812
+	}
813
+
814
+
815
+	/**
816
+	 * This echos the results of date and time range.
817
+	 *
818
+	 * @see date_and_time_range() for more details on purpose.
819
+	 * @param string $dt_format
820
+	 * @param string $tm_format
821
+	 * @param string $conjunction
822
+	 * @return void
823
+	 * @throws ReflectionException
824
+	 * @throws InvalidArgumentException
825
+	 * @throws InvalidInterfaceException
826
+	 * @throws InvalidDataTypeException
827
+	 * @throws EE_Error
828
+	 */
829
+	public function e_date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ')
830
+	{
831
+		echo $this->date_and_time_range($dt_format, $tm_format, $conjunction);
832
+	}
833
+
834
+
835
+	/**
836
+	 * get start date and start time
837
+	 *
838
+	 * @param    string $dt_format - string representation of date format defaults to 'F j, Y'
839
+	 * @param    string $tm_format - string representation of time format defaults to 'g:i a'
840
+	 * @return    mixed    string on success, FALSE on fail
841
+	 * @throws ReflectionException
842
+	 * @throws InvalidArgumentException
843
+	 * @throws InvalidInterfaceException
844
+	 * @throws InvalidDataTypeException
845
+	 * @throws EE_Error
846
+	 */
847
+	public function start_date_and_time($dt_format = '', $tm_format = '')
848
+	{
849
+		return $this->_show_datetime('', 'start', $dt_format, $tm_format);
850
+	}
851
+
852
+
853
+	/**
854
+	 * @param string $dt_frmt
855
+	 * @param string $tm_format
856
+	 * @throws ReflectionException
857
+	 * @throws InvalidArgumentException
858
+	 * @throws InvalidInterfaceException
859
+	 * @throws InvalidDataTypeException
860
+	 * @throws EE_Error
861
+	 */
862
+	public function e_start_date_and_time($dt_frmt = '', $tm_format = '')
863
+	{
864
+		$this->_show_datetime('', 'start', $dt_frmt, $tm_format, true);
865
+	}
866
+
867
+
868
+	/**
869
+	 * Shows the length of the event (start to end time).
870
+	 * Can be shown in 'seconds','minutes','hours', or 'days'.
871
+	 * By default, rounds up. (So if you use 'days', and then event
872
+	 * only occurs for 1 hour, it will return 1 day).
873
+	 *
874
+	 * @param string $units 'seconds','minutes','hours','days'
875
+	 * @param bool   $round_up
876
+	 * @return float|int|mixed
877
+	 * @throws ReflectionException
878
+	 * @throws InvalidArgumentException
879
+	 * @throws InvalidInterfaceException
880
+	 * @throws InvalidDataTypeException
881
+	 * @throws EE_Error
882
+	 */
883
+	public function length($units = 'seconds', $round_up = false)
884
+	{
885
+		$start = $this->get_raw('DTT_EVT_start');
886
+		$end = $this->get_raw('DTT_EVT_end');
887
+		$length_in_units = $end - $start;
888
+		switch ($units) {
889
+			// NOTE: We purposefully don't use "break;" in order to chain the divisions
890
+			/** @noinspection PhpMissingBreakStatementInspection */
891
+			// phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
892
+			case 'days':
893
+				$length_in_units /= 24;
894
+			/** @noinspection PhpMissingBreakStatementInspection */
895
+			case 'hours':
896
+				// fall through is intentional
897
+				$length_in_units /= 60;
898
+			/** @noinspection PhpMissingBreakStatementInspection */
899
+			case 'minutes':
900
+				// fall through is intentional
901
+				$length_in_units /= 60;
902
+			case 'seconds':
903
+			default:
904
+				$length_in_units = ceil($length_in_units);
905
+		}
906
+		// phpcs:enable
907
+		if ($round_up) {
908
+			$length_in_units = max($length_in_units, 1);
909
+		}
910
+		return $length_in_units;
911
+	}
912
+
913
+
914
+	/**
915
+	 *        get end date and time
916
+	 *
917
+	 * @param string $dt_frmt   - string representation of date format defaults to 'F j, Y'
918
+	 * @param string $tm_format - string representation of time format defaults to 'g:i a'
919
+	 * @return    mixed                string on success, FALSE on fail
920
+	 * @throws ReflectionException
921
+	 * @throws InvalidArgumentException
922
+	 * @throws InvalidInterfaceException
923
+	 * @throws InvalidDataTypeException
924
+	 * @throws EE_Error
925
+	 */
926
+	public function end_date_and_time($dt_frmt = '', $tm_format = '')
927
+	{
928
+		return $this->_show_datetime('', 'end', $dt_frmt, $tm_format);
929
+	}
930
+
931
+
932
+	/**
933
+	 * @param string $dt_frmt
934
+	 * @param string $tm_format
935
+	 * @throws ReflectionException
936
+	 * @throws InvalidArgumentException
937
+	 * @throws InvalidInterfaceException
938
+	 * @throws InvalidDataTypeException
939
+	 * @throws EE_Error
940
+	 */
941
+	public function e_end_date_and_time($dt_frmt = '', $tm_format = '')
942
+	{
943
+		$this->_show_datetime('', 'end', $dt_frmt, $tm_format, true);
944
+	}
945
+
946
+
947
+	/**
948
+	 *        get start timestamp
949
+	 *
950
+	 * @return        int
951
+	 * @throws ReflectionException
952
+	 * @throws InvalidArgumentException
953
+	 * @throws InvalidInterfaceException
954
+	 * @throws InvalidDataTypeException
955
+	 * @throws EE_Error
956
+	 */
957
+	public function start()
958
+	{
959
+		return $this->get_raw('DTT_EVT_start');
960
+	}
961
+
962
+
963
+	/**
964
+	 *        get end timestamp
965
+	 *
966
+	 * @return        int
967
+	 * @throws ReflectionException
968
+	 * @throws InvalidArgumentException
969
+	 * @throws InvalidInterfaceException
970
+	 * @throws InvalidDataTypeException
971
+	 * @throws EE_Error
972
+	 */
973
+	public function end()
974
+	{
975
+		return $this->get_raw('DTT_EVT_end');
976
+	}
977
+
978
+
979
+	/**
980
+	 *    get the registration limit for this datetime slot
981
+	 *
982
+	 * @return        mixed        int on success, FALSE on fail
983
+	 * @throws ReflectionException
984
+	 * @throws InvalidArgumentException
985
+	 * @throws InvalidInterfaceException
986
+	 * @throws InvalidDataTypeException
987
+	 * @throws EE_Error
988
+	 */
989
+	public function reg_limit()
990
+	{
991
+		return $this->get_raw('DTT_reg_limit');
992
+	}
993
+
994
+
995
+	/**
996
+	 *    have the tickets sold for this datetime, met or exceed the registration limit ?
997
+	 *
998
+	 * @return        boolean
999
+	 * @throws ReflectionException
1000
+	 * @throws InvalidArgumentException
1001
+	 * @throws InvalidInterfaceException
1002
+	 * @throws InvalidDataTypeException
1003
+	 * @throws EE_Error
1004
+	 */
1005
+	public function sold_out()
1006
+	{
1007
+		return $this->reg_limit() > 0 && $this->sold() >= $this->reg_limit();
1008
+	}
1009
+
1010
+
1011
+	/**
1012
+	 * return the total number of spaces remaining at this venue.
1013
+	 * This only takes the venue's capacity into account, NOT the tickets available for sale
1014
+	 *
1015
+	 * @param bool $consider_tickets Whether to consider tickets remaining when determining if there are any spaces left
1016
+	 *                               Because if all tickets attached to this datetime have no spaces left,
1017
+	 *                               then this datetime IS effectively sold out.
1018
+	 *                               However, there are cases where we just want to know the spaces
1019
+	 *                               remaining for this particular datetime, hence the flag.
1020
+	 * @return int
1021
+	 * @throws ReflectionException
1022
+	 * @throws InvalidArgumentException
1023
+	 * @throws InvalidInterfaceException
1024
+	 * @throws InvalidDataTypeException
1025
+	 * @throws EE_Error
1026
+	 */
1027
+	public function spaces_remaining($consider_tickets = false)
1028
+	{
1029
+		// tickets remaining available for purchase
1030
+		// no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF
1031
+		$dtt_remaining = $this->reg_limit() - $this->sold_and_reserved();
1032
+		if (! $consider_tickets) {
1033
+			return $dtt_remaining;
1034
+		}
1035
+		$tickets_remaining = $this->tickets_remaining();
1036
+		return min($dtt_remaining, $tickets_remaining);
1037
+	}
1038
+
1039
+
1040
+	/**
1041
+	 * Counts the total tickets available
1042
+	 * (from all the different types of tickets which are available for this datetime).
1043
+	 *
1044
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1045
+	 * @return int
1046
+	 * @throws ReflectionException
1047
+	 * @throws InvalidArgumentException
1048
+	 * @throws InvalidInterfaceException
1049
+	 * @throws InvalidDataTypeException
1050
+	 * @throws EE_Error
1051
+	 */
1052
+	public function tickets_remaining($query_params = array())
1053
+	{
1054
+		$sum = 0;
1055
+		$tickets = $this->tickets($query_params);
1056
+		if (! empty($tickets)) {
1057
+			foreach ($tickets as $ticket) {
1058
+				if ($ticket instanceof EE_Ticket) {
1059
+					// get the actual amount of tickets that can be sold
1060
+					$qty = $ticket->qty('saleable');
1061
+					if ($qty === EE_INF) {
1062
+						return EE_INF;
1063
+					}
1064
+					// no negative ticket quantities plz
1065
+					if ($qty > 0) {
1066
+						$sum += $qty;
1067
+					}
1068
+				}
1069
+			}
1070
+		}
1071
+		return $sum;
1072
+	}
1073
+
1074
+
1075
+	/**
1076
+	 * Gets the count of all the tickets available at this datetime (not ticket types)
1077
+	 * before any were sold
1078
+	 *
1079
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1080
+	 * @return int
1081
+	 * @throws ReflectionException
1082
+	 * @throws InvalidArgumentException
1083
+	 * @throws InvalidInterfaceException
1084
+	 * @throws InvalidDataTypeException
1085
+	 * @throws EE_Error
1086
+	 */
1087
+	public function sum_tickets_initially_available($query_params = array())
1088
+	{
1089
+		return $this->sum_related('Ticket', $query_params, 'TKT_qty');
1090
+	}
1091
+
1092
+
1093
+	/**
1094
+	 * Returns the lesser-of-the two: spaces remaining at this datetime, or
1095
+	 * the total tickets remaining (a sum of the tickets remaining for each ticket type
1096
+	 * that is available for this datetime).
1097
+	 *
1098
+	 * @return int
1099
+	 * @throws ReflectionException
1100
+	 * @throws InvalidArgumentException
1101
+	 * @throws InvalidInterfaceException
1102
+	 * @throws InvalidDataTypeException
1103
+	 * @throws EE_Error
1104
+	 */
1105
+	public function total_tickets_available_at_this_datetime()
1106
+	{
1107
+		return $this->spaces_remaining(true);
1108
+	}
1109
+
1110
+
1111
+	/**
1112
+	 * This simply compares the internal dtt for the given string with NOW
1113
+	 * and determines if the date is upcoming or not.
1114
+	 *
1115
+	 * @access public
1116
+	 * @return boolean
1117
+	 * @throws ReflectionException
1118
+	 * @throws InvalidArgumentException
1119
+	 * @throws InvalidInterfaceException
1120
+	 * @throws InvalidDataTypeException
1121
+	 * @throws EE_Error
1122
+	 */
1123
+	public function is_upcoming()
1124
+	{
1125
+		return ($this->get_raw('DTT_EVT_start') > time());
1126
+	}
1127
+
1128
+
1129
+	/**
1130
+	 * This simply compares the internal datetime for the given string with NOW
1131
+	 * and returns if the date is active (i.e. start and end time)
1132
+	 *
1133
+	 * @return boolean
1134
+	 * @throws ReflectionException
1135
+	 * @throws InvalidArgumentException
1136
+	 * @throws InvalidInterfaceException
1137
+	 * @throws InvalidDataTypeException
1138
+	 * @throws EE_Error
1139
+	 */
1140
+	public function is_active()
1141
+	{
1142
+		return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time());
1143
+	}
1144
+
1145
+
1146
+	/**
1147
+	 * This simply compares the internal dtt for the given string with NOW
1148
+	 * and determines if the date is expired or not.
1149
+	 *
1150
+	 * @return boolean
1151
+	 * @throws ReflectionException
1152
+	 * @throws InvalidArgumentException
1153
+	 * @throws InvalidInterfaceException
1154
+	 * @throws InvalidDataTypeException
1155
+	 * @throws EE_Error
1156
+	 */
1157
+	public function is_expired()
1158
+	{
1159
+		return ($this->get_raw('DTT_EVT_end') < time());
1160
+	}
1161
+
1162
+
1163
+	/**
1164
+	 * This returns the active status for whether an event is active, upcoming, or expired
1165
+	 *
1166
+	 * @return int return value will be one of the EE_Datetime status constants.
1167
+	 * @throws ReflectionException
1168
+	 * @throws InvalidArgumentException
1169
+	 * @throws InvalidInterfaceException
1170
+	 * @throws InvalidDataTypeException
1171
+	 * @throws EE_Error
1172
+	 */
1173
+	public function get_active_status()
1174
+	{
1175
+		$total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime();
1176
+		if ($total_tickets_for_this_dtt !== false && $total_tickets_for_this_dtt < 1) {
1177
+			return EE_Datetime::sold_out;
1178
+		}
1179
+		if ($this->is_expired()) {
1180
+			return EE_Datetime::expired;
1181
+		}
1182
+		if ($this->is_upcoming()) {
1183
+			return EE_Datetime::upcoming;
1184
+		}
1185
+		if ($this->is_active()) {
1186
+			return EE_Datetime::active;
1187
+		}
1188
+		return null;
1189
+	}
1190
+
1191
+
1192
+	/**
1193
+	 * This returns a nice display name for the datetime that is contingent on the span between the dates and times.
1194
+	 *
1195
+	 * @param  boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty.
1196
+	 * @return string
1197
+	 * @throws ReflectionException
1198
+	 * @throws InvalidArgumentException
1199
+	 * @throws InvalidInterfaceException
1200
+	 * @throws InvalidDataTypeException
1201
+	 * @throws EE_Error
1202
+	 */
1203
+	public function get_dtt_display_name($use_dtt_name = false)
1204
+	{
1205
+		if ($use_dtt_name) {
1206
+			$dtt_name = $this->name();
1207
+			if (! empty($dtt_name)) {
1208
+				return $dtt_name;
1209
+			}
1210
+		}
1211
+		// first condition is to see if the months are different
1212
+		if (
1213
+			date('m', $this->get_raw('DTT_EVT_start')) !== date('m', $this->get_raw('DTT_EVT_end'))
1214
+		) {
1215
+			$display_date = $this->start_date('M j\, Y g:i a') . ' - ' . $this->end_date('M j\, Y g:i a');
1216
+			// next condition is if its the same month but different day
1217
+		} else {
1218
+			if (
1219
+				date('m', $this->get_raw('DTT_EVT_start')) === date('m', $this->get_raw('DTT_EVT_end'))
1220
+				&& date('d', $this->get_raw('DTT_EVT_start')) !== date('d', $this->get_raw('DTT_EVT_end'))
1221
+			) {
1222
+				$display_date = $this->start_date('M j\, g:i a') . ' - ' . $this->end_date('M j\, g:i a Y');
1223
+			} else {
1224
+				$display_date = $this->start_date('F j\, Y')
1225
+								. ' @ '
1226
+								. $this->start_date('g:i a')
1227
+								. ' - '
1228
+								. $this->end_date('g:i a');
1229
+			}
1230
+		}
1231
+		return $display_date;
1232
+	}
1233
+
1234
+
1235
+	/**
1236
+	 * Gets all the tickets for this datetime
1237
+	 *
1238
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1239
+	 * @return EE_Base_Class[]|EE_Ticket[]
1240
+	 * @throws ReflectionException
1241
+	 * @throws InvalidArgumentException
1242
+	 * @throws InvalidInterfaceException
1243
+	 * @throws InvalidDataTypeException
1244
+	 * @throws EE_Error
1245
+	 */
1246
+	public function tickets($query_params = array())
1247
+	{
1248
+		return $this->get_many_related('Ticket', $query_params);
1249
+	}
1250
+
1251
+
1252
+	/**
1253
+	 * Gets all the ticket types currently available for purchase
1254
+	 *
1255
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1256
+	 * @return EE_Ticket[]
1257
+	 * @throws ReflectionException
1258
+	 * @throws InvalidArgumentException
1259
+	 * @throws InvalidInterfaceException
1260
+	 * @throws InvalidDataTypeException
1261
+	 * @throws EE_Error
1262
+	 */
1263
+	public function ticket_types_available_for_purchase($query_params = array())
1264
+	{
1265
+		// first check if datetime is valid
1266
+		if ($this->sold_out() || ! ($this->is_upcoming() || $this->is_active())) {
1267
+			return array();
1268
+		}
1269
+		if (empty($query_params)) {
1270
+			$query_params = array(
1271
+				array(
1272
+					'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')),
1273
+					'TKT_end_date'   => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')),
1274
+					'TKT_deleted'    => false,
1275
+				),
1276
+			);
1277
+		}
1278
+		return $this->tickets($query_params);
1279
+	}
1280
+
1281
+
1282
+	/**
1283
+	 * @return EE_Base_Class|EE_Event
1284
+	 * @throws ReflectionException
1285
+	 * @throws InvalidArgumentException
1286
+	 * @throws InvalidInterfaceException
1287
+	 * @throws InvalidDataTypeException
1288
+	 * @throws EE_Error
1289
+	 */
1290
+	public function event()
1291
+	{
1292
+		return $this->get_first_related('Event');
1293
+	}
1294
+
1295
+
1296
+	/**
1297
+	 * Updates the DTT_sold attribute (and saves) based on the number of registrations for this datetime
1298
+	 * (via the tickets).
1299
+	 *
1300
+	 * @return int
1301
+	 * @throws ReflectionException
1302
+	 * @throws InvalidArgumentException
1303
+	 * @throws InvalidInterfaceException
1304
+	 * @throws InvalidDataTypeException
1305
+	 * @throws EE_Error
1306
+	 */
1307
+	public function update_sold()
1308
+	{
1309
+		$count_regs_for_this_datetime = EEM_Registration::instance()->count(
1310
+			array(
1311
+				array(
1312
+					'STS_ID'                 => EEM_Registration::status_id_approved,
1313
+					'REG_deleted'            => 0,
1314
+					'Ticket.Datetime.DTT_ID' => $this->ID(),
1315
+				),
1316
+			)
1317
+		);
1318
+		$this->set_sold($count_regs_for_this_datetime);
1319
+		$this->save();
1320
+		return $count_regs_for_this_datetime;
1321
+	}
1322
+
1323
+
1324
+	/*******************************************************************
1325 1325
      ***********************  DEPRECATED METHODS  **********************
1326 1326
      *******************************************************************/
1327 1327
 
1328 1328
 
1329
-    /**
1330
-     * Increments sold by amount passed by $qty, and persists it immediately to the database.
1331
-     *
1332
-     * @deprecated 4.9.80.p
1333
-     * @param int $qty
1334
-     * @return boolean
1335
-     * @throws ReflectionException
1336
-     * @throws InvalidArgumentException
1337
-     * @throws InvalidInterfaceException
1338
-     * @throws InvalidDataTypeException
1339
-     * @throws EE_Error
1340
-     */
1341
-    public function increase_sold($qty = 1)
1342
-    {
1343
-        EE_Error::doing_it_wrong(
1344
-            __FUNCTION__,
1345
-            esc_html__('Please use EE_Datetime::increaseSold() instead', 'event_espresso'),
1346
-            '4.9.80.p',
1347
-            '5.0.0.p'
1348
-        );
1349
-        return $this->increaseSold($qty);
1350
-    }
1351
-
1352
-
1353
-    /**
1354
-     * Decrements (subtracts) sold amount passed by $qty directly in the DB and on the model object. (Ie, no need
1355
-     * to save afterwards.)
1356
-     *
1357
-     * @deprecated 4.9.80.p
1358
-     * @param int $qty
1359
-     * @return boolean
1360
-     * @throws ReflectionException
1361
-     * @throws InvalidArgumentException
1362
-     * @throws InvalidInterfaceException
1363
-     * @throws InvalidDataTypeException
1364
-     * @throws EE_Error
1365
-     */
1366
-    public function decrease_sold($qty = 1)
1367
-    {
1368
-        EE_Error::doing_it_wrong(
1369
-            __FUNCTION__,
1370
-            esc_html__('Please use EE_Datetime::decreaseSold() instead', 'event_espresso'),
1371
-            '4.9.80.p',
1372
-            '5.0.0.p'
1373
-        );
1374
-        return $this->decreaseSold($qty);
1375
-    }
1376
-
1377
-
1378
-    /**
1379
-     * Increments reserved by amount passed by $qty, and persists it immediately to the database.
1380
-     *
1381
-     * @deprecated 4.9.80.p
1382
-     * @param int $qty
1383
-     * @return boolean indicating success
1384
-     * @throws ReflectionException
1385
-     * @throws InvalidArgumentException
1386
-     * @throws InvalidInterfaceException
1387
-     * @throws InvalidDataTypeException
1388
-     * @throws EE_Error
1389
-     */
1390
-    public function increase_reserved($qty = 1)
1391
-    {
1392
-        EE_Error::doing_it_wrong(
1393
-            __FUNCTION__,
1394
-            esc_html__('Please use EE_Datetime::increaseReserved() instead', 'event_espresso'),
1395
-            '4.9.80.p',
1396
-            '5.0.0.p'
1397
-        );
1398
-        return $this->increaseReserved($qty);
1399
-    }
1400
-
1401
-
1402
-    /**
1403
-     * Decrements (subtracts) reserved by amount passed by $qty, and persists it immediately to the database.
1404
-     *
1405
-     * @deprecated 4.9.80.p
1406
-     * @param int $qty
1407
-     * @return boolean
1408
-     * @throws ReflectionException
1409
-     * @throws InvalidArgumentException
1410
-     * @throws InvalidInterfaceException
1411
-     * @throws InvalidDataTypeException
1412
-     * @throws EE_Error
1413
-     */
1414
-    public function decrease_reserved($qty = 1)
1415
-    {
1416
-        EE_Error::doing_it_wrong(
1417
-            __FUNCTION__,
1418
-            esc_html__('Please use EE_Datetime::decreaseReserved() instead', 'event_espresso'),
1419
-            '4.9.80.p',
1420
-            '5.0.0.p'
1421
-        );
1422
-        return $this->decreaseReserved($qty);
1423
-    }
1329
+	/**
1330
+	 * Increments sold by amount passed by $qty, and persists it immediately to the database.
1331
+	 *
1332
+	 * @deprecated 4.9.80.p
1333
+	 * @param int $qty
1334
+	 * @return boolean
1335
+	 * @throws ReflectionException
1336
+	 * @throws InvalidArgumentException
1337
+	 * @throws InvalidInterfaceException
1338
+	 * @throws InvalidDataTypeException
1339
+	 * @throws EE_Error
1340
+	 */
1341
+	public function increase_sold($qty = 1)
1342
+	{
1343
+		EE_Error::doing_it_wrong(
1344
+			__FUNCTION__,
1345
+			esc_html__('Please use EE_Datetime::increaseSold() instead', 'event_espresso'),
1346
+			'4.9.80.p',
1347
+			'5.0.0.p'
1348
+		);
1349
+		return $this->increaseSold($qty);
1350
+	}
1351
+
1352
+
1353
+	/**
1354
+	 * Decrements (subtracts) sold amount passed by $qty directly in the DB and on the model object. (Ie, no need
1355
+	 * to save afterwards.)
1356
+	 *
1357
+	 * @deprecated 4.9.80.p
1358
+	 * @param int $qty
1359
+	 * @return boolean
1360
+	 * @throws ReflectionException
1361
+	 * @throws InvalidArgumentException
1362
+	 * @throws InvalidInterfaceException
1363
+	 * @throws InvalidDataTypeException
1364
+	 * @throws EE_Error
1365
+	 */
1366
+	public function decrease_sold($qty = 1)
1367
+	{
1368
+		EE_Error::doing_it_wrong(
1369
+			__FUNCTION__,
1370
+			esc_html__('Please use EE_Datetime::decreaseSold() instead', 'event_espresso'),
1371
+			'4.9.80.p',
1372
+			'5.0.0.p'
1373
+		);
1374
+		return $this->decreaseSold($qty);
1375
+	}
1376
+
1377
+
1378
+	/**
1379
+	 * Increments reserved by amount passed by $qty, and persists it immediately to the database.
1380
+	 *
1381
+	 * @deprecated 4.9.80.p
1382
+	 * @param int $qty
1383
+	 * @return boolean indicating success
1384
+	 * @throws ReflectionException
1385
+	 * @throws InvalidArgumentException
1386
+	 * @throws InvalidInterfaceException
1387
+	 * @throws InvalidDataTypeException
1388
+	 * @throws EE_Error
1389
+	 */
1390
+	public function increase_reserved($qty = 1)
1391
+	{
1392
+		EE_Error::doing_it_wrong(
1393
+			__FUNCTION__,
1394
+			esc_html__('Please use EE_Datetime::increaseReserved() instead', 'event_espresso'),
1395
+			'4.9.80.p',
1396
+			'5.0.0.p'
1397
+		);
1398
+		return $this->increaseReserved($qty);
1399
+	}
1400
+
1401
+
1402
+	/**
1403
+	 * Decrements (subtracts) reserved by amount passed by $qty, and persists it immediately to the database.
1404
+	 *
1405
+	 * @deprecated 4.9.80.p
1406
+	 * @param int $qty
1407
+	 * @return boolean
1408
+	 * @throws ReflectionException
1409
+	 * @throws InvalidArgumentException
1410
+	 * @throws InvalidInterfaceException
1411
+	 * @throws InvalidDataTypeException
1412
+	 * @throws EE_Error
1413
+	 */
1414
+	public function decrease_reserved($qty = 1)
1415
+	{
1416
+		EE_Error::doing_it_wrong(
1417
+			__FUNCTION__,
1418
+			esc_html__('Please use EE_Datetime::decreaseReserved() instead', 'event_espresso'),
1419
+			'4.9.80.p',
1420
+			'5.0.0.p'
1421
+		);
1422
+		return $this->decreaseReserved($qty);
1423
+	}
1424 1424
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
             $date_or_time,
534 534
             $echo
535 535
         );
536
-        if (! $echo) {
536
+        if ( ! $echo) {
537 537
             return $dtt;
538 538
         }
539 539
         return '';
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
             '&nbsp;',
636 636
             $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)
637 637
         );
638
-        return $start !== $end ? $start . $conjunction . $end : $start;
638
+        return $start !== $end ? $start.$conjunction.$end : $start;
639 639
     }
640 640
 
641 641
 
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
             '&nbsp;',
744 744
             $this->get_i18n_datetime('DTT_EVT_end', $tm_format)
745 745
         );
746
-        return $start !== $end ? $start . $conjunction . $end : $start;
746
+        return $start !== $end ? $start.$conjunction.$end : $start;
747 747
     }
748 748
 
749 749
 
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
     ) {
789 789
         $dt_format = ! empty($dt_format) ? $dt_format : $this->_dt_frmt;
790 790
         $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
791
-        $full_format = $dt_format . $separator . $tm_format;
791
+        $full_format = $dt_format.$separator.$tm_format;
792 792
         // the range output depends on various conditions
793 793
         switch (true) {
794 794
             // start date timestamp and end date timestamp are the same.
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
         // tickets remaining available for purchase
1030 1030
         // no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF
1031 1031
         $dtt_remaining = $this->reg_limit() - $this->sold_and_reserved();
1032
-        if (! $consider_tickets) {
1032
+        if ( ! $consider_tickets) {
1033 1033
             return $dtt_remaining;
1034 1034
         }
1035 1035
         $tickets_remaining = $this->tickets_remaining();
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
     {
1054 1054
         $sum = 0;
1055 1055
         $tickets = $this->tickets($query_params);
1056
-        if (! empty($tickets)) {
1056
+        if ( ! empty($tickets)) {
1057 1057
             foreach ($tickets as $ticket) {
1058 1058
                 if ($ticket instanceof EE_Ticket) {
1059 1059
                     // get the actual amount of tickets that can be sold
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
     {
1205 1205
         if ($use_dtt_name) {
1206 1206
             $dtt_name = $this->name();
1207
-            if (! empty($dtt_name)) {
1207
+            if ( ! empty($dtt_name)) {
1208 1208
                 return $dtt_name;
1209 1209
             }
1210 1210
         }
@@ -1212,14 +1212,14 @@  discard block
 block discarded – undo
1212 1212
         if (
1213 1213
             date('m', $this->get_raw('DTT_EVT_start')) !== date('m', $this->get_raw('DTT_EVT_end'))
1214 1214
         ) {
1215
-            $display_date = $this->start_date('M j\, Y g:i a') . ' - ' . $this->end_date('M j\, Y g:i a');
1215
+            $display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a');
1216 1216
             // next condition is if its the same month but different day
1217 1217
         } else {
1218 1218
             if (
1219 1219
                 date('m', $this->get_raw('DTT_EVT_start')) === date('m', $this->get_raw('DTT_EVT_end'))
1220 1220
                 && date('d', $this->get_raw('DTT_EVT_start')) !== date('d', $this->get_raw('DTT_EVT_end'))
1221 1221
             ) {
1222
-                $display_date = $this->start_date('M j\, g:i a') . ' - ' . $this->end_date('M j\, g:i a Y');
1222
+                $display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y');
1223 1223
             } else {
1224 1224
                 $display_date = $this->start_date('F j\, Y')
1225 1225
                                 . ' @ '
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Proper.form.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
      *                                                      with construction finalize being called later
460 460
      *                                                      (realizing that the subsections' html names
461 461
      *                                                      might not be set yet, etc.)
462
-     * @return EE_Form_Section_Base
462
+     * @return EE_Form_Section_Validatable|null
463 463
      * @throws EE_Error
464 464
      */
465 465
     public function get_subsection($name, $require_construction_to_be_finalized = true)
@@ -1289,7 +1289,6 @@  discard block
 block discarded – undo
1289 1289
     /**
1290 1290
      * Sets the submission error message (aka validation error message for this form section and all sub-sections)
1291 1291
      * @param string                           $form_submission_error_message
1292
-     * @param EE_Form_Section_Validatable $form_section unused
1293 1292
      * @throws EE_Error
1294 1293
      */
1295 1294
     public function set_submission_error_message(
Please login to merge, or discard this patch.
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   +1526 added lines, -1526 removed lines patch added patch discarded remove patch
@@ -14,1530 +14,1530 @@
 block discarded – undo
14 14
 class EE_Form_Section_Proper extends EE_Form_Section_Validatable
15 15
 {
16 16
 
17
-    const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data';
18
-
19
-    /**
20
-     * Subsections
21
-     *
22
-     * @var EE_Form_Section_Validatable[]
23
-     */
24
-    protected $_subsections = array();
25
-
26
-    /**
27
-     * Strategy for laying out the form
28
-     *
29
-     * @var EE_Form_Section_Layout_Base
30
-     */
31
-    protected $_layout_strategy;
32
-
33
-    /**
34
-     * Whether or not this form has received and validated a form submission yet
35
-     *
36
-     * @var boolean
37
-     */
38
-    protected $_received_submission = false;
39
-
40
-    /**
41
-     * message displayed to users upon successful form submission
42
-     *
43
-     * @var string
44
-     */
45
-    protected $_form_submission_success_message = '';
46
-
47
-    /**
48
-     * message displayed to users upon unsuccessful form submission
49
-     *
50
-     * @var string
51
-     */
52
-    protected $_form_submission_error_message = '';
53
-
54
-    /**
55
-     * @var array like $_REQUEST
56
-     */
57
-    protected $cached_request_data;
58
-
59
-    /**
60
-     * Stores whether this form (and its sub-sections) were found to be valid or not.
61
-     * Starts off as null, but once the form is validated, it set to either true or false
62
-     * @var boolean|null
63
-     */
64
-    protected $is_valid;
65
-
66
-    /**
67
-     * Stores all the data that will localized for form validation
68
-     *
69
-     * @var array
70
-     */
71
-    protected static $_js_localization = array();
72
-
73
-    /**
74
-     * whether or not the form's localized validation JS vars have been set
75
-     *
76
-     * @type boolean
77
-     */
78
-    protected static $_scripts_localized = false;
79
-
80
-
81
-    /**
82
-     * when constructing a proper form section, calls _construct_finalize on children
83
-     * so that they know who their parent is, and what name they've been given.
84
-     *
85
-     * @param array[] $options_array   {
86
-     * @type          $subsections     EE_Form_Section_Validatable[] where keys are the section's name
87
-     * @type          $include         string[] numerically-indexed where values are section names to be included,
88
-     *                                 and in that order. This is handy if you want
89
-     *                                 the subsections to be ordered differently than the default, and if you override
90
-     *                                 which fields are shown
91
-     * @type          $exclude         string[] values are subsections to be excluded. This is handy if you want
92
-     *                                 to remove certain default subsections (note: if you specify BOTH 'include' AND
93
-     *                                 'exclude', the inclusions will be applied first, and the exclusions will exclude
94
-     *                                 items from that list of inclusions)
95
-     * @type          $layout_strategy EE_Form_Section_Layout_Base strategy for laying out the form
96
-     *                                 } @see EE_Form_Section_Validatable::__construct()
97
-     * @throws EE_Error
98
-     */
99
-    public function __construct($options_array = array())
100
-    {
101
-        $options_array = (array) apply_filters(
102
-            'FHEE__EE_Form_Section_Proper___construct__options_array',
103
-            $options_array,
104
-            $this
105
-        );
106
-        // call parent first, as it may be setting the name
107
-        parent::__construct($options_array);
108
-        // if they've included subsections in the constructor, add them now
109
-        if (isset($options_array['include'])) {
110
-            // we are going to make sure we ONLY have those subsections to include
111
-            // AND we are going to make sure they're in that specified order
112
-            $reordered_subsections = array();
113
-            foreach ($options_array['include'] as $input_name) {
114
-                if (isset($this->_subsections[ $input_name ])) {
115
-                    $reordered_subsections[ $input_name ] = $this->_subsections[ $input_name ];
116
-                }
117
-            }
118
-            $this->_subsections = $reordered_subsections;
119
-        }
120
-        if (isset($options_array['exclude'])) {
121
-            $exclude            = $options_array['exclude'];
122
-            $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
123
-        }
124
-        if (isset($options_array['layout_strategy'])) {
125
-            $this->_layout_strategy = $options_array['layout_strategy'];
126
-        }
127
-        if (! $this->_layout_strategy) {
128
-            $this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
129
-        }
130
-        $this->_layout_strategy->_construct_finalize($this);
131
-        // ok so we are definitely going to want the forms JS,
132
-        // so enqueue it or remember to enqueue it during wp_enqueue_scripts
133
-        if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
134
-            // ok so they've constructed this object after when they should have.
135
-            // just enqueue the generic form scripts and initialize the form immediately in the JS
136
-            EE_Form_Section_Proper::wp_enqueue_scripts(true);
137
-        } else {
138
-            add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
139
-            add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
140
-        }
141
-        add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
142
-        /**
143
-         * Gives other plugins a chance to hook in before construct finalize is called.
144
-         * The form probably doesn't yet have a parent form section.
145
-         * Since 4.9.32, when this action was introduced, this is the best place to add a subsection onto a form,
146
-         * assuming you don't care what the form section's name, HTML ID, or HTML name etc are.
147
-         * Also see AHEE__EE_Form_Section_Proper___construct_finalize__end
148
-         *
149
-         * @since 4.9.32
150
-         * @param EE_Form_Section_Proper $this          before __construct is done, but all of its logic,
151
-         *                                              except maybe calling _construct_finalize has been done
152
-         * @param array                  $options_array options passed into the constructor
153
-         */
154
-        do_action(
155
-            'AHEE__EE_Form_Input_Base___construct__before_construct_finalize_called',
156
-            $this,
157
-            $options_array
158
-        );
159
-        if (isset($options_array['name'])) {
160
-            $this->_construct_finalize(null, $options_array['name']);
161
-        }
162
-    }
163
-
164
-
165
-    /**
166
-     * Finishes construction given the parent form section and this form section's name
167
-     *
168
-     * @param EE_Form_Section_Proper $parent_form_section
169
-     * @param string                 $name
170
-     * @throws EE_Error
171
-     */
172
-    public function _construct_finalize($parent_form_section, $name)
173
-    {
174
-        parent::_construct_finalize($parent_form_section, $name);
175
-        $this->_set_default_name_if_empty();
176
-        $this->_set_default_html_id_if_empty();
177
-        foreach ($this->_subsections as $subsection_name => $subsection) {
178
-            if ($subsection instanceof EE_Form_Section_Base) {
179
-                $subsection->_construct_finalize($this, $subsection_name);
180
-            } else {
181
-                throw new EE_Error(
182
-                    sprintf(
183
-                        esc_html__(
184
-                            'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"',
185
-                            'event_espresso'
186
-                        ),
187
-                        $subsection_name,
188
-                        get_class($this),
189
-                        $subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
190
-                    )
191
-                );
192
-            }
193
-        }
194
-        /**
195
-         * Action performed just after form has been given a name (and HTML ID etc) and is fully constructed.
196
-         * If you have code that should modify the form and needs it and its subsections to have a name, HTML ID
197
-         * (or other attributes derived from the name like the HTML label id, etc), this is where it should be done.
198
-         * This might only happen just before displaying the form, or just before it receives form submission data.
199
-         * If you need to modify the form or its subsections before _construct_finalize is called on it (and we've
200
-         * ensured it has a name, HTML IDs, etc
201
-         *
202
-         * @param EE_Form_Section_Proper      $this
203
-         * @param EE_Form_Section_Proper|null $parent_form_section
204
-         * @param string                      $name
205
-         */
206
-        do_action(
207
-            'AHEE__EE_Form_Section_Proper___construct_finalize__end',
208
-            $this,
209
-            $parent_form_section,
210
-            $name
211
-        );
212
-    }
213
-
214
-
215
-    /**
216
-     * Gets the layout strategy for this form section
217
-     *
218
-     * @return EE_Form_Section_Layout_Base
219
-     */
220
-    public function get_layout_strategy()
221
-    {
222
-        return $this->_layout_strategy;
223
-    }
224
-
225
-
226
-    /**
227
-     * Gets the HTML for a single input for this form section according
228
-     * to the layout strategy
229
-     *
230
-     * @param EE_Form_Input_Base $input
231
-     * @return string
232
-     */
233
-    public function get_html_for_input($input)
234
-    {
235
-        return $this->_layout_strategy->layout_input($input);
236
-    }
237
-
238
-
239
-    /**
240
-     * was_submitted - checks if form inputs are present in request data
241
-     * Basically an alias for form_data_present_in() (which is used by both
242
-     * proper form sections and form inputs)
243
-     *
244
-     * @param null $form_data
245
-     * @return boolean
246
-     * @throws EE_Error
247
-     */
248
-    public function was_submitted($form_data = null)
249
-    {
250
-        return $this->form_data_present_in($form_data);
251
-    }
252
-
253
-    /**
254
-     * Gets the cached request data; but if there is none, or $req_data was set with
255
-     * something different, refresh the cache, and then return it
256
-     * @param null $req_data
257
-     * @return array
258
-     */
259
-    protected function getCachedRequest($req_data = null)
260
-    {
261
-        if (
262
-            $this->cached_request_data === null
263
-            || (
264
-                $req_data !== null
265
-                && $req_data !== $this->cached_request_data
266
-            )
267
-        ) {
268
-            $req_data = apply_filters(
269
-                'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
270
-                $req_data,
271
-                $this
272
-            );
273
-            if ($req_data === null) {
274
-                $req_data = array_merge($_GET, $_POST);
275
-            }
276
-            $req_data = apply_filters(
277
-                'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
278
-                $req_data,
279
-                $this
280
-            );
281
-            $this->cached_request_data = (array) $req_data;
282
-        }
283
-        return $this->cached_request_data;
284
-    }
285
-
286
-
287
-    /**
288
-     * After the form section is initially created, call this to sanitize the data in the submission
289
-     * which relates to this form section, validate it, and set it as properties on the form.
290
-     *
291
-     * @param array|null $req_data should usually be $_POST (the default).
292
-     *                             However, you CAN supply a different array.
293
-     *                             Consider using set_defaults() instead however.
294
-     *                             (If you rendered the form in the page using echo $form_x->get_html()
295
-     *                             the inputs will have the correct name in the request data for this function
296
-     *                             to find them and populate the form with them.
297
-     *                             If you have a flat form (with only input subsections),
298
-     *                             you can supply a flat array where keys
299
-     *                             are the form input names and values are their values)
300
-     * @param boolean    $validate whether or not to perform validation on this data. Default is,
301
-     *                             of course, to validate that data, and set errors on the invalid values.
302
-     *                             But if the data has already been validated
303
-     *                             (eg you validated the data then stored it in the DB)
304
-     *                             you may want to skip this step.
305
-     * @throws InvalidArgumentException
306
-     * @throws InvalidInterfaceException
307
-     * @throws InvalidDataTypeException
308
-     * @throws EE_Error
309
-     */
310
-    public function receive_form_submission($req_data = null, $validate = true)
311
-    {
312
-        $req_data = $this->getCachedRequest($req_data);
313
-        $this->_normalize($req_data);
314
-        if ($validate) {
315
-            $this->_validate();
316
-            // if it's invalid, we're going to want to re-display so remember what they submitted
317
-            if (! $this->is_valid()) {
318
-                $this->store_submitted_form_data_in_session();
319
-            }
320
-        }
321
-        if ($this->submission_error_message() === '' && ! $this->is_valid()) {
322
-            $this->set_submission_error_message();
323
-        }
324
-        do_action(
325
-            'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
326
-            $req_data,
327
-            $this,
328
-            $validate
329
-        );
330
-    }
331
-
332
-
333
-    /**
334
-     * caches the originally submitted input values in the session
335
-     * so that they can be used to repopulate the form if it failed validation
336
-     *
337
-     * @return boolean whether or not the data was successfully stored in the session
338
-     * @throws InvalidArgumentException
339
-     * @throws InvalidInterfaceException
340
-     * @throws InvalidDataTypeException
341
-     * @throws EE_Error
342
-     */
343
-    protected function store_submitted_form_data_in_session()
344
-    {
345
-        return EE_Registry::instance()->SSN->set_session_data(
346
-            array(
347
-                EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true),
348
-            )
349
-        );
350
-    }
351
-
352
-
353
-    /**
354
-     * retrieves the originally submitted input values in the session
355
-     * so that they can be used to repopulate the form if it failed validation
356
-     *
357
-     * @return array
358
-     * @throws InvalidArgumentException
359
-     * @throws InvalidInterfaceException
360
-     * @throws InvalidDataTypeException
361
-     */
362
-    protected function get_submitted_form_data_from_session()
363
-    {
364
-        $session = EE_Registry::instance()->SSN;
365
-        if ($session instanceof EE_Session) {
366
-            return $session->get_session_data(
367
-                EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY
368
-            );
369
-        }
370
-        return array();
371
-    }
372
-
373
-
374
-    /**
375
-     * flushed the originally submitted input values from the session
376
-     *
377
-     * @return boolean whether or not the data was successfully removed from the session
378
-     * @throws InvalidArgumentException
379
-     * @throws InvalidInterfaceException
380
-     * @throws InvalidDataTypeException
381
-     */
382
-    public static function flush_submitted_form_data_from_session()
383
-    {
384
-        return EE_Registry::instance()->SSN->reset_data(
385
-            array(EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
386
-        );
387
-    }
388
-
389
-
390
-    /**
391
-     * Populates this form and its subsections with data from the session.
392
-     * (Wrapper for EE_Form_Section_Proper::receive_form_submission, so it shows
393
-     * validation errors when displaying too)
394
-     * Returns true if the form was populated from the session, false otherwise
395
-     *
396
-     * @return boolean
397
-     * @throws InvalidArgumentException
398
-     * @throws InvalidInterfaceException
399
-     * @throws InvalidDataTypeException
400
-     * @throws EE_Error
401
-     */
402
-    public function populate_from_session()
403
-    {
404
-        $form_data_in_session = $this->get_submitted_form_data_from_session();
405
-        if (empty($form_data_in_session)) {
406
-            return false;
407
-        }
408
-        $this->receive_form_submission($form_data_in_session);
409
-        add_action('shutdown', array('EE_Form_Section_Proper', 'flush_submitted_form_data_from_session'));
410
-        if ($this->form_data_present_in($form_data_in_session)) {
411
-            return true;
412
-        }
413
-        return false;
414
-    }
415
-
416
-
417
-    /**
418
-     * Populates the default data for the form, given an array where keys are
419
-     * the input names, and values are their values (preferably normalized to be their
420
-     * proper PHP types, not all strings... although that should be ok too).
421
-     * Proper subsections are sub-arrays, the key being the subsection's name, and
422
-     * the value being an array formatted in teh same way
423
-     *
424
-     * @param array $default_data
425
-     * @throws EE_Error
426
-     */
427
-    public function populate_defaults($default_data)
428
-    {
429
-        foreach ($this->subsections(false) as $subsection_name => $subsection) {
430
-            if (isset($default_data[ $subsection_name ])) {
431
-                if ($subsection instanceof EE_Form_Input_Base) {
432
-                    $subsection->set_default($default_data[ $subsection_name ]);
433
-                } elseif ($subsection instanceof EE_Form_Section_Proper) {
434
-                    $subsection->populate_defaults($default_data[ $subsection_name ]);
435
-                }
436
-            }
437
-        }
438
-    }
439
-
440
-
441
-    /**
442
-     * returns true if subsection exists
443
-     *
444
-     * @param string $name
445
-     * @return boolean
446
-     */
447
-    public function subsection_exists($name)
448
-    {
449
-        return isset($this->_subsections[ $name ]) ? true : false;
450
-    }
451
-
452
-
453
-    /**
454
-     * Gets the subsection specified by its name
455
-     *
456
-     * @param string  $name
457
-     * @param boolean $require_construction_to_be_finalized most client code should leave this as TRUE
458
-     *                                                      so that the inputs will be properly configured.
459
-     *                                                      However, some client code may be ok
460
-     *                                                      with construction finalize being called later
461
-     *                                                      (realizing that the subsections' html names
462
-     *                                                      might not be set yet, etc.)
463
-     * @return EE_Form_Section_Base
464
-     * @throws EE_Error
465
-     */
466
-    public function get_subsection($name, $require_construction_to_be_finalized = true)
467
-    {
468
-        if ($require_construction_to_be_finalized) {
469
-            $this->ensure_construct_finalized_called();
470
-        }
471
-        return $this->subsection_exists($name) ? $this->_subsections[ $name ] : null;
472
-    }
473
-
474
-
475
-    /**
476
-     * Gets all the validatable subsections of this form section
477
-     *
478
-     * @return EE_Form_Section_Validatable[]
479
-     * @throws EE_Error
480
-     */
481
-    public function get_validatable_subsections()
482
-    {
483
-        $validatable_subsections = array();
484
-        foreach ($this->subsections() as $name => $obj) {
485
-            if ($obj instanceof EE_Form_Section_Validatable) {
486
-                $validatable_subsections[ $name ] = $obj;
487
-            }
488
-        }
489
-        return $validatable_subsections;
490
-    }
491
-
492
-
493
-    /**
494
-     * Gets an input by the given name. If not found, or if its not an EE_FOrm_Input_Base child,
495
-     * throw an EE_Error.
496
-     *
497
-     * @param string  $name
498
-     * @param boolean $require_construction_to_be_finalized most client code should
499
-     *                                                      leave this as TRUE so that the inputs will be properly
500
-     *                                                      configured. However, some client code may be ok with
501
-     *                                                      construction finalize being called later
502
-     *                                                      (realizing that the subsections' html names might not be
503
-     *                                                      set yet, etc.)
504
-     * @return EE_Form_Input_Base
505
-     * @throws EE_Error
506
-     */
507
-    public function get_input($name, $require_construction_to_be_finalized = true)
508
-    {
509
-        $subsection = $this->get_subsection(
510
-            $name,
511
-            $require_construction_to_be_finalized
512
-        );
513
-        if (! $subsection instanceof EE_Form_Input_Base) {
514
-            throw new EE_Error(
515
-                sprintf(
516
-                    esc_html__(
517
-                        "Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'",
518
-                        'event_espresso'
519
-                    ),
520
-                    $name,
521
-                    get_class($this),
522
-                    $subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
523
-                )
524
-            );
525
-        }
526
-        return $subsection;
527
-    }
528
-
529
-
530
-    /**
531
-     * Like get_input(), gets the proper subsection of the form given the name,
532
-     * otherwise throws an EE_Error
533
-     *
534
-     * @param string  $name
535
-     * @param boolean $require_construction_to_be_finalized most client code should
536
-     *                                                      leave this as TRUE so that the inputs will be properly
537
-     *                                                      configured. However, some client code may be ok with
538
-     *                                                      construction finalize being called later
539
-     *                                                      (realizing that the subsections' html names might not be
540
-     *                                                      set yet, etc.)
541
-     * @return EE_Form_Section_Proper
542
-     * @throws EE_Error
543
-     */
544
-    public function get_proper_subsection($name, $require_construction_to_be_finalized = true)
545
-    {
546
-        $subsection = $this->get_subsection(
547
-            $name,
548
-            $require_construction_to_be_finalized
549
-        );
550
-        if (! $subsection instanceof EE_Form_Section_Proper) {
551
-            throw new EE_Error(
552
-                sprintf(
553
-                    esc_html__(
554
-                        "Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'",
555
-                        'event_espresso'
556
-                    ),
557
-                    $name,
558
-                    get_class($this)
559
-                )
560
-            );
561
-        }
562
-        return $subsection;
563
-    }
564
-
565
-
566
-    /**
567
-     * Gets the value of the specified input. Should be called after receive_form_submission()
568
-     * or populate_defaults() on the form, where the normalized value on the input is set.
569
-     *
570
-     * @param string $name
571
-     * @return mixed depending on the input's type and its normalization strategy
572
-     * @throws EE_Error
573
-     */
574
-    public function get_input_value($name)
575
-    {
576
-        $input = $this->get_input($name);
577
-        return $input->normalized_value();
578
-    }
579
-
580
-
581
-    /**
582
-     * Checks if this form section itself is valid, and then checks its subsections
583
-     *
584
-     * @throws EE_Error
585
-     * @return boolean
586
-     */
587
-    public function is_valid()
588
-    {
589
-        if ($this->is_valid === null) {
590
-            if (! $this->has_received_submission()) {
591
-                throw new EE_Error(
592
-                    sprintf(
593
-                        esc_html__(
594
-                            'You cannot check if a form is valid before receiving the form submission using receive_form_submission',
595
-                            'event_espresso'
596
-                        )
597
-                    )
598
-                );
599
-            }
600
-            if (! parent::is_valid()) {
601
-                $this->is_valid = false;
602
-            } else {
603
-                // ok so no general errors to this entire form section.
604
-                // so let's check the subsections, but only set errors if that hasn't been done yet
605
-                $this->is_valid = true;
606
-                foreach ($this->get_validatable_subsections() as $subsection) {
607
-                    if (! $subsection->is_valid()) {
608
-                        $this->is_valid = false;
609
-                    }
610
-                }
611
-            }
612
-        }
613
-        return $this->is_valid;
614
-    }
615
-
616
-
617
-    /**
618
-     * gets the default name of this form section if none is specified
619
-     *
620
-     * @return void
621
-     */
622
-    protected function _set_default_name_if_empty()
623
-    {
624
-        if (! $this->_name) {
625
-            $classname    = get_class($this);
626
-            $default_name = str_replace('EE_', '', $classname);
627
-            $this->_name  = $default_name;
628
-        }
629
-    }
630
-
631
-
632
-    /**
633
-     * Returns the HTML for the form, except for the form opening and closing tags
634
-     * (as the form section doesn't know where you necessarily want to send the information to),
635
-     * and except for a submit button. Enqueues JS and CSS; if called early enough we will
636
-     * try to enqueue them in the header, otherwise they'll be enqueued in the footer.
637
-     * Not doing_it_wrong because theoretically this CAN be used properly,
638
-     * provided its used during "wp_enqueue_scripts", or it doesn't need to enqueue
639
-     * any CSS.
640
-     *
641
-     * @throws InvalidArgumentException
642
-     * @throws InvalidInterfaceException
643
-     * @throws InvalidDataTypeException
644
-     * @throws EE_Error
645
-     */
646
-    public function get_html_and_js()
647
-    {
648
-        $this->enqueue_js();
649
-        return $this->get_html();
650
-    }
651
-
652
-
653
-    /**
654
-     * returns HTML for displaying this form section. recursively calls display_section() on all subsections
655
-     *
656
-     * @param bool $display_previously_submitted_data
657
-     * @return string
658
-     * @throws InvalidArgumentException
659
-     * @throws InvalidInterfaceException
660
-     * @throws InvalidDataTypeException
661
-     * @throws EE_Error
662
-     * @throws EE_Error
663
-     * @throws EE_Error
664
-     */
665
-    public function get_html($display_previously_submitted_data = true)
666
-    {
667
-        $this->ensure_construct_finalized_called();
668
-        if ($display_previously_submitted_data) {
669
-            $this->populate_from_session();
670
-        }
671
-        return $this->_form_html_filter
672
-            ? $this->_form_html_filter->filterHtml($this->_layout_strategy->layout_form(), $this)
673
-            : $this->_layout_strategy->layout_form();
674
-    }
675
-
676
-
677
-    /**
678
-     * enqueues JS and CSS for the form.
679
-     * It is preferred to call this before wp_enqueue_scripts so the
680
-     * scripts and styles can be put in the header, but if called later
681
-     * they will be put in the footer (which is OK for JS, but in HTML4 CSS should
682
-     * only be in the header; but in HTML5 its ok in the body.
683
-     * See http://stackoverflow.com/questions/4957446/load-external-css-file-in-body-tag.
684
-     * So if your form enqueues CSS, it's preferred to call this before wp_enqueue_scripts.)
685
-     *
686
-     * @return void
687
-     * @throws EE_Error
688
-     */
689
-    public function enqueue_js()
690
-    {
691
-        $this->_enqueue_and_localize_form_js();
692
-        foreach ($this->subsections() as $subsection) {
693
-            $subsection->enqueue_js();
694
-        }
695
-    }
696
-
697
-
698
-    /**
699
-     * adds a filter so that jquery validate gets enqueued in EE_System::wp_enqueue_scripts().
700
-     * This must be done BEFORE wp_enqueue_scripts() gets called, which is on
701
-     * the wp_enqueue_scripts hook.
702
-     * However, registering the form js and localizing it can happen when we
703
-     * actually output the form (which is preferred, seeing how teh form's fields
704
-     * could change until it's actually outputted)
705
-     *
706
-     * @param boolean $init_form_validation_automatically whether or not we want the form validation
707
-     *                                                    to be triggered automatically or not
708
-     * @return void
709
-     */
710
-    public static function wp_enqueue_scripts($init_form_validation_automatically = true)
711
-    {
712
-        wp_register_script(
713
-            'ee_form_section_validation',
714
-            EE_GLOBAL_ASSETS_URL . 'scripts' . '/form_section_validation.js',
715
-            array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
716
-            EVENT_ESPRESSO_VERSION,
717
-            true
718
-        );
719
-        wp_localize_script(
720
-            'ee_form_section_validation',
721
-            'ee_form_section_validation_init',
722
-            array('init' => $init_form_validation_automatically ? '1' : '0')
723
-        );
724
-    }
725
-
726
-
727
-    /**
728
-     * gets the variables used by form_section_validation.js.
729
-     * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
730
-     * but before the wordpress hook wp_loaded
731
-     *
732
-     * @throws EE_Error
733
-     */
734
-    public function _enqueue_and_localize_form_js()
735
-    {
736
-        $this->ensure_construct_finalized_called();
737
-        // actually, we don't want to localize just yet. There may be other forms on the page.
738
-        // so we need to add our form section data to a static variable accessible by all form sections
739
-        // and localize it just before the footer
740
-        $this->localize_validation_rules();
741
-        add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
742
-        add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
743
-    }
744
-
745
-
746
-    /**
747
-     * add our form section data to a static variable accessible by all form sections
748
-     *
749
-     * @param bool $return_for_subsection
750
-     * @return void
751
-     * @throws EE_Error
752
-     */
753
-    public function localize_validation_rules($return_for_subsection = false)
754
-    {
755
-        // we only want to localize vars ONCE for the entire form,
756
-        // so if the form section doesn't have a parent, then it must be the top dog
757
-        if ($return_for_subsection || ! $this->parent_section()) {
758
-            EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
759
-                'form_section_id'  => $this->html_id(true),
760
-                'validation_rules' => $this->get_jquery_validation_rules(),
761
-                'other_data'       => $this->get_other_js_data(),
762
-                'errors'           => $this->subsection_validation_errors_by_html_name(),
763
-            );
764
-            EE_Form_Section_Proper::$_scripts_localized                                = true;
765
-        }
766
-    }
767
-
768
-
769
-    /**
770
-     * Gets an array of extra data that will be useful for client-side javascript.
771
-     * This is primarily data added by inputs and forms in addition to any
772
-     * scripts they might enqueue
773
-     *
774
-     * @param array $form_other_js_data
775
-     * @return array
776
-     * @throws EE_Error
777
-     */
778
-    public function get_other_js_data($form_other_js_data = array())
779
-    {
780
-        foreach ($this->subsections() as $subsection) {
781
-            $form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
782
-        }
783
-        return $form_other_js_data;
784
-    }
785
-
786
-
787
-    /**
788
-     * Gets a flat array of inputs for this form section and its subsections.
789
-     * Keys are their form names, and values are the inputs themselves
790
-     *
791
-     * @return EE_Form_Input_Base
792
-     * @throws EE_Error
793
-     */
794
-    public function inputs_in_subsections()
795
-    {
796
-        $inputs = array();
797
-        foreach ($this->subsections() as $subsection) {
798
-            if ($subsection instanceof EE_Form_Input_Base) {
799
-                $inputs[ $subsection->html_name() ] = $subsection;
800
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
801
-                $inputs += $subsection->inputs_in_subsections();
802
-            }
803
-        }
804
-        return $inputs;
805
-    }
806
-
807
-
808
-    /**
809
-     * Gets a flat array of all the validation errors.
810
-     * Keys are html names (because those should be unique)
811
-     * and values are a string of all their validation errors
812
-     *
813
-     * @return string[]
814
-     * @throws EE_Error
815
-     */
816
-    public function subsection_validation_errors_by_html_name()
817
-    {
818
-        $inputs = $this->inputs();
819
-        $errors = array();
820
-        foreach ($inputs as $form_input) {
821
-            if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
822
-                $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
823
-            }
824
-        }
825
-        return $errors;
826
-    }
827
-
828
-
829
-    /**
830
-     * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
831
-     * Should be setup by each form during the _enqueues_and_localize_form_js
832
-     *
833
-     * @throws InvalidArgumentException
834
-     * @throws InvalidInterfaceException
835
-     * @throws InvalidDataTypeException
836
-     */
837
-    public static function localize_script_for_all_forms()
838
-    {
839
-        // allow inputs and stuff to hook in their JS and stuff here
840
-        do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
841
-        EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
842
-        $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
843
-            ? EE_Registry::instance()->CFG->registration->email_validation_level
844
-            : 'wp_default';
845
-        EE_Form_Section_Proper::$_js_localization['email_validation_level']   = $email_validation_level;
846
-        wp_enqueue_script('ee_form_section_validation');
847
-        wp_localize_script(
848
-            'ee_form_section_validation',
849
-            'ee_form_section_vars',
850
-            EE_Form_Section_Proper::$_js_localization
851
-        );
852
-    }
853
-
854
-
855
-    /**
856
-     * ensure_scripts_localized
857
-     *
858
-     * @throws EE_Error
859
-     */
860
-    public function ensure_scripts_localized()
861
-    {
862
-        if (! EE_Form_Section_Proper::$_scripts_localized) {
863
-            $this->_enqueue_and_localize_form_js();
864
-        }
865
-    }
866
-
867
-
868
-    /**
869
-     * Gets the hard-coded validation error messages to be used in the JS. The convention
870
-     * is that the key here should be the same as the custom validation rule put in the JS file
871
-     *
872
-     * @return array keys are custom validation rules, and values are internationalized strings
873
-     */
874
-    private static function _get_localized_error_messages()
875
-    {
876
-        return array(
877
-            'validUrl' => esc_html__('This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg', 'event_espresso'),
878
-            'regex'    => esc_html__('Please check your input', 'event_espresso'),
879
-        );
880
-    }
881
-
882
-
883
-    /**
884
-     * @return array
885
-     */
886
-    public static function js_localization()
887
-    {
888
-        return self::$_js_localization;
889
-    }
890
-
891
-
892
-    /**
893
-     * @return void
894
-     */
895
-    public static function reset_js_localization()
896
-    {
897
-        self::$_js_localization = array();
898
-    }
899
-
900
-
901
-    /**
902
-     * Gets the JS to put inside the jquery validation rules for subsection of this form section.
903
-     * See parent function for more...
904
-     *
905
-     * @return array
906
-     * @throws EE_Error
907
-     */
908
-    public function get_jquery_validation_rules()
909
-    {
910
-        $jquery_validation_rules = array();
911
-        foreach ($this->get_validatable_subsections() as $subsection) {
912
-            $jquery_validation_rules = array_merge(
913
-                $jquery_validation_rules,
914
-                $subsection->get_jquery_validation_rules()
915
-            );
916
-        }
917
-        return $jquery_validation_rules;
918
-    }
919
-
920
-
921
-    /**
922
-     * Sanitizes all the data and sets the sanitized value of each field
923
-     *
924
-     * @param array $req_data like $_POST
925
-     * @return void
926
-     * @throws EE_Error
927
-     */
928
-    protected function _normalize($req_data)
929
-    {
930
-        $this->_received_submission = true;
931
-        $this->_validation_errors   = array();
932
-        foreach ($this->get_validatable_subsections() as $subsection) {
933
-            try {
934
-                $subsection->_normalize($req_data);
935
-            } catch (EE_Validation_Error $e) {
936
-                $subsection->add_validation_error($e);
937
-            }
938
-        }
939
-    }
940
-
941
-
942
-    /**
943
-     * Performs validation on this form section and its subsections.
944
-     * For each subsection,
945
-     * calls _validate_{subsection_name} on THIS form (if the function exists)
946
-     * and passes it the subsection, then calls _validate on that subsection.
947
-     * If you need to perform validation on the form as a whole (considering multiple)
948
-     * you would be best to override this _validate method,
949
-     * calling parent::_validate() first.
950
-     *
951
-     * @throws EE_Error
952
-     */
953
-    protected function _validate()
954
-    {
955
-        // reset the cache of whether this form is valid or not- we're re-validating it now
956
-        $this->is_valid = null;
957
-        foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
958
-            if (method_exists($this, '_validate_' . $subsection_name)) {
959
-                call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
960
-            }
961
-            $subsection->_validate();
962
-        }
963
-    }
964
-
965
-
966
-    /**
967
-     * Gets all the validated inputs for the form section
968
-     *
969
-     * @return array
970
-     * @throws EE_Error
971
-     */
972
-    public function valid_data()
973
-    {
974
-        $inputs = array();
975
-        foreach ($this->subsections() as $subsection_name => $subsection) {
976
-            if ($subsection instanceof EE_Form_Section_Proper) {
977
-                $inputs[ $subsection_name ] = $subsection->valid_data();
978
-            } elseif ($subsection instanceof EE_Form_Input_Base) {
979
-                $inputs[ $subsection_name ] = $subsection->normalized_value();
980
-            }
981
-        }
982
-        return $inputs;
983
-    }
984
-
985
-
986
-    /**
987
-     * Gets all the inputs on this form section
988
-     *
989
-     * @return EE_Form_Input_Base[]
990
-     * @throws EE_Error
991
-     */
992
-    public function inputs()
993
-    {
994
-        $inputs = array();
995
-        foreach ($this->subsections() as $subsection_name => $subsection) {
996
-            if ($subsection instanceof EE_Form_Input_Base) {
997
-                $inputs[ $subsection_name ] = $subsection;
998
-            }
999
-        }
1000
-        return $inputs;
1001
-    }
1002
-
1003
-
1004
-    /**
1005
-     * Gets all the subsections which are a proper form
1006
-     *
1007
-     * @return EE_Form_Section_Proper[]
1008
-     * @throws EE_Error
1009
-     */
1010
-    public function subforms()
1011
-    {
1012
-        $form_sections = array();
1013
-        foreach ($this->subsections() as $name => $obj) {
1014
-            if ($obj instanceof EE_Form_Section_Proper) {
1015
-                $form_sections[ $name ] = $obj;
1016
-            }
1017
-        }
1018
-        return $form_sections;
1019
-    }
1020
-
1021
-
1022
-    /**
1023
-     * Gets all the subsections (inputs, proper subsections, or html-only sections).
1024
-     * Consider using inputs() or subforms()
1025
-     * if you only want form inputs or proper form sections.
1026
-     *
1027
-     * @param boolean $require_construction_to_be_finalized most client code should
1028
-     *                                                      leave this as TRUE so that the inputs will be properly
1029
-     *                                                      configured. However, some client code may be ok with
1030
-     *                                                      construction finalize being called later
1031
-     *                                                      (realizing that the subsections' html names might not be
1032
-     *                                                      set yet, etc.)
1033
-     * @return EE_Form_Section_Proper[]
1034
-     * @throws EE_Error
1035
-     */
1036
-    public function subsections($require_construction_to_be_finalized = true)
1037
-    {
1038
-        if ($require_construction_to_be_finalized) {
1039
-            $this->ensure_construct_finalized_called();
1040
-        }
1041
-        return $this->_subsections;
1042
-    }
1043
-
1044
-
1045
-    /**
1046
-     * Returns whether this form has any subforms or inputs
1047
-     * @return bool
1048
-     */
1049
-    public function hasSubsections()
1050
-    {
1051
-        return ! empty($this->_subsections);
1052
-    }
1053
-
1054
-
1055
-    /**
1056
-     * Returns a simple array where keys are input names, and values are their normalized
1057
-     * values. (Similar to calling get_input_value on inputs)
1058
-     *
1059
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1060
-     *                                        or just this forms' direct children inputs
1061
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1062
-     *                                        or allow multidimensional array
1063
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array
1064
-     *                                        with array keys being input names
1065
-     *                                        (regardless of whether they are from a subsection or not),
1066
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1067
-     *                                        where keys are always subsection names and values are either
1068
-     *                                        the input's normalized value, or an array like the top-level array
1069
-     * @throws EE_Error
1070
-     */
1071
-    public function input_values($include_subform_inputs = false, $flatten = false)
1072
-    {
1073
-        return $this->_input_values(false, $include_subform_inputs, $flatten);
1074
-    }
1075
-
1076
-
1077
-    /**
1078
-     * Similar to EE_Form_Section_Proper::input_values(), except this returns the 'display_value'
1079
-     * of each input. On some inputs (especially radio boxes or checkboxes), the value stored
1080
-     * is not necessarily the value we want to display to users. This creates an array
1081
-     * where keys are the input names, and values are their display values
1082
-     *
1083
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1084
-     *                                        or just this forms' direct children inputs
1085
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1086
-     *                                        or allow multidimensional array
1087
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array
1088
-     *                                        with array keys being input names
1089
-     *                                        (regardless of whether they are from a subsection or not),
1090
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1091
-     *                                        where keys are always subsection names and values are either
1092
-     *                                        the input's normalized value, or an array like the top-level array
1093
-     * @throws EE_Error
1094
-     */
1095
-    public function input_pretty_values($include_subform_inputs = false, $flatten = false)
1096
-    {
1097
-        return $this->_input_values(true, $include_subform_inputs, $flatten);
1098
-    }
1099
-
1100
-
1101
-    /**
1102
-     * Gets the input values from the form
1103
-     *
1104
-     * @param boolean $pretty                 Whether to retrieve the pretty value,
1105
-     *                                        or just the normalized value
1106
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1107
-     *                                        or just this forms' direct children inputs
1108
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1109
-     *                                        or allow multidimensional array
1110
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array with array keys being
1111
-     *                                        input names (regardless of whether they are from a subsection or not),
1112
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1113
-     *                                        where keys are always subsection names and values are either
1114
-     *                                        the input's normalized value, or an array like the top-level array
1115
-     * @throws EE_Error
1116
-     */
1117
-    public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false)
1118
-    {
1119
-        $input_values = array();
1120
-        foreach ($this->subsections() as $subsection_name => $subsection) {
1121
-            if ($subsection instanceof EE_Form_Input_Base) {
1122
-                $input_values[ $subsection_name ] = $pretty
1123
-                    ? $subsection->pretty_value()
1124
-                    : $subsection->normalized_value();
1125
-            } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
1126
-                $subform_input_values = $subsection->_input_values(
1127
-                    $pretty,
1128
-                    $include_subform_inputs,
1129
-                    $flatten
1130
-                );
1131
-                if ($flatten) {
1132
-                    $input_values = array_merge($input_values, $subform_input_values);
1133
-                } else {
1134
-                    $input_values[ $subsection_name ] = $subform_input_values;
1135
-                }
1136
-            }
1137
-        }
1138
-        return $input_values;
1139
-    }
1140
-
1141
-
1142
-    /**
1143
-     * Gets the originally submitted input values from the form
1144
-     *
1145
-     * @param boolean $include_subforms  Whether to include inputs from subforms,
1146
-     *                                   or just this forms' direct children inputs
1147
-     * @return array                     if $flatten is TRUE it will always be a 1-dimensional array
1148
-     *                                   with array keys being input names
1149
-     *                                   (regardless of whether they are from a subsection or not),
1150
-     *                                   and if $flatten is FALSE it can be a multidimensional array
1151
-     *                                   where keys are always subsection names and values are either
1152
-     *                                   the input's normalized value, or an array like the top-level array
1153
-     * @throws EE_Error
1154
-     */
1155
-    public function submitted_values($include_subforms = false)
1156
-    {
1157
-        $submitted_values = array();
1158
-        foreach ($this->subsections() as $subsection) {
1159
-            if ($subsection instanceof EE_Form_Input_Base) {
1160
-                // is this input part of an array of inputs?
1161
-                if (strpos($subsection->html_name(), '[') !== false) {
1162
-                    $full_input_name  = EEH_Array::convert_array_values_to_keys(
1163
-                        explode(
1164
-                            '[',
1165
-                            str_replace(']', '', $subsection->html_name())
1166
-                        ),
1167
-                        $subsection->raw_value()
1168
-                    );
1169
-                    $submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1170
-                } else {
1171
-                    $submitted_values[ $subsection->html_name() ] = $subsection->raw_value();
1172
-                }
1173
-            } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1174
-                $subform_input_values = $subsection->submitted_values($include_subforms);
1175
-                $submitted_values     = array_replace_recursive($submitted_values, $subform_input_values);
1176
-            }
1177
-        }
1178
-        return $submitted_values;
1179
-    }
1180
-
1181
-
1182
-    /**
1183
-     * Indicates whether or not this form has received a submission yet
1184
-     * (ie, had receive_form_submission called on it yet)
1185
-     *
1186
-     * @return boolean
1187
-     * @throws EE_Error
1188
-     */
1189
-    public function has_received_submission()
1190
-    {
1191
-        $this->ensure_construct_finalized_called();
1192
-        return $this->_received_submission;
1193
-    }
1194
-
1195
-
1196
-    /**
1197
-     * Equivalent to passing 'exclude' in the constructor's options array.
1198
-     * Removes the listed inputs from the form
1199
-     *
1200
-     * @param array $inputs_to_exclude values are the input names
1201
-     * @return void
1202
-     */
1203
-    public function exclude(array $inputs_to_exclude = array())
1204
-    {
1205
-        foreach ($inputs_to_exclude as $input_to_exclude_name) {
1206
-            unset($this->_subsections[ $input_to_exclude_name ]);
1207
-        }
1208
-    }
1209
-
1210
-
1211
-    /**
1212
-     * Changes these inputs' display strategy to be EE_Hidden_Display_Strategy.
1213
-     * @param array $inputs_to_hide
1214
-     * @throws EE_Error
1215
-     */
1216
-    public function hide(array $inputs_to_hide = array())
1217
-    {
1218
-        foreach ($inputs_to_hide as $input_to_hide) {
1219
-            $input = $this->get_input($input_to_hide);
1220
-            $input->set_display_strategy(new EE_Hidden_Display_Strategy());
1221
-        }
1222
-    }
1223
-
1224
-
1225
-    /**
1226
-     * add_subsections
1227
-     * Adds the listed subsections to the form section.
1228
-     * If $subsection_name_to_target is provided,
1229
-     * then new subsections are added before or after that subsection,
1230
-     * otherwise to the start or end of the entire subsections array.
1231
-     *
1232
-     * @param EE_Form_Section_Base[] $new_subsections           array of new form subsections
1233
-     *                                                          where keys are their names
1234
-     * @param string                 $subsection_name_to_target an existing for section that $new_subsections
1235
-     *                                                          should be added before or after
1236
-     *                                                          IF $subsection_name_to_target is null,
1237
-     *                                                          then $new_subsections will be added to
1238
-     *                                                          the beginning or end of the entire subsections array
1239
-     * @param boolean                $add_before                whether to add $new_subsections, before or after
1240
-     *                                                          $subsection_name_to_target,
1241
-     *                                                          or if $subsection_name_to_target is null,
1242
-     *                                                          before or after entire subsections array
1243
-     * @return void
1244
-     * @throws EE_Error
1245
-     */
1246
-    public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1247
-    {
1248
-        foreach ($new_subsections as $subsection_name => $subsection) {
1249
-            if (! $subsection instanceof EE_Form_Section_Base) {
1250
-                EE_Error::add_error(
1251
-                    sprintf(
1252
-                        esc_html__(
1253
-                            "Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.",
1254
-                            'event_espresso'
1255
-                        ),
1256
-                        get_class($subsection),
1257
-                        $subsection_name,
1258
-                        $this->name()
1259
-                    )
1260
-                );
1261
-                unset($new_subsections[ $subsection_name ]);
1262
-            }
1263
-        }
1264
-        $this->_subsections = EEH_Array::insert_into_array(
1265
-            $this->_subsections,
1266
-            $new_subsections,
1267
-            $subsection_name_to_target,
1268
-            $add_before
1269
-        );
1270
-        if ($this->_construction_finalized) {
1271
-            foreach ($this->_subsections as $name => $subsection) {
1272
-                $subsection->_construct_finalize($this, $name);
1273
-            }
1274
-        }
1275
-    }
1276
-
1277
-
1278
-    /**
1279
-     * @param string $subsection_name
1280
-     * @param bool   $recursive
1281
-     * @return bool
1282
-     */
1283
-    public function has_subsection($subsection_name, $recursive = false)
1284
-    {
1285
-        foreach ($this->_subsections as $name => $subsection) {
1286
-            if (
1287
-                $name === $subsection_name
1288
-                || (
1289
-                    $recursive
1290
-                    && $subsection instanceof EE_Form_Section_Proper
1291
-                    && $subsection->has_subsection($subsection_name, $recursive)
1292
-                )
1293
-            ) {
1294
-                return true;
1295
-            }
1296
-        }
1297
-        return false;
1298
-    }
1299
-
1300
-
1301
-
1302
-    /**
1303
-     * Just gets all validatable subsections to clean their sensitive data
1304
-     *
1305
-     * @throws EE_Error
1306
-     */
1307
-    public function clean_sensitive_data()
1308
-    {
1309
-        foreach ($this->get_validatable_subsections() as $subsection) {
1310
-            $subsection->clean_sensitive_data();
1311
-        }
1312
-    }
1313
-
1314
-
1315
-    /**
1316
-     * Sets the submission error message (aka validation error message for this form section and all sub-sections)
1317
-     * @param string                           $form_submission_error_message
1318
-     * @param EE_Form_Section_Validatable $form_section unused
1319
-     * @throws EE_Error
1320
-     */
1321
-    public function set_submission_error_message(
1322
-        $form_submission_error_message = ''
1323
-    ) {
1324
-        $this->_form_submission_error_message = ! empty($form_submission_error_message)
1325
-            ? $form_submission_error_message
1326
-            : $this->getAllValidationErrorsString();
1327
-    }
1328
-
1329
-
1330
-    /**
1331
-     * Returns the cached error message. A default value is set for this during _validate(),
1332
-     * (called during receive_form_submission) but it can be explicitly set using
1333
-     * set_submission_error_message
1334
-     *
1335
-     * @return string
1336
-     */
1337
-    public function submission_error_message()
1338
-    {
1339
-        return $this->_form_submission_error_message;
1340
-    }
1341
-
1342
-
1343
-    /**
1344
-     * Sets a message to display if the data submitted to the form was valid.
1345
-     * @param string $form_submission_success_message
1346
-     */
1347
-    public function set_submission_success_message($form_submission_success_message = '')
1348
-    {
1349
-        $this->_form_submission_success_message = ! empty($form_submission_success_message)
1350
-            ? $form_submission_success_message
1351
-            : esc_html__('Form submitted successfully', 'event_espresso');
1352
-    }
1353
-
1354
-
1355
-    /**
1356
-     * Gets a message appropriate for display when the form is correctly submitted
1357
-     * @return string
1358
-     */
1359
-    public function submission_success_message()
1360
-    {
1361
-        return $this->_form_submission_success_message;
1362
-    }
1363
-
1364
-
1365
-    /**
1366
-     * Returns the prefix that should be used on child of this form section for
1367
-     * their html names. If this form section itself has a parent, prepends ITS
1368
-     * prefix onto this form section's prefix. Used primarily by
1369
-     * EE_Form_Input_Base::_set_default_html_name_if_empty
1370
-     *
1371
-     * @return string
1372
-     * @throws EE_Error
1373
-     */
1374
-    public function html_name_prefix()
1375
-    {
1376
-        if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1377
-            return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1378
-        }
1379
-        return $this->name();
1380
-    }
1381
-
1382
-
1383
-    /**
1384
-     * Gets the name, but first checks _construct_finalize has been called. If not,
1385
-     * calls it (assumes there is no parent and that we want the name to be whatever
1386
-     * was set, which is probably nothing, or the classname)
1387
-     *
1388
-     * @return string
1389
-     * @throws EE_Error
1390
-     */
1391
-    public function name()
1392
-    {
1393
-        $this->ensure_construct_finalized_called();
1394
-        return parent::name();
1395
-    }
1396
-
1397
-
1398
-    /**
1399
-     * @return EE_Form_Section_Proper
1400
-     * @throws EE_Error
1401
-     */
1402
-    public function parent_section()
1403
-    {
1404
-        $this->ensure_construct_finalized_called();
1405
-        return parent::parent_section();
1406
-    }
1407
-
1408
-
1409
-    /**
1410
-     * make sure construction finalized was called, otherwise children might not be ready
1411
-     *
1412
-     * @return void
1413
-     * @throws EE_Error
1414
-     */
1415
-    public function ensure_construct_finalized_called()
1416
-    {
1417
-        if (! $this->_construction_finalized) {
1418
-            $this->_construct_finalize($this->_parent_section, $this->_name);
1419
-        }
1420
-    }
1421
-
1422
-
1423
-    /**
1424
-     * Checks if any of this form section's inputs, or any of its children's inputs,
1425
-     * are in teh form data. If any are found, returns true. Else false
1426
-     *
1427
-     * @param array $req_data
1428
-     * @return boolean
1429
-     * @throws EE_Error
1430
-     */
1431
-    public function form_data_present_in($req_data = null)
1432
-    {
1433
-        $req_data = $this->getCachedRequest($req_data);
1434
-        foreach ($this->subsections() as $subsection) {
1435
-            if ($subsection instanceof EE_Form_Input_Base) {
1436
-                if ($subsection->form_data_present_in($req_data)) {
1437
-                    return true;
1438
-                }
1439
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
1440
-                if ($subsection->form_data_present_in($req_data)) {
1441
-                    return true;
1442
-                }
1443
-            }
1444
-        }
1445
-        return false;
1446
-    }
1447
-
1448
-
1449
-    /**
1450
-     * Gets validation errors for this form section and subsections
1451
-     * Similar to EE_Form_Section_Validatable::get_validation_errors() except this
1452
-     * gets the validation errors for ALL subsection
1453
-     *
1454
-     * @return EE_Validation_Error[]
1455
-     * @throws EE_Error
1456
-     */
1457
-    public function get_validation_errors_accumulated()
1458
-    {
1459
-        $validation_errors = $this->get_validation_errors();
1460
-        foreach ($this->get_validatable_subsections() as $subsection) {
1461
-            if ($subsection instanceof EE_Form_Section_Proper) {
1462
-                $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1463
-            } else {
1464
-                $validation_errors_on_this_subsection = $subsection->get_validation_errors();
1465
-            }
1466
-            if ($validation_errors_on_this_subsection) {
1467
-                $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1468
-            }
1469
-        }
1470
-        return $validation_errors;
1471
-    }
1472
-
1473
-    /**
1474
-     * Fetch validation errors from children and grandchildren and puts them in a single string.
1475
-     * This traverses the form section tree to generate this, but you probably want to instead use
1476
-     * get_form_submission_error_message() which is usually this message cached (or a custom validation error message)
1477
-     *
1478
-     * @return string
1479
-     * @since 4.9.59.p
1480
-     */
1481
-    protected function getAllValidationErrorsString()
1482
-    {
1483
-        $submission_error_messages = array();
1484
-        // bad, bad, bad registrant
1485
-        foreach ($this->get_validation_errors_accumulated() as $validation_error) {
1486
-            if ($validation_error instanceof EE_Validation_Error) {
1487
-                $form_section = $validation_error->get_form_section();
1488
-                if ($form_section instanceof EE_Form_Input_Base) {
1489
-                    $label = $validation_error->get_form_section()->html_label_text();
1490
-                } elseif ($form_section instanceof EE_Form_Section_Validatable) {
1491
-                    $label = $validation_error->get_form_section()->name();
1492
-                } else {
1493
-                    $label = esc_html__('Unknown', 'event_espresso');
1494
-                }
1495
-                $submission_error_messages[] = sprintf(
1496
-                    __('%s : %s', 'event_espresso'),
1497
-                    $label,
1498
-                    $validation_error->getMessage()
1499
-                );
1500
-            }
1501
-        }
1502
-        return implode('<br>', $submission_error_messages);
1503
-    }
1504
-
1505
-
1506
-    /**
1507
-     * This isn't just the name of an input, it's a path pointing to an input. The
1508
-     * path is similar to a folder path: slash (/) means to descend into a subsection,
1509
-     * dot-dot-slash (../) means to ascend into the parent section.
1510
-     * After a series of slashes and dot-dot-slashes, there should be the name of an input,
1511
-     * which will be returned.
1512
-     * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
1513
-     * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
1514
-     * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
1515
-     * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
1516
-     * Etc
1517
-     *
1518
-     * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1519
-     * @return EE_Form_Section_Base
1520
-     * @throws EE_Error
1521
-     */
1522
-    public function find_section_from_path($form_section_path)
1523
-    {
1524
-        // check if we can find the input from purely going straight up the tree
1525
-        $input = parent::find_section_from_path($form_section_path);
1526
-        if ($input instanceof EE_Form_Section_Base) {
1527
-            return $input;
1528
-        }
1529
-        $next_slash_pos = strpos($form_section_path, '/');
1530
-        if ($next_slash_pos !== false) {
1531
-            $child_section_name = substr($form_section_path, 0, $next_slash_pos);
1532
-            $subpath            = substr($form_section_path, $next_slash_pos + 1);
1533
-        } else {
1534
-            $child_section_name = $form_section_path;
1535
-            $subpath            = '';
1536
-        }
1537
-        $child_section = $this->get_subsection($child_section_name);
1538
-        if ($child_section instanceof EE_Form_Section_Base) {
1539
-            return $child_section->find_section_from_path($subpath);
1540
-        }
1541
-        return null;
1542
-    }
17
+	const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data';
18
+
19
+	/**
20
+	 * Subsections
21
+	 *
22
+	 * @var EE_Form_Section_Validatable[]
23
+	 */
24
+	protected $_subsections = array();
25
+
26
+	/**
27
+	 * Strategy for laying out the form
28
+	 *
29
+	 * @var EE_Form_Section_Layout_Base
30
+	 */
31
+	protected $_layout_strategy;
32
+
33
+	/**
34
+	 * Whether or not this form has received and validated a form submission yet
35
+	 *
36
+	 * @var boolean
37
+	 */
38
+	protected $_received_submission = false;
39
+
40
+	/**
41
+	 * message displayed to users upon successful form submission
42
+	 *
43
+	 * @var string
44
+	 */
45
+	protected $_form_submission_success_message = '';
46
+
47
+	/**
48
+	 * message displayed to users upon unsuccessful form submission
49
+	 *
50
+	 * @var string
51
+	 */
52
+	protected $_form_submission_error_message = '';
53
+
54
+	/**
55
+	 * @var array like $_REQUEST
56
+	 */
57
+	protected $cached_request_data;
58
+
59
+	/**
60
+	 * Stores whether this form (and its sub-sections) were found to be valid or not.
61
+	 * Starts off as null, but once the form is validated, it set to either true or false
62
+	 * @var boolean|null
63
+	 */
64
+	protected $is_valid;
65
+
66
+	/**
67
+	 * Stores all the data that will localized for form validation
68
+	 *
69
+	 * @var array
70
+	 */
71
+	protected static $_js_localization = array();
72
+
73
+	/**
74
+	 * whether or not the form's localized validation JS vars have been set
75
+	 *
76
+	 * @type boolean
77
+	 */
78
+	protected static $_scripts_localized = false;
79
+
80
+
81
+	/**
82
+	 * when constructing a proper form section, calls _construct_finalize on children
83
+	 * so that they know who their parent is, and what name they've been given.
84
+	 *
85
+	 * @param array[] $options_array   {
86
+	 * @type          $subsections     EE_Form_Section_Validatable[] where keys are the section's name
87
+	 * @type          $include         string[] numerically-indexed where values are section names to be included,
88
+	 *                                 and in that order. This is handy if you want
89
+	 *                                 the subsections to be ordered differently than the default, and if you override
90
+	 *                                 which fields are shown
91
+	 * @type          $exclude         string[] values are subsections to be excluded. This is handy if you want
92
+	 *                                 to remove certain default subsections (note: if you specify BOTH 'include' AND
93
+	 *                                 'exclude', the inclusions will be applied first, and the exclusions will exclude
94
+	 *                                 items from that list of inclusions)
95
+	 * @type          $layout_strategy EE_Form_Section_Layout_Base strategy for laying out the form
96
+	 *                                 } @see EE_Form_Section_Validatable::__construct()
97
+	 * @throws EE_Error
98
+	 */
99
+	public function __construct($options_array = array())
100
+	{
101
+		$options_array = (array) apply_filters(
102
+			'FHEE__EE_Form_Section_Proper___construct__options_array',
103
+			$options_array,
104
+			$this
105
+		);
106
+		// call parent first, as it may be setting the name
107
+		parent::__construct($options_array);
108
+		// if they've included subsections in the constructor, add them now
109
+		if (isset($options_array['include'])) {
110
+			// we are going to make sure we ONLY have those subsections to include
111
+			// AND we are going to make sure they're in that specified order
112
+			$reordered_subsections = array();
113
+			foreach ($options_array['include'] as $input_name) {
114
+				if (isset($this->_subsections[ $input_name ])) {
115
+					$reordered_subsections[ $input_name ] = $this->_subsections[ $input_name ];
116
+				}
117
+			}
118
+			$this->_subsections = $reordered_subsections;
119
+		}
120
+		if (isset($options_array['exclude'])) {
121
+			$exclude            = $options_array['exclude'];
122
+			$this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
123
+		}
124
+		if (isset($options_array['layout_strategy'])) {
125
+			$this->_layout_strategy = $options_array['layout_strategy'];
126
+		}
127
+		if (! $this->_layout_strategy) {
128
+			$this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
129
+		}
130
+		$this->_layout_strategy->_construct_finalize($this);
131
+		// ok so we are definitely going to want the forms JS,
132
+		// so enqueue it or remember to enqueue it during wp_enqueue_scripts
133
+		if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
134
+			// ok so they've constructed this object after when they should have.
135
+			// just enqueue the generic form scripts and initialize the form immediately in the JS
136
+			EE_Form_Section_Proper::wp_enqueue_scripts(true);
137
+		} else {
138
+			add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
139
+			add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
140
+		}
141
+		add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
142
+		/**
143
+		 * Gives other plugins a chance to hook in before construct finalize is called.
144
+		 * The form probably doesn't yet have a parent form section.
145
+		 * Since 4.9.32, when this action was introduced, this is the best place to add a subsection onto a form,
146
+		 * assuming you don't care what the form section's name, HTML ID, or HTML name etc are.
147
+		 * Also see AHEE__EE_Form_Section_Proper___construct_finalize__end
148
+		 *
149
+		 * @since 4.9.32
150
+		 * @param EE_Form_Section_Proper $this          before __construct is done, but all of its logic,
151
+		 *                                              except maybe calling _construct_finalize has been done
152
+		 * @param array                  $options_array options passed into the constructor
153
+		 */
154
+		do_action(
155
+			'AHEE__EE_Form_Input_Base___construct__before_construct_finalize_called',
156
+			$this,
157
+			$options_array
158
+		);
159
+		if (isset($options_array['name'])) {
160
+			$this->_construct_finalize(null, $options_array['name']);
161
+		}
162
+	}
163
+
164
+
165
+	/**
166
+	 * Finishes construction given the parent form section and this form section's name
167
+	 *
168
+	 * @param EE_Form_Section_Proper $parent_form_section
169
+	 * @param string                 $name
170
+	 * @throws EE_Error
171
+	 */
172
+	public function _construct_finalize($parent_form_section, $name)
173
+	{
174
+		parent::_construct_finalize($parent_form_section, $name);
175
+		$this->_set_default_name_if_empty();
176
+		$this->_set_default_html_id_if_empty();
177
+		foreach ($this->_subsections as $subsection_name => $subsection) {
178
+			if ($subsection instanceof EE_Form_Section_Base) {
179
+				$subsection->_construct_finalize($this, $subsection_name);
180
+			} else {
181
+				throw new EE_Error(
182
+					sprintf(
183
+						esc_html__(
184
+							'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"',
185
+							'event_espresso'
186
+						),
187
+						$subsection_name,
188
+						get_class($this),
189
+						$subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
190
+					)
191
+				);
192
+			}
193
+		}
194
+		/**
195
+		 * Action performed just after form has been given a name (and HTML ID etc) and is fully constructed.
196
+		 * If you have code that should modify the form and needs it and its subsections to have a name, HTML ID
197
+		 * (or other attributes derived from the name like the HTML label id, etc), this is where it should be done.
198
+		 * This might only happen just before displaying the form, or just before it receives form submission data.
199
+		 * If you need to modify the form or its subsections before _construct_finalize is called on it (and we've
200
+		 * ensured it has a name, HTML IDs, etc
201
+		 *
202
+		 * @param EE_Form_Section_Proper      $this
203
+		 * @param EE_Form_Section_Proper|null $parent_form_section
204
+		 * @param string                      $name
205
+		 */
206
+		do_action(
207
+			'AHEE__EE_Form_Section_Proper___construct_finalize__end',
208
+			$this,
209
+			$parent_form_section,
210
+			$name
211
+		);
212
+	}
213
+
214
+
215
+	/**
216
+	 * Gets the layout strategy for this form section
217
+	 *
218
+	 * @return EE_Form_Section_Layout_Base
219
+	 */
220
+	public function get_layout_strategy()
221
+	{
222
+		return $this->_layout_strategy;
223
+	}
224
+
225
+
226
+	/**
227
+	 * Gets the HTML for a single input for this form section according
228
+	 * to the layout strategy
229
+	 *
230
+	 * @param EE_Form_Input_Base $input
231
+	 * @return string
232
+	 */
233
+	public function get_html_for_input($input)
234
+	{
235
+		return $this->_layout_strategy->layout_input($input);
236
+	}
237
+
238
+
239
+	/**
240
+	 * was_submitted - checks if form inputs are present in request data
241
+	 * Basically an alias for form_data_present_in() (which is used by both
242
+	 * proper form sections and form inputs)
243
+	 *
244
+	 * @param null $form_data
245
+	 * @return boolean
246
+	 * @throws EE_Error
247
+	 */
248
+	public function was_submitted($form_data = null)
249
+	{
250
+		return $this->form_data_present_in($form_data);
251
+	}
252
+
253
+	/**
254
+	 * Gets the cached request data; but if there is none, or $req_data was set with
255
+	 * something different, refresh the cache, and then return it
256
+	 * @param null $req_data
257
+	 * @return array
258
+	 */
259
+	protected function getCachedRequest($req_data = null)
260
+	{
261
+		if (
262
+			$this->cached_request_data === null
263
+			|| (
264
+				$req_data !== null
265
+				&& $req_data !== $this->cached_request_data
266
+			)
267
+		) {
268
+			$req_data = apply_filters(
269
+				'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
270
+				$req_data,
271
+				$this
272
+			);
273
+			if ($req_data === null) {
274
+				$req_data = array_merge($_GET, $_POST);
275
+			}
276
+			$req_data = apply_filters(
277
+				'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
278
+				$req_data,
279
+				$this
280
+			);
281
+			$this->cached_request_data = (array) $req_data;
282
+		}
283
+		return $this->cached_request_data;
284
+	}
285
+
286
+
287
+	/**
288
+	 * After the form section is initially created, call this to sanitize the data in the submission
289
+	 * which relates to this form section, validate it, and set it as properties on the form.
290
+	 *
291
+	 * @param array|null $req_data should usually be $_POST (the default).
292
+	 *                             However, you CAN supply a different array.
293
+	 *                             Consider using set_defaults() instead however.
294
+	 *                             (If you rendered the form in the page using echo $form_x->get_html()
295
+	 *                             the inputs will have the correct name in the request data for this function
296
+	 *                             to find them and populate the form with them.
297
+	 *                             If you have a flat form (with only input subsections),
298
+	 *                             you can supply a flat array where keys
299
+	 *                             are the form input names and values are their values)
300
+	 * @param boolean    $validate whether or not to perform validation on this data. Default is,
301
+	 *                             of course, to validate that data, and set errors on the invalid values.
302
+	 *                             But if the data has already been validated
303
+	 *                             (eg you validated the data then stored it in the DB)
304
+	 *                             you may want to skip this step.
305
+	 * @throws InvalidArgumentException
306
+	 * @throws InvalidInterfaceException
307
+	 * @throws InvalidDataTypeException
308
+	 * @throws EE_Error
309
+	 */
310
+	public function receive_form_submission($req_data = null, $validate = true)
311
+	{
312
+		$req_data = $this->getCachedRequest($req_data);
313
+		$this->_normalize($req_data);
314
+		if ($validate) {
315
+			$this->_validate();
316
+			// if it's invalid, we're going to want to re-display so remember what they submitted
317
+			if (! $this->is_valid()) {
318
+				$this->store_submitted_form_data_in_session();
319
+			}
320
+		}
321
+		if ($this->submission_error_message() === '' && ! $this->is_valid()) {
322
+			$this->set_submission_error_message();
323
+		}
324
+		do_action(
325
+			'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
326
+			$req_data,
327
+			$this,
328
+			$validate
329
+		);
330
+	}
331
+
332
+
333
+	/**
334
+	 * caches the originally submitted input values in the session
335
+	 * so that they can be used to repopulate the form if it failed validation
336
+	 *
337
+	 * @return boolean whether or not the data was successfully stored in the session
338
+	 * @throws InvalidArgumentException
339
+	 * @throws InvalidInterfaceException
340
+	 * @throws InvalidDataTypeException
341
+	 * @throws EE_Error
342
+	 */
343
+	protected function store_submitted_form_data_in_session()
344
+	{
345
+		return EE_Registry::instance()->SSN->set_session_data(
346
+			array(
347
+				EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true),
348
+			)
349
+		);
350
+	}
351
+
352
+
353
+	/**
354
+	 * retrieves the originally submitted input values in the session
355
+	 * so that they can be used to repopulate the form if it failed validation
356
+	 *
357
+	 * @return array
358
+	 * @throws InvalidArgumentException
359
+	 * @throws InvalidInterfaceException
360
+	 * @throws InvalidDataTypeException
361
+	 */
362
+	protected function get_submitted_form_data_from_session()
363
+	{
364
+		$session = EE_Registry::instance()->SSN;
365
+		if ($session instanceof EE_Session) {
366
+			return $session->get_session_data(
367
+				EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY
368
+			);
369
+		}
370
+		return array();
371
+	}
372
+
373
+
374
+	/**
375
+	 * flushed the originally submitted input values from the session
376
+	 *
377
+	 * @return boolean whether or not the data was successfully removed from the session
378
+	 * @throws InvalidArgumentException
379
+	 * @throws InvalidInterfaceException
380
+	 * @throws InvalidDataTypeException
381
+	 */
382
+	public static function flush_submitted_form_data_from_session()
383
+	{
384
+		return EE_Registry::instance()->SSN->reset_data(
385
+			array(EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
386
+		);
387
+	}
388
+
389
+
390
+	/**
391
+	 * Populates this form and its subsections with data from the session.
392
+	 * (Wrapper for EE_Form_Section_Proper::receive_form_submission, so it shows
393
+	 * validation errors when displaying too)
394
+	 * Returns true if the form was populated from the session, false otherwise
395
+	 *
396
+	 * @return boolean
397
+	 * @throws InvalidArgumentException
398
+	 * @throws InvalidInterfaceException
399
+	 * @throws InvalidDataTypeException
400
+	 * @throws EE_Error
401
+	 */
402
+	public function populate_from_session()
403
+	{
404
+		$form_data_in_session = $this->get_submitted_form_data_from_session();
405
+		if (empty($form_data_in_session)) {
406
+			return false;
407
+		}
408
+		$this->receive_form_submission($form_data_in_session);
409
+		add_action('shutdown', array('EE_Form_Section_Proper', 'flush_submitted_form_data_from_session'));
410
+		if ($this->form_data_present_in($form_data_in_session)) {
411
+			return true;
412
+		}
413
+		return false;
414
+	}
415
+
416
+
417
+	/**
418
+	 * Populates the default data for the form, given an array where keys are
419
+	 * the input names, and values are their values (preferably normalized to be their
420
+	 * proper PHP types, not all strings... although that should be ok too).
421
+	 * Proper subsections are sub-arrays, the key being the subsection's name, and
422
+	 * the value being an array formatted in teh same way
423
+	 *
424
+	 * @param array $default_data
425
+	 * @throws EE_Error
426
+	 */
427
+	public function populate_defaults($default_data)
428
+	{
429
+		foreach ($this->subsections(false) as $subsection_name => $subsection) {
430
+			if (isset($default_data[ $subsection_name ])) {
431
+				if ($subsection instanceof EE_Form_Input_Base) {
432
+					$subsection->set_default($default_data[ $subsection_name ]);
433
+				} elseif ($subsection instanceof EE_Form_Section_Proper) {
434
+					$subsection->populate_defaults($default_data[ $subsection_name ]);
435
+				}
436
+			}
437
+		}
438
+	}
439
+
440
+
441
+	/**
442
+	 * returns true if subsection exists
443
+	 *
444
+	 * @param string $name
445
+	 * @return boolean
446
+	 */
447
+	public function subsection_exists($name)
448
+	{
449
+		return isset($this->_subsections[ $name ]) ? true : false;
450
+	}
451
+
452
+
453
+	/**
454
+	 * Gets the subsection specified by its name
455
+	 *
456
+	 * @param string  $name
457
+	 * @param boolean $require_construction_to_be_finalized most client code should leave this as TRUE
458
+	 *                                                      so that the inputs will be properly configured.
459
+	 *                                                      However, some client code may be ok
460
+	 *                                                      with construction finalize being called later
461
+	 *                                                      (realizing that the subsections' html names
462
+	 *                                                      might not be set yet, etc.)
463
+	 * @return EE_Form_Section_Base
464
+	 * @throws EE_Error
465
+	 */
466
+	public function get_subsection($name, $require_construction_to_be_finalized = true)
467
+	{
468
+		if ($require_construction_to_be_finalized) {
469
+			$this->ensure_construct_finalized_called();
470
+		}
471
+		return $this->subsection_exists($name) ? $this->_subsections[ $name ] : null;
472
+	}
473
+
474
+
475
+	/**
476
+	 * Gets all the validatable subsections of this form section
477
+	 *
478
+	 * @return EE_Form_Section_Validatable[]
479
+	 * @throws EE_Error
480
+	 */
481
+	public function get_validatable_subsections()
482
+	{
483
+		$validatable_subsections = array();
484
+		foreach ($this->subsections() as $name => $obj) {
485
+			if ($obj instanceof EE_Form_Section_Validatable) {
486
+				$validatable_subsections[ $name ] = $obj;
487
+			}
488
+		}
489
+		return $validatable_subsections;
490
+	}
491
+
492
+
493
+	/**
494
+	 * Gets an input by the given name. If not found, or if its not an EE_FOrm_Input_Base child,
495
+	 * throw an EE_Error.
496
+	 *
497
+	 * @param string  $name
498
+	 * @param boolean $require_construction_to_be_finalized most client code should
499
+	 *                                                      leave this as TRUE so that the inputs will be properly
500
+	 *                                                      configured. However, some client code may be ok with
501
+	 *                                                      construction finalize being called later
502
+	 *                                                      (realizing that the subsections' html names might not be
503
+	 *                                                      set yet, etc.)
504
+	 * @return EE_Form_Input_Base
505
+	 * @throws EE_Error
506
+	 */
507
+	public function get_input($name, $require_construction_to_be_finalized = true)
508
+	{
509
+		$subsection = $this->get_subsection(
510
+			$name,
511
+			$require_construction_to_be_finalized
512
+		);
513
+		if (! $subsection instanceof EE_Form_Input_Base) {
514
+			throw new EE_Error(
515
+				sprintf(
516
+					esc_html__(
517
+						"Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'",
518
+						'event_espresso'
519
+					),
520
+					$name,
521
+					get_class($this),
522
+					$subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
523
+				)
524
+			);
525
+		}
526
+		return $subsection;
527
+	}
528
+
529
+
530
+	/**
531
+	 * Like get_input(), gets the proper subsection of the form given the name,
532
+	 * otherwise throws an EE_Error
533
+	 *
534
+	 * @param string  $name
535
+	 * @param boolean $require_construction_to_be_finalized most client code should
536
+	 *                                                      leave this as TRUE so that the inputs will be properly
537
+	 *                                                      configured. However, some client code may be ok with
538
+	 *                                                      construction finalize being called later
539
+	 *                                                      (realizing that the subsections' html names might not be
540
+	 *                                                      set yet, etc.)
541
+	 * @return EE_Form_Section_Proper
542
+	 * @throws EE_Error
543
+	 */
544
+	public function get_proper_subsection($name, $require_construction_to_be_finalized = true)
545
+	{
546
+		$subsection = $this->get_subsection(
547
+			$name,
548
+			$require_construction_to_be_finalized
549
+		);
550
+		if (! $subsection instanceof EE_Form_Section_Proper) {
551
+			throw new EE_Error(
552
+				sprintf(
553
+					esc_html__(
554
+						"Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'",
555
+						'event_espresso'
556
+					),
557
+					$name,
558
+					get_class($this)
559
+				)
560
+			);
561
+		}
562
+		return $subsection;
563
+	}
564
+
565
+
566
+	/**
567
+	 * Gets the value of the specified input. Should be called after receive_form_submission()
568
+	 * or populate_defaults() on the form, where the normalized value on the input is set.
569
+	 *
570
+	 * @param string $name
571
+	 * @return mixed depending on the input's type and its normalization strategy
572
+	 * @throws EE_Error
573
+	 */
574
+	public function get_input_value($name)
575
+	{
576
+		$input = $this->get_input($name);
577
+		return $input->normalized_value();
578
+	}
579
+
580
+
581
+	/**
582
+	 * Checks if this form section itself is valid, and then checks its subsections
583
+	 *
584
+	 * @throws EE_Error
585
+	 * @return boolean
586
+	 */
587
+	public function is_valid()
588
+	{
589
+		if ($this->is_valid === null) {
590
+			if (! $this->has_received_submission()) {
591
+				throw new EE_Error(
592
+					sprintf(
593
+						esc_html__(
594
+							'You cannot check if a form is valid before receiving the form submission using receive_form_submission',
595
+							'event_espresso'
596
+						)
597
+					)
598
+				);
599
+			}
600
+			if (! parent::is_valid()) {
601
+				$this->is_valid = false;
602
+			} else {
603
+				// ok so no general errors to this entire form section.
604
+				// so let's check the subsections, but only set errors if that hasn't been done yet
605
+				$this->is_valid = true;
606
+				foreach ($this->get_validatable_subsections() as $subsection) {
607
+					if (! $subsection->is_valid()) {
608
+						$this->is_valid = false;
609
+					}
610
+				}
611
+			}
612
+		}
613
+		return $this->is_valid;
614
+	}
615
+
616
+
617
+	/**
618
+	 * gets the default name of this form section if none is specified
619
+	 *
620
+	 * @return void
621
+	 */
622
+	protected function _set_default_name_if_empty()
623
+	{
624
+		if (! $this->_name) {
625
+			$classname    = get_class($this);
626
+			$default_name = str_replace('EE_', '', $classname);
627
+			$this->_name  = $default_name;
628
+		}
629
+	}
630
+
631
+
632
+	/**
633
+	 * Returns the HTML for the form, except for the form opening and closing tags
634
+	 * (as the form section doesn't know where you necessarily want to send the information to),
635
+	 * and except for a submit button. Enqueues JS and CSS; if called early enough we will
636
+	 * try to enqueue them in the header, otherwise they'll be enqueued in the footer.
637
+	 * Not doing_it_wrong because theoretically this CAN be used properly,
638
+	 * provided its used during "wp_enqueue_scripts", or it doesn't need to enqueue
639
+	 * any CSS.
640
+	 *
641
+	 * @throws InvalidArgumentException
642
+	 * @throws InvalidInterfaceException
643
+	 * @throws InvalidDataTypeException
644
+	 * @throws EE_Error
645
+	 */
646
+	public function get_html_and_js()
647
+	{
648
+		$this->enqueue_js();
649
+		return $this->get_html();
650
+	}
651
+
652
+
653
+	/**
654
+	 * returns HTML for displaying this form section. recursively calls display_section() on all subsections
655
+	 *
656
+	 * @param bool $display_previously_submitted_data
657
+	 * @return string
658
+	 * @throws InvalidArgumentException
659
+	 * @throws InvalidInterfaceException
660
+	 * @throws InvalidDataTypeException
661
+	 * @throws EE_Error
662
+	 * @throws EE_Error
663
+	 * @throws EE_Error
664
+	 */
665
+	public function get_html($display_previously_submitted_data = true)
666
+	{
667
+		$this->ensure_construct_finalized_called();
668
+		if ($display_previously_submitted_data) {
669
+			$this->populate_from_session();
670
+		}
671
+		return $this->_form_html_filter
672
+			? $this->_form_html_filter->filterHtml($this->_layout_strategy->layout_form(), $this)
673
+			: $this->_layout_strategy->layout_form();
674
+	}
675
+
676
+
677
+	/**
678
+	 * enqueues JS and CSS for the form.
679
+	 * It is preferred to call this before wp_enqueue_scripts so the
680
+	 * scripts and styles can be put in the header, but if called later
681
+	 * they will be put in the footer (which is OK for JS, but in HTML4 CSS should
682
+	 * only be in the header; but in HTML5 its ok in the body.
683
+	 * See http://stackoverflow.com/questions/4957446/load-external-css-file-in-body-tag.
684
+	 * So if your form enqueues CSS, it's preferred to call this before wp_enqueue_scripts.)
685
+	 *
686
+	 * @return void
687
+	 * @throws EE_Error
688
+	 */
689
+	public function enqueue_js()
690
+	{
691
+		$this->_enqueue_and_localize_form_js();
692
+		foreach ($this->subsections() as $subsection) {
693
+			$subsection->enqueue_js();
694
+		}
695
+	}
696
+
697
+
698
+	/**
699
+	 * adds a filter so that jquery validate gets enqueued in EE_System::wp_enqueue_scripts().
700
+	 * This must be done BEFORE wp_enqueue_scripts() gets called, which is on
701
+	 * the wp_enqueue_scripts hook.
702
+	 * However, registering the form js and localizing it can happen when we
703
+	 * actually output the form (which is preferred, seeing how teh form's fields
704
+	 * could change until it's actually outputted)
705
+	 *
706
+	 * @param boolean $init_form_validation_automatically whether or not we want the form validation
707
+	 *                                                    to be triggered automatically or not
708
+	 * @return void
709
+	 */
710
+	public static function wp_enqueue_scripts($init_form_validation_automatically = true)
711
+	{
712
+		wp_register_script(
713
+			'ee_form_section_validation',
714
+			EE_GLOBAL_ASSETS_URL . 'scripts' . '/form_section_validation.js',
715
+			array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
716
+			EVENT_ESPRESSO_VERSION,
717
+			true
718
+		);
719
+		wp_localize_script(
720
+			'ee_form_section_validation',
721
+			'ee_form_section_validation_init',
722
+			array('init' => $init_form_validation_automatically ? '1' : '0')
723
+		);
724
+	}
725
+
726
+
727
+	/**
728
+	 * gets the variables used by form_section_validation.js.
729
+	 * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
730
+	 * but before the wordpress hook wp_loaded
731
+	 *
732
+	 * @throws EE_Error
733
+	 */
734
+	public function _enqueue_and_localize_form_js()
735
+	{
736
+		$this->ensure_construct_finalized_called();
737
+		// actually, we don't want to localize just yet. There may be other forms on the page.
738
+		// so we need to add our form section data to a static variable accessible by all form sections
739
+		// and localize it just before the footer
740
+		$this->localize_validation_rules();
741
+		add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
742
+		add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
743
+	}
744
+
745
+
746
+	/**
747
+	 * add our form section data to a static variable accessible by all form sections
748
+	 *
749
+	 * @param bool $return_for_subsection
750
+	 * @return void
751
+	 * @throws EE_Error
752
+	 */
753
+	public function localize_validation_rules($return_for_subsection = false)
754
+	{
755
+		// we only want to localize vars ONCE for the entire form,
756
+		// so if the form section doesn't have a parent, then it must be the top dog
757
+		if ($return_for_subsection || ! $this->parent_section()) {
758
+			EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
759
+				'form_section_id'  => $this->html_id(true),
760
+				'validation_rules' => $this->get_jquery_validation_rules(),
761
+				'other_data'       => $this->get_other_js_data(),
762
+				'errors'           => $this->subsection_validation_errors_by_html_name(),
763
+			);
764
+			EE_Form_Section_Proper::$_scripts_localized                                = true;
765
+		}
766
+	}
767
+
768
+
769
+	/**
770
+	 * Gets an array of extra data that will be useful for client-side javascript.
771
+	 * This is primarily data added by inputs and forms in addition to any
772
+	 * scripts they might enqueue
773
+	 *
774
+	 * @param array $form_other_js_data
775
+	 * @return array
776
+	 * @throws EE_Error
777
+	 */
778
+	public function get_other_js_data($form_other_js_data = array())
779
+	{
780
+		foreach ($this->subsections() as $subsection) {
781
+			$form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
782
+		}
783
+		return $form_other_js_data;
784
+	}
785
+
786
+
787
+	/**
788
+	 * Gets a flat array of inputs for this form section and its subsections.
789
+	 * Keys are their form names, and values are the inputs themselves
790
+	 *
791
+	 * @return EE_Form_Input_Base
792
+	 * @throws EE_Error
793
+	 */
794
+	public function inputs_in_subsections()
795
+	{
796
+		$inputs = array();
797
+		foreach ($this->subsections() as $subsection) {
798
+			if ($subsection instanceof EE_Form_Input_Base) {
799
+				$inputs[ $subsection->html_name() ] = $subsection;
800
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
801
+				$inputs += $subsection->inputs_in_subsections();
802
+			}
803
+		}
804
+		return $inputs;
805
+	}
806
+
807
+
808
+	/**
809
+	 * Gets a flat array of all the validation errors.
810
+	 * Keys are html names (because those should be unique)
811
+	 * and values are a string of all their validation errors
812
+	 *
813
+	 * @return string[]
814
+	 * @throws EE_Error
815
+	 */
816
+	public function subsection_validation_errors_by_html_name()
817
+	{
818
+		$inputs = $this->inputs();
819
+		$errors = array();
820
+		foreach ($inputs as $form_input) {
821
+			if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
822
+				$errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
823
+			}
824
+		}
825
+		return $errors;
826
+	}
827
+
828
+
829
+	/**
830
+	 * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
831
+	 * Should be setup by each form during the _enqueues_and_localize_form_js
832
+	 *
833
+	 * @throws InvalidArgumentException
834
+	 * @throws InvalidInterfaceException
835
+	 * @throws InvalidDataTypeException
836
+	 */
837
+	public static function localize_script_for_all_forms()
838
+	{
839
+		// allow inputs and stuff to hook in their JS and stuff here
840
+		do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
841
+		EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
842
+		$email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
843
+			? EE_Registry::instance()->CFG->registration->email_validation_level
844
+			: 'wp_default';
845
+		EE_Form_Section_Proper::$_js_localization['email_validation_level']   = $email_validation_level;
846
+		wp_enqueue_script('ee_form_section_validation');
847
+		wp_localize_script(
848
+			'ee_form_section_validation',
849
+			'ee_form_section_vars',
850
+			EE_Form_Section_Proper::$_js_localization
851
+		);
852
+	}
853
+
854
+
855
+	/**
856
+	 * ensure_scripts_localized
857
+	 *
858
+	 * @throws EE_Error
859
+	 */
860
+	public function ensure_scripts_localized()
861
+	{
862
+		if (! EE_Form_Section_Proper::$_scripts_localized) {
863
+			$this->_enqueue_and_localize_form_js();
864
+		}
865
+	}
866
+
867
+
868
+	/**
869
+	 * Gets the hard-coded validation error messages to be used in the JS. The convention
870
+	 * is that the key here should be the same as the custom validation rule put in the JS file
871
+	 *
872
+	 * @return array keys are custom validation rules, and values are internationalized strings
873
+	 */
874
+	private static function _get_localized_error_messages()
875
+	{
876
+		return array(
877
+			'validUrl' => esc_html__('This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg', 'event_espresso'),
878
+			'regex'    => esc_html__('Please check your input', 'event_espresso'),
879
+		);
880
+	}
881
+
882
+
883
+	/**
884
+	 * @return array
885
+	 */
886
+	public static function js_localization()
887
+	{
888
+		return self::$_js_localization;
889
+	}
890
+
891
+
892
+	/**
893
+	 * @return void
894
+	 */
895
+	public static function reset_js_localization()
896
+	{
897
+		self::$_js_localization = array();
898
+	}
899
+
900
+
901
+	/**
902
+	 * Gets the JS to put inside the jquery validation rules for subsection of this form section.
903
+	 * See parent function for more...
904
+	 *
905
+	 * @return array
906
+	 * @throws EE_Error
907
+	 */
908
+	public function get_jquery_validation_rules()
909
+	{
910
+		$jquery_validation_rules = array();
911
+		foreach ($this->get_validatable_subsections() as $subsection) {
912
+			$jquery_validation_rules = array_merge(
913
+				$jquery_validation_rules,
914
+				$subsection->get_jquery_validation_rules()
915
+			);
916
+		}
917
+		return $jquery_validation_rules;
918
+	}
919
+
920
+
921
+	/**
922
+	 * Sanitizes all the data and sets the sanitized value of each field
923
+	 *
924
+	 * @param array $req_data like $_POST
925
+	 * @return void
926
+	 * @throws EE_Error
927
+	 */
928
+	protected function _normalize($req_data)
929
+	{
930
+		$this->_received_submission = true;
931
+		$this->_validation_errors   = array();
932
+		foreach ($this->get_validatable_subsections() as $subsection) {
933
+			try {
934
+				$subsection->_normalize($req_data);
935
+			} catch (EE_Validation_Error $e) {
936
+				$subsection->add_validation_error($e);
937
+			}
938
+		}
939
+	}
940
+
941
+
942
+	/**
943
+	 * Performs validation on this form section and its subsections.
944
+	 * For each subsection,
945
+	 * calls _validate_{subsection_name} on THIS form (if the function exists)
946
+	 * and passes it the subsection, then calls _validate on that subsection.
947
+	 * If you need to perform validation on the form as a whole (considering multiple)
948
+	 * you would be best to override this _validate method,
949
+	 * calling parent::_validate() first.
950
+	 *
951
+	 * @throws EE_Error
952
+	 */
953
+	protected function _validate()
954
+	{
955
+		// reset the cache of whether this form is valid or not- we're re-validating it now
956
+		$this->is_valid = null;
957
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
958
+			if (method_exists($this, '_validate_' . $subsection_name)) {
959
+				call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
960
+			}
961
+			$subsection->_validate();
962
+		}
963
+	}
964
+
965
+
966
+	/**
967
+	 * Gets all the validated inputs for the form section
968
+	 *
969
+	 * @return array
970
+	 * @throws EE_Error
971
+	 */
972
+	public function valid_data()
973
+	{
974
+		$inputs = array();
975
+		foreach ($this->subsections() as $subsection_name => $subsection) {
976
+			if ($subsection instanceof EE_Form_Section_Proper) {
977
+				$inputs[ $subsection_name ] = $subsection->valid_data();
978
+			} elseif ($subsection instanceof EE_Form_Input_Base) {
979
+				$inputs[ $subsection_name ] = $subsection->normalized_value();
980
+			}
981
+		}
982
+		return $inputs;
983
+	}
984
+
985
+
986
+	/**
987
+	 * Gets all the inputs on this form section
988
+	 *
989
+	 * @return EE_Form_Input_Base[]
990
+	 * @throws EE_Error
991
+	 */
992
+	public function inputs()
993
+	{
994
+		$inputs = array();
995
+		foreach ($this->subsections() as $subsection_name => $subsection) {
996
+			if ($subsection instanceof EE_Form_Input_Base) {
997
+				$inputs[ $subsection_name ] = $subsection;
998
+			}
999
+		}
1000
+		return $inputs;
1001
+	}
1002
+
1003
+
1004
+	/**
1005
+	 * Gets all the subsections which are a proper form
1006
+	 *
1007
+	 * @return EE_Form_Section_Proper[]
1008
+	 * @throws EE_Error
1009
+	 */
1010
+	public function subforms()
1011
+	{
1012
+		$form_sections = array();
1013
+		foreach ($this->subsections() as $name => $obj) {
1014
+			if ($obj instanceof EE_Form_Section_Proper) {
1015
+				$form_sections[ $name ] = $obj;
1016
+			}
1017
+		}
1018
+		return $form_sections;
1019
+	}
1020
+
1021
+
1022
+	/**
1023
+	 * Gets all the subsections (inputs, proper subsections, or html-only sections).
1024
+	 * Consider using inputs() or subforms()
1025
+	 * if you only want form inputs or proper form sections.
1026
+	 *
1027
+	 * @param boolean $require_construction_to_be_finalized most client code should
1028
+	 *                                                      leave this as TRUE so that the inputs will be properly
1029
+	 *                                                      configured. However, some client code may be ok with
1030
+	 *                                                      construction finalize being called later
1031
+	 *                                                      (realizing that the subsections' html names might not be
1032
+	 *                                                      set yet, etc.)
1033
+	 * @return EE_Form_Section_Proper[]
1034
+	 * @throws EE_Error
1035
+	 */
1036
+	public function subsections($require_construction_to_be_finalized = true)
1037
+	{
1038
+		if ($require_construction_to_be_finalized) {
1039
+			$this->ensure_construct_finalized_called();
1040
+		}
1041
+		return $this->_subsections;
1042
+	}
1043
+
1044
+
1045
+	/**
1046
+	 * Returns whether this form has any subforms or inputs
1047
+	 * @return bool
1048
+	 */
1049
+	public function hasSubsections()
1050
+	{
1051
+		return ! empty($this->_subsections);
1052
+	}
1053
+
1054
+
1055
+	/**
1056
+	 * Returns a simple array where keys are input names, and values are their normalized
1057
+	 * values. (Similar to calling get_input_value on inputs)
1058
+	 *
1059
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1060
+	 *                                        or just this forms' direct children inputs
1061
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1062
+	 *                                        or allow multidimensional array
1063
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array
1064
+	 *                                        with array keys being input names
1065
+	 *                                        (regardless of whether they are from a subsection or not),
1066
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1067
+	 *                                        where keys are always subsection names and values are either
1068
+	 *                                        the input's normalized value, or an array like the top-level array
1069
+	 * @throws EE_Error
1070
+	 */
1071
+	public function input_values($include_subform_inputs = false, $flatten = false)
1072
+	{
1073
+		return $this->_input_values(false, $include_subform_inputs, $flatten);
1074
+	}
1075
+
1076
+
1077
+	/**
1078
+	 * Similar to EE_Form_Section_Proper::input_values(), except this returns the 'display_value'
1079
+	 * of each input. On some inputs (especially radio boxes or checkboxes), the value stored
1080
+	 * is not necessarily the value we want to display to users. This creates an array
1081
+	 * where keys are the input names, and values are their display values
1082
+	 *
1083
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1084
+	 *                                        or just this forms' direct children inputs
1085
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1086
+	 *                                        or allow multidimensional array
1087
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array
1088
+	 *                                        with array keys being input names
1089
+	 *                                        (regardless of whether they are from a subsection or not),
1090
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1091
+	 *                                        where keys are always subsection names and values are either
1092
+	 *                                        the input's normalized value, or an array like the top-level array
1093
+	 * @throws EE_Error
1094
+	 */
1095
+	public function input_pretty_values($include_subform_inputs = false, $flatten = false)
1096
+	{
1097
+		return $this->_input_values(true, $include_subform_inputs, $flatten);
1098
+	}
1099
+
1100
+
1101
+	/**
1102
+	 * Gets the input values from the form
1103
+	 *
1104
+	 * @param boolean $pretty                 Whether to retrieve the pretty value,
1105
+	 *                                        or just the normalized value
1106
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1107
+	 *                                        or just this forms' direct children inputs
1108
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1109
+	 *                                        or allow multidimensional array
1110
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array with array keys being
1111
+	 *                                        input names (regardless of whether they are from a subsection or not),
1112
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1113
+	 *                                        where keys are always subsection names and values are either
1114
+	 *                                        the input's normalized value, or an array like the top-level array
1115
+	 * @throws EE_Error
1116
+	 */
1117
+	public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false)
1118
+	{
1119
+		$input_values = array();
1120
+		foreach ($this->subsections() as $subsection_name => $subsection) {
1121
+			if ($subsection instanceof EE_Form_Input_Base) {
1122
+				$input_values[ $subsection_name ] = $pretty
1123
+					? $subsection->pretty_value()
1124
+					: $subsection->normalized_value();
1125
+			} elseif ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
1126
+				$subform_input_values = $subsection->_input_values(
1127
+					$pretty,
1128
+					$include_subform_inputs,
1129
+					$flatten
1130
+				);
1131
+				if ($flatten) {
1132
+					$input_values = array_merge($input_values, $subform_input_values);
1133
+				} else {
1134
+					$input_values[ $subsection_name ] = $subform_input_values;
1135
+				}
1136
+			}
1137
+		}
1138
+		return $input_values;
1139
+	}
1140
+
1141
+
1142
+	/**
1143
+	 * Gets the originally submitted input values from the form
1144
+	 *
1145
+	 * @param boolean $include_subforms  Whether to include inputs from subforms,
1146
+	 *                                   or just this forms' direct children inputs
1147
+	 * @return array                     if $flatten is TRUE it will always be a 1-dimensional array
1148
+	 *                                   with array keys being input names
1149
+	 *                                   (regardless of whether they are from a subsection or not),
1150
+	 *                                   and if $flatten is FALSE it can be a multidimensional array
1151
+	 *                                   where keys are always subsection names and values are either
1152
+	 *                                   the input's normalized value, or an array like the top-level array
1153
+	 * @throws EE_Error
1154
+	 */
1155
+	public function submitted_values($include_subforms = false)
1156
+	{
1157
+		$submitted_values = array();
1158
+		foreach ($this->subsections() as $subsection) {
1159
+			if ($subsection instanceof EE_Form_Input_Base) {
1160
+				// is this input part of an array of inputs?
1161
+				if (strpos($subsection->html_name(), '[') !== false) {
1162
+					$full_input_name  = EEH_Array::convert_array_values_to_keys(
1163
+						explode(
1164
+							'[',
1165
+							str_replace(']', '', $subsection->html_name())
1166
+						),
1167
+						$subsection->raw_value()
1168
+					);
1169
+					$submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1170
+				} else {
1171
+					$submitted_values[ $subsection->html_name() ] = $subsection->raw_value();
1172
+				}
1173
+			} elseif ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1174
+				$subform_input_values = $subsection->submitted_values($include_subforms);
1175
+				$submitted_values     = array_replace_recursive($submitted_values, $subform_input_values);
1176
+			}
1177
+		}
1178
+		return $submitted_values;
1179
+	}
1180
+
1181
+
1182
+	/**
1183
+	 * Indicates whether or not this form has received a submission yet
1184
+	 * (ie, had receive_form_submission called on it yet)
1185
+	 *
1186
+	 * @return boolean
1187
+	 * @throws EE_Error
1188
+	 */
1189
+	public function has_received_submission()
1190
+	{
1191
+		$this->ensure_construct_finalized_called();
1192
+		return $this->_received_submission;
1193
+	}
1194
+
1195
+
1196
+	/**
1197
+	 * Equivalent to passing 'exclude' in the constructor's options array.
1198
+	 * Removes the listed inputs from the form
1199
+	 *
1200
+	 * @param array $inputs_to_exclude values are the input names
1201
+	 * @return void
1202
+	 */
1203
+	public function exclude(array $inputs_to_exclude = array())
1204
+	{
1205
+		foreach ($inputs_to_exclude as $input_to_exclude_name) {
1206
+			unset($this->_subsections[ $input_to_exclude_name ]);
1207
+		}
1208
+	}
1209
+
1210
+
1211
+	/**
1212
+	 * Changes these inputs' display strategy to be EE_Hidden_Display_Strategy.
1213
+	 * @param array $inputs_to_hide
1214
+	 * @throws EE_Error
1215
+	 */
1216
+	public function hide(array $inputs_to_hide = array())
1217
+	{
1218
+		foreach ($inputs_to_hide as $input_to_hide) {
1219
+			$input = $this->get_input($input_to_hide);
1220
+			$input->set_display_strategy(new EE_Hidden_Display_Strategy());
1221
+		}
1222
+	}
1223
+
1224
+
1225
+	/**
1226
+	 * add_subsections
1227
+	 * Adds the listed subsections to the form section.
1228
+	 * If $subsection_name_to_target is provided,
1229
+	 * then new subsections are added before or after that subsection,
1230
+	 * otherwise to the start or end of the entire subsections array.
1231
+	 *
1232
+	 * @param EE_Form_Section_Base[] $new_subsections           array of new form subsections
1233
+	 *                                                          where keys are their names
1234
+	 * @param string                 $subsection_name_to_target an existing for section that $new_subsections
1235
+	 *                                                          should be added before or after
1236
+	 *                                                          IF $subsection_name_to_target is null,
1237
+	 *                                                          then $new_subsections will be added to
1238
+	 *                                                          the beginning or end of the entire subsections array
1239
+	 * @param boolean                $add_before                whether to add $new_subsections, before or after
1240
+	 *                                                          $subsection_name_to_target,
1241
+	 *                                                          or if $subsection_name_to_target is null,
1242
+	 *                                                          before or after entire subsections array
1243
+	 * @return void
1244
+	 * @throws EE_Error
1245
+	 */
1246
+	public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1247
+	{
1248
+		foreach ($new_subsections as $subsection_name => $subsection) {
1249
+			if (! $subsection instanceof EE_Form_Section_Base) {
1250
+				EE_Error::add_error(
1251
+					sprintf(
1252
+						esc_html__(
1253
+							"Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.",
1254
+							'event_espresso'
1255
+						),
1256
+						get_class($subsection),
1257
+						$subsection_name,
1258
+						$this->name()
1259
+					)
1260
+				);
1261
+				unset($new_subsections[ $subsection_name ]);
1262
+			}
1263
+		}
1264
+		$this->_subsections = EEH_Array::insert_into_array(
1265
+			$this->_subsections,
1266
+			$new_subsections,
1267
+			$subsection_name_to_target,
1268
+			$add_before
1269
+		);
1270
+		if ($this->_construction_finalized) {
1271
+			foreach ($this->_subsections as $name => $subsection) {
1272
+				$subsection->_construct_finalize($this, $name);
1273
+			}
1274
+		}
1275
+	}
1276
+
1277
+
1278
+	/**
1279
+	 * @param string $subsection_name
1280
+	 * @param bool   $recursive
1281
+	 * @return bool
1282
+	 */
1283
+	public function has_subsection($subsection_name, $recursive = false)
1284
+	{
1285
+		foreach ($this->_subsections as $name => $subsection) {
1286
+			if (
1287
+				$name === $subsection_name
1288
+				|| (
1289
+					$recursive
1290
+					&& $subsection instanceof EE_Form_Section_Proper
1291
+					&& $subsection->has_subsection($subsection_name, $recursive)
1292
+				)
1293
+			) {
1294
+				return true;
1295
+			}
1296
+		}
1297
+		return false;
1298
+	}
1299
+
1300
+
1301
+
1302
+	/**
1303
+	 * Just gets all validatable subsections to clean their sensitive data
1304
+	 *
1305
+	 * @throws EE_Error
1306
+	 */
1307
+	public function clean_sensitive_data()
1308
+	{
1309
+		foreach ($this->get_validatable_subsections() as $subsection) {
1310
+			$subsection->clean_sensitive_data();
1311
+		}
1312
+	}
1313
+
1314
+
1315
+	/**
1316
+	 * Sets the submission error message (aka validation error message for this form section and all sub-sections)
1317
+	 * @param string                           $form_submission_error_message
1318
+	 * @param EE_Form_Section_Validatable $form_section unused
1319
+	 * @throws EE_Error
1320
+	 */
1321
+	public function set_submission_error_message(
1322
+		$form_submission_error_message = ''
1323
+	) {
1324
+		$this->_form_submission_error_message = ! empty($form_submission_error_message)
1325
+			? $form_submission_error_message
1326
+			: $this->getAllValidationErrorsString();
1327
+	}
1328
+
1329
+
1330
+	/**
1331
+	 * Returns the cached error message. A default value is set for this during _validate(),
1332
+	 * (called during receive_form_submission) but it can be explicitly set using
1333
+	 * set_submission_error_message
1334
+	 *
1335
+	 * @return string
1336
+	 */
1337
+	public function submission_error_message()
1338
+	{
1339
+		return $this->_form_submission_error_message;
1340
+	}
1341
+
1342
+
1343
+	/**
1344
+	 * Sets a message to display if the data submitted to the form was valid.
1345
+	 * @param string $form_submission_success_message
1346
+	 */
1347
+	public function set_submission_success_message($form_submission_success_message = '')
1348
+	{
1349
+		$this->_form_submission_success_message = ! empty($form_submission_success_message)
1350
+			? $form_submission_success_message
1351
+			: esc_html__('Form submitted successfully', 'event_espresso');
1352
+	}
1353
+
1354
+
1355
+	/**
1356
+	 * Gets a message appropriate for display when the form is correctly submitted
1357
+	 * @return string
1358
+	 */
1359
+	public function submission_success_message()
1360
+	{
1361
+		return $this->_form_submission_success_message;
1362
+	}
1363
+
1364
+
1365
+	/**
1366
+	 * Returns the prefix that should be used on child of this form section for
1367
+	 * their html names. If this form section itself has a parent, prepends ITS
1368
+	 * prefix onto this form section's prefix. Used primarily by
1369
+	 * EE_Form_Input_Base::_set_default_html_name_if_empty
1370
+	 *
1371
+	 * @return string
1372
+	 * @throws EE_Error
1373
+	 */
1374
+	public function html_name_prefix()
1375
+	{
1376
+		if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1377
+			return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1378
+		}
1379
+		return $this->name();
1380
+	}
1381
+
1382
+
1383
+	/**
1384
+	 * Gets the name, but first checks _construct_finalize has been called. If not,
1385
+	 * calls it (assumes there is no parent and that we want the name to be whatever
1386
+	 * was set, which is probably nothing, or the classname)
1387
+	 *
1388
+	 * @return string
1389
+	 * @throws EE_Error
1390
+	 */
1391
+	public function name()
1392
+	{
1393
+		$this->ensure_construct_finalized_called();
1394
+		return parent::name();
1395
+	}
1396
+
1397
+
1398
+	/**
1399
+	 * @return EE_Form_Section_Proper
1400
+	 * @throws EE_Error
1401
+	 */
1402
+	public function parent_section()
1403
+	{
1404
+		$this->ensure_construct_finalized_called();
1405
+		return parent::parent_section();
1406
+	}
1407
+
1408
+
1409
+	/**
1410
+	 * make sure construction finalized was called, otherwise children might not be ready
1411
+	 *
1412
+	 * @return void
1413
+	 * @throws EE_Error
1414
+	 */
1415
+	public function ensure_construct_finalized_called()
1416
+	{
1417
+		if (! $this->_construction_finalized) {
1418
+			$this->_construct_finalize($this->_parent_section, $this->_name);
1419
+		}
1420
+	}
1421
+
1422
+
1423
+	/**
1424
+	 * Checks if any of this form section's inputs, or any of its children's inputs,
1425
+	 * are in teh form data. If any are found, returns true. Else false
1426
+	 *
1427
+	 * @param array $req_data
1428
+	 * @return boolean
1429
+	 * @throws EE_Error
1430
+	 */
1431
+	public function form_data_present_in($req_data = null)
1432
+	{
1433
+		$req_data = $this->getCachedRequest($req_data);
1434
+		foreach ($this->subsections() as $subsection) {
1435
+			if ($subsection instanceof EE_Form_Input_Base) {
1436
+				if ($subsection->form_data_present_in($req_data)) {
1437
+					return true;
1438
+				}
1439
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
1440
+				if ($subsection->form_data_present_in($req_data)) {
1441
+					return true;
1442
+				}
1443
+			}
1444
+		}
1445
+		return false;
1446
+	}
1447
+
1448
+
1449
+	/**
1450
+	 * Gets validation errors for this form section and subsections
1451
+	 * Similar to EE_Form_Section_Validatable::get_validation_errors() except this
1452
+	 * gets the validation errors for ALL subsection
1453
+	 *
1454
+	 * @return EE_Validation_Error[]
1455
+	 * @throws EE_Error
1456
+	 */
1457
+	public function get_validation_errors_accumulated()
1458
+	{
1459
+		$validation_errors = $this->get_validation_errors();
1460
+		foreach ($this->get_validatable_subsections() as $subsection) {
1461
+			if ($subsection instanceof EE_Form_Section_Proper) {
1462
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1463
+			} else {
1464
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors();
1465
+			}
1466
+			if ($validation_errors_on_this_subsection) {
1467
+				$validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1468
+			}
1469
+		}
1470
+		return $validation_errors;
1471
+	}
1472
+
1473
+	/**
1474
+	 * Fetch validation errors from children and grandchildren and puts them in a single string.
1475
+	 * This traverses the form section tree to generate this, but you probably want to instead use
1476
+	 * get_form_submission_error_message() which is usually this message cached (or a custom validation error message)
1477
+	 *
1478
+	 * @return string
1479
+	 * @since 4.9.59.p
1480
+	 */
1481
+	protected function getAllValidationErrorsString()
1482
+	{
1483
+		$submission_error_messages = array();
1484
+		// bad, bad, bad registrant
1485
+		foreach ($this->get_validation_errors_accumulated() as $validation_error) {
1486
+			if ($validation_error instanceof EE_Validation_Error) {
1487
+				$form_section = $validation_error->get_form_section();
1488
+				if ($form_section instanceof EE_Form_Input_Base) {
1489
+					$label = $validation_error->get_form_section()->html_label_text();
1490
+				} elseif ($form_section instanceof EE_Form_Section_Validatable) {
1491
+					$label = $validation_error->get_form_section()->name();
1492
+				} else {
1493
+					$label = esc_html__('Unknown', 'event_espresso');
1494
+				}
1495
+				$submission_error_messages[] = sprintf(
1496
+					__('%s : %s', 'event_espresso'),
1497
+					$label,
1498
+					$validation_error->getMessage()
1499
+				);
1500
+			}
1501
+		}
1502
+		return implode('<br>', $submission_error_messages);
1503
+	}
1504
+
1505
+
1506
+	/**
1507
+	 * This isn't just the name of an input, it's a path pointing to an input. The
1508
+	 * path is similar to a folder path: slash (/) means to descend into a subsection,
1509
+	 * dot-dot-slash (../) means to ascend into the parent section.
1510
+	 * After a series of slashes and dot-dot-slashes, there should be the name of an input,
1511
+	 * which will be returned.
1512
+	 * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
1513
+	 * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
1514
+	 * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
1515
+	 * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
1516
+	 * Etc
1517
+	 *
1518
+	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1519
+	 * @return EE_Form_Section_Base
1520
+	 * @throws EE_Error
1521
+	 */
1522
+	public function find_section_from_path($form_section_path)
1523
+	{
1524
+		// check if we can find the input from purely going straight up the tree
1525
+		$input = parent::find_section_from_path($form_section_path);
1526
+		if ($input instanceof EE_Form_Section_Base) {
1527
+			return $input;
1528
+		}
1529
+		$next_slash_pos = strpos($form_section_path, '/');
1530
+		if ($next_slash_pos !== false) {
1531
+			$child_section_name = substr($form_section_path, 0, $next_slash_pos);
1532
+			$subpath            = substr($form_section_path, $next_slash_pos + 1);
1533
+		} else {
1534
+			$child_section_name = $form_section_path;
1535
+			$subpath            = '';
1536
+		}
1537
+		$child_section = $this->get_subsection($child_section_name);
1538
+		if ($child_section instanceof EE_Form_Section_Base) {
1539
+			return $child_section->find_section_from_path($subpath);
1540
+		}
1541
+		return null;
1542
+	}
1543 1543
 }
Please login to merge, or discard this patch.