Completed
Branch BUG-10729-PayPal-Pro-order-des... (4e72cf)
by
unknown
138:09 queued 125:48
created
core/EE_Config.core.php 2 patches
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     public static function instance()
151 151
     {
152 152
         // check if class object is instantiated, and instantiated properly
153
-        if (! self::$_instance instanceof EE_Config) {
153
+        if ( ! self::$_instance instanceof EE_Config) {
154 154
             self::$_instance = new self();
155 155
         }
156 156
         return self::$_instance;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
                 $this
294 294
             );
295 295
             if (is_object($settings) && property_exists($this, $config)) {
296
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
296
+                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
297 297
                 //call configs populate method to ensure any defaults are set for empty values.
298 298
                 if (method_exists($settings, 'populate')) {
299 299
                     $this->{$config}->populate();
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
                         break;
562 562
                     // TEST #2 : check that settings section exists
563 563
                     case 2 :
564
-                        if (! isset($this->{$section})) {
564
+                        if ( ! isset($this->{$section})) {
565 565
                             if ($display_errors) {
566 566
                                 throw new EE_Error(
567 567
                                     sprintf(
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
                         break;
623 623
                     // TEST #6 : verify config class is accessible
624 624
                     case 6 :
625
-                        if (! class_exists($config_class)) {
625
+                        if ( ! class_exists($config_class)) {
626 626
                             if ($display_errors) {
627 627
                                 throw new EE_Error(
628 628
                                     sprintf(
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
                         break;
640 640
                     // TEST #7 : check that config has even been set
641 641
                     case 7 :
642
-                        if (! isset($this->{$section}->{$name})) {
642
+                        if ( ! isset($this->{$section}->{$name})) {
643 643
                             if ($display_errors) {
644 644
                                 throw new EE_Error(
645 645
                                     sprintf(
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
                         break;
658 658
                     // TEST #8 : check that config is the requested type
659 659
                     case 8 :
660
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
660
+                        if ( ! $this->{$section}->{$name} instanceof $config_class) {
661 661
                             if ($display_errors) {
662 662
                                 throw new EE_Error(
663 663
                                     sprintf(
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
                         break;
677 677
                     // TEST #9 : verify config object
678 678
                     case 9 :
679
-                        if (! $config_obj instanceof EE_Config_Base) {
679
+                        if ( ! $config_obj instanceof EE_Config_Base) {
680 680
                             if ($display_errors) {
681 681
                                 throw new EE_Error(
682 682
                                     sprintf(
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
      */
710 710
     private function _generate_config_option_name($section = '', $name = '')
711 711
     {
712
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
712
+        return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
713 713
     }
714 714
 
715 715
 
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
     {
728 728
         return ! empty($config_class)
729 729
             ? $config_class
730
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
730
+            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
731 731
     }
732 732
 
733 733
 
@@ -747,17 +747,17 @@  discard block
 block discarded – undo
747 747
         // ensure config class is set to something
748 748
         $config_class = $this->_set_config_class($config_class, $name);
749 749
         // run tests 1-4, 6, and 7 to verify all config params are set and valid
750
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
750
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
751 751
             return null;
752 752
         }
753 753
         $config_option_name = $this->_generate_config_option_name($section, $name);
754 754
         // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
755
-        if (! isset($this->_addon_option_names[$config_option_name])) {
755
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
756 756
             $this->_addon_option_names[$config_option_name] = $config_class;
757 757
             $this->update_addon_option_names();
758 758
         }
759 759
         // verify the incoming config object but suppress errors
760
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
760
+        if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
761 761
             $config_obj = new $config_class();
762 762
         }
763 763
         if (get_option($config_option_name)) {
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
         // get class name of the incoming object
806 806
         $config_class = get_class($config_obj);
807 807
         // run tests 1-5 and 9 to verify config
808
-        if (! $this->_verify_config_params(
808
+        if ( ! $this->_verify_config_params(
809 809
             $section,
810 810
             $name,
811 811
             $config_class,
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
         }
818 818
         $config_option_name = $this->_generate_config_option_name($section, $name);
819 819
         // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
820
-        if (! isset($this->_addon_option_names[$config_option_name])) {
820
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
821 821
             // save new config to db
822 822
             if ($this->set_config($section, $name, $config_class, $config_obj)) {
823 823
                 return true;
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
                             'event_espresso'
844 844
                         ),
845 845
                         $config_class,
846
-                        'EE_Config->' . $section . '->' . $name
846
+                        'EE_Config->'.$section.'->'.$name
847 847
                     ),
848 848
                     __FILE__,
849 849
                     __FUNCTION__,
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
         // ensure config class is set to something
871 871
         $config_class = $this->_set_config_class($config_class, $name);
872 872
         // run tests 1-4, 6 and 7 to verify that all params have been set
873
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
873
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
874 874
             return null;
875 875
         }
876 876
         // now test if the requested config object exists, but suppress errors
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
         // retrieve the wp-option for this config class.
917 917
         $config_option = maybe_unserialize(get_option($config_option_name, array()));
918 918
         if (empty($config_option)) {
919
-            EE_Config::log($config_option_name . '-NOT-FOUND');
919
+            EE_Config::log($config_option_name.'-NOT-FOUND');
920 920
         }
921 921
         return $config_option;
922 922
     }
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
             //copy incoming $_REQUEST and sanitize it so we can save it
936 936
             $_request = $_REQUEST;
937 937
             array_walk_recursive($_request, 'sanitize_text_field');
938
-            $config_log[(string)microtime(true)] = array(
938
+            $config_log[(string) microtime(true)] = array(
939 939
                 'config_name' => $config_option_name,
940 940
                 'request'     => $_request,
941 941
             );
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
      */
952 952
     public static function trim_log()
953 953
     {
954
-        if (! EE_Config::logging_enabled()) {
954
+        if ( ! EE_Config::logging_enabled()) {
955 955
             return;
956 956
         }
957 957
         $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
     public static function get_page_for_posts()
977 977
     {
978 978
         $page_for_posts = get_option('page_for_posts');
979
-        if (! $page_for_posts) {
979
+        if ( ! $page_for_posts) {
980 980
             return 'posts';
981 981
         }
982 982
         /** @type WPDB $wpdb */
@@ -1037,13 +1037,13 @@  discard block
 block discarded – undo
1037 1037
             )
1038 1038
         ) {
1039 1039
             // grab list of installed widgets
1040
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1040
+            $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
1041 1041
             // filter list of modules to register
1042 1042
             $widgets_to_register = apply_filters(
1043 1043
                 'FHEE__EE_Config__register_widgets__widgets_to_register',
1044 1044
                 $widgets_to_register
1045 1045
             );
1046
-            if (! empty($widgets_to_register)) {
1046
+            if ( ! empty($widgets_to_register)) {
1047 1047
                 // cycle thru widget folders
1048 1048
                 foreach ($widgets_to_register as $widget_path) {
1049 1049
                     // add to list of installed widget modules
@@ -1094,31 +1094,31 @@  discard block
 block discarded – undo
1094 1094
         // create classname from widget directory name
1095 1095
         $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1096 1096
         // add class prefix
1097
-        $widget_class = 'EEW_' . $widget;
1097
+        $widget_class = 'EEW_'.$widget;
1098 1098
         // does the widget exist ?
1099
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1099
+        if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) {
1100 1100
             $msg = sprintf(
1101 1101
                 __(
1102 1102
                     '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',
1103 1103
                     'event_espresso'
1104 1104
                 ),
1105 1105
                 $widget_class,
1106
-                $widget_path . DS . $widget_class . $widget_ext
1106
+                $widget_path.DS.$widget_class.$widget_ext
1107 1107
             );
1108
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1108
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1109 1109
             return;
1110 1110
         }
1111 1111
         // load the widget class file
1112
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1112
+        require_once($widget_path.DS.$widget_class.$widget_ext);
1113 1113
         // verify that class exists
1114
-        if (! class_exists($widget_class)) {
1114
+        if ( ! class_exists($widget_class)) {
1115 1115
             $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1116
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1116
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1117 1117
             return;
1118 1118
         }
1119 1119
         register_widget($widget_class);
1120 1120
         // add to array of registered widgets
1121
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1121
+        EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext;
1122 1122
     }
1123 1123
 
1124 1124
 
@@ -1132,19 +1132,19 @@  discard block
 block discarded – undo
1132 1132
     private function _register_modules()
1133 1133
     {
1134 1134
         // grab list of installed modules
1135
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1135
+        $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1136 1136
         // filter list of modules to register
1137 1137
         $modules_to_register = apply_filters(
1138 1138
             'FHEE__EE_Config__register_modules__modules_to_register',
1139 1139
             $modules_to_register
1140 1140
         );
1141
-        if (! empty($modules_to_register)) {
1141
+        if ( ! empty($modules_to_register)) {
1142 1142
             // loop through folders
1143 1143
             foreach ($modules_to_register as $module_path) {
1144 1144
                 /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1145 1145
                 if (
1146
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1147
-                    && $module_path !== EE_MODULES . 'gateways'
1146
+                    $module_path !== EE_MODULES.'zzz-copy-this-module-template'
1147
+                    && $module_path !== EE_MODULES.'gateways'
1148 1148
                 ) {
1149 1149
                     // add to list of installed modules
1150 1150
                     EE_Config::register_module($module_path);
@@ -1182,25 +1182,25 @@  discard block
 block discarded – undo
1182 1182
             // remove last segment
1183 1183
             array_pop($module_path);
1184 1184
             // glue it back together
1185
-            $module_path = implode(DS, $module_path) . DS;
1185
+            $module_path = implode(DS, $module_path).DS;
1186 1186
             // take first segment from file name pieces and sanitize it
1187 1187
             $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1188 1188
             // ensure class prefix is added
1189
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1189
+            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1190 1190
         } else {
1191 1191
             // we need to generate the filename based off of the folder name
1192 1192
             // grab and sanitize module name
1193 1193
             $module = strtolower(basename($module_path));
1194 1194
             $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1195 1195
             // like trailingslashit()
1196
-            $module_path = rtrim($module_path, DS) . DS;
1196
+            $module_path = rtrim($module_path, DS).DS;
1197 1197
             // create classname from module directory name
1198 1198
             $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1199 1199
             // add class prefix
1200
-            $module_class = 'EED_' . $module;
1200
+            $module_class = 'EED_'.$module;
1201 1201
         }
1202 1202
         // does the module exist ?
1203
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1203
+        if ( ! is_readable($module_path.DS.$module_class.$module_ext)) {
1204 1204
             $msg = sprintf(
1205 1205
                 __(
1206 1206
                     'The requested %s module file could not be found or is not readable due to file permissions.',
@@ -1208,19 +1208,19 @@  discard block
 block discarded – undo
1208 1208
                 ),
1209 1209
                 $module
1210 1210
             );
1211
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1211
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1212 1212
             return false;
1213 1213
         }
1214 1214
         // load the module class file
1215
-        require_once($module_path . $module_class . $module_ext);
1215
+        require_once($module_path.$module_class.$module_ext);
1216 1216
         // verify that class exists
1217
-        if (! class_exists($module_class)) {
1217
+        if ( ! class_exists($module_class)) {
1218 1218
             $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1219
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1219
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1220 1220
             return false;
1221 1221
         }
1222 1222
         // add to array of registered modules
1223
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1223
+        EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1224 1224
         do_action(
1225 1225
             'AHEE__EE_Config__register_module__complete',
1226 1226
             $module_class,
@@ -1273,26 +1273,26 @@  discard block
 block discarded – undo
1273 1273
     {
1274 1274
         do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1275 1275
         $module = str_replace('EED_', '', $module);
1276
-        $module_class = 'EED_' . $module;
1277
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1276
+        $module_class = 'EED_'.$module;
1277
+        if ( ! isset(EE_Registry::instance()->modules->{$module_class})) {
1278 1278
             $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1279
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1279
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1280 1280
             return false;
1281 1281
         }
1282 1282
         if (empty($route)) {
1283 1283
             $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1284
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1284
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1285 1285
             return false;
1286 1286
         }
1287
-        if (! method_exists('EED_' . $module, $method_name)) {
1287
+        if ( ! method_exists('EED_'.$module, $method_name)) {
1288 1288
             $msg = sprintf(
1289 1289
                 __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1290 1290
                 $route
1291 1291
             );
1292
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1292
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1293 1293
             return false;
1294 1294
         }
1295
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1295
+        EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name);
1296 1296
         return true;
1297 1297
     }
1298 1298
 
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
     public static function get_route($route = null, $key = 'ee')
1310 1310
     {
1311 1311
         do_action('AHEE__EE_Config__get_route__begin', $route);
1312
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1312
+        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1313 1313
         if (isset(EE_Config::$_module_route_map[$key][$route])) {
1314 1314
             return EE_Config::$_module_route_map[$key][$route];
1315 1315
         }
@@ -1345,44 +1345,44 @@  discard block
 block discarded – undo
1345 1345
     public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1346 1346
     {
1347 1347
         do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1348
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1348
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1349 1349
             $msg = sprintf(
1350 1350
                 __('The module route %s for this forward has not been registered.', 'event_espresso'),
1351 1351
                 $route
1352 1352
             );
1353
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1353
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1354 1354
             return false;
1355 1355
         }
1356 1356
         if (empty($forward)) {
1357 1357
             $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1358
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1358
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1359 1359
             return false;
1360 1360
         }
1361 1361
         if (is_array($forward)) {
1362
-            if (! isset($forward[1])) {
1362
+            if ( ! isset($forward[1])) {
1363 1363
                 $msg = sprintf(
1364 1364
                     __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1365 1365
                     $route
1366 1366
                 );
1367
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1367
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1368 1368
                 return false;
1369 1369
             }
1370
-            if (! method_exists($forward[0], $forward[1])) {
1370
+            if ( ! method_exists($forward[0], $forward[1])) {
1371 1371
                 $msg = sprintf(
1372 1372
                     __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1373 1373
                     $forward[1],
1374 1374
                     $route
1375 1375
                 );
1376
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1376
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1377 1377
                 return false;
1378 1378
             }
1379
-        } else if (! function_exists($forward)) {
1379
+        } else if ( ! function_exists($forward)) {
1380 1380
             $msg = sprintf(
1381 1381
                 __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1382 1382
                 $forward,
1383 1383
                 $route
1384 1384
             );
1385
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1385
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1386 1386
             return false;
1387 1387
         }
1388 1388
         EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
@@ -1432,15 +1432,15 @@  discard block
 block discarded – undo
1432 1432
     public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1433 1433
     {
1434 1434
         do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1435
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1435
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1436 1436
             $msg = sprintf(
1437 1437
                 __('The module route %s for this view has not been registered.', 'event_espresso'),
1438 1438
                 $route
1439 1439
             );
1440
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1440
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1441 1441
             return false;
1442 1442
         }
1443
-        if (! is_readable($view)) {
1443
+        if ( ! is_readable($view)) {
1444 1444
             $msg = sprintf(
1445 1445
                 __(
1446 1446
                     'The %s view file could not be found or is not readable due to file permissions.',
@@ -1448,7 +1448,7 @@  discard block
 block discarded – undo
1448 1448
                 ),
1449 1449
                 $view
1450 1450
             );
1451
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1451
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1452 1452
             return false;
1453 1453
         }
1454 1454
         EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
      */
1556 1556
     public function get_pretty($property)
1557 1557
     {
1558
-        if (! property_exists($this, $property)) {
1558
+        if ( ! property_exists($this, $property)) {
1559 1559
             throw new EE_Error(
1560 1560
                 sprintf(
1561 1561
                     __(
@@ -1794,11 +1794,11 @@  discard block
 block discarded – undo
1794 1794
      */
1795 1795
     public function reg_page_url()
1796 1796
     {
1797
-        if (! $this->reg_page_url) {
1797
+        if ( ! $this->reg_page_url) {
1798 1798
             $this->reg_page_url = add_query_arg(
1799 1799
                                       array('uts' => time()),
1800 1800
                                       get_permalink($this->reg_page_id)
1801
-                                  ) . '#checkout';
1801
+                                  ).'#checkout';
1802 1802
         }
1803 1803
         return $this->reg_page_url;
1804 1804
     }
@@ -1815,7 +1815,7 @@  discard block
 block discarded – undo
1815 1815
      */
1816 1816
     public function txn_page_url($query_args = array())
1817 1817
     {
1818
-        if (! $this->txn_page_url) {
1818
+        if ( ! $this->txn_page_url) {
1819 1819
             $this->txn_page_url = get_permalink($this->txn_page_id);
1820 1820
         }
1821 1821
         if ($query_args) {
@@ -1837,7 +1837,7 @@  discard block
 block discarded – undo
1837 1837
      */
1838 1838
     public function thank_you_page_url($query_args = array())
1839 1839
     {
1840
-        if (! $this->thank_you_page_url) {
1840
+        if ( ! $this->thank_you_page_url) {
1841 1841
             $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1842 1842
         }
1843 1843
         if ($query_args) {
@@ -1857,7 +1857,7 @@  discard block
 block discarded – undo
1857 1857
      */
1858 1858
     public function cancel_page_url()
1859 1859
     {
1860
-        if (! $this->cancel_page_url) {
1860
+        if ( ! $this->cancel_page_url) {
1861 1861
             $this->cancel_page_url = get_permalink($this->cancel_page_id);
1862 1862
         }
1863 1863
         return $this->cancel_page_url;
@@ -1902,13 +1902,13 @@  discard block
 block discarded – undo
1902 1902
         $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1903 1903
         $option = 'ee_ueip_optin';
1904 1904
         //set correct table for query
1905
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1905
+        $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1906 1906
         //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1907 1907
         //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1908 1908
         //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1909 1909
         //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1910 1910
         //for the purpose of caching.
1911
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1911
+        $pre = apply_filters('pre_option_'.$option, false, $option);
1912 1912
         if (false !== $pre) {
1913 1913
             EE_Core_Config::$ee_ueip_option = $pre;
1914 1914
             return EE_Core_Config::$ee_ueip_option;
@@ -1918,9 +1918,9 @@  discard block
 block discarded – undo
1918 1918
         if (is_object($row)) {
1919 1919
             $value = $row->option_value;
1920 1920
         } else { //option does not exist so use default.
1921
-            return apply_filters('default_option_' . $option, false, $option);
1921
+            return apply_filters('default_option_'.$option, false, $option);
1922 1922
         }
1923
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1923
+        EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
1924 1924
         return EE_Core_Config::$ee_ueip_option;
1925 1925
     }
1926 1926
 
@@ -2197,27 +2197,27 @@  discard block
 block discarded – undo
2197 2197
             // retrieve the country settings from the db, just in case they have been customized
2198 2198
             $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2199 2199
             if ($country instanceof EE_Country) {
2200
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2201
-                $this->name = $country->currency_name_single();    // Dollar
2202
-                $this->plural = $country->currency_name_plural();    // Dollars
2203
-                $this->sign = $country->currency_sign();            // currency sign: $
2204
-                $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2205
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2206
-                $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2207
-                $this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2200
+                $this->code = $country->currency_code(); // currency code: USD, CAD, EUR
2201
+                $this->name = $country->currency_name_single(); // Dollar
2202
+                $this->plural = $country->currency_name_plural(); // Dollars
2203
+                $this->sign = $country->currency_sign(); // currency sign: $
2204
+                $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE  or  FALSE$
2205
+                $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
2206
+                $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2207
+                $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2208 2208
             }
2209 2209
         }
2210 2210
         // fallback to hardcoded defaults, in case the above failed
2211 2211
         if (empty($this->code)) {
2212 2212
             // set default currency settings
2213
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2214
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2215
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2216
-            $this->sign = '$';    // currency sign: $
2217
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2218
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2219
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2220
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2213
+            $this->code = 'USD'; // currency code: USD, CAD, EUR
2214
+            $this->name = __('Dollar', 'event_espresso'); // Dollar
2215
+            $this->plural = __('Dollars', 'event_espresso'); // Dollars
2216
+            $this->sign = '$'; // currency sign: $
2217
+            $this->sign_b4 = true; // currency sign before or after: $TRUE  or  FALSE$
2218
+            $this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
2219
+            $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2220
+            $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2221 2221
         }
2222 2222
     }
2223 2223
 }
@@ -2541,7 +2541,7 @@  discard block
 block discarded – undo
2541 2541
     public function log_file_name($reset = false)
2542 2542
     {
2543 2543
         if (empty($this->log_file_name) || $reset) {
2544
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2544
+            $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt';
2545 2545
             EE_Config::instance()->update_espresso_config(false, false);
2546 2546
         }
2547 2547
         return $this->log_file_name;
@@ -2556,7 +2556,7 @@  discard block
 block discarded – undo
2556 2556
     public function debug_file_name($reset = false)
2557 2557
     {
2558 2558
         if (empty($this->debug_file_name) || $reset) {
2559
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2559
+            $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt';
2560 2560
             EE_Config::instance()->update_espresso_config(false, false);
2561 2561
         }
2562 2562
         return $this->debug_file_name;
@@ -2773,21 +2773,21 @@  discard block
 block discarded – undo
2773 2773
         $this->use_google_maps = true;
2774 2774
         $this->google_map_api_key = '';
2775 2775
         // for event details pages (reg page)
2776
-        $this->event_details_map_width = 585;            // ee_map_width_single
2777
-        $this->event_details_map_height = 362;            // ee_map_height_single
2778
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2779
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2780
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2781
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2782
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2776
+        $this->event_details_map_width = 585; // ee_map_width_single
2777
+        $this->event_details_map_height = 362; // ee_map_height_single
2778
+        $this->event_details_map_zoom = 14; // ee_map_zoom_single
2779
+        $this->event_details_display_nav = true; // ee_map_nav_display_single
2780
+        $this->event_details_nav_size = false; // ee_map_nav_size_single
2781
+        $this->event_details_control_type = 'default'; // ee_map_type_control_single
2782
+        $this->event_details_map_align = 'center'; // ee_map_align_single
2783 2783
         // for event list pages
2784
-        $this->event_list_map_width = 300;            // ee_map_width
2785
-        $this->event_list_map_height = 185;        // ee_map_height
2786
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2787
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2788
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2789
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2790
-        $this->event_list_map_align = 'center';            // ee_map_align
2784
+        $this->event_list_map_width = 300; // ee_map_width
2785
+        $this->event_list_map_height = 185; // ee_map_height
2786
+        $this->event_list_map_zoom = 12; // ee_map_zoom
2787
+        $this->event_list_display_nav = false; // ee_map_nav_display
2788
+        $this->event_list_nav_size = true; // ee_map_nav_size
2789
+        $this->event_list_control_type = 'dropdown'; // ee_map_type_control
2790
+        $this->event_list_map_align = 'center'; // ee_map_align
2791 2791
     }
2792 2792
 
2793 2793
 }
@@ -3102,7 +3102,7 @@  discard block
 block discarded – undo
3102 3102
      */
3103 3103
     public function max_input_vars_limit_check($input_count = 0)
3104 3104
     {
3105
-        if (! empty($this->php->max_input_vars)
3105
+        if ( ! empty($this->php->max_input_vars)
3106 3106
             && ($input_count >= $this->php->max_input_vars)
3107 3107
             && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3108 3108
         ) {
Please login to merge, or discard this patch.
Indentation   +3062 added lines, -3062 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\services\shortcodes\LegacyShortcodesManager;
2 2
 
3 3
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('No direct script access allowed');
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 
@@ -16,2443 +16,2443 @@  discard block
 block discarded – undo
16 16
 final class EE_Config
17 17
 {
18 18
 
19
-    const OPTION_NAME        = 'ee_config';
19
+	const OPTION_NAME        = 'ee_config';
20
+
21
+	const LOG_NAME           = 'ee_config_log';
22
+
23
+	const LOG_LENGTH         = 100;
24
+
25
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
26
+
27
+
28
+	/**
29
+	 *    instance of the EE_Config object
30
+	 *
31
+	 * @var    EE_Config $_instance
32
+	 * @access    private
33
+	 */
34
+	private static $_instance;
35
+
36
+	/**
37
+	 * @var boolean $_logging_enabled
38
+	 */
39
+	private static $_logging_enabled = false;
40
+
41
+	/**
42
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
43
+	 */
44
+	private $legacy_shortcodes_manager;
45
+
46
+	/**
47
+	 * An StdClass whose property names are addon slugs,
48
+	 * and values are their config classes
49
+	 *
50
+	 * @var StdClass
51
+	 */
52
+	public $addons;
53
+
54
+	/**
55
+	 * @var EE_Admin_Config
56
+	 */
57
+	public $admin;
58
+
59
+	/**
60
+	 * @var EE_Core_Config
61
+	 */
62
+	public $core;
63
+
64
+	/**
65
+	 * @var EE_Currency_Config
66
+	 */
67
+	public $currency;
68
+
69
+	/**
70
+	 * @var EE_Organization_Config
71
+	 */
72
+	public $organization;
73
+
74
+	/**
75
+	 * @var EE_Registration_Config
76
+	 */
77
+	public $registration;
78
+
79
+	/**
80
+	 * @var EE_Template_Config
81
+	 */
82
+	public $template_settings;
83
+
84
+	/**
85
+	 * Holds EE environment values.
86
+	 *
87
+	 * @var EE_Environment_Config
88
+	 */
89
+	public $environment;
90
+
91
+	/**
92
+	 * settings pertaining to Google maps
93
+	 *
94
+	 * @var EE_Map_Config
95
+	 */
96
+	public $map_settings;
97
+
98
+	/**
99
+	 * settings pertaining to Taxes
100
+	 *
101
+	 * @var EE_Tax_Config
102
+	 */
103
+	public $tax_settings;
104
+
105
+
106
+	/**
107
+	 * Settings pertaining to global messages settings.
108
+	 *
109
+	 * @var EE_Messages_Config
110
+	 */
111
+	public $messages;
112
+
113
+	/**
114
+	 * @deprecated
115
+	 * @var EE_Gateway_Config
116
+	 */
117
+	public $gateway;
118
+
119
+	/**
120
+	 * @var    array $_addon_option_names
121
+	 * @access    private
122
+	 */
123
+	private $_addon_option_names = array();
124
+
125
+	/**
126
+	 * @var    array $_module_route_map
127
+	 * @access    private
128
+	 */
129
+	private static $_module_route_map = array();
130
+
131
+	/**
132
+	 * @var    array $_module_forward_map
133
+	 * @access    private
134
+	 */
135
+	private static $_module_forward_map = array();
136
+
137
+	/**
138
+	 * @var    array $_module_view_map
139
+	 * @access    private
140
+	 */
141
+	private static $_module_view_map = array();
142
+
143
+
144
+
145
+	/**
146
+	 * @singleton method used to instantiate class object
147
+	 * @access    public
148
+	 * @return EE_Config instance
149
+	 */
150
+	public static function instance()
151
+	{
152
+		// check if class object is instantiated, and instantiated properly
153
+		if (! self::$_instance instanceof EE_Config) {
154
+			self::$_instance = new self();
155
+		}
156
+		return self::$_instance;
157
+	}
158
+
159
+
160
+
161
+	/**
162
+	 * Resets the config
163
+	 *
164
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
165
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
166
+	 *                               reflect its state in the database
167
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
168
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
169
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
170
+	 *                               site was put into maintenance mode)
171
+	 * @return EE_Config
172
+	 */
173
+	public static function reset($hard_reset = false, $reinstantiate = true)
174
+	{
175
+		if (self::$_instance instanceof EE_Config) {
176
+			if ($hard_reset) {
177
+				self::$_instance->legacy_shortcodes_manager = null;
178
+				self::$_instance->_addon_option_names = array();
179
+				self::$_instance->_initialize_config();
180
+				self::$_instance->update_espresso_config();
181
+			}
182
+			self::$_instance->update_addon_option_names();
183
+		}
184
+		self::$_instance = null;
185
+		//we don't need to reset the static properties imo because those should
186
+		//only change when a module is added or removed. Currently we don't
187
+		//support removing a module during a request when it previously existed
188
+		if ($reinstantiate) {
189
+			return self::instance();
190
+		} else {
191
+			return null;
192
+		}
193
+	}
194
+
195
+
196
+
197
+	/**
198
+	 *    class constructor
199
+	 *
200
+	 * @access    private
201
+	 */
202
+	private function __construct()
203
+	{
204
+		do_action('AHEE__EE_Config__construct__begin', $this);
205
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
206
+		// setup empty config classes
207
+		$this->_initialize_config();
208
+		// load existing EE site settings
209
+		$this->_load_core_config();
210
+		// confirm everything loaded correctly and set filtered defaults if not
211
+		$this->_verify_config();
212
+		//  register shortcodes and modules
213
+		add_action(
214
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
215
+			array($this, 'register_shortcodes_and_modules'),
216
+			999
217
+		);
218
+		//  initialize shortcodes and modules
219
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
220
+		// register widgets
221
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
222
+		// shutdown
223
+		add_action('shutdown', array($this, 'shutdown'), 10);
224
+		// construct__end hook
225
+		do_action('AHEE__EE_Config__construct__end', $this);
226
+		// hardcoded hack
227
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
228
+	}
229
+
230
+
231
+
232
+	/**
233
+	 * @return boolean
234
+	 */
235
+	public static function logging_enabled()
236
+	{
237
+		return self::$_logging_enabled;
238
+	}
239
+
240
+
241
+
242
+	/**
243
+	 * use to get the current theme if needed from static context
244
+	 *
245
+	 * @return string current theme set.
246
+	 */
247
+	public static function get_current_theme()
248
+	{
249
+		return isset(self::$_instance->template_settings->current_espresso_theme)
250
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
251
+	}
252
+
253
+
254
+
255
+	/**
256
+	 *        _initialize_config
257
+	 *
258
+	 * @access private
259
+	 * @return void
260
+	 */
261
+	private function _initialize_config()
262
+	{
263
+		EE_Config::trim_log();
264
+		//set defaults
265
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
266
+		$this->addons = new stdClass();
267
+		// set _module_route_map
268
+		EE_Config::$_module_route_map = array();
269
+		// set _module_forward_map
270
+		EE_Config::$_module_forward_map = array();
271
+		// set _module_view_map
272
+		EE_Config::$_module_view_map = array();
273
+	}
274
+
275
+
276
+
277
+	/**
278
+	 *        load core plugin configuration
279
+	 *
280
+	 * @access private
281
+	 * @return void
282
+	 */
283
+	private function _load_core_config()
284
+	{
285
+		// load_core_config__start hook
286
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
287
+		$espresso_config = $this->get_espresso_config();
288
+		foreach ($espresso_config as $config => $settings) {
289
+			// load_core_config__start hook
290
+			$settings = apply_filters(
291
+				'FHEE__EE_Config___load_core_config__config_settings',
292
+				$settings,
293
+				$config,
294
+				$this
295
+			);
296
+			if (is_object($settings) && property_exists($this, $config)) {
297
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
298
+				//call configs populate method to ensure any defaults are set for empty values.
299
+				if (method_exists($settings, 'populate')) {
300
+					$this->{$config}->populate();
301
+				}
302
+				if (method_exists($settings, 'do_hooks')) {
303
+					$this->{$config}->do_hooks();
304
+				}
305
+			}
306
+		}
307
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
308
+			$this->update_espresso_config();
309
+		}
310
+		// load_core_config__end hook
311
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
312
+	}
313
+
314
+
315
+
316
+	/**
317
+	 *    _verify_config
318
+	 *
319
+	 * @access    protected
320
+	 * @return    void
321
+	 */
322
+	protected function _verify_config()
323
+	{
324
+		$this->core = $this->core instanceof EE_Core_Config
325
+			? $this->core
326
+			: new EE_Core_Config();
327
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
328
+		$this->organization = $this->organization instanceof EE_Organization_Config
329
+			? $this->organization
330
+			: new EE_Organization_Config();
331
+		$this->organization = apply_filters(
332
+			'FHEE__EE_Config___initialize_config__organization',
333
+			$this->organization
334
+		);
335
+		$this->currency = $this->currency instanceof EE_Currency_Config
336
+			? $this->currency
337
+			: new EE_Currency_Config();
338
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
339
+		$this->registration = $this->registration instanceof EE_Registration_Config
340
+			? $this->registration
341
+			: new EE_Registration_Config();
342
+		$this->registration = apply_filters(
343
+			'FHEE__EE_Config___initialize_config__registration',
344
+			$this->registration
345
+		);
346
+		$this->admin = $this->admin instanceof EE_Admin_Config
347
+			? $this->admin
348
+			: new EE_Admin_Config();
349
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
350
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
351
+			? $this->template_settings
352
+			: new EE_Template_Config();
353
+		$this->template_settings = apply_filters(
354
+			'FHEE__EE_Config___initialize_config__template_settings',
355
+			$this->template_settings
356
+		);
357
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
358
+			? $this->map_settings
359
+			: new EE_Map_Config();
360
+		$this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
361
+			$this->map_settings);
362
+		$this->environment = $this->environment instanceof EE_Environment_Config
363
+			? $this->environment
364
+			: new EE_Environment_Config();
365
+		$this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
366
+			$this->environment);
367
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
368
+			? $this->tax_settings
369
+			: new EE_Tax_Config();
370
+		$this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
371
+			$this->tax_settings);
372
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
373
+		$this->messages = $this->messages instanceof EE_Messages_Config
374
+			? $this->messages
375
+			: new EE_Messages_Config();
376
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
377
+			? $this->gateway
378
+			: new EE_Gateway_Config();
379
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
380
+		$this->legacy_shortcodes_manager = null;
381
+	}
382
+
383
+
384
+	/**
385
+	 *    get_espresso_config
386
+	 *
387
+	 * @access    public
388
+	 * @return    array of espresso config stuff
389
+	 */
390
+	public function get_espresso_config()
391
+	{
392
+		// grab espresso configuration
393
+		return apply_filters(
394
+			'FHEE__EE_Config__get_espresso_config__CFG',
395
+			get_option(EE_Config::OPTION_NAME, array())
396
+		);
397
+	}
398
+
399
+
400
+
401
+	/**
402
+	 *    double_check_config_comparison
403
+	 *
404
+	 * @access    public
405
+	 * @param string $option
406
+	 * @param        $old_value
407
+	 * @param        $value
408
+	 */
409
+	public function double_check_config_comparison($option = '', $old_value, $value)
410
+	{
411
+		// make sure we're checking the ee config
412
+		if ($option === EE_Config::OPTION_NAME) {
413
+			// run a loose comparison of the old value against the new value for type and properties,
414
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
415
+			if ($value != $old_value) {
416
+				// if they are NOT the same, then remove the hook,
417
+				// which means the subsequent update results will be based solely on the update query results
418
+				// the reason we do this is because, as stated above,
419
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
420
+				// this happens PRIOR to serialization and any subsequent update.
421
+				// If values are found to match their previous old value,
422
+				// then WP bails before performing any update.
423
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
424
+				// it just pulled from the db, with the one being passed to it (which will not match).
425
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
426
+				// MySQL MAY ALSO NOT perform the update because
427
+				// the string it sees in the db looks the same as the new one it has been passed!!!
428
+				// This results in the query returning an "affected rows" value of ZERO,
429
+				// which gets returned immediately by WP update_option and looks like an error.
430
+				remove_action('update_option', array($this, 'check_config_updated'));
431
+			}
432
+		}
433
+	}
434
+
435
+
436
+
437
+	/**
438
+	 *    update_espresso_config
439
+	 *
440
+	 * @access   public
441
+	 */
442
+	protected function _reset_espresso_addon_config()
443
+	{
444
+		$this->_addon_option_names = array();
445
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
446
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
447
+			$config_class = get_class($addon_config_obj);
448
+			if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
449
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
450
+			}
451
+			$this->addons->{$addon_name} = null;
452
+		}
453
+	}
454
+
455
+
456
+
457
+	/**
458
+	 *    update_espresso_config
459
+	 *
460
+	 * @access   public
461
+	 * @param   bool $add_success
462
+	 * @param   bool $add_error
463
+	 * @return   bool
464
+	 */
465
+	public function update_espresso_config($add_success = false, $add_error = true)
466
+	{
467
+		// don't allow config updates during WP heartbeats
468
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
+			return false;
470
+		}
471
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
+		//$clone = clone( self::$_instance );
473
+		//self::$_instance = NULL;
474
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
+		$this->_reset_espresso_addon_config();
476
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
+		// but BEFORE the actual update occurs
478
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
+		$this->legacy_shortcodes_manager = null;
482
+		// now update "ee_config"
483
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
484
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
+		EE_Config::log(EE_Config::OPTION_NAME);
486
+		// if not saved... check if the hook we just added still exists;
487
+		// if it does, it means one of two things:
488
+		// 		that update_option bailed at the ( $value === $old_value ) conditional,
489
+		//		 or...
490
+		// 		the db update query returned 0 rows affected
491
+		// 		(probably because the data  value was the same from it's perspective)
492
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
493
+		// but just means no update occurred, so don't display an error to the user.
494
+		// BUT... if update_option returns FALSE, AND the hook is missing,
495
+		// then it means that something truly went wrong
496
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
+		// remove our action since we don't want it in the system anymore
498
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
+		//self::$_instance = $clone;
501
+		//unset( $clone );
502
+		// if config remains the same or was updated successfully
503
+		if ($saved) {
504
+			if ($add_success) {
505
+				EE_Error::add_success(
506
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
+					__FILE__,
508
+					__FUNCTION__,
509
+					__LINE__
510
+				);
511
+			}
512
+			return true;
513
+		} else {
514
+			if ($add_error) {
515
+				EE_Error::add_error(
516
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
+					__FILE__,
518
+					__FUNCTION__,
519
+					__LINE__
520
+				);
521
+			}
522
+			return false;
523
+		}
524
+	}
525
+
526
+
527
+
528
+	/**
529
+	 *    _verify_config_params
530
+	 *
531
+	 * @access    private
532
+	 * @param    string         $section
533
+	 * @param    string         $name
534
+	 * @param    string         $config_class
535
+	 * @param    EE_Config_Base $config_obj
536
+	 * @param    array          $tests_to_run
537
+	 * @param    bool           $display_errors
538
+	 * @return    bool    TRUE on success, FALSE on fail
539
+	 */
540
+	private function _verify_config_params(
541
+		$section = '',
542
+		$name = '',
543
+		$config_class = '',
544
+		$config_obj = null,
545
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
+		$display_errors = true
547
+	) {
548
+		try {
549
+			foreach ($tests_to_run as $test) {
550
+				switch ($test) {
551
+					// TEST #1 : check that section was set
552
+					case 1 :
553
+						if (empty($section)) {
554
+							if ($display_errors) {
555
+								throw new EE_Error(
556
+									sprintf(
557
+										__(
558
+											'No configuration section has been provided while attempting to save "%s".',
559
+											'event_espresso'
560
+										),
561
+										$config_class
562
+									)
563
+								);
564
+							}
565
+							return false;
566
+						}
567
+						break;
568
+					// TEST #2 : check that settings section exists
569
+					case 2 :
570
+						if (! isset($this->{$section})) {
571
+							if ($display_errors) {
572
+								throw new EE_Error(
573
+									sprintf(
574
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
575
+										$section
576
+									)
577
+								);
578
+							}
579
+							return false;
580
+						}
581
+						break;
582
+					// TEST #3 : check that section is the proper format
583
+					case 3 :
584
+						if (
585
+						! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
+						) {
587
+							if ($display_errors) {
588
+								throw new EE_Error(
589
+									sprintf(
590
+										__(
591
+											'The "%s" configuration settings have not been formatted correctly.',
592
+											'event_espresso'
593
+										),
594
+										$section
595
+									)
596
+								);
597
+							}
598
+							return false;
599
+						}
600
+						break;
601
+					// TEST #4 : check that config section name has been set
602
+					case 4 :
603
+						if (empty($name)) {
604
+							if ($display_errors) {
605
+								throw new EE_Error(
606
+									__(
607
+										'No name has been provided for the specific configuration section.',
608
+										'event_espresso'
609
+									)
610
+								);
611
+							}
612
+							return false;
613
+						}
614
+						break;
615
+					// TEST #5 : check that a config class name has been set
616
+					case 5 :
617
+						if (empty($config_class)) {
618
+							if ($display_errors) {
619
+								throw new EE_Error(
620
+									__(
621
+										'No class name has been provided for the specific configuration section.',
622
+										'event_espresso'
623
+									)
624
+								);
625
+							}
626
+							return false;
627
+						}
628
+						break;
629
+					// TEST #6 : verify config class is accessible
630
+					case 6 :
631
+						if (! class_exists($config_class)) {
632
+							if ($display_errors) {
633
+								throw new EE_Error(
634
+									sprintf(
635
+										__(
636
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
+											'event_espresso'
638
+										),
639
+										$config_class
640
+									)
641
+								);
642
+							}
643
+							return false;
644
+						}
645
+						break;
646
+					// TEST #7 : check that config has even been set
647
+					case 7 :
648
+						if (! isset($this->{$section}->{$name})) {
649
+							if ($display_errors) {
650
+								throw new EE_Error(
651
+									sprintf(
652
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
+										$section,
654
+										$name
655
+									)
656
+								);
657
+							}
658
+							return false;
659
+						} else {
660
+							// and make sure it's not serialized
661
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
+						}
663
+						break;
664
+					// TEST #8 : check that config is the requested type
665
+					case 8 :
666
+						if (! $this->{$section}->{$name} instanceof $config_class) {
667
+							if ($display_errors) {
668
+								throw new EE_Error(
669
+									sprintf(
670
+										__(
671
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
+											'event_espresso'
673
+										),
674
+										$section,
675
+										$name,
676
+										$config_class
677
+									)
678
+								);
679
+							}
680
+							return false;
681
+						}
682
+						break;
683
+					// TEST #9 : verify config object
684
+					case 9 :
685
+						if (! $config_obj instanceof EE_Config_Base) {
686
+							if ($display_errors) {
687
+								throw new EE_Error(
688
+									sprintf(
689
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
+										print_r($config_obj, true)
691
+									)
692
+								);
693
+							}
694
+							return false;
695
+						}
696
+						break;
697
+				}
698
+			}
699
+		} catch (EE_Error $e) {
700
+			$e->get_error();
701
+		}
702
+		// you have successfully run the gauntlet
703
+		return true;
704
+	}
705
+
706
+
707
+
708
+	/**
709
+	 *    _generate_config_option_name
710
+	 *
711
+	 * @access        protected
712
+	 * @param        string $section
713
+	 * @param        string $name
714
+	 * @return        string
715
+	 */
716
+	private function _generate_config_option_name($section = '', $name = '')
717
+	{
718
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
+	}
720
+
721
+
722
+
723
+	/**
724
+	 *    _set_config_class
725
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
726
+	 *
727
+	 * @access    private
728
+	 * @param    string $config_class
729
+	 * @param    string $name
730
+	 * @return    string
731
+	 */
732
+	private function _set_config_class($config_class = '', $name = '')
733
+	{
734
+		return ! empty($config_class)
735
+			? $config_class
736
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
+	}
738
+
739
+
740
+
741
+	/**
742
+	 *    set_config
743
+	 *
744
+	 * @access    protected
745
+	 * @param    string         $section
746
+	 * @param    string         $name
747
+	 * @param    string         $config_class
748
+	 * @param    EE_Config_Base $config_obj
749
+	 * @return    EE_Config_Base
750
+	 */
751
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
+	{
753
+		// ensure config class is set to something
754
+		$config_class = $this->_set_config_class($config_class, $name);
755
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
756
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
+			return null;
758
+		}
759
+		$config_option_name = $this->_generate_config_option_name($section, $name);
760
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
+		if (! isset($this->_addon_option_names[$config_option_name])) {
762
+			$this->_addon_option_names[$config_option_name] = $config_class;
763
+			$this->update_addon_option_names();
764
+		}
765
+		// verify the incoming config object but suppress errors
766
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
+			$config_obj = new $config_class();
768
+		}
769
+		if (get_option($config_option_name)) {
770
+			EE_Config::log($config_option_name);
771
+			update_option($config_option_name, $config_obj);
772
+			$this->{$section}->{$name} = $config_obj;
773
+			return $this->{$section}->{$name};
774
+		} else {
775
+			// create a wp-option for this config
776
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
777
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
778
+				return $this->{$section}->{$name};
779
+			} else {
780
+				EE_Error::add_error(
781
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
+					__FILE__,
783
+					__FUNCTION__,
784
+					__LINE__
785
+				);
786
+				return null;
787
+			}
788
+		}
789
+	}
790
+
791
+
792
+
793
+	/**
794
+	 *    update_config
795
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
+	 *
797
+	 * @access    public
798
+	 * @param    string                $section
799
+	 * @param    string                $name
800
+	 * @param    EE_Config_Base|string $config_obj
801
+	 * @param    bool                  $throw_errors
802
+	 * @return    bool
803
+	 */
804
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
+	{
806
+		// don't allow config updates during WP heartbeats
807
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
+			return false;
809
+		}
810
+		$config_obj = maybe_unserialize($config_obj);
811
+		// get class name of the incoming object
812
+		$config_class = get_class($config_obj);
813
+		// run tests 1-5 and 9 to verify config
814
+		if (! $this->_verify_config_params(
815
+			$section,
816
+			$name,
817
+			$config_class,
818
+			$config_obj,
819
+			array(1, 2, 3, 4, 7, 9)
820
+		)
821
+		) {
822
+			return false;
823
+		}
824
+		$config_option_name = $this->_generate_config_option_name($section, $name);
825
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
+		if (! isset($this->_addon_option_names[$config_option_name])) {
827
+			// save new config to db
828
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
+				return true;
830
+			}
831
+		} else {
832
+			// first check if the record already exists
833
+			$existing_config = get_option($config_option_name);
834
+			$config_obj = serialize($config_obj);
835
+			// just return if db record is already up to date (NOT type safe comparison)
836
+			if ($existing_config == $config_obj) {
837
+				$this->{$section}->{$name} = $config_obj;
838
+				return true;
839
+			} else if (update_option($config_option_name, $config_obj)) {
840
+				EE_Config::log($config_option_name);
841
+				// update wp-option for this config class
842
+				$this->{$section}->{$name} = $config_obj;
843
+				return true;
844
+			} elseif ($throw_errors) {
845
+				EE_Error::add_error(
846
+					sprintf(
847
+						__(
848
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
+							'event_espresso'
850
+						),
851
+						$config_class,
852
+						'EE_Config->' . $section . '->' . $name
853
+					),
854
+					__FILE__,
855
+					__FUNCTION__,
856
+					__LINE__
857
+				);
858
+			}
859
+		}
860
+		return false;
861
+	}
862
+
863
+
864
+
865
+	/**
866
+	 *    get_config
867
+	 *
868
+	 * @access    public
869
+	 * @param    string $section
870
+	 * @param    string $name
871
+	 * @param    string $config_class
872
+	 * @return    mixed EE_Config_Base | NULL
873
+	 */
874
+	public function get_config($section = '', $name = '', $config_class = '')
875
+	{
876
+		// ensure config class is set to something
877
+		$config_class = $this->_set_config_class($config_class, $name);
878
+		// run tests 1-4, 6 and 7 to verify that all params have been set
879
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
+			return null;
881
+		}
882
+		// now test if the requested config object exists, but suppress errors
883
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
+			// config already exists, so pass it back
885
+			return $this->{$section}->{$name};
886
+		}
887
+		// load config option from db if it exists
888
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
+		// verify the newly retrieved config object, but suppress errors
890
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
+			// config is good, so set it and pass it back
892
+			$this->{$section}->{$name} = $config_obj;
893
+			return $this->{$section}->{$name};
894
+		}
895
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
896
+		$config_obj = $this->set_config($section, $name, $config_class);
897
+		// verify the newly created config object
898
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
+			return $this->{$section}->{$name};
900
+		} else {
901
+			EE_Error::add_error(
902
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
+				__FILE__,
904
+				__FUNCTION__,
905
+				__LINE__
906
+			);
907
+		}
908
+		return null;
909
+	}
910
+
911
+
912
+
913
+	/**
914
+	 *    get_config_option
915
+	 *
916
+	 * @access    public
917
+	 * @param    string $config_option_name
918
+	 * @return    mixed EE_Config_Base | FALSE
919
+	 */
920
+	public function get_config_option($config_option_name = '')
921
+	{
922
+		// retrieve the wp-option for this config class.
923
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
924
+		if (empty($config_option)) {
925
+			EE_Config::log($config_option_name . '-NOT-FOUND');
926
+		}
927
+		return $config_option;
928
+	}
929
+
930
+
931
+
932
+	/**
933
+	 * log
934
+	 *
935
+	 * @param string $config_option_name
936
+	 */
937
+	public static function log($config_option_name = '')
938
+	{
939
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
+			$config_log = get_option(EE_Config::LOG_NAME, array());
941
+			//copy incoming $_REQUEST and sanitize it so we can save it
942
+			$_request = $_REQUEST;
943
+			array_walk_recursive($_request, 'sanitize_text_field');
944
+			$config_log[(string)microtime(true)] = array(
945
+				'config_name' => $config_option_name,
946
+				'request'     => $_request,
947
+			);
948
+			update_option(EE_Config::LOG_NAME, $config_log);
949
+		}
950
+	}
951
+
952
+
953
+
954
+	/**
955
+	 * trim_log
956
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
+	 */
958
+	public static function trim_log()
959
+	{
960
+		if (! EE_Config::logging_enabled()) {
961
+			return;
962
+		}
963
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
+		$log_length = count($config_log);
965
+		if ($log_length > EE_Config::LOG_LENGTH) {
966
+			ksort($config_log);
967
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
+			update_option(EE_Config::LOG_NAME, $config_log);
969
+		}
970
+	}
971
+
972
+
973
+
974
+	/**
975
+	 *    get_page_for_posts
976
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
978
+	 *
979
+	 * @access    public
980
+	 * @return    string
981
+	 */
982
+	public static function get_page_for_posts()
983
+	{
984
+		$page_for_posts = get_option('page_for_posts');
985
+		if (! $page_for_posts) {
986
+			return 'posts';
987
+		}
988
+		/** @type WPDB $wpdb */
989
+		global $wpdb;
990
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
+	}
993
+
994
+
995
+
996
+	/**
997
+	 *    register_shortcodes_and_modules.
998
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
999
+	 *    In fact, this is where we give modules a chance to let core know they exist
1000
+	 *    so they can help trigger maintenance mode if it's needed
1001
+	 *
1002
+	 * @access    public
1003
+	 * @return    void
1004
+	 */
1005
+	public function register_shortcodes_and_modules()
1006
+	{
1007
+		// allow modules to set hooks for the rest of the system
1008
+		EE_Registry::instance()->modules = $this->_register_modules();
1009
+	}
1010
+
1011
+
1012
+
1013
+	/**
1014
+	 *    initialize_shortcodes_and_modules
1015
+	 *    meaning they can start adding their hooks to get stuff done
1016
+	 *
1017
+	 * @access    public
1018
+	 * @return    void
1019
+	 */
1020
+	public function initialize_shortcodes_and_modules()
1021
+	{
1022
+		// allow modules to set hooks for the rest of the system
1023
+		$this->_initialize_modules();
1024
+	}
1025
+
1026
+
1027
+
1028
+	/**
1029
+	 *    widgets_init
1030
+	 *
1031
+	 * @access private
1032
+	 * @return void
1033
+	 */
1034
+	public function widgets_init()
1035
+	{
1036
+		//only init widgets on admin pages when not in complete maintenance, and
1037
+		//on frontend when not in any maintenance mode
1038
+		if (
1039
+			! EE_Maintenance_Mode::instance()->level()
1040
+			|| (
1041
+				is_admin()
1042
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
+			)
1044
+		) {
1045
+			// grab list of installed widgets
1046
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
+			// filter list of modules to register
1048
+			$widgets_to_register = apply_filters(
1049
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
+				$widgets_to_register
1051
+			);
1052
+			if (! empty($widgets_to_register)) {
1053
+				// cycle thru widget folders
1054
+				foreach ($widgets_to_register as $widget_path) {
1055
+					// add to list of installed widget modules
1056
+					EE_Config::register_ee_widget($widget_path);
1057
+				}
1058
+			}
1059
+			// filter list of installed modules
1060
+			EE_Registry::instance()->widgets = apply_filters(
1061
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1062
+				EE_Registry::instance()->widgets
1063
+			);
1064
+		}
1065
+	}
1066
+
1067
+
1068
+
1069
+	/**
1070
+	 *    register_ee_widget - makes core aware of this widget
1071
+	 *
1072
+	 * @access    public
1073
+	 * @param    string $widget_path - full path up to and including widget folder
1074
+	 * @return    void
1075
+	 */
1076
+	public static function register_ee_widget($widget_path = null)
1077
+	{
1078
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
+		$widget_ext = '.widget.php';
1080
+		// make all separators match
1081
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
+		// does the file path INCLUDE the actual file name as part of the path ?
1083
+		if (strpos($widget_path, $widget_ext) !== false) {
1084
+			// grab and shortcode file name from directory name and break apart at dots
1085
+			$file_name = explode('.', basename($widget_path));
1086
+			// take first segment from file name pieces and remove class prefix if it exists
1087
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
+			// sanitize shortcode directory name
1089
+			$widget = sanitize_key($widget);
1090
+			// now we need to rebuild the shortcode path
1091
+			$widget_path = explode(DS, $widget_path);
1092
+			// remove last segment
1093
+			array_pop($widget_path);
1094
+			// glue it back together
1095
+			$widget_path = implode(DS, $widget_path);
1096
+		} else {
1097
+			// grab and sanitize widget directory name
1098
+			$widget = sanitize_key(basename($widget_path));
1099
+		}
1100
+		// create classname from widget directory name
1101
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
+		// add class prefix
1103
+		$widget_class = 'EEW_' . $widget;
1104
+		// does the widget exist ?
1105
+		if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
+			$msg = sprintf(
1107
+				__(
1108
+					'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',
1109
+					'event_espresso'
1110
+				),
1111
+				$widget_class,
1112
+				$widget_path . DS . $widget_class . $widget_ext
1113
+			);
1114
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
+			return;
1116
+		}
1117
+		// load the widget class file
1118
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1119
+		// verify that class exists
1120
+		if (! class_exists($widget_class)) {
1121
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
+			return;
1124
+		}
1125
+		register_widget($widget_class);
1126
+		// add to array of registered widgets
1127
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
+	}
1129
+
1130
+
1131
+
1132
+	/**
1133
+	 *        _register_modules
1134
+	 *
1135
+	 * @access private
1136
+	 * @return array
1137
+	 */
1138
+	private function _register_modules()
1139
+	{
1140
+		// grab list of installed modules
1141
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
+		// filter list of modules to register
1143
+		$modules_to_register = apply_filters(
1144
+			'FHEE__EE_Config__register_modules__modules_to_register',
1145
+			$modules_to_register
1146
+		);
1147
+		if (! empty($modules_to_register)) {
1148
+			// loop through folders
1149
+			foreach ($modules_to_register as $module_path) {
1150
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
+				if (
1152
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
+					&& $module_path !== EE_MODULES . 'gateways'
1154
+				) {
1155
+					// add to list of installed modules
1156
+					EE_Config::register_module($module_path);
1157
+				}
1158
+			}
1159
+		}
1160
+		// filter list of installed modules
1161
+		return apply_filters(
1162
+			'FHEE__EE_Config___register_modules__installed_modules',
1163
+			EE_Registry::instance()->modules
1164
+		);
1165
+	}
1166
+
1167
+
1168
+
1169
+	/**
1170
+	 *    register_module - makes core aware of this module
1171
+	 *
1172
+	 * @access    public
1173
+	 * @param    string $module_path - full path up to and including module folder
1174
+	 * @return    bool
1175
+	 */
1176
+	public static function register_module($module_path = null)
1177
+	{
1178
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
+		$module_ext = '.module.php';
1180
+		// make all separators match
1181
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
+		// does the file path INCLUDE the actual file name as part of the path ?
1183
+		if (strpos($module_path, $module_ext) !== false) {
1184
+			// grab and shortcode file name from directory name and break apart at dots
1185
+			$module_file = explode('.', basename($module_path));
1186
+			// now we need to rebuild the shortcode path
1187
+			$module_path = explode(DS, $module_path);
1188
+			// remove last segment
1189
+			array_pop($module_path);
1190
+			// glue it back together
1191
+			$module_path = implode(DS, $module_path) . DS;
1192
+			// take first segment from file name pieces and sanitize it
1193
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
+			// ensure class prefix is added
1195
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
+		} else {
1197
+			// we need to generate the filename based off of the folder name
1198
+			// grab and sanitize module name
1199
+			$module = strtolower(basename($module_path));
1200
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
+			// like trailingslashit()
1202
+			$module_path = rtrim($module_path, DS) . DS;
1203
+			// create classname from module directory name
1204
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
+			// add class prefix
1206
+			$module_class = 'EED_' . $module;
1207
+		}
1208
+		// does the module exist ?
1209
+		if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
+			$msg = sprintf(
1211
+				__(
1212
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1213
+					'event_espresso'
1214
+				),
1215
+				$module
1216
+			);
1217
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
+			return false;
1219
+		}
1220
+		// load the module class file
1221
+		require_once($module_path . $module_class . $module_ext);
1222
+		// verify that class exists
1223
+		if (! class_exists($module_class)) {
1224
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
+			return false;
1227
+		}
1228
+		// add to array of registered modules
1229
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
+		do_action(
1231
+			'AHEE__EE_Config__register_module__complete',
1232
+			$module_class,
1233
+			EE_Registry::instance()->modules->{$module_class}
1234
+		);
1235
+		return true;
1236
+	}
1237
+
1238
+
1239
+
1240
+	/**
1241
+	 *    _initialize_modules
1242
+	 *    allow modules to set hooks for the rest of the system
1243
+	 *
1244
+	 * @access private
1245
+	 * @return void
1246
+	 */
1247
+	private function _initialize_modules()
1248
+	{
1249
+		// cycle thru shortcode folders
1250
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
+			// which set hooks ?
1253
+			if (is_admin()) {
1254
+				// fire immediately
1255
+				call_user_func(array($module_class, 'set_hooks_admin'));
1256
+			} else {
1257
+				// delay until other systems are online
1258
+				add_action(
1259
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
+					array($module_class, 'set_hooks')
1261
+				);
1262
+			}
1263
+		}
1264
+	}
1265
+
1266
+
1267
+
1268
+	/**
1269
+	 *    register_route - adds module method routes to route_map
1270
+	 *
1271
+	 * @access    public
1272
+	 * @param    string $route       - "pretty" public alias for module method
1273
+	 * @param    string $module      - module name (classname without EED_ prefix)
1274
+	 * @param    string $method_name - the actual module method to be routed to
1275
+	 * @param    string $key         - url param key indicating a route is being called
1276
+	 * @return    bool
1277
+	 */
1278
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
+	{
1280
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
+		$module = str_replace('EED_', '', $module);
1282
+		$module_class = 'EED_' . $module;
1283
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
+			return false;
1287
+		}
1288
+		if (empty($route)) {
1289
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
+			return false;
1292
+		}
1293
+		if (! method_exists('EED_' . $module, $method_name)) {
1294
+			$msg = sprintf(
1295
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
+				$route
1297
+			);
1298
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
+			return false;
1300
+		}
1301
+		EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
+		return true;
1303
+	}
1304
+
1305
+
1306
+
1307
+	/**
1308
+	 *    get_route - get module method route
1309
+	 *
1310
+	 * @access    public
1311
+	 * @param    string $route - "pretty" public alias for module method
1312
+	 * @param    string $key   - url param key indicating a route is being called
1313
+	 * @return    string
1314
+	 */
1315
+	public static function get_route($route = null, $key = 'ee')
1316
+	{
1317
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1318
+		$route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
+			return EE_Config::$_module_route_map[$key][$route];
1321
+		}
1322
+		return null;
1323
+	}
1324
+
1325
+
1326
+
1327
+	/**
1328
+	 *    get_routes - get ALL module method routes
1329
+	 *
1330
+	 * @access    public
1331
+	 * @return    array
1332
+	 */
1333
+	public static function get_routes()
1334
+	{
1335
+		return EE_Config::$_module_route_map;
1336
+	}
1337
+
1338
+
1339
+
1340
+	/**
1341
+	 *    register_forward - allows modules to forward request to another module for further processing
1342
+	 *
1343
+	 * @access    public
1344
+	 * @param    string       $route   - "pretty" public alias for module method
1345
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
+	 *                                 class, allows different forwards to be served based on status
1347
+	 * @param    array|string $forward - function name or array( class, method )
1348
+	 * @param    string       $key     - url param key indicating a route is being called
1349
+	 * @return    bool
1350
+	 */
1351
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
+	{
1353
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
+			$msg = sprintf(
1356
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
+				$route
1358
+			);
1359
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
+			return false;
1361
+		}
1362
+		if (empty($forward)) {
1363
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
+			return false;
1366
+		}
1367
+		if (is_array($forward)) {
1368
+			if (! isset($forward[1])) {
1369
+				$msg = sprintf(
1370
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
+					$route
1372
+				);
1373
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
+				return false;
1375
+			}
1376
+			if (! method_exists($forward[0], $forward[1])) {
1377
+				$msg = sprintf(
1378
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
+					$forward[1],
1380
+					$route
1381
+				);
1382
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
+				return false;
1384
+			}
1385
+		} else if (! function_exists($forward)) {
1386
+			$msg = sprintf(
1387
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
+				$forward,
1389
+				$route
1390
+			);
1391
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
+			return false;
1393
+		}
1394
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
+		return true;
1396
+	}
1397
+
1398
+
1399
+
1400
+	/**
1401
+	 *    get_forward - get forwarding route
1402
+	 *
1403
+	 * @access    public
1404
+	 * @param    string  $route  - "pretty" public alias for module method
1405
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
+	 *                           allows different forwards to be served based on status
1407
+	 * @param    string  $key    - url param key indicating a route is being called
1408
+	 * @return    string
1409
+	 */
1410
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
+	{
1412
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
+			return apply_filters(
1415
+				'FHEE__EE_Config__get_forward',
1416
+				EE_Config::$_module_forward_map[$key][$route][$status],
1417
+				$route,
1418
+				$status
1419
+			);
1420
+		}
1421
+		return null;
1422
+	}
1423
+
1424
+
1425
+
1426
+	/**
1427
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1428
+	 *    results
1429
+	 *
1430
+	 * @access    public
1431
+	 * @param    string  $route  - "pretty" public alias for module method
1432
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
+	 *                           allows different views to be served based on status
1434
+	 * @param    string  $view
1435
+	 * @param    string  $key    - url param key indicating a route is being called
1436
+	 * @return    bool
1437
+	 */
1438
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
+	{
1440
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
+			$msg = sprintf(
1443
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1444
+				$route
1445
+			);
1446
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
+			return false;
1448
+		}
1449
+		if (! is_readable($view)) {
1450
+			$msg = sprintf(
1451
+				__(
1452
+					'The %s view file could not be found or is not readable due to file permissions.',
1453
+					'event_espresso'
1454
+				),
1455
+				$view
1456
+			);
1457
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
+			return false;
1459
+		}
1460
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
+		return true;
1462
+	}
1463
+
1464
+
1465
+
1466
+	/**
1467
+	 *    get_view - get view for route and status
1468
+	 *
1469
+	 * @access    public
1470
+	 * @param    string  $route  - "pretty" public alias for module method
1471
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
+	 *                           allows different views to be served based on status
1473
+	 * @param    string  $key    - url param key indicating a route is being called
1474
+	 * @return    string
1475
+	 */
1476
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1477
+	{
1478
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
+			return apply_filters(
1481
+				'FHEE__EE_Config__get_view',
1482
+				EE_Config::$_module_view_map[$key][$route][$status],
1483
+				$route,
1484
+				$status
1485
+			);
1486
+		}
1487
+		return null;
1488
+	}
1489
+
1490
+
1491
+
1492
+	public function update_addon_option_names()
1493
+	{
1494
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
+	}
1496
+
1497
+
1498
+
1499
+	public function shutdown()
1500
+	{
1501
+		$this->update_addon_option_names();
1502
+	}
1503
+
1504
+
1505
+
1506
+	/**
1507
+	 * @return LegacyShortcodesManager
1508
+	 */
1509
+	public static function getLegacyShortcodesManager()
1510
+	{
1511
+
1512
+		if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
+				EE_Registry::instance()
1515
+			);
1516
+		}
1517
+		return EE_Config::instance()->legacy_shortcodes_manager;
1518
+	}
1519
+
1520
+
1521
+
1522
+	/**
1523
+	 * register_shortcode - makes core aware of this shortcode
1524
+	 *
1525
+	 * @deprecated 4.9.26
1526
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1527
+	 * @return    bool
1528
+	 */
1529
+	public static function register_shortcode($shortcode_path = null)
1530
+	{
1531
+		EE_Error::doing_it_wrong(
1532
+			__METHOD__,
1533
+			__(
1534
+				'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.',
1535
+				'event_espresso'
1536
+			),
1537
+			'4.9.26'
1538
+		);
1539
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
+	}
20 1541
 
21
-    const LOG_NAME           = 'ee_config_log';
22 1542
 
23
-    const LOG_LENGTH         = 100;
24 1543
 
25
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
26
-
27
-
28
-    /**
29
-     *    instance of the EE_Config object
30
-     *
31
-     * @var    EE_Config $_instance
32
-     * @access    private
33
-     */
34
-    private static $_instance;
35
-
36
-    /**
37
-     * @var boolean $_logging_enabled
38
-     */
39
-    private static $_logging_enabled = false;
40
-
41
-    /**
42
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
43
-     */
44
-    private $legacy_shortcodes_manager;
45
-
46
-    /**
47
-     * An StdClass whose property names are addon slugs,
48
-     * and values are their config classes
49
-     *
50
-     * @var StdClass
51
-     */
52
-    public $addons;
53
-
54
-    /**
55
-     * @var EE_Admin_Config
56
-     */
57
-    public $admin;
58
-
59
-    /**
60
-     * @var EE_Core_Config
61
-     */
62
-    public $core;
63
-
64
-    /**
65
-     * @var EE_Currency_Config
66
-     */
67
-    public $currency;
68
-
69
-    /**
70
-     * @var EE_Organization_Config
71
-     */
72
-    public $organization;
73
-
74
-    /**
75
-     * @var EE_Registration_Config
76
-     */
77
-    public $registration;
78
-
79
-    /**
80
-     * @var EE_Template_Config
81
-     */
82
-    public $template_settings;
83
-
84
-    /**
85
-     * Holds EE environment values.
86
-     *
87
-     * @var EE_Environment_Config
88
-     */
89
-    public $environment;
90
-
91
-    /**
92
-     * settings pertaining to Google maps
93
-     *
94
-     * @var EE_Map_Config
95
-     */
96
-    public $map_settings;
97
-
98
-    /**
99
-     * settings pertaining to Taxes
100
-     *
101
-     * @var EE_Tax_Config
102
-     */
103
-    public $tax_settings;
104
-
105
-
106
-    /**
107
-     * Settings pertaining to global messages settings.
108
-     *
109
-     * @var EE_Messages_Config
110
-     */
111
-    public $messages;
112
-
113
-    /**
114
-     * @deprecated
115
-     * @var EE_Gateway_Config
116
-     */
117
-    public $gateway;
118
-
119
-    /**
120
-     * @var    array $_addon_option_names
121
-     * @access    private
122
-     */
123
-    private $_addon_option_names = array();
124
-
125
-    /**
126
-     * @var    array $_module_route_map
127
-     * @access    private
128
-     */
129
-    private static $_module_route_map = array();
130
-
131
-    /**
132
-     * @var    array $_module_forward_map
133
-     * @access    private
134
-     */
135
-    private static $_module_forward_map = array();
136
-
137
-    /**
138
-     * @var    array $_module_view_map
139
-     * @access    private
140
-     */
141
-    private static $_module_view_map = array();
142
-
143
-
144
-
145
-    /**
146
-     * @singleton method used to instantiate class object
147
-     * @access    public
148
-     * @return EE_Config instance
149
-     */
150
-    public static function instance()
151
-    {
152
-        // check if class object is instantiated, and instantiated properly
153
-        if (! self::$_instance instanceof EE_Config) {
154
-            self::$_instance = new self();
155
-        }
156
-        return self::$_instance;
157
-    }
158
-
159
-
160
-
161
-    /**
162
-     * Resets the config
163
-     *
164
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
165
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
166
-     *                               reflect its state in the database
167
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
168
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
169
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
170
-     *                               site was put into maintenance mode)
171
-     * @return EE_Config
172
-     */
173
-    public static function reset($hard_reset = false, $reinstantiate = true)
174
-    {
175
-        if (self::$_instance instanceof EE_Config) {
176
-            if ($hard_reset) {
177
-                self::$_instance->legacy_shortcodes_manager = null;
178
-                self::$_instance->_addon_option_names = array();
179
-                self::$_instance->_initialize_config();
180
-                self::$_instance->update_espresso_config();
181
-            }
182
-            self::$_instance->update_addon_option_names();
183
-        }
184
-        self::$_instance = null;
185
-        //we don't need to reset the static properties imo because those should
186
-        //only change when a module is added or removed. Currently we don't
187
-        //support removing a module during a request when it previously existed
188
-        if ($reinstantiate) {
189
-            return self::instance();
190
-        } else {
191
-            return null;
192
-        }
193
-    }
194
-
195
-
196
-
197
-    /**
198
-     *    class constructor
199
-     *
200
-     * @access    private
201
-     */
202
-    private function __construct()
203
-    {
204
-        do_action('AHEE__EE_Config__construct__begin', $this);
205
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
206
-        // setup empty config classes
207
-        $this->_initialize_config();
208
-        // load existing EE site settings
209
-        $this->_load_core_config();
210
-        // confirm everything loaded correctly and set filtered defaults if not
211
-        $this->_verify_config();
212
-        //  register shortcodes and modules
213
-        add_action(
214
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
215
-            array($this, 'register_shortcodes_and_modules'),
216
-            999
217
-        );
218
-        //  initialize shortcodes and modules
219
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
220
-        // register widgets
221
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
222
-        // shutdown
223
-        add_action('shutdown', array($this, 'shutdown'), 10);
224
-        // construct__end hook
225
-        do_action('AHEE__EE_Config__construct__end', $this);
226
-        // hardcoded hack
227
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
228
-    }
229
-
230
-
231
-
232
-    /**
233
-     * @return boolean
234
-     */
235
-    public static function logging_enabled()
236
-    {
237
-        return self::$_logging_enabled;
238
-    }
239
-
240
-
241
-
242
-    /**
243
-     * use to get the current theme if needed from static context
244
-     *
245
-     * @return string current theme set.
246
-     */
247
-    public static function get_current_theme()
248
-    {
249
-        return isset(self::$_instance->template_settings->current_espresso_theme)
250
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
251
-    }
252
-
253
-
254
-
255
-    /**
256
-     *        _initialize_config
257
-     *
258
-     * @access private
259
-     * @return void
260
-     */
261
-    private function _initialize_config()
262
-    {
263
-        EE_Config::trim_log();
264
-        //set defaults
265
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
266
-        $this->addons = new stdClass();
267
-        // set _module_route_map
268
-        EE_Config::$_module_route_map = array();
269
-        // set _module_forward_map
270
-        EE_Config::$_module_forward_map = array();
271
-        // set _module_view_map
272
-        EE_Config::$_module_view_map = array();
273
-    }
274
-
275
-
276
-
277
-    /**
278
-     *        load core plugin configuration
279
-     *
280
-     * @access private
281
-     * @return void
282
-     */
283
-    private function _load_core_config()
284
-    {
285
-        // load_core_config__start hook
286
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
287
-        $espresso_config = $this->get_espresso_config();
288
-        foreach ($espresso_config as $config => $settings) {
289
-            // load_core_config__start hook
290
-            $settings = apply_filters(
291
-                'FHEE__EE_Config___load_core_config__config_settings',
292
-                $settings,
293
-                $config,
294
-                $this
295
-            );
296
-            if (is_object($settings) && property_exists($this, $config)) {
297
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
298
-                //call configs populate method to ensure any defaults are set for empty values.
299
-                if (method_exists($settings, 'populate')) {
300
-                    $this->{$config}->populate();
301
-                }
302
-                if (method_exists($settings, 'do_hooks')) {
303
-                    $this->{$config}->do_hooks();
304
-                }
305
-            }
306
-        }
307
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
308
-            $this->update_espresso_config();
309
-        }
310
-        // load_core_config__end hook
311
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
312
-    }
313
-
314
-
315
-
316
-    /**
317
-     *    _verify_config
318
-     *
319
-     * @access    protected
320
-     * @return    void
321
-     */
322
-    protected function _verify_config()
323
-    {
324
-        $this->core = $this->core instanceof EE_Core_Config
325
-            ? $this->core
326
-            : new EE_Core_Config();
327
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
328
-        $this->organization = $this->organization instanceof EE_Organization_Config
329
-            ? $this->organization
330
-            : new EE_Organization_Config();
331
-        $this->organization = apply_filters(
332
-            'FHEE__EE_Config___initialize_config__organization',
333
-            $this->organization
334
-        );
335
-        $this->currency = $this->currency instanceof EE_Currency_Config
336
-            ? $this->currency
337
-            : new EE_Currency_Config();
338
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
339
-        $this->registration = $this->registration instanceof EE_Registration_Config
340
-            ? $this->registration
341
-            : new EE_Registration_Config();
342
-        $this->registration = apply_filters(
343
-            'FHEE__EE_Config___initialize_config__registration',
344
-            $this->registration
345
-        );
346
-        $this->admin = $this->admin instanceof EE_Admin_Config
347
-            ? $this->admin
348
-            : new EE_Admin_Config();
349
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
350
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
351
-            ? $this->template_settings
352
-            : new EE_Template_Config();
353
-        $this->template_settings = apply_filters(
354
-            'FHEE__EE_Config___initialize_config__template_settings',
355
-            $this->template_settings
356
-        );
357
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
358
-            ? $this->map_settings
359
-            : new EE_Map_Config();
360
-        $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
361
-            $this->map_settings);
362
-        $this->environment = $this->environment instanceof EE_Environment_Config
363
-            ? $this->environment
364
-            : new EE_Environment_Config();
365
-        $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
366
-            $this->environment);
367
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
368
-            ? $this->tax_settings
369
-            : new EE_Tax_Config();
370
-        $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
371
-            $this->tax_settings);
372
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
373
-        $this->messages = $this->messages instanceof EE_Messages_Config
374
-            ? $this->messages
375
-            : new EE_Messages_Config();
376
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
377
-            ? $this->gateway
378
-            : new EE_Gateway_Config();
379
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
380
-        $this->legacy_shortcodes_manager = null;
381
-    }
382
-
383
-
384
-    /**
385
-     *    get_espresso_config
386
-     *
387
-     * @access    public
388
-     * @return    array of espresso config stuff
389
-     */
390
-    public function get_espresso_config()
391
-    {
392
-        // grab espresso configuration
393
-        return apply_filters(
394
-            'FHEE__EE_Config__get_espresso_config__CFG',
395
-            get_option(EE_Config::OPTION_NAME, array())
396
-        );
397
-    }
398
-
399
-
400
-
401
-    /**
402
-     *    double_check_config_comparison
403
-     *
404
-     * @access    public
405
-     * @param string $option
406
-     * @param        $old_value
407
-     * @param        $value
408
-     */
409
-    public function double_check_config_comparison($option = '', $old_value, $value)
410
-    {
411
-        // make sure we're checking the ee config
412
-        if ($option === EE_Config::OPTION_NAME) {
413
-            // run a loose comparison of the old value against the new value for type and properties,
414
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
415
-            if ($value != $old_value) {
416
-                // if they are NOT the same, then remove the hook,
417
-                // which means the subsequent update results will be based solely on the update query results
418
-                // the reason we do this is because, as stated above,
419
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
420
-                // this happens PRIOR to serialization and any subsequent update.
421
-                // If values are found to match their previous old value,
422
-                // then WP bails before performing any update.
423
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
424
-                // it just pulled from the db, with the one being passed to it (which will not match).
425
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
426
-                // MySQL MAY ALSO NOT perform the update because
427
-                // the string it sees in the db looks the same as the new one it has been passed!!!
428
-                // This results in the query returning an "affected rows" value of ZERO,
429
-                // which gets returned immediately by WP update_option and looks like an error.
430
-                remove_action('update_option', array($this, 'check_config_updated'));
431
-            }
432
-        }
433
-    }
434
-
435
-
436
-
437
-    /**
438
-     *    update_espresso_config
439
-     *
440
-     * @access   public
441
-     */
442
-    protected function _reset_espresso_addon_config()
443
-    {
444
-        $this->_addon_option_names = array();
445
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
446
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
447
-            $config_class = get_class($addon_config_obj);
448
-            if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
449
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
450
-            }
451
-            $this->addons->{$addon_name} = null;
452
-        }
453
-    }
454
-
455
-
456
-
457
-    /**
458
-     *    update_espresso_config
459
-     *
460
-     * @access   public
461
-     * @param   bool $add_success
462
-     * @param   bool $add_error
463
-     * @return   bool
464
-     */
465
-    public function update_espresso_config($add_success = false, $add_error = true)
466
-    {
467
-        // don't allow config updates during WP heartbeats
468
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
-            return false;
470
-        }
471
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
-        //$clone = clone( self::$_instance );
473
-        //self::$_instance = NULL;
474
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
-        $this->_reset_espresso_addon_config();
476
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
-        // but BEFORE the actual update occurs
478
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
-        $this->legacy_shortcodes_manager = null;
482
-        // now update "ee_config"
483
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
484
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
-        EE_Config::log(EE_Config::OPTION_NAME);
486
-        // if not saved... check if the hook we just added still exists;
487
-        // if it does, it means one of two things:
488
-        // 		that update_option bailed at the ( $value === $old_value ) conditional,
489
-        //		 or...
490
-        // 		the db update query returned 0 rows affected
491
-        // 		(probably because the data  value was the same from it's perspective)
492
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
493
-        // but just means no update occurred, so don't display an error to the user.
494
-        // BUT... if update_option returns FALSE, AND the hook is missing,
495
-        // then it means that something truly went wrong
496
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
-        // remove our action since we don't want it in the system anymore
498
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
-        //self::$_instance = $clone;
501
-        //unset( $clone );
502
-        // if config remains the same or was updated successfully
503
-        if ($saved) {
504
-            if ($add_success) {
505
-                EE_Error::add_success(
506
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
-                    __FILE__,
508
-                    __FUNCTION__,
509
-                    __LINE__
510
-                );
511
-            }
512
-            return true;
513
-        } else {
514
-            if ($add_error) {
515
-                EE_Error::add_error(
516
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
-                    __FILE__,
518
-                    __FUNCTION__,
519
-                    __LINE__
520
-                );
521
-            }
522
-            return false;
523
-        }
524
-    }
525
-
526
-
527
-
528
-    /**
529
-     *    _verify_config_params
530
-     *
531
-     * @access    private
532
-     * @param    string         $section
533
-     * @param    string         $name
534
-     * @param    string         $config_class
535
-     * @param    EE_Config_Base $config_obj
536
-     * @param    array          $tests_to_run
537
-     * @param    bool           $display_errors
538
-     * @return    bool    TRUE on success, FALSE on fail
539
-     */
540
-    private function _verify_config_params(
541
-        $section = '',
542
-        $name = '',
543
-        $config_class = '',
544
-        $config_obj = null,
545
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
-        $display_errors = true
547
-    ) {
548
-        try {
549
-            foreach ($tests_to_run as $test) {
550
-                switch ($test) {
551
-                    // TEST #1 : check that section was set
552
-                    case 1 :
553
-                        if (empty($section)) {
554
-                            if ($display_errors) {
555
-                                throw new EE_Error(
556
-                                    sprintf(
557
-                                        __(
558
-                                            'No configuration section has been provided while attempting to save "%s".',
559
-                                            'event_espresso'
560
-                                        ),
561
-                                        $config_class
562
-                                    )
563
-                                );
564
-                            }
565
-                            return false;
566
-                        }
567
-                        break;
568
-                    // TEST #2 : check that settings section exists
569
-                    case 2 :
570
-                        if (! isset($this->{$section})) {
571
-                            if ($display_errors) {
572
-                                throw new EE_Error(
573
-                                    sprintf(
574
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
575
-                                        $section
576
-                                    )
577
-                                );
578
-                            }
579
-                            return false;
580
-                        }
581
-                        break;
582
-                    // TEST #3 : check that section is the proper format
583
-                    case 3 :
584
-                        if (
585
-                        ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
-                        ) {
587
-                            if ($display_errors) {
588
-                                throw new EE_Error(
589
-                                    sprintf(
590
-                                        __(
591
-                                            'The "%s" configuration settings have not been formatted correctly.',
592
-                                            'event_espresso'
593
-                                        ),
594
-                                        $section
595
-                                    )
596
-                                );
597
-                            }
598
-                            return false;
599
-                        }
600
-                        break;
601
-                    // TEST #4 : check that config section name has been set
602
-                    case 4 :
603
-                        if (empty($name)) {
604
-                            if ($display_errors) {
605
-                                throw new EE_Error(
606
-                                    __(
607
-                                        'No name has been provided for the specific configuration section.',
608
-                                        'event_espresso'
609
-                                    )
610
-                                );
611
-                            }
612
-                            return false;
613
-                        }
614
-                        break;
615
-                    // TEST #5 : check that a config class name has been set
616
-                    case 5 :
617
-                        if (empty($config_class)) {
618
-                            if ($display_errors) {
619
-                                throw new EE_Error(
620
-                                    __(
621
-                                        'No class name has been provided for the specific configuration section.',
622
-                                        'event_espresso'
623
-                                    )
624
-                                );
625
-                            }
626
-                            return false;
627
-                        }
628
-                        break;
629
-                    // TEST #6 : verify config class is accessible
630
-                    case 6 :
631
-                        if (! class_exists($config_class)) {
632
-                            if ($display_errors) {
633
-                                throw new EE_Error(
634
-                                    sprintf(
635
-                                        __(
636
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
-                                            'event_espresso'
638
-                                        ),
639
-                                        $config_class
640
-                                    )
641
-                                );
642
-                            }
643
-                            return false;
644
-                        }
645
-                        break;
646
-                    // TEST #7 : check that config has even been set
647
-                    case 7 :
648
-                        if (! isset($this->{$section}->{$name})) {
649
-                            if ($display_errors) {
650
-                                throw new EE_Error(
651
-                                    sprintf(
652
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
-                                        $section,
654
-                                        $name
655
-                                    )
656
-                                );
657
-                            }
658
-                            return false;
659
-                        } else {
660
-                            // and make sure it's not serialized
661
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
-                        }
663
-                        break;
664
-                    // TEST #8 : check that config is the requested type
665
-                    case 8 :
666
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
667
-                            if ($display_errors) {
668
-                                throw new EE_Error(
669
-                                    sprintf(
670
-                                        __(
671
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
-                                            'event_espresso'
673
-                                        ),
674
-                                        $section,
675
-                                        $name,
676
-                                        $config_class
677
-                                    )
678
-                                );
679
-                            }
680
-                            return false;
681
-                        }
682
-                        break;
683
-                    // TEST #9 : verify config object
684
-                    case 9 :
685
-                        if (! $config_obj instanceof EE_Config_Base) {
686
-                            if ($display_errors) {
687
-                                throw new EE_Error(
688
-                                    sprintf(
689
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
-                                        print_r($config_obj, true)
691
-                                    )
692
-                                );
693
-                            }
694
-                            return false;
695
-                        }
696
-                        break;
697
-                }
698
-            }
699
-        } catch (EE_Error $e) {
700
-            $e->get_error();
701
-        }
702
-        // you have successfully run the gauntlet
703
-        return true;
704
-    }
705
-
706
-
707
-
708
-    /**
709
-     *    _generate_config_option_name
710
-     *
711
-     * @access        protected
712
-     * @param        string $section
713
-     * @param        string $name
714
-     * @return        string
715
-     */
716
-    private function _generate_config_option_name($section = '', $name = '')
717
-    {
718
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
-    }
720
-
721
-
722
-
723
-    /**
724
-     *    _set_config_class
725
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
726
-     *
727
-     * @access    private
728
-     * @param    string $config_class
729
-     * @param    string $name
730
-     * @return    string
731
-     */
732
-    private function _set_config_class($config_class = '', $name = '')
733
-    {
734
-        return ! empty($config_class)
735
-            ? $config_class
736
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
-    }
738
-
739
-
740
-
741
-    /**
742
-     *    set_config
743
-     *
744
-     * @access    protected
745
-     * @param    string         $section
746
-     * @param    string         $name
747
-     * @param    string         $config_class
748
-     * @param    EE_Config_Base $config_obj
749
-     * @return    EE_Config_Base
750
-     */
751
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
-    {
753
-        // ensure config class is set to something
754
-        $config_class = $this->_set_config_class($config_class, $name);
755
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
756
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
-            return null;
758
-        }
759
-        $config_option_name = $this->_generate_config_option_name($section, $name);
760
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
-        if (! isset($this->_addon_option_names[$config_option_name])) {
762
-            $this->_addon_option_names[$config_option_name] = $config_class;
763
-            $this->update_addon_option_names();
764
-        }
765
-        // verify the incoming config object but suppress errors
766
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
-            $config_obj = new $config_class();
768
-        }
769
-        if (get_option($config_option_name)) {
770
-            EE_Config::log($config_option_name);
771
-            update_option($config_option_name, $config_obj);
772
-            $this->{$section}->{$name} = $config_obj;
773
-            return $this->{$section}->{$name};
774
-        } else {
775
-            // create a wp-option for this config
776
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
777
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
778
-                return $this->{$section}->{$name};
779
-            } else {
780
-                EE_Error::add_error(
781
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
-                    __FILE__,
783
-                    __FUNCTION__,
784
-                    __LINE__
785
-                );
786
-                return null;
787
-            }
788
-        }
789
-    }
790
-
791
-
792
-
793
-    /**
794
-     *    update_config
795
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
-     *
797
-     * @access    public
798
-     * @param    string                $section
799
-     * @param    string                $name
800
-     * @param    EE_Config_Base|string $config_obj
801
-     * @param    bool                  $throw_errors
802
-     * @return    bool
803
-     */
804
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
-    {
806
-        // don't allow config updates during WP heartbeats
807
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
-            return false;
809
-        }
810
-        $config_obj = maybe_unserialize($config_obj);
811
-        // get class name of the incoming object
812
-        $config_class = get_class($config_obj);
813
-        // run tests 1-5 and 9 to verify config
814
-        if (! $this->_verify_config_params(
815
-            $section,
816
-            $name,
817
-            $config_class,
818
-            $config_obj,
819
-            array(1, 2, 3, 4, 7, 9)
820
-        )
821
-        ) {
822
-            return false;
823
-        }
824
-        $config_option_name = $this->_generate_config_option_name($section, $name);
825
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
-        if (! isset($this->_addon_option_names[$config_option_name])) {
827
-            // save new config to db
828
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
-                return true;
830
-            }
831
-        } else {
832
-            // first check if the record already exists
833
-            $existing_config = get_option($config_option_name);
834
-            $config_obj = serialize($config_obj);
835
-            // just return if db record is already up to date (NOT type safe comparison)
836
-            if ($existing_config == $config_obj) {
837
-                $this->{$section}->{$name} = $config_obj;
838
-                return true;
839
-            } else if (update_option($config_option_name, $config_obj)) {
840
-                EE_Config::log($config_option_name);
841
-                // update wp-option for this config class
842
-                $this->{$section}->{$name} = $config_obj;
843
-                return true;
844
-            } elseif ($throw_errors) {
845
-                EE_Error::add_error(
846
-                    sprintf(
847
-                        __(
848
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
-                            'event_espresso'
850
-                        ),
851
-                        $config_class,
852
-                        'EE_Config->' . $section . '->' . $name
853
-                    ),
854
-                    __FILE__,
855
-                    __FUNCTION__,
856
-                    __LINE__
857
-                );
858
-            }
859
-        }
860
-        return false;
861
-    }
862
-
863
-
864
-
865
-    /**
866
-     *    get_config
867
-     *
868
-     * @access    public
869
-     * @param    string $section
870
-     * @param    string $name
871
-     * @param    string $config_class
872
-     * @return    mixed EE_Config_Base | NULL
873
-     */
874
-    public function get_config($section = '', $name = '', $config_class = '')
875
-    {
876
-        // ensure config class is set to something
877
-        $config_class = $this->_set_config_class($config_class, $name);
878
-        // run tests 1-4, 6 and 7 to verify that all params have been set
879
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
-            return null;
881
-        }
882
-        // now test if the requested config object exists, but suppress errors
883
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
-            // config already exists, so pass it back
885
-            return $this->{$section}->{$name};
886
-        }
887
-        // load config option from db if it exists
888
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
-        // verify the newly retrieved config object, but suppress errors
890
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
-            // config is good, so set it and pass it back
892
-            $this->{$section}->{$name} = $config_obj;
893
-            return $this->{$section}->{$name};
894
-        }
895
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
896
-        $config_obj = $this->set_config($section, $name, $config_class);
897
-        // verify the newly created config object
898
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
-            return $this->{$section}->{$name};
900
-        } else {
901
-            EE_Error::add_error(
902
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
-                __FILE__,
904
-                __FUNCTION__,
905
-                __LINE__
906
-            );
907
-        }
908
-        return null;
909
-    }
910
-
911
-
912
-
913
-    /**
914
-     *    get_config_option
915
-     *
916
-     * @access    public
917
-     * @param    string $config_option_name
918
-     * @return    mixed EE_Config_Base | FALSE
919
-     */
920
-    public function get_config_option($config_option_name = '')
921
-    {
922
-        // retrieve the wp-option for this config class.
923
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
924
-        if (empty($config_option)) {
925
-            EE_Config::log($config_option_name . '-NOT-FOUND');
926
-        }
927
-        return $config_option;
928
-    }
929
-
930
-
931
-
932
-    /**
933
-     * log
934
-     *
935
-     * @param string $config_option_name
936
-     */
937
-    public static function log($config_option_name = '')
938
-    {
939
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
-            $config_log = get_option(EE_Config::LOG_NAME, array());
941
-            //copy incoming $_REQUEST and sanitize it so we can save it
942
-            $_request = $_REQUEST;
943
-            array_walk_recursive($_request, 'sanitize_text_field');
944
-            $config_log[(string)microtime(true)] = array(
945
-                'config_name' => $config_option_name,
946
-                'request'     => $_request,
947
-            );
948
-            update_option(EE_Config::LOG_NAME, $config_log);
949
-        }
950
-    }
951
-
952
-
953
-
954
-    /**
955
-     * trim_log
956
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
-     */
958
-    public static function trim_log()
959
-    {
960
-        if (! EE_Config::logging_enabled()) {
961
-            return;
962
-        }
963
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
-        $log_length = count($config_log);
965
-        if ($log_length > EE_Config::LOG_LENGTH) {
966
-            ksort($config_log);
967
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
-            update_option(EE_Config::LOG_NAME, $config_log);
969
-        }
970
-    }
971
-
972
-
973
-
974
-    /**
975
-     *    get_page_for_posts
976
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
-     *    wp-option "page_for_posts", or "posts" if no page is selected
978
-     *
979
-     * @access    public
980
-     * @return    string
981
-     */
982
-    public static function get_page_for_posts()
983
-    {
984
-        $page_for_posts = get_option('page_for_posts');
985
-        if (! $page_for_posts) {
986
-            return 'posts';
987
-        }
988
-        /** @type WPDB $wpdb */
989
-        global $wpdb;
990
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
-    }
993
-
994
-
995
-
996
-    /**
997
-     *    register_shortcodes_and_modules.
998
-     *    At this point, it's too early to tell if we're maintenance mode or not.
999
-     *    In fact, this is where we give modules a chance to let core know they exist
1000
-     *    so they can help trigger maintenance mode if it's needed
1001
-     *
1002
-     * @access    public
1003
-     * @return    void
1004
-     */
1005
-    public function register_shortcodes_and_modules()
1006
-    {
1007
-        // allow modules to set hooks for the rest of the system
1008
-        EE_Registry::instance()->modules = $this->_register_modules();
1009
-    }
1010
-
1011
-
1012
-
1013
-    /**
1014
-     *    initialize_shortcodes_and_modules
1015
-     *    meaning they can start adding their hooks to get stuff done
1016
-     *
1017
-     * @access    public
1018
-     * @return    void
1019
-     */
1020
-    public function initialize_shortcodes_and_modules()
1021
-    {
1022
-        // allow modules to set hooks for the rest of the system
1023
-        $this->_initialize_modules();
1024
-    }
1025
-
1026
-
1027
-
1028
-    /**
1029
-     *    widgets_init
1030
-     *
1031
-     * @access private
1032
-     * @return void
1033
-     */
1034
-    public function widgets_init()
1035
-    {
1036
-        //only init widgets on admin pages when not in complete maintenance, and
1037
-        //on frontend when not in any maintenance mode
1038
-        if (
1039
-            ! EE_Maintenance_Mode::instance()->level()
1040
-            || (
1041
-                is_admin()
1042
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
-            )
1044
-        ) {
1045
-            // grab list of installed widgets
1046
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
-            // filter list of modules to register
1048
-            $widgets_to_register = apply_filters(
1049
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
-                $widgets_to_register
1051
-            );
1052
-            if (! empty($widgets_to_register)) {
1053
-                // cycle thru widget folders
1054
-                foreach ($widgets_to_register as $widget_path) {
1055
-                    // add to list of installed widget modules
1056
-                    EE_Config::register_ee_widget($widget_path);
1057
-                }
1058
-            }
1059
-            // filter list of installed modules
1060
-            EE_Registry::instance()->widgets = apply_filters(
1061
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1062
-                EE_Registry::instance()->widgets
1063
-            );
1064
-        }
1065
-    }
1066
-
1067
-
1068
-
1069
-    /**
1070
-     *    register_ee_widget - makes core aware of this widget
1071
-     *
1072
-     * @access    public
1073
-     * @param    string $widget_path - full path up to and including widget folder
1074
-     * @return    void
1075
-     */
1076
-    public static function register_ee_widget($widget_path = null)
1077
-    {
1078
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
-        $widget_ext = '.widget.php';
1080
-        // make all separators match
1081
-        $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
-        // does the file path INCLUDE the actual file name as part of the path ?
1083
-        if (strpos($widget_path, $widget_ext) !== false) {
1084
-            // grab and shortcode file name from directory name and break apart at dots
1085
-            $file_name = explode('.', basename($widget_path));
1086
-            // take first segment from file name pieces and remove class prefix if it exists
1087
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
-            // sanitize shortcode directory name
1089
-            $widget = sanitize_key($widget);
1090
-            // now we need to rebuild the shortcode path
1091
-            $widget_path = explode(DS, $widget_path);
1092
-            // remove last segment
1093
-            array_pop($widget_path);
1094
-            // glue it back together
1095
-            $widget_path = implode(DS, $widget_path);
1096
-        } else {
1097
-            // grab and sanitize widget directory name
1098
-            $widget = sanitize_key(basename($widget_path));
1099
-        }
1100
-        // create classname from widget directory name
1101
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
-        // add class prefix
1103
-        $widget_class = 'EEW_' . $widget;
1104
-        // does the widget exist ?
1105
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
-            $msg = sprintf(
1107
-                __(
1108
-                    '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',
1109
-                    'event_espresso'
1110
-                ),
1111
-                $widget_class,
1112
-                $widget_path . DS . $widget_class . $widget_ext
1113
-            );
1114
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
-            return;
1116
-        }
1117
-        // load the widget class file
1118
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1119
-        // verify that class exists
1120
-        if (! class_exists($widget_class)) {
1121
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
-            return;
1124
-        }
1125
-        register_widget($widget_class);
1126
-        // add to array of registered widgets
1127
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
-    }
1129
-
1130
-
1131
-
1132
-    /**
1133
-     *        _register_modules
1134
-     *
1135
-     * @access private
1136
-     * @return array
1137
-     */
1138
-    private function _register_modules()
1139
-    {
1140
-        // grab list of installed modules
1141
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
-        // filter list of modules to register
1143
-        $modules_to_register = apply_filters(
1144
-            'FHEE__EE_Config__register_modules__modules_to_register',
1145
-            $modules_to_register
1146
-        );
1147
-        if (! empty($modules_to_register)) {
1148
-            // loop through folders
1149
-            foreach ($modules_to_register as $module_path) {
1150
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
-                if (
1152
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
-                    && $module_path !== EE_MODULES . 'gateways'
1154
-                ) {
1155
-                    // add to list of installed modules
1156
-                    EE_Config::register_module($module_path);
1157
-                }
1158
-            }
1159
-        }
1160
-        // filter list of installed modules
1161
-        return apply_filters(
1162
-            'FHEE__EE_Config___register_modules__installed_modules',
1163
-            EE_Registry::instance()->modules
1164
-        );
1165
-    }
1166
-
1167
-
1168
-
1169
-    /**
1170
-     *    register_module - makes core aware of this module
1171
-     *
1172
-     * @access    public
1173
-     * @param    string $module_path - full path up to and including module folder
1174
-     * @return    bool
1175
-     */
1176
-    public static function register_module($module_path = null)
1177
-    {
1178
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
-        $module_ext = '.module.php';
1180
-        // make all separators match
1181
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
-        // does the file path INCLUDE the actual file name as part of the path ?
1183
-        if (strpos($module_path, $module_ext) !== false) {
1184
-            // grab and shortcode file name from directory name and break apart at dots
1185
-            $module_file = explode('.', basename($module_path));
1186
-            // now we need to rebuild the shortcode path
1187
-            $module_path = explode(DS, $module_path);
1188
-            // remove last segment
1189
-            array_pop($module_path);
1190
-            // glue it back together
1191
-            $module_path = implode(DS, $module_path) . DS;
1192
-            // take first segment from file name pieces and sanitize it
1193
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
-            // ensure class prefix is added
1195
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
-        } else {
1197
-            // we need to generate the filename based off of the folder name
1198
-            // grab and sanitize module name
1199
-            $module = strtolower(basename($module_path));
1200
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
-            // like trailingslashit()
1202
-            $module_path = rtrim($module_path, DS) . DS;
1203
-            // create classname from module directory name
1204
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
-            // add class prefix
1206
-            $module_class = 'EED_' . $module;
1207
-        }
1208
-        // does the module exist ?
1209
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
-            $msg = sprintf(
1211
-                __(
1212
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1213
-                    'event_espresso'
1214
-                ),
1215
-                $module
1216
-            );
1217
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
-            return false;
1219
-        }
1220
-        // load the module class file
1221
-        require_once($module_path . $module_class . $module_ext);
1222
-        // verify that class exists
1223
-        if (! class_exists($module_class)) {
1224
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
-            return false;
1227
-        }
1228
-        // add to array of registered modules
1229
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
-        do_action(
1231
-            'AHEE__EE_Config__register_module__complete',
1232
-            $module_class,
1233
-            EE_Registry::instance()->modules->{$module_class}
1234
-        );
1235
-        return true;
1236
-    }
1237
-
1238
-
1239
-
1240
-    /**
1241
-     *    _initialize_modules
1242
-     *    allow modules to set hooks for the rest of the system
1243
-     *
1244
-     * @access private
1245
-     * @return void
1246
-     */
1247
-    private function _initialize_modules()
1248
-    {
1249
-        // cycle thru shortcode folders
1250
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
-            // which set hooks ?
1253
-            if (is_admin()) {
1254
-                // fire immediately
1255
-                call_user_func(array($module_class, 'set_hooks_admin'));
1256
-            } else {
1257
-                // delay until other systems are online
1258
-                add_action(
1259
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
-                    array($module_class, 'set_hooks')
1261
-                );
1262
-            }
1263
-        }
1264
-    }
1265
-
1266
-
1267
-
1268
-    /**
1269
-     *    register_route - adds module method routes to route_map
1270
-     *
1271
-     * @access    public
1272
-     * @param    string $route       - "pretty" public alias for module method
1273
-     * @param    string $module      - module name (classname without EED_ prefix)
1274
-     * @param    string $method_name - the actual module method to be routed to
1275
-     * @param    string $key         - url param key indicating a route is being called
1276
-     * @return    bool
1277
-     */
1278
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
-    {
1280
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
-        $module = str_replace('EED_', '', $module);
1282
-        $module_class = 'EED_' . $module;
1283
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
-            return false;
1287
-        }
1288
-        if (empty($route)) {
1289
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
-            return false;
1292
-        }
1293
-        if (! method_exists('EED_' . $module, $method_name)) {
1294
-            $msg = sprintf(
1295
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
-                $route
1297
-            );
1298
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
-            return false;
1300
-        }
1301
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
-        return true;
1303
-    }
1304
-
1305
-
1306
-
1307
-    /**
1308
-     *    get_route - get module method route
1309
-     *
1310
-     * @access    public
1311
-     * @param    string $route - "pretty" public alias for module method
1312
-     * @param    string $key   - url param key indicating a route is being called
1313
-     * @return    string
1314
-     */
1315
-    public static function get_route($route = null, $key = 'ee')
1316
-    {
1317
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1318
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
-        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
-            return EE_Config::$_module_route_map[$key][$route];
1321
-        }
1322
-        return null;
1323
-    }
1324
-
1325
-
1326
-
1327
-    /**
1328
-     *    get_routes - get ALL module method routes
1329
-     *
1330
-     * @access    public
1331
-     * @return    array
1332
-     */
1333
-    public static function get_routes()
1334
-    {
1335
-        return EE_Config::$_module_route_map;
1336
-    }
1337
-
1338
-
1339
-
1340
-    /**
1341
-     *    register_forward - allows modules to forward request to another module for further processing
1342
-     *
1343
-     * @access    public
1344
-     * @param    string       $route   - "pretty" public alias for module method
1345
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
-     *                                 class, allows different forwards to be served based on status
1347
-     * @param    array|string $forward - function name or array( class, method )
1348
-     * @param    string       $key     - url param key indicating a route is being called
1349
-     * @return    bool
1350
-     */
1351
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
-    {
1353
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
-            $msg = sprintf(
1356
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
-                $route
1358
-            );
1359
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
-            return false;
1361
-        }
1362
-        if (empty($forward)) {
1363
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
-            return false;
1366
-        }
1367
-        if (is_array($forward)) {
1368
-            if (! isset($forward[1])) {
1369
-                $msg = sprintf(
1370
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
-                    $route
1372
-                );
1373
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
-                return false;
1375
-            }
1376
-            if (! method_exists($forward[0], $forward[1])) {
1377
-                $msg = sprintf(
1378
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
-                    $forward[1],
1380
-                    $route
1381
-                );
1382
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
-                return false;
1384
-            }
1385
-        } else if (! function_exists($forward)) {
1386
-            $msg = sprintf(
1387
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
-                $forward,
1389
-                $route
1390
-            );
1391
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
-            return false;
1393
-        }
1394
-        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
-        return true;
1396
-    }
1397
-
1398
-
1399
-
1400
-    /**
1401
-     *    get_forward - get forwarding route
1402
-     *
1403
-     * @access    public
1404
-     * @param    string  $route  - "pretty" public alias for module method
1405
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
-     *                           allows different forwards to be served based on status
1407
-     * @param    string  $key    - url param key indicating a route is being called
1408
-     * @return    string
1409
-     */
1410
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
-    {
1412
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
-        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
-            return apply_filters(
1415
-                'FHEE__EE_Config__get_forward',
1416
-                EE_Config::$_module_forward_map[$key][$route][$status],
1417
-                $route,
1418
-                $status
1419
-            );
1420
-        }
1421
-        return null;
1422
-    }
1423
-
1424
-
1425
-
1426
-    /**
1427
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1428
-     *    results
1429
-     *
1430
-     * @access    public
1431
-     * @param    string  $route  - "pretty" public alias for module method
1432
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
-     *                           allows different views to be served based on status
1434
-     * @param    string  $view
1435
-     * @param    string  $key    - url param key indicating a route is being called
1436
-     * @return    bool
1437
-     */
1438
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
-    {
1440
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
-            $msg = sprintf(
1443
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1444
-                $route
1445
-            );
1446
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
-            return false;
1448
-        }
1449
-        if (! is_readable($view)) {
1450
-            $msg = sprintf(
1451
-                __(
1452
-                    'The %s view file could not be found or is not readable due to file permissions.',
1453
-                    'event_espresso'
1454
-                ),
1455
-                $view
1456
-            );
1457
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
-            return false;
1459
-        }
1460
-        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
-        return true;
1462
-    }
1463
-
1464
-
1465
-
1466
-    /**
1467
-     *    get_view - get view for route and status
1468
-     *
1469
-     * @access    public
1470
-     * @param    string  $route  - "pretty" public alias for module method
1471
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
-     *                           allows different views to be served based on status
1473
-     * @param    string  $key    - url param key indicating a route is being called
1474
-     * @return    string
1475
-     */
1476
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1477
-    {
1478
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
-        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
-            return apply_filters(
1481
-                'FHEE__EE_Config__get_view',
1482
-                EE_Config::$_module_view_map[$key][$route][$status],
1483
-                $route,
1484
-                $status
1485
-            );
1486
-        }
1487
-        return null;
1488
-    }
1489
-
1490
-
1491
-
1492
-    public function update_addon_option_names()
1493
-    {
1494
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
-    }
1496
-
1497
-
1498
-
1499
-    public function shutdown()
1500
-    {
1501
-        $this->update_addon_option_names();
1502
-    }
1503
-
1504
-
1505
-
1506
-    /**
1507
-     * @return LegacyShortcodesManager
1508
-     */
1509
-    public static function getLegacyShortcodesManager()
1510
-    {
1511
-
1512
-        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
-                EE_Registry::instance()
1515
-            );
1516
-        }
1517
-        return EE_Config::instance()->legacy_shortcodes_manager;
1518
-    }
1519
-
1520
-
1521
-
1522
-    /**
1523
-     * register_shortcode - makes core aware of this shortcode
1524
-     *
1525
-     * @deprecated 4.9.26
1526
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1527
-     * @return    bool
1528
-     */
1529
-    public static function register_shortcode($shortcode_path = null)
1530
-    {
1531
-        EE_Error::doing_it_wrong(
1532
-            __METHOD__,
1533
-            __(
1534
-                '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.',
1535
-                'event_espresso'
1536
-            ),
1537
-            '4.9.26'
1538
-        );
1539
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
-    }
1541
-
1542
-
1543
-
1544
-}
1545
-
1546
-
1547
-
1548
-/**
1549
- * Base class used for config classes. These classes should generally not have
1550
- * magic functions in use, except we'll allow them to magically set and get stuff...
1551
- * basically, they should just be well-defined stdClasses
1552
- */
1553
-class EE_Config_Base
1554
-{
1555
-
1556
-    /**
1557
-     * Utility function for escaping the value of a property and returning.
1558
-     *
1559
-     * @param string $property property name (checks to see if exists).
1560
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
-     * @throws \EE_Error
1562
-     */
1563
-    public function get_pretty($property)
1564
-    {
1565
-        if (! property_exists($this, $property)) {
1566
-            throw new EE_Error(
1567
-                sprintf(
1568
-                    __(
1569
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
-                        'event_espresso'
1571
-                    ),
1572
-                    get_class($this),
1573
-                    $property
1574
-                )
1575
-            );
1576
-        }
1577
-        //just handling escaping of strings for now.
1578
-        if (is_string($this->{$property})) {
1579
-            return stripslashes($this->{$property});
1580
-        }
1581
-        return $this->{$property};
1582
-    }
1583
-
1584
-
1585
-
1586
-    public function populate()
1587
-    {
1588
-        //grab defaults via a new instance of this class.
1589
-        $class_name = get_class($this);
1590
-        $defaults = new $class_name;
1591
-        //loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
-        //default from our $defaults object.
1593
-        foreach (get_object_vars($defaults) as $property => $value) {
1594
-            if ($this->{$property} === null) {
1595
-                $this->{$property} = $value;
1596
-            }
1597
-        }
1598
-        //cleanup
1599
-        unset($defaults);
1600
-    }
1601
-
1602
-
1603
-
1604
-    /**
1605
-     *        __isset
1606
-     *
1607
-     * @param $a
1608
-     * @return bool
1609
-     */
1610
-    public function __isset($a)
1611
-    {
1612
-        return false;
1613
-    }
1614
-
1615
-
1616
-
1617
-    /**
1618
-     *        __unset
1619
-     *
1620
-     * @param $a
1621
-     * @return bool
1622
-     */
1623
-    public function __unset($a)
1624
-    {
1625
-        return false;
1626
-    }
1627
-
1628
-
1629
-
1630
-    /**
1631
-     *        __clone
1632
-     */
1633
-    public function __clone()
1634
-    {
1635
-    }
1636
-
1637
-
1638
-
1639
-    /**
1640
-     *        __wakeup
1641
-     */
1642
-    public function __wakeup()
1643
-    {
1644
-    }
1645
-
1646
-
1647
-
1648
-    /**
1649
-     *        __destruct
1650
-     */
1651
-    public function __destruct()
1652
-    {
1653
-    }
1654
-}
1655
-
1656
-
1657
-
1658
-/**
1659
- * Class for defining what's in the EE_Config relating to registration settings
1660
- */
1661
-class EE_Core_Config extends EE_Config_Base
1662
-{
1663
-
1664
-    public $current_blog_id;
1665
-
1666
-    public $ee_ueip_optin;
1667
-
1668
-    public $ee_ueip_has_notified;
1669
-
1670
-    /**
1671
-     * Not to be confused with the 4 critical page variables (See
1672
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
-     *
1676
-     * @var array
1677
-     */
1678
-    public $post_shortcodes;
1679
-
1680
-    public $module_route_map;
1681
-
1682
-    public $module_forward_map;
1683
-
1684
-    public $module_view_map;
1685
-
1686
-    /**
1687
-     * The next 4 vars are the IDs of critical EE pages.
1688
-     *
1689
-     * @var int
1690
-     */
1691
-    public $reg_page_id;
1692
-
1693
-    public $txn_page_id;
1694
-
1695
-    public $thank_you_page_id;
1696
-
1697
-    public $cancel_page_id;
1698
-
1699
-    /**
1700
-     * The next 4 vars are the URLs of critical EE pages.
1701
-     *
1702
-     * @var int
1703
-     */
1704
-    public $reg_page_url;
1705
-
1706
-    public $txn_page_url;
1707
-
1708
-    public $thank_you_page_url;
1709
-
1710
-    public $cancel_page_url;
1711
-
1712
-    /**
1713
-     * The next vars relate to the custom slugs for EE CPT routes
1714
-     */
1715
-    public $event_cpt_slug;
1716
-
1717
-
1718
-    /**
1719
-     * This caches the _ee_ueip_option in case this config is reset in the same
1720
-     * request across blog switches in a multisite context.
1721
-     * Avoids extra queries to the db for this option.
1722
-     *
1723
-     * @var bool
1724
-     */
1725
-    public static $ee_ueip_option;
1726
-
1727
-
1728
-
1729
-    /**
1730
-     *    class constructor
1731
-     *
1732
-     * @access    public
1733
-     */
1734
-    public function __construct()
1735
-    {
1736
-        // set default organization settings
1737
-        $this->current_blog_id = get_current_blog_id();
1738
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
-        $this->post_shortcodes = array();
1742
-        $this->module_route_map = array();
1743
-        $this->module_forward_map = array();
1744
-        $this->module_view_map = array();
1745
-        // critical EE page IDs
1746
-        $this->reg_page_id = 0;
1747
-        $this->txn_page_id = 0;
1748
-        $this->thank_you_page_id = 0;
1749
-        $this->cancel_page_id = 0;
1750
-        // critical EE page URLs
1751
-        $this->reg_page_url = '';
1752
-        $this->txn_page_url = '';
1753
-        $this->thank_you_page_url = '';
1754
-        $this->cancel_page_url = '';
1755
-        //cpt slugs
1756
-        $this->event_cpt_slug = __('events', 'event_espresso');
1757
-        //ueip constant check
1758
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
-            $this->ee_ueip_optin = false;
1760
-            $this->ee_ueip_has_notified = true;
1761
-        }
1762
-    }
1763
-
1764
-
1765
-
1766
-    /**
1767
-     * @return array
1768
-     */
1769
-    public function get_critical_pages_array()
1770
-    {
1771
-        return array(
1772
-            $this->reg_page_id,
1773
-            $this->txn_page_id,
1774
-            $this->thank_you_page_id,
1775
-            $this->cancel_page_id,
1776
-        );
1777
-    }
1778
-
1779
-
1780
-
1781
-    /**
1782
-     * @return array
1783
-     */
1784
-    public function get_critical_pages_shortcodes_array()
1785
-    {
1786
-        return array(
1787
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
-        );
1792
-    }
1793
-
1794
-
1795
-
1796
-    /**
1797
-     *  gets/returns URL for EE reg_page
1798
-     *
1799
-     * @access    public
1800
-     * @return    string
1801
-     */
1802
-    public function reg_page_url()
1803
-    {
1804
-        if (! $this->reg_page_url) {
1805
-            $this->reg_page_url = add_query_arg(
1806
-                                      array('uts' => time()),
1807
-                                      get_permalink($this->reg_page_id)
1808
-                                  ) . '#checkout';
1809
-        }
1810
-        return $this->reg_page_url;
1811
-    }
1812
-
1813
-
1814
-
1815
-    /**
1816
-     *  gets/returns URL for EE txn_page
1817
-     *
1818
-     * @param array $query_args like what gets passed to
1819
-     *                          add_query_arg() as the first argument
1820
-     * @access    public
1821
-     * @return    string
1822
-     */
1823
-    public function txn_page_url($query_args = array())
1824
-    {
1825
-        if (! $this->txn_page_url) {
1826
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1827
-        }
1828
-        if ($query_args) {
1829
-            return add_query_arg($query_args, $this->txn_page_url);
1830
-        } else {
1831
-            return $this->txn_page_url;
1832
-        }
1833
-    }
1834
-
1835
-
1836
-
1837
-    /**
1838
-     *  gets/returns URL for EE thank_you_page
1839
-     *
1840
-     * @param array $query_args like what gets passed to
1841
-     *                          add_query_arg() as the first argument
1842
-     * @access    public
1843
-     * @return    string
1844
-     */
1845
-    public function thank_you_page_url($query_args = array())
1846
-    {
1847
-        if (! $this->thank_you_page_url) {
1848
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
-        }
1850
-        if ($query_args) {
1851
-            return add_query_arg($query_args, $this->thank_you_page_url);
1852
-        } else {
1853
-            return $this->thank_you_page_url;
1854
-        }
1855
-    }
1856
-
1857
-
1858
-
1859
-    /**
1860
-     *  gets/returns URL for EE cancel_page
1861
-     *
1862
-     * @access    public
1863
-     * @return    string
1864
-     */
1865
-    public function cancel_page_url()
1866
-    {
1867
-        if (! $this->cancel_page_url) {
1868
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
-        }
1870
-        return $this->cancel_page_url;
1871
-    }
1872
-
1873
-
1874
-
1875
-    /**
1876
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
-     *
1878
-     * @since 4.7.5
1879
-     */
1880
-    protected function _reset_urls()
1881
-    {
1882
-        $this->reg_page_url = '';
1883
-        $this->txn_page_url = '';
1884
-        $this->cancel_page_url = '';
1885
-        $this->thank_you_page_url = '';
1886
-    }
1887
-
1888
-
1889
-
1890
-    /**
1891
-     * Used to return what the optin value is set for the EE User Experience Program.
1892
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
-     * on the main site only.
1894
-     *
1895
-     * @return mixed|void
1896
-     */
1897
-    protected function _get_main_ee_ueip_optin()
1898
-    {
1899
-        //if this is the main site then we can just bypass our direct query.
1900
-        if (is_main_site()) {
1901
-            return get_option('ee_ueip_optin', false);
1902
-        }
1903
-        //is this already cached for this request?  If so use it.
1904
-        if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
-            return EE_Core_Config::$ee_ueip_option;
1906
-        }
1907
-        global $wpdb;
1908
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1909
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
-        $option = 'ee_ueip_optin';
1911
-        //set correct table for query
1912
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
-        //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
-        //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
-        //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
-        //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
-        //for the purpose of caching.
1918
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1919
-        if (false !== $pre) {
1920
-            EE_Core_Config::$ee_ueip_option = $pre;
1921
-            return EE_Core_Config::$ee_ueip_option;
1922
-        }
1923
-        $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
-            $option));
1925
-        if (is_object($row)) {
1926
-            $value = $row->option_value;
1927
-        } else { //option does not exist so use default.
1928
-            return apply_filters('default_option_' . $option, false, $option);
1929
-        }
1930
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
-        return EE_Core_Config::$ee_ueip_option;
1932
-    }
1933
-
1934
-
1935
-
1936
-    /**
1937
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1938
-     * on the object.
1939
-     *
1940
-     * @return array
1941
-     */
1942
-    public function __sleep()
1943
-    {
1944
-        //reset all url properties
1945
-        $this->_reset_urls();
1946
-        //return what to save to db
1947
-        return array_keys(get_object_vars($this));
1948
-    }
1949
-
1950
-}
1951
-
1952
-
1953
-
1954
-/**
1955
- * Config class for storing info on the Organization
1956
- */
1957
-class EE_Organization_Config extends EE_Config_Base
1958
-{
1959
-
1960
-    /**
1961
-     * @var string $name
1962
-     * eg EE4.1
1963
-     */
1964
-    public $name;
1965
-
1966
-    /**
1967
-     * @var string $address_1
1968
-     * eg 123 Onna Road
1969
-     */
1970
-    public $address_1;
1971
-
1972
-    /**
1973
-     * @var string $address_2
1974
-     * eg PO Box 123
1975
-     */
1976
-    public $address_2;
1977
-
1978
-    /**
1979
-     * @var string $city
1980
-     * eg Inna City
1981
-     */
1982
-    public $city;
1983
-
1984
-    /**
1985
-     * @var int $STA_ID
1986
-     * eg 4
1987
-     */
1988
-    public $STA_ID;
1989
-
1990
-    /**
1991
-     * @var string $CNT_ISO
1992
-     * eg US
1993
-     */
1994
-    public $CNT_ISO;
1995
-
1996
-    /**
1997
-     * @var string $zip
1998
-     * eg 12345  or V1A 2B3
1999
-     */
2000
-    public $zip;
2001
-
2002
-    /**
2003
-     * @var string $email
2004
-     * eg [email protected]
2005
-     */
2006
-    public $email;
2007
-
2008
-
2009
-    /**
2010
-     * @var string $phone
2011
-     * eg. 111-111-1111
2012
-     */
2013
-    public $phone;
2014
-
2015
-
2016
-    /**
2017
-     * @var string $vat
2018
-     * VAT/Tax Number
2019
-     */
2020
-    public $vat;
2021
-
2022
-    /**
2023
-     * @var string $logo_url
2024
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2025
-     */
2026
-    public $logo_url;
2027
-
2028
-
2029
-    /**
2030
-     * The below are all various properties for holding links to organization social network profiles
2031
-     *
2032
-     * @var string
2033
-     */
2034
-    /**
2035
-     * facebook (facebook.com/profile.name)
2036
-     *
2037
-     * @var string
2038
-     */
2039
-    public $facebook;
2040
-
2041
-
2042
-    /**
2043
-     * twitter (twitter.com/twitter_handle)
2044
-     *
2045
-     * @var string
2046
-     */
2047
-    public $twitter;
2048
-
2049
-
2050
-    /**
2051
-     * linkedin (linkedin.com/in/profile_name)
2052
-     *
2053
-     * @var string
2054
-     */
2055
-    public $linkedin;
2056
-
2057
-
2058
-    /**
2059
-     * pinterest (www.pinterest.com/profile_name)
2060
-     *
2061
-     * @var string
2062
-     */
2063
-    public $pinterest;
2064
-
2065
-
2066
-    /**
2067
-     * google+ (google.com/+profileName)
2068
-     *
2069
-     * @var string
2070
-     */
2071
-    public $google;
2072
-
2073
-
2074
-    /**
2075
-     * instagram (instagram.com/handle)
2076
-     *
2077
-     * @var string
2078
-     */
2079
-    public $instagram;
2080
-
2081
-
2082
-
2083
-    /**
2084
-     *    class constructor
2085
-     *
2086
-     * @access    public
2087
-     */
2088
-    public function __construct()
2089
-    {
2090
-        // set default organization settings
2091
-        $this->name = get_bloginfo('name');
2092
-        $this->address_1 = '123 Onna Road';
2093
-        $this->address_2 = 'PO Box 123';
2094
-        $this->city = 'Inna City';
2095
-        $this->STA_ID = 4;
2096
-        $this->CNT_ISO = 'US';
2097
-        $this->zip = '12345';
2098
-        $this->email = get_bloginfo('admin_email');
2099
-        $this->phone = '';
2100
-        $this->vat = '123456789';
2101
-        $this->logo_url = '';
2102
-        $this->facebook = '';
2103
-        $this->twitter = '';
2104
-        $this->linkedin = '';
2105
-        $this->pinterest = '';
2106
-        $this->google = '';
2107
-        $this->instagram = '';
2108
-    }
2109
-
2110
-}
2111
-
2112
-
2113
-
2114
-/**
2115
- * Class for defining what's in the EE_Config relating to currency
2116
- */
2117
-class EE_Currency_Config extends EE_Config_Base
2118
-{
2119
-
2120
-    /**
2121
-     * @var string $code
2122
-     * eg 'US'
2123
-     */
2124
-    public $code;
2125
-
2126
-    /**
2127
-     * @var string $name
2128
-     * eg 'Dollar'
2129
-     */
2130
-    public $name;
2131
-
2132
-    /**
2133
-     * plural name
2134
-     *
2135
-     * @var string $plural
2136
-     * eg 'Dollars'
2137
-     */
2138
-    public $plural;
2139
-
2140
-    /**
2141
-     * currency sign
2142
-     *
2143
-     * @var string $sign
2144
-     * eg '$'
2145
-     */
2146
-    public $sign;
2147
-
2148
-    /**
2149
-     * Whether the currency sign should come before the number or not
2150
-     *
2151
-     * @var boolean $sign_b4
2152
-     */
2153
-    public $sign_b4;
2154
-
2155
-    /**
2156
-     * How many digits should come after the decimal place
2157
-     *
2158
-     * @var int $dec_plc
2159
-     */
2160
-    public $dec_plc;
2161
-
2162
-    /**
2163
-     * Symbol to use for decimal mark
2164
-     *
2165
-     * @var string $dec_mrk
2166
-     * eg '.'
2167
-     */
2168
-    public $dec_mrk;
2169
-
2170
-    /**
2171
-     * Symbol to use for thousands
2172
-     *
2173
-     * @var string $thsnds
2174
-     * eg ','
2175
-     */
2176
-    public $thsnds;
2177
-
2178
-
2179
-
2180
-    /**
2181
-     *    class constructor
2182
-     *
2183
-     * @access    public
2184
-     * @param string $CNT_ISO
2185
-     * @throws \EE_Error
2186
-     */
2187
-    public function __construct($CNT_ISO = '')
2188
-    {
2189
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2190
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2191
-        // get country code from organization settings or use default
2192
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2193
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2194
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2195
-            : '';
2196
-        // but override if requested
2197
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2198
-        // 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
2199
-        if (
2200
-            ! empty($CNT_ISO)
2201
-            && EE_Maintenance_Mode::instance()->models_can_query()
2202
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2203
-        ) {
2204
-            // retrieve the country settings from the db, just in case they have been customized
2205
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2206
-            if ($country instanceof EE_Country) {
2207
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2208
-                $this->name = $country->currency_name_single();    // Dollar
2209
-                $this->plural = $country->currency_name_plural();    // Dollars
2210
-                $this->sign = $country->currency_sign();            // currency sign: $
2211
-                $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2212
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2213
-                $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2214
-                $this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2215
-            }
2216
-        }
2217
-        // fallback to hardcoded defaults, in case the above failed
2218
-        if (empty($this->code)) {
2219
-            // set default currency settings
2220
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2221
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2222
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2223
-            $this->sign = '$';    // currency sign: $
2224
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2225
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2226
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2227
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2228
-        }
2229
-    }
2230
-}
2231
-
2232
-
2233
-
2234
-/**
2235
- * Class for defining what's in the EE_Config relating to registration settings
2236
- */
2237
-class EE_Registration_Config extends EE_Config_Base
2238
-{
2239
-
2240
-    /**
2241
-     * Default registration status
2242
-     *
2243
-     * @var string $default_STS_ID
2244
-     * eg 'RPP'
2245
-     */
2246
-    public $default_STS_ID;
2247
-
2248
-
2249
-    /**
2250
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2251
-     * registrations)
2252
-     * @var int
2253
-     */
2254
-    public $default_maximum_number_of_tickets;
2255
-
2256
-
2257
-    /**
2258
-     * level of validation to apply to email addresses
2259
-     *
2260
-     * @var string $email_validation_level
2261
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2262
-     */
2263
-    public $email_validation_level;
2264
-
2265
-    /**
2266
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2267
-     *
2268
-     * @var boolean $show_pending_payment_options
2269
-     */
2270
-    public $show_pending_payment_options;
2271
-
2272
-    /**
2273
-     * Whether to skip the registration confirmation page
2274
-     *
2275
-     * @var boolean $skip_reg_confirmation
2276
-     */
2277
-    public $skip_reg_confirmation;
2278
-
2279
-    /**
2280
-     * an array of SPCO reg steps where:
2281
-     *        the keys denotes the reg step order
2282
-     *        each element consists of an array with the following elements:
2283
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2284
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2285
-     *            "slug" => the URL param used to trigger the reg step
2286
-     *
2287
-     * @var array $reg_steps
2288
-     */
2289
-    public $reg_steps;
2290
-
2291
-    /**
2292
-     * Whether registration confirmation should be the last page of SPCO
2293
-     *
2294
-     * @var boolean $reg_confirmation_last
2295
-     */
2296
-    public $reg_confirmation_last;
2297
-
2298
-    /**
2299
-     * Whether or not to enable the EE Bot Trap
2300
-     *
2301
-     * @var boolean $use_bot_trap
2302
-     */
2303
-    public $use_bot_trap;
2304
-
2305
-    /**
2306
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2307
-     *
2308
-     * @var boolean $use_encryption
2309
-     */
2310
-    public $use_encryption;
1544
+}
2311 1545
 
2312
-    /**
2313
-     * Whether or not to use ReCaptcha
2314
-     *
2315
-     * @var boolean $use_captcha
2316
-     */
2317
-    public $use_captcha;
2318 1546
 
2319
-    /**
2320
-     * ReCaptcha Theme
2321
-     *
2322
-     * @var string $recaptcha_theme
2323
-     *    options: 'dark    ', 'light'
2324
-     */
2325
-    public $recaptcha_theme;
2326 1547
 
2327
-    /**
2328
-     * ReCaptcha Type
2329
-     *
2330
-     * @var string $recaptcha_type
2331
-     *    options: 'audio', 'image'
2332
-     */
2333
-    public $recaptcha_type;
1548
+/**
1549
+ * Base class used for config classes. These classes should generally not have
1550
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1551
+ * basically, they should just be well-defined stdClasses
1552
+ */
1553
+class EE_Config_Base
1554
+{
2334 1555
 
2335
-    /**
2336
-     * ReCaptcha language
2337
-     *
2338
-     * @var string $recaptcha_language
2339
-     * eg 'en'
2340
-     */
2341
-    public $recaptcha_language;
1556
+	/**
1557
+	 * Utility function for escaping the value of a property and returning.
1558
+	 *
1559
+	 * @param string $property property name (checks to see if exists).
1560
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
+	 * @throws \EE_Error
1562
+	 */
1563
+	public function get_pretty($property)
1564
+	{
1565
+		if (! property_exists($this, $property)) {
1566
+			throw new EE_Error(
1567
+				sprintf(
1568
+					__(
1569
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
+						'event_espresso'
1571
+					),
1572
+					get_class($this),
1573
+					$property
1574
+				)
1575
+			);
1576
+		}
1577
+		//just handling escaping of strings for now.
1578
+		if (is_string($this->{$property})) {
1579
+			return stripslashes($this->{$property});
1580
+		}
1581
+		return $this->{$property};
1582
+	}
1583
+
1584
+
1585
+
1586
+	public function populate()
1587
+	{
1588
+		//grab defaults via a new instance of this class.
1589
+		$class_name = get_class($this);
1590
+		$defaults = new $class_name;
1591
+		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
+		//default from our $defaults object.
1593
+		foreach (get_object_vars($defaults) as $property => $value) {
1594
+			if ($this->{$property} === null) {
1595
+				$this->{$property} = $value;
1596
+			}
1597
+		}
1598
+		//cleanup
1599
+		unset($defaults);
1600
+	}
1601
+
1602
+
1603
+
1604
+	/**
1605
+	 *        __isset
1606
+	 *
1607
+	 * @param $a
1608
+	 * @return bool
1609
+	 */
1610
+	public function __isset($a)
1611
+	{
1612
+		return false;
1613
+	}
1614
+
1615
+
1616
+
1617
+	/**
1618
+	 *        __unset
1619
+	 *
1620
+	 * @param $a
1621
+	 * @return bool
1622
+	 */
1623
+	public function __unset($a)
1624
+	{
1625
+		return false;
1626
+	}
1627
+
1628
+
1629
+
1630
+	/**
1631
+	 *        __clone
1632
+	 */
1633
+	public function __clone()
1634
+	{
1635
+	}
1636
+
1637
+
1638
+
1639
+	/**
1640
+	 *        __wakeup
1641
+	 */
1642
+	public function __wakeup()
1643
+	{
1644
+	}
1645
+
1646
+
1647
+
1648
+	/**
1649
+	 *        __destruct
1650
+	 */
1651
+	public function __destruct()
1652
+	{
1653
+	}
1654
+}
2342 1655
 
2343
-    /**
2344
-     * ReCaptcha public key
2345
-     *
2346
-     * @var string $recaptcha_publickey
2347
-     */
2348
-    public $recaptcha_publickey;
2349 1656
 
2350
-    /**
2351
-     * ReCaptcha private key
2352
-     *
2353
-     * @var string $recaptcha_privatekey
2354
-     */
2355
-    public $recaptcha_privatekey;
2356 1657
 
2357
-    /**
2358
-     * ReCaptcha width
2359
-     *
2360
-     * @var int $recaptcha_width
2361
-     * @deprecated
2362
-     */
2363
-    public $recaptcha_width;
1658
+/**
1659
+ * Class for defining what's in the EE_Config relating to registration settings
1660
+ */
1661
+class EE_Core_Config extends EE_Config_Base
1662
+{
2364 1663
 
2365
-    /**
2366
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2367
-     *
2368
-     * @var boolean $track_invalid_checkout_access
2369
-     */
2370
-    protected $track_invalid_checkout_access = true;
1664
+	public $current_blog_id;
1665
+
1666
+	public $ee_ueip_optin;
1667
+
1668
+	public $ee_ueip_has_notified;
1669
+
1670
+	/**
1671
+	 * Not to be confused with the 4 critical page variables (See
1672
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
+	 *
1676
+	 * @var array
1677
+	 */
1678
+	public $post_shortcodes;
1679
+
1680
+	public $module_route_map;
1681
+
1682
+	public $module_forward_map;
1683
+
1684
+	public $module_view_map;
1685
+
1686
+	/**
1687
+	 * The next 4 vars are the IDs of critical EE pages.
1688
+	 *
1689
+	 * @var int
1690
+	 */
1691
+	public $reg_page_id;
1692
+
1693
+	public $txn_page_id;
1694
+
1695
+	public $thank_you_page_id;
1696
+
1697
+	public $cancel_page_id;
1698
+
1699
+	/**
1700
+	 * The next 4 vars are the URLs of critical EE pages.
1701
+	 *
1702
+	 * @var int
1703
+	 */
1704
+	public $reg_page_url;
1705
+
1706
+	public $txn_page_url;
1707
+
1708
+	public $thank_you_page_url;
1709
+
1710
+	public $cancel_page_url;
1711
+
1712
+	/**
1713
+	 * The next vars relate to the custom slugs for EE CPT routes
1714
+	 */
1715
+	public $event_cpt_slug;
1716
+
1717
+
1718
+	/**
1719
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1720
+	 * request across blog switches in a multisite context.
1721
+	 * Avoids extra queries to the db for this option.
1722
+	 *
1723
+	 * @var bool
1724
+	 */
1725
+	public static $ee_ueip_option;
1726
+
1727
+
1728
+
1729
+	/**
1730
+	 *    class constructor
1731
+	 *
1732
+	 * @access    public
1733
+	 */
1734
+	public function __construct()
1735
+	{
1736
+		// set default organization settings
1737
+		$this->current_blog_id = get_current_blog_id();
1738
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
+		$this->post_shortcodes = array();
1742
+		$this->module_route_map = array();
1743
+		$this->module_forward_map = array();
1744
+		$this->module_view_map = array();
1745
+		// critical EE page IDs
1746
+		$this->reg_page_id = 0;
1747
+		$this->txn_page_id = 0;
1748
+		$this->thank_you_page_id = 0;
1749
+		$this->cancel_page_id = 0;
1750
+		// critical EE page URLs
1751
+		$this->reg_page_url = '';
1752
+		$this->txn_page_url = '';
1753
+		$this->thank_you_page_url = '';
1754
+		$this->cancel_page_url = '';
1755
+		//cpt slugs
1756
+		$this->event_cpt_slug = __('events', 'event_espresso');
1757
+		//ueip constant check
1758
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
+			$this->ee_ueip_optin = false;
1760
+			$this->ee_ueip_has_notified = true;
1761
+		}
1762
+	}
1763
+
1764
+
1765
+
1766
+	/**
1767
+	 * @return array
1768
+	 */
1769
+	public function get_critical_pages_array()
1770
+	{
1771
+		return array(
1772
+			$this->reg_page_id,
1773
+			$this->txn_page_id,
1774
+			$this->thank_you_page_id,
1775
+			$this->cancel_page_id,
1776
+		);
1777
+	}
1778
+
1779
+
1780
+
1781
+	/**
1782
+	 * @return array
1783
+	 */
1784
+	public function get_critical_pages_shortcodes_array()
1785
+	{
1786
+		return array(
1787
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
+		);
1792
+	}
1793
+
1794
+
1795
+
1796
+	/**
1797
+	 *  gets/returns URL for EE reg_page
1798
+	 *
1799
+	 * @access    public
1800
+	 * @return    string
1801
+	 */
1802
+	public function reg_page_url()
1803
+	{
1804
+		if (! $this->reg_page_url) {
1805
+			$this->reg_page_url = add_query_arg(
1806
+									  array('uts' => time()),
1807
+									  get_permalink($this->reg_page_id)
1808
+								  ) . '#checkout';
1809
+		}
1810
+		return $this->reg_page_url;
1811
+	}
1812
+
1813
+
1814
+
1815
+	/**
1816
+	 *  gets/returns URL for EE txn_page
1817
+	 *
1818
+	 * @param array $query_args like what gets passed to
1819
+	 *                          add_query_arg() as the first argument
1820
+	 * @access    public
1821
+	 * @return    string
1822
+	 */
1823
+	public function txn_page_url($query_args = array())
1824
+	{
1825
+		if (! $this->txn_page_url) {
1826
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1827
+		}
1828
+		if ($query_args) {
1829
+			return add_query_arg($query_args, $this->txn_page_url);
1830
+		} else {
1831
+			return $this->txn_page_url;
1832
+		}
1833
+	}
1834
+
1835
+
1836
+
1837
+	/**
1838
+	 *  gets/returns URL for EE thank_you_page
1839
+	 *
1840
+	 * @param array $query_args like what gets passed to
1841
+	 *                          add_query_arg() as the first argument
1842
+	 * @access    public
1843
+	 * @return    string
1844
+	 */
1845
+	public function thank_you_page_url($query_args = array())
1846
+	{
1847
+		if (! $this->thank_you_page_url) {
1848
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
+		}
1850
+		if ($query_args) {
1851
+			return add_query_arg($query_args, $this->thank_you_page_url);
1852
+		} else {
1853
+			return $this->thank_you_page_url;
1854
+		}
1855
+	}
1856
+
1857
+
1858
+
1859
+	/**
1860
+	 *  gets/returns URL for EE cancel_page
1861
+	 *
1862
+	 * @access    public
1863
+	 * @return    string
1864
+	 */
1865
+	public function cancel_page_url()
1866
+	{
1867
+		if (! $this->cancel_page_url) {
1868
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
+		}
1870
+		return $this->cancel_page_url;
1871
+	}
1872
+
1873
+
1874
+
1875
+	/**
1876
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
+	 *
1878
+	 * @since 4.7.5
1879
+	 */
1880
+	protected function _reset_urls()
1881
+	{
1882
+		$this->reg_page_url = '';
1883
+		$this->txn_page_url = '';
1884
+		$this->cancel_page_url = '';
1885
+		$this->thank_you_page_url = '';
1886
+	}
1887
+
1888
+
1889
+
1890
+	/**
1891
+	 * Used to return what the optin value is set for the EE User Experience Program.
1892
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
+	 * on the main site only.
1894
+	 *
1895
+	 * @return mixed|void
1896
+	 */
1897
+	protected function _get_main_ee_ueip_optin()
1898
+	{
1899
+		//if this is the main site then we can just bypass our direct query.
1900
+		if (is_main_site()) {
1901
+			return get_option('ee_ueip_optin', false);
1902
+		}
1903
+		//is this already cached for this request?  If so use it.
1904
+		if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
+			return EE_Core_Config::$ee_ueip_option;
1906
+		}
1907
+		global $wpdb;
1908
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1909
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
+		$option = 'ee_ueip_optin';
1911
+		//set correct table for query
1912
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
+		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
+		//get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
+		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
+		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
+		//for the purpose of caching.
1918
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1919
+		if (false !== $pre) {
1920
+			EE_Core_Config::$ee_ueip_option = $pre;
1921
+			return EE_Core_Config::$ee_ueip_option;
1922
+		}
1923
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
+			$option));
1925
+		if (is_object($row)) {
1926
+			$value = $row->option_value;
1927
+		} else { //option does not exist so use default.
1928
+			return apply_filters('default_option_' . $option, false, $option);
1929
+		}
1930
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
+		return EE_Core_Config::$ee_ueip_option;
1932
+	}
1933
+
1934
+
1935
+
1936
+	/**
1937
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1938
+	 * on the object.
1939
+	 *
1940
+	 * @return array
1941
+	 */
1942
+	public function __sleep()
1943
+	{
1944
+		//reset all url properties
1945
+		$this->_reset_urls();
1946
+		//return what to save to db
1947
+		return array_keys(get_object_vars($this));
1948
+	}
2371 1949
 
1950
+}
2372 1951
 
2373 1952
 
2374
-    /**
2375
-     *    class constructor
2376
-     *
2377
-     * @access    public
2378
-     */
2379
-    public function __construct()
2380
-    {
2381
-        // set default registration settings
2382
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2383
-        $this->email_validation_level = 'wp_default';
2384
-        $this->show_pending_payment_options = true;
2385
-        $this->skip_reg_confirmation = false;
2386
-        $this->reg_steps = array();
2387
-        $this->reg_confirmation_last = false;
2388
-        $this->use_bot_trap = true;
2389
-        $this->use_encryption = true;
2390
-        $this->use_captcha = false;
2391
-        $this->recaptcha_theme = 'light';
2392
-        $this->recaptcha_type = 'image';
2393
-        $this->recaptcha_language = 'en';
2394
-        $this->recaptcha_publickey = null;
2395
-        $this->recaptcha_privatekey = null;
2396
-        $this->recaptcha_width = 500;
2397
-        $this->default_maximum_number_of_tickets = 10;
2398
-    }
2399
-
2400
-
2401
-
2402
-    /**
2403
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2404
-     *
2405
-     * @since 4.8.8.rc.019
2406
-     */
2407
-    public function do_hooks()
2408
-    {
2409
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2410
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2411
-    }
2412 1953
 
1954
+/**
1955
+ * Config class for storing info on the Organization
1956
+ */
1957
+class EE_Organization_Config extends EE_Config_Base
1958
+{
2413 1959
 
1960
+	/**
1961
+	 * @var string $name
1962
+	 * eg EE4.1
1963
+	 */
1964
+	public $name;
1965
+
1966
+	/**
1967
+	 * @var string $address_1
1968
+	 * eg 123 Onna Road
1969
+	 */
1970
+	public $address_1;
1971
+
1972
+	/**
1973
+	 * @var string $address_2
1974
+	 * eg PO Box 123
1975
+	 */
1976
+	public $address_2;
1977
+
1978
+	/**
1979
+	 * @var string $city
1980
+	 * eg Inna City
1981
+	 */
1982
+	public $city;
1983
+
1984
+	/**
1985
+	 * @var int $STA_ID
1986
+	 * eg 4
1987
+	 */
1988
+	public $STA_ID;
1989
+
1990
+	/**
1991
+	 * @var string $CNT_ISO
1992
+	 * eg US
1993
+	 */
1994
+	public $CNT_ISO;
1995
+
1996
+	/**
1997
+	 * @var string $zip
1998
+	 * eg 12345  or V1A 2B3
1999
+	 */
2000
+	public $zip;
2001
+
2002
+	/**
2003
+	 * @var string $email
2004
+	 * eg [email protected]
2005
+	 */
2006
+	public $email;
2007
+
2008
+
2009
+	/**
2010
+	 * @var string $phone
2011
+	 * eg. 111-111-1111
2012
+	 */
2013
+	public $phone;
2014
+
2015
+
2016
+	/**
2017
+	 * @var string $vat
2018
+	 * VAT/Tax Number
2019
+	 */
2020
+	public $vat;
2021
+
2022
+	/**
2023
+	 * @var string $logo_url
2024
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2025
+	 */
2026
+	public $logo_url;
2027
+
2028
+
2029
+	/**
2030
+	 * The below are all various properties for holding links to organization social network profiles
2031
+	 *
2032
+	 * @var string
2033
+	 */
2034
+	/**
2035
+	 * facebook (facebook.com/profile.name)
2036
+	 *
2037
+	 * @var string
2038
+	 */
2039
+	public $facebook;
2040
+
2041
+
2042
+	/**
2043
+	 * twitter (twitter.com/twitter_handle)
2044
+	 *
2045
+	 * @var string
2046
+	 */
2047
+	public $twitter;
2048
+
2049
+
2050
+	/**
2051
+	 * linkedin (linkedin.com/in/profile_name)
2052
+	 *
2053
+	 * @var string
2054
+	 */
2055
+	public $linkedin;
2056
+
2057
+
2058
+	/**
2059
+	 * pinterest (www.pinterest.com/profile_name)
2060
+	 *
2061
+	 * @var string
2062
+	 */
2063
+	public $pinterest;
2064
+
2065
+
2066
+	/**
2067
+	 * google+ (google.com/+profileName)
2068
+	 *
2069
+	 * @var string
2070
+	 */
2071
+	public $google;
2072
+
2073
+
2074
+	/**
2075
+	 * instagram (instagram.com/handle)
2076
+	 *
2077
+	 * @var string
2078
+	 */
2079
+	public $instagram;
2080
+
2081
+
2082
+
2083
+	/**
2084
+	 *    class constructor
2085
+	 *
2086
+	 * @access    public
2087
+	 */
2088
+	public function __construct()
2089
+	{
2090
+		// set default organization settings
2091
+		$this->name = get_bloginfo('name');
2092
+		$this->address_1 = '123 Onna Road';
2093
+		$this->address_2 = 'PO Box 123';
2094
+		$this->city = 'Inna City';
2095
+		$this->STA_ID = 4;
2096
+		$this->CNT_ISO = 'US';
2097
+		$this->zip = '12345';
2098
+		$this->email = get_bloginfo('admin_email');
2099
+		$this->phone = '';
2100
+		$this->vat = '123456789';
2101
+		$this->logo_url = '';
2102
+		$this->facebook = '';
2103
+		$this->twitter = '';
2104
+		$this->linkedin = '';
2105
+		$this->pinterest = '';
2106
+		$this->google = '';
2107
+		$this->instagram = '';
2108
+	}
2414 2109
 
2415
-    /**
2416
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2417
-     * field matches the config setting for default_STS_ID.
2418
-     */
2419
-    public function set_default_reg_status_on_EEM_Event()
2420
-    {
2421
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2422
-    }
2110
+}
2423 2111
 
2424 2112
 
2425
-    /**
2426
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2427
-     * for Events matches the config setting for default_maximum_number_of_tickets
2428
-     */
2429
-    public function set_default_max_ticket_on_EEM_Event()
2430
-    {
2431
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2432
-    }
2433 2113
 
2114
+/**
2115
+ * Class for defining what's in the EE_Config relating to currency
2116
+ */
2117
+class EE_Currency_Config extends EE_Config_Base
2118
+{
2434 2119
 
2120
+	/**
2121
+	 * @var string $code
2122
+	 * eg 'US'
2123
+	 */
2124
+	public $code;
2125
+
2126
+	/**
2127
+	 * @var string $name
2128
+	 * eg 'Dollar'
2129
+	 */
2130
+	public $name;
2131
+
2132
+	/**
2133
+	 * plural name
2134
+	 *
2135
+	 * @var string $plural
2136
+	 * eg 'Dollars'
2137
+	 */
2138
+	public $plural;
2139
+
2140
+	/**
2141
+	 * currency sign
2142
+	 *
2143
+	 * @var string $sign
2144
+	 * eg '$'
2145
+	 */
2146
+	public $sign;
2147
+
2148
+	/**
2149
+	 * Whether the currency sign should come before the number or not
2150
+	 *
2151
+	 * @var boolean $sign_b4
2152
+	 */
2153
+	public $sign_b4;
2154
+
2155
+	/**
2156
+	 * How many digits should come after the decimal place
2157
+	 *
2158
+	 * @var int $dec_plc
2159
+	 */
2160
+	public $dec_plc;
2161
+
2162
+	/**
2163
+	 * Symbol to use for decimal mark
2164
+	 *
2165
+	 * @var string $dec_mrk
2166
+	 * eg '.'
2167
+	 */
2168
+	public $dec_mrk;
2169
+
2170
+	/**
2171
+	 * Symbol to use for thousands
2172
+	 *
2173
+	 * @var string $thsnds
2174
+	 * eg ','
2175
+	 */
2176
+	public $thsnds;
2177
+
2178
+
2179
+
2180
+	/**
2181
+	 *    class constructor
2182
+	 *
2183
+	 * @access    public
2184
+	 * @param string $CNT_ISO
2185
+	 * @throws \EE_Error
2186
+	 */
2187
+	public function __construct($CNT_ISO = '')
2188
+	{
2189
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2190
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2191
+		// get country code from organization settings or use default
2192
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2193
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2194
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2195
+			: '';
2196
+		// but override if requested
2197
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2198
+		// 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
2199
+		if (
2200
+			! empty($CNT_ISO)
2201
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2202
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2203
+		) {
2204
+			// retrieve the country settings from the db, just in case they have been customized
2205
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2206
+			if ($country instanceof EE_Country) {
2207
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2208
+				$this->name = $country->currency_name_single();    // Dollar
2209
+				$this->plural = $country->currency_name_plural();    // Dollars
2210
+				$this->sign = $country->currency_sign();            // currency sign: $
2211
+				$this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2212
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2213
+				$this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2214
+				$this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2215
+			}
2216
+		}
2217
+		// fallback to hardcoded defaults, in case the above failed
2218
+		if (empty($this->code)) {
2219
+			// set default currency settings
2220
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2221
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2222
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2223
+			$this->sign = '$';    // currency sign: $
2224
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2225
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2226
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2227
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2228
+		}
2229
+	}
2230
+}
2435 2231
 
2436
-    /**
2437
-     * @return boolean
2438
-     */
2439
-    public function track_invalid_checkout_access()
2440
-    {
2441
-        return $this->track_invalid_checkout_access;
2442
-    }
2443 2232
 
2444 2233
 
2234
+/**
2235
+ * Class for defining what's in the EE_Config relating to registration settings
2236
+ */
2237
+class EE_Registration_Config extends EE_Config_Base
2238
+{
2445 2239
 
2446
-    /**
2447
-     * @param boolean $track_invalid_checkout_access
2448
-     */
2449
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2450
-    {
2451
-        $this->track_invalid_checkout_access = filter_var(
2452
-            $track_invalid_checkout_access,
2453
-            FILTER_VALIDATE_BOOLEAN
2454
-        );
2455
-    }
2240
+	/**
2241
+	 * Default registration status
2242
+	 *
2243
+	 * @var string $default_STS_ID
2244
+	 * eg 'RPP'
2245
+	 */
2246
+	public $default_STS_ID;
2247
+
2248
+
2249
+	/**
2250
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2251
+	 * registrations)
2252
+	 * @var int
2253
+	 */
2254
+	public $default_maximum_number_of_tickets;
2255
+
2256
+
2257
+	/**
2258
+	 * level of validation to apply to email addresses
2259
+	 *
2260
+	 * @var string $email_validation_level
2261
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2262
+	 */
2263
+	public $email_validation_level;
2264
+
2265
+	/**
2266
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2267
+	 *
2268
+	 * @var boolean $show_pending_payment_options
2269
+	 */
2270
+	public $show_pending_payment_options;
2271
+
2272
+	/**
2273
+	 * Whether to skip the registration confirmation page
2274
+	 *
2275
+	 * @var boolean $skip_reg_confirmation
2276
+	 */
2277
+	public $skip_reg_confirmation;
2278
+
2279
+	/**
2280
+	 * an array of SPCO reg steps where:
2281
+	 *        the keys denotes the reg step order
2282
+	 *        each element consists of an array with the following elements:
2283
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2284
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2285
+	 *            "slug" => the URL param used to trigger the reg step
2286
+	 *
2287
+	 * @var array $reg_steps
2288
+	 */
2289
+	public $reg_steps;
2290
+
2291
+	/**
2292
+	 * Whether registration confirmation should be the last page of SPCO
2293
+	 *
2294
+	 * @var boolean $reg_confirmation_last
2295
+	 */
2296
+	public $reg_confirmation_last;
2297
+
2298
+	/**
2299
+	 * Whether or not to enable the EE Bot Trap
2300
+	 *
2301
+	 * @var boolean $use_bot_trap
2302
+	 */
2303
+	public $use_bot_trap;
2304
+
2305
+	/**
2306
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2307
+	 *
2308
+	 * @var boolean $use_encryption
2309
+	 */
2310
+	public $use_encryption;
2311
+
2312
+	/**
2313
+	 * Whether or not to use ReCaptcha
2314
+	 *
2315
+	 * @var boolean $use_captcha
2316
+	 */
2317
+	public $use_captcha;
2318
+
2319
+	/**
2320
+	 * ReCaptcha Theme
2321
+	 *
2322
+	 * @var string $recaptcha_theme
2323
+	 *    options: 'dark    ', 'light'
2324
+	 */
2325
+	public $recaptcha_theme;
2326
+
2327
+	/**
2328
+	 * ReCaptcha Type
2329
+	 *
2330
+	 * @var string $recaptcha_type
2331
+	 *    options: 'audio', 'image'
2332
+	 */
2333
+	public $recaptcha_type;
2334
+
2335
+	/**
2336
+	 * ReCaptcha language
2337
+	 *
2338
+	 * @var string $recaptcha_language
2339
+	 * eg 'en'
2340
+	 */
2341
+	public $recaptcha_language;
2342
+
2343
+	/**
2344
+	 * ReCaptcha public key
2345
+	 *
2346
+	 * @var string $recaptcha_publickey
2347
+	 */
2348
+	public $recaptcha_publickey;
2349
+
2350
+	/**
2351
+	 * ReCaptcha private key
2352
+	 *
2353
+	 * @var string $recaptcha_privatekey
2354
+	 */
2355
+	public $recaptcha_privatekey;
2356
+
2357
+	/**
2358
+	 * ReCaptcha width
2359
+	 *
2360
+	 * @var int $recaptcha_width
2361
+	 * @deprecated
2362
+	 */
2363
+	public $recaptcha_width;
2364
+
2365
+	/**
2366
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2367
+	 *
2368
+	 * @var boolean $track_invalid_checkout_access
2369
+	 */
2370
+	protected $track_invalid_checkout_access = true;
2371
+
2372
+
2373
+
2374
+	/**
2375
+	 *    class constructor
2376
+	 *
2377
+	 * @access    public
2378
+	 */
2379
+	public function __construct()
2380
+	{
2381
+		// set default registration settings
2382
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2383
+		$this->email_validation_level = 'wp_default';
2384
+		$this->show_pending_payment_options = true;
2385
+		$this->skip_reg_confirmation = false;
2386
+		$this->reg_steps = array();
2387
+		$this->reg_confirmation_last = false;
2388
+		$this->use_bot_trap = true;
2389
+		$this->use_encryption = true;
2390
+		$this->use_captcha = false;
2391
+		$this->recaptcha_theme = 'light';
2392
+		$this->recaptcha_type = 'image';
2393
+		$this->recaptcha_language = 'en';
2394
+		$this->recaptcha_publickey = null;
2395
+		$this->recaptcha_privatekey = null;
2396
+		$this->recaptcha_width = 500;
2397
+		$this->default_maximum_number_of_tickets = 10;
2398
+	}
2399
+
2400
+
2401
+
2402
+	/**
2403
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2404
+	 *
2405
+	 * @since 4.8.8.rc.019
2406
+	 */
2407
+	public function do_hooks()
2408
+	{
2409
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2410
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2411
+	}
2412
+
2413
+
2414
+
2415
+	/**
2416
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2417
+	 * field matches the config setting for default_STS_ID.
2418
+	 */
2419
+	public function set_default_reg_status_on_EEM_Event()
2420
+	{
2421
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2422
+	}
2423
+
2424
+
2425
+	/**
2426
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2427
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2428
+	 */
2429
+	public function set_default_max_ticket_on_EEM_Event()
2430
+	{
2431
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2432
+	}
2433
+
2434
+
2435
+
2436
+	/**
2437
+	 * @return boolean
2438
+	 */
2439
+	public function track_invalid_checkout_access()
2440
+	{
2441
+		return $this->track_invalid_checkout_access;
2442
+	}
2443
+
2444
+
2445
+
2446
+	/**
2447
+	 * @param boolean $track_invalid_checkout_access
2448
+	 */
2449
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2450
+	{
2451
+		$this->track_invalid_checkout_access = filter_var(
2452
+			$track_invalid_checkout_access,
2453
+			FILTER_VALIDATE_BOOLEAN
2454
+		);
2455
+	}
2456 2456
 
2457 2457
 
2458 2458
 
@@ -2466,160 +2466,160 @@  discard block
 block discarded – undo
2466 2466
 class EE_Admin_Config extends EE_Config_Base
2467 2467
 {
2468 2468
 
2469
-    /**
2470
-     * @var boolean $use_personnel_manager
2471
-     */
2472
-    public $use_personnel_manager;
2473
-
2474
-    /**
2475
-     * @var boolean $use_dashboard_widget
2476
-     */
2477
-    public $use_dashboard_widget;
2478
-
2479
-    /**
2480
-     * @var int $events_in_dashboard
2481
-     */
2482
-    public $events_in_dashboard;
2483
-
2484
-    /**
2485
-     * @var boolean $use_event_timezones
2486
-     */
2487
-    public $use_event_timezones;
2488
-
2489
-    /**
2490
-     * @var boolean $use_full_logging
2491
-     */
2492
-    public $use_full_logging;
2493
-
2494
-    /**
2495
-     * @var string $log_file_name
2496
-     */
2497
-    public $log_file_name;
2498
-
2499
-    /**
2500
-     * @var string $debug_file_name
2501
-     */
2502
-    public $debug_file_name;
2503
-
2504
-    /**
2505
-     * @var boolean $use_remote_logging
2506
-     */
2507
-    public $use_remote_logging;
2508
-
2509
-    /**
2510
-     * @var string $remote_logging_url
2511
-     */
2512
-    public $remote_logging_url;
2513
-
2514
-    /**
2515
-     * @var boolean $show_reg_footer
2516
-     */
2517
-    public $show_reg_footer;
2518
-
2519
-    /**
2520
-     * @var string $affiliate_id
2521
-     */
2522
-    public $affiliate_id;
2523
-
2524
-    /**
2525
-     * help tours on or off (global setting)
2526
-     *
2527
-     * @var boolean
2528
-     */
2529
-    public $help_tour_activation;
2530
-
2531
-    /**
2532
-     * adds extra layer of encoding to session data to prevent serialization errors
2533
-     * but is incompatible with some server configuration errors
2534
-     * if you get "500 internal server errors" during registration, try turning this on
2535
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2536
-     *
2537
-     * @var boolean $encode_session_data
2538
-     */
2539
-    private $encode_session_data = false;
2540
-
2541
-
2542
-
2543
-    /**
2544
-     *    class constructor
2545
-     *
2546
-     * @access    public
2547
-     */
2548
-    public function __construct()
2549
-    {
2550
-        // set default general admin settings
2551
-        $this->use_personnel_manager = true;
2552
-        $this->use_dashboard_widget = true;
2553
-        $this->events_in_dashboard = 30;
2554
-        $this->use_event_timezones = false;
2555
-        $this->use_full_logging = false;
2556
-        $this->use_remote_logging = false;
2557
-        $this->remote_logging_url = null;
2558
-        $this->show_reg_footer = true;
2559
-        $this->affiliate_id = 'default';
2560
-        $this->help_tour_activation = true;
2561
-        $this->encode_session_data = false;
2562
-    }
2563
-
2564
-
2565
-
2566
-    /**
2567
-     * @param bool $reset
2568
-     * @return string
2569
-     */
2570
-    public function log_file_name($reset = false)
2571
-    {
2572
-        if (empty($this->log_file_name) || $reset) {
2573
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2574
-            EE_Config::instance()->update_espresso_config(false, false);
2575
-        }
2576
-        return $this->log_file_name;
2577
-    }
2578
-
2579
-
2580
-
2581
-    /**
2582
-     * @param bool $reset
2583
-     * @return string
2584
-     */
2585
-    public function debug_file_name($reset = false)
2586
-    {
2587
-        if (empty($this->debug_file_name) || $reset) {
2588
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2589
-            EE_Config::instance()->update_espresso_config(false, false);
2590
-        }
2591
-        return $this->debug_file_name;
2592
-    }
2593
-
2594
-
2595
-
2596
-    /**
2597
-     * @return string
2598
-     */
2599
-    public function affiliate_id()
2600
-    {
2601
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2602
-    }
2603
-
2604
-
2605
-
2606
-    /**
2607
-     * @return boolean
2608
-     */
2609
-    public function encode_session_data()
2610
-    {
2611
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2612
-    }
2613
-
2614
-
2615
-
2616
-    /**
2617
-     * @param boolean $encode_session_data
2618
-     */
2619
-    public function set_encode_session_data($encode_session_data)
2620
-    {
2621
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2622
-    }
2469
+	/**
2470
+	 * @var boolean $use_personnel_manager
2471
+	 */
2472
+	public $use_personnel_manager;
2473
+
2474
+	/**
2475
+	 * @var boolean $use_dashboard_widget
2476
+	 */
2477
+	public $use_dashboard_widget;
2478
+
2479
+	/**
2480
+	 * @var int $events_in_dashboard
2481
+	 */
2482
+	public $events_in_dashboard;
2483
+
2484
+	/**
2485
+	 * @var boolean $use_event_timezones
2486
+	 */
2487
+	public $use_event_timezones;
2488
+
2489
+	/**
2490
+	 * @var boolean $use_full_logging
2491
+	 */
2492
+	public $use_full_logging;
2493
+
2494
+	/**
2495
+	 * @var string $log_file_name
2496
+	 */
2497
+	public $log_file_name;
2498
+
2499
+	/**
2500
+	 * @var string $debug_file_name
2501
+	 */
2502
+	public $debug_file_name;
2503
+
2504
+	/**
2505
+	 * @var boolean $use_remote_logging
2506
+	 */
2507
+	public $use_remote_logging;
2508
+
2509
+	/**
2510
+	 * @var string $remote_logging_url
2511
+	 */
2512
+	public $remote_logging_url;
2513
+
2514
+	/**
2515
+	 * @var boolean $show_reg_footer
2516
+	 */
2517
+	public $show_reg_footer;
2518
+
2519
+	/**
2520
+	 * @var string $affiliate_id
2521
+	 */
2522
+	public $affiliate_id;
2523
+
2524
+	/**
2525
+	 * help tours on or off (global setting)
2526
+	 *
2527
+	 * @var boolean
2528
+	 */
2529
+	public $help_tour_activation;
2530
+
2531
+	/**
2532
+	 * adds extra layer of encoding to session data to prevent serialization errors
2533
+	 * but is incompatible with some server configuration errors
2534
+	 * if you get "500 internal server errors" during registration, try turning this on
2535
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2536
+	 *
2537
+	 * @var boolean $encode_session_data
2538
+	 */
2539
+	private $encode_session_data = false;
2540
+
2541
+
2542
+
2543
+	/**
2544
+	 *    class constructor
2545
+	 *
2546
+	 * @access    public
2547
+	 */
2548
+	public function __construct()
2549
+	{
2550
+		// set default general admin settings
2551
+		$this->use_personnel_manager = true;
2552
+		$this->use_dashboard_widget = true;
2553
+		$this->events_in_dashboard = 30;
2554
+		$this->use_event_timezones = false;
2555
+		$this->use_full_logging = false;
2556
+		$this->use_remote_logging = false;
2557
+		$this->remote_logging_url = null;
2558
+		$this->show_reg_footer = true;
2559
+		$this->affiliate_id = 'default';
2560
+		$this->help_tour_activation = true;
2561
+		$this->encode_session_data = false;
2562
+	}
2563
+
2564
+
2565
+
2566
+	/**
2567
+	 * @param bool $reset
2568
+	 * @return string
2569
+	 */
2570
+	public function log_file_name($reset = false)
2571
+	{
2572
+		if (empty($this->log_file_name) || $reset) {
2573
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2574
+			EE_Config::instance()->update_espresso_config(false, false);
2575
+		}
2576
+		return $this->log_file_name;
2577
+	}
2578
+
2579
+
2580
+
2581
+	/**
2582
+	 * @param bool $reset
2583
+	 * @return string
2584
+	 */
2585
+	public function debug_file_name($reset = false)
2586
+	{
2587
+		if (empty($this->debug_file_name) || $reset) {
2588
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2589
+			EE_Config::instance()->update_espresso_config(false, false);
2590
+		}
2591
+		return $this->debug_file_name;
2592
+	}
2593
+
2594
+
2595
+
2596
+	/**
2597
+	 * @return string
2598
+	 */
2599
+	public function affiliate_id()
2600
+	{
2601
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2602
+	}
2603
+
2604
+
2605
+
2606
+	/**
2607
+	 * @return boolean
2608
+	 */
2609
+	public function encode_session_data()
2610
+	{
2611
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2612
+	}
2613
+
2614
+
2615
+
2616
+	/**
2617
+	 * @param boolean $encode_session_data
2618
+	 */
2619
+	public function set_encode_session_data($encode_session_data)
2620
+	{
2621
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2622
+	}
2623 2623
 
2624 2624
 
2625 2625
 
@@ -2633,71 +2633,71 @@  discard block
 block discarded – undo
2633 2633
 class EE_Template_Config extends EE_Config_Base
2634 2634
 {
2635 2635
 
2636
-    /**
2637
-     * @var boolean $enable_default_style
2638
-     */
2639
-    public $enable_default_style;
2640
-
2641
-    /**
2642
-     * @var string $custom_style_sheet
2643
-     */
2644
-    public $custom_style_sheet;
2645
-
2646
-    /**
2647
-     * @var boolean $display_address_in_regform
2648
-     */
2649
-    public $display_address_in_regform;
2650
-
2651
-    /**
2652
-     * @var int $display_description_on_multi_reg_page
2653
-     */
2654
-    public $display_description_on_multi_reg_page;
2655
-
2656
-    /**
2657
-     * @var boolean $use_custom_templates
2658
-     */
2659
-    public $use_custom_templates;
2660
-
2661
-    /**
2662
-     * @var string $current_espresso_theme
2663
-     */
2664
-    public $current_espresso_theme;
2665
-
2666
-    /**
2667
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2668
-     */
2669
-    public $EED_Ticket_Selector;
2670
-
2671
-    /**
2672
-     * @var EE_Event_Single_Config $EED_Event_Single
2673
-     */
2674
-    public $EED_Event_Single;
2675
-
2676
-    /**
2677
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2678
-     */
2679
-    public $EED_Events_Archive;
2680
-
2681
-
2682
-
2683
-    /**
2684
-     *    class constructor
2685
-     *
2686
-     * @access    public
2687
-     */
2688
-    public function __construct()
2689
-    {
2690
-        // set default template settings
2691
-        $this->enable_default_style = true;
2692
-        $this->custom_style_sheet = null;
2693
-        $this->display_address_in_regform = true;
2694
-        $this->display_description_on_multi_reg_page = false;
2695
-        $this->use_custom_templates = false;
2696
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2697
-        $this->EED_Event_Single = null;
2698
-        $this->EED_Events_Archive = null;
2699
-        $this->EED_Ticket_Selector = null;
2700
-    }
2636
+	/**
2637
+	 * @var boolean $enable_default_style
2638
+	 */
2639
+	public $enable_default_style;
2640
+
2641
+	/**
2642
+	 * @var string $custom_style_sheet
2643
+	 */
2644
+	public $custom_style_sheet;
2645
+
2646
+	/**
2647
+	 * @var boolean $display_address_in_regform
2648
+	 */
2649
+	public $display_address_in_regform;
2650
+
2651
+	/**
2652
+	 * @var int $display_description_on_multi_reg_page
2653
+	 */
2654
+	public $display_description_on_multi_reg_page;
2655
+
2656
+	/**
2657
+	 * @var boolean $use_custom_templates
2658
+	 */
2659
+	public $use_custom_templates;
2660
+
2661
+	/**
2662
+	 * @var string $current_espresso_theme
2663
+	 */
2664
+	public $current_espresso_theme;
2665
+
2666
+	/**
2667
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2668
+	 */
2669
+	public $EED_Ticket_Selector;
2670
+
2671
+	/**
2672
+	 * @var EE_Event_Single_Config $EED_Event_Single
2673
+	 */
2674
+	public $EED_Event_Single;
2675
+
2676
+	/**
2677
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2678
+	 */
2679
+	public $EED_Events_Archive;
2680
+
2681
+
2682
+
2683
+	/**
2684
+	 *    class constructor
2685
+	 *
2686
+	 * @access    public
2687
+	 */
2688
+	public function __construct()
2689
+	{
2690
+		// set default template settings
2691
+		$this->enable_default_style = true;
2692
+		$this->custom_style_sheet = null;
2693
+		$this->display_address_in_regform = true;
2694
+		$this->display_description_on_multi_reg_page = false;
2695
+		$this->use_custom_templates = false;
2696
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2697
+		$this->EED_Event_Single = null;
2698
+		$this->EED_Events_Archive = null;
2699
+		$this->EED_Ticket_Selector = null;
2700
+	}
2701 2701
 
2702 2702
 }
2703 2703
 
@@ -2709,115 +2709,115 @@  discard block
 block discarded – undo
2709 2709
 class EE_Map_Config extends EE_Config_Base
2710 2710
 {
2711 2711
 
2712
-    /**
2713
-     * @var boolean $use_google_maps
2714
-     */
2715
-    public $use_google_maps;
2716
-
2717
-    /**
2718
-     * @var string $api_key
2719
-     */
2720
-    public $google_map_api_key;
2721
-
2722
-    /**
2723
-     * @var int $event_details_map_width
2724
-     */
2725
-    public $event_details_map_width;
2726
-
2727
-    /**
2728
-     * @var int $event_details_map_height
2729
-     */
2730
-    public $event_details_map_height;
2731
-
2732
-    /**
2733
-     * @var int $event_details_map_zoom
2734
-     */
2735
-    public $event_details_map_zoom;
2736
-
2737
-    /**
2738
-     * @var boolean $event_details_display_nav
2739
-     */
2740
-    public $event_details_display_nav;
2741
-
2742
-    /**
2743
-     * @var boolean $event_details_nav_size
2744
-     */
2745
-    public $event_details_nav_size;
2746
-
2747
-    /**
2748
-     * @var string $event_details_control_type
2749
-     */
2750
-    public $event_details_control_type;
2751
-
2752
-    /**
2753
-     * @var string $event_details_map_align
2754
-     */
2755
-    public $event_details_map_align;
2756
-
2757
-    /**
2758
-     * @var int $event_list_map_width
2759
-     */
2760
-    public $event_list_map_width;
2761
-
2762
-    /**
2763
-     * @var int $event_list_map_height
2764
-     */
2765
-    public $event_list_map_height;
2766
-
2767
-    /**
2768
-     * @var int $event_list_map_zoom
2769
-     */
2770
-    public $event_list_map_zoom;
2771
-
2772
-    /**
2773
-     * @var boolean $event_list_display_nav
2774
-     */
2775
-    public $event_list_display_nav;
2776
-
2777
-    /**
2778
-     * @var boolean $event_list_nav_size
2779
-     */
2780
-    public $event_list_nav_size;
2781
-
2782
-    /**
2783
-     * @var string $event_list_control_type
2784
-     */
2785
-    public $event_list_control_type;
2786
-
2787
-    /**
2788
-     * @var string $event_list_map_align
2789
-     */
2790
-    public $event_list_map_align;
2791
-
2792
-
2793
-
2794
-    /**
2795
-     *    class constructor
2796
-     *
2797
-     * @access    public
2798
-     */
2799
-    public function __construct()
2800
-    {
2801
-        // set default map settings
2802
-        $this->use_google_maps = true;
2803
-        $this->google_map_api_key = '';
2804
-        // for event details pages (reg page)
2805
-        $this->event_details_map_width = 585;            // ee_map_width_single
2806
-        $this->event_details_map_height = 362;            // ee_map_height_single
2807
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2808
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2809
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2810
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2811
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2812
-        // for event list pages
2813
-        $this->event_list_map_width = 300;            // ee_map_width
2814
-        $this->event_list_map_height = 185;        // ee_map_height
2815
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2816
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2817
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2818
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2819
-        $this->event_list_map_align = 'center';            // ee_map_align
2820
-    }
2712
+	/**
2713
+	 * @var boolean $use_google_maps
2714
+	 */
2715
+	public $use_google_maps;
2716
+
2717
+	/**
2718
+	 * @var string $api_key
2719
+	 */
2720
+	public $google_map_api_key;
2721
+
2722
+	/**
2723
+	 * @var int $event_details_map_width
2724
+	 */
2725
+	public $event_details_map_width;
2726
+
2727
+	/**
2728
+	 * @var int $event_details_map_height
2729
+	 */
2730
+	public $event_details_map_height;
2731
+
2732
+	/**
2733
+	 * @var int $event_details_map_zoom
2734
+	 */
2735
+	public $event_details_map_zoom;
2736
+
2737
+	/**
2738
+	 * @var boolean $event_details_display_nav
2739
+	 */
2740
+	public $event_details_display_nav;
2741
+
2742
+	/**
2743
+	 * @var boolean $event_details_nav_size
2744
+	 */
2745
+	public $event_details_nav_size;
2746
+
2747
+	/**
2748
+	 * @var string $event_details_control_type
2749
+	 */
2750
+	public $event_details_control_type;
2751
+
2752
+	/**
2753
+	 * @var string $event_details_map_align
2754
+	 */
2755
+	public $event_details_map_align;
2756
+
2757
+	/**
2758
+	 * @var int $event_list_map_width
2759
+	 */
2760
+	public $event_list_map_width;
2761
+
2762
+	/**
2763
+	 * @var int $event_list_map_height
2764
+	 */
2765
+	public $event_list_map_height;
2766
+
2767
+	/**
2768
+	 * @var int $event_list_map_zoom
2769
+	 */
2770
+	public $event_list_map_zoom;
2771
+
2772
+	/**
2773
+	 * @var boolean $event_list_display_nav
2774
+	 */
2775
+	public $event_list_display_nav;
2776
+
2777
+	/**
2778
+	 * @var boolean $event_list_nav_size
2779
+	 */
2780
+	public $event_list_nav_size;
2781
+
2782
+	/**
2783
+	 * @var string $event_list_control_type
2784
+	 */
2785
+	public $event_list_control_type;
2786
+
2787
+	/**
2788
+	 * @var string $event_list_map_align
2789
+	 */
2790
+	public $event_list_map_align;
2791
+
2792
+
2793
+
2794
+	/**
2795
+	 *    class constructor
2796
+	 *
2797
+	 * @access    public
2798
+	 */
2799
+	public function __construct()
2800
+	{
2801
+		// set default map settings
2802
+		$this->use_google_maps = true;
2803
+		$this->google_map_api_key = '';
2804
+		// for event details pages (reg page)
2805
+		$this->event_details_map_width = 585;            // ee_map_width_single
2806
+		$this->event_details_map_height = 362;            // ee_map_height_single
2807
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2808
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2809
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2810
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2811
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2812
+		// for event list pages
2813
+		$this->event_list_map_width = 300;            // ee_map_width
2814
+		$this->event_list_map_height = 185;        // ee_map_height
2815
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2816
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2817
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2818
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2819
+		$this->event_list_map_align = 'center';            // ee_map_align
2820
+	}
2821 2821
 
2822 2822
 }
2823 2823
 
@@ -2829,47 +2829,47 @@  discard block
 block discarded – undo
2829 2829
 class EE_Events_Archive_Config extends EE_Config_Base
2830 2830
 {
2831 2831
 
2832
-    public $display_status_banner;
2832
+	public $display_status_banner;
2833 2833
 
2834
-    public $display_description;
2834
+	public $display_description;
2835 2835
 
2836
-    public $display_ticket_selector;
2836
+	public $display_ticket_selector;
2837 2837
 
2838
-    public $display_datetimes;
2838
+	public $display_datetimes;
2839 2839
 
2840
-    public $display_venue;
2840
+	public $display_venue;
2841 2841
 
2842
-    public $display_expired_events;
2842
+	public $display_expired_events;
2843 2843
 
2844
-    public $use_sortable_display_order;
2844
+	public $use_sortable_display_order;
2845 2845
 
2846
-    public $display_order_tickets;
2846
+	public $display_order_tickets;
2847 2847
 
2848
-    public $display_order_datetimes;
2848
+	public $display_order_datetimes;
2849 2849
 
2850
-    public $display_order_event;
2850
+	public $display_order_event;
2851 2851
 
2852
-    public $display_order_venue;
2852
+	public $display_order_venue;
2853 2853
 
2854 2854
 
2855 2855
 
2856
-    /**
2857
-     *    class constructor
2858
-     */
2859
-    public function __construct()
2860
-    {
2861
-        $this->display_status_banner = 0;
2862
-        $this->display_description = 1;
2863
-        $this->display_ticket_selector = 0;
2864
-        $this->display_datetimes = 1;
2865
-        $this->display_venue = 0;
2866
-        $this->display_expired_events = 0;
2867
-        $this->use_sortable_display_order = false;
2868
-        $this->display_order_tickets = 100;
2869
-        $this->display_order_datetimes = 110;
2870
-        $this->display_order_event = 120;
2871
-        $this->display_order_venue = 130;
2872
-    }
2856
+	/**
2857
+	 *    class constructor
2858
+	 */
2859
+	public function __construct()
2860
+	{
2861
+		$this->display_status_banner = 0;
2862
+		$this->display_description = 1;
2863
+		$this->display_ticket_selector = 0;
2864
+		$this->display_datetimes = 1;
2865
+		$this->display_venue = 0;
2866
+		$this->display_expired_events = 0;
2867
+		$this->use_sortable_display_order = false;
2868
+		$this->display_order_tickets = 100;
2869
+		$this->display_order_datetimes = 110;
2870
+		$this->display_order_event = 120;
2871
+		$this->display_order_venue = 130;
2872
+	}
2873 2873
 }
2874 2874
 
2875 2875
 
@@ -2880,35 +2880,35 @@  discard block
 block discarded – undo
2880 2880
 class EE_Event_Single_Config extends EE_Config_Base
2881 2881
 {
2882 2882
 
2883
-    public $display_status_banner_single;
2883
+	public $display_status_banner_single;
2884 2884
 
2885
-    public $display_venue;
2885
+	public $display_venue;
2886 2886
 
2887
-    public $use_sortable_display_order;
2887
+	public $use_sortable_display_order;
2888 2888
 
2889
-    public $display_order_tickets;
2889
+	public $display_order_tickets;
2890 2890
 
2891
-    public $display_order_datetimes;
2891
+	public $display_order_datetimes;
2892 2892
 
2893
-    public $display_order_event;
2893
+	public $display_order_event;
2894 2894
 
2895
-    public $display_order_venue;
2895
+	public $display_order_venue;
2896 2896
 
2897 2897
 
2898 2898
 
2899
-    /**
2900
-     *    class constructor
2901
-     */
2902
-    public function __construct()
2903
-    {
2904
-        $this->display_status_banner_single = 0;
2905
-        $this->display_venue = 1;
2906
-        $this->use_sortable_display_order = false;
2907
-        $this->display_order_tickets = 100;
2908
-        $this->display_order_datetimes = 110;
2909
-        $this->display_order_event = 120;
2910
-        $this->display_order_venue = 130;
2911
-    }
2899
+	/**
2900
+	 *    class constructor
2901
+	 */
2902
+	public function __construct()
2903
+	{
2904
+		$this->display_status_banner_single = 0;
2905
+		$this->display_venue = 1;
2906
+		$this->use_sortable_display_order = false;
2907
+		$this->display_order_tickets = 100;
2908
+		$this->display_order_datetimes = 110;
2909
+		$this->display_order_event = 120;
2910
+		$this->display_order_venue = 130;
2911
+	}
2912 2912
 }
2913 2913
 
2914 2914
 
@@ -2919,152 +2919,152 @@  discard block
 block discarded – undo
2919 2919
 class EE_Ticket_Selector_Config extends EE_Config_Base
2920 2920
 {
2921 2921
 
2922
-    /**
2923
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2924
-     */
2925
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2926
-
2927
-    /**
2928
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2929
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2930
-     */
2931
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2932
-
2933
-    /**
2934
-     * @var boolean $show_ticket_sale_columns
2935
-     */
2936
-    public $show_ticket_sale_columns;
2937
-
2938
-    /**
2939
-     * @var boolean $show_ticket_details
2940
-     */
2941
-    public $show_ticket_details;
2942
-
2943
-    /**
2944
-     * @var boolean $show_expired_tickets
2945
-     */
2946
-    public $show_expired_tickets;
2947
-
2948
-    /**
2949
-     * whether or not to display a dropdown box populated with event datetimes
2950
-     * that toggles which tickets are displayed for a ticket selector.
2951
-     * uses one of the *_DATETIME_SELECTOR constants defined above
2952
-     *
2953
-     * @var string $show_datetime_selector
2954
-     */
2955
-    private $show_datetime_selector = 'no_datetime_selector';
2956
-
2957
-    /**
2958
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
2959
-     *
2960
-     * @var int $datetime_selector_threshold
2961
-     */
2962
-    private $datetime_selector_threshold = 3;
2963
-
2964
-
2965
-
2966
-    /**
2967
-     *    class constructor
2968
-     */
2969
-    public function __construct()
2970
-    {
2971
-        $this->show_ticket_sale_columns = true;
2972
-        $this->show_ticket_details = true;
2973
-        $this->show_expired_tickets = true;
2974
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2975
-        $this->datetime_selector_threshold = 3;
2976
-    }
2977
-
2978
-
2979
-
2980
-    /**
2981
-     * returns true if a datetime selector should be displayed
2982
-     *
2983
-     * @param array $datetimes
2984
-     * @return bool
2985
-     */
2986
-    public function showDatetimeSelector(array $datetimes)
2987
-    {
2988
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
2989
-        return ! (
2990
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
2991
-            || (
2992
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
2993
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
2994
-            )
2995
-        );
2996
-    }
2997
-
2998
-
2999
-
3000
-    /**
3001
-     * @return string
3002
-     */
3003
-    public function getShowDatetimeSelector()
3004
-    {
3005
-        return $this->show_datetime_selector;
3006
-    }
3007
-
3008
-
3009
-
3010
-    /**
3011
-     * @param bool $keys_only
3012
-     * @return array
3013
-     */
3014
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3015
-    {
3016
-        return $keys_only
3017
-            ? array(
3018
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3019
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3020
-            )
3021
-            : array(
3022
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3023
-                    'Do not show date & time filter', 'event_espresso'
3024
-                ),
3025
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3026
-                    'Maybe show date & time filter', 'event_espresso'
3027
-                ),
3028
-            );
3029
-    }
3030
-
3031
-
3032
-
3033
-    /**
3034
-     * @param string $show_datetime_selector
3035
-     */
3036
-    public function setShowDatetimeSelector($show_datetime_selector)
3037
-    {
3038
-        $this->show_datetime_selector = in_array(
3039
-            $show_datetime_selector,
3040
-            $this->getShowDatetimeSelectorOptions(),
3041
-            true
3042
-        )
3043
-            ? $show_datetime_selector
3044
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3045
-    }
3046
-
3047
-
3048
-
3049
-    /**
3050
-     * @return int
3051
-     */
3052
-    public function getDatetimeSelectorThreshold()
3053
-    {
3054
-        return $this->datetime_selector_threshold;
3055
-    }
3056
-
3057
-
3058
-
3059
-
3060
-    /**
3061
-     * @param int $datetime_selector_threshold
3062
-     */
3063
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3064
-    {
3065
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3066
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3067
-    }
2922
+	/**
2923
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2924
+	 */
2925
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2926
+
2927
+	/**
2928
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2929
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2930
+	 */
2931
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2932
+
2933
+	/**
2934
+	 * @var boolean $show_ticket_sale_columns
2935
+	 */
2936
+	public $show_ticket_sale_columns;
2937
+
2938
+	/**
2939
+	 * @var boolean $show_ticket_details
2940
+	 */
2941
+	public $show_ticket_details;
2942
+
2943
+	/**
2944
+	 * @var boolean $show_expired_tickets
2945
+	 */
2946
+	public $show_expired_tickets;
2947
+
2948
+	/**
2949
+	 * whether or not to display a dropdown box populated with event datetimes
2950
+	 * that toggles which tickets are displayed for a ticket selector.
2951
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
2952
+	 *
2953
+	 * @var string $show_datetime_selector
2954
+	 */
2955
+	private $show_datetime_selector = 'no_datetime_selector';
2956
+
2957
+	/**
2958
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
2959
+	 *
2960
+	 * @var int $datetime_selector_threshold
2961
+	 */
2962
+	private $datetime_selector_threshold = 3;
2963
+
2964
+
2965
+
2966
+	/**
2967
+	 *    class constructor
2968
+	 */
2969
+	public function __construct()
2970
+	{
2971
+		$this->show_ticket_sale_columns = true;
2972
+		$this->show_ticket_details = true;
2973
+		$this->show_expired_tickets = true;
2974
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2975
+		$this->datetime_selector_threshold = 3;
2976
+	}
2977
+
2978
+
2979
+
2980
+	/**
2981
+	 * returns true if a datetime selector should be displayed
2982
+	 *
2983
+	 * @param array $datetimes
2984
+	 * @return bool
2985
+	 */
2986
+	public function showDatetimeSelector(array $datetimes)
2987
+	{
2988
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
2989
+		return ! (
2990
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
2991
+			|| (
2992
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
2993
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
2994
+			)
2995
+		);
2996
+	}
2997
+
2998
+
2999
+
3000
+	/**
3001
+	 * @return string
3002
+	 */
3003
+	public function getShowDatetimeSelector()
3004
+	{
3005
+		return $this->show_datetime_selector;
3006
+	}
3007
+
3008
+
3009
+
3010
+	/**
3011
+	 * @param bool $keys_only
3012
+	 * @return array
3013
+	 */
3014
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3015
+	{
3016
+		return $keys_only
3017
+			? array(
3018
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3019
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3020
+			)
3021
+			: array(
3022
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3023
+					'Do not show date & time filter', 'event_espresso'
3024
+				),
3025
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3026
+					'Maybe show date & time filter', 'event_espresso'
3027
+				),
3028
+			);
3029
+	}
3030
+
3031
+
3032
+
3033
+	/**
3034
+	 * @param string $show_datetime_selector
3035
+	 */
3036
+	public function setShowDatetimeSelector($show_datetime_selector)
3037
+	{
3038
+		$this->show_datetime_selector = in_array(
3039
+			$show_datetime_selector,
3040
+			$this->getShowDatetimeSelectorOptions(),
3041
+			true
3042
+		)
3043
+			? $show_datetime_selector
3044
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3045
+	}
3046
+
3047
+
3048
+
3049
+	/**
3050
+	 * @return int
3051
+	 */
3052
+	public function getDatetimeSelectorThreshold()
3053
+	{
3054
+		return $this->datetime_selector_threshold;
3055
+	}
3056
+
3057
+
3058
+
3059
+
3060
+	/**
3061
+	 * @param int $datetime_selector_threshold
3062
+	 */
3063
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3064
+	{
3065
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3066
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3067
+	}
3068 3068
 
3069 3069
 
3070 3070
 
@@ -3082,85 +3082,85 @@  discard block
 block discarded – undo
3082 3082
 class EE_Environment_Config extends EE_Config_Base
3083 3083
 {
3084 3084
 
3085
-    /**
3086
-     * Hold any php environment variables that we want to track.
3087
-     *
3088
-     * @var stdClass;
3089
-     */
3090
-    public $php;
3091
-
3092
-
3093
-
3094
-    /**
3095
-     *    constructor
3096
-     */
3097
-    public function __construct()
3098
-    {
3099
-        $this->php = new stdClass();
3100
-        $this->_set_php_values();
3101
-    }
3102
-
3103
-
3104
-
3105
-    /**
3106
-     * This sets the php environment variables.
3107
-     *
3108
-     * @since 4.4.0
3109
-     * @return void
3110
-     */
3111
-    protected function _set_php_values()
3112
-    {
3113
-        $this->php->max_input_vars = ini_get('max_input_vars');
3114
-        $this->php->version = phpversion();
3115
-    }
3116
-
3117
-
3118
-
3119
-    /**
3120
-     * helper method for determining whether input_count is
3121
-     * reaching the potential maximum the server can handle
3122
-     * according to max_input_vars
3123
-     *
3124
-     * @param int   $input_count the count of input vars.
3125
-     * @return array {
3126
-     *                           An array that represents whether available space and if no available space the error
3127
-     *                           message.
3128
-     * @type bool   $has_space   whether more inputs can be added.
3129
-     * @type string $msg         Any message to be displayed.
3130
-     *                           }
3131
-     */
3132
-    public function max_input_vars_limit_check($input_count = 0)
3133
-    {
3134
-        if (! empty($this->php->max_input_vars)
3135
-            && ($input_count >= $this->php->max_input_vars)
3136
-            && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3137
-        ) {
3138
-            return sprintf(
3139
-                __(
3140
-                    'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3141
-                    'event_espresso'
3142
-                ),
3143
-                '<br>',
3144
-                $input_count,
3145
-                $this->php->max_input_vars
3146
-            );
3147
-        } else {
3148
-            return '';
3149
-        }
3150
-    }
3151
-
3152
-
3153
-
3154
-    /**
3155
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3156
-     *
3157
-     * @since 4.4.1
3158
-     * @return void
3159
-     */
3160
-    public function recheck_values()
3161
-    {
3162
-        $this->_set_php_values();
3163
-    }
3085
+	/**
3086
+	 * Hold any php environment variables that we want to track.
3087
+	 *
3088
+	 * @var stdClass;
3089
+	 */
3090
+	public $php;
3091
+
3092
+
3093
+
3094
+	/**
3095
+	 *    constructor
3096
+	 */
3097
+	public function __construct()
3098
+	{
3099
+		$this->php = new stdClass();
3100
+		$this->_set_php_values();
3101
+	}
3102
+
3103
+
3104
+
3105
+	/**
3106
+	 * This sets the php environment variables.
3107
+	 *
3108
+	 * @since 4.4.0
3109
+	 * @return void
3110
+	 */
3111
+	protected function _set_php_values()
3112
+	{
3113
+		$this->php->max_input_vars = ini_get('max_input_vars');
3114
+		$this->php->version = phpversion();
3115
+	}
3116
+
3117
+
3118
+
3119
+	/**
3120
+	 * helper method for determining whether input_count is
3121
+	 * reaching the potential maximum the server can handle
3122
+	 * according to max_input_vars
3123
+	 *
3124
+	 * @param int   $input_count the count of input vars.
3125
+	 * @return array {
3126
+	 *                           An array that represents whether available space and if no available space the error
3127
+	 *                           message.
3128
+	 * @type bool   $has_space   whether more inputs can be added.
3129
+	 * @type string $msg         Any message to be displayed.
3130
+	 *                           }
3131
+	 */
3132
+	public function max_input_vars_limit_check($input_count = 0)
3133
+	{
3134
+		if (! empty($this->php->max_input_vars)
3135
+			&& ($input_count >= $this->php->max_input_vars)
3136
+			&& (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3137
+		) {
3138
+			return sprintf(
3139
+				__(
3140
+					'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3141
+					'event_espresso'
3142
+				),
3143
+				'<br>',
3144
+				$input_count,
3145
+				$this->php->max_input_vars
3146
+			);
3147
+		} else {
3148
+			return '';
3149
+		}
3150
+	}
3151
+
3152
+
3153
+
3154
+	/**
3155
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3156
+	 *
3157
+	 * @since 4.4.1
3158
+	 * @return void
3159
+	 */
3160
+	public function recheck_values()
3161
+	{
3162
+		$this->_set_php_values();
3163
+	}
3164 3164
 
3165 3165
 
3166 3166
 
@@ -3178,22 +3178,22 @@  discard block
 block discarded – undo
3178 3178
 class EE_Tax_Config extends EE_Config_Base
3179 3179
 {
3180 3180
 
3181
-    /*
3181
+	/*
3182 3182
      * flag to indicate whether or not to display ticket prices with the taxes included
3183 3183
      *
3184 3184
      * @var boolean $prices_displayed_including_taxes
3185 3185
      */
3186
-    public $prices_displayed_including_taxes;
3186
+	public $prices_displayed_including_taxes;
3187 3187
 
3188 3188
 
3189 3189
 
3190
-    /**
3191
-     *    class constructor
3192
-     */
3193
-    public function __construct()
3194
-    {
3195
-        $this->prices_displayed_including_taxes = true;
3196
-    }
3190
+	/**
3191
+	 *    class constructor
3192
+	 */
3193
+	public function __construct()
3194
+	{
3195
+		$this->prices_displayed_including_taxes = true;
3196
+	}
3197 3197
 }
3198 3198
 
3199 3199
 
@@ -3208,17 +3208,17 @@  discard block
 block discarded – undo
3208 3208
 class EE_Messages_Config extends EE_Config_Base
3209 3209
 {
3210 3210
 
3211
-    /**
3212
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3213
-     * A value of 0 represents never deleting.  Default is 0.
3214
-     *
3215
-     * @var integer
3216
-     */
3217
-    public $delete_threshold;
3218
-
3219
-    public function __construct() {
3220
-        $this->delete_threshold = 0;
3221
-    }
3211
+	/**
3212
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3213
+	 * A value of 0 represents never deleting.  Default is 0.
3214
+	 *
3215
+	 * @var integer
3216
+	 */
3217
+	public $delete_threshold;
3218
+
3219
+	public function __construct() {
3220
+		$this->delete_threshold = 0;
3221
+	}
3222 3222
 }
3223 3223
 
3224 3224
 
@@ -3230,34 +3230,34 @@  discard block
 block discarded – undo
3230 3230
 class EE_Gateway_Config extends EE_Config_Base
3231 3231
 {
3232 3232
 
3233
-    /**
3234
-     * Array with keys that are payment gateways slugs, and values are arrays
3235
-     * with any config info the gateway wants to store
3236
-     *
3237
-     * @var array
3238
-     */
3239
-    public $payment_settings;
3240
-
3241
-    /**
3242
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3243
-     * the gateway is stored in the uploads directory
3244
-     *
3245
-     * @var array
3246
-     */
3247
-    public $active_gateways;
3248
-
3249
-
3250
-
3251
-    /**
3252
-     *    class constructor
3253
-     *
3254
-     * @deprecated
3255
-     */
3256
-    public function __construct()
3257
-    {
3258
-        $this->payment_settings = array();
3259
-        $this->active_gateways = array('Invoice' => false);
3260
-    }
3233
+	/**
3234
+	 * Array with keys that are payment gateways slugs, and values are arrays
3235
+	 * with any config info the gateway wants to store
3236
+	 *
3237
+	 * @var array
3238
+	 */
3239
+	public $payment_settings;
3240
+
3241
+	/**
3242
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3243
+	 * the gateway is stored in the uploads directory
3244
+	 *
3245
+	 * @var array
3246
+	 */
3247
+	public $active_gateways;
3248
+
3249
+
3250
+
3251
+	/**
3252
+	 *    class constructor
3253
+	 *
3254
+	 * @deprecated
3255
+	 */
3256
+	public function __construct()
3257
+	{
3258
+		$this->payment_settings = array();
3259
+		$this->active_gateways = array('Invoice' => false);
3260
+	}
3261 3261
 }
3262 3262
 
3263 3263
 // End of file EE_Config.core.php
Please login to merge, or discard this patch.
modules/events_archive/EED_Events_Archive.module.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -37,19 +37,19 @@  discard block
 block discarded – undo
37 37
 	 */
38 38
 	protected static $using_get_the_excerpt = false;
39 39
 
40
-    /**
41
-     * Used to flag when the event list is being called from an external iframe.
42
-     *
43
-     * @var bool $iframe
44
-     */
45
-    protected static $iframe = false;
46
-
47
-    /**
40
+	/**
41
+	 * Used to flag when the event list is being called from an external iframe.
42
+	 *
43
+	 * @var bool $iframe
44
+	 */
45
+	protected static $iframe = false;
46
+
47
+	/**
48 48
 	 * @var \EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton $_iframe_embed_button
49 49
 	 */
50 50
 	private static $_iframe_embed_button;
51 51
 
52
-    /**
52
+	/**
53 53
 	 * @type EE_Template_Part_Manager $template_parts
54 54
 	 */
55 55
 	protected $template_parts;
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
 
220 220
 
221 221
 	/**
222
-     * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
223
-     *
224
-     * @return    void
222
+	 * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
223
+	 *
224
+	 * @return    void
225 225
 	 */
226 226
 	public function event_list() {
227 227
 		// ensure valid EE_Events_Archive_Config() object exists
@@ -232,36 +232,36 @@  discard block
 block discarded – undo
232 232
 
233 233
 
234 234
 
235
-    /**
236
-     * @access    public
237
-     * @return    void
238
-     * @throws \EE_Error
239
-     * @throws \DomainException
240
-     */
235
+	/**
236
+	 * @access    public
237
+	 * @return    void
238
+	 * @throws \EE_Error
239
+	 * @throws \DomainException
240
+	 */
241 241
 	public function event_list_iframe() {
242
-        \EED_Events_Archive::$iframe = true;
242
+		\EED_Events_Archive::$iframe = true;
243 243
 		$event_list_iframe = new EventsArchiveIframe( $this );
244 244
 		$event_list_iframe->display();
245 245
 	}
246 246
 
247 247
 
248 248
 
249
-    /**
250
-     * @access public
251
-     * @return string
252
-     */
249
+	/**
250
+	 * @access public
251
+	 * @return string
252
+	 */
253 253
 	public static function is_iframe() {
254
-        return \EED_Events_Archive::$iframe;
254
+		return \EED_Events_Archive::$iframe;
255 255
 	}
256 256
 
257 257
 
258 258
 
259
-    /**
260
-     * @access public
261
-     * @return string
262
-     */
259
+	/**
260
+	 * @access public
261
+	 * @return string
262
+	 */
263 263
 	public static function link_target() {
264
-        return \EED_Events_Archive::$iframe ? ' target="_blank"' : '';
264
+		return \EED_Events_Archive::$iframe ? ' target="_blank"' : '';
265 265
 	}
266 266
 
267 267
 
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
 			}
290 290
 			// if NOT a custom template
291 291
 			if (
292
-                apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
292
+				apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
293 293
 				|| EE_Registry::instance()
294
-                    ->load_core( 'Front_Controller' )
295
-                    ->get_selected_template() !== 'archive-espresso_events.php'
294
+					->load_core( 'Front_Controller' )
295
+					->get_selected_template() !== 'archive-espresso_events.php'
296 296
 			) {
297 297
 				// don't display entry meta because the existing theme will take care of that
298 298
 				add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' );
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 		// no further password checks required atm
418 418
 		add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' );
419 419
 		// we need to first remove this callback from being applied to the_content() or the_excerpt()
420
-        // (otherwise it will recurse and blow up the interweb)
420
+		// (otherwise it will recurse and blow up the interweb)
421 421
 		remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1 );
422 422
 		remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1 );
423 423
 		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	 *  @return 	void
603 603
 	 */
604 604
 	public function load_event_list_assets() {
605
-        do_action( 'AHEE__EED_Events_Archive__before_load_assets' );
605
+		do_action( 'AHEE__EED_Events_Archive__before_load_assets' );
606 606
 		add_filter( 'FHEE_load_EE_Session', '__return_true' );
607 607
 		add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
608 608
 		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 );
Please login to merge, or discard this patch.
Spacing   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton;
4 4
 use EventEspresso\modules\events_archive\EventsArchiveIframe;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
7 7
 /**
8 8
  * Event Espresso
9 9
  *
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @return EED_Events_Archive
61 61
 	 */
62 62
 	public static function instance() {
63
-		return parent::get_instance( __CLASS__ );
63
+		return parent::get_instance(__CLASS__);
64 64
 	}
65 65
 
66 66
 
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
 	 *  @return 	void
73 73
 	 */
74 74
 	public static function set_hooks() {
75
-		EE_Config::register_route( EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run' );
76
-		EE_Config::register_route( 'event_list', 'Events_Archive', 'event_list' );
77
-		EE_Config::register_route( 'iframe', 'Events_Archive', 'event_list_iframe', 'event_list' );
78
-		add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 );
75
+		EE_Config::register_route(EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run');
76
+		EE_Config::register_route('event_list', 'Events_Archive', 'event_list');
77
+		EE_Config::register_route('iframe', 'Events_Archive', 'event_list_iframe', 'event_list');
78
+		add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
79 79
 	}
80 80
 
81 81
 	/**
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
 	 *  @return 	void
86 86
 	 */
87 87
 	public static function set_hooks_admin() {
88
-		add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 );
88
+		add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
89 89
 		// hook into the end of the \EE_Admin_Page::_load_page_dependencies()
90 90
 		// to load assets for "espresso_events" page on the "default" route (action)
91 91
 		add_action(
92 92
 			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default',
93
-			array( 'EED_Events_Archive', 'event_list_iframe_embed_button' ),
93
+			array('EED_Events_Archive', 'event_list_iframe_embed_button'),
94 94
 			10
95 95
 		);
96 96
 	}
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 *  @return 	void
106 106
 	 */
107 107
 	public static function set_definitions() {
108
-		define( 'EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
109
-		define( 'EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
108
+		define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
109
+		define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
110 110
 	}
111 111
 
112 112
 
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
 	/**
115 115
 	 * set up EE_Events_Archive_Config
116 116
 	 */
117
-	protected function set_config(){
118
-		$this->set_config_section( 'template_settings' );
119
-		$this->set_config_class( 'EE_Events_Archive_Config' );
120
-		$this->set_config_name( 'EED_Events_Archive' );
117
+	protected function set_config() {
118
+		$this->set_config_section('template_settings');
119
+		$this->set_config_class('EE_Events_Archive_Config');
120
+		$this->set_config_name('EED_Events_Archive');
121 121
 	}
122 122
 
123 123
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @return EventListIframeEmbedButton
127 127
 	 */
128 128
 	public static function get_iframe_embed_button() {
129
-		if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton ) {
129
+		if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
130 130
 			self::$_iframe_embed_button = new EventListIframeEmbedButton();
131 131
 		}
132 132
 		return self::$_iframe_embed_button;
@@ -152,35 +152,35 @@  discard block
 block discarded – undo
152 152
 	 * @param \EE_Events_Archive_Config $config
153 153
 	 * @return \EE_Template_Part_Manager
154 154
 	 */
155
-	public function initialize_template_parts( EE_Events_Archive_Config $config = null ) {
155
+	public function initialize_template_parts(EE_Events_Archive_Config $config = null) {
156 156
 		$config = $config instanceof EE_Events_Archive_Config ? $config : $this->config();
157 157
 		EEH_Autoloader::instance()->register_template_part_autoloaders();
158 158
 		$template_parts = new EE_Template_Part_Manager();
159 159
 		$template_parts->add_template_part(
160 160
 			'tickets',
161
-			__( 'Ticket Selector', 'event_espresso' ),
161
+			__('Ticket Selector', 'event_espresso'),
162 162
 			'content-espresso_events-tickets.php',
163 163
 			$config->display_order_tickets
164 164
 		);
165 165
 		$template_parts->add_template_part(
166 166
 			'datetimes',
167
-			__( 'Dates and Times', 'event_espresso' ),
167
+			__('Dates and Times', 'event_espresso'),
168 168
 			'content-espresso_events-datetimes.php',
169 169
 			$config->display_order_datetimes
170 170
 		);
171 171
 		$template_parts->add_template_part(
172 172
 			'event',
173
-			__( 'Event Description', 'event_espresso' ),
173
+			__('Event Description', 'event_espresso'),
174 174
 			'content-espresso_events-details.php',
175 175
 			$config->display_order_event
176 176
 		);
177 177
 		$template_parts->add_template_part(
178 178
 			'venue',
179
-			__( 'Venue Information', 'event_espresso' ),
179
+			__('Venue Information', 'event_espresso'),
180 180
 			'content-espresso_events-venues.php',
181 181
 			$config->display_order_venue
182 182
 		);
183
-		do_action( 'AHEE__EED_Event_Archive__initialize_template_parts', $template_parts );
183
+		do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts);
184 184
 		return $template_parts;
185 185
 	}
186 186
 
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
 	 * @param WP $WP
194 194
 	 * @return    void
195 195
 	 */
196
-	public function run( $WP ) {
197
-		do_action( 'AHEE__EED_Events_Archive__before_run' );
196
+	public function run($WP) {
197
+		do_action('AHEE__EED_Events_Archive__before_run');
198 198
 		// ensure valid EE_Events_Archive_Config() object exists
199 199
 		$this->set_config();
200 200
 		/** @type EE_Events_Archive_Config $config */
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
 		EEH_Event_Query::add_query_filters();
207 207
 		// set params that will get used by the filters
208 208
 		EEH_Event_Query::set_query_params(
209
-			'', 	// month
210
-			'', 	// category
211
-			$config->display_expired_events, 	// show_expired
212
-			'start_date', 	// orderby
209
+			'', // month
210
+			'', // category
211
+			$config->display_expired_events, // show_expired
212
+			'start_date', // orderby
213 213
 			'ASC' 	// sort
214 214
 		);
215 215
 		// check what template is loaded
216
-		add_filter( 'template_include',  array( $this, 'template_include' ), 999, 1 );
216
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
217 217
 	}
218 218
 
219 219
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      */
241 241
 	public function event_list_iframe() {
242 242
         \EED_Events_Archive::$iframe = true;
243
-		$event_list_iframe = new EventsArchiveIframe( $this );
243
+		$event_list_iframe = new EventsArchiveIframe($this);
244 244
 		$event_list_iframe->display();
245 245
 	}
246 246
 
@@ -278,34 +278,34 @@  discard block
 block discarded – undo
278 278
 	 * @param string $template
279 279
 	 * @return    string
280 280
 	 */
281
-	public function template_include( $template = '' ) {
281
+	public function template_include($template = '') {
282 282
 		// don't add content filter for dedicated EE child themes or private posts
283
-		if ( ! EEH_Template::is_espresso_theme() ) {
283
+		if ( ! EEH_Template::is_espresso_theme()) {
284 284
 			/** @type EE_Events_Archive_Config $config */
285 285
 			$config = $this->config();
286 286
 			// add status banner ?
287
-			if ( $config->display_status_banner ) {
288
-				add_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100, 2 );
287
+			if ($config->display_status_banner) {
288
+				add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2);
289 289
 			}
290 290
 			// if NOT a custom template
291 291
 			if (
292 292
                 apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
293 293
 				|| EE_Registry::instance()
294
-                    ->load_core( 'Front_Controller' )
294
+                    ->load_core('Front_Controller')
295 295
                     ->get_selected_template() !== 'archive-espresso_events.php'
296 296
 			) {
297 297
 				// don't display entry meta because the existing theme will take care of that
298
-				add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' );
298
+				add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true');
299 299
 			// load functions.php file for the theme (loaded by WP if using child theme)
300 300
 				EEH_Template::load_espresso_theme_functions();
301 301
 				// because we don't know if the theme is using the_excerpt()
302
-				add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1, 1 );
302
+				add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1, 1);
303 303
 				// or the_content
304
-				add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1, 1 );
304
+				add_filter('the_content', array('EED_Events_Archive', 'event_details'), 1, 1);
305 305
 				// and just in case they are running get_the_excerpt() which DESTROYS things
306
-				add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
306
+				add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
307 307
 				// don't display entry meta because the existing theme will take care of that
308
-				add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' );
308
+				add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
309 309
 			}
310 310
 		}
311 311
 		return $template;
@@ -320,17 +320,17 @@  discard block
 block discarded – undo
320 320
 	 * 	@param		string 	$excerpt
321 321
 	 * 	@return 		string
322 322
 	 */
323
-	public static function get_the_excerpt( $excerpt = '' ) {
324
-		if ( post_password_required() ) {
323
+	public static function get_the_excerpt($excerpt = '') {
324
+		if (post_password_required()) {
325 325
 			return $excerpt;
326 326
 		}
327
-		if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) {
328
-			remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1 );
329
-			remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1 );
330
-			$excerpt = EED_Events_Archive::event_details( $excerpt );
327
+		if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) {
328
+			remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1);
329
+			remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 1);
330
+			$excerpt = EED_Events_Archive::event_details($excerpt);
331 331
 		} else {
332 332
 			EED_Events_Archive::$using_get_the_excerpt = true;
333
-			add_filter( 'wp_trim_excerpt', array( 'EED_Events_Archive', 'end_get_the_excerpt' ), 999, 1 );
333
+			add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1);
334 334
 		}
335 335
 		return $excerpt;
336 336
 	}
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 	 * @param  string $text
345 345
 	 * @return string
346 346
 	 */
347
-	public static function end_get_the_excerpt( $text = '' ) {
347
+	public static function end_get_the_excerpt($text = '') {
348 348
 		EED_Events_Archive::$using_get_the_excerpt = false;
349 349
 		return $text;
350 350
 	}
@@ -359,10 +359,10 @@  discard block
 block discarded – undo
359 359
 	 * @param 		string 		$id
360 360
 	 * @return 		string
361 361
 	 */
362
-	public static function the_title( $title = '', $id = '' ) {
362
+	public static function the_title($title = '', $id = '') {
363 363
 	global $post;
364
-	if ( $post instanceof WP_Post ) {
365
-		return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID  ) . $title :  $title;
364
+	if ($post instanceof WP_Post) {
365
+		return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title;
366 366
 	}
367 367
 	return $title;
368 368
 }
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	 * 	@param		string 	$content
377 377
 	 * 	@return 		string
378 378
 	 */
379
-	public static function event_details( $content ) {
379
+	public static function event_details($content) {
380 380
 		global $post;
381 381
 		static $current_post_ID = 0;
382 382
 		if (
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
 			&& ! EED_Events_Archive::$using_get_the_excerpt
386 386
 			&& ! post_password_required()
387 387
 			&& (
388
-				apply_filters( 'FHEE__EES_Espresso_Events__process_shortcode__true', false )
389
-				|| ! apply_filters( 'FHEE__content_espresso_events__template_loaded', false )
388
+				apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false)
389
+				|| ! apply_filters('FHEE__content_espresso_events__template_loaded', false)
390 390
 			)
391 391
 		) {
392 392
 			// Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 			// We want to allow those plugins to still do their thing and have access to our content, but depending on
396 396
 			// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
397 397
 			// so the following allows this filter to be applied multiple times, but only once for real
398
-			$current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0;
399
-			if ( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order ) {
398
+			$current_post_ID = did_action('loop_start') ? $post->ID : 0;
399
+			if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) {
400 400
 				$content = \EED_Events_Archive::use_sortable_display_order();
401 401
 			} else {
402 402
 				$content = \EED_Events_Archive::use_filterable_display_order();
@@ -415,21 +415,21 @@  discard block
 block discarded – undo
415 415
 	 */
416 416
 	protected static function use_sortable_display_order() {
417 417
 		// no further password checks required atm
418
-		add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' );
418
+		add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true');
419 419
 		// we need to first remove this callback from being applied to the_content() or the_excerpt()
420 420
         // (otherwise it will recurse and blow up the interweb)
421
-		remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1 );
422
-		remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1 );
423
-		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
421
+		remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1);
422
+		remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 1);
423
+		remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
424 424
 		// now add additional content depending on whether event is using the_excerpt() or the_content()
425 425
 		EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts();
426
-		$content = EEH_Template::locate_template( 'content-espresso_events-details.php' );
427
-		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content );
426
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
427
+		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content);
428 428
 		// re-add our main filters (or else the next event won't have them)
429
-		add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1, 1 );
430
-		add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1, 1 );
431
-		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
432
-		remove_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' );
429
+		add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1, 1);
430
+		add_filter('the_content', array('EED_Events_Archive', 'event_details'), 1, 1);
431
+		add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
432
+		remove_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true');
433 433
 		return $content;
434 434
 	}
435 435
 
@@ -444,22 +444,22 @@  discard block
 block discarded – undo
444 444
 	protected static function use_filterable_display_order() {
445 445
 		// we need to first remove this callback from being applied to the_content()
446 446
 		// (otherwise it will recurse and blow up the interweb)
447
-		remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1 );
448
-		remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1 );
449
-		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
447
+		remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1);
448
+		remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 1);
449
+		remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
450 450
 		//now add additional content depending on whether event is using the_excerpt() or the_content()
451 451
 		EED_Events_Archive::_add_additional_excerpt_filters();
452 452
 		EED_Events_Archive::_add_additional_content_filters();
453
-		do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters' );
453
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters');
454 454
 		// now load our template
455
-		$content = EEH_Template::locate_template( 'content-espresso_events-details.php' );
455
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
456 456
 		// re-add our main filters (or else the next event won't have them)
457
-		add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1, 1 );
458
-		add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1, 1 );
459
-		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
457
+		add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1, 1);
458
+		add_filter('the_content', array('EED_Events_Archive', 'event_details'), 1, 1);
459
+		add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
460 460
 		// but remove the other filters so that they don't get applied to the next post
461 461
 		EED_Events_Archive::_remove_additional_events_archive_filters();
462
-		do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters' );
462
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters');
463 463
 		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
464 464
 		//return ! empty( $template ) ? $template : $content;
465 465
 		return $content;
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 	 * 	@param		string 	$content
475 475
 	 *  	@return 		string
476 476
 	 */
477
-	public static function event_datetimes( $content ) {
478
-		if ( post_password_required() ) {
477
+	public static function event_datetimes($content) {
478
+		if (post_password_required()) {
479 479
 			return $content;
480 480
 		}
481
-		return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content;
481
+		return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content;
482 482
 	}
483 483
 
484 484
 	/**
@@ -488,11 +488,11 @@  discard block
 block discarded – undo
488 488
 	 * 	@param		string 	$content
489 489
 	 *  	@return 		string
490 490
 	 */
491
-	public static function event_tickets( $content ) {
492
-		if ( post_password_required() ) {
491
+	public static function event_tickets($content) {
492
+		if (post_password_required()) {
493 493
 			return $content;
494 494
 		}
495
-		return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content;
495
+		return EEH_Template::locate_template('content-espresso_events-tickets.php').$content;
496 496
 	}
497 497
 
498 498
 
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
 	 * @param    string $content
505 505
 	 * @return    string
506 506
 	 */
507
-	public static function event_venue( $content ) {
508
-		return EED_Events_Archive::event_venues( $content );
507
+	public static function event_venue($content) {
508
+		return EED_Events_Archive::event_venues($content);
509 509
 	}
510 510
 
511 511
 	/**
@@ -515,11 +515,11 @@  discard block
 block discarded – undo
515 515
 	 * 	@param		string 	$content
516 516
 	 *  	@return 		string
517 517
 	 */
518
-	public static function event_venues( $content ) {
519
-		if ( post_password_required() ) {
518
+	public static function event_venues($content) {
519
+		if (post_password_required()) {
520 520
 			return $content;
521 521
 		}
522
-		return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' );
522
+		return $content.EEH_Template::locate_template('content-espresso_events-venues.php');
523 523
 	}
524 524
 
525 525
 
@@ -531,9 +531,9 @@  discard block
 block discarded – undo
531 531
 	 * @return        void
532 532
 	 */
533 533
 	private static function _add_additional_excerpt_filters() {
534
-		add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110, 1 );
535
-		add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120, 1 );
536
-		add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130, 1 );
534
+		add_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 110, 1);
535
+		add_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 120, 1);
536
+		add_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 130, 1);
537 537
 	}
538 538
 
539 539
 
@@ -545,9 +545,9 @@  discard block
 block discarded – undo
545 545
 	 * @return        void
546 546
 	 */
547 547
 	private static function _add_additional_content_filters() {
548
-		add_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110, 1 );
549
-		add_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120, 1 );
550
-		add_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130, 1 );
548
+		add_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 110, 1);
549
+		add_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 120, 1);
550
+		add_filter('the_content', array('EED_Events_Archive', 'event_venues'), 130, 1);
551 551
 	}
552 552
 
553 553
 
@@ -559,12 +559,12 @@  discard block
 block discarded – undo
559 559
 	 * @return        void
560 560
 	 */
561 561
 	private static function _remove_additional_events_archive_filters() {
562
-		remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110 );
563
-		remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120 );
564
-		remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130 );
565
-		remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110 );
566
-		remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120 );
567
-		remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130 );
562
+		remove_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 110);
563
+		remove_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 120);
564
+		remove_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 130);
565
+		remove_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 110);
566
+		remove_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 120);
567
+		remove_filter('the_content', array('EED_Events_Archive', 'event_venues'), 130);
568 568
 	}
569 569
 
570 570
 
@@ -577,17 +577,17 @@  discard block
 block discarded – undo
577 577
 	 */
578 578
 	public static function remove_all_events_archive_filters() {
579 579
 		//remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
580
-		remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 1 );
581
-		remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1 );
582
-		remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 2 );
583
-		remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 3 );
584
-		remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 4 );
585
-		remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1 );
586
-		remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 2 );
587
-		remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 3 );
588
-		remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 4 );
580
+		remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1);
581
+		remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1);
582
+		remove_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 2);
583
+		remove_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 3);
584
+		remove_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 4);
585
+		remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 1);
586
+		remove_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 2);
587
+		remove_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 3);
588
+		remove_filter('the_content', array('EED_Events_Archive', 'event_venues'), 4);
589 589
 		// don't display entry meta because the existing theme will take care of that
590
-		remove_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' );
590
+		remove_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
591 591
 	}
592 592
 
593 593
 
@@ -602,12 +602,12 @@  discard block
 block discarded – undo
602 602
 	 *  @return 	void
603 603
 	 */
604 604
 	public function load_event_list_assets() {
605
-        do_action( 'AHEE__EED_Events_Archive__before_load_assets' );
606
-		add_filter( 'FHEE_load_EE_Session', '__return_true' );
607
-		add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
608
-		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 );
609
-		if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) {
610
-			add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 );
605
+        do_action('AHEE__EED_Events_Archive__before_load_assets');
606
+		add_filter('FHEE_load_EE_Session', '__return_true');
607
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
608
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
609
+		if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
610
+			add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
611 611
 		}
612 612
 	}
613 613
 
@@ -624,13 +624,13 @@  discard block
 block discarded – undo
624 624
 	 */
625 625
 	public function wp_enqueue_scripts() {
626 626
 		// get some style
627
-		if ( apply_filters( 'FHEE_enable_default_espresso_css', FALSE ) ) {
627
+		if (apply_filters('FHEE_enable_default_espresso_css', FALSE)) {
628 628
 			// first check uploads folder
629
-			if ( EEH_File::is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) {
630
-				wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' ));
629
+			if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) {
630
+				wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default'));
631 631
 			} else {
632 632
 		}
633
-		wp_enqueue_style( $this->theme );
633
+		wp_enqueue_style($this->theme);
634 634
 
635 635
 	}
636 636
 }
@@ -648,8 +648,8 @@  discard block
 block discarded – undo
648 648
 	 */
649 649
 	public static function template_settings_form() {
650 650
 	$template_settings = EE_Registry::instance()->CFG->template_settings;
651
-	$template_settings->EED_Events_Archive = isset( $template_settings->EED_Events_Archive ) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
652
-	$template_settings->EED_Events_Archive = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive );
651
+	$template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
652
+	$template_settings->EED_Events_Archive = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive);
653 653
 	$events_archive_settings = array(
654 654
 		'display_status_banner' => 0,
655 655
 		'display_description' => 1,
@@ -658,8 +658,8 @@  discard block
 block discarded – undo
658 658
 		'display_venue' => 0,
659 659
 		'display_expired_events' => 0
660 660
 	);
661
-	$events_archive_settings = array_merge( $events_archive_settings, (array)$template_settings->EED_Events_Archive );
662
-	EEH_Template::display_template( EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $events_archive_settings );
661
+	$events_archive_settings = array_merge($events_archive_settings, (array) $template_settings->EED_Events_Archive);
662
+	EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', $events_archive_settings);
663 663
 }
664 664
 
665 665
 
@@ -675,16 +675,16 @@  discard block
 block discarded – undo
675 675
 	 *  @param 	EE_Request_Handler $REQ
676 676
 	 *  @return 	EE_Template_Config
677 677
 	 */
678
-	public static function update_template_settings( $CFG, $REQ ) {
678
+	public static function update_template_settings($CFG, $REQ) {
679 679
 		$CFG->EED_Events_Archive = new EE_Events_Archive_Config();
680 680
 		// unless we are resetting the config...
681
-		if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) {
682
-			$CFG->EED_Events_Archive->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0;
683
-			$CFG->EED_Events_Archive->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1;
684
-			$CFG->EED_Events_Archive->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0;
685
-			$CFG->EED_Events_Archive->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1;
686
-			$CFG->EED_Events_Archive->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0;
687
-			$CFG->EED_Events_Archive->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0;			}
681
+		if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) {
682
+			$CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0;
683
+			$CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1;
684
+			$CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0;
685
+			$CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1;
686
+			$CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0;
687
+			$CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; }
688 688
 		return $CFG;
689 689
 	}
690 690
 
@@ -697,10 +697,10 @@  discard block
 block discarded – undo
697 697
 	 * @param string $extra_class
698 698
 	 * @return    string
699 699
 	 */
700
-	public static function event_list_css( $extra_class = '' ) {
701
-		$event_list_css = ! empty( $extra_class ) ? array( $extra_class ) : array();
700
+	public static function event_list_css($extra_class = '') {
701
+		$event_list_css = ! empty($extra_class) ? array($extra_class) : array();
702 702
 		$event_list_css[] = 'espresso-event-list-event';
703
-		return implode( ' ', $event_list_css );
703
+		return implode(' ', $event_list_css);
704 704
 	}
705 705
 
706 706
 
@@ -727,9 +727,9 @@  discard block
 block discarded – undo
727 727
 	 * @param $value
728 728
 	 * @return    bool
729 729
 	 */
730
-	public static function display_description( $value ) {
730
+	public static function display_description($value) {
731 731
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
732
-		$display_description= isset( $config->display_description ) ? $config->display_description : 1;
732
+		$display_description = isset($config->display_description) ? $config->display_description : 1;
733 733
 		return $display_description === $value ? TRUE : FALSE;
734 734
 	}
735 735
 
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 	 */
743 743
 	public static function display_ticket_selector() {
744 744
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
745
-		return isset( $config->display_ticket_selector ) && $config->display_ticket_selector ? TRUE : FALSE;
745
+		return isset($config->display_ticket_selector) && $config->display_ticket_selector ? TRUE : FALSE;
746 746
 	}
747 747
 
748 748
 
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 	 */
756 756
 	public static function display_venue() {
757 757
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
758
-		return isset( $config->display_venue ) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE;
758
+		return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE;
759 759
 	}
760 760
 
761 761
 
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 	 */
768 768
 	public static function display_datetimes() {
769 769
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
770
-		return isset( $config->display_datetimes ) && $config->display_datetimes ? TRUE : FALSE;
770
+		return isset($config->display_datetimes) && $config->display_datetimes ? TRUE : FALSE;
771 771
 }
772 772
 
773 773
 
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 	 *  @return 	string
783 783
 	 */
784 784
 	public static function event_list_title() {
785
-		return apply_filters( 'FHEE__archive_espresso_events_template__upcoming_events_h1', __( 'Upcoming Events', 'event_espresso' ));
785
+		return apply_filters('FHEE__archive_espresso_events_template__upcoming_events_h1', __('Upcoming Events', 'event_espresso'));
786 786
 	}
787 787
 
788 788
 
@@ -791,11 +791,11 @@  discard block
 block discarded – undo
791 791
 	/**
792 792
 	 * 	@since 4.4.0
793 793
 	 */
794
-	public static function _doing_it_wrong_notice( $function = '' ) {
794
+	public static function _doing_it_wrong_notice($function = '') {
795 795
 		EE_Error::doing_it_wrong(
796 796
 			__FUNCTION__,
797 797
 			sprintf(
798
-				__( 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso' ),
798
+				__('EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso'),
799 799
 				$function,
800 800
 				'<br />',
801 801
 				'4.6.0'
@@ -817,89 +817,89 @@  discard block
 block discarded – undo
817 817
 	 * 	@deprecated
818 818
 	 * 	@since 4.4.0
819 819
 	 */
820
-	public function posts_fields( $SQL, WP_Query $wp_query ) {
821
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
822
-		return EEH_Event_Query::posts_fields( $SQL, $wp_query );
820
+	public function posts_fields($SQL, WP_Query $wp_query) {
821
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
822
+		return EEH_Event_Query::posts_fields($SQL, $wp_query);
823 823
 	}
824 824
 	/**
825 825
 	 * 	@deprecated
826 826
 	 * 	@since 4.4.0
827 827
 	 */
828
-	public static function posts_fields_sql_for_orderby( $orderby_params = array() ) {
829
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
830
-		return EEH_Event_Query::posts_fields_sql_for_orderby( $orderby_params );
828
+	public static function posts_fields_sql_for_orderby($orderby_params = array()) {
829
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
830
+		return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params);
831 831
 	}
832 832
 	/**
833 833
 	 * 	@deprecated
834 834
 	 * 	@since 4.4.0
835 835
 	 */
836
-	public function posts_join( $SQL, WP_Query $wp_query ) {
837
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
838
-		return EEH_Event_Query::posts_join( $SQL, $wp_query );
836
+	public function posts_join($SQL, WP_Query $wp_query) {
837
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
838
+		return EEH_Event_Query::posts_join($SQL, $wp_query);
839 839
 	}
840 840
 	/**
841 841
 	 * 	@deprecated
842 842
 	 * 	@since 4.4.0
843 843
 	 */
844
-	public static function posts_join_sql_for_terms( $join_terms = NULL ) {
845
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
846
-		return EEH_Event_Query::posts_join_sql_for_terms( $join_terms );
844
+	public static function posts_join_sql_for_terms($join_terms = NULL) {
845
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
846
+		return EEH_Event_Query::posts_join_sql_for_terms($join_terms);
847 847
 	}
848 848
 	/**
849 849
 	 * 	@deprecated
850 850
 	 * 	@since 4.4.0
851 851
 	 */
852
-	public static function posts_join_for_orderby( $orderby_params = array() ) {
853
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
854
-		return EEH_Event_Query::posts_join_for_orderby( $orderby_params );
852
+	public static function posts_join_for_orderby($orderby_params = array()) {
853
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
854
+		return EEH_Event_Query::posts_join_for_orderby($orderby_params);
855 855
 	}
856 856
 	/**
857 857
 	 * 	@deprecated
858 858
 	 * 	@since 4.4.0
859 859
 	 */
860
-	public function posts_where( $SQL, WP_Query $wp_query ) {
861
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
862
-		return EEH_Event_Query::posts_where( $SQL, $wp_query );
860
+	public function posts_where($SQL, WP_Query $wp_query) {
861
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
862
+		return EEH_Event_Query::posts_where($SQL, $wp_query);
863 863
 	}
864 864
 	/**
865 865
 	 * 	@deprecated
866 866
 	 * 	@since 4.4.0
867 867
 	 */
868
-	public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) {
869
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
870
-		return EEH_Event_Query::posts_where_sql_for_show_expired( $show_expired );
868
+	public static function posts_where_sql_for_show_expired($show_expired = FALSE) {
869
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
870
+		return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired);
871 871
 	}
872 872
 	/**
873 873
 	 * 	@deprecated
874 874
 	 * 	@since 4.4.0
875 875
 	 */
876
-	public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) {
877
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
878
-		return EEH_Event_Query::posts_where_sql_for_event_category_slug( $event_category_slug );
876
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) {
877
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
878
+		return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug);
879 879
 	}
880 880
 	/**
881 881
 	 * 	@deprecated
882 882
 	 * 	@since 4.4.0
883 883
 	 */
884
-	public static function posts_where_sql_for_event_list_month( $month = NULL ) {
885
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
886
-		return EEH_Event_Query::posts_where_sql_for_event_list_month( $month );
884
+	public static function posts_where_sql_for_event_list_month($month = NULL) {
885
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
886
+		return EEH_Event_Query::posts_where_sql_for_event_list_month($month);
887 887
 	}
888 888
 	/**
889 889
 	 * 	@deprecated
890 890
 	 * 	@since 4.4.0
891 891
 	 */
892
-	public function posts_orderby( $SQL, WP_Query $wp_query ) {
893
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
894
-		return EEH_Event_Query::posts_orderby( $SQL, $wp_query );
892
+	public function posts_orderby($SQL, WP_Query $wp_query) {
893
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
894
+		return EEH_Event_Query::posts_orderby($SQL, $wp_query);
895 895
 	}
896 896
 	/**
897 897
 	 * 	@deprecated
898 898
 	 * 	@since 4.4.0
899 899
 	 */
900
-	public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) {
901
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
902
-		return EEH_Event_Query::posts_orderby_sql( $orderby_params, $sort );
900
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') {
901
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
902
+		return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort);
903 903
 	}
904 904
 
905 905
 
@@ -930,8 +930,8 @@  discard block
 block discarded – undo
930 930
  * @param string $extra_class
931 931
  * @return string
932 932
  */
933
-function espresso_event_list_css( $extra_class = '' ) {
934
-	return EED_Events_Archive::event_list_css( $extra_class );
933
+function espresso_event_list_css($extra_class = '') {
934
+	return EED_Events_Archive::event_list_css($extra_class);
935 935
 }
936 936
 
937 937
 /**
@@ -945,14 +945,14 @@  discard block
 block discarded – undo
945 945
  * @return bool
946 946
  */
947 947
 function espresso_display_full_description_in_event_list() {
948
-	return EED_Events_Archive::display_description( 2 );
948
+	return EED_Events_Archive::display_description(2);
949 949
 }
950 950
 
951 951
 /**
952 952
  * @return bool
953 953
  */
954 954
 function espresso_display_excerpt_in_event_list() {
955
-	return EED_Events_Archive::display_description( 1 );
955
+	return EED_Events_Archive::display_description(1);
956 956
 }
957 957
 
958 958
 /**
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/AttendeesReport.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -108,10 +108,10 @@
 block discarded – undo
108 108
 				}
109 109
 			}
110 110
 			$csv_data[] = apply_filters(
111
-			    'FHEE___EventEspresso_core_libraries_batch_JobHandlers_AttendeesReport__get_csv_data__row',
112
-                $csv_row,
113
-                $attendee_row
114
-            );
111
+				'FHEE___EventEspresso_core_libraries_batch_JobHandlers_AttendeesReport__get_csv_data__row',
112
+				$csv_row,
113
+				$attendee_row
114
+			);
115 115
 		}
116 116
 		return $csv_data;
117 117
 	}
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use EventEspressoBatchRequest\Helpers\JobParameters;
19 19
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
20 20
 
21
-if (!defined('EVENT_ESPRESSO_VERSION')) {
21
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
22 22
 	exit('No direct script access allowed');
23 23
 }
24 24
 
@@ -27,84 +27,84 @@  discard block
 block discarded – undo
27 27
 
28 28
 
29 29
 	public function create_job(JobParameters $job_parameters) {
30
-		if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_contacts', 'generating_report' ) ) {
30
+		if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_contacts', 'generating_report')) {
31 31
 			throw new BatchRequestException(
32
-				__( 'You do not have permission to view contacts', 'event_espresso')
32
+				__('You do not have permission to view contacts', 'event_espresso')
33 33
 			);
34 34
 		}
35 35
 		$filepath = $this->create_file_from_job_with_name(
36 36
 			$job_parameters->job_id(),
37 37
 			__('contact-list-report.csv', 'event_espresso')
38 38
 		);
39
-		$job_parameters->add_extra_data( 'filepath', $filepath );
40
-		$job_parameters->set_job_size( $this->count_units_to_process() );
39
+		$job_parameters->add_extra_data('filepath', $filepath);
40
+		$job_parameters->set_job_size($this->count_units_to_process());
41 41
 		//we should also set the header columns
42
-		$csv_data_for_row = $this->get_csv_data( 0, 1 );
43
-		\EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true );
42
+		$csv_data_for_row = $this->get_csv_data(0, 1);
43
+		\EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
44 44
 		//if we actually processed a row there, record it
45
-		if( $job_parameters->job_size() ) {
46
-			$job_parameters->mark_processed( 1 );
45
+		if ($job_parameters->job_size()) {
46
+			$job_parameters->mark_processed(1);
47 47
 		}
48 48
 		return new JobStepResponse(
49 49
 			$job_parameters,
50
-			__( 'Contacts report started successfully...', 'event_espresso' )
50
+			__('Contacts report started successfully...', 'event_espresso')
51 51
 		);
52 52
 	}
53 53
 
54 54
 
55 55
 	public function continue_job(JobParameters $job_parameters, $batch_size = 50) {
56
-		$csv_data = $this->get_csv_data( $job_parameters->units_processed(), $batch_size );
57
-		\EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false );
58
-		$units_processed = count( $csv_data );
59
-		$job_parameters->mark_processed( $units_processed );
56
+		$csv_data = $this->get_csv_data($job_parameters->units_processed(), $batch_size);
57
+		\EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
58
+		$units_processed = count($csv_data);
59
+		$job_parameters->mark_processed($units_processed);
60 60
 		$extra_response_data = array(
61 61
 			'file_url' => ''
62 62
 		);
63
-		if( $units_processed < $batch_size ) {
64
-			$job_parameters->set_status( JobParameters::status_complete );
65
-			$extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) );
63
+		if ($units_processed < $batch_size) {
64
+			$job_parameters->set_status(JobParameters::status_complete);
65
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
66 66
 		}
67 67
 		return new JobStepResponse(
68 68
 				$job_parameters,
69 69
 				sprintf(
70
-					__( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ),
71
-					count( $csv_data ) ),
70
+					__('Wrote %1$s rows to report CSV file...', 'event_espresso'),
71
+					count($csv_data) ),
72 72
 				$extra_response_data );
73 73
 	}
74 74
 
75 75
 
76 76
 	public function cleanup_job(JobParameters $job_parameters) {
77 77
 		$this->_file_helper->delete(
78
-			\EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ),
78
+			\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
79 79
 			true,
80 80
 			'd'
81 81
 		);
82
-		return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) );
82
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
83 83
 	}
84 84
 
85 85
 	public function count_units_to_process() {
86
-		return \EEM_Attendee::instance()->count( array( 'caps' => \EEM_Base::caps_read_admin ));
86
+		return \EEM_Attendee::instance()->count(array('caps' => \EEM_Base::caps_read_admin));
87 87
 	}
88
-	public function get_csv_data( $offset, $limit ) {
88
+	public function get_csv_data($offset, $limit) {
89 89
 		$attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results( 
90 90
 			array( 
91
-				'limit' => array( $offset, $limit ),
92
-				'force_join' => array( 'State', 'Country' ),
91
+				'limit' => array($offset, $limit),
92
+				'force_join' => array('State', 'Country'),
93 93
 				'caps' => \EEM_Base::caps_read_admin
94 94
 			) 
95 95
 		);
96 96
 		$csv_data = array();
97
-		foreach( $attendee_rows as $attendee_row ){
97
+		foreach ($attendee_rows as $attendee_row) {
98 98
 			$csv_row = array();
99
-			foreach( \EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){
100
-				if( $field_name == 'STA_ID' ){
101
-					$state_name_field = \EEM_State::instance()->field_settings_for( 'STA_name' );
102
-					$csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ];
103
-				}elseif( $field_name == 'CNT_ISO' ){
104
-					$country_name_field = \EEM_Country::instance()->field_settings_for( 'CNT_name' );
105
-					$csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ];
106
-				}else{
107
-					$csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ];
99
+			foreach (\EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) {
100
+				if ($field_name == 'STA_ID') {
101
+					$state_name_field = \EEM_State::instance()->field_settings_for('STA_name');
102
+					$csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()];
103
+				}elseif ($field_name == 'CNT_ISO') {
104
+					$country_name_field = \EEM_Country::instance()->field_settings_for('CNT_name');
105
+					$csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()];
106
+				} else {
107
+					$csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()];
108 108
 				}
109 109
 			}
110 110
 			$csv_data[] = apply_filters(
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 1 patch
Indentation   +414 added lines, -415 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
18 18
 
19 19
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
20
-    exit('No direct script access allowed');
20
+	exit('No direct script access allowed');
21 21
 }
22 22
 
23 23
 
@@ -25,443 +25,442 @@  discard block
 block discarded – undo
25 25
 class RegistrationsReport extends JobHandlerFile
26 26
 {
27 27
 
28
-    /**
29
-     * Performs any necessary setup for starting the job. This is also a good
30
-     * place to setup the $job_arguments which will be used for subsequent HTTP requests
31
-     * when continue_job will be called
32
-     *
33
-     * @param JobParameters $job_parameters
34
-     * @throws BatchRequestException
35
-     * @return JobStepResponse
36
-     */
37
-    public function create_job(JobParameters $job_parameters)
38
-    {
39
-        $event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
40
-        if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
41
-            throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
42
-        }
43
-        $filepath = $this->create_file_from_job_with_name($job_parameters->job_id(),
44
-            $this->get_filename($event_id));
45
-        $job_parameters->add_extra_data('filepath', $filepath);
46
-        if ($job_parameters->request_datum('use_filters', false)) {
47
-            $query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array())));
48
-        } else {
49
-            $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
50
-                array(
51
-                    'OR'                 => array(
52
-                        //don't include registrations from failed or abandoned transactions...
53
-                        'Transaction.STS_ID' => array(
54
-                            'NOT IN',
55
-                            array(
56
-                                \EEM_Transaction::failed_status_code,
57
-                                \EEM_Transaction::abandoned_status_code,
58
-                            ),
59
-                        ),
60
-                        //unless the registration is approved, in which case include it regardless of transaction status
61
-                        'STS_ID'             => \EEM_Registration::status_id_approved,
62
-                    ),
63
-                    'Ticket.TKT_deleted' => array('IN', array(true, false)),
64
-                ),
65
-                'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
66
-                'force_join' => array('Transaction', 'Ticket', 'Attendee'),
67
-                'caps'       => \EEM_Base::caps_read_admin,
68
-            ), $event_id);
69
-            if ($event_id) {
70
-                $query_params[0]['EVT_ID'] = $event_id;
71
-            } else {
72
-                $query_params['force_join'][] = 'Event';
73
-            }
74
-        }
75
-        if ( ! isset($query_params['force_join'])) {
76
-            $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee');
77
-        }
78
-        $job_parameters->add_extra_data('query_params', $query_params);
79
-        $question_labels = $this->_get_question_labels($query_params);
80
-        $job_parameters->add_extra_data('question_labels', $question_labels);
81
-        $job_parameters->set_job_size(
82
-            \EEM_Registration::instance()->count(
83
-                array_diff_key(
84
-                    $query_params,
85
-                    array_flip(
86
-                        array( 'limit' )
87
-                    )
88
-                )
89
-            )
90
-        );
91
-        //we should also set the header columns
92
-        $csv_data_for_row = $this->get_csv_data_for($event_id, 0, 1, $job_parameters->extra_datum('question_labels'),
93
-            $job_parameters->extra_datum('query_params'));
94
-        \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
95
-        //if we actually processed a row there, record it
96
-        if ($job_parameters->job_size()) {
97
-            $job_parameters->mark_processed(1);
98
-        }
99
-        return new JobStepResponse($job_parameters,
100
-            __('Registrations report started successfully...', 'event_espresso'));
101
-    }
28
+	/**
29
+	 * Performs any necessary setup for starting the job. This is also a good
30
+	 * place to setup the $job_arguments which will be used for subsequent HTTP requests
31
+	 * when continue_job will be called
32
+	 *
33
+	 * @param JobParameters $job_parameters
34
+	 * @throws BatchRequestException
35
+	 * @return JobStepResponse
36
+	 */
37
+	public function create_job(JobParameters $job_parameters)
38
+	{
39
+		$event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
40
+		if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
41
+			throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
42
+		}
43
+		$filepath = $this->create_file_from_job_with_name($job_parameters->job_id(),
44
+			$this->get_filename($event_id));
45
+		$job_parameters->add_extra_data('filepath', $filepath);
46
+		if ($job_parameters->request_datum('use_filters', false)) {
47
+			$query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array())));
48
+		} else {
49
+			$query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
50
+				array(
51
+					'OR'                 => array(
52
+						//don't include registrations from failed or abandoned transactions...
53
+						'Transaction.STS_ID' => array(
54
+							'NOT IN',
55
+							array(
56
+								\EEM_Transaction::failed_status_code,
57
+								\EEM_Transaction::abandoned_status_code,
58
+							),
59
+						),
60
+						//unless the registration is approved, in which case include it regardless of transaction status
61
+						'STS_ID'             => \EEM_Registration::status_id_approved,
62
+					),
63
+					'Ticket.TKT_deleted' => array('IN', array(true, false)),
64
+				),
65
+				'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
66
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
67
+				'caps'       => \EEM_Base::caps_read_admin,
68
+			), $event_id);
69
+			if ($event_id) {
70
+				$query_params[0]['EVT_ID'] = $event_id;
71
+			} else {
72
+				$query_params['force_join'][] = 'Event';
73
+			}
74
+		}
75
+		if ( ! isset($query_params['force_join'])) {
76
+			$query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee');
77
+		}
78
+		$job_parameters->add_extra_data('query_params', $query_params);
79
+		$question_labels = $this->_get_question_labels($query_params);
80
+		$job_parameters->add_extra_data('question_labels', $question_labels);
81
+		$job_parameters->set_job_size(
82
+			\EEM_Registration::instance()->count(
83
+				array_diff_key(
84
+					$query_params,
85
+					array_flip(
86
+						array( 'limit' )
87
+					)
88
+				)
89
+			)
90
+		);
91
+		//we should also set the header columns
92
+		$csv_data_for_row = $this->get_csv_data_for($event_id, 0, 1, $job_parameters->extra_datum('question_labels'),
93
+			$job_parameters->extra_datum('query_params'));
94
+		\EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
95
+		//if we actually processed a row there, record it
96
+		if ($job_parameters->job_size()) {
97
+			$job_parameters->mark_processed(1);
98
+		}
99
+		return new JobStepResponse($job_parameters,
100
+			__('Registrations report started successfully...', 'event_espresso'));
101
+	}
102 102
 
103 103
 
104 104
 
105
-    /**
106
-     * Gets the filename
107
-     * @return string
108
-     */
109
-    protected function get_filename()
110
-    {
111
-        return sprintf("event-espresso-registrations-%s.csv", str_replace(':', '-', current_time('mysql')));
112
-    }
105
+	/**
106
+	 * Gets the filename
107
+	 * @return string
108
+	 */
109
+	protected function get_filename()
110
+	{
111
+		return sprintf("event-espresso-registrations-%s.csv", str_replace(':', '-', current_time('mysql')));
112
+	}
113 113
 
114 114
 
115 115
 
116
-    /**
117
-     * Gets the questions which are to be used for this report, so they
118
-     * can be remembered for later
119
-     *
120
-     * @param array $registration_query_params
121
-     * @return array question admin labels to be used for this report
122
-     */
123
-    protected function _get_question_labels($registration_query_params)
124
-    {
125
-        $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
126
-        $question_query_params = array();
127
-        if ($where !== null) {
128
-            $question_query_params = array(
129
-                $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
130
-            );
131
-        }
132
-        $question_query_params[0]['QST_system'] = array('NOT_IN', array_keys(\EEM_Attendee::instance()->system_question_to_attendee_field_mapping()));
133
-        if(apply_filters('FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', false, $registration_query_params)) {
134
-            $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
135
-        }
136
-        $question_query_params['group_by'] = array( 'QST_ID' );
137
-        return array_unique( \EEM_Question::instance()->get_col( $question_query_params, 'QST_admin_label' ) );
138
-    }
116
+	/**
117
+	 * Gets the questions which are to be used for this report, so they
118
+	 * can be remembered for later
119
+	 *
120
+	 * @param array $registration_query_params
121
+	 * @return array question admin labels to be used for this report
122
+	 */
123
+	protected function _get_question_labels($registration_query_params)
124
+	{
125
+		$where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
126
+		$question_query_params = array();
127
+		if ($where !== null) {
128
+			$question_query_params = array(
129
+				$this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
130
+			);
131
+		}
132
+		$question_query_params[0]['QST_system'] = array('NOT_IN', array_keys(\EEM_Attendee::instance()->system_question_to_attendee_field_mapping()));
133
+		if(apply_filters('FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', false, $registration_query_params)) {
134
+			$question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
135
+		}
136
+		$question_query_params['group_by'] = array( 'QST_ID' );
137
+		return array_unique( \EEM_Question::instance()->get_col( $question_query_params, 'QST_admin_label' ) );
138
+	}
139 139
 
140 140
 
141 141
 
142
-    /**
143
-     * Takes where params meant for registrations and changes them to work for questions
144
-     *
145
-     * @param array $reg_where_params
146
-     * @return array
147
-     */
148
-    protected function _change_registration_where_params_to_question_where_params($reg_where_params)
149
-    {
150
-        $question_where_params = array();
151
-        foreach ($reg_where_params as $key => $val) {
152
-            if (\EEM_Registration::instance()->is_logic_query_param_key($key)) {
153
-                $question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val);
154
-            } else {
155
-                //it's a normal where condition
156
-                $question_where_params['Question_Group.Event.Registration.' . $key] = $val;
157
-            }
158
-        }
159
-        return $question_where_params;
160
-    }
142
+	/**
143
+	 * Takes where params meant for registrations and changes them to work for questions
144
+	 *
145
+	 * @param array $reg_where_params
146
+	 * @return array
147
+	 */
148
+	protected function _change_registration_where_params_to_question_where_params($reg_where_params)
149
+	{
150
+		$question_where_params = array();
151
+		foreach ($reg_where_params as $key => $val) {
152
+			if (\EEM_Registration::instance()->is_logic_query_param_key($key)) {
153
+				$question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val);
154
+			} else {
155
+				//it's a normal where condition
156
+				$question_where_params['Question_Group.Event.Registration.' . $key] = $val;
157
+			}
158
+		}
159
+		return $question_where_params;
160
+	}
161 161
 
162 162
 
163 163
 
164
-    /**
165
-     * Performs another step of the job
166
-     *
167
-     * @param JobParameters $job_parameters
168
-     * @param int           $batch_size
169
-     * @return JobStepResponse
170
-     * @throws \EE_Error
171
-     */
172
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
173
-    {
174
-        if( $job_parameters->units_processed() < $job_parameters->job_size() ) {
175
-            $csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'),
176
-                $job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('question_labels'),
177
-                $job_parameters->extra_datum('query_params'));
178
-            \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
179
-            $units_processed = count($csv_data);
180
-        }else{
181
-            $units_processed = 0;
182
-        }
183
-        $job_parameters->mark_processed($units_processed);
184
-        $extra_response_data = array(
185
-            'file_url' => '',
186
-        );
187
-        if ($units_processed < $batch_size) {
188
-            $job_parameters->set_status(JobParameters::status_complete);
189
-            $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
190
-        }
164
+	/**
165
+	 * Performs another step of the job
166
+	 *
167
+	 * @param JobParameters $job_parameters
168
+	 * @param int           $batch_size
169
+	 * @return JobStepResponse
170
+	 * @throws \EE_Error
171
+	 */
172
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
173
+	{
174
+		if( $job_parameters->units_processed() < $job_parameters->job_size() ) {
175
+			$csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'),
176
+				$job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('question_labels'),
177
+				$job_parameters->extra_datum('query_params'));
178
+			\EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
179
+			$units_processed = count($csv_data);
180
+		}else{
181
+			$units_processed = 0;
182
+		}
183
+		$job_parameters->mark_processed($units_processed);
184
+		$extra_response_data = array(
185
+			'file_url' => '',
186
+		);
187
+		if ($units_processed < $batch_size) {
188
+			$job_parameters->set_status(JobParameters::status_complete);
189
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
190
+		}
191 191
 
192
-        return new JobStepResponse($job_parameters,
193
-            sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count($csv_data)),
194
-            $extra_response_data);
195
-    }
192
+		return new JobStepResponse($job_parameters,
193
+			sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count($csv_data)),
194
+			$extra_response_data);
195
+	}
196 196
 
197 197
 
198 198
 
199
-    /**
200
-     * Gets the csv data for a batch of registrations
201
-
202
-     *
199
+	/**
200
+	 * Gets the csv data for a batch of registrations
201
+	 *
203 202
 *@param int|null    $event_id
204
-     * @param int   $offset
205
-     * @param int   $limit
206
-     * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
207
-     * @param array $query_params    for using where querying the model
208
-     * @return array top-level keys are numeric, next-level keys are column headers
209
-     */
210
-    function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params)
211
-    {
212
-        $reg_fields_to_include = array(
213
-            'TXN_ID',
214
-            'ATT_ID',
215
-            'REG_ID',
216
-            'REG_date',
217
-            'REG_code',
218
-            'REG_count',
219
-            'REG_final_price',
220
-        );
221
-        $att_fields_to_include = array(
222
-            'ATT_fname',
223
-            'ATT_lname',
224
-            'ATT_email',
225
-            'ATT_address',
226
-            'ATT_address2',
227
-            'ATT_city',
228
-            'STA_ID',
229
-            'CNT_ISO',
230
-            'ATT_zip',
231
-            'ATT_phone',
232
-        );
233
-        $registrations_csv_ready_array = array();
234
-        $reg_model = \EE_Registry::instance()->load_model('Registration');
235
-        $query_params['limit'] = array($offset, $limit);
236
-        $registration_rows = $reg_model->get_all_wpdb_results($query_params);
237
-        $registration_ids = array();
238
-        foreach ($registration_rows as $reg_row) {
239
-            $registration_ids[] = intval($reg_row['Registration.REG_ID']);
240
-        }
241
-        foreach ($registration_rows as $reg_row) {
242
-            if (is_array($reg_row)) {
243
-                $reg_csv_array = array();
244
-                if ( ! $event_id) {
245
-                    //get the event's name and Id
246
-                    $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'),
247
-                        \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name',
248
-                            $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
249
-                }
250
-                $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
251
-                /*@var $reg_row EE_Registration */
252
-                foreach ($reg_fields_to_include as $field_name) {
253
-                    $field = $reg_model->field_settings_for($field_name);
254
-                    if ($field_name == 'REG_final_price') {
255
-                        $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
256
-                            $reg_row['Registration.REG_final_price'], 'localized_float');
257
-                    } elseif ($field_name == 'REG_count') {
258
-                        $value = sprintf(__('%s of %s', 'event_espresso'),
259
-                            \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count',
260
-                                $reg_row['Registration.REG_count']),
261
-                            \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size',
262
-                                $reg_row['Registration.REG_group_size']));
263
-                    } elseif ($field_name == 'REG_date') {
264
-                        $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
265
-                            $reg_row['Registration.REG_date'], 'no_html');
266
-                    } else {
267
-                        $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
268
-                            $reg_row[$field->get_qualified_column()]);
269
-                    }
270
-                    $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
271
-                    if ($field_name == 'REG_final_price') {
272
-                        //add a column named Currency after the final price
273
-                        $reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code;
274
-                    }
275
-                }
276
-                //get pretty status
277
-                $stati = \EEM_Status::instance()->localized_status(array(
278
-                    $reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
279
-                    $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
280
-                ), false, 'sentence');
281
-                $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
282
-                //get pretty transaction status
283
-                $reg_csv_array[__("Transaction Status",
284
-                    'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']];
285
-                $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg
286
-                    ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total',
287
-                        $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00';
288
-                $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg
289
-                    ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid',
290
-                        $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00';
291
-                $payment_methods = array();
292
-                $gateway_txn_ids_etc = array();
293
-                $payment_times = array();
294
-                if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
295
-                    $payments_info = \EEM_Payment::instance()->get_all_wpdb_results(array(
296
-                        array(
297
-                            'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
298
-                            'STS_ID' => \EEM_Payment::status_id_approved,
299
-                        ),
300
-                        'force_join' => array('Payment_Method'),
301
-                    ), ARRAY_A,
302
-                        'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time');
303
-                    foreach ($payments_info as $payment_method_and_gateway_txn_id) {
304
-                        $payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
305
-                            ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
306
-                        $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
307
-                            ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
308
-                        $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
309
-                            ? $payment_method_and_gateway_txn_id['payment_time'] : '';
310
-                    }
311
-                }
312
-                $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
313
-                $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
314
-                $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
315
-                //get whether or not the user has checked in
316
-                $reg_csv_array[__("Check-Ins",
317
-                    "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
318
-                //get ticket of registration and its price
319
-                $ticket_model = \EE_Registry::instance()->load_model('Ticket');
320
-                if ($reg_row['Ticket.TKT_ID']) {
321
-                    $ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name',
322
-                        $reg_row['Ticket.TKT_name']);
323
-                    $datetimes_strings = array();
324
-                    foreach (
325
-                        \EEM_Datetime::instance()->get_all_wpdb_results(array(
326
-                            array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
327
-                            'order_by'                 => array('DTT_EVT_start' => 'ASC'),
328
-                            'default_where_conditions' => 'none',
329
-                        )) as $datetime
330
-                    ) {
331
-                        $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(),
332
-                            'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
333
-                    }
334
-                } else {
335
-                    $ticket_name = __('Unknown', 'event_espresso');
336
-                    $datetimes_strings = array(__('Unknown', 'event_espresso'));
337
-                }
338
-                $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
339
-                $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
340
-                //get datetime(s) of registration
341
-                //add attendee columns
342
-                foreach ($att_fields_to_include as $att_field_name) {
343
-                    $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
344
-                    if ($reg_row['Attendee_CPT.ID']) {
345
-                        if ($att_field_name == 'STA_ID') {
346
-                            $value = \EEM_State::instance()
347
-                                               ->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
348
-                                                   'STA_name');
349
-                        } elseif ($att_field_name == 'CNT_ISO') {
350
-                            $value = \EEM_Country::instance()
351
-                                                 ->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
352
-                                                     'CNT_name');
353
-                        } else {
354
-                            $value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(),
355
-                                $att_field_name, $reg_row[$field_obj->get_qualified_column()]);
356
-                        }
357
-                    } else {
358
-                        $value = '';
359
-                    }
360
-                    $reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value;
361
-                }
362
-                //make sure each registration has the same questions in the same order
363
-                foreach ($question_labels as $question_label) {
364
-                    if ( ! isset($reg_csv_array[$question_label])) {
365
-                        $reg_csv_array[$question_label] = null;
366
-                    }
367
-                }
368
-                $answers = \EEM_Answer::instance()->get_all_wpdb_results(array(
369
-                    array('REG_ID' => $reg_row['Registration.REG_ID']),
370
-                    'force_join' => array('Question'),
371
-                ));
372
-                //now fill out the questions THEY answered
373
-                foreach ($answers as $answer_row) {
374
-                    if ($answer_row['Question.QST_ID']) {
375
-                        $question_label = \EEH_Export::prepare_value_from_db_for_display(\EEM_Question::instance(),
376
-                            'QST_admin_label', $answer_row['Question.QST_admin_label']);
377
-                    } else {
378
-                        $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
379
-                    }
380
-                    if (isset($answer_row['Question.QST_type'])
381
-                        && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
382
-                    ) {
383
-                        $reg_csv_array[$question_label] = \EEM_State::instance()
384
-                                                                    ->get_state_name_by_ID($answer_row['Answer.ANS_value']);
385
-                    } else {
386
-                        //this isn't for html, so don't show html entities
387
-                        $reg_csv_array[$question_label] = html_entity_decode(\EEH_Export::prepare_value_from_db_for_display(\EEM_Answer::instance(),
388
-                            'ANS_value', $answer_row['Answer.ANS_value']));
389
-                    }
390
-                }
391
-                /**
392
-                 * Filter to change the contents of each row of the registrations report CSV file.
393
-                 *
394
-                 * This can be used to add or remote columns from the CSV file, or change their values.                 *
395
-                 * Note: it has this name because originally that's where this filter resided,
396
-                 * and we've left its name as-is for backward compatibility.
397
-                 * Note when using: all rows in the CSV should have the same columns.
398
-                 *
399
-                 * @param array $reg_csv_array keys are column-header names, and values are that columns' value
400
-                 *                             in this row
401
-                 * @param array $reg_row is the row from the database's wp_esp_registration table
402
-                 *
403
-                 */
404
-                $registrations_csv_ready_array[] = apply_filters(
405
-                    'FHEE__EE_Export__report_registrations__reg_csv_array',
406
-                    $reg_csv_array,
407
-                    $reg_row
408
-                );
409
-            }
410
-        }
411
-        //if we couldn't export anything, we want to at least show the column headers
412
-        if (empty($registrations_csv_ready_array)) {
413
-            $reg_csv_array = array();
414
-            $model_and_fields_to_include = array(
415
-                'Registration' => $reg_fields_to_include,
416
-                'Attendee'     => $att_fields_to_include,
417
-            );
418
-            foreach ($model_and_fields_to_include as $model_name => $field_list) {
419
-                $model = \EE_Registry::instance()->load_model($model_name);
420
-                foreach ($field_list as $field_name) {
421
-                    $field = $model->field_settings_for($field_name);
422
-                    $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null;
423
-                }
424
-            }
425
-            $registrations_csv_ready_array[] = $reg_csv_array;
426
-        }
427
-        return $registrations_csv_ready_array;
428
-    }
203
+	 * @param int   $offset
204
+	 * @param int   $limit
205
+	 * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
206
+	 * @param array $query_params    for using where querying the model
207
+	 * @return array top-level keys are numeric, next-level keys are column headers
208
+	 */
209
+	function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params)
210
+	{
211
+		$reg_fields_to_include = array(
212
+			'TXN_ID',
213
+			'ATT_ID',
214
+			'REG_ID',
215
+			'REG_date',
216
+			'REG_code',
217
+			'REG_count',
218
+			'REG_final_price',
219
+		);
220
+		$att_fields_to_include = array(
221
+			'ATT_fname',
222
+			'ATT_lname',
223
+			'ATT_email',
224
+			'ATT_address',
225
+			'ATT_address2',
226
+			'ATT_city',
227
+			'STA_ID',
228
+			'CNT_ISO',
229
+			'ATT_zip',
230
+			'ATT_phone',
231
+		);
232
+		$registrations_csv_ready_array = array();
233
+		$reg_model = \EE_Registry::instance()->load_model('Registration');
234
+		$query_params['limit'] = array($offset, $limit);
235
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
236
+		$registration_ids = array();
237
+		foreach ($registration_rows as $reg_row) {
238
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
239
+		}
240
+		foreach ($registration_rows as $reg_row) {
241
+			if (is_array($reg_row)) {
242
+				$reg_csv_array = array();
243
+				if ( ! $event_id) {
244
+					//get the event's name and Id
245
+					$reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'),
246
+						\EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name',
247
+							$reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
248
+				}
249
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
250
+				/*@var $reg_row EE_Registration */
251
+				foreach ($reg_fields_to_include as $field_name) {
252
+					$field = $reg_model->field_settings_for($field_name);
253
+					if ($field_name == 'REG_final_price') {
254
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
255
+							$reg_row['Registration.REG_final_price'], 'localized_float');
256
+					} elseif ($field_name == 'REG_count') {
257
+						$value = sprintf(__('%s of %s', 'event_espresso'),
258
+							\EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count',
259
+								$reg_row['Registration.REG_count']),
260
+							\EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size',
261
+								$reg_row['Registration.REG_group_size']));
262
+					} elseif ($field_name == 'REG_date') {
263
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
264
+							$reg_row['Registration.REG_date'], 'no_html');
265
+					} else {
266
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
267
+							$reg_row[$field->get_qualified_column()]);
268
+					}
269
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
270
+					if ($field_name == 'REG_final_price') {
271
+						//add a column named Currency after the final price
272
+						$reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code;
273
+					}
274
+				}
275
+				//get pretty status
276
+				$stati = \EEM_Status::instance()->localized_status(array(
277
+					$reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
278
+					$reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
279
+				), false, 'sentence');
280
+				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
281
+				//get pretty transaction status
282
+				$reg_csv_array[__("Transaction Status",
283
+					'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']];
284
+				$reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg
285
+					? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total',
286
+						$reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00';
287
+				$reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg
288
+					? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid',
289
+						$reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00';
290
+				$payment_methods = array();
291
+				$gateway_txn_ids_etc = array();
292
+				$payment_times = array();
293
+				if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
294
+					$payments_info = \EEM_Payment::instance()->get_all_wpdb_results(array(
295
+						array(
296
+							'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
297
+							'STS_ID' => \EEM_Payment::status_id_approved,
298
+						),
299
+						'force_join' => array('Payment_Method'),
300
+					), ARRAY_A,
301
+						'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time');
302
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
303
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
304
+							? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
305
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
306
+							? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
307
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
308
+							? $payment_method_and_gateway_txn_id['payment_time'] : '';
309
+					}
310
+				}
311
+				$reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
312
+				$reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
313
+				$reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
314
+				//get whether or not the user has checked in
315
+				$reg_csv_array[__("Check-Ins",
316
+					"event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
317
+				//get ticket of registration and its price
318
+				$ticket_model = \EE_Registry::instance()->load_model('Ticket');
319
+				if ($reg_row['Ticket.TKT_ID']) {
320
+					$ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name',
321
+						$reg_row['Ticket.TKT_name']);
322
+					$datetimes_strings = array();
323
+					foreach (
324
+						\EEM_Datetime::instance()->get_all_wpdb_results(array(
325
+							array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
326
+							'order_by'                 => array('DTT_EVT_start' => 'ASC'),
327
+							'default_where_conditions' => 'none',
328
+						)) as $datetime
329
+					) {
330
+						$datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(),
331
+							'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
332
+					}
333
+				} else {
334
+					$ticket_name = __('Unknown', 'event_espresso');
335
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
336
+				}
337
+				$reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
338
+				$reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
339
+				//get datetime(s) of registration
340
+				//add attendee columns
341
+				foreach ($att_fields_to_include as $att_field_name) {
342
+					$field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
343
+					if ($reg_row['Attendee_CPT.ID']) {
344
+						if ($att_field_name == 'STA_ID') {
345
+							$value = \EEM_State::instance()
346
+											   ->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
347
+												   'STA_name');
348
+						} elseif ($att_field_name == 'CNT_ISO') {
349
+							$value = \EEM_Country::instance()
350
+												 ->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
351
+													 'CNT_name');
352
+						} else {
353
+							$value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(),
354
+								$att_field_name, $reg_row[$field_obj->get_qualified_column()]);
355
+						}
356
+					} else {
357
+						$value = '';
358
+					}
359
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value;
360
+				}
361
+				//make sure each registration has the same questions in the same order
362
+				foreach ($question_labels as $question_label) {
363
+					if ( ! isset($reg_csv_array[$question_label])) {
364
+						$reg_csv_array[$question_label] = null;
365
+					}
366
+				}
367
+				$answers = \EEM_Answer::instance()->get_all_wpdb_results(array(
368
+					array('REG_ID' => $reg_row['Registration.REG_ID']),
369
+					'force_join' => array('Question'),
370
+				));
371
+				//now fill out the questions THEY answered
372
+				foreach ($answers as $answer_row) {
373
+					if ($answer_row['Question.QST_ID']) {
374
+						$question_label = \EEH_Export::prepare_value_from_db_for_display(\EEM_Question::instance(),
375
+							'QST_admin_label', $answer_row['Question.QST_admin_label']);
376
+					} else {
377
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
378
+					}
379
+					if (isset($answer_row['Question.QST_type'])
380
+						&& $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
381
+					) {
382
+						$reg_csv_array[$question_label] = \EEM_State::instance()
383
+																	->get_state_name_by_ID($answer_row['Answer.ANS_value']);
384
+					} else {
385
+						//this isn't for html, so don't show html entities
386
+						$reg_csv_array[$question_label] = html_entity_decode(\EEH_Export::prepare_value_from_db_for_display(\EEM_Answer::instance(),
387
+							'ANS_value', $answer_row['Answer.ANS_value']));
388
+					}
389
+				}
390
+				/**
391
+				 * Filter to change the contents of each row of the registrations report CSV file.
392
+				 *
393
+				 * This can be used to add or remote columns from the CSV file, or change their values.                 *
394
+				 * Note: it has this name because originally that's where this filter resided,
395
+				 * and we've left its name as-is for backward compatibility.
396
+				 * Note when using: all rows in the CSV should have the same columns.
397
+				 *
398
+				 * @param array $reg_csv_array keys are column-header names, and values are that columns' value
399
+				 *                             in this row
400
+				 * @param array $reg_row is the row from the database's wp_esp_registration table
401
+				 *
402
+				 */
403
+				$registrations_csv_ready_array[] = apply_filters(
404
+					'FHEE__EE_Export__report_registrations__reg_csv_array',
405
+					$reg_csv_array,
406
+					$reg_row
407
+				);
408
+			}
409
+		}
410
+		//if we couldn't export anything, we want to at least show the column headers
411
+		if (empty($registrations_csv_ready_array)) {
412
+			$reg_csv_array = array();
413
+			$model_and_fields_to_include = array(
414
+				'Registration' => $reg_fields_to_include,
415
+				'Attendee'     => $att_fields_to_include,
416
+			);
417
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
418
+				$model = \EE_Registry::instance()->load_model($model_name);
419
+				foreach ($field_list as $field_name) {
420
+					$field = $model->field_settings_for($field_name);
421
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null;
422
+				}
423
+			}
424
+			$registrations_csv_ready_array[] = $reg_csv_array;
425
+		}
426
+		return $registrations_csv_ready_array;
427
+	}
429 428
 
430 429
 
431 430
 
432
-    /**
433
-     * Counts total unit to process
434
-     *
435
-     * @deprecated since 4.9.19
436
-     * @param int|array $event_id
437
-     * @return int
438
-     */
439
-    public function count_units_to_process($event_id)
440
-    {
441
-        //use the legacy filter
442
-        if ($event_id) {
443
-            $query_params[0]['EVT_ID'] = $event_id;
444
-        } else {
445
-            $query_params['force_join'][] = 'Event';
446
-        }
447
-        return \EEM_Registration::instance()->count($query_params);
448
-    }
431
+	/**
432
+	 * Counts total unit to process
433
+	 *
434
+	 * @deprecated since 4.9.19
435
+	 * @param int|array $event_id
436
+	 * @return int
437
+	 */
438
+	public function count_units_to_process($event_id)
439
+	{
440
+		//use the legacy filter
441
+		if ($event_id) {
442
+			$query_params[0]['EVT_ID'] = $event_id;
443
+		} else {
444
+			$query_params['force_join'][] = 'Event';
445
+		}
446
+		return \EEM_Registration::instance()->count($query_params);
447
+	}
449 448
 
450 449
 
451 450
 
452
-    /**
453
-     * Performs any clean-up logic when we know the job is completed.
454
-     * In this case, we delete the temporary file
455
-     *
456
-     * @param JobParameters $job_parameters
457
-     * @return boolean
458
-     */
459
-    public function cleanup_job(JobParameters $job_parameters)
460
-    {
461
-        $this->_file_helper->delete(\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
462
-            true, 'd');
463
-        return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
464
-    }
451
+	/**
452
+	 * Performs any clean-up logic when we know the job is completed.
453
+	 * In this case, we delete the temporary file
454
+	 *
455
+	 * @param JobParameters $job_parameters
456
+	 * @return boolean
457
+	 */
458
+	public function cleanup_job(JobParameters $job_parameters)
459
+	{
460
+		$this->_file_helper->delete(\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
461
+			true, 'd');
462
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
463
+	}
465 464
 }
466 465
 
467 466
 
Please login to merge, or discard this patch.
core/services/shortcodes/ShortcodesManager.php 2 patches
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -33,210 +33,210 @@
 block discarded – undo
33 33
 class ShortcodesManager
34 34
 {
35 35
 
36
-    /**
37
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
38
-     */
39
-    private $legacy_shortcodes_manager;
40
-
41
-    /**
42
-     * @var ShortcodeInterface[] $shortcodes
43
-     */
44
-    private $shortcodes;
45
-
46
-
47
-
48
-    /**
49
-     * ShortcodesManager constructor
50
-     *
51
-     * @param LegacyShortcodesManager $legacy_shortcodes_manager
52
-     */
53
-    public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager) {
54
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
55
-        // assemble a list of installed and active shortcodes
56
-        add_action(
57
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
58
-            array($this, 'registerShortcodes'),
59
-            999
60
-        );
61
-        //  call add_shortcode() for all installed shortcodes
62
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes'));
63
-        // check content for shortcodes, the old way, and the more efficient new way
64
-        add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5);
65
-        add_action('get_header', array($this, 'getHeader'));
66
-    }
67
-
68
-
69
-
70
-    /**
71
-     * @return CollectionInterface|ShortcodeInterface[]
72
-     * @throws InvalidIdentifierException
73
-     * @throws InvalidInterfaceException
74
-     * @throws InvalidFilePathException
75
-     * @throws InvalidEntityException
76
-     * @throws InvalidDataTypeException
77
-     * @throws InvalidClassException
78
-     */
79
-    public function getShortcodes()
80
-    {
81
-        if ( ! $this->shortcodes instanceof CollectionInterface) {
82
-            $this->shortcodes = $this->loadShortcodesCollection();
83
-        }
84
-        return $this->shortcodes;
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     * @return CollectionInterface|ShortcodeInterface[]
91
-     * @throws InvalidIdentifierException
92
-     * @throws InvalidInterfaceException
93
-     * @throws InvalidFilePathException
94
-     * @throws InvalidEntityException
95
-     * @throws InvalidDataTypeException
96
-     * @throws InvalidClassException
97
-     */
98
-    protected function loadShortcodesCollection()
99
-    {
100
-        $loader = new CollectionLoader(
101
-            new CollectionDetails(
102
-            // collection name
103
-                'shortcodes',
104
-                // collection interface
105
-                'EventEspresso\core\services\shortcodes\ShortcodeInterface',
106
-                // FQCNs for classes to add (all classes within that namespace will be loaded)
107
-                array('EventEspresso\core\domain\entities\shortcodes'),
108
-                // filepaths to classes to add
109
-                array(),
110
-                // filemask to use if parsing folder for files to add
111
-                '',
112
-                // what to use as identifier for collection entities
113
-                // using CLASS NAME prevents duplicates (works like a singleton)
114
-                CollectionDetails::ID_CLASS_NAME
115
-            )
116
-        );
117
-        return $loader->getCollection();
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * @return void
124
-     * @throws DomainException
125
-     * @throws InvalidInterfaceException
126
-     * @throws InvalidIdentifierException
127
-     * @throws InvalidFilePathException
128
-     * @throws InvalidEntityException
129
-     * @throws InvalidDataTypeException
130
-     * @throws InvalidClassException
131
-     */
132
-    public function registerShortcodes()
133
-    {
134
-        try {
135
-            $this->shortcodes = apply_filters(
136
-                'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
137
-                $this->getShortcodes()
138
-            );
139
-            if (! $this->shortcodes instanceof CollectionInterface) {
140
-                throw new InvalidEntityException(
141
-                    $this->shortcodes,
142
-                    'CollectionInterface',
143
-                    sprintf(
144
-                        esc_html__(
145
-                            'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
146
-                            'event_espresso'
147
-                        ),
148
-                        is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
149
-                    )
150
-                );
151
-            }
152
-            $this->legacy_shortcodes_manager->registerShortcodes();
153
-        } catch (Exception $exception) {
154
-            new ExceptionStackTraceDisplay($exception);
155
-        }
156
-    }
157
-
158
-
159
-
160
-    /**
161
-     * @return void
162
-     */
163
-    public function addShortcodes()
164
-    {
165
-        try {
166
-            // cycle thru shortcode folders
167
-            foreach ($this->shortcodes as $shortcode) {
168
-                /** @var ShortcodeInterface $shortcode */
169
-                if ( $shortcode instanceof EnqueueAssetsInterface) {
170
-                    add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10);
171
-                    add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11);
172
-                }
173
-                // add_shortcode() if it has not already been added
174
-                if ( ! shortcode_exists($shortcode->getTag())) {
175
-                    add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback'));
176
-                }
177
-            }
178
-            $this->legacy_shortcodes_manager->addShortcodes();
179
-        } catch (Exception $exception) {
180
-            new ExceptionStackTraceDisplay($exception);
181
-        }
182
-    }
183
-
184
-
185
-
186
-    /**
187
-     * callback for the WP "get_header" hook point
188
-     * checks posts for EE shortcodes, and initializes them,
189
-     * then toggles filter switch that loads core default assets
190
-     *
191
-     * @return void
192
-     */
193
-    public function getHeader()
194
-    {
195
-        global $wp_query;
196
-        if (empty($wp_query->posts)) {
197
-            return;
198
-        }
199
-        $load_assets = false;
200
-        // array of posts displayed in current request
201
-        $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts);
202
-        foreach ($posts as $post) {
203
-            // now check post content and excerpt for EE shortcodes
204
-            $load_assets = $this->parseContentForShortcodes($post->post_content)
205
-                ? true
206
-                : $load_assets;
207
-        }
208
-        if ($load_assets) {
209
-            $this->legacy_shortcodes_manager->registry()->REQ->set_espresso_page(true);
210
-            add_filter('FHEE_load_css', '__return_true');
211
-            add_filter('FHEE_load_js', '__return_true');
212
-        }
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     * checks supplied content against list of shortcodes,
219
-     * then initializes any found shortcodes, and returns true.
220
-     * returns false if no shortcodes found.
221
-     *
222
-     * @param string $content
223
-     * @return bool
224
-     */
225
-    public function parseContentForShortcodes($content)
226
-    {
227
-        $has_shortcode = false;
228
-        if(empty($this->shortcodes)){
229
-            return $has_shortcode;
230
-        }
231
-        foreach ($this->shortcodes as $shortcode) {
232
-            /** @var ShortcodeInterface $shortcode */
233
-            if (has_shortcode($content, $shortcode->getTag())) {
234
-                $shortcode->initializeShortcode();
235
-                $has_shortcode = true;
236
-            }
237
-        }
238
-        return $has_shortcode;
239
-    }
36
+	/**
37
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
38
+	 */
39
+	private $legacy_shortcodes_manager;
40
+
41
+	/**
42
+	 * @var ShortcodeInterface[] $shortcodes
43
+	 */
44
+	private $shortcodes;
45
+
46
+
47
+
48
+	/**
49
+	 * ShortcodesManager constructor
50
+	 *
51
+	 * @param LegacyShortcodesManager $legacy_shortcodes_manager
52
+	 */
53
+	public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager) {
54
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
55
+		// assemble a list of installed and active shortcodes
56
+		add_action(
57
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
58
+			array($this, 'registerShortcodes'),
59
+			999
60
+		);
61
+		//  call add_shortcode() for all installed shortcodes
62
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes'));
63
+		// check content for shortcodes, the old way, and the more efficient new way
64
+		add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5);
65
+		add_action('get_header', array($this, 'getHeader'));
66
+	}
67
+
68
+
69
+
70
+	/**
71
+	 * @return CollectionInterface|ShortcodeInterface[]
72
+	 * @throws InvalidIdentifierException
73
+	 * @throws InvalidInterfaceException
74
+	 * @throws InvalidFilePathException
75
+	 * @throws InvalidEntityException
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws InvalidClassException
78
+	 */
79
+	public function getShortcodes()
80
+	{
81
+		if ( ! $this->shortcodes instanceof CollectionInterface) {
82
+			$this->shortcodes = $this->loadShortcodesCollection();
83
+		}
84
+		return $this->shortcodes;
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 * @return CollectionInterface|ShortcodeInterface[]
91
+	 * @throws InvalidIdentifierException
92
+	 * @throws InvalidInterfaceException
93
+	 * @throws InvalidFilePathException
94
+	 * @throws InvalidEntityException
95
+	 * @throws InvalidDataTypeException
96
+	 * @throws InvalidClassException
97
+	 */
98
+	protected function loadShortcodesCollection()
99
+	{
100
+		$loader = new CollectionLoader(
101
+			new CollectionDetails(
102
+			// collection name
103
+				'shortcodes',
104
+				// collection interface
105
+				'EventEspresso\core\services\shortcodes\ShortcodeInterface',
106
+				// FQCNs for classes to add (all classes within that namespace will be loaded)
107
+				array('EventEspresso\core\domain\entities\shortcodes'),
108
+				// filepaths to classes to add
109
+				array(),
110
+				// filemask to use if parsing folder for files to add
111
+				'',
112
+				// what to use as identifier for collection entities
113
+				// using CLASS NAME prevents duplicates (works like a singleton)
114
+				CollectionDetails::ID_CLASS_NAME
115
+			)
116
+		);
117
+		return $loader->getCollection();
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * @return void
124
+	 * @throws DomainException
125
+	 * @throws InvalidInterfaceException
126
+	 * @throws InvalidIdentifierException
127
+	 * @throws InvalidFilePathException
128
+	 * @throws InvalidEntityException
129
+	 * @throws InvalidDataTypeException
130
+	 * @throws InvalidClassException
131
+	 */
132
+	public function registerShortcodes()
133
+	{
134
+		try {
135
+			$this->shortcodes = apply_filters(
136
+				'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
137
+				$this->getShortcodes()
138
+			);
139
+			if (! $this->shortcodes instanceof CollectionInterface) {
140
+				throw new InvalidEntityException(
141
+					$this->shortcodes,
142
+					'CollectionInterface',
143
+					sprintf(
144
+						esc_html__(
145
+							'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
146
+							'event_espresso'
147
+						),
148
+						is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
149
+					)
150
+				);
151
+			}
152
+			$this->legacy_shortcodes_manager->registerShortcodes();
153
+		} catch (Exception $exception) {
154
+			new ExceptionStackTraceDisplay($exception);
155
+		}
156
+	}
157
+
158
+
159
+
160
+	/**
161
+	 * @return void
162
+	 */
163
+	public function addShortcodes()
164
+	{
165
+		try {
166
+			// cycle thru shortcode folders
167
+			foreach ($this->shortcodes as $shortcode) {
168
+				/** @var ShortcodeInterface $shortcode */
169
+				if ( $shortcode instanceof EnqueueAssetsInterface) {
170
+					add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10);
171
+					add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11);
172
+				}
173
+				// add_shortcode() if it has not already been added
174
+				if ( ! shortcode_exists($shortcode->getTag())) {
175
+					add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback'));
176
+				}
177
+			}
178
+			$this->legacy_shortcodes_manager->addShortcodes();
179
+		} catch (Exception $exception) {
180
+			new ExceptionStackTraceDisplay($exception);
181
+		}
182
+	}
183
+
184
+
185
+
186
+	/**
187
+	 * callback for the WP "get_header" hook point
188
+	 * checks posts for EE shortcodes, and initializes them,
189
+	 * then toggles filter switch that loads core default assets
190
+	 *
191
+	 * @return void
192
+	 */
193
+	public function getHeader()
194
+	{
195
+		global $wp_query;
196
+		if (empty($wp_query->posts)) {
197
+			return;
198
+		}
199
+		$load_assets = false;
200
+		// array of posts displayed in current request
201
+		$posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts);
202
+		foreach ($posts as $post) {
203
+			// now check post content and excerpt for EE shortcodes
204
+			$load_assets = $this->parseContentForShortcodes($post->post_content)
205
+				? true
206
+				: $load_assets;
207
+		}
208
+		if ($load_assets) {
209
+			$this->legacy_shortcodes_manager->registry()->REQ->set_espresso_page(true);
210
+			add_filter('FHEE_load_css', '__return_true');
211
+			add_filter('FHEE_load_js', '__return_true');
212
+		}
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 * checks supplied content against list of shortcodes,
219
+	 * then initializes any found shortcodes, and returns true.
220
+	 * returns false if no shortcodes found.
221
+	 *
222
+	 * @param string $content
223
+	 * @return bool
224
+	 */
225
+	public function parseContentForShortcodes($content)
226
+	{
227
+		$has_shortcode = false;
228
+		if(empty($this->shortcodes)){
229
+			return $has_shortcode;
230
+		}
231
+		foreach ($this->shortcodes as $shortcode) {
232
+			/** @var ShortcodeInterface $shortcode */
233
+			if (has_shortcode($content, $shortcode->getTag())) {
234
+				$shortcode->initializeShortcode();
235
+				$has_shortcode = true;
236
+			}
237
+		}
238
+		return $has_shortcode;
239
+	}
240 240
 
241 241
 }
242 242
 // End of file ShortcodesManager.php
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
                 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
137 137
                 $this->getShortcodes()
138 138
             );
139
-            if (! $this->shortcodes instanceof CollectionInterface) {
139
+            if ( ! $this->shortcodes instanceof CollectionInterface) {
140 140
                 throw new InvalidEntityException(
141 141
                     $this->shortcodes,
142 142
                     'CollectionInterface',
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
             // cycle thru shortcode folders
167 167
             foreach ($this->shortcodes as $shortcode) {
168 168
                 /** @var ShortcodeInterface $shortcode */
169
-                if ( $shortcode instanceof EnqueueAssetsInterface) {
169
+                if ($shortcode instanceof EnqueueAssetsInterface) {
170 170
                     add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10);
171 171
                     add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11);
172 172
                 }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     public function parseContentForShortcodes($content)
226 226
     {
227 227
         $has_shortcode = false;
228
-        if(empty($this->shortcodes)){
228
+        if (empty($this->shortcodes)) {
229 229
             return $has_shortcode;
230 230
         }
231 231
         foreach ($this->shortcodes as $shortcode) {
Please login to merge, or discard this patch.
caffeinated/core/libraries/shortcodes/EE_Question_Shortcodes.lib.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('NO direct script access allowed');
4
+	exit('NO direct script access allowed');
5 5
 }
6 6
 
7 7
 /**
@@ -36,82 +36,82 @@  discard block
 block discarded – undo
36 36
 {
37 37
     
38 38
     
39
-    /**
40
-     * _init_props
41
-     *
42
-     * @access protected
43
-     * @return void
44
-     */
45
-    protected function _init_props()
46
-    {
47
-        $this->label       = __('Attendee Shortcodes', 'event_espresso');
48
-        $this->description = __('All shortcodes specific to attendee related data', 'event_espresso');
49
-        $this->_shortcodes = array(
50
-            '[QUESTION]' => __('Will parse to a question.', 'event_espresso'),
51
-            '[ANSWER]'   => __('Will parse to the answer for a question', 'event_espresso')
52
-        );
53
-    }
39
+	/**
40
+	 * _init_props
41
+	 *
42
+	 * @access protected
43
+	 * @return void
44
+	 */
45
+	protected function _init_props()
46
+	{
47
+		$this->label       = __('Attendee Shortcodes', 'event_espresso');
48
+		$this->description = __('All shortcodes specific to attendee related data', 'event_espresso');
49
+		$this->_shortcodes = array(
50
+			'[QUESTION]' => __('Will parse to a question.', 'event_espresso'),
51
+			'[ANSWER]'   => __('Will parse to the answer for a question', 'event_espresso')
52
+		);
53
+	}
54 54
     
55 55
     
56
-    /**
57
-     * This method will give parsing instructions for each shortcode defined in the _shortcodes array.  Child methods
58
-     * will have to take care of handling.
59
-     *
60
-     * @access protected
61
-     *
62
-     * @param string $shortcode the shortcode to be parsed.
63
-     *
64
-     * @return string parsed shortcode
65
-     */
66
-    protected function _parser($shortcode)
67
-    {
56
+	/**
57
+	 * This method will give parsing instructions for each shortcode defined in the _shortcodes array.  Child methods
58
+	 * will have to take care of handling.
59
+	 *
60
+	 * @access protected
61
+	 *
62
+	 * @param string $shortcode the shortcode to be parsed.
63
+	 *
64
+	 * @return string parsed shortcode
65
+	 */
66
+	protected function _parser($shortcode)
67
+	{
68 68
         
69
-        if ( ! $this->_data instanceof EE_Answer || ! isset($this->_extra_data['data']) || ! $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
70
-            return '';
71
-        }
69
+		if ( ! $this->_data instanceof EE_Answer || ! isset($this->_extra_data['data']) || ! $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
70
+			return '';
71
+		}
72 72
         
73
-        switch ($shortcode) {
73
+		switch ($shortcode) {
74 74
             
75
-            case '[QUESTION]' :
76
-                $question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question();
77
-                if ( ! $question instanceof EE_Question) {
78
-                    return ''; //get out because we can't figure out what the question is.
79
-                }
75
+			case '[QUESTION]' :
76
+				$question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question();
77
+				if ( ! $question instanceof EE_Question) {
78
+					return ''; //get out because we can't figure out what the question is.
79
+				}
80 80
                 
81
-                return $question->get('QST_display_text');
82
-                break;
81
+				return $question->get('QST_display_text');
82
+				break;
83 83
             
84
-            case '[ANSWER]' :
85
-                //need to get the question to determine the type of question (some questions require translation of the answer).
86
-                $question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question();
87
-                if ( ! $question instanceof EE_Question) {
88
-                    return ''; //get out cause we can't figure out what the question type is!
89
-                }
84
+			case '[ANSWER]' :
85
+				//need to get the question to determine the type of question (some questions require translation of the answer).
86
+				$question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question();
87
+				if ( ! $question instanceof EE_Question) {
88
+					return ''; //get out cause we can't figure out what the question type is!
89
+				}
90 90
                 
91
-                //what we show for the answer depends on the question type!
92
-                switch ($question->get('QST_type')) {
91
+				//what we show for the answer depends on the question type!
92
+				switch ($question->get('QST_type')) {
93 93
                     
94
-                    case 'STATE' :
95
-                        $state  = EEM_State::instance()->get_one_by_ID($this->_data->get('ANS_value'));
96
-                        $answer = $state instanceof EE_State ? $state->name() : '';
97
-                        break;
94
+					case 'STATE' :
95
+						$state  = EEM_State::instance()->get_one_by_ID($this->_data->get('ANS_value'));
96
+						$answer = $state instanceof EE_State ? $state->name() : '';
97
+						break;
98 98
                     
99
-                    case 'COUNTRY' :
100
-                        $country = EEM_Country::instance()->get_one_by_ID($this->_data->get('ANS_value'));
101
-                        $answer  = $country instanceof EE_Country ? $country->name() : '';
102
-                        break;
99
+					case 'COUNTRY' :
100
+						$country = EEM_Country::instance()->get_one_by_ID($this->_data->get('ANS_value'));
101
+						$answer  = $country instanceof EE_Country ? $country->name() : '';
102
+						break;
103 103
                     
104
-                    default :
105
-                        $answer = $this->_data->get_pretty('ANS_value', 'no_wpautop');
106
-                        break;
107
-                }
104
+					default :
105
+						$answer = $this->_data->get_pretty('ANS_value', 'no_wpautop');
106
+						break;
107
+				}
108 108
                 
109
-                return $answer;
110
-                break;
109
+				return $answer;
110
+				break;
111 111
             
112
-        }
112
+		}
113 113
         
114
-        return '';
115
-    }
114
+		return '';
115
+	}
116 116
     
117 117
 } //end EE_Question_Shortcodes class
Please login to merge, or discard this patch.
caffeinated/payment_methods/Paypal_Pro/EEG_Paypal_Pro.gateway.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -450,7 +450,7 @@
 block discarded – undo
450 450
 
451 451
 
452 452
     /**
453
-     * @param $Request
453
+     * @param string $Request
454 454
      * @return mixed
455 455
      */
456 456
     private function _CURLRequest($Request)
Please login to merge, or discard this patch.
Indentation   +587 added lines, -587 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('No direct script access allowed');
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -25,591 +25,591 @@  discard block
 block discarded – undo
25 25
 class EEG_Paypal_Pro extends EE_Onsite_Gateway
26 26
 {
27 27
 
28
-    /**
29
-     * @var $_paypal_api_username string
30
-     */
31
-    protected $_username = null;
32
-
33
-    /**
34
-     * @var $_password string
35
-     */
36
-    protected $_password = null;
37
-
38
-    /**
39
-     * @var $_signature string
40
-     */
41
-    protected $_signature = null;
42
-
43
-    /**
44
-     * @var $_credit_card_types array with the keys for credit card types accepted on this account
45
-     */
46
-    protected $_credit_card_types    = null;
47
-
48
-    protected $_currencies_supported = array(
49
-        'USD',
50
-        'GBP',
51
-        'CAD',
52
-        'AUD',
53
-        'BRL',
54
-        'CHF',
55
-        'CZK',
56
-        'DKK',
57
-        'EUR',
58
-        'HKD',
59
-        'HUF',
60
-        'ILS',
61
-        'JPY',
62
-        'MXN',
63
-        'MYR',
64
-        'NOK',
65
-        'NZD',
66
-        'PHP',
67
-        'PLN',
68
-        'SEK',
69
-        'SGD',
70
-        'THB',
71
-        'TRY',
72
-        'TWD',
73
-        'RUB',
74
-    );
75
-
76
-
77
-
78
-    /**
79
-     * @param EEI_Payment $payment
80
-     * @param array       $billing_info {
81
-     * @type string $credit_card
82
-     * @type string $credit_card_type
83
-     * @type string $exp_month always 2 characters
84
-     * @type string $exp_year always 4 characters
85
-     * @type string $cvv
86
-     * }
87
-     * @see      parent::do_direct_payment for more info
88
-     * @return EE_Payment|EEI_Payment
89
-     * @throws EE_Error
90
-     */
91
-    public function do_direct_payment($payment, $billing_info = null)
92
-    {
93
-        $transaction = $payment->transaction();
94
-        if (! $transaction instanceof EEI_Transaction) {
95
-            throw new EE_Error(
96
-                esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
97
-            );
98
-        }
99
-        $primary_registrant = $transaction->primary_registration();
100
-        if (! $primary_registrant instanceof EEI_Registration) {
101
-            throw new EE_Error(
102
-                esc_html__(
103
-                    'No primary registration on transaction while paying with PayPal Pro.',
104
-                    'event_espresso'
105
-                )
106
-            );
107
-        }
108
-        $attendee = $primary_registrant->attendee();
109
-        if (! $attendee instanceof EEI_Attendee) {
110
-            throw new EE_Error(
111
-                esc_html__(
112
-                    'No attendee on primary registration while paying with PayPal Pro.',
113
-                    'event_espresso'
114
-                )
115
-            );
116
-        }
117
-        $order_description = substr($this->_format_order_description($payment), 0, 127);
118
-        //charge for the full amount. Show itemized list
119
-        if ($this->_can_easily_itemize_transaction_for($payment)) {
120
-            $item_num = 1;
121
-            $total_line_item = $transaction->total_line_item();
122
-            $order_items = array();
123
-            foreach ($total_line_item->get_items() as $line_item) {
124
-                //ignore line items with a quantity of 0
125
-                if ($line_item->quantity() == 0) {
126
-                    continue;
127
-                }
128
-                $item = array(
129
-                    // Item Name.  127 char max.
130
-                    'l_name'                 => substr(
131
-                        $this->_format_line_item_name($line_item, $payment),
132
-                        0,
133
-                        127
134
-                    ),
135
-                    // Item description.  127 char max.
136
-                    'l_desc'                 => substr(
137
-                        $this->_format_line_item_desc($line_item, $payment),
138
-                        0,
139
-                        127
140
-                    ),
141
-                    // Cost of individual item.
142
-                    'l_amt'                  => $line_item->unit_price(),
143
-                    // Item Number.  127 char max.
144
-                    'l_number'               => $item_num++,
145
-                    // Item quantity.  Must be any positive integer.
146
-                    'l_qty'                  => $line_item->quantity(),
147
-                    // Item's sales tax amount.
148
-                    'l_taxamt'               => '',
149
-                    // eBay auction number of item.
150
-                    'l_ebayitemnumber'       => '',
151
-                    // eBay transaction ID of purchased item.
152
-                    'l_ebayitemauctiontxnid' => '',
153
-                    // eBay order ID for the item.
154
-                    'l_ebayitemorderid'      => '',
155
-                );
156
-                // add to array of all items
157
-                array_push($order_items, $item);
158
-            }
159
-            $item_amount = $total_line_item->get_items_total();
160
-            $tax_amount = $total_line_item->get_total_tax();
161
-        } else {
162
-            $order_items = array();
163
-            $item_amount = $payment->amount();
164
-            $tax_amount = 0;
165
-            array_push($order_items, array(
166
-                // Item Name.  127 char max.
167
-                'l_name'   => substr(
168
-                    $this->_format_partial_payment_line_item_name($payment),
169
-                    0,
170
-                    127
171
-                ),
172
-                // Item description.  127 char max.
173
-                'l_desc'   => substr(
174
-                    $this->_format_partial_payment_line_item_desc($payment),
175
-                    0,
176
-                    127
177
-                ),
178
-                // Cost of individual item.
179
-                'l_amt'    => $payment->amount(),
180
-                // Item Number.  127 char max.
181
-                'l_number' => 1,
182
-                // Item quantity.  Must be any positive integer.
183
-                'l_qty'    => 1,
184
-            ));
185
-        }
186
-        // Populate data arrays with order data.
187
-        $DPFields = array(
188
-            // How you want to obtain payment ?
189
-            // Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture.
190
-            // Sale indicates that this is a final sale for which you are requesting payment.  Default is Sale.
191
-            'paymentaction'    => 'Sale',
192
-            // Required.  IP address of the payer's browser.
193
-            'ipaddress'        => $_SERVER['REMOTE_ADDR'],
194
-            // Flag to determine whether you want the results returned by FMF.  1 or 0.  Default is 0.
195
-            'returnfmfdetails' => '1',
196
-        );
197
-        $CCDetails = array(
198
-            // Required. Type of credit card.  Visa, MasterCard, Discover, Amex, Maestro, Solo.
199
-            // If Maestro or Solo, the currency code must be GBP.
200
-            //  In addition, either start date or issue number must be specified.
201
-            'creditcardtype' => $billing_info['credit_card_type'],
202
-            // Required.  Credit card number.  No spaces or punctuation.
203
-            'acct'           => $billing_info['credit_card'],
204
-            // Required.  Credit card expiration date.  Format is MMYYYY
205
-            'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
206
-            // Requirements determined by your PayPal account settings.  Security digits for credit card.
207
-            'cvv2'           => $billing_info['cvv'],
208
-        );
209
-        $PayerInfo = array(
210
-            // Email address of payer.
211
-            'email'       => $billing_info['email'],
212
-            // Unique PayPal customer ID for payer.
213
-            'payerid'     => '',
214
-            // Status of payer.  Values are verified or unverified
215
-            'payerstatus' => '',
216
-            // Payer's business name.
217
-            'business'    => '',
218
-        );
219
-        $PayerName = array(
220
-            // Payer's salutation.  20 char max.
221
-            'salutation' => '',
222
-            // Payer's first name.  25 char max.
223
-            'firstname'  => substr($billing_info['first_name'], 0, 25),
224
-            // Payer's middle name.  25 char max.
225
-            'middlename' => '',
226
-            // Payer's last name.  25 char max.
227
-            'lastname'   => substr($billing_info['last_name'], 0, 25),
228
-            // Payer's suffix.  12 char max.
229
-            'suffix'     => '',
230
-        );
231
-        $BillingAddress = array(
232
-            // Required.  First street address.
233
-            'street'      => $billing_info['address'],
234
-            // Second street address.
235
-            'street2'     => $billing_info['address2'],
236
-            // Required.  Name of City.
237
-            'city'        => $billing_info['city'],
238
-            // Required. Name of State or Province.
239
-            'state'       => substr($billing_info['state'], 0, 40),
240
-            // Required.  Country code.
241
-            'countrycode' => $billing_info['country'],
242
-            // Required.  Postal code of payer.
243
-            'zip'         => $billing_info['zip'],
244
-        );
245
-        //check if the registration info contains the needed fields for paypal pro
246
-        //(see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
247
-        if ($attendee->address() && $attendee->city() && $attendee->country_ID()) {
248
-            $use_registration_address_info = true;
249
-        } else {
250
-            $use_registration_address_info = false;
251
-        }
252
-        //so if the attendee has enough data to fill out PayPal Pro's shipping info, use it.
253
-        // If not, use the billing info again
254
-        $ShippingAddress = array(
255
-            'shiptoname'     => substr($use_registration_address_info
256
-                ? $attendee->full_name()
257
-                : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
258
-            'shiptostreet'   => substr($use_registration_address_info
259
-                ? $attendee->address()
260
-                : $billing_info['address'], 0, 100),
261
-            'shiptostreet2'  => substr($use_registration_address_info
262
-                ? $attendee->address2() : $billing_info['address2'], 0, 100),
263
-            'shiptocity'     => substr($use_registration_address_info
264
-                ? $attendee->city()
265
-                : $billing_info['city'], 0, 40),
266
-            'state'          => substr($use_registration_address_info
267
-                ? $attendee->state_name()
268
-                : $billing_info['state'], 0, 40),
269
-            'shiptocountry'  => $use_registration_address_info
270
-                ? $attendee->country_ID()
271
-                : $billing_info['country'],
272
-            'shiptozip'      => substr($use_registration_address_info
273
-                ? $attendee->zip()
274
-                : $billing_info['zip'], 0, 20),
275
-            'shiptophonenum' => substr($use_registration_address_info
276
-                ? $attendee->phone()
277
-                : $billing_info['phone'], 0, 20),
278
-        );
279
-        $PaymentDetails = array(
280
-            // Required.  Total amount of order, including shipping, handling, and tax.
281
-            'amt'          => $this->format_currency($payment->amount()),
282
-            // Required.  Three-letter currency code.  Default is USD.
283
-            'currencycode' => $payment->currency_code(),
284
-            // Required if you include itemized cart details. (L_AMTn, etc.)
285
-            //Subtotal of items not including S&H, or tax.
286
-            'itemamt'      => $this->format_currency($item_amount),//
287
-            // Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
288
-            'shippingamt'  => '',
289
-            // Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
290
-            'handlingamt'  => '',
291
-            // Required if you specify itemized cart tax details.
292
-            // Sum of tax for all items on the order.  Total sales tax.
293
-            'taxamt'       => $this->format_currency($tax_amount),
294
-            // Description of the order the customer is purchasing.  127 char max.
295
-            'desc'         => $order_description,
296
-            // Free-form field for your own use.  256 char max.
297
-            'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
298
-            // Your own invoice or tracking number
299
-            'invnum'       => wp_generate_password(12, false),//$transaction->ID(),
300
-            // URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
301
-            'notifyurl'    => '',
302
-            'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this
303
-        );
304
-        // Wrap all data arrays into a single, "master" array which will be passed into the class function.
305
-        $PayPalRequestData = array(
306
-            'DPFields'        => $DPFields,
307
-            'CCDetails'       => $CCDetails,
308
-            'PayerInfo'       => $PayerInfo,
309
-            'PayerName'       => $PayerName,
310
-            'BillingAddress'  => $BillingAddress,
311
-            'ShippingAddress' => $ShippingAddress,
312
-            'PaymentDetails'  => $PaymentDetails,
313
-            'OrderItems'      => $order_items,
314
-        );
315
-        $this->_log_clean_request($PayPalRequestData, $payment);
316
-        try {
317
-            $PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
318
-            //remove PCI-sensitive data so it doesn't get stored
319
-            $PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
320
-            $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK'];
321
-            if (empty($PayPalResult['RAWRESPONSE'])) {
322
-                $payment->set_status($this->_pay_model->failed_status());
323
-                $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso'));
324
-                $payment->set_details($PayPalResult);
325
-            } else {
326
-                if ($this->_APICallSuccessful($PayPalResult)) {
327
-                    $payment->set_status($this->_pay_model->approved_status());
328
-                } else {
329
-                    $payment->set_status($this->_pay_model->declined_status());
330
-                }
331
-                //make sure we interpret the AMT as a float, not an international string
332
-                // (where periods are thousand separators)
333
-                $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
334
-                $payment->set_gateway_response($message);
335
-                $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID'])
336
-                    ? $PayPalResult['TRANSACTIONID']
337
-                    : null);
338
-                $primary_registration_code = $primary_registrant instanceof EE_Registration
339
-                    ? $primary_registrant->reg_code()
340
-                    : '';
341
-                $payment->set_extra_accntng($primary_registration_code);
342
-                $payment->set_details($PayPalResult);
343
-            }
344
-        } catch (Exception $e) {
345
-            $payment->set_status($this->_pay_model->failed_status());
346
-            $payment->set_gateway_response($e->getMessage());
347
-        }
348
-        //$payment->set_status( $this->_pay_model->declined_status() );
349
-        //$payment->set_gateway_response( '' );
350
-        return $payment;
351
-    }
352
-
353
-
354
-
355
-    /**
356
-     * CLeans out sensitive CC data and then logs it, and returns the cleaned request
357
-     *
358
-     * @param array       $request
359
-     * @param EEI_Payment $payment
360
-     * @return void
361
-     */
362
-    private function _log_clean_request($request, $payment)
363
-    {
364
-        $cleaned_request_data = $request;
365
-        unset($cleaned_request_data['CCDetails']['acct']);
366
-        unset($cleaned_request_data['CCDetails']['cvv2']);
367
-        unset($cleaned_request_data['CCDetails']['expdate']);
368
-        $this->log(array('Paypal Request' => $cleaned_request_data), $payment);
369
-    }
370
-
371
-
372
-
373
-    /**
374
-     * Cleans the response, logs it, and returns it
375
-     *
376
-     * @param array       $response
377
-     * @param EEI_Payment $payment
378
-     * @return array cleaned
379
-     */
380
-    private function _log_clean_response($response, $payment)
381
-    {
382
-        unset($response['REQUESTDATA']['CREDITCARDTYPE']);
383
-        unset($response['REQUESTDATA']['ACCT']);
384
-        unset($response['REQUESTDATA']['EXPDATE']);
385
-        unset($response['REQUESTDATA']['CVV2']);
386
-        unset($response['RAWREQUEST']);
387
-        $this->log(array('Paypal Response' => $response), $payment);
388
-        return $response;
389
-    }
390
-
391
-
392
-
393
-    /**
394
-     * @param $DataArray
395
-     * @return array
396
-     */
397
-    private function prep_and_curl_request($DataArray)
398
-    {
399
-        // Create empty holders for each portion of the NVP string
400
-        $DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP';
401
-        $CCDetailsNVP = '';
402
-        $PayerInfoNVP = '';
403
-        $PayerNameNVP = '';
404
-        $BillingAddressNVP = '';
405
-        $ShippingAddressNVP = '';
406
-        $PaymentDetailsNVP = '';
407
-        $OrderItemsNVP = '';
408
-        $Secure3DNVP = '';
409
-        // DP Fields
410
-        $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
411
-        foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
412
-            $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
413
-        }
414
-        // CC Details Fields
415
-        $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
416
-        foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
417
-            $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
418
-        }
419
-        // PayerInfo Type Fields
420
-        $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
421
-        foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
422
-            $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
423
-        }
424
-        // Payer Name Fields
425
-        $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
426
-        foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
427
-            $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
428
-        }
429
-        // Address Fields (Billing)
430
-        $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
431
-        foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
432
-            $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
433
-        }
434
-        // Payment Details Type Fields
435
-        $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
436
-        foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
437
-            $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
438
-        }
439
-        // Payment Details Item Type Fields
440
-        $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
441
-        $n = 0;
442
-        foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
443
-            $CurrentItem = $OrderItems[$OrderItemsVar];
444
-            foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
445
-                $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
446
-            }
447
-            $n++;
448
-        }
449
-        // Ship To Address Fields
450
-        $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
451
-        foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
452
-            $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
453
-        }
454
-        // 3D Secure Fields
455
-        $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
456
-        foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
457
-            $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
458
-        }
459
-        // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
460
-        $NVPRequest = 'USER='
461
-                      . $this->_username
462
-                      . '&PWD='
463
-                      . $this->_password
464
-                      . '&VERSION=64.0'
465
-                      . '&SIGNATURE='
466
-                      . $this->_signature
467
-                      . $DPFieldsNVP
468
-                      . $CCDetailsNVP
469
-                      . $PayerInfoNVP
470
-                      . $PayerNameNVP
471
-                      . $BillingAddressNVP
472
-                      . $PaymentDetailsNVP
473
-                      . $OrderItemsNVP
474
-                      . $ShippingAddressNVP
475
-                      . $Secure3DNVP;
476
-        $NVPResponse = $this->_CURLRequest($NVPRequest);
477
-        $NVPRequestArray = $this->_NVPToArray($NVPRequest);
478
-        $NVPResponseArray = $this->_NVPToArray($NVPResponse);
479
-        $Errors = $this->_GetErrors($NVPResponseArray);
480
-        $NVPResponseArray['ERRORS'] = $Errors;
481
-        $NVPResponseArray['REQUESTDATA'] = $NVPRequestArray;
482
-        $NVPResponseArray['RAWREQUEST'] = $NVPRequest;
483
-        $NVPResponseArray['RAWRESPONSE'] = $NVPResponse;
484
-        return $NVPResponseArray;
485
-    }
486
-
487
-
488
-
489
-    /**
490
-     * @param $Request
491
-     * @return mixed
492
-     */
493
-    private function _CURLRequest($Request)
494
-    {
495
-        $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
496
-        $curl = curl_init();
497
-        curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true));
498
-        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
499
-        curl_setopt($curl, CURLOPT_TIMEOUT, 60);
500
-        curl_setopt($curl, CURLOPT_URL, $EndPointURL);
501
-        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
502
-        curl_setopt($curl, CURLOPT_POSTFIELDS, $Request);
503
-        curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
504
-        //execute the curl POST
505
-        $Response = curl_exec($curl);
506
-        curl_close($curl);
507
-        return $Response;
508
-    }
509
-
510
-
511
-
512
-    /**
513
-     * @param $NVPString
514
-     * @return array
515
-     */
516
-    private function _NVPToArray($NVPString)
517
-    {
518
-        // prepare responses into array
519
-        $proArray = array();
520
-        while (strlen($NVPString)) {
521
-            // name
522
-            $keypos = strpos($NVPString, '=');
523
-            $keyval = substr($NVPString, 0, $keypos);
524
-            // value
525
-            $valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
526
-            $valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1);
527
-            // decoding the response
528
-            $proArray[$keyval] = urldecode($valval);
529
-            $NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString));
530
-        }
531
-        return $proArray;
532
-    }
533
-
534
-
535
-
536
-    /**
537
-     * @param array $PayPalResult
538
-     * @return bool
539
-     */
540
-    private function _APICallSuccessful($PayPalResult)
541
-    {
542
-        $approved = false;
543
-        // check main response message from PayPal
544
-        if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
545
-            $ack = strtoupper($PayPalResult['ACK']);
546
-            $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
547
-        }
548
-        return $approved;
549
-    }
550
-
551
-
552
-
553
-    /**
554
-     * @param $DataArray
555
-     * @return array
556
-     */
557
-    private function _GetErrors($DataArray)
558
-    {
559
-        $Errors = array();
560
-        $n = 0;
561
-        while (isset($DataArray['L_ERRORCODE' . $n . ''])) {
562
-            $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : '';
563
-            $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . ''])
564
-                ? $DataArray['L_SHORTMESSAGE' . $n . '']
565
-                : '';
566
-            $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . ''])
567
-                ? $DataArray['L_LONGMESSAGE' . $n . '']
568
-                : '';
569
-            $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . ''])
570
-                ? $DataArray['L_SEVERITYCODE' . $n . '']
571
-                : '';
572
-            $CurrentItem = array(
573
-                'L_ERRORCODE'    => $LErrorCode,
574
-                'L_SHORTMESSAGE' => $LShortMessage,
575
-                'L_LONGMESSAGE'  => $LLongMessage,
576
-                'L_SEVERITYCODE' => $LSeverityCode,
577
-            );
578
-            array_push($Errors, $CurrentItem);
579
-            $n++;
580
-        }
581
-        return $Errors;
582
-    }
583
-
584
-
585
-
586
-    /**
587
-     *        nothing to see here...  move along....
588
-     *
589
-     * @access protected
590
-     * @param $Errors
591
-     * @return string
592
-     */
593
-    private function _DisplayErrors($Errors)
594
-    {
595
-        $error = '';
596
-        foreach ($Errors as $ErrorVar => $ErrorVal) {
597
-            $CurrentError = $Errors[$ErrorVar];
598
-            foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) {
599
-                $CurrentVarName = '';
600
-                if ($CurrentErrorVar == 'L_ERRORCODE') {
601
-                    $CurrentVarName = 'Error Code';
602
-                } elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') {
603
-                    $CurrentVarName = 'Short Message';
604
-                } elseif ($CurrentErrorVar == 'L_LONGMESSAGE') {
605
-                    $CurrentVarName = 'Long Message';
606
-                } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
607
-                    $CurrentVarName = 'Severity Code';
608
-                }
609
-                $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
610
-            }
611
-        }
612
-        return $error;
613
-    }
28
+	/**
29
+	 * @var $_paypal_api_username string
30
+	 */
31
+	protected $_username = null;
32
+
33
+	/**
34
+	 * @var $_password string
35
+	 */
36
+	protected $_password = null;
37
+
38
+	/**
39
+	 * @var $_signature string
40
+	 */
41
+	protected $_signature = null;
42
+
43
+	/**
44
+	 * @var $_credit_card_types array with the keys for credit card types accepted on this account
45
+	 */
46
+	protected $_credit_card_types    = null;
47
+
48
+	protected $_currencies_supported = array(
49
+		'USD',
50
+		'GBP',
51
+		'CAD',
52
+		'AUD',
53
+		'BRL',
54
+		'CHF',
55
+		'CZK',
56
+		'DKK',
57
+		'EUR',
58
+		'HKD',
59
+		'HUF',
60
+		'ILS',
61
+		'JPY',
62
+		'MXN',
63
+		'MYR',
64
+		'NOK',
65
+		'NZD',
66
+		'PHP',
67
+		'PLN',
68
+		'SEK',
69
+		'SGD',
70
+		'THB',
71
+		'TRY',
72
+		'TWD',
73
+		'RUB',
74
+	);
75
+
76
+
77
+
78
+	/**
79
+	 * @param EEI_Payment $payment
80
+	 * @param array       $billing_info {
81
+	 * @type string $credit_card
82
+	 * @type string $credit_card_type
83
+	 * @type string $exp_month always 2 characters
84
+	 * @type string $exp_year always 4 characters
85
+	 * @type string $cvv
86
+	 * }
87
+	 * @see      parent::do_direct_payment for more info
88
+	 * @return EE_Payment|EEI_Payment
89
+	 * @throws EE_Error
90
+	 */
91
+	public function do_direct_payment($payment, $billing_info = null)
92
+	{
93
+		$transaction = $payment->transaction();
94
+		if (! $transaction instanceof EEI_Transaction) {
95
+			throw new EE_Error(
96
+				esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
97
+			);
98
+		}
99
+		$primary_registrant = $transaction->primary_registration();
100
+		if (! $primary_registrant instanceof EEI_Registration) {
101
+			throw new EE_Error(
102
+				esc_html__(
103
+					'No primary registration on transaction while paying with PayPal Pro.',
104
+					'event_espresso'
105
+				)
106
+			);
107
+		}
108
+		$attendee = $primary_registrant->attendee();
109
+		if (! $attendee instanceof EEI_Attendee) {
110
+			throw new EE_Error(
111
+				esc_html__(
112
+					'No attendee on primary registration while paying with PayPal Pro.',
113
+					'event_espresso'
114
+				)
115
+			);
116
+		}
117
+		$order_description = substr($this->_format_order_description($payment), 0, 127);
118
+		//charge for the full amount. Show itemized list
119
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
120
+			$item_num = 1;
121
+			$total_line_item = $transaction->total_line_item();
122
+			$order_items = array();
123
+			foreach ($total_line_item->get_items() as $line_item) {
124
+				//ignore line items with a quantity of 0
125
+				if ($line_item->quantity() == 0) {
126
+					continue;
127
+				}
128
+				$item = array(
129
+					// Item Name.  127 char max.
130
+					'l_name'                 => substr(
131
+						$this->_format_line_item_name($line_item, $payment),
132
+						0,
133
+						127
134
+					),
135
+					// Item description.  127 char max.
136
+					'l_desc'                 => substr(
137
+						$this->_format_line_item_desc($line_item, $payment),
138
+						0,
139
+						127
140
+					),
141
+					// Cost of individual item.
142
+					'l_amt'                  => $line_item->unit_price(),
143
+					// Item Number.  127 char max.
144
+					'l_number'               => $item_num++,
145
+					// Item quantity.  Must be any positive integer.
146
+					'l_qty'                  => $line_item->quantity(),
147
+					// Item's sales tax amount.
148
+					'l_taxamt'               => '',
149
+					// eBay auction number of item.
150
+					'l_ebayitemnumber'       => '',
151
+					// eBay transaction ID of purchased item.
152
+					'l_ebayitemauctiontxnid' => '',
153
+					// eBay order ID for the item.
154
+					'l_ebayitemorderid'      => '',
155
+				);
156
+				// add to array of all items
157
+				array_push($order_items, $item);
158
+			}
159
+			$item_amount = $total_line_item->get_items_total();
160
+			$tax_amount = $total_line_item->get_total_tax();
161
+		} else {
162
+			$order_items = array();
163
+			$item_amount = $payment->amount();
164
+			$tax_amount = 0;
165
+			array_push($order_items, array(
166
+				// Item Name.  127 char max.
167
+				'l_name'   => substr(
168
+					$this->_format_partial_payment_line_item_name($payment),
169
+					0,
170
+					127
171
+				),
172
+				// Item description.  127 char max.
173
+				'l_desc'   => substr(
174
+					$this->_format_partial_payment_line_item_desc($payment),
175
+					0,
176
+					127
177
+				),
178
+				// Cost of individual item.
179
+				'l_amt'    => $payment->amount(),
180
+				// Item Number.  127 char max.
181
+				'l_number' => 1,
182
+				// Item quantity.  Must be any positive integer.
183
+				'l_qty'    => 1,
184
+			));
185
+		}
186
+		// Populate data arrays with order data.
187
+		$DPFields = array(
188
+			// How you want to obtain payment ?
189
+			// Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture.
190
+			// Sale indicates that this is a final sale for which you are requesting payment.  Default is Sale.
191
+			'paymentaction'    => 'Sale',
192
+			// Required.  IP address of the payer's browser.
193
+			'ipaddress'        => $_SERVER['REMOTE_ADDR'],
194
+			// Flag to determine whether you want the results returned by FMF.  1 or 0.  Default is 0.
195
+			'returnfmfdetails' => '1',
196
+		);
197
+		$CCDetails = array(
198
+			// Required. Type of credit card.  Visa, MasterCard, Discover, Amex, Maestro, Solo.
199
+			// If Maestro or Solo, the currency code must be GBP.
200
+			//  In addition, either start date or issue number must be specified.
201
+			'creditcardtype' => $billing_info['credit_card_type'],
202
+			// Required.  Credit card number.  No spaces or punctuation.
203
+			'acct'           => $billing_info['credit_card'],
204
+			// Required.  Credit card expiration date.  Format is MMYYYY
205
+			'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
206
+			// Requirements determined by your PayPal account settings.  Security digits for credit card.
207
+			'cvv2'           => $billing_info['cvv'],
208
+		);
209
+		$PayerInfo = array(
210
+			// Email address of payer.
211
+			'email'       => $billing_info['email'],
212
+			// Unique PayPal customer ID for payer.
213
+			'payerid'     => '',
214
+			// Status of payer.  Values are verified or unverified
215
+			'payerstatus' => '',
216
+			// Payer's business name.
217
+			'business'    => '',
218
+		);
219
+		$PayerName = array(
220
+			// Payer's salutation.  20 char max.
221
+			'salutation' => '',
222
+			// Payer's first name.  25 char max.
223
+			'firstname'  => substr($billing_info['first_name'], 0, 25),
224
+			// Payer's middle name.  25 char max.
225
+			'middlename' => '',
226
+			// Payer's last name.  25 char max.
227
+			'lastname'   => substr($billing_info['last_name'], 0, 25),
228
+			// Payer's suffix.  12 char max.
229
+			'suffix'     => '',
230
+		);
231
+		$BillingAddress = array(
232
+			// Required.  First street address.
233
+			'street'      => $billing_info['address'],
234
+			// Second street address.
235
+			'street2'     => $billing_info['address2'],
236
+			// Required.  Name of City.
237
+			'city'        => $billing_info['city'],
238
+			// Required. Name of State or Province.
239
+			'state'       => substr($billing_info['state'], 0, 40),
240
+			// Required.  Country code.
241
+			'countrycode' => $billing_info['country'],
242
+			// Required.  Postal code of payer.
243
+			'zip'         => $billing_info['zip'],
244
+		);
245
+		//check if the registration info contains the needed fields for paypal pro
246
+		//(see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
247
+		if ($attendee->address() && $attendee->city() && $attendee->country_ID()) {
248
+			$use_registration_address_info = true;
249
+		} else {
250
+			$use_registration_address_info = false;
251
+		}
252
+		//so if the attendee has enough data to fill out PayPal Pro's shipping info, use it.
253
+		// If not, use the billing info again
254
+		$ShippingAddress = array(
255
+			'shiptoname'     => substr($use_registration_address_info
256
+				? $attendee->full_name()
257
+				: $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
258
+			'shiptostreet'   => substr($use_registration_address_info
259
+				? $attendee->address()
260
+				: $billing_info['address'], 0, 100),
261
+			'shiptostreet2'  => substr($use_registration_address_info
262
+				? $attendee->address2() : $billing_info['address2'], 0, 100),
263
+			'shiptocity'     => substr($use_registration_address_info
264
+				? $attendee->city()
265
+				: $billing_info['city'], 0, 40),
266
+			'state'          => substr($use_registration_address_info
267
+				? $attendee->state_name()
268
+				: $billing_info['state'], 0, 40),
269
+			'shiptocountry'  => $use_registration_address_info
270
+				? $attendee->country_ID()
271
+				: $billing_info['country'],
272
+			'shiptozip'      => substr($use_registration_address_info
273
+				? $attendee->zip()
274
+				: $billing_info['zip'], 0, 20),
275
+			'shiptophonenum' => substr($use_registration_address_info
276
+				? $attendee->phone()
277
+				: $billing_info['phone'], 0, 20),
278
+		);
279
+		$PaymentDetails = array(
280
+			// Required.  Total amount of order, including shipping, handling, and tax.
281
+			'amt'          => $this->format_currency($payment->amount()),
282
+			// Required.  Three-letter currency code.  Default is USD.
283
+			'currencycode' => $payment->currency_code(),
284
+			// Required if you include itemized cart details. (L_AMTn, etc.)
285
+			//Subtotal of items not including S&H, or tax.
286
+			'itemamt'      => $this->format_currency($item_amount),//
287
+			// Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
288
+			'shippingamt'  => '',
289
+			// Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
290
+			'handlingamt'  => '',
291
+			// Required if you specify itemized cart tax details.
292
+			// Sum of tax for all items on the order.  Total sales tax.
293
+			'taxamt'       => $this->format_currency($tax_amount),
294
+			// Description of the order the customer is purchasing.  127 char max.
295
+			'desc'         => $order_description,
296
+			// Free-form field for your own use.  256 char max.
297
+			'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
298
+			// Your own invoice or tracking number
299
+			'invnum'       => wp_generate_password(12, false),//$transaction->ID(),
300
+			// URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
301
+			'notifyurl'    => '',
302
+			'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this
303
+		);
304
+		// Wrap all data arrays into a single, "master" array which will be passed into the class function.
305
+		$PayPalRequestData = array(
306
+			'DPFields'        => $DPFields,
307
+			'CCDetails'       => $CCDetails,
308
+			'PayerInfo'       => $PayerInfo,
309
+			'PayerName'       => $PayerName,
310
+			'BillingAddress'  => $BillingAddress,
311
+			'ShippingAddress' => $ShippingAddress,
312
+			'PaymentDetails'  => $PaymentDetails,
313
+			'OrderItems'      => $order_items,
314
+		);
315
+		$this->_log_clean_request($PayPalRequestData, $payment);
316
+		try {
317
+			$PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
318
+			//remove PCI-sensitive data so it doesn't get stored
319
+			$PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
320
+			$message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK'];
321
+			if (empty($PayPalResult['RAWRESPONSE'])) {
322
+				$payment->set_status($this->_pay_model->failed_status());
323
+				$payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso'));
324
+				$payment->set_details($PayPalResult);
325
+			} else {
326
+				if ($this->_APICallSuccessful($PayPalResult)) {
327
+					$payment->set_status($this->_pay_model->approved_status());
328
+				} else {
329
+					$payment->set_status($this->_pay_model->declined_status());
330
+				}
331
+				//make sure we interpret the AMT as a float, not an international string
332
+				// (where periods are thousand separators)
333
+				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
334
+				$payment->set_gateway_response($message);
335
+				$payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID'])
336
+					? $PayPalResult['TRANSACTIONID']
337
+					: null);
338
+				$primary_registration_code = $primary_registrant instanceof EE_Registration
339
+					? $primary_registrant->reg_code()
340
+					: '';
341
+				$payment->set_extra_accntng($primary_registration_code);
342
+				$payment->set_details($PayPalResult);
343
+			}
344
+		} catch (Exception $e) {
345
+			$payment->set_status($this->_pay_model->failed_status());
346
+			$payment->set_gateway_response($e->getMessage());
347
+		}
348
+		//$payment->set_status( $this->_pay_model->declined_status() );
349
+		//$payment->set_gateway_response( '' );
350
+		return $payment;
351
+	}
352
+
353
+
354
+
355
+	/**
356
+	 * CLeans out sensitive CC data and then logs it, and returns the cleaned request
357
+	 *
358
+	 * @param array       $request
359
+	 * @param EEI_Payment $payment
360
+	 * @return void
361
+	 */
362
+	private function _log_clean_request($request, $payment)
363
+	{
364
+		$cleaned_request_data = $request;
365
+		unset($cleaned_request_data['CCDetails']['acct']);
366
+		unset($cleaned_request_data['CCDetails']['cvv2']);
367
+		unset($cleaned_request_data['CCDetails']['expdate']);
368
+		$this->log(array('Paypal Request' => $cleaned_request_data), $payment);
369
+	}
370
+
371
+
372
+
373
+	/**
374
+	 * Cleans the response, logs it, and returns it
375
+	 *
376
+	 * @param array       $response
377
+	 * @param EEI_Payment $payment
378
+	 * @return array cleaned
379
+	 */
380
+	private function _log_clean_response($response, $payment)
381
+	{
382
+		unset($response['REQUESTDATA']['CREDITCARDTYPE']);
383
+		unset($response['REQUESTDATA']['ACCT']);
384
+		unset($response['REQUESTDATA']['EXPDATE']);
385
+		unset($response['REQUESTDATA']['CVV2']);
386
+		unset($response['RAWREQUEST']);
387
+		$this->log(array('Paypal Response' => $response), $payment);
388
+		return $response;
389
+	}
390
+
391
+
392
+
393
+	/**
394
+	 * @param $DataArray
395
+	 * @return array
396
+	 */
397
+	private function prep_and_curl_request($DataArray)
398
+	{
399
+		// Create empty holders for each portion of the NVP string
400
+		$DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP';
401
+		$CCDetailsNVP = '';
402
+		$PayerInfoNVP = '';
403
+		$PayerNameNVP = '';
404
+		$BillingAddressNVP = '';
405
+		$ShippingAddressNVP = '';
406
+		$PaymentDetailsNVP = '';
407
+		$OrderItemsNVP = '';
408
+		$Secure3DNVP = '';
409
+		// DP Fields
410
+		$DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
411
+		foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
412
+			$DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
413
+		}
414
+		// CC Details Fields
415
+		$CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
416
+		foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
417
+			$CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
418
+		}
419
+		// PayerInfo Type Fields
420
+		$PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
421
+		foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
422
+			$PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
423
+		}
424
+		// Payer Name Fields
425
+		$PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
426
+		foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
427
+			$PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
428
+		}
429
+		// Address Fields (Billing)
430
+		$BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
431
+		foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
432
+			$BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
433
+		}
434
+		// Payment Details Type Fields
435
+		$PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
436
+		foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
437
+			$PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
438
+		}
439
+		// Payment Details Item Type Fields
440
+		$OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
441
+		$n = 0;
442
+		foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
443
+			$CurrentItem = $OrderItems[$OrderItemsVar];
444
+			foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
445
+				$OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
446
+			}
447
+			$n++;
448
+		}
449
+		// Ship To Address Fields
450
+		$ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
451
+		foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
452
+			$ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
453
+		}
454
+		// 3D Secure Fields
455
+		$Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
456
+		foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
457
+			$Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
458
+		}
459
+		// Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
460
+		$NVPRequest = 'USER='
461
+					  . $this->_username
462
+					  . '&PWD='
463
+					  . $this->_password
464
+					  . '&VERSION=64.0'
465
+					  . '&SIGNATURE='
466
+					  . $this->_signature
467
+					  . $DPFieldsNVP
468
+					  . $CCDetailsNVP
469
+					  . $PayerInfoNVP
470
+					  . $PayerNameNVP
471
+					  . $BillingAddressNVP
472
+					  . $PaymentDetailsNVP
473
+					  . $OrderItemsNVP
474
+					  . $ShippingAddressNVP
475
+					  . $Secure3DNVP;
476
+		$NVPResponse = $this->_CURLRequest($NVPRequest);
477
+		$NVPRequestArray = $this->_NVPToArray($NVPRequest);
478
+		$NVPResponseArray = $this->_NVPToArray($NVPResponse);
479
+		$Errors = $this->_GetErrors($NVPResponseArray);
480
+		$NVPResponseArray['ERRORS'] = $Errors;
481
+		$NVPResponseArray['REQUESTDATA'] = $NVPRequestArray;
482
+		$NVPResponseArray['RAWREQUEST'] = $NVPRequest;
483
+		$NVPResponseArray['RAWRESPONSE'] = $NVPResponse;
484
+		return $NVPResponseArray;
485
+	}
486
+
487
+
488
+
489
+	/**
490
+	 * @param $Request
491
+	 * @return mixed
492
+	 */
493
+	private function _CURLRequest($Request)
494
+	{
495
+		$EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
496
+		$curl = curl_init();
497
+		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true));
498
+		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
499
+		curl_setopt($curl, CURLOPT_TIMEOUT, 60);
500
+		curl_setopt($curl, CURLOPT_URL, $EndPointURL);
501
+		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
502
+		curl_setopt($curl, CURLOPT_POSTFIELDS, $Request);
503
+		curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
504
+		//execute the curl POST
505
+		$Response = curl_exec($curl);
506
+		curl_close($curl);
507
+		return $Response;
508
+	}
509
+
510
+
511
+
512
+	/**
513
+	 * @param $NVPString
514
+	 * @return array
515
+	 */
516
+	private function _NVPToArray($NVPString)
517
+	{
518
+		// prepare responses into array
519
+		$proArray = array();
520
+		while (strlen($NVPString)) {
521
+			// name
522
+			$keypos = strpos($NVPString, '=');
523
+			$keyval = substr($NVPString, 0, $keypos);
524
+			// value
525
+			$valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
526
+			$valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1);
527
+			// decoding the response
528
+			$proArray[$keyval] = urldecode($valval);
529
+			$NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString));
530
+		}
531
+		return $proArray;
532
+	}
533
+
534
+
535
+
536
+	/**
537
+	 * @param array $PayPalResult
538
+	 * @return bool
539
+	 */
540
+	private function _APICallSuccessful($PayPalResult)
541
+	{
542
+		$approved = false;
543
+		// check main response message from PayPal
544
+		if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
545
+			$ack = strtoupper($PayPalResult['ACK']);
546
+			$approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
547
+		}
548
+		return $approved;
549
+	}
550
+
551
+
552
+
553
+	/**
554
+	 * @param $DataArray
555
+	 * @return array
556
+	 */
557
+	private function _GetErrors($DataArray)
558
+	{
559
+		$Errors = array();
560
+		$n = 0;
561
+		while (isset($DataArray['L_ERRORCODE' . $n . ''])) {
562
+			$LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : '';
563
+			$LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . ''])
564
+				? $DataArray['L_SHORTMESSAGE' . $n . '']
565
+				: '';
566
+			$LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . ''])
567
+				? $DataArray['L_LONGMESSAGE' . $n . '']
568
+				: '';
569
+			$LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . ''])
570
+				? $DataArray['L_SEVERITYCODE' . $n . '']
571
+				: '';
572
+			$CurrentItem = array(
573
+				'L_ERRORCODE'    => $LErrorCode,
574
+				'L_SHORTMESSAGE' => $LShortMessage,
575
+				'L_LONGMESSAGE'  => $LLongMessage,
576
+				'L_SEVERITYCODE' => $LSeverityCode,
577
+			);
578
+			array_push($Errors, $CurrentItem);
579
+			$n++;
580
+		}
581
+		return $Errors;
582
+	}
583
+
584
+
585
+
586
+	/**
587
+	 *        nothing to see here...  move along....
588
+	 *
589
+	 * @access protected
590
+	 * @param $Errors
591
+	 * @return string
592
+	 */
593
+	private function _DisplayErrors($Errors)
594
+	{
595
+		$error = '';
596
+		foreach ($Errors as $ErrorVar => $ErrorVal) {
597
+			$CurrentError = $Errors[$ErrorVar];
598
+			foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) {
599
+				$CurrentVarName = '';
600
+				if ($CurrentErrorVar == 'L_ERRORCODE') {
601
+					$CurrentVarName = 'Error Code';
602
+				} elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') {
603
+					$CurrentVarName = 'Short Message';
604
+				} elseif ($CurrentErrorVar == 'L_LONGMESSAGE') {
605
+					$CurrentVarName = 'Long Message';
606
+				} elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
607
+					$CurrentVarName = 'Severity Code';
608
+				}
609
+				$error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
610
+			}
611
+		}
612
+		return $error;
613
+	}
614 614
 }
615 615
 // End of file EEG_Paypal_Pro.gateway.php
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('No direct script access allowed');
4 4
 }
5 5
 
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
     public function do_direct_payment($payment, $billing_info = null)
92 92
     {
93 93
         $transaction = $payment->transaction();
94
-        if (! $transaction instanceof EEI_Transaction) {
94
+        if ( ! $transaction instanceof EEI_Transaction) {
95 95
             throw new EE_Error(
96 96
                 esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
97 97
             );
98 98
         }
99 99
         $primary_registrant = $transaction->primary_registration();
100
-        if (! $primary_registrant instanceof EEI_Registration) {
100
+        if ( ! $primary_registrant instanceof EEI_Registration) {
101 101
             throw new EE_Error(
102 102
                 esc_html__(
103 103
                     'No primary registration on transaction while paying with PayPal Pro.',
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             );
107 107
         }
108 108
         $attendee = $primary_registrant->attendee();
109
-        if (! $attendee instanceof EEI_Attendee) {
109
+        if ( ! $attendee instanceof EEI_Attendee) {
110 110
             throw new EE_Error(
111 111
                 esc_html__(
112 112
                     'No attendee on primary registration while paying with PayPal Pro.',
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             // Required.  Credit card number.  No spaces or punctuation.
203 203
             'acct'           => $billing_info['credit_card'],
204 204
             // Required.  Credit card expiration date.  Format is MMYYYY
205
-            'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
205
+            'expdate'        => $billing_info['exp_month'].$billing_info['exp_year'],
206 206
             // Requirements determined by your PayPal account settings.  Security digits for credit card.
207 207
             'cvv2'           => $billing_info['cvv'],
208 208
         );
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
         $ShippingAddress = array(
255 255
             'shiptoname'     => substr($use_registration_address_info
256 256
                 ? $attendee->full_name()
257
-                : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
257
+                : $billing_info['first_name'].' '.$billing_info['last_name'], 0, 32),
258 258
             'shiptostreet'   => substr($use_registration_address_info
259 259
                 ? $attendee->address()
260 260
                 : $billing_info['address'], 0, 100),
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
             'currencycode' => $payment->currency_code(),
284 284
             // Required if you include itemized cart details. (L_AMTn, etc.)
285 285
             //Subtotal of items not including S&H, or tax.
286
-            'itemamt'      => $this->format_currency($item_amount),//
286
+            'itemamt'      => $this->format_currency($item_amount), //
287 287
             // Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
288 288
             'shippingamt'  => '',
289 289
             // Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
@@ -296,10 +296,10 @@  discard block
 block discarded – undo
296 296
             // Free-form field for your own use.  256 char max.
297 297
             'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
298 298
             // Your own invoice or tracking number
299
-            'invnum'       => wp_generate_password(12, false),//$transaction->ID(),
299
+            'invnum'       => wp_generate_password(12, false), //$transaction->ID(),
300 300
             // URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
301 301
             'notifyurl'    => '',
302
-            'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this
302
+            'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this
303 303
         );
304 304
         // Wrap all data arrays into a single, "master" array which will be passed into the class function.
305 305
         $PayPalRequestData = array(
@@ -409,32 +409,32 @@  discard block
 block discarded – undo
409 409
         // DP Fields
410 410
         $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
411 411
         foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
412
-            $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
412
+            $DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal);
413 413
         }
414 414
         // CC Details Fields
415 415
         $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
416 416
         foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
417
-            $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
417
+            $CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal);
418 418
         }
419 419
         // PayerInfo Type Fields
420 420
         $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
421 421
         foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
422
-            $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
422
+            $PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal);
423 423
         }
424 424
         // Payer Name Fields
425 425
         $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
426 426
         foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
427
-            $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
427
+            $PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal);
428 428
         }
429 429
         // Address Fields (Billing)
430 430
         $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
431 431
         foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
432
-            $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
432
+            $BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal);
433 433
         }
434 434
         // Payment Details Type Fields
435 435
         $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
436 436
         foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
437
-            $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
437
+            $PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal);
438 438
         }
439 439
         // Payment Details Item Type Fields
440 440
         $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
@@ -442,19 +442,19 @@  discard block
 block discarded – undo
442 442
         foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
443 443
             $CurrentItem = $OrderItems[$OrderItemsVar];
444 444
             foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
445
-                $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
445
+                $OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal);
446 446
             }
447 447
             $n++;
448 448
         }
449 449
         // Ship To Address Fields
450 450
         $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
451 451
         foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
452
-            $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
452
+            $ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal);
453 453
         }
454 454
         // 3D Secure Fields
455 455
         $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
456 456
         foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
457
-            $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
457
+            $Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal);
458 458
         }
459 459
         // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
460 460
         $NVPRequest = 'USER='
@@ -558,16 +558,16 @@  discard block
 block discarded – undo
558 558
     {
559 559
         $Errors = array();
560 560
         $n = 0;
561
-        while (isset($DataArray['L_ERRORCODE' . $n . ''])) {
562
-            $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : '';
563
-            $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . ''])
564
-                ? $DataArray['L_SHORTMESSAGE' . $n . '']
561
+        while (isset($DataArray['L_ERRORCODE'.$n.''])) {
562
+            $LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : '';
563
+            $LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.''])
564
+                ? $DataArray['L_SHORTMESSAGE'.$n.'']
565 565
                 : '';
566
-            $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . ''])
567
-                ? $DataArray['L_LONGMESSAGE' . $n . '']
566
+            $LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.''])
567
+                ? $DataArray['L_LONGMESSAGE'.$n.'']
568 568
                 : '';
569
-            $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . ''])
570
-                ? $DataArray['L_SEVERITYCODE' . $n . '']
569
+            $LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.''])
570
+                ? $DataArray['L_SEVERITYCODE'.$n.'']
571 571
                 : '';
572 572
             $CurrentItem = array(
573 573
                 'L_ERRORCODE'    => $LErrorCode,
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
                 } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
607 607
                     $CurrentVarName = 'Severity Code';
608 608
                 }
609
-                $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
609
+                $error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal;
610 610
             }
611 611
         }
612 612
         return $error;
Please login to merge, or discard this patch.
libraries/line_item_display/EE_SPCO_Line_Item_Display_Strategy.strategy.php 3 patches
Doc Comments   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      * @param EE_Line_Item $line_item
78 78
      * @param array        $options
79 79
      * @param EE_Line_Item $parent_line_item
80
-     * @return mixed
80
+     * @return string
81 81
      * @throws EE_Error
82 82
      */
83 83
     public function display_line_item(
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      * _event_row - basically a Heading row displayed once above each event's ticket rows
224 224
      *
225 225
      * @param EE_Line_Item $line_item
226
-     * @return mixed
226
+     * @return string
227 227
      */
228 228
     private function _event_row(EE_Line_Item $line_item)
229 229
     {
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      *
250 250
      * @param EE_Line_Item $line_item
251 251
      * @param array        $options
252
-     * @return mixed
252
+     * @return string
253 253
      * @throws EE_Error
254 254
      */
255 255
     private function _ticket_row(EE_Line_Item $line_item, $options = array())
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      *
304 304
      * @param EE_Line_Item $line_item
305 305
      * @param array        $options
306
-     * @return mixed
306
+     * @return string
307 307
      * @throws EE_Error
308 308
      */
309 309
     private function _item_row(EE_Line_Item $line_item, $options = array())
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
      * @param EE_Line_Item $line_item
364 364
      * @param array        $options
365 365
      * @param EE_Line_Item $parent_line_item
366
-     * @return mixed
366
+     * @return string
367 367
      * @throws EE_Error
368 368
      */
369 369
     private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null)
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
      *
408 408
      * @param EE_Line_Item $line_item
409 409
      * @param array        $options
410
-     * @return mixed
410
+     * @return string
411 411
      * @throws EE_Error
412 412
      */
413 413
     private function _tax_row(EE_Line_Item $line_item, $options = array())
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
      *
445 445
      * @param EE_Line_Item $line_item
446 446
      * @param string       $text
447
-     * @return mixed
447
+     * @return string
448 448
      * @throws EE_Error
449 449
      */
450 450
     private function _total_tax_row(EE_Line_Item $line_item, $text = '')
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
      * @param EE_Line_Item $line_item
484 484
      * @param string       $text
485 485
      * @param array        $options
486
-     * @return mixed
486
+     * @return string
487 487
      * @throws EE_Error
488 488
      */
489 489
     private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array())
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
      *
520 520
      * @param EE_Line_Item $line_item
521 521
      * @param string       $text
522
-     * @return mixed
522
+     * @return string
523 523
      * @throws EE_Error
524 524
      */
525 525
     private function _total_row(EE_Line_Item $line_item, $text = '')
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
      *
547 547
      * @param EE_Line_Item $line_item
548 548
      * @param array        $options
549
-     * @return mixed
549
+     * @return string
550 550
      * @throws EE_Error
551 551
      */
552 552
     private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array())
Please login to merge, or discard this patch.
Indentation   +603 added lines, -603 removed lines patch added patch discarded remove patch
@@ -16,609 +16,609 @@
 block discarded – undo
16 16
 class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display
17 17
 {
18 18
 
19
-    /**
20
-     * array of events
21
-     *
22
-     * @type EE_Line_Item[] $_events
23
-     */
24
-    private $_events = array();
25
-
26
-    /**
27
-     * whether to display the taxes row or not
28
-     *
29
-     * @type bool $_show_taxes
30
-     */
31
-    private $_show_taxes = false;
32
-
33
-    /**
34
-     * html for any tax rows
35
-     *
36
-     * @type string $_show_taxes
37
-     */
38
-    private $_taxes_html = '';
39
-
40
-    /**
41
-     * total amount including tax we can bill for at this time
42
-     *
43
-     * @type float $_grand_total
44
-     */
45
-    private $_grand_total = 0.00;
46
-
47
-    /**
48
-     * total number of items being billed for
49
-     *
50
-     * @type int $_total_items
51
-     */
52
-    private $_total_items = 0;
53
-
54
-
55
-
56
-    /**
57
-     * @return float
58
-     */
59
-    public function grand_total()
60
-    {
61
-        return $this->_grand_total;
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * @return int
68
-     */
69
-    public function total_items()
70
-    {
71
-        return $this->_total_items;
72
-    }
73
-
74
-
75
-
76
-    /**
77
-     * @param EE_Line_Item $line_item
78
-     * @param array        $options
79
-     * @param EE_Line_Item $parent_line_item
80
-     * @return mixed
81
-     * @throws EE_Error
82
-     */
83
-    public function display_line_item(
84
-        EE_Line_Item $line_item,
85
-        $options = array(),
86
-        EE_Line_Item $parent_line_item = null
87
-    ) {
88
-        $html = '';
89
-        // set some default options and merge with incoming
90
-        $default_options = array(
91
-            'show_desc' => true,  // 	true 		false
92
-            'odd'       => false,
93
-        );
94
-        $options = array_merge($default_options, (array)$options);
95
-        switch ($line_item->type()) {
96
-            case EEM_Line_Item::type_line_item:
97
-                $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes;
98
-                if ($line_item->OBJ_type() === 'Ticket') {
99
-                    // item row
100
-                    $html .= $this->_ticket_row($line_item, $options);
101
-                } else {
102
-                    // item row
103
-                    $html .= $this->_item_row($line_item, $options);
104
-                }
105
-                if (
106
-                apply_filters(
107
-                    'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items',
108
-                    true
109
-                )
110
-                ) {
111
-                    // got any kids?
112
-                    foreach ($line_item->children() as $child_line_item) {
113
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
114
-                    }
115
-                }
116
-                break;
117
-            case EEM_Line_Item::type_sub_line_item:
118
-                $html .= $this->_sub_item_row($line_item, $options, $parent_line_item);
119
-                break;
120
-            case EEM_Line_Item::type_sub_total:
121
-                static $sub_total = 0;
122
-                $event_sub_total = 0;
123
-                $text = esc_html__('Sub-Total', 'event_espresso');
124
-                if ($line_item->OBJ_type() === 'Event') {
125
-                    $options['event_id'] = $event_id = $line_item->OBJ_ID();
126
-                    if (! isset($this->_events[$options['event_id']])) {
127
-                        $event = EEM_Event::instance()->get_one_by_ID($options['event_id']);
128
-                        // if event has default reg status of Not Approved, then don't display info on it
129
-                        if (
130
-                            $event instanceof EE_Event
131
-                            && $event->default_registration_status() === EEM_Registration::status_id_not_approved
132
-                        ) {
133
-                            $display_event = false;
134
-                            // unless there are registrations for it that are returning to pay
135
-                            if (isset($options['registrations']) && is_array($options['registrations'])) {
136
-                                foreach ($options['registrations'] as $registration) {
137
-                                    if (! $registration instanceof EE_Registration) {
138
-                                        continue;
139
-                                    }
140
-                                    $display_event = $registration->event_ID() === $options['event_id']
141
-                                                     && $registration->status_ID() !== EEM_Registration::status_id_not_approved
142
-                                        ? true
143
-                                        : $display_event;
144
-                                }
145
-                            }
146
-                            if (! $display_event) {
147
-                                return '';
148
-                            }
149
-                        }
150
-                        $this->_events[$options['event_id']] = 0;
151
-                        $html .= $this->_event_row($line_item);
152
-                        $text = esc_html__('Event Sub-Total', 'event_espresso');
153
-                    }
154
-                }
155
-                $child_line_items = $line_item->children();
156
-                // loop thru children
157
-                foreach ($child_line_items as $child_line_item) {
158
-                    // recursively feed children back into this method
159
-                    $html .= $this->display_line_item($child_line_item, $options, $line_item);
160
-                }
161
-                $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0;
162
-                $sub_total += $event_sub_total;
163
-                if (
164
-                    (
165
-                        // event subtotals
166
-                        $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1
167
-                    )
168
-                    || (
169
-                        // pre-tax subtotals
170
-                        $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1
171
-                    )
172
-                ) {
173
-                    $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total;
174
-                    $html .= $this->_sub_total_row($line_item, $text, $options);
175
-                }
176
-                break;
177
-            case EEM_Line_Item::type_tax:
178
-                if ($this->_show_taxes) {
179
-                    $this->_taxes_html .= $this->_tax_row($line_item, $options);
180
-                }
181
-                break;
182
-            case EEM_Line_Item::type_tax_sub_total:
183
-                if ($this->_show_taxes) {
184
-                    $child_line_items = $line_item->children();
185
-                    // loop thru children
186
-                    foreach ($child_line_items as $child_line_item) {
187
-                        // recursively feed children back into this method
188
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
189
-                    }
190
-                    if (count($child_line_items) > 1) {
191
-                        $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso'));
192
-                    }
193
-                }
194
-                break;
195
-            case EEM_Line_Item::type_total:
196
-                // get all child line items
197
-                $children = $line_item->children();
198
-                // loop thru all non-tax child line items
199
-                foreach ($children as $child_line_item) {
200
-                    if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) {
201
-                        // recursively feed children back into this method
202
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
203
-                    }
204
-                }
205
-                // now loop thru  tax child line items
206
-                foreach ($children as $child_line_item) {
207
-                    if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) {
208
-                        // recursively feed children back into this method
209
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
210
-                    }
211
-                }
212
-                $html .= $this->_taxes_html;
213
-                $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso'));
214
-                $html .= $this->_payments_and_amount_owing_rows($line_item, $options);
215
-                break;
216
-        }
217
-        return $html;
218
-    }
219
-
220
-
221
-
222
-    /**
223
-     * _event_row - basically a Heading row displayed once above each event's ticket rows
224
-     *
225
-     * @param EE_Line_Item $line_item
226
-     * @return mixed
227
-     */
228
-    private function _event_row(EE_Line_Item $line_item)
229
-    {
230
-        // start of row
231
-        $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd');
232
-        // event name td
233
-        $html .= EEH_HTML::td(
234
-            EEH_HTML::strong($line_item->name()),
235
-            '',
236
-            'event-header',
237
-            '',
238
-            ' colspan="4"'
239
-        );
240
-        // end of row
241
-        $html .= EEH_HTML::trx();
242
-        return $html;
243
-    }
244
-
245
-
246
-
247
-    /**
248
-     * _ticket_row
249
-     *
250
-     * @param EE_Line_Item $line_item
251
-     * @param array        $options
252
-     * @return mixed
253
-     * @throws EE_Error
254
-     */
255
-    private function _ticket_row(EE_Line_Item $line_item, $options = array())
256
-    {
257
-        // start of row
258
-        $row_class = $options['odd'] ? 'item odd' : 'item';
259
-        $html = EEH_HTML::tr('', '', $row_class);
260
-        // name && desc
261
-        $name_and_desc = apply_filters(
262
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
263
-            $line_item->name(),
264
-            $line_item
265
-        );
266
-        $name_and_desc .= apply_filters(
267
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
268
-            (
269
-                $options['show_desc']
270
-                    ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
271
-                    : ''
272
-            ),
273
-            $line_item,
274
-            $options
275
-        );
276
-        $name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
277
-        // name td
278
-        $html .= EEH_HTML::td( /*__FUNCTION__ .*/
279
-            $name_and_desc, '', 'item_l');
280
-        // price td
281
-        $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
282
-        // quantity td
283
-        $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
284
-        $this->_total_items += $line_item->quantity();
285
-        // determine total for line item
286
-        $total = $line_item->total();
287
-        $this->_events[$options['event_id']] += $total;
288
-        // total td
289
-        $html .= EEH_HTML::td(
290
-            EEH_Template::format_currency($total, false, false),
291
-            '',
292
-            'item_r jst-rght'
293
-        );
294
-        // end of row
295
-        $html .= EEH_HTML::trx();
296
-        return $html;
297
-    }
298
-
299
-
300
-
301
-    /**
302
-     * _item_row
303
-     *
304
-     * @param EE_Line_Item $line_item
305
-     * @param array        $options
306
-     * @return mixed
307
-     * @throws EE_Error
308
-     */
309
-    private function _item_row(EE_Line_Item $line_item, $options = array())
310
-    {
311
-        // start of row
312
-        $row_class = $options['odd'] ? 'item odd' : 'item';
313
-        $html = EEH_HTML::tr('', '', $row_class);
314
-        $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : '';
315
-        // name && desc
316
-        $name_and_desc = apply_filters(
317
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
318
-            $obj_name . $line_item->name(),
319
-            $line_item
320
-        );
321
-        $name_and_desc .= apply_filters(
322
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
323
-            (
324
-                $options['show_desc']
325
-                ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
326
-                : ''
327
-            ),
328
-            $line_item,
329
-            $options
330
-        );
331
-        $name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
332
-        // name td
333
-        $html .= EEH_HTML::td($name_and_desc, '', 'item_l');
334
-        // price td
335
-        if ($line_item->is_percent()) {
336
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght');
337
-        } else {
338
-            $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
339
-        }
340
-        // quantity td
341
-        $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
342
-        //$total = $line_item->total() * $line_item->quantity();
343
-        $total = $line_item->total();
344
-        if (isset($options['event_id'], $this->_events[$options['event_id']])) {
345
-            $this->_events[$options['event_id']] += $total;
346
-        }
347
-        // total td
348
-        $html .= EEH_HTML::td(
349
-            EEH_Template::format_currency($total, false, false),
350
-            '',
351
-            'item_r jst-rght'
352
-        );
353
-        // end of row
354
-        $html .= EEH_HTML::trx();
355
-        return $html;
356
-    }
357
-
358
-
359
-
360
-    /**
361
-     * _sub_item_row
362
-     *
363
-     * @param EE_Line_Item $line_item
364
-     * @param array        $options
365
-     * @param EE_Line_Item $parent_line_item
366
-     * @return mixed
367
-     * @throws EE_Error
368
-     */
369
-    private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null)
370
-    {
371
-        // start of row
372
-        $html = EEH_HTML::tr('', '', 'item sub-item-row');
373
-        // name && desc
374
-        $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right')
375
-                         . $line_item->name();
376
-        $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '
377
-                                                  . $line_item->desc()
378
-                                                  . '</span>' : '';
379
-        // name td
380
-        $html .= EEH_HTML::td( $name_and_desc, '', 'item_l sub-item');
381
-        $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1;
382
-        // discount/surcharge td
383
-        if ($line_item->is_percent()) {
384
-            $html .= EEH_HTML::td(
385
-                EEH_Template::format_currency(
386
-                    $line_item->total() / $qty,
387
-                    false, false
388
-                ),
389
-                '', 'item_c jst-rght'
390
-            );
391
-        } else {
392
-            $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
393
-        }
394
-        // no quantity td
395
-        $html .= EEH_HTML::td();
396
-        // no total td
397
-        $html .= EEH_HTML::td();
398
-        // end of row
399
-        $html .= EEH_HTML::trx();
400
-        return $html;
401
-    }
402
-
403
-
404
-
405
-    /**
406
-     * _tax_row
407
-     *
408
-     * @param EE_Line_Item $line_item
409
-     * @param array        $options
410
-     * @return mixed
411
-     * @throws EE_Error
412
-     */
413
-    private function _tax_row(EE_Line_Item $line_item, $options = array())
414
-    {
415
-        // start of row
416
-        $html = EEH_HTML::tr('', 'item sub-item tax-total');
417
-        // name && desc
418
-        $name_and_desc = $line_item->name();
419
-        $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
420
-                          . esc_html__(' * taxable items', 'event_espresso') . '</span>';
421
-        $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : '';
422
-        // name td
423
-        $html .= EEH_HTML::td( /*__FUNCTION__ .*/
424
-            $name_and_desc, '', 'item_l sub-item');
425
-        // percent td
426
-        $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', '');
427
-        // empty td (price)
428
-        $html .= EEH_HTML::td(EEH_HTML::nbsp());
429
-        // total td
430
-        $html .= EEH_HTML::td(EEH_Template::format_currency(
431
-            $line_item->total(), false, false),
432
-            '',
433
-            'item_r jst-rght'
434
-        );
435
-        // end of row
436
-        $html .= EEH_HTML::trx();
437
-        return $html;
438
-    }
439
-
440
-
441
-
442
-    /**
443
-     * _total_row
444
-     *
445
-     * @param EE_Line_Item $line_item
446
-     * @param string       $text
447
-     * @return mixed
448
-     * @throws EE_Error
449
-     */
450
-    private function _total_tax_row(EE_Line_Item $line_item, $text = '')
451
-    {
452
-        $html = '';
453
-        if ($line_item->total()) {
454
-            // start of row
455
-            $html = EEH_HTML::tr('', '', 'total_tr odd');
456
-            // total td
457
-            $html .= EEH_HTML::td(
458
-                $text,
459
-                '',
460
-                'total_currency total jst-rght',
461
-                '',
462
-                ' colspan="2"'
463
-            );
464
-            // empty td (price)
465
-            $html .= EEH_HTML::td(EEH_HTML::nbsp());
466
-            // total td
467
-            $html .= EEH_HTML::td(
468
-                EEH_Template::format_currency($line_item->total(), false, false),
469
-                '',
470
-                'total jst-rght'
471
-            );
472
-            // end of row
473
-            $html .= EEH_HTML::trx();
474
-        }
475
-        return $html;
476
-    }
477
-
478
-
479
-
480
-    /**
481
-     * _total_row
482
-     *
483
-     * @param EE_Line_Item $line_item
484
-     * @param string       $text
485
-     * @param array        $options
486
-     * @return mixed
487
-     * @throws EE_Error
488
-     */
489
-    private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array())
490
-    {
491
-        $html = '';
492
-        if ($line_item->total()) {
493
-            // start of row
494
-            $html = EEH_HTML::tr('', '', 'total_tr odd');
495
-            // total td
496
-            $html .= EEH_HTML::td(
497
-                $text,
498
-                '',
499
-                'total_currency total jst-rght',
500
-                '',
501
-                ' colspan="3"'
502
-            );
503
-            // total td
504
-            $html .= EEH_HTML::td(
505
-                EEH_Template::format_currency($options['sub_total'], false, false),
506
-                '',
507
-                'total jst-rght'
508
-            );
509
-            // end of row
510
-            $html .= EEH_HTML::trx();
511
-        }
512
-        return $html;
513
-    }
514
-
515
-
516
-
517
-    /**
518
-     * _total_row
519
-     *
520
-     * @param EE_Line_Item $line_item
521
-     * @param string       $text
522
-     * @return mixed
523
-     * @throws EE_Error
524
-     */
525
-    private function _total_row(EE_Line_Item $line_item, $text = '')
526
-    {
527
-        // start of row
528
-        $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd');
529
-        // total td
530
-        $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
531
-        // total td
532
-        $html .= EEH_HTML::td(
533
-            EEH_Template::format_currency($line_item->total(), false, false),
534
-            '',
535
-            'total jst-rght'
536
-        );
537
-        // end of row
538
-        $html .= EEH_HTML::trx();
539
-        return $html;
540
-    }
541
-
542
-
543
-
544
-    /**
545
-     * _payments_and_amount_owing_rows
546
-     *
547
-     * @param EE_Line_Item $line_item
548
-     * @param array        $options
549
-     * @return mixed
550
-     * @throws EE_Error
551
-     */
552
-    private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array())
553
-    {
554
-        $html = '';
555
-        $owing = $line_item->total();
556
-        $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID());
557
-        if ($transaction instanceof EE_Transaction) {
558
-            $registration_payments = array();
559
-            $registrations = ! empty($options['registrations'])
560
-                ? $options['registrations']
561
-                : $transaction->registrations();
562
-            foreach ($registrations as $registration) {
563
-                if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
564
-                    $registration_payments += $registration->registration_payments();
565
-                }
566
-            }
567
-            if (! empty($registration_payments)) {
568
-                foreach ($registration_payments as $registration_payment) {
569
-                    if ($registration_payment instanceof EE_Registration_Payment) {
570
-                        $owing -= $registration_payment->amount();
571
-                        $payment = $registration_payment->payment();
572
-                        $payment_desc = '';
573
-                        if ($payment instanceof EE_Payment) {
574
-                            $payment_desc = sprintf(
575
-                                esc_html__('Payment%1$s Received: %2$s', 'event_espresso'),
576
-                                $payment->txn_id_chq_nmbr() !== ''
577
-                                    ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
578
-                                    : '',
579
-                                $payment->timestamp()
580
-                            );
581
-                        }
582
-                        // start of row
583
-                        $html .= EEH_HTML::tr('', '', 'total_tr odd');
584
-                        // payment desc
585
-                        $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"');
586
-                        // total td
587
-                        $html .= EEH_HTML::td(
588
-                            EEH_Template::format_currency(
589
-                                $registration_payment->amount(),
590
-                                false,
591
-                                false
592
-                            ),
593
-                            '',
594
-                            'total jst-rght'
595
-                        );
596
-                        // end of row
597
-                        $html .= EEH_HTML::trx();
598
-                    }
599
-                }
600
-                if ($line_item->total()) {
601
-                    // start of row
602
-                    $html .= EEH_HTML::tr('', '', 'total_tr odd');
603
-                    // total td
604
-                    $html .= EEH_HTML::td(
605
-                        esc_html__('Amount Owing', 'event_espresso'),
606
-                        '', 'total_currency total jst-rght', '', ' colspan="3"'
607
-                    );
608
-                    // total td
609
-                    $html .= EEH_HTML::td(
610
-                        EEH_Template::format_currency($owing, false, false),
611
-                        '',
612
-                        'total jst-rght'
613
-                    );
614
-                    // end of row
615
-                    $html .= EEH_HTML::trx();
616
-                }
617
-            }
618
-        }
619
-        $this->_grand_total = $owing;
620
-        return $html;
621
-    }
19
+	/**
20
+	 * array of events
21
+	 *
22
+	 * @type EE_Line_Item[] $_events
23
+	 */
24
+	private $_events = array();
25
+
26
+	/**
27
+	 * whether to display the taxes row or not
28
+	 *
29
+	 * @type bool $_show_taxes
30
+	 */
31
+	private $_show_taxes = false;
32
+
33
+	/**
34
+	 * html for any tax rows
35
+	 *
36
+	 * @type string $_show_taxes
37
+	 */
38
+	private $_taxes_html = '';
39
+
40
+	/**
41
+	 * total amount including tax we can bill for at this time
42
+	 *
43
+	 * @type float $_grand_total
44
+	 */
45
+	private $_grand_total = 0.00;
46
+
47
+	/**
48
+	 * total number of items being billed for
49
+	 *
50
+	 * @type int $_total_items
51
+	 */
52
+	private $_total_items = 0;
53
+
54
+
55
+
56
+	/**
57
+	 * @return float
58
+	 */
59
+	public function grand_total()
60
+	{
61
+		return $this->_grand_total;
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * @return int
68
+	 */
69
+	public function total_items()
70
+	{
71
+		return $this->_total_items;
72
+	}
73
+
74
+
75
+
76
+	/**
77
+	 * @param EE_Line_Item $line_item
78
+	 * @param array        $options
79
+	 * @param EE_Line_Item $parent_line_item
80
+	 * @return mixed
81
+	 * @throws EE_Error
82
+	 */
83
+	public function display_line_item(
84
+		EE_Line_Item $line_item,
85
+		$options = array(),
86
+		EE_Line_Item $parent_line_item = null
87
+	) {
88
+		$html = '';
89
+		// set some default options and merge with incoming
90
+		$default_options = array(
91
+			'show_desc' => true,  // 	true 		false
92
+			'odd'       => false,
93
+		);
94
+		$options = array_merge($default_options, (array)$options);
95
+		switch ($line_item->type()) {
96
+			case EEM_Line_Item::type_line_item:
97
+				$this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes;
98
+				if ($line_item->OBJ_type() === 'Ticket') {
99
+					// item row
100
+					$html .= $this->_ticket_row($line_item, $options);
101
+				} else {
102
+					// item row
103
+					$html .= $this->_item_row($line_item, $options);
104
+				}
105
+				if (
106
+				apply_filters(
107
+					'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items',
108
+					true
109
+				)
110
+				) {
111
+					// got any kids?
112
+					foreach ($line_item->children() as $child_line_item) {
113
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
114
+					}
115
+				}
116
+				break;
117
+			case EEM_Line_Item::type_sub_line_item:
118
+				$html .= $this->_sub_item_row($line_item, $options, $parent_line_item);
119
+				break;
120
+			case EEM_Line_Item::type_sub_total:
121
+				static $sub_total = 0;
122
+				$event_sub_total = 0;
123
+				$text = esc_html__('Sub-Total', 'event_espresso');
124
+				if ($line_item->OBJ_type() === 'Event') {
125
+					$options['event_id'] = $event_id = $line_item->OBJ_ID();
126
+					if (! isset($this->_events[$options['event_id']])) {
127
+						$event = EEM_Event::instance()->get_one_by_ID($options['event_id']);
128
+						// if event has default reg status of Not Approved, then don't display info on it
129
+						if (
130
+							$event instanceof EE_Event
131
+							&& $event->default_registration_status() === EEM_Registration::status_id_not_approved
132
+						) {
133
+							$display_event = false;
134
+							// unless there are registrations for it that are returning to pay
135
+							if (isset($options['registrations']) && is_array($options['registrations'])) {
136
+								foreach ($options['registrations'] as $registration) {
137
+									if (! $registration instanceof EE_Registration) {
138
+										continue;
139
+									}
140
+									$display_event = $registration->event_ID() === $options['event_id']
141
+													 && $registration->status_ID() !== EEM_Registration::status_id_not_approved
142
+										? true
143
+										: $display_event;
144
+								}
145
+							}
146
+							if (! $display_event) {
147
+								return '';
148
+							}
149
+						}
150
+						$this->_events[$options['event_id']] = 0;
151
+						$html .= $this->_event_row($line_item);
152
+						$text = esc_html__('Event Sub-Total', 'event_espresso');
153
+					}
154
+				}
155
+				$child_line_items = $line_item->children();
156
+				// loop thru children
157
+				foreach ($child_line_items as $child_line_item) {
158
+					// recursively feed children back into this method
159
+					$html .= $this->display_line_item($child_line_item, $options, $line_item);
160
+				}
161
+				$event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0;
162
+				$sub_total += $event_sub_total;
163
+				if (
164
+					(
165
+						// event subtotals
166
+						$line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1
167
+					)
168
+					|| (
169
+						// pre-tax subtotals
170
+						$line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1
171
+					)
172
+				) {
173
+					$options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total;
174
+					$html .= $this->_sub_total_row($line_item, $text, $options);
175
+				}
176
+				break;
177
+			case EEM_Line_Item::type_tax:
178
+				if ($this->_show_taxes) {
179
+					$this->_taxes_html .= $this->_tax_row($line_item, $options);
180
+				}
181
+				break;
182
+			case EEM_Line_Item::type_tax_sub_total:
183
+				if ($this->_show_taxes) {
184
+					$child_line_items = $line_item->children();
185
+					// loop thru children
186
+					foreach ($child_line_items as $child_line_item) {
187
+						// recursively feed children back into this method
188
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
189
+					}
190
+					if (count($child_line_items) > 1) {
191
+						$this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso'));
192
+					}
193
+				}
194
+				break;
195
+			case EEM_Line_Item::type_total:
196
+				// get all child line items
197
+				$children = $line_item->children();
198
+				// loop thru all non-tax child line items
199
+				foreach ($children as $child_line_item) {
200
+					if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) {
201
+						// recursively feed children back into this method
202
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
203
+					}
204
+				}
205
+				// now loop thru  tax child line items
206
+				foreach ($children as $child_line_item) {
207
+					if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) {
208
+						// recursively feed children back into this method
209
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
210
+					}
211
+				}
212
+				$html .= $this->_taxes_html;
213
+				$html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso'));
214
+				$html .= $this->_payments_and_amount_owing_rows($line_item, $options);
215
+				break;
216
+		}
217
+		return $html;
218
+	}
219
+
220
+
221
+
222
+	/**
223
+	 * _event_row - basically a Heading row displayed once above each event's ticket rows
224
+	 *
225
+	 * @param EE_Line_Item $line_item
226
+	 * @return mixed
227
+	 */
228
+	private function _event_row(EE_Line_Item $line_item)
229
+	{
230
+		// start of row
231
+		$html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd');
232
+		// event name td
233
+		$html .= EEH_HTML::td(
234
+			EEH_HTML::strong($line_item->name()),
235
+			'',
236
+			'event-header',
237
+			'',
238
+			' colspan="4"'
239
+		);
240
+		// end of row
241
+		$html .= EEH_HTML::trx();
242
+		return $html;
243
+	}
244
+
245
+
246
+
247
+	/**
248
+	 * _ticket_row
249
+	 *
250
+	 * @param EE_Line_Item $line_item
251
+	 * @param array        $options
252
+	 * @return mixed
253
+	 * @throws EE_Error
254
+	 */
255
+	private function _ticket_row(EE_Line_Item $line_item, $options = array())
256
+	{
257
+		// start of row
258
+		$row_class = $options['odd'] ? 'item odd' : 'item';
259
+		$html = EEH_HTML::tr('', '', $row_class);
260
+		// name && desc
261
+		$name_and_desc = apply_filters(
262
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
263
+			$line_item->name(),
264
+			$line_item
265
+		);
266
+		$name_and_desc .= apply_filters(
267
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
268
+			(
269
+				$options['show_desc']
270
+					? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
271
+					: ''
272
+			),
273
+			$line_item,
274
+			$options
275
+		);
276
+		$name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
277
+		// name td
278
+		$html .= EEH_HTML::td( /*__FUNCTION__ .*/
279
+			$name_and_desc, '', 'item_l');
280
+		// price td
281
+		$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
282
+		// quantity td
283
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
284
+		$this->_total_items += $line_item->quantity();
285
+		// determine total for line item
286
+		$total = $line_item->total();
287
+		$this->_events[$options['event_id']] += $total;
288
+		// total td
289
+		$html .= EEH_HTML::td(
290
+			EEH_Template::format_currency($total, false, false),
291
+			'',
292
+			'item_r jst-rght'
293
+		);
294
+		// end of row
295
+		$html .= EEH_HTML::trx();
296
+		return $html;
297
+	}
298
+
299
+
300
+
301
+	/**
302
+	 * _item_row
303
+	 *
304
+	 * @param EE_Line_Item $line_item
305
+	 * @param array        $options
306
+	 * @return mixed
307
+	 * @throws EE_Error
308
+	 */
309
+	private function _item_row(EE_Line_Item $line_item, $options = array())
310
+	{
311
+		// start of row
312
+		$row_class = $options['odd'] ? 'item odd' : 'item';
313
+		$html = EEH_HTML::tr('', '', $row_class);
314
+		$obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : '';
315
+		// name && desc
316
+		$name_and_desc = apply_filters(
317
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
318
+			$obj_name . $line_item->name(),
319
+			$line_item
320
+		);
321
+		$name_and_desc .= apply_filters(
322
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
323
+			(
324
+				$options['show_desc']
325
+				? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
326
+				: ''
327
+			),
328
+			$line_item,
329
+			$options
330
+		);
331
+		$name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
332
+		// name td
333
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l');
334
+		// price td
335
+		if ($line_item->is_percent()) {
336
+			$html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght');
337
+		} else {
338
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
339
+		}
340
+		// quantity td
341
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
342
+		//$total = $line_item->total() * $line_item->quantity();
343
+		$total = $line_item->total();
344
+		if (isset($options['event_id'], $this->_events[$options['event_id']])) {
345
+			$this->_events[$options['event_id']] += $total;
346
+		}
347
+		// total td
348
+		$html .= EEH_HTML::td(
349
+			EEH_Template::format_currency($total, false, false),
350
+			'',
351
+			'item_r jst-rght'
352
+		);
353
+		// end of row
354
+		$html .= EEH_HTML::trx();
355
+		return $html;
356
+	}
357
+
358
+
359
+
360
+	/**
361
+	 * _sub_item_row
362
+	 *
363
+	 * @param EE_Line_Item $line_item
364
+	 * @param array        $options
365
+	 * @param EE_Line_Item $parent_line_item
366
+	 * @return mixed
367
+	 * @throws EE_Error
368
+	 */
369
+	private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null)
370
+	{
371
+		// start of row
372
+		$html = EEH_HTML::tr('', '', 'item sub-item-row');
373
+		// name && desc
374
+		$name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right')
375
+						 . $line_item->name();
376
+		$name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '
377
+												  . $line_item->desc()
378
+												  . '</span>' : '';
379
+		// name td
380
+		$html .= EEH_HTML::td( $name_and_desc, '', 'item_l sub-item');
381
+		$qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1;
382
+		// discount/surcharge td
383
+		if ($line_item->is_percent()) {
384
+			$html .= EEH_HTML::td(
385
+				EEH_Template::format_currency(
386
+					$line_item->total() / $qty,
387
+					false, false
388
+				),
389
+				'', 'item_c jst-rght'
390
+			);
391
+		} else {
392
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
393
+		}
394
+		// no quantity td
395
+		$html .= EEH_HTML::td();
396
+		// no total td
397
+		$html .= EEH_HTML::td();
398
+		// end of row
399
+		$html .= EEH_HTML::trx();
400
+		return $html;
401
+	}
402
+
403
+
404
+
405
+	/**
406
+	 * _tax_row
407
+	 *
408
+	 * @param EE_Line_Item $line_item
409
+	 * @param array        $options
410
+	 * @return mixed
411
+	 * @throws EE_Error
412
+	 */
413
+	private function _tax_row(EE_Line_Item $line_item, $options = array())
414
+	{
415
+		// start of row
416
+		$html = EEH_HTML::tr('', 'item sub-item tax-total');
417
+		// name && desc
418
+		$name_and_desc = $line_item->name();
419
+		$name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
420
+						  . esc_html__(' * taxable items', 'event_espresso') . '</span>';
421
+		$name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : '';
422
+		// name td
423
+		$html .= EEH_HTML::td( /*__FUNCTION__ .*/
424
+			$name_and_desc, '', 'item_l sub-item');
425
+		// percent td
426
+		$html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', '');
427
+		// empty td (price)
428
+		$html .= EEH_HTML::td(EEH_HTML::nbsp());
429
+		// total td
430
+		$html .= EEH_HTML::td(EEH_Template::format_currency(
431
+			$line_item->total(), false, false),
432
+			'',
433
+			'item_r jst-rght'
434
+		);
435
+		// end of row
436
+		$html .= EEH_HTML::trx();
437
+		return $html;
438
+	}
439
+
440
+
441
+
442
+	/**
443
+	 * _total_row
444
+	 *
445
+	 * @param EE_Line_Item $line_item
446
+	 * @param string       $text
447
+	 * @return mixed
448
+	 * @throws EE_Error
449
+	 */
450
+	private function _total_tax_row(EE_Line_Item $line_item, $text = '')
451
+	{
452
+		$html = '';
453
+		if ($line_item->total()) {
454
+			// start of row
455
+			$html = EEH_HTML::tr('', '', 'total_tr odd');
456
+			// total td
457
+			$html .= EEH_HTML::td(
458
+				$text,
459
+				'',
460
+				'total_currency total jst-rght',
461
+				'',
462
+				' colspan="2"'
463
+			);
464
+			// empty td (price)
465
+			$html .= EEH_HTML::td(EEH_HTML::nbsp());
466
+			// total td
467
+			$html .= EEH_HTML::td(
468
+				EEH_Template::format_currency($line_item->total(), false, false),
469
+				'',
470
+				'total jst-rght'
471
+			);
472
+			// end of row
473
+			$html .= EEH_HTML::trx();
474
+		}
475
+		return $html;
476
+	}
477
+
478
+
479
+
480
+	/**
481
+	 * _total_row
482
+	 *
483
+	 * @param EE_Line_Item $line_item
484
+	 * @param string       $text
485
+	 * @param array        $options
486
+	 * @return mixed
487
+	 * @throws EE_Error
488
+	 */
489
+	private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array())
490
+	{
491
+		$html = '';
492
+		if ($line_item->total()) {
493
+			// start of row
494
+			$html = EEH_HTML::tr('', '', 'total_tr odd');
495
+			// total td
496
+			$html .= EEH_HTML::td(
497
+				$text,
498
+				'',
499
+				'total_currency total jst-rght',
500
+				'',
501
+				' colspan="3"'
502
+			);
503
+			// total td
504
+			$html .= EEH_HTML::td(
505
+				EEH_Template::format_currency($options['sub_total'], false, false),
506
+				'',
507
+				'total jst-rght'
508
+			);
509
+			// end of row
510
+			$html .= EEH_HTML::trx();
511
+		}
512
+		return $html;
513
+	}
514
+
515
+
516
+
517
+	/**
518
+	 * _total_row
519
+	 *
520
+	 * @param EE_Line_Item $line_item
521
+	 * @param string       $text
522
+	 * @return mixed
523
+	 * @throws EE_Error
524
+	 */
525
+	private function _total_row(EE_Line_Item $line_item, $text = '')
526
+	{
527
+		// start of row
528
+		$html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd');
529
+		// total td
530
+		$html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
531
+		// total td
532
+		$html .= EEH_HTML::td(
533
+			EEH_Template::format_currency($line_item->total(), false, false),
534
+			'',
535
+			'total jst-rght'
536
+		);
537
+		// end of row
538
+		$html .= EEH_HTML::trx();
539
+		return $html;
540
+	}
541
+
542
+
543
+
544
+	/**
545
+	 * _payments_and_amount_owing_rows
546
+	 *
547
+	 * @param EE_Line_Item $line_item
548
+	 * @param array        $options
549
+	 * @return mixed
550
+	 * @throws EE_Error
551
+	 */
552
+	private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array())
553
+	{
554
+		$html = '';
555
+		$owing = $line_item->total();
556
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID());
557
+		if ($transaction instanceof EE_Transaction) {
558
+			$registration_payments = array();
559
+			$registrations = ! empty($options['registrations'])
560
+				? $options['registrations']
561
+				: $transaction->registrations();
562
+			foreach ($registrations as $registration) {
563
+				if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
564
+					$registration_payments += $registration->registration_payments();
565
+				}
566
+			}
567
+			if (! empty($registration_payments)) {
568
+				foreach ($registration_payments as $registration_payment) {
569
+					if ($registration_payment instanceof EE_Registration_Payment) {
570
+						$owing -= $registration_payment->amount();
571
+						$payment = $registration_payment->payment();
572
+						$payment_desc = '';
573
+						if ($payment instanceof EE_Payment) {
574
+							$payment_desc = sprintf(
575
+								esc_html__('Payment%1$s Received: %2$s', 'event_espresso'),
576
+								$payment->txn_id_chq_nmbr() !== ''
577
+									? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
578
+									: '',
579
+								$payment->timestamp()
580
+							);
581
+						}
582
+						// start of row
583
+						$html .= EEH_HTML::tr('', '', 'total_tr odd');
584
+						// payment desc
585
+						$html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"');
586
+						// total td
587
+						$html .= EEH_HTML::td(
588
+							EEH_Template::format_currency(
589
+								$registration_payment->amount(),
590
+								false,
591
+								false
592
+							),
593
+							'',
594
+							'total jst-rght'
595
+						);
596
+						// end of row
597
+						$html .= EEH_HTML::trx();
598
+					}
599
+				}
600
+				if ($line_item->total()) {
601
+					// start of row
602
+					$html .= EEH_HTML::tr('', '', 'total_tr odd');
603
+					// total td
604
+					$html .= EEH_HTML::td(
605
+						esc_html__('Amount Owing', 'event_espresso'),
606
+						'', 'total_currency total jst-rght', '', ' colspan="3"'
607
+					);
608
+					// total td
609
+					$html .= EEH_HTML::td(
610
+						EEH_Template::format_currency($owing, false, false),
611
+						'',
612
+						'total jst-rght'
613
+					);
614
+					// end of row
615
+					$html .= EEH_HTML::trx();
616
+				}
617
+			}
618
+		}
619
+		$this->_grand_total = $owing;
620
+		return $html;
621
+	}
622 622
 
623 623
 
624 624
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
         $html = '';
89 89
         // set some default options and merge with incoming
90 90
         $default_options = array(
91
-            'show_desc' => true,  // 	true 		false
91
+            'show_desc' => true, // 	true 		false
92 92
             'odd'       => false,
93 93
         );
94
-        $options = array_merge($default_options, (array)$options);
94
+        $options = array_merge($default_options, (array) $options);
95 95
         switch ($line_item->type()) {
96 96
             case EEM_Line_Item::type_line_item:
97 97
                 $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
                 $text = esc_html__('Sub-Total', 'event_espresso');
124 124
                 if ($line_item->OBJ_type() === 'Event') {
125 125
                     $options['event_id'] = $event_id = $line_item->OBJ_ID();
126
-                    if (! isset($this->_events[$options['event_id']])) {
126
+                    if ( ! isset($this->_events[$options['event_id']])) {
127 127
                         $event = EEM_Event::instance()->get_one_by_ID($options['event_id']);
128 128
                         // if event has default reg status of Not Approved, then don't display info on it
129 129
                         if (
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                             // unless there are registrations for it that are returning to pay
135 135
                             if (isset($options['registrations']) && is_array($options['registrations'])) {
136 136
                                 foreach ($options['registrations'] as $registration) {
137
-                                    if (! $registration instanceof EE_Registration) {
137
+                                    if ( ! $registration instanceof EE_Registration) {
138 138
                                         continue;
139 139
                                     }
140 140
                                     $display_event = $registration->event_ID() === $options['event_id']
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                                         : $display_event;
144 144
                                 }
145 145
                             }
146
-                            if (! $display_event) {
146
+                            if ( ! $display_event) {
147 147
                                 return '';
148 148
                             }
149 149
                         }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
             'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
268 268
             (
269 269
                 $options['show_desc']
270
-                    ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
270
+                    ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>'
271 271
                     : ''
272 272
             ),
273 273
             $line_item,
@@ -311,18 +311,18 @@  discard block
 block discarded – undo
311 311
         // start of row
312 312
         $row_class = $options['odd'] ? 'item odd' : 'item';
313 313
         $html = EEH_HTML::tr('', '', $row_class);
314
-        $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : '';
314
+        $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().': ' : '';
315 315
         // name && desc
316 316
         $name_and_desc = apply_filters(
317 317
             'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
318
-            $obj_name . $line_item->name(),
318
+            $obj_name.$line_item->name(),
319 319
             $line_item
320 320
         );
321 321
         $name_and_desc .= apply_filters(
322 322
             'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
323 323
             (
324 324
                 $options['show_desc']
325
-                ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
325
+                ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>'
326 326
                 : ''
327 327
             ),
328 328
             $line_item,
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
         $html .= EEH_HTML::td($name_and_desc, '', 'item_l');
334 334
         // price td
335 335
         if ($line_item->is_percent()) {
336
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght');
336
+            $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght');
337 337
         } else {
338 338
             $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
339 339
         }
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
                                                   . $line_item->desc()
378 378
                                                   . '</span>' : '';
379 379
         // name td
380
-        $html .= EEH_HTML::td( $name_and_desc, '', 'item_l sub-item');
380
+        $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item');
381 381
         $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1;
382 382
         // discount/surcharge td
383 383
         if ($line_item->is_percent()) {
@@ -417,13 +417,13 @@  discard block
 block discarded – undo
417 417
         // name && desc
418 418
         $name_and_desc = $line_item->name();
419 419
         $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
420
-                          . esc_html__(' * taxable items', 'event_espresso') . '</span>';
421
-        $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : '';
420
+                          . esc_html__(' * taxable items', 'event_espresso').'</span>';
421
+        $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : '';
422 422
         // name td
423 423
         $html .= EEH_HTML::td( /*__FUNCTION__ .*/
424 424
             $name_and_desc, '', 'item_l sub-item');
425 425
         // percent td
426
-        $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', '');
426
+        $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', '');
427 427
         // empty td (price)
428 428
         $html .= EEH_HTML::td(EEH_HTML::nbsp());
429 429
         // total td
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
                     $registration_payments += $registration->registration_payments();
565 565
                 }
566 566
             }
567
-            if (! empty($registration_payments)) {
567
+            if ( ! empty($registration_payments)) {
568 568
                 foreach ($registration_payments as $registration_payment) {
569 569
                     if ($registration_payment instanceof EE_Registration_Payment) {
570 570
                         $owing -= $registration_payment->amount();
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
                             $payment_desc = sprintf(
575 575
                                 esc_html__('Payment%1$s Received: %2$s', 'event_espresso'),
576 576
                                 $payment->txn_id_chq_nmbr() !== ''
577
-                                    ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
577
+                                    ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> '
578 578
                                     : '',
579 579
                                 $payment->timestamp()
580 580
                             );
Please login to merge, or discard this patch.
core/libraries/line_item_filters/EE_Non_Zero_Line_Item_Filter.class.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('No direct script access allowed');
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -19,102 +19,102 @@  discard block
 block discarded – undo
19 19
 class EE_Non_Zero_Line_Item_Filter extends EE_Line_Item_Filter_Base
20 20
 {
21 21
 
22
-    /**
23
-     * EE_Non_Zero_Line_Item_Filter constructor.
24
-     */
25
-    public function __construct()
26
-    {
27
-    }
28
-
29
-
30
-
31
-    /**
32
-     * Creates a duplicate of the line item tree, except only includes billable items
33
-     * and the portion of line items attributed to billable things
34
-     *
35
-     * @param EEI_Line_Item $line_item
36
-     * @return EEI_Line_Item
37
-     */
38
-    public function process(EEI_Line_Item $line_item)
39
-    {
40
-        $non_zero_line_item = $this->_filter_zero_line_item($line_item);
41
-        if (! $non_zero_line_item instanceof EEI_Line_Item) {
42
-            return null;
43
-        }
44
-        //if this is an event subtotal, we want to only include it if it
45
-        //has a non-zero total and at least one ticket line item child
46
-        if ($line_item->children()) {
47
-            $ticket_or_subtotals_with_tkt_children_count = 0;
48
-            foreach ($line_item->children() as $child_line_item) {
49
-                $code = $child_line_item->code();
50
-                $child_line_item = $this->process($child_line_item);
51
-                if (! $child_line_item instanceof EEI_Line_Item) {
52
-                    $line_item->delete_child_line_item($code);
53
-                    continue;
54
-                }
55
-                if (
56
-                    (
57
-                        $child_line_item instanceof EEI_Line_Item
58
-                        && $child_line_item->type() === EEM_Line_Item::type_sub_total
59
-                    )
60
-                    || (
61
-                        $child_line_item instanceof EEI_Line_Item
62
-                        && $child_line_item->type() === EEM_Line_Item::type_line_item
63
-                        && $child_line_item->OBJ_type() === 'Ticket'
64
-                    )
65
-                ) {
66
-                    $ticket_or_subtotals_with_tkt_children_count++;
67
-                }
68
-            }
69
-            // if this is an event subtotal with NO ticket children
70
-            // we basically want to ignore it
71
-            return $this->_filter_zero_subtotal_line_item($non_zero_line_item,
72
-                $ticket_or_subtotals_with_tkt_children_count);
73
-        }
74
-        return $non_zero_line_item;
75
-    }
76
-
77
-
78
-
79
-    /**
80
-     * Creates a new, unsaved line item, but if it's a ticket line item
81
-     * with a total of 0, or a subtotal of 0, returns null instead
82
-     *
83
-     * @param EEI_Line_Item $line_item
84
-     * @return EEI_Line_Item
85
-     */
86
-    protected function _filter_zero_line_item(EEI_Line_Item $line_item)
87
-    {
88
-        if (
89
-            $line_item->type() === EEM_Line_Item::type_line_item
90
-            && $line_item->OBJ_type() === 'Ticket'
91
-            && (int)$line_item->quantity() === 0
92
-        ) {
93
-            return null;
94
-        }
95
-        return $line_item;
96
-    }
97
-
98
-
99
-
100
-    /**
101
-     * Creates a new, unsaved line item, but if it's a ticket line item
102
-     * with a total of 0, or a subtotal of 0, returns null instead
103
-     *
104
-     * @param EEI_Line_Item $line_item
105
-     * @param int           $ticket_children
106
-     * @return EEI_Line_Item
107
-     */
108
-    protected function _filter_zero_subtotal_line_item(EEI_Line_Item $line_item, $ticket_children = 0)
109
-    {
110
-        if (
111
-            (int)$ticket_children === 0
112
-            && $line_item->type() === EEM_Line_Item::type_sub_total
113
-        ) {
114
-            return null;
115
-        }
116
-        return $line_item;
117
-    }
22
+	/**
23
+	 * EE_Non_Zero_Line_Item_Filter constructor.
24
+	 */
25
+	public function __construct()
26
+	{
27
+	}
28
+
29
+
30
+
31
+	/**
32
+	 * Creates a duplicate of the line item tree, except only includes billable items
33
+	 * and the portion of line items attributed to billable things
34
+	 *
35
+	 * @param EEI_Line_Item $line_item
36
+	 * @return EEI_Line_Item
37
+	 */
38
+	public function process(EEI_Line_Item $line_item)
39
+	{
40
+		$non_zero_line_item = $this->_filter_zero_line_item($line_item);
41
+		if (! $non_zero_line_item instanceof EEI_Line_Item) {
42
+			return null;
43
+		}
44
+		//if this is an event subtotal, we want to only include it if it
45
+		//has a non-zero total and at least one ticket line item child
46
+		if ($line_item->children()) {
47
+			$ticket_or_subtotals_with_tkt_children_count = 0;
48
+			foreach ($line_item->children() as $child_line_item) {
49
+				$code = $child_line_item->code();
50
+				$child_line_item = $this->process($child_line_item);
51
+				if (! $child_line_item instanceof EEI_Line_Item) {
52
+					$line_item->delete_child_line_item($code);
53
+					continue;
54
+				}
55
+				if (
56
+					(
57
+						$child_line_item instanceof EEI_Line_Item
58
+						&& $child_line_item->type() === EEM_Line_Item::type_sub_total
59
+					)
60
+					|| (
61
+						$child_line_item instanceof EEI_Line_Item
62
+						&& $child_line_item->type() === EEM_Line_Item::type_line_item
63
+						&& $child_line_item->OBJ_type() === 'Ticket'
64
+					)
65
+				) {
66
+					$ticket_or_subtotals_with_tkt_children_count++;
67
+				}
68
+			}
69
+			// if this is an event subtotal with NO ticket children
70
+			// we basically want to ignore it
71
+			return $this->_filter_zero_subtotal_line_item($non_zero_line_item,
72
+				$ticket_or_subtotals_with_tkt_children_count);
73
+		}
74
+		return $non_zero_line_item;
75
+	}
76
+
77
+
78
+
79
+	/**
80
+	 * Creates a new, unsaved line item, but if it's a ticket line item
81
+	 * with a total of 0, or a subtotal of 0, returns null instead
82
+	 *
83
+	 * @param EEI_Line_Item $line_item
84
+	 * @return EEI_Line_Item
85
+	 */
86
+	protected function _filter_zero_line_item(EEI_Line_Item $line_item)
87
+	{
88
+		if (
89
+			$line_item->type() === EEM_Line_Item::type_line_item
90
+			&& $line_item->OBJ_type() === 'Ticket'
91
+			&& (int)$line_item->quantity() === 0
92
+		) {
93
+			return null;
94
+		}
95
+		return $line_item;
96
+	}
97
+
98
+
99
+
100
+	/**
101
+	 * Creates a new, unsaved line item, but if it's a ticket line item
102
+	 * with a total of 0, or a subtotal of 0, returns null instead
103
+	 *
104
+	 * @param EEI_Line_Item $line_item
105
+	 * @param int           $ticket_children
106
+	 * @return EEI_Line_Item
107
+	 */
108
+	protected function _filter_zero_subtotal_line_item(EEI_Line_Item $line_item, $ticket_children = 0)
109
+	{
110
+		if (
111
+			(int)$ticket_children === 0
112
+			&& $line_item->type() === EEM_Line_Item::type_sub_total
113
+		) {
114
+			return null;
115
+		}
116
+		return $line_item;
117
+	}
118 118
 
119 119
 
120 120
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('No direct script access allowed');
4 4
 }
5 5
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     public function process(EEI_Line_Item $line_item)
39 39
     {
40 40
         $non_zero_line_item = $this->_filter_zero_line_item($line_item);
41
-        if (! $non_zero_line_item instanceof EEI_Line_Item) {
41
+        if ( ! $non_zero_line_item instanceof EEI_Line_Item) {
42 42
             return null;
43 43
         }
44 44
         //if this is an event subtotal, we want to only include it if it
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             foreach ($line_item->children() as $child_line_item) {
49 49
                 $code = $child_line_item->code();
50 50
                 $child_line_item = $this->process($child_line_item);
51
-                if (! $child_line_item instanceof EEI_Line_Item) {
51
+                if ( ! $child_line_item instanceof EEI_Line_Item) {
52 52
                     $line_item->delete_child_line_item($code);
53 53
                     continue;
54 54
                 }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         if (
89 89
             $line_item->type() === EEM_Line_Item::type_line_item
90 90
             && $line_item->OBJ_type() === 'Ticket'
91
-            && (int)$line_item->quantity() === 0
91
+            && (int) $line_item->quantity() === 0
92 92
         ) {
93 93
             return null;
94 94
         }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     protected function _filter_zero_subtotal_line_item(EEI_Line_Item $line_item, $ticket_children = 0)
109 109
     {
110 110
         if (
111
-            (int)$ticket_children === 0
111
+            (int) $ticket_children === 0
112 112
             && $line_item->type() === EEM_Line_Item::type_sub_total
113 113
         ) {
114 114
             return null;
Please login to merge, or discard this patch.