Completed
Branch BUG-10236-FIX-RESET-CAPABILITI... (cbd980)
by
unknown
26:22 queued 14:04
created
core/EE_Config.core.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
      * @param    string         $name
492 492
      * @param    string         $config_class
493 493
      * @param    EE_Config_Base $config_obj
494
-     * @param    array          $tests_to_run
494
+     * @param    integer[]          $tests_to_run
495 495
      * @param    bool           $display_errors
496 496
      * @return    bool    TRUE on success, FALSE on fail
497 497
      */
@@ -1794,7 +1794,7 @@  discard block
 block discarded – undo
1794 1794
 
1795 1795
 
1796 1796
     /**
1797
-     * @return array
1797
+     * @return integer[]
1798 1798
      */
1799 1799
     public function get_critical_pages_array()
1800 1800
     {
@@ -1808,7 +1808,7 @@  discard block
 block discarded – undo
1808 1808
 
1809 1809
 
1810 1810
     /**
1811
-     * @return array
1811
+     * @return string[]
1812 1812
      */
1813 1813
     public function get_critical_pages_shortcodes_array()
1814 1814
     {
@@ -3088,7 +3088,7 @@  discard block
 block discarded – undo
3088 3088
      * according to max_input_vars
3089 3089
      *
3090 3090
      * @param int   $input_count the count of input vars.
3091
-     * @return array {
3091
+     * @return string {
3092 3092
      *                           An array that represents whether available space and if no available space the error
3093 3093
      *                           message.
3094 3094
      * @type bool   $has_space   whether more inputs can be added.
Please login to merge, or discard this patch.
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.
core/libraries/iframe_display/IframeEmbedButton.php 2 patches
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -16,282 +16,282 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * @var string $iframe_name
21
-     */
22
-    private $iframe_name;
23
-
24
-    /**
25
-     * @var string $route_name
26
-     */
27
-    private $route_name;
28
-
29
-    /**
30
-     * @var string $slug
31
-     */
32
-    private $slug;
33
-
34
-    /**
35
-     * @var boolean $append_filterable_content
36
-     */
37
-    private $append_filterable_content;
38
-
39
-
40
-
41
-    /**
42
-     * IframeEmbedButton constructor.
43
-     *
44
-     * @param string $iframe_name i18n name for the iframe. This will be used in HTML
45
-     * @param string $route_name  the name of the registered route
46
-     * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
47
-     *                            will most likely be "event" since that's the only usage atm
48
-     */
49
-    public function __construct( $iframe_name, $route_name, $slug = 'event' )
50
-    {
51
-        $this->iframe_name = $iframe_name;
52
-        $this->route_name = $route_name;
53
-        $this->slug = $slug;
54
-    }
55
-
56
-
57
-
58
-    /**
59
-     * Adds an iframe embed code button to the Event editor.
60
-     */
61
-    public function addEventEditorIframeEmbedButtonFilter()
62
-    {
63
-        // add button for iframe code to event editor.
64
-        add_filter(
65
-            'get_sample_permalink_html',
66
-            array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ),
67
-            10,
68
-            2
69
-        );
70
-        add_action(
71
-            'admin_enqueue_scripts',
72
-            array( $this, 'embedButtonAssets' ),
73
-            10
74
-        );
75
-    }
76
-
77
-
78
-
79
-    /**
80
-     * @param $permalink_string
81
-     * @param $id
82
-     * @return string
83
-     */
84
-    public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id )
85
-    {
86
-        return $this->eventEditorIframeEmbedButton(
87
-            $permalink_string,
88
-            $id
89
-        );
90
-    }
91
-
92
-
93
-
94
-    /**
95
-     * iframe embed code button to the Event editor.
96
-     *
97
-     * @param string $permalink_string
98
-     * @param int    $id
99
-     * @return string
100
-     */
101
-    public function eventEditorIframeEmbedButton(
102
-        $permalink_string,
103
-        $id
104
-    ) {
105
-        //make sure this is ONLY when editing and the event id has been set.
106
-        if ( ! empty( $id ) ) {
107
-            $post = get_post( $id );
108
-            //if NOT event then let's get out.
109
-            if ( $post->post_type !== 'espresso_events' ) {
110
-                return $permalink_string;
111
-            }
112
-            $permalink_string .= $this->embedButtonHtml(
113
-                array( $this->slug => $id ),
114
-                'button-small'
115
-            );
116
-        }
117
-        return $permalink_string;
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * Adds an iframe embed code button via a WP do_action() as determined by the first parameter
124
-     *
125
-     * @param string $action name of the WP do_action() to hook into
126
-     */
127
-    public function addActionIframeEmbedButton( $action )
128
-    {
129
-        // add button for iframe code to event editor.
130
-        add_action(
131
-            $action,
132
-            array( $this, 'addActionIframeEmbedButtonCallback' ),
133
-            10, 2
134
-        );
135
-    }
136
-
137
-
138
-
139
-    /**
140
-     * @return void
141
-     */
142
-    public function addActionIframeEmbedButtonCallback()
143
-    {
144
-        echo $this->embedButtonHtml();
145
-    }
146
-
147
-
148
-
149
-    /**
150
-     * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter
151
-     *
152
-     * @param string $filter     name of the WP apply_filters() to hook into
153
-     * @param bool   $append     if true, will add iframe embed button to end of content,
154
-     *                           else if false, will add to the beginning of the content
155
-     */
156
-    public function addFilterIframeEmbedButton( $filter, $append = true )
157
-    {
158
-        $this->append_filterable_content = $append;
159
-        // add button for iframe code to event editor.
160
-        add_filter(
161
-            $filter,
162
-            array( $this, 'addFilterIframeEmbedButtonCallback' ),
163
-            10
164
-        );
165
-    }
166
-
167
-
168
-
169
-    /**
170
-     * @param array|string $filterable_content
171
-     * @return array|string
172
-     */
173
-    public function addFilterIframeEmbedButtonCallback( $filterable_content )
174
-    {
175
-        $embedButtonHtml = $this->embedButtonHtml();
176
-        if ( is_array( $filterable_content ) ) {
177
-            $filterable_content = $this->append_filterable_content
178
-                ? $filterable_content + array( $this->route_name => $embedButtonHtml )
179
-                : array( $this->route_name => $embedButtonHtml ) + $filterable_content;
180
-        } else {
181
-            $filterable_content = $this->append_filterable_content
182
-                ? $filterable_content . $embedButtonHtml
183
-                : $embedButtonHtml . $filterable_content;
184
-        }
185
-        return $filterable_content;
186
-    }
187
-
188
-
189
-
190
-    /**
191
-     * iframe_embed_html
192
-     *
193
-     * @param array  $query_args
194
-     * @param string $button_class
195
-     * @return string
196
-     */
197
-    public function embedButtonHtml( $query_args = array(), $button_class = '' )
198
-    {
199
-        // incoming args will replace the defaults listed here in the second array (union preserves first array)
200
-        $query_args = (array)$query_args + array( $this->route_name => 'iframe' );
201
-        $query_args = (array)apply_filters(
202
-            'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
203
-            $query_args
204
-        );
205
-        // add this route to our localized vars
206
-        $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] )
207
-            ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ]
208
-            : array();
209
-        $iframe_module_routes[ $this->route_name ] = $this->route_name;
210
-        \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes;
211
-        $iframe_embed_html = \EEH_HTML::link(
212
-            '#',
213
-            sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ),
214
-            sprintf(
215
-                esc_html__(
216
-                    'click here to generate code for embedding %1$s iframe into another site.',
217
-                    'event_espresso'
218
-                ),
219
-                \EEH_Inflector::add_indefinite_article( $this->iframe_name )
220
-            ),
221
-            "{$this->route_name}-iframe-embed-trigger-js",
222
-            'iframe-embed-trigger-js button ' . $button_class,
223
-            '',
224
-            ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"'
225
-        );
226
-        $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js',
227
-                                              'display:none;' );
228
-        $iframe_embed_html .= esc_html(
229
-            \EEH_HTML::div(
230
-                '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>',
231
-                '',
232
-                '',
233
-                'width:100%; height: 500px;'
234
-            )
235
-        );
236
-        $iframe_embed_html .= \EEH_HTML::divx();
237
-        return $iframe_embed_html;
238
-    }
239
-
240
-
241
-
242
-    /**
243
-     * enqueue iframe button js
244
-     */
245
-    public function embedButtonAssets()
246
-    {
247
-        \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__(
248
-            'copy and paste the following into any other site\'s content to display this event:',
249
-            'event_espresso'
250
-        );
251
-        \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__(
252
-            'click anywhere outside of this window to close it.',
253
-            'event_espresso'
254
-        );
255
-        wp_register_script(
256
-            'iframe_embed_button',
257
-            plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js',
258
-            array( 'ee-dialog' ),
259
-            EVENT_ESPRESSO_VERSION,
260
-            true
261
-        );
262
-        wp_enqueue_script( 'iframe_embed_button' );
263
-    }
264
-
265
-
266
-
267
-    /**
268
-     * generates embed button sections for admin pages
269
-     *
270
-     * @param array $embed_buttons
271
-     * @return string
272
-     */
273
-    public function addIframeEmbedButtonsSection( array $embed_buttons )
274
-    {
275
-        $embed_buttons = (array)apply_filters(
276
-            'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
277
-            $embed_buttons
278
-        );
279
-        if ( empty($embed_buttons)) {
280
-            return '';
281
-        }
282
-        // add button for iframe code to event editor.
283
-        $html = \EEH_HTML::br( 2 );
284
-        $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) );
285
-        $html .= \EEH_HTML::p(
286
-            esc_html__(
287
-                'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
288
-                'event_espresso'
289
-            )
290
-        );
291
-        $html .= ' &nbsp; ' . implode( ' &nbsp; ', $embed_buttons ) . ' ';
292
-        $html .= \EEH_HTML::br( 2 );
293
-        return $html;
294
-    }
19
+	/**
20
+	 * @var string $iframe_name
21
+	 */
22
+	private $iframe_name;
23
+
24
+	/**
25
+	 * @var string $route_name
26
+	 */
27
+	private $route_name;
28
+
29
+	/**
30
+	 * @var string $slug
31
+	 */
32
+	private $slug;
33
+
34
+	/**
35
+	 * @var boolean $append_filterable_content
36
+	 */
37
+	private $append_filterable_content;
38
+
39
+
40
+
41
+	/**
42
+	 * IframeEmbedButton constructor.
43
+	 *
44
+	 * @param string $iframe_name i18n name for the iframe. This will be used in HTML
45
+	 * @param string $route_name  the name of the registered route
46
+	 * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
47
+	 *                            will most likely be "event" since that's the only usage atm
48
+	 */
49
+	public function __construct( $iframe_name, $route_name, $slug = 'event' )
50
+	{
51
+		$this->iframe_name = $iframe_name;
52
+		$this->route_name = $route_name;
53
+		$this->slug = $slug;
54
+	}
55
+
56
+
57
+
58
+	/**
59
+	 * Adds an iframe embed code button to the Event editor.
60
+	 */
61
+	public function addEventEditorIframeEmbedButtonFilter()
62
+	{
63
+		// add button for iframe code to event editor.
64
+		add_filter(
65
+			'get_sample_permalink_html',
66
+			array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ),
67
+			10,
68
+			2
69
+		);
70
+		add_action(
71
+			'admin_enqueue_scripts',
72
+			array( $this, 'embedButtonAssets' ),
73
+			10
74
+		);
75
+	}
76
+
77
+
78
+
79
+	/**
80
+	 * @param $permalink_string
81
+	 * @param $id
82
+	 * @return string
83
+	 */
84
+	public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id )
85
+	{
86
+		return $this->eventEditorIframeEmbedButton(
87
+			$permalink_string,
88
+			$id
89
+		);
90
+	}
91
+
92
+
93
+
94
+	/**
95
+	 * iframe embed code button to the Event editor.
96
+	 *
97
+	 * @param string $permalink_string
98
+	 * @param int    $id
99
+	 * @return string
100
+	 */
101
+	public function eventEditorIframeEmbedButton(
102
+		$permalink_string,
103
+		$id
104
+	) {
105
+		//make sure this is ONLY when editing and the event id has been set.
106
+		if ( ! empty( $id ) ) {
107
+			$post = get_post( $id );
108
+			//if NOT event then let's get out.
109
+			if ( $post->post_type !== 'espresso_events' ) {
110
+				return $permalink_string;
111
+			}
112
+			$permalink_string .= $this->embedButtonHtml(
113
+				array( $this->slug => $id ),
114
+				'button-small'
115
+			);
116
+		}
117
+		return $permalink_string;
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * Adds an iframe embed code button via a WP do_action() as determined by the first parameter
124
+	 *
125
+	 * @param string $action name of the WP do_action() to hook into
126
+	 */
127
+	public function addActionIframeEmbedButton( $action )
128
+	{
129
+		// add button for iframe code to event editor.
130
+		add_action(
131
+			$action,
132
+			array( $this, 'addActionIframeEmbedButtonCallback' ),
133
+			10, 2
134
+		);
135
+	}
136
+
137
+
138
+
139
+	/**
140
+	 * @return void
141
+	 */
142
+	public function addActionIframeEmbedButtonCallback()
143
+	{
144
+		echo $this->embedButtonHtml();
145
+	}
146
+
147
+
148
+
149
+	/**
150
+	 * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter
151
+	 *
152
+	 * @param string $filter     name of the WP apply_filters() to hook into
153
+	 * @param bool   $append     if true, will add iframe embed button to end of content,
154
+	 *                           else if false, will add to the beginning of the content
155
+	 */
156
+	public function addFilterIframeEmbedButton( $filter, $append = true )
157
+	{
158
+		$this->append_filterable_content = $append;
159
+		// add button for iframe code to event editor.
160
+		add_filter(
161
+			$filter,
162
+			array( $this, 'addFilterIframeEmbedButtonCallback' ),
163
+			10
164
+		);
165
+	}
166
+
167
+
168
+
169
+	/**
170
+	 * @param array|string $filterable_content
171
+	 * @return array|string
172
+	 */
173
+	public function addFilterIframeEmbedButtonCallback( $filterable_content )
174
+	{
175
+		$embedButtonHtml = $this->embedButtonHtml();
176
+		if ( is_array( $filterable_content ) ) {
177
+			$filterable_content = $this->append_filterable_content
178
+				? $filterable_content + array( $this->route_name => $embedButtonHtml )
179
+				: array( $this->route_name => $embedButtonHtml ) + $filterable_content;
180
+		} else {
181
+			$filterable_content = $this->append_filterable_content
182
+				? $filterable_content . $embedButtonHtml
183
+				: $embedButtonHtml . $filterable_content;
184
+		}
185
+		return $filterable_content;
186
+	}
187
+
188
+
189
+
190
+	/**
191
+	 * iframe_embed_html
192
+	 *
193
+	 * @param array  $query_args
194
+	 * @param string $button_class
195
+	 * @return string
196
+	 */
197
+	public function embedButtonHtml( $query_args = array(), $button_class = '' )
198
+	{
199
+		// incoming args will replace the defaults listed here in the second array (union preserves first array)
200
+		$query_args = (array)$query_args + array( $this->route_name => 'iframe' );
201
+		$query_args = (array)apply_filters(
202
+			'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
203
+			$query_args
204
+		);
205
+		// add this route to our localized vars
206
+		$iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] )
207
+			? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ]
208
+			: array();
209
+		$iframe_module_routes[ $this->route_name ] = $this->route_name;
210
+		\EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes;
211
+		$iframe_embed_html = \EEH_HTML::link(
212
+			'#',
213
+			sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ),
214
+			sprintf(
215
+				esc_html__(
216
+					'click here to generate code for embedding %1$s iframe into another site.',
217
+					'event_espresso'
218
+				),
219
+				\EEH_Inflector::add_indefinite_article( $this->iframe_name )
220
+			),
221
+			"{$this->route_name}-iframe-embed-trigger-js",
222
+			'iframe-embed-trigger-js button ' . $button_class,
223
+			'',
224
+			' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"'
225
+		);
226
+		$iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js',
227
+											  'display:none;' );
228
+		$iframe_embed_html .= esc_html(
229
+			\EEH_HTML::div(
230
+				'<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>',
231
+				'',
232
+				'',
233
+				'width:100%; height: 500px;'
234
+			)
235
+		);
236
+		$iframe_embed_html .= \EEH_HTML::divx();
237
+		return $iframe_embed_html;
238
+	}
239
+
240
+
241
+
242
+	/**
243
+	 * enqueue iframe button js
244
+	 */
245
+	public function embedButtonAssets()
246
+	{
247
+		\EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__(
248
+			'copy and paste the following into any other site\'s content to display this event:',
249
+			'event_espresso'
250
+		);
251
+		\EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__(
252
+			'click anywhere outside of this window to close it.',
253
+			'event_espresso'
254
+		);
255
+		wp_register_script(
256
+			'iframe_embed_button',
257
+			plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js',
258
+			array( 'ee-dialog' ),
259
+			EVENT_ESPRESSO_VERSION,
260
+			true
261
+		);
262
+		wp_enqueue_script( 'iframe_embed_button' );
263
+	}
264
+
265
+
266
+
267
+	/**
268
+	 * generates embed button sections for admin pages
269
+	 *
270
+	 * @param array $embed_buttons
271
+	 * @return string
272
+	 */
273
+	public function addIframeEmbedButtonsSection( array $embed_buttons )
274
+	{
275
+		$embed_buttons = (array)apply_filters(
276
+			'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
277
+			$embed_buttons
278
+		);
279
+		if ( empty($embed_buttons)) {
280
+			return '';
281
+		}
282
+		// add button for iframe code to event editor.
283
+		$html = \EEH_HTML::br( 2 );
284
+		$html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) );
285
+		$html .= \EEH_HTML::p(
286
+			esc_html__(
287
+				'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
288
+				'event_espresso'
289
+			)
290
+		);
291
+		$html .= ' &nbsp; ' . implode( ' &nbsp; ', $embed_buttons ) . ' ';
292
+		$html .= \EEH_HTML::br( 2 );
293
+		return $html;
294
+	}
295 295
 
296 296
 
297 297
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\libraries\iframe_display;
3 3
 
4
-defined( 'ABSPATH' ) || exit;
4
+defined('ABSPATH') || exit;
5 5
 
6 6
 
7 7
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
47 47
      *                            will most likely be "event" since that's the only usage atm
48 48
      */
49
-    public function __construct( $iframe_name, $route_name, $slug = 'event' )
49
+    public function __construct($iframe_name, $route_name, $slug = 'event')
50 50
     {
51 51
         $this->iframe_name = $iframe_name;
52 52
         $this->route_name = $route_name;
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
         // add button for iframe code to event editor.
64 64
         add_filter(
65 65
             'get_sample_permalink_html',
66
-            array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ),
66
+            array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'),
67 67
             10,
68 68
             2
69 69
         );
70 70
         add_action(
71 71
             'admin_enqueue_scripts',
72
-            array( $this, 'embedButtonAssets' ),
72
+            array($this, 'embedButtonAssets'),
73 73
             10
74 74
         );
75 75
     }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      * @param $id
82 82
      * @return string
83 83
      */
