Completed
Branch FET-3467-waitlists (78124b)
by
unknown
141:27 queued 128:30
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.
core/libraries/form_sections/form_handlers/SequentialStepForm.php 2 patches
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use InvalidArgumentException;
9 9
 
10 10
 if (! defined('EVENT_ESPRESSO_VERSION')) {
11
-    exit('No direct script access allowed');
11
+	exit('No direct script access allowed');
12 12
 }
13 13
 
14 14
 
@@ -25,228 +25,228 @@  discard block
 block discarded – undo
25 25
 abstract class SequentialStepForm extends FormHandler implements SequentialStepFormInterface
26 26
 {
27 27
 
28
-    const REDIRECT_TO_NEXT_STEP    = 'redirect_to_next_step';
29
-
30
-    const REDIRECT_TO_CURRENT_STEP = 'redirect_to_current_step';
31
-
32
-    const REDIRECT_TO_PREV_STEP    = 'redirect_to_prev_step';
33
-
34
-    const REDIRECT_TO_OTHER        = 'redirect_to_other';
35
-
36
-    /**
37
-     * numerical value used for sorting form steps
38
-     *
39
-     * @var int $order
40
-     */
41
-    private $order = 1;
42
-
43
-    /**
44
-     * a final URL with all form related parameters added
45
-     * that will be used to advance to the next step
46
-     *
47
-     * @var string $redirect_url
48
-     */
49
-    private $redirect_url = '';
50
-
51
-    /**
52
-     * URL params in key value pairs
53
-     *
54
-     * @var array $redirect_args
55
-     */
56
-    private $redirect_args = array();
57
-
58
-    /**
59
-     * Which step should be redirected to after form processing.
60
-     * Usually after successfully processing this value would be REDIRECT_TO_NEXT_STEP
61
-     * If a form is invalid and requires errors to be corrected,
62
-     * then this value would be REDIRECT_TO_CURRENT_STEP so that form can be resubmitted
63
-     * Some form handlers do not have a form that is displayable,
64
-     * and only perform data processing, but if an error occurs,
65
-     * then this value needs to be set to REDIRECT_TO_PREV_STEP
66
-     * since the current step has no displayable content.
67
-     * if the form is completely finished, and needs to redirect to somewhere
68
-     * completely different, then this value will be REDIRECT_TO_OTHER
69
-     *
70
-     * @var string $redirect_to
71
-     */
72
-    private $redirect_to = SequentialStepForm::REDIRECT_TO_CURRENT_STEP;
73
-
74
-
75
-
76
-    /**
77
-     * SequentialStepForm constructor
78
-     *
79
-     * @param int         $order
80
-     * @param string      $form_name
81
-     * @param string      $admin_name
82
-     * @param string      $slug
83
-     * @param string      $form_action
84
-     * @param string      $form_config
85
-     * @param EE_Registry $registry
86
-     * @throws InvalidArgumentException
87
-     * @throws InvalidDataTypeException
88
-     * @throws DomainException
89
-     */
90
-    public function __construct(
91
-        $order,
92
-        $form_name,
93
-        $admin_name,
94
-        $slug,
95
-        $form_action = '',
96
-        $form_config = 'add_form_tags_and_submit',
97
-        EE_Registry $registry
98
-    ) {
99
-        $this->setOrder($order);
100
-        parent::__construct($form_name, $admin_name, $slug, $form_action, $form_config, $registry);
101
-    }
102
-
103
-
104
-
105
-    /**
106
-     * @return int
107
-     */
108
-    public function order()
109
-    {
110
-        return $this->order;
111
-    }
112
-
113
-
114
-
115
-    /**
116
-     * @param int $order
117
-     * @throws InvalidArgumentException
118
-     */
119
-    public function setOrder($order)
120
-    {
121
-        $order = absint($order);
122
-        if (! $order > 0) {
123
-            throw new InvalidArgumentException(
124
-                esc_html__('The form order property must be a positive integer.', 'event_espresso')
125
-            );
126
-        }
127
-        $this->order = $order;
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     * @return string
134
-     */
135
-    public function redirectUrl()
136
-    {
137
-        return ! empty($this->redirect_args)
138
-            ? add_query_arg($this->redirect_args, $this->redirect_url)
139
-            : $this->redirect_url;
140
-    }
141
-
142
-
143
-
144
-    /**
145
-     * @param string $redirect_url
146
-     * @throws InvalidDataTypeException
147
-     * @throws InvalidArgumentException
148
-     */
149
-    public function setRedirectUrl($redirect_url)
150
-    {
151
-        if (! is_string($redirect_url)) {
152
-            throw new InvalidDataTypeException('$redirect_url', $redirect_url, 'string');
153
-        }
154
-        if (empty($redirect_url)) {
155
-            throw new InvalidArgumentException(
156
-                esc_html__('The redirect URL can not be an empty string.', 'event_espresso')
157
-            );
158
-        }
159
-        $this->redirect_url = $redirect_url;
160
-    }
161
-
162
-
163
-
164
-    /**
165
-     * @param array $redirect_args
166
-     * @throws InvalidDataTypeException
167
-     * @throws InvalidArgumentException
168
-     */
169
-    public function addRedirectArgs($redirect_args = array())
170
-    {
171
-        if (is_object($redirect_args)) {
172
-            throw new InvalidDataTypeException(
173
-                '$redirect_args',
174
-                $redirect_args,
175
-                'anything other than an object was expected.'
176
-            );
177
-        }
178
-        if (empty($redirect_args)) {
179
-            throw new InvalidArgumentException(
180
-                esc_html__('The redirect argument can not be an empty array.', 'event_espresso')
181
-            );
182
-        }
183
-        $this->redirect_args = array_merge($this->redirect_args, (array)$redirect_args);
184
-    }
185
-
186
-
187
-
188
-    /**
189
-     * @param array $redirect_arg_keys_to_remove
190
-     * @throws InvalidDataTypeException
191
-     * @throws InvalidArgumentException
192
-     */
193
-    public function removeRedirectArgs($redirect_arg_keys_to_remove = array())
194
-    {
195
-        if (is_object($redirect_arg_keys_to_remove)) {
196
-            throw new InvalidDataTypeException(
197
-                '$redirect_arg_keys_to_remove',
198
-                $redirect_arg_keys_to_remove,
199
-                'anything other than an object was expected.'
200
-            );
201
-        }
202
-        if (empty($redirect_arg_keys_to_remove)) {
203
-            throw new InvalidArgumentException(
204
-                esc_html__('The $redirect_arg_keys_to_remove argument can not be an empty array.', 'event_espresso')
205
-            );
206
-        }
207
-        foreach ($redirect_arg_keys_to_remove as $redirect_arg_key) {
208
-            unset($this->redirect_args[$redirect_arg_key]);
209
-        }
210
-    }
211
-
212
-
213
-
214
-    /**
215
-     * @return string
216
-     */
217
-    public function redirectTo()
218
-    {
219
-        return $this->redirect_to;
220
-    }
221
-
222
-
223
-
224
-    /**
225
-     * @param string $redirect_to
226
-     * @throws InvalidDataTypeException
227
-     */
228
-    public function setRedirectTo($redirect_to)
229
-    {
230
-        if (
231
-            ! in_array(
232
-                $redirect_to,
233
-                array(
234
-                    SequentialStepForm::REDIRECT_TO_NEXT_STEP,
235
-                    SequentialStepForm::REDIRECT_TO_CURRENT_STEP,
236
-                    SequentialStepForm::REDIRECT_TO_PREV_STEP,
237
-                    SequentialStepForm::REDIRECT_TO_OTHER,
238
-                ),
239
-                true
240
-            )
241
-        ) {
242
-            throw new InvalidDataTypeException(
243
-                'setRedirectTo()',
244
-                $redirect_to,
245
-                'one of the SequentialStepForm class constants was expected.'
246
-            );
247
-        }
248
-        $this->redirect_to = $redirect_to;
249
-    }
28
+	const REDIRECT_TO_NEXT_STEP    = 'redirect_to_next_step';
29
+
30
+	const REDIRECT_TO_CURRENT_STEP = 'redirect_to_current_step';
31
+
32
+	const REDIRECT_TO_PREV_STEP    = 'redirect_to_prev_step';
33
+
34
+	const REDIRECT_TO_OTHER        = 'redirect_to_other';
35
+
36
+	/**
37
+	 * numerical value used for sorting form steps
38
+	 *
39
+	 * @var int $order
40
+	 */
41
+	private $order = 1;
42
+
43
+	/**
44
+	 * a final URL with all form related parameters added
45
+	 * that will be used to advance to the next step
46
+	 *
47
+	 * @var string $redirect_url
48
+	 */
49
+	private $redirect_url = '';
50
+
51
+	/**
52
+	 * URL params in key value pairs
53
+	 *
54
+	 * @var array $redirect_args
55
+	 */
56
+	private $redirect_args = array();
57
+
58
+	/**
59
+	 * Which step should be redirected to after form processing.
60
+	 * Usually after successfully processing this value would be REDIRECT_TO_NEXT_STEP
61
+	 * If a form is invalid and requires errors to be corrected,
62
+	 * then this value would be REDIRECT_TO_CURRENT_STEP so that form can be resubmitted
63
+	 * Some form handlers do not have a form that is displayable,
64
+	 * and only perform data processing, but if an error occurs,
65
+	 * then this value needs to be set to REDIRECT_TO_PREV_STEP
66
+	 * since the current step has no displayable content.
67
+	 * if the form is completely finished, and needs to redirect to somewhere
68
+	 * completely different, then this value will be REDIRECT_TO_OTHER
69
+	 *
70
+	 * @var string $redirect_to
71
+	 */
72
+	private $redirect_to = SequentialStepForm::REDIRECT_TO_CURRENT_STEP;
73
+
74
+
75
+
76
+	/**
77
+	 * SequentialStepForm constructor
78
+	 *
79
+	 * @param int         $order
80
+	 * @param string      $form_name
81
+	 * @param string      $admin_name
82
+	 * @param string      $slug
83
+	 * @param string      $form_action
84
+	 * @param string      $form_config
85
+	 * @param EE_Registry $registry
86
+	 * @throws InvalidArgumentException
87
+	 * @throws InvalidDataTypeException
88
+	 * @throws DomainException
89
+	 */
90
+	public function __construct(
91
+		$order,
92
+		$form_name,
93
+		$admin_name,
94
+		$slug,
95
+		$form_action = '',
96
+		$form_config = 'add_form_tags_and_submit',
97
+		EE_Registry $registry
98
+	) {
99
+		$this->setOrder($order);
100
+		parent::__construct($form_name, $admin_name, $slug, $form_action, $form_config, $registry);
101
+	}
102
+
103
+
104
+
105
+	/**
106
+	 * @return int
107
+	 */
108
+	public function order()
109
+	{
110
+		return $this->order;
111
+	}
112
+
113
+
114
+
115
+	/**
116
+	 * @param int $order
117
+	 * @throws InvalidArgumentException
118
+	 */
119
+	public function setOrder($order)
120
+	{
121
+		$order = absint($order);
122
+		if (! $order > 0) {
123
+			throw new InvalidArgumentException(
124
+				esc_html__('The form order property must be a positive integer.', 'event_espresso')
125
+			);
126
+		}
127
+		$this->order = $order;
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 * @return string
134
+	 */
135
+	public function redirectUrl()
136
+	{
137
+		return ! empty($this->redirect_args)
138
+			? add_query_arg($this->redirect_args, $this->redirect_url)
139
+			: $this->redirect_url;
140
+	}
141
+
142
+
143
+
144
+	/**
145
+	 * @param string $redirect_url
146
+	 * @throws InvalidDataTypeException
147
+	 * @throws InvalidArgumentException
148
+	 */
149
+	public function setRedirectUrl($redirect_url)
150
+	{
151
+		if (! is_string($redirect_url)) {
152
+			throw new InvalidDataTypeException('$redirect_url', $redirect_url, 'string');
153
+		}
154
+		if (empty($redirect_url)) {
155
+			throw new InvalidArgumentException(
156
+				esc_html__('The redirect URL can not be an empty string.', 'event_espresso')
157
+			);
158
+		}
159
+		$this->redirect_url = $redirect_url;
160
+	}
161
+
162
+
163
+
164
+	/**
165
+	 * @param array $redirect_args
166
+	 * @throws InvalidDataTypeException
167
+	 * @throws InvalidArgumentException
168
+	 */
169
+	public function addRedirectArgs($redirect_args = array())
170
+	{
171
+		if (is_object($redirect_args)) {
172
+			throw new InvalidDataTypeException(
173
+				'$redirect_args',
174
+				$redirect_args,
175
+				'anything other than an object was expected.'
176
+			);
177
+		}
178
+		if (empty($redirect_args)) {
179
+			throw new InvalidArgumentException(
180
+				esc_html__('The redirect argument can not be an empty array.', 'event_espresso')
181
+			);
182
+		}
183
+		$this->redirect_args = array_merge($this->redirect_args, (array)$redirect_args);
184
+	}
185
+
186
+
187
+
188
+	/**
189
+	 * @param array $redirect_arg_keys_to_remove
190
+	 * @throws InvalidDataTypeException
191
+	 * @throws InvalidArgumentException
192
+	 */
193
+	public function removeRedirectArgs($redirect_arg_keys_to_remove = array())
194
+	{
195
+		if (is_object($redirect_arg_keys_to_remove)) {
196
+			throw new InvalidDataTypeException(
197
+				'$redirect_arg_keys_to_remove',
198
+				$redirect_arg_keys_to_remove,
199
+				'anything other than an object was expected.'
200
+			);
201
+		}
202
+		if (empty($redirect_arg_keys_to_remove)) {
203
+			throw new InvalidArgumentException(
204
+				esc_html__('The $redirect_arg_keys_to_remove argument can not be an empty array.', 'event_espresso')
205
+			);
206
+		}
207
+		foreach ($redirect_arg_keys_to_remove as $redirect_arg_key) {
208
+			unset($this->redirect_args[$redirect_arg_key]);
209
+		}
210
+	}
211
+
212
+
213
+
214
+	/**
215
+	 * @return string
216
+	 */
217
+	public function redirectTo()
218
+	{
219
+		return $this->redirect_to;
220
+	}
221
+
222
+
223
+
224
+	/**
225
+	 * @param string $redirect_to
226
+	 * @throws InvalidDataTypeException
227
+	 */
228
+	public function setRedirectTo($redirect_to)
229
+	{
230
+		if (
231
+			! in_array(
232
+				$redirect_to,
233
+				array(
234
+					SequentialStepForm::REDIRECT_TO_NEXT_STEP,
235
+					SequentialStepForm::REDIRECT_TO_CURRENT_STEP,
236
+					SequentialStepForm::REDIRECT_TO_PREV_STEP,
237
+					SequentialStepForm::REDIRECT_TO_OTHER,
238
+				),
239
+				true
240
+			)
241
+		) {
242
+			throw new InvalidDataTypeException(
243
+				'setRedirectTo()',
244
+				$redirect_to,
245
+				'one of the SequentialStepForm class constants was expected.'
246
+			);
247
+		}
248
+		$this->redirect_to = $redirect_to;
249
+	}
250 250
 
251 251
 
252 252
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use EventEspresso\core\exceptions\InvalidDataTypeException;
8 8
 use InvalidArgumentException;
9 9
 
10
-if (! defined('EVENT_ESPRESSO_VERSION')) {
10
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
11 11
     exit('No direct script access allowed');
12 12
 }
13 13
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     public function setOrder($order)
120 120
     {
121 121
         $order = absint($order);
122
-        if (! $order > 0) {
122
+        if ( ! $order > 0) {
123 123
             throw new InvalidArgumentException(
124 124
                 esc_html__('The form order property must be a positive integer.', 'event_espresso')
125 125
             );
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public function setRedirectUrl($redirect_url)
150 150
     {
151
-        if (! is_string($redirect_url)) {
151
+        if ( ! is_string($redirect_url)) {
152 152
             throw new InvalidDataTypeException('$redirect_url', $redirect_url, 'string');
153 153
         }
154 154
         if (empty($redirect_url)) {
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
                 esc_html__('The redirect argument can not be an empty array.', 'event_espresso')
181 181
             );
182 182
         }
183
-        $this->redirect_args = array_merge($this->redirect_args, (array)$redirect_args);
183
+        $this->redirect_args = array_merge($this->redirect_args, (array) $redirect_args);
184 184
     }
185 185
 
186 186
 
Please login to merge, or discard this patch.
core/libraries/form_sections/form_handlers/SequentialStepFormManager.php 3 patches
Indentation   +614 added lines, -614 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use InvalidArgumentException;
19 19
 
20 20
 if (! defined('EVENT_ESPRESSO_VERSION')) {
21
-    exit('No direct script access allowed');
21
+	exit('No direct script access allowed');
22 22
 }
23 23
 
24 24
 
@@ -35,619 +35,619 @@  discard block
 block discarded – undo
35 35
 abstract class SequentialStepFormManager
36 36
 {
37 37
 
38
-    /**
39
-     * a simplified URL with no form related parameters
40
-     * that will be used to build the form's redirect URLs
41
-     *
42
-     * @var string $base_url
43
-     */
44
-    private $base_url = '';
45
-
46
-    /**
47
-     * the key used for the URL param that denotes the current form step
48
-     * defaults to 'ee-form-step'
49
-     *
50
-     * @var string $form_step_url_key
51
-     */
52
-    private $form_step_url_key = '';
53
-
54
-    /**
55
-     * @var string $default_form_step
56
-     */
57
-    private $default_form_step = '';
58
-
59
-    /**
60
-     * @var string $form_action
61
-     */
62
-    private $form_action;
63
-
64
-    /**
65
-     * value of one of the string constant above
66
-     *
67
-     * @var string $form_config
68
-     */
69
-    private $form_config;
70
-
71
-    /**
72
-     * @var string $progress_step_style
73
-     */
74
-    private $progress_step_style = '';
75
-
76
-    /**
77
-     * @var EE_Request $request
78
-     */
79
-    private $request;
80
-
81
-    /**
82
-     * @var Collection $form_steps
83
-     */
84
-    protected $form_steps;
85
-
86
-    /**
87
-     * @var ProgressStepManager $progress_step_manager
88
-     */
89
-    protected $progress_step_manager;
90
-
91
-
92
-
93
-    /**
94
-     * @return Collection|null
95
-     */
96
-    abstract protected function getFormStepsCollection();
97
-
98
-
99
-
100
-    /**
101
-     * StepsManager constructor
102
-     *
103
-     * @param string     $base_url
104
-     * @param string     $default_form_step
105
-     * @param string     $form_action
106
-     * @param string     $form_config
107
-     * @param EE_Request $request
108
-     * @param string     $progress_step_style
109
-     * @throws InvalidDataTypeException
110
-     * @throws InvalidArgumentException
111
-     */
112
-    public function __construct(
113
-        $base_url,
114
-        $default_form_step,
115
-        $form_action = '',
116
-        $form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
117
-        $progress_step_style = 'number_bubbles',
118
-        EE_Request $request
119
-    ) {
120
-        $this->setBaseUrl($base_url);
121
-        $this->setDefaultFormStep($default_form_step);
122
-        $this->setFormAction($form_action);
123
-        $this->setFormConfig($form_config);
124
-        $this->setProgressStepStyle($progress_step_style);
125
-        $this->request = $request;
126
-    }
127
-
128
-
129
-
130
-    /**
131
-     * @return string
132
-     * @throws InvalidFormHandlerException
133
-     */
134
-    public function baseUrl()
135
-    {
136
-        if (strpos($this->base_url, $this->getCurrentStep()->slug()) === false) {
137
-            add_query_arg(
138
-                array($this->form_step_url_key => $this->getCurrentStep()->slug()),
139
-                $this->base_url
140
-            );
141
-        }
142
-        return $this->base_url;
143
-    }
144
-
145
-
146
-
147
-    /**
148
-     * @param string $base_url
149
-     * @throws InvalidDataTypeException
150
-     * @throws InvalidArgumentException
151
-     */
152
-    protected function setBaseUrl($base_url)
153
-    {
154
-        if (! is_string($base_url)) {
155
-            throw new InvalidDataTypeException('$base_url', $base_url, 'string');
156
-        }
157
-        if (empty($base_url)) {
158
-            throw new InvalidArgumentException(
159
-                esc_html__('The base URL can not be an empty string.', 'event_espresso')
160
-            );
161
-        }
162
-        $this->base_url = $base_url;
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * @return string
169
-     * @throws InvalidDataTypeException
170
-     */
171
-    public function formStepUrlKey()
172
-    {
173
-        if (empty($this->form_step_url_key)) {
174
-            $this->setFormStepUrlKey();
175
-        }
176
-        return $this->form_step_url_key;
177
-    }
178
-
179
-
180
-
181
-    /**
182
-     * @param string $form_step_url_key
183
-     * @throws InvalidDataTypeException
184
-     */
185
-    public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
186
-    {
187
-        if (! is_string($form_step_url_key)) {
188
-            throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
189
-        }
190
-        $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
191
-    }
192
-
193
-
194
-
195
-    /**
196
-     * @return string
197
-     */
198
-    public function defaultFormStep()
199
-    {
200
-        return $this->default_form_step;
201
-    }
202
-
203
-
204
-
205
-    /**
206
-     * @param $default_form_step
207
-     * @throws InvalidDataTypeException
208
-     */
209
-    protected function setDefaultFormStep($default_form_step)
210
-    {
211
-        if (! is_string($default_form_step)) {
212
-            throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
213
-        }
214
-        $this->default_form_step = $default_form_step;
215
-    }
216
-
217
-
218
-
219
-    /**
220
-     * @return void
221
-     * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
222
-     * @throws InvalidDataTypeException
223
-     */
224
-    protected function setCurrentStepFromRequest()
225
-    {
226
-        $current_step_slug = $this->request()->get($this->formStepUrlKey(), $this->defaultFormStep());
227
-        if (! $this->form_steps->setCurrent($current_step_slug)) {
228
-            throw new InvalidIdentifierException(
229
-                $current_step_slug,
230
-                $this->defaultFormStep(),
231
-                $message = sprintf(
232
-                    esc_html__(
233
-                        'The "%1$s" form step could not be set.',
234
-                        'event_espresso'
235
-                    ),
236
-                    $current_step_slug
237
-                )
238
-            );
239
-        }
240
-    }
241
-
242
-
243
-
244
-    /**
245
-     * @return object|SequentialStepFormInterface
246
-     * @throws InvalidFormHandlerException
247
-     */
248
-    public function getCurrentStep()
249
-    {
250
-        if (! $this->form_steps->current() instanceof SequentialStepForm) {
251
-            throw new InvalidFormHandlerException($this->form_steps->current());
252
-        }
253
-        return $this->form_steps->current();
254
-    }
255
-
256
-
257
-
258
-    /**
259
-     * @return string
260
-     * @throws InvalidFormHandlerException
261
-     */
262
-    public function formAction()
263
-    {
264
-        if (! is_string($this->form_action) || empty($this->form_action)) {
265
-            $this->form_action = $this->baseUrl();
266
-        }
267
-        return $this->form_action;
268
-    }
269
-
270
-
271
-
272
-    /**
273
-     * @param string $form_action
274
-     * @throws InvalidDataTypeException
275
-     */
276
-    public function setFormAction($form_action)
277
-    {
278
-        if (! is_string($form_action)) {
279
-            throw new InvalidDataTypeException('$form_action', $form_action, 'string');
280
-        }
281
-        $this->form_action = $form_action;
282
-    }
283
-
284
-
285
-
286
-    /**
287
-     * @param array $form_action_args
288
-     * @throws InvalidDataTypeException
289
-     * @throws InvalidFormHandlerException
290
-     */
291
-    public function addFormActionArgs($form_action_args = array())
292
-    {
293
-        if (! is_array($form_action_args)) {
294
-            throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
295
-        }
296
-        $form_action_args = ! empty($form_action_args)
297
-            ? $form_action_args
298
-            : array($this->formStepUrlKey() => $this->form_steps->current()->slug());
299
-        $this->getCurrentStep()->setFormAction(
300
-            add_query_arg($form_action_args, $this->formAction())
301
-        );
302
-        $this->form_action = $this->getCurrentStep()->formAction();
303
-    }
304
-
305
-
306
-
307
-    /**
308
-     * @return string
309
-     */
310
-    public function formConfig()
311
-    {
312
-        return $this->form_config;
313
-    }
314
-
315
-
316
-
317
-    /**
318
-     * @param string $form_config
319
-     */
320
-    public function setFormConfig($form_config)
321
-    {
322
-        $this->form_config = $form_config;
323
-    }
324
-
325
-
326
-
327
-    /**
328
-     * @return string
329
-     */
330
-    public function progressStepStyle()
331
-    {
332
-        return $this->progress_step_style;
333
-    }
334
-
335
-
336
-
337
-    /**
338
-     * @param string $progress_step_style
339
-     */
340
-    public function setProgressStepStyle($progress_step_style)
341
-    {
342
-        $this->progress_step_style = $progress_step_style;
343
-    }
344
-
345
-
346
-
347
-    /**
348
-     * @return EE_Request
349
-     */
350
-    public function request()
351
-    {
352
-        return $this->request;
353
-    }
354
-
355
-
356
-
357
-    /**
358
-     * @return Collection|null
359
-     * @throws InvalidInterfaceException
360
-     */
361
-    protected function getProgressStepsCollection()
362
-    {
363
-        static $collection = null;
364
-        if (! $collection instanceof ProgressStepCollection) {
365
-            $collection = new ProgressStepCollection();
366
-        }
367
-        return $collection;
368
-    }
369
-
370
-
371
-
372
-    /**
373
-     * @param Collection $progress_steps_collection
374
-     * @return ProgressStepManager
375
-     * @throws InvalidInterfaceException
376
-     * @throws InvalidClassException
377
-     * @throws InvalidDataTypeException
378
-     * @throws InvalidEntityException
379
-     * @throws InvalidFormHandlerException
380
-     */
381
-    protected function generateProgressSteps(Collection $progress_steps_collection)
382
-    {
383
-        $current_step = $this->getCurrentStep();
384
-        /** @var SequentialStepForm $form_step */
385
-        foreach ($this->form_steps as $form_step) {
386
-            // is this step active ?
387
-            if (! $form_step->initialize()) {
388
-                continue;
389
-            }
390
-            $progress_steps_collection->add(
391
-                new ProgressStep(
392
-                    $form_step->order(),
393
-                    $form_step->slug(),
394
-                    $form_step->slug(),
395
-                    $form_step->formName()
396
-                ),
397
-                $form_step->slug()
398
-            );
399
-        }
400
-        // set collection pointer back to current step
401
-        $this->form_steps->setCurrentUsingObject($current_step);
402
-        return new ProgressStepManager(
403
-            $this->progressStepStyle(),
404
-            $this->defaultFormStep(),
405
-            $this->formStepUrlKey(),
406
-            $progress_steps_collection
407
-        );
408
-    }
409
-
410
-
411
-
412
-    /**
413
-     * @throws InvalidClassException
414
-     * @throws InvalidDataTypeException
415
-     * @throws InvalidEntityException
416
-     * @throws InvalidIdentifierException
417
-     * @throws InvalidInterfaceException
418
-     * @throws InvalidArgumentException
419
-     * @throws InvalidFormHandlerException
420
-     */
421
-    public function buildForm()
422
-    {
423
-        $this->buildCurrentStepFormForDisplay();
424
-    }
425
-
426
-
427
-
428
-    /**
429
-     * @param array $form_data
430
-     * @throws InvalidArgumentException
431
-     * @throws InvalidClassException
432
-     * @throws InvalidDataTypeException
433
-     * @throws InvalidEntityException
434
-     * @throws InvalidFormHandlerException
435
-     * @throws InvalidIdentifierException
436
-     * @throws InvalidInterfaceException
437
-     */
438
-    public function processForm($form_data = array())
439
-    {
440
-        $this->buildCurrentStepFormForProcessing();
441
-        $this->processCurrentStepForm($form_data);
442
-    }
443
-
444
-
445
-
446
-    /**
447
-     * @throws InvalidClassException
448
-     * @throws InvalidDataTypeException
449
-     * @throws InvalidEntityException
450
-     * @throws InvalidInterfaceException
451
-     * @throws InvalidIdentifierException
452
-     * @throws InvalidArgumentException
453
-     * @throws InvalidFormHandlerException
454
-     */
455
-    public function buildCurrentStepFormForDisplay()
456
-    {
457
-        $form_step = $this->buildCurrentStepForm();
458
-        // no displayable content ? then skip straight to processing
459
-        if (! $form_step->displayable()) {
460
-            $this->addFormActionArgs();
461
-            $form_step->setFormAction($this->formAction());
462
-            wp_safe_redirect($form_step->formAction());
463
-        }
464
-    }
465
-
466
-
467
-
468
-    /**
469
-     * @throws InvalidClassException
470
-     * @throws InvalidDataTypeException
471
-     * @throws InvalidEntityException
472
-     * @throws InvalidInterfaceException
473
-     * @throws InvalidIdentifierException
474
-     * @throws InvalidArgumentException
475
-     * @throws InvalidFormHandlerException
476
-     */
477
-    public function buildCurrentStepFormForProcessing()
478
-    {
479
-        $this->buildCurrentStepForm(false);
480
-    }
481
-
482
-
483
-
484
-    /**
485
-     * @param bool $for_display
486
-     * @return SequentialStepFormInterface
487
-     * @throws InvalidArgumentException
488
-     * @throws InvalidClassException
489
-     * @throws InvalidDataTypeException
490
-     * @throws InvalidEntityException
491
-     * @throws InvalidFormHandlerException
492
-     * @throws InvalidIdentifierException
493
-     * @throws InvalidInterfaceException
494
-     */
495
-    private function buildCurrentStepForm($for_display = true)
496
-    {
497
-        $this->form_steps = $this->getFormStepsCollection();
498
-        $this->setCurrentStepFromRequest();
499
-        $form_step = $this->getCurrentStep();
500
-        if ($form_step->submitBtnText() === esc_html__('Submit', 'event_espresso')) {
501
-            $form_step->setSubmitBtnText(esc_html__('Next Step', 'event_espresso'));
502
-        }
503
-        if ($for_display && $form_step->displayable()) {
504
-            $this->progress_step_manager = $this->generateProgressSteps(
505
-                $this->getProgressStepsCollection()
506
-            );
507
-            $this->progress_step_manager->setCurrentStep(
508
-                $form_step->slug()
509
-            );
510
-            // mark all previous progress steps as completed
511
-            $this->progress_step_manager->setPreviousStepsCompleted();
512
-            $this->progress_step_manager->enqueueStylesAndScripts();
513
-            $this->addFormActionArgs();
514
-            $form_step->setFormAction($this->formAction());
515
-        } else {
516
-            $form_step->setRedirectUrl($this->baseUrl());
517
-            $form_step->addRedirectArgs(
518
-                array($this->formStepUrlKey() => $this->form_steps->current()->slug())
519
-            );
520
-        }
521
-        $form_step->generate();
522
-        if ($for_display) {
523
-            $form_step->enqueueStylesAndScripts();
524
-        }
525
-        return $form_step;
526
-    }
527
-
528
-
529
-
530
-    /**
531
-     * @param bool $return_as_string
532
-     * @return string
533
-     * @throws InvalidFormHandlerException
534
-     */
535
-    public function displayProgressSteps($return_as_string = true)
536
-    {
537
-        $form_step = $this->getCurrentStep();
538
-        if (! $form_step->displayable()) {
539
-            return '';
540
-        }
541
-        $progress_steps = apply_filters(
542
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__before_steps',
543
-            ''
544
-        );
545
-        $progress_steps .= $this->progress_step_manager->displaySteps();
546
-        $progress_steps .= apply_filters(
547
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__after_steps',
548
-            ''
549
-        );
550
-        if ($return_as_string) {
551
-            return $progress_steps;
552
-        }
553
-        echo $progress_steps;
554
-        return '';
555
-    }
556
-
557
-
558
-
559
-    /**
560
-     * @param bool $return_as_string
561
-     * @return string
562
-     * @throws InvalidFormHandlerException
563
-     */
564
-    public function displayCurrentStepForm($return_as_string = true)
565
-    {
566
-        if ($return_as_string) {
567
-            return $this->getCurrentStep()->display();
568
-        }
569
-        echo $this->getCurrentStep()->display();
570
-        return '';
571
-    }
572
-
573
-
574
-
575
-    /**
576
-     * @param array $form_data
577
-     * @return void
578
-     * @throws InvalidArgumentException
579
-     * @throws InvalidDataTypeException
580
-     * @throws InvalidFormHandlerException
581
-     */
582
-    public function processCurrentStepForm($form_data = array())
583
-    {
584
-        // grab instance of current step because after calling next() below,
585
-        // any calls to getCurrentStep() will return the "next" step because we advanced
586
-        $current_step = $this->getCurrentStep();
587
-        try {
588
-            // form processing should either throw exceptions or return true
589
-            $current_step->process($form_data);
590
-        } catch (Exception $e) {
591
-            // something went wrong, so...
592
-            // if WP_DEBUG === true, display the Exception and stack trace right now
593
-            new ExceptionStackTraceDisplay($e);
594
-            // else convert the Exception to an EE_Error
595
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
596
-            // prevent redirect to next step or other if exception was thrown
597
-            if (
598
-                $current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_NEXT_STEP
599
-                || $current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_OTHER
600
-            ) {
601
-                $current_step->setRedirectTo(SequentialStepForm::REDIRECT_TO_CURRENT_STEP);
602
-            }
603
-        }
604
-        // save notices to a transient so that when we redirect back
605
-        // to the display portion for this step
606
-        // those notices can be displayed
607
-        EE_Error::get_notices(false, true);
608
-        $this->redirectForm($current_step);
609
-    }
610
-
611
-
612
-
613
-    /**
614
-     * handles where to go to next
615
-     *
616
-     * @param SequentialStepFormInterface $current_step
617
-     * @throws InvalidArgumentException
618
-     * @throws InvalidDataTypeException
619
-     * @throws InvalidFormHandlerException
620
-     */
621
-    public function redirectForm(SequentialStepFormInterface $current_step)
622
-    {
623
-        $redirect_step = $current_step;
624
-        switch ($current_step->redirectTo()) {
625
-            case SequentialStepForm::REDIRECT_TO_OTHER:
626
-                // going somewhere else, so just check out now
627
-                wp_safe_redirect($redirect_step->redirectUrl());
628
-                exit();
629
-                break;
630
-            case SequentialStepForm::REDIRECT_TO_PREV_STEP:
631
-                $redirect_step = $this->form_steps->previous();
632
-                break;
633
-            case SequentialStepForm::REDIRECT_TO_NEXT_STEP:
634
-                $this->form_steps->next();
635
-                if ($this->form_steps->valid()) {
636
-                    $redirect_step = $this->form_steps->current();
637
-                }
638
-                break;
639
-            case SequentialStepForm::REDIRECT_TO_CURRENT_STEP:
640
-            default :
641
-                // $redirect_step is already set
642
-        }
643
-        $current_step->setRedirectUrl($this->baseUrl());
644
-        $current_step->addRedirectArgs(
645
-        // use the slug for whatever step we are redirecting too
646
-            array($this->formStepUrlKey() => $redirect_step->slug())
647
-        );
648
-        wp_safe_redirect($current_step->redirectUrl());
649
-        exit();
650
-    }
38
+	/**
39
+	 * a simplified URL with no form related parameters
40
+	 * that will be used to build the form's redirect URLs
41
+	 *
42
+	 * @var string $base_url
43
+	 */
44
+	private $base_url = '';
45
+
46
+	/**
47
+	 * the key used for the URL param that denotes the current form step
48
+	 * defaults to 'ee-form-step'
49
+	 *
50
+	 * @var string $form_step_url_key
51
+	 */
52
+	private $form_step_url_key = '';
53
+
54
+	/**
55
+	 * @var string $default_form_step
56
+	 */
57
+	private $default_form_step = '';
58
+
59
+	/**
60
+	 * @var string $form_action
61
+	 */
62
+	private $form_action;
63
+
64
+	/**
65
+	 * value of one of the string constant above
66
+	 *
67
+	 * @var string $form_config
68
+	 */
69
+	private $form_config;
70
+
71
+	/**
72
+	 * @var string $progress_step_style
73
+	 */
74
+	private $progress_step_style = '';
75
+
76
+	/**
77
+	 * @var EE_Request $request
78
+	 */
79
+	private $request;
80
+
81
+	/**
82
+	 * @var Collection $form_steps
83
+	 */
84
+	protected $form_steps;
85
+
86
+	/**
87
+	 * @var ProgressStepManager $progress_step_manager
88
+	 */
89
+	protected $progress_step_manager;
90
+
91
+
92
+
93
+	/**
94
+	 * @return Collection|null
95
+	 */
96
+	abstract protected function getFormStepsCollection();
97
+
98
+
99
+
100
+	/**
101
+	 * StepsManager constructor
102
+	 *
103
+	 * @param string     $base_url
104
+	 * @param string     $default_form_step
105
+	 * @param string     $form_action
106
+	 * @param string     $form_config
107
+	 * @param EE_Request $request
108
+	 * @param string     $progress_step_style
109
+	 * @throws InvalidDataTypeException
110
+	 * @throws InvalidArgumentException
111
+	 */
112
+	public function __construct(
113
+		$base_url,
114
+		$default_form_step,
115
+		$form_action = '',
116
+		$form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
117
+		$progress_step_style = 'number_bubbles',
118
+		EE_Request $request
119
+	) {
120
+		$this->setBaseUrl($base_url);
121
+		$this->setDefaultFormStep($default_form_step);
122
+		$this->setFormAction($form_action);
123
+		$this->setFormConfig($form_config);
124
+		$this->setProgressStepStyle($progress_step_style);
125
+		$this->request = $request;
126
+	}
127
+
128
+
129
+
130
+	/**
131
+	 * @return string
132
+	 * @throws InvalidFormHandlerException
133
+	 */
134
+	public function baseUrl()
135
+	{
136
+		if (strpos($this->base_url, $this->getCurrentStep()->slug()) === false) {
137
+			add_query_arg(
138
+				array($this->form_step_url_key => $this->getCurrentStep()->slug()),
139
+				$this->base_url
140
+			);
141
+		}
142
+		return $this->base_url;
143
+	}
144
+
145
+
146
+
147
+	/**
148
+	 * @param string $base_url
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws InvalidArgumentException
151
+	 */
152
+	protected function setBaseUrl($base_url)
153
+	{
154
+		if (! is_string($base_url)) {
155
+			throw new InvalidDataTypeException('$base_url', $base_url, 'string');
156
+		}
157
+		if (empty($base_url)) {
158
+			throw new InvalidArgumentException(
159
+				esc_html__('The base URL can not be an empty string.', 'event_espresso')
160
+			);
161
+		}
162
+		$this->base_url = $base_url;
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * @return string
169
+	 * @throws InvalidDataTypeException
170
+	 */
171
+	public function formStepUrlKey()
172
+	{
173
+		if (empty($this->form_step_url_key)) {
174
+			$this->setFormStepUrlKey();
175
+		}
176
+		return $this->form_step_url_key;
177
+	}
178
+
179
+
180
+
181
+	/**
182
+	 * @param string $form_step_url_key
183
+	 * @throws InvalidDataTypeException
184
+	 */
185
+	public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
186
+	{
187
+		if (! is_string($form_step_url_key)) {
188
+			throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
189
+		}
190
+		$this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
191
+	}
192
+
193
+
194
+
195
+	/**
196
+	 * @return string
197
+	 */
198
+	public function defaultFormStep()
199
+	{
200
+		return $this->default_form_step;
201
+	}
202
+
203
+
204
+
205
+	/**
206
+	 * @param $default_form_step
207
+	 * @throws InvalidDataTypeException
208
+	 */
209
+	protected function setDefaultFormStep($default_form_step)
210
+	{
211
+		if (! is_string($default_form_step)) {
212
+			throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
213
+		}
214
+		$this->default_form_step = $default_form_step;
215
+	}
216
+
217
+
218
+
219
+	/**
220
+	 * @return void
221
+	 * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
222
+	 * @throws InvalidDataTypeException
223
+	 */
224
+	protected function setCurrentStepFromRequest()
225
+	{
226
+		$current_step_slug = $this->request()->get($this->formStepUrlKey(), $this->defaultFormStep());
227
+		if (! $this->form_steps->setCurrent($current_step_slug)) {
228
+			throw new InvalidIdentifierException(
229
+				$current_step_slug,
230
+				$this->defaultFormStep(),
231
+				$message = sprintf(
232
+					esc_html__(
233
+						'The "%1$s" form step could not be set.',
234
+						'event_espresso'
235
+					),
236
+					$current_step_slug
237
+				)
238
+			);
239
+		}
240
+	}
241
+
242
+
243
+
244
+	/**
245
+	 * @return object|SequentialStepFormInterface
246
+	 * @throws InvalidFormHandlerException
247
+	 */
248
+	public function getCurrentStep()
249
+	{
250
+		if (! $this->form_steps->current() instanceof SequentialStepForm) {
251
+			throw new InvalidFormHandlerException($this->form_steps->current());
252
+		}
253
+		return $this->form_steps->current();
254
+	}
255
+
256
+
257
+
258
+	/**
259
+	 * @return string
260
+	 * @throws InvalidFormHandlerException
261
+	 */
262
+	public function formAction()
263
+	{
264
+		if (! is_string($this->form_action) || empty($this->form_action)) {
265
+			$this->form_action = $this->baseUrl();
266
+		}
267
+		return $this->form_action;
268
+	}
269
+
270
+
271
+
272
+	/**
273
+	 * @param string $form_action
274
+	 * @throws InvalidDataTypeException
275
+	 */
276
+	public function setFormAction($form_action)
277
+	{
278
+		if (! is_string($form_action)) {
279
+			throw new InvalidDataTypeException('$form_action', $form_action, 'string');
280
+		}
281
+		$this->form_action = $form_action;
282
+	}
283
+
284
+
285
+
286
+	/**
287
+	 * @param array $form_action_args
288
+	 * @throws InvalidDataTypeException
289
+	 * @throws InvalidFormHandlerException
290
+	 */
291
+	public function addFormActionArgs($form_action_args = array())
292
+	{
293
+		if (! is_array($form_action_args)) {
294
+			throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
295
+		}
296
+		$form_action_args = ! empty($form_action_args)
297
+			? $form_action_args
298
+			: array($this->formStepUrlKey() => $this->form_steps->current()->slug());
299
+		$this->getCurrentStep()->setFormAction(
300
+			add_query_arg($form_action_args, $this->formAction())
301
+		);
302
+		$this->form_action = $this->getCurrentStep()->formAction();
303
+	}
304
+
305
+
306
+
307
+	/**
308
+	 * @return string
309
+	 */
310
+	public function formConfig()
311
+	{
312
+		return $this->form_config;
313
+	}
314
+
315
+
316
+
317
+	/**
318
+	 * @param string $form_config
319
+	 */
320
+	public function setFormConfig($form_config)
321
+	{
322
+		$this->form_config = $form_config;
323
+	}
324
+
325
+
326
+
327
+	/**
328
+	 * @return string
329
+	 */
330
+	public function progressStepStyle()
331
+	{
332
+		return $this->progress_step_style;
333
+	}
334
+
335
+
336
+
337
+	/**
338
+	 * @param string $progress_step_style
339
+	 */
340
+	public function setProgressStepStyle($progress_step_style)
341
+	{
342
+		$this->progress_step_style = $progress_step_style;
343
+	}
344
+
345
+
346
+
347
+	/**
348
+	 * @return EE_Request
349
+	 */
350
+	public function request()
351
+	{
352
+		return $this->request;
353
+	}
354
+
355
+
356
+
357
+	/**
358
+	 * @return Collection|null
359
+	 * @throws InvalidInterfaceException
360
+	 */
361
+	protected function getProgressStepsCollection()
362
+	{
363
+		static $collection = null;
364
+		if (! $collection instanceof ProgressStepCollection) {
365
+			$collection = new ProgressStepCollection();
366
+		}
367
+		return $collection;
368
+	}
369
+
370
+
371
+
372
+	/**
373
+	 * @param Collection $progress_steps_collection
374
+	 * @return ProgressStepManager
375
+	 * @throws InvalidInterfaceException
376
+	 * @throws InvalidClassException
377
+	 * @throws InvalidDataTypeException
378
+	 * @throws InvalidEntityException
379
+	 * @throws InvalidFormHandlerException
380
+	 */
381
+	protected function generateProgressSteps(Collection $progress_steps_collection)
382
+	{
383
+		$current_step = $this->getCurrentStep();
384
+		/** @var SequentialStepForm $form_step */
385
+		foreach ($this->form_steps as $form_step) {
386
+			// is this step active ?
387
+			if (! $form_step->initialize()) {
388
+				continue;
389
+			}
390
+			$progress_steps_collection->add(
391
+				new ProgressStep(
392
+					$form_step->order(),
393
+					$form_step->slug(),
394
+					$form_step->slug(),
395
+					$form_step->formName()
396
+				),
397
+				$form_step->slug()
398
+			);
399
+		}
400
+		// set collection pointer back to current step
401
+		$this->form_steps->setCurrentUsingObject($current_step);
402
+		return new ProgressStepManager(
403
+			$this->progressStepStyle(),
404
+			$this->defaultFormStep(),
405
+			$this->formStepUrlKey(),
406
+			$progress_steps_collection
407
+		);
408
+	}
409
+
410
+
411
+
412
+	/**
413
+	 * @throws InvalidClassException
414
+	 * @throws InvalidDataTypeException
415
+	 * @throws InvalidEntityException
416
+	 * @throws InvalidIdentifierException
417
+	 * @throws InvalidInterfaceException
418
+	 * @throws InvalidArgumentException
419
+	 * @throws InvalidFormHandlerException
420
+	 */
421
+	public function buildForm()
422
+	{
423
+		$this->buildCurrentStepFormForDisplay();
424
+	}
425
+
426
+
427
+
428
+	/**
429
+	 * @param array $form_data
430
+	 * @throws InvalidArgumentException
431
+	 * @throws InvalidClassException
432
+	 * @throws InvalidDataTypeException
433
+	 * @throws InvalidEntityException
434
+	 * @throws InvalidFormHandlerException
435
+	 * @throws InvalidIdentifierException
436
+	 * @throws InvalidInterfaceException
437
+	 */
438
+	public function processForm($form_data = array())
439
+	{
440
+		$this->buildCurrentStepFormForProcessing();
441
+		$this->processCurrentStepForm($form_data);
442
+	}
443
+
444
+
445
+
446
+	/**
447
+	 * @throws InvalidClassException
448
+	 * @throws InvalidDataTypeException
449
+	 * @throws InvalidEntityException
450
+	 * @throws InvalidInterfaceException
451
+	 * @throws InvalidIdentifierException
452
+	 * @throws InvalidArgumentException
453
+	 * @throws InvalidFormHandlerException
454
+	 */
455
+	public function buildCurrentStepFormForDisplay()
456
+	{
457
+		$form_step = $this->buildCurrentStepForm();
458
+		// no displayable content ? then skip straight to processing
459
+		if (! $form_step->displayable()) {
460
+			$this->addFormActionArgs();
461
+			$form_step->setFormAction($this->formAction());
462
+			wp_safe_redirect($form_step->formAction());
463
+		}
464
+	}
465
+
466
+
467
+
468
+	/**
469
+	 * @throws InvalidClassException
470
+	 * @throws InvalidDataTypeException
471
+	 * @throws InvalidEntityException
472
+	 * @throws InvalidInterfaceException
473
+	 * @throws InvalidIdentifierException
474
+	 * @throws InvalidArgumentException
475
+	 * @throws InvalidFormHandlerException
476
+	 */
477
+	public function buildCurrentStepFormForProcessing()
478
+	{
479
+		$this->buildCurrentStepForm(false);
480
+	}
481
+
482
+
483
+
484
+	/**
485
+	 * @param bool $for_display
486
+	 * @return SequentialStepFormInterface
487
+	 * @throws InvalidArgumentException
488
+	 * @throws InvalidClassException
489
+	 * @throws InvalidDataTypeException
490
+	 * @throws InvalidEntityException
491
+	 * @throws InvalidFormHandlerException
492
+	 * @throws InvalidIdentifierException
493
+	 * @throws InvalidInterfaceException
494
+	 */
495
+	private function buildCurrentStepForm($for_display = true)
496
+	{
497
+		$this->form_steps = $this->getFormStepsCollection();
498
+		$this->setCurrentStepFromRequest();
499
+		$form_step = $this->getCurrentStep();
500
+		if ($form_step->submitBtnText() === esc_html__('Submit', 'event_espresso')) {
501
+			$form_step->setSubmitBtnText(esc_html__('Next Step', 'event_espresso'));
502
+		}
503
+		if ($for_display && $form_step->displayable()) {
504
+			$this->progress_step_manager = $this->generateProgressSteps(
505
+				$this->getProgressStepsCollection()
506
+			);
507
+			$this->progress_step_manager->setCurrentStep(
508
+				$form_step->slug()
509
+			);
510
+			// mark all previous progress steps as completed
511
+			$this->progress_step_manager->setPreviousStepsCompleted();
512
+			$this->progress_step_manager->enqueueStylesAndScripts();
513
+			$this->addFormActionArgs();
514
+			$form_step->setFormAction($this->formAction());
515
+		} else {
516
+			$form_step->setRedirectUrl($this->baseUrl());
517
+			$form_step->addRedirectArgs(
518
+				array($this->formStepUrlKey() => $this->form_steps->current()->slug())
519
+			);
520
+		}
521
+		$form_step->generate();
522
+		if ($for_display) {
523
+			$form_step->enqueueStylesAndScripts();
524
+		}
525
+		return $form_step;
526
+	}
527
+
528
+
529
+
530
+	/**
531
+	 * @param bool $return_as_string
532
+	 * @return string
533
+	 * @throws InvalidFormHandlerException
534
+	 */
535
+	public function displayProgressSteps($return_as_string = true)
536
+	{
537
+		$form_step = $this->getCurrentStep();
538
+		if (! $form_step->displayable()) {
539
+			return '';
540
+		}
541
+		$progress_steps = apply_filters(
542
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__before_steps',
543
+			''
544
+		);
545
+		$progress_steps .= $this->progress_step_manager->displaySteps();
546
+		$progress_steps .= apply_filters(
547
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__after_steps',
548
+			''
549
+		);
550
+		if ($return_as_string) {
551
+			return $progress_steps;
552
+		}
553
+		echo $progress_steps;
554
+		return '';
555
+	}
556
+
557
+
558
+
559
+	/**
560
+	 * @param bool $return_as_string
561
+	 * @return string
562
+	 * @throws InvalidFormHandlerException
563
+	 */
564
+	public function displayCurrentStepForm($return_as_string = true)
565
+	{
566
+		if ($return_as_string) {
567
+			return $this->getCurrentStep()->display();
568
+		}
569
+		echo $this->getCurrentStep()->display();
570
+		return '';
571
+	}
572
+
573
+
574
+
575
+	/**
576
+	 * @param array $form_data
577
+	 * @return void
578
+	 * @throws InvalidArgumentException
579
+	 * @throws InvalidDataTypeException
580
+	 * @throws InvalidFormHandlerException
581
+	 */
582
+	public function processCurrentStepForm($form_data = array())
583
+	{
584
+		// grab instance of current step because after calling next() below,
585
+		// any calls to getCurrentStep() will return the "next" step because we advanced
586
+		$current_step = $this->getCurrentStep();
587
+		try {
588
+			// form processing should either throw exceptions or return true
589
+			$current_step->process($form_data);
590
+		} catch (Exception $e) {
591
+			// something went wrong, so...
592
+			// if WP_DEBUG === true, display the Exception and stack trace right now
593
+			new ExceptionStackTraceDisplay($e);
594
+			// else convert the Exception to an EE_Error
595
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
596
+			// prevent redirect to next step or other if exception was thrown
597
+			if (
598
+				$current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_NEXT_STEP
599
+				|| $current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_OTHER
600
+			) {
601
+				$current_step->setRedirectTo(SequentialStepForm::REDIRECT_TO_CURRENT_STEP);
602
+			}
603
+		}
604
+		// save notices to a transient so that when we redirect back
605
+		// to the display portion for this step
606
+		// those notices can be displayed
607
+		EE_Error::get_notices(false, true);
608
+		$this->redirectForm($current_step);
609
+	}
610
+
611
+
612
+
613
+	/**
614
+	 * handles where to go to next
615
+	 *
616
+	 * @param SequentialStepFormInterface $current_step
617
+	 * @throws InvalidArgumentException
618
+	 * @throws InvalidDataTypeException
619
+	 * @throws InvalidFormHandlerException
620
+	 */
621
+	public function redirectForm(SequentialStepFormInterface $current_step)
622
+	{
623
+		$redirect_step = $current_step;
624
+		switch ($current_step->redirectTo()) {
625
+			case SequentialStepForm::REDIRECT_TO_OTHER:
626
+				// going somewhere else, so just check out now
627
+				wp_safe_redirect($redirect_step->redirectUrl());
628
+				exit();
629
+				break;
630
+			case SequentialStepForm::REDIRECT_TO_PREV_STEP:
631
+				$redirect_step = $this->form_steps->previous();
632
+				break;
633
+			case SequentialStepForm::REDIRECT_TO_NEXT_STEP:
634
+				$this->form_steps->next();
635
+				if ($this->form_steps->valid()) {
636
+					$redirect_step = $this->form_steps->current();
637
+				}
638
+				break;
639
+			case SequentialStepForm::REDIRECT_TO_CURRENT_STEP:
640
+			default :
641
+				// $redirect_step is already set
642
+		}
643
+		$current_step->setRedirectUrl($this->baseUrl());
644
+		$current_step->addRedirectArgs(
645
+		// use the slug for whatever step we are redirecting too
646
+			array($this->formStepUrlKey() => $redirect_step->slug())
647
+		);
648
+		wp_safe_redirect($current_step->redirectUrl());
649
+		exit();
650
+	}
651 651
 
652 652
 
653 653
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 use Exception;
18 18
 use InvalidArgumentException;
19 19
 
20
-if (! defined('EVENT_ESPRESSO_VERSION')) {
20
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
21 21
     exit('No direct script access allowed');
22 22
 }
23 23
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      */
152 152
     protected function setBaseUrl($base_url)
153 153
     {
154
-        if (! is_string($base_url)) {
154
+        if ( ! is_string($base_url)) {
155 155
             throw new InvalidDataTypeException('$base_url', $base_url, 'string');
156 156
         }
157 157
         if (empty($base_url)) {
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
186 186
     {
187
-        if (! is_string($form_step_url_key)) {
187
+        if ( ! is_string($form_step_url_key)) {
188 188
             throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
189 189
         }
190 190
         $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
      */
209 209
     protected function setDefaultFormStep($default_form_step)
210 210
     {
211
-        if (! is_string($default_form_step)) {
211
+        if ( ! is_string($default_form_step)) {
212 212
             throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
213 213
         }
214 214
         $this->default_form_step = $default_form_step;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
     protected function setCurrentStepFromRequest()
225 225
     {
226 226
         $current_step_slug = $this->request()->get($this->formStepUrlKey(), $this->defaultFormStep());
227
-        if (! $this->form_steps->setCurrent($current_step_slug)) {
227
+        if ( ! $this->form_steps->setCurrent($current_step_slug)) {
228 228
             throw new InvalidIdentifierException(
229 229
                 $current_step_slug,
230 230
                 $this->defaultFormStep(),
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public function getCurrentStep()
249 249
     {
250
-        if (! $this->form_steps->current() instanceof SequentialStepForm) {
250
+        if ( ! $this->form_steps->current() instanceof SequentialStepForm) {
251 251
             throw new InvalidFormHandlerException($this->form_steps->current());
252 252
         }
253 253
         return $this->form_steps->current();
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
      */
262 262
     public function formAction()
263 263
     {
264
-        if (! is_string($this->form_action) || empty($this->form_action)) {
264
+        if ( ! is_string($this->form_action) || empty($this->form_action)) {
265 265
             $this->form_action = $this->baseUrl();
266 266
         }
267 267
         return $this->form_action;
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
      */
276 276
     public function setFormAction($form_action)
277 277
     {
278
-        if (! is_string($form_action)) {
278
+        if ( ! is_string($form_action)) {
279 279
             throw new InvalidDataTypeException('$form_action', $form_action, 'string');
280 280
         }
281 281
         $this->form_action = $form_action;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      */
291 291
     public function addFormActionArgs($form_action_args = array())
292 292
     {
293
-        if (! is_array($form_action_args)) {
293
+        if ( ! is_array($form_action_args)) {
294 294
             throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
295 295
         }
296 296
         $form_action_args = ! empty($form_action_args)
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
     protected function getProgressStepsCollection()
362 362
     {
363 363
         static $collection = null;
364
-        if (! $collection instanceof ProgressStepCollection) {
364
+        if ( ! $collection instanceof ProgressStepCollection) {
365 365
             $collection = new ProgressStepCollection();
366 366
         }
367 367
         return $collection;
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
         /** @var SequentialStepForm $form_step */
385 385
         foreach ($this->form_steps as $form_step) {
386 386
             // is this step active ?
387
-            if (! $form_step->initialize()) {
387
+            if ( ! $form_step->initialize()) {
388 388
                 continue;
389 389
             }
390 390
             $progress_steps_collection->add(
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
     {
457 457
         $form_step = $this->buildCurrentStepForm();
458 458
         // no displayable content ? then skip straight to processing
459
-        if (! $form_step->displayable()) {
459
+        if ( ! $form_step->displayable()) {
460 460
             $this->addFormActionArgs();
461 461
             $form_step->setFormAction($this->formAction());
462 462
             wp_safe_redirect($form_step->formAction());
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
     public function displayProgressSteps($return_as_string = true)
536 536
     {
537 537
         $form_step = $this->getCurrentStep();
538
-        if (! $form_step->displayable()) {
538
+        if ( ! $form_step->displayable()) {
539 539
             return '';
540 540
         }
541 541
         $progress_steps = apply_filters(
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 
204 204
 
205 205
     /**
206
-     * @param $default_form_step
206
+     * @param string $default_form_step
207 207
      * @throws InvalidDataTypeException
208 208
      */
209 209
     protected function setDefaultFormStep($default_form_step)
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 
244 244
     /**
245
-     * @return object|SequentialStepFormInterface
245
+     * @return SequentialStepForm
246 246
      * @throws InvalidFormHandlerException
247 247
      */
248 248
     public function getCurrentStep()
Please login to merge, or discard this patch.
admin/extend/messages/Custom_Messages_Template_List_Table.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -409,7 +409,7 @@
 block discarded – undo
409 409
      * This provides a count of events using this custom template
410 410
      *
411 411
      * @param  EE_Message_Template_Group $item message_template group data
412
-     * @return string column output
412
+     * @return integer column output
413 413
      */
414 414
     function column_events($item)
415 415
     {
Please login to merge, or discard this patch.
Indentation   +476 added lines, -476 removed lines patch added patch discarded remove patch
@@ -12,481 +12,481 @@
 block discarded – undo
12 12
 class Custom_Messages_Template_List_Table extends EE_Admin_List_Table
13 13
 {
14 14
 
15
-    /**
16
-     * Custom_Messages_Template_List_Table constructor.
17
-     *
18
-     * @param EE_Admin_Page $admin_page
19
-     */
20
-    public function __construct($admin_page)
21
-    {
22
-        //Set parent defaults
23
-        parent::__construct($admin_page);
24
-    }
25
-
26
-
27
-    /**
28
-     * @return Messages_Admin_Page
29
-     */
30
-    public function get_admin_page()
31
-    {
32
-        return $this->_admin_page;
33
-    }
34
-
35
-    /**
36
-     * Setup initial data.
37
-     */
38
-    protected function _setup_data()
39
-    {
40
-        $this->_data           = $this->get_admin_page()->get_message_templates(
41
-            $this->_per_page,
42
-            $this->_view,
43
-            false,
44
-            false,
45
-            false
46
-        );
47
-        $this->_all_data_count = $this->get_admin_page()->get_message_templates(
48
-            $this->_per_page,
49
-            $this->_view,
50
-            true,
51
-            true,
52
-            false
53
-        );
54
-    }
55
-
56
-
57
-    /**
58
-     * Set initial properties
59
-     */
60
-    protected function _set_properties()
61
-    {
62
-        $this->_wp_list_args = array(
63
-            'singular' => esc_html__('Message Template Group', 'event_espresso'),
64
-            'plural'   => esc_html__('Message Template', 'event_espresso'),
65
-            'ajax'     => true, //for now,
66
-            'screen'   => $this->get_admin_page()->get_current_screen()->id,
67
-        );
68
-
69
-        $this->_columns = array(
70
-            'cb'           => '<input type="checkbox" />',
71
-            'name'         => esc_html__('Template Name', 'event_espresso'),
72
-            'message_type' => esc_html__('Message Type', 'event_espresso'),
73
-            'messenger'    => esc_html__('Messenger', 'event_espresso'),
74
-            'description'  => esc_html__('Description', 'event_espresso'),
75
-            'events'       => esc_html__('Events', 'event_espresso'),
76
-            //count of events using this template.
77
-            'actions'      => ''
78
-        );
79
-
80
-        $this->_sortable_columns = array(
81
-            'messenger' => array('MTP_messenger' => true),
82
-        );
83
-
84
-        $this->_hidden_columns = array();
85
-    }
86
-
87
-
88
-    /**
89
-     * Overriding the single_row method from parent to verify whether the $item has an accessible
90
-     * message_type or messenger object before generating the row.
91
-     *
92
-     * @param EE_Message_Template_Group $item
93
-     * @return string
94
-     */
95
-    public function single_row($item)
96
-    {
97
-        $message_type = $item->message_type_obj();
98
-        $messenger    = $item->messenger_obj();
99
-
100
-        if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) {
101
-            echo '';
102
-            return;
103
-        }
104
-
105
-        parent::single_row($item);
106
-    }
107
-
108
-
109
-    /**
110
-     * @return array
111
-     */
112
-    protected function _get_table_filters()
113
-    {
114
-        $filters = array();
115
-
116
-        //get select inputs
117
-        $select_inputs = array(
118
-            $this->_get_messengers_dropdown_filter(),
119
-            $this->_get_message_types_dropdown_filter(),
120
-        );
121
-
122
-        //set filters to select inputs if they aren't empty
123
-        foreach ($select_inputs as $select_input) {
124
-            if ($select_input) {
125
-                $filters[] = $select_input;
126
-            }
127
-        }
128
-        return $filters;
129
-    }
130
-
131
-    /**
132
-     * we're just removing the search box for message templates, not needed.
133
-     *
134
-     * @return string (empty);
135
-     */
136
-    function search_box($text, $input_id)
137
-    {
138
-        return '';
139
-    }
140
-
141
-
142
-    /**
143
-     * Set the view counts on the _views property
144
-     */
145
-    protected function _add_view_counts()
146
-    {
147
-        foreach ($this->_views as $view => $args) {
148
-            $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates(
149
-                $this->_per_page,
150
-                $view,
151
-                true,
152
-                true,
153
-                false
154
-            );
155
-        }
156
-    }
157
-
158
-
159
-    /**
160
-     * Custom message for when there are no items found.
161
-     *
162
-     * @since 4.3.0
163
-     * @return string
164
-     */
165
-    public function no_items()
166
-    {
167
-        if ($this->_view !== 'trashed') {
168
-            printf(
169
-                esc_html__(
170
-                    '%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.',
171
-                    'event_espresso'
172
-                ),
173
-                '<strong>',
174
-                '</strong>'
175
-            );
176
-        } else {
177
-            parent::no_items();
178
-        }
179
-    }
180
-
181
-
182
-    /**
183
-     * @param EE_Message_Template_Group $item
184
-     * @return string
185
-     */
186
-    public function column_cb($item)
187
-    {
188
-        return sprintf('<input type="checkbox" name="checkbox[%s] value="1" />', $item->GRP_ID());
189
-    }
190
-
191
-
192
-    /**
193
-     * @param EE_Message_Template_Group $item
194
-     * @return string
195
-     */
196
-    function column_name($item)
197
-    {
198
-        return '<p>' . $item->name() . '</p>';
199
-    }
200
-
201
-
202
-    /**
203
-     * @param EE_Message_Template_Group $item
204
-     * @return string
205
-     */
206
-    function column_description($item)
207
-    {
208
-        return '<p>' . $item->description() . '</p>';
209
-    }
210
-
211
-
212
-    /**
213
-     * @param EE_Message_Template_Group $item
214
-     * @return string
215
-     */
216
-    function column_actions($item)
217
-    {
218
-        if (EE_Registry::instance()->CAP->current_user_can(
219
-            'ee_edit_messages',
220
-            'espresso_messages_add_new_message_template'
221
-        )) {
222
-            $create_args = array(
223
-                'GRP_ID'       => $item->ID(),
224
-                'messenger'    => $item->messenger(),
225
-                'message_type' => $item->message_type(),
226
-                'action'       => 'add_new_message_template',
227
-            );
228
-            $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL);
229
-            return sprintf(
230
-                '<p><a href="%s" class="button button-small">%s</a></p>',
231
-                $create_link,
232
-                esc_html__('Create Custom', 'event_espresso')
233
-            );
234
-        }
235
-        return '';
236
-    }
237
-
238
-
239
-    /**
240
-     * Return the content for the messenger column
241
-     * @param EE_Message_Template_Group $item
242
-     * @return string
243
-     */
244
-    function column_messenger($item)
245
-    {
246
-
247
-        //Build row actions
248
-        $actions = array();
249
-        $edit_lnk_url = '';
250
-
251
-        // edit link but only if item isn't trashed.
252
-        if (! $item->get('MTP_deleted')
253
-            && EE_Registry::instance()->CAP->current_user_can(
254
-                'ee_edit_message',
255
-                'espresso_messages_edit_message_template',
256
-                $item->ID()
257
-            )
258
-        ) {
259
-            $edit_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(array(
260
-                'action' => 'edit_m`es`sage_template',
261
-                'id'     => $item->GRP_ID(),
262
-            ), EE_MSG_ADMIN_URL);
263
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '"'
264
-                               . ' class="' . $item->message_type() . '-edit-link"'
265
-                               . ' title="'
266
-                               . esc_attr__('Edit Template', 'event_espresso')
267
-                               . '">'
268
-                               . esc_html__('Edit', 'event_espresso')
269
-                               . '</a>';
270
-        }
271
-
272
-        $name_link     = ! $item->get('MTP_deleted')
273
-                         && EE_Registry::instance()->CAP->current_user_can(
274
-                             'ee_edit_message',
275
-                             'espresso_messages_edit_message_template',
276
-                             $item->ID()
277
-                         )
278
-                        && $edit_lnk_url
279
-            ? '<a href="'
280
-              . $edit_lnk_url
281
-              . '" title="'
282
-              . esc_attr__('Edit Template', 'event_espresso')
283
-              . '">'
284
-              . ucwords($item->messenger_obj()->label['singular'])
285
-              . '</a>'
286
-            : ucwords($item->messenger_obj()->label['singular']);
287
-        $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'   => 'trash_message_template',
288
-                                                                       'id'       => $item->GRP_ID(),
289
-                                                                       'noheader' => true,
290
-        ), EE_MSG_ADMIN_URL);
291
-        // restore link
292
-        $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'   => 'restore_message_template',
293
-                                                                         'id'       => $item->GRP_ID(),
294
-                                                                         'noheader' => true,
295
-        ), EE_MSG_ADMIN_URL);
296
-        // delete price link
297
-        $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'   => 'delete_message_template',
298
-                                                                        'id'       => $item->GRP_ID(),
299
-                                                                        'noheader' => true,
300
-        ), EE_MSG_ADMIN_URL);
301
-
302
-        if (! $item->get('MTP_deleted')
303
-            && EE_Registry::instance()->CAP->current_user_can(
304
-                'ee_delete_message',
305
-                'espresso_messages_trash_message_template',
306
-                $item->ID()
307
-            )
308
-        ) {
309
-            $actions['trash'] = '<a href="'
310
-                                . $trash_lnk_url
311
-                                . '" title="'
312
-                                . esc_attr__('Move Template Group to Trash', 'event_espresso')
313
-                                . '">'
314
-                                . esc_html__('Move to Trash', 'event_espresso')
315
-                                . '</a>';
316
-        } else {
317
-            if (EE_Registry::instance()->CAP->current_user_can(
318
-                'ee_delete_message',
319
-                'espresso_messages_restore_message_template',
320
-                $item->ID()
321
-            )) {
322
-                $actions['restore'] = '<a href="'
323
-                                      . $restore_lnk_url
324
-                                      . '" title="'
325
-                                      . esc_attr__('Restore Message Template', 'event_espresso')
326
-                                      . '">'
327
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
328
-            }
329
-
330
-            if ($this->_view == 'trashed'
331
-                && EE_Registry::instance()->CAP->current_user_can(
332
-                    'ee_delete_message',
333
-                    'espresso_messages_delete_message_template',
334
-                    $item->ID()
335
-                )) {
336
-                $actions['delete'] = '<a href="'
337
-                                     . $delete_lnk_url
338
-                                     . '" title="'
339
-                                     . esc_attr__('Delete Template Group Permanently', 'event_espresso')
340
-                                     . '">'
341
-                                     . esc_html__('Delete Permanently', 'event_espresso')
342
-                                     . '</a>';
343
-            }
344
-        }
345
-
346
-        //we want to display the contexts in here so we need to set them up
347
-        $c_label           = $item->context_label();
348
-        $c_configs         = $item->contexts_config();
349
-        $ctxt              = array();
350
-        $context_templates = $item->context_templates();
351
-        foreach ($context_templates as $context => $template_fields) {
352
-            $mtp_to        = ! empty($context_templates[$context]['to'])
353
-                             && $context_templates[$context]['to'] instanceof EE_Message_Template
354
-                ? $context_templates[$context]['to']->get('MTP_content')
355
-                : null;
356
-            $inactive      = empty($mtp_to) && ! empty($context_templates[$context]['to'])
357
-                ? ' class="mtp-inactive"'
358
-                : '';
359
-            $context_title = ucwords($c_configs[$context]['label']);
360
-            $edit_link     = EE_Admin_Page::add_query_args_and_nonce(array('action'  => 'edit_message_template',
361
-                                                                           'id'      => $item->GRP_ID(),
362
-                                                                           'context' => $context,
363
-            ), EE_MSG_ADMIN_URL);
364
-            $ctxt[]        = EE_Registry::instance()->CAP->current_user_can(
365
-                'ee_edit_message',
366
-                'espresso_messages_edit_message_template',
367
-                $item->ID()
368
-            )
369
-                ? '<a'
370
-                  . $inactive
371
-                  . ' class="' . $item->message_type() . '-' . $context . '-edit-link"'
372
-                  . ' href="' . $edit_link . '"'
373
-                  . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">'
374
-                  . $context_title
375
-                  . '</a>'
376
-                : $context_title;
377
-        }
378
-
379
-        $ctx_content = ! $item->get('MTP_deleted')
380
-                       && EE_Registry::instance()->CAP->current_user_can(
381
-                           'ee_edit_message',
382
-                           'espresso_messages_edit_message_template',
383
-                           $item->ID()
384
-                       )
385
-            ? sprintf(
386
-                '<strong>%s:</strong> ',
387
-                ucwords($c_label['plural'])
388
-            )
389
-              . implode(' | ', $ctxt)
390
-            : '';
391
-
392
-
393
-        //Return the name contents
394
-        return sprintf(
395
-            '%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s',
396
-            /* $1%s */
397
-            $name_link,
398
-            /* $2%s */
399
-            $item->GRP_ID(),
400
-            /* %4$s */
401
-            $ctx_content,
402
-            /* $3%s */
403
-            $this->row_actions($actions)
404
-        );
405
-    }
406
-
407
-    /**
408
-     * column_events
409
-     * This provides a count of events using this custom template
410
-     *
411
-     * @param  EE_Message_Template_Group $item message_template group data
412
-     * @return string column output
413
-     */
414
-    function column_events($item)
415
-    {
416
-        return $item->count_events();
417
-    }
418
-
419
-    /**
420
-     * column_message_type
421
-     *
422
-     * @param  EE_Message_Template_Group $item message info for the row
423
-     * @return string       message_type name
424
-     */
425
-    function column_message_type($item)
426
-    {
427
-        return ucwords($item->message_type_obj()->label['singular']);
428
-    }
429
-
430
-
431
-    /**
432
-     * Generate dropdown filter select input for messengers
433
-     *
434
-     * @return string
435
-     */
436
-    protected function _get_messengers_dropdown_filter()
437
-    {
438
-        $messenger_options                                   = array();
439
-        $active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all(
440
-            array(
441
-                array(
442
-                    'MTP_is_active' => true,
443
-                    'MTP_is_global' => false,
444
-                ),
445
-                'group_by' => 'MTP_messenger',
446
-            )
447
-        );
448
-
449
-        foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) {
450
-            if ($active_message_template_group instanceof EE_Message_Template_Group) {
451
-                $messenger                                                      = $active_message_template_group->messenger_obj();
452
-                $messenger_label                                                = $messenger instanceof EE_messenger
453
-                    ? $messenger->label['singular']
454
-                    : $active_message_template_group->messenger();
455
-                $messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label);
456
-            }
457
-        }
458
-        return $this->get_admin_page()->get_messengers_select_input($messenger_options);
459
-    }
460
-
461
-
462
-    /**
463
-     * Generate dropdown filter select input for message types
464
-     *
465
-     * @return string
466
-     */
467
-    protected function _get_message_types_dropdown_filter()
468
-    {
469
-        $message_type_options                                   = array();
470
-        $active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all(
471
-            array(
472
-                array(
473
-                    'MTP_is_active' => true,
474
-                    'MTP_is_global' => false,
475
-                ),
476
-                'group_by' => 'MTP_message_type',
477
-            )
478
-        );
479
-
480
-        foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) {
481
-            if ($active_message_template_group instanceof EE_Message_Template_Group) {
482
-                $message_type                                                         = $active_message_template_group->message_type_obj();
483
-                $message_type_label                                                   = $message_type instanceof EE_message_type
484
-                    ? $message_type->label['singular']
485
-                    : $active_message_template_group->message_type();
486
-                $message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label);
487
-            }
488
-        }
489
-        return $this->get_admin_page()->get_message_types_select_input($message_type_options);
490
-    }
15
+	/**
16
+	 * Custom_Messages_Template_List_Table constructor.
17
+	 *
18
+	 * @param EE_Admin_Page $admin_page
19
+	 */
20
+	public function __construct($admin_page)
21
+	{
22
+		//Set parent defaults
23
+		parent::__construct($admin_page);
24
+	}
25
+
26
+
27
+	/**
28
+	 * @return Messages_Admin_Page
29
+	 */
30
+	public function get_admin_page()
31
+	{
32
+		return $this->_admin_page;
33
+	}
34
+
35
+	/**
36
+	 * Setup initial data.
37
+	 */
38
+	protected function _setup_data()
39
+	{
40
+		$this->_data           = $this->get_admin_page()->get_message_templates(
41
+			$this->_per_page,
42
+			$this->_view,
43
+			false,
44
+			false,
45
+			false
46
+		);
47
+		$this->_all_data_count = $this->get_admin_page()->get_message_templates(
48
+			$this->_per_page,
49
+			$this->_view,
50
+			true,
51
+			true,
52
+			false
53
+		);
54
+	}
55
+
56
+
57
+	/**
58
+	 * Set initial properties
59
+	 */
60
+	protected function _set_properties()
61
+	{
62
+		$this->_wp_list_args = array(
63
+			'singular' => esc_html__('Message Template Group', 'event_espresso'),
64
+			'plural'   => esc_html__('Message Template', 'event_espresso'),
65
+			'ajax'     => true, //for now,
66
+			'screen'   => $this->get_admin_page()->get_current_screen()->id,
67
+		);
68
+
69
+		$this->_columns = array(
70
+			'cb'           => '<input type="checkbox" />',
71
+			'name'         => esc_html__('Template Name', 'event_espresso'),
72
+			'message_type' => esc_html__('Message Type', 'event_espresso'),
73
+			'messenger'    => esc_html__('Messenger', 'event_espresso'),
74
+			'description'  => esc_html__('Description', 'event_espresso'),
75
+			'events'       => esc_html__('Events', 'event_espresso'),
76
+			//count of events using this template.
77
+			'actions'      => ''
78
+		);
79
+
80
+		$this->_sortable_columns = array(
81
+			'messenger' => array('MTP_messenger' => true),
82
+		);
83
+
84
+		$this->_hidden_columns = array();
85
+	}
86
+
87
+
88
+	/**
89
+	 * Overriding the single_row method from parent to verify whether the $item has an accessible
90
+	 * message_type or messenger object before generating the row.
91
+	 *
92
+	 * @param EE_Message_Template_Group $item
93
+	 * @return string
94
+	 */
95
+	public function single_row($item)
96
+	{
97
+		$message_type = $item->message_type_obj();
98
+		$messenger    = $item->messenger_obj();
99
+
100
+		if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) {
101
+			echo '';
102
+			return;
103
+		}
104
+
105
+		parent::single_row($item);
106
+	}
107
+
108
+
109
+	/**
110
+	 * @return array
111
+	 */
112
+	protected function _get_table_filters()
113
+	{
114
+		$filters = array();
115
+
116
+		//get select inputs
117
+		$select_inputs = array(
118
+			$this->_get_messengers_dropdown_filter(),
119
+			$this->_get_message_types_dropdown_filter(),
120
+		);
121
+
122
+		//set filters to select inputs if they aren't empty
123
+		foreach ($select_inputs as $select_input) {
124
+			if ($select_input) {
125
+				$filters[] = $select_input;
126
+			}
127
+		}
128
+		return $filters;
129
+	}
130
+
131
+	/**
132
+	 * we're just removing the search box for message templates, not needed.
133
+	 *
134
+	 * @return string (empty);
135
+	 */
136
+	function search_box($text, $input_id)
137
+	{
138
+		return '';
139
+	}
140
+
141
+
142
+	/**
143
+	 * Set the view counts on the _views property
144
+	 */
145
+	protected function _add_view_counts()
146
+	{
147
+		foreach ($this->_views as $view => $args) {
148
+			$this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates(
149
+				$this->_per_page,
150
+				$view,
151
+				true,
152
+				true,
153
+				false
154
+			);
155
+		}
156
+	}
157
+
158
+
159
+	/**
160
+	 * Custom message for when there are no items found.
161
+	 *
162
+	 * @since 4.3.0
163
+	 * @return string
164
+	 */
165
+	public function no_items()
166
+	{
167
+		if ($this->_view !== 'trashed') {
168
+			printf(
169
+				esc_html__(
170
+					'%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.',
171
+					'event_espresso'
172
+				),
173
+				'<strong>',
174
+				'</strong>'
175
+			);
176
+		} else {
177
+			parent::no_items();
178
+		}
179
+	}
180
+
181
+
182
+	/**
183
+	 * @param EE_Message_Template_Group $item
184
+	 * @return string
185
+	 */
186
+	public function column_cb($item)
187
+	{
188
+		return sprintf('<input type="checkbox" name="checkbox[%s] value="1" />', $item->GRP_ID());
189
+	}
190
+
191
+
192
+	/**
193
+	 * @param EE_Message_Template_Group $item
194
+	 * @return string
195
+	 */
196
+	function column_name($item)
197
+	{
198
+		return '<p>' . $item->name() . '</p>';
199
+	}
200
+
201
+
202
+	/**
203
+	 * @param EE_Message_Template_Group $item
204
+	 * @return string
205
+	 */
206
+	function column_description($item)
207
+	{
208
+		return '<p>' . $item->description() . '</p>';
209
+	}
210
+
211
+
212
+	/**
213
+	 * @param EE_Message_Template_Group $item
214
+	 * @return string
215
+	 */
216
+	function column_actions($item)
217
+	{
218
+		if (EE_Registry::instance()->CAP->current_user_can(
219
+			'ee_edit_messages',
220
+			'espresso_messages_add_new_message_template'
221
+		)) {
222
+			$create_args = array(
223
+				'GRP_ID'       => $item->ID(),
224
+				'messenger'    => $item->messenger(),
225
+				'message_type' => $item->message_type(),
226
+				'action'       => 'add_new_message_template',
227
+			);
228
+			$create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL);
229
+			return sprintf(
230
+				'<p><a href="%s" class="button button-small">%s</a></p>',
231
+				$create_link,
232
+				esc_html__('Create Custom', 'event_espresso')
233
+			);
234
+		}
235
+		return '';
236
+	}
237
+
238
+
239
+	/**
240
+	 * Return the content for the messenger column
241
+	 * @param EE_Message_Template_Group $item
242
+	 * @return string
243
+	 */
244
+	function column_messenger($item)
245
+	{
246
+
247
+		//Build row actions
248
+		$actions = array();
249
+		$edit_lnk_url = '';
250
+
251
+		// edit link but only if item isn't trashed.
252
+		if (! $item->get('MTP_deleted')
253
+			&& EE_Registry::instance()->CAP->current_user_can(
254
+				'ee_edit_message',
255
+				'espresso_messages_edit_message_template',
256
+				$item->ID()
257
+			)
258
+		) {
259
+			$edit_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(array(
260
+				'action' => 'edit_m`es`sage_template',
261
+				'id'     => $item->GRP_ID(),
262
+			), EE_MSG_ADMIN_URL);
263
+			$actions['edit'] = '<a href="' . $edit_lnk_url . '"'
264
+							   . ' class="' . $item->message_type() . '-edit-link"'
265
+							   . ' title="'
266
+							   . esc_attr__('Edit Template', 'event_espresso')
267
+							   . '">'
268
+							   . esc_html__('Edit', 'event_espresso')
269
+							   . '</a>';
270
+		}
271
+
272
+		$name_link     = ! $item->get('MTP_deleted')
273
+						 && EE_Registry::instance()->CAP->current_user_can(
274
+							 'ee_edit_message',
275
+							 'espresso_messages_edit_message_template',
276
+							 $item->ID()
277
+						 )
278
+						&& $edit_lnk_url
279
+			? '<a href="'
280
+			  . $edit_lnk_url
281
+			  . '" title="'
282
+			  . esc_attr__('Edit Template', 'event_espresso')
283
+			  . '">'
284
+			  . ucwords($item->messenger_obj()->label['singular'])
285
+			  . '</a>'
286
+			: ucwords($item->messenger_obj()->label['singular']);
287
+		$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'   => 'trash_message_template',
288
+																	   'id'       => $item->GRP_ID(),
289
+																	   'noheader' => true,
290
+		), EE_MSG_ADMIN_URL);
291
+		// restore link
292
+		$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'   => 'restore_message_template',
293
+																		 'id'       => $item->GRP_ID(),
294
+																		 'noheader' => true,
295
+		), EE_MSG_ADMIN_URL);
296
+		// delete price link
297
+		$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'   => 'delete_message_template',
298
+																		'id'       => $item->GRP_ID(),
299
+																		'noheader' => true,
300
+		), EE_MSG_ADMIN_URL);
301
+
302
+		if (! $item->get('MTP_deleted')
303
+			&& EE_Registry::instance()->CAP->current_user_can(
304
+				'ee_delete_message',
305
+				'espresso_messages_trash_message_template',
306
+				$item->ID()
307
+			)
308
+		) {
309
+			$actions['trash'] = '<a href="'
310
+								. $trash_lnk_url
311
+								. '" title="'
312
+								. esc_attr__('Move Template Group to Trash', 'event_espresso')
313
+								. '">'
314
+								. esc_html__('Move to Trash', 'event_espresso')
315
+								. '</a>';
316
+		} else {
317
+			if (EE_Registry::instance()->CAP->current_user_can(
318
+				'ee_delete_message',
319
+				'espresso_messages_restore_message_template',
320
+				$item->ID()
321
+			)) {
322
+				$actions['restore'] = '<a href="'
323
+									  . $restore_lnk_url
324
+									  . '" title="'
325
+									  . esc_attr__('Restore Message Template', 'event_espresso')
326
+									  . '">'
327
+									  . esc_html__('Restore', 'event_espresso') . '</a>';
328
+			}
329
+
330
+			if ($this->_view == 'trashed'
331
+				&& EE_Registry::instance()->CAP->current_user_can(
332
+					'ee_delete_message',
333
+					'espresso_messages_delete_message_template',
334
+					$item->ID()
335
+				)) {
336
+				$actions['delete'] = '<a href="'
337
+									 . $delete_lnk_url
338
+									 . '" title="'
339
+									 . esc_attr__('Delete Template Group Permanently', 'event_espresso')
340
+									 . '">'
341
+									 . esc_html__('Delete Permanently', 'event_espresso')
342
+									 . '</a>';
343
+			}
344
+		}
345
+
346
+		//we want to display the contexts in here so we need to set them up
347
+		$c_label           = $item->context_label();
348
+		$c_configs         = $item->contexts_config();
349
+		$ctxt              = array();
350
+		$context_templates = $item->context_templates();
351
+		foreach ($context_templates as $context => $template_fields) {
352
+			$mtp_to        = ! empty($context_templates[$context]['to'])
353
+							 && $context_templates[$context]['to'] instanceof EE_Message_Template
354
+				? $context_templates[$context]['to']->get('MTP_content')
355
+				: null;
356
+			$inactive      = empty($mtp_to) && ! empty($context_templates[$context]['to'])
357
+				? ' class="mtp-inactive"'
358
+				: '';
359
+			$context_title = ucwords($c_configs[$context]['label']);
360
+			$edit_link     = EE_Admin_Page::add_query_args_and_nonce(array('action'  => 'edit_message_template',
361
+																		   'id'      => $item->GRP_ID(),
362
+																		   'context' => $context,
363
+			), EE_MSG_ADMIN_URL);
364
+			$ctxt[]        = EE_Registry::instance()->CAP->current_user_can(
365
+				'ee_edit_message',
366
+				'espresso_messages_edit_message_template',
367
+				$item->ID()
368
+			)
369
+				? '<a'
370
+				  . $inactive
371
+				  . ' class="' . $item->message_type() . '-' . $context . '-edit-link"'
372
+				  . ' href="' . $edit_link . '"'
373
+				  . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">'
374
+				  . $context_title
375
+				  . '</a>'
376
+				: $context_title;
377
+		}
378
+
379
+		$ctx_content = ! $item->get('MTP_deleted')
380
+					   && EE_Registry::instance()->CAP->current_user_can(
381
+						   'ee_edit_message',
382
+						   'espresso_messages_edit_message_template',
383
+						   $item->ID()
384
+					   )
385
+			? sprintf(
386
+				'<strong>%s:</strong> ',
387
+				ucwords($c_label['plural'])
388
+			)
389
+			  . implode(' | ', $ctxt)
390
+			: '';
391
+
392
+
393
+		//Return the name contents
394
+		return sprintf(
395
+			'%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s',
396
+			/* $1%s */
397
+			$name_link,
398
+			/* $2%s */
399
+			$item->GRP_ID(),
400
+			/* %4$s */
401
+			$ctx_content,
402
+			/* $3%s */
403
+			$this->row_actions($actions)
404
+		);
405
+	}
406
+
407
+	/**
408
+	 * column_events
409
+	 * This provides a count of events using this custom template
410
+	 *
411
+	 * @param  EE_Message_Template_Group $item message_template group data
412
+	 * @return string column output
413
+	 */
414
+	function column_events($item)
415
+	{
416
+		return $item->count_events();
417
+	}
418
+
419
+	/**
420
+	 * column_message_type
421
+	 *
422
+	 * @param  EE_Message_Template_Group $item message info for the row
423
+	 * @return string       message_type name
424
+	 */
425
+	function column_message_type($item)
426
+	{
427
+		return ucwords($item->message_type_obj()->label['singular']);
428
+	}
429
+
430
+
431
+	/**
432
+	 * Generate dropdown filter select input for messengers
433
+	 *
434
+	 * @return string
435
+	 */
436
+	protected function _get_messengers_dropdown_filter()
437
+	{
438
+		$messenger_options                                   = array();
439
+		$active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all(
440
+			array(
441
+				array(
442
+					'MTP_is_active' => true,
443
+					'MTP_is_global' => false,
444
+				),
445
+				'group_by' => 'MTP_messenger',
446
+			)
447
+		);
448
+
449
+		foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) {
450
+			if ($active_message_template_group instanceof EE_Message_Template_Group) {
451
+				$messenger                                                      = $active_message_template_group->messenger_obj();
452
+				$messenger_label                                                = $messenger instanceof EE_messenger
453
+					? $messenger->label['singular']
454
+					: $active_message_template_group->messenger();
455
+				$messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label);
456
+			}
457
+		}
458
+		return $this->get_admin_page()->get_messengers_select_input($messenger_options);
459
+	}
460
+
461
+
462
+	/**
463
+	 * Generate dropdown filter select input for message types
464
+	 *
465
+	 * @return string
466
+	 */
467
+	protected function _get_message_types_dropdown_filter()
468
+	{
469
+		$message_type_options                                   = array();
470
+		$active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all(
471
+			array(
472
+				array(
473
+					'MTP_is_active' => true,
474
+					'MTP_is_global' => false,
475
+				),
476
+				'group_by' => 'MTP_message_type',
477
+			)
478
+		);
479
+
480
+		foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) {
481
+			if ($active_message_template_group instanceof EE_Message_Template_Group) {
482
+				$message_type                                                         = $active_message_template_group->message_type_obj();
483
+				$message_type_label                                                   = $message_type instanceof EE_message_type
484
+					? $message_type->label['singular']
485
+					: $active_message_template_group->message_type();
486
+				$message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label);
487
+			}
488
+		}
489
+		return $this->get_admin_page()->get_message_types_select_input($message_type_options);
490
+	}
491 491
 
492 492
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     protected function _setup_data()
39 39
     {
40
-        $this->_data           = $this->get_admin_page()->get_message_templates(
40
+        $this->_data = $this->get_admin_page()->get_message_templates(
41 41
             $this->_per_page,
42 42
             $this->_view,
43 43
             false,
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         $message_type = $item->message_type_obj();
98 98
         $messenger    = $item->messenger_obj();
99 99
 
100
-        if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) {
100
+        if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) {
101 101
             echo '';
102 102
             return;
103 103
         }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      */
196 196
     function column_name($item)
197 197
     {
198
-        return '<p>' . $item->name() . '</p>';
198
+        return '<p>'.$item->name().'</p>';
199 199
     }
200 200
 
201 201
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     function column_description($item)
207 207
     {
208
-        return '<p>' . $item->description() . '</p>';
208
+        return '<p>'.$item->description().'</p>';
209 209
     }
210 210
 
211 211
 
@@ -249,19 +249,19 @@  discard block
 block discarded – undo
249 249
         $edit_lnk_url = '';
250 250
 
251 251
         // edit link but only if item isn't trashed.
252
-        if (! $item->get('MTP_deleted')
252
+        if ( ! $item->get('MTP_deleted')
253 253
             && EE_Registry::instance()->CAP->current_user_can(
254 254
                 'ee_edit_message',
255 255
                 'espresso_messages_edit_message_template',
256 256
                 $item->ID()
257 257
             )
258 258
         ) {
259
-            $edit_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(array(
259
+            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
260 260
                 'action' => 'edit_m`es`sage_template',
261 261
                 'id'     => $item->GRP_ID(),
262 262
             ), EE_MSG_ADMIN_URL);
263
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '"'
264
-                               . ' class="' . $item->message_type() . '-edit-link"'
263
+            $actions['edit'] = '<a href="'.$edit_lnk_url.'"'
264
+                               . ' class="'.$item->message_type().'-edit-link"'
265 265
                                . ' title="'
266 266
                                . esc_attr__('Edit Template', 'event_espresso')
267 267
                                . '">'
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
                                . '</a>';
270 270
         }
271 271
 
272
-        $name_link     = ! $item->get('MTP_deleted')
272
+        $name_link = ! $item->get('MTP_deleted')
273 273
                          && EE_Registry::instance()->CAP->current_user_can(
274 274
                              'ee_edit_message',
275 275
                              'espresso_messages_edit_message_template',
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                                                                         'noheader' => true,
300 300
         ), EE_MSG_ADMIN_URL);
301 301
 
302
-        if (! $item->get('MTP_deleted')
302
+        if ( ! $item->get('MTP_deleted')
303 303
             && EE_Registry::instance()->CAP->current_user_can(
304 304
                 'ee_delete_message',
305 305
                 'espresso_messages_trash_message_template',
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
                                       . '" title="'
325 325
                                       . esc_attr__('Restore Message Template', 'event_espresso')
326 326
                                       . '">'
327
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
327
+                                      . esc_html__('Restore', 'event_espresso').'</a>';
328 328
             }
329 329
 
330 330
             if ($this->_view == 'trashed'
@@ -361,16 +361,16 @@  discard block
 block discarded – undo
361 361
                                                                            'id'      => $item->GRP_ID(),
362 362
                                                                            'context' => $context,
363 363
             ), EE_MSG_ADMIN_URL);
364
-            $ctxt[]        = EE_Registry::instance()->CAP->current_user_can(
364
+            $ctxt[] = EE_Registry::instance()->CAP->current_user_can(
365 365
                 'ee_edit_message',
366 366
                 'espresso_messages_edit_message_template',
367 367
                 $item->ID()
368 368
             )
369 369
                 ? '<a'
370 370
                   . $inactive
371
-                  . ' class="' . $item->message_type() . '-' . $context . '-edit-link"'
372
-                  . ' href="' . $edit_link . '"'
373
-                  . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">'
371
+                  . ' class="'.$item->message_type().'-'.$context.'-edit-link"'
372
+                  . ' href="'.$edit_link.'"'
373
+                  . ' title="'.esc_attr__('Edit Context', 'event_espresso').'">'
374 374
                   . $context_title
375 375
                   . '</a>'
376 376
                 : $context_title;
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Template_List_Table.class.php 2 patches
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -13,325 +13,325 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * @return Messages_Admin_Page
18
-     */
19
-    public function get_admin_page()
20
-    {
21
-        return $this->_admin_page;
22
-    }
23
-
24
-
25
-    /**
26
-     * Setup data object
27
-     */
28
-    protected function _setup_data()
29
-    {
30
-        $this->_data           = $this->get_admin_page()->get_message_templates(
31
-            $this->_per_page,
32
-            $this->_view,
33
-            false
34
-        );
35
-        $this->_all_data_count = $this->get_admin_page()->get_message_templates(
36
-            $this->_per_page,
37
-            $this->_view,
38
-            true,
39
-            true
40
-        );
41
-    }
42
-
43
-
44
-    /**
45
-     * Set internal properties
46
-     */
47
-    protected function _set_properties()
48
-    {
49
-        $this->_wp_list_args = array(
50
-            'singular' => esc_html__('Message Template Group', 'event_espresso'),
51
-            'plural'   => esc_html__('Message Template', 'event_espresso'),
52
-            'ajax'     => true, //for now,
53
-            'screen'   => $this->get_admin_page()->get_current_screen()->id,
54
-        );
55
-        $this->_columns      = array(
56
-            //'cb' => '<input type="checkbox" />', //no deleting default (global) templates!
57
-            'message_type' => esc_html__('Message Type', 'event_espresso'),
58
-            'messenger'    => esc_html__('Messenger', 'event_espresso'),
59
-            'description'  => esc_html__('Description', 'event_espresso'),
60
-        );
61
-
62
-        $this->_sortable_columns = array(
63
-            'messenger' => array('MTP_messenger' => true),
64
-        );
65
-
66
-        $this->_hidden_columns = array();
67
-    }
68
-
69
-
70
-    /**
71
-     * Overriding the single_row method from parent to verify whether the $item has an accessible
72
-     * message_type or messenger object before generating the row.
73
-     *
74
-     * @param EE_Message_Template_Group $item
75
-     * @return string
76
-     */
77
-    public function single_row($item)
78
-    {
79
-        $message_type = $item->message_type_obj();
80
-        $messenger    = $item->messenger_obj();
81
-
82
-        if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) {
83
-            echo '';
84
-            return;
85
-        }
86
-
87
-        parent::single_row($item);
88
-    }
89
-
90
-
91
-    /**
92
-     * @return array
93
-     */
94
-    protected function _get_table_filters()
95
-    {
96
-        $filters = array();
97
-
98
-        //get select inputs
99
-        $select_inputs = array(
100
-            $this->_get_messengers_dropdown_filter(),
101
-            $this->_get_message_types_dropdown_filter(),
102
-        );
103
-
104
-        //set filters to select inputs if they aren't empty
105
-        foreach ($select_inputs as $select_input) {
106
-            if ($select_input) {
107
-                $filters[] = $select_input;
108
-            }
109
-        }
110
-        return $filters;
111
-    }
112
-
113
-    /**
114
-     * we're just removing the search box for message templates, not needed.
115
-     *
116
-     * @return string (empty);
117
-     */
118
-    function search_box($text, $input_id)
119
-    {
120
-        return '';
121
-    }
122
-
123
-
124
-    /**
125
-     * Add counts to the _views property
126
-     */
127
-    protected function _add_view_counts()
128
-    {
129
-        foreach ($this->_views as $view => $args) {
130
-            $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates(
131
-                $this->_per_page,
132
-                $view,
133
-                true,
134
-                true
135
-            );
136
-        }
137
-    }
138
-
139
-
140
-    /**
141
-     * @param EE_Message_Template_Group $item
142
-     * @return string
143
-     */
144
-    public function column_cb($item)
145
-    {
146
-        return '';
147
-    }
148
-
149
-
150
-    /**
151
-     * @param EE_Message_Template_Group $item
152
-     * @return string
153
-     */
154
-    function column_description($item)
155
-    {
156
-        return '<p>' . $item->message_type_obj()->description . '</p>';
157
-    }
158
-
159
-
160
-    /**
161
-     * @param EE_Message_Template_Group $item
162
-     * @return string
163
-     */
164
-    function column_messenger($item)
165
-    {
166
-        //Build row actions
167
-        $actions = array();
168
-
169
-        // edit link but only if item isn't trashed.
170
-        if (! $item->get('MTP_deleted')
171
-            && EE_Registry::instance()->CAP->current_user_can(
172
-                'ee_edit_message',
173
-                'espresso_messages_edit_message_template',
174
-                $item->ID()
175
-            )) {
176
-            $edit_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
177
-                array(
178
-                    'action' => 'edit_message_template',
179
-                    'id'     => $item->GRP_ID(),
180
-                ),
181
-                EE_MSG_ADMIN_URL
182
-            );
183
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '"'
184
-                               . ' class="' . $item->message_type() . '-edit-link"'
185
-                               . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">'
186
-                               . esc_html__('Edit', 'event_espresso')
187
-                               . '</a>';
188
-        }
189
-
190
-        $name_link = ! $item->get('MTP_deleted')
191
-                     && EE_Registry::instance()->CAP->current_user_can(
192
-                         'ee_edit_message',
193
-                         'espresso_messages_edit_message_template',
194
-                         $item->ID()
195
-                     )
196
-            ? '<a href="' . $edit_lnk_url . '"'
197
-              . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">'
198
-              . ucwords($item->messenger_obj()->label['singular'])
199
-              . '</a>'
200
-            : ucwords($item->messenger_obj()->label['singular']);
201
-
202
-        //we want to display the contexts in here so we need to set them up
203
-        $c_label           = $item->context_label();
204
-        $c_configs         = $item->contexts_config();
205
-        $ctxt              = array();
206
-        $context_templates = $item->context_templates();
207
-        foreach ($context_templates as $context => $template_fields) {
208
-            $mtp_to        = ! empty($context_templates[$context]['to'])
209
-                             && $context_templates[$context]['to'] instanceof EE_Message_Template
210
-                ? $context_templates[$context]['to']->get('MTP_content')
211
-                : null;
212
-            $inactive      = empty($mtp_to)
213
-                             && ! empty($context_templates[$context]['to'])
214
-                ? ' class="mtp-inactive"'
215
-                : '';
216
-            $context_title = ucwords($c_configs[$context]['label']);
217
-            $edit_link     = EE_Admin_Page::add_query_args_and_nonce(array('action'  => 'edit_message_template',
218
-                                                                           'id'      => $item->GRP_ID(),
219
-                                                                           'context' => $context,
220
-            ), EE_MSG_ADMIN_URL);
221
-            $ctxt[]        = EE_Registry::instance()->CAP->current_user_can(
222
-                'ee_edit_message',
223
-                'espresso_messages_edit_message_template',
224
-                $item->ID()
225
-            )
226
-                ? '<a' . $inactive
227
-                  . ' href="' . $edit_link . '"'
228
-                  . ' class="' . $item->message_type() . '-' . $context . '-edit-link"'
229
-                  . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">'
230
-                  . $context_title
231
-                  . '</a>'
232
-                : $context_title;
233
-        }
234
-
235
-        $ctx_content = ! $item->get('MTP_deleted')
236
-                       && EE_Registry::instance()->CAP->current_user_can(
237
-                           'ee_edit_message',
238
-                           'espresso_messages_edit_message_template',
239
-                           $item->ID()
240
-                       )
241
-            ? sprintf(
242
-                '<strong>%s:</strong> ',
243
-                ucwords($c_label['plural'])
244
-            )
245
-              . implode(' | ', $ctxt)
246
-            : '';
247
-
248
-
249
-        //Return the name contents
250
-        return sprintf(
251
-            '%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s',
252
-            /* $1%s */
253
-            $name_link,
254
-            /* $2%s */
255
-            $item->GRP_ID(),
256
-            /* %4$s */
257
-            $ctx_content,
258
-            /* $3%s */
259
-            $this->row_actions($actions)
260
-        );
261
-    }
262
-
263
-    /**
264
-     * column_message_type
265
-     *
266
-     * @param  EE_Message_Template_Group  $item message info for the row
267
-     * @return string       message_type name
268
-     */
269
-    function column_message_type($item)
270
-    {
271
-        return ucwords($item->message_type_obj()->label['singular']);
272
-    }
273
-
274
-
275
-
276
-    /**
277
-     * Generate dropdown filter select input for messengers
278
-     *
279
-     * @return string
280
-     */
281
-    protected function _get_messengers_dropdown_filter()
282
-    {
283
-        $messenger_options                                   = array();
284
-        $active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all(
285
-            array(
286
-                array(
287
-                    'MTP_is_active' => true,
288
-                    'MTP_is_global' => true,
289
-                ),
290
-                'group_by' => 'MTP_messenger',
291
-            )
292
-        );
293
-
294
-        foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) {
295
-            if ($active_message_template_group instanceof EE_Message_Template_Group) {
296
-                $messenger                                                      = $active_message_template_group->messenger_obj();
297
-                $messenger_label                                                = $messenger instanceof EE_messenger
298
-                    ? $messenger->label['singular']
299
-                    : $active_message_template_group->messenger();
300
-                $messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label);
301
-            }
302
-        }
303
-        return $this->get_admin_page()->get_messengers_select_input($messenger_options);
304
-    }
305
-
306
-
307
-    /**
308
-     * Generate dropdown filter select input for message types
309
-     *
310
-     * @return string
311
-     */
312
-    protected function _get_message_types_dropdown_filter()
313
-    {
314
-        $message_type_options                                   = array();
315
-        $active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all(
316
-            array(
317
-                array(
318
-                    'MTP_is_active' => true,
319
-                    'MTP_is_global' => true,
320
-                ),
321
-                'group_by' => 'MTP_message_type',
322
-            )
323
-        );
324
-
325
-        foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) {
326
-            if ($active_message_template_group instanceof EE_Message_Template_Group) {
327
-                $message_type                                                         = $active_message_template_group->message_type_obj();
328
-                $message_type_label                                                   = $message_type instanceof EE_message_type
329
-                    ? $message_type->label['singular']
330
-                    : $active_message_template_group->message_type();
331
-                $message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label);
332
-            }
333
-        }
334
-        return $this->get_admin_page()->get_message_types_select_input($message_type_options);
335
-    }
16
+	/**
17
+	 * @return Messages_Admin_Page
18
+	 */
19
+	public function get_admin_page()
20
+	{
21
+		return $this->_admin_page;
22
+	}
23
+
24
+
25
+	/**
26
+	 * Setup data object
27
+	 */
28
+	protected function _setup_data()
29
+	{
30
+		$this->_data           = $this->get_admin_page()->get_message_templates(
31
+			$this->_per_page,
32
+			$this->_view,
33
+			false
34
+		);
35
+		$this->_all_data_count = $this->get_admin_page()->get_message_templates(
36
+			$this->_per_page,
37
+			$this->_view,
38
+			true,
39
+			true
40
+		);
41
+	}
42
+
43
+
44
+	/**
45
+	 * Set internal properties
46
+	 */
47
+	protected function _set_properties()
48
+	{
49
+		$this->_wp_list_args = array(
50
+			'singular' => esc_html__('Message Template Group', 'event_espresso'),
51
+			'plural'   => esc_html__('Message Template', 'event_espresso'),
52
+			'ajax'     => true, //for now,
53
+			'screen'   => $this->get_admin_page()->get_current_screen()->id,
54
+		);
55
+		$this->_columns      = array(
56
+			//'cb' => '<input type="checkbox" />', //no deleting default (global) templates!
57
+			'message_type' => esc_html__('Message Type', 'event_espresso'),
58
+			'messenger'    => esc_html__('Messenger', 'event_espresso'),
59
+			'description'  => esc_html__('Description', 'event_espresso'),
60
+		);
61
+
62
+		$this->_sortable_columns = array(
63
+			'messenger' => array('MTP_messenger' => true),
64
+		);
65
+
66
+		$this->_hidden_columns = array();
67
+	}
68
+
69
+
70
+	/**
71
+	 * Overriding the single_row method from parent to verify whether the $item has an accessible
72
+	 * message_type or messenger object before generating the row.
73
+	 *
74
+	 * @param EE_Message_Template_Group $item
75
+	 * @return string
76
+	 */
77
+	public function single_row($item)
78
+	{
79
+		$message_type = $item->message_type_obj();
80
+		$messenger    = $item->messenger_obj();
81
+
82
+		if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) {
83
+			echo '';
84
+			return;
85
+		}
86
+
87
+		parent::single_row($item);
88
+	}
89
+
90
+
91
+	/**
92
+	 * @return array
93
+	 */
94
+	protected function _get_table_filters()
95
+	{
96
+		$filters = array();
97
+
98
+		//get select inputs
99
+		$select_inputs = array(
100
+			$this->_get_messengers_dropdown_filter(),
101
+			$this->_get_message_types_dropdown_filter(),
102
+		);
103
+
104
+		//set filters to select inputs if they aren't empty
105
+		foreach ($select_inputs as $select_input) {
106
+			if ($select_input) {
107
+				$filters[] = $select_input;
108
+			}
109
+		}
110
+		return $filters;
111
+	}
112
+
113
+	/**
114
+	 * we're just removing the search box for message templates, not needed.
115
+	 *
116
+	 * @return string (empty);
117
+	 */
118
+	function search_box($text, $input_id)
119
+	{
120
+		return '';
121
+	}
122
+
123
+
124
+	/**
125
+	 * Add counts to the _views property
126
+	 */
127
+	protected function _add_view_counts()
128
+	{
129
+		foreach ($this->_views as $view => $args) {
130
+			$this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates(
131
+				$this->_per_page,
132
+				$view,
133
+				true,
134
+				true
135
+			);
136
+		}
137
+	}
138
+
139
+
140
+	/**
141
+	 * @param EE_Message_Template_Group $item
142
+	 * @return string
143
+	 */
144
+	public function column_cb($item)
145
+	{
146
+		return '';
147
+	}
148
+
149
+
150
+	/**
151
+	 * @param EE_Message_Template_Group $item
152
+	 * @return string
153
+	 */
154
+	function column_description($item)
155
+	{
156
+		return '<p>' . $item->message_type_obj()->description . '</p>';
157
+	}
158
+
159
+
160
+	/**
161
+	 * @param EE_Message_Template_Group $item
162
+	 * @return string
163
+	 */
164
+	function column_messenger($item)
165
+	{
166
+		//Build row actions
167
+		$actions = array();
168
+
169
+		// edit link but only if item isn't trashed.
170
+		if (! $item->get('MTP_deleted')
171
+			&& EE_Registry::instance()->CAP->current_user_can(
172
+				'ee_edit_message',
173
+				'espresso_messages_edit_message_template',
174
+				$item->ID()
175
+			)) {
176
+			$edit_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
177
+				array(
178
+					'action' => 'edit_message_template',
179
+					'id'     => $item->GRP_ID(),
180
+				),
181
+				EE_MSG_ADMIN_URL
182
+			);
183
+			$actions['edit'] = '<a href="' . $edit_lnk_url . '"'
184
+							   . ' class="' . $item->message_type() . '-edit-link"'
185
+							   . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">'
186
+							   . esc_html__('Edit', 'event_espresso')
187
+							   . '</a>';
188
+		}
189
+
190
+		$name_link = ! $item->get('MTP_deleted')
191
+					 && EE_Registry::instance()->CAP->current_user_can(
192
+						 'ee_edit_message',
193
+						 'espresso_messages_edit_message_template',
194
+						 $item->ID()
195
+					 )
196
+			? '<a href="' . $edit_lnk_url . '"'
197
+			  . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">'
198
+			  . ucwords($item->messenger_obj()->label['singular'])
199
+			  . '</a>'
200
+			: ucwords($item->messenger_obj()->label['singular']);
201
+
202
+		//we want to display the contexts in here so we need to set them up
203
+		$c_label           = $item->context_label();
204
+		$c_configs         = $item->contexts_config();
205
+		$ctxt              = array();
206
+		$context_templates = $item->context_templates();
207
+		foreach ($context_templates as $context => $template_fields) {
208
+			$mtp_to        = ! empty($context_templates[$context]['to'])
209
+							 && $context_templates[$context]['to'] instanceof EE_Message_Template
210
+				? $context_templates[$context]['to']->get('MTP_content')
211
+				: null;
212
+			$inactive      = empty($mtp_to)
213
+							 && ! empty($context_templates[$context]['to'])
214
+				? ' class="mtp-inactive"'
215
+				: '';
216
+			$context_title = ucwords($c_configs[$context]['label']);
217
+			$edit_link     = EE_Admin_Page::add_query_args_and_nonce(array('action'  => 'edit_message_template',
218
+																		   'id'      => $item->GRP_ID(),
219
+																		   'context' => $context,
220
+			), EE_MSG_ADMIN_URL);
221
+			$ctxt[]        = EE_Registry::instance()->CAP->current_user_can(
222
+				'ee_edit_message',
223
+				'espresso_messages_edit_message_template',
224
+				$item->ID()
225
+			)
226
+				? '<a' . $inactive
227
+				  . ' href="' . $edit_link . '"'
228
+				  . ' class="' . $item->message_type() . '-' . $context . '-edit-link"'
229
+				  . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">'
230
+				  . $context_title
231
+				  . '</a>'
232
+				: $context_title;
233
+		}
234
+
235
+		$ctx_content = ! $item->get('MTP_deleted')
236
+					   && EE_Registry::instance()->CAP->current_user_can(
237
+						   'ee_edit_message',
238
+						   'espresso_messages_edit_message_template',
239
+						   $item->ID()
240
+					   )
241
+			? sprintf(
242
+				'<strong>%s:</strong> ',
243
+				ucwords($c_label['plural'])
244
+			)
245
+			  . implode(' | ', $ctxt)
246
+			: '';
247
+
248
+
249
+		//Return the name contents
250
+		return sprintf(
251
+			'%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s',
252
+			/* $1%s */
253
+			$name_link,
254
+			/* $2%s */
255
+			$item->GRP_ID(),
256
+			/* %4$s */
257
+			$ctx_content,
258
+			/* $3%s */
259
+			$this->row_actions($actions)
260
+		);
261
+	}
262
+
263
+	/**
264
+	 * column_message_type
265
+	 *
266
+	 * @param  EE_Message_Template_Group  $item message info for the row
267
+	 * @return string       message_type name
268
+	 */
269
+	function column_message_type($item)
270
+	{
271
+		return ucwords($item->message_type_obj()->label['singular']);
272
+	}
273
+
274
+
275
+
276
+	/**
277
+	 * Generate dropdown filter select input for messengers
278
+	 *
279
+	 * @return string
280
+	 */
281
+	protected function _get_messengers_dropdown_filter()
282
+	{
283
+		$messenger_options                                   = array();
284
+		$active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all(
285
+			array(
286
+				array(
287
+					'MTP_is_active' => true,
288
+					'MTP_is_global' => true,
289
+				),
290
+				'group_by' => 'MTP_messenger',
291
+			)
292
+		);
293
+
294
+		foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) {
295
+			if ($active_message_template_group instanceof EE_Message_Template_Group) {
296
+				$messenger                                                      = $active_message_template_group->messenger_obj();
297
+				$messenger_label                                                = $messenger instanceof EE_messenger
298
+					? $messenger->label['singular']
299
+					: $active_message_template_group->messenger();
300
+				$messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label);
301
+			}
302
+		}
303
+		return $this->get_admin_page()->get_messengers_select_input($messenger_options);
304
+	}
305
+
306
+
307
+	/**
308
+	 * Generate dropdown filter select input for message types
309
+	 *
310
+	 * @return string
311
+	 */
312
+	protected function _get_message_types_dropdown_filter()
313
+	{
314
+		$message_type_options                                   = array();
315
+		$active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all(
316
+			array(
317
+				array(
318
+					'MTP_is_active' => true,
319
+					'MTP_is_global' => true,
320
+				),
321
+				'group_by' => 'MTP_message_type',
322
+			)
323
+		);
324
+
325
+		foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) {
326
+			if ($active_message_template_group instanceof EE_Message_Template_Group) {
327
+				$message_type                                                         = $active_message_template_group->message_type_obj();
328
+				$message_type_label                                                   = $message_type instanceof EE_message_type
329
+					? $message_type->label['singular']
330
+					: $active_message_template_group->message_type();
331
+				$message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label);
332
+			}
333
+		}
334
+		return $this->get_admin_page()->get_message_types_select_input($message_type_options);
335
+	}
336 336
 
337 337
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      */
28 28
     protected function _setup_data()
29 29
     {
30
-        $this->_data           = $this->get_admin_page()->get_message_templates(
30
+        $this->_data = $this->get_admin_page()->get_message_templates(
31 31
             $this->_per_page,
32 32
             $this->_view,
33 33
             false
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             'ajax'     => true, //for now,
53 53
             'screen'   => $this->get_admin_page()->get_current_screen()->id,
54 54
         );
55
-        $this->_columns      = array(
55
+        $this->_columns = array(
56 56
             //'cb' => '<input type="checkbox" />', //no deleting default (global) templates!
57 57
             'message_type' => esc_html__('Message Type', 'event_espresso'),
58 58
             'messenger'    => esc_html__('Messenger', 'event_espresso'),
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         $message_type = $item->message_type_obj();
80 80
         $messenger    = $item->messenger_obj();
81 81
 
82
-        if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) {
82
+        if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) {
83 83
             echo '';
84 84
             return;
85 85
         }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      */
154 154
     function column_description($item)
155 155
     {
156
-        return '<p>' . $item->message_type_obj()->description . '</p>';
156
+        return '<p>'.$item->message_type_obj()->description.'</p>';
157 157
     }
158 158
 
159 159
 
@@ -167,22 +167,22 @@  discard block
 block discarded – undo
167 167
         $actions = array();
168 168
 
169 169
         // edit link but only if item isn't trashed.
170
-        if (! $item->get('MTP_deleted')
170
+        if ( ! $item->get('MTP_deleted')
171 171
             && EE_Registry::instance()->CAP->current_user_can(
172 172
                 'ee_edit_message',
173 173
                 'espresso_messages_edit_message_template',
174 174
                 $item->ID()
175 175
             )) {
176
-            $edit_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
176
+            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
177 177
                 array(
178 178
                     'action' => 'edit_message_template',
179 179
                     'id'     => $item->GRP_ID(),
180 180
                 ),
181 181
                 EE_MSG_ADMIN_URL
182 182
             );
183
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '"'
184
-                               . ' class="' . $item->message_type() . '-edit-link"'
185
-                               . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">'
183
+            $actions['edit'] = '<a href="'.$edit_lnk_url.'"'
184
+                               . ' class="'.$item->message_type().'-edit-link"'
185
+                               . ' title="'.esc_attr__('Edit Template Group', 'event_espresso').'">'
186 186
                                . esc_html__('Edit', 'event_espresso')
187 187
                                . '</a>';
188 188
         }
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
                          'espresso_messages_edit_message_template',
194 194
                          $item->ID()
195 195
                      )
196
-            ? '<a href="' . $edit_lnk_url . '"'
197
-              . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">'
196
+            ? '<a href="'.$edit_lnk_url.'"'
197
+              . ' title="'.esc_attr__('Edit Template Group', 'event_espresso').'">'
198 198
               . ucwords($item->messenger_obj()->label['singular'])
199 199
               . '</a>'
200 200
             : ucwords($item->messenger_obj()->label['singular']);
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
                              && $context_templates[$context]['to'] instanceof EE_Message_Template
210 210
                 ? $context_templates[$context]['to']->get('MTP_content')
211 211
                 : null;
212
-            $inactive      = empty($mtp_to)
212
+            $inactive = empty($mtp_to)
213 213
                              && ! empty($context_templates[$context]['to'])
214 214
                 ? ' class="mtp-inactive"'
215 215
                 : '';
@@ -218,15 +218,15 @@  discard block
 block discarded – undo
218 218
                                                                            'id'      => $item->GRP_ID(),
219 219
                                                                            'context' => $context,
220 220
             ), EE_MSG_ADMIN_URL);
221
-            $ctxt[]        = EE_Registry::instance()->CAP->current_user_can(
221
+            $ctxt[] = EE_Registry::instance()->CAP->current_user_can(
222 222
                 'ee_edit_message',
223 223
                 'espresso_messages_edit_message_template',
224 224
                 $item->ID()
225 225
             )
226
-                ? '<a' . $inactive
227
-                  . ' href="' . $edit_link . '"'
228
-                  . ' class="' . $item->message_type() . '-' . $context . '-edit-link"'
229
-                  . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">'
226
+                ? '<a'.$inactive
227
+                  . ' href="'.$edit_link.'"'
228
+                  . ' class="'.$item->message_type().'-'.$context.'-edit-link"'
229
+                  . ' title="'.esc_attr__('Edit Context', 'event_espresso').'">'
230 230
                   . $context_title
231 231
                   . '</a>'
232 232
                 : $context_title;
Please login to merge, or discard this patch.