84
-    public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id )
84
+    public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id)
85 85
     {
86 86
         return $this->eventEditorIframeEmbedButton(
87 87
             $permalink_string,
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
         $id
104 104
     ) {
105 105
         //make sure this is ONLY when editing and the event id has been set.
106
-        if ( ! empty( $id ) ) {
107
-            $post = get_post( $id );
106
+        if ( ! empty($id)) {
107
+            $post = get_post($id);
108 108
             //if NOT event then let's get out.
109
-            if ( $post->post_type !== 'espresso_events' ) {
109
+            if ($post->post_type !== 'espresso_events') {
110 110
                 return $permalink_string;
111 111
             }
112 112
             $permalink_string .= $this->embedButtonHtml(
113
-                array( $this->slug => $id ),
113
+                array($this->slug => $id),
114 114
                 'button-small'
115 115
             );
116 116
         }
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
      *
125 125
      * @param string $action name of the WP do_action() to hook into
126 126
      */
127
-    public function addActionIframeEmbedButton( $action )
127
+    public function addActionIframeEmbedButton($action)
128 128
     {
129 129
         // add button for iframe code to event editor.
130 130
         add_action(
131 131
             $action,
132
-            array( $this, 'addActionIframeEmbedButtonCallback' ),
132
+            array($this, 'addActionIframeEmbedButtonCallback'),
133 133
             10, 2
134 134
         );
135 135
     }
@@ -153,13 +153,13 @@  discard block
 block discarded – undo
153 153
      * @param bool   $append     if true, will add iframe embed button to end of content,
154 154
      *                           else if false, will add to the beginning of the content
155 155
      */
156
-    public function addFilterIframeEmbedButton( $filter, $append = true )
156
+    public function addFilterIframeEmbedButton($filter, $append = true)
157 157
     {
158 158
         $this->append_filterable_content = $append;
159 159
         // add button for iframe code to event editor.
160 160
         add_filter(
161 161
             $filter,
162
-            array( $this, 'addFilterIframeEmbedButtonCallback' ),
162
+            array($this, 'addFilterIframeEmbedButtonCallback'),
163 163
             10
164 164
         );
165 165
     }
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
      * @param array|string $filterable_content
171 171
      * @return array|string
172 172
      */
173
-    public function addFilterIframeEmbedButtonCallback( $filterable_content )
173
+    public function addFilterIframeEmbedButtonCallback($filterable_content)
174 174
     {
175 175
         $embedButtonHtml = $this->embedButtonHtml();
176
-        if ( is_array( $filterable_content ) ) {
176
+        if (is_array($filterable_content)) {
177 177
             $filterable_content = $this->append_filterable_content
178
-                ? $filterable_content + array( $this->route_name => $embedButtonHtml )
179
-                : array( $this->route_name => $embedButtonHtml ) + $filterable_content;
178
+                ? $filterable_content + array($this->route_name => $embedButtonHtml)
179
+                : array($this->route_name => $embedButtonHtml) + $filterable_content;
180 180
         } else {
181 181
             $filterable_content = $this->append_filterable_content
182
-                ? $filterable_content . $embedButtonHtml
183
-                : $embedButtonHtml . $filterable_content;
182
+                ? $filterable_content.$embedButtonHtml
183
+                : $embedButtonHtml.$filterable_content;
184 184
         }
185 185
         return $filterable_content;
186 186
     }
@@ -194,40 +194,40 @@  discard block
 block discarded – undo
194 194
      * @param string $button_class
195 195
      * @return string
196 196
      */
197
-    public function embedButtonHtml( $query_args = array(), $button_class = '' )
197
+    public function embedButtonHtml($query_args = array(), $button_class = '')
198 198
     {
199 199
         // incoming args will replace the defaults listed here in the second array (union preserves first array)
200
-        $query_args = (array)$query_args + array( $this->route_name => 'iframe' );
201
-        $query_args = (array)apply_filters(
200
+        $query_args = (array) $query_args + array($this->route_name => 'iframe');
201
+        $query_args = (array) apply_filters(
202 202
             'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
203 203
             $query_args
204 204
         );
205 205
         // add this route to our localized vars
206
-        $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] )
207
-            ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ]
206
+        $iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes'])
207
+            ? \EE_Registry::$i18n_js_strings['iframe_module_routes']
208 208
             : array();
209
-        $iframe_module_routes[ $this->route_name ] = $this->route_name;
210
-        \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes;
209
+        $iframe_module_routes[$this->route_name] = $this->route_name;
210
+        \EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes;
211 211
         $iframe_embed_html = \EEH_HTML::link(
212 212
             '#',
213
-            sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ),
213
+            sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name),
214 214
             sprintf(
215 215
                 esc_html__(
216 216
                     'click here to generate code for embedding %1$s iframe into another site.',
217 217
                     'event_espresso'
218 218
                 ),
219
-                \EEH_Inflector::add_indefinite_article( $this->iframe_name )
219
+                \EEH_Inflector::add_indefinite_article($this->iframe_name)
220 220
             ),
221 221
             "{$this->route_name}-iframe-embed-trigger-js",
222
-            'iframe-embed-trigger-js button ' . $button_class,
222
+            'iframe-embed-trigger-js button '.$button_class,
223 223
             '',
224
-            ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"'
224
+            ' data-iframe_embed_button="#'.$this->route_name.'-iframe-js" tabindex="-1"'
225 225
         );
226
-        $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js',
227
-                                              'display:none;' );
226
+        $iframe_embed_html .= \EEH_HTML::div('', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js',
227
+                                              'display:none;');
228 228
         $iframe_embed_html .= esc_html(
229 229
             \EEH_HTML::div(
230
-                '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>',
230
+                '<iframe src="'.add_query_arg($query_args, site_url()).'" width="100%" height="100%"></iframe>',
231 231
                 '',
232 232
                 '',
233 233
                 'width:100%; height: 500px;'
@@ -244,22 +244,22 @@  discard block
 block discarded – undo
244 244
      */
245 245
     public function embedButtonAssets()
246 246
     {
247
-        \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__(
247
+        \EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__(
248 248
             'copy and paste the following into any other site\'s content to display this event:',
249 249
             'event_espresso'
250 250
         );
251
-        \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__(
251
+        \EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__(
252 252
             'click anywhere outside of this window to close it.',
253 253
             'event_espresso'
254 254
         );
255 255
         wp_register_script(
256 256
             'iframe_embed_button',
257
-            plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js',
258
-            array( 'ee-dialog' ),
257
+            plugin_dir_url(__FILE__).'iframe-embed-button.js',
258
+            array('ee-dialog'),
259 259
             EVENT_ESPRESSO_VERSION,
260 260
             true
261 261
         );
262
-        wp_enqueue_script( 'iframe_embed_button' );
262
+        wp_enqueue_script('iframe_embed_button');
263 263
     }
264 264
 
265 265
 
@@ -270,26 +270,26 @@  discard block
 block discarded – undo
270 270
      * @param array $embed_buttons
271 271
      * @return string
272 272
      */
273
-    public function addIframeEmbedButtonsSection( array $embed_buttons )
273
+    public function addIframeEmbedButtonsSection(array $embed_buttons)
274 274
     {
275
-        $embed_buttons = (array)apply_filters(
275
+        $embed_buttons = (array) apply_filters(
276 276
             'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
277 277
             $embed_buttons
278 278
         );
279
-        if ( empty($embed_buttons)) {
279
+        if (empty($embed_buttons)) {
280 280
             return '';
281 281
         }
282 282
         // add button for iframe code to event editor.
283
-        $html = \EEH_HTML::br( 2 );
284
-        $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) );
283
+        $html = \EEH_HTML::br(2);
284
+        $html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso'));
285 285
         $html .= \EEH_HTML::p(
286 286
             esc_html__(
287 287
                 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
288 288
                 'event_espresso'
289 289
             )
290 290
         );
291
-        $html .= ' &nbsp; ' . implode( ' &nbsp; ', $embed_buttons ) . ' ';
292
-        $html .= \EEH_HTML::br( 2 );
291
+        $html .= ' &nbsp; '.implode(' &nbsp; ', $embed_buttons).' ';
292
+        $html .= \EEH_HTML::br(2);
293 293
         return $html;
294 294
     }
295 295
 
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorIframe.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\libraries\iframe_display\Iframe;
5 5
 
6 6
 if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-    exit( 'No direct script access allowed' );
7
+	exit( 'No direct script access allowed' );
8 8
 }
9 9
 
10 10
 
@@ -21,64 +21,64 @@  discard block
 block discarded – undo
21 21
 class TicketSelectorIframe extends Iframe
22 22
 {
23 23
 
24
-    /**
25
-     * TicketSelectorIframe constructor.
26
-     *
27
-     * @throws \DomainException
28
-     * @throws \EE_Error
29
-     */
30
-    public function __construct()
31
-    {
32
-        \EE_Registry::instance()->REQ->set_espresso_page( true );
33
-        /** @type \EEM_Event $EEM_Event */
34
-        $EEM_Event = \EE_Registry::instance()->load_model( 'Event' );
35
-        $event = $EEM_Event->get_one_by_ID(
36
-            \EE_Registry::instance()->REQ->get( 'event', 0 )
37
-        );
38
-        $ticket_selector = new DisplayTicketSelector();
39
-        $ticket_selector->setIframe( true );
40
-        parent::__construct(
41
-            esc_html__( 'Ticket Selector', 'event_espresso' ),
42
-            $ticket_selector->display( $event )
43
-        );
44
-        $this->addStylesheets(
45
-            apply_filters(
46
-                'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
47
-                array(
48
-                    'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL
49
-                                               . 'ticket_selector_embed.css?ver='
50
-                                               . EVENT_ESPRESSO_VERSION,
51
-                    'ticket_selector'       => TICKET_SELECTOR_ASSETS_URL
52
-                                               . 'ticket_selector.css?ver='
53
-                                               . EVENT_ESPRESSO_VERSION,
54
-                ),
55
-                $this
56
-            )
57
-        );
58
-        if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) {
59
-            $this->addStylesheets( array('site_theme' => '' ) );
60
-        }
61
-        $this->addScripts(
62
-            apply_filters(
63
-                'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
64
-                array(
65
-                    'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL
66
-                                                      . 'ticket_selector_iframe_embed.js?ver='
67
-                                                      . EVENT_ESPRESSO_VERSION,
68
-                ),
69
-                $this
70
-            )
71
-        );
72
-        $this->addLocalizedVars(
73
-            array(
74
-                'ticket_selector_iframe' => true,
75
-                'EEDTicketSelectorMsg'   => __(
76
-                    'Please choose at least one ticket before continuing.',
77
-                    'event_espresso'
78
-                ),
79
-            )
80
-        );
81
-    }
24
+	/**
25
+	 * TicketSelectorIframe constructor.
26
+	 *
27
+	 * @throws \DomainException
28
+	 * @throws \EE_Error
29
+	 */
30
+	public function __construct()
31
+	{
32
+		\EE_Registry::instance()->REQ->set_espresso_page( true );
33
+		/** @type \EEM_Event $EEM_Event */
34
+		$EEM_Event = \EE_Registry::instance()->load_model( 'Event' );
35
+		$event = $EEM_Event->get_one_by_ID(
36
+			\EE_Registry::instance()->REQ->get( 'event', 0 )
37
+		);
38
+		$ticket_selector = new DisplayTicketSelector();
39
+		$ticket_selector->setIframe( true );
40
+		parent::__construct(
41
+			esc_html__( 'Ticket Selector', 'event_espresso' ),
42
+			$ticket_selector->display( $event )
43
+		);
44
+		$this->addStylesheets(
45
+			apply_filters(
46
+				'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
47
+				array(
48
+					'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL
49
+											   . 'ticket_selector_embed.css?ver='
50
+											   . EVENT_ESPRESSO_VERSION,
51
+					'ticket_selector'       => TICKET_SELECTOR_ASSETS_URL
52
+											   . 'ticket_selector.css?ver='
53
+											   . EVENT_ESPRESSO_VERSION,
54
+				),
55
+				$this
56
+			)
57
+		);
58
+		if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) {
59
+			$this->addStylesheets( array('site_theme' => '' ) );
60
+		}
61
+		$this->addScripts(
62
+			apply_filters(
63
+				'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
64
+				array(
65
+					'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL
66
+													  . 'ticket_selector_iframe_embed.js?ver='
67
+													  . EVENT_ESPRESSO_VERSION,
68
+				),
69
+				$this
70
+			)
71
+		);
72
+		$this->addLocalizedVars(
73
+			array(
74
+				'ticket_selector_iframe' => true,
75
+				'EEDTicketSelectorMsg'   => __(
76
+					'Please choose at least one ticket before continuing.',
77
+					'event_espresso'
78
+				),
79
+			)
80
+		);
81
+	}
82 82
 
83 83
 }
84 84
 // End of file TicketSelectorIframe.php
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 
4 4
 use EventEspresso\core\libraries\iframe_display\Iframe;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-    exit( 'No direct script access allowed' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
+    exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public function __construct()
31 31
     {
32
-        \EE_Registry::instance()->REQ->set_espresso_page( true );
32
+        \EE_Registry::instance()->REQ->set_espresso_page(true);
33 33
         /** @type \EEM_Event $EEM_Event */
34
-        $EEM_Event = \EE_Registry::instance()->load_model( 'Event' );
34
+        $EEM_Event = \EE_Registry::instance()->load_model('Event');
35 35
         $event = $EEM_Event->get_one_by_ID(
36
-            \EE_Registry::instance()->REQ->get( 'event', 0 )
36
+            \EE_Registry::instance()->REQ->get('event', 0)
37 37
         );
38 38
         $ticket_selector = new DisplayTicketSelector();
39
-        $ticket_selector->setIframe( true );
39
+        $ticket_selector->setIframe(true);
40 40
         parent::__construct(
41
-            esc_html__( 'Ticket Selector', 'event_espresso' ),
42
-            $ticket_selector->display( $event )
41
+            esc_html__('Ticket Selector', 'event_espresso'),
42
+            $ticket_selector->display($event)
43 43
         );
44 44
         $this->addStylesheets(
45 45
             apply_filters(
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             )
57 57
         );
58 58
         if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) {
59
-            $this->addStylesheets( array('site_theme' => '' ) );
59
+            $this->addStylesheets(array('site_theme' => ''));
60 60
         }
61 61
         $this->addScripts(
62 62
             apply_filters(
Please login to merge, or discard this patch.
display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php 2 patches
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -17,151 +17,151 @@  discard block
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * enqueues css and js, so that this can be called statically
22
-     */
23
-    public static function enqueue_styles_and_scripts()
24
-    {
25
-        wp_register_style(
26
-            'checkbox_dropdown_selector',
27
-            EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css',
28
-            array('espresso_default'),
29
-            EVENT_ESPRESSO_VERSION
30
-        );
31
-        wp_enqueue_style('checkbox_dropdown_selector');
32
-        wp_register_script(
33
-            'checkbox_dropdown_selector',
34
-            EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js',
35
-            array('jquery'),
36
-            EVENT_ESPRESSO_VERSION,
37
-            true
38
-        );
39
-        wp_enqueue_script('checkbox_dropdown_selector');
40
-    }
41
-
42
-
43
-
44
-    /**
45
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
46
-     */
47
-    public function enqueue_js(){
48
-        EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
49
-    }
50
-
51
-
52
-
53
-    /**
54
-     * callback for Iframe::addStylesheets() child class methods
55
-     *
56
-     * @param array $iframe_css
57
-     * @return array
58
-     */
59
-    public function iframe_css(array $iframe_css){
60
-        $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css';
61
-        return $iframe_css;
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * callback for Iframe::addScripts() child class methods
68
-     *
69
-     * @param array $iframe_js
70
-     * @return array
71
-     */
72
-    public function iframe_js(array $iframe_js){
73
-        $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js';
74
-        return $iframe_js;
75
-    }
76
-
77
-
78
-    /**
79
-     * @throws EE_Error
80
-     * @return string of html to display the field
81
-     */
82
-    public function display()
83
-    {
84
-        $input = $this->get_input();
85
-        $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : '';
86
-        // $multi = count( $input->options() ) > 1 ? TRUE : FALSE;
87
-        $input->set_label_sizes();
88
-        $label_size_class = $input->get_label_size_class();
89
-        if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) {
90
-            EE_Error::doing_it_wrong(
91
-                'EE_Checkbox_Display_Strategy::display()',
92
-                sprintf(
93
-                    esc_html__(
94
-                        'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"',
95
-                        'event_espresso'
96
-                    ),
97
-                    $input->html_id(),
98
-                    var_export($input->raw_value(), true),
99
-                    $input->html_name() . '[]'
100
-                ),
101
-                '4.8.1'
102
-            );
103
-        }
104
-
105
-
106
-        $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv');
107
-        $html .= '<button id="' . $input->html_id() . '-btn"';
108
-        // $html .= ' name="' . $input->html_name() . '"';
109
-        $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"';
110
-        $html .= ' style="' . $input->html_style() . '"';
111
-        $html .= ' data-target="' . $input->html_id() . '-options-dv"';
112
-        $html .= ' ' . $input->html_other_attributes() . '>';
113
-        $html .= '<span class="checkbox-dropdown-selector-selected-spn">';
114
-        $html .= $select_button_text;
115
-        $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>';
116
-        $html .= '</button>';
117
-        $html .= EEH_HTML::div(
118
-            '',
119
-            $input->html_id() . '-options-dv',
120
-            'checkbox-dropdown-selector'
121
-        );
122
-        $html .= EEH_HTML::link(
123
-            '',
124
-            '<span class="dashicons dashicons-no"></span>',
125
-            esc_html__('close datetime selector', 'event_espresso'),
126
-            '',
127
-            'close-espresso-notice'
128
-        );
129
-        $html .= EEH_HTML::ul();
130
-        $input_raw_value = (array)$input->raw_value();
131
-        foreach ($input->options() as $value => $display_text) {
132
-            $html .= EEH_HTML::li();
133
-            $value = $input->get_normalization_strategy()->unnormalize_one($value);
134
-            $html_id = $this->get_sub_input_id($value);
135
-            $html .= EEH_HTML::nl(0, 'checkbox');
136
-            $html .= '<label for="'
137
-                     . $html_id
138
-                     . '" id="'
139
-                     . $html_id
140
-                     . '-lbl" class="ee-checkbox-label-after'
141
-                     . $label_size_class
142
-                     . '">';
143
-            $html .= EEH_HTML::nl(1, 'checkbox');
144
-            $html .= '<input type="checkbox"';
145
-            $html .= ' name="' . $input->html_name() . '[]"';
146
-            $html .= ' id="' . $html_id . '"';
147
-            $html .= ' class="' . $input->html_class() . '-option"';
148
-            $html .= ' style="' . $input->html_style() . '"';
149
-            $html .= ' value="' . esc_attr($value) . '"';
150
-            $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
151
-                ? ' checked="checked"'
152
-                : '';
153
-            $html .= ' ' . $this->_input->other_html_attributes();
154
-            $html .= '>';
155
-            $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>';
156
-            $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
157
-            $html .= EEH_HTML::lix();
158
-        }
159
-        $html .= EEH_HTML::ulx();
160
-        $html .= EEH_HTML::divx();
161
-        $html .= EEH_HTML::divx();
162
-        $html .= \EEH_HTML::br();
163
-        return $html;
164
-    }
20
+	/**
21
+	 * enqueues css and js, so that this can be called statically
22
+	 */
23
+	public static function enqueue_styles_and_scripts()
24
+	{
25
+		wp_register_style(
26
+			'checkbox_dropdown_selector',
27
+			EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css',
28
+			array('espresso_default'),
29
+			EVENT_ESPRESSO_VERSION
30
+		);
31
+		wp_enqueue_style('checkbox_dropdown_selector');
32
+		wp_register_script(
33
+			'checkbox_dropdown_selector',
34
+			EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js',
35
+			array('jquery'),
36
+			EVENT_ESPRESSO_VERSION,
37
+			true
38
+		);
39
+		wp_enqueue_script('checkbox_dropdown_selector');
40
+	}
41
+
42
+
43
+
44
+	/**
45
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
46
+	 */
47
+	public function enqueue_js(){
48
+		EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
49
+	}
50
+
51
+
52
+
53
+	/**
54
+	 * callback for Iframe::addStylesheets() child class methods
55
+	 *
56
+	 * @param array $iframe_css
57
+	 * @return array
58
+	 */
59
+	public function iframe_css(array $iframe_css){
60
+		$iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css';
61
+		return $iframe_css;
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * callback for Iframe::addScripts() child class methods
68
+	 *
69
+	 * @param array $iframe_js
70
+	 * @return array
71
+	 */
72
+	public function iframe_js(array $iframe_js){
73
+		$iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js';
74
+		return $iframe_js;
75
+	}
76
+
77
+
78
+	/**
79
+	 * @throws EE_Error
80
+	 * @return string of html to display the field
81
+	 */
82
+	public function display()
83
+	{
84
+		$input = $this->get_input();
85
+		$select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : '';
86
+		// $multi = count( $input->options() ) > 1 ? TRUE : FALSE;
87
+		$input->set_label_sizes();
88
+		$label_size_class = $input->get_label_size_class();
89
+		if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) {
90
+			EE_Error::doing_it_wrong(
91
+				'EE_Checkbox_Display_Strategy::display()',
92
+				sprintf(
93
+					esc_html__(
94
+						'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"',
95
+						'event_espresso'
96
+					),
97
+					$input->html_id(),
98
+					var_export($input->raw_value(), true),
99
+					$input->html_name() . '[]'
100
+				),
101
+				'4.8.1'
102
+			);
103
+		}
104
+
105
+
106
+		$html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv');
107
+		$html .= '<button id="' . $input->html_id() . '-btn"';
108
+		// $html .= ' name="' . $input->html_name() . '"';
109
+		$html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"';
110
+		$html .= ' style="' . $input->html_style() . '"';
111
+		$html .= ' data-target="' . $input->html_id() . '-options-dv"';
112
+		$html .= ' ' . $input->html_other_attributes() . '>';
113
+		$html .= '<span class="checkbox-dropdown-selector-selected-spn">';
114
+		$html .= $select_button_text;
115
+		$html .= '</span> <span class="dashicons dashicons-arrow-down"></span>';
116
+		$html .= '</button>';
117
+		$html .= EEH_HTML::div(
118
+			'',
119
+			$input->html_id() . '-options-dv',
120
+			'checkbox-dropdown-selector'
121
+		);
122
+		$html .= EEH_HTML::link(
123
+			'',
124
+			'<span class="dashicons dashicons-no"></span>',
125
+			esc_html__('close datetime selector', 'event_espresso'),
126
+			'',
127
+			'close-espresso-notice'
128
+		);
129
+		$html .= EEH_HTML::ul();
130
+		$input_raw_value = (array)$input->raw_value();
131
+		foreach ($input->options() as $value => $display_text) {
132
+			$html .= EEH_HTML::li();
133
+			$value = $input->get_normalization_strategy()->unnormalize_one($value);
134
+			$html_id = $this->get_sub_input_id($value);
135
+			$html .= EEH_HTML::nl(0, 'checkbox');
136
+			$html .= '<label for="'
137
+					 . $html_id
138
+					 . '" id="'
139
+					 . $html_id
140
+					 . '-lbl" class="ee-checkbox-label-after'
141
+					 . $label_size_class
142
+					 . '">';
143
+			$html .= EEH_HTML::nl(1, 'checkbox');
144
+			$html .= '<input type="checkbox"';
145
+			$html .= ' name="' . $input->html_name() . '[]"';
146
+			$html .= ' id="' . $html_id . '"';
147
+			$html .= ' class="' . $input->html_class() . '-option"';
148
+			$html .= ' style="' . $input->html_style() . '"';
149
+			$html .= ' value="' . esc_attr($value) . '"';
150
+			$html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
151
+				? ' checked="checked"'
152
+				: '';
153
+			$html .= ' ' . $this->_input->other_html_attributes();
154
+			$html .= '>';
155
+			$html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>';
156
+			$html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
157
+			$html .= EEH_HTML::lix();
158
+		}
159
+		$html .= EEH_HTML::ulx();
160
+		$html .= EEH_HTML::divx();
161
+		$html .= EEH_HTML::divx();
162
+		$html .= \EEH_HTML::br();
163
+		return $html;
164
+	}
165 165
 
166 166
 
167 167
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
     {
25 25
         wp_register_style(
26 26
             'checkbox_dropdown_selector',
27
-            EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css',
27
+            EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css',
28 28
             array('espresso_default'),
29 29
             EVENT_ESPRESSO_VERSION
30 30
         );
31 31
         wp_enqueue_style('checkbox_dropdown_selector');
32 32
         wp_register_script(
33 33
             'checkbox_dropdown_selector',
34
-            EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js',
34
+            EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js',
35 35
             array('jquery'),
36 36
             EVENT_ESPRESSO_VERSION,
37 37
             true
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     /**
45 45
      * Informs the rest of the forms system what CSS and JS is needed to display the input
46 46
      */
47
-    public function enqueue_js(){
47
+    public function enqueue_js() {
48 48
         EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
49 49
     }
50 50
 
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
      * @param array $iframe_css
57 57
      * @return array
58 58
      */
59
-    public function iframe_css(array $iframe_css){
60
-        $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css';
59
+    public function iframe_css(array $iframe_css) {
60
+        $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css';
61 61
         return $iframe_css;
62 62
     }
63 63
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
      * @param array $iframe_js
70 70
      * @return array
71 71
      */
72
-    public function iframe_js(array $iframe_js){
73
-        $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js';
72
+    public function iframe_js(array $iframe_js) {
73
+        $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js';
74 74
         return $iframe_js;
75 75
     }
76 76
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
                     ),
97 97
                     $input->html_id(),
98 98
                     var_export($input->raw_value(), true),
99
-                    $input->html_name() . '[]'
99
+                    $input->html_name().'[]'
100 100
                 ),
101 101
                 '4.8.1'
102 102
             );
@@ -104,19 +104,19 @@  discard block
 block discarded – undo
104 104
 
105 105
 
106 106
         $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv');
107
-        $html .= '<button id="' . $input->html_id() . '-btn"';
107
+        $html .= '<button id="'.$input->html_id().'-btn"';
108 108
         // $html .= ' name="' . $input->html_name() . '"';
109
-        $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"';
110
-        $html .= ' style="' . $input->html_style() . '"';
111
-        $html .= ' data-target="' . $input->html_id() . '-options-dv"';
112
-        $html .= ' ' . $input->html_other_attributes() . '>';
109
+        $html .= ' class="'.$input->html_class().' checkbox-dropdown-selector-btn button-secondary button"';
110
+        $html .= ' style="'.$input->html_style().'"';
111
+        $html .= ' data-target="'.$input->html_id().'-options-dv"';
112
+        $html .= ' '.$input->html_other_attributes().'>';
113 113
         $html .= '<span class="checkbox-dropdown-selector-selected-spn">';
114 114
         $html .= $select_button_text;
115 115
         $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>';
116 116
         $html .= '</button>';
117 117
         $html .= EEH_HTML::div(
118 118
             '',
119
-            $input->html_id() . '-options-dv',
119
+            $input->html_id().'-options-dv',
120 120
             'checkbox-dropdown-selector'
121 121
         );
122 122
         $html .= EEH_HTML::link(
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             'close-espresso-notice'
128 128
         );
129 129
         $html .= EEH_HTML::ul();
130
-        $input_raw_value = (array)$input->raw_value();
130
+        $input_raw_value = (array) $input->raw_value();
131 131
         foreach ($input->options() as $value => $display_text) {
132 132
             $html .= EEH_HTML::li();
133 133
             $value = $input->get_normalization_strategy()->unnormalize_one($value);
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
                      . '">';
143 143
             $html .= EEH_HTML::nl(1, 'checkbox');
144 144
             $html .= '<input type="checkbox"';
145
-            $html .= ' name="' . $input->html_name() . '[]"';
146
-            $html .= ' id="' . $html_id . '"';
147
-            $html .= ' class="' . $input->html_class() . '-option"';
148
-            $html .= ' style="' . $input->html_style() . '"';
149
-            $html .= ' value="' . esc_attr($value) . '"';
145
+            $html .= ' name="'.$input->html_name().'[]"';
146
+            $html .= ' id="'.$html_id.'"';
147
+            $html .= ' class="'.$input->html_class().'-option"';
148
+            $html .= ' style="'.$input->html_style().'"';
149
+            $html .= ' value="'.esc_attr($value).'"';
150 150
             $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
151 151
                 ? ' checked="checked"'
152 152
                 : '';
153
-            $html .= ' ' . $this->_input->other_html_attributes();
153
+            $html .= ' '.$this->_input->other_html_attributes();
154 154
             $html .= '>';
155
-            $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>';
156
-            $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
155
+            $html .= '<span class="datetime-selector-option-text-spn">'.$display_text.'</span>';
156
+            $html .= EEH_HTML::nl(-1, 'checkbox').'</label>';
157 157
             $html .= EEH_HTML::lix();
158 158
         }
159 159
         $html .= EEH_HTML::ulx();
Please login to merge, or discard this patch.
core/db_models/EEM_Message.model.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             self::priority_low    => __('low', 'event_espresso'),
128 128
         );
129 129
 
130
-        $this->_fields          = array(
130
+        $this->_fields = array(
131 131
             'Message' => array(
132 132
                 'MSG_ID'             => new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')),
133 133
                 'MSG_token'          => new EE_Plain_Text_Field('MSG_token',
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
                         );
358 358
                         break;
359 359
                     default :
360
-                        $query_params[0]['AND**filter_by']['OR**filter_by_' . $request_key][$model_name . '.' . $request_key] = $request_value;
360
+                        $query_params[0]['AND**filter_by']['OR**filter_by_'.$request_key][$model_name.'.'.$request_key] = $request_value;
361 361
                         break;
362 362
                 }
363 363
             }
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
             //prepend to the last element of $label_parts an "and".
421 421
             if (count($label_parts) > 1) {
422 422
                 $label_parts_index_to_prepend               = count($label_parts) - 1;
423
-                $label_parts[$label_parts_index_to_prepend] = 'and' . $label_parts[$label_parts_index_to_prepend];
423
+                $label_parts[$label_parts_index_to_prepend] = 'and'.$label_parts[$label_parts_index_to_prepend];
424 424
             }
425 425
 
426 426
             $pretty_label .= sprintf(
@@ -541,13 +541,13 @@  discard block
 block discarded – undo
541 541
             )
542 542
         );
543 543
 
544
-        if(! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) {
544
+        if ( ! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) {
545 545
             global $wpdb;
546 546
             $number_deleted = $wpdb->query('
547 547
                 DELETE
548
-                FROM ' . $this->table() . '
548
+                FROM ' . $this->table().'
549 549
                 WHERE
550
-                    MSG_ID IN (' . implode(",", $message_ids_to_delete) . ')
550
+                    MSG_ID IN (' . implode(",", $message_ids_to_delete).')
551 551
             ');
552 552
         }
553 553
 
Please login to merge, or discard this patch.
Indentation   +542 added lines, -542 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 /**
@@ -12,556 +12,556 @@  discard block
 block discarded – undo
12 12
 class EEM_Message extends EEM_Base implements EEI_Query_Filter
13 13
 {
14 14
 
15
-    // private instance of the Message object
16
-    protected static $_instance = null;
15
+	// private instance of the Message object
16
+	protected static $_instance = null;
17 17
 
18 18
 
19
-    /**
20
-     * This priority indicates a message should be generated and sent ASAP
21
-     *
22
-     * @type int
23
-     */
24
-    const priority_high = 10;
19
+	/**
20
+	 * This priority indicates a message should be generated and sent ASAP
21
+	 *
22
+	 * @type int
23
+	 */
24
+	const priority_high = 10;
25 25
 
26 26
 
27
-    /**
28
-     * This priority indicates a message should be generated ASAP and queued for sending.
29
-     *
30
-     * @type
31
-     */
32
-    const priority_medium = 20;
33
-
34
-
35
-    /**
36
-     * This priority indicates a message should be queued for generating.
37
-     *
38
-     * @type int
39
-     */
40
-    const priority_low = 30;
41
-
42
-
43
-    /**
44
-     * indicates this message was sent at the time modified
45
-     */
46
-    const status_sent = 'MSN';
47
-
48
-
49
-    /**
50
-     * indicates this message is waiting to be sent
51
-     */
52
-    const status_idle = 'MID';
53
-
54
-
55
-    /**
56
-     * indicates an attempt was a made to send this message
57
-     * at the scheduled time, but it failed at the time modified.  This differs from MDO status in that it will ALWAYS
58
-     * appear to the end user.
59
-     */
60
-    const status_failed = 'MFL';
61
-
62
-
63
-    /**
64
-     * indicates the message has been flagged for resending (at the time modified).
65
-     */
66
-    const status_resend = 'MRS';
67
-
68
-
69
-    /**
70
-     * indicates the message has been flagged for generation but has not been generated yet.  Messages always start as
71
-     * this status when added to the queue.
72
-     */
73
-    const status_incomplete = 'MIC';
74
-
75
-
76
-    /**
77
-     * Indicates everything was generated fine for the message, however, the messenger was unable to send.
78
-     * This status means that its possible to retry sending the message.
79
-     */
80
-    const status_retry = 'MRT';
81
-
82
-
83
-    /**
84
-     * This is used for more informational messages that may not indicate anything is broken but still cannot be
85
-     * generated or sent correctly. An example of a message that would get flagged this way would be when a not
86
-     * approved message was queued for generation, but at time of generation, the attached registration(s) are
87
-     * approved. So the message queued for generation is no longer valid.  Messages for this status will only persist
88
-     * in the db and be viewable in the message activity list table when the messages system is in debug mode.
89
-     *
90
-     * @see EEM_Message::debug()
91
-     */
92
-    const status_debug_only = 'MDO';
93
-
94
-
95
-    /**
96
-     * This status is given to messages it is processed by the messenger send method.
97
-     * Messages with this status should rarely be seen in the Message List table, but if they are, that's usually
98
-     * indicative of a PHP timeout or memory limit issue.
99
-     */
100
-    const status_messenger_executing = 'MEX';
101
-
102
-
103
-    /**
104
-     *    Private constructor to prevent direct creation.
105
-     *
106
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and
107
-     *                         any incoming timezone data that gets saved).  Note this just sends the timezone info to
108
-     *                         the date time model field objects.  Default is null (and will be assumed using the set
109
-     *                         timezone in the 'timezone_string' wp option)
110
-     * @return EEM_Message
111
-     */
112
-    protected function __construct($timezone = null)
113
-    {
114
-        $this->singular_item = __('Message', 'event_espresso');
115
-        $this->plural_item   = __('Messages', 'event_espresso');
116
-
117
-        //used for token generator
118
-        EE_Registry::instance()->load_helper('URL');
119
-
120
-        $this->_tables = array(
121
-            'Message' => new EE_Primary_Table('esp_message', 'MSG_ID'),
122
-        );
123
-
124
-        $allowed_priority = array(
125
-            self::priority_high   => __('high', 'event_espresso'),
126
-            self::priority_medium => __('medium', 'event_espresso'),
127
-            self::priority_low    => __('low', 'event_espresso'),
128
-        );
129
-
130
-        $this->_fields          = array(
131
-            'Message' => array(
132
-                'MSG_ID'             => new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')),
133
-                'MSG_token'          => new EE_Plain_Text_Field('MSG_token',
134
-                    __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).',
135
-                        'event_espresso'), false, EEH_URL::generate_unique_token()),
136
-                'GRP_ID'             => new EE_Foreign_Key_Int_Field('GRP_ID',
137
-                    __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0,
138
-                    'Message_Template_Group'),
139
-                'TXN_ID'             => new EE_Foreign_Key_Int_Field('TXN_ID',
140
-                    __('Foreign key to the related EE_Transaction.  This is required to give context for regenerating the specific message',
141
-                        'event_espresso'), true, 0, 'Transaction'),
142
-                'MSG_messenger'      => new EE_Plain_Text_Field('MSG_messenger',
143
-                    __('Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.',
144
-                        'event_espresso'), false, 'email'),
145
-                'MSG_message_type'   => new EE_Plain_Text_Field('MSG_message_type',
146
-                    __('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'),
147
-                    false, 'receipt'),
148
-                'MSG_context'        => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false),
149
-                'MSG_recipient_ID'   => new EE_Foreign_Key_Int_Field('MSG_recipient_ID',
150
-                    __('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')),
151
-                'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type',
152
-                    __('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')),
153
-                'MSG_content'        => new EE_Maybe_Serialized_Text_Field('MSG_content',
154
-                    __('Content', 'event_espresso'), true, ''),
155
-                'MSG_to'             => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'),
156
-                    true),
157
-                'MSG_from'           => new EE_Maybe_Serialized_Text_Field('MSG_from',
158
-                    __('Address From', 'event_espresso'), true),
159
-                'MSG_subject'        => new EE_Maybe_Serialized_Text_Field('MSG_subject',
160
-                    __('Subject', 'event_espresso'), true, ''),
161
-                'MSG_priority'       => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'),
162
-                    false, self::priority_low, $allowed_priority),
163
-                'STS_ID'             => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false,
164
-                    self::status_incomplete, 'Status'),
165
-                'MSG_created'        => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false,
166
-                    EE_Datetime_Field::now),
167
-                'MSG_modified'       => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true,
168
-                    EE_Datetime_Field::now),
169
-            ),
170
-        );
171
-        $this->_model_relations = array(
172
-            'Attendee'               => new EE_Belongs_To_Any_Relation(),
173
-            'Registration'           => new EE_Belongs_To_Any_Relation(),
174
-            'WP_User'                => new EE_Belongs_To_Any_Relation(),
175
-            'Message_Template_Group' => new EE_Belongs_To_Relation(),
176
-            'Transaction'            => new EE_Belongs_To_Relation(),
177
-        );
178
-        parent::__construct($timezone);
179
-    }
180
-
181
-
182
-    /**
183
-     * @return \EE_Message
184
-     */
185
-    public function create_default_object()
186
-    {
187
-        /** @type EE_Message $message */
188
-        $message = parent::create_default_object();
189
-        if ($message instanceof EE_Message) {
190
-            return EE_Message_Factory::set_messenger_and_message_type($message);
191
-        }
192
-        return null;
193
-    }
194
-
195
-
196
-    /**
197
-     * @param mixed $cols_n_values
198
-     * @return \EE_Message
199
-     */
200
-    public function instantiate_class_from_array_or_object($cols_n_values)
201
-    {
202
-        /** @type EE_Message $message */
203
-        $message = parent::instantiate_class_from_array_or_object($cols_n_values);
204
-        if ($message instanceof EE_Message) {
205
-            return EE_Message_Factory::set_messenger_and_message_type($message);
206
-        }
207
-        return null;
208
-    }
209
-
210
-
211
-    /**
212
-     * Returns whether or not a message of that type was sent for a given attendee.
213
-     *
214
-     * @param EE_Attendee|int $attendee
215
-     * @param string          $message_type the message type slug
216
-     * @return boolean
217
-     */
218
-    public function message_sent_for_attendee($attendee, $message_type)
219
-    {
220
-        $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee);
221
-        return $this->exists(array(
222
-            array(
223
-                'Attendee.ATT_ID'  => $attendee_ID,
224
-                'MSG_message_type' => $message_type,
225
-                'STS_ID'           => array('IN', $this->stati_indicating_sent()),
226
-            ),
227
-        ));
228
-    }
229
-
230
-
231
-    /**
232
-     * Returns whether or not a message of that type was sent for a given registration
233
-     *
234
-     * @param EE_Registration|int $registration
235
-     * @param string              $message_type the message type slug
236
-     * @return boolean
237
-     */
238
-    public function message_sent_for_registration($registration, $message_type)
239
-    {
240
-        $registrationID = EEM_Registration::instance()->ensure_is_ID($registration);
241
-        return $this->exists(array(
242
-            array(
243
-                'Registration.REG_ID' => $registrationID,
244
-                'MSG_message_type'    => $message_type,
245
-                'STS_ID'              => array('IN', $this->stati_indicating_sent()),
246
-            ),
247
-        ));
248
-    }
249
-
250
-
251
-    /**
252
-     * This retrieves an EE_Message object from the db matching the given token string.
253
-     *
254
-     * @param string $token
255
-     * @return EE_Message
256
-     */
257
-    public function get_one_by_token($token)
258
-    {
259
-        return $this->get_one(array(
260
-            array(
261
-                'MSG_token' => $token,
262
-            ),
263
-        ));
264
-    }
265
-
266
-
267
-    /**
268
-     * Returns stati that indicate the message HAS been sent
269
-     *
270
-     * @return array of strings for possible stati
271
-     */
272
-    public function stati_indicating_sent()
273
-    {
274
-        return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent));
275
-    }
276
-
277
-
278
-    /**
279
-     * Returns stati that indicate the message is waiting to be sent.
280
-     *
281
-     * @return array of strings for possible stati.
282
-     */
283
-    public function stati_indicating_to_send()
284
-    {
285
-        return apply_filters('FHEE__EEM_Message__stati_indicating_to_send',
286
-            array(self::status_idle, self::status_resend));
287
-    }
288
-
289
-
290
-    /**
291
-     * Returns stati that indicate the message has failed sending
292
-     *
293
-     * @return array  array of strings for possible stati.
294
-     */
295
-    public function stati_indicating_failed_sending()
296
-    {
297
-        $failed_stati = array(
298
-            self::status_failed,
299
-            self::status_retry,
300
-            self::status_messenger_executing,
301
-        );
302
-        //if WP_DEBUG is set, then let's include debug_only fails
303
-        if (WP_DEBUG) {
304
-            $failed_stati[] = self::status_debug_only;
305
-        }
306
-        return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati);
307
-    }
308
-
309
-
310
-    /**
311
-     * Returns filterable array of all EEM_Message statuses.
312
-     *
313
-     * @return array
314
-     */
315
-    public function all_statuses()
316
-    {
317
-        return apply_filters(
318
-            'FHEE__EEM_Message__all_statuses',
319
-            array(
320
-                EEM_Message::status_sent,
321
-                EEM_Message::status_incomplete,
322
-                EEM_Message::status_idle,
323
-                EEM_Message::status_resend,
324
-                EEM_Message::status_retry,
325
-                EEM_Message::status_failed,
326
-                EEM_Message::status_messenger_executing,
327
-                EEM_Message::status_debug_only,
328
-            )
329
-        );
330
-    }
331
-
332
-    /**
333
-     * Detects any specific query variables in the request and uses those to setup appropriate
334
-     * filter for any queries.
335
-     *
336
-     * @return array
337
-     */
338
-    public function filter_by_query_params()
339
-    {
340
-        // expected possible query_vars, the key in this array matches an expected key in the request,
341
-        // the value, matches the corresponding EEM_Base child reference.
342
-        $expected_vars   = $this->_expected_vars_for_query_inject();
343
-        $query_params[0] = array();
344
-        foreach ($expected_vars as $request_key => $model_name) {
345
-            $request_value = EE_Registry::instance()->REQ->get($request_key);
346
-            if ($request_value) {
347
-                //special case
348
-                switch ($request_key) {
349
-                    case '_REG_ID' :
350
-                        $query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array(
351
-                            'Transaction.Registration.REG_ID' => $request_value,
352
-                        );
353
-                        break;
354
-                    case 'EVT_ID' :
355
-                        $query_params[0]['AND**filter_by']['OR**filter_by_EVT_ID'] = array(
356
-                            'Transaction.Registration.EVT_ID' => $request_value,
357
-                        );
358
-                        break;
359
-                    default :
360
-                        $query_params[0]['AND**filter_by']['OR**filter_by_' . $request_key][$model_name . '.' . $request_key] = $request_value;
361
-                        break;
362
-                }
363
-            }
364
-        }
365
-        return $query_params;
366
-    }
367
-
368
-
369
-    /**
370
-     * @return string
371
-     */
372
-    public function get_pretty_label_for_results()
373
-    {
374
-        $expected_vars = $this->_expected_vars_for_query_inject();
375
-        $pretty_label  = '';
376
-        $label_parts   = array();
377
-        foreach ($expected_vars as $request_key => $model_name) {
378
-            $model = EE_Registry::instance()->load_model($model_name);
379
-            if ($model_field_value = EE_Registry::instance()->REQ->get($request_key)) {
380
-                switch ($request_key) {
381
-                    case '_REG_ID' :
382
-                        $label_parts[] = sprintf(
383
-                            esc_html__('Registration with the ID: %s', 'event_espresso'),
384
-                            $model_field_value
385
-                        );
386
-                        break;
387
-                    case 'ATT_ID' :
388
-                        /** @var EE_Attendee $attendee */
389
-                        $attendee      = $model->get_one_by_ID($model_field_value);
390
-                        $label_parts[] = $attendee instanceof EE_Attendee
391
-                            ? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name())
392
-                            : sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value);
393
-                        break;
394
-                    case 'ID' :
395
-                        /** @var EE_WP_User $wpUser */
396
-                        $wpUser        = $model->get_one_by_ID($model_field_value);
397
-                        $label_parts[] = $wpUser instanceof EE_WP_User
398
-                            ? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name())
399
-                            : sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value);
400
-                        break;
401
-                    case 'TXN_ID' :
402
-                        $label_parts[] = sprintf(
403
-                            esc_html__('Transaction with the ID: %s', 'event_espresso'),
404
-                            $model_field_value
405
-                        );
406
-                        break;
407
-                    case 'EVT_ID' :
408
-                        /** @var EE_Event $Event */
409
-                        $Event         = $model->get_one_by_ID($model_field_value);
410
-                        $label_parts[] = $Event instanceof EE_Event
411
-                            ? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name())
412
-                            : sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value);
413
-                        break;
414
-                }
415
-            }
416
-        }
417
-
418
-        if ($label_parts) {
419
-
420
-            //prepend to the last element of $label_parts an "and".
421
-            if (count($label_parts) > 1) {
422
-                $label_parts_index_to_prepend               = count($label_parts) - 1;
423
-                $label_parts[$label_parts_index_to_prepend] = 'and' . $label_parts[$label_parts_index_to_prepend];
424
-            }
425
-
426
-            $pretty_label .= sprintf(
427
-                esc_html_x(
428
-                    'Showing messages for %s',
429
-                    'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.',
430
-                    'event_espresso'
431
-                ),
432
-                implode(', ', $label_parts)
433
-            );
434
-        }
435
-        return $pretty_label;
436
-    }
437
-
438
-
439
-    /**
440
-     * This returns the array of expected variables for the EEI_Query_Filter methods being implemented
441
-     * The array is in the format:
442
-     * array(
443
-     *  {$field_name} => {$model_name}
444
-     * );
445
-     *
446
-     * @since 4.9.0
447
-     * @return array
448
-     */
449
-    protected function _expected_vars_for_query_inject()
450
-    {
451
-        return array(
452
-            '_REG_ID' => 'Registration',
453
-            'ATT_ID'  => 'Attendee',
454
-            'ID'      => 'WP_User',
455
-            'TXN_ID'  => 'Transaction',
456
-            'EVT_ID'  => 'Event',
457
-        );
458
-    }
459
-
460
-
461
-    /**
462
-     * This returns whether EEM_Message is in debug mode or not.
463
-     * Currently "debug mode" is used to control the handling of the EEM_Message::debug_only status when
464
-     * generating/sending messages. Debug mode can be set by either:
465
-     * 1. Sending in a value for the $set_debug argument
466
-     * 2. Defining `EE_DEBUG_MESSAGES` constant in wp-config.php
467
-     * 3. Overriding the above via the provided filter.
468
-     *
469
-     * @param bool|null $set_debug      If provided, then the debug mode will be set internally until reset via the
470
-     *                                  provided boolean. When no argument is provided (default null) then the debug
471
-     *                                  mode will be returned.
472
-     * @return bool         true means Messages is in debug mode.  false means messages system is not in debug mode.
473
-     */
474
-    public static function debug($set_debug = null)
475
-    {
476
-        static $is_debugging = null;
477
-
478
-        //initialize (use constant if set).
479
-        if (is_null($set_debug) && is_null($is_debugging)) {
480
-            $is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES;
481
-        }
482
-
483
-        if ( ! is_null($set_debug)) {
484
-            $is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN);
485
-        }
486
-
487
-        //return filtered value
488
-        return apply_filters('FHEE__EEM_Message__debug', $is_debugging);
489
-    }
490
-
491
-
492
-    /**
493
-     * Deletes old messages meeting certain criteria for removal from the database.
494
-     * By default, this will delete messages that:
495
-     * - are older than the value of the delete_threshold in months.
496
-     * - have a STS_ID other than EEM_Message::status_idle
497
-     *
498
-     * @param int $delete_threshold  This integer will be used to set the boundary for what messages are deleted in months.
499
-     * @return bool|false|int Either the number of records affected or false if there was an error (you can call
500
-     *                         $wpdb->last_error to find out what the error was.
501
-     */
502
-    public function delete_old_messages($delete_threshold = 6)
503
-    {
504
-        $number_deleted = 0;
505
-        /**
506
-         * Allows code to change the boundary for what messages are kept.
507
-         * Uses the value of the `delete_threshold` variable by default.
508
-         *
509
-         * @param int $seconds seconds that will be subtracted from the timestamp for now.
510
-         * @return int
511
-         */
512
-        $time_to_leave_alone = absint(
513
-            apply_filters(
514
-                'FHEE__EEM_Message__delete_old_messages__time_to_leave_alone',
515
-                ((int) $delete_threshold) * MONTH_IN_SECONDS
516
-            )
517
-        );
518
-
519
-
520
-        /**
521
-         * Allows code to change what message stati are ignored when deleting.
522
-         * Defaults to only ignore EEM_Message::status_idle messages.
523
-         *
524
-         * @param string $message_stati_to_keep  An array of message statuses that will be ignored when deleting.
525
-         */
526
-        $message_stati_to_keep = (array) apply_filters(
527
-            'FHEE__EEM_Message__delete_old_messages__message_stati_to_keep',
528
-            array(
529
-                EEM_Message::status_idle
530
-            )
531
-        );
532
-
533
-        //first get all the ids of messages being deleted
534
-        $message_ids_to_delete = EEM_Message::instance()->get_col(
535
-            array(
536
-                0 => array(
537
-                    'STS_ID' => array('NOT_IN', $message_stati_to_keep),
538
-                    'MSG_modified' => array('<', time() - $time_to_leave_alone)
539
-                )
540
-            )
541
-        );
542
-
543
-        if(! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) {
544
-            global $wpdb;
545
-            $number_deleted = $wpdb->query('
27
+	/**
28
+	 * This priority indicates a message should be generated ASAP and queued for sending.
29
+	 *
30
+	 * @type
31
+	 */
32
+	const priority_medium = 20;
33
+
34
+
35
+	/**
36
+	 * This priority indicates a message should be queued for generating.
37
+	 *
38
+	 * @type int
39
+	 */
40
+	const priority_low = 30;
41
+
42
+
43
+	/**
44
+	 * indicates this message was sent at the time modified
45
+	 */
46
+	const status_sent = 'MSN';
47
+
48
+
49
+	/**
50
+	 * indicates this message is waiting to be sent
51
+	 */
52
+	const status_idle = 'MID';
53
+
54
+
55
+	/**
56
+	 * indicates an attempt was a made to send this message
57
+	 * at the scheduled time, but it failed at the time modified.  This differs from MDO status in that it will ALWAYS
58
+	 * appear to the end user.
59
+	 */
60
+	const status_failed = 'MFL';
61
+
62
+
63
+	/**
64
+	 * indicates the message has been flagged for resending (at the time modified).
65
+	 */
66
+	const status_resend = 'MRS';
67
+
68
+
69
+	/**
70
+	 * indicates the message has been flagged for generation but has not been generated yet.  Messages always start as
71
+	 * this status when added to the queue.
72
+	 */
73
+	const status_incomplete = 'MIC';
74
+
75
+
76
+	/**
77
+	 * Indicates everything was generated fine for the message, however, the messenger was unable to send.
78
+	 * This status means that its possible to retry sending the message.
79
+	 */
80
+	const status_retry = 'MRT';
81
+
82
+
83
+	/**
84
+	 * This is used for more informational messages that may not indicate anything is broken but still cannot be
85
+	 * generated or sent correctly. An example of a message that would get flagged this way would be when a not
86
+	 * approved message was queued for generation, but at time of generation, the attached registration(s) are
87
+	 * approved. So the message queued for generation is no longer valid.  Messages for this status will only persist
88
+	 * in the db and be viewable in the message activity list table when the messages system is in debug mode.
89
+	 *
90
+	 * @see EEM_Message::debug()
91
+	 */
92
+	const status_debug_only = 'MDO';
93
+
94
+
95
+	/**
96
+	 * This status is given to messages it is processed by the messenger send method.
97
+	 * Messages with this status should rarely be seen in the Message List table, but if they are, that's usually
98
+	 * indicative of a PHP timeout or memory limit issue.
99
+	 */
100
+	const status_messenger_executing = 'MEX';
101
+
102
+
103
+	/**
104
+	 *    Private constructor to prevent direct creation.
105
+	 *
106
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and
107
+	 *                         any incoming timezone data that gets saved).  Note this just sends the timezone info to
108
+	 *                         the date time model field objects.  Default is null (and will be assumed using the set
109
+	 *                         timezone in the 'timezone_string' wp option)
110
+	 * @return EEM_Message
111
+	 */
112
+	protected function __construct($timezone = null)
113
+	{
114
+		$this->singular_item = __('Message', 'event_espresso');
115
+		$this->plural_item   = __('Messages', 'event_espresso');
116
+
117
+		//used for token generator
118
+		EE_Registry::instance()->load_helper('URL');
119
+
120
+		$this->_tables = array(
121
+			'Message' => new EE_Primary_Table('esp_message', 'MSG_ID'),
122
+		);
123
+
124
+		$allowed_priority = array(
125
+			self::priority_high   => __('high', 'event_espresso'),
126
+			self::priority_medium => __('medium', 'event_espresso'),
127
+			self::priority_low    => __('low', 'event_espresso'),
128
+		);
129
+
130
+		$this->_fields          = array(
131
+			'Message' => array(
132
+				'MSG_ID'             => new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')),
133
+				'MSG_token'          => new EE_Plain_Text_Field('MSG_token',
134
+					__('Unique Token used to represent this row in publicly viewable contexts (eg. a url).',
135
+						'event_espresso'), false, EEH_URL::generate_unique_token()),
136
+				'GRP_ID'             => new EE_Foreign_Key_Int_Field('GRP_ID',
137
+					__('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0,
138
+					'Message_Template_Group'),
139
+				'TXN_ID'             => new EE_Foreign_Key_Int_Field('TXN_ID',
140
+					__('Foreign key to the related EE_Transaction.  This is required to give context for regenerating the specific message',
141
+						'event_espresso'), true, 0, 'Transaction'),
142
+				'MSG_messenger'      => new EE_Plain_Text_Field('MSG_messenger',
143
+					__('Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.',
144
+						'event_espresso'), false, 'email'),
145
+				'MSG_message_type'   => new EE_Plain_Text_Field('MSG_message_type',
146
+					__('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'),
147
+					false, 'receipt'),
148
+				'MSG_context'        => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false),
149
+				'MSG_recipient_ID'   => new EE_Foreign_Key_Int_Field('MSG_recipient_ID',
150
+					__('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')),
151
+				'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type',
152
+					__('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')),
153
+				'MSG_content'        => new EE_Maybe_Serialized_Text_Field('MSG_content',
154
+					__('Content', 'event_espresso'), true, ''),
155
+				'MSG_to'             => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'),
156
+					true),
157
+				'MSG_from'           => new EE_Maybe_Serialized_Text_Field('MSG_from',
158
+					__('Address From', 'event_espresso'), true),
159
+				'MSG_subject'        => new EE_Maybe_Serialized_Text_Field('MSG_subject',
160
+					__('Subject', 'event_espresso'), true, ''),
161
+				'MSG_priority'       => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'),
162
+					false, self::priority_low, $allowed_priority),
163
+				'STS_ID'             => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false,
164
+					self::status_incomplete, 'Status'),
165
+				'MSG_created'        => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false,
166
+					EE_Datetime_Field::now),
167
+				'MSG_modified'       => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true,
168
+					EE_Datetime_Field::now),
169
+			),
170
+		);
171
+		$this->_model_relations = array(
172
+			'Attendee'               => new EE_Belongs_To_Any_Relation(),
173
+			'Registration'           => new EE_Belongs_To_Any_Relation(),
174
+			'WP_User'                => new EE_Belongs_To_Any_Relation(),
175
+			'Message_Template_Group' => new EE_Belongs_To_Relation(),
176
+			'Transaction'            => new EE_Belongs_To_Relation(),
177
+		);
178
+		parent::__construct($timezone);
179
+	}
180
+
181
+
182
+	/**
183
+	 * @return \EE_Message
184
+	 */
185
+	public function create_default_object()
186
+	{
187
+		/** @type EE_Message $message */
188
+		$message = parent::create_default_object();
189
+		if ($message instanceof EE_Message) {
190
+			return EE_Message_Factory::set_messenger_and_message_type($message);
191
+		}
192
+		return null;
193
+	}
194
+
195
+
196
+	/**
197
+	 * @param mixed $cols_n_values
198
+	 * @return \EE_Message
199
+	 */
200
+	public function instantiate_class_from_array_or_object($cols_n_values)
201
+	{
202
+		/** @type EE_Message $message */
203
+		$message = parent::instantiate_class_from_array_or_object($cols_n_values);
204
+		if ($message instanceof EE_Message) {
205
+			return EE_Message_Factory::set_messenger_and_message_type($message);
206
+		}
207
+		return null;
208
+	}
209
+
210
+
211
+	/**
212
+	 * Returns whether or not a message of that type was sent for a given attendee.
213
+	 *
214
+	 * @param EE_Attendee|int $attendee
215
+	 * @param string          $message_type the message type slug
216
+	 * @return boolean
217
+	 */
218
+	public function message_sent_for_attendee($attendee, $message_type)
219
+	{
220
+		$attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee);
221
+		return $this->exists(array(
222
+			array(
223
+				'Attendee.ATT_ID'  => $attendee_ID,
224
+				'MSG_message_type' => $message_type,
225
+				'STS_ID'           => array('IN', $this->stati_indicating_sent()),
226
+			),
227
+		));
228
+	}
229
+
230
+
231
+	/**
232
+	 * Returns whether or not a message of that type was sent for a given registration
233
+	 *
234
+	 * @param EE_Registration|int $registration
235
+	 * @param string              $message_type the message type slug
236
+	 * @return boolean
237
+	 */
238
+	public function message_sent_for_registration($registration, $message_type)
239
+	{
240
+		$registrationID = EEM_Registration::instance()->ensure_is_ID($registration);
241
+		return $this->exists(array(
242
+			array(
243
+				'Registration.REG_ID' => $registrationID,
244
+				'MSG_message_type'    => $message_type,
245
+				'STS_ID'              => array('IN', $this->stati_indicating_sent()),
246
+			),
247
+		));
248
+	}
249
+
250
+
251
+	/**
252
+	 * This retrieves an EE_Message object from the db matching the given token string.
253
+	 *
254
+	 * @param string $token
255
+	 * @return EE_Message
256
+	 */
257
+	public function get_one_by_token($token)
258
+	{
259
+		return $this->get_one(array(
260
+			array(
261
+				'MSG_token' => $token,
262
+			),
263
+		));
264
+	}
265
+
266
+
267
+	/**
268
+	 * Returns stati that indicate the message HAS been sent
269
+	 *
270
+	 * @return array of strings for possible stati
271
+	 */
272
+	public function stati_indicating_sent()
273
+	{
274
+		return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent));
275
+	}
276
+
277
+
278
+	/**
279
+	 * Returns stati that indicate the message is waiting to be sent.
280
+	 *
281
+	 * @return array of strings for possible stati.
282
+	 */
283
+	public function stati_indicating_to_send()
284
+	{
285
+		return apply_filters('FHEE__EEM_Message__stati_indicating_to_send',
286
+			array(self::status_idle, self::status_resend));
287
+	}
288
+
289
+
290
+	/**
291
+	 * Returns stati that indicate the message has failed sending
292
+	 *
293
+	 * @return array  array of strings for possible stati.
294
+	 */
295
+	public function stati_indicating_failed_sending()
296
+	{
297
+		$failed_stati = array(
298
+			self::status_failed,
299
+			self::status_retry,
300
+			self::status_messenger_executing,
301
+		);
302
+		//if WP_DEBUG is set, then let's include debug_only fails
303
+		if (WP_DEBUG) {
304
+			$failed_stati[] = self::status_debug_only;
305
+		}
306
+		return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati);
307
+	}
308
+
309
+
310
+	/**
311
+	 * Returns filterable array of all EEM_Message statuses.
312
+	 *
313
+	 * @return array
314
+	 */
315
+	public function all_statuses()
316
+	{
317
+		return apply_filters(
318
+			'FHEE__EEM_Message__all_statuses',
319
+			array(
320
+				EEM_Message::status_sent,
321
+				EEM_Message::status_incomplete,
322
+				EEM_Message::status_idle,
323
+				EEM_Message::status_resend,
324
+				EEM_Message::status_retry,
325
+				EEM_Message::status_failed,
326
+				EEM_Message::status_messenger_executing,
327
+				EEM_Message::status_debug_only,
328
+			)
329
+		);
330
+	}
331
+
332
+	/**
333
+	 * Detects any specific query variables in the request and uses those to setup appropriate
334
+	 * filter for any queries.
335
+	 *
336
+	 * @return array
337
+	 */
338
+	public function filter_by_query_params()
339
+	{
340
+		// expected possible query_vars, the key in this array matches an expected key in the request,
341
+		// the value, matches the corresponding EEM_Base child reference.
342
+		$expected_vars   = $this->_expected_vars_for_query_inject();
343
+		$query_params[0] = array();
344
+		foreach ($expected_vars as $request_key => $model_name) {
345
+			$request_value = EE_Registry::instance()->REQ->get($request_key);
346
+			if ($request_value) {
347
+				//special case
348
+				switch ($request_key) {
349
+					case '_REG_ID' :
350
+						$query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array(
351
+							'Transaction.Registration.REG_ID' => $request_value,
352
+						);
353
+						break;
354
+					case 'EVT_ID' :
355
+						$query_params[0]['AND**filter_by']['OR**filter_by_EVT_ID'] = array(
356
+							'Transaction.Registration.EVT_ID' => $request_value,
357
+						);
358
+						break;
359
+					default :
360
+						$query_params[0]['AND**filter_by']['OR**filter_by_' . $request_key][$model_name . '.' . $request_key] = $request_value;
361
+						break;
362
+				}
363
+			}
364
+		}
365
+		return $query_params;
366
+	}
367
+
368
+
369
+	/**
370
+	 * @return string
371
+	 */
372
+	public function get_pretty_label_for_results()
373
+	{
374
+		$expected_vars = $this->_expected_vars_for_query_inject();
375
+		$pretty_label  = '';
376
+		$label_parts   = array();
377
+		foreach ($expected_vars as $request_key => $model_name) {
378
+			$model = EE_Registry::instance()->load_model($model_name);
379
+			if ($model_field_value = EE_Registry::instance()->REQ->get($request_key)) {
380
+				switch ($request_key) {
381
+					case '_REG_ID' :
382
+						$label_parts[] = sprintf(
383
+							esc_html__('Registration with the ID: %s', 'event_espresso'),
384
+							$model_field_value
385
+						);
386
+						break;
387
+					case 'ATT_ID' :
388
+						/** @var EE_Attendee $attendee */
389
+						$attendee      = $model->get_one_by_ID($model_field_value);
390
+						$label_parts[] = $attendee instanceof EE_Attendee
391
+							? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name())
392
+							: sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value);
393
+						break;
394
+					case 'ID' :
395
+						/** @var EE_WP_User $wpUser */
396
+						$wpUser        = $model->get_one_by_ID($model_field_value);
397
+						$label_parts[] = $wpUser instanceof EE_WP_User
398
+							? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name())
399
+							: sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value);
400
+						break;
401
+					case 'TXN_ID' :
402
+						$label_parts[] = sprintf(
403
+							esc_html__('Transaction with the ID: %s', 'event_espresso'),
404
+							$model_field_value
405
+						);
406
+						break;
407
+					case 'EVT_ID' :
408
+						/** @var EE_Event $Event */
409
+						$Event         = $model->get_one_by_ID($model_field_value);
410
+						$label_parts[] = $Event instanceof EE_Event
411
+							? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name())
412
+							: sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value);
413
+						break;
414
+				}
415
+			}
416
+		}
417
+
418
+		if ($label_parts) {
419
+
420
+			//prepend to the last element of $label_parts an "and".
421
+			if (count($label_parts) > 1) {
422
+				$label_parts_index_to_prepend               = count($label_parts) - 1;
423
+				$label_parts[$label_parts_index_to_prepend] = 'and' . $label_parts[$label_parts_index_to_prepend];
424
+			}
425
+
426
+			$pretty_label .= sprintf(
427
+				esc_html_x(
428
+					'Showing messages for %s',
429
+					'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.',
430
+					'event_espresso'
431
+				),
432
+				implode(', ', $label_parts)
433
+			);
434
+		}
435
+		return $pretty_label;
436
+	}
437
+
438
+
439
+	/**
440
+	 * This returns the array of expected variables for the EEI_Query_Filter methods being implemented
441
+	 * The array is in the format:
442
+	 * array(
443
+	 *  {$field_name} => {$model_name}
444
+	 * );
445
+	 *
446
+	 * @since 4.9.0
447
+	 * @return array
448
+	 */
449
+	protected function _expected_vars_for_query_inject()
450
+	{
451
+		return array(
452
+			'_REG_ID' => 'Registration',
453
+			'ATT_ID'  => 'Attendee',
454
+			'ID'      => 'WP_User',
455
+			'TXN_ID'  => 'Transaction',
456
+			'EVT_ID'  => 'Event',
457
+		);
458
+	}
459
+
460
+
461
+	/**
462
+	 * This returns whether EEM_Message is in debug mode or not.
463
+	 * Currently "debug mode" is used to control the handling of the EEM_Message::debug_only status when
464
+	 * generating/sending messages. Debug mode can be set by either:
465
+	 * 1. Sending in a value for the $set_debug argument
466
+	 * 2. Defining `EE_DEBUG_MESSAGES` constant in wp-config.php
467
+	 * 3. Overriding the above via the provided filter.
468
+	 *
469
+	 * @param bool|null $set_debug      If provided, then the debug mode will be set internally until reset via the
470
+	 *                                  provided boolean. When no argument is provided (default null) then the debug
471
+	 *                                  mode will be returned.
472
+	 * @return bool         true means Messages is in debug mode.  false means messages system is not in debug mode.
473
+	 */
474
+	public static function debug($set_debug = null)
475
+	{
476
+		static $is_debugging = null;
477
+
478
+		//initialize (use constant if set).
479
+		if (is_null($set_debug) && is_null($is_debugging)) {
480
+			$is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES;
481
+		}
482
+
483
+		if ( ! is_null($set_debug)) {
484
+			$is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN);
485
+		}
486
+
487
+		//return filtered value
488
+		return apply_filters('FHEE__EEM_Message__debug', $is_debugging);
489
+	}
490
+
491
+
492
+	/**
493
+	 * Deletes old messages meeting certain criteria for removal from the database.
494
+	 * By default, this will delete messages that:
495
+	 * - are older than the value of the delete_threshold in months.
496
+	 * - have a STS_ID other than EEM_Message::status_idle
497
+	 *
498
+	 * @param int $delete_threshold  This integer will be used to set the boundary for what messages are deleted in months.
499
+	 * @return bool|false|int Either the number of records affected or false if there was an error (you can call
500
+	 *                         $wpdb->last_error to find out what the error was.
501
+	 */
502
+	public function delete_old_messages($delete_threshold = 6)
503
+	{
504
+		$number_deleted = 0;
505
+		/**
506
+		 * Allows code to change the boundary for what messages are kept.
507
+		 * Uses the value of the `delete_threshold` variable by default.
508
+		 *
509
+		 * @param int $seconds seconds that will be subtracted from the timestamp for now.
510
+		 * @return int
511
+		 */
512
+		$time_to_leave_alone = absint(
513
+			apply_filters(
514
+				'FHEE__EEM_Message__delete_old_messages__time_to_leave_alone',
515
+				((int) $delete_threshold) * MONTH_IN_SECONDS
516
+			)
517
+		);
518
+
519
+
520
+		/**
521
+		 * Allows code to change what message stati are ignored when deleting.
522
+		 * Defaults to only ignore EEM_Message::status_idle messages.
523
+		 *
524
+		 * @param string $message_stati_to_keep  An array of message statuses that will be ignored when deleting.
525
+		 */
526
+		$message_stati_to_keep = (array) apply_filters(
527
+			'FHEE__EEM_Message__delete_old_messages__message_stati_to_keep',
528
+			array(
529
+				EEM_Message::status_idle
530
+			)
531
+		);
532
+
533
+		//first get all the ids of messages being deleted
534
+		$message_ids_to_delete = EEM_Message::instance()->get_col(
535
+			array(
536
+				0 => array(
537
+					'STS_ID' => array('NOT_IN', $message_stati_to_keep),
538
+					'MSG_modified' => array('<', time() - $time_to_leave_alone)
539
+				)
540
+			)
541
+		);
542
+
543
+		if(! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) {
544
+			global $wpdb;
545
+			$number_deleted = $wpdb->query('
546 546
                 DELETE
547 547
                 FROM ' . $this->table() . '
548 548
                 WHERE
549 549
                     MSG_ID IN (' . implode(",", $message_ids_to_delete) . ')
550 550
             ');
551
-        }
552
-
553
-        /**
554
-         * This will get called if the number of records deleted 0 or greater.  So a successful deletion is one where
555
-         * there were no errors.  An unsuccessful deletion is where there were errors.  Keep that in mind for the actions
556
-         * below.
557
-         */
558
-        if ($number_deleted !== false) {
559
-            do_action('AHEE__EEM_Message__delete_old_messages__after_successful_deletion', $message_ids_to_delete, $number_deleted);
560
-        } else {
561
-            do_action('AHEE__EEM_Message__delete_old_messages__after_deletion_fail', $message_ids_to_delete, $number_deleted);
562
-        }
563
-        return $number_deleted;
564
-    }
551
+		}
552
+
553
+		/**
554
+		 * This will get called if the number of records deleted 0 or greater.  So a successful deletion is one where
555
+		 * there were no errors.  An unsuccessful deletion is where there were errors.  Keep that in mind for the actions
556
+		 * below.
557
+		 */
558
+		if ($number_deleted !== false) {
559
+			do_action('AHEE__EEM_Message__delete_old_messages__after_successful_deletion', $message_ids_to_delete, $number_deleted);
560
+		} else {
561
+			do_action('AHEE__EEM_Message__delete_old_messages__after_deletion_fail', $message_ids_to_delete, $number_deleted);
562
+		}
563
+		return $number_deleted;
564
+	}
565 565
 
566 566
 }
567 567
 // End of file EEM_Message.model.php
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Scheduler.lib.php 2 patches
Indentation   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -12,199 +12,199 @@
 block discarded – undo
12 12
 class EE_Messages_Scheduler extends EE_Base
13 13
 {
14 14
 
15
-    /**
16
-     * Number of seconds between batch sends/generates on the cron job.
17
-     * Defaults to 5 minutes in seconds.  If you want to change this interval, you can use the native WordPress
18
-     * `cron_schedules` filter and modify the existing custom `ee_message_cron` schedule interval added.
19
-     *
20
-     * @type int
21
-     */
22
-    const message_cron_schedule = 300;
23
-
24
-    /**
25
-     * Constructor
26
-     */
27
-    public function __construct()
28
-    {
29
-        //register tasks (and make sure only registered once).
30
-        if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) {
31
-            add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10);
32
-        }
33
-
34
-        //register callbacks for scheduled events (but make sure they are set only once).
35
-        if (! has_action(
36
-            'AHEE__EE_Messages_Scheduler__generation',
37
-            array('EE_Messages_Scheduler', 'batch_generation')
38
-        )) {
39
-            add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation'));
40
-            add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending'));
41
-            add_action('AHEE__EE_Messages_Scheduler__cleanup', array('EE_Messages_Scheduler', 'cleanup'));
42
-        }
43
-
44
-        //add custom schedules
45
-        add_filter('cron_schedules', array($this, 'custom_schedules'));
46
-    }
47
-
48
-
49
-    /**
50
-     * Add custom schedules for wp_cron
51
-     *
52
-     * @param $schedules
53
-     */
54
-    public function custom_schedules($schedules)
55
-    {
56
-        $schedules['ee_message_cron'] = array(
57
-            'interval' => self::message_cron_schedule,
58
-            'display'  => __(
59
-                'This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)',
60
-                'event_espresso'
61
-            ),
62
-        );
63
-        return $schedules;
64
-    }
65
-
66
-
67
-    /**
68
-     * Callback for FHEE__EEH_Activation__get_cron_tasks that is used to retrieve scheduled Cron events to add and
69
-     * remove.
70
-     *
71
-     * @param array $tasks already existing scheduled tasks
72
-     * @return array
73
-     */
74
-    public function register_scheduled_tasks($tasks)
75
-    {
76
-        EE_Registry::instance()->load_helper('DTT_Helper');
77
-        $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron';
78
-        $tasks['AHEE__EE_Messages_Scheduler__sending']    = 'ee_message_cron';
79
-        $tasks['AHEE__EE_Messages_Scheduler__cleanup'] = array( EEH_DTT_Helper::tomorrow(), 'daily');
80
-        return $tasks;
81
-    }
82
-
83
-
84
-    /**
85
-     * This initiates a non-blocking separate request to execute on a scheduled task.
86
-     * Note: The EED_Messages module has the handlers for these requests.
87
-     *
88
-     * @param string $task The task the request is being generated for.
89
-     */
90
-    public static function initiate_scheduled_non_blocking_request($task)
91
-    {
92
-        if (apply_filters(
93
-            'EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request',
94
-            true
95
-        )) {
96
-            $request_url  = add_query_arg(
97
-                array_merge(
98
-                    array('ee' => 'msg_cron_trigger'),
99
-                    EE_Messages_Scheduler::get_request_params($task)
100
-                ),
101
-                site_url()
102
-            );
103
-            $request_args = array(
104
-                'timeout'     => 300,
105
-                'blocking'    => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false,
106
-                'sslverify'   => false,
107
-                'redirection' => 10,
108
-            );
109
-            $response     = wp_remote_get($request_url, $request_args);
110
-            if (is_wp_error($response)) {
111
-                trigger_error($response->get_error_message());
112
-            }
113
-        } else {
114
-            EE_Messages_Scheduler::initiate_immediate_request_on_cron($task);
115
-        }
116
-    }
117
-
118
-
119
-    /**
120
-     * This returns
121
-     * the request params used for a scheduled message task request.
122
-     *
123
-     * @param string $task The task the request is for.
124
-     * @return array
125
-     */
126
-    public static function get_request_params($task)
127
-    {
128
-        //transient is used for flood control on msg_cron_trigger requests
129
-        $transient_key = 'ee_trans_' . uniqid($task);
130
-        set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS);
131
-        return array(
132
-            'type' => $task,
133
-            'key'  => $transient_key,
134
-        );
135
-    }
136
-
137
-
138
-    /**
139
-     * This is used to execute an immediate call to the run_cron task performed by EED_Messages
140
-     *
141
-     * @param string $task The task the request is being generated for.
142
-     */
143
-    public static function initiate_immediate_request_on_cron($task)
144
-    {
145
-        $request_args = EE_Messages_Scheduler::get_request_params($task);
146
-        //set those request args in the request so it gets picked up
147
-        foreach ($request_args as $request_key => $request_value) {
148
-            EE_Registry::instance()->REQ->set($request_key, $request_value);
149
-        }
150
-        EED_Messages::instance()->run_cron();
151
-    }
152
-
153
-
154
-    /**
155
-     * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event
156
-     */
157
-    public static function batch_generation()
158
-    {
159
-        /**
160
-         * @see filter usage in EE_Messages_Queue::initiate_request_by_priority()
161
-         */
162
-        if (! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
163
-            || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
164
-        ) {
165
-            EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate');
166
-        }
167
-    }
168
-
169
-
170
-    /**
171
-     * Callback for scheduled AHEE__EE_Messages_Scheduler__sending
172
-     */
173
-    public static function batch_sending()
174
-    {
175
-        /**
176
-         * @see filter usage in EE_Messages_Queue::initiate_request_by_priority()
177
-         */
178
-        if (! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
179
-            || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
180
-        ) {
181
-            EE_Messages_Scheduler::initiate_immediate_request_on_cron('send');
182
-        }
183
-    }
184
-
185
-
186
-    /**
187
-     * This is the callback for the `AHEE__EE_Messages_Scheduler__cleanup` scheduled event action.
188
-     * This runs once a day and if cleanup is active (set via messages settings), it will (by default) delete permanently
189
-     * from the database messages that have a MSG_modified date older than 30 days.
190
-     */
191
-    public static function cleanup()
192
-    {
193
-        //first check if user has cleanup turned on or if we're in maintenance mode.  If in maintenance mode we'll wait
194
-        //until the next scheduled event.
195
-        if (! EE_Registry::instance()->CFG->messages->delete_threshold
196
-            || ! EE_Maintenance_Mode::instance()->models_can_query()
197
-        ) {
198
-            return;
199
-        }
200
-
201
-        /**
202
-         * This filter switch allows other code (such as the EE_Worker_Queue add-on) to replace this with its own handling
203
-         * of deleting messages.
204
-         */
205
-        if (apply_filters('FHEE__EE_Messages_Scheduler__cleanup__handle_cleanup_on_cron', true)) {
206
-            EEM_Message::instance()->delete_old_messages(EE_Registry::instance()->CFG->messages->delete_threshold);
207
-        }
208
-    }
15
+	/**
16
+	 * Number of seconds between batch sends/generates on the cron job.
17
+	 * Defaults to 5 minutes in seconds.  If you want to change this interval, you can use the native WordPress
18
+	 * `cron_schedules` filter and modify the existing custom `ee_message_cron` schedule interval added.
19
+	 *
20
+	 * @type int
21
+	 */
22
+	const message_cron_schedule = 300;
23
+
24
+	/**
25
+	 * Constructor
26
+	 */
27
+	public function __construct()
28
+	{
29
+		//register tasks (and make sure only registered once).
30
+		if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) {
31
+			add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10);
32
+		}
33
+
34
+		//register callbacks for scheduled events (but make sure they are set only once).
35
+		if (! has_action(
36
+			'AHEE__EE_Messages_Scheduler__generation',
37
+			array('EE_Messages_Scheduler', 'batch_generation')
38
+		)) {
39
+			add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation'));
40
+			add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending'));
41
+			add_action('AHEE__EE_Messages_Scheduler__cleanup', array('EE_Messages_Scheduler', 'cleanup'));
42
+		}
43
+
44
+		//add custom schedules
45
+		add_filter('cron_schedules', array($this, 'custom_schedules'));
46
+	}
47
+
48
+
49
+	/**
50
+	 * Add custom schedules for wp_cron
51
+	 *
52
+	 * @param $schedules
53
+	 */
54
+	public function custom_schedules($schedules)
55
+	{
56
+		$schedules['ee_message_cron'] = array(
57
+			'interval' => self::message_cron_schedule,
58
+			'display'  => __(
59
+				'This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)',
60
+				'event_espresso'
61
+			),
62
+		);
63
+		return $schedules;
64
+	}
65
+
66
+
67
+	/**
68
+	 * Callback for FHEE__EEH_Activation__get_cron_tasks that is used to retrieve scheduled Cron events to add and
69
+	 * remove.
70
+	 *
71
+	 * @param array $tasks already existing scheduled tasks
72
+	 * @return array
73
+	 */
74
+	public function register_scheduled_tasks($tasks)
75
+	{
76
+		EE_Registry::instance()->load_helper('DTT_Helper');
77
+		$tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron';
78
+		$tasks['AHEE__EE_Messages_Scheduler__sending']    = 'ee_message_cron';
79
+		$tasks['AHEE__EE_Messages_Scheduler__cleanup'] = array( EEH_DTT_Helper::tomorrow(), 'daily');
80
+		return $tasks;
81
+	}
82
+
83
+
84
+	/**
85
+	 * This initiates a non-blocking separate request to execute on a scheduled task.
86
+	 * Note: The EED_Messages module has the handlers for these requests.
87
+	 *
88
+	 * @param string $task The task the request is being generated for.
89
+	 */
90
+	public static function initiate_scheduled_non_blocking_request($task)
91
+	{
92
+		if (apply_filters(
93
+			'EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request',
94
+			true
95
+		)) {
96
+			$request_url  = add_query_arg(
97
+				array_merge(
98
+					array('ee' => 'msg_cron_trigger'),
99
+					EE_Messages_Scheduler::get_request_params($task)
100
+				),
101
+				site_url()
102
+			);
103
+			$request_args = array(
104
+				'timeout'     => 300,
105
+				'blocking'    => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false,
106
+				'sslverify'   => false,
107
+				'redirection' => 10,
108
+			);
109
+			$response     = wp_remote_get($request_url, $request_args);
110
+			if (is_wp_error($response)) {
111
+				trigger_error($response->get_error_message());
112
+			}
113
+		} else {
114
+			EE_Messages_Scheduler::initiate_immediate_request_on_cron($task);
115
+		}
116
+	}
117
+
118
+
119
+	/**
120
+	 * This returns
121
+	 * the request params used for a scheduled message task request.
122
+	 *
123
+	 * @param string $task The task the request is for.
124
+	 * @return array
125
+	 */
126
+	public static function get_request_params($task)
127
+	{
128
+		//transient is used for flood control on msg_cron_trigger requests
129
+		$transient_key = 'ee_trans_' . uniqid($task);
130
+		set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS);
131
+		return array(
132
+			'type' => $task,
133
+			'key'  => $transient_key,
134
+		);
135
+	}
136
+
137
+
138
+	/**
139
+	 * This is used to execute an immediate call to the run_cron task performed by EED_Messages
140
+	 *
141
+	 * @param string $task The task the request is being generated for.
142
+	 */
143
+	public static function initiate_immediate_request_on_cron($task)
144
+	{
145
+		$request_args = EE_Messages_Scheduler::get_request_params($task);
146
+		//set those request args in the request so it gets picked up
147
+		foreach ($request_args as $request_key => $request_value) {
148
+			EE_Registry::instance()->REQ->set($request_key, $request_value);
149
+		}
150
+		EED_Messages::instance()->run_cron();
151
+	}
152
+
153
+
154
+	/**
155
+	 * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event
156
+	 */
157
+	public static function batch_generation()
158
+	{
159
+		/**
160
+		 * @see filter usage in EE_Messages_Queue::initiate_request_by_priority()
161
+		 */
162
+		if (! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
163
+			|| ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
164
+		) {
165
+			EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate');
166
+		}
167
+	}
168
+
169
+
170
+	/**
171
+	 * Callback for scheduled AHEE__EE_Messages_Scheduler__sending
172
+	 */
173
+	public static function batch_sending()
174
+	{
175
+		/**
176
+		 * @see filter usage in EE_Messages_Queue::initiate_request_by_priority()
177
+		 */
178
+		if (! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
179
+			|| ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
180
+		) {
181
+			EE_Messages_Scheduler::initiate_immediate_request_on_cron('send');
182
+		}
183
+	}
184
+
185
+
186
+	/**
187
+	 * This is the callback for the `AHEE__EE_Messages_Scheduler__cleanup` scheduled event action.
188
+	 * This runs once a day and if cleanup is active (set via messages settings), it will (by default) delete permanently
189
+	 * from the database messages that have a MSG_modified date older than 30 days.
190
+	 */
191
+	public static function cleanup()
192
+	{
193
+		//first check if user has cleanup turned on or if we're in maintenance mode.  If in maintenance mode we'll wait
194
+		//until the next scheduled event.
195
+		if (! EE_Registry::instance()->CFG->messages->delete_threshold
196
+			|| ! EE_Maintenance_Mode::instance()->models_can_query()
197
+		) {
198
+			return;
199
+		}
200
+
201
+		/**
202
+		 * This filter switch allows other code (such as the EE_Worker_Queue add-on) to replace this with its own handling
203
+		 * of deleting messages.
204
+		 */
205
+		if (apply_filters('FHEE__EE_Messages_Scheduler__cleanup__handle_cleanup_on_cron', true)) {
206
+			EEM_Message::instance()->delete_old_messages(EE_Registry::instance()->CFG->messages->delete_threshold);
207
+		}
208
+	}
209 209
 
210 210
 } //end EE_Messages_Scheduler
211 211
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
     public function __construct()
28 28
     {
29 29
         //register tasks (and make sure only registered once).
30
-        if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) {
30
+        if ( ! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) {
31 31
             add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10);
32 32
         }
33 33
 
34 34
         //register callbacks for scheduled events (but make sure they are set only once).
35
-        if (! has_action(
35
+        if ( ! has_action(
36 36
             'AHEE__EE_Messages_Scheduler__generation',
37 37
             array('EE_Messages_Scheduler', 'batch_generation')
38 38
         )) {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         EE_Registry::instance()->load_helper('DTT_Helper');
77 77
         $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron';
78 78
         $tasks['AHEE__EE_Messages_Scheduler__sending']    = 'ee_message_cron';
79
-        $tasks['AHEE__EE_Messages_Scheduler__cleanup'] = array( EEH_DTT_Helper::tomorrow(), 'daily');
79
+        $tasks['AHEE__EE_Messages_Scheduler__cleanup'] = array(EEH_DTT_Helper::tomorrow(), 'daily');
80 80
         return $tasks;
81 81
     }
82 82
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             'EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request',
94 94
             true
95 95
         )) {
96
-            $request_url  = add_query_arg(
96
+            $request_url = add_query_arg(
97 97
                 array_merge(
98 98
                     array('ee' => 'msg_cron_trigger'),
99 99
                     EE_Messages_Scheduler::get_request_params($task)
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                 'sslverify'   => false,
107 107
                 'redirection' => 10,
108 108
             );
109
-            $response     = wp_remote_get($request_url, $request_args);
109
+            $response = wp_remote_get($request_url, $request_args);
110 110
             if (is_wp_error($response)) {
111 111
                 trigger_error($response->get_error_message());
112 112
             }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     public static function get_request_params($task)
127 127
     {
128 128
         //transient is used for flood control on msg_cron_trigger requests
129
-        $transient_key = 'ee_trans_' . uniqid($task);
129
+        $transient_key = 'ee_trans_'.uniqid($task);
130 130
         set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS);
131 131
         return array(
132 132
             'type' => $task,
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         /**
160 160
          * @see filter usage in EE_Messages_Queue::initiate_request_by_priority()
161 161
          */
162
-        if (! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
162
+        if ( ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
163 163
             || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
164 164
         ) {
165 165
             EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate');
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
         /**
176 176
          * @see filter usage in EE_Messages_Queue::initiate_request_by_priority()
177 177
          */
178
-        if (! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
178
+        if ( ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
179 179
             || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
180 180
         ) {
181 181
             EE_Messages_Scheduler::initiate_immediate_request_on_cron('send');
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     {
193 193
         //first check if user has cleanup turned on or if we're in maintenance mode.  If in maintenance mode we'll wait
194 194
         //until the next scheduled event.
195
-        if (! EE_Registry::instance()->CFG->messages->delete_threshold
195
+        if ( ! EE_Registry::instance()->CFG->messages->delete_threshold
196 196
             || ! EE_Maintenance_Mode::instance()->models_can_query()
197 197
         ) {
198 198
             return;
Please login to merge, or discard this patch.
core/EE_Cron_Tasks.core.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
              * wanting to not have this functionality can just register its own action at a priority after this one to
58 58
              * reverse any changes.
59 59
              */
60
-            add_action('AHEE__EE_System__load_core_configuration__complete', function () {
60
+            add_action('AHEE__EE_System__load_core_configuration__complete', function() {
61 61
                 EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true;
62 62
                 EE_Registry::instance()->NET_CFG->update_config(true, false);
63 63
                 add_option('ee_disabled_wp_cron_check', 1, '', false);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		// EXPIRED TRANSACTION CHECK
79 79
 		add_action(
80 80
 			'AHEE__EE_Cron_Tasks__expired_transaction_check',
81
-			array( 'EE_Cron_Tasks', 'expired_transaction_check' ),
81
+			array('EE_Cron_Tasks', 'expired_transaction_check'),
82 82
 			10, 1
83 83
 		);
84 84
         // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
      * @return bool
147 147
      * @throws \DomainException
148 148
      */
149
-	public static function reschedule_cron_for_transactions_if_maintenance_mode( $cron_task, array $TXN_IDs ) {
150
-        if( ! method_exists('EE_Cron_Tasks', $cron_task)) {
149
+	public static function reschedule_cron_for_transactions_if_maintenance_mode($cron_task, array $TXN_IDs) {
150
+        if ( ! method_exists('EE_Cron_Tasks', $cron_task)) {
151 151
             throw new \DomainException(
152 152
                 sprintf(
153 153
                     __('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'),
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
             );
157 157
         }
158 158
 		// reschedule the cron if we can't hit the db right now
159
-		if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) {
160
-			foreach( $TXN_IDs as $TXN_ID => $additional_vars ) {
159
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
160
+			foreach ($TXN_IDs as $TXN_ID => $additional_vars) {
161 161
                 // ensure $additional_vars is an array
162 162
                 $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars);
163 163
 				// reset cron job for the TXN
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         do_action('AHEE_log', __CLASS__, __FUNCTION__);
262 262
 		if (
263 263
 			// are there any TXNs that need cleaning up ?
264
-			empty( self::$_update_transactions_with_payment )
264
+			empty(self::$_update_transactions_with_payment)
265 265
 			// reschedule the cron if we can't hit the db right now
266 266
 			|| EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode(
267 267
 				'schedule_update_transaction_with_payment',
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
         do_action('AHEE_log', __CLASS__, __FUNCTION__);
383 383
         if (
384 384
 			// are there any TXNs that need cleaning up ?
385
-			empty( self::$_abandoned_transactions )
385
+			empty(self::$_abandoned_transactions)
386 386
 			// reschedule the cron if we can't hit the db right now
387 387
 			|| EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode(
388 388
 				'schedule_finalize_abandoned_transactions_check',
@@ -455,13 +455,13 @@  discard block
 block discarded – undo
455 455
 		$TXN_ID
456 456
 	) {
457 457
 		// validate $TXN_ID and $timestamp
458
-		$TXN_ID = absint( $TXN_ID );
459
-		$timestamp = absint( $timestamp );
460
-		if ( $TXN_ID && $timestamp ) {
458
+		$TXN_ID = absint($TXN_ID);
459
+		$timestamp = absint($timestamp);
460
+		if ($TXN_ID && $timestamp) {
461 461
 			wp_schedule_single_event(
462 462
 				$timestamp,
463 463
 				'AHEE__EE_Cron_Tasks__expired_transaction_check',
464
-				array( $TXN_ID )
464
+				array($TXN_ID)
465 465
 			);
466 466
 		}
467 467
 	}
@@ -483,12 +483,12 @@  discard block
 block discarded – undo
483 483
 	 *
484 484
 	 * @param int $TXN_ID
485 485
 	 */
486
-	public static function expired_transaction_check( $TXN_ID = 0 ) {
487
-		if ( absint( $TXN_ID )) {
488
-			self::$_expired_transactions[ $TXN_ID ]  = $TXN_ID;
486
+	public static function expired_transaction_check($TXN_ID = 0) {
487
+		if (absint($TXN_ID)) {
488
+			self::$_expired_transactions[$TXN_ID] = $TXN_ID;
489 489
 			add_action(
490 490
 				'shutdown',
491
-				array( 'EE_Cron_Tasks', 'process_expired_transactions' ),
491
+				array('EE_Cron_Tasks', 'process_expired_transactions'),
492 492
 				5
493 493
 			);
494 494
 		}
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 	public static function process_expired_transactions() {
506 506
 		if (
507 507
 			// are there any TXNs that need cleaning up ?
508
-			empty( self::$_expired_transactions )
508
+			empty(self::$_expired_transactions)
509 509
 			// reschedule the cron if we can't hit the db right now
510 510
 			|| EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode(
511 511
 				'schedule_expired_transaction_check',
@@ -515,33 +515,33 @@  discard block
 block discarded – undo
515 515
             return;
516 516
         }
517 517
         /** @type EE_Transaction_Processor $transaction_processor */
518
-        $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
518
+        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
519 519
         // set revisit flag for txn processor
520
-        $transaction_processor->set_revisit( false );
520
+        $transaction_processor->set_revisit(false);
521 521
          // load EEM_Transaction
522
-        EE_Registry::instance()->load_model( 'Transaction' );
523
-        foreach ( self::$_expired_transactions as $TXN_ID ) {
524
-            $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
522
+        EE_Registry::instance()->load_model('Transaction');
523
+        foreach (self::$_expired_transactions as $TXN_ID) {
524
+            $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
525 525
             // verify transaction and whether it is failed or not
526
-            if ( $transaction instanceof EE_Transaction) {
527
-                switch( $transaction->status_ID() ) {
526
+            if ($transaction instanceof EE_Transaction) {
527
+                switch ($transaction->status_ID()) {
528 528
                     // Completed TXNs
529 529
                     case EEM_Transaction::complete_status_code :
530
-                        do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction );
530
+                        do_action('AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction);
531 531
                         break;
532 532
                     // Overpaid TXNs
533 533
                     case EEM_Transaction::overpaid_status_code :
534
-                        do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction );
534
+                        do_action('AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction);
535 535
                         break;
536 536
                     // Incomplete TXNs
537 537
                     case EEM_Transaction::incomplete_status_code :
538
-                        do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction );
538
+                        do_action('AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction);
539 539
                         // todo : merge the finalize_abandoned_transactions cron into this one...
540 540
                         // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions
541 541
                         break;
542 542
                     // Failed TXNs
543 543
                     case EEM_Transaction::failed_status_code :
544
-                        do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction );
544
+                        do_action('AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction);
545 545
                         // todo : perform garbage collection here and remove clean_out_junk_transactions()
546 546
                         //$registrations = $transaction->registrations();
547 547
                         //if ( ! empty( $registrations ) ) {
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
                 }
563 563
 
564 564
             }
565
-            unset( self::$_expired_transactions[ $TXN_ID ] );
565
+            unset(self::$_expired_transactions[$TXN_ID]);
566 566
         }
567 567
 	}
568 568
 
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
     /**
590 590
      * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that.
591 591
      */
592
-    public static function clean_out_old_gateway_logs(){
592
+    public static function clean_out_old_gateway_logs() {
593 593
         if (EE_Maintenance_Mode::instance()->models_can_query()) {
594 594
             $time_diff_for_comparison = apply_filters(
595 595
                 'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison',
Please login to merge, or discard this patch.
Indentation   +465 added lines, -465 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 /**
@@ -12,165 +12,165 @@  discard block
 block discarded – undo
12 12
 class EE_Cron_Tasks extends EE_Base
13 13
 {
14 14
 
15
-    /**
16
-     * WordPress doesn't allow duplicate crons within 10 minutes of the original,
17
-     * so we'll set our retry time for just over 10 minutes to avoid that
18
-     */
19
-    const reschedule_timeout = 605;
20
-
21
-
22
-    /**
23
-     * @var EE_Cron_Tasks
24
-     */
25
-    private static $_instance;
26
-
27
-
28
-    /**
29
-     * @return EE_Cron_Tasks
30
-     */
31
-    public static function instance()
32
-    {
33
-        if ( ! self::$_instance instanceof EE_Cron_Tasks) {
34
-            self::$_instance = new self();
35
-        }
36
-        return self::$_instance;
37
-    }
38
-
39
-
40
-    /**
41
-     * @access private
42
-     */
43
-    private function __construct()
44
-    {
45
-        do_action('AHEE_log', __CLASS__, __FUNCTION__);
46
-        // verify that WP Cron is enabled
47
-        if (
48
-            defined('DISABLE_WP_CRON')
49
-            && DISABLE_WP_CRON
50
-            && is_admin()
51
-            && ! get_option('ee_disabled_wp_cron_check')
52
-        ) {
53
-            /**
54
-             * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before
55
-             * config is loaded.
56
-             * This is intentionally using a anonymous function so that its not easily de-registered.  Client code
57
-             * wanting to not have this functionality can just register its own action at a priority after this one to
58
-             * reverse any changes.
59
-             */
60
-            add_action('AHEE__EE_System__load_core_configuration__complete', function () {
61
-                EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true;
62
-                EE_Registry::instance()->NET_CFG->update_config(true, false);
63
-                add_option('ee_disabled_wp_cron_check', 1, '', false);
64
-            });
65
-        }
66
-        // UPDATE TRANSACTION WITH PAYMENT
67
-        add_action(
68
-            'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
69
-            array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'),
70
-            10, 2
71
-        );
72
-        // FINALIZE ABANDONED TRANSACTIONS
73
-        add_action(
74
-            'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
75
-            array('EE_Cron_Tasks', 'check_for_abandoned_transactions'),
76
-            10, 1
77
-        );
15
+	/**
16
+	 * WordPress doesn't allow duplicate crons within 10 minutes of the original,
17
+	 * so we'll set our retry time for just over 10 minutes to avoid that
18
+	 */
19
+	const reschedule_timeout = 605;
20
+
21
+
22
+	/**
23
+	 * @var EE_Cron_Tasks
24
+	 */
25
+	private static $_instance;
26
+
27
+
28
+	/**
29
+	 * @return EE_Cron_Tasks
30
+	 */
31
+	public static function instance()
32
+	{
33
+		if ( ! self::$_instance instanceof EE_Cron_Tasks) {
34
+			self::$_instance = new self();
35
+		}
36
+		return self::$_instance;
37
+	}
38
+
39
+
40
+	/**
41
+	 * @access private
42
+	 */
43
+	private function __construct()
44
+	{
45
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
46
+		// verify that WP Cron is enabled
47
+		if (
48
+			defined('DISABLE_WP_CRON')
49
+			&& DISABLE_WP_CRON
50
+			&& is_admin()
51
+			&& ! get_option('ee_disabled_wp_cron_check')
52
+		) {
53
+			/**
54
+			 * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before
55
+			 * config is loaded.
56
+			 * This is intentionally using a anonymous function so that its not easily de-registered.  Client code
57
+			 * wanting to not have this functionality can just register its own action at a priority after this one to
58
+			 * reverse any changes.
59
+			 */
60
+			add_action('AHEE__EE_System__load_core_configuration__complete', function () {
61
+				EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true;
62
+				EE_Registry::instance()->NET_CFG->update_config(true, false);
63
+				add_option('ee_disabled_wp_cron_check', 1, '', false);
64
+			});
65
+		}
66
+		// UPDATE TRANSACTION WITH PAYMENT
67
+		add_action(
68
+			'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
69
+			array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'),
70
+			10, 2
71
+		);
72
+		// FINALIZE ABANDONED TRANSACTIONS
73
+		add_action(
74
+			'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
75
+			array('EE_Cron_Tasks', 'check_for_abandoned_transactions'),
76
+			10, 1
77
+		);
78 78
 		// EXPIRED TRANSACTION CHECK
79 79
 		add_action(
80 80
 			'AHEE__EE_Cron_Tasks__expired_transaction_check',
81 81
 			array( 'EE_Cron_Tasks', 'expired_transaction_check' ),
82 82
 			10, 1
83 83
 		);
84
-        // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA
85
-        add_action(
86
-            'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
87
-            array('EE_Cron_Tasks', 'clean_out_junk_transactions')
88
-        );
89
-        // logging
90
-        add_action(
91
-            'AHEE__EE_System__load_core_configuration__complete',
92
-            array('EE_Cron_Tasks', 'log_scheduled_ee_crons')
93
-        );
94
-        EE_Registry::instance()->load_lib('Messages_Scheduler');
95
-        //clean out old gateway logs
96
-        add_action(
97
-            'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs',
98
-            array('EE_Cron_Tasks', 'clean_out_old_gateway_logs')
99
-        );
100
-    }
101
-
102
-
103
-    /**
104
-     * @access protected
105
-     * @return void
106
-     */
107
-    public static function log_scheduled_ee_crons()
108
-    {
109
-        $ee_crons = array(
110
-            'AHEE__EE_Cron_Tasks__update_transaction_with_payment',
111
-            'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
112
-            'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
113
-        );
114
-        $crons = (array) get_option('cron');
115
-        if ( ! is_array($crons)) {
116
-            return;
117
-        }
118
-        foreach ($crons as $timestamp => $cron) {
119
-            foreach ($ee_crons as $ee_cron) {
120
-                if (isset($cron[$ee_cron]) && is_array($cron[$ee_cron])) {
121
-                    do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron');
122
-                    foreach ($cron[$ee_cron] as $ee_cron_details) {
123
-                        if ( ! empty($ee_cron_details['args'])) {
124
-                            do_action(
125
-                                'AHEE_log',
126
-                                __CLASS__,
127
-                                __FUNCTION__,
128
-                                print_r($ee_cron_details['args'], true),
129
-                                "{$ee_cron} args"
130
-                            );
131
-                        }
132
-                    }
133
-                }
134
-            }
135
-        }
136
-    }
137
-
138
-
139
-
140
-    /**
141
-     * reschedule_cron_for_transactions_if_maintenance_mode
142
-     * if Maintenance Mode is active, this will reschedule a cron to run again in 10 minutes
143
-     *
144
-     * @param string $cron_task
145
-     * @param array  $TXN_IDs
146
-     * @return bool
147
-     * @throws \DomainException
148
-     */
84
+		// CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA
85
+		add_action(
86
+			'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
87
+			array('EE_Cron_Tasks', 'clean_out_junk_transactions')
88
+		);
89
+		// logging
90
+		add_action(
91
+			'AHEE__EE_System__load_core_configuration__complete',
92
+			array('EE_Cron_Tasks', 'log_scheduled_ee_crons')
93
+		);
94
+		EE_Registry::instance()->load_lib('Messages_Scheduler');
95
+		//clean out old gateway logs
96
+		add_action(
97
+			'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs',
98
+			array('EE_Cron_Tasks', 'clean_out_old_gateway_logs')
99
+		);
100
+	}
101
+
102
+
103
+	/**
104
+	 * @access protected
105
+	 * @return void
106
+	 */
107
+	public static function log_scheduled_ee_crons()
108
+	{
109
+		$ee_crons = array(
110
+			'AHEE__EE_Cron_Tasks__update_transaction_with_payment',
111
+			'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
112
+			'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
113
+		);
114
+		$crons = (array) get_option('cron');
115
+		if ( ! is_array($crons)) {
116
+			return;
117
+		}
118
+		foreach ($crons as $timestamp => $cron) {
119
+			foreach ($ee_crons as $ee_cron) {
120
+				if (isset($cron[$ee_cron]) && is_array($cron[$ee_cron])) {
121
+					do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron');
122
+					foreach ($cron[$ee_cron] as $ee_cron_details) {
123
+						if ( ! empty($ee_cron_details['args'])) {
124
+							do_action(
125
+								'AHEE_log',
126
+								__CLASS__,
127
+								__FUNCTION__,
128
+								print_r($ee_cron_details['args'], true),
129
+								"{$ee_cron} args"
130
+							);
131
+						}
132
+					}
133
+				}
134
+			}
135
+		}
136
+	}
137
+
138
+
139
+
140
+	/**
141
+	 * reschedule_cron_for_transactions_if_maintenance_mode
142
+	 * if Maintenance Mode is active, this will reschedule a cron to run again in 10 minutes
143
+	 *
144
+	 * @param string $cron_task
145
+	 * @param array  $TXN_IDs
146
+	 * @return bool
147
+	 * @throws \DomainException
148
+	 */
149 149
 	public static function reschedule_cron_for_transactions_if_maintenance_mode( $cron_task, array $TXN_IDs ) {
150
-        if( ! method_exists('EE_Cron_Tasks', $cron_task)) {
151
-            throw new \DomainException(
152
-                sprintf(
153
-                    __('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'),
154
-                    $cron_task
155
-                )
156
-            );
157
-        }
150
+		if( ! method_exists('EE_Cron_Tasks', $cron_task)) {
151
+			throw new \DomainException(
152
+				sprintf(
153
+					__('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'),
154
+					$cron_task
155
+				)
156
+			);
157
+		}
158 158
 		// reschedule the cron if we can't hit the db right now
159 159
 		if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) {
160 160
 			foreach( $TXN_IDs as $TXN_ID => $additional_vars ) {
161
-                // ensure $additional_vars is an array
162
-                $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars);
161
+				// ensure $additional_vars is an array
162
+				$additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars);
163 163
 				// reset cron job for the TXN
164
-                call_user_func_array(
165
-                    array('EE_Cron_Tasks', $cron_task),
166
-                    array_merge(
167
-                        array(
168
-                            time() + (10 * MINUTE_IN_SECONDS),
169
-                            $TXN_ID
170
-                        ),
171
-                        $additional_vars
172
-                    )
173
-                );
164
+				call_user_func_array(
165
+					array('EE_Cron_Tasks', $cron_task),
166
+					array_merge(
167
+						array(
168
+							time() + (10 * MINUTE_IN_SECONDS),
169
+							$TXN_ID
170
+						),
171
+						$additional_vars
172
+					)
173
+				);
174 174
 			}
175 175
 			return true;
176 176
 		}
@@ -180,85 +180,85 @@  discard block
 block discarded – undo
180 180
 
181 181
 
182 182
 
183
-    /****************  UPDATE TRANSACTION WITH PAYMENT ****************/
184
-
185
-
186
-    /**
187
-     * array of TXN IDs and the payment
188
-     *
189
-     * @var array
190
-     */
191
-    protected static $_update_transactions_with_payment = array();
192
-
193
-
194
-    /**
195
-     * schedule_update_transaction_with_payment
196
-     * sets a wp_schedule_single_event() for updating any TXNs that may
197
-     * require updating due to recently received payments
198
-     *
199
-     * @param int $timestamp
200
-     * @param int $TXN_ID
201
-     * @param int $PAY_ID
202
-     */
203
-    public static function schedule_update_transaction_with_payment(
204
-        $timestamp,
205
-        $TXN_ID,
206
-        $PAY_ID
207
-    ) {
208
-        do_action('AHEE_log', __CLASS__, __FUNCTION__);
209
-        // validate $TXN_ID and $timestamp
210
-        $TXN_ID    = absint($TXN_ID);
211
-        $timestamp = absint($timestamp);
212
-        if ($TXN_ID && $timestamp) {
213
-            wp_schedule_single_event(
214
-                $timestamp,
215
-                'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
216
-                array($TXN_ID, $PAY_ID)
217
-            );
218
-        }
219
-    }
220
-
221
-
222
-    /**
223
-     * setup_update_for_transaction_with_payment
224
-     * this is the callback for the action hook:
225
-     * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment'
226
-     * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment().
227
-     * The passed TXN_ID and associated payment gets added to an array, and then
228
-     * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into
229
-     * 'shutdown' which will actually handle the processing of any
230
-     * transactions requiring updating, because doing so now would be too early
231
-     * and the required resources may not be available
232
-     *
233
-     * @param int $TXN_ID
234
-     * @param int $PAY_ID
235
-     */
236
-    public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0)
237
-    {
238
-        do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
239
-        if (absint($TXN_ID)) {
240
-            self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID;
241
-            add_action(
242
-                'shutdown',
243
-                array('EE_Cron_Tasks', 'update_transaction_with_payment'),
244
-                5
245
-            );
246
-        }
247
-    }
248
-
249
-
250
-    /**
251
-     * update_transaction_with_payment
252
-     * loops through the self::$_abandoned_transactions array
253
-     * and attempts to finalize any TXNs that have not been completed
254
-     * but have had their sessions expired, most likely due to a user not
255
-     * returning from an off-site payment gateway
256
-     *
257
-     * @throws \EE_Error
258
-     */
259
-    public static function update_transaction_with_payment()
260
-    {
261
-        do_action('AHEE_log', __CLASS__, __FUNCTION__);
183
+	/****************  UPDATE TRANSACTION WITH PAYMENT ****************/
184
+
185
+
186
+	/**
187
+	 * array of TXN IDs and the payment
188
+	 *
189
+	 * @var array
190
+	 */
191
+	protected static $_update_transactions_with_payment = array();
192
+
193
+
194
+	/**
195
+	 * schedule_update_transaction_with_payment
196
+	 * sets a wp_schedule_single_event() for updating any TXNs that may
197
+	 * require updating due to recently received payments
198
+	 *
199
+	 * @param int $timestamp
200
+	 * @param int $TXN_ID
201
+	 * @param int $PAY_ID
202
+	 */
203
+	public static function schedule_update_transaction_with_payment(
204
+		$timestamp,
205
+		$TXN_ID,
206
+		$PAY_ID
207
+	) {
208
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
209
+		// validate $TXN_ID and $timestamp
210
+		$TXN_ID    = absint($TXN_ID);
211
+		$timestamp = absint($timestamp);
212
+		if ($TXN_ID && $timestamp) {
213
+			wp_schedule_single_event(
214
+				$timestamp,
215
+				'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
216
+				array($TXN_ID, $PAY_ID)
217
+			);
218
+		}
219
+	}
220
+
221
+
222
+	/**
223
+	 * setup_update_for_transaction_with_payment
224
+	 * this is the callback for the action hook:
225
+	 * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment'
226
+	 * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment().
227
+	 * The passed TXN_ID and associated payment gets added to an array, and then
228
+	 * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into
229
+	 * 'shutdown' which will actually handle the processing of any
230
+	 * transactions requiring updating, because doing so now would be too early
231
+	 * and the required resources may not be available
232
+	 *
233
+	 * @param int $TXN_ID
234
+	 * @param int $PAY_ID
235
+	 */
236
+	public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0)
237
+	{
238
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
239
+		if (absint($TXN_ID)) {
240
+			self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID;
241
+			add_action(
242
+				'shutdown',
243
+				array('EE_Cron_Tasks', 'update_transaction_with_payment'),
244
+				5
245
+			);
246
+		}
247
+	}
248
+
249
+
250
+	/**
251
+	 * update_transaction_with_payment
252
+	 * loops through the self::$_abandoned_transactions array
253
+	 * and attempts to finalize any TXNs that have not been completed
254
+	 * but have had their sessions expired, most likely due to a user not
255
+	 * returning from an off-site payment gateway
256
+	 *
257
+	 * @throws \EE_Error
258
+	 */
259
+	public static function update_transaction_with_payment()
260
+	{
261
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
262 262
 		if (
263 263
 			// are there any TXNs that need cleaning up ?
264 264
 			empty( self::$_update_transactions_with_payment )
@@ -268,119 +268,119 @@  discard block
 block discarded – undo
268 268
 				self::$_update_transactions_with_payment
269 269
 			)
270 270
 		) {
271
-            return;
272
-        }
273
-        /** @type EE_Payment_Processor $payment_processor */
274
-        $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
275
-        // set revisit flag for payment processor
276
-        $payment_processor->set_revisit(false);
277
-        // load EEM_Transaction
278
-        EE_Registry::instance()->load_model('Transaction');
279
-        foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) {
280
-            // reschedule the cron if we can't hit the db right now
281
-            if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
282
-                // reset cron job for updating the TXN
283
-                EE_Cron_Tasks::schedule_update_transaction_with_payment(
284
-                    time() + EE_Cron_Tasks::reschedule_timeout,
285
-                    $TXN_ID,
286
-                    $PAY_ID
287
-                );
288
-                continue;
289
-            }
290
-            $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
291
-            $payment     = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
292
-            // verify transaction
293
-            if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) {
294
-                // now try to update the TXN with any payments
295
-                $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true);
296
-            }
297
-            unset(self::$_update_transactions_with_payment[$TXN_ID]);
298
-        }
299
-    }
300
-
301
-
302
-
303
-    /************  END OF UPDATE TRANSACTION WITH PAYMENT  ************/
304
-
305
-
306
-    /*****************  FINALIZE ABANDONED TRANSACTIONS *****************/
307
-
308
-
309
-    /**
310
-     * array of TXN IDs
311
-     *
312
-     * @var array
313
-     */
314
-    protected static $_abandoned_transactions = array();
315
-
316
-
317
-    /**
318
-     * schedule_finalize_abandoned_transactions_check
319
-     * sets a wp_schedule_single_event() for finalizing any TXNs that may
320
-     * have been abandoned during the registration process
321
-     *
322
-     * @param int $timestamp
323
-     * @param int $TXN_ID
324
-     */
325
-    public static function schedule_finalize_abandoned_transactions_check(
326
-        $timestamp,
327
-        $TXN_ID
328
-    ) {
329
-        // validate $TXN_ID and $timestamp
330
-        $TXN_ID    = absint($TXN_ID);
331
-        $timestamp = absint($timestamp);
332
-        do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
333
-        if ($TXN_ID && $timestamp) {
334
-            wp_schedule_single_event(
335
-                $timestamp,
336
-                'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
337
-                array($TXN_ID)
338
-            );
339
-        }
340
-    }
341
-
342
-
343
-    /**
344
-     * check_for_abandoned_transactions
345
-     * this is the callback for the action hook:
346
-     * 'AHEE__EE_Cron_Tasks__espresso_finalize_abandoned_transactions'
347
-     * which is utilized by wp_schedule_single_event()
348
-     * in EE_SPCO_Reg_Step_Payment_Options::_post_payment_processing().
349
-     * The passed TXN_ID gets added to an array, and then the
350
-     * espresso_finalize_abandoned_transactions() function is hooked into
351
-     * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the
352
-     * processing of any abandoned transactions, because doing so now would be
353
-     * too early and the required resources may not be available
354
-     *
355
-     * @param int $TXN_ID
356
-     */
357
-    public static function check_for_abandoned_transactions($TXN_ID = 0)
358
-    {
359
-        do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
360
-        if (absint($TXN_ID)) {
361
-            self::$_abandoned_transactions[] = $TXN_ID;
362
-            add_action(
363
-                'shutdown',
364
-                array('EE_Cron_Tasks', 'finalize_abandoned_transactions'),
365
-                5
366
-            );
367
-        }
368
-    }
369
-
370
-
371
-    /**
372
-     * finalize_abandoned_transactions
373
-     * loops through the self::$_abandoned_transactions array
374
-     * and attempts to finalize any TXNs that have not been completed
375
-     * but have had their sessions expired, most likely due to a user not
376
-     * returning from an off-site payment gateway
377
-     *
378
-     * @throws \EE_Error
379
-     */
380
-    public static function finalize_abandoned_transactions()
381
-    {
382
-        do_action('AHEE_log', __CLASS__, __FUNCTION__);
383
-        if (
271
+			return;
272
+		}
273
+		/** @type EE_Payment_Processor $payment_processor */
274
+		$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
275
+		// set revisit flag for payment processor
276
+		$payment_processor->set_revisit(false);
277
+		// load EEM_Transaction
278
+		EE_Registry::instance()->load_model('Transaction');
279
+		foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) {
280
+			// reschedule the cron if we can't hit the db right now
281
+			if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
282
+				// reset cron job for updating the TXN
283
+				EE_Cron_Tasks::schedule_update_transaction_with_payment(
284
+					time() + EE_Cron_Tasks::reschedule_timeout,
285
+					$TXN_ID,
286
+					$PAY_ID
287
+				);
288
+				continue;
289
+			}
290
+			$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
291
+			$payment     = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
292
+			// verify transaction
293
+			if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) {
294
+				// now try to update the TXN with any payments
295
+				$payment_processor->update_txn_based_on_payment($transaction, $payment, true, true);
296
+			}
297
+			unset(self::$_update_transactions_with_payment[$TXN_ID]);
298
+		}
299
+	}
300
+
301
+
302
+
303
+	/************  END OF UPDATE TRANSACTION WITH PAYMENT  ************/
304
+
305
+
306
+	/*****************  FINALIZE ABANDONED TRANSACTIONS *****************/
307
+
308
+
309
+	/**
310
+	 * array of TXN IDs
311
+	 *
312
+	 * @var array
313
+	 */
314
+	protected static $_abandoned_transactions = array();
315
+
316
+
317
+	/**
318
+	 * schedule_finalize_abandoned_transactions_check
319
+	 * sets a wp_schedule_single_event() for finalizing any TXNs that may
320
+	 * have been abandoned during the registration process
321
+	 *
322
+	 * @param int $timestamp
323
+	 * @param int $TXN_ID
324
+	 */
325
+	public static function schedule_finalize_abandoned_transactions_check(
326
+		$timestamp,
327
+		$TXN_ID
328
+	) {
329
+		// validate $TXN_ID and $timestamp
330
+		$TXN_ID    = absint($TXN_ID);
331
+		$timestamp = absint($timestamp);
332
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
333
+		if ($TXN_ID && $timestamp) {
334
+			wp_schedule_single_event(
335
+				$timestamp,
336
+				'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
337
+				array($TXN_ID)
338
+			);
339
+		}
340
+	}
341
+
342
+
343
+	/**
344
+	 * check_for_abandoned_transactions
345
+	 * this is the callback for the action hook:
346
+	 * 'AHEE__EE_Cron_Tasks__espresso_finalize_abandoned_transactions'
347
+	 * which is utilized by wp_schedule_single_event()
348
+	 * in EE_SPCO_Reg_Step_Payment_Options::_post_payment_processing().
349
+	 * The passed TXN_ID gets added to an array, and then the
350
+	 * espresso_finalize_abandoned_transactions() function is hooked into
351
+	 * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the
352
+	 * processing of any abandoned transactions, because doing so now would be
353
+	 * too early and the required resources may not be available
354
+	 *
355
+	 * @param int $TXN_ID
356
+	 */
357
+	public static function check_for_abandoned_transactions($TXN_ID = 0)
358
+	{
359
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
360
+		if (absint($TXN_ID)) {
361
+			self::$_abandoned_transactions[] = $TXN_ID;
362
+			add_action(
363
+				'shutdown',
364
+				array('EE_Cron_Tasks', 'finalize_abandoned_transactions'),
365
+				5
366
+			);
367
+		}
368
+	}
369
+
370
+
371
+	/**
372
+	 * finalize_abandoned_transactions
373
+	 * loops through the self::$_abandoned_transactions array
374
+	 * and attempts to finalize any TXNs that have not been completed
375
+	 * but have had their sessions expired, most likely due to a user not
376
+	 * returning from an off-site payment gateway
377
+	 *
378
+	 * @throws \EE_Error
379
+	 */
380
+	public static function finalize_abandoned_transactions()
381
+	{
382
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
383
+		if (
384 384
 			// are there any TXNs that need cleaning up ?
385 385
 			empty( self::$_abandoned_transactions )
386 386
 			// reschedule the cron if we can't hit the db right now
@@ -389,45 +389,45 @@  discard block
 block discarded – undo
389 389
 				self::$_abandoned_transactions
390 390
 			)
391 391
 		) {
392
-            return;
393
-        }
394
-        /** @type EE_Transaction_Processor $transaction_processor */
395
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
396
-        // set revisit flag for txn processor
397
-        $transaction_processor->set_revisit(false);
398
-        /** @type EE_Payment_Processor $payment_processor */
399
-        $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
400
-        // load EEM_Transaction
401
-        EE_Registry::instance()->load_model('Transaction');
402
-        foreach (self::$_abandoned_transactions as $TXN_ID) {
403
-            do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
404
-            // reschedule the cron if we can't hit the db right now
405
-            if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
406
-                // reset cron job for finalizing the TXN
407
-                EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check(
408
-                    time() + EE_Cron_Tasks::reschedule_timeout,
409
-                    $TXN_ID
410
-                );
411
-                continue;
412
-            }
413
-            $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
414
-            // verify transaction
415
-            if ($transaction instanceof EE_Transaction) {
416
-                // don't finalize the TXN if it has already been completed
417
-                if ($transaction->all_reg_steps_completed() === true) {
418
-                    continue;
419
-                }
420
-                // let's simulate an IPN here which will trigger any notifications that need to go out
421
-                $payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true, true);
422
-                do_action('AHEE__EE_Cron_Tasks__finalize_abandoned_transactions__abandoned_transaction', $transaction);
423
-            }
424
-            unset(self::$_abandoned_transactions[$TXN_ID]);
425
-        }
426
-    }
427
-
428
-
429
-
430
-    /*************  END OF FINALIZE ABANDONED TRANSACTIONS  *************/
392
+			return;
393
+		}
394
+		/** @type EE_Transaction_Processor $transaction_processor */
395
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
396
+		// set revisit flag for txn processor
397
+		$transaction_processor->set_revisit(false);
398
+		/** @type EE_Payment_Processor $payment_processor */
399
+		$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
400
+		// load EEM_Transaction
401
+		EE_Registry::instance()->load_model('Transaction');
402
+		foreach (self::$_abandoned_transactions as $TXN_ID) {
403
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
404
+			// reschedule the cron if we can't hit the db right now
405
+			if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
406
+				// reset cron job for finalizing the TXN
407
+				EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check(
408
+					time() + EE_Cron_Tasks::reschedule_timeout,
409
+					$TXN_ID
410
+				);
411
+				continue;
412
+			}
413
+			$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
414
+			// verify transaction
415
+			if ($transaction instanceof EE_Transaction) {
416
+				// don't finalize the TXN if it has already been completed
417
+				if ($transaction->all_reg_steps_completed() === true) {
418
+					continue;
419
+				}
420
+				// let's simulate an IPN here which will trigger any notifications that need to go out
421
+				$payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true, true);
422
+				do_action('AHEE__EE_Cron_Tasks__finalize_abandoned_transactions__abandoned_transaction', $transaction);
423
+			}
424
+			unset(self::$_abandoned_transactions[$TXN_ID]);
425
+		}
426
+	}
427
+
428
+
429
+
430
+	/*************  END OF FINALIZE ABANDONED TRANSACTIONS  *************/
431 431
 
432 432
 
433 433
 	/*****************  EXPIRED TRANSACTION CHECK *****************/
@@ -496,12 +496,12 @@  discard block
 block discarded – undo
496 496
 
497 497
 
498 498
 
499
-    /**
500
-     * process_expired_transactions
501
-     * loops through the self::$_expired_transactions array and processes any failed TXNs
502
-     *
503
-     * @throws \EE_Error
504
-     */
499
+	/**
500
+	 * process_expired_transactions
501
+	 * loops through the self::$_expired_transactions array and processes any failed TXNs
502
+	 *
503
+	 * @throws \EE_Error
504
+	 */
505 505
 	public static function process_expired_transactions() {
506 506
 		if (
507 507
 			// are there any TXNs that need cleaning up ?
@@ -512,58 +512,58 @@  discard block
 block discarded – undo
512 512
 				self::$_expired_transactions
513 513
 			)
514 514
 		) {
515
-            return;
516
-        }
517
-        /** @type EE_Transaction_Processor $transaction_processor */
518
-        $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
519
-        // set revisit flag for txn processor
520
-        $transaction_processor->set_revisit( false );
521
-         // load EEM_Transaction
522
-        EE_Registry::instance()->load_model( 'Transaction' );
523
-        foreach ( self::$_expired_transactions as $TXN_ID ) {
524
-            $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
525
-            // verify transaction and whether it is failed or not
526
-            if ( $transaction instanceof EE_Transaction) {
527
-                switch( $transaction->status_ID() ) {
528
-                    // Completed TXNs
529
-                    case EEM_Transaction::complete_status_code :
530
-                        do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction );
531
-                        break;
532
-                    // Overpaid TXNs
533
-                    case EEM_Transaction::overpaid_status_code :
534
-                        do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction );
535
-                        break;
536
-                    // Incomplete TXNs
537
-                    case EEM_Transaction::incomplete_status_code :
538
-                        do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction );
539
-                        // todo : merge the finalize_abandoned_transactions cron into this one...
540
-                        // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions
541
-                        break;
542
-                    // Failed TXNs
543
-                    case EEM_Transaction::failed_status_code :
544
-                        do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction );
545
-                        // todo : perform garbage collection here and remove clean_out_junk_transactions()
546
-                        //$registrations = $transaction->registrations();
547
-                        //if ( ! empty( $registrations ) ) {
548
-                        //	foreach ( $registrations as $registration ) {
549
-                        //		if ( $registration instanceof EE_Registration ) {
550
-                        //$delete_registration = true;
551
-                        //if ( $registration->attendee() instanceof EE_Attendee ) {
552
-                        //	$delete_registration = false;
553
-                        //}
554
-                        //if ( $delete_registration ) {
555
-                        //	$registration->delete_permanently();
556
-                        //	$registration->delete_related_permanently();
557
-                        //}
558
-                        //		}
559
-                        //	}
560
-                        //}
561
-                        break;
562
-                }
563
-
564
-            }
565
-            unset( self::$_expired_transactions[ $TXN_ID ] );
566
-        }
515
+			return;
516
+		}
517
+		/** @type EE_Transaction_Processor $transaction_processor */
518
+		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
519
+		// set revisit flag for txn processor
520
+		$transaction_processor->set_revisit( false );
521
+		 // load EEM_Transaction
522
+		EE_Registry::instance()->load_model( 'Transaction' );
523
+		foreach ( self::$_expired_transactions as $TXN_ID ) {
524
+			$transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
525
+			// verify transaction and whether it is failed or not
526
+			if ( $transaction instanceof EE_Transaction) {
527
+				switch( $transaction->status_ID() ) {
528
+					// Completed TXNs
529
+					case EEM_Transaction::complete_status_code :
530
+						do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction );
531
+						break;
532
+					// Overpaid TXNs
533
+					case EEM_Transaction::overpaid_status_code :
534
+						do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction );
535
+						break;
536
+					// Incomplete TXNs
537
+					case EEM_Transaction::incomplete_status_code :
538
+						do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction );
539
+						// todo : merge the finalize_abandoned_transactions cron into this one...
540
+						// todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions
541
+						break;
542
+					// Failed TXNs
543
+					case EEM_Transaction::failed_status_code :
544
+						do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction );
545
+						// todo : perform garbage collection here and remove clean_out_junk_transactions()
546
+						//$registrations = $transaction->registrations();
547
+						//if ( ! empty( $registrations ) ) {
548
+						//	foreach ( $registrations as $registration ) {
549
+						//		if ( $registration instanceof EE_Registration ) {
550
+						//$delete_registration = true;
551
+						//if ( $registration->attendee() instanceof EE_Attendee ) {
552
+						//	$delete_registration = false;
553
+						//}
554
+						//if ( $delete_registration ) {
555
+						//	$registration->delete_permanently();
556
+						//	$registration->delete_related_permanently();
557
+						//}
558
+						//		}
559
+						//	}
560
+						//}
561
+						break;
562
+				}
563
+
564
+			}
565
+			unset( self::$_expired_transactions[ $TXN_ID ] );
566
+		}
567 567
 	}
568 568
 
569 569
 
@@ -571,33 +571,33 @@  discard block
 block discarded – undo
571 571
 	/*************  END OF EXPIRED TRANSACTION CHECK  *************/
572 572
 
573 573
 
574
-    /************* START CLEAN UP BOT TRANSACTIONS **********************/
575
-
576
-    //when a transaction is initially made, schedule this check.
577
-    //if it has NO REG data by the time it has expired, forget about it
578
-    public static function clean_out_junk_transactions()
579
-    {
580
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
581
-            EEM_Transaction::instance('')->delete_junk_transactions();
582
-            EEM_Registration::instance('')->delete_registrations_with_no_transaction();
583
-            EEM_Line_Item::instance('')->delete_line_items_with_no_transaction();
584
-        }
585
-    }
586
-
587
-
588
-
589
-    /**
590
-     * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that.
591
-     */
592
-    public static function clean_out_old_gateway_logs(){
593
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
594
-            $time_diff_for_comparison = apply_filters(
595
-                'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison',
596
-                "-1 week"
597
-            );
598
-            EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison));
599
-        }
600
-    }
574
+	/************* START CLEAN UP BOT TRANSACTIONS **********************/
575
+
576
+	//when a transaction is initially made, schedule this check.
577
+	//if it has NO REG data by the time it has expired, forget about it
578
+	public static function clean_out_junk_transactions()
579
+	{
580
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
581
+			EEM_Transaction::instance('')->delete_junk_transactions();
582
+			EEM_Registration::instance('')->delete_registrations_with_no_transaction();
583
+			EEM_Line_Item::instance('')->delete_line_items_with_no_transaction();
584
+		}
585
+	}
586
+
587
+
588
+
589
+	/**
590
+	 * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that.
591
+	 */
592
+	public static function clean_out_old_gateway_logs(){
593
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
594
+			$time_diff_for_comparison = apply_filters(
595
+				'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison',
596
+				"-1 week"
597
+			);
598
+			EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison));
599
+		}
600
+	}
601 601
 
602 602
 
603 603
 }
Please login to merge, or discard this patch.
caffeinated/payment_methods/Aim/EEG_Aim.gateway.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -329,7 +329,7 @@
 block discarded – undo
329 329
 	/**
330 330
 	 * Posts the request to AuthorizeNet & returns response.
331 331
 	 *
332
-	 * @param $payment
332
+	 * @param EEI_Payment $payment
333 333
 	 * @return \EE_AuthorizeNetAIM_Response
334 334
 	 */
335 335
 	private function _sendRequest($payment) {
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if (!defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5
+}
5 6
 
6 7
 /**
7 8
  * Event Espresso
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEG_Aim extends EE_Onsite_Gateway{
28
+class EEG_Aim extends EE_Onsite_Gateway {
29 29
 
30 30
 	const LIVE_URL    = 'https://secure2.authorize.net/gateway/transact.dll'; //Authnet URL
31 31
 
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 	 * @param EEG_Aim $gateway_object
158 158
 	 * @return string
159 159
 	 */
160
-	public function possibly_use_deprecated_aim_server( $url, EEG_Aim $gateway_object ) {
161
-		if(  $gateway_object->_server === 'authorize.net'
162
-			&& ! $gateway_object->_debug_mode ) {
160
+	public function possibly_use_deprecated_aim_server($url, EEG_Aim $gateway_object) {
161
+		if ($gateway_object->_server === 'authorize.net'
162
+			&& ! $gateway_object->_debug_mode) {
163 163
 			return 'https://secure.authorize.net/gateway/transact.dll';
164 164
 		} else {
165 165
 			return $url;
@@ -182,33 +182,33 @@  discard block
 block discarded – undo
182 182
 	 */
183 183
 
184 184
 	public function do_direct_payment($payment, $billing_info = null) {
185
-			add_filter( 'FHEE__EEG_Aim___get_server_url', array( $this, 'possibly_use_deprecated_aim_server' ), 10, 2 );
185
+			add_filter('FHEE__EEG_Aim___get_server_url', array($this, 'possibly_use_deprecated_aim_server'), 10, 2);
186 186
 			// Enable test mode if needed
187 187
 			//4007000000027  <-- test successful visa
188 188
 			//4222222222222  <-- test failure card number
189 189
 
190 190
 			$item_num = 1;
191 191
 			$transaction = $payment->transaction();
192
-			$order_description = $this->_format_order_description( $payment );
192
+			$order_description = $this->_format_order_description($payment);
193 193
 			$primary_registrant = $transaction->primary_registration();
194 194
 			//if we're are charging for the full amount, show the normal line items
195 195
 			//and the itemized total adds up properly
196
-			if( $this->_can_easily_itemize_transaction_for( $payment ) ){
196
+			if ($this->_can_easily_itemize_transaction_for($payment)) {
197 197
 				$total_line_item = $transaction->total_line_item();
198 198
 				foreach ($total_line_item->get_items() as $line_item) {
199
-					if( $line_item->quantity() == 0 ){
199
+					if ($line_item->quantity() == 0) {
200 200
 						continue;
201 201
 					}
202 202
 					$this->addLineItem(
203 203
 						$item_num++, 
204
-						$this->_format_line_item_name( $line_item, $payment ), 
205
-						$this->_format_line_item_desc( $line_item, $payment ), 
204
+						$this->_format_line_item_name($line_item, $payment), 
205
+						$this->_format_line_item_desc($line_item, $payment), 
206 206
 						$line_item->quantity(),
207 207
 						$line_item->unit_price(), 
208 208
 						'N');
209 209
 					$order_description .= $line_item->desc().', ';
210 210
 				}
211
-				foreach($total_line_item->tax_descendants() as $tax_line_item){
211
+				foreach ($total_line_item->tax_descendants() as $tax_line_item) {
212 212
 					$this->addLineItem($item_num++, $tax_line_item->name(), $tax_line_item->desc(), 1, $tax_line_item->total(), 'N');
213 213
 				}
214 214
 			}
@@ -219,18 +219,18 @@  discard block
 block discarded – undo
219 219
 			//start transaction
220 220
 			//if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id
221 221
 			$partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363';
222
-			$this->setField( 'solution_id', $partner_id );
222
+			$this->setField('solution_id', $partner_id);
223 223
 			$this->setField('amount', $this->format_currency($payment->amount()));
224
-			$this->setField('description',substr(rtrim($order_description, ', '), 0, 255));
225
-			$this->_set_sensitive_billing_data( $billing_info );
224
+			$this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
225
+			$this->_set_sensitive_billing_data($billing_info);
226 226
 			$this->setField('first_name', $billing_info['first_name']);
227 227
 			$this->setField('last_name', $billing_info['last_name']);
228 228
 			$this->setField('email', $billing_info['email']);
229 229
 			$this->setField('company', $billing_info['company']);
230 230
 			$this->setField('address', $billing_info['address'].' '.$billing_info['address2']);
231 231
 			$this->setField('city', $billing_info['city']);
232
-			$this->setField('state', $billing_info['state'] );
233
-			$this->setField('country', $billing_info['country'] );
232
+			$this->setField('state', $billing_info['state']);
233
+			$this->setField('country', $billing_info['country']);
234 234
 			$this->setField('zip', $billing_info['zip']);
235 235
 			$this->setField('fax', $billing_info['fax']);
236 236
 			$this->setField('cust_id', $primary_registrant->ID());
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 			//invoice_num would be nice to have it be unique per SPCO page-load, that way if users
239 239
 			//press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
240 240
 			//in which case, we need to generate teh invoice num per request right here...
241
-			$this->setField('invoice_num', wp_generate_password(12,false));//$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
241
+			$this->setField('invoice_num', wp_generate_password(12, false)); //$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
242 242
 			//tell AIM that any duplicates sent in the next 5 minutes are to be ignored
243
-            $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS );
243
+            $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
244 244
 
245 245
 
246 246
 			if ($this->_test_transactions) {
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			//Capture response
251 251
 			$this->type = "AUTH_CAPTURE";
252 252
 			$response = $this->_sendRequest($payment);
253
-			if (!empty($response)){
253
+			if ( ! empty($response)) {
254 254
 				if ($response->error_message) {
255 255
                     $payment->set_status($this->_pay_model->failed_status());
256 256
                     $payment->set_gateway_response($response->error_message);
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
                     $payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status();
259 259
                     $payment->set_status($payment_status);
260 260
                     //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
261
-                    $payment->set_amount( (float) $response->amount );
261
+                    $payment->set_amount((float) $response->amount);
262 262
                     $payment->set_gateway_response(
263 263
                         sprintf(
264 264
                             esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'),
@@ -271,14 +271,14 @@  discard block
 block discarded – undo
271 271
                     } else {
272 272
                         $txn_id = $response->transaction_id;
273 273
                     }
274
-                    $payment->set_txn_id_chq_nmbr( $txn_id );
274
+                    $payment->set_txn_id_chq_nmbr($txn_id);
275 275
                 }
276 276
 				$payment->set_extra_accntng($primary_registrant->reg_code());
277
-				$payment->set_details(print_r($response,true));
277
+				$payment->set_details(print_r($response, true));
278 278
 			} else {
279 279
 				$payment->set_status($this->_pay_model->failed_status());
280 280
 				$payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso'));
281
-				$payment->set_details(print_r($response,true));
281
+				$payment->set_details(print_r($response, true));
282 282
 			}
283 283
 		return $payment;
284 284
 	}
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 * what billing data gets sent
290 290
 	 * @param array $billing_info
291 291
 	 */
292
-	protected function _set_sensitive_billing_data( $billing_info ) {
292
+	protected function _set_sensitive_billing_data($billing_info) {
293 293
 		$this->setField('card_num', $billing_info['credit_card']);
294 294
 		$this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']);
295 295
 		$this->setField('card_code', $billing_info['cvv']);
@@ -347,23 +347,23 @@  discard block
 block discarded – undo
347 347
 		$this->_x_post_fields['tran_key'] = $this->_transaction_key;
348 348
 		$x_keys = array();
349 349
 		foreach ($this->_x_post_fields as $key => $value) {
350
-			$x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
350
+			$x_keys[] = "x_$key=".urlencode($this->_get_unsupported_character_remover()->format($value));
351 351
 		}
352 352
 		// Add line items
353 353
 		foreach ($this->_additional_line_items as $key => $value) {
354
-			$x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
354
+			$x_keys[] = "x_line_item=".urlencode($this->_get_unsupported_character_remover()->format($value));
355 355
 		}
356 356
 		$this->_log_clean_request($x_keys, $payment);
357 357
 		$post_url = $this->_get_server_url();
358 358
 		$curl_request = curl_init($post_url);
359
-        $post_body = implode("&",$x_keys);
359
+        $post_body = implode("&", $x_keys);
360 360
 		curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body);
361 361
 		curl_setopt($curl_request, CURLOPT_HEADER, 0);
362 362
 		curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
363 363
 		curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
364 364
 		curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
365 365
 		if ($this->VERIFY_PEER) {
366
-			curl_setopt($curl_request, CURLOPT_CAINFO, dirname( __DIR__ ) . '/ssl/cert.pem');
366
+			curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__).'/ssl/cert.pem');
367 367
 		} else {
368 368
 			curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
369 369
 		}
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 		$response = curl_exec($curl_request);
376 376
 
377 377
 		curl_close($curl_request);
378
-		$response_obj =  new EE_AuthorizeNetAIM_Response($response);
378
+		$response_obj = new EE_AuthorizeNetAIM_Response($response);
379 379
 
380 380
 		return $this->_log_and_clean_response($response_obj, $payment);
381 381
 	}
@@ -384,18 +384,18 @@  discard block
 block discarded – undo
384 384
 	 * @param array $request_array
385 385
 	 * @param EEI_Payment $payment
386 386
 	 */
387
-	protected function _log_clean_request($request_array,$payment){
388
-		$keys_to_filter_out = array( 'x_card_num', 'x_card_code', 'x_exp_date' );
389
-		foreach($request_array as $index => $keyvaltogether ) {
390
-			foreach( $keys_to_filter_out as $key ) {
391
-				if( strpos( $keyvaltogether, $key ) === 0 ){
387
+	protected function _log_clean_request($request_array, $payment) {
388
+		$keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
389
+		foreach ($request_array as $index => $keyvaltogether) {
390
+			foreach ($keys_to_filter_out as $key) {
391
+				if (strpos($keyvaltogether, $key) === 0) {
392 392
 					//found it at the first character
393 393
 					//so its one of them
394
-					unset( $request_array[ $index ] );
394
+					unset($request_array[$index]);
395 395
 				}
396 396
 			}
397 397
 		}
398
-		$this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url() ),$payment);
398
+		$this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url()), $payment);
399 399
 	}
400 400
 
401 401
 
@@ -407,9 +407,9 @@  discard block
 block discarded – undo
407 407
 	 * @param EE_Payment                  $payment
408 408
 	 * @return \EE_AuthorizeNetAIM_Response
409 409
 	 */
410
-	private function _log_and_clean_response($response_obj,$payment){
410
+	private function _log_and_clean_response($response_obj, $payment) {
411 411
 		$response_obj->account_number = '';
412
-		$this->log(array('AIM Response received:'=>(array)$response_obj),$payment);
412
+		$this->log(array('AIM Response received:'=>(array) $response_obj), $payment);
413 413
 		return $response_obj;
414 414
 	}
415 415
 
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 			// Split Array
509 509
 			$this->response = $response;
510 510
 			if ($encap_char) {
511
-				$this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
511
+				$this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
512 512
 			} else {
513 513
 				$this->_response_array = explode($delimiter, $response);
514 514
 			}
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 
592 592
 }
593 593
 
594
-if ( ! class_exists( 'AuthorizeNetException' ) ) {
594
+if ( ! class_exists('AuthorizeNetException')) {
595 595
 	/**
596 596
 	 * Class AuthorizeNetException
597 597
 	 *
@@ -607,8 +607,8 @@  discard block
 block discarded – undo
607 607
 		 * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
608 608
 		 * @since 5.1.0
609 609
 		 */
610
-		public function __construct( $message = "", $code = 0, Exception $previous = null ) {
611
-			parent::__construct( $message, $code, $previous );
610
+		public function __construct($message = "", $code = 0, Exception $previous = null) {
611
+			parent::__construct($message, $code, $previous);
612 612
 		}
613 613
 	}
614 614
 }
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 			//in which case, we need to generate teh invoice num per request right here...
241 241
 			$this->setField('invoice_num', wp_generate_password(12,false));//$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
242 242
 			//tell AIM that any duplicates sent in the next 5 minutes are to be ignored
243
-            $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS );
243
+			$this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS );
244 244
 
245 245
 
246 246
 			if ($this->_test_transactions) {
@@ -252,27 +252,27 @@  discard block
 block discarded – undo
252 252
 			$response = $this->_sendRequest($payment);
253 253
 			if (!empty($response)){
254 254
 				if ($response->error_message) {
255
-                    $payment->set_status($this->_pay_model->failed_status());
256
-                    $payment->set_gateway_response($response->error_message);
257
-                } else {
258
-                    $payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status();
259
-                    $payment->set_status($payment_status);
260
-                    //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
261
-                    $payment->set_amount( (float) $response->amount );
262
-                    $payment->set_gateway_response(
263
-                        sprintf(
264
-                            esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'),
265
-                            $response->response_reason_text,
266
-                            $response->response_reason_code
267
-                        )
268
-                    );
269
-                    if ($this->_debug_mode) {
270
-                        $txn_id = $response->invoice_number;
271
-                    } else {
272
-                        $txn_id = $response->transaction_id;
273
-                    }
274
-                    $payment->set_txn_id_chq_nmbr( $txn_id );
275
-                }
255
+					$payment->set_status($this->_pay_model->failed_status());
256
+					$payment->set_gateway_response($response->error_message);
257
+				} else {
258
+					$payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status();
259
+					$payment->set_status($payment_status);
260
+					//make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
261
+					$payment->set_amount( (float) $response->amount );
262
+					$payment->set_gateway_response(
263
+						sprintf(
264
+							esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'),
265
+							$response->response_reason_text,
266
+							$response->response_reason_code
267
+						)
268
+					);
269
+					if ($this->_debug_mode) {
270
+						$txn_id = $response->invoice_number;
271
+					} else {
272
+						$txn_id = $response->transaction_id;
273
+					}
274
+					$payment->set_txn_id_chq_nmbr( $txn_id );
275
+				}
276 276
 				$payment->set_extra_accntng($primary_registrant->reg_code());
277 277
 				$payment->set_details(print_r($response,true));
278 278
 			} else {
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 		$this->_log_clean_request($x_keys, $payment);
357 357
 		$post_url = $this->_get_server_url();
358 358
 		$curl_request = curl_init($post_url);
359
-        $post_body = implode("&",$x_keys);
359
+		$post_body = implode("&",$x_keys);
360 360
 		curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body);
361 361
 		curl_setopt($curl_request, CURLOPT_HEADER, 0);
362 362
 		curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 	public $requested_amount;
490 490
 	public $balance_on_card;
491 491
 	public $response; // The response string from AuthorizeNet.
492
-    public $error_message;
492
+	public $error_message;
493 493
 	private $_response_array = array(); // An array with the split response.
494 494
 
495 495
 	/**
@@ -521,9 +521,9 @@  discard block
 block discarded – undo
521 521
 				$this->approved = false;
522 522
 				$this->error = true;
523 523
 				$this->error_message = sprintf(
524
-				    esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'),
525
-                    esc_html($response)
526
-                );
524
+					esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'),
525
+					esc_html($response)
526
+				);
527 527
 				return;
528 528
 			}
529 529
 
@@ -584,9 +584,9 @@  discard block
 block discarded – undo
584 584
 			$this->approved = false;
585 585
 			$this->error = true;
586 586
 			$this->error_message = esc_html__(
587
-			    'Error connecting to Authorize.net',
588
-                'event_espresso'
589
-            );
587
+				'Error connecting to Authorize.net',
588
+				'event_espresso'
589
+			);
590 590
 		}
591 591
 	}
592 592
 
Please login to merge, or discard this patch.
core/helpers/EEH_Template.helper.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
      * _find_common_base_path
305 305
      * given two paths, this determines if there is a common base path between the two
306 306
      *
307
-     * @param array $paths
307
+     * @param string[] $paths
308 308
      * @return string
309 309
      */
310 310
     protected static function _find_common_base_path($paths)
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
      * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
335 335
      * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
336 336
      *                                      not found or is not readable
337
-     * @return mixed string
337
+     * @return string string
338 338
      * @throws \DomainException
339 339
      */
340 340
 	public static function display_template(
Please login to merge, or discard this patch.
Indentation   +930 added lines, -930 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Event Espresso
@@ -16,35 +16,35 @@  discard block
 block discarded – undo
16 16
 
17 17
 
18 18
 if ( ! function_exists('espresso_get_template_part')) {
19
-    /**
20
-     * espresso_get_template_part
21
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
22
-     * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
23
-     *
24
-     * @param string $slug The slug name for the generic template.
25
-     * @param string $name The name of the specialised template.
26
-     * @return string        the html output for the formatted money value
27
-     */
28
-    function espresso_get_template_part($slug = null, $name = null)
29
-    {
30
-        EEH_Template::get_template_part($slug, $name);
31
-    }
19
+	/**
20
+	 * espresso_get_template_part
21
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
22
+	 * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
23
+	 *
24
+	 * @param string $slug The slug name for the generic template.
25
+	 * @param string $name The name of the specialised template.
26
+	 * @return string        the html output for the formatted money value
27
+	 */
28
+	function espresso_get_template_part($slug = null, $name = null)
29
+	{
30
+		EEH_Template::get_template_part($slug, $name);
31
+	}
32 32
 }
33 33
 
34 34
 
35 35
 if ( ! function_exists('espresso_get_object_css_class')) {
36
-    /**
37
-     * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
38
-     *
39
-     * @param EE_Base_Class $object the EE object the css class is being generated for
40
-     * @param  string       $prefix added to the beginning of the generated class
41
-     * @param  string       $suffix added to the end of the generated class
42
-     * @return string
43
-     */
44
-    function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
45
-    {
46
-        return EEH_Template::get_object_css_class($object, $prefix, $suffix);
47
-    }
36
+	/**
37
+	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
38
+	 *
39
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
40
+	 * @param  string       $prefix added to the beginning of the generated class
41
+	 * @param  string       $suffix added to the end of the generated class
42
+	 * @return string
43
+	 */
44
+	function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
45
+	{
46
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
47
+	}
48 48
 }
49 49
 
50 50
 
@@ -59,650 +59,650 @@  discard block
 block discarded – undo
59 59
 class EEH_Template
60 60
 {
61 61
 
62
-    private static $_espresso_themes = array();
63
-
64
-
65
-    /**
66
-     *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
67
-     *
68
-     * @return boolean
69
-     */
70
-    public static function is_espresso_theme()
71
-    {
72
-        return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false;
73
-    }
74
-
75
-    /**
76
-     *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
77
-     *    load it's functions.php file ( if not already loaded )
78
-     *
79
-     * @return void
80
-     */
81
-    public static function load_espresso_theme_functions()
82
-    {
83
-        if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
84
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) {
85
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php');
86
-            }
87
-        }
88
-    }
89
-
90
-
91
-    /**
92
-     *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
93
-     *
94
-     * @return array
95
-     */
96
-    public static function get_espresso_themes()
97
-    {
98
-        if (empty(EEH_Template::$_espresso_themes)) {
99
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
100
-            if (empty($espresso_themes)) {
101
-                return array();
102
-            }
103
-            if (($key = array_search('global_assets', $espresso_themes)) !== false) {
104
-                unset($espresso_themes[$key]);
105
-            }
106
-            EEH_Template::$_espresso_themes = array();
107
-            foreach ($espresso_themes as $espresso_theme) {
108
-                EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
109
-            }
110
-        }
111
-        return EEH_Template::$_espresso_themes;
112
-    }
113
-
114
-
115
-    /**
116
-     * EEH_Template::get_template_part
117
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
118
-     * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
119
-     * filtering based off of the entire template part name
120
-     *
121
-     * @param string $slug The slug name for the generic template.
122
-     * @param string $name The name of the specialised template.
123
-     * @param array  $template_args
124
-     * @param bool   $return_string
125
-     * @return string        the html output for the formatted money value
126
-     */
127
-    public static function get_template_part(
128
-        $slug = null,
129
-        $name = null,
130
-        $template_args = array(),
131
-        $return_string = false
132
-    ) {
133
-        do_action("get_template_part_{$slug}-{$name}", $slug, $name);
134
-        $templates = array();
135
-        $name      = (string)$name;
136
-        if ($name != '') {
137
-            $templates[] = "{$slug}-{$name}.php";
138
-        }
139
-        // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
140
-        if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
141
-            EEH_Template::locate_template($templates, $template_args, true, $return_string);
142
-        }
143
-    }
144
-
145
-
146
-    /**
147
-     *    locate_template
148
-     *    locate a template file by looking in the following places, in the following order:
149
-     *        <server path up to>/wp-content/themes/<current active WordPress theme>/
150
-     *        <assumed full absolute server path>
151
-     *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
152
-     *        <server path up to>/wp-content/uploads/espresso/templates/
153
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
154
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
155
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/
156
-     *    as soon as the template is found in one of these locations, it will be returned or loaded
157
-     *        Example:
158
-     *          You are using the WordPress Twenty Sixteen theme,
159
-     *        and you want to customize the "some-event.template.php" template,
160
-     *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
161
-     *          Assuming WP is installed on your server in the "/home/public_html/" folder,
162
-     *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
163
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
164
-     *        /relative/path/to/some-event.template.php
165
-     *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
166
-     *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
167
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
168
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
169
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
170
-     *          Had you passed an absolute path to your template that was in some other location,
171
-     *        ie: "/absolute/path/to/some-event.template.php"
172
-     *          then the search would have been :
173
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
174
-     *        /absolute/path/to/some-event.template.php
175
-     *          and stopped there upon finding it in the second location
176
-     *
177
-     * @param array|string $templates       array of template file names including extension (or just a single string)
178
-     * @param  array       $template_args   an array of arguments to be extracted for use in the template
179
-     * @param  boolean     $load            whether to pass the located template path on to the
180
-     *                                      EEH_Template::display_template() method or simply return it
181
-     * @param  boolean     $return_string   whether to send output immediately to screen, or capture and return as a
182
-     *                                      string
183
-     * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
184
-     *                                      generate a custom template or not. Used in places where you don't actually
185
-     *                                      load the template, you just want to know if there's a custom version of it.
186
-     * @return mixed
187
-     */
188
-    public static function locate_template(
189
-        $templates = array(),
190
-        $template_args = array(),
191
-        $load = true,
192
-        $return_string = true,
193
-        $check_if_custom = false
194
-    ) {
195
-        // first use WP locate_template to check for template in the current theme folder
196
-        $template_path = locate_template($templates);
197
-
198
-        if ($check_if_custom && ! empty($template_path)) {
199
-            return true;
200
-        }
201
-
202
-        // not in the theme
203
-        if (empty($template_path)) {
204
-            // not even a template to look for ?
205
-            if (empty($templates)) {
206
-                // get post_type
207
-                $post_type = EE_Registry::instance()->REQ->get('post_type');
208
-                // get array of EE Custom Post Types
209
-                $EE_CPTs = EE_Register_CPTs::get_CPTs();
210
-                // build template name based on request
211
-                if (isset($EE_CPTs[$post_type])) {
212
-                    $archive_or_single = is_archive() ? 'archive' : '';
213
-                    $archive_or_single = is_single() ? 'single' : $archive_or_single;
214
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
215
-                }
216
-            }
217
-            // currently active EE template theme
218
-            $current_theme = EE_Config::get_current_theme();
219
-
220
-            // array of paths to folders that may contain templates
221
-            $template_folder_paths = array(
222
-                // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
223
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
224
-                // then in the root of the /wp-content/uploads/espresso/templates/ folder
225
-                EVENT_ESPRESSO_TEMPLATE_DIR,
226
-            );
227
-
228
-            //add core plugin folders for checking only if we're not $check_if_custom
229
-            if ( ! $check_if_custom) {
230
-                $core_paths            = array(
231
-                    // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
232
-                    EE_PUBLIC . $current_theme,
233
-                    // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
234
-                    EE_TEMPLATES . $current_theme,
235
-                    // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
236
-                    EE_PLUGIN_DIR_PATH,
237
-                );
238
-                $template_folder_paths = array_merge($template_folder_paths, $core_paths);
239
-            }
240
-
241
-            // now filter that array
242
-            $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths',
243
-                $template_folder_paths);
244
-            $templates             = is_array($templates) ? $templates : array($templates);
245
-            $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths);
246
-            // array to hold all possible template paths
247
-            $full_template_paths = array();
248
-
249
-            // loop through $templates
250
-            foreach ($templates as $template) {
251
-                // normalize directory separators
252
-                $template                      = EEH_File::standardise_directory_separators($template);
253
-                $file_name                     = basename($template);
254
-                $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
255
-                // while looping through all template folder paths
256
-                foreach ($template_folder_paths as $template_folder_path) {
257
-                    // normalize directory separators
258
-                    $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
259
-                    // determine if any common base path exists between the two paths
260
-                    $common_base_path = EEH_Template::_find_common_base_path(
261
-                        array($template_folder_path, $template_path_minus_file_name)
262
-                    );
263
-                    if ($common_base_path !== '') {
264
-                        // both paths have a common base, so just tack the filename onto our search path
265
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
266
-                    } else {
267
-                        // no common base path, so let's just concatenate
268
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
269
-                    }
270
-                    // build up our template locations array by adding our resolved paths
271
-                    $full_template_paths[] = $resolved_path;
272
-                }
273
-                // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
274
-                array_unshift($full_template_paths, $template);
275
-                // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
276
-                array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name);
277
-            }
278
-            // filter final array of full template paths
279
-            $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths',
280
-                $full_template_paths, $file_name);
281
-            // now loop through our final array of template location paths and check each location
282
-            foreach ((array)$full_template_paths as $full_template_path) {
283
-                if (is_readable($full_template_path)) {
284
-                    $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
285
-                    break;
286
-                }
287
-            }
288
-        }
289
-
290
-        // hook that can be used to display the full template path that will be used
291
-        do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
292
-
293
-        // if we got it and you want to see it...
294
-        if ($template_path && $load && ! $check_if_custom) {
295
-            if ($return_string) {
296
-                return EEH_Template::display_template($template_path, $template_args, true);
297
-            } else {
298
-                EEH_Template::display_template($template_path, $template_args, false);
299
-            }
300
-        }
301
-        return $check_if_custom && ! empty($template_path) ? true : $template_path;
302
-    }
303
-
304
-
305
-    /**
306
-     * _find_common_base_path
307
-     * given two paths, this determines if there is a common base path between the two
308
-     *
309
-     * @param array $paths
310
-     * @return string
311
-     */
312
-    protected static function _find_common_base_path($paths)
313
-    {
314
-        $last_offset      = 0;
315
-        $common_base_path = '';
316
-        while (($index = strpos($paths[0], DS, $last_offset)) !== false) {
317
-            $dir_length = $index - $last_offset + 1;
318
-            $directory  = substr($paths[0], $last_offset, $dir_length);
319
-            foreach ($paths as $path) {
320
-                if (substr($path, $last_offset, $dir_length) != $directory) {
321
-                    return $common_base_path;
322
-                }
323
-            }
324
-            $common_base_path .= $directory;
325
-            $last_offset = $index + 1;
326
-        }
327
-        return substr($common_base_path, 0, -1);
328
-    }
329
-
330
-
331
-    /**
332
-     * load and display a template
333
-     *
334
-     * @param bool|string $template_path server path to the file to be loaded, including file name and extension
335
-     * @param  array      $template_args an array of arguments to be extracted for use in the template
336
-     * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
337
-     * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
338
-     *                                      not found or is not readable
339
-     * @return mixed string
340
-     * @throws \DomainException
341
-     */
62
+	private static $_espresso_themes = array();
63
+
64
+
65
+	/**
66
+	 *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
67
+	 *
68
+	 * @return boolean
69
+	 */
70
+	public static function is_espresso_theme()
71
+	{
72
+		return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false;
73
+	}
74
+
75
+	/**
76
+	 *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
77
+	 *    load it's functions.php file ( if not already loaded )
78
+	 *
79
+	 * @return void
80
+	 */
81
+	public static function load_espresso_theme_functions()
82
+	{
83
+		if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
84
+			if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) {
85
+				require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php');
86
+			}
87
+		}
88
+	}
89
+
90
+
91
+	/**
92
+	 *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
93
+	 *
94
+	 * @return array
95
+	 */
96
+	public static function get_espresso_themes()
97
+	{
98
+		if (empty(EEH_Template::$_espresso_themes)) {
99
+			$espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
100
+			if (empty($espresso_themes)) {
101
+				return array();
102
+			}
103
+			if (($key = array_search('global_assets', $espresso_themes)) !== false) {
104
+				unset($espresso_themes[$key]);
105
+			}
106
+			EEH_Template::$_espresso_themes = array();
107
+			foreach ($espresso_themes as $espresso_theme) {
108
+				EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
109
+			}
110
+		}
111
+		return EEH_Template::$_espresso_themes;
112
+	}
113
+
114
+
115
+	/**
116
+	 * EEH_Template::get_template_part
117
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
118
+	 * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
119
+	 * filtering based off of the entire template part name
120
+	 *
121
+	 * @param string $slug The slug name for the generic template.
122
+	 * @param string $name The name of the specialised template.
123
+	 * @param array  $template_args
124
+	 * @param bool   $return_string
125
+	 * @return string        the html output for the formatted money value
126
+	 */
127
+	public static function get_template_part(
128
+		$slug = null,
129
+		$name = null,
130
+		$template_args = array(),
131
+		$return_string = false
132
+	) {
133
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
134
+		$templates = array();
135
+		$name      = (string)$name;
136
+		if ($name != '') {
137
+			$templates[] = "{$slug}-{$name}.php";
138
+		}
139
+		// allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
140
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
141
+			EEH_Template::locate_template($templates, $template_args, true, $return_string);
142
+		}
143
+	}
144
+
145
+
146
+	/**
147
+	 *    locate_template
148
+	 *    locate a template file by looking in the following places, in the following order:
149
+	 *        <server path up to>/wp-content/themes/<current active WordPress theme>/
150
+	 *        <assumed full absolute server path>
151
+	 *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
152
+	 *        <server path up to>/wp-content/uploads/espresso/templates/
153
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
154
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
155
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/
156
+	 *    as soon as the template is found in one of these locations, it will be returned or loaded
157
+	 *        Example:
158
+	 *          You are using the WordPress Twenty Sixteen theme,
159
+	 *        and you want to customize the "some-event.template.php" template,
160
+	 *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
161
+	 *          Assuming WP is installed on your server in the "/home/public_html/" folder,
162
+	 *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
163
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
164
+	 *        /relative/path/to/some-event.template.php
165
+	 *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
166
+	 *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
167
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
168
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
169
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
170
+	 *          Had you passed an absolute path to your template that was in some other location,
171
+	 *        ie: "/absolute/path/to/some-event.template.php"
172
+	 *          then the search would have been :
173
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
174
+	 *        /absolute/path/to/some-event.template.php
175
+	 *          and stopped there upon finding it in the second location
176
+	 *
177
+	 * @param array|string $templates       array of template file names including extension (or just a single string)
178
+	 * @param  array       $template_args   an array of arguments to be extracted for use in the template
179
+	 * @param  boolean     $load            whether to pass the located template path on to the
180
+	 *                                      EEH_Template::display_template() method or simply return it
181
+	 * @param  boolean     $return_string   whether to send output immediately to screen, or capture and return as a
182
+	 *                                      string
183
+	 * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
184
+	 *                                      generate a custom template or not. Used in places where you don't actually
185
+	 *                                      load the template, you just want to know if there's a custom version of it.
186
+	 * @return mixed
187
+	 */
188
+	public static function locate_template(
189
+		$templates = array(),
190
+		$template_args = array(),
191
+		$load = true,
192
+		$return_string = true,
193
+		$check_if_custom = false
194
+	) {
195
+		// first use WP locate_template to check for template in the current theme folder
196
+		$template_path = locate_template($templates);
197
+
198
+		if ($check_if_custom && ! empty($template_path)) {
199
+			return true;
200
+		}
201
+
202
+		// not in the theme
203
+		if (empty($template_path)) {
204
+			// not even a template to look for ?
205
+			if (empty($templates)) {
206
+				// get post_type
207
+				$post_type = EE_Registry::instance()->REQ->get('post_type');
208
+				// get array of EE Custom Post Types
209
+				$EE_CPTs = EE_Register_CPTs::get_CPTs();
210
+				// build template name based on request
211
+				if (isset($EE_CPTs[$post_type])) {
212
+					$archive_or_single = is_archive() ? 'archive' : '';
213
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
214
+					$templates         = $archive_or_single . '-' . $post_type . '.php';
215
+				}
216
+			}
217
+			// currently active EE template theme
218
+			$current_theme = EE_Config::get_current_theme();
219
+
220
+			// array of paths to folders that may contain templates
221
+			$template_folder_paths = array(
222
+				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
223
+				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
224
+				// then in the root of the /wp-content/uploads/espresso/templates/ folder
225
+				EVENT_ESPRESSO_TEMPLATE_DIR,
226
+			);
227
+
228
+			//add core plugin folders for checking only if we're not $check_if_custom
229
+			if ( ! $check_if_custom) {
230
+				$core_paths            = array(
231
+					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
232
+					EE_PUBLIC . $current_theme,
233
+					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
234
+					EE_TEMPLATES . $current_theme,
235
+					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
236
+					EE_PLUGIN_DIR_PATH,
237
+				);
238
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
239
+			}
240
+
241
+			// now filter that array
242
+			$template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths',
243
+				$template_folder_paths);
244
+			$templates             = is_array($templates) ? $templates : array($templates);
245
+			$template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths);
246
+			// array to hold all possible template paths
247
+			$full_template_paths = array();
248
+
249
+			// loop through $templates
250
+			foreach ($templates as $template) {
251
+				// normalize directory separators
252
+				$template                      = EEH_File::standardise_directory_separators($template);
253
+				$file_name                     = basename($template);
254
+				$template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
255
+				// while looping through all template folder paths
256
+				foreach ($template_folder_paths as $template_folder_path) {
257
+					// normalize directory separators
258
+					$template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
259
+					// determine if any common base path exists between the two paths
260
+					$common_base_path = EEH_Template::_find_common_base_path(
261
+						array($template_folder_path, $template_path_minus_file_name)
262
+					);
263
+					if ($common_base_path !== '') {
264
+						// both paths have a common base, so just tack the filename onto our search path
265
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
266
+					} else {
267
+						// no common base path, so let's just concatenate
268
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
269
+					}
270
+					// build up our template locations array by adding our resolved paths
271
+					$full_template_paths[] = $resolved_path;
272
+				}
273
+				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
274
+				array_unshift($full_template_paths, $template);
275
+				// path to the directory of the current theme: /wp-content/themes/(current WP theme)/
276
+				array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name);
277
+			}
278
+			// filter final array of full template paths
279
+			$full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths',
280
+				$full_template_paths, $file_name);
281
+			// now loop through our final array of template location paths and check each location
282
+			foreach ((array)$full_template_paths as $full_template_path) {
283
+				if (is_readable($full_template_path)) {
284
+					$template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
285
+					break;
286
+				}
287
+			}
288
+		}
289
+
290
+		// hook that can be used to display the full template path that will be used
291
+		do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
292
+
293
+		// if we got it and you want to see it...
294
+		if ($template_path && $load && ! $check_if_custom) {
295
+			if ($return_string) {
296
+				return EEH_Template::display_template($template_path, $template_args, true);
297
+			} else {
298
+				EEH_Template::display_template($template_path, $template_args, false);
299
+			}
300
+		}
301
+		return $check_if_custom && ! empty($template_path) ? true : $template_path;
302
+	}
303
+
304
+
305
+	/**
306
+	 * _find_common_base_path
307
+	 * given two paths, this determines if there is a common base path between the two
308
+	 *
309
+	 * @param array $paths
310
+	 * @return string
311
+	 */
312
+	protected static function _find_common_base_path($paths)
313
+	{
314
+		$last_offset      = 0;
315
+		$common_base_path = '';
316
+		while (($index = strpos($paths[0], DS, $last_offset)) !== false) {
317
+			$dir_length = $index - $last_offset + 1;
318
+			$directory  = substr($paths[0], $last_offset, $dir_length);
319
+			foreach ($paths as $path) {
320
+				if (substr($path, $last_offset, $dir_length) != $directory) {
321
+					return $common_base_path;
322
+				}
323
+			}
324
+			$common_base_path .= $directory;
325
+			$last_offset = $index + 1;
326
+		}
327
+		return substr($common_base_path, 0, -1);
328
+	}
329
+
330
+
331
+	/**
332
+	 * load and display a template
333
+	 *
334
+	 * @param bool|string $template_path server path to the file to be loaded, including file name and extension
335
+	 * @param  array      $template_args an array of arguments to be extracted for use in the template
336
+	 * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
337
+	 * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
338
+	 *                                      not found or is not readable
339
+	 * @return mixed string
340
+	 * @throws \DomainException
341
+	 */
342 342
 	public static function display_template(
343
-        $template_path    = false,
344
-        $template_args    = array(),
345
-        $return_string    = false,
346
-        $throw_exceptions = false
347
-    ) {
348
-
349
-        /**
350
-         * These two filters are intended for last minute changes to templates being loaded and/or template arg
351
-         * modifications.  NOTE... modifying these things can cause breakage as most templates running through
352
-         * the display_template method are templates we DON'T want modified (usually because of js
353
-         * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
354
-         * using this.
355
-         *
356
-         * @since 4.6.0
357
-         */
358
-        $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
359
-        $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
360
-
361
-        // you gimme nuttin - YOU GET NUTTIN !!
362
-        if ( ! $template_path || ! is_readable($template_path)) {
363
-            return '';
364
-        }
365
-        // if $template_args are not in an array, then make it so
366
-        if ( ! is_array($template_args) && ! is_object($template_args)) {
367
-            $template_args = array($template_args);
368
-        }
369
-        extract( $template_args, EXTR_SKIP );
370
-        // ignore whether template is accessible ?
371
-        if ( $throw_exceptions && ! is_readable( $template_path ) ) {
372
-            throw new \DomainException(
373
-                    esc_html__(
374
-                            'Invalid, unreadable, or missing file.',
375
-                            'event_espresso'
376
-                    )
377
-            );
378
-        }
379
-
380
-
381
-        if ($return_string) {
382
-            // because we want to return a string, we are going to capture the output
383
-            ob_start();
384
-            include($template_path);
385
-            return ob_get_clean();
386
-        } else {
387
-            include($template_path);
388
-        }
389
-        return '';
390
-    }
391
-
392
-
393
-    /**
394
-     * get_object_css_class - attempts to generate a css class based on the type of EE object passed
395
-     *
396
-     * @param EE_Base_Class $object the EE object the css class is being generated for
397
-     * @param  string       $prefix added to the beginning of the generated class
398
-     * @param  string       $suffix added to the end of the generated class
399
-     * @return string
400
-     */
401
-    public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
402
-    {
403
-        // in the beginning...
404
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
405
-        // da muddle
406
-        $class = '';
407
-        // the end
408
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
409
-        // is the passed object an EE object ?
410
-        if ($object instanceof EE_Base_Class) {
411
-            // grab the exact type of object
412
-            $obj_class = get_class($object);
413
-            // depending on the type of object...
414
-            switch ($obj_class) {
415
-                // no specifics just yet...
416
-                default :
417
-                    $class = strtolower(str_replace('_', '-', $obj_class));
418
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
419
-
420
-            }
421
-        }
422
-        return $prefix . $class . $suffix;
423
-    }
424
-
425
-
426
-
427
-    /**
428
-     * EEH_Template::format_currency
429
-     * This helper takes a raw float value and formats it according to the default config country currency settings, or
430
-     * the country currency settings from the supplied country ISO code
431
-     *
432
-     * @param  float   $amount       raw money value
433
-     * @param  boolean $return_raw   whether to return the formatted float value only with no currency sign or code
434
-     * @param  boolean $display_code whether to display the country code (USD). Default = TRUE
435
-     * @param string   $CNT_ISO      2 letter ISO code for a country
436
-     * @param string   $cur_code_span_class
437
-     * @return string        the html output for the formatted money value
438
-     * @throws \EE_Error
439
-     */
440
-    public static function format_currency(
441
-        $amount = null,
442
-        $return_raw = false,
443
-        $display_code = true,
444
-        $CNT_ISO = '',
445
-        $cur_code_span_class = 'currency-code'
446
-    ) {
447
-        // ensure amount was received
448
-        if ($amount === null) {
449
-            $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso');
450
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
451
-            return '';
452
-        }
453
-        //ensure amount is float
454
-        $amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount);
455
-        $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
456
-        // filter raw amount (allows 0.00 to be changed to "free" for example)
457
-        $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
458
-        // still a number or was amount converted to a string like "free" ?
459
-        if (is_float($amount_formatted)) {
460
-            // was a country ISO code passed ? if so generate currency config object for that country
461
-            $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
462
-            // verify results
463
-            if ( ! $mny instanceof EE_Currency_Config) {
464
-                // set default config country currency settings
465
-                $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
466
-                    ? EE_Registry::instance()->CFG->currency
467
-                    : new EE_Currency_Config();
468
-            }
469
-            // format float
470
-            $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
471
-            // add formatting ?
472
-            if ( ! $return_raw) {
473
-                // add currency sign
474
-                if ($mny->sign_b4) {
475
-                    if ($amount >= 0) {
476
-                        $amount_formatted = $mny->sign . $amount_formatted;
477
-                    } else {
478
-                        $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
479
-                    }
480
-
481
-                } else {
482
-                    $amount_formatted = $amount_formatted . $mny->sign;
483
-                }
484
-
485
-                // filter to allow global setting of display_code
486
-                $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code);
487
-
488
-                // add currency code ?
489
-                $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
490
-            }
491
-            // filter results
492
-            $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted',
493
-                $amount_formatted, $mny, $return_raw);
494
-        }
495
-        // clean up vars
496
-        unset($mny);
497
-        // return formatted currency amount
498
-        return $amount_formatted;
499
-    }
500
-
501
-
502
-    /**
503
-     * This function is used for outputting the localized label for a given status id in the schema requested (and
504
-     * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
505
-     * related status model or model object (i.e. in documentation etc.)
506
-     *
507
-     * @param  string  $status_id Status ID matching a registered status in the esp_status table.  If there is no
508
-     *                            match, then 'Unknown' will be returned.
509
-     * @param  boolean $plural    Whether to return plural or not
510
-     * @param  string  $schema    'UPPER', 'lower', or 'Sentence'
511
-     * @return string             The localized label for the status id.
512
-     */
513
-    public static function pretty_status($status_id, $plural = false, $schema = 'upper')
514
-    {
515
-        /** @type EEM_Status $EEM_Status */
516
-        $EEM_Status = EE_Registry::instance()->load_model('Status');
517
-        $status     = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural,
518
-            $schema);
519
-        return $status[$status_id];
520
-    }
521
-
522
-
523
-    /**
524
-     * This helper just returns a button or link for the given parameters
525
-     *
526
-     * @param  string $url   the url for the link
527
-     * @param  string $label What is the label you want displayed for the button
528
-     * @param  string $class what class is used for the button (defaults to 'button-primary')
529
-     * @param string  $icon
530
-     * @param string  $title
531
-     * @return string the html output for the button
532
-     */
533
-    public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
534
-    {
535
-        $icon_html = '';
536
-        if ( ! empty($icon)) {
537
-            $dashicons = preg_split("(ee-icon |dashicons )", $icon);
538
-            $dashicons = array_filter($dashicons);
539
-            $count     = count($dashicons);
540
-            $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
541
-            foreach ($dashicons as $dashicon) {
542
-                $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
543
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
544
-            }
545
-            $icon_html .= $count > 1 ? '</span>' : '';
546
-        }
547
-        $label  = ! empty($icon) ? $icon_html . $label : $label;
548
-        $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
549
-        return $button;
550
-    }
551
-
552
-
553
-    /**
554
-     * This returns a generated link that will load the related help tab on admin pages.
555
-     *
556
-     * @param  string     $help_tab_id the id for the connected help tab
557
-     * @param bool|string $page        The page identifier for the page the help tab is on
558
-     * @param bool|string $action      The action (route) for the admin page the help tab is on.
559
-     * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
560
-     * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
561
-     * @return string              generated link
562
-     */
563
-    public static function get_help_tab_link(
564
-        $help_tab_id,
565
-        $page = false,
566
-        $action = false,
567
-        $icon_style = false,
568
-        $help_text = false
569
-    ) {
570
-
571
-        if ( ! $page) {
572
-            $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
573
-        }
574
-
575
-        if ( ! $action) {
576
-            $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
577
-        }
578
-
579
-        $action = empty($action) ? 'default' : $action;
580
-
581
-
582
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
583
-        $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
584
-        $help_text    = ! $help_text ? '' : $help_text;
585
-        return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
586
-                'event_espresso') . '" > ' . $help_text . ' </a>';
587
-    }
588
-
589
-
590
-    /**
591
-     * This helper generates the html structure for the jquery joyride plugin with the given params.
592
-     *
593
-     * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
594
-     * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
595
-     * @param EE_Help_Tour
596
-     * @return string         html
597
-     */
598
-    public static function help_tour_stops_generator(EE_Help_Tour $tour)
599
-    {
600
-        $id    = $tour->get_slug();
601
-        $stops = $tour->get_stops();
602
-
603
-        $content = '<ol style="display:none" id="' . $id . '">';
604
-
605
-        foreach ($stops as $stop) {
606
-            $data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
607
-            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
608
-
609
-            //if container is set to modal then let's make sure we set the options accordingly
610
-            if (empty($data_id) && empty($data_class)) {
611
-                $stop['options']['modal']  = true;
612
-                $stop['options']['expose'] = true;
613
-            }
614
-
615
-            $custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
616
-            $button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
617
-            $inner_content = isset($stop['content']) ? $stop['content'] : '';
618
-
619
-            //options
620
-            if (isset($stop['options']) && is_array($stop['options'])) {
621
-                $options = ' data-options="';
622
-                foreach ($stop['options'] as $option => $value) {
623
-                    $options .= $option . ':' . $value . ';';
624
-                }
625
-                $options .= '"';
626
-            } else {
627
-                $options = '';
628
-            }
629
-
630
-            //let's put all together
631
-            $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
632
-        }
633
-
634
-        $content .= '</ol>';
635
-        return $content;
636
-    }
637
-
638
-
639
-    /**
640
-     * This is a helper method to generate a status legend for a given status array.
641
-     * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
642
-     * status_array.
643
-     *
644
-     * @param  array  $status_array  array of statuses that will make up the legend. In format:
645
-     *                               array(
646
-     *                               'status_item' => 'status_name'
647
-     *                               )
648
-     * @param  string $active_status This is used to indicate what the active status is IF that is to be highlighted in
649
-     *                               the legend.
650
-     * @throws EE_Error
651
-     * @return string               html structure for status.
652
-     */
653
-    public static function status_legend($status_array, $active_status = '')
654
-    {
655
-        if ( ! is_array($status_array)) {
656
-            throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
657
-                'event_espresso'));
658
-        }
659
-
660
-        $setup_array = array();
661
-        foreach ($status_array as $item => $status) {
662
-            $setup_array[$item] = array(
663
-                'class'  => 'ee-status-legend ee-status-legend-' . $status,
664
-                'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
665
-                'status' => $status,
666
-            );
667
-        }
668
-
669
-        $content = '<div class="ee-list-table-legend-container">' . "\n";
670
-        $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
671
-        $content .= '<dl class="ee-list-table-legend">' . "\n\t";
672
-        foreach ($setup_array as $item => $details) {
673
-            $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
674
-            $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
675
-            $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
676
-            $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
677
-            $content .= '</dt>' . "\n";
678
-        }
679
-        $content .= '</dl>' . "\n";
680
-        $content .= '</div>' . "\n";
681
-        return $content;
682
-    }
683
-
684
-
685
-    /**
686
-     * Gets HTML for laying out a deeply-nested array (and objects) in a format
687
-     * that's nice for presenting in the wp admin
688
-     *
689
-     * @param mixed $data
690
-     * @return string
691
-     */
692
-    public static function layout_array_as_table($data)
693
-    {
694
-        if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
695
-            $data = (array)$data;
696
-        }
697
-        ob_start();
698
-        if (is_array($data)) {
699
-            if (EEH_Array::is_associative_array($data)) {
700
-                ?>
343
+		$template_path    = false,
344
+		$template_args    = array(),
345
+		$return_string    = false,
346
+		$throw_exceptions = false
347
+	) {
348
+
349
+		/**
350
+		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
351
+		 * modifications.  NOTE... modifying these things can cause breakage as most templates running through
352
+		 * the display_template method are templates we DON'T want modified (usually because of js
353
+		 * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
354
+		 * using this.
355
+		 *
356
+		 * @since 4.6.0
357
+		 */
358
+		$template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
359
+		$template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
360
+
361
+		// you gimme nuttin - YOU GET NUTTIN !!
362
+		if ( ! $template_path || ! is_readable($template_path)) {
363
+			return '';
364
+		}
365
+		// if $template_args are not in an array, then make it so
366
+		if ( ! is_array($template_args) && ! is_object($template_args)) {
367
+			$template_args = array($template_args);
368
+		}
369
+		extract( $template_args, EXTR_SKIP );
370
+		// ignore whether template is accessible ?
371
+		if ( $throw_exceptions && ! is_readable( $template_path ) ) {
372
+			throw new \DomainException(
373
+					esc_html__(
374
+							'Invalid, unreadable, or missing file.',
375
+							'event_espresso'
376
+					)
377
+			);
378
+		}
379
+
380
+
381
+		if ($return_string) {
382
+			// because we want to return a string, we are going to capture the output
383
+			ob_start();
384
+			include($template_path);
385
+			return ob_get_clean();
386
+		} else {
387
+			include($template_path);
388
+		}
389
+		return '';
390
+	}
391
+
392
+
393
+	/**
394
+	 * get_object_css_class - attempts to generate a css class based on the type of EE object passed
395
+	 *
396
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
397
+	 * @param  string       $prefix added to the beginning of the generated class
398
+	 * @param  string       $suffix added to the end of the generated class
399
+	 * @return string
400
+	 */
401
+	public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
402
+	{
403
+		// in the beginning...
404
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
405
+		// da muddle
406
+		$class = '';
407
+		// the end
408
+		$suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
409
+		// is the passed object an EE object ?
410
+		if ($object instanceof EE_Base_Class) {
411
+			// grab the exact type of object
412
+			$obj_class = get_class($object);
413
+			// depending on the type of object...
414
+			switch ($obj_class) {
415
+				// no specifics just yet...
416
+				default :
417
+					$class = strtolower(str_replace('_', '-', $obj_class));
418
+					$class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
419
+
420
+			}
421
+		}
422
+		return $prefix . $class . $suffix;
423
+	}
424
+
425
+
426
+
427
+	/**
428
+	 * EEH_Template::format_currency
429
+	 * This helper takes a raw float value and formats it according to the default config country currency settings, or
430
+	 * the country currency settings from the supplied country ISO code
431
+	 *
432
+	 * @param  float   $amount       raw money value
433
+	 * @param  boolean $return_raw   whether to return the formatted float value only with no currency sign or code
434
+	 * @param  boolean $display_code whether to display the country code (USD). Default = TRUE
435
+	 * @param string   $CNT_ISO      2 letter ISO code for a country
436
+	 * @param string   $cur_code_span_class
437
+	 * @return string        the html output for the formatted money value
438
+	 * @throws \EE_Error
439
+	 */
440
+	public static function format_currency(
441
+		$amount = null,
442
+		$return_raw = false,
443
+		$display_code = true,
444
+		$CNT_ISO = '',
445
+		$cur_code_span_class = 'currency-code'
446
+	) {
447
+		// ensure amount was received
448
+		if ($amount === null) {
449
+			$msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso');
450
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
451
+			return '';
452
+		}
453
+		//ensure amount is float
454
+		$amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount);
455
+		$CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
456
+		// filter raw amount (allows 0.00 to be changed to "free" for example)
457
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
458
+		// still a number or was amount converted to a string like "free" ?
459
+		if (is_float($amount_formatted)) {
460
+			// was a country ISO code passed ? if so generate currency config object for that country
461
+			$mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
462
+			// verify results
463
+			if ( ! $mny instanceof EE_Currency_Config) {
464
+				// set default config country currency settings
465
+				$mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
466
+					? EE_Registry::instance()->CFG->currency
467
+					: new EE_Currency_Config();
468
+			}
469
+			// format float
470
+			$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
471
+			// add formatting ?
472
+			if ( ! $return_raw) {
473
+				// add currency sign
474
+				if ($mny->sign_b4) {
475
+					if ($amount >= 0) {
476
+						$amount_formatted = $mny->sign . $amount_formatted;
477
+					} else {
478
+						$amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
479
+					}
480
+
481
+				} else {
482
+					$amount_formatted = $amount_formatted . $mny->sign;
483
+				}
484
+
485
+				// filter to allow global setting of display_code
486
+				$display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code);
487
+
488
+				// add currency code ?
489
+				$amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
490
+			}
491
+			// filter results
492
+			$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted',
493
+				$amount_formatted, $mny, $return_raw);
494
+		}
495
+		// clean up vars
496
+		unset($mny);
497
+		// return formatted currency amount
498
+		return $amount_formatted;
499
+	}
500
+
501
+
502
+	/**
503
+	 * This function is used for outputting the localized label for a given status id in the schema requested (and
504
+	 * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
505
+	 * related status model or model object (i.e. in documentation etc.)
506
+	 *
507
+	 * @param  string  $status_id Status ID matching a registered status in the esp_status table.  If there is no
508
+	 *                            match, then 'Unknown' will be returned.
509
+	 * @param  boolean $plural    Whether to return plural or not
510
+	 * @param  string  $schema    'UPPER', 'lower', or 'Sentence'
511
+	 * @return string             The localized label for the status id.
512
+	 */
513
+	public static function pretty_status($status_id, $plural = false, $schema = 'upper')
514
+	{
515
+		/** @type EEM_Status $EEM_Status */
516
+		$EEM_Status = EE_Registry::instance()->load_model('Status');
517
+		$status     = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural,
518
+			$schema);
519
+		return $status[$status_id];
520
+	}
521
+
522
+
523
+	/**
524
+	 * This helper just returns a button or link for the given parameters
525
+	 *
526
+	 * @param  string $url   the url for the link
527
+	 * @param  string $label What is the label you want displayed for the button
528
+	 * @param  string $class what class is used for the button (defaults to 'button-primary')
529
+	 * @param string  $icon
530
+	 * @param string  $title
531
+	 * @return string the html output for the button
532
+	 */
533
+	public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
534
+	{
535
+		$icon_html = '';
536
+		if ( ! empty($icon)) {
537
+			$dashicons = preg_split("(ee-icon |dashicons )", $icon);
538
+			$dashicons = array_filter($dashicons);
539
+			$count     = count($dashicons);
540
+			$icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
541
+			foreach ($dashicons as $dashicon) {
542
+				$type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
543
+				$icon_html .= '<span class="' . $type . $dashicon . '"></span>';
544
+			}
545
+			$icon_html .= $count > 1 ? '</span>' : '';
546
+		}
547
+		$label  = ! empty($icon) ? $icon_html . $label : $label;
548
+		$button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
549
+		return $button;
550
+	}
551
+
552
+
553
+	/**
554
+	 * This returns a generated link that will load the related help tab on admin pages.
555
+	 *
556
+	 * @param  string     $help_tab_id the id for the connected help tab
557
+	 * @param bool|string $page        The page identifier for the page the help tab is on
558
+	 * @param bool|string $action      The action (route) for the admin page the help tab is on.
559
+	 * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
560
+	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
561
+	 * @return string              generated link
562
+	 */
563
+	public static function get_help_tab_link(
564
+		$help_tab_id,
565
+		$page = false,
566
+		$action = false,
567
+		$icon_style = false,
568
+		$help_text = false
569
+	) {
570
+
571
+		if ( ! $page) {
572
+			$page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
573
+		}
574
+
575
+		if ( ! $action) {
576
+			$action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
577
+		}
578
+
579
+		$action = empty($action) ? 'default' : $action;
580
+
581
+
582
+		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
583
+		$icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
584
+		$help_text    = ! $help_text ? '' : $help_text;
585
+		return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
586
+				'event_espresso') . '" > ' . $help_text . ' </a>';
587
+	}
588
+
589
+
590
+	/**
591
+	 * This helper generates the html structure for the jquery joyride plugin with the given params.
592
+	 *
593
+	 * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
594
+	 * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
595
+	 * @param EE_Help_Tour
596
+	 * @return string         html
597
+	 */
598
+	public static function help_tour_stops_generator(EE_Help_Tour $tour)
599
+	{
600
+		$id    = $tour->get_slug();
601
+		$stops = $tour->get_stops();
602
+
603
+		$content = '<ol style="display:none" id="' . $id . '">';
604
+
605
+		foreach ($stops as $stop) {
606
+			$data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
607
+			$data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
608
+
609
+			//if container is set to modal then let's make sure we set the options accordingly
610
+			if (empty($data_id) && empty($data_class)) {
611
+				$stop['options']['modal']  = true;
612
+				$stop['options']['expose'] = true;
613
+			}
614
+
615
+			$custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
616
+			$button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
617
+			$inner_content = isset($stop['content']) ? $stop['content'] : '';
618
+
619
+			//options
620
+			if (isset($stop['options']) && is_array($stop['options'])) {
621
+				$options = ' data-options="';
622
+				foreach ($stop['options'] as $option => $value) {
623
+					$options .= $option . ':' . $value . ';';
624
+				}
625
+				$options .= '"';
626
+			} else {
627
+				$options = '';
628
+			}
629
+
630
+			//let's put all together
631
+			$content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
632
+		}
633
+
634
+		$content .= '</ol>';
635
+		return $content;
636
+	}
637
+
638
+
639
+	/**
640
+	 * This is a helper method to generate a status legend for a given status array.
641
+	 * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
642
+	 * status_array.
643
+	 *
644
+	 * @param  array  $status_array  array of statuses that will make up the legend. In format:
645
+	 *                               array(
646
+	 *                               'status_item' => 'status_name'
647
+	 *                               )
648
+	 * @param  string $active_status This is used to indicate what the active status is IF that is to be highlighted in
649
+	 *                               the legend.
650
+	 * @throws EE_Error
651
+	 * @return string               html structure for status.
652
+	 */
653
+	public static function status_legend($status_array, $active_status = '')
654
+	{
655
+		if ( ! is_array($status_array)) {
656
+			throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
657
+				'event_espresso'));
658
+		}
659
+
660
+		$setup_array = array();
661
+		foreach ($status_array as $item => $status) {
662
+			$setup_array[$item] = array(
663
+				'class'  => 'ee-status-legend ee-status-legend-' . $status,
664
+				'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
665
+				'status' => $status,
666
+			);
667
+		}
668
+
669
+		$content = '<div class="ee-list-table-legend-container">' . "\n";
670
+		$content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
671
+		$content .= '<dl class="ee-list-table-legend">' . "\n\t";
672
+		foreach ($setup_array as $item => $details) {
673
+			$active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
674
+			$content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
675
+			$content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
676
+			$content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
677
+			$content .= '</dt>' . "\n";
678
+		}
679
+		$content .= '</dl>' . "\n";
680
+		$content .= '</div>' . "\n";
681
+		return $content;
682
+	}
683
+
684
+
685
+	/**
686
+	 * Gets HTML for laying out a deeply-nested array (and objects) in a format
687
+	 * that's nice for presenting in the wp admin
688
+	 *
689
+	 * @param mixed $data
690
+	 * @return string
691
+	 */
692
+	public static function layout_array_as_table($data)
693
+	{
694
+		if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
695
+			$data = (array)$data;
696
+		}
697
+		ob_start();
698
+		if (is_array($data)) {
699
+			if (EEH_Array::is_associative_array($data)) {
700
+				?>
701 701
                 <table class="widefat">
702 702
                     <tbody>
703 703
                     <?php
704
-                    foreach ($data as $data_key => $data_values) {
705
-                        ?>
704
+					foreach ($data as $data_key => $data_values) {
705
+						?>
706 706
                         <tr>
707 707
                             <td>
708 708
                                 <?php echo $data_key; ?>
@@ -712,248 +712,248 @@  discard block
 block discarded – undo
712 712
                             </td>
713 713
                         </tr>
714 714
                         <?php
715
-                    } ?>
715
+					} ?>
716 716
                     </tbody>
717 717
                 </table>
718 718
                 <?php
719
-            } else {
720
-                ?>
719
+			} else {
720
+				?>
721 721
                 <ul>
722 722
                     <?php
723
-                    foreach ($data as $datum) {
724
-                        echo "<li>";
725
-                        echo self::layout_array_as_table($datum);
726
-                        echo "</li>";
727
-                    } ?>
723
+					foreach ($data as $datum) {
724
+						echo "<li>";
725
+						echo self::layout_array_as_table($datum);
726
+						echo "</li>";
727
+					} ?>
728 728
                 </ul>
729 729
                 <?php
730
-            }
731
-        } else {
732
-            //simple value
733
-            echo esc_html($data);
734
-        }
735
-        return ob_get_clean();
736
-    }
737
-
738
-
739
-    /**
740
-     * wrapper for self::get_paging_html() that simply echos the generated paging html
741
-     *
742
-     * @since 4.4.0
743
-     * @see   self:get_paging_html() for argument docs.
744
-     * @param        $total_items
745
-     * @param        $current
746
-     * @param        $per_page
747
-     * @param        $url
748
-     * @param bool   $show_num_field
749
-     * @param string $paged_arg_name
750
-     * @param array  $items_label
751
-     * @return string
752
-     */
753
-    public static function paging_html(
754
-        $total_items,
755
-        $current,
756
-        $per_page,
757
-        $url,
758
-        $show_num_field = true,
759
-        $paged_arg_name = 'paged',
760
-        $items_label = array()
761
-    ) {
762
-        echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name,
763
-            $items_label);
764
-    }
765
-
766
-
767
-    /**
768
-     * A method for generating paging similar to WP_List_Table
769
-     *
770
-     * @since    4.4.0
771
-     * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
772
-     * @param  integer $total_items     How many total items there are to page.
773
-     * @param  integer $current         What the current page is.
774
-     * @param  integer $per_page        How many items per page.
775
-     * @param  string  $url             What the base url for page links is.
776
-     * @param  boolean $show_num_field  Whether to show the input for changing page number.
777
-     * @param  string  $paged_arg_name  The name of the key for the paged query argument.
778
-     * @param  array   $items_label     An array of singular/plural values for the items label:
779
-     *                                  array(
780
-     *                                  'single' => 'item',
781
-     *                                  'plural' => 'items'
782
-     *                                  )
783
-     * @return  string
784
-     */
785
-    public static function get_paging_html(
786
-        $total_items,
787
-        $current,
788
-        $per_page,
789
-        $url,
790
-        $show_num_field = true,
791
-        $paged_arg_name = 'paged',
792
-        $items_label = array()
793
-    ) {
794
-        $page_links     = array();
795
-        $disable_first  = $disable_last = '';
796
-        $total_items    = (int)$total_items;
797
-        $per_page       = (int)$per_page;
798
-        $current        = (int)$current;
799
-        $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
800
-
801
-        //filter items_label
802
-        $items_label = apply_filters(
803
-            'FHEE__EEH_Template__get_paging_html__items_label',
804
-            $items_label
805
-        );
806
-
807
-        if (empty($items_label)
808
-            || ! is_array($items_label)
809
-            || ! isset($items_label['single'])
810
-            || ! isset($items_label['plural'])
811
-        ) {
812
-            $items_label = array(
813
-                'single' => __('1 item', 'event_espresso'),
814
-                'plural' => __('%s items', 'event_espresso'),
815
-            );
816
-        } else {
817
-            $items_label = array(
818
-                'single' => '1 ' . esc_html($items_label['single']),
819
-                'plural' => '%s ' . esc_html($items_label['plural']),
820
-            );
821
-        }
822
-
823
-        $total_pages = ceil($total_items / $per_page);
824
-
825
-        if ($total_pages <= 1) {
826
-            return '';
827
-        }
828
-
829
-        $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
830
-
831
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
832
-
833
-        if ($current === 1) {
834
-            $disable_first = ' disabled';
835
-        }
836
-        if ($current == $total_pages) {
837
-            $disable_last = ' disabled';
838
-        }
839
-
840
-        $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
841
-            'first-page' . $disable_first,
842
-            esc_attr__('Go to the first page'),
843
-            esc_url(remove_query_arg($paged_arg_name, $url)),
844
-            '&laquo;'
845
-        );
846
-
847
-        $page_links[] = sprintf(
848
-            '<a class="%s" title="%s" href="%s">%s</a>',
849
-            'prev-page' . $disable_first,
850
-            esc_attr__('Go to the previous page'),
851
-            esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
852
-            '&lsaquo;'
853
-        );
854
-
855
-        if ( ! $show_num_field) {
856
-            $html_current_page = $current;
857
-        } else {
858
-            $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
859
-                esc_attr__('Current page'),
860
-                $current,
861
-                strlen($total_pages)
862
-            );
863
-        }
864
-
865
-        $html_total_pages = sprintf(
866
-            '<span class="total-pages">%s</span>',
867
-            number_format_i18n($total_pages)
868
-        );
869
-        $page_links[]     = sprintf(
870
-            _x('%3$s%1$s of %2$s%4$s', 'paging'),
871
-            $html_current_page,
872
-            $html_total_pages,
873
-            '<span class="paging-input">',
874
-            '</span>'
875
-        );
876
-
877
-        $page_links[] = sprintf(
878
-            '<a class="%s" title="%s" href="%s">%s</a>',
879
-            'next-page' . $disable_last,
880
-            esc_attr__('Go to the next page'),
881
-            esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
882
-            '&rsaquo;'
883
-        );
884
-
885
-        $page_links[] = sprintf(
886
-            '<a class="%s" title="%s" href="%s">%s</a>',
887
-            'last-page' . $disable_last,
888
-            esc_attr__('Go to the last page'),
889
-            esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
890
-            '&raquo;'
891
-        );
892
-
893
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
894
-        // set page class
895
-        if ($total_pages) {
896
-            $page_class = $total_pages < 2 ? ' one-page' : '';
897
-        } else {
898
-            $page_class = ' no-pages';
899
-        }
900
-
901
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
902
-    }
903
-
904
-
905
-    /**
906
-     * @param string $wrap_class
907
-     * @param string $wrap_id
908
-     * @return string
909
-     */
910
-    public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array())
911
-    {
912
-        $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
913
-        if (
914
-            ! $admin &&
915
-            ! apply_filters(
916
-                'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
917
-                EE_Registry::instance()->CFG->admin->show_reg_footer
918
-            )
919
-        ) {
920
-            return '';
921
-        }
922
-        $tag        = $admin ? 'span' : 'div';
923
-        $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
924
-        $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
925
-        $attributes .= ! empty($wrap_class)
926
-            ? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
927
-            : ' class="powered-by-event-espresso-credit"';
928
-        $query_args = array_merge(
929
-            array(
930
-                'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
931
-                'utm_source'   => 'powered_by_event_espresso',
932
-                'utm_medium'   => 'link',
933
-                'utm_campaign' => 'powered_by',
934
-            ),
935
-            $query_args
936
-        );
937
-        $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text',
938
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso');
939
-        $url        = add_query_arg($query_args, 'https://eventespresso.com/');
940
-        $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
941
-        return (string)apply_filters(
942
-            'FHEE__EEH_Template__powered_by_event_espresso__html',
943
-            sprintf(
944
-                esc_html_x(
945
-                    '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
946
-                    'Online event registration and ticketing powered by [link to eventespresso.com]',
947
-                    'event_espresso'
948
-                ),
949
-                "<{$tag}{$attributes}>",
950
-                "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
951
-                $admin ? '' : '<br />'
952
-            ),
953
-            $wrap_class,
954
-            $wrap_id
955
-        );
956
-    }
730
+			}
731
+		} else {
732
+			//simple value
733
+			echo esc_html($data);
734
+		}
735
+		return ob_get_clean();
736
+	}
737
+
738
+
739
+	/**
740
+	 * wrapper for self::get_paging_html() that simply echos the generated paging html
741
+	 *
742
+	 * @since 4.4.0
743
+	 * @see   self:get_paging_html() for argument docs.
744
+	 * @param        $total_items
745
+	 * @param        $current
746
+	 * @param        $per_page
747
+	 * @param        $url
748
+	 * @param bool   $show_num_field
749
+	 * @param string $paged_arg_name
750
+	 * @param array  $items_label
751
+	 * @return string
752
+	 */
753
+	public static function paging_html(
754
+		$total_items,
755
+		$current,
756
+		$per_page,
757
+		$url,
758
+		$show_num_field = true,
759
+		$paged_arg_name = 'paged',
760
+		$items_label = array()
761
+	) {
762
+		echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name,
763
+			$items_label);
764
+	}
765
+
766
+
767
+	/**
768
+	 * A method for generating paging similar to WP_List_Table
769
+	 *
770
+	 * @since    4.4.0
771
+	 * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
772
+	 * @param  integer $total_items     How many total items there are to page.
773
+	 * @param  integer $current         What the current page is.
774
+	 * @param  integer $per_page        How many items per page.
775
+	 * @param  string  $url             What the base url for page links is.
776
+	 * @param  boolean $show_num_field  Whether to show the input for changing page number.
777
+	 * @param  string  $paged_arg_name  The name of the key for the paged query argument.
778
+	 * @param  array   $items_label     An array of singular/plural values for the items label:
779
+	 *                                  array(
780
+	 *                                  'single' => 'item',
781
+	 *                                  'plural' => 'items'
782
+	 *                                  )
783
+	 * @return  string
784
+	 */
785
+	public static function get_paging_html(
786
+		$total_items,
787
+		$current,
788
+		$per_page,
789
+		$url,
790
+		$show_num_field = true,
791
+		$paged_arg_name = 'paged',
792
+		$items_label = array()
793
+	) {
794
+		$page_links     = array();
795
+		$disable_first  = $disable_last = '';
796
+		$total_items    = (int)$total_items;
797
+		$per_page       = (int)$per_page;
798
+		$current        = (int)$current;
799
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
800
+
801
+		//filter items_label
802
+		$items_label = apply_filters(
803
+			'FHEE__EEH_Template__get_paging_html__items_label',
804
+			$items_label
805
+		);
806
+
807
+		if (empty($items_label)
808
+			|| ! is_array($items_label)
809
+			|| ! isset($items_label['single'])
810
+			|| ! isset($items_label['plural'])
811
+		) {
812
+			$items_label = array(
813
+				'single' => __('1 item', 'event_espresso'),
814
+				'plural' => __('%s items', 'event_espresso'),
815
+			);
816
+		} else {
817
+			$items_label = array(
818
+				'single' => '1 ' . esc_html($items_label['single']),
819
+				'plural' => '%s ' . esc_html($items_label['plural']),
820
+			);
821
+		}
822
+
823
+		$total_pages = ceil($total_items / $per_page);
824
+
825
+		if ($total_pages <= 1) {
826
+			return '';
827
+		}
828
+
829
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
830
+
831
+		$output = '<span class="displaying-num">' . $item_label . '</span>';
832
+
833
+		if ($current === 1) {
834
+			$disable_first = ' disabled';
835
+		}
836
+		if ($current == $total_pages) {
837
+			$disable_last = ' disabled';
838
+		}
839
+
840
+		$page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
841
+			'first-page' . $disable_first,
842
+			esc_attr__('Go to the first page'),
843
+			esc_url(remove_query_arg($paged_arg_name, $url)),
844
+			'&laquo;'
845
+		);
846
+
847
+		$page_links[] = sprintf(
848
+			'<a class="%s" title="%s" href="%s">%s</a>',
849
+			'prev-page' . $disable_first,
850
+			esc_attr__('Go to the previous page'),
851
+			esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
852
+			'&lsaquo;'
853
+		);
854
+
855
+		if ( ! $show_num_field) {
856
+			$html_current_page = $current;
857
+		} else {
858
+			$html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
859
+				esc_attr__('Current page'),
860
+				$current,
861
+				strlen($total_pages)
862
+			);
863
+		}
864
+
865
+		$html_total_pages = sprintf(
866
+			'<span class="total-pages">%s</span>',
867
+			number_format_i18n($total_pages)
868
+		);
869
+		$page_links[]     = sprintf(
870
+			_x('%3$s%1$s of %2$s%4$s', 'paging'),
871
+			$html_current_page,
872
+			$html_total_pages,
873
+			'<span class="paging-input">',
874
+			'</span>'
875
+		);
876
+
877
+		$page_links[] = sprintf(
878
+			'<a class="%s" title="%s" href="%s">%s</a>',
879
+			'next-page' . $disable_last,
880
+			esc_attr__('Go to the next page'),
881
+			esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
882
+			'&rsaquo;'
883
+		);
884
+
885
+		$page_links[] = sprintf(
886
+			'<a class="%s" title="%s" href="%s">%s</a>',
887
+			'last-page' . $disable_last,
888
+			esc_attr__('Go to the last page'),
889
+			esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
890
+			'&raquo;'
891
+		);
892
+
893
+		$output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
894
+		// set page class
895
+		if ($total_pages) {
896
+			$page_class = $total_pages < 2 ? ' one-page' : '';
897
+		} else {
898
+			$page_class = ' no-pages';
899
+		}
900
+
901
+		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
902
+	}
903
+
904
+
905
+	/**
906
+	 * @param string $wrap_class
907
+	 * @param string $wrap_id
908
+	 * @return string
909
+	 */
910
+	public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array())
911
+	{
912
+		$admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
913
+		if (
914
+			! $admin &&
915
+			! apply_filters(
916
+				'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
917
+				EE_Registry::instance()->CFG->admin->show_reg_footer
918
+			)
919
+		) {
920
+			return '';
921
+		}
922
+		$tag        = $admin ? 'span' : 'div';
923
+		$attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
924
+		$wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
925
+		$attributes .= ! empty($wrap_class)
926
+			? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
927
+			: ' class="powered-by-event-espresso-credit"';
928
+		$query_args = array_merge(
929
+			array(
930
+				'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
931
+				'utm_source'   => 'powered_by_event_espresso',
932
+				'utm_medium'   => 'link',
933
+				'utm_campaign' => 'powered_by',
934
+			),
935
+			$query_args
936
+		);
937
+		$powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text',
938
+			$admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso');
939
+		$url        = add_query_arg($query_args, 'https://eventespresso.com/');
940
+		$url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
941
+		return (string)apply_filters(
942
+			'FHEE__EEH_Template__powered_by_event_espresso__html',
943
+			sprintf(
944
+				esc_html_x(
945
+					'%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
946
+					'Online event registration and ticketing powered by [link to eventespresso.com]',
947
+					'event_espresso'
948
+				),
949
+				"<{$tag}{$attributes}>",
950
+				"<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
951
+				$admin ? '' : '<br />'
952
+			),
953
+			$wrap_class,
954
+			$wrap_id
955
+		);
956
+	}
957 957
 
958 958
 
959 959
 } //end EEH_Template class
@@ -962,33 +962,33 @@  discard block
 block discarded – undo
962 962
 
963 963
 
964 964
 if ( ! function_exists('espresso_pagination')) {
965
-    /**
966
-     *    espresso_pagination
967
-     *
968
-     * @access    public
969
-     * @return    void
970
-     */
971
-    function espresso_pagination()
972
-    {
973
-        global $wp_query;
974
-        $big        = 999999999; // need an unlikely integer
975
-        $pagination = paginate_links(
976
-            array(
977
-                'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
978
-                'format'       => '?paged=%#%',
979
-                'current'      => max(1, get_query_var('paged')),
980
-                'total'        => $wp_query->max_num_pages,
981
-                'show_all'     => true,
982
-                'end_size'     => 10,
983
-                'mid_size'     => 6,
984
-                'prev_next'    => true,
985
-                'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
986
-                'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
987
-                'type'         => 'plain',
988
-                'add_args'     => false,
989
-                'add_fragment' => '',
990
-            )
991
-        );
992
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : '';
993
-    }
965
+	/**
966
+	 *    espresso_pagination
967
+	 *
968
+	 * @access    public
969
+	 * @return    void
970
+	 */
971
+	function espresso_pagination()
972
+	{
973
+		global $wp_query;
974
+		$big        = 999999999; // need an unlikely integer
975
+		$pagination = paginate_links(
976
+			array(
977
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
978
+				'format'       => '?paged=%#%',
979
+				'current'      => max(1, get_query_var('paged')),
980
+				'total'        => $wp_query->max_num_pages,
981
+				'show_all'     => true,
982
+				'end_size'     => 10,
983
+				'mid_size'     => 6,
984
+				'prev_next'    => true,
985
+				'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
986
+				'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
987
+				'type'         => 'plain',
988
+				'add_args'     => false,
989
+				'add_fragment' => '',
990
+			)
991
+		);
992
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : '';
993
+	}
994 994
 }
995 995
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 /**
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     public static function load_espresso_theme_functions()
82 82
     {
83 83
         if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
84
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) {
85
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php');
84
+            if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) {
85
+                require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php');
86 86
             }
87 87
         }
88 88
     }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     public static function get_espresso_themes()
97 97
     {
98 98
         if (empty(EEH_Template::$_espresso_themes)) {
99
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
99
+            $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
100 100
             if (empty($espresso_themes)) {
101 101
                 return array();
102 102
             }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     ) {
133 133
         do_action("get_template_part_{$slug}-{$name}", $slug, $name);
134 134
         $templates = array();
135
-        $name      = (string)$name;
135
+        $name      = (string) $name;
136 136
         if ($name != '') {
137 137
             $templates[] = "{$slug}-{$name}.php";
138 138
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                 if (isset($EE_CPTs[$post_type])) {
212 212
                     $archive_or_single = is_archive() ? 'archive' : '';
213 213
                     $archive_or_single = is_single() ? 'single' : $archive_or_single;
214
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
214
+                    $templates         = $archive_or_single.'-'.$post_type.'.php';
215 215
                 }
216 216
             }
217 217
             // currently active EE template theme
@@ -220,18 +220,18 @@  discard block
 block discarded – undo
220 220
             // array of paths to folders that may contain templates
221 221
             $template_folder_paths = array(
222 222
                 // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
223
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
223
+                EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
224 224
                 // then in the root of the /wp-content/uploads/espresso/templates/ folder
225 225
                 EVENT_ESPRESSO_TEMPLATE_DIR,
226 226
             );
227 227
 
228 228
             //add core plugin folders for checking only if we're not $check_if_custom
229 229
             if ( ! $check_if_custom) {
230
-                $core_paths            = array(
230
+                $core_paths = array(
231 231
                     // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
232
-                    EE_PUBLIC . $current_theme,
232
+                    EE_PUBLIC.$current_theme,
233 233
                     // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
234
-                    EE_TEMPLATES . $current_theme,
234
+                    EE_TEMPLATES.$current_theme,
235 235
                     // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
236 236
                     EE_PLUGIN_DIR_PATH,
237 237
                 );
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
                     );
263 263
                     if ($common_base_path !== '') {
264 264
                         // both paths have a common base, so just tack the filename onto our search path
265
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
265
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name;
266 266
                     } else {
267 267
                         // no common base path, so let's just concatenate
268
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
268
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template;
269 269
                     }
270 270
                     // build up our template locations array by adding our resolved paths
271 271
                     $full_template_paths[] = $resolved_path;
@@ -273,13 +273,13 @@  discard block
 block discarded – undo
273 273
                 // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
274 274
                 array_unshift($full_template_paths, $template);
275 275
                 // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
276
-                array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name);
276
+                array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name);
277 277
             }
278 278
             // filter final array of full template paths
279 279
             $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths',
280 280
                 $full_template_paths, $file_name);
281 281
             // now loop through our final array of template location paths and check each location
282
-            foreach ((array)$full_template_paths as $full_template_path) {
282
+            foreach ((array) $full_template_paths as $full_template_path) {
283 283
                 if (is_readable($full_template_path)) {
284 284
                     $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
285 285
                     break;
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
         if ( ! is_array($template_args) && ! is_object($template_args)) {
367 367
             $template_args = array($template_args);
368 368
         }
369
-        extract( $template_args, EXTR_SKIP );
369
+        extract($template_args, EXTR_SKIP);
370 370
         // ignore whether template is accessible ?
371
-        if ( $throw_exceptions && ! is_readable( $template_path ) ) {
371
+        if ($throw_exceptions && ! is_readable($template_path)) {
372 372
             throw new \DomainException(
373 373
                     esc_html__(
374 374
                             'Invalid, unreadable, or missing file.',
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
     public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
402 402
     {
403 403
         // in the beginning...
404
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
404
+        $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
405 405
         // da muddle
406 406
         $class = '';
407 407
         // the end
408
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
408
+        $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
409 409
         // is the passed object an EE object ?
410 410
         if ($object instanceof EE_Base_Class) {
411 411
             // grab the exact type of object
@@ -415,11 +415,11 @@  discard block
 block discarded – undo
415 415
                 // no specifics just yet...
416 416
                 default :
417 417
                     $class = strtolower(str_replace('_', '-', $obj_class));
418
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
418
+                    $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
419 419
 
420 420
             }
421 421
         }
422
-        return $prefix . $class . $suffix;
422
+        return $prefix.$class.$suffix;
423 423
     }
424 424
 
425 425
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
             return '';
452 452
         }
453 453
         //ensure amount is float
454
-        $amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount);
454
+        $amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
455 455
         $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
456 456
         // filter raw amount (allows 0.00 to be changed to "free" for example)
457 457
         $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
@@ -473,20 +473,20 @@  discard block
 block discarded – undo
473 473
                 // add currency sign
474 474
                 if ($mny->sign_b4) {
475 475
                     if ($amount >= 0) {
476
-                        $amount_formatted = $mny->sign . $amount_formatted;
476
+                        $amount_formatted = $mny->sign.$amount_formatted;
477 477
                     } else {
478
-                        $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
478
+                        $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
479 479
                     }
480 480
 
481 481
                 } else {
482
-                    $amount_formatted = $amount_formatted . $mny->sign;
482
+                    $amount_formatted = $amount_formatted.$mny->sign;
483 483
                 }
484 484
 
485 485
                 // filter to allow global setting of display_code
486 486
                 $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code);
487 487
 
488 488
                 // add currency code ?
489
-                $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
489
+                $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted;
490 490
             }
491 491
             // filter results
492 492
             $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted',
@@ -540,12 +540,12 @@  discard block
 block discarded – undo
540 540
             $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
541 541
             foreach ($dashicons as $dashicon) {
542 542
                 $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
543
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
543
+                $icon_html .= '<span class="'.$type.$dashicon.'"></span>';
544 544
             }
545 545
             $icon_html .= $count > 1 ? '</span>' : '';
546 546
         }
547
-        $label  = ! empty($icon) ? $icon_html . $label : $label;
548
-        $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
547
+        $label  = ! empty($icon) ? $icon_html.$label : $label;
548
+        $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'" title="'.$title.'">'.$label.'</a>';
549 549
         return $button;
550 550
     }
551 551
 
@@ -579,11 +579,11 @@  discard block
 block discarded – undo
579 579
         $action = empty($action) ? 'default' : $action;
580 580
 
581 581
 
582
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
582
+        $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
583 583
         $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
584 584
         $help_text    = ! $help_text ? '' : $help_text;
585
-        return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
586
-                'event_espresso') . '" > ' . $help_text . ' </a>';
585
+        return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
586
+                'event_espresso').'" > '.$help_text.' </a>';
587 587
     }
588 588
 
589 589
 
@@ -600,11 +600,11 @@  discard block
 block discarded – undo
600 600
         $id    = $tour->get_slug();
601 601
         $stops = $tour->get_stops();
602 602
 
603
-        $content = '<ol style="display:none" id="' . $id . '">';
603
+        $content = '<ol style="display:none" id="'.$id.'">';
604 604
 
605 605
         foreach ($stops as $stop) {
606
-            $data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
607
-            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
606
+            $data_id    = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : '';
607
+            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : '';
608 608
 
609 609
             //if container is set to modal then let's make sure we set the options accordingly
610 610
             if (empty($data_id) && empty($data_class)) {
@@ -612,15 +612,15 @@  discard block
 block discarded – undo
612 612
                 $stop['options']['expose'] = true;
613 613
             }
614 614
 
615
-            $custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
616
-            $button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
615
+            $custom_class  = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : '';
616
+            $button_text   = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : '';
617 617
             $inner_content = isset($stop['content']) ? $stop['content'] : '';
618 618
 
619 619
             //options
620 620
             if (isset($stop['options']) && is_array($stop['options'])) {
621 621
                 $options = ' data-options="';
622 622
                 foreach ($stop['options'] as $option => $value) {
623
-                    $options .= $option . ':' . $value . ';';
623
+                    $options .= $option.':'.$value.';';
624 624
                 }
625 625
                 $options .= '"';
626 626
             } else {
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
             }
629 629
 
630 630
             //let's put all together
631
-            $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
631
+            $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>';
632 632
         }
633 633
 
634 634
         $content .= '</ol>';
@@ -660,24 +660,24 @@  discard block
 block discarded – undo
660 660
         $setup_array = array();
661 661
         foreach ($status_array as $item => $status) {
662 662
             $setup_array[$item] = array(
663
-                'class'  => 'ee-status-legend ee-status-legend-' . $status,
663
+                'class'  => 'ee-status-legend ee-status-legend-'.$status,
664 664
                 'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
665 665
                 'status' => $status,
666 666
             );
667 667
         }
668 668
 
669
-        $content = '<div class="ee-list-table-legend-container">' . "\n";
670
-        $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
671
-        $content .= '<dl class="ee-list-table-legend">' . "\n\t";
669
+        $content = '<div class="ee-list-table-legend-container">'."\n";
670
+        $content .= '<h4 class="status-legend-title">'.esc_html__('Status Legend', 'event_espresso').'</h4>'."\n";
671
+        $content .= '<dl class="ee-list-table-legend">'."\n\t";
672 672
         foreach ($setup_array as $item => $details) {
673 673
             $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
674
-            $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
675
-            $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
676
-            $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
677
-            $content .= '</dt>' . "\n";
674
+            $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t";
675
+            $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t";
676
+            $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t";
677
+            $content .= '</dt>'."\n";
678 678
         }
679
-        $content .= '</dl>' . "\n";
680
-        $content .= '</div>' . "\n";
679
+        $content .= '</dl>'."\n";
680
+        $content .= '</div>'."\n";
681 681
         return $content;
682 682
     }
683 683
 
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
     public static function layout_array_as_table($data)
693 693
     {
694 694
         if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
695
-            $data = (array)$data;
695
+            $data = (array) $data;
696 696
         }
697 697
         ob_start();
698 698
         if (is_array($data)) {
@@ -793,9 +793,9 @@  discard block
 block discarded – undo
793 793
     ) {
794 794
         $page_links     = array();
795 795
         $disable_first  = $disable_last = '';
796
-        $total_items    = (int)$total_items;
797
-        $per_page       = (int)$per_page;
798
-        $current        = (int)$current;
796
+        $total_items    = (int) $total_items;
797
+        $per_page       = (int) $per_page;
798
+        $current        = (int) $current;
799 799
         $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
800 800
 
801 801
         //filter items_label
@@ -815,8 +815,8 @@  discard block
 block discarded – undo
815 815
             );
816 816
         } else {
817 817
             $items_label = array(
818
-                'single' => '1 ' . esc_html($items_label['single']),
819
-                'plural' => '%s ' . esc_html($items_label['plural']),
818
+                'single' => '1 '.esc_html($items_label['single']),
819
+                'plural' => '%s '.esc_html($items_label['plural']),
820 820
             );
821 821
         }
822 822
 
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 
829 829
         $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
830 830
 
831
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
831
+        $output = '<span class="displaying-num">'.$item_label.'</span>';
832 832
 
833 833
         if ($current === 1) {
834 834
             $disable_first = ' disabled';
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
         }
839 839
 
840 840
         $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
841
-            'first-page' . $disable_first,
841
+            'first-page'.$disable_first,
842 842
             esc_attr__('Go to the first page'),
843 843
             esc_url(remove_query_arg($paged_arg_name, $url)),
844 844
             '&laquo;'
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 
847 847
         $page_links[] = sprintf(
848 848
             '<a class="%s" title="%s" href="%s">%s</a>',
849
-            'prev-page' . $disable_first,
849
+            'prev-page'.$disable_first,
850 850
             esc_attr__('Go to the previous page'),
851 851
             esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
852 852
             '&lsaquo;'
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
             '<span class="total-pages">%s</span>',
867 867
             number_format_i18n($total_pages)
868 868
         );
869
-        $page_links[]     = sprintf(
869
+        $page_links[] = sprintf(
870 870
             _x('%3$s%1$s of %2$s%4$s', 'paging'),
871 871
             $html_current_page,
872 872
             $html_total_pages,
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 
877 877
         $page_links[] = sprintf(
878 878
             '<a class="%s" title="%s" href="%s">%s</a>',
879
-            'next-page' . $disable_last,
879
+            'next-page'.$disable_last,
880 880
             esc_attr__('Go to the next page'),
881 881
             esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
882 882
             '&rsaquo;'
@@ -884,13 +884,13 @@  discard block
 block discarded – undo
884 884
 
885 885
         $page_links[] = sprintf(
886 886
             '<a class="%s" title="%s" href="%s">%s</a>',
887
-            'last-page' . $disable_last,
887
+            'last-page'.$disable_last,
888 888
             esc_attr__('Go to the last page'),
889 889
             esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
890 890
             '&raquo;'
891 891
         );
892 892
 
893
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
893
+        $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
894 894
         // set page class
895 895
         if ($total_pages) {
896 896
             $page_class = $total_pages < 2 ? ' one-page' : '';
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
             $page_class = ' no-pages';
899 899
         }
900 900
 
901
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
901
+        return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
902 902
     }
903 903
 
904 904
 
@@ -935,10 +935,10 @@  discard block
 block discarded – undo
935 935
             $query_args
936 936
         );
937 937
         $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text',
938
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso');
938
+            $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso');
939 939
         $url        = add_query_arg($query_args, 'https://eventespresso.com/');
940 940
         $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
941
-        return (string)apply_filters(
941
+        return (string) apply_filters(
942 942
             'FHEE__EEH_Template__powered_by_event_espresso__html',
943 943
             sprintf(
944 944
                 esc_html_x(
@@ -989,6 +989,6 @@  discard block
 block discarded – undo
989 989
                 'add_fragment' => '',
990 990
             )
991 991
         );
992
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : '';
992
+        echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : '';
993 993
     }
994 994
 }
995 995
\ No newline at end of file
Please login to merge, or discard this patch